diff --git a/cmake/taosadapter_CMakeLists.txt.in b/cmake/taosadapter_CMakeLists.txt.in index cc46ef9938..2a7b76d768 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 ff7de07 + GIT_TAG e07f41b 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 ed2ec0b6da..2d7bcf6592 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 d5df76d + GIT_TAG e62c5ea SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/docs/en/07-develop/03-insert-data/20-kafka-writting.mdx b/docs/en/07-develop/03-insert-data/20-kafka-writting.mdx new file mode 100644 index 0000000000..ffb969a8a6 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/20-kafka-writting.mdx @@ -0,0 +1,46 @@ +--- +title: Write from Kafka +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import PyKafka from "./_py_kafka.mdx"; + +## About Kafka + +Apache Kafka is an open-source distributed event streaming platform, used by thousands of companies for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications. For the key concepts of kafka, please refer to [kafka documentation](https://kafka.apache.org/documentation/#gettingStarted). + +### kafka topic + +Messages in Kafka are organized by topics. A topic may have one or more partitions. We can manage kafka topics through `kafka-topics`. + +create a topic named `kafka-events`: + +``` +bin/kafka-topics.sh --create --topic kafka-events --bootstrap-server localhost:9092 +``` + +Alter `kafka-events` topic to set partitions to 3: + +``` +bin/kafka-topics.sh --alter --topic kafka-events --partitions 3 --bootstrap-server=localhost:9092 +``` + +Show all topics and partitions in Kafka: + +``` +bin/kafka-topics.sh --bootstrap-server=localhost:9092 --describe +``` + +## Insert into TDengine + +We can write data into TDengine via SQL or Schemaless. For more information, please refer to [Insert Using SQL](/develop/insert-data/sql-writing/) or [High Performance Writing](/develop/insert-data/high-volume/) or [Schemaless Writing](/reference/schemaless/). + +## Examples + + + + + + + diff --git a/docs/en/07-develop/03-insert-data/02-influxdb-line.mdx b/docs/en/07-develop/03-insert-data/30-influxdb-line.mdx similarity index 100% rename from docs/en/07-develop/03-insert-data/02-influxdb-line.mdx rename to docs/en/07-develop/03-insert-data/30-influxdb-line.mdx diff --git a/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx b/docs/en/07-develop/03-insert-data/40-opentsdb-telnet.mdx similarity index 100% rename from docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx rename to docs/en/07-develop/03-insert-data/40-opentsdb-telnet.mdx diff --git a/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx b/docs/en/07-develop/03-insert-data/50-opentsdb-json.mdx similarity index 100% rename from docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx rename to docs/en/07-develop/03-insert-data/50-opentsdb-json.mdx diff --git a/docs/en/07-develop/03-insert-data/05-high-volume.md b/docs/en/07-develop/03-insert-data/60-high-volume.md similarity index 100% rename from docs/en/07-develop/03-insert-data/05-high-volume.md rename to docs/en/07-develop/03-insert-data/60-high-volume.md diff --git a/docs/en/07-develop/03-insert-data/_py_kafka.mdx b/docs/en/07-develop/03-insert-data/_py_kafka.mdx new file mode 100644 index 0000000000..dc43a0d415 --- /dev/null +++ b/docs/en/07-develop/03-insert-data/_py_kafka.mdx @@ -0,0 +1,60 @@ +### python Kafka 客户端 + +For python kafka client, please refer to [kafka client](https://cwiki.apache.org/confluence/display/KAFKA/Clients#Clients-Python). In this document, we use [kafka-python](http://github.com/dpkp/kafka-python). + +### consume from Kafka + +The simple way to consume messages from Kafka is to read messages one by one. The demo is as follows: + +``` +from kafka import KafkaConsumer +consumer = KafkaConsumer('my_favorite_topic') +for msg in consumer: + print (msg) +``` + +For higher performance, we can consume message from kafka in batch. The demo is as follows: + +``` +from kafka import KafkaConsumer +consumer = KafkaConsumer('my_favorite_topic') +while True: + msgs = consumer.poll(timeout_ms=500, max_records=1000) + if msgs: + print (msgs) +``` + +### multi-threading + +For more higher performance we can process data from kafka in multi-thread. We can use python's ThreadPoolExecutor to achieve multithreading. The demo is as follows: + +``` +from concurrent.futures import ThreadPoolExecutor, Future +pool = ThreadPoolExecutor(max_workers=10) +pool.submit(...) +``` + +### multi-process + +For more higher performance, sometimes we use multiprocessing. In this case, the number of Kafka Consumers should not be greater than the number of Kafka Topic Partitions. The demo is as follows: + +``` +from multiprocessing import Process + +ps = [] +for i in range(5): + p = Process(target=Consumer().consume()) + p.start() + ps.append(p) + +for p in ps: + p.join() +``` + +In addition to python's built-in multithreading and multiprocessing library, we can also use the third-party library gunicorn. + +### Examples + +```py +{{#include docs/examples/python/kafka_example.py}} +``` diff --git a/docs/en/14-reference/03-connector/index.mdx b/docs/en/14-reference/03-connector/index.mdx index 54031db618..ba8dbb85d4 100644 --- a/docs/en/14-reference/03-connector/index.mdx +++ b/docs/en/14-reference/03-connector/index.mdx @@ -59,10 +59,10 @@ The different database framework specifications for various programming language | -------------------------------------- | ------------- | --------------- | ------------- | ------------- | ------------- | ------------- | | **Connection Management** | Support | Support | Support | Support | Support | Support | | **Regular Query** | Support | Support | Support | Support | Support | Support | -| **Parameter Binding** | Not supported | Not supported | Not supported | Support | Not supported | Support | -| **Subscription (TMQ) ** | Not supported | Not supported | Not supported | Not supported | Not supported | Support | +| **Parameter Binding** | Not supported | Not supported | support | Support | Not supported | Support | +| **Subscription (TMQ) ** | Not supported | Not supported | support | Not supported | Not supported | Support | | **Schemaless** | Not supported | Not supported | Not supported | Not supported | Not supported | Not supported | -| **Bulk Pulling (based on WebSocket) ** | Support | Support | Not Supported | support | Not Supported | Supported | +| **Bulk Pulling (based on WebSocket) ** | Support | Support | Support | support | Support | Support | | **DataFrame** | Not supported | Support | Not supported | Not supported | Not supported | Not supported | :::warning diff --git a/docs/en/20-third-party/01-grafana.mdx b/docs/en/20-third-party/01-grafana.mdx index e0fbefd5a8..ca32ce8afc 100644 --- a/docs/en/20-third-party/01-grafana.mdx +++ b/docs/en/20-third-party/01-grafana.mdx @@ -76,7 +76,7 @@ sudo -u grafana grafana-cli plugins install tdengine-datasource You can also download zip files from [GitHub](https://github.com/taosdata/grafanaplugin/releases/tag/latest) or [Grafana](https://grafana.com/grafana/plugins/tdengine-datasource/?tab=installation) and install manually. The commands are as follows: ```bash -GF_VERSION=3.2.2 +GF_VERSION=3.2.7 # from GitHub wget https://github.com/taosdata/grafanaplugin/releases/download/v$GF_VERSION/tdengine-datasource-$GF_VERSION.zip # from Grafana diff --git a/docs/en/25-application/01-telegraf.md b/docs/en/25-application/01-telegraf.md index f700326449..65fb08ee67 100644 --- a/docs/en/25-application/01-telegraf.md +++ b/docs/en/25-application/01-telegraf.md @@ -38,15 +38,9 @@ Download the latest TDengine-server from the [Downloads](http://tdengine.com/en/ ## Data Connection Setup -### Download TDengine plug-in to grafana plug-in directory +### Install Grafana Plugin and Configure Data Source -```bash -1. wget -c https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip -2. sudo unzip tdengine-datasource-3.1.3.zip -d /var/lib/grafana/plugins/ -3. sudo chown grafana:grafana -R /var/lib/grafana/plugins/tdengine -4. echo -e "[plugins]\nallow_loading_unsigned_plugins = tdengine-datasource\n" | sudo tee -a /etc/grafana/grafana.ini -5. sudo systemctl restart grafana-server.service -``` +Please refer to [Install Grafana Plugin and Configure Data Source](/third-party/grafana/#install-grafana-plugin-and-configure-data-source) ### Modify /etc/telegraf/telegraf.conf diff --git a/docs/en/25-application/02-collectd.md b/docs/en/25-application/02-collectd.md index 692cd8d929..97412b2309 100644 --- a/docs/en/25-application/02-collectd.md +++ b/docs/en/25-application/02-collectd.md @@ -41,15 +41,9 @@ Download the latest TDengine-server from the [Downloads](http://tdengine.com/en/ ## Data Connection Setup -### Copy the TDengine plugin to the grafana plugin directory +### Install Grafana Plugin and Configure Data Source -```bash -1. wget -c https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip -2. sudo unzip tdengine-datasource-3.1.3.zip -d /var/lib/grafana/plugins/ -3. sudo chown grafana:grafana -R /var/lib/grafana/plugins/tdengine -4. echo -e "[plugins]\nallow_loading_unsigned_plugins = tdengine-datasource\n" | sudo tee -a /etc/grafana/grafana.ini -5. sudo systemctl restart grafana-server.service -``` +Please refer to [Install Grafana Plugin and Configure Data Source](/third-party/grafana/#install-grafana-plugin-and-configure-data-source) ### Configure collectd diff --git a/docs/examples/python/kafka_example.py b/docs/examples/python/kafka_example.py new file mode 100644 index 0000000000..735059eec0 --- /dev/null +++ b/docs/examples/python/kafka_example.py @@ -0,0 +1,192 @@ +#! encoding = utf-8 +import json +import time +from json import JSONDecodeError +from typing import Callable +import logging +from concurrent.futures import ThreadPoolExecutor, Future + +import taos +from kafka import KafkaConsumer +from kafka.consumer.fetcher import ConsumerRecord + + +class Consumer(object): + DEFAULT_CONFIGS = { + 'kafka_brokers': 'localhost:9092', + 'kafka_topic': 'python_kafka', + 'kafka_group_id': 'taos', + 'taos_host': 'localhost', + 'taos_user': 'root', + 'taos_password': 'taosdata', + 'taos_database': 'power', + 'taos_port': 6030, + 'timezone': None, + 'clean_after_testing': False, + 'bath_consume': True, + 'batch_size': 1000, + 'async_model': True, + 'workers': 10 + } + + LOCATIONS = ['California.SanFrancisco', 'California.LosAngles', 'California.SanDiego', 'California.SanJose', + 'California.PaloAlto', 'California.Campbell', 'California.MountainView', 'California.Sunnyvale', + 'California.SantaClara', 'California.Cupertino'] + + CREATE_DATABASE_SQL = 'create database if not exists {} keep 365 duration 10 buffer 16 wal_level 1' + USE_DATABASE_SQL = 'use {}' + DROP_TABLE_SQL = 'drop table if exists meters' + DROP_DATABASE_SQL = 'drop database if exists {}' + CREATE_STABLE_SQL = 'create stable meters (ts timestamp, current float, voltage int, phase float) ' \ + 'tags (location binary(64), groupId int)' + CREATE_TABLE_SQL = 'create table if not exists {} using meters tags (\'{}\', {})' + INSERT_SQL_HEADER = "insert into " + INSERT_PART_SQL = 'power.{} values (\'{}\', {}, {}, {})' + + 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'), + ) + self.taos = taos.connect( + host=self.config.get('taos_host'), + user=self.config.get('taos_user'), + password=self.config.get('taos_password'), + port=self.config.get('taos_port'), + timezone=self.config.get('timezone'), + ) + if self.config.get('async_model'): + self.pool = ThreadPoolExecutor(max_workers=self.config.get('workers')) + self.tasks: list[Future] = [] + # tags and table mapping # key: {location}_{groupId} value: + self.tag_table_mapping = {} + i = 0 + for location in self.LOCATIONS: + for j in range(1, 11): + table_name = 'd{}'.format(i) + self._cache_table(location=location, group_id=j, table_name=table_name) + i += 1 + + def init_env(self): + # create database and table + self.taos.execute(self.DROP_DATABASE_SQL.format(self.config.get('taos_database'))) + self.taos.execute(self.CREATE_DATABASE_SQL.format(self.config.get('taos_database'))) + self.taos.execute(self.USE_DATABASE_SQL.format(self.config.get('taos_database'))) + self.taos.execute(self.DROP_TABLE_SQL) + self.taos.execute(self.CREATE_STABLE_SQL) + for tags, table_name in self.tag_table_mapping.items(): + location, group_id = _get_location_and_group(tags) + self.taos.execute(self.CREATE_TABLE_SQL.format(table_name, location, group_id)) + + def consume(self): + logging.warning('## start consumer topic-[%s]', self.config.get('kafka_topic')) + try: + if self.config.get('bath_consume'): + self._run_batch(self._to_taos_batch) + else: + self._run(self._to_taos) + except KeyboardInterrupt: + logging.warning("## caught keyboard interrupt, stopping") + finally: + self.stop() + + def stop(self): + # close consumer + if self.consumer is not None: + self.consumer.commit() + self.consumer.close() + + # multi thread + if self.config.get('async_model'): + for task in self.tasks: + while not task.done(): + pass + if self.pool is not None: + self.pool.shutdown() + + # clean data + if self.config.get('clean_after_testing'): + self.taos.execute(self.DROP_TABLE_SQL) + self.taos.execute(self.DROP_DATABASE_SQL.format(self.config.get('taos_database'))) + # close taos + if self.taos is not None: + self.taos.close() + + def _run(self, f: Callable[[ConsumerRecord], bool]): + 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]): + while True: + messages = self.consumer.poll(timeout_ms=500, max_records=self.config.get('batch_size')) + if messages: + if self.config.get('async_model'): + self.pool.submit(f, messages.values()) + else: + f(list(messages.values())) + if not messages: + time.sleep(0.1) + + def _to_taos(self, message: ConsumerRecord) -> bool: + sql = self.INSERT_SQL_HEADER + self._build_sql(message.value) + if len(sql) == 0: # decode error, skip + return True + logging.info('## insert sql %s', sql) + return self.taos.execute(sql=sql) == 1 + + def _to_taos_batch(self, messages: list[list[ConsumerRecord]]): + sql = self._build_sql_batch(messages=messages) + if len(sql) == 0: # decode error, skip + return + self.taos.execute(sql=sql) + + def _build_sql(self, msg_value: str) -> str: + try: + data = json.loads(msg_value) + except JSONDecodeError as e: + logging.error('## decode message [%s] error ', msg_value, e) + return '' + location = data.get('location') + group_id = data.get('groupId') + ts = data.get('ts') + current = data.get('current') + voltage = data.get('voltage') + phase = data.get('phase') + + 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: + sql_list = [] + for partition_messages in messages: + for message in partition_messages: + sql_list.append(self._build_sql(message.value)) + + return self.INSERT_SQL_HEADER + ' '.join(sql_list) + + def _cache_table(self, location: str, group_id: int, table_name: str): + self.tag_table_mapping[_tag_table_mapping_key(location=location, group_id=group_id)] = table_name + + def _get_table_name(self, location: str, group_id: int) -> str: + return self.tag_table_mapping.get(_tag_table_mapping_key(location=location, group_id=group_id)) + + +def _tag_table_mapping_key(location: str, group_id: int): + return '{}_{}'.format(location, group_id) + + +def _get_location_and_group(key: str) -> (str, int): + fields = key.split('_') + return fields[0], fields[1] + + +if __name__ == '__main__': + consumer = Consumer(async_model=True) + consumer.init_env() + consumer.consume() \ No newline at end of file diff --git a/docs/zh/07-develop/03-insert-data/20-kafka-writting.mdx b/docs/zh/07-develop/03-insert-data/20-kafka-writting.mdx new file mode 100644 index 0000000000..32d3c2e5cb --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/20-kafka-writting.mdx @@ -0,0 +1,47 @@ +--- +title: 从 Kafka 写入 +--- + +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; +import PyKafka from "./_py_kafka.mdx"; + +## Kafka 介绍 + +Apache Kafka 是开源的分布式消息分发平台,被广泛应用于高性能数据管道、流式数据分析、数据集成和事件驱动类型的应用程序。Kafka 包含 Producer、Consumer 和 Topic,其中 Producer 是向 Kafka 发送消息的进程,Consumer 是从 Kafka 消费消息的进程。Kafka 相关概念可以参考[官方文档](https://kafka.apache.org/documentation/#gettingStarted)。 + + +### kafka topic + +Kafka 的消息按 topic 组织,每个 topic 会有一到多个 partition。可以通过 kafka 的 `kafka-topics` 管理 topic。 + +创建名为 `kafka-events` 的topic: + +``` +bin/kafka-topics.sh --create --topic kafka-events --bootstrap-server localhost:9092 +``` + +修改 `kafka-events` 的 partition 数量为 3: + +``` +bin/kafka-topics.sh --alter --topic kafka-events --partitions 3 --bootstrap-server=localhost:9092 +``` + +展示所有的 topic 和 partition: + +``` +bin/kafka-topics.sh --bootstrap-server=localhost:9092 --describe +``` + +## 写入 TDengine + +TDengine 支持 Sql 方式和 Schemaless 方式的数据写入,Sql 方式数据写入可以参考 [TDengine SQL 写入](/develop/insert-data/sql-writing/) 和 [TDengine 高效写入](/develop/insert-data/high-volume/)。Schemaless 方式数据写入可以参考 [TDengine Schemaless 写入](/reference/schemaless/) 文档。 + +## 示例代码 + + + + + + + diff --git a/docs/zh/07-develop/03-insert-data/02-influxdb-line.mdx b/docs/zh/07-develop/03-insert-data/30-influxdb-line.mdx similarity index 100% rename from docs/zh/07-develop/03-insert-data/02-influxdb-line.mdx rename to docs/zh/07-develop/03-insert-data/30-influxdb-line.mdx diff --git a/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx b/docs/zh/07-develop/03-insert-data/40-opentsdb-telnet.mdx similarity index 100% rename from docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx rename to docs/zh/07-develop/03-insert-data/40-opentsdb-telnet.mdx diff --git a/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx b/docs/zh/07-develop/03-insert-data/50-opentsdb-json.mdx similarity index 100% rename from docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx rename to docs/zh/07-develop/03-insert-data/50-opentsdb-json.mdx diff --git a/docs/zh/07-develop/03-insert-data/05-high-volume.md b/docs/zh/07-develop/03-insert-data/60-high-volume.md similarity index 100% rename from docs/zh/07-develop/03-insert-data/05-high-volume.md rename to docs/zh/07-develop/03-insert-data/60-high-volume.md diff --git a/docs/zh/07-develop/03-insert-data/_py_kafka.mdx b/docs/zh/07-develop/03-insert-data/_py_kafka.mdx new file mode 100644 index 0000000000..cd7edf557d --- /dev/null +++ b/docs/zh/07-develop/03-insert-data/_py_kafka.mdx @@ -0,0 +1,60 @@ +### python Kafka 客户端 + +Kafka 的 python 客户端可以参考文档 [kafka client](https://cwiki.apache.org/confluence/display/KAFKA/Clients#Clients-Python)。推荐使用 [confluent-kafka-python](https://github.com/confluentinc/confluent-kafka-python) 和 [kafka-python](http://github.com/dpkp/kafka-python)。以下示例以 [kafka-python](http://github.com/dpkp/kafka-python) 为例。 + +### 从 Kafka 消费数据 + +Kafka 客户端采用 pull 的方式从 Kafka 消费数据,可以采用单条消费的方式或批量消费的方式读取数据。使用 [kafka-python](http://github.com/dpkp/kafka-python) 客户端单条消费数据的示例如下: + +``` +from kafka import KafkaConsumer +consumer = KafkaConsumer('my_favorite_topic') +for msg in consumer: + print (msg) +``` + +单条消费的方式在数据流量大的情况下往往存在性能瓶颈,导致 Kafka 消息积压,更推荐使用批量消费的方式消费数据。使用 [kafka-python](http://github.com/dpkp/kafka-python) 客户端批量消费数据的示例如下: + +``` +from kafka import KafkaConsumer +consumer = KafkaConsumer('my_favorite_topic') +while True: + msgs = consumer.poll(timeout_ms=500, max_records=1000) + if msgs: + print (msgs) +``` + +### Python 多线程 + +为了提高数据写入效率,通常采用多线程的方式写入数据,可以使用 python 线程池 ThreadPoolExecutor 实现多线程。示例代码如下: + +``` +from concurrent.futures import ThreadPoolExecutor, Future +pool = ThreadPoolExecutor(max_workers=10) +pool.submit(...) +``` + +### Python 多进程 + +单个python进程不能充分发挥多核 CPU 的性能,有时候我们会选择多进程的方式。在多进程的情况下,需要注意,Kafka Consumer 的数量应该小于等于 Kafka Topic Partition 数量。Python 多进程示例代码如下: + +``` +from multiprocessing import Process + +ps = [] +for i in range(5): + p = Process(target=Consumer().consume()) + p.start() + ps.append(p) + +for p in ps: + p.join() +``` + +除了 Python 内置的多线程和多进程方式,还可以通过第三方库 gunicorn 实现并发。 + +### 完整示例 + +```py +{{#include docs/examples/python/kafka_example.py}} +``` diff --git a/docs/zh/08-connector/index.md b/docs/zh/08-connector/index.md index eecf564b90..a28a7cd66c 100644 --- a/docs/zh/08-connector/index.md +++ b/docs/zh/08-connector/index.md @@ -59,10 +59,10 @@ TDengine 版本更新往往会增加新的功能特性,列表中的连接器 | ------------------------------ | -------- | ---------- | -------- | -------- | ----------- | -------- | | **连接管理** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | | **普通查询** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | -| **参数绑定** | 暂不支持 | 暂不支持 | 暂不支持 | 支持 | 暂不支持 | 支持 | -| **数据订阅(TMQ)** | 暂不支持 | 暂不支持 | 暂不支持 | 暂不支持 | 暂不支持 | 支持 | +| **参数绑定** | 暂不支持 | 暂不支持 | 支持 | 支持 | 暂不支持 | 支持 | +| **数据订阅(TMQ)** | 暂不支持 | 暂不支持 | 支持 | 暂不支持 | 暂不支持 | 支持 | | **Schemaless** | 暂不支持 | 暂不支持 | 暂不支持 | 暂不支持 | 暂不支持 | 暂不支持 | -| **批量拉取(基于 WebSocket)** | 支持 | 支持 | 暂不支持 | 支持 | 暂不支持 | 支持 | +| **批量拉取(基于 WebSocket)** | 支持 | 支持 | 支持 | 支持 | 支持 | 支持 | | **DataFrame** | 不支持 | 支持 | 不支持 | 不支持 | 不支持 | 不支持 | :::warning diff --git a/docs/zh/25-application/01-telegraf.md b/docs/zh/25-application/01-telegraf.md index 6338264d17..ec263d7792 100644 --- a/docs/zh/25-application/01-telegraf.md +++ b/docs/zh/25-application/01-telegraf.md @@ -39,15 +39,9 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如 ## 数据链路设置 -### 下载 TDengine 插件到 Grafana 插件目录 +### 安装 Grafana Plugin 并配置数据源 -```bash -1. wget -c https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip -2. sudo unzip tdengine-datasource-3.1.3.zip -d /var/lib/grafana/plugins/ -3. sudo chown grafana:grafana -R /var/lib/grafana/plugins/tdengine -4. echo -e "[plugins]\nallow_loading_unsigned_plugins = tdengine-datasource\n" | sudo tee -a /etc/grafana/grafana.ini -5. sudo systemctl restart grafana-server.service -``` +请参考[安装 Grafana Plugin 并配置数据源](/third-party/grafana/#%E5%AE%89%E8%A3%85-grafana-plugin-%E5%B9%B6%E9%85%8D%E7%BD%AE%E6%95%B0%E6%8D%AE%E6%BA%90)。 ### 修改 /etc/telegraf/telegraf.conf diff --git a/docs/zh/25-application/02-collectd.md b/docs/zh/25-application/02-collectd.md index c6230f48ab..8b39a6431d 100644 --- a/docs/zh/25-application/02-collectd.md +++ b/docs/zh/25-application/02-collectd.md @@ -41,15 +41,9 @@ IT 运维监测数据通常都是对时间特性比较敏感的数据,例如 ## 数据链路设置 -### 复制 TDengine 插件到 grafana 插件目录 +### 安装 Grafana Plugin 并配置数据源 -```bash -1. wget -c https://github.com/taosdata/grafanaplugin/releases/download/v3.1.3/tdengine-datasource-3.1.3.zip -2. sudo unzip tdengine-datasource-3.1.3.zip -d /var/lib/grafana/plugins/ -3. sudo chown grafana:grafana -R /var/lib/grafana/plugins/tdengine -4. echo -e "[plugins]\nallow_loading_unsigned_plugins = tdengine-datasource\n" | sudo tee -a /etc/grafana/grafana.ini -5. sudo systemctl restart grafana-server.service -``` +请参考[安装 Grafana Plugin 并配置数据源](/third-party/grafana/#%E5%AE%89%E8%A3%85-grafana-plugin-%E5%B9%B6%E9%85%8D%E7%BD%AE%E6%95%B0%E6%8D%AE%E6%BA%90)。 ### 配置 collectd diff --git a/docs/zh/27-train-faq/01-faq.md b/docs/zh/27-train-faq/01-faq.md index 9c2f1e790c..595b69b08b 100644 --- a/docs/zh/27-train-faq/01-faq.md +++ b/docs/zh/27-train-faq/01-faq.md @@ -201,3 +201,45 @@ TDengine 中时间戳的时区总是由客户端进行处理,而与服务端 OOM 是操作系统的保护机制,当操作系统内存(包括 SWAP )不足时,会杀掉某些进程,从而保证操作系统的稳定运行。通常内存不足主要是如下两个原因导致,一是剩余内存小于 vm.min_free_kbytes ;二是程序请求的内存大于剩余内存。还有一种情况是内存充足但程序占用了特殊的内存地址,也会触发 OOM 。 TDengine 会预先为每个 VNode 分配好内存,每个 Database 的 VNode 个数受 建库时的vgroups参数影响,每个 VNode 占用的内存大小受 buffer参数 影响。要防止 OOM,需要在项目建设之初合理规划内存,并合理设置 SWAP ,除此之外查询过量的数据也有可能导致内存暴涨,这取决于具体的查询语句。TDengine 企业版对内存管理做了优化,采用了新的内存分配器,对稳定性有更高要求的用户可以考虑选择企业版。 + +### 19. 在macOS上遇到Too many open files怎么办? + +taosd日志文件报错Too many open file,是由于taosd打开文件数超过系统设置的上限所致。 +解决方案如下: +1. 新建文件 /Library/LaunchDaemons/limit.maxfiles.plist,写入以下内容(以下示例将limit和maxfiles改为10万,可按需修改): +``` + + + + +Label + limit.maxfiles +ProgramArguments + + launchctl + limit + maxfiles + 100000 + 100000 + +RunAtLoad + +ServiceIPC + + + +``` +2. 修改文件权限 +``` +sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist +sudo chmod 644 /Library/LaunchDaemons/limit.maxfiles.plist +``` +3. 加载 plist 文件 (或重启系统后生效。launchd在启动时会自动加载该目录的 plist) +``` +sudo launchctl load -w /Library/LaunchDaemons/limit.maxfiles.plist +``` +4.确认更改后的限制 +``` +launchctl limit maxfiles +``` diff --git a/include/client/taos.h b/include/client/taos.h index 2940f1dfd0..69774b750f 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -185,6 +185,7 @@ DLL_EXPORT void taos_kill_query(TAOS *taos); DLL_EXPORT int taos_field_count(TAOS_RES *res); DLL_EXPORT int taos_num_fields(TAOS_RES *res); DLL_EXPORT int taos_affected_rows(TAOS_RES *res); +DLL_EXPORT int64_t taos_affected_rows64(TAOS_RES *res); DLL_EXPORT TAOS_FIELD *taos_fetch_fields(TAOS_RES *res); DLL_EXPORT int taos_select_db(TAOS *taos, const char *db); diff --git a/include/common/systable.h b/include/common/systable.h index 57f85f16bc..6f65c1e8b8 100644 --- a/include/common/systable.h +++ b/include/common/systable.h @@ -47,6 +47,7 @@ extern "C" { #define TSDB_INS_TABLE_TOPICS "ins_topics" #define TSDB_INS_TABLE_STREAMS "ins_streams" #define TSDB_INS_TABLE_STREAM_TASKS "ins_stream_tasks" +#define TSDB_INS_TABLE_USER_PRIVILEGES "ins_user_privileges" #define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema" #define TSDB_PERFS_TABLE_SMAS "perf_smas" diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 77f1879b81..6ec3d5db10 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -249,10 +249,11 @@ typedef struct SColumnInfoData { typedef struct SQueryTableDataCond { uint64_t suid; - int32_t order; // desc|asc order to iterate the data block + int32_t order; // desc|asc order to iterate the data block int32_t numOfCols; SColumnInfo* colList; - int32_t type; // data block load type: + int32_t* pSlotList; // the column output destation slot, and it may be null + int32_t type; // data block load type: STimeWindow twindows; int64_t startVersion; int64_t endVersion; diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index db6ca65cf0..e1d3b01611 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -41,9 +41,9 @@ typedef struct SBlockOrderInfo { BMCharPos(bm_, r_) |= (1u << (7u - BitPos(r_))); \ } while (0) -#define colDataSetNotNull_f(bm_, r_) \ - do { \ - BMCharPos(bm_, r_) &= ~(1u << (7u - BitPos(r_))); \ +#define colDataClearNull_f(bm_, r_) \ + do { \ + BMCharPos(bm_, r_) &= ((char)(~(1u << (7u - BitPos(r_))))); \ } while (0) #define colDataIsNull_var(pColumnInfoData, row) (pColumnInfoData->varmeta.offset[row] == -1) @@ -151,9 +151,6 @@ static FORCE_INLINE void colDataAppendNNULL(SColumnInfoData* pColumnInfoData, ui for (int32_t i = start; i < start + nRows; ++i) { colDataSetNull_f(pColumnInfoData->nullbitmap, i); } - - int32_t bytes = pColumnInfoData->info.bytes; - memset(pColumnInfoData->pData + start * bytes, 0, nRows * bytes); } pColumnInfoData->hasNull = true; @@ -234,9 +231,11 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows, bool clearPayload); int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows); +int32_t blockDataEnsureCapacityNoClear(SSDataBlock* pDataBlock, uint32_t numOfRows); void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows); void blockDataCleanup(SSDataBlock* pDataBlock); +void blockDataEmpty(SSDataBlock* pDataBlock); size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize); diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 89ec9dc6c8..92672311d0 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -64,6 +64,11 @@ extern int32_t tsNumOfSnodeStreamThreads; extern int32_t tsNumOfSnodeWriteThreads; extern int64_t tsRpcQueueMemoryAllowed; +// sync raft +extern int32_t tsElectInterval; +extern int32_t tsHeartbeatInterval; +extern int32_t tsHeartbeatTimeout; + // monitor extern bool tsEnableMonitor; extern int32_t tsMonitorInterval; @@ -126,9 +131,9 @@ extern char tsUdfdResFuncs[]; extern char tsUdfdLdLibPath[]; // schemaless -extern char tsSmlChildTableName[]; -extern char tsSmlTagName[]; -extern bool tsSmlDataFormat; +extern char tsSmlChildTableName[]; +extern char tsSmlTagName[]; +extern bool tsSmlDataFormat; extern int32_t tsSmlBatchSize; // wal @@ -137,6 +142,7 @@ extern int64_t tsWalFsyncDataSizeLimit; // internal extern int32_t tsTransPullupInterval; extern int32_t tsMqRebalanceInterval; +extern int32_t tsStreamCheckpointTickInterval; extern int32_t tsTtlUnit; extern int32_t tsTtlPushInterval; extern int32_t tsGrantHBInterval; @@ -145,7 +151,7 @@ extern int32_t tsUptimeInterval; extern int32_t tsRpcRetryLimit; extern int32_t tsRpcRetryInterval; -//#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize) +// #define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize) int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd, const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc); diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 80590a25c0..fcb155e43e 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -66,6 +66,10 @@ extern int32_t tMsgDict[]; typedef uint16_t tmsg_t; +static inline bool vnodeIsMsgBlock(tmsg_t type) { + return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) || + (type == TDMT_VND_UPDATE_TAG_VAL); +} /* ------------------------ OTHER DEFINITIONS ------------------------ */ // IE type #define TSDB_IE_TYPE_SEC 1 @@ -120,6 +124,7 @@ typedef enum _mgmt_table { TSDB_MGMT_TABLE_VNODES, TSDB_MGMT_TABLE_APPS, TSDB_MGMT_TABLE_STREAM_TASKS, + TSDB_MGMT_TABLE_PRIVILEGES, TSDB_MGMT_TABLE_MAX, } EShowType; @@ -141,16 +146,18 @@ typedef enum _mgmt_table { #define TSDB_FILL_PREV 4 #define TSDB_FILL_NEXT 5 -#define TSDB_ALTER_USER_PASSWD 0x1 -#define TSDB_ALTER_USER_SUPERUSER 0x2 -#define TSDB_ALTER_USER_ADD_READ_DB 0x3 -#define TSDB_ALTER_USER_REMOVE_READ_DB 0x4 -#define TSDB_ALTER_USER_ADD_WRITE_DB 0x5 -#define TSDB_ALTER_USER_REMOVE_WRITE_DB 0x6 -#define TSDB_ALTER_USER_ADD_ALL_DB 0x7 -#define TSDB_ALTER_USER_REMOVE_ALL_DB 0x8 -#define TSDB_ALTER_USER_ENABLE 0x9 -#define TSDB_ALTER_USER_SYSINFO 0xA +#define TSDB_ALTER_USER_PASSWD 0x1 +#define TSDB_ALTER_USER_SUPERUSER 0x2 +#define TSDB_ALTER_USER_ADD_READ_DB 0x3 +#define TSDB_ALTER_USER_REMOVE_READ_DB 0x4 +#define TSDB_ALTER_USER_ADD_WRITE_DB 0x5 +#define TSDB_ALTER_USER_REMOVE_WRITE_DB 0x6 +#define TSDB_ALTER_USER_ADD_ALL_DB 0x7 +#define TSDB_ALTER_USER_REMOVE_ALL_DB 0x8 +#define TSDB_ALTER_USER_ENABLE 0x9 +#define TSDB_ALTER_USER_SYSINFO 0xA +#define TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC 0xB +#define TSDB_ALTER_USER_REMOVE_SUBSCRIBE_TOPIC 0xC #define TSDB_ALTER_USER_PRIVILEGES 0x2 @@ -620,7 +627,7 @@ typedef struct { int8_t enable; char user[TSDB_USER_LEN]; char pass[TSDB_USET_PASSWORD_LEN]; - char dbname[TSDB_DB_FNAME_LEN]; + char objname[TSDB_DB_FNAME_LEN]; // db or topic } SAlterUserReq; int32_t tSerializeSAlterUserReq(void* buf, int32_t bufLen, SAlterUserReq* pReq); @@ -1059,6 +1066,7 @@ typedef struct { int32_t vgId; int8_t syncState; int8_t syncRestore; + int8_t syncCanRead; int64_t cacheUsage; int64_t numOfTables; int64_t numOfTimeSeries; @@ -1144,6 +1152,13 @@ typedef struct { int32_t tSerializeSMTimerMsg(void* buf, int32_t bufLen, SMTimerReq* pReq); int32_t tDeserializeSMTimerMsg(void* buf, int32_t bufLen, SMTimerReq* pReq); +typedef struct { + int64_t tick; +} SMStreamTickReq; + +int32_t tSerializeSMStreamTickMsg(void* buf, int32_t bufLen, SMStreamTickReq* pReq); +int32_t tDeserializeSMStreamTickMsg(void* buf, int32_t bufLen, SMStreamTickReq* pReq); + typedef struct { int32_t id; uint16_t port; // node sync Port @@ -1392,8 +1407,8 @@ typedef struct { int8_t streamBlockType; int32_t compLen; int32_t numOfBlocks; - int32_t numOfRows; - int32_t numOfCols; + int64_t numOfRows; // from int32_t change to int64_t + int64_t numOfCols; int64_t skey; int64_t ekey; int64_t version; // for stream @@ -1744,6 +1759,8 @@ typedef struct { int64_t watermark; int32_t numOfTags; SArray* pTags; // array of SField + // 3.0.20 + int64_t checkpointFreq; // ms } SCMCreateStreamReq; typedef struct { @@ -1943,6 +1960,12 @@ typedef struct { SHashObj* rebSubHash; // SHashObj } SMqDoRebalanceMsg; +typedef struct { + int64_t streamId; + int64_t checkpointId; + char streamName[TSDB_STREAM_FNAME_LEN]; +} SMStreamDoCheckpointMsg; + typedef struct { int64_t status; } SMVSubscribeRsp; diff --git a/include/common/tmsgcb.h b/include/common/tmsgcb.h index b5b997dac0..32d00bb422 100644 --- a/include/common/tmsgcb.h +++ b/include/common/tmsgcb.h @@ -43,7 +43,6 @@ typedef int32_t (*PutToQueueFp)(void* pMgmt, EQueueType qtype, SRpcMsg* pMsg); typedef int32_t (*GetQueueSizeFp)(void* pMgmt, int32_t vgId, EQueueType qtype); typedef int32_t (*SendReqFp)(const SEpSet* pEpSet, SRpcMsg* pMsg); typedef void (*SendRspFp)(SRpcMsg* pMsg); -typedef void (*SendRedirectRspFp)(SRpcMsg* pMsg, const SEpSet* pNewEpSet); typedef void (*RegisterBrokenLinkArgFp)(SRpcMsg* pMsg); typedef void (*ReleaseHandleFp)(SRpcHandleInfo* pHandle, int8_t type); typedef void (*ReportStartup)(const char* name, const char* desc); @@ -55,7 +54,6 @@ typedef struct { GetQueueSizeFp qsizeFp; SendReqFp sendReqFp; SendRspFp sendRspFp; - SendRedirectRspFp sendRedirectRspFp; RegisterBrokenLinkArgFp registerBrokenLinkArgFp; ReleaseHandleFp releaseHandleFp; ReportStartup reportStartupFp; @@ -66,7 +64,6 @@ int32_t tmsgPutToQueue(const SMsgCb* msgcb, EQueueType qtype, SRpcMsg* pMsg); int32_t tmsgGetQueueSize(const SMsgCb* msgcb, int32_t vgId, EQueueType qtype); int32_t tmsgSendReq(const SEpSet* epSet, SRpcMsg* pMsg); void tmsgSendRsp(SRpcMsg* pMsg); -void tmsgSendRedirectRsp(SRpcMsg* pMsg, const SEpSet* pNewEpSet); void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg); void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type); void tmsgReportStartup(const char* name, const char* desc); diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index e80766d249..7833bdf139 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -172,6 +172,8 @@ enum { TD_DEF_MSG_TYPE(TDMT_MND_SERVER_VERSION, "server-version", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_UPTIME_TIMER, "uptime-timer", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_TMQ_LOST_CONSUMER_CLEAR, "lost-consumer-clear", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_STREAM_CHECKPOINT_TIMER, "stream-checkpoint-tmr", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_STREAM_BEGIN_CHECKPOINT, "stream-begin-checkpoint", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL) TD_NEW_MSG_SEG(TDMT_VND_MSG) @@ -241,8 +243,11 @@ enum { TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_DISPATCH, "stream-task-dispatch", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_STREAM_UNUSED1, "stream-unused1", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_STREAM_RETRIEVE, "stream-retrieve", NULL, NULL) - TD_DEF_MSG_TYPE(TDMT_STREAM_RECOVER_FINISH, "vnode-stream-finish", NULL, NULL) - TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_CHECK, "vnode-stream-task-check", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_STREAM_RECOVER_FINISH, "stream-recover-finish", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_CHECK, "stream-task-check", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_CHECKPOINT, "stream-checkpoint", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_REPORT_CHECKPOINT, "stream-report-checkpoint", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_RESTORE_CHECKPOINT, "stream-restore-checkpoint", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_STREAM_MAX_MSG, "stream-max", NULL, NULL) TD_NEW_MSG_SEG(TDMT_MON_MSG) @@ -282,6 +287,7 @@ enum { TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TRIGGER, "vnode-stream-trigger", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_STREAM_RECOVER_NONBLOCKING_STAGE, "vnode-stream-recover1", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_STREAM_RECOVER_BLOCKING_STAGE, "vnode-stream-recover2", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_VND_STREAM_CHECK_POINT_SOURCE, "vnode-stream-checkpoint-source", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_STREAM_MAX_MSG, "vnd-stream-max", NULL, NULL) TD_NEW_MSG_SEG(TDMT_VND_TMQ_MSG) diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index f3c570aa85..ccf91600db 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -58,282 +58,284 @@ #define TK_TO 40 #define TK_REVOKE 41 #define TK_FROM 42 -#define TK_NK_COMMA 43 -#define TK_READ 44 -#define TK_WRITE 45 -#define TK_NK_DOT 46 -#define TK_DNODE 47 -#define TK_PORT 48 -#define TK_DNODES 49 -#define TK_NK_IPTOKEN 50 -#define TK_FORCE 51 -#define TK_LOCAL 52 -#define TK_QNODE 53 -#define TK_BNODE 54 -#define TK_SNODE 55 -#define TK_MNODE 56 -#define TK_DATABASE 57 -#define TK_USE 58 -#define TK_FLUSH 59 -#define TK_TRIM 60 -#define TK_IF 61 -#define TK_NOT 62 -#define TK_EXISTS 63 -#define TK_BUFFER 64 -#define TK_CACHEMODEL 65 -#define TK_CACHESIZE 66 -#define TK_COMP 67 -#define TK_DURATION 68 -#define TK_NK_VARIABLE 69 -#define TK_MAXROWS 70 -#define TK_MINROWS 71 -#define TK_KEEP 72 -#define TK_PAGES 73 -#define TK_PAGESIZE 74 -#define TK_TSDB_PAGESIZE 75 -#define TK_PRECISION 76 -#define TK_REPLICA 77 -#define TK_STRICT 78 -#define TK_VGROUPS 79 -#define TK_SINGLE_STABLE 80 -#define TK_RETENTIONS 81 -#define TK_SCHEMALESS 82 -#define TK_WAL_LEVEL 83 -#define TK_WAL_FSYNC_PERIOD 84 -#define TK_WAL_RETENTION_PERIOD 85 -#define TK_WAL_RETENTION_SIZE 86 -#define TK_WAL_ROLL_PERIOD 87 -#define TK_WAL_SEGMENT_SIZE 88 -#define TK_STT_TRIGGER 89 -#define TK_TABLE_PREFIX 90 -#define TK_TABLE_SUFFIX 91 -#define TK_NK_COLON 92 -#define TK_MAX_SPEED 93 -#define TK_TABLE 94 -#define TK_NK_LP 95 -#define TK_NK_RP 96 -#define TK_STABLE 97 -#define TK_ADD 98 -#define TK_COLUMN 99 -#define TK_MODIFY 100 -#define TK_RENAME 101 -#define TK_TAG 102 -#define TK_SET 103 -#define TK_NK_EQ 104 -#define TK_USING 105 -#define TK_TAGS 106 -#define TK_COMMENT 107 -#define TK_BOOL 108 -#define TK_TINYINT 109 -#define TK_SMALLINT 110 -#define TK_INT 111 -#define TK_INTEGER 112 -#define TK_BIGINT 113 -#define TK_FLOAT 114 -#define TK_DOUBLE 115 -#define TK_BINARY 116 -#define TK_TIMESTAMP 117 -#define TK_NCHAR 118 -#define TK_UNSIGNED 119 -#define TK_JSON 120 -#define TK_VARCHAR 121 -#define TK_MEDIUMBLOB 122 -#define TK_BLOB 123 -#define TK_VARBINARY 124 -#define TK_DECIMAL 125 -#define TK_MAX_DELAY 126 -#define TK_WATERMARK 127 -#define TK_ROLLUP 128 -#define TK_TTL 129 -#define TK_SMA 130 -#define TK_FIRST 131 -#define TK_LAST 132 -#define TK_SHOW 133 -#define TK_DATABASES 134 -#define TK_TABLES 135 -#define TK_STABLES 136 -#define TK_MNODES 137 -#define TK_QNODES 138 -#define TK_FUNCTIONS 139 -#define TK_INDEXES 140 -#define TK_ACCOUNTS 141 -#define TK_APPS 142 -#define TK_CONNECTIONS 143 -#define TK_LICENCES 144 -#define TK_GRANTS 145 -#define TK_QUERIES 146 -#define TK_SCORES 147 -#define TK_TOPICS 148 -#define TK_VARIABLES 149 -#define TK_CLUSTER 150 -#define TK_BNODES 151 -#define TK_SNODES 152 -#define TK_TRANSACTIONS 153 -#define TK_DISTRIBUTED 154 -#define TK_CONSUMERS 155 -#define TK_SUBSCRIPTIONS 156 -#define TK_VNODES 157 -#define TK_LIKE 158 -#define TK_TBNAME 159 -#define TK_QTAGS 160 -#define TK_AS 161 -#define TK_INDEX 162 -#define TK_FUNCTION 163 -#define TK_INTERVAL 164 -#define TK_TOPIC 165 -#define TK_WITH 166 -#define TK_META 167 -#define TK_CONSUMER 168 -#define TK_GROUP 169 -#define TK_DESC 170 -#define TK_DESCRIBE 171 -#define TK_RESET 172 -#define TK_QUERY 173 -#define TK_CACHE 174 -#define TK_EXPLAIN 175 -#define TK_ANALYZE 176 -#define TK_VERBOSE 177 -#define TK_NK_BOOL 178 -#define TK_RATIO 179 -#define TK_NK_FLOAT 180 -#define TK_OUTPUTTYPE 181 -#define TK_AGGREGATE 182 -#define TK_BUFSIZE 183 -#define TK_STREAM 184 -#define TK_INTO 185 -#define TK_TRIGGER 186 -#define TK_AT_ONCE 187 -#define TK_WINDOW_CLOSE 188 -#define TK_IGNORE 189 -#define TK_EXPIRED 190 -#define TK_FILL_HISTORY 191 -#define TK_SUBTABLE 192 -#define TK_KILL 193 -#define TK_CONNECTION 194 -#define TK_TRANSACTION 195 -#define TK_BALANCE 196 -#define TK_VGROUP 197 -#define TK_MERGE 198 -#define TK_REDISTRIBUTE 199 -#define TK_SPLIT 200 -#define TK_DELETE 201 -#define TK_INSERT 202 -#define TK_NULL 203 -#define TK_NK_QUESTION 204 -#define TK_NK_ARROW 205 -#define TK_ROWTS 206 -#define TK_QSTART 207 -#define TK_QEND 208 -#define TK_QDURATION 209 -#define TK_WSTART 210 -#define TK_WEND 211 -#define TK_WDURATION 212 -#define TK_IROWTS 213 -#define TK_CAST 214 -#define TK_NOW 215 -#define TK_TODAY 216 -#define TK_TIMEZONE 217 -#define TK_CLIENT_VERSION 218 -#define TK_SERVER_VERSION 219 -#define TK_SERVER_STATUS 220 -#define TK_CURRENT_USER 221 -#define TK_COUNT 222 -#define TK_LAST_ROW 223 -#define TK_CASE 224 -#define TK_END 225 -#define TK_WHEN 226 -#define TK_THEN 227 -#define TK_ELSE 228 -#define TK_BETWEEN 229 -#define TK_IS 230 -#define TK_NK_LT 231 -#define TK_NK_GT 232 -#define TK_NK_LE 233 -#define TK_NK_GE 234 -#define TK_NK_NE 235 -#define TK_MATCH 236 -#define TK_NMATCH 237 -#define TK_CONTAINS 238 -#define TK_IN 239 -#define TK_JOIN 240 -#define TK_INNER 241 -#define TK_SELECT 242 -#define TK_DISTINCT 243 -#define TK_WHERE 244 -#define TK_PARTITION 245 -#define TK_BY 246 -#define TK_SESSION 247 -#define TK_STATE_WINDOW 248 -#define TK_SLIDING 249 -#define TK_FILL 250 -#define TK_VALUE 251 -#define TK_NONE 252 -#define TK_PREV 253 -#define TK_LINEAR 254 -#define TK_NEXT 255 -#define TK_HAVING 256 -#define TK_RANGE 257 -#define TK_EVERY 258 -#define TK_ORDER 259 -#define TK_SLIMIT 260 -#define TK_SOFFSET 261 -#define TK_LIMIT 262 -#define TK_OFFSET 263 -#define TK_ASC 264 -#define TK_NULLS 265 -#define TK_ABORT 266 -#define TK_AFTER 267 -#define TK_ATTACH 268 -#define TK_BEFORE 269 -#define TK_BEGIN 270 -#define TK_BITAND 271 -#define TK_BITNOT 272 -#define TK_BITOR 273 -#define TK_BLOCKS 274 -#define TK_CHANGE 275 -#define TK_COMMA 276 -#define TK_COMPACT 277 -#define TK_CONCAT 278 -#define TK_CONFLICT 279 -#define TK_COPY 280 -#define TK_DEFERRED 281 -#define TK_DELIMITERS 282 -#define TK_DETACH 283 -#define TK_DIVIDE 284 -#define TK_DOT 285 -#define TK_EACH 286 -#define TK_FAIL 287 -#define TK_FILE 288 -#define TK_FOR 289 -#define TK_GLOB 290 -#define TK_ID 291 -#define TK_IMMEDIATE 292 -#define TK_IMPORT 293 -#define TK_INITIALLY 294 -#define TK_INSTEAD 295 -#define TK_ISNULL 296 -#define TK_KEY 297 -#define TK_MODULES 298 -#define TK_NK_BITNOT 299 -#define TK_NK_SEMI 300 -#define TK_NOTNULL 301 -#define TK_OF 302 -#define TK_PLUS 303 -#define TK_PRIVILEGE 304 -#define TK_RAISE 305 -#define TK_REPLACE 306 -#define TK_RESTRICT 307 -#define TK_ROW 308 -#define TK_SEMI 309 -#define TK_STAR 310 -#define TK_STATEMENT 311 -#define TK_STRING 312 -#define TK_TIMES 313 -#define TK_UPDATE 314 -#define TK_VALUES 315 -#define TK_VARIABLE 316 -#define TK_VIEW 317 -#define TK_WAL 318 +#define TK_SUBSCRIBE 43 +#define TK_NK_COMMA 44 +#define TK_READ 45 +#define TK_WRITE 46 +#define TK_NK_DOT 47 +#define TK_DNODE 48 +#define TK_PORT 49 +#define TK_DNODES 50 +#define TK_NK_IPTOKEN 51 +#define TK_FORCE 52 +#define TK_LOCAL 53 +#define TK_QNODE 54 +#define TK_BNODE 55 +#define TK_SNODE 56 +#define TK_MNODE 57 +#define TK_DATABASE 58 +#define TK_USE 59 +#define TK_FLUSH 60 +#define TK_TRIM 61 +#define TK_IF 62 +#define TK_NOT 63 +#define TK_EXISTS 64 +#define TK_BUFFER 65 +#define TK_CACHEMODEL 66 +#define TK_CACHESIZE 67 +#define TK_COMP 68 +#define TK_DURATION 69 +#define TK_NK_VARIABLE 70 +#define TK_MAXROWS 71 +#define TK_MINROWS 72 +#define TK_KEEP 73 +#define TK_PAGES 74 +#define TK_PAGESIZE 75 +#define TK_TSDB_PAGESIZE 76 +#define TK_PRECISION 77 +#define TK_REPLICA 78 +#define TK_STRICT 79 +#define TK_VGROUPS 80 +#define TK_SINGLE_STABLE 81 +#define TK_RETENTIONS 82 +#define TK_SCHEMALESS 83 +#define TK_WAL_LEVEL 84 +#define TK_WAL_FSYNC_PERIOD 85 +#define TK_WAL_RETENTION_PERIOD 86 +#define TK_WAL_RETENTION_SIZE 87 +#define TK_WAL_ROLL_PERIOD 88 +#define TK_WAL_SEGMENT_SIZE 89 +#define TK_STT_TRIGGER 90 +#define TK_TABLE_PREFIX 91 +#define TK_TABLE_SUFFIX 92 +#define TK_NK_COLON 93 +#define TK_MAX_SPEED 94 +#define TK_TABLE 95 +#define TK_NK_LP 96 +#define TK_NK_RP 97 +#define TK_STABLE 98 +#define TK_ADD 99 +#define TK_COLUMN 100 +#define TK_MODIFY 101 +#define TK_RENAME 102 +#define TK_TAG 103 +#define TK_SET 104 +#define TK_NK_EQ 105 +#define TK_USING 106 +#define TK_TAGS 107 +#define TK_COMMENT 108 +#define TK_BOOL 109 +#define TK_TINYINT 110 +#define TK_SMALLINT 111 +#define TK_INT 112 +#define TK_INTEGER 113 +#define TK_BIGINT 114 +#define TK_FLOAT 115 +#define TK_DOUBLE 116 +#define TK_BINARY 117 +#define TK_TIMESTAMP 118 +#define TK_NCHAR 119 +#define TK_UNSIGNED 120 +#define TK_JSON 121 +#define TK_VARCHAR 122 +#define TK_MEDIUMBLOB 123 +#define TK_BLOB 124 +#define TK_VARBINARY 125 +#define TK_DECIMAL 126 +#define TK_MAX_DELAY 127 +#define TK_WATERMARK 128 +#define TK_ROLLUP 129 +#define TK_TTL 130 +#define TK_SMA 131 +#define TK_FIRST 132 +#define TK_LAST 133 +#define TK_SHOW 134 +#define TK_PRIVILEGES 135 +#define TK_DATABASES 136 +#define TK_TABLES 137 +#define TK_STABLES 138 +#define TK_MNODES 139 +#define TK_QNODES 140 +#define TK_FUNCTIONS 141 +#define TK_INDEXES 142 +#define TK_ACCOUNTS 143 +#define TK_APPS 144 +#define TK_CONNECTIONS 145 +#define TK_LICENCES 146 +#define TK_GRANTS 147 +#define TK_QUERIES 148 +#define TK_SCORES 149 +#define TK_TOPICS 150 +#define TK_VARIABLES 151 +#define TK_CLUSTER 152 +#define TK_BNODES 153 +#define TK_SNODES 154 +#define TK_TRANSACTIONS 155 +#define TK_DISTRIBUTED 156 +#define TK_CONSUMERS 157 +#define TK_SUBSCRIPTIONS 158 +#define TK_VNODES 159 +#define TK_LIKE 160 +#define TK_TBNAME 161 +#define TK_QTAGS 162 +#define TK_AS 163 +#define TK_INDEX 164 +#define TK_FUNCTION 165 +#define TK_INTERVAL 166 +#define TK_TOPIC 167 +#define TK_WITH 168 +#define TK_META 169 +#define TK_CONSUMER 170 +#define TK_GROUP 171 +#define TK_DESC 172 +#define TK_DESCRIBE 173 +#define TK_RESET 174 +#define TK_QUERY 175 +#define TK_CACHE 176 +#define TK_EXPLAIN 177 +#define TK_ANALYZE 178 +#define TK_VERBOSE 179 +#define TK_NK_BOOL 180 +#define TK_RATIO 181 +#define TK_NK_FLOAT 182 +#define TK_OUTPUTTYPE 183 +#define TK_AGGREGATE 184 +#define TK_BUFSIZE 185 +#define TK_STREAM 186 +#define TK_INTO 187 +#define TK_TRIGGER 188 +#define TK_AT_ONCE 189 +#define TK_WINDOW_CLOSE 190 +#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_STRING 314 +#define TK_TIMES 315 +#define TK_UPDATE 316 +#define TK_VALUES 317 +#define TK_VARIABLE 318 +#define TK_VIEW 319 +#define TK_WAL 320 #define TK_NK_SPACE 600 #define TK_NK_COMMENT 601 diff --git a/include/common/ttypes.h b/include/common/ttypes.h index 761ffd0f1c..6350057c1f 100644 --- a/include/common/ttypes.h +++ b/include/common/ttypes.h @@ -278,11 +278,9 @@ typedef struct { #define IS_VALID_TINYINT(_t) ((_t) >= INT8_MIN && (_t) <= INT8_MAX) #define IS_VALID_SMALLINT(_t) ((_t) >= INT16_MIN && (_t) <= INT16_MAX) #define IS_VALID_INT(_t) ((_t) >= INT32_MIN && (_t) <= INT32_MAX) -#define IS_VALID_BIGINT(_t) ((_t) >= INT64_MIN && (_t) <= INT64_MAX) #define IS_VALID_UTINYINT(_t) ((_t) >= 0 && (_t) <= UINT8_MAX) #define IS_VALID_USMALLINT(_t) ((_t) >= 0 && (_t) <= UINT16_MAX) #define IS_VALID_UINT(_t) ((_t) >= 0 && (_t) <= UINT32_MAX) -#define IS_VALID_UBIGINT(_t) ((_t) >= 0 && (_t) <= UINT64_MAX) #define IS_VALID_FLOAT(_t) ((_t) >= -FLT_MAX && (_t) <= FLT_MAX) #define IS_VALID_DOUBLE(_t) ((_t) >= -DBL_MAX && (_t) <= DBL_MAX) diff --git a/include/libs/executor/dataSinkMgt.h b/include/libs/executor/dataSinkMgt.h index 8a02f372d1..ed7cbc8125 100644 --- a/include/libs/executor/dataSinkMgt.h +++ b/include/libs/executor/dataSinkMgt.h @@ -68,7 +68,7 @@ typedef struct SInputData { typedef struct SOutputData { int32_t numOfBlocks; - int32_t numOfRows; + int64_t numOfRows; // int32_t changed to int64_t int32_t numOfCols; int8_t compressed; char* pData; diff --git a/include/libs/executor/executor.h b/include/libs/executor/executor.h index d210004760..412b4b4cf6 100644 --- a/include/libs/executor/executor.h +++ b/include/libs/executor/executor.h @@ -152,7 +152,7 @@ void qCleanExecTaskBlockBuf(qTaskInfo_t tinfo); * @param tinfo qhandle * @return */ -int32_t qAsyncKillTask(qTaskInfo_t tinfo); +int32_t qAsyncKillTask(qTaskInfo_t tinfo, int32_t rspCode); /** * destroy query info structure diff --git a/include/libs/function/function.h b/include/libs/function/function.h index 13a8370dfd..32b8cc7389 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -137,22 +137,22 @@ typedef struct SqlFunctionCtx { int16_t functionId; // function id char *pOutput; // final result output buffer, point to sdata->data int32_t numOfParams; - SFunctParam *param; // input parameter, e.g., top(k, 20), the number of results for top query is kept in param - SColumnInfoData *pTsOutput; // corresponding output buffer for timestamp of each result, e.g., top/bottom*/ - int32_t offset; - struct SResultRowEntryInfo *resultInfo; - SSubsidiaryResInfo subsidiaries; - SPoint1 start; - SPoint1 end; - SFuncExecFuncs fpSet; - SScalarFuncExecFuncs sfp; - struct SExprInfo *pExpr; - struct SSDataBlock *pSrcBlock; - struct SSDataBlock *pDstBlock; // used by indefinite rows function to set selectivity - SSerializeDataHandle saveHandle; - bool isStream; - - char udfName[TSDB_FUNC_NAME_LEN]; + // input parameter, e.g., top(k, 20), the number of results of top query is kept in param + SFunctParam *param; + // corresponding output buffer for timestamp of each result, e.g., diff/csum + SColumnInfoData *pTsOutput; + int32_t offset; + SResultRowEntryInfo *resultInfo; + SSubsidiaryResInfo subsidiaries; + SPoint1 start; + SPoint1 end; + SFuncExecFuncs fpSet; + SScalarFuncExecFuncs sfp; + struct SExprInfo *pExpr; + struct SSDataBlock *pSrcBlock; + struct SSDataBlock *pDstBlock; // used by indefinite rows function to set selectivity + SSerializeDataHandle saveHandle; + char udfName[TSDB_FUNC_NAME_LEN]; } SqlFunctionCtx; typedef struct tExprNode { @@ -163,6 +163,7 @@ typedef struct tExprNode { int32_t functionId; int32_t num; struct SFunctionNode *pFunctNode; + int32_t functionType; } _function; struct { @@ -182,7 +183,6 @@ struct SScalarParam { }; void cleanupResultRowEntry(struct SResultRowEntryInfo *pCell); -//int32_t getNumOfResult(SqlFunctionCtx *pCtx, int32_t num, SSDataBlock *pResBlock); bool isRowEntryCompleted(struct SResultRowEntryInfo *pEntry); bool isRowEntryInitialized(struct SResultRowEntryInfo *pEntry); @@ -194,32 +194,6 @@ typedef struct SPoint { int32_t taosGetLinearInterpolationVal(SPoint *point, int32_t outputType, SPoint *point1, SPoint *point2, int32_t inputType); -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// udf api -/** - * create udfd proxy, called once in process that call doSetupUdf/callUdfxxx/doTeardownUdf - * @return error code - */ -int32_t udfcOpen(); - -/** - * destroy udfd proxy - * @return error code - */ -int32_t udfcClose(); - -/** - * start udfd that serves udf function invocation under dnode startDnodeId - * @param startDnodeId - * @return - */ -int32_t udfStartUdfd(int32_t startDnodeId); -/** - * stop udfd - * @return - */ -int32_t udfStopUdfd(); - #ifdef __cplusplus } #endif diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index 81f63537e5..9ca6a7a9fa 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -130,6 +130,7 @@ typedef enum EFunctionType { FUNCTION_TYPE_GROUP_KEY, FUNCTION_TYPE_CACHE_LAST_ROW, FUNCTION_TYPE_CACHE_LAST, + FUNCTION_TYPE_TABLE_COUNT, // distributed splitting functions FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000, diff --git a/include/libs/function/taosudf.h b/include/libs/function/taosudf.h index 5f57e203b9..1b1339340b 100644 --- a/include/libs/function/taosudf.h +++ b/include/libs/function/taosudf.h @@ -228,7 +228,7 @@ static FORCE_INLINE int32_t udfColDataSet(SUdfColumn *pColumn, uint32_t currentR newSize = 8; } - while (newSize < data->varLenCol.payloadLen + dataLen) { + while (newSize < (uint32_t)(data->varLenCol.payloadLen + dataLen)) { newSize = newSize * UDF_MEMORY_EXP_GROWTH; } @@ -248,7 +248,7 @@ static FORCE_INLINE int32_t udfColDataSet(SUdfColumn *pColumn, uint32_t currentR data->varLenCol.payloadLen += dataLen; } } - data->numOfRows = (currentRow + 1 > data->numOfRows) ? (currentRow + 1) : data->numOfRows; + data->numOfRows = ((int32_t)(currentRow + 1) > data->numOfRows) ? (int32_t)(currentRow + 1) : data->numOfRows; return 0; } diff --git a/include/libs/function/tudf.h b/include/libs/function/tudf.h index 31cc53bb9f..b71d50d43c 100644 --- a/include/libs/function/tudf.h +++ b/include/libs/function/tudf.h @@ -85,6 +85,32 @@ int32_t callUdfScalarFunc(char *udfName, SScalarParam *input, int32_t numOfCols, int32_t cleanUpUdfs(); +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// udf api +/** + * create udfd proxy, called once in process that call doSetupUdf/callUdfxxx/doTeardownUdf + * @return error code + */ +int32_t udfcOpen(); + +/** + * destroy udfd proxy + * @return error code + */ +int32_t udfcClose(); + +/** + * start udfd that serves udf function invocation under dnode startDnodeId + * @param startDnodeId + * @return + */ +int32_t udfStartUdfd(int32_t startDnodeId); +/** + * stop udfd + * @return + */ +int32_t udfStopUdfd(); + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index fc9bd461f6..e69c6e747d 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -42,9 +42,10 @@ extern "C" { #define PRIVILEGE_TYPE_MASK(n) (1 << n) -#define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0) -#define PRIVILEGE_TYPE_READ PRIVILEGE_TYPE_MASK(1) -#define PRIVILEGE_TYPE_WRITE PRIVILEGE_TYPE_MASK(2) +#define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0) +#define PRIVILEGE_TYPE_READ PRIVILEGE_TYPE_MASK(1) +#define PRIVILEGE_TYPE_WRITE PRIVILEGE_TYPE_MASK(2) +#define PRIVILEGE_TYPE_SUBSCRIBE PRIVILEGE_TYPE_MASK(3) #define PRIVILEGE_TYPE_TEST_MASK(val, mask) (((val) & (mask)) != 0) @@ -423,7 +424,7 @@ typedef struct SDropFunctionStmt { typedef struct SGrantStmt { ENodeType type; char userName[TSDB_USER_LEN]; - char dbName[TSDB_DB_NAME_LEN]; + char objName[TSDB_DB_NAME_LEN]; // db or topic int64_t privileges; } SGrantStmt; diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 00e896f586..f94e0c98dc 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -60,6 +60,12 @@ extern "C" { for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); \ (NULL != cell ? (node = &(cell->pNode), true) : (node = NULL, false)); cell = cell->pNext) +#define NODES_DESTORY_NODE(node) \ + do { \ + nodesDestroyNode((node)); \ + (node) = NULL; \ + } while (0) + #define NODES_DESTORY_LIST(list) \ do { \ nodesDestroyList((list)); \ @@ -187,6 +193,7 @@ typedef enum ENodeType { QUERY_NODE_SHOW_TRANSACTIONS_STMT, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT, QUERY_NODE_SHOW_VNODES_STMT, + QUERY_NODE_SHOW_USER_PRIVILEGES_STMT, QUERY_NODE_SHOW_CREATE_DATABASE_STMT, QUERY_NODE_SHOW_CREATE_TABLE_STMT, QUERY_NODE_SHOW_CREATE_STABLE_STMT, @@ -227,6 +234,7 @@ typedef enum ENodeType { QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN, QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN, QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN, + QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN, QUERY_NODE_PHYSICAL_PLAN_PROJECT, QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN, QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 6a6fd50f2a..574d41db58 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -62,7 +62,8 @@ typedef enum EScanType { SCAN_TYPE_STREAM, SCAN_TYPE_TABLE_MERGE, SCAN_TYPE_BLOCK_INFO, - SCAN_TYPE_LAST_ROW + SCAN_TYPE_LAST_ROW, + SCAN_TYPE_TABLE_COUNT } EScanType; typedef struct SScanLogicNode { @@ -323,6 +324,8 @@ typedef struct SLastRowScanPhysiNode { bool ignoreNull; } SLastRowScanPhysiNode; +typedef SLastRowScanPhysiNode STableCountScanPhysiNode; + typedef struct SSystemTableScanPhysiNode { SScanPhysiNode scan; SEpSet mgmtEpSet; diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index f51aa88485..ffb982af8e 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -129,6 +129,7 @@ typedef struct SDBVgInfo { int32_t numOfTable; // DB's table num, unit is TSDB_TABLE_NUM_UNIT int64_t stateTs; SHashObj* vgHash; // key:vgId, value:SVgroupInfo + SArray* vgArray; } SDBVgInfo; typedef struct SUseDbOutput { @@ -238,6 +239,7 @@ int32_t dataConverToStr(char* str, int type, void* buf, int32_t bufSize, int32_t char* parseTagDatatoJson(void* p); int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst); int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst); +void freeVgInfo(SDBVgInfo* vgInfo); extern int32_t (*queryBuildMsg[TDMT_MAX])(void* input, char** msg, int32_t msgSize, int32_t* msgLen, void* (*mallocFp)(int64_t)); @@ -260,24 +262,24 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t (NEED_CLIENT_RM_TBLMETA_ERROR(_code) || NEED_CLIENT_REFRESH_VG_ERROR(_code) || \ NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code)) -#define SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR) -#define SYNC_SELF_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR) +#define SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR || (_code) == TSDB_CODE_VND_STOPPED) +#define SYNC_SELF_LEADER_REDIRECT_ERROR(_code) ((_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_SYN_RESTORING || (_code) == TSDB_CODE_SYN_INTERNAL_ERROR) #define SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) (false) // used later -#define NEED_REDIRECT_ERROR(_code) \ - ((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || \ - (_code) == TSDB_CODE_NODE_NOT_DEPLOYED || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \ - SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) || \ - (_code) == TSDB_CODE_APP_NOT_READY || (_code) == TSDB_CODE_RPC_BROKEN_LINK) +#define NEED_REDIRECT_ERROR(_code) \ + ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || \ + (_code) == TSDB_CODE_MNODE_NOT_FOUND || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \ + SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) || \ + (_code) == TSDB_CODE_APP_IS_STARTING || (_code) == TSDB_CODE_APP_IS_STOPPING) #define NEED_CLIENT_RM_TBLMETA_REQ(_type) \ ((_type) == TDMT_VND_CREATE_TABLE || (_type) == TDMT_MND_CREATE_STB || (_type) == TDMT_VND_DROP_TABLE || \ (_type) == TDMT_MND_DROP_STB) -#define NEED_SCHEDULER_REDIRECT_ERROR(_code) \ - ((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_NODE_NOT_DEPLOYED || \ - SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || \ - SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) || (_code) == TSDB_CODE_APP_NOT_READY) +#define NEED_SCHEDULER_REDIRECT_ERROR(_code) \ + ((_code) == TSDB_CODE_MNODE_NOT_FOUND || SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || \ + SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || SYNC_OTHER_LEADER_REDIRECT_ERROR(_code) || \ + (_code) == TSDB_CODE_APP_IS_STARTING || (_code) == TSDB_CODE_APP_IS_STOPPING) #define REQUEST_TOTAL_EXEC_TIMES 2 diff --git a/include/libs/stream/streamState.h b/include/libs/stream/streamState.h index 59f030a60c..8fdac0da7f 100644 --- a/include/libs/stream/streamState.h +++ b/include/libs/stream/streamState.h @@ -35,7 +35,7 @@ typedef struct STdbState { TTB* pFillStateDb; // todo refactor TTB* pSessionStateDb; TTB* pParNameDb; - TXN txn; + TXN* txn; } STdbState; // incremental state storage diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index 4099551188..16cf960724 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -275,31 +275,6 @@ typedef struct { SEpSet epSet; } SStreamChildEpInfo; -typedef struct { - int32_t srcNodeId; - int32_t srcChildId; - int64_t stateSaveVer; - int64_t stateProcessedVer; -} SStreamCheckpointInfo; - -typedef struct { - int64_t streamId; - int64_t checkTs; - int32_t checkpointId; // incremental - int32_t taskId; - SArray* checkpointVer; // SArray -} SStreamMultiVgCheckpointInfo; - -typedef struct { - int32_t taskId; - int32_t checkpointId; // incremental -} SStreamCheckpointKey; - -typedef struct { - int32_t taskId; - SArray* checkpointVer; -} SStreamRecoveringState; - typedef struct SStreamTask { int64_t streamId; int32_t taskId; @@ -364,6 +339,10 @@ typedef struct SStreamTask { int64_t checkReqId; SArray* checkReqIds; // shuffle int32_t refCnt; + + int64_t checkpointingId; + int32_t checkpointAlignCnt; + } SStreamTask; int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo); @@ -509,6 +488,60 @@ typedef struct { int32_t tEncodeSStreamRecoverFinishReq(SEncoder* pEncoder, const SStreamRecoverFinishReq* pReq); int32_t tDecodeSStreamRecoverFinishReq(SDecoder* pDecoder, SStreamRecoverFinishReq* pReq); +typedef struct { + int64_t streamId; + int64_t checkpointId; + int32_t taskId; + int32_t nodeId; + int64_t expireTime; +} SStreamCheckpointSourceReq; + +typedef struct { + int64_t streamId; + int64_t checkpointId; + int32_t taskId; + int32_t nodeId; + int64_t expireTime; +} SStreamCheckpointSourceRsp; + +int32_t tEncodeSStreamCheckpointSourceReq(SEncoder* pEncoder, const SStreamCheckpointSourceReq* pReq); +int32_t tDecodeSStreamCheckpointSourceReq(SDecoder* pDecoder, SStreamCheckpointSourceReq* pReq); + +int32_t tEncodeSStreamCheckpointSourceRsp(SEncoder* pEncoder, const SStreamCheckpointSourceRsp* pRsp); +int32_t tDecodeSStreamCheckpointSourceRsp(SDecoder* pDecoder, SStreamCheckpointSourceRsp* pRsp); + +typedef struct { + SMsgHead msgHead; + int64_t streamId; + int64_t checkpointId; + int32_t downstreamTaskId; + int32_t downstreamNodeId; + int32_t upstreamTaskId; + int32_t upstreamNodeId; + int32_t childId; + int64_t expireTime; + int8_t taskLevel; +} SStreamCheckpointReq; + +typedef struct { + SMsgHead msgHead; + int64_t streamId; + int64_t checkpointId; + int32_t downstreamTaskId; + int32_t downstreamNodeId; + int32_t upstreamTaskId; + int32_t upstreamNodeId; + int32_t childId; + int64_t expireTime; + int8_t taskLevel; +} SStreamCheckpointRsp; + +int32_t tEncodeSStreamCheckpointReq(SEncoder* pEncoder, const SStreamCheckpointReq* pReq); +int32_t tDecodeSStreamCheckpointReq(SDecoder* pDecoder, SStreamCheckpointReq* pReq); + +int32_t tEncodeSStreamCheckpointRsp(SEncoder* pEncoder, const SStreamCheckpointRsp* pRsp); +int32_t tDecodeSStreamCheckpointRsp(SDecoder* pDecoder, SStreamCheckpointRsp* pRsp); + typedef struct { int64_t streamId; int32_t downstreamTaskId; @@ -587,7 +620,7 @@ typedef struct SStreamMeta { SHashObj* pTasks; SHashObj* pRecoverStatus; void* ahandle; - TXN txn; + TXN* txn; FTaskExpand* expandFunc; int32_t vgId; SRWLatch lock; @@ -598,18 +631,22 @@ void streamMetaClose(SStreamMeta* streamMeta); int32_t streamMetaAddTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTask); int32_t streamMetaAddSerializedTask(SStreamMeta* pMeta, int64_t startVer, char* msg, int32_t msgLen); -int32_t streamMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId); SStreamTask* streamMetaGetTask(SStreamMeta* pMeta, int32_t taskId); SStreamTask* streamMetaAcquireTask(SStreamMeta* pMeta, int32_t taskId); void streamMetaReleaseTask(SStreamMeta* pMeta, SStreamTask* pTask); -void streamMetaRemoveTask1(SStreamMeta* pMeta, int32_t taskId); +void streamMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId); int32_t streamMetaBegin(SStreamMeta* pMeta); int32_t streamMetaCommit(SStreamMeta* pMeta); int32_t streamMetaRollBack(SStreamMeta* pMeta); int32_t streamLoadTasks(SStreamMeta* pMeta); +// checkpoint +int32_t streamProcessCheckpointSourceReq(SStreamMeta* pMeta, SStreamTask* pTask, SStreamCheckpointSourceReq* pReq); +int32_t streamProcessCheckpointReq(SStreamMeta* pMeta, SStreamTask* pTask, SStreamCheckpointReq* pReq); +int32_t streamProcessCheckpointRsp(SStreamMeta* pMeta, SStreamTask* pTask, SStreamCheckpointRsp* pRsp); + #ifdef __cplusplus } #endif diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index 604e1479d5..7f9b240f63 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -40,8 +40,10 @@ extern "C" { #define SNAPSHOT_MAX_CLOCK_SKEW_MS 1000 * 10 #define SNAPSHOT_WAIT_MS 1000 * 30 +#define SYNC_MAX_RETRY_BACKOFF 5 +#define SYNC_LOG_REPL_RETRY_WAIT_MS 100 #define SYNC_APPEND_ENTRIES_TIMEOUT_MS 10000 -#define SYNC_HEART_TIMEOUT_MS 1000 * 8 +#define SYNC_HEART_TIMEOUT_MS 1000 * 15 #define SYNC_HEARTBEAT_SLOW_MS 1500 #define SYNC_HEARTBEAT_REPLY_SLOW_MS 1500 @@ -49,7 +51,7 @@ extern "C" { #define SYNC_MAX_BATCH_SIZE 1 #define SYNC_INDEX_BEGIN 0 #define SYNC_INDEX_INVALID -1 -#define SYNC_TERM_INVALID 0xFFFFFFFFFFFFFFFF +#define SYNC_TERM_INVALID -1 // 0xFFFFFFFFFFFFFFFF typedef enum { SYNC_STRATEGY_NO_SNAPSHOT = 0, @@ -60,7 +62,7 @@ typedef enum { typedef uint64_t SyncNodeId; typedef int32_t SyncGroupId; typedef int64_t SyncIndex; -typedef uint64_t SyncTerm; +typedef int64_t SyncTerm; typedef struct SSyncNode SSyncNode; typedef struct SWal SWal; @@ -136,13 +138,13 @@ typedef struct SSnapshotMeta { typedef struct SSyncFSM { void* data; - void (*FpCommitCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SFsmCbMeta* pMeta); - void (*FpPreCommitCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SFsmCbMeta* pMeta); - void (*FpRollBackCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SFsmCbMeta* pMeta); + int32_t (*FpCommitCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta); + int32_t (*FpPreCommitCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta); + void (*FpRollBackCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta); void (*FpRestoreFinishCb)(const struct SSyncFSM* pFsm); - void (*FpReConfigCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SReConfigCbMeta* pMeta); - void (*FpLeaderTransferCb)(const struct SSyncFSM* pFsm, const SRpcMsg* pMsg, const SFsmCbMeta* pMeta); + void (*FpReConfigCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SReConfigCbMeta* pMeta); + void (*FpLeaderTransferCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta); bool (*FpApplyQueueEmptyCb)(const struct SSyncFSM* pFsm); int32_t (*FpApplyQueueItems)(const struct SSyncFSM* pFsm); @@ -211,15 +213,20 @@ typedef struct SSyncInfo { int32_t (*syncEqCtrlMsg)(const SMsgCb* msgcb, SRpcMsg* pMsg); } SSyncInfo; +// if state == leader +// if restored, display "leader" +// if !restored && canRead, display "leader*" +// if !restored && !canRead, display "leader**" typedef struct SSyncState { ESyncState state; bool restored; + bool canRead; } SSyncState; int32_t syncInit(); void syncCleanUp(); int64_t syncOpen(SSyncInfo* pSyncInfo); -void syncStart(int64_t rid); +int32_t syncStart(int64_t rid); void syncStop(int64_t rid); void syncPreStop(int64_t rid); int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak); diff --git a/include/libs/wal/wal.h b/include/libs/wal/wal.h index ed85fd3517..936f11c41a 100644 --- a/include/libs/wal/wal.h +++ b/include/libs/wal/wal.h @@ -170,7 +170,7 @@ int32_t walWriteWithSyncInfo(SWal *, int64_t index, tmsg_t msgType, SWalSyncInfo // Assign version automatically and return to caller, // -1 will be returned for failed writes -int64_t walAppendLog(SWal *, tmsg_t msgType, SWalSyncInfo syncMeta, const void *body, int32_t bodyLen); +int64_t walAppendLog(SWal *, int64_t index, tmsg_t msgType, SWalSyncInfo syncMeta, const void *body, int32_t bodyLen); void walFsync(SWal *, bool force); diff --git a/include/os/osFile.h b/include/os/osFile.h index f6759d19a7..ae77e0f27a 100644 --- a/include/os/osFile.h +++ b/include/os/osFile.h @@ -88,6 +88,7 @@ int32_t taosFsyncFile(TdFilePtr pFile); int64_t taosReadFile(TdFilePtr pFile, void *buf, int64_t count); int64_t taosPReadFile(TdFilePtr pFile, void *buf, int64_t count, int64_t offset); int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count); +int64_t taosPWriteFile(TdFilePtr pFile, const void *buf, int64_t count, int64_t offset); void taosFprintfFile(TdFilePtr pFile, const char *format, ...); int64_t taosGetLineFile(TdFilePtr pFile, char **__restrict ptrBuf); diff --git a/include/os/osTime.h b/include/os/osTime.h index 48f046d4d0..0a0a54119b 100644 --- a/include/os/osTime.h +++ b/include/os/osTime.h @@ -35,6 +35,7 @@ extern "C" { #ifdef WINDOWS #define CLOCK_REALTIME 0 +#define CLOCK_MONOTONIC 0 #define MILLISECOND_PER_SECOND (1000i64) #else @@ -82,6 +83,13 @@ static FORCE_INLINE int64_t taosGetTimestampNs() { return (int64_t)systemTime.tv_sec * 1000000000LL + (int64_t)systemTime.tv_nsec; } +//@return timestamp of monotonic clock in millisecond +static FORCE_INLINE int64_t taosGetMonoTimestampMs() { + struct timespec systemTime = {0}; + taosClockGetTime(CLOCK_MONOTONIC, &systemTime); + return (int64_t)systemTime.tv_sec * 1000LL + (int64_t)systemTime.tv_nsec / 1000000; +} + char *taosStrpTime(const char *buf, const char *fmt, struct tm *tm); struct tm *taosLocalTime(const time_t *timep, struct tm *result); struct tm *taosLocalTimeNolock(struct tm *result, const time_t *timep, int dst); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 25d37020cc..739e14790d 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -40,48 +40,64 @@ int32_t* taosGetErrno(); #define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error // rpc -#define TSDB_CODE_RPC_AUTH_FAILURE TAOS_DEF_ERROR_CODE(0, 0x0003) -#define TSDB_CODE_RPC_REDIRECT TAOS_DEF_ERROR_CODE(0, 0x0004) +// #define TSDB_CODE_RPC_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0001) // 2.x +// #define TSDB_CODE_RPC_AUTH_REQUIRED TAOS_DEF_ERROR_CODE(0, 0x0002) // 2.x +// #define TSDB_CODE_RPC_AUTH_FAILURE TAOS_DEF_ERROR_CODE(0, 0x0003) // 2.x +// #define TSDB_CODE_RPC_REDIRECT TAOS_DEF_ERROR_CODE(0, 0x0004) // 2.x +// #define TSDB_CODE_RPC_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0005) // 2.x +// #define TSDB_CODE_RPC_ALREADY_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0006) // 2.x +// #define TSDB_CODE_RPC_LAST_SESSION_NOT_FINI. TAOS_DEF_ERROR_CODE(0, 0x0007) // 2.x +// #define TSDB_CODE_RPC_MISMATCHED_LINK_ID TAOS_DEF_ERROR_CODE(0, 0x0008) // 2.x +// #define TSDB_CODE_RPC_TOO_SLOW TAOS_DEF_ERROR_CODE(0, 0x0009) // 2.x +// #define TSDB_CODE_RPC_MAX_SESSIONS TAOS_DEF_ERROR_CODE(0, 0x000A) // 2.x #define TSDB_CODE_RPC_NETWORK_UNAVAIL TAOS_DEF_ERROR_CODE(0, 0x000B) +// #define TSDB_CODE_RPC_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x000C) // 2.x +// #define TSDB_CODE_RPC_UNEXPECTED_RESPONSE TAOS_DEF_ERROR_CODE(0, 0x000D) // 2.x +// #define TSDB_CODE_RPC_INVALID_VALUE TAOS_DEF_ERROR_CODE(0, 0x000E) // 2.x +// #define TSDB_CODE_RPC_INVALID_TRAN_ID TAOS_DEF_ERROR_CODE(0, 0x000F) // 2.x +// #define TSDB_CODE_RPC_INVALID_SESSION_ID TAOS_DEF_ERROR_CODE(0, 0x0010) // 2.x +// #define TSDB_CODE_RPC_INVALID_MSG_TYPE TAOS_DEF_ERROR_CODE(0, 0x0011) // 2.x +// #define TSDB_CODE_RPC_INVALID_RESPONSE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0012) // 2.x +#define TSDB_CODE_TIME_UNSYNCED TAOS_DEF_ERROR_CODE(0, 0x0013) // +// #define TSDB_CODE_APP_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0014) // 2.x #define TSDB_CODE_RPC_FQDN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0015) -#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0017) -#define TSDB_CODE_RPC_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0018) -#define TSDB_CODE_RPC_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0019) +// #define TSDB_CODE_RPC_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x0016) // 2.x +#define TSDB_CODE_RPC_PORT_EADDRINUSE TAOS_DEF_ERROR_CODE(0, 0x0017) // +#define TSDB_CODE_RPC_BROKEN_LINK TAOS_DEF_ERROR_CODE(0, 0x0018) // +#define TSDB_CODE_RPC_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0019) // //common & util -#define TSDB_CODE_TIME_UNSYNCED TAOS_DEF_ERROR_CODE(0, 0x0013) -#define TSDB_CODE_APP_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0014) - -#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100) -#define TSDB_CODE_MEMORY_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0101) +#define TSDB_CODE_OPS_NOT_SUPPORT TAOS_DEF_ERROR_CODE(0, 0x0100) // +// #define TSDB_CODE_MEMORY_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0101) // 2.x #define TSDB_CODE_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0102) -#define TSDB_CODE_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0104) -#define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0105) -#define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0106) -#define TSDB_CODE_REF_ID_REMOVED TAOS_DEF_ERROR_CODE(0, 0x0107) -#define TSDB_CODE_REF_INVALID_ID TAOS_DEF_ERROR_CODE(0, 0x0108) -#define TSDB_CODE_REF_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0109) -#define TSDB_CODE_REF_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x010A) +// #define TSDB_CODE_COM_INVALID_CFG_MSG TAOS_DEF_ERROR_CODE(0, 0x0103) // 2.x +#define TSDB_CODE_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0104) // +#define TSDB_CODE_REF_NO_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0105) // internal +#define TSDB_CODE_REF_FULL TAOS_DEF_ERROR_CODE(0, 0x0106) // internal +#define TSDB_CODE_REF_ID_REMOVED TAOS_DEF_ERROR_CODE(0, 0x0107) // internal +#define TSDB_CODE_REF_INVALID_ID TAOS_DEF_ERROR_CODE(0, 0x0108) // internal +#define TSDB_CODE_REF_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0109) // internal +#define TSDB_CODE_REF_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x010A) // internal -#define TSDB_CODE_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0110) -#define TSDB_CODE_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0111) -#define TSDB_CODE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0112) -#define TSDB_CODE_OUT_OF_SHM_MEM TAOS_DEF_ERROR_CODE(0, 0x0113) -#define TSDB_CODE_INVALID_SHM_ID TAOS_DEF_ERROR_CODE(0, 0x0114) -#define TSDB_CODE_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0115) -#define TSDB_CODE_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0116) -#define TSDB_CODE_INVALID_PTR TAOS_DEF_ERROR_CODE(0, 0x0117) -#define TSDB_CODE_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x0118) -#define TSDB_CODE_INVALID_CFG TAOS_DEF_ERROR_CODE(0, 0x0119) -#define TSDB_CODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x011A) -#define TSDB_CODE_INVALID_JSON_FORMAT TAOS_DEF_ERROR_CODE(0, 0x011B) -#define TSDB_CODE_INVALID_VERSION_NUMBER TAOS_DEF_ERROR_CODE(0, 0x011C) -#define TSDB_CODE_INVALID_VERSION_STRING TAOS_DEF_ERROR_CODE(0, 0x011D) -#define TSDB_CODE_VERSION_NOT_COMPATIBLE TAOS_DEF_ERROR_CODE(0, 0x011E) -#define TSDB_CODE_CHECKSUM_ERROR TAOS_DEF_ERROR_CODE(0, 0x011F) +#define TSDB_CODE_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0110) // +#define TSDB_CODE_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0111) // internal +#define TSDB_CODE_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x0112) // +// #define TSDB_CODE_OUT_OF_SHM_MEM TAOS_DEF_ERROR_CODE(0, 0x0113) +// #define TSDB_CODE_INVALID_SHM_ID TAOS_DEF_ERROR_CODE(0, 0x0114) +#define TSDB_CODE_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0115) // +#define TSDB_CODE_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0116) // +#define TSDB_CODE_INVALID_PTR TAOS_DEF_ERROR_CODE(0, 0x0117) // internal +#define TSDB_CODE_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x0118) // +#define TSDB_CODE_INVALID_CFG TAOS_DEF_ERROR_CODE(0, 0x0119) // internal +#define TSDB_CODE_INVALID_OPTION TAOS_DEF_ERROR_CODE(0, 0x011A) // internal +#define TSDB_CODE_INVALID_JSON_FORMAT TAOS_DEF_ERROR_CODE(0, 0x011B) // internal +#define TSDB_CODE_INVALID_VERSION_NUMBER TAOS_DEF_ERROR_CODE(0, 0x011C) // internal +#define TSDB_CODE_INVALID_VERSION_STRING TAOS_DEF_ERROR_CODE(0, 0x011D) // internal +#define TSDB_CODE_VERSION_NOT_COMPATIBLE TAOS_DEF_ERROR_CODE(0, 0x011E) // internal +#define TSDB_CODE_CHECKSUM_ERROR TAOS_DEF_ERROR_CODE(0, 0x011F) // internal #define TSDB_CODE_COMPRESS_ERROR TAOS_DEF_ERROR_CODE(0, 0x0120) -#define TSDB_CODE_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0121) +#define TSDB_CODE_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0121) // #define TSDB_CODE_CFG_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x0122) #define TSDB_CODE_REPEAT_INIT TAOS_DEF_ERROR_CODE(0, 0x0123) #define TSDB_CODE_DUP_KEY TAOS_DEF_ERROR_CODE(0, 0x0124) @@ -94,6 +110,9 @@ int32_t* taosGetErrno(); #define TSDB_CODE_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x012B) #define TSDB_CODE_TIMEOUT_ERROR TAOS_DEF_ERROR_CODE(0, 0x012C) +#define TSDB_CODE_APP_IS_STARTING TAOS_DEF_ERROR_CODE(0, 0x0130) // +#define TSDB_CODE_APP_IS_STOPPING TAOS_DEF_ERROR_CODE(0, 0x0131) // + //client #define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200) #define TSDB_CODE_TSC_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0201) @@ -107,11 +126,11 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TSC_INVALID_DB_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0209) #define TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH TAOS_DEF_ERROR_CODE(0, 0x020A) #define TSDB_CODE_TSC_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x020B) -#define TSDB_CODE_TSC_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x020C) +// #define TSDB_CODE_TSC_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x020C) // 2.x #define TSDB_CODE_TSC_QUERY_CACHE_ERASED TAOS_DEF_ERROR_CODE(0, 0x020E) #define TSDB_CODE_TSC_QUERY_CANCELLED TAOS_DEF_ERROR_CODE(0, 0x020F) #define TSDB_CODE_TSC_SORTED_RES_TOO_MANY TAOS_DEF_ERROR_CODE(0, 0x0210) -#define TSDB_CODE_TSC_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0211) +// #define TSDB_CODE_TSC_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0211) // 2.x #define TSDB_CODE_TSC_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0212) #define TSDB_CODE_TSC_DISCONNECTED TAOS_DEF_ERROR_CODE(0, 0x0213) #define TSDB_CODE_TSC_NO_WRITE_AUTH TAOS_DEF_ERROR_CODE(0, 0x0214) @@ -139,9 +158,17 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TSC_NOT_STABLE_ERROR TAOS_DEF_ERROR_CODE(0, 0X022F) // mnode-common +// #define TSDB_CODE_MND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0300) // 2.x +// #define TSDB_CODE_MND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0301) // 2.x +// #define TSDB_CODE_MND_ACTION_NEED_REPROCESSEDTAOS_DEF_ERROR_CODE(0, 0x0302) // 2.x #define TSDB_CODE_MND_NO_RIGHTS TAOS_DEF_ERROR_CODE(0, 0x0303) -#define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0304) +// #define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0304) // 2.x #define TSDB_CODE_MND_INVALID_CONNECTION TAOS_DEF_ERROR_CODE(0, 0x0305) +// #define TSDB_CODE_MND_INVALID_MSG_VERSION TAOS_DEF_ERROR_CODE(0, 0x0306) // 2.x +// #define TSDB_CODE_MND_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0307) // 2.x +// #define TSDB_CODE_MND_INVALID_MSG_TYPE TAOS_DEF_ERROR_CODE(0, 0x0308) // 2.x +// #define TSDB_CODE_MND_TOO_MANY_SHELL_CONNS TAOS_DEF_ERROR_CODE(0, 0x0309) // 2.x +// #define TSDB_CODE_MND_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x030A) // 2.x #define TSDB_CODE_MND_INVALID_SHOWOBJ TAOS_DEF_ERROR_CODE(0, 0x030B) #define TSDB_CODE_MND_INVALID_QUERY_ID TAOS_DEF_ERROR_CODE(0, 0x030C) #define TSDB_CODE_MND_INVALID_STREAM_ID TAOS_DEF_ERROR_CODE(0, 0x030D) @@ -155,7 +182,7 @@ int32_t* taosGetErrno(); // mnode-sdb #define TSDB_CODE_SDB_OBJ_ALREADY_THERE TAOS_DEF_ERROR_CODE(0, 0x0320) -#define TSDB_CODE_SDB_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0321) // internal +// #define TSDB_CODE_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0321) // 2.x #define TSDB_CODE_SDB_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0322) #define TSDB_CODE_SDB_OBJ_NOT_THERE TAOS_DEF_ERROR_CODE(0, 0x0323) #define TSDB_CODE_SDB_INVALID_KEY_TYPE TAOS_DEF_ERROR_CODE(0, 0x0325) @@ -198,22 +225,31 @@ int32_t* taosGetErrno(); // mnode-stable-part1 #define TSDB_CODE_MND_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0360) +// #define TSDB_CODE_MND_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0361) // 2.x #define TSDB_CODE_MND_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0362) +// #define TSDB_CODE_MND_INVALID_TABLE_TYPE TAOS_DEF_ERROR_CODE(0, 0x0363) // 2.x #define TSDB_CODE_MND_TOO_MANY_TAGS TAOS_DEF_ERROR_CODE(0, 0x0364) #define TSDB_CODE_MND_TOO_MANY_COLUMNS TAOS_DEF_ERROR_CODE(0, 0x0365) +// #define TSDB_CODE_MND_TOO_MANY_TIMESERIES TAOS_DEF_ERROR_CODE(0, 0x0366) // 2.x +// #define TSDB_CODE_MND_NOT_SUPER_TABLE TAOS_DEF_ERROR_CODE(0, 0x0367) // 2.x +// #define TSDB_CODE_MND_COL_NAME_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x0368) // 2.x #define TSDB_CODE_MND_TAG_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0369) #define TSDB_CODE_MND_TAG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x036A) #define TSDB_CODE_MND_COLUMN_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x036B) #define TSDB_CODE_MND_COLUMN_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x036C) +// #define TSDB_CODE_MND_INVALID_STABLE_NAME TAOS_DEF_ERROR_CODE(0, 0x036D) // 2.x #define TSDB_CODE_MND_INVALID_STB_OPTION TAOS_DEF_ERROR_CODE(0, 0x036E) #define TSDB_CODE_MND_INVALID_ROW_BYTES TAOS_DEF_ERROR_CODE(0, 0x036F) // mnode-func #define TSDB_CODE_MND_INVALID_FUNC_NAME TAOS_DEF_ERROR_CODE(0, 0x0370) +// #define TSDB_CODE_MND_INVALID_FUNC_LEN TAOS_DEF_ERROR_CODE(0, 0x0371) // 2.x #define TSDB_CODE_MND_INVALID_FUNC_CODE TAOS_DEF_ERROR_CODE(0, 0x0372) #define TSDB_CODE_MND_FUNC_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0373) #define TSDB_CODE_MND_FUNC_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0374) #define TSDB_CODE_MND_INVALID_FUNC_BUFSIZE TAOS_DEF_ERROR_CODE(0, 0x0375) +// #define TSDB_CODE_MND_INVALID_TAG_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0376) // 2.x +// #define TSDB_CODE_MND_INVALID_COLUMN_LENGTH TAOS_DEF_ERROR_CODE(0, 0x0377) // 2.x #define TSDB_CODE_MND_INVALID_FUNC_COMMENT TAOS_DEF_ERROR_CODE(0, 0x0378) #define TSDB_CODE_MND_INVALID_FUNC_RETRIEVE TAOS_DEF_ERROR_CODE(0, 0x0379) @@ -279,6 +315,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_TRANS_CONFLICT TAOS_DEF_ERROR_CODE(0, 0x03D3) #define TSDB_CODE_MND_TRANS_CLOG_IS_NULL TAOS_DEF_ERROR_CODE(0, 0x03D4) #define TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL TAOS_DEF_ERROR_CODE(0, 0x03D5) +#define TSDB_CODE_MND_LAST_TRANS_NOT_FINISHED TAOS_DEF_ERROR_CODE(0, 0x03D6) //internal #define TSDB_CODE_MND_TRANS_UNKNOW_ERROR TAOS_DEF_ERROR_CODE(0, 0x03DF) // mnode-mq @@ -311,19 +348,57 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_INVALID_SMA_OPTION TAOS_DEF_ERROR_CODE(0, 0x0482) // dnode -#define TSDB_CODE_NODE_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x0408) -#define TSDB_CODE_NODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0409) -#define TSDB_CODE_NODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x040A) +// #define TSDB_CODE_DND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0400) // 2.x +// #define TSDB_CODE_DND_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0401) // 2.x +// #define TSDB_CODE_DND_NO_WRITE_ACCESS TAOS_DEF_ERROR_CODE(0, 0x0402) // 2.x +// #define TSDB_CODE_DND_INVALID_MSG_LEN TAOS_DEF_ERROR_CODE(0, 0x0403) // 2.x +// #define TSDB_CODE_DND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0404) // 2.x +// #define TSDB_CODE_DND_TOO_MANY_VNODES TAOS_DEF_ERROR_CODE(0, 0x0405) // 2.x +// #define TSDB_CODE_DND_EXITING TAOS_DEF_ERROR_CODE(0, 0x0406) // 2.x +// #define TSDB_CODE_DND_VNODE_OPEN_FAILED TAOS_DEF_ERROR_CODE(0, 0x0407) // 2.x +#define TSDB_CODE_DNODE_OFFLINE TAOS_DEF_ERROR_CODE(0, 0x0408) +#define TSDB_CODE_MNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0409) +#define TSDB_CODE_MNODE_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x040A) +#define TSDB_CODE_MNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x040B) +#define TSDB_CODE_QNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x040C) +#define TSDB_CODE_QNODE_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x040D) +#define TSDB_CODE_QNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x040E) +#define TSDB_CODE_SNODE_ALREADY_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x040F) +#define TSDB_CODE_SNODE_NOT_FOUND TAOS_DEF_ERROR_CODE(0, 0x0410) +#define TSDB_CODE_SNODE_NOT_DEPLOYED TAOS_DEF_ERROR_CODE(0, 0x0411) // vnode +// #define TSDB_CODE_VND_ACTION_IN_PROGRESS TAOS_DEF_ERROR_CODE(0, 0x0500) // 2.x +// #define TSDB_CODE_VND_MSG_NOT_PROCESSED TAOS_DEF_ERROR_CODE(0, 0x0501) // 2.x +// #define TSDB_CODE_VND_ACTION_NEED_REPROCESS. TAOS_DEF_ERROR_CODE(0, 0x0502) // 2.x #define TSDB_CODE_VND_INVALID_VGROUP_ID TAOS_DEF_ERROR_CODE(0, 0x0503) +// #define TSDB_CODE_VND_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0504) // 2.x +// #define TSDB_CODE_VND_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0505) // 2.x +// #define TSDB_CODE_VND_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0506) // 2.x +// #define TSDB_CODE_VND_NO_SUCH_FILE_OR_DIR TAOS_DEF_ERROR_CODE(0, 0x0507) // 2.x +// #define TSDB_CODE_VND_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0508) // 2.x +// #define TSDB_CODE_VND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0509) // 2.x +// #define TSDB_CODE_VND_INVALID_VRESION_FILE TAOS_DEF_ERROR_CODE(0, 0x050A) // 2.x +// #define TSDB_CODE_VND_IS_FULL TAOS_DEF_ERROR_CODE(0, 0x050B) // 2.x +// #define TSDB_CODE_VND_IS_FLOWCTRL TAOS_DEF_ERROR_CODE(0, 0x050C) // 2.x +// #define TSDB_CODE_VND_IS_DROPPING TAOS_DEF_ERROR_CODE(0, 0x050D) // 2.x +// #define TSDB_CODE_VND_IS_BALANCING TAOS_DEF_ERROR_CODE(0, 0x050E) // 2.x +// #define TSDB_CODE_VND_IS_CLOSING TAOS_DEF_ERROR_CODE(0, 0x0510) // 2.x +// #define TSDB_CODE_VND_NOT_SYNCED TAOS_DEF_ERROR_CODE(0, 0x0511) // 2.x #define TSDB_CODE_VND_NO_WRITE_AUTH TAOS_DEF_ERROR_CODE(0, 0x0512) +// #define TSDB_CODE_VND_IS_SYNCING TAOS_DEF_ERROR_CODE(0, 0x0513) // 2.x +// #define TSDB_CODE_VND_INVALID_TSDB_STATE TAOS_DEF_ERROR_CODE(0, 0x0514) // 2.x +// #define TSDB_CODE_WAIT_THREAD_TOO_MANY TAOS_DEF_ERROR_CODE(0, 0x0515) // 2.x +#define TSDB_CODE_VND_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0520) // internal +#define TSDB_CODE_VND_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0521) // internal #define TSDB_CODE_VND_HASH_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x0522) #define TSDB_CODE_VND_INVALID_TABLE_ACTION TAOS_DEF_ERROR_CODE(0, 0x0524) #define TSDB_CODE_VND_COL_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0525) #define TSDB_CODE_VND_COL_NOT_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0526) #define TSDB_CODE_VND_COL_SUBSCRIBED TAOS_DEF_ERROR_CODE(0, 0x0527) #define TSDB_CODE_VND_NO_AVAIL_BUFPOOL TAOS_DEF_ERROR_CODE(0, 0x0528) +#define TSDB_CODE_VND_STOPPED TAOS_DEF_ERROR_CODE(0, 0x0529) +#define TSDB_CODE_VND_DUP_REQUEST TAOS_DEF_ERROR_CODE(0, 0x0530) // tsdb #define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600) @@ -333,8 +408,8 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TDB_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0604) #define TSDB_CODE_TDB_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0605) #define TSDB_CODE_TDB_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0607) -#define TSDB_CODE_TDB_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0608) -#define TSDB_CODE_TDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0609) +// #define TSDB_CODE_TDB_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0608) // 2.x +// #define TSDB_CODE_TDB_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0609) // 2.x #define TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE TAOS_DEF_ERROR_CODE(0, 0x060A) #define TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE TAOS_DEF_ERROR_CODE(0, 0x060B) #define TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x060C) @@ -348,6 +423,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TDB_MESSED_MSG TAOS_DEF_ERROR_CODE(0, 0x0614) #define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615) #define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616) +// #define TSDB_CODE_TDB_INCOMPLETE_DFILESET TAOS_DEF_ERROR_CODE(0, 0x0617) // 2.x #define TSDB_CODE_TDB_TABLE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0618) #define TSDB_CODE_TDB_STB_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0619) #define TSDB_CODE_TDB_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x061A) @@ -358,8 +434,9 @@ int32_t* taosGetErrno(); // query #define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700) #define TSDB_CODE_QRY_INVALID_MSG TAOS_DEF_ERROR_CODE(0, 0x0701) -#define TSDB_CODE_QRY_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0703) -#define TSDB_CODE_QRY_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0704) +// #define TSDB_CODE_QRY_NO_DISKSPACE TAOS_DEF_ERROR_CODE(0, 0x0702) // 2.x +// #define TSDB_CODE_QRY_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0703) // 2.x +// #define TSDB_CODE_QRY_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0704) // 2.x #define TSDB_CODE_QRY_DUP_JOIN_KEY TAOS_DEF_ERROR_CODE(0, 0x0705) #define TSDB_CODE_QRY_EXCEED_TAGS_LIMIT TAOS_DEF_ERROR_CODE(0, 0x0706) #define TSDB_CODE_QRY_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0707) @@ -371,6 +448,8 @@ int32_t* taosGetErrno(); #define TSDB_CODE_QRY_SYS_ERROR TAOS_DEF_ERROR_CODE(0, 0x070D) #define TSDB_CODE_QRY_INVALID_TIME_CONDITION TAOS_DEF_ERROR_CODE(0, 0x070E) #define TSDB_CODE_QRY_INVALID_INPUT TAOS_DEF_ERROR_CODE(0, 0x070F) +// #define TSDB_CODE_QRY_INVALID_SCHEMA_VERSION TAOS_DEF_ERROR_CODE(0, 0x0710) // 2.x +// #define TSDB_CODE_QRY_RESULT_TOO_LARGE TAOS_DEF_ERROR_CODE(0, 0x0711) // 2.x #define TSDB_CODE_QRY_SCH_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0720) #define TSDB_CODE_QRY_TASK_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0721) #define TSDB_CODE_QRY_TASK_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0722) @@ -406,7 +485,17 @@ int32_t* taosGetErrno(); #define TSDB_CODE_GRANT_TABLE_LIMITED TAOS_DEF_ERROR_CODE(0, 0x080D) // sync +// #define TSDB_CODE_SYN_INVALID_CONFIG TAOS_DEF_ERROR_CODE(0, 0x0900) // 2.x +// #define TSDB_CODE_SYN_NOT_ENABLED TAOS_DEF_ERROR_CODE(0, 0x0901) // 2.x +// #define TSDB_CODE_SYN_INVALID_VERSION TAOS_DEF_ERROR_CODE(0, 0x0902) // 2.x #define TSDB_CODE_SYN_TIMEOUT TAOS_DEF_ERROR_CODE(0, 0x0903) +// #define TSDB_CODE_SYN_TOO_MANY_FWDINFO TAOS_DEF_ERROR_CODE(0, 0x0904) // 2.x +// #define TSDB_CODE_SYN_MISMATCHED_PROTOCOL TAOS_DEF_ERROR_CODE(0, 0x0905) // 2.x +// #define TSDB_CODE_SYN_MISMATCHED_CLUSTERID TAOS_DEF_ERROR_CODE(0, 0x0906) // 2.x +// #define TSDB_CODE_SYN_MISMATCHED_SIGNATURE TAOS_DEF_ERROR_CODE(0, 0x0907) // 2.x +// #define TSDB_CODE_SYN_INVALID_CHECKSUM TAOS_DEF_ERROR_CODE(0, 0x0908) // 2.x +// #define TSDB_CODE_SYN_INVALID_MSGLEN TAOS_DEF_ERROR_CODE(0, 0x0909) // 2.x +// #define TSDB_CODE_SYN_INVALID_MSGTYPE TAOS_DEF_ERROR_CODE(0, 0x090A) // 2.x #define TSDB_CODE_SYN_IS_LEADER TAOS_DEF_ERROR_CODE(0, 0x090B) #define TSDB_CODE_SYN_NOT_LEADER TAOS_DEF_ERROR_CODE(0, 0x090C) #define TSDB_CODE_SYN_ONE_REPLICA TAOS_DEF_ERROR_CODE(0, 0x090D) @@ -424,7 +513,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TQ_INIT_FAILED TAOS_DEF_ERROR_CODE(0, 0x0A01) #define TSDB_CODE_TQ_NO_DISK_PERMISSIONS TAOS_DEF_ERROR_CODE(0, 0x0A03) #define TSDB_CODE_TQ_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x0A04) -#define TSDB_CODE_TQ_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0A05) +// #define TSDB_CODE_TQ_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x0A05) #define TSDB_CODE_TQ_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x0A06) #define TSDB_CODE_TQ_FAILED_TO_CREATE_DIR TAOS_DEF_ERROR_CODE(0, 0x0A07) #define TSDB_CODE_TQ_META_NO_SUCH_KEY TAOS_DEF_ERROR_CODE(0, 0x0A08) @@ -435,16 +524,17 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TQ_NO_COMMITTED_OFFSET TAOS_DEF_ERROR_CODE(0, 0x0A0D) // wal -#define TSDB_CODE_WAL_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x1000) +// #define TSDB_CODE_WAL_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x1000) // 2.x #define TSDB_CODE_WAL_FILE_CORRUPTED TAOS_DEF_ERROR_CODE(0, 0x1001) #define TSDB_CODE_WAL_SIZE_LIMIT TAOS_DEF_ERROR_CODE(0, 0x1002) #define TSDB_CODE_WAL_INVALID_VER TAOS_DEF_ERROR_CODE(0, 0x1003) -#define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004) +// #define TSDB_CODE_WAL_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x1004) // 2.x #define TSDB_CODE_WAL_LOG_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x1005) #define TSDB_CODE_WAL_CHKSUM_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x1006) #define TSDB_CODE_WAL_LOG_INCOMPLETE TAOS_DEF_ERROR_CODE(0, 0x1007) // tfs +// #define TSDB_CODE_FS_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x2200) // 2.x #define TSDB_CODE_FS_INVLD_CFG TAOS_DEF_ERROR_CODE(0, 0x2201) #define TSDB_CODE_FS_TOO_MANY_MOUNT TAOS_DEF_ERROR_CODE(0, 0x2202) #define TSDB_CODE_FS_DUP_PRIMARY TAOS_DEF_ERROR_CODE(0, 0x2203) @@ -453,7 +543,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_FS_FILE_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x2206) #define TSDB_CODE_FS_INVLD_LEVEL TAOS_DEF_ERROR_CODE(0, 0x2207) #define TSDB_CODE_FS_NO_VALID_DISK TAOS_DEF_ERROR_CODE(0, 0x2208) -#define TSDB_CODE_FS_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x220F) +// #define TSDB_CODE_FS_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x220F) // 2.x // catalog #define TSDB_CODE_CTG_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2400) diff --git a/include/util/tdef.h b/include/util/tdef.h index ad44daed46..6ce7b737a8 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -281,6 +281,7 @@ typedef enum ELogicConditionType { #define TSDB_DNODE_ROLE_VNODE 2 #define TSDB_MAX_REPLICA 5 +#define TSDB_SYNC_LOG_BUFFER_SIZE 4096 #define TSDB_TBNAME_COLUMN_INDEX (-1) #define TSDB_MULTI_TABLEMETA_MAX_NUM 100000 // maximum batch size allowed to load table meta diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index aae20c587d..ea76f726ea 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -171,9 +171,9 @@ typedef struct SReqResultInfo { char** convertBuf; TAOS_ROW row; SResultColumn* pCol; - uint32_t numOfRows; + uint64_t numOfRows; // from int32_t change to int64_t uint64_t totalRows; - uint32_t current; + uint64_t current; bool localResultFetched; bool completed; int32_t precision; diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 6f1414b72d..f4b18a373b 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -244,14 +244,14 @@ void destroyTscObj(void *pObj) { void *createTscObj(const char *user, const char *auth, const char *db, int32_t connType, SAppInstInfo *pAppInfo) { STscObj *pObj = (STscObj *)taosMemoryCalloc(1, sizeof(STscObj)); if (NULL == pObj) { - terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } pObj->pRequests = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK); if (NULL == pObj->pRequests) { taosMemoryFree(pObj); - terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } @@ -281,7 +281,7 @@ int32_t releaseTscObj(int64_t rid) { return taosReleaseRef(clientConnRefPool, ri void *createRequest(uint64_t connId, int32_t type, int64_t reqid) { SRequestObj *pRequest = (SRequestObj *)taosMemoryCalloc(1, sizeof(SRequestObj)); if (NULL == pRequest) { - terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index 6bdc835217..47ed2cf035 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -69,7 +69,7 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog } else { SDBVgInfo *vgInfo = taosMemoryCalloc(1, sizeof(SDBVgInfo)); if (NULL == vgInfo) { - code = TSDB_CODE_TSC_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _return; } @@ -82,7 +82,7 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog if (NULL == vgInfo->vgHash) { taosMemoryFree(vgInfo); tscError("hash init[%d] failed", rsp->vgNum); - code = TSDB_CODE_TSC_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _return; } @@ -92,7 +92,7 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog tscError("hash push failed, errno:%d", errno); taosHashCleanup(vgInfo->vgHash); taosMemoryFree(vgInfo); - code = TSDB_CODE_TSC_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _return; } } @@ -366,7 +366,7 @@ int32_t hbBuildQueryDesc(SQueryHbReqBasic *hbBasic, STscObj *pObj) { desc.subDesc = taosArrayInit(desc.subPlanNum, sizeof(SQuerySubDesc)); if (NULL == desc.subDesc) { releaseRequest(*rid); - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } code = schedulerGetTasksStatus(pRequest->body.queryJob, desc.subDesc); @@ -394,14 +394,14 @@ int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) { STscObj *pTscObj = (STscObj *)acquireTscObj(connKey->tscRid); if (NULL == pTscObj) { tscWarn("tscObj rid %" PRIx64 " not exist", connKey->tscRid); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } SQueryHbReqBasic *hbBasic = (SQueryHbReqBasic *)taosMemoryCalloc(1, sizeof(SQueryHbReqBasic)); if (NULL == hbBasic) { tscError("calloc %d failed", (int32_t)sizeof(SQueryHbReqBasic)); releaseTscObj(connKey->tscRid); - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } hbBasic->connId = pTscObj->connId; @@ -419,7 +419,7 @@ int32_t hbGetQueryBasicInfo(SClientHbKey *connKey, SClientHbReq *req) { tscWarn("taosArrayInit %d queryDesc failed", numOfQueries); releaseTscObj(connKey->tscRid); taosMemoryFree(hbBasic); - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } int32_t code = hbBuildQueryDesc(hbBasic, pTscObj); @@ -613,7 +613,7 @@ static FORCE_INLINE void hbMgrInitHandle() { SClientHbBatchReq *hbGatherAllInfo(SAppHbMgr *pAppHbMgr) { SClientHbBatchReq *pBatchReq = taosMemoryCalloc(1, sizeof(SClientHbBatchReq)); if (pBatchReq == NULL) { - terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } int32_t connKeyCnt = atomic_load_32(&pAppHbMgr->connKeyCnt); @@ -737,7 +737,7 @@ static void *hbThreadFunc(void *param) { int tlen = tSerializeSClientHbBatchReq(NULL, 0, pReq); void *buf = taosMemoryMalloc(tlen); if (buf == NULL) { - terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; tFreeClientHbBatchReq(pReq); // hbClearReqInfo(pAppHbMgr); taosArrayPush(mgr, &pAppHbMgr); @@ -748,7 +748,7 @@ static void *hbThreadFunc(void *param) { SMsgSendInfo *pInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (pInfo == NULL) { - terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; tFreeClientHbBatchReq(pReq); // hbClearReqInfo(pAppHbMgr); taosMemoryFree(buf); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 846accf51b..e6584f4a00 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -166,7 +166,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param, tscError("0x%" PRIx64 " failed to prepare sql string buffer, %s", (*pRequest)->self, sql); destroyRequest(*pRequest); *pRequest = NULL; - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } strntolower((*pRequest)->sqlstr, sql, (int32_t)sqlLen); @@ -179,7 +179,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param, if (pParam == NULL) { destroyRequest(*pRequest); *pRequest = NULL; - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } tsem_init(&pParam->sem, 0, 0); @@ -198,7 +198,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param, taosMemoryFree(param); destroyRequest(*pRequest); *pRequest = NULL; - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } (*pRequest)->allocatorRefId = -1; @@ -209,7 +209,7 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param, (*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql); destroyRequest(*pRequest); *pRequest = NULL; - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } } @@ -317,7 +317,7 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { tscError("0x%" PRIx64 " fetch results failed, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(code), pRequest->requestId); } else { - tscDebug("0x%" PRIx64 " fetch results, numOfRows:%d total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64, + tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64, pRequest->self, pResultInfo->numOfRows, pResultInfo->totalRows, pResultInfo->completed, pRequest->requestId); } @@ -609,7 +609,7 @@ int32_t buildAsyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray } default: tscError("unknown query policy: %d", tsQueryPolicy); - return TSDB_CODE_TSC_APP_ERROR; + return TSDB_CODE_APP_ERROR; } taosArrayDestroy(pDbVgList); @@ -670,7 +670,7 @@ int32_t buildSyncExecNodeList(SRequestObj* pRequest, SArray** pNodeList, SArray* } default: tscError("unknown query policy: %d", tsQueryPolicy); - return TSDB_CODE_TSC_APP_ERROR; + return TSDB_CODE_APP_ERROR; } _return: @@ -1136,7 +1136,7 @@ int32_t refreshMeta(STscObj* pTscObj, SRequestObj* pRequest) { int32_t tblNum = taosArrayGetSize(pRequest->tableList); if (dbNum <= 0 && tblNum <= 0) { - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog); @@ -1231,7 +1231,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t SAppInstInfo* pAppInfo, int connType) { STscObj* pTscObj = createTscObj(user, auth, db, connType, pAppInfo); if (NULL == pTscObj) { - terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return pTscObj; } @@ -1268,7 +1268,7 @@ STscObj* taosConnectImpl(const char* user, const char* auth, const char* db, __t static SMsgSendInfo* buildConnectMsg(SRequestObj* pRequest) { SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (pMsgSendInfo == NULL) { - terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } @@ -1527,7 +1527,7 @@ void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4) return NULL; } - tscDebug("0x%" PRIx64 " fetch results, numOfRows:%d total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64, + tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64, pRequest->self, pResInfo->numOfRows, pResInfo->totalRows, pResInfo->completed, pRequest->requestId); STscObj* pTscObj = pRequest->pTscObj; @@ -1941,7 +1941,7 @@ int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableR pResultInfo->pRspMsg = (const char*)pRsp; pResultInfo->pData = (void*)pRsp->data; - pResultInfo->numOfRows = htonl(pRsp->numOfRows); + pResultInfo->numOfRows = htobe64(pRsp->numOfRows); pResultInfo->current = 0; pResultInfo->completed = (pRsp->completed == 1); pResultInfo->payloadLen = htonl(pRsp->compLen); diff --git a/source/client/src/clientJniConnector.c b/source/client/src/clientJniConnector.c index b5a6ebadee..34fc480432 100644 --- a/source/client/src/clientJniConnector.c +++ b/source/client/src/clientJniConnector.c @@ -136,7 +136,7 @@ int32_t check_for_params(jobject jobj, jlong conn, jlong res) { } if ((TAOS_RES *)res == NULL) { - jniError("jobj:%p, conn:%p, res is null", jobj, (TAOS *)conn); + jniError("jobj:%p, conn:%p, param res is null", jobj, (TAOS *)conn); return JNI_RESULT_SET_NULL; } @@ -393,9 +393,8 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_freeResultSetImp( return code; } - taos_free_result((void *)res); jniDebug("jobj:%p, conn:%p, free resultset:%p", jobj, (TAOS *)con, (void *)res); - + taos_free_result((void *)res); return JNI_SUCCESS; } @@ -489,7 +488,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn numOfFields); return JNI_FETCH_END; } else { - jniDebug("jobj:%p, conn:%p, interrupted query", jobj, tscon); + jniDebug("jobj:%p, conn:%p, interrupted query. fetch row error code: %d, msg:%s", jobj, tscon, code, taos_errstr(result)); return JNI_RESULT_SET_NULL; } } @@ -584,7 +583,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchBlockImp(JNI jniDebug("jobj:%p, conn:%p, resultset:%p, no data to retrieve", jobj, tscon, (void *)res); return JNI_FETCH_END; } else { - jniError("jobj:%p, conn:%p, query interrupted", jobj, tscon); + jniError("jobj:%p, conn:%p, query interrupted. fetch block error code:%d, msg:%s", jobj, tscon, error_code, taos_errstr(tres)); return JNI_RESULT_SET_NULL; } } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 976d1dd1b0..9f3c78aba2 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -146,7 +146,6 @@ void taos_close(TAOS *taos) { int taos_errno(TAOS_RES *res) { if (res == NULL || TD_RES_TMQ_META(res)) { - if (terrno == TSDB_CODE_RPC_REDIRECT) terrno = TSDB_CODE_QRY_NOT_READY; return terrno; } @@ -154,12 +153,11 @@ int taos_errno(TAOS_RES *res) { return 0; } - return ((SRequestObj *)res)->code == TSDB_CODE_RPC_REDIRECT ? TSDB_CODE_QRY_NOT_READY : ((SRequestObj *)res)->code; + return ((SRequestObj *)res)->code; } const char *taos_errstr(TAOS_RES *res) { if (res == NULL || TD_RES_TMQ_META(res)) { - if (terrno == TSDB_CODE_RPC_REDIRECT) terrno = TSDB_CODE_QRY_NOT_READY; return (const char *)tstrerror(terrno); } @@ -171,8 +169,7 @@ const char *taos_errstr(TAOS_RES *res) { if (NULL != pRequest->msgBuf && (strlen(pRequest->msgBuf) > 0 || pRequest->code == TSDB_CODE_RPC_FQDN_ERROR)) { return pRequest->msgBuf; } else { - return pRequest->code == TSDB_CODE_RPC_REDIRECT ? (const char *)tstrerror(TSDB_CODE_QRY_NOT_READY) - : (const char *)tstrerror(pRequest->code); + return (const char *)tstrerror(pRequest->code); } } @@ -438,11 +435,23 @@ const char *taos_data_type(int type) { const char *taos_get_client_info() { return version; } +// return int32_t int taos_affected_rows(TAOS_RES *res) { if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res)) { return 0; } + SRequestObj *pRequest = (SRequestObj *)res; + SReqResultInfo *pResInfo = &pRequest->body.resInfo; + return (int)pResInfo->numOfRows; +} + +// return int64_t +int64_t taos_affected_rows64(TAOS_RES *res) { + if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res) || TD_RES_TMQ_METADATA(res)) { + return 0; + } + SRequestObj *pRequest = (SRequestObj *)res; SReqResultInfo *pResInfo = &pRequest->body.resInfo; return pResInfo->numOfRows; @@ -959,7 +968,7 @@ static void fetchCallback(void *pResult, void *param, int32_t code) { tscError("0x%" PRIx64 " fetch results failed, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(code), pRequest->requestId); } else { - tscDebug("0x%" PRIx64 " fetch results, numOfRows:%d total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64, + tscDebug("0x%" PRIx64 " fetch results, numOfRows:%" PRId64 " total Rows:%" PRId64 ", complete:%d, reqId:0x%" PRIx64, pRequest->self, pResultInfo->numOfRows, pResultInfo->totalRows, pResultInfo->completed, pRequest->requestId); diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 4bd74a842f..85027ff371 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -86,7 +86,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { /*assert(connectRsp.epSet.numOfEps > 0);*/ if (connectRsp.epSet.numOfEps == 0) { - setErrno(pRequest, TSDB_CODE_MND_APP_ERROR); + setErrno(pRequest, TSDB_CODE_APP_ERROR); tsem_post(&pRequest->body.rspSem); goto End; } @@ -450,7 +450,7 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) { (*pRsp)->precision = 0; (*pRsp)->compressed = 0; (*pRsp)->compLen = 0; - (*pRsp)->numOfRows = htonl(pBlock->info.rows); + (*pRsp)->numOfRows = htobe64((int64_t)pBlock->info.rows); (*pRsp)->numOfCols = htonl(SHOW_VARIABLES_RESULT_COLS); int32_t len = blockEncode(pBlock, (*pRsp)->data, SHOW_VARIABLES_RESULT_COLS); diff --git a/source/client/src/clientRawBlockWrite.c b/source/client/src/clientRawBlockWrite.c index 5583c8ae00..150194aa27 100644 --- a/source/client/src/clientRawBlockWrite.c +++ b/source/client/src/clientRawBlockWrite.c @@ -1388,7 +1388,7 @@ int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const ch SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == dst) { - code = TSDB_CODE_TSC_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto end; } dst->vg = vgData; @@ -1579,7 +1579,7 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname) SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == dst) { - code = TSDB_CODE_TSC_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto end; } dst->vg = vgData; @@ -1726,7 +1726,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { int32_t totalLen = ((SSubmitReq*)(vgData.data))->length + submitLen; void* tmp = taosMemoryRealloc(vgData.data, totalLen); if (tmp == NULL) { - code = TSDB_CODE_TSC_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto end; } vgData.data = tmp; @@ -1737,7 +1737,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { int32_t totalLen = sizeof(SSubmitReq) + submitLen; void* tmp = taosMemoryCalloc(1, totalLen); if (tmp == NULL) { - code = TSDB_CODE_TSC_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto end; } vgData.data = tmp; @@ -1840,7 +1840,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { while (vData) { SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == dst) { - code = TSDB_CODE_TSC_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto end; } dst->vg = vData->vg; @@ -2029,7 +2029,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) int32_t totalLen = ((SSubmitReq*)(vgData.data))->length + submitLen; void* tmp = taosMemoryRealloc(vgData.data, totalLen); if (tmp == NULL) { - code = TSDB_CODE_TSC_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto end; } vgData.data = tmp; @@ -2040,7 +2040,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) int32_t totalLen = sizeof(SSubmitReq) + submitLen; void* tmp = taosMemoryCalloc(1, totalLen); if (tmp == NULL) { - code = TSDB_CODE_TSC_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto end; } vgData.data = tmp; @@ -2146,7 +2146,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) while (vData) { SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == dst) { - code = TSDB_CODE_TSC_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto end; } dst->vg = vData->vg; diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index d811eb7fec..a4e943da32 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -139,6 +139,8 @@ typedef struct { int32_t numOfSTables; int32_t numOfCTables; int32_t numOfCreateSTables; + int32_t numOfAlterColSTables; + int32_t numOfAlterTagSTables; int64_t parseTime; int64_t schemaTime; @@ -512,6 +514,7 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { goto end; } + info->cost.numOfAlterTagSTables++; taosMemoryFreeClear(pTableMeta); code = catalogRefreshTableMeta(info->pCatalog, &conn, &pName, -1); if (code != TSDB_CODE_SUCCESS) { @@ -559,6 +562,8 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { goto end; } + info->cost.numOfAlterColSTables++; + taosMemoryFreeClear(pTableMeta); code = catalogRefreshTableMeta(info->pCatalog, &conn, &pName, -1); if (code != TSDB_CODE_SUCCESS) { goto end; @@ -820,11 +825,6 @@ static int8_t smlGetTsTypeByPrecision(int8_t precision) { } static int64_t smlParseInfluxTime(SSmlHandle *info, const char *data, int32_t len) { - void *tmp = taosMemoryCalloc(1, len + 1); - memcpy(tmp, data, len); - uDebug("SML:0x%" PRIx64 " smlParseInfluxTime tslen:%d, ts:%s", info->id, len, (char*)tmp); - taosMemoryFree(tmp); - if (len == 0 || (len == 1 && data[0] == '0')) { return taosGetTimestampNs(); } @@ -877,7 +877,10 @@ static int32_t smlParseTS(SSmlHandle *info, const char *data, int32_t len, SArra } uDebug("SML:0x%" PRIx64 " smlParseTS:%" PRId64, info->id, ts); - if (ts == -1) return TSDB_CODE_INVALID_TIMESTAMP; + if (ts <= 0) { + uError("SML:0x%" PRIx64 " smlParseTS error:%" PRId64, info->id, ts); + return TSDB_CODE_INVALID_TIMESTAMP; + } // add ts to SSmlKv *kv = (SSmlKv *)taosMemoryCalloc(sizeof(SSmlKv), 1); @@ -1414,7 +1417,7 @@ static int32_t smlDealCols(SSmlTableInfo *oneTable, bool dataFormat, SArray *col SHashObj *kvHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); if (!kvHash) { uError("SML:smlDealCols failed to allocate memory"); - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } for (size_t i = 0; i < taosArrayGetSize(cols); i++) { SSmlKv *kv = (SSmlKv *)taosArrayGetP(cols, i); @@ -2076,10 +2079,7 @@ static int32_t smlParseJSONString(SSmlHandle *info, cJSON *root, SSmlTableInfo * static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql, const int len) { SSmlLineInfo elements = {0}; - void *tmp = taosMemoryCalloc(1, len + 1); - memcpy(tmp, sql, len); - uDebug("SML:0x%" PRIx64 " smlParseInfluxLine raw:%d, len:%d, sql:%s", info->id, info->isRawLine, len, (info->isRawLine ? (char*)tmp : sql)); - taosMemoryFree(tmp); + uDebug("SML:0x%" PRIx64 " smlParseInfluxLine raw:%d, len:%d, sql:%s", info->id, info->isRawLine, len, (info->isRawLine ? "rawdata" : sql)); int ret = smlParseInfluxString(sql, sql + len, &elements, &info->msgBuf); if (ret != TSDB_CODE_SUCCESS) { @@ -2092,7 +2092,7 @@ static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql, const int l cols = taosArrayInit(16, POINTER_BYTES); if (cols == NULL) { uError("SML:0x%" PRIx64 " smlParseInfluxLine failed to allocate memory", info->id); - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } } else { // if dataFormat is false, cols do not need to save data, there is another new memory to save data cols = info->colsContainer; @@ -2121,7 +2121,7 @@ static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql, const int l if (!tinfo) { smlDestroyCols(cols); if (info->dataFormat) taosArrayDestroy(cols); - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } taosHashPut(info->childTables, elements.measure, elements.measureTagsLen, &tinfo, POINTER_BYTES); oneTable = &tinfo; @@ -2192,13 +2192,13 @@ static int32_t smlParseTelnetLine(SSmlHandle *info, void *data, const int len) { int ret = TSDB_CODE_SUCCESS; SSmlTableInfo *tinfo = smlBuildTableInfo(); if (!tinfo) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } SArray *cols = taosArrayInit(16, POINTER_BYTES); if (cols == NULL) { uError("SML:0x%" PRIx64 " smlParseTelnetLine failed to allocate memory", info->id); - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } if (info->protocol == TSDB_SML_TELNET_PROTOCOL) { @@ -2372,11 +2372,12 @@ static int32_t smlInsertData(SSmlHandle *info) { static void smlPrintStatisticInfo(SSmlHandle *info) { uError("SML:0x%" PRIx64 - " smlInsertLines result, code:%d,lineNum:%d,stable num:%d,ctable num:%d,create stable num:%d \ + " smlInsertLines result, code:%d,lineNum:%d,stable num:%d,ctable num:%d,create stable num:%d,alter stable tag num:%d,alter stable col num:%d \ parse cost:%" PRId64 ",schema cost:%" PRId64 ",bind cost:%" PRId64 ",rpc cost:%" PRId64 ",total cost:%" PRId64 "", info->id, info->cost.code, info->cost.lineNum, info->cost.numOfSTables, info->cost.numOfCTables, - info->cost.numOfCreateSTables, info->cost.schemaTime - info->cost.parseTime, + info->cost.numOfCreateSTables, info->cost.numOfAlterTagSTables, info->cost.numOfAlterColSTables, + info->cost.schemaTime - info->cost.parseTime, info->cost.insertBindTime - info->cost.schemaTime, info->cost.insertRpcTime - info->cost.insertBindTime, info->cost.endTime - info->cost.insertRpcTime, info->cost.endTime - info->cost.parseTime); } diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c index 291e0f6ae3..82ea9e0d8f 100644 --- a/source/client/src/clientStmt.c +++ b/source/client/src/clientStmt.c @@ -83,7 +83,7 @@ int32_t stmtSwitchStatus(STscStmt* pStmt, STMT_STATUS newStatus) { } break; default: - code = TSDB_CODE_TSC_APP_ERROR; + code = TSDB_CODE_APP_ERROR; break; } @@ -118,7 +118,7 @@ int32_t stmtBackupQueryFields(STscStmt* pStmt) { pRes->fields = taosMemoryMalloc(size); pRes->userFields = taosMemoryMalloc(size); if (NULL == pRes->fields || NULL == pRes->userFields) { - STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY); + STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } memcpy(pRes->fields, pStmt->exec.pRequest->body.resInfo.fields, size); memcpy(pRes->userFields, pStmt->exec.pRequest->body.resInfo.userFields, size); @@ -136,7 +136,7 @@ int32_t stmtRestoreQueryFields(STscStmt* pStmt) { if (NULL == pStmt->exec.pRequest->body.resInfo.fields) { pStmt->exec.pRequest->body.resInfo.fields = taosMemoryMalloc(size); if (NULL == pStmt->exec.pRequest->body.resInfo.fields) { - STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY); + STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } memcpy(pStmt->exec.pRequest->body.resInfo.fields, pRes->fields, size); } @@ -144,7 +144,7 @@ int32_t stmtRestoreQueryFields(STscStmt* pStmt) { if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) { pStmt->exec.pRequest->body.resInfo.userFields = taosMemoryMalloc(size); if (NULL == pStmt->exec.pRequest->body.resInfo.userFields) { - STMT_ERR_RET(TSDB_CODE_TSC_OUT_OF_MEMORY); + STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } memcpy(pStmt->exec.pRequest->body.resInfo.userFields, pRes->userFields, size); } @@ -463,7 +463,7 @@ int32_t stmtGetFromCache(STscStmt* pStmt) { tscError("table [%s, %" PRIx64 ", %" PRIx64 "] found in exec blockHash, but not in sql blockHash", pStmt->bInfo.tbFName, uid, cacheUid); - STMT_ERR_RET(TSDB_CODE_TSC_APP_ERROR); + STMT_ERR_RET(TSDB_CODE_APP_ERROR); } pStmt->bInfo.needParse = false; @@ -512,7 +512,7 @@ int32_t stmtResetStmt(STscStmt* pStmt) { pStmt->sql.pTableCache = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); if (NULL == pStmt->sql.pTableCache) { - terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; STMT_ERR_RET(terrno); } @@ -527,13 +527,13 @@ TAOS_STMT* stmtInit(STscObj* taos, int64_t reqid) { pStmt = taosMemoryCalloc(1, sizeof(STscStmt)); if (NULL == pStmt) { - terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } pStmt->sql.pTableCache = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); if (NULL == pStmt->sql.pTableCache) { - terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; taosMemoryFree(pStmt); return NULL; } @@ -618,7 +618,7 @@ int stmtSetTbTags(TAOS_STMT* stmt, TAOS_MULTI_BIND* tags) { (STableDataBlocks**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName)); if (NULL == pDataBlock) { tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName); - STMT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + STMT_ERR_RET(TSDB_CODE_APP_ERROR); } tscDebug("start to bind stmt tag values"); @@ -641,7 +641,7 @@ int stmtFetchTagFields(STscStmt* pStmt, int32_t* fieldNum, TAOS_FIELD_E** fields (STableDataBlocks**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName)); if (NULL == pDataBlock) { tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName); - STMT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + STMT_ERR_RET(TSDB_CODE_APP_ERROR); } STMT_ERR_RET(qBuildStmtTagFields(*pDataBlock, pStmt->bInfo.boundTags, fieldNum, fields)); @@ -659,7 +659,7 @@ int stmtFetchColFields(STscStmt* pStmt, int32_t* fieldNum, TAOS_FIELD_E** fields (STableDataBlocks**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName)); if (NULL == pDataBlock) { tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName); - STMT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + STMT_ERR_RET(TSDB_CODE_APP_ERROR); } STMT_ERR_RET(qBuildStmtColFields(*pDataBlock, fieldNum, fields)); @@ -733,7 +733,7 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) { (STableDataBlocks**)taosHashGet(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName)); if (NULL == pDataBlock) { tscError("table %s not found in exec blockHash", pStmt->bInfo.tbFName); - STMT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + STMT_ERR_RET(TSDB_CODE_APP_ERROR); } if (colIdx < 0) { @@ -745,7 +745,7 @@ int stmtBindBatch(TAOS_STMT* stmt, TAOS_MULTI_BIND* bind, int32_t colIdx) { } else { if (colIdx != (pStmt->bInfo.sBindLastIdx + 1) && colIdx != 0) { tscError("bind column index not in sequence"); - STMT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + STMT_ERR_RET(TSDB_CODE_APP_ERROR); } pStmt->bInfo.sBindLastIdx = colIdx; @@ -897,7 +897,7 @@ _return: if (TSDB_CODE_SUCCESS == code && autoCreateTbl) { if (NULL == pRsp) { tscError("no submit resp got for auto create table"); - code = TSDB_CODE_TSC_APP_ERROR; + code = TSDB_CODE_APP_ERROR; } else { code = stmtUpdateTableUid(pStmt, pRsp); } diff --git a/source/client/src/clientTmqConnector.c b/source/client/src/clientTmqConnector.c index 42988b16fe..ccfc4980bc 100644 --- a/source/client/src/clientTmqConnector.c +++ b/source/client/src/clientTmqConnector.c @@ -303,7 +303,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_fetchRawBlockImp( jniDebug("jobj:%p, conn:%p, resultset:%p, no data to retrieve", jobj, tscon, (void *)res); return JNI_FETCH_END; } else { - jniError("jobj:%p, conn:%p, query interrupted", jobj, tscon); + jniError("jobj:%p, conn:%p, query interrupted, tmq fetch block error code:%d, msg:%s", jobj, tscon, error_code, taos_errstr(tres)); return JNI_RESULT_SET_NULL; } } diff --git a/source/common/src/systable.c b/source/common/src/systable.c index 1255116d0c..60a673ef9c 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -273,6 +273,12 @@ static const SSysDbTableSchema vnodesSchema[] = { {.name = "dnode_ep", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, }; +static const SSysDbTableSchema userUserPrivilegesSchema[] = { + {.name = "user_name", .bytes = TSDB_USER_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "privilege", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "object_name", .bytes = TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, +}; + static const SSysTableMeta infosMeta[] = { {TSDB_INS_TABLE_DNODES, dnodesSchema, tListLen(dnodesSchema), true}, {TSDB_INS_TABLE_MNODES, mnodesSchema, tListLen(mnodesSchema), true}, @@ -297,6 +303,7 @@ static const SSysTableMeta infosMeta[] = { {TSDB_INS_TABLE_STREAMS, streamSchema, tListLen(streamSchema), false}, {TSDB_INS_TABLE_STREAM_TASKS, streamTaskSchema, tListLen(streamTaskSchema), false}, {TSDB_INS_TABLE_VNODES, vnodesSchema, tListLen(vnodesSchema), true}, + {TSDB_INS_TABLE_USER_PRIVILEGES, userUserPrivilegesSchema, tListLen(userUserPrivilegesSchema), false}, }; static const SSysDbTableSchema connectionsSchema[] = { diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index a4a185e5ee..dfd0b68039 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -19,7 +19,7 @@ #include "tlog.h" #include "tname.h" -#define MALLOC_ALIGN_BYTES 32 +#define MALLOC_ALIGN_BYTES 256 int32_t colDataGetLength(const SColumnInfoData* pColumnInfoData, int32_t numOfRows) { ASSERT(pColumnInfoData != NULL); @@ -1137,14 +1137,15 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF } void blockDataCleanup(SSDataBlock* pDataBlock) { + blockDataEmpty(pDataBlock); SDataBlockInfo* pInfo = &pDataBlock->info; - - pInfo->rows = 0; pInfo->id.uid = 0; pInfo->id.groupId = 0; - pInfo->window.ekey = 0; - pInfo->window.skey = 0; +} +void blockDataEmpty(SSDataBlock* pDataBlock) { + SDataBlockInfo* pInfo = &pDataBlock->info; + ASSERT(pInfo->rows <= pDataBlock->info.capacity); if (pInfo->capacity == 0) { return; } @@ -1154,6 +1155,10 @@ void blockDataCleanup(SSDataBlock* pDataBlock) { SColumnInfoData* p = taosArrayGet(pDataBlock->pDataBlock, i); colInfoDataCleanup(p, pInfo->capacity); } + + pInfo->rows = 0; + pInfo->window.ekey = 0; + pInfo->window.skey = 0; } // todo temporarily disable it @@ -1186,7 +1191,6 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo* int32_t oldLen = BitmapLen(existedRows); pColumn->nullbitmap = tmp; memset(&pColumn->nullbitmap[oldLen], 0, BitmapLen(numOfRows) - oldLen); - ASSERT(pColumn->info.bytes); // make sure the allocated memory is MALLOC_ALIGN_BYTES aligned @@ -1202,6 +1206,12 @@ static int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo* } pColumn->pData = tmp; + + // todo remove it soon +#if defined LINUX + ASSERT((((uint64_t)pColumn->pData) & (MALLOC_ALIGN_BYTES - 1)) == 0x0); +#endif + if (clearPayload) { memset(tmp + pColumn->info.bytes * existedRows, 0, pColumn->info.bytes * (numOfRows - existedRows)); } @@ -1249,6 +1259,25 @@ int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows) { return TSDB_CODE_SUCCESS; } +int32_t blockDataEnsureCapacityNoClear(SSDataBlock* pDataBlock, uint32_t numOfRows) { + int32_t code = 0; + if (numOfRows == 0 || numOfRows <= pDataBlock->info.capacity) { + return TSDB_CODE_SUCCESS; + } + + size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock); + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData* p = taosArrayGet(pDataBlock->pDataBlock, i); + code = doEnsureCapacity(p, &pDataBlock->info, numOfRows, false); + if (code) { + return code; + } + } + + pDataBlock->info.capacity = numOfRows; + return TSDB_CODE_SUCCESS; +} + void blockDataFreeRes(SSDataBlock* pBlock) { int32_t numOfOutput = taosArrayGetSize(pBlock->pDataBlock); for (int32_t i = 0; i < numOfOutput; ++i) { @@ -1621,6 +1650,8 @@ static int32_t colDataMoveVarData(SColumnInfoData* pColInfoData, size_t start, s static void colDataTrimFirstNRows(SColumnInfoData* pColInfoData, size_t n, size_t total) { if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) { pColInfoData->varmeta.length = colDataMoveVarData(pColInfoData, n, total); + + // clear the offset value of the unused entries. memset(&pColInfoData->varmeta.offset[total - n], 0, n); } else { int32_t bytes = pColInfoData->info.bytes; @@ -1635,7 +1666,7 @@ int32_t blockDataTrimFirstNRows(SSDataBlock* pBlock, size_t n) { } if (pBlock->info.rows <= n) { - blockDataCleanup(pBlock); + blockDataEmpty(pBlock); } else { size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); for (int32_t i = 0; i < numOfCols; ++i) { @@ -1652,12 +1683,22 @@ static void colDataKeepFirstNRows(SColumnInfoData* pColInfoData, size_t n, size_ if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) { pColInfoData->varmeta.length = colDataMoveVarData(pColInfoData, 0, n); memset(&pColInfoData->varmeta.offset[n], 0, total - n); + } else { // reset the bitmap value + /*int32_t stopIndex = BitmapLen(n) * 8; + for(int32_t i = n; i < stopIndex; ++i) { + colDataClearNull_f(pColInfoData->nullbitmap, i); + } + + int32_t remain = BitmapLen(total) - BitmapLen(n); + if (remain > 0) { + memset(pColInfoData->nullbitmap+BitmapLen(n), 0, remain); + }*/ } } int32_t blockDataKeepFirstNRows(SSDataBlock* pBlock, size_t n) { if (n == 0) { - blockDataCleanup(pBlock); + blockDataEmpty(pBlock); return TSDB_CODE_SUCCESS; } diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 728f669fc8..fc49c03379 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -518,7 +518,7 @@ int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter) { SRowIter *pIter = taosMemoryCalloc(1, sizeof(*pIter)); if (pIter == NULL) { - code = TSDB_CODE_TDB_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; } diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index ab46ba24cf..3bcfddb8b2 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -55,6 +55,11 @@ int32_t tsNumOfQnodeFetchThreads = 1; int32_t tsNumOfSnodeStreamThreads = 4; int32_t tsNumOfSnodeWriteThreads = 1; +// sync raft +int32_t tsElectInterval = 25 * 1000; +int32_t tsHeartbeatInterval = 1000; +int32_t tsHeartbeatTimeout = 20 * 1000; + // monitor bool tsEnableMonitor = true; int32_t tsMonitorInterval = 30; @@ -74,8 +79,8 @@ char tsSmlTagName[TSDB_COL_NAME_LEN] = "_tag_null"; char tsSmlChildTableName[TSDB_TABLE_NAME_LEN] = ""; // user defined child table name can be specified in tag value. // If set to empty system will generate table name using MD5 hash. // true means that the name and order of cols in each line are the same(only for influx protocol) -bool tsSmlDataFormat = false; -int32_t tsSmlBatchSize = 10000; +bool tsSmlDataFormat = false; +int32_t tsSmlBatchSize = 10000; // query int32_t tsQueryPolicy = 1; @@ -167,6 +172,7 @@ int64_t tsWalFsyncDataSizeLimit = (100 * 1024 * 1024L); // internal int32_t tsTransPullupInterval = 2; int32_t tsMqRebalanceInterval = 2; +int32_t tsStreamCheckpointTickInterval = 1; int32_t tsTtlUnit = 86400; int32_t tsTtlPushInterval = 86400; int32_t tsGrantHBInterval = 60; @@ -197,9 +203,7 @@ int32_t taosSetTfsCfg(SConfig *pCfg) { int32_t taosSetTfsCfg(SConfig *pCfg); #endif -struct SConfig *taosGetCfg() { - return tsCfg; -} +struct SConfig *taosGetCfg() { return tsCfg; } static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *inputCfgDir, const char *envFile, char *apolloUrl) { @@ -422,6 +426,10 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddInt64(pCfg, "rpcQueueMemoryAllowed", tsRpcQueueMemoryAllowed, TSDB_MAX_MSG_SIZE * 10L, INT64_MAX, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "syncElectInterval", tsElectInterval, 10, 1000 * 60 * 24 * 2, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "syncHeartbeatInterval", tsHeartbeatInterval, 10, 1000 * 60 * 24 * 2, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "syncHeartbeatTimeout", tsHeartbeatTimeout, 10, 1000 * 60 * 24 * 2, 0) != 0) return -1; + if (cfgAddBool(pCfg, "monitor", tsEnableMonitor, 0) != 0) return -1; if (cfgAddInt32(pCfg, "monitorInterval", tsMonitorInterval, 1, 200000, 0) != 0) return -1; if (cfgAddString(pCfg, "monitorFqdn", tsMonitorFqdn, 0) != 0) return -1; @@ -727,6 +735,10 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tstrncpy(tsTelemServer, cfgGetItem(pCfg, "telemetryServer")->str, TSDB_FQDN_LEN); tsTelemPort = (uint16_t)cfgGetItem(pCfg, "telemetryPort")->i32; + tsElectInterval = cfgGetItem(pCfg, "syncElectInterval")->i32; + tsHeartbeatInterval = cfgGetItem(pCfg, "syncHeartbeatInterval")->i32; + tsHeartbeatTimeout = cfgGetItem(pCfg, "syncHeartbeatTimeout")->i32; + tsTransPullupInterval = cfgGetItem(pCfg, "transPullupInterval")->i32; tsMqRebalanceInterval = cfgGetItem(pCfg, "mqRebalanceInterval")->i32; tsTtlUnit = cfgGetItem(pCfg, "ttlUnit")->i32; @@ -736,6 +748,10 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsWalFsyncDataSizeLimit = cfgGetItem(pCfg, "walFsyncDataSizeLimit")->i64; + tsElectInterval = cfgGetItem(pCfg, "syncElectInterval")->i32; + tsHeartbeatInterval = cfgGetItem(pCfg, "syncHeartbeatInterval")->i32; + tsHeartbeatTimeout = cfgGetItem(pCfg, "syncHeartbeatTimeout")->i32; + tsStartUdfd = cfgGetItem(pCfg, "udf")->bval; tstrncpy(tsUdfdResFuncs, cfgGetItem(pCfg, "udfdResFuncs")->str, sizeof(tsUdfdResFuncs)); tstrncpy(tsUdfdLdLibPath, cfgGetItem(pCfg, "udfdLdLibPath")->str, sizeof(tsUdfdLdLibPath)); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index c7e98415d1..5b16a55ae3 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -992,15 +992,20 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { if (tEncodeI32(&encoder, vlen) < 0) return -1; for (int32_t i = 0; i < vlen; ++i) { SVnodeLoad *pload = taosArrayGet(pReq->pVloads, i); + int64_t reserved = 0; if (tEncodeI32(&encoder, pload->vgId) < 0) return -1; if (tEncodeI8(&encoder, pload->syncState) < 0) return -1; if (tEncodeI8(&encoder, pload->syncRestore) < 0) return -1; + if (tEncodeI8(&encoder, pload->syncCanRead) < 0) return -1; if (tEncodeI64(&encoder, pload->cacheUsage) < 0) return -1; if (tEncodeI64(&encoder, pload->numOfTables) < 0) return -1; if (tEncodeI64(&encoder, pload->numOfTimeSeries) < 0) return -1; if (tEncodeI64(&encoder, pload->totalStorage) < 0) return -1; if (tEncodeI64(&encoder, pload->compStorage) < 0) return -1; if (tEncodeI64(&encoder, pload->pointsWritten) < 0) return -1; + if (tEncodeI64(&encoder, reserved) < 0) return -1; + if (tEncodeI64(&encoder, reserved) < 0) return -1; + if (tEncodeI64(&encoder, reserved) < 0) return -1; } // mnode loads @@ -1065,15 +1070,20 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { for (int32_t i = 0; i < vlen; ++i) { SVnodeLoad vload = {0}; + int64_t reserved = 0; if (tDecodeI32(&decoder, &vload.vgId) < 0) return -1; if (tDecodeI8(&decoder, &vload.syncState) < 0) return -1; if (tDecodeI8(&decoder, &vload.syncRestore) < 0) return -1; + if (tDecodeI8(&decoder, &vload.syncCanRead) < 0) return -1; if (tDecodeI64(&decoder, &vload.cacheUsage) < 0) return -1; if (tDecodeI64(&decoder, &vload.numOfTables) < 0) return -1; if (tDecodeI64(&decoder, &vload.numOfTimeSeries) < 0) return -1; if (tDecodeI64(&decoder, &vload.totalStorage) < 0) return -1; if (tDecodeI64(&decoder, &vload.compStorage) < 0) return -1; if (tDecodeI64(&decoder, &vload.pointsWritten) < 0) return -1; + if (tDecodeI64(&decoder, &reserved) < 0) return -1; + if (tDecodeI64(&decoder, &reserved) < 0) return -1; + if (tDecodeI64(&decoder, &reserved) < 0) return -1; if (taosArrayPush(pReq->pVloads, &vload) == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; @@ -1288,7 +1298,7 @@ int32_t tSerializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq) if (tEncodeI8(&encoder, pReq->enable) < 0) return -1; if (tEncodeCStr(&encoder, pReq->user) < 0) return -1; if (tEncodeCStr(&encoder, pReq->pass) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->dbname) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->objname) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -1307,7 +1317,7 @@ int32_t tDeserializeSAlterUserReq(void *buf, int32_t bufLen, SAlterUserReq *pReq if (tDecodeI8(&decoder, &pReq->enable) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->user) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->pass) < 0) return -1; - if (tDecodeCStrTo(&decoder, pReq->dbname) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->objname) < 0) return -1; tEndDecode(&decoder); tDecoderClear(&decoder); @@ -3738,6 +3748,31 @@ int32_t tDeserializeSMTimerMsg(void *buf, int32_t bufLen, SMTimerReq *pReq) { return 0; } +int32_t tSerializeSMStreamTickMsg(void *buf, int32_t bufLen, SMStreamTickReq *pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeI64(&encoder, pReq->tick) < 0) return -1; + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSMStreamTickMsg(void *buf, int32_t bufLen, SMStreamTickReq *pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->tick) < 0) return -1; + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + int32_t tEncodeSReplica(SEncoder *pEncoder, SReplica *pReplica) { if (tEncodeI32(pEncoder, pReplica->id) < 0) return -1; if (tEncodeU16(pEncoder, pReplica->port) < 0) return -1; diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c index 07a612bb35..30ef7b9542 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c @@ -144,6 +144,7 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { break; default: terrno = TSDB_CODE_MSG_NOT_PROCESSED; + dGError("msg:%p, not processed in mgmt queue", pMsg); break; } diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index ceb452c551..16fe6c1b91 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -196,7 +196,7 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, mmPutMsgToSyncCtrlQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, mmPutMsgToSyncCtrlQueue, 1) == NULL) goto _OVER; code = 0; diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c index d3d92e1bbf..857fbcbce5 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c @@ -61,7 +61,7 @@ static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) { pMsg->info.rsp = NULL; } - if (code == TSDB_CODE_RPC_REDIRECT) { + if (code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_SYN_RESTORING) { mndPostProcessQueryMsg(pMsg); } @@ -162,11 +162,13 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM); if (pMsg == NULL) return -1; memcpy(pMsg, pRpc, sizeof(SRpcMsg)); + pRpc->pCont = NULL; dTrace("msg:%p, is created and will put into %s queue, type:%s", pMsg, pWorker->name, TMSG_INFO(pRpc->msgType)); int32_t code = mmPutMsgToWorker(pMgmt, pWorker, pMsg); if (code != 0) { dTrace("msg:%p, is freed", pMsg); + rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); } return code; diff --git a/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c b/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c index edbe9882a4..3e5ad65db7 100644 --- a/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c +++ b/source/dnode/mgmt/mgmt_qnode/src/qmWorker.c @@ -61,6 +61,7 @@ int32_t qmPutRpcMsgToQueue(SQnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM); if (pMsg == NULL) return -1; memcpy(pMsg, pRpc, sizeof(SRpcMsg)); + pRpc->pCont = NULL; switch (qtype) { case QUERY_QUEUE: @@ -74,6 +75,7 @@ int32_t qmPutRpcMsgToQueue(SQnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { return 0; default: terrno = TSDB_CODE_INVALID_PARA; + rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); return -1; } diff --git a/source/dnode/mgmt/mgmt_snode/src/smWorker.c b/source/dnode/mgmt/mgmt_snode/src/smWorker.c index f6942c8114..2d2a121795 100644 --- a/source/dnode/mgmt/mgmt_snode/src/smWorker.c +++ b/source/dnode/mgmt/mgmt_snode/src/smWorker.c @@ -151,6 +151,7 @@ int32_t smPutMsgToQueue(SSnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { pHead->contLen = htonl(pHead->contLen); pHead->vgId = SNODE_HANDLE; memcpy(pMsg, pRpc, sizeof(SRpcMsg)); + pRpc->pCont = NULL; switch (qtype) { case STREAM_QUEUE: diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index 743beb7f82..bc46772858 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -216,7 +216,7 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { dDebug("vgId:%d, already exist", req.vgId); tFreeSCreateVnodeReq(&req); vmReleaseVnode(pMgmt, pVnode); - terrno = TSDB_CODE_NODE_ALREADY_DEPLOYED; + terrno = TSDB_CODE_VND_ALREADY_EXIST; code = terrno; return 0; } @@ -307,7 +307,7 @@ int32_t vmProcessAlterVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { SVnodeObj *pVnode = vmAcquireVnode(pMgmt, vgId); if (pVnode == NULL) { dError("vgId:%d, failed to alter replica since %s", vgId, terrstr()); - terrno = TSDB_CODE_NODE_NOT_DEPLOYED; + terrno = TSDB_CODE_VND_NOT_EXIST; return -1; } @@ -369,7 +369,7 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { SVnodeObj *pVnode = vmAcquireVnode(pMgmt, vgId); if (pVnode == NULL) { dDebug("vgId:%d, failed to drop since %s", vgId, terrstr()); - terrno = TSDB_CODE_NODE_NOT_DEPLOYED; + terrno = TSDB_CODE_VND_NOT_EXIST; return -1; } @@ -464,7 +464,7 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER; code = 0; diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index 4aa07cad98..08ea880b97 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c @@ -246,12 +246,12 @@ int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { pHead->contLen = htonl(pHead->contLen); pHead->vgId = htonl(pHead->vgId); memcpy(pMsg, pRpc, sizeof(SRpcMsg)); + pRpc->pCont = NULL; int32_t code = vmPutMsgToQueue(pMgmt, pMsg, qtype); if (code != 0) { dTrace("msg:%p, is freed", pMsg); rpcFreeCont(pMsg->pCont); - pRpc->pCont = NULL; taosFreeQitem(pMsg); } diff --git a/source/dnode/mgmt/node_mgmt/src/dmEnv.c b/source/dnode/mgmt/node_mgmt/src/dmEnv.c index 421d723202..e3bda5a3f0 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmEnv.c +++ b/source/dnode/mgmt/node_mgmt/src/dmEnv.c @@ -152,7 +152,19 @@ static int32_t dmProcessCreateNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) { SMgmtWrapper *pWrapper = dmAcquireWrapper(pDnode, ntype); if (pWrapper != NULL) { dmReleaseWrapper(pWrapper); - terrno = TSDB_CODE_NODE_ALREADY_DEPLOYED; + switch (ntype) { + case MNODE: + terrno = TSDB_CODE_MNODE_ALREADY_DEPLOYED; + break; + case QNODE: + terrno = TSDB_CODE_QNODE_ALREADY_DEPLOYED; + break; + case SNODE: + terrno = TSDB_CODE_SNODE_ALREADY_DEPLOYED; + break; + default: + terrno = TSDB_CODE_APP_ERROR; + } dError("failed to create node since %s", terrstr()); return -1; } @@ -191,7 +203,20 @@ static int32_t dmProcessDropNodeReq(EDndNodeType ntype, SRpcMsg *pMsg) { SMgmtWrapper *pWrapper = dmAcquireWrapper(pDnode, ntype); if (pWrapper == NULL) { - terrno = TSDB_CODE_NODE_NOT_DEPLOYED; + switch (ntype) { + case MNODE: + terrno = TSDB_CODE_MNODE_NOT_DEPLOYED; + break; + case QNODE: + terrno = TSDB_CODE_QNODE_NOT_DEPLOYED; + break; + case SNODE: + terrno = TSDB_CODE_SNODE_NOT_DEPLOYED; + break; + default: + terrno = TSDB_CODE_APP_ERROR; + } + dError("failed to drop node since %s", terrstr()); return -1; } diff --git a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c index 2c9020b668..02a268afda 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMgmt.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMgmt.c @@ -189,7 +189,6 @@ SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType ntype) { int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1); // dTrace("node:%s, is acquired, ref:%d", pWrapper->name, refCount); } else { - terrno = TSDB_CODE_NODE_NOT_DEPLOYED; pRetWrapper = NULL; } taosThreadRwlockUnlock(&pWrapper->lock); @@ -205,7 +204,20 @@ int32_t dmMarkWrapper(SMgmtWrapper *pWrapper) { int32_t refCount = atomic_add_fetch_32(&pWrapper->refCount, 1); // dTrace("node:%s, is marked, ref:%d", pWrapper->name, refCount); } else { - terrno = TSDB_CODE_NODE_NOT_DEPLOYED; + switch (pWrapper->ntype) { + case MNODE: + terrno = TSDB_CODE_MNODE_NOT_FOUND; + break; + case QNODE: + terrno = TSDB_CODE_QNODE_NOT_FOUND; + break; + case SNODE: + terrno = TSDB_CODE_SNODE_NOT_FOUND; + break; + default: + terrno = TSDB_CODE_APP_IS_STOPPING; + break; + } code = -1; } taosThreadRwlockUnlock(&pWrapper->lock); diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index 95656fd76c..12aba130d5 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -33,31 +33,16 @@ static inline void dmBuildMnodeRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg) { } } -static inline void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet) { - pMsg->info.hasEpSet = 1; - SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info, .msgType = pMsg->msgType}; - int32_t contLen = tSerializeSEpSet(NULL, 0, pNewEpSet); - - rsp.pCont = rpcMallocCont(contLen); - if (rsp.pCont == NULL) { - pMsg->code = TSDB_CODE_OUT_OF_MEMORY; - } else { - tSerializeSEpSet(rsp.pCont, contLen, pNewEpSet); - rsp.contLen = contLen; - } - dmSendRsp(&rsp); - rpcFreeCont(pMsg->pCont); - pMsg->pCont = NULL; -} - int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) { + const STraceId *trace = &pMsg->info.traceId; + NodeMsgFp msgFp = pWrapper->msgFps[TMSG_INDEX(pMsg->msgType)]; if (msgFp == NULL) { terrno = TSDB_CODE_MSG_NOT_PROCESSED; + dGError("msg:%p, not processed since no handler", pMsg); return -1; } - const STraceId *trace = &pMsg->info.traceId; dGTrace("msg:%p, will be processed by %s", pMsg, pWrapper->name); pMsg->info.wrapper = pWrapper; return (*msgFp)(pWrapper->pMgmt, pMsg); @@ -99,18 +84,23 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) { dmProcessServerStartupStatus(pDnode, pRpc); return; } else { - terrno = TSDB_CODE_APP_NOT_READY; + if (pDnode->status == DND_STAT_INIT) { + terrno = TSDB_CODE_APP_IS_STARTING; + } else { + terrno = TSDB_CODE_APP_IS_STOPPING; + } goto _OVER; } } - if (IsReq(pRpc) && pRpc->pCont == NULL) { + if (pRpc->pCont == NULL && (IsReq(pRpc) || pRpc->contLen != 0)) { dGError("msg:%p, type:%s pCont is NULL", pRpc, TMSG_INFO(pRpc->msgType)); terrno = TSDB_CODE_INVALID_MSG_LEN; goto _OVER; } if (pHandle->defaultNtype == NODE_END) { + dGError("msg:%p, type:%s not processed since no handle", pRpc, TMSG_INFO(pRpc->msgType)); terrno = TSDB_CODE_MSG_NOT_PROCESSED; goto _OVER; } @@ -165,8 +155,7 @@ _OVER: if (IsReq(pRpc)) { SRpcMsg rsp = {.code = code, .info = pRpc->info}; - if ((code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_APP_NOT_READY) && pRpc->msgType > TDMT_MND_MSG && - pRpc->msgType < TDMT_VND_MSG) { + if (code == TSDB_CODE_MNODE_NOT_FOUND) { dmBuildMnodeRedirectRsp(pDnode, &rsp); } @@ -219,7 +208,11 @@ static inline int32_t dmSendReq(const SEpSet *pEpSet, SRpcMsg *pMsg) { if (pDnode->status != DND_STAT_RUNNING && pMsg->msgType < TDMT_SYNC_MSG) { rpcFreeCont(pMsg->pCont); pMsg->pCont = NULL; - terrno = TSDB_CODE_NODE_OFFLINE; + if (pDnode->status == DND_STAT_INIT) { + terrno = TSDB_CODE_APP_IS_STARTING; + } else { + terrno = TSDB_CODE_APP_IS_STOPPING; + } dError("failed to send rpc msg:%s since %s, handle:%p", TMSG_INFO(pMsg->msgType), terrstr(), pMsg->info.handle); return -1; } else { @@ -233,8 +226,9 @@ static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) { rpcRegisterBrokenLin static inline void dmReleaseHandle(SRpcHandleInfo *pHandle, int8_t type) { rpcReleaseHandle(pHandle, type); } static bool rpcRfp(int32_t code, tmsg_t msgType) { - if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED || - code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY || code == TSDB_CODE_RPC_BROKEN_LINK) { + if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_MNODE_NOT_FOUND || + code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_VND_STOPPED || + code == TSDB_CODE_APP_IS_STARTING || code == TSDB_CODE_APP_IS_STOPPING) { if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH || msgType == TDMT_SCH_MERGE_FETCH) { return false; @@ -323,7 +317,6 @@ SMsgCb dmGetMsgcb(SDnode *pDnode) { .clientRpc = pDnode->trans.clientRpc, .sendReqFp = dmSendReq, .sendRspFp = dmSendRsp, - .sendRedirectRspFp = dmSendRedirectRsp, .registerBrokenLinkArgFp = dmRegisterBrokenLinkArg, .releaseHandleFp = dmReleaseHandle, .reportStartupFp = dmReportStartup, diff --git a/source/dnode/mgmt/node_util/inc/dmUtil.h b/source/dnode/mgmt/node_util/inc/dmUtil.h index 8719e988e7..2124b387ec 100644 --- a/source/dnode/mgmt/node_util/inc/dmUtil.h +++ b/source/dnode/mgmt/node_util/inc/dmUtil.h @@ -39,7 +39,7 @@ #include "sync.h" #include "wal.h" -#include "libs/function/function.h" +#include "libs/function/tudf.h" #ifdef __cplusplus extern "C" { #endif diff --git a/source/dnode/mgmt/test/mnode/dmnode.cpp b/source/dnode/mgmt/test/mnode/dmnode.cpp index 7b7eb97216..28cb376b37 100644 --- a/source/dnode/mgmt/test/mnode/dmnode.cpp +++ b/source/dnode/mgmt/test/mnode/dmnode.cpp @@ -40,7 +40,7 @@ TEST_F(DndTestMnode, 01_Create_Mnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_MNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_ALREADY_DEPLOYED); + ASSERT_EQ(pRsp->code, TSDB_CODE_MNODE_ALREADY_DEPLOYED); } { @@ -57,7 +57,7 @@ TEST_F(DndTestMnode, 01_Create_Mnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_MNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_ALREADY_DEPLOYED); + ASSERT_EQ(pRsp->code, TSDB_CODE_MNODE_ALREADY_DEPLOYED); } { @@ -77,7 +77,7 @@ TEST_F(DndTestMnode, 01_Create_Mnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_MNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_ALREADY_DEPLOYED); + ASSERT_EQ(pRsp->code, TSDB_CODE_MNODE_ALREADY_DEPLOYED); } } @@ -171,7 +171,7 @@ TEST_F(DndTestMnode, 03_Drop_Mnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_MNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED); + ASSERT_EQ(pRsp->code, TSDB_CODE_MNODE_NOT_DEPLOYED); } { @@ -188,7 +188,7 @@ TEST_F(DndTestMnode, 03_Drop_Mnode) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_MNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED); + ASSERT_EQ(pRsp->code, TSDB_CODE_MNODE_NOT_DEPLOYED); } { diff --git a/source/dnode/mgmt/test/qnode/dqnode.cpp b/source/dnode/mgmt/test/qnode/dqnode.cpp index a2c6a2c28c..3beb57c516 100644 --- a/source/dnode/mgmt/test/qnode/dqnode.cpp +++ b/source/dnode/mgmt/test/qnode/dqnode.cpp @@ -62,7 +62,7 @@ TEST_F(DndTestQnode, 01_Create_Qnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_ALREADY_DEPLOYED); + ASSERT_EQ(pRsp->code, TSDB_CODE_QNODE_ALREADY_DEPLOYED); } test.Restart(); @@ -77,7 +77,7 @@ TEST_F(DndTestQnode, 01_Create_Qnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_ALREADY_DEPLOYED); + ASSERT_EQ(pRsp->code, TSDB_CODE_QNODE_ALREADY_DEPLOYED); } } @@ -120,7 +120,7 @@ TEST_F(DndTestQnode, 02_Drop_Qnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED); + ASSERT_EQ(pRsp->code, TSDB_CODE_QNODE_NOT_DEPLOYED); } test.Restart(); @@ -135,7 +135,7 @@ TEST_F(DndTestQnode, 02_Drop_Qnode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_QNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED); + ASSERT_EQ(pRsp->code, TSDB_CODE_QNODE_NOT_DEPLOYED); } { diff --git a/source/dnode/mgmt/test/snode/dsnode.cpp b/source/dnode/mgmt/test/snode/dsnode.cpp index e3ad65d831..30d6a34813 100644 --- a/source/dnode/mgmt/test/snode/dsnode.cpp +++ b/source/dnode/mgmt/test/snode/dsnode.cpp @@ -62,7 +62,7 @@ TEST_F(DndTestSnode, 01_Create_Snode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_ALREADY_DEPLOYED); + ASSERT_EQ(pRsp->code, TSDB_CODE_SNODE_ALREADY_DEPLOYED); } test.Restart(); @@ -77,7 +77,7 @@ TEST_F(DndTestSnode, 01_Create_Snode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_CREATE_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_ALREADY_DEPLOYED); + ASSERT_EQ(pRsp->code, TSDB_CODE_SNODE_ALREADY_DEPLOYED); } } @@ -120,7 +120,7 @@ TEST_F(DndTestSnode, 01_Drop_Snode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED); + ASSERT_EQ(pRsp->code, TSDB_CODE_SNODE_NOT_DEPLOYED); } test.Restart(); @@ -135,7 +135,7 @@ TEST_F(DndTestSnode, 01_Drop_Snode) { SRpcMsg* pRsp = test.SendReq(TDMT_DND_DROP_SNODE, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED); + ASSERT_EQ(pRsp->code, TSDB_CODE_SNODE_NOT_DEPLOYED); } { diff --git a/source/dnode/mgmt/test/vnode/vnode.cpp b/source/dnode/mgmt/test/vnode/vnode.cpp index 8a8e332289..24e7affd88 100644 --- a/source/dnode/mgmt/test/vnode/vnode.cpp +++ b/source/dnode/mgmt/test/vnode/vnode.cpp @@ -63,7 +63,7 @@ TEST_F(DndTestVnode, 01_Create_Vnode) { ASSERT_EQ(pRsp->code, 0); test.Restart(); } else { - ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_ALREADY_DEPLOYED); + ASSERT_EQ(pRsp->code, TSDB_CODE_VND_ALREADY_EXIST); } } } @@ -285,7 +285,7 @@ TEST_F(DndTestVnode, 06_Drop_Vnode) { ASSERT_EQ(pRsp->code, 0); test.Restart(); } else { - ASSERT_EQ(pRsp->code, TSDB_CODE_NODE_NOT_DEPLOYED); + ASSERT_EQ(pRsp->code, TSDB_CODE_VND_NOT_EXIST); } } } \ No newline at end of file diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 04ac5aba49..9961828747 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -71,6 +71,9 @@ typedef enum { MND_OPER_READ_DB, MND_OPER_READ_OR_WRITE_DB, MND_OPER_SHOW_VARIBALES, + MND_OPER_SUBSCRIBE, + MND_OPER_CREATE_TOPIC, + MND_OPER_DROP_TOPIC, } EOperType; typedef enum { @@ -273,6 +276,7 @@ typedef struct { int32_t authVersion; SHashObj* readDbs; SHashObj* writeDbs; + SHashObj* topics; SRWLatch lock; } SUserObj; @@ -328,6 +332,7 @@ typedef struct { int32_t dnodeId; ESyncState syncState; bool syncRestore; + bool syncCanRead; } SVnodeGid; typedef struct { @@ -635,10 +640,14 @@ typedef struct { SArray* tasks; // SArray> SSchemaWrapper outputSchema; SSchemaWrapper tagSchema; + + // 3.0.20 + int64_t checkpointFreq; // ms + int64_t currentTick; // do not serialize } SStreamObj; int32_t tEncodeSStreamObj(SEncoder* pEncoder, const SStreamObj* pObj); -int32_t tDecodeSStreamObj(SDecoder* pDecoder, SStreamObj* pObj); +int32_t tDecodeSStreamObj(SDecoder* pDecoder, SStreamObj* pObj, int32_t sver); void tFreeStreamObj(SStreamObj* pObj); typedef struct { @@ -648,15 +657,6 @@ typedef struct { SArray* childInfo; // SArray } SStreamCheckpointObj; -#if 0 -typedef struct { - int64_t uid; - int64_t streamId; - int8_t status; - int8_t stage; -} SStreamRecoverObj; -#endif - #ifdef __cplusplus } #endif diff --git a/source/dnode/mnode/impl/inc/mndPrivilege.h b/source/dnode/mnode/impl/inc/mndPrivilege.h index dc88b25f51..dfde2f671e 100644 --- a/source/dnode/mnode/impl/inc/mndPrivilege.h +++ b/source/dnode/mnode/impl/inc/mndPrivilege.h @@ -28,6 +28,8 @@ void mndCleanupPrivilege(SMnode *pMnode); int32_t mndCheckOperPrivilege(SMnode *pMnode, const char *user, EOperType operType); int32_t mndCheckDbPrivilege(SMnode *pMnode, const char *user, EOperType operType, SDbObj *pDb); int32_t mndCheckDbPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *dbname); +int32_t mndCheckTopicPrivilege(SMnode *pMnode, const char *user, EOperType operType, SMqTopicObj *pTopic); +int32_t mndCheckTopicPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *topicName); int32_t mndCheckShowPrivilege(SMnode *pMnode, const char *user, EShowType showType, const char *dbname); int32_t mndCheckAlterUserPrivilege(SUserObj *pOperUser, SUserObj *pUser, SAlterUserReq *pAlter); int32_t mndSetUserAuthRsp(SMnode *pMnode, SUserObj *pUser, SGetUserAuthRsp *pRsp); diff --git a/source/dnode/mnode/impl/inc/mndTopic.h b/source/dnode/mnode/impl/inc/mndTopic.h index 9f516904ce..8cd669c769 100644 --- a/source/dnode/mnode/impl/inc/mndTopic.h +++ b/source/dnode/mnode/impl/inc/mndTopic.h @@ -25,7 +25,7 @@ extern "C" { int32_t mndInitTopic(SMnode *pMnode); void mndCleanupTopic(SMnode *pMnode); -SMqTopicObj *mndAcquireTopic(SMnode *pMnode, char *topicName); +SMqTopicObj *mndAcquireTopic(SMnode *pMnode, const char *topicName); void mndReleaseTopic(SMnode *pMnode, SMqTopicObj *pTopic); SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic); diff --git a/source/dnode/mnode/impl/inc/mndUser.h b/source/dnode/mnode/impl/inc/mndUser.h index 970d1db7db..cf7deba397 100644 --- a/source/dnode/mnode/impl/inc/mndUser.h +++ b/source/dnode/mnode/impl/inc/mndUser.h @@ -31,6 +31,7 @@ void mndReleaseUser(SMnode *pMnode, SUserObj *pUser); // for trans test SSdbRaw *mndUserActionEncode(SUserObj *pUser); SHashObj *mndDupDbHash(SHashObj *pOld); +SHashObj *mndDupTopicHash(SHashObj *pOld); int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int32_t numOfUses, void **ppRsp, int32_t *pRspLen); diff --git a/source/dnode/mnode/impl/src/mndAcct.c b/source/dnode/mnode/impl/src/mndAcct.c index ffa5dc6d0b..148e21b507 100644 --- a/source/dnode/mnode/impl/src/mndAcct.c +++ b/source/dnode/mnode/impl/src/mndAcct.c @@ -147,6 +147,8 @@ _OVER: static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; + SAcctObj *pAcct = NULL; + SSdbRow *pRow = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; @@ -156,10 +158,10 @@ static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw) { goto _OVER; } - SSdbRow *pRow = sdbAllocRow(sizeof(SAcctObj)); + pRow = sdbAllocRow(sizeof(SAcctObj)); if (pRow == NULL) goto _OVER; - SAcctObj *pAcct = sdbGetRowObj(pRow); + pAcct = sdbGetRowObj(pRow); if (pAcct == NULL) goto _OVER; int32_t dataPos = 0; @@ -186,7 +188,7 @@ static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw) { _OVER: if (terrno != 0) { - mError("acct:%s, failed to decode from raw:%p since %s", pAcct->acct, pRaw, terrstr()); + mError("acct:%s, failed to decode from raw:%p since %s", pAcct == NULL ? "null" : pAcct->acct, pRaw, terrstr()); taosMemoryFreeClear(pRow); return NULL; } @@ -218,7 +220,7 @@ static int32_t mndProcessCreateAcctReq(SRpcMsg *pReq) { return -1; } - terrno = TSDB_CODE_MSG_NOT_PROCESSED; + terrno = TSDB_CODE_OPS_NOT_SUPPORT; mError("failed to process create acct request since %s", terrstr()); return -1; } @@ -228,7 +230,7 @@ static int32_t mndProcessAlterAcctReq(SRpcMsg *pReq) { return -1; } - terrno = TSDB_CODE_MSG_NOT_PROCESSED; + terrno = TSDB_CODE_OPS_NOT_SUPPORT; mError("failed to process create acct request since %s", terrstr()); return -1; } @@ -238,7 +240,7 @@ static int32_t mndProcessDropAcctReq(SRpcMsg *pReq) { return -1; } - terrno = TSDB_CODE_MSG_NOT_PROCESSED; + terrno = TSDB_CODE_OPS_NOT_SUPPORT; mError("failed to process create acct request since %s", terrstr()); return -1; } \ No newline at end of file diff --git a/source/dnode/mnode/impl/src/mndCluster.c b/source/dnode/mnode/impl/src/mndCluster.c index 348c8f4cb8..ca03207d2b 100644 --- a/source/dnode/mnode/impl/src/mndCluster.c +++ b/source/dnode/mnode/impl/src/mndCluster.c @@ -157,6 +157,8 @@ _OVER: static SSdbRow *mndClusterActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; + SClusterObj *pCluster = NULL; + SSdbRow *pRow = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; @@ -166,10 +168,10 @@ static SSdbRow *mndClusterActionDecode(SSdbRaw *pRaw) { goto _OVER; } - SSdbRow *pRow = sdbAllocRow(sizeof(SClusterObj)); + pRow = sdbAllocRow(sizeof(SClusterObj)); if (pRow == NULL) goto _OVER; - SClusterObj *pCluster = sdbGetRowObj(pRow); + pCluster = sdbGetRowObj(pRow); if (pCluster == NULL) goto _OVER; int32_t dataPos = 0; @@ -184,7 +186,8 @@ static SSdbRow *mndClusterActionDecode(SSdbRaw *pRaw) { _OVER: if (terrno != 0) { - mError("cluster:%" PRId64 ", failed to decode from raw:%p since %s", pCluster->id, pRaw, terrstr()); + mError("cluster:%" PRId64 ", failed to decode from raw:%p since %s", pCluster == NULL ? 0 : pCluster->id, pRaw, + terrstr()); taosMemoryFreeClear(pRow); return NULL; } diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 4397ea0751..76bff9a70f 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -712,7 +712,9 @@ CM_ENCODE_OVER: SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; - void *buf = NULL; + SSdbRow *pRow = NULL; + SMqConsumerObj *pConsumer = NULL; + void *buf = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto CM_DECODE_OVER; @@ -722,10 +724,10 @@ SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) { goto CM_DECODE_OVER; } - SSdbRow *pRow = sdbAllocRow(sizeof(SMqConsumerObj)); + pRow = sdbAllocRow(sizeof(SMqConsumerObj)); if (pRow == NULL) goto CM_DECODE_OVER; - SMqConsumerObj *pConsumer = sdbGetRowObj(pRow); + pConsumer = sdbGetRowObj(pRow); if (pConsumer == NULL) goto CM_DECODE_OVER; int32_t dataPos = 0; @@ -745,7 +747,8 @@ SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) { CM_DECODE_OVER: taosMemoryFreeClear(buf); if (terrno != TSDB_CODE_SUCCESS) { - mError("consumer:%" PRId64 ", failed to decode from raw:%p since %s", pConsumer->consumerId, pRaw, terrstr()); + mError("consumer:%" PRId64 ", failed to decode from raw:%p since %s", pConsumer == NULL ? 0 : pConsumer->consumerId, + pRaw, terrstr()); taosMemoryFreeClear(pRow); return NULL; } diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index c5d5687ade..5fa86dffe2 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -147,6 +147,8 @@ _OVER: static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; + SSdbRow *pRow = NULL; + SDbObj *pDb = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; @@ -156,10 +158,10 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) { goto _OVER; } - SSdbRow *pRow = sdbAllocRow(sizeof(SDbObj)); + pRow = sdbAllocRow(sizeof(SDbObj)); if (pRow == NULL) goto _OVER; - SDbObj *pDb = sdbGetRowObj(pRow); + pDb = sdbGetRowObj(pRow); if (pDb == NULL) goto _OVER; int32_t dataPos = 0; @@ -232,7 +234,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) { _OVER: if (terrno != 0) { - mError("db:%s, failed to decode from raw:%p since %s", pDb->name, pRaw, terrstr()); + mError("db:%s, failed to decode from raw:%p since %s", pDb == NULL ? "null" : pDb->name, pRaw, terrstr()); taosMemoryFreeClear(pRow); return NULL; } diff --git a/source/dnode/mnode/impl/src/mndDef.c b/source/dnode/mnode/impl/src/mndDef.c index 2e984212a1..b5c2fb05b3 100644 --- a/source/dnode/mnode/impl/src/mndDef.c +++ b/source/dnode/mnode/impl/src/mndDef.c @@ -76,11 +76,14 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) { if (tEncodeSSchemaWrapper(pEncoder, &pObj->outputSchema) < 0) return -1; + // 3.0.20 + if (tEncodeI64(pEncoder, pObj->checkpointFreq) < 0) return -1; + tEndEncode(pEncoder); return pEncoder->pos; } -int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) { +int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj, int32_t sver) { if (tStartDecode(pDecoder) < 0) return -1; if (tDecodeCStrTo(pDecoder, pObj->name) < 0) return -1; @@ -139,6 +142,10 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj) { if (tDecodeSSchemaWrapper(pDecoder, &pObj->outputSchema) < 0) return -1; + // 3.0.20 + if (sver >= 2) { + if (tDecodeI64(pDecoder, &pObj->checkpointFreq) < 0) return -1; + } tEndDecode(pDecoder); return 0; } diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 2a3ecf1924..df25e44bee 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -154,8 +154,9 @@ _OVER: } static SSdbRow *mndDnodeActionDecode(SSdbRaw *pRaw) { - SSdbRow *pRow = NULL; terrno = TSDB_CODE_OUT_OF_MEMORY; + SSdbRow *pRow = NULL; + SDnodeObj *pDnode = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; @@ -166,7 +167,8 @@ static SSdbRow *mndDnodeActionDecode(SSdbRaw *pRaw) { pRow = sdbAllocRow(sizeof(SDnodeObj)); if (pRow == NULL) goto _OVER; - SDnodeObj *pDnode = sdbGetRowObj(pRow); + + pDnode = sdbGetRowObj(pRow); if (pDnode == NULL) goto _OVER; int32_t dataPos = 0; @@ -181,7 +183,7 @@ static SSdbRow *mndDnodeActionDecode(SSdbRaw *pRaw) { _OVER: if (terrno != 0) { - mError("dnode:%d, failed to decode from raw:%p since %s", pDnode->id, pRaw, terrstr()); + mError("dnode:%d, failed to decode from raw:%p since %s", pDnode == NULL ? 0 : pDnode->id, pRaw, terrstr()); taosMemoryFreeClear(pRow); return NULL; } @@ -375,14 +377,18 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { } bool roleChanged = false; for (int32_t vg = 0; vg < pVgroup->replica; ++vg) { - if (pVgroup->vnodeGid[vg].dnodeId == statusReq.dnodeId) { - if (pVgroup->vnodeGid[vg].syncState != pVload->syncState || - pVgroup->vnodeGid[vg].syncRestore != pVload->syncRestore) { - mInfo("vgId:%d, state changed by status msg, old state:%s restored:%d new state:%s restored:%d", - pVgroup->vgId, syncStr(pVgroup->vnodeGid[vg].syncState), pVgroup->vnodeGid[vg].syncRestore, - syncStr(pVload->syncState), pVload->syncRestore); - pVgroup->vnodeGid[vg].syncState = pVload->syncState; - pVgroup->vnodeGid[vg].syncRestore = pVload->syncRestore; + SVnodeGid *pGid = &pVgroup->vnodeGid[vg]; + if (pGid->dnodeId == statusReq.dnodeId) { + if (pGid->syncState != pVload->syncState || pGid->syncRestore != pVload->syncRestore || + pGid->syncCanRead != pVload->syncCanRead) { + mInfo( + "vgId:%d, state changed by status msg, old state:%s restored:%d canRead:%d new state:%s restored:%d " + "canRead:%d", + pVgroup->vgId, syncStr(pGid->syncState), pGid->syncRestore, pGid->syncCanRead, + syncStr(pVload->syncState), pVload->syncRestore, pVload->syncCanRead); + pGid->syncState = pVload->syncState; + pGid->syncRestore = pVload->syncRestore; + pGid->syncCanRead = pVload->syncCanRead; roleChanged = true; } break; @@ -781,7 +787,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) { int32_t numOfVnodes = mndGetVnodesNum(pMnode, pDnode->id); if ((numOfVnodes > 0 || pMObj != NULL || pSObj != NULL || pQObj != NULL) && !dropReq.force) { if (!mndIsDnodeOnline(pDnode, taosGetTimestampMs())) { - terrno = TSDB_CODE_NODE_OFFLINE; + terrno = TSDB_CODE_DNODE_OFFLINE; mError("dnode:%d, failed to drop since %s, vnodes:%d mnode:%d qnode:%d snode:%d", pDnode->id, terrstr(), numOfVnodes, pMObj != NULL, pQObj != NULL, pSObj != NULL); goto _OVER; diff --git a/source/dnode/mnode/impl/src/mndFunc.c b/source/dnode/mnode/impl/src/mndFunc.c index c9b22fad3a..31f31a15ba 100644 --- a/source/dnode/mnode/impl/src/mndFunc.c +++ b/source/dnode/mnode/impl/src/mndFunc.c @@ -101,6 +101,8 @@ _OVER: static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; + SSdbRow *pRow = NULL; + SFuncObj *pFunc = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; @@ -110,10 +112,10 @@ static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) { goto _OVER; } - SSdbRow *pRow = sdbAllocRow(sizeof(SFuncObj)); + pRow = sdbAllocRow(sizeof(SFuncObj)); if (pRow == NULL) goto _OVER; - SFuncObj *pFunc = sdbGetRowObj(pRow); + pFunc = sdbGetRowObj(pRow); if (pFunc == NULL) goto _OVER; int32_t dataPos = 0; @@ -148,7 +150,7 @@ static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) { _OVER: if (terrno != 0) { - mError("func:%s, failed to decode from raw:%p since %s", pFunc->name, pRaw, terrstr()); + mError("func:%s, failed to decode from raw:%p since %s", pFunc == NULL ? "null" : pFunc->name, pRaw, terrstr()); taosMemoryFreeClear(pRow); return NULL; } diff --git a/source/dnode/mnode/impl/src/mndInfoSchema.c b/source/dnode/mnode/impl/src/mndInfoSchema.c index 09172115f8..82294ac7bf 100644 --- a/source/dnode/mnode/impl/src/mndInfoSchema.c +++ b/source/dnode/mnode/impl/src/mndInfoSchema.c @@ -71,7 +71,7 @@ static int32_t mndInsInitMeta(SHashObj *hash) { int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, bool sysinfo, STableMetaRsp *pRsp) { if (NULL == pMnode->infosMeta) { - terrno = TSDB_CODE_APP_NOT_READY; + terrno = TSDB_CODE_APP_ERROR; return -1; } @@ -97,7 +97,7 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char * int32_t mndBuildInsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbName, STableCfgRsp *pRsp) { if (NULL == pMnode->infosMeta) { - terrno = TSDB_CODE_APP_NOT_READY; + terrno = TSDB_CODE_APP_ERROR; return -1; } diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index f533fafeee..eb6742a564 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -45,7 +45,7 @@ static inline int32_t mndAcquireRpc(SMnode *pMnode) { int32_t code = 0; taosThreadRwlockRdlock(&pMnode->lock); if (pMnode->stopped) { - terrno = TSDB_CODE_APP_NOT_READY; + terrno = TSDB_CODE_APP_IS_STOPPING; code = -1; } else if (!mndIsLeader(pMnode)) { code = -1; @@ -85,6 +85,21 @@ static void *mndBuildTimerMsg(int32_t *pContLen) { return pReq; } +static void *mndBuildCheckpointTickMsg(int32_t *pContLen, int64_t sec) { + SMStreamTickReq timerReq = { + .tick = sec, + }; + + int32_t contLen = tSerializeSMStreamTickMsg(NULL, 0, &timerReq); + if (contLen <= 0) return NULL; + void *pReq = rpcMallocCont(contLen); + if (pReq == NULL) return NULL; + + tSerializeSMStreamTickMsg(pReq, contLen, &timerReq); + *pContLen = contLen; + return pReq; +} + static void mndPullupTrans(SMnode *pMnode) { int32_t contLen = 0; void *pReq = mndBuildTimerMsg(&contLen); @@ -105,7 +120,24 @@ static void mndCalMqRebalance(SMnode *pMnode) { int32_t contLen = 0; void *pReq = mndBuildTimerMsg(&contLen); if (pReq != NULL) { - SRpcMsg rpcMsg = {.msgType = TDMT_MND_TMQ_TIMER, .pCont = pReq, .contLen = contLen}; + SRpcMsg rpcMsg = { + .msgType = TDMT_MND_TMQ_TIMER, + .pCont = pReq, + .contLen = contLen, + }; + tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg); + } +} + +static void mndStreamCheckpointTick(SMnode *pMnode, int64_t sec) { + int32_t contLen = 0; + void *pReq = mndBuildCheckpointTickMsg(&contLen, sec); + if (pReq != NULL) { + SRpcMsg rpcMsg = { + .msgType = TDMT_MND_STREAM_CHECKPOINT_TIMER, + .pCont = pReq, + .contLen = contLen, + }; tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg); } } @@ -150,12 +182,16 @@ static void mndSetVgroupOffline(SMnode *pMnode, int32_t dnodeId, int64_t curMs) bool roleChanged = false; for (int32_t vg = 0; vg < pVgroup->replica; ++vg) { - if (pVgroup->vnodeGid[vg].dnodeId == dnodeId) { - if (pVgroup->vnodeGid[vg].syncState != TAOS_SYNC_STATE_OFFLINE) { - mInfo("vgId:%d, state changed by offline check, old state:%s restored:%d new state:error restored:0", - pVgroup->vgId, syncStr(pVgroup->vnodeGid[vg].syncState), pVgroup->vnodeGid[vg].syncRestore); - pVgroup->vnodeGid[vg].syncState = TAOS_SYNC_STATE_OFFLINE; - pVgroup->vnodeGid[vg].syncRestore = 0; + SVnodeGid *pGid = &pVgroup->vnodeGid[vg]; + if (pGid->dnodeId == dnodeId) { + if (pGid->syncState != TAOS_SYNC_STATE_OFFLINE) { + mInfo( + "vgId:%d, state changed by offline check, old state:%s restored:%d canRead:%d new state:error restored:0 " + "canRead:0", + pVgroup->vgId, syncStr(pGid->syncState), pGid->syncRestore, pGid->syncCanRead); + pGid->syncState = TAOS_SYNC_STATE_OFFLINE; + pGid->syncRestore = 0; + pGid->syncCanRead = 0; roleChanged = true; } break; @@ -220,6 +256,12 @@ static void *mndThreadFp(void *param) { mndCalMqRebalance(pMnode); } +#if 0 + if (sec % tsStreamCheckpointTickInterval == 0) { + mndStreamCheckpointTick(pMnode, sec); + } +#endif + if (sec % tsTelemInterval == (TMIN(60, (tsTelemInterval - 1)))) { mndPullupTelem(pMnode); } @@ -491,7 +533,7 @@ void mndPreClose(SMnode *pMnode) { if (pMnode != NULL) { syncLeaderTransfer(pMnode->syncMgmt.sync); syncPreStop(pMnode->syncMgmt.sync); - +#if 0 while (syncSnapshotRecving(pMnode->syncMgmt.sync)) { mInfo("vgId:1, snapshot is recving"); taosMsleep(300); @@ -500,6 +542,7 @@ void mndPreClose(SMnode *pMnode) { mInfo("vgId:1, snapshot is sending"); taosMsleep(300); } +#endif } } @@ -556,11 +599,45 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) { pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_SCH_MERGE_FETCH || pMsg->msgType == TDMT_SCH_DROP_TASK) { return 0; } - if (mndAcquireRpc(pMsg->info.node) == 0) return 0; - SMnode *pMnode = pMsg->info.node; + SMnode *pMnode = pMsg->info.node; + taosThreadRwlockRdlock(&pMnode->lock); + if (pMnode->stopped) { + taosThreadRwlockUnlock(&pMnode->lock); + terrno = TSDB_CODE_APP_IS_STOPPING; + return -1; + } + + terrno = 0; SSyncState state = syncGetState(pMnode->syncMgmt.sync); + if (terrno != 0) { + taosThreadRwlockUnlock(&pMnode->lock); + return -1; + } + if (state.state != TAOS_SYNC_STATE_LEADER) { + taosThreadRwlockUnlock(&pMnode->lock); + terrno = TSDB_CODE_SYN_NOT_LEADER; + goto _OVER; + } + + if (!state.restored || !pMnode->restored) { + taosThreadRwlockUnlock(&pMnode->lock); + terrno = TSDB_CODE_SYN_RESTORING; + goto _OVER; + } + +#if 1 + atomic_add_fetch_32(&pMnode->rpcRef, 1); +#else + int32_t ref = atomic_add_fetch_32(&pMnode->rpcRef, 1); + mTrace("mnode rpc is acquired, ref:%d", ref); +#endif + + taosThreadRwlockUnlock(&pMnode->lock); + return 0; + +_OVER: if (pMsg->msgType == TDMT_MND_TMQ_TIMER || pMsg->msgType == TDMT_MND_TELEM_TIMER || pMsg->msgType == TDMT_MND_TRANS_TIMER || pMsg->msgType == TDMT_MND_TTL_TIMER || pMsg->msgType == TDMT_MND_UPTIME_TIMER) { @@ -573,42 +650,26 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) { SEpSet epSet = {0}; mndGetMnodeEpSet(pMnode, &epSet); - mDebug( + mGDebug( "msg:%p, type:%s failed to process since %s, mnode restored:%d stopped:%d, sync restored:%d " "role:%s, redirect numOfEps:%d inUse:%d", pMsg, TMSG_INFO(pMsg->msgType), terrstr(), pMnode->restored, pMnode->stopped, state.restored, syncStr(state.restored), epSet.numOfEps, epSet.inUse); - if (epSet.numOfEps > 0) { - for (int32_t i = 0; i < epSet.numOfEps; ++i) { - mDebug("mnode index:%d, ep:%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port); - } + if (epSet.numOfEps <= 0) return -1; - int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet); - pMsg->info.rsp = rpcMallocCont(contLen); - if (pMsg->info.rsp != NULL) { - tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet); - pMsg->info.hasEpSet = 1; - pMsg->info.rspLen = contLen; - terrno = TSDB_CODE_RPC_REDIRECT; - } else { - terrno = TSDB_CODE_OUT_OF_MEMORY; - } - } else { - terrno = TSDB_CODE_APP_NOT_READY; + for (int32_t i = 0; i < epSet.numOfEps; ++i) { + mDebug("mnode index:%d, ep:%s:%u", i, epSet.eps[i].fqdn, epSet.eps[i].port); } - return -1; -} + int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet); + pMsg->info.rsp = rpcMallocCont(contLen); + if (pMsg->info.rsp != NULL) { + tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet); + pMsg->info.hasEpSet = 1; + pMsg->info.rspLen = contLen; + } -static int32_t mndCheckMsgContent(SRpcMsg *pMsg) { - if (!IsReq(pMsg)) return 0; - if (pMsg->contLen != 0 && pMsg->pCont != NULL) return 0; - - const STraceId *trace = &pMsg->info.traceId; - mGError("msg:%p, failed to check msg, cont:%p contLen:%d, app:%p type:%s", pMsg, pMsg->pCont, pMsg->contLen, - pMsg->info.ahandle, TMSG_INFO(pMsg->msgType)); - terrno = TSDB_CODE_INVALID_MSG_LEN; return -1; } @@ -623,7 +684,6 @@ int32_t mndProcessRpcMsg(SRpcMsg *pMsg) { return -1; } - if (mndCheckMsgContent(pMsg) != 0) return -1; if (mndCheckMnodeState(pMsg) != 0) return -1; mGTrace("msg:%p, start to process in mnode, app:%p type:%s", pMsg, pMsg->info.ahandle, TMSG_INFO(pMsg->msgType)); diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index 7c86a5be22..9c847c1138 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -142,6 +142,8 @@ _OVER: static SSdbRow *mndMnodeActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; + SSdbRow *pRow = NULL; + SMnodeObj *pObj = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) return NULL; @@ -151,10 +153,10 @@ static SSdbRow *mndMnodeActionDecode(SSdbRaw *pRaw) { goto _OVER; } - SSdbRow *pRow = sdbAllocRow(sizeof(SMnodeObj)); + pRow = sdbAllocRow(sizeof(SMnodeObj)); if (pRow == NULL) goto _OVER; - SMnodeObj *pObj = sdbGetRowObj(pRow); + pObj = sdbGetRowObj(pRow); if (pObj == NULL) goto _OVER; int32_t dataPos = 0; @@ -167,7 +169,7 @@ static SSdbRow *mndMnodeActionDecode(SSdbRaw *pRaw) { _OVER: if (terrno != 0) { - mError("mnode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr()); + mError("mnode:%d, failed to decode from raw:%p since %s", pObj == NULL ? 0 : pObj->id, pRaw, terrstr()); taosMemoryFreeClear(pRow); return NULL; } @@ -290,7 +292,7 @@ static int32_t mndBuildCreateMnodeRedoAction(STrans *pTrans, SDCreateMnodeReq *p .pCont = pReq, .contLen = contLen, .msgType = TDMT_DND_CREATE_MNODE, - .acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED, + .acceptableCode = TSDB_CODE_MNODE_ALREADY_DEPLOYED, }; if (mndTransAppendRedoAction(pTrans, &action) != 0) { @@ -331,7 +333,7 @@ static int32_t mndBuildDropMnodeRedoAction(STrans *pTrans, SDDropMnodeReq *pDrop .pCont = pReq, .contLen = contLen, .msgType = TDMT_DND_DROP_MNODE, - .acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED, + .acceptableCode = TSDB_CODE_MNODE_NOT_DEPLOYED, }; if (mndTransAppendRedoAction(pTrans, &action) != 0) { @@ -438,7 +440,7 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) { } if (!mndIsDnodeOnline(pDnode, taosGetTimestampMs())) { - terrno = TSDB_CODE_NODE_OFFLINE; + terrno = TSDB_CODE_DNODE_OFFLINE; goto _OVER; } @@ -488,7 +490,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode if (totalMnodes == 2) { if (force) { mError("cant't force drop dnode, since a mnode on it and replica is 2"); - terrno = TSDB_CODE_NODE_OFFLINE; + terrno = TSDB_CODE_DNODE_OFFLINE; return -1; } mInfo("vgId:1, has %d mnodes, exec redo log first", totalMnodes); @@ -572,7 +574,7 @@ static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) { } if (!mndIsDnodeOnline(pObj->pDnode, taosGetTimestampMs())) { - terrno = TSDB_CODE_NODE_OFFLINE; + terrno = TSDB_CODE_DNODE_OFFLINE; goto _OVER; } diff --git a/source/dnode/mnode/impl/src/mndPerfSchema.c b/source/dnode/mnode/impl/src/mndPerfSchema.c index e874c1a53e..cf463304a1 100644 --- a/source/dnode/mnode/impl/src/mndPerfSchema.c +++ b/source/dnode/mnode/impl/src/mndPerfSchema.c @@ -68,7 +68,7 @@ int32_t mndPerfsInitMeta(SHashObj *hash) { int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp) { if (NULL == pMnode->perfsMeta) { - terrno = TSDB_CODE_APP_NOT_READY; + terrno = TSDB_CODE_APP_ERROR; return -1; } @@ -94,7 +94,7 @@ int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char int32_t mndBuildPerfsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbName, STableCfgRsp *pRsp) { if (NULL == pMnode->perfsMeta) { - terrno = TSDB_CODE_APP_NOT_READY; + terrno = TSDB_CODE_APP_ERROR; return -1; } diff --git a/source/dnode/mnode/impl/src/mndPrivilege.c b/source/dnode/mnode/impl/src/mndPrivilege.c index 151a2a6404..ccb4140b83 100644 --- a/source/dnode/mnode/impl/src/mndPrivilege.c +++ b/source/dnode/mnode/impl/src/mndPrivilege.c @@ -28,6 +28,10 @@ int32_t mndCheckDbPrivilege(SMnode *pMnode, const char *user, EOperType operType int32_t mndCheckDbPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *dbname) { return 0; } +int32_t mndCheckTopicPrivilege(SMnode *pMnode, const char *user, EOperType operType, SMqTopicObj *pTopic) { return 0; } +int32_t mndCheckTopicPrivilegeByName(SMnode *pMnode, const char *user, EOperType operType, const char *topicName) { + return 0; +} int32_t mndSetUserAuthRsp(SMnode *pMnode, SUserObj *pUser, SGetUserAuthRsp *pRsp) { memcpy(pRsp->user, pUser->user, TSDB_USER_LEN); pRsp->superAuth = 1; diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index d42b66455f..fe76ba31d7 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -542,7 +542,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb } default: mError("invalid kv key:%d", kv->key); - hbRsp.status = TSDB_CODE_MND_APP_ERROR; + hbRsp.status = TSDB_CODE_APP_ERROR; break; } diff --git a/source/dnode/mnode/impl/src/mndQnode.c b/source/dnode/mnode/impl/src/mndQnode.c index 434e6fbc52..28a5dee2db 100644 --- a/source/dnode/mnode/impl/src/mndQnode.c +++ b/source/dnode/mnode/impl/src/mndQnode.c @@ -100,6 +100,8 @@ _OVER: static SSdbRow *mndQnodeActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; + SSdbRow *pRow = NULL; + SQnodeObj *pObj = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; @@ -109,10 +111,10 @@ static SSdbRow *mndQnodeActionDecode(SSdbRaw *pRaw) { goto _OVER; } - SSdbRow *pRow = sdbAllocRow(sizeof(SQnodeObj)); + pRow = sdbAllocRow(sizeof(SQnodeObj)); if (pRow == NULL) goto _OVER; - SQnodeObj *pObj = sdbGetRowObj(pRow); + pObj = sdbGetRowObj(pRow); if (pObj == NULL) goto _OVER; int32_t dataPos = 0; @@ -125,7 +127,7 @@ static SSdbRow *mndQnodeActionDecode(SSdbRaw *pRaw) { _OVER: if (terrno != 0) { - mError("qnode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr()); + mError("qnode:%d, failed to decode from raw:%p since %s", pObj == NULL ? 0 : pObj->id, pRaw, terrstr()); taosMemoryFreeClear(pRow); return NULL; } @@ -203,7 +205,7 @@ static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S action.pCont = pReq; action.contLen = contLen; action.msgType = TDMT_DND_CREATE_QNODE; - action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED; + action.acceptableCode = TSDB_CODE_QNODE_ALREADY_DEPLOYED; if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); @@ -230,7 +232,7 @@ static int32_t mndSetCreateQnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S action.pCont = pReq; action.contLen = contLen; action.msgType = TDMT_DND_DROP_QNODE; - action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; + action.acceptableCode = TSDB_CODE_QNODE_NOT_DEPLOYED; if (mndTransAppendUndoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); @@ -343,7 +345,7 @@ static int32_t mndSetDropQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQn action.pCont = pReq; action.contLen = contLen; action.msgType = TDMT_DND_DROP_QNODE; - action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; + action.acceptableCode = TSDB_CODE_QNODE_NOT_DEPLOYED; if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index 20c2ebb0a4..ec2e844ba5 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -108,6 +108,8 @@ static int32_t convertToRetrieveType(char *name, int32_t len) { type = TSDB_MGMT_TABLE_APPS; } else if (strncasecmp(name, TSDB_INS_TABLE_STREAM_TASKS, len) == 0) { type = TSDB_MGMT_TABLE_STREAM_TASKS; + } else if (strncasecmp(name, TSDB_INS_TABLE_USER_PRIVILEGES, len) == 0) { + type = TSDB_MGMT_TABLE_PRIVILEGES; } else { // ASSERT(0); } diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index 698c07d9bc..f9d0a9b9ba 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -132,6 +132,8 @@ _OVER: static SSdbRow *mndSmaActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; + SSdbRow *pRow = NULL; + SSmaObj *pSma = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; @@ -141,10 +143,10 @@ static SSdbRow *mndSmaActionDecode(SSdbRaw *pRaw) { goto _OVER; } - SSdbRow *pRow = sdbAllocRow(sizeof(SSmaObj)); + pRow = sdbAllocRow(sizeof(SSmaObj)); if (pRow == NULL) goto _OVER; - SSmaObj *pSma = sdbGetRowObj(pRow); + pSma = sdbGetRowObj(pRow); if (pSma == NULL) goto _OVER; int32_t dataPos = 0; @@ -200,7 +202,7 @@ static SSdbRow *mndSmaActionDecode(SSdbRaw *pRaw) { _OVER: if (terrno != 0) { - mError("sma:%s, failed to decode from raw:%p since %s", pSma->name, pRaw, terrstr()); + mError("sma:%s, failed to decode from raw:%p since %s", pSma == NULL ? "null" : pSma->name, pRaw, terrstr()); taosMemoryFreeClear(pSma->expr); taosMemoryFreeClear(pSma->tagsFilter); taosMemoryFreeClear(pSma->sql); @@ -461,7 +463,7 @@ static int32_t mndSetCreateSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, action.pCont = pReq; action.contLen = contLen; action.msgType = TDMT_DND_CREATE_VNODE; - action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED; + action.acceptableCode = TSDB_CODE_VND_ALREADY_EXIST; if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); @@ -778,7 +780,7 @@ static int32_t mndSetDropSmaVgroupRedoActions(SMnode *pMnode, STrans *pTrans, SD action.pCont = pReq; action.contLen = contLen; action.msgType = TDMT_DND_DROP_VNODE; - action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; + action.acceptableCode = TSDB_CODE_VND_NOT_EXIST; if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); diff --git a/source/dnode/mnode/impl/src/mndSnode.c b/source/dnode/mnode/impl/src/mndSnode.c index 7753e5b127..e6a253bcc0 100644 --- a/source/dnode/mnode/impl/src/mndSnode.c +++ b/source/dnode/mnode/impl/src/mndSnode.c @@ -105,6 +105,8 @@ _OVER: static SSdbRow *mndSnodeActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; + SSdbRow *pRow = NULL; + SSnodeObj *pObj = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; @@ -114,10 +116,10 @@ static SSdbRow *mndSnodeActionDecode(SSdbRaw *pRaw) { goto _OVER; } - SSdbRow *pRow = sdbAllocRow(sizeof(SSnodeObj)); + pRow = sdbAllocRow(sizeof(SSnodeObj)); if (pRow == NULL) goto _OVER; - SSnodeObj *pObj = sdbGetRowObj(pRow); + pObj = sdbGetRowObj(pRow); if (pObj == NULL) goto _OVER; int32_t dataPos = 0; @@ -130,7 +132,7 @@ static SSdbRow *mndSnodeActionDecode(SSdbRaw *pRaw) { _OVER: if (terrno != 0) { - mError("snode:%d, failed to decode from raw:%p since %s", pObj->id, pRaw, terrstr()); + mError("snode:%d, failed to decode from raw:%p since %s", pObj == NULL ? 0 : pObj->id, pRaw, terrstr()); taosMemoryFreeClear(pRow); return NULL; } @@ -208,7 +210,7 @@ static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S action.pCont = pReq; action.contLen = contLen; action.msgType = TDMT_DND_CREATE_SNODE; - action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED; + action.acceptableCode = TSDB_CODE_SNODE_ALREADY_DEPLOYED; if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); @@ -235,7 +237,7 @@ static int32_t mndSetCreateSnodeUndoActions(STrans *pTrans, SDnodeObj *pDnode, S action.pCont = pReq; action.contLen = contLen; action.msgType = TDMT_DND_DROP_SNODE; - action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; + action.acceptableCode = TSDB_CODE_SNODE_NOT_DEPLOYED; if (mndTransAppendUndoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); @@ -350,7 +352,7 @@ static int32_t mndSetDropSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SSn action.pCont = pReq; action.contLen = contLen; action.msgType = TDMT_DND_DROP_SNODE; - action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; + action.acceptableCode = TSDB_CODE_SNODE_NOT_DEPLOYED; if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 6dad7d74c8..2ed4fde509 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -162,6 +162,8 @@ _OVER: static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; + SSdbRow *pRow = NULL; + SStbObj *pStb = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; @@ -171,10 +173,10 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) { goto _OVER; } - SSdbRow *pRow = sdbAllocRow(sizeof(SStbObj)); + pRow = sdbAllocRow(sizeof(SStbObj)); if (pRow == NULL) goto _OVER; - SStbObj *pStb = sdbGetRowObj(pRow); + pStb = sdbGetRowObj(pRow); if (pStb == NULL) goto _OVER; int32_t dataPos = 0; @@ -254,10 +256,12 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) { _OVER: if (terrno != 0) { - mError("stb:%s, failed to decode from raw:%p since %s", pStb->name, pRaw, terrstr()); - taosMemoryFreeClear(pStb->pColumns); - taosMemoryFreeClear(pStb->pTags); - taosMemoryFreeClear(pStb->comment); + mError("stb:%s, failed to decode from raw:%p since %s", pStb == NULL ? "null" : pStb->name, pRaw, terrstr()); + if (pStb != NULL) { + taosMemoryFreeClear(pStb->pColumns); + taosMemoryFreeClear(pStb->pTags); + taosMemoryFreeClear(pStb->comment); + } taosMemoryFreeClear(pRow); return NULL; } diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index d8cf7a837e..7ee688d220 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -28,7 +28,7 @@ #include "parser.h" #include "tname.h" -#define MND_STREAM_VER_NUMBER 1 +#define MND_STREAM_VER_NUMBER 2 #define MND_STREAM_RESERVE_SIZE 64 static int32_t mndStreamActionInsert(SSdb *pSdb, SStreamObj *pStream); @@ -36,6 +36,8 @@ static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream); static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pStream, SStreamObj *pNewStream); static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq); static int32_t mndProcessDropStreamReq(SRpcMsg *pReq); +static int32_t mndProcessStreamCheckpointTmr(SRpcMsg *pReq); +static int32_t mndProcessStreamDoCheckpoint(SRpcMsg *pReq); /*static int32_t mndProcessRecoverStreamReq(SRpcMsg *pReq);*/ static int32_t mndProcessStreamMetaReq(SRpcMsg *pReq); static int32_t mndGetStreamMeta(SRpcMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta); @@ -62,6 +64,10 @@ int32_t mndInitStream(SMnode *pMnode) { mndSetMsgHandle(pMnode, TDMT_STREAM_TASK_DEPLOY_RSP, mndTransProcessRsp); mndSetMsgHandle(pMnode, TDMT_STREAM_TASK_DROP_RSP, mndTransProcessRsp); + mndSetMsgHandle(pMnode, TDMT_MND_STREAM_CHECKPOINT_TIMER, mndProcessStreamCheckpointTmr); + mndSetMsgHandle(pMnode, TDMT_MND_STREAM_BEGIN_CHECKPOINT, mndProcessStreamDoCheckpoint); + mndSetMsgHandle(pMnode, TDMT_STREAM_TASK_REPORT_CHECKPOINT, mndTransProcessRsp); + mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndRetrieveStream); mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndCancelGetNextStream); mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAM_TASKS, mndRetrieveStreamTask); @@ -120,21 +126,22 @@ STREAM_ENCODE_OVER: SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; - void *buf = NULL; + SSdbRow *pRow = NULL; + SStreamObj *pStream = NULL; + void *buf = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto STREAM_DECODE_OVER; - if (sver != MND_STREAM_VER_NUMBER) { + if (sver != 1 && sver != 2) { terrno = TSDB_CODE_SDB_INVALID_DATA_VER; goto STREAM_DECODE_OVER; } - int32_t size = sizeof(SStreamObj); - SSdbRow *pRow = sdbAllocRow(size); + pRow = sdbAllocRow(sizeof(SStreamObj)); if (pRow == NULL) goto STREAM_DECODE_OVER; - SStreamObj *pStream = sdbGetRowObj(pRow); + pStream = sdbGetRowObj(pRow); if (pStream == NULL) goto STREAM_DECODE_OVER; int32_t tlen; @@ -146,7 +153,7 @@ SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw) { SDecoder decoder; tDecoderInit(&decoder, buf, tlen + 1); - if (tDecodeSStreamObj(&decoder, pStream) < 0) { + if (tDecodeSStreamObj(&decoder, pStream, sver) < 0) { tDecoderClear(&decoder); goto STREAM_DECODE_OVER; } @@ -157,7 +164,7 @@ SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw) { STREAM_DECODE_OVER: taosMemoryFreeClear(buf); if (terrno != TSDB_CODE_SUCCESS) { - mError("stream:%s, failed to decode from raw:%p since %s", pStream->name, pRaw, terrstr()); + mError("stream:%s, failed to decode from raw:%p since %s", pStream == NULL ? "null" : pStream->name, pRaw, terrstr()); taosMemoryFreeClear(pRow); return NULL; } @@ -679,6 +686,164 @@ _OVER: tFreeStreamObj(&streamObj); return code; } +static int32_t mndProcessStreamCheckpointTmr(SRpcMsg *pReq) { + SMnode *pMnode = pReq->info.node; + SSdb *pSdb = pMnode->pSdb; + void *pIter = NULL; + SStreamObj *pStream = NULL; + + // iterate all stream obj + while (1) { + pIter = sdbFetch(pSdb, SDB_STREAM, pIter, (void **)&pStream); + if (pIter == NULL) break; + // incr tick + int64_t currentTick = atomic_add_fetch_64(&pStream->currentTick, 1); + // if >= checkpointFreq, build msg TDMT_MND_STREAM_BEGIN_CHECKPOINT, put into write q + if (currentTick >= pStream->checkpointFreq) { + atomic_store_64(&pStream->currentTick, 0); + SMStreamDoCheckpointMsg *pMsg = rpcMallocCont(sizeof(SMStreamDoCheckpointMsg)); + + pMsg->streamId = pStream->uid; + pMsg->checkpointId = tGenIdPI64(); + memcpy(pMsg->streamName, pStream->name, TSDB_STREAM_FNAME_LEN); + + SRpcMsg rpcMsg = { + .msgType = TDMT_MND_STREAM_BEGIN_CHECKPOINT, + .pCont = pMsg, + .contLen = sizeof(SMStreamDoCheckpointMsg), + }; + + tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + } + } + + return 0; +} + +static int32_t mndBuildStreamCheckpointSourceReq(void **pBuf, int32_t *pLen, const SStreamTask *pTask, + SMStreamDoCheckpointMsg *pMsg) { + SStreamCheckpointSourceReq req = {0}; + req.checkpointId = pMsg->checkpointId; + req.nodeId = pTask->nodeId; + req.expireTime = -1; + req.streamId = pTask->streamId; + req.taskId = pTask->taskId; + + int32_t code; + int32_t blen; + + tEncodeSize(tEncodeSStreamCheckpointSourceReq, &req, blen, code); + if (code < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + int32_t tlen = sizeof(SMsgHead) + blen; + + void *buf = taosMemoryMalloc(tlen); + if (buf == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); + SEncoder encoder; + tEncoderInit(&encoder, abuf, tlen); + tEncodeSStreamCheckpointSourceReq(&encoder, &req); + + SMsgHead *pMsgHead = (SMsgHead *)buf; + pMsgHead->contLen = htonl(tlen); + pMsgHead->vgId = htonl(pTask->nodeId); + + tEncoderClear(&encoder); + + *pBuf = buf; + *pLen = tlen; + + return 0; +} + +static int32_t mndProcessStreamDoCheckpoint(SRpcMsg *pReq) { + SMnode *pMnode = pReq->info.node; + SSdb *pSdb = pMnode->pSdb; + + SMStreamDoCheckpointMsg *pMsg = (SMStreamDoCheckpointMsg *)pReq->pCont; + + SStreamObj *pStream = mndAcquireStream(pMnode, pMsg->streamName); + + if (pStream == NULL || pStream->uid != pMsg->streamId) { + mError("start checkpointing failed since stream %s not found", pMsg->streamName); + return -1; + } + + // build new transaction: + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB_INSIDE, pReq, "stream-checkpoint"); + if (pTrans == NULL) return -1; + mndTransSetDbName(pTrans, pStream->sourceDb, pStream->targetDb); + taosRLockLatch(&pStream->lock); + // 1. redo action: broadcast checkpoint source msg for all source vg + int32_t totLevel = taosArrayGetSize(pStream->tasks); + for (int32_t i = 0; i < totLevel; i++) { + SArray *pLevel = taosArrayGetP(pStream->tasks, i); + SStreamTask *pTask = taosArrayGetP(pLevel, 0); + if (pTask->taskLevel == TASK_LEVEL__SOURCE) { + int32_t sz = taosArrayGetSize(pLevel); + for (int32_t j = 0; j < sz; j++) { + SStreamTask *pTask = taosArrayGetP(pLevel, j); + ASSERT(pTask->nodeId > 0); + SVgObj *pVgObj = mndAcquireVgroup(pMnode, pTask->nodeId); + if (pVgObj == NULL) { + ASSERT(0); + taosRUnLockLatch(&pStream->lock); + mndReleaseStream(pMnode, pStream); + mndTransDrop(pTrans); + return -1; + } + + void *buf; + int32_t tlen; + if (mndBuildStreamCheckpointSourceReq(&buf, &tlen, pTask, pMsg) < 0) { + taosRUnLockLatch(&pStream->lock); + mndReleaseStream(pMnode, pStream); + mndTransDrop(pTrans); + return -1; + } + + STransAction action = {0}; + action.epSet = mndGetVgroupEpset(pMnode, pVgObj); + action.pCont = buf; + action.contLen = tlen; + action.msgType = TDMT_VND_STREAM_CHECK_POINT_SOURCE; + + mndReleaseVgroup(pMnode, pVgObj); + + if (mndTransAppendRedoAction(pTrans, &action) != 0) { + taosMemoryFree(buf); + taosRUnLockLatch(&pStream->lock); + mndReleaseStream(pMnode, pStream); + mndTransDrop(pTrans); + return -1; + } + } + } + } + // 2. reset tick + atomic_store_64(&pStream->currentTick, 0); + // 3. commit log: stream checkpoint info + taosRUnLockLatch(&pStream->lock); + + if (mndTransPrepare(pMnode, pTrans) != 0) { + mError("failed to prepare trans rebalance since %s", terrstr()); + mndTransDrop(pTrans); + mndReleaseStream(pMnode, pStream); + return -1; + } + + mndReleaseStream(pMnode, pStream); + mndTransDrop(pTrans); + + return 0; +} static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; @@ -747,71 +912,6 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) { return TSDB_CODE_ACTION_IN_PROGRESS; } -#if 0 -static int32_t mndProcessRecoverStreamReq(SRpcMsg *pReq) { - SMnode *pMnode = pReq->info.node; - SStreamObj *pStream = NULL; - /*SDbObj *pDb = NULL;*/ - /*SUserObj *pUser = NULL;*/ - - SMRecoverStreamReq recoverReq = {0}; - if (tDeserializeSMRecoverStreamReq(pReq->pCont, pReq->contLen, &recoverReq) < 0) { - ASSERT(0); - terrno = TSDB_CODE_INVALID_MSG; - return -1; - } - - pStream = mndAcquireStream(pMnode, recoverReq.name); - - if (pStream == NULL) { - if (recoverReq.igNotExists) { - mInfo("stream:%s, not exist, ignore not exist is set", recoverReq.name); - sdbRelease(pMnode->pSdb, pStream); - return 0; - } else { - terrno = TSDB_CODE_MND_STREAM_NOT_EXIST; - return -1; - } - } - - if (mndCheckDbPrivilegeByName(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, pStream->targetDb) != 0) { - return -1; - } - - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq); - if (pTrans == NULL) { - mError("stream:%s, failed to recover since %s", recoverReq.name, terrstr()); - sdbRelease(pMnode->pSdb, pStream); - return -1; - } - mInfo("trans:%d, used to drop stream:%s", pTrans->id, recoverReq.name); - - // broadcast to recover all tasks - if (mndRecoverStreamTasks(pMnode, pTrans, pStream) < 0) { - mError("stream:%s, failed to recover task since %s", recoverReq.name, terrstr()); - sdbRelease(pMnode->pSdb, pStream); - return -1; - } - - // update stream status - if (mndSetStreamRecover(pMnode, pTrans, pStream) < 0) { - sdbRelease(pMnode->pSdb, pStream); - return -1; - } - - if (mndTransPrepare(pMnode, pTrans) != 0) { - mError("trans:%d, failed to prepare recover stream trans since %s", pTrans->id, terrstr()); - sdbRelease(pMnode->pSdb, pStream); - mndTransDrop(pTrans); - return -1; - } - - sdbRelease(pMnode->pSdb, pStream); - - return TSDB_CODE_ACTION_IN_PROGRESS; -} -#endif - int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { SSdb *pSdb = pMnode->pSdb; void *pIter = NULL; @@ -846,13 +946,6 @@ int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { } } -#if 0 - if (mndSetDropOffsetStreamLogs(pMnode, pTrans, pStream) < 0) { - sdbRelease(pSdb, pStream); - goto END; - } -#endif - sdbRelease(pSdb, pStream); } diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index ffb46e5f1b..55e073a8a4 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -440,9 +440,9 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR } static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOutputObj *pOutput) { - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pMsg, "persist-reb"); - mndTransSetDbName(pTrans, pOutput->pSub->dbName, NULL); + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_DB_INSIDE, pMsg, "tmq-reb"); if (pTrans == NULL) return -1; + mndTransSetDbName(pTrans, pOutput->pSub->dbName, NULL); // make txn: // 1. redo action: action to all vg @@ -523,28 +523,6 @@ static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOu tDeleteSMqConsumerObj(pConsumerNew); taosMemoryFree(pConsumerNew); } -#if 0 - if (consumerNum) { - char topic[TSDB_TOPIC_FNAME_LEN]; - char cgroup[TSDB_CGROUP_LEN]; - mndSplitSubscribeKey(pOutput->pSub->key, topic, cgroup, true); - SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); - if (pTopic) { - // TODO make topic complete - SMqTopicObj topicObj = {0}; - memcpy(&topicObj, pTopic, sizeof(SMqTopicObj)); - topicObj.refConsumerCnt = pTopic->refConsumerCnt - consumerNum; - // TODO is that correct? - pTopic->refConsumerCnt = topicObj.refConsumerCnt; - mInfo("subscribe topic %s unref %d consumer cgroup %s, refcnt %d", pTopic->name, consumerNum, cgroup, - topicObj.refConsumerCnt); - if (mndSetTopicCommitLogs(pMnode, pTrans, &topicObj) != 0) { - ASSERT(0); - goto REB_FAIL; - } - } - } -#endif // 4. TODO commit log: modification log @@ -743,7 +721,9 @@ SUB_ENCODE_OVER: static SSdbRow *mndSubActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; - void *buf = NULL; + SSdbRow *pRow = NULL; + SMqSubscribeObj *pSub = NULL; + void *buf = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto SUB_DECODE_OVER; @@ -753,11 +733,10 @@ static SSdbRow *mndSubActionDecode(SSdbRaw *pRaw) { goto SUB_DECODE_OVER; } - int32_t size = sizeof(SMqSubscribeObj); - SSdbRow *pRow = sdbAllocRow(size); + pRow = sdbAllocRow(sizeof(SMqSubscribeObj)); if (pRow == NULL) goto SUB_DECODE_OVER; - SMqSubscribeObj *pSub = sdbGetRowObj(pRow); + pSub = sdbGetRowObj(pRow); if (pSub == NULL) goto SUB_DECODE_OVER; int32_t dataPos = 0; @@ -777,7 +756,7 @@ static SSdbRow *mndSubActionDecode(SSdbRaw *pRaw) { SUB_DECODE_OVER: taosMemoryFreeClear(buf); if (terrno != TSDB_CODE_SUCCESS) { - mError("subscribe:%s, failed to decode from raw:%p since %s", pSub->key, pRaw, terrstr()); + mError("subscribe:%s, failed to decode from raw:%p since %s", pSub == NULL ? "null" : pSub->key, pRaw, terrstr()); taosMemoryFreeClear(pRow); return NULL; } diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index 4dd7e070b3..895d7fedc4 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -72,15 +72,11 @@ static int32_t mndSyncSendMsg(const SEpSet *pEpSet, SRpcMsg *pMsg) { return code; } -void mndSyncCommitMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const SFsmCbMeta *pMeta) { +int32_t mndProcessWriteMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) { SMnode *pMnode = pFsm->data; SSyncMgmt *pMgmt = &pMnode->syncMgmt; SSdbRaw *pRaw = pMsg->pCont; - // delete msg handle - SRpcMsg rpcMsg = {0}; - rpcMsg.info = pMsg->info; - int32_t transId = sdbGetIdFromRaw(pMnode->pSdb, pRaw); pMgmt->errCode = pMeta->code; mInfo("trans:%d, is proposed, saved:%d code:0x%x, apply index:%" PRId64 " term:%" PRIu64 " config:%" PRId64 @@ -118,6 +114,15 @@ void mndSyncCommitMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const SFsmCbMet mError("trans:%d, not found while execute in mnode since %s", transId, terrstr()); } } + + return 0; +} + +int32_t mndSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) { + int32_t code = mndProcessWriteMsg(pFsm, pMsg, pMeta); + rpcFreeCont(pMsg->pCont); + pMsg->pCont = NULL; + return code; } int32_t mndSyncGetSnapshot(const SSyncFSM *pFsm, SSnapshot *pSnapshot, void *pReaderParam, void **ppReader) { @@ -316,7 +321,7 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) { if (pMgmt->transId != 0) { mError("trans:%d, can't be proposed since trans:%d already waiting for confirm", transId, pMgmt->transId); taosWUnLockLatch(&pMgmt->lock); - terrno = TSDB_CODE_APP_NOT_READY; + terrno = TSDB_CODE_MND_LAST_TRANS_NOT_FINISHED; return -1; } @@ -337,13 +342,11 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) { sdbSetApplyInfo(pMnode->pSdb, req.info.conn.applyIndex, req.info.conn.applyTerm, SYNC_INDEX_INVALID); code = 0; } else { - mInfo("trans:%d, failed to proposed since %s", transId, terrstr()); + mError("trans:%d, failed to proposed since %s", transId, terrstr()); taosWLockLatch(&pMgmt->lock); pMgmt->transId = 0; taosWUnLockLatch(&pMgmt->lock); - if (terrno == TSDB_CODE_SYN_NOT_LEADER) { - terrno = TSDB_CODE_APP_NOT_READY; - } else { + if (terrno == 0) { terrno = TSDB_CODE_APP_ERROR; } } @@ -361,7 +364,10 @@ int32_t mndSyncPropose(SMnode *pMnode, SSdbRaw *pRaw, int32_t transId) { void mndSyncStart(SMnode *pMnode) { SSyncMgmt *pMgmt = &pMnode->syncMgmt; - syncStart(pMgmt->sync); + if (syncStart(pMgmt->sync) < 0) { + mError("vgId:1, failed to start sync, id:%" PRId64, pMgmt->sync); + return; + } mInfo("vgId:1, sync started, id:%" PRId64, pMgmt->sync); } @@ -376,20 +382,23 @@ void mndSyncStop(SMnode *pMnode) { } bool mndIsLeader(SMnode *pMnode) { + terrno = 0; SSyncState state = syncGetState(pMnode->syncMgmt.sync); - if (state.state != TAOS_SYNC_STATE_LEADER || !state.restored) { - if (state.state != TAOS_SYNC_STATE_LEADER) { - terrno = TSDB_CODE_SYN_NOT_LEADER; - } else { - terrno = TSDB_CODE_APP_NOT_READY; - } - mDebug("vgId:1, mnode not ready, state:%s, restore:%d", syncStr(state.state), state.restored); + if (terrno != 0) { + mDebug("vgId:1, mnode is stopping"); return false; } - if (!mndGetRestored(pMnode)) { - terrno = TSDB_CODE_APP_NOT_READY; + if (state.state != TAOS_SYNC_STATE_LEADER) { + terrno = TSDB_CODE_SYN_NOT_LEADER; + mDebug("vgId:1, mnode not leader, state:%s", syncStr(state.state)); + return false; + } + + if (!state.restored || !pMnode->restored) { + terrno = TSDB_CODE_SYN_RESTORING; + mDebug("vgId:1, mnode not restored:%d:%d", state.restored, pMnode->restored); return false; } diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 6412761f0b..eea74c6dd8 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -152,8 +152,10 @@ TOPIC_ENCODE_OVER: SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; + SSdbRow *pRow = NULL; + SMqTopicObj *pTopic = NULL; + void *buf = NULL; - void *buf = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto TOPIC_DECODE_OVER; @@ -162,11 +164,10 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { goto TOPIC_DECODE_OVER; } - int32_t size = sizeof(SMqTopicObj); - SSdbRow *pRow = sdbAllocRow(size); + pRow = sdbAllocRow(sizeof(SMqTopicObj)); if (pRow == NULL) goto TOPIC_DECODE_OVER; - SMqTopicObj *pTopic = sdbGetRowObj(pRow); + pTopic = sdbGetRowObj(pRow); if (pTopic == NULL) goto TOPIC_DECODE_OVER; int32_t len; @@ -251,7 +252,7 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { TOPIC_DECODE_OVER: taosMemoryFreeClear(buf); if (terrno != TSDB_CODE_SUCCESS) { - mError("topic:%s, failed to decode from raw:%p since %s", pTopic->name, pRaw, terrstr()); + mError("topic:%s, failed to decode from raw:%p since %s", pTopic == NULL ? "null" : pTopic->name, pRaw, terrstr()); taosMemoryFreeClear(pRow); return NULL; } @@ -288,7 +289,7 @@ static int32_t mndTopicActionUpdate(SSdb *pSdb, SMqTopicObj *pOldTopic, SMqTopic return 0; } -SMqTopicObj *mndAcquireTopic(SMnode *pMnode, char *topicName) { +SMqTopicObj *mndAcquireTopic(SMnode *pMnode, const char *topicName) { SSdb *pSdb = pMnode->pSdb; SMqTopicObj *pTopic = sdbAcquire(pSdb, SDB_TOPIC, topicName); if (pTopic == NULL && terrno == TSDB_CODE_SDB_OBJ_NOT_THERE) { @@ -573,7 +574,7 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) { goto _OVER; } - if (mndCheckDbPrivilege(pMnode, pReq->info.conn.user, MND_OPER_READ_DB, pDb) != 0) { + if (mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CREATE_TOPIC) != 0) { goto _OVER; } @@ -633,6 +634,11 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) { } } + if (mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_DROP_TOPIC) != 0) { + mndReleaseTopic(pMnode, pTopic); + return -1; + } + void *pIter = NULL; SMqConsumerObj *pConsumer; while (1) { diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 27c58dfba1..4b11884050 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -918,10 +918,13 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) { sendRsp = true; } } else { - if (pTrans->stage == TRN_STAGE_REDO_ACTION && ((code == TSDB_CODE_APP_NOT_READY && pTrans->failedTimes > 60) || - (code != TSDB_CODE_APP_NOT_READY && pTrans->failedTimes > 6))) { + if (pTrans->stage == TRN_STAGE_REDO_ACTION) { + if (code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_APP_IS_STARTING) { + if (pTrans->failedTimes > 60) sendRsp = true; + } else { + if (pTrans->failedTimes > 6) sendRsp = true; + } if (code == 0) code = TSDB_CODE_MND_TRANS_UNKNOW_ERROR; - sendRsp = true; } } @@ -942,7 +945,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) { code = TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL; } if (i != 0 && code == 0) { - code = TSDB_CODE_RPC_REDIRECT; + code = TSDB_CODE_MNODE_NOT_FOUND; } mInfo("trans:%d, client:%d send rsp, code:0x%x stage:%s app:%p", pTrans->id, i, code, mndTransStr(pTrans->stage), pInfo->ahandle); @@ -1039,8 +1042,8 @@ static void mndTransResetAction(SMnode *pMnode, STrans *pTrans, STransAction *pA pAction->rawWritten = 0; pAction->msgSent = 0; pAction->msgReceived = 0; - if (pAction->errCode == TSDB_CODE_RPC_REDIRECT || pAction->errCode == TSDB_CODE_SYN_NEW_CONFIG_ERROR || - pAction->errCode == TSDB_CODE_SYN_INTERNAL_ERROR || pAction->errCode == TSDB_CODE_SYN_NOT_LEADER) { + if (pAction->errCode == TSDB_CODE_SYN_NEW_CONFIG_ERROR || pAction->errCode == TSDB_CODE_SYN_INTERNAL_ERROR || + pAction->errCode == TSDB_CODE_SYN_NOT_LEADER) { pAction->epSet.inUse = (pAction->epSet.inUse + 1) % pAction->epSet.numOfEps; mInfo("trans:%d, %s:%d execute status is reset and set epset inuse:%d", pTrans->id, mndTransStr(pAction->stage), pAction->id, pAction->epSet.inUse); diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index 9f4b9fc2de..806ba0c98e 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -18,10 +18,11 @@ #include "mndDb.h" #include "mndPrivilege.h" #include "mndShow.h" +#include "mndTopic.h" #include "mndTrans.h" #include "tbase64.h" -#define USER_VER_NUMBER 1 +#define USER_VER_NUMBER 2 #define USER_RESERVE_SIZE 64 static int32_t mndCreateDefaultUsers(SMnode *pMnode); @@ -36,6 +37,8 @@ static int32_t mndProcessDropUserReq(SRpcMsg *pReq); static int32_t mndProcessGetUserAuthReq(SRpcMsg *pReq); static int32_t mndRetrieveUsers(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextUser(SMnode *pMnode, void *pIter); +static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); +static void mndCancelGetNextPrivileges(SMnode *pMnode, void *pIter); int32_t mndInitUser(SMnode *pMnode) { SSdbTable table = { @@ -56,6 +59,8 @@ int32_t mndInitUser(SMnode *pMnode) { mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_USER, mndRetrieveUsers); mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_USER, mndCancelGetNextUser); + mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_PRIVILEGES, mndRetrievePrivileges); + mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_PRIVILEGES, mndCancelGetNextPrivileges); return sdbSetTable(pMnode->pSdb, table); } @@ -119,7 +124,9 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) { int32_t numOfReadDbs = taosHashGetSize(pUser->readDbs); int32_t numOfWriteDbs = taosHashGetSize(pUser->writeDbs); - int32_t size = sizeof(SUserObj) + USER_RESERVE_SIZE + (numOfReadDbs + numOfWriteDbs) * TSDB_DB_FNAME_LEN; + int32_t numOfTopics = taosHashGetSize(pUser->topics); + int32_t size = sizeof(SUserObj) + USER_RESERVE_SIZE + (numOfReadDbs + numOfWriteDbs) * TSDB_DB_FNAME_LEN + + numOfTopics * TSDB_TOPIC_FNAME_LEN; SSdbRaw *pRaw = sdbAllocRaw(SDB_USER, USER_VER_NUMBER, size); if (pRaw == NULL) goto _OVER; @@ -137,6 +144,7 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) { SDB_SET_INT32(pRaw, dataPos, pUser->authVersion, _OVER) SDB_SET_INT32(pRaw, dataPos, numOfReadDbs, _OVER) SDB_SET_INT32(pRaw, dataPos, numOfWriteDbs, _OVER) + SDB_SET_INT32(pRaw, dataPos, numOfTopics, _OVER) char *db = taosHashIterate(pUser->readDbs, NULL); while (db != NULL) { @@ -150,6 +158,12 @@ SSdbRaw *mndUserActionEncode(SUserObj *pUser) { db = taosHashIterate(pUser->writeDbs, db); } + char *topic = taosHashIterate(pUser->topics, NULL); + while (topic != NULL) { + SDB_SET_BINARY(pRaw, dataPos, topic, TSDB_TOPIC_FNAME_LEN, _OVER); + topic = taosHashIterate(pUser->topics, topic); + } + SDB_SET_RESERVE(pRaw, dataPos, USER_RESERVE_SIZE, _OVER) SDB_SET_DATALEN(pRaw, dataPos, _OVER) @@ -168,19 +182,21 @@ _OVER: static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; + SSdbRow *pRow = NULL; + SUserObj *pUser = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; - if (sver != USER_VER_NUMBER) { + if (sver != 1 && sver != 2) { terrno = TSDB_CODE_SDB_INVALID_DATA_VER; goto _OVER; } - SSdbRow *pRow = sdbAllocRow(sizeof(SUserObj)); + pRow = sdbAllocRow(sizeof(SUserObj)); if (pRow == NULL) goto _OVER; - SUserObj *pUser = sdbGetRowObj(pRow); + pUser = sdbGetRowObj(pRow); if (pUser == NULL) goto _OVER; int32_t dataPos = 0; @@ -197,12 +213,18 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) { int32_t numOfReadDbs = 0; int32_t numOfWriteDbs = 0; + int32_t numOfTopics = 0; SDB_GET_INT32(pRaw, dataPos, &numOfReadDbs, _OVER) SDB_GET_INT32(pRaw, dataPos, &numOfWriteDbs, _OVER) + if (sver >= 2) { + SDB_GET_INT32(pRaw, dataPos, &numOfTopics, _OVER) + } + pUser->readDbs = taosHashInit(numOfReadDbs, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); pUser->writeDbs = taosHashInit(numOfWriteDbs, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); - if (pUser->readDbs == NULL || pUser->writeDbs == NULL) goto _OVER; + pUser->topics = taosHashInit(numOfTopics, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + if (pUser->readDbs == NULL || pUser->writeDbs == NULL || pUser->topics == NULL) goto _OVER; for (int32_t i = 0; i < numOfReadDbs; ++i) { char db[TSDB_DB_FNAME_LEN] = {0}; @@ -218,6 +240,15 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) { taosHashPut(pUser->writeDbs, db, len, db, TSDB_DB_FNAME_LEN); } + if (sver >= 2) { + for (int32_t i = 0; i < numOfTopics; ++i) { + char topic[TSDB_TOPIC_FNAME_LEN] = {0}; + SDB_GET_BINARY(pRaw, dataPos, topic, TSDB_TOPIC_FNAME_LEN, _OVER) + int32_t len = strlen(topic) + 1; + taosHashPut(pUser->topics, topic, len, topic, TSDB_TOPIC_FNAME_LEN); + } + } + SDB_GET_RESERVE(pRaw, dataPos, USER_RESERVE_SIZE, _OVER) taosInitRWLatch(&pUser->lock); @@ -225,9 +256,12 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw) { _OVER: if (terrno != 0) { - mError("user:%s, failed to decode from raw:%p since %s", pUser->user, pRaw, terrstr()); - taosHashCleanup(pUser->readDbs); - taosHashCleanup(pUser->writeDbs); + mError("user:%s, failed to decode from raw:%p since %s", pUser == NULL ? "null" : pUser->user, pRaw, terrstr()); + if (pUser != NULL) { + taosHashCleanup(pUser->readDbs); + taosHashCleanup(pUser->writeDbs); + taosHashCleanup(pUser->topics); + } taosMemoryFreeClear(pRow); return NULL; } @@ -255,8 +289,10 @@ static int32_t mndUserActionDelete(SSdb *pSdb, SUserObj *pUser) { mTrace("user:%s, perform delete action, row:%p", pUser->user, pUser); taosHashCleanup(pUser->readDbs); taosHashCleanup(pUser->writeDbs); + taosHashCleanup(pUser->topics); pUser->readDbs = NULL; pUser->writeDbs = NULL; + pUser->topics = NULL; return 0; } @@ -270,6 +306,7 @@ static int32_t mndUserActionUpdate(SSdb *pSdb, SUserObj *pOld, SUserObj *pNew) { memcpy(pOld->pass, pNew->pass, TSDB_PASSWORD_LEN); TSWAP(pOld->readDbs, pNew->readDbs); TSWAP(pOld->writeDbs, pNew->writeDbs); + TSWAP(pOld->topics, pNew->topics); taosWUnLockLatch(&pOld->lock); return 0; @@ -409,7 +446,7 @@ static int32_t mndAlterUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SRpc return 0; } -SHashObj *mndDupDbHash(SHashObj *pOld) { +SHashObj *mndDupObjHash(SHashObj *pOld, int32_t dataLen) { SHashObj *pNew = taosHashInit(taosHashGetSize(pOld), taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); if (pNew == NULL) { @@ -420,7 +457,7 @@ SHashObj *mndDupDbHash(SHashObj *pOld) { char *db = taosHashIterate(pOld, NULL); while (db != NULL) { int32_t len = strlen(db) + 1; - if (taosHashPut(pNew, db, len, db, TSDB_DB_FNAME_LEN) != 0) { + if (taosHashPut(pNew, db, len, db, dataLen) != 0) { taosHashCancelIterate(pOld, db); taosHashCleanup(pNew); terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -432,6 +469,10 @@ SHashObj *mndDupDbHash(SHashObj *pOld) { return pNew; } +SHashObj *mndDupDbHash(SHashObj *pOld) { return mndDupObjHash(pOld, TSDB_DB_FNAME_LEN); } + +SHashObj *mndDupTopicHash(SHashObj *pOld) { return mndDupObjHash(pOld, TSDB_TOPIC_FNAME_LEN); } + static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; SSdb *pSdb = pMnode->pSdb; @@ -482,9 +523,10 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) { taosRLockLatch(&pUser->lock); newUser.readDbs = mndDupDbHash(pUser->readDbs); newUser.writeDbs = mndDupDbHash(pUser->writeDbs); + newUser.topics = mndDupTopicHash(pUser->topics); taosRUnLockLatch(&pUser->lock); - if (newUser.readDbs == NULL || newUser.writeDbs == NULL) { + if (newUser.readDbs == NULL || newUser.writeDbs == NULL || newUser.topics == NULL) { goto _OVER; } @@ -507,14 +549,14 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) { } if (alterReq.alterType == TSDB_ALTER_USER_ADD_READ_DB || alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_DB) { - if (strcmp(alterReq.dbname, "1.*") != 0) { - int32_t len = strlen(alterReq.dbname) + 1; - SDbObj *pDb = mndAcquireDb(pMnode, alterReq.dbname); + if (strcmp(alterReq.objname, "1.*") != 0) { + int32_t len = strlen(alterReq.objname) + 1; + SDbObj *pDb = mndAcquireDb(pMnode, alterReq.objname); if (pDb == NULL) { mndReleaseDb(pMnode, pDb); goto _OVER; } - if (taosHashPut(newUser.readDbs, alterReq.dbname, len, alterReq.dbname, TSDB_DB_FNAME_LEN) != 0) { + if (taosHashPut(newUser.readDbs, alterReq.objname, len, alterReq.objname, TSDB_DB_FNAME_LEN) != 0) { mndReleaseDb(pMnode, pDb); goto _OVER; } @@ -531,14 +573,14 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) { } if (alterReq.alterType == TSDB_ALTER_USER_ADD_WRITE_DB || alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_DB) { - if (strcmp(alterReq.dbname, "1.*") != 0) { - int32_t len = strlen(alterReq.dbname) + 1; - SDbObj *pDb = mndAcquireDb(pMnode, alterReq.dbname); + if (strcmp(alterReq.objname, "1.*") != 0) { + int32_t len = strlen(alterReq.objname) + 1; + SDbObj *pDb = mndAcquireDb(pMnode, alterReq.objname); if (pDb == NULL) { mndReleaseDb(pMnode, pDb); goto _OVER; } - if (taosHashPut(newUser.writeDbs, alterReq.dbname, len, alterReq.dbname, TSDB_DB_FNAME_LEN) != 0) { + if (taosHashPut(newUser.writeDbs, alterReq.objname, len, alterReq.objname, TSDB_DB_FNAME_LEN) != 0) { mndReleaseDb(pMnode, pDb); goto _OVER; } @@ -555,33 +597,53 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) { } if (alterReq.alterType == TSDB_ALTER_USER_REMOVE_READ_DB || alterReq.alterType == TSDB_ALTER_USER_REMOVE_ALL_DB) { - if (strcmp(alterReq.dbname, "1.*") != 0) { - int32_t len = strlen(alterReq.dbname) + 1; - SDbObj *pDb = mndAcquireDb(pMnode, alterReq.dbname); + if (strcmp(alterReq.objname, "1.*") != 0) { + int32_t len = strlen(alterReq.objname) + 1; + SDbObj *pDb = mndAcquireDb(pMnode, alterReq.objname); if (pDb == NULL) { mndReleaseDb(pMnode, pDb); goto _OVER; } - taosHashRemove(newUser.readDbs, alterReq.dbname, len); + taosHashRemove(newUser.readDbs, alterReq.objname, len); } else { taosHashClear(newUser.readDbs); } } if (alterReq.alterType == TSDB_ALTER_USER_REMOVE_WRITE_DB || alterReq.alterType == TSDB_ALTER_USER_REMOVE_ALL_DB) { - if (strcmp(alterReq.dbname, "1.*") != 0) { - int32_t len = strlen(alterReq.dbname) + 1; - SDbObj *pDb = mndAcquireDb(pMnode, alterReq.dbname); + if (strcmp(alterReq.objname, "1.*") != 0) { + int32_t len = strlen(alterReq.objname) + 1; + SDbObj *pDb = mndAcquireDb(pMnode, alterReq.objname); if (pDb == NULL) { mndReleaseDb(pMnode, pDb); goto _OVER; } - taosHashRemove(newUser.writeDbs, alterReq.dbname, len); + taosHashRemove(newUser.writeDbs, alterReq.objname, len); } else { taosHashClear(newUser.writeDbs); } } + if (alterReq.alterType == TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC) { + int32_t len = strlen(alterReq.objname) + 1; + SMqTopicObj *pTopic = mndAcquireTopic(pMnode, alterReq.objname); + if (pTopic == NULL) { + mndReleaseTopic(pMnode, pTopic); + goto _OVER; + } + taosHashPut(newUser.topics, pTopic->name, len, pTopic->name, TSDB_TOPIC_FNAME_LEN); + } + + if (alterReq.alterType == TSDB_ALTER_USER_REMOVE_SUBSCRIBE_TOPIC) { + int32_t len = strlen(alterReq.objname) + 1; + SMqTopicObj *pTopic = mndAcquireTopic(pMnode, alterReq.objname); + if (pTopic == NULL) { + mndReleaseTopic(pMnode, pTopic); + goto _OVER; + } + taosHashRemove(newUser.topics, alterReq.objname, len); + } + code = mndAlterUser(pMnode, pUser, &newUser, pReq); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; @@ -594,6 +656,7 @@ _OVER: mndReleaseUser(pMnode, pUser); taosHashCleanup(newUser.writeDbs); taosHashCleanup(newUser.readDbs); + taosHashCleanup(newUser.topics); return code; } @@ -756,6 +819,128 @@ static void mndCancelGetNextUser(SMnode *pMnode, void *pIter) { sdbCancelFetch(pSdb, pIter); } +static int32_t mndRetrievePrivileges(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { + SMnode *pMnode = pReq->info.node; + SSdb *pSdb = pMnode->pSdb; + int32_t numOfRows = 0; + SUserObj *pUser = NULL; + int32_t cols = 0; + char *pWrite; + + while (numOfRows < rows) { + pShow->pIter = sdbFetch(pSdb, SDB_USER, pShow->pIter, (void **)&pUser); + if (pShow->pIter == NULL) break; + + int32_t numOfReadDbs = taosHashGetSize(pUser->readDbs); + int32_t numOfWriteDbs = taosHashGetSize(pUser->writeDbs); + int32_t numOfTopics = taosHashGetSize(pUser->topics); + if (numOfRows + numOfReadDbs + numOfWriteDbs + numOfTopics >= rows) break; + + if (pUser->superUser) { + cols = 0; + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + char userName[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(userName, pUser->user, pShow->pMeta->pSchemas[cols].bytes); + colDataAppend(pColInfo, numOfRows, (const char *)userName, false); + + char privilege[20] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(privilege, "all", pShow->pMeta->pSchemas[cols].bytes); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)privilege, false); + + char objName[20] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(objName, "all", pShow->pMeta->pSchemas[cols].bytes); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)objName, false); + + numOfRows++; + } + + char *db = taosHashIterate(pUser->readDbs, NULL); + while (db != NULL) { + cols = 0; + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + char userName[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(userName, pUser->user, pShow->pMeta->pSchemas[cols].bytes); + colDataAppend(pColInfo, numOfRows, (const char *)userName, false); + + char privilege[20] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(privilege, "read", pShow->pMeta->pSchemas[cols].bytes); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)privilege, false); + + SName name = {0}; + char objName[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + tNameFromString(&name, db, T_NAME_ACCT | T_NAME_DB); + tNameGetDbName(&name, varDataVal(objName)); + varDataSetLen(objName, strlen(varDataVal(objName))); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)objName, false); + + numOfRows++; + db = taosHashIterate(pUser->readDbs, db); + } + + db = taosHashIterate(pUser->writeDbs, NULL); + while (db != NULL) { + cols = 0; + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + char userName[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(userName, pUser->user, pShow->pMeta->pSchemas[cols].bytes); + colDataAppend(pColInfo, numOfRows, (const char *)userName, false); + + char privilege[20] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(privilege, "write", pShow->pMeta->pSchemas[cols].bytes); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)privilege, false); + + SName name = {0}; + char objName[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + tNameFromString(&name, db, T_NAME_ACCT | T_NAME_DB); + tNameGetDbName(&name, varDataVal(objName)); + varDataSetLen(objName, strlen(varDataVal(objName))); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)objName, false); + + numOfRows++; + db = taosHashIterate(pUser->writeDbs, db); + } + + char *topic = taosHashIterate(pUser->topics, NULL); + while (topic != NULL) { + cols = 0; + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + char userName[TSDB_USER_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(userName, pUser->user, pShow->pMeta->pSchemas[cols].bytes); + colDataAppend(pColInfo, numOfRows, (const char *)userName, false); + + char privilege[20] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(privilege, "subscribe", pShow->pMeta->pSchemas[cols].bytes); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)privilege, false); + + char topicName[TSDB_TOPIC_NAME_LEN + VARSTR_HEADER_SIZE + 5] = {0}; + tstrncpy(varDataVal(topicName), mndGetDbStr(topic), TSDB_TOPIC_NAME_LEN - 2); + varDataSetLen(topicName, strlen(varDataVal(topicName))); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataAppend(pColInfo, numOfRows, (const char *)topicName, false); + + numOfRows++; + topic = taosHashIterate(pUser->topics, topic); + } + + sdbRelease(pSdb, pUser); + } + + pShow->numOfRows += numOfRows; + return numOfRows; +} + +static void mndCancelGetNextPrivileges(SMnode *pMnode, void *pIter) { + SSdb *pSdb = pMnode->pSdb; + sdbCancelFetch(pSdb, pIter); +} + int32_t mndValidateUserAuthInfo(SMnode *pMnode, SUserAuthVersion *pUsers, int32_t numOfUses, void **ppRsp, int32_t *pRspLen) { SUserAuthBatchRsp batchRsp = {0}; diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index d06853e470..b4ea8ee125 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -113,6 +113,8 @@ _OVER: SSdbRow *mndVgroupActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; + SSdbRow *pRow = NULL; + SVgObj *pVgroup = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; @@ -122,10 +124,10 @@ SSdbRow *mndVgroupActionDecode(SSdbRaw *pRaw) { goto _OVER; } - SSdbRow *pRow = sdbAllocRow(sizeof(SVgObj)); + pRow = sdbAllocRow(sizeof(SVgObj)); if (pRow == NULL) goto _OVER; - SVgObj *pVgroup = sdbGetRowObj(pRow); + pVgroup = sdbGetRowObj(pRow); if (pVgroup == NULL) goto _OVER; int32_t dataPos = 0; @@ -152,7 +154,7 @@ SSdbRow *mndVgroupActionDecode(SSdbRaw *pRaw) { _OVER: if (terrno != 0) { - mError("vgId:%d, failed to decode from raw:%p since %s", pVgroup->vgId, pRaw, terrstr()); + mError("vgId:%d, failed to decode from raw:%p since %s", pVgroup == NULL ? 0 : pVgroup->vgId, pRaw, terrstr()); taosMemoryFreeClear(pRow); return NULL; } @@ -186,6 +188,7 @@ static int32_t mndVgroupActionUpdate(SSdb *pSdb, SVgObj *pOld, SVgObj *pNew) { if (pNewGid->dnodeId == pOldGid->dnodeId) { pNewGid->syncState = pOldGid->syncState; pNewGid->syncRestore = pOldGid->syncRestore; + pNewGid->syncCanRead = pOldGid->syncCanRead; } } } @@ -273,7 +276,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg } if (createReq.selfIndex == -1) { - terrno = TSDB_CODE_MND_APP_ERROR; + terrno = TSDB_CODE_APP_ERROR; return NULL; } @@ -373,7 +376,7 @@ static void *mndBuildAlterVnodeReplicaReq(SMnode *pMnode, SDbObj *pDb, SVgObj *p } if (alterReq.selfIndex == -1) { - terrno = TSDB_CODE_MND_APP_ERROR; + terrno = TSDB_CODE_APP_ERROR; return NULL; } @@ -696,8 +699,16 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p if (!exist) { strcpy(role, "dropping"); } else if (online) { - bool show = (pVgroup->vnodeGid[i].syncState == TAOS_SYNC_STATE_LEADER && !pVgroup->vnodeGid[i].syncRestore); - snprintf(role, sizeof(role), "%s%s", syncStr(pVgroup->vnodeGid[i].syncState), show ? "*" : ""); + char *star = ""; + if (pVgroup->vnodeGid[i].syncState == TAOS_SYNC_STATE_LEADER) { + if (!pVgroup->vnodeGid[i].syncRestore && !pVgroup->vnodeGid[i].syncCanRead) { + star = "**"; + } else if (!pVgroup->vnodeGid[i].syncRestore && pVgroup->vnodeGid[i].syncCanRead) { + star = "*"; + } else { + } + } + snprintf(role, sizeof(role), "%s%s", syncStr(pVgroup->vnodeGid[i].syncState), star); } else { } STR_WITH_MAXSIZE_TO_VARSTR(buf1, role, pShow->pMeta->pSchemas[cols].bytes); @@ -987,7 +998,7 @@ int32_t mndAddCreateVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVg action.pCont = pReq; action.contLen = contLen; action.msgType = TDMT_DND_CREATE_VNODE; - action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED; + action.acceptableCode = TSDB_CODE_VND_ALREADY_EXIST; if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); @@ -1087,7 +1098,7 @@ int32_t mndAddDropVnodeAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgOb action.pCont = pReq; action.contLen = contLen; action.msgType = TDMT_DND_DROP_VNODE; - action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; + action.acceptableCode = TSDB_CODE_VND_NOT_EXIST; if (isRedo) { if (mndTransAppendRedoAction(pTrans, &action) != 0) { diff --git a/source/dnode/mnode/impl/test/acct/acct.cpp b/source/dnode/mnode/impl/test/acct/acct.cpp index 46a9a465eb..1f59a7fcca 100644 --- a/source/dnode/mnode/impl/test/acct/acct.cpp +++ b/source/dnode/mnode/impl/test/acct/acct.cpp @@ -32,7 +32,7 @@ TEST_F(MndTestAcct, 01_Create_Acct) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_ACCT, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_MSG_NOT_PROCESSED); + ASSERT_EQ(pRsp->code, TSDB_CODE_OPS_NOT_SUPPORT); } TEST_F(MndTestAcct, 02_Alter_Acct) { @@ -42,7 +42,7 @@ TEST_F(MndTestAcct, 02_Alter_Acct) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_ALTER_ACCT, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_MSG_NOT_PROCESSED); + ASSERT_EQ(pRsp->code, TSDB_CODE_OPS_NOT_SUPPORT); } TEST_F(MndTestAcct, 03_Drop_Acct) { @@ -52,5 +52,5 @@ TEST_F(MndTestAcct, 03_Drop_Acct) { SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_ACCT, pReq, contLen); ASSERT_NE(pRsp, nullptr); - ASSERT_EQ(pRsp->code, TSDB_CODE_MSG_NOT_PROCESSED); + ASSERT_EQ(pRsp->code, TSDB_CODE_OPS_NOT_SUPPORT); } diff --git a/source/dnode/mnode/impl/test/trans/trans2.cpp b/source/dnode/mnode/impl/test/trans/trans2.cpp index 60be7cfbc0..89c2b6931a 100644 --- a/source/dnode/mnode/impl/test/trans/trans2.cpp +++ b/source/dnode/mnode/impl/test/trans/trans2.cpp @@ -173,7 +173,7 @@ class MndTestTrans2 : public ::testing::Test { action.pCont = pReq; action.contLen = contLen; action.msgType = TDMT_DND_CREATE_MNODE; - action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED; + action.acceptableCode = TSDB_CODE_MNODE_ALREADY_DEPLOYED; mndTransAppendRedoAction(pTrans, &action); } @@ -190,7 +190,7 @@ class MndTestTrans2 : public ::testing::Test { action.pCont = pReq; action.contLen = contLen; action.msgType = TDMT_DND_CREATE_MNODE; - action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED; + action.acceptableCode = TSDB_CODE_MNODE_ALREADY_DEPLOYED; mndTransAppendUndoAction(pTrans, &action); } diff --git a/source/dnode/mnode/sdb/src/sdbFile.c b/source/dnode/mnode/sdb/src/sdbFile.c index 6558a98aaa..318a746bb0 100644 --- a/source/dnode/mnode/sdb/src/sdbFile.c +++ b/source/dnode/mnode/sdb/src/sdbFile.c @@ -415,7 +415,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) { break; } } else { - code = TSDB_CODE_SDB_APP_ERROR; + code = TSDB_CODE_APP_ERROR; taosHashCancelIterate(hash, ppRow); break; } diff --git a/source/dnode/mnode/sdb/src/sdbHash.c b/source/dnode/mnode/sdb/src/sdbHash.c index c44b659ef5..32b34ea3a3 100644 --- a/source/dnode/mnode/sdb/src/sdbHash.c +++ b/source/dnode/mnode/sdb/src/sdbHash.c @@ -108,7 +108,7 @@ static SHashObj *sdbGetHash(SSdb *pSdb, int32_t type) { SHashObj *hash = pSdb->hashObjs[type]; if (hash == NULL) { - terrno = TSDB_CODE_SDB_APP_ERROR; + terrno = TSDB_CODE_APP_ERROR; return NULL; } @@ -302,7 +302,7 @@ void *sdbAcquire(SSdb *pSdb, ESdbType type, const void *pKey) { terrno = TSDB_CODE_SDB_OBJ_DROPPING; break; default: - terrno = TSDB_CODE_SDB_APP_ERROR; + terrno = TSDB_CODE_APP_ERROR; break; } diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index aa55204ae5..b133226ed3 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -168,7 +168,7 @@ int32_t sndProcessTaskDeployReq(SSnode *pSnode, char *msg, int32_t msgLen) { int32_t sndProcessTaskDropReq(SSnode *pSnode, char *msg, int32_t msgLen) { SVDropStreamTaskReq *pReq = (SVDropStreamTaskReq *)msg; - streamMetaRemoveTask1(pSnode->pMeta, pReq->taskId); + streamMetaRemoveTask(pSnode->pMeta, pReq->taskId); return 0; } diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 7ef3207b4d..c4040644b1 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -106,14 +106,24 @@ int32_t metaGetTableTagsByUids(SMeta *pMeta, int64_t suid, SArray *uidList, int32_t metaReadNext(SMetaReader *pReader); const void *metaGetTableTagVal(void *tag, int16_t type, STagVal *tagVal); int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName); -int metaGetTableUidByName(void *meta, char *tbName, uint64_t *uid); -int metaGetTableTypeByName(void *meta, char *tbName, ETableType *tbType); -bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid); -int32_t metaGetCachedTableUidList(SMeta *pMeta, tb_uid_t suid, const uint8_t *key, int32_t keyLen, SArray *pList, - bool *acquired); -int32_t metaUidFilterCachePut(SMeta *pMeta, uint64_t suid, const void *pKey, int32_t keyLen, void *pPayload, - int32_t payloadLen, double selectivityRatio); -int32_t metaUidCacheClear(SMeta *pMeta, uint64_t suid); + +int metaGetTableSzNameByUid(void *meta, uint64_t uid, char *tbName); +int metaGetTableUidByName(void *meta, char *tbName, uint64_t *uid); +int metaGetTableTypeByName(void *meta, char *tbName, ETableType *tbType); +bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid); +int32_t metaGetCachedTableUidList(SMeta *pMeta, tb_uid_t suid, const uint8_t *key, int32_t keyLen, SArray *pList, + bool *acquired); +int32_t metaUidFilterCachePut(SMeta *pMeta, uint64_t suid, const void *pKey, int32_t keyLen, void *pPayload, + int32_t payloadLen, double selectivityRatio); +int32_t metaUidCacheClear(SMeta *pMeta, uint64_t suid); +tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name); +int64_t metaGetTbNum(SMeta *pMeta); +int64_t metaGetNtbNum(SMeta *pMeta); +typedef struct { + int64_t uid; + int64_t ctbNum; +} SMetaStbStats; +int32_t metaGetStbStats(SMeta *pMeta, int64_t uid, SMetaStbStats *pInfo); typedef struct SMetaFltParam { tb_uid_t suid; @@ -159,20 +169,19 @@ typedef struct STsdbReader STsdbReader; int32_t tsdbSetTableList(STsdbReader *pReader, const void *pTableList, int32_t num); int32_t tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, void *pTableList, int32_t numOfTables, - STsdbReader **ppReader, const char *idstr); + SSDataBlock *pResBlock, STsdbReader **ppReader, const char *idstr); -void tsdbReaderClose(STsdbReader *pReader); -bool tsdbNextDataBlock(STsdbReader *pReader); -bool tsdbTableNextDataBlock(STsdbReader *pReader, uint64_t uid); -void tsdbRetrieveDataBlockInfo(const STsdbReader *pReader, int32_t *rows, uint64_t *uid, STimeWindow *pWindow); -int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SColumnDataAgg ***pBlockStatis, bool *allHave); -SArray *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList); -int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond); -int32_t tsdbGetFileBlocksDistInfo(STsdbReader *pReader, STableBlockDistInfo *pTableBlockInfo); -int64_t tsdbGetNumOfRowsInMemTable(STsdbReader *pHandle); -void *tsdbGetIdx(SMeta *pMeta); -void *tsdbGetIvtIdx(SMeta *pMeta); -uint64_t getReaderMaxVersion(STsdbReader *pReader); +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, SColumnDataAgg ***pBlockSMA, bool *allHave); +SSDataBlock *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList); +int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond); +int32_t tsdbGetFileBlocksDistInfo(STsdbReader *pReader, STableBlockDistInfo *pTableBlockInfo); +int64_t tsdbGetNumOfRowsInMemTable(STsdbReader *pHandle); +void *tsdbGetIdx(SMeta *pMeta); +void *tsdbGetIvtIdx(SMeta *pMeta); +uint64_t getReaderMaxVersion(STsdbReader *pReader); int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, void *pTableIdList, int32_t numOfTables, int32_t numOfCols, uint64_t suid, void **pReader); diff --git a/source/dnode/vnode/src/inc/meta.h b/source/dnode/vnode/src/inc/meta.h index dbfe9e1671..3999aa0b7f 100644 --- a/source/dnode/vnode/src/inc/meta.h +++ b/source/dnode/vnode/src/inc/meta.h @@ -70,7 +70,7 @@ int32_t metaCacheDrop(SMeta* pMeta, int64_t uid); int32_t metaStatsCacheUpsert(SMeta* pMeta, SMetaStbStats* pInfo); int32_t metaStatsCacheDrop(SMeta* pMeta, int64_t uid); int32_t metaStatsCacheGet(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo); -void metaUpdateStbStats(SMeta *pMeta, int64_t uid, int64_t delta); +void metaUpdateStbStats(SMeta* pMeta, int64_t uid, int64_t delta); int32_t metaUidFilterCacheGet(SMeta* pMeta, uint64_t suid, const void* pKey, int32_t keyLen, LRUHandle** pHandle); struct SMeta { @@ -79,7 +79,7 @@ struct SMeta { char* path; SVnode* pVnode; TDB* pEnv; - TXN txn; + TXN* txn; TTB* pTbDb; TTB* pSkmDb; TTB* pUidIdx; diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index 83f375c986..28797c5361 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -77,7 +77,7 @@ void vnodeBufPoolReset(SVBufPool* pPool); // vnodeQuery.c int32_t vnodeQueryOpen(SVnode* pVnode); -void vnodeQueryPreClose(SVnode *pVnode); +void vnodeQueryPreClose(SVnode* pVnode); void vnodeQueryClose(SVnode* pVnode); int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg, bool direct); int vnodeGetTableCfg(SVnode* pVnode, SRpcMsg* pMsg, bool direct); @@ -86,7 +86,6 @@ int32_t vnodeGetBatchMeta(SVnode* pVnode, SRpcMsg* pMsg); // vnodeCommit.c int32_t vnodeBegin(SVnode* pVnode); int32_t vnodeShouldCommit(SVnode* pVnode); -int32_t vnodeCommit(SVnode* pVnode); void vnodeRollback(SVnode* pVnode); int32_t vnodeSaveInfo(const char* dir, const SVnodeInfo* pCfg); int32_t vnodeCommitInfo(const char* dir, const SVnodeInfo* pInfo); @@ -97,10 +96,10 @@ bool vnodeShouldRollback(SVnode* pVnode); // vnodeSync.c int32_t vnodeSyncOpen(SVnode* pVnode, char* path); -void vnodeSyncStart(SVnode* pVnode); +int32_t vnodeSyncStart(SVnode* pVnode); void vnodeSyncPreClose(SVnode* pVnode); void vnodeSyncClose(SVnode* pVnode); -void vnodeRedirectRpcMsg(SVnode* pVnode, SRpcMsg* pMsg); +void vnodeRedirectRpcMsg(SVnode* pVnode, SRpcMsg* pMsg, int32_t code); bool vnodeIsLeader(SVnode* pVnode); bool vnodeIsRoleLeader(SVnode* pVnode); diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index f229b3b127..8cf212cb1d 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -75,6 +75,7 @@ typedef struct SStreamStateWriter SStreamStateWriter; typedef struct SRSmaSnapReader SRSmaSnapReader; typedef struct SRSmaSnapWriter SRSmaSnapWriter; typedef struct SSnapDataHdr SSnapDataHdr; +typedef struct SCommitInfo SCommitInfo; #define VNODE_META_DIR "meta" #define VNODE_TSDB_DIR "tsdb" @@ -100,8 +101,9 @@ typedef struct STbUidStore STbUidStore; int metaOpen(SVnode* pVnode, SMeta** ppMeta, int8_t rollback); int metaClose(SMeta* pMeta); int metaBegin(SMeta* pMeta, int8_t fromSys); -int metaCommit(SMeta* pMeta); -int metaFinishCommit(SMeta* pMeta); +TXN* metaGetTxn(SMeta* pMeta); +int metaCommit(SMeta* pMeta, TXN* txn); +int metaFinishCommit(SMeta* pMeta, TXN* txn); int metaPrepareAsyncCommit(SMeta* pMeta); int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq); int metaAlterSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq); @@ -116,8 +118,6 @@ int32_t metaGetTbTSchemaEx(SMeta* pMeta, tb_uid_t suid, tb_uid_t uid, in int metaGetTableEntryByName(SMetaReader* pReader, const char* name); int metaAlterCache(SMeta* pMeta, int32_t nPage); -tb_uid_t metaGetTableEntryUidByName(SMeta* pMeta, const char* name); -int64_t metaGetTbNum(SMeta* pMeta); int64_t metaGetTimeSeriesNum(SMeta* pMeta); SMCtbCursor* metaOpenCtbCursor(SMeta* pMeta, tb_uid_t uid, int lock); void metaCloseCtbCursor(SMCtbCursor* pCtbCur, int lock); @@ -144,17 +144,12 @@ typedef struct SMetaInfo { } SMetaInfo; int32_t metaGetInfo(SMeta* pMeta, int64_t uid, SMetaInfo* pInfo, SMetaReader* pReader); -typedef struct { - int64_t uid; - int64_t ctbNum; -} SMetaStbStats; -int32_t metaGetStbStats(SMeta* pMeta, int64_t uid, SMetaStbStats* pInfo); - // tsdb int tsdbOpen(SVnode* pVnode, STsdb** ppTsdb, const char* dir, STsdbKeepCfg* pKeepCfg, int8_t rollback); int tsdbClose(STsdb** pTsdb); int32_t tsdbBegin(STsdb* pTsdb); -int32_t tsdbCommit(STsdb* pTsdb); +int32_t tsdbPrepareCommit(STsdb* pTsdb); +int32_t tsdbCommit(STsdb* pTsdb, SCommitInfo* pInfo); int32_t tsdbFinishCommit(STsdb* pTsdb); int32_t tsdbRollbackCommit(STsdb* pTsdb); int32_t tsdbDoRetention(STsdb* pTsdb, int64_t now); @@ -211,8 +206,8 @@ int32_t smaBegin(SSma* pSma); int32_t smaSyncPreCommit(SSma* pSma); int32_t smaSyncCommit(SSma* pSma); int32_t smaSyncPostCommit(SSma* pSma); -int32_t smaPreCommit(SSma* pSma); -int32_t smaCommit(SSma* pSma); +int32_t smaPrepareAsyncCommit(SSma* pSma); +int32_t smaCommit(SSma* pSma, SCommitInfo* pInfo); int32_t smaFinishCommit(SSma* pSma); int32_t smaPostCommit(SSma* pSma); int32_t smaDoRetention(SSma* pSma, int64_t now); @@ -414,6 +409,12 @@ struct SSnapDataHdr { uint8_t data[]; }; +struct SCommitInfo { + SVnodeInfo info; + SVnode* pVnode; + TXN* txn; +}; + #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/src/meta/metaCommit.c b/source/dnode/vnode/src/meta/metaCommit.c index 0be0c3e407..5eb27679bb 100644 --- a/source/dnode/vnode/src/meta/metaCommit.c +++ b/source/dnode/vnode/src/meta/metaCommit.c @@ -20,12 +20,19 @@ static FORCE_INLINE void metaFree(void *pPool, void *p) { vnodeBufPoolFree((SVB // begin a meta txn int metaBegin(SMeta *pMeta, int8_t fromSys) { + void *(*xMalloc)(void *, size_t); + void (*xFree)(void *, void *); + void *xArg = NULL; + if (fromSys) { - tdbTxnOpen(&pMeta->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); + xMalloc = tdbDefaultMalloc; + xFree = tdbDefaultFree; } else { - tdbTxnOpen(&pMeta->txn, 0, metaMalloc, metaFree, pMeta->pVnode->inUse, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); + xMalloc = metaMalloc; + xFree = metaFree; + xArg = pMeta->pVnode->inUse; } - if (tdbBegin(pMeta->pEnv, &pMeta->txn) < 0) { + if (tdbBegin(pMeta->pEnv, &pMeta->txn, xMalloc, xFree, xArg, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { return -1; } @@ -33,9 +40,16 @@ int metaBegin(SMeta *pMeta, int8_t fromSys) { } // commit the meta txn -int metaCommit(SMeta *pMeta) { return tdbCommit(pMeta->pEnv, &pMeta->txn); } -int metaFinishCommit(SMeta *pMeta) { return tdbPostCommit(pMeta->pEnv, &pMeta->txn); } -int metaPrepareAsyncCommit(SMeta *pMeta) { return tdbPrepareAsyncCommit(pMeta->pEnv, &pMeta->txn); } +TXN *metaGetTxn(SMeta *pMeta) { return pMeta->txn; } +int metaCommit(SMeta *pMeta, TXN *txn) { return tdbCommit(pMeta->pEnv, txn); } +int metaFinishCommit(SMeta *pMeta, TXN *txn) { return tdbPostCommit(pMeta->pEnv, txn); } +int metaPrepareAsyncCommit(SMeta *pMeta) { + // return tdbPrepareAsyncCommit(pMeta->pEnv, pMeta->txn); + int code = 0; + code = tdbCommit(pMeta->pEnv, pMeta->txn); + + return code; +} // abort the meta txn -int metaAbort(SMeta *pMeta) { return tdbAbort(pMeta->pEnv, &pMeta->txn); } +int metaAbort(SMeta *pMeta) { return tdbAbort(pMeta->pEnv, pMeta->txn); } diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index 0257aede3d..cfdb4ab8d1 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -223,6 +223,23 @@ int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName) { return 0; } + +int metaGetTableSzNameByUid(void *meta, uint64_t uid, char *tbName) { + int code = 0; + SMetaReader mr = {0}; + metaReaderInit(&mr, (SMeta *)meta, 0); + code = metaGetTableEntryByUid(&mr, uid); + if (code < 0) { + metaReaderClear(&mr); + return -1; + } + strncpy(tbName, mr.me.name, TSDB_TABLE_NAME_LEN); + metaReaderClear(&mr); + + return 0; +} + + int metaGetTableUidByName(void *meta, char *tbName, uint64_t *uid) { int code = 0; SMetaReader mr = {0}; @@ -739,6 +756,10 @@ int64_t metaGetTimeSeriesNum(SMeta *pMeta) { return pMeta->pVnode->config.vndStats.numOfTimeSeries + pMeta->pVnode->config.vndStats.numOfNTimeSeries; } +int64_t metaGetNtbNum(SMeta *pMeta) { + return pMeta->pVnode->config.vndStats.numOfNTables; +} + typedef struct { SMeta *pMeta; TBC *pCur; diff --git a/source/dnode/vnode/src/meta/metaSma.c b/source/dnode/vnode/src/meta/metaSma.c index 52452bf710..8d5821e28b 100644 --- a/source/dnode/vnode/src/meta/metaSma.c +++ b/source/dnode/vnode/src/meta/metaSma.c @@ -117,7 +117,7 @@ static int metaSaveSmaToDB(SMeta *pMeta, const SMetaEntry *pME) { tEncoderClear(&coder); // write to table.db - if (tdbTbInsert(pMeta->pTbDb, pKey, kLen, pVal, vLen, &pMeta->txn) < 0) { + if (tdbTbInsert(pMeta->pTbDb, pKey, kLen, pVal, vLen, pMeta->txn) < 0) { goto _err; } @@ -131,17 +131,17 @@ _err: static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME) { SUidIdxVal uidIdxVal = {.suid = pME->smaEntry.tsma->indexUid, .version = pME->version, .skmVer = 0}; - return tdbTbInsert(pMeta->pUidIdx, &pME->uid, sizeof(tb_uid_t), &uidIdxVal, sizeof(uidIdxVal), &pMeta->txn); + return tdbTbInsert(pMeta->pUidIdx, &pME->uid, sizeof(tb_uid_t), &uidIdxVal, sizeof(uidIdxVal), pMeta->txn); } static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME) { - return tdbTbInsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), &pMeta->txn); + return tdbTbInsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), pMeta->txn); } static int metaUpdateSmaIdx(SMeta *pMeta, const SMetaEntry *pME) { SSmaIdxKey smaIdxKey = {.uid = pME->smaEntry.tsma->tableUid, .smaUid = pME->smaEntry.tsma->indexUid}; - return tdbTbInsert(pMeta->pSmaIdx, &smaIdxKey, sizeof(smaIdxKey), NULL, 0, &pMeta->txn); + return tdbTbInsert(pMeta->pSmaIdx, &smaIdxKey, sizeof(smaIdxKey), NULL, 0, pMeta->txn); } static int metaHandleSmaEntry(SMeta *pMeta, const SMetaEntry *pME) { diff --git a/source/dnode/vnode/src/meta/metaSnapshot.c b/source/dnode/vnode/src/meta/metaSnapshot.c index 5c5b49ece5..6a4dcf6ead 100644 --- a/source/dnode/vnode/src/meta/metaSnapshot.c +++ b/source/dnode/vnode/src/meta/metaSnapshot.c @@ -163,9 +163,9 @@ int32_t metaSnapWriterClose(SMetaSnapWriter** ppWriter, int8_t rollback) { if (rollback) { ASSERT(0); } else { - code = metaCommit(pWriter->pMeta); + code = metaCommit(pWriter->pMeta, pWriter->pMeta->txn); if (code) goto _err; - code = metaFinishCommit(pWriter->pMeta); + code = metaFinishCommit(pWriter->pMeta, pWriter->pMeta->txn); if (code) goto _err; } taosMemoryFree(pWriter); diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 5c97ee5633..0b00f036de 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -261,7 +261,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb // drop all child tables TBC *pCtbIdxc = NULL; - tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, &pMeta->txn); + tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, NULL); rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = pReq->suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c); if (rc < 0) { tdbTbcClose(pCtbIdxc); @@ -295,10 +295,10 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq, SArray *tb _drop_super_table: tdbTbGet(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), &pData, &nData); tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = ((SUidIdxVal *)pData)[0].version, .uid = pReq->suid}, - sizeof(STbDbKey), &pMeta->txn); - tdbTbDelete(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pMeta->txn); - tdbTbDelete(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), &pMeta->txn); - tdbTbDelete(pMeta->pSuidIdx, &pReq->suid, sizeof(tb_uid_t), &pMeta->txn); + sizeof(STbDbKey), pMeta->txn); + tdbTbDelete(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, pMeta->txn); + tdbTbDelete(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn); + tdbTbDelete(pMeta->pSuidIdx, &pReq->suid, sizeof(tb_uid_t), pMeta->txn); metaULock(pMeta); @@ -321,7 +321,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { int32_t ret; int32_t c = -2; - tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn); + tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL); ret = tdbTbcMoveTo(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &c); if (ret < 0 || c) { tdbTbcClose(pUidIdxc); @@ -340,7 +340,7 @@ int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { oversion = ((SUidIdxVal *)pData)[0].version; - tdbTbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn); + tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL); ret = tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = pReq->suid, .version = oversion}), sizeof(STbDbKey), &c); ASSERT(ret == 0 && c == 0); @@ -595,7 +595,7 @@ static int metaDeleteTtlIdx(SMeta *pMeta, const SMetaEntry *pME) { STtlIdxKey ttlKey = {0}; metaBuildTtlIdxKey(&ttlKey, pME); if (ttlKey.dtime == 0) return 0; - return tdbTbDelete(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), &pMeta->txn); + return tdbTbDelete(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), pMeta->txn); } static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) { @@ -657,7 +657,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) { if (metaCreateTagIdxKey(e.ctbEntry.suid, pTagColumn->colId, pTagData, nTagData, pTagColumn->type, uid, &pTagIdxKey, &nTagIdxKey) == 0) { - tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, &pMeta->txn); + tdbTbDelete(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, pMeta->txn); } metaDestroyTagIdxKey(pTagIdxKey); } @@ -667,9 +667,9 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) { } } - tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), &pMeta->txn); - tdbTbDelete(pMeta->pNameIdx, e.name, strlen(e.name) + 1, &pMeta->txn); - tdbTbDelete(pMeta->pUidIdx, &uid, sizeof(uid), &pMeta->txn); + tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), pMeta->txn); + tdbTbDelete(pMeta->pNameIdx, e.name, strlen(e.name) + 1, pMeta->txn); + tdbTbDelete(pMeta->pUidIdx, &uid, sizeof(uid), pMeta->txn); if (e.type == TSDB_CHILD_TABLE || e.type == TSDB_NORMAL_TABLE) metaDeleteCtimeIdx(pMeta, &e); if (e.type == TSDB_NORMAL_TABLE) metaDeleteNcolIdx(pMeta, &e); @@ -677,7 +677,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) { if (e.type != TSDB_SUPER_TABLE) metaDeleteTtlIdx(pMeta, &e); if (e.type == TSDB_CHILD_TABLE) { - tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), &pMeta->txn); + tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), pMeta->txn); --pMeta->pVnode->config.vndStats.numOfCTables; @@ -689,7 +689,7 @@ static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) { --pMeta->pVnode->config.vndStats.numOfNTables; pMeta->pVnode->config.vndStats.numOfNTimeSeries -= e.ntbEntry.schemaRow.nCols - 1; } else if (e.type == TSDB_SUPER_TABLE) { - tdbTbDelete(pMeta->pSuidIdx, &e.uid, sizeof(tb_uid_t), &pMeta->txn); + tdbTbDelete(pMeta->pSuidIdx, &e.uid, sizeof(tb_uid_t), pMeta->txn); // drop schema.db (todo) metaStatsCacheDrop(pMeta, uid); @@ -710,7 +710,7 @@ int metaUpdateCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) { if (metaBuildCtimeIdxKey(&ctimeKey, pME) < 0) { return 0; } - return tdbTbInsert(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), NULL, 0, &pMeta->txn); + return tdbTbInsert(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), NULL, 0, pMeta->txn); } int metaDeleteCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) { @@ -718,14 +718,14 @@ int metaDeleteCtimeIdx(SMeta *pMeta, const SMetaEntry *pME) { if (metaBuildCtimeIdxKey(&ctimeKey, pME) < 0) { return 0; } - return tdbTbDelete(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), &pMeta->txn); + return tdbTbDelete(pMeta->pCtimeIdx, &ctimeKey, sizeof(ctimeKey), pMeta->txn); } int metaUpdateNcolIdx(SMeta *pMeta, const SMetaEntry *pME) { SNcolIdxKey ncolKey = {0}; if (metaBuildNColIdxKey(&ncolKey, pME) < 0) { return 0; } - return tdbTbInsert(pMeta->pNcolIdx, &ncolKey, sizeof(ncolKey), NULL, 0, &pMeta->txn); + return tdbTbInsert(pMeta->pNcolIdx, &ncolKey, sizeof(ncolKey), NULL, 0, pMeta->txn); } int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME) { @@ -733,7 +733,7 @@ int metaDeleteNcolIdx(SMeta *pMeta, const SMetaEntry *pME) { if (metaBuildNColIdxKey(&ncolKey, pME) < 0) { return 0; } - return tdbTbDelete(pMeta->pNcolIdx, &ncolKey, sizeof(ncolKey), &pMeta->txn); + return tdbTbDelete(pMeta->pNcolIdx, &ncolKey, sizeof(ncolKey), pMeta->txn); } static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAlterTbReq, STableMetaRsp *pMetaRsp) { @@ -768,7 +768,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl // search uid index TBC *pUidIdxc = NULL; - tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn); + tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL); tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c); ASSERT(c == 0); @@ -778,7 +778,7 @@ static int metaAlterTableColumn(SMeta *pMeta, int64_t version, SVAlterTbReq *pAl // search table.db TBC *pTbDbc = NULL; - tdbTbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn); + tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL); tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c); ASSERT(c == 0); tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData); @@ -959,7 +959,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA // search uid index TBC *pUidIdxc = NULL; - tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn); + tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL); tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c); ASSERT(c == 0); @@ -972,7 +972,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA SDecoder dc2 = {0}; /* get ctbEntry */ - tdbTbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn); + tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL); tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c); ASSERT(c == 0); tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData); @@ -1075,7 +1075,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA ASSERT(ctbEntry.ctbEntry.pTags); SCtbIdxKey ctbIdxKey = {.suid = ctbEntry.ctbEntry.suid, .uid = uid}; tdbTbUpsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), ctbEntry.ctbEntry.pTags, - ((STag *)(ctbEntry.ctbEntry.pTags))->len, &pMeta->txn); + ((STag *)(ctbEntry.ctbEntry.pTags))->len, pMeta->txn); metaUidCacheClear(pMeta, ctbEntry.ctbEntry.suid); @@ -1125,7 +1125,7 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p // search uid index TBC *pUidIdxc = NULL; - tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn); + tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, NULL); tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c); ASSERT(c == 0); @@ -1135,7 +1135,7 @@ static int metaUpdateTableOptions(SMeta *pMeta, int64_t version, SVAlterTbReq *p // search table.db TBC *pTbDbc = NULL; - tdbTbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn); + tdbTbcOpen(pMeta->pTbDb, &pTbDbc, NULL); tdbTbcMoveTo(pTbDbc, &((STbDbKey){.uid = uid, .version = oversion}), sizeof(STbDbKey), &c); ASSERT(c == 0); tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData); @@ -1242,7 +1242,7 @@ static int metaSaveToTbDb(SMeta *pMeta, const SMetaEntry *pME) { tEncoderClear(&coder); // write to table.db - if (tdbTbInsert(pMeta->pTbDb, pKey, kLen, pVal, vLen, &pMeta->txn) < 0) { + if (tdbTbInsert(pMeta->pTbDb, pKey, kLen, pVal, vLen, pMeta->txn) < 0) { goto _err; } @@ -1265,29 +1265,29 @@ static int metaUpdateUidIdx(SMeta *pMeta, const SMetaEntry *pME) { SUidIdxVal uidIdxVal = {.suid = info.suid, .version = info.version, .skmVer = info.skmVer}; - return tdbTbUpsert(pMeta->pUidIdx, &pME->uid, sizeof(tb_uid_t), &uidIdxVal, sizeof(uidIdxVal), &pMeta->txn); + return tdbTbUpsert(pMeta->pUidIdx, &pME->uid, sizeof(tb_uid_t), &uidIdxVal, sizeof(uidIdxVal), pMeta->txn); } static int metaUpdateSuidIdx(SMeta *pMeta, const SMetaEntry *pME) { - return tdbTbInsert(pMeta->pSuidIdx, &pME->uid, sizeof(tb_uid_t), NULL, 0, &pMeta->txn); + return tdbTbInsert(pMeta->pSuidIdx, &pME->uid, sizeof(tb_uid_t), NULL, 0, pMeta->txn); } static int metaUpdateNameIdx(SMeta *pMeta, const SMetaEntry *pME) { - return tdbTbInsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), &pMeta->txn); + return tdbTbInsert(pMeta->pNameIdx, pME->name, strlen(pME->name) + 1, &pME->uid, sizeof(tb_uid_t), pMeta->txn); } static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME) { STtlIdxKey ttlKey = {0}; metaBuildTtlIdxKey(&ttlKey, pME); if (ttlKey.dtime == 0) return 0; - return tdbTbInsert(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), NULL, 0, &pMeta->txn); + return tdbTbInsert(pMeta->pTtlIdx, &ttlKey, sizeof(ttlKey), NULL, 0, pMeta->txn); } static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME) { SCtbIdxKey ctbIdxKey = {.suid = pME->ctbEntry.suid, .uid = pME->uid}; return tdbTbInsert(pMeta->pCtbIdx, &ctbIdxKey, sizeof(ctbIdxKey), pME->ctbEntry.pTags, - ((STag *)(pME->ctbEntry.pTags))->len, &pMeta->txn); + ((STag *)(pME->ctbEntry.pTags))->len, pMeta->txn); } int metaCreateTagIdxKey(tb_uid_t suid, int32_t cid, const void *pTagData, int32_t nTagData, int8_t type, tb_uid_t uid, @@ -1379,7 +1379,7 @@ static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry) { ret = -1; goto end; } - tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, &pMeta->txn); + tdbTbUpsert(pMeta->pTagIdx, pTagIdxKey, nTagIdxKey, NULL, 0, pMeta->txn); } end: metaDestroyTagIdxKey(pTagIdxKey); @@ -1426,7 +1426,7 @@ static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME) { tEncoderInit(&coder, pVal, vLen); tEncodeSSchemaWrapper(&coder, pSW); - if (tdbTbInsert(pMeta->pSkmDb, &skmDbKey, sizeof(skmDbKey), pVal, vLen, &pMeta->txn) < 0) { + if (tdbTbInsert(pMeta->pSkmDb, &skmDbKey, sizeof(skmDbKey), pVal, vLen, pMeta->txn) < 0) { rcode = -1; goto _exit; } diff --git a/source/dnode/vnode/src/sma/smaCommit.c b/source/dnode/vnode/src/sma/smaCommit.c index a79ae35d79..9748963722 100644 --- a/source/dnode/vnode/src/sma/smaCommit.c +++ b/source/dnode/vnode/src/sma/smaCommit.c @@ -23,7 +23,7 @@ static int32_t tdProcessRSmaSyncCommitImpl(SSma *pSma); static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma); #endif static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma); -static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma); +static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma, SCommitInfo *pInfo); static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma); static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat); @@ -59,7 +59,7 @@ int32_t smaSyncPostCommit(SSma *pSma) { return tdProcessRSmaSyncPostCommitImpl(p * @param pSma * @return int32_t */ -int32_t smaPreCommit(SSma *pSma) { return tdProcessRSmaAsyncPreCommitImpl(pSma); } +int32_t smaPrepareAsyncCommit(SSma *pSma) { return tdProcessRSmaAsyncPreCommitImpl(pSma); } /** * @brief async commit, only applicable to Rollup SMA @@ -67,7 +67,7 @@ int32_t smaPreCommit(SSma *pSma) { return tdProcessRSmaAsyncPreCommitImpl(pSma); * @param pSma * @return int32_t */ -int32_t smaCommit(SSma *pSma) { return tdProcessRSmaAsyncCommitImpl(pSma); } +int32_t smaCommit(SSma *pSma, SCommitInfo *pInfo) { return tdProcessRSmaAsyncCommitImpl(pSma, pInfo); } /** * @brief async commit, only applicable to Rollup SMA @@ -127,8 +127,8 @@ _exit: } int32_t smaFinishCommit(SSma *pSma) { - int32_t code = 0; - SVnode *pVnode = pSma->pVnode; + int32_t code = 0; + SVnode *pVnode = pSma->pVnode; if (VND_RSMA1(pVnode) && (code = tsdbFinishCommit(VND_RSMA1(pVnode))) < 0) { smaError("vgId:%d, failed to finish commit tsdb rsma1 since %s", TD_VID(pVnode), tstrerror(code)); @@ -378,6 +378,11 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) { taosWUnLockLatch(SMA_ENV_LOCK(pEnv)); #endif + // all rsma results are written completely + STsdb *pTsdb = NULL; + if ((pTsdb = VND_RSMA1(pSma->pVnode))) tsdbPrepareCommit(pTsdb); + if ((pTsdb = VND_RSMA2(pSma->pVnode))) tsdbPrepareCommit(pTsdb); + return TSDB_CODE_SUCCESS; } @@ -387,9 +392,9 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) { * @param pSma * @return int32_t */ -static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma) { - int32_t code = 0; - SVnode *pVnode = pSma->pVnode; +static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma, SCommitInfo *pInfo) { + int32_t code = 0; + SVnode *pVnode = pSma->pVnode; #if 0 SRSmaStat *pRSmaStat = (SRSmaStat *)SMA_ENV_STAT(pSmaEnv); @@ -399,11 +404,11 @@ static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma) { } #endif - if ((code = tsdbCommit(VND_RSMA1(pVnode))) < 0) { + if ((code = tsdbCommit(VND_RSMA1(pVnode), pInfo)) < 0) { smaError("vgId:%d, failed to commit tsdb rsma1 since %s", TD_VID(pVnode), tstrerror(code)); goto _exit; } - if ((code = tsdbCommit(VND_RSMA2(pVnode))) < 0) { + if ((code = tsdbCommit(VND_RSMA2(pVnode), pInfo)) < 0) { smaError("vgId:%d, failed to commit tsdb rsma2 since %s", TD_VID(pVnode), tstrerror(code)); goto _exit; } diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 3d9ebec4c9..191fc1b49c 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -75,7 +75,7 @@ static void tqPushEntryFree(void* data) { STQ* tqOpen(const char* path, SVnode* pVnode) { STQ* pTq = taosMemoryCalloc(1, sizeof(STQ)); if (pTq == NULL) { - terrno = TSDB_CODE_TQ_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } pTq->path = strdup(path); @@ -1425,7 +1425,7 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) { int32_t tqProcessTaskDropReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen) { SVDropStreamTaskReq* pReq = (SVDropStreamTaskReq*)msg; - streamMetaRemoveTask1(pTq->pStreamMeta, pReq->taskId); + streamMetaRemoveTask(pTq->pStreamMeta, pReq->taskId); return 0; } diff --git a/source/dnode/vnode/src/tq/tqExec.c b/source/dnode/vnode/src/tq/tqExec.c index 2514190035..093186ebbb 100644 --- a/source/dnode/vnode/src/tq/tqExec.c +++ b/source/dnode/vnode/src/tq/tqExec.c @@ -25,7 +25,7 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t pRetrieve->precision = precision; pRetrieve->compressed = 0; pRetrieve->completed = 1; - pRetrieve->numOfRows = htonl(pBlock->info.rows); + pRetrieve->numOfRows = htobe64((int64_t)pBlock->info.rows); int32_t actualLen = blockEncode(pBlock, pRetrieve->data, numOfCols); actualLen += sizeof(SRetrieveTableRsp); diff --git a/source/dnode/vnode/src/tq/tqMeta.c b/source/dnode/vnode/src/tq/tqMeta.c index 612e465295..f476f58b56 100644 --- a/source/dnode/vnode/src/tq/tqMeta.c +++ b/source/dnode/vnode/src/tq/tqMeta.c @@ -108,24 +108,22 @@ int32_t tqMetaClose(STQ* pTq) { } int32_t tqMetaSaveCheckInfo(STQ* pTq, const char* key, const void* value, int32_t vLen) { - TXN txn; - if (tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { + TXN* txn; + + if (tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < + 0) { return -1; } - if (tdbBegin(pTq->pMetaDB, &txn) < 0) { + if (tdbTbUpsert(pTq->pCheckStore, key, strlen(key), value, vLen, txn) < 0) { return -1; } - if (tdbTbUpsert(pTq->pCheckStore, key, strlen(key), value, vLen, &txn) < 0) { + if (tdbCommit(pTq->pMetaDB, txn) < 0) { return -1; } - if (tdbCommit(pTq->pMetaDB, &txn) < 0) { - return -1; - } - - if (tdbPostCommit(pTq->pMetaDB, &txn) < 0) { + if (tdbPostCommit(pTq->pMetaDB, txn) < 0) { return -1; } @@ -133,25 +131,22 @@ int32_t tqMetaSaveCheckInfo(STQ* pTq, const char* key, const void* value, int32_ } int32_t tqMetaDeleteCheckInfo(STQ* pTq, const char* key) { - TXN txn; + TXN* txn; - if (tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { + if (tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < + 0) { ASSERT(0); } - if (tdbBegin(pTq->pMetaDB, &txn) < 0) { - ASSERT(0); - } - - if (tdbTbDelete(pTq->pCheckStore, key, (int)strlen(key), &txn) < 0) { + if (tdbTbDelete(pTq->pCheckStore, key, (int)strlen(key), txn) < 0) { /*ASSERT(0);*/ } - if (tdbCommit(pTq->pMetaDB, &txn) < 0) { + if (tdbCommit(pTq->pMetaDB, txn) < 0) { ASSERT(0); } - if (tdbPostCommit(pTq->pMetaDB, &txn) < 0) { + if (tdbPostCommit(pTq->pMetaDB, txn) < 0) { ASSERT(0); } @@ -219,25 +214,22 @@ int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) { ASSERT(0); } - TXN txn; + TXN* txn; - if (tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { + if (tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < + 0) { ASSERT(0); } - if (tdbBegin(pTq->pMetaDB, &txn) < 0) { + if (tdbTbUpsert(pTq->pExecStore, key, (int)strlen(key), buf, vlen, txn) < 0) { ASSERT(0); } - if (tdbTbUpsert(pTq->pExecStore, key, (int)strlen(key), buf, vlen, &txn) < 0) { + if (tdbCommit(pTq->pMetaDB, txn) < 0) { ASSERT(0); } - if (tdbCommit(pTq->pMetaDB, &txn) < 0) { - ASSERT(0); - } - - if (tdbPostCommit(pTq->pMetaDB, &txn) < 0) { + if (tdbPostCommit(pTq->pMetaDB, txn) < 0) { ASSERT(0); } @@ -247,25 +239,22 @@ int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) { } int32_t tqMetaDeleteHandle(STQ* pTq, const char* key) { - TXN txn; + TXN* txn; - if (tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { + if (tdbBegin(pTq->pMetaDB, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < + 0) { ASSERT(0); } - if (tdbBegin(pTq->pMetaDB, &txn) < 0) { - ASSERT(0); - } - - if (tdbTbDelete(pTq->pExecStore, key, (int)strlen(key), &txn) < 0) { + if (tdbTbDelete(pTq->pExecStore, key, (int)strlen(key), txn) < 0) { /*ASSERT(0);*/ } - if (tdbCommit(pTq->pMetaDB, &txn) < 0) { + if (tdbCommit(pTq->pMetaDB, txn) < 0) { ASSERT(0); } - if (tdbPostCommit(pTq->pMetaDB, &txn) < 0) { + if (tdbPostCommit(pTq->pMetaDB, txn) < 0) { ASSERT(0); } diff --git a/source/dnode/vnode/src/tq/tqSnapshot.c b/source/dnode/vnode/src/tq/tqSnapshot.c index b68763867e..d811d943ed 100644 --- a/source/dnode/vnode/src/tq/tqSnapshot.c +++ b/source/dnode/vnode/src/tq/tqSnapshot.c @@ -129,7 +129,7 @@ struct STqSnapWriter { STQ* pTq; int64_t sver; int64_t ever; - TXN txn; + TXN* txn; }; int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) { @@ -146,8 +146,10 @@ int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** p pWriter->sver = sver; pWriter->ever = ever; - if (tdbTxnOpen(&pWriter->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) { - ASSERT(0); + if (tdbBegin(pTq->pMetaDB, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) { + code = -1; + taosMemoryFree(pWriter); + goto _err; } *ppWriter = pWriter; @@ -165,11 +167,11 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) { STQ* pTq = pWriter->pTq; if (rollback) { - tdbAbort(pWriter->pTq->pMetaDB, &pWriter->txn); + tdbAbort(pWriter->pTq->pMetaDB, pWriter->txn); } else { - code = tdbCommit(pWriter->pTq->pMetaDB, &pWriter->txn); + code = tdbCommit(pWriter->pTq->pMetaDB, pWriter->txn); if (code) goto _err; - code = tdbPostCommit(pWriter->pTq->pMetaDB, &pWriter->txn); + code = tdbPostCommit(pWriter->pTq->pMetaDB, pWriter->txn); if (code) goto _err; } diff --git a/source/dnode/vnode/src/tq/tqStreamStateSnap.c b/source/dnode/vnode/src/tq/tqStreamStateSnap.c index 08d5931bc3..b1f00bdf74 100644 --- a/source/dnode/vnode/src/tq/tqStreamStateSnap.c +++ b/source/dnode/vnode/src/tq/tqStreamStateSnap.c @@ -129,7 +129,7 @@ struct STqSnapWriter { STQ* pTq; int64_t sver; int64_t ever; - TXN txn; + TXN* txn; }; int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) { @@ -146,8 +146,10 @@ int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** p pWriter->sver = sver; pWriter->ever = ever; - if (tdbTxnOpen(&pWriter->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) { - ASSERT(0); + if (tdbBegin(pTq->pMetaDB, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) { + code = -1; + taosMemoryFree(pWriter); + goto _err; } *ppWriter = pWriter; @@ -165,11 +167,12 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) { STQ* pTq = pWriter->pTq; if (rollback) { + tdbAbort(pWriter->pTq->pMetaDB, pWriter->txn); ASSERT(0); } else { - code = tdbCommit(pWriter->pTq->pMetaDB, &pWriter->txn); + code = tdbCommit(pWriter->pTq->pMetaDB, pWriter->txn); if (code) goto _err; - code = tdbPostCommit(pWriter->pTq->pMetaDB, &pWriter->txn); + code = tdbPostCommit(pWriter->pTq->pMetaDB, pWriter->txn); if (code) goto _err; } diff --git a/source/dnode/vnode/src/tq/tqStreamTaskSnap.c b/source/dnode/vnode/src/tq/tqStreamTaskSnap.c index 31e44a5b6d..305378bc93 100644 --- a/source/dnode/vnode/src/tq/tqStreamTaskSnap.c +++ b/source/dnode/vnode/src/tq/tqStreamTaskSnap.c @@ -129,7 +129,7 @@ struct STqSnapWriter { STQ* pTq; int64_t sver; int64_t ever; - TXN txn; + TXN* txn; }; int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) { @@ -146,8 +146,10 @@ int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** p pWriter->sver = sver; pWriter->ever = ever; - if (tdbTxnOpen(&pWriter->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) { - ASSERT(0); + if (tdbBegin(pTq->pMetaStore, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) { + code = -1; + taosMemoryFree(pWriter); + goto _err; } *ppWriter = pWriter; @@ -165,11 +167,12 @@ int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) { STQ* pTq = pWriter->pTq; if (rollback) { + tdbAbort(pWriter->pTq->pMetaStore, pWriter->txn); ASSERT(0); } else { - code = tdbCommit(pWriter->pTq->pMetaStore, &pWriter->txn); + code = tdbCommit(pWriter->pTq->pMetaStore, pWriter->txn); if (code) goto _err; - code = tdbPostCommit(pWriter->pTq->pMetaStore, &pWriter->txn); + code = tdbPostCommit(pWriter->pTq->pMetaStore, pWriter->txn); if (code) goto _err; } diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index d71eb33951..7309ea3407 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -228,23 +228,23 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST invalidate = true; break; - } - } else { - SLastCol lastCol = {.ts = keyTs, .colVal = colVal}; - if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) { - SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol); - taosMemoryFree(pLastCol->colVal.value.pData); + } else { // new inserting key is greater than cached, update cached entry + SLastCol lastCol = {.ts = keyTs, .colVal = colVal}; + if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) { + SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol); + taosMemoryFree(pLastCol->colVal.value.pData); - lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData); - if (lastCol.colVal.value.pData == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - code = TSDB_CODE_OUT_OF_MEMORY; - goto _invalidate; + lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData); + if (lastCol.colVal.value.pData == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; + goto _invalidate; + } + memcpy(lastCol.colVal.value.pData, colVal.value.pData, colVal.value.nData); } - memcpy(lastCol.colVal.value.pData, colVal.value.pData, colVal.value.nData); - } - taosArraySet(pLast, iCol, &lastCol); + taosArraySet(pLast, iCol, &lastCol); + } } } } @@ -253,65 +253,10 @@ int32_t tsdbCacheInsertLastrow(SLRUCache *pCache, STsdb *pTsdb, tb_uid_t uid, ST taosMemoryFreeClear(pTSchema); taosLRUCacheRelease(pCache, h, invalidate); - /* - cacheRow = (STSRow *)taosLRUCacheValue(pCache, h); - if (row->ts >= cacheRow->ts) { - if (row->ts == cacheRow->ts) { - STSRow *mergedRow = NULL; - SRowMerger merger = {0}; - STSchema *pTSchema = metaGetTbTSchema(pTsdb->pVnode->pMeta, uid, -1, 1); - - tRowMergerInit(&merger, &tsdbRowFromTSRow(0, cacheRow), pTSchema); - - tRowMerge(&merger, &tsdbRowFromTSRow(1, row)); - - tRowMergerGetRow(&merger, &mergedRow); - tRowMergerClear(&merger); - - taosMemoryFreeClear(pTSchema); - - row = mergedRow; - dup = false; - } - - if (TD_ROW_LEN(row) <= TD_ROW_LEN(cacheRow)) { - tdRowCpy(cacheRow, row); - if (!dup) { - taosMemoryFree(row); - } - - taosLRUCacheRelease(pCache, h, false); - } else { - taosLRUCacheRelease(pCache, h, true); - // tsdbCacheDeleteLastrow(pCache, uid, TSKEY_MAX); - if (dup) { - cacheRow = tdRowDup(row); - } else { - cacheRow = row; - } - _taos_lru_deleter_t deleter = deleteTableCacheLastrow; - LRUStatus status = taosLRUCacheInsert(pCache, key, keyLen, cacheRow, TD_ROW_LEN(cacheRow), deleter, NULL, - TAOS_LRU_PRIORITY_LOW); - if (status != TAOS_LRU_STATUS_OK) { - code = -1; - } - // tsdbCacheInsertLastrow(pCache, uid, row, dup); - } - }*/ - } /*else { - if (dup) { - cacheRow = tdRowDup(row); - } else { - cacheRow = row; + if (invalidate) { + taosLRUCacheErase(pCache, key, keyLen); } - - _taos_lru_deleter_t deleter = deleteTableCacheLastrow; - LRUStatus status = - taosLRUCacheInsert(pCache, key, keyLen, cacheRow, TD_ROW_LEN(cacheRow), deleter, NULL, TAOS_LRU_PRIORITY_LOW); - if (status != TAOS_LRU_STATUS_OK) { - code = -1; - } - }*/ + } return code; } @@ -349,28 +294,28 @@ int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, STSRow *row, STsdb SColVal colVal = {0}; tTSRowGetVal(row, pTSchema, iCol, &colVal); - if (!COL_VAL_IS_VALUE(&colVal)) { + if (COL_VAL_IS_VALUE(&colVal)) { if (keyTs == tTsVal1->ts && COL_VAL_IS_VALUE(tColVal)) { invalidate = true; break; - } - } else { - SLastCol lastCol = {.ts = keyTs, .colVal = colVal}; - if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) { - SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol); - taosMemoryFree(pLastCol->colVal.value.pData); + } else { + SLastCol lastCol = {.ts = keyTs, .colVal = colVal}; + if (IS_VAR_DATA_TYPE(colVal.type) && colVal.value.nData > 0) { + SLastCol *pLastCol = (SLastCol *)taosArrayGet(pLast, iCol); + taosMemoryFree(pLastCol->colVal.value.pData); - lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData); - if (lastCol.colVal.value.pData == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - code = TSDB_CODE_OUT_OF_MEMORY; - goto _invalidate; + lastCol.colVal.value.pData = taosMemoryMalloc(colVal.value.nData); + if (lastCol.colVal.value.pData == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; + goto _invalidate; + } + memcpy(lastCol.colVal.value.pData, colVal.value.pData, colVal.value.nData); } - memcpy(lastCol.colVal.value.pData, colVal.value.pData, colVal.value.nData); - } - taosArraySet(pLast, iCol, &lastCol); + taosArraySet(pLast, iCol, &lastCol); + } } } } @@ -379,9 +324,9 @@ int32_t tsdbCacheInsertLast(SLRUCache *pCache, tb_uid_t uid, STSRow *row, STsdb taosMemoryFreeClear(pTSchema); taosLRUCacheRelease(pCache, h, invalidate); - - // clear last cache anyway, lazy load when get last lookup - // taosLRUCacheRelease(pCache, h, true); + if (invalidate) { + taosLRUCacheErase(pCache, key, keyLen); + } } return code; diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index cf9ae30ff0..906e3b2638 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -93,7 +93,7 @@ typedef struct { SArray *aDelData; // SArray } SCommitter; -static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter); +static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter, SCommitInfo *pInfo); static int32_t tsdbCommitData(SCommitter *pCommitter); static int32_t tsdbCommitDel(SCommitter *pCommitter); static int32_t tsdbCommitCache(SCommitter *pCommitter); @@ -150,18 +150,28 @@ _exit: return code; } -int32_t tsdbCommit(STsdb *pTsdb) { +int32_t tsdbPrepareCommit(STsdb *pTsdb) { + taosThreadRwlockWrlock(&pTsdb->rwLock); + ASSERT(pTsdb->imem == NULL); + pTsdb->imem = pTsdb->mem; + pTsdb->mem = NULL; + taosThreadRwlockUnlock(&pTsdb->rwLock); + + return 0; +} + +int32_t tsdbCommit(STsdb *pTsdb, SCommitInfo *pInfo) { if (!pTsdb) return 0; int32_t code = 0; int32_t lino = 0; SCommitter commith; - SMemTable *pMemTable = pTsdb->mem; + SMemTable *pMemTable = pTsdb->imem; // check if (pMemTable->nRow == 0 && pMemTable->nDel == 0) { taosThreadRwlockWrlock(&pTsdb->rwLock); - pTsdb->mem = NULL; + pTsdb->imem = NULL; taosThreadRwlockUnlock(&pTsdb->rwLock); tsdbUnrefMemTable(pMemTable); @@ -169,7 +179,7 @@ int32_t tsdbCommit(STsdb *pTsdb) { } // start commit - code = tsdbStartCommit(pTsdb, &commith); + code = tsdbStartCommit(pTsdb, &commith, pInfo); TSDB_CHECK_CODE(code, lino, _exit); // commit impl @@ -806,26 +816,21 @@ _exit: } // ---------------------------------------------------------------------------- -static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) { +static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter, SCommitInfo *pInfo) { int32_t code = 0; int32_t lino = 0; memset(pCommitter, 0, sizeof(*pCommitter)); - ASSERT(pTsdb->mem && pTsdb->imem == NULL); - - taosThreadRwlockWrlock(&pTsdb->rwLock); - pTsdb->imem = pTsdb->mem; - pTsdb->mem = NULL; - taosThreadRwlockUnlock(&pTsdb->rwLock); + ASSERT(pTsdb->imem && "last tsdb commit incomplete"); pCommitter->pTsdb = pTsdb; - pCommitter->commitID = pTsdb->pVnode->state.commitID; + pCommitter->commitID = pInfo->info.state.commitID; pCommitter->minutes = pTsdb->keepCfg.days; pCommitter->precision = pTsdb->keepCfg.precision; - pCommitter->minRow = pTsdb->pVnode->config.tsdbCfg.minRows; - pCommitter->maxRow = pTsdb->pVnode->config.tsdbCfg.maxRows; - pCommitter->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression; - pCommitter->sttTrigger = pTsdb->pVnode->config.sttTrigger; + pCommitter->minRow = pInfo->info.config.tsdbCfg.minRows; + pCommitter->maxRow = pInfo->info.config.tsdbCfg.maxRows; + pCommitter->cmprAlg = pInfo->info.config.tsdbCfg.compression; + pCommitter->sttTrigger = pInfo->info.config.sttTrigger; pCommitter->aTbDataP = tsdbMemTableGetTbDataArray(pTsdb->imem); if (pCommitter->aTbDataP == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; @@ -1261,7 +1266,7 @@ static int32_t tsdbCommitMergeBlock(SCommitter *pCommitter, SDataBlk *pDataBlk) } } } else { - ASSERT(0); + ASSERT(0 && "dup rows not allowed"); } if (pBDataW->nRow >= pCommitter->maxRow) { @@ -1682,4 +1687,4 @@ _exit: tsdbInfo("vgId:%d, tsdb rollback commit", TD_VID(pTsdb->pVnode)); } return code; -} \ No newline at end of file +} diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 83532c2a20..5dd9293118 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -84,8 +84,8 @@ typedef struct SIOCostSummary { typedef struct SBlockLoadSuppInfo { SArray* pColAgg; SColumnDataAgg tsColAgg; - SColumnDataAgg** plist; - int16_t* colIds; // column ids for loading file block data + 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 @@ -158,6 +158,7 @@ struct STsdbReader { STsdb* pTsdb; uint64_t suid; int16_t order; + bool freeBlock; STimeWindow window; // the primary query time window that applies to all queries SSDataBlock* pResBlock; int32_t capacity; @@ -169,7 +170,9 @@ struct STsdbReader { 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; + SDataFReader* pFileReader; // the file reader + SDelFReader* pDelFReader; // the del file reader + SArray* pDelIdx; // del file block index; SVersionRange verRange; SBlockInfoBuf blockInfoBuf; int32_t step; @@ -214,25 +217,25 @@ static bool hasDataInFileBlock(const SBlockData* pBlockData, const SFil static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWindow->ekey) || (ts < pWindow->skey); } -static int32_t setColumnIdSlotList(SBlockLoadSuppInfo* pSupInfo, SSDataBlock* pBlock) { - size_t numOfCols = blockDataGetNumOfCols(pBlock); - +static int32_t setColumnIdSlotList(SBlockLoadSuppInfo* pSupInfo, SColumnInfo* pCols, const int32_t* pSlotIdList, int32_t numOfCols) { pSupInfo->smaValid = true; pSupInfo->numOfCols = numOfCols; - pSupInfo->colIds = taosMemoryMalloc(numOfCols * sizeof(int16_t)); - pSupInfo->buildBuf = taosMemoryCalloc(numOfCols, POINTER_BYTES); - if (pSupInfo->buildBuf == NULL || pSupInfo->colIds == NULL) { - taosMemoryFree(pSupInfo->colIds); - taosMemoryFree(pSupInfo->buildBuf); + 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)); for (int32_t i = 0; i < numOfCols; ++i) { - SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, i); - pSupInfo->colIds[i] = pCol->info.colId; + pSupInfo->colId[i] = pCols[i].colId; + pSupInfo->slotId[i] = pSlotIdList[i]; - if (IS_VAR_DATA_TYPE(pCol->info.type)) { - pSupInfo->buildBuf[i] = taosMemoryMalloc(pCol->info.bytes); + if (IS_VAR_DATA_TYPE(pCols[i].type)) { + pSupInfo->buildBuf[i] = taosMemoryMalloc(pCols[i].bytes); + } else { + pSupInfo->buildBuf[i] = NULL; } } @@ -244,7 +247,7 @@ static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo) while(i < pSchema->numOfCols && j < pSupInfo->numOfCols) { STColumn* pTCol = &pSchema->columns[i]; - if (pTCol->colId == pSupInfo->colIds[j]) { + if (pTCol->colId == pSupInfo->colId[j]) { if (!IS_BSMA_ON(pTCol)) { pSupInfo->smaValid = false; return; @@ -252,7 +255,7 @@ static void updateBlockSMAInfo(STSchema* pSchema, SBlockLoadSuppInfo* pSupInfo) i += 1; j += 1; - } else if (pTCol->colId < pSupInfo->colIds[j]) { + } else if (pTCol->colId < pSupInfo->colId[j]) { // do nothing i += 1; } else { @@ -454,7 +457,7 @@ static int32_t initFilesetIterator(SFilesetIter* pIter, SArray* aDFileSet, STsdb if (pLReader->pInfo == NULL) { // here we ignore the first column, which is always be the primary timestamp column pLReader->pInfo = - tCreateLastBlockLoadInfo(pReader->pSchema, &pReader->suppInfo.colIds[1], pReader->suppInfo.numOfCols - 1); + tCreateLastBlockLoadInfo(pReader->pSchema, &pReader->suppInfo.colId[1], pReader->suppInfo.numOfCols - 1); if (pLReader->pInfo == NULL) { tsdbDebug("init fileset iterator failed, code:%s %s", tstrerror(terrno), pReader->idStr); return terrno; @@ -566,7 +569,7 @@ static SSDataBlock* createResBlock(SQueryTableDataCond* pCond, int32_t capacity) } static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsdbReader** ppReader, int32_t capacity, - const char* idstr) { + SSDataBlock* pResBlock, const char* idstr) { int32_t code = 0; int8_t level = 0; STsdbReader* pReader = (STsdbReader*)taosMemoryCalloc(1, sizeof(*pReader)); @@ -585,6 +588,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd pReader->suid = pCond->suid; pReader->order = pCond->order; pReader->capacity = capacity; + pReader->pResBlock = pResBlock; pReader->idStr = (idstr != NULL) ? strdup(idstr) : NULL; pReader->verRange = getQueryVerRange(pVnode, pCond, level); pReader->type = pCond->type; @@ -592,13 +596,22 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd pReader->blockInfoBuf.numPerBucket = 1000; // 1000 tables per bucket ASSERT(pCond->numOfCols > 0); + if (pReader->pResBlock == NULL) { + pReader->freeBlock = true; + pReader->pResBlock = createResBlock(pCond, pReader->capacity); + if (pReader->pResBlock == NULL) { + code = terrno; + goto _end; + } + } + + // todo refactor. limitOutputBufferSize(pCond, &pReader->capacity); // allocate buffer in order to load data blocks from file SBlockLoadSuppInfo* pSup = &pReader->suppInfo; pSup->pColAgg = taosArrayInit(pCond->numOfCols, sizeof(SColumnDataAgg)); - pSup->plist = taosMemoryCalloc(pCond->numOfCols, POINTER_BYTES); - if (pSup->pColAgg == NULL || pSup->plist == NULL) { + if (pSup->pColAgg == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _end; } @@ -611,13 +624,7 @@ static int32_t tsdbReaderCreate(SVnode* pVnode, SQueryTableDataCond* pCond, STsd goto _end; } - pReader->pResBlock = createResBlock(pCond, pReader->capacity); - if (pReader->pResBlock == NULL) { - code = terrno; - goto _end; - } - - setColumnIdSlotList(&pReader->suppInfo, pReader->pResBlock); + setColumnIdSlotList(&pReader->suppInfo, pCond->colList, pCond->pSlotList, pCond->numOfCols); *ppReader = pReader; return code; @@ -1044,17 +1051,16 @@ static void copyNumericCols(const SColData* pData, SFileBlockDumpInfo* pDumpInfo } static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo) { - SReaderStatus* pStatus = &pReader->status; - SDataBlockIter* pBlockIter = &pStatus->blockIter; + SReaderStatus* pStatus = &pReader->status; + SDataBlockIter* pBlockIter = &pStatus->blockIter; + SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo; + SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; SBlockData* pBlockData = &pStatus->fileBlockData; SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter); SDataBlk* pBlock = getCurrentBlock(pBlockIter); SSDataBlock* pResBlock = pReader->pResBlock; - int32_t numOfOutputCols = blockDataGetNumOfCols(pResBlock); - - SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo; - SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; + int32_t numOfOutputCols = pSupInfo->numOfCols; SColVal cv = {0}; int64_t st = taosGetTimestampUs(); @@ -1090,8 +1096,8 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn int32_t i = 0; int32_t rowIndex = 0; - SColumnInfoData* pColData = taosArrayGet(pResBlock->pDataBlock, i); - if (pColData->info.colId == PRIMARYKEY_TIMESTAMP_COL_ID) { + SColumnInfoData* pColData = taosArrayGet(pResBlock->pDataBlock, pSupInfo->slotId[i]); + if (pSupInfo->colId[i] == PRIMARYKEY_TIMESTAMP_COL_ID) { copyPrimaryTsCol(pBlockData, pDumpInfo, pColData, dumpedRows, asc); i += 1; } @@ -1100,12 +1106,13 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn int32_t num = pBlockData->nColData; while (i < numOfOutputCols && colIndex < num) { rowIndex = 0; - pColData = taosArrayGet(pResBlock->pDataBlock, i); SColData* pData = tBlockDataGetColDataByIdx(pBlockData, colIndex); - if (pData->cid < pColData->info.colId) { + if (pData->cid < pSupInfo->colId[i]) { colIndex += 1; - } else if (pData->cid == pColData->info.colId) { + } else if (pData->cid == pSupInfo->colId[i]) { + pColData = taosArrayGet(pResBlock->pDataBlock, pSupInfo->slotId[i]); + if (pData->flag == HAS_NONE || pData->flag == HAS_NULL || pData->flag == (HAS_NULL | HAS_NONE)) { colDataAppendNNULL(pColData, 0, dumpedRows); } else { @@ -1122,6 +1129,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn colIndex += 1; i += 1; } else { // the specified column does not exist in file block, fill with null data + pColData = taosArrayGet(pResBlock->pDataBlock, pSupInfo->slotId[i]); colDataAppendNNULL(pColData, 0, dumpedRows); i += 1; } @@ -1129,7 +1137,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn // fill the mis-matched columns with null value while (i < numOfOutputCols) { - pColData = taosArrayGet(pResBlock->pDataBlock, i); + pColData = taosArrayGet(pResBlock->pDataBlock, pSupInfo->slotId[i]); colDataAppendNNULL(pColData, 0, dumpedRows); i += 1; } @@ -1167,7 +1175,7 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI tBlockDataReset(pBlockData); TABLEID tid = {.suid = pReader->suid, .uid = uid}; int32_t code = - tBlockDataInit(pBlockData, &tid, pReader->pSchema, &pReader->suppInfo.colIds[1], pReader->suppInfo.numOfCols - 1); + tBlockDataInit(pBlockData, &tid, pReader->pSchema, &pReader->suppInfo.colId[1], pReader->suppInfo.numOfCols - 1); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -1305,7 +1313,7 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte char* buf = taosMemoryMalloc(sizeof(SBlockOrderWrapper) * num); if (buf == NULL) { cleanupBlockOrderSupporter(&sup); - return TSDB_CODE_TDB_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } sup.pDataBlockInfo[sup.numOfTables] = (SBlockOrderWrapper*)buf; @@ -1348,7 +1356,7 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte uint8_t ret = tMergeTreeCreate(&pTree, sup.numOfTables, &sup, fileDataBlockOrderCompar); if (ret != TSDB_CODE_SUCCESS) { cleanupBlockOrderSupporter(&sup); - return TSDB_CODE_TDB_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } int32_t numOfTotal = 0; @@ -1626,7 +1634,7 @@ static int32_t buildDataBlockFromBuf(STsdbReader* pReader, STableBlockScanInfo* int64_t st = taosGetTimestampUs(); int32_t code = buildDataBlockFromBufImpl(pBlockScanInfo, endKey, pReader->capacity, pReader); - blockDataUpdateTsWindow(pBlock, 0); + blockDataUpdateTsWindow(pBlock, pReader->suppInfo.slotId[0]); pBlock->info.id.uid = pBlockScanInfo->uid; setComposedBlockFlag(pReader, true); @@ -2498,7 +2506,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) { _end: pResBlock->info.id.uid = (pBlockScanInfo != NULL) ? pBlockScanInfo->uid : 0; - blockDataUpdateTsWindow(pResBlock, 0); + blockDataUpdateTsWindow(pResBlock, pReader->suppInfo.slotId[0]); setComposedBlockFlag(pReader, true); double el = (taosGetTimestampUs() - st) / 1000.0; @@ -2525,42 +2533,18 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* } int32_t code = 0; - STsdb* pTsdb = pReader->pTsdb; - SArray* pDelData = taosArrayInit(4, sizeof(SDelData)); + ASSERT(pReader->pReadSnap != NULL); SDelFile* pDelFile = pReader->pReadSnap->fs.pDelFile; - if (pDelFile) { - SDelFReader* pDelFReader = NULL; - code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb); - if (code != TSDB_CODE_SUCCESS) { - goto _err; - } - - SArray* aDelIdx = taosArrayInit(4, sizeof(SDelIdx)); - if (aDelIdx == NULL) { - tsdbDelFReaderClose(&pDelFReader); - goto _err; - } - - // TODO: opt the perf of read del index - code = tsdbReadDelIdx(pDelFReader, aDelIdx); - if (code != TSDB_CODE_SUCCESS) { - taosArrayDestroy(aDelIdx); - tsdbDelFReaderClose(&pDelFReader); - goto _err; - } - + if (pDelFile && taosArrayGetSize(pReader->pDelIdx) > 0) { SDelIdx idx = {.suid = pReader->suid, .uid = pBlockScanInfo->uid}; - SDelIdx* pIdx = taosArraySearch(aDelIdx, &idx, tCmprDelIdx, TD_EQ); + SDelIdx* pIdx = taosArraySearch(pReader->pDelIdx, &idx, tCmprDelIdx, TD_EQ); if (pIdx != NULL) { - code = tsdbReadDelData(pDelFReader, pIdx, pDelData); + code = tsdbReadDelData(pReader->pDelFReader, pIdx, pDelData); } - taosArrayDestroy(aDelIdx); - tsdbDelFReaderClose(&pDelFReader); - if (code != TSDB_CODE_SUCCESS) { goto _err; } @@ -2656,6 +2640,30 @@ 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); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + pReader->pDelIdx = taosArrayInit(4, sizeof(SDelIdx)); + if (pReader->pDelIdx == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + return code; + } + + code = tsdbReadDelIdx(pReader->pDelFReader, pReader->pDelIdx); + if (code != TSDB_CODE_SUCCESS) { + taosArrayDestroy(pReader->pDelIdx); + return code; + } + } + } + return TSDB_CODE_SUCCESS; } @@ -3539,8 +3547,7 @@ int32_t tsdbGetNextRowInMem(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pR int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* pTSRow, STableBlockScanInfo* pScanInfo) { - int32_t numOfRows = pBlock->info.rows; - int32_t numOfCols = (int32_t)taosArrayGetSize(pBlock->pDataBlock); + int32_t outputRowIndex = pBlock->info.rows; int64_t uid = pScanInfo->uid; SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo; @@ -3549,23 +3556,26 @@ int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* SColVal colVal = {0}; int32_t i = 0, j = 0; - SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i); - if (pColInfoData->info.colId == PRIMARYKEY_TIMESTAMP_COL_ID) { - colDataAppend(pColInfoData, numOfRows, (const char*)&pTSRow->ts, false); + 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; } - while (i < numOfCols && j < pSchema->numOfCols) { - pColInfoData = taosArrayGet(pBlock->pDataBlock, i); - col_id_t colId = pColInfoData->info.colId; + while (i < pSupInfo->numOfCols && j < pSchema->numOfCols) { + col_id_t colId = pSupInfo->colId[i]; if (colId == pSchema->columns[j].colId) { + SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pSupInfo->slotId[i]); + tTSRowGetVal(pTSRow, pSchema, j, &colVal); - doCopyColVal(pColInfoData, numOfRows, i, &colVal, pSupInfo); + doCopyColVal(pColInfoData, outputRowIndex, i, &colVal, pSupInfo); i += 1; j += 1; } else if (colId < pSchema->columns[j].colId) { - colDataAppendNULL(pColInfoData, numOfRows); + SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pSupInfo->slotId[i]); + + colDataAppendNULL(pColInfoData, outputRowIndex); i += 1; } else if (colId > pSchema->columns[j].colId) { j += 1; @@ -3573,9 +3583,9 @@ int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* } // set null value since current column does not exist in the "pSchema" - while (i < numOfCols) { - pColInfoData = taosArrayGet(pBlock->pDataBlock, i); - colDataAppendNULL(pColInfoData, numOfRows); + while (i < pSupInfo->numOfCols) { + SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pSupInfo->slotId[i]); + colDataAppendNULL(pColInfoData, outputRowIndex); i += 1; } @@ -3590,27 +3600,25 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S int32_t outputRowIndex = pResBlock->info.rows; SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo; - - SColumnInfoData* pColData = taosArrayGet(pResBlock->pDataBlock, i); - if (pColData->info.colId == PRIMARYKEY_TIMESTAMP_COL_ID) { - colDataAppendInt64(pColData, outputRowIndex, &pBlockData->aTSKEY[rowIndex]); + 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; } SColVal cv = {0}; int32_t numOfInputCols = pBlockData->nColData; - int32_t numOfOutputCols = pResBlock->pDataBlock->size; + int32_t numOfOutputCols = pSupInfo->numOfCols; while (i < numOfOutputCols && j < numOfInputCols) { - SColumnInfoData* pCol = TARRAY_GET_ELEM(pResBlock->pDataBlock, i); - SColData* pData = tBlockDataGetColDataByIdx(pBlockData, j); - - if (pData->cid < pCol->info.colId) { + SColData* pData = tBlockDataGetColDataByIdx(pBlockData, j); + if (pData->cid < pSupInfo->colId[i]) { j += 1; continue; } - if (pData->cid == pCol->info.colId) { + SColumnInfoData* pCol = TARRAY_GET_ELEM(pResBlock->pDataBlock, pSupInfo->slotId[i]); + if (pData->cid == pSupInfo->colId[i]) { tColDataGetValue(pData, rowIndex, &cv); doCopyColVal(pCol, outputRowIndex, i, &cv, pSupInfo); j += 1; @@ -3623,7 +3631,7 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S } while (i < numOfOutputCols) { - SColumnInfoData* pCol = taosArrayGet(pResBlock->pDataBlock, i); + SColumnInfoData* pCol = taosArrayGet(pResBlock->pDataBlock, pSupInfo->slotId[i]); colDataAppendNULL(pCol, outputRowIndex); i += 1; } @@ -3722,14 +3730,21 @@ static int32_t doOpenReaderImpl(STsdbReader* pReader) { // ====================================== EXPOSED APIs ====================================== int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableList, int32_t numOfTables, - STsdbReader** ppReader, const char* idstr) { + SSDataBlock* pResBlock, STsdbReader** ppReader, const char* idstr) { STimeWindow window = pCond->twindows; if (pCond->type == TIMEWINDOW_RANGE_EXTERNAL) { pCond->twindows.skey += 1; pCond->twindows.ekey -= 1; } - int32_t code = tsdbReaderCreate(pVnode, pCond, ppReader, 4096, idstr); + int32_t capacity = 0; + if (pResBlock == NULL) { + capacity = 4096; + } else { + capacity = pResBlock->info.capacity; + } + + int32_t code = tsdbReaderCreate(pVnode, pCond, ppReader, capacity, pResBlock, idstr); if (code != TSDB_CODE_SUCCESS) { goto _err; } @@ -3755,7 +3770,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL } // here we only need one more row, so the capacity is set to be ONE. - code = tsdbReaderCreate(pVnode, pCond, &pReader->innerReader[0], 1, idstr); + code = tsdbReaderCreate(pVnode, pCond, &pReader->innerReader[0], 1, pResBlock, idstr); if (code != TSDB_CODE_SUCCESS) { goto _err; } @@ -3769,7 +3784,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL } pCond->order = order; - code = tsdbReaderCreate(pVnode, pCond, &pReader->innerReader[1], 1, idstr); + code = tsdbReaderCreate(pVnode, pCond, &pReader->innerReader[1], 1, pResBlock, idstr); if (code != TSDB_CODE_SUCCESS) { goto _err; } @@ -3799,7 +3814,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL tsdbReaderClose(p); *ppReader = NULL; - code = TSDB_CODE_TDB_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _err; } @@ -3841,10 +3856,10 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL tsdbDebug("%p total numOfTable:%d in this query %s", pReader, numOfTables, pReader->idStr); return code; -_err: + _err: tsdbError("failed to create data reader, code:%s %s", tstrerror(code), idstr); return code; -} + } void tsdbReaderClose(STsdbReader* pReader) { if (pReader == NULL) { @@ -3874,19 +3889,19 @@ void tsdbReaderClose(STsdbReader* pReader) { SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo; - taosMemoryFreeClear(pSupInfo->plist); - taosMemoryFree(pSupInfo->colIds); - taosArrayDestroy(pSupInfo->pColAgg); - for (int32_t i = 0; i < blockDataGetNumOfCols(pReader->pResBlock); ++i) { + for (int32_t i = 0; i < pSupInfo->numOfCols; ++i) { if (pSupInfo->buildBuf[i] != NULL) { taosMemoryFreeClear(pSupInfo->buildBuf[i]); } } - taosMemoryFree(pSupInfo->buildBuf); - tBlockDataDestroy(&pReader->status.fileBlockData, true); + if (pReader->freeBlock) { + pReader->pResBlock = blockDataDestroy(pReader->pResBlock); + } + taosMemoryFree(pSupInfo->colId); + tBlockDataDestroy(&pReader->status.fileBlockData, true); cleanupDataBlockIterator(&pReader->status.blockIter); size_t numOfTables = taosHashGetSize(pReader->status.pTableMap); @@ -3895,12 +3910,19 @@ void tsdbReaderClose(STsdbReader* pReader) { clearBlockScanInfoBuf(&pReader->blockInfoBuf); } - blockDataDestroy(pReader->pResBlock); - if (pReader->pFileReader != NULL) { tsdbDataFReaderClose(&pReader->pFileReader); } + if (pReader->pDelFReader != NULL) { + tsdbDelFReaderClose(&pReader->pDelFReader); + } + + if (pReader->pDelIdx != NULL) { + taosArrayDestroy(pReader->pDelIdx); + pReader->pDelIdx = NULL; + } + tsdbUntakeReadSnap(pReader->pTsdb, pReader->pReadSnap, pReader->idStr); taosMemoryFree(pReader->status.uidCheckInfo.tableUidList); @@ -3942,6 +3964,9 @@ static bool doTsdbNextDataBlock(STsdbReader* pReader) { blockDataCleanup(pBlock); SReaderStatus* pStatus = &pReader->status; + if (taosHashGetSize(pStatus->pTableMap) == 0){ + return false; + } if (pStatus->loadFromFile) { int32_t code = buildBlockFromFiles(pReader); @@ -3959,8 +3984,6 @@ static bool doTsdbNextDataBlock(STsdbReader* pReader) { buildBlockFromBufferSequentially(pReader); return pBlock->info.rows > 0; } - - return false; } bool tsdbNextDataBlock(STsdbReader* pReader) { @@ -4011,16 +4034,6 @@ bool tsdbNextDataBlock(STsdbReader* pReader) { return false; } -bool tsdbTableNextDataBlock(STsdbReader* pReader, uint64_t uid) { - STableBlockScanInfo* pBlockScanInfo = - *(STableBlockScanInfo**)taosHashGet(pReader->status.pTableMap, &uid, sizeof(uid)); - if (pBlockScanInfo == NULL) { // no data block for the table of given uid - return false; - } - - return true; -} - static void setBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64_t* uid, STimeWindow* pWindow) { ASSERT(pReader != NULL); *rows = pReader->pResBlock->info.rows; @@ -4042,28 +4055,27 @@ void tsdbRetrieveDataBlockInfo(const STsdbReader* pReader, int32_t* rows, uint64 } } -int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockStatis, bool* allHave) { +int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg ***pBlockSMA, bool* allHave) { int32_t code = 0; *allHave = false; if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) { - *pBlockStatis = NULL; + *pBlockSMA = NULL; return TSDB_CODE_SUCCESS; } // there is no statistics data for composed block if (pReader->status.composedDataBlock || (!pReader->suppInfo.smaValid)) { - *pBlockStatis = NULL; + *pBlockSMA = NULL; return TSDB_CODE_SUCCESS; } SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pReader->status.blockIter); - - SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter); - // int64_t stime = taosGetTimestampUs(); - SBlockLoadSuppInfo* pSup = &pReader->suppInfo; + ASSERT(pReader->pResBlock->info.id.uid == pFBlock->uid); + + SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter); if (tDataBlkHasSma(pBlock)) { code = tsdbReadBlockSma(pReader->pFileReader, pBlock, pSup->pColAgg); if (code != TSDB_CODE_SUCCESS) { @@ -4072,7 +4084,7 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockS return code; } } else { - *pBlockStatis = NULL; + *pBlockSMA = NULL; return TSDB_CODE_SUCCESS; } @@ -4085,80 +4097,53 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockS pTsAgg->colId = PRIMARYKEY_TIMESTAMP_COL_ID; pTsAgg->min = pReader->pResBlock->info.window.skey; pTsAgg->max = pReader->pResBlock->info.window.ekey; - pSup->plist[0] = pTsAgg; // update the number of NULL data rows - size_t numOfCols = blockDataGetNumOfCols(pReader->pResBlock); + size_t numOfCols = pSup->numOfCols; int32_t i = 0, j = 0; size_t size = taosArrayGetSize(pSup->pColAgg); -#if 0 - while (j < numOfCols && i < size) { - SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i); - if (pAgg->colId == pSup->colIds[j]) { - if (IS_BSMA_ON(&(pReader->pSchema->columns[i]))) { - pSup->plist[j] = pAgg; - } else { - *allHave = false; - break; - } - i += 1; - j += 1; - } else if (pAgg->colId < pSup->colIds[j]) { - i += 1; - } else if (pSup->colIds[j] < pAgg->colId) { - j += 1; - } + + SSDataBlock* pResBlock = pReader->pResBlock; + if (pResBlock->pBlockAgg == NULL) { + size_t num = taosArrayGetSize(pResBlock->pDataBlock); + pResBlock->pBlockAgg = taosMemoryCalloc(num, sizeof(SColumnDataAgg)); } -#else - - // fill the all null data column - SArray* pNewAggList = taosArrayInit(numOfCols, sizeof(SColumnDataAgg)); while (j < numOfCols && i < size) { SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i); - if (pAgg->colId == pSup->colIds[j]) { - taosArrayPush(pNewAggList, pAgg); + if (pAgg->colId == pSup->colId[j]) { + pResBlock->pBlockAgg[pSup->slotId[j]] = pAgg; i += 1; j += 1; - } else if (pAgg->colId < pSup->colIds[j]) { + } else if (pAgg->colId < pSup->colId[j]) { i += 1; - } else if (pSup->colIds[j] < pAgg->colId) { - if (pSup->colIds[j] == PRIMARYKEY_TIMESTAMP_COL_ID) { - taosArrayPush(pNewAggList, &pSup->tsColAgg); + } else if (pSup->colId[j] < pAgg->colId) { + if (pSup->colId[j] == PRIMARYKEY_TIMESTAMP_COL_ID) { + pResBlock->pBlockAgg[pSup->slotId[j]] = &pSup->tsColAgg; } else { // all date in this block are null - SColumnDataAgg nullColAgg = {.colId = pSup->colIds[j], .numOfNull = pBlock->nRow}; - taosArrayPush(pNewAggList, &nullColAgg); + SColumnDataAgg nullColAgg = {.colId = pSup->colId[j], .numOfNull = pBlock->nRow}; + taosArrayPush(pSup->pColAgg, &nullColAgg); + + pResBlock->pBlockAgg[pSup->slotId[j]] = taosArrayGetLast(pSup->pColAgg); } j += 1; } } - taosArrayClear(pSup->pColAgg); - taosArrayAddAll(pSup->pColAgg, pNewAggList); - - size_t num = taosArrayGetSize(pSup->pColAgg); - for(int32_t k = 0; k < num; ++k) { - pSup->plist[k] = taosArrayGet(pSup->pColAgg, k); - } - - taosArrayDestroy(pNewAggList); - -#endif - + *pBlockSMA = pResBlock->pBlockAgg; pReader->cost.smaDataLoad += 1; - *pBlockStatis = pSup->plist; tsdbDebug("vgId:%d, succeed to load block SMA for uid %" PRIu64 ", %s", 0, pFBlock->uid, pReader->idStr); return code; } -static SArray* doRetrieveDataBlock(STsdbReader* pReader) { +static SSDataBlock* doRetrieveDataBlock(STsdbReader* pReader) { SReaderStatus* pStatus = &pReader->status; if (pStatus->composedDataBlock) { - return pReader->pResBlock->pDataBlock; + return pReader->pResBlock; } SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(&pStatus->blockIter); @@ -4179,10 +4164,10 @@ static SArray* doRetrieveDataBlock(STsdbReader* pReader) { } copyBlockDataToSDataBlock(pReader, pBlockScanInfo); - return pReader->pResBlock->pDataBlock; + return pReader->pResBlock; } -SArray* tsdbRetrieveDataBlock(STsdbReader* pReader, SArray* pIdList) { +SSDataBlock* tsdbRetrieveDataBlock(STsdbReader* pReader, SArray* pIdList) { if (pReader->type == TIMEWINDOW_RANGE_EXTERNAL) { if (pReader->step == EXTERNAL_ROWS_PREV) { return doRetrieveDataBlock(pReader->innerReader[0]); @@ -4209,7 +4194,6 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) { // allocate buffer in order to load data blocks from file memset(&pReader->suppInfo.tsColAgg, 0, sizeof(SColumnDataAgg)); - memset(pReader->suppInfo.plist, 0, POINTER_BYTES); pReader->suppInfo.tsColAgg.colId = PRIMARYKEY_TIMESTAMP_COL_ID; tsdbDataFReaderClose(&pReader->pFileReader); diff --git a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c index 294a4bd3e4..c7bce6182a 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c +++ b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c @@ -750,7 +750,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) { // head tsdbHeadFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pHeadF, fNameFrom); tsdbHeadFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pHeadF, fNameTo); - pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC); + pOutFD = taosCreateFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC); if (pOutFD == NULL) { code = TAOS_SYSTEM_ERROR(errno); goto _err; @@ -771,7 +771,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) { // data tsdbDataFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pDataF, fNameFrom); tsdbDataFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pDataF, fNameTo); - pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC); + pOutFD = taosCreateFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC); if (pOutFD == NULL) { code = TAOS_SYSTEM_ERROR(errno); goto _err; @@ -781,7 +781,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) { code = TAOS_SYSTEM_ERROR(errno); goto _err; } - n = taosFSendFile(pOutFD, PInFD, 0, LOGIC_TO_FILE_OFFSET(pSetFrom->pDataF->size, szPage)); + n = taosFSendFile(pOutFD, PInFD, 0, tsdbLogicToFileSize(pSetFrom->pDataF->size, szPage)); if (n < 0) { code = TAOS_SYSTEM_ERROR(errno); goto _err; @@ -792,7 +792,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) { // sma tsdbSmaFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pSmaF, fNameFrom); tsdbSmaFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pSmaF, fNameTo); - pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC); + pOutFD = taosCreateFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC); if (pOutFD == NULL) { code = TAOS_SYSTEM_ERROR(errno); goto _err; @@ -814,7 +814,7 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) { for (int8_t iStt = 0; iStt < pSetFrom->nSttF; iStt++) { tsdbSttFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->aSttF[iStt], fNameFrom); tsdbSttFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->aSttF[iStt], fNameTo); - pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC); + pOutFD = taosCreateFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC); if (pOutFD == NULL) { code = TAOS_SYSTEM_ERROR(errno); goto _err; @@ -1477,9 +1477,8 @@ int32_t tsdbDelFReaderClose(SDelFReader **ppReader) { } taosMemoryFree(pReader); } - *ppReader = NULL; -_exit: + *ppReader = NULL; return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c index db86a9429d..55703002b8 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c @@ -107,7 +107,7 @@ int32_t tMapDataToArray(SMapData *pMapData, int32_t itemSize, int32_t (*tGetItem SArray *pArray = taosArrayInit(pMapData->nItem, itemSize); if (pArray == NULL) { - code = TSDB_CODE_TDB_OUT_OF_MEMORY; + code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; } @@ -728,7 +728,7 @@ int32_t tRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) { taosArraySet(pMerger->pArray, iCol, pColVal); } } else { - ASSERT(0); + ASSERT(0 && "dup versions not allowed"); } } @@ -902,7 +902,6 @@ int32_t tsdbBuildDeleteSkyline(SArray *aDelData, int32_t sidx, int32_t eidx, SAr code = TSDB_CODE_OUT_OF_MEMORY; goto _clear; } - midx = (sidx + eidx) / 2; code = tsdbBuildDeleteSkyline(aDelData, sidx, midx, aSkyline1); diff --git a/source/dnode/vnode/src/vnd/vnodeBufPool.c b/source/dnode/vnode/src/vnd/vnodeBufPool.c index 71e926bd35..dcc323f778 100644 --- a/source/dnode/vnode/src/vnd/vnodeBufPool.c +++ b/source/dnode/vnode/src/vnd/vnodeBufPool.c @@ -176,6 +176,9 @@ void vnodeBufPoolRef(SVBufPool *pPool) { } void vnodeBufPoolUnRef(SVBufPool *pPool) { + if (pPool == NULL) { + return; + } int32_t nRef = atomic_sub_fetch_32(&pPool->nRef, 1); if (nRef == 0) { SVnode *pVnode = pPool->pVnode; diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index 7040d2d7c8..cd56468371 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -14,14 +14,14 @@ */ #include "vnd.h" +#include "vnodeInt.h" -#define VND_INFO_FNAME "vnode.json" +#define VND_INFO_FNAME "vnode.json" #define VND_INFO_FNAME_TMP "vnode_tmp.json" -static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData); -static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo); -static int vnodeCommitImpl(void *arg); -static void vnodeWaitCommit(SVnode *pVnode); +static int vnodeEncodeInfo(const SVnodeInfo *pInfo, char **ppData); +static int vnodeDecodeInfo(uint8_t *pData, SVnodeInfo *pInfo); +static int vnodeCommitImpl(SCommitInfo *pInfo); int vnodeBegin(SVnode *pVnode) { // alloc buffer pool @@ -107,7 +107,8 @@ int vnodeSaveInfo(const char *dir, const SVnodeInfo *pInfo) { // free info binary taosMemoryFree(data); - vInfo("vgId:%d, vnode info is saved, fname:%s replica:%d", pInfo->config.vgId, fname, pInfo->config.syncCfg.replicaNum); + vInfo("vgId:%d, vnode info is saved, fname:%s replica:%d", pInfo->config.vgId, fname, + pInfo->config.syncCfg.replicaNum); return 0; @@ -185,32 +186,80 @@ _err: return -1; } +static void vnodePrepareCommit(SVnode *pVnode) { + tsem_wait(&pVnode->canCommit); + + tsdbPrepareCommit(pVnode->pTsdb); + metaPrepareAsyncCommit(pVnode->pMeta); + smaPrepareAsyncCommit(pVnode->pSma); + + vnodeBufPoolUnRef(pVnode->inUse); + pVnode->inUse = NULL; +} +static int32_t vnodeCommitTask(void *arg) { + int32_t code = 0; + + SCommitInfo *pInfo = (SCommitInfo *)arg; + + // commit + code = vnodeCommitImpl(pInfo); + if (code) goto _exit; + + // end commit + tsem_post(&pInfo->pVnode->canCommit); + +_exit: + taosMemoryFree(pInfo); + return code; +} int vnodeAsyncCommit(SVnode *pVnode) { - vnodeWaitCommit(pVnode); + int32_t code = 0; - // vnodeBufPoolSwitch(pVnode); - // tsdbPrepareCommit(pVnode->pTsdb); + // prepare to commit + vnodePrepareCommit(pVnode); - vnodeScheduleTask(vnodeCommitImpl, pVnode); + // schedule the task + pVnode->state.commitTerm = pVnode->state.applyTerm; - return 0; + SCommitInfo *pInfo = (SCommitInfo *)taosMemoryCalloc(1, sizeof(*pInfo)); + if (NULL == pInfo) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + pInfo->info.config = pVnode->config; + pInfo->info.state.committed = pVnode->state.applied; + pInfo->info.state.commitTerm = pVnode->state.applyTerm; + pInfo->info.state.commitID = pVnode->state.commitID; + pInfo->pVnode = pVnode; + pInfo->txn = metaGetTxn(pVnode->pMeta); + vnodeScheduleTask(vnodeCommitTask, pInfo); + +_exit: + if (code) { + vError("vgId:%d %s failed since %s, commit id:%" PRId64, TD_VID(pVnode), __func__, tstrerror(code), + pVnode->state.commitID); + } else { + vDebug("vgId:%d %s done", TD_VID(pVnode), __func__); + } + return code; } int vnodeSyncCommit(SVnode *pVnode) { vnodeAsyncCommit(pVnode); - vnodeWaitCommit(pVnode); - tsem_post(&(pVnode->canCommit)); + tsem_wait(&pVnode->canCommit); + tsem_post(&pVnode->canCommit); return 0; } -int vnodeCommit(SVnode *pVnode) { - int32_t code = 0; - int32_t lino = 0; - SVnodeInfo info = {0}; - char dir[TSDB_FILENAME_LEN]; +static int vnodeCommitImpl(SCommitInfo *pInfo) { + int32_t code = 0; + int32_t lino = 0; - vInfo("vgId:%d, start to commit, commit ID:%" PRId64 " version:%" PRId64, TD_VID(pVnode), pVnode->state.commitID, - pVnode->state.applied); + char dir[TSDB_FILENAME_LEN] = {0}; + SVnode *pVnode = pInfo->pVnode; + + vInfo("vgId:%d, start to commit, commit ID:%" PRId64 " version:%" PRId64 " term: %" PRId64, TD_VID(pVnode), + pVnode->state.commitID, pVnode->state.applied, pVnode->state.applyTerm); // persist wal before starting if (walPersist(pVnode->pWal) < 0) { @@ -218,19 +267,13 @@ int vnodeCommit(SVnode *pVnode) { return -1; } - pVnode->state.commitTerm = pVnode->state.applyTerm; - // save info - info.config = pVnode->config; - info.state.committed = pVnode->state.applied; - info.state.commitTerm = pVnode->state.applyTerm; - info.state.commitID = pVnode->state.commitID; if (pVnode->pTfs) { snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pVnode->pTfs), TD_DIRSEP, pVnode->path); } else { snprintf(dir, TSDB_FILENAME_LEN, "%s", pVnode->path); } - if (vnodeSaveInfo(dir, &info) < 0) { + if (vnodeSaveInfo(dir, &pInfo->info) < 0) { code = terrno; TSDB_CHECK_CODE(code, lino, _exit); } @@ -238,23 +281,12 @@ int vnodeCommit(SVnode *pVnode) { // walBeginSnapshot(pVnode->pWal, pVnode->state.applied); syncBeginSnapshot(pVnode->sync, pVnode->state.applied); - code = smaPreCommit(pVnode->pSma); - TSDB_CHECK_CODE(code, lino, _exit); - - vnodeBufPoolUnRef(pVnode->inUse); - pVnode->inUse = NULL; - // commit each sub-system - if (metaCommit(pVnode->pMeta) < 0) { - code = TSDB_CODE_FAILED; - TSDB_CHECK_CODE(code, lino, _exit); - } - - code = tsdbCommit(pVnode->pTsdb); + code = tsdbCommit(pVnode->pTsdb, pInfo); TSDB_CHECK_CODE(code, lino, _exit); if (VND_IS_RSMA(pVnode)) { - code = smaCommit(pVnode->pSma); + code = smaCommit(pVnode->pSma, pInfo); TSDB_CHECK_CODE(code, lino, _exit); } @@ -264,7 +296,7 @@ int vnodeCommit(SVnode *pVnode) { } // commit info - if (vnodeCommitInfo(dir, &info) < 0) { + if (vnodeCommitInfo(dir, &pInfo->info) < 0) { code = terrno; TSDB_CHECK_CODE(code, lino, _exit); } @@ -277,19 +309,18 @@ int vnodeCommit(SVnode *pVnode) { TSDB_CHECK_CODE(code, lino, _exit); } - if (metaFinishCommit(pVnode->pMeta) < 0) { + if (metaFinishCommit(pVnode->pMeta, pInfo->txn) < 0) { code = terrno; TSDB_CHECK_CODE(code, lino, _exit); } - pVnode->state.committed = info.state.committed; + pVnode->state.committed = pInfo->info.state.committed; if (smaPostCommit(pVnode->pSma) < 0) { vError("vgId:%d, failed to post-commit sma since %s", TD_VID(pVnode), tstrerror(terrno)); return -1; } - // apply the commit (TODO) // walEndSnapshot(pVnode->pWal); syncEndSnapshot(pVnode->sync); @@ -318,20 +349,6 @@ void vnodeRollback(SVnode *pVnode) { (void)taosRemoveFile(tFName); } -static int vnodeCommitImpl(void *arg) { - SVnode *pVnode = (SVnode *)arg; - - // metaCommit(pVnode->pMeta); - tqCommit(pVnode->pTq); - // tsdbCommit(pVnode->pTsdb, ); - - // vnodeBufPoolRecycle(pVnode); - tsem_post(&(pVnode->canCommit)); - return 0; -} - -static FORCE_INLINE void vnodeWaitCommit(SVnode *pVnode) { tsem_wait(&pVnode->canCommit); } - static int vnodeEncodeState(const void *pObj, SJson *pJson) { const SVState *pState = (SVState *)pObj; diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index 77d375bc45..e09fafb756 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -144,9 +144,9 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) { pVnode->config = info.config; pVnode->state.committed = info.state.committed; pVnode->state.commitTerm = info.state.commitTerm; - pVnode->state.applied = info.state.committed; pVnode->state.commitID = info.state.commitID; - pVnode->state.commitTerm = info.state.commitTerm; + pVnode->state.applied = info.state.committed; + pVnode->state.applyTerm = info.state.commitTerm; pVnode->pTfs = pTfs; pVnode->msgCb = msgCb; taosThreadMutexInit(&pVnode->lock, NULL); @@ -242,14 +242,14 @@ _err: return NULL; } -void vnodePreClose(SVnode *pVnode) { +void vnodePreClose(SVnode *pVnode) { vnodeQueryPreClose(pVnode); - vnodeSyncPreClose(pVnode); + vnodeSyncPreClose(pVnode); } void vnodeClose(SVnode *pVnode) { if (pVnode) { - vnodeCommit(pVnode); + vnodeSyncCommit(pVnode); vnodeSyncClose(pVnode); vnodeQueryClose(pVnode); walClose(pVnode->pWal); @@ -269,10 +269,7 @@ void vnodeClose(SVnode *pVnode) { } // start the sync timer after the queue is ready -int32_t vnodeStart(SVnode *pVnode) { - vnodeSyncStart(pVnode); - return 0; -} +int32_t vnodeStart(SVnode *pVnode) { return vnodeSyncStart(pVnode); } void vnodeStop(SVnode *pVnode) {} diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 8e9aab0afd..1199127f6d 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -380,6 +380,7 @@ int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { pLoad->vgId = TD_VID(pVnode); pLoad->syncState = state.state; pLoad->syncRestore = state.restored; + pLoad->syncCanRead = state.canRead; pLoad->cacheUsage = tsdbCacheGetUsage(pVnode); pLoad->numOfTables = metaGetTbNum(pVnode->pMeta); pLoad->numOfTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta); diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index e8cdf9513f..a34744a1da 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -259,7 +259,7 @@ int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWr pWriter->ever = ever; // commit it - code = vnodeCommit(pVnode); + code = vnodeSyncCommit(pVnode); if (code) { taosMemoryFree(pWriter); goto _err; diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 2d87bb3b07..d8c8a3e1b2 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -178,9 +178,18 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp return -1; } + if (version <= pVnode->state.applied) { + vError("vgId:%d, duplicate write request. version: %" PRId64 ", applied: %" PRId64 "", TD_VID(pVnode), version, + pVnode->state.applied); + terrno = TSDB_CODE_VND_DUP_REQUEST; + pRsp->info.handle = NULL; + return -1; + } + vDebug("vgId:%d, start to process write request %s, index:%" PRId64, TD_VID(pVnode), TMSG_INFO(pMsg->msgType), version); + ASSERT(pVnode->state.applyTerm <= pMsg->info.conn.applyTerm); pVnode->state.applied = version; pVnode->state.applyTerm = pMsg->info.conn.applyTerm; @@ -283,7 +292,9 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp vnodeProcessAlterConfigReq(pVnode, version, pReq, len, pRsp); break; case TDMT_VND_COMMIT: - goto _do_commit; + vnodeSyncCommit(pVnode); + vnodeBegin(pVnode); + goto _exit; default: vError("vgId:%d, unprocessed msg, %d", TD_VID(pVnode), pMsg->msgType); return -1; @@ -301,13 +312,12 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp // commit if need if (vnodeShouldCommit(pVnode)) { - _do_commit: vInfo("vgId:%d, commit at version %" PRId64, TD_VID(pVnode), version); - // commit current change - if (vnodeCommit(pVnode) < 0) { - vError("vgId:%d, failed to commit vnode since %s.", TD_VID(pVnode), tstrerror(terrno)); - goto _err; - } +#if 0 + vnodeSyncCommit(pVnode); +#else + vnodeAsyncCommit(pVnode); +#endif // start a new one if (vnodeBegin(pVnode) < 0) { @@ -316,6 +326,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp } } +_exit: return 0; _err: @@ -336,7 +347,7 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) { vTrace("message in vnode query queue is processing"); // if ((pMsg->msgType == TDMT_SCH_QUERY) && !vnodeIsLeader(pVnode)) { if ((pMsg->msgType == TDMT_SCH_QUERY) && !syncIsReadyForRead(pVnode->sync)) { - vnodeRedirectRpcMsg(pVnode, pMsg); + vnodeRedirectRpcMsg(pVnode, pMsg, terrno); return 0; } @@ -359,12 +370,12 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { pMsg->msgType == TDMT_VND_BATCH_META) && !syncIsReadyForRead(pVnode->sync)) { // !vnodeIsLeader(pVnode)) { - vnodeRedirectRpcMsg(pVnode, pMsg); + vnodeRedirectRpcMsg(pVnode, pMsg, terrno); return 0; } if (pMsg->msgType == TDMT_VND_TMQ_CONSUME && !pVnode->restored) { - vnodeRedirectRpcMsg(pVnode, pMsg); + vnodeRedirectRpcMsg(pVnode, pMsg, TSDB_CODE_SYN_RESTORING); return 0; } diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index dd382411c1..1c2139c95d 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -16,16 +16,17 @@ #define _DEFAULT_SOURCE #include "vnd.h" -#define BATCH_DISABLE 1 - -static inline bool vnodeIsMsgBlock(tmsg_t type) { - return (type == TDMT_VND_CREATE_TABLE) || (type == TDMT_VND_ALTER_TABLE) || (type == TDMT_VND_DROP_TABLE) || - (type == TDMT_VND_UPDATE_TAG_VAL); -} +#define BATCH_ENABLE 0 static inline bool vnodeIsMsgWeak(tmsg_t type) { return false; } static inline void vnodeWaitBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) { + const STraceId *trace = &pMsg->info.traceId; + vGTrace("vgId:%d, msg:%p wait block, type:%s", pVnode->config.vgId, pMsg, TMSG_INFO(pMsg->msgType)); + tsem_wait(&pVnode->syncSem); +} + +static inline void vnodeWaitBlockMsgOld(SVnode *pVnode, const SRpcMsg *pMsg) { if (vnodeIsMsgBlock(pMsg->msgType)) { const STraceId *trace = &pMsg->info.traceId; taosThreadMutexLock(&pVnode->lock); @@ -53,7 +54,7 @@ static inline void vnodePostBlockMsg(SVnode *pVnode, const SRpcMsg *pMsg) { } } -void vnodeRedirectRpcMsg(SVnode *pVnode, SRpcMsg *pMsg) { +void vnodeRedirectRpcMsg(SVnode *pVnode, SRpcMsg *pMsg, int32_t code) { SEpSet newEpSet = {0}; syncGetRetryEpSet(pVnode->sync, &newEpSet); @@ -66,8 +67,20 @@ void vnodeRedirectRpcMsg(SVnode *pVnode, SRpcMsg *pMsg) { } pMsg->info.hasEpSet = 1; - SRpcMsg rsp = {.code = TSDB_CODE_SYN_NOT_LEADER, .info = pMsg->info, .msgType = pMsg->msgType + 1}; - tmsgSendRedirectRsp(&rsp, &newEpSet); + if (code == 0) code = TSDB_CODE_SYN_NOT_LEADER; + + SRpcMsg rsp = {.code = code, .info = pMsg->info, .msgType = pMsg->msgType + 1}; + int32_t contLen = tSerializeSEpSet(NULL, 0, &newEpSet); + + rsp.pCont = rpcMallocCont(contLen); + if (rsp.pCont == NULL) { + pMsg->code = TSDB_CODE_OUT_OF_MEMORY; + } else { + tSerializeSEpSet(rsp.pCont, contLen, &newEpSet); + rsp.contLen = contLen; + } + + tmsgSendRsp(&rsp); } static void inline vnodeHandleWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) { @@ -87,8 +100,8 @@ static void inline vnodeHandleWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) { } static void vnodeHandleProposeError(SVnode *pVnode, SRpcMsg *pMsg, int32_t code) { - if (code == TSDB_CODE_SYN_NOT_LEADER) { - vnodeRedirectRpcMsg(pVnode, pMsg); + if (code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_SYN_RESTORING) { + vnodeRedirectRpcMsg(pVnode, pMsg, code); } else { const STraceId *trace = &pMsg->info.traceId; vGError("vgId:%d, msg:%p failed to propose since %s, code:0x%x", pVnode->config.vgId, pMsg, tstrerror(code), code); @@ -99,28 +112,35 @@ static void vnodeHandleProposeError(SVnode *pVnode, SRpcMsg *pMsg, int32_t code) } } +#if BATCH_ENABLE + static void inline vnodeProposeBatchMsg(SVnode *pVnode, SRpcMsg **pMsgArr, bool *pIsWeakArr, int32_t *arrSize) { if (*arrSize <= 0) return; + SRpcMsg *pLastMsg = pMsgArr[*arrSize - 1]; -#if BATCH_DISABLE - int32_t code = syncPropose(pVnode->sync, pMsgArr[0], pIsWeakArr[0]); -#else + taosThreadMutexLock(&pVnode->lock); int32_t code = syncProposeBatch(pVnode->sync, pMsgArr, pIsWeakArr, *arrSize); -#endif + bool wait = (code == 0 && vnodeIsBlockMsg(pLastMsg->msgType)); + if (wait) { + ASSERT(!pVnode->blocked); + pVnode->blocked = true; + } + taosThreadMutexUnlock(&pVnode->lock); if (code > 0) { for (int32_t i = 0; i < *arrSize; ++i) { vnodeHandleWriteMsg(pVnode, pMsgArr[i]); } - } else if (code == 0) { - vnodeWaitBlockMsg(pVnode, pMsgArr[*arrSize - 1]); - } else { + } else if (code < 0) { if (terrno != 0) code = terrno; for (int32_t i = 0; i < *arrSize; ++i) { vnodeHandleProposeError(pVnode, pMsgArr[i], code); } } + if (wait) vnodeWaitBlockMsg(pVnode, pLastMsg); + pLastMsg = NULL; + for (int32_t i = 0; i < *arrSize; ++i) { SRpcMsg *pMsg = pMsgArr[i]; const STraceId *trace = &pMsg->info.traceId; @@ -153,8 +173,8 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) if (!pVnode->restored) { vGError("vgId:%d, msg:%p failed to process since restore not finished", vgId, pMsg); - terrno = TSDB_CODE_APP_NOT_READY; - vnodeHandleProposeError(pVnode, pMsg, TSDB_CODE_APP_NOT_READY); + terrno = TSDB_CODE_SYN_RESTORING; + vnodeHandleProposeError(pVnode, pMsg, TSDB_CODE_SYN_RESTORING); rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); continue; @@ -177,7 +197,7 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) continue; } - if (isBlock || BATCH_DISABLE) { + if (isBlock) { vnodeProposeBatchMsg(pVnode, pMsgArr, pIsWeakArr, &arrayPos); } @@ -185,7 +205,7 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) pIsWeakArr[arrayPos] = isWeak; arrayPos++; - if (isBlock || msg == numOfMsgs - 1 || BATCH_DISABLE) { + if (isBlock || msg == numOfMsgs - 1) { vnodeProposeBatchMsg(pVnode, pMsgArr, pIsWeakArr, &arrayPos); } } @@ -194,6 +214,72 @@ void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) taosMemoryFree(pIsWeakArr); } +#else + +static int32_t inline vnodeProposeMsg(SVnode *pVnode, SRpcMsg *pMsg, bool isWeak) { + taosThreadMutexLock(&pVnode->lock); + int32_t code = syncPropose(pVnode->sync, pMsg, isWeak); + bool wait = (code == 0 && vnodeIsMsgBlock(pMsg->msgType)); + if (wait) { + ASSERT(!pVnode->blocked); + pVnode->blocked = true; + } + taosThreadMutexUnlock(&pVnode->lock); + + if (code > 0) { + vnodeHandleWriteMsg(pVnode, pMsg); + } else if (code < 0) { + if (terrno != 0) code = terrno; + vnodeHandleProposeError(pVnode, pMsg, code); + } + + if (wait) vnodeWaitBlockMsg(pVnode, pMsg); + return code; +} + +void vnodeProposeWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { + SVnode *pVnode = pInfo->ahandle; + int32_t vgId = pVnode->config.vgId; + int32_t code = 0; + SRpcMsg *pMsg = NULL; + vTrace("vgId:%d, get %d msgs from vnode-write queue", vgId, numOfMsgs); + + for (int32_t msg = 0; msg < numOfMsgs; msg++) { + if (taosGetQitem(qall, (void **)&pMsg) == 0) continue; + bool isWeak = vnodeIsMsgWeak(pMsg->msgType); + + const STraceId *trace = &pMsg->info.traceId; + vGTrace("vgId:%d, msg:%p get from vnode-write queue, weak:%d block:%d msg:%d:%d, handle:%p", vgId, pMsg, isWeak, + vnodeIsMsgBlock(pMsg->msgType), msg, numOfMsgs, pMsg->info.handle); + + if (!pVnode->restored) { + vGError("vgId:%d, msg:%p failed to process since restore not finished", vgId, pMsg); + vnodeHandleProposeError(pVnode, pMsg, TSDB_CODE_SYN_RESTORING); + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); + continue; + } + + code = vnodePreProcessWriteMsg(pVnode, pMsg); + if (code != 0) { + vGError("vgId:%d, msg:%p failed to pre-process since %s", vgId, pMsg, terrstr()); + if (terrno != 0) code = terrno; + vnodeHandleProposeError(pVnode, pMsg, code); + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); + continue; + } + + code = vnodeProposeMsg(pVnode, pMsg, isWeak); + + vGTrace("vgId:%d, msg:%p is freed, code:0x%x", vgId, pMsg, code); + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); + } +} + +#endif + void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { SVnode *pVnode = pInfo->ahandle; int32_t vgId = pVnode->config.vgId; @@ -206,6 +292,11 @@ void vnodeApplyWriteMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) { vGTrace("vgId:%d, msg:%p get from vnode-apply queue, type:%s handle:%p index:%" PRId64, vgId, pMsg, TMSG_INFO(pMsg->msgType), pMsg->info.handle, pMsg->info.conn.applyIndex); + if (vnodeIsMsgBlock(pMsg->msgType)) { + vTrace("vgId:%d, blocking msg obtained from apply-queue. index:%" PRId64 ", term: %" PRId64 ", type: %s", vgId, + pMsg->info.conn.applyIndex, pMsg->info.conn.applyTerm, TMSG_INFO(pMsg->msgType)); + } + SRpcMsg rsp = {.code = pMsg->code, .info = pMsg->info}; if (rsp.code == 0) { if (vnodeProcessWriteMsg(pVnode, pMsg, pMsg->info.conn.applyIndex, &rsp) < 0) { @@ -295,36 +386,32 @@ static int32_t vnodeSyncGetSnapshot(const SSyncFSM *pFsm, SSnapshot *pSnapshot) return 0; } -static void vnodeSyncApplyMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const SFsmCbMeta *pMeta) { +static int32_t vnodeSyncApplyMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) { SVnode *pVnode = pFsm->data; - - SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen}; - rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen); - memcpy(rpcMsg.pCont, pMsg->pCont, pMsg->contLen); - rpcMsg.info = pMsg->info; - rpcMsg.info.conn.applyIndex = pMeta->index; - rpcMsg.info.conn.applyTerm = pMeta->term; + pMsg->info.conn.applyIndex = pMeta->index; + pMsg->info.conn.applyTerm = pMeta->term; const STraceId *trace = &pMsg->info.traceId; vGTrace("vgId:%d, commit-cb is excuted, fsm:%p, index:%" PRId64 ", term:%" PRIu64 ", msg-index:%" PRId64 ", weak:%d, code:%d, state:%d %s, type:%s", - pVnode->config.vgId, pFsm, pMeta->index, pMeta->term, rpcMsg.info.conn.applyIndex, pMeta->isWeak, pMeta->code, + pVnode->config.vgId, pFsm, pMeta->index, pMeta->term, pMsg->info.conn.applyIndex, pMeta->isWeak, pMeta->code, pMeta->state, syncStr(pMeta->state), TMSG_INFO(pMsg->msgType)); - tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg); + return tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, pMsg); } -static void vnodeSyncCommitMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const SFsmCbMeta *pMeta) { - vnodeSyncApplyMsg(pFsm, pMsg, pMeta); +static int32_t vnodeSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) { + return vnodeSyncApplyMsg(pFsm, pMsg, pMeta); } -static void vnodeSyncPreCommitMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const SFsmCbMeta *pMeta) { +static int32_t vnodeSyncPreCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) { if (pMeta->isWeak == 1) { - vnodeSyncApplyMsg(pFsm, pMsg, pMeta); + return vnodeSyncApplyMsg(pFsm, pMsg, pMeta); } + return 0; } -static void vnodeSyncRollBackMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const SFsmCbMeta *pMeta) { +static void vnodeSyncRollBackMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) { SVnode *pVnode = pFsm->data; vTrace("vgId:%d, rollback-cb is excuted, fsm:%p, index:%" PRId64 ", weak:%d, code:%d, state:%d %s, type:%s", pVnode->config.vgId, pFsm, pMeta->index, pMeta->isWeak, pMeta->code, pMeta->state, syncStr(pMeta->state), @@ -404,7 +491,7 @@ static void vnodeRestoreFinish(const SSyncFSM *pFsm) { walApplyVer(pVnode->pWal, pVnode->state.applied); pVnode->restored = true; - vDebug("vgId:%d, sync restore finished", pVnode->config.vgId); + vInfo("vgId:%d, sync restore finished", pVnode->config.vgId); } static void vnodeBecomeFollower(const SSyncFSM *pFsm) { @@ -506,16 +593,20 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) { return 0; } -void vnodeSyncStart(SVnode *pVnode) { +int32_t vnodeSyncStart(SVnode *pVnode) { vInfo("vgId:%d, start sync", pVnode->config.vgId); - syncStart(pVnode->sync); + if (syncStart(pVnode->sync) < 0) { + vError("vgId:%d, failed to start sync subsystem since %s", pVnode->config.vgId, terrstr()); + return -1; + } + return 0; } void vnodeSyncPreClose(SVnode *pVnode) { vInfo("vgId:%d, pre close sync", pVnode->config.vgId); syncLeaderTransfer(pVnode->sync); syncPreStop(pVnode->sync); - +#if 0 while (syncSnapshotRecving(pVnode->sync)) { vInfo("vgId:%d, snapshot is recving", pVnode->config.vgId); taosMsleep(300); @@ -524,7 +615,7 @@ void vnodeSyncPreClose(SVnode *pVnode) { vInfo("vgId:%d, snapshot is sending", pVnode->config.vgId); taosMsleep(300); } - +#endif taosThreadMutexLock(&pVnode->lock); if (pVnode->blocked) { vInfo("vgId:%d, post block after close sync", pVnode->config.vgId); @@ -545,21 +636,23 @@ bool vnodeIsRoleLeader(SVnode *pVnode) { } bool vnodeIsLeader(SVnode *pVnode) { + terrno = 0; SSyncState state = syncGetState(pVnode->sync); - if (state.state != TAOS_SYNC_STATE_LEADER || !state.restored) { - if (state.state != TAOS_SYNC_STATE_LEADER) { - terrno = TSDB_CODE_SYN_NOT_LEADER; - } else { - terrno = TSDB_CODE_APP_NOT_READY; - } - vDebug("vgId:%d, vnode not ready, state:%s, restore:%d", pVnode->config.vgId, syncStr(state.state), state.restored); + if (terrno != 0) { + vInfo("vgId:%d, vnode is stopping", pVnode->config.vgId); return false; } - if (!pVnode->restored) { - vDebug("vgId:%d, vnode not restored", pVnode->config.vgId); - terrno = TSDB_CODE_APP_NOT_READY; + if (state.state != TAOS_SYNC_STATE_LEADER) { + terrno = TSDB_CODE_SYN_NOT_LEADER; + vInfo("vgId:%d, vnode not leader, state:%s", pVnode->config.vgId, syncStr(state.state)); + return false; + } + + if (!state.restored || !pVnode->restored) { + terrno = TSDB_CODE_SYN_RESTORING; + vInfo("vgId:%d, vnode not restored:%d:%d", pVnode->config.vgId, state.restored, pVnode->restored); return false; } diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index c95d0fe462..ba99906589 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -762,7 +762,6 @@ int32_t ctgCloneMetaOutput(STableMetaOutput* output, STableMetaOutput** pOutput) int32_t ctgGenerateVgList(SCatalog* pCtg, SHashObj* vgHash, SArray** pList); void ctgFreeJob(void* job); void ctgFreeHandleImpl(SCatalog* pCtg); -void ctgFreeVgInfo(SDBVgInfo* vgInfo); int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName* pTableName, SVgroupInfo* pVgroup); int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo* dbInfo, SCtgTbHashsCtx* pCtx, char* dbFName, SArray* pNames, bool update); @@ -789,6 +788,8 @@ int32_t ctgRemoveTbMeta(SCatalog* pCtg, SName* pTableName); int32_t ctgGetTbHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SVgroupInfo* pVgroup, bool* exists); SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch); int32_t ctgdGetOneHandle(SCatalog **pHandle); +int ctgVgInfoComp(const void* lp, const void* rp); +int32_t ctgMakeVgArray(SDBVgInfo* dbInfo); extern SCatalogMgmt gCtgMgmt; extern SCtgDebug gCTGDebug; diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 3a398d1551..1b9bf7f99c 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -505,8 +505,7 @@ _return: taosMemoryFreeClear(tbMeta); if (vgInfo) { - taosHashCleanup(vgInfo->vgHash); - taosMemoryFreeClear(vgInfo); + freeVgInfo(vgInfo); } if (vgList) { @@ -546,8 +545,7 @@ _return: } if (vgInfo) { - taosHashCleanup(vgInfo->vgHash); - taosMemoryFreeClear(vgInfo); + freeVgInfo(vgInfo); } CTG_RET(code); @@ -619,7 +617,7 @@ int32_t catalogInit(SCatalogCfg* cfg) { gCtgMgmt.queue.head = taosMemoryCalloc(1, sizeof(SCtgQNode)); if (NULL == gCtgMgmt.queue.head) { qError("calloc %d failed", (int32_t)sizeof(SCtgQNode)); - CTG_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } gCtgMgmt.queue.tail = gCtgMgmt.queue.head; @@ -778,8 +776,7 @@ _return: } if (vgInfo) { - taosHashCleanup(vgInfo->vgHash); - taosMemoryFreeClear(vgInfo); + freeVgInfo(vgInfo); } CTG_API_LEAVE(code); @@ -836,8 +833,7 @@ _return: ctgRUnlockVgInfo(dbCache); ctgReleaseDBCache(pCtg, dbCache); } else if (dbInfo) { - taosHashCleanup(dbInfo->vgHash); - taosMemoryFreeClear(dbInfo); + freeVgInfo(dbInfo); } CTG_API_LEAVE(code); @@ -849,7 +845,7 @@ int32_t catalogUpdateDBVgInfo(SCatalog* pCtg, const char* dbFName, uint64_t dbId int32_t code = 0; if (NULL == pCtg || NULL == dbFName || NULL == dbInfo) { - ctgFreeVgInfo(dbInfo); + freeVgInfo(dbInfo); CTG_ERR_JRET(TSDB_CODE_CTG_INVALID_INPUT); } diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index 19b7ee32ae..f41058584f 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -226,6 +226,7 @@ _return: return TSDB_CODE_SUCCESS; } +/* int32_t ctgAcquireStbMetaFromCache(SCatalog *pCtg, char *dbFName, uint64_t suid, SCtgDBCache **pDb, SCtgTbCache **pTb) { SCtgDBCache *dbCache = NULL; SCtgTbCache *pCache = NULL; @@ -276,6 +277,49 @@ _return: return TSDB_CODE_SUCCESS; } +*/ + +int32_t ctgAcquireStbMetaFromCache(SCtgDBCache *dbCache, SCatalog *pCtg, char *dbFName, uint64_t suid, SCtgTbCache **pTb) { + SCtgTbCache *pCache = NULL; + char *stName = taosHashAcquire(dbCache->stbCache, &suid, sizeof(suid)); + if (NULL == stName) { + ctgDebug("stb 0x%" PRIx64 " not in cache, dbFName:%s", suid, dbFName); + goto _return; + } + + pCache = taosHashAcquire(dbCache->tbCache, stName, strlen(stName)); + if (NULL == pCache) { + ctgDebug("stb 0x%" PRIx64 " name %s not in cache, dbFName:%s", suid, stName, dbFName); + taosHashRelease(dbCache->stbCache, stName); + goto _return; + } + + taosHashRelease(dbCache->stbCache, stName); + + CTG_LOCK(CTG_READ, &pCache->metaLock); + if (NULL == pCache->pMeta) { + ctgDebug("stb 0x%" PRIx64 " meta not in cache, dbFName:%s", suid, dbFName); + goto _return; + } + + *pTb = pCache; + + ctgDebug("stb 0x%" PRIx64 " meta got in cache, dbFName:%s", suid, dbFName); + + CTG_CACHE_STAT_INC(numOfMetaHit, 1); + + return TSDB_CODE_SUCCESS; + +_return: + + ctgReleaseTbMetaToCache(pCtg, dbCache, pCache); + + CTG_CACHE_STAT_INC(numOfMetaMiss, 1); + + *pTb = NULL; + + return TSDB_CODE_SUCCESS; +} int32_t ctgAcquireTbIndexFromCache(SCatalog *pCtg, char *dbFName, char *tbName, SCtgDBCache **pDb, SCtgTbCache **pTb) { SCtgDBCache *dbCache = NULL; @@ -384,13 +428,19 @@ int32_t ctgReadTbMetaFromCache(SCatalog *pCtg, SCtgTbMetaCtx *ctx, STableMeta ** memcpy(*pTableMeta, tbMeta, metaSize); - ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache); + //ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache); + + if (tbCache) { + CTG_UNLOCK(CTG_READ, &tbCache->metaLock); + taosHashRelease(dbCache->tbCache, tbCache); + } + ctgDebug("Got ctb %s meta from cache, will continue to get its stb meta, type:%d, dbFName:%s", ctx->pName->tname, ctx->tbInfo.tbType, dbFName); - ctgAcquireStbMetaFromCache(pCtg, dbFName, ctx->tbInfo.suid, &dbCache, &tbCache); + ctgAcquireStbMetaFromCache(dbCache, pCtg, dbFName, ctx->tbInfo.suid, &tbCache); if (NULL == tbCache) { - ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache); + //ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache); taosMemoryFreeClear(*pTableMeta); ctgDebug("stb 0x%" PRIx64 " meta not in cache", ctx->tbInfo.suid); return TSDB_CODE_SUCCESS; @@ -460,12 +510,17 @@ int32_t ctgReadTbVerFromCache(SCatalog *pCtg, SName *pTableName, int32_t *sver, // PROCESS FOR CHILD TABLE - ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache); + //ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache); + if (tbCache) { + CTG_UNLOCK(CTG_READ, &tbCache->metaLock); + taosHashRelease(dbCache->tbCache, tbCache); + } + ctgDebug("Got ctb %s ver from cache, will continue to get its stb ver, dbFName:%s", pTableName->tname, dbFName); - ctgAcquireStbMetaFromCache(pCtg, dbFName, *suid, &dbCache, &tbCache); + ctgAcquireStbMetaFromCache(dbCache, pCtg, dbFName, *suid, &tbCache); if (NULL == tbCache) { - ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache); + //ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache); ctgDebug("stb 0x%" PRIx64 " meta not in cache", *suid); return TSDB_CODE_SUCCESS; } @@ -794,7 +849,7 @@ int32_t ctgUpdateVgroupEnqueue(SCatalog *pCtg, const char *dbFName, int64_t dbId if (NULL == msg) { ctgError("malloc %d failed", (int32_t)sizeof(SCtgUpdateVgMsg)); taosMemoryFree(op); - ctgFreeVgInfo(dbInfo); + freeVgInfo(dbInfo); CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } @@ -803,6 +858,14 @@ int32_t ctgUpdateVgroupEnqueue(SCatalog *pCtg, const char *dbFName, int64_t dbId dbFName = p + 1; } + code = ctgMakeVgArray(dbInfo); + if (code) { + taosMemoryFree(op); + taosMemoryFree(msg); + freeVgInfo(dbInfo); + CTG_ERR_RET(code); + } + tstrncpy(msg->dbFName, dbFName, sizeof(msg->dbFName)); msg->pCtg = pCtg; msg->dbId = dbId; @@ -816,7 +879,7 @@ int32_t ctgUpdateVgroupEnqueue(SCatalog *pCtg, const char *dbFName, int64_t dbId _return: - ctgFreeVgInfo(dbInfo); + freeVgInfo(dbInfo); CTG_RET(code); } @@ -1549,6 +1612,20 @@ void ctgFreeAllInstance(void) { taosHashClear(gCtgMgmt.pCluster); } +int32_t ctgVgInfoIdComp(void const* lp, void const* rp) { + int32_t* key = (int32_t*)lp; + SVgroupInfo* pVg = (SVgroupInfo*)rp; + + if (*key < pVg->vgId) { + return -1; + } else if (*key > pVg->vgId) { + return 1; + } + + return 0; +} + + int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) { int32_t code = 0; SCtgUpdateVgMsg *msg = operation->data; @@ -1600,7 +1677,7 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) { goto _return; } - ctgFreeVgInfo(vgInfo); + freeVgInfo(vgInfo); } vgCache->vgInfo = dbInfo; @@ -1621,7 +1698,7 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) { _return: - ctgFreeVgInfo(msg->dbInfo); + freeVgInfo(msg->dbInfo); taosMemoryFreeClear(msg); CTG_RET(code); @@ -1674,7 +1751,7 @@ int32_t ctgOpDropDbVgroup(SCtgCacheOperation *operation) { CTG_ERR_JRET(ctgWLockVgInfo(pCtg, dbCache)); - ctgFreeVgInfo(dbCache->vgCache.vgInfo); + freeVgInfo(dbCache->vgCache.vgInfo); dbCache->vgCache.vgInfo = NULL; ctgDebug("db vgInfo removed, dbFName:%s", msg->dbFName); @@ -1930,7 +2007,13 @@ int32_t ctgOpUpdateEpset(SCtgCacheOperation *operation) { SVgroupInfo *pInfo = taosHashGet(vgInfo->vgHash, &msg->vgId, sizeof(msg->vgId)); if (NULL == pInfo) { - ctgDebug("no vgroup %d in db %s, ignore epset update", msg->vgId, msg->dbFName); + ctgDebug("no vgroup %d in db %s vgHash, ignore epset update", msg->vgId, msg->dbFName); + goto _return; + } + + SVgroupInfo *pInfo2 = taosArraySearch(vgInfo->vgArray, &msg->vgId, ctgVgInfoIdComp, TD_EQ); + if (NULL == pInfo2) { + ctgDebug("no vgroup %d in db %s vgArray, ignore epset update", msg->vgId, msg->dbFName); goto _return; } @@ -1941,6 +2024,7 @@ int32_t ctgOpUpdateEpset(SCtgCacheOperation *operation) { msg->epSet.numOfEps, pNewEp->fqdn, pNewEp->port, msg->dbFName); pInfo->epSet = msg->epSet; + pInfo2->epSet = msg->epSet; _return: @@ -2057,7 +2141,7 @@ void ctgFreeCacheOperationData(SCtgCacheOperation *op) { switch (op->opId) { case CTG_OP_UPDATE_VGROUP: { SCtgUpdateVgMsg *msg = op->data; - ctgFreeVgInfo(msg->dbInfo); + freeVgInfo(msg->dbInfo); taosMemoryFreeClear(op->data); break; } diff --git a/source/libs/catalog/src/ctgRemote.c b/source/libs/catalog/src/ctgRemote.c index 753c4ce917..7cc6c90d30 100644 --- a/source/libs/catalog/src/ctgRemote.c +++ b/source/libs/catalog/src/ctgRemote.c @@ -384,13 +384,13 @@ int32_t ctgMakeMsgSendInfo(SCtgJob* pJob, SArray* pTaskId, int32_t batchId, SArr SMsgSendInfo* msgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == msgSendInfo) { qError("calloc %d failed", (int32_t)sizeof(SMsgSendInfo)); - CTG_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } SCtgTaskCallbackParam* param = taosMemoryCalloc(1, sizeof(SCtgTaskCallbackParam)); if (NULL == param) { qError("calloc %d failed", (int32_t)sizeof(SCtgTaskCallbackParam)); - CTG_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } param->reqType = msgType; diff --git a/source/libs/catalog/src/ctgUtil.c b/source/libs/catalog/src/ctgUtil.c index f795be3ac2..802ecde63e 100644 --- a/source/libs/catalog/src/ctgUtil.c +++ b/source/libs/catalog/src/ctgUtil.c @@ -231,20 +231,7 @@ void ctgFreeTbCache(SCtgDBCache* dbCache) { CTG_CACHE_STAT_DEC(numOfTbl, tblNum); } -void ctgFreeVgInfo(SDBVgInfo* vgInfo) { - if (NULL == vgInfo) { - return; - } - - if (vgInfo->vgHash) { - taosHashCleanup(vgInfo->vgHash); - vgInfo->vgHash = NULL; - } - - taosMemoryFreeClear(vgInfo); -} - -void ctgFreeVgInfoCache(SCtgDBCache* dbCache) { ctgFreeVgInfo(dbCache->vgCache.vgInfo); } +void ctgFreeVgInfoCache(SCtgDBCache* dbCache) { freeVgInfo(dbCache->vgCache.vgInfo); } void ctgFreeDbCache(SCtgDBCache* dbCache) { if (NULL == dbCache) { @@ -366,8 +353,7 @@ void ctgFreeSUseDbOutput(SUseDbOutput* pOutput) { } if (pOutput->dbVgroup) { - taosHashCleanup(pOutput->dbVgroup->vgHash); - taosMemoryFreeClear(pOutput->dbVgroup); + freeVgInfo(pOutput->dbVgroup); } taosMemoryFree(pOutput); @@ -573,8 +559,7 @@ void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void** pRes) { case CTG_TASK_GET_DB_VGROUP: { if (*pRes) { SDBVgInfo* pInfo = (SDBVgInfo*)*pRes; - taosHashCleanup(pInfo->vgHash); - taosMemoryFreeClear(*pRes); + freeVgInfo(pInfo); } break; } @@ -837,10 +822,36 @@ _return: CTG_RET(code); } +int ctgVgInfoComp(const void* lp, const void* rp) { + SVgroupInfo* pLeft = (SVgroupInfo*)lp; + SVgroupInfo* pRight = (SVgroupInfo*)rp; + if (pLeft->hashBegin < pRight->hashBegin) { + return -1; + } else if (pLeft->hashBegin > pRight->hashBegin) { + return 1; + } + + return 0; +} + +int32_t ctgHashValueComp(void const* lp, void const* rp) { + uint32_t* key = (uint32_t*)lp; + SVgroupInfo* pVg = (SVgroupInfo*)rp; + + if (*key < pVg->hashBegin) { + return -1; + } else if (*key > pVg->hashEnd) { + return 1; + } + + return 0; +} + int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName* pTableName, SVgroupInfo* pVgroup) { int32_t code = 0; + CTG_ERR_RET(ctgMakeVgArray(dbInfo)); - int32_t vgNum = taosHashGetSize(dbInfo->vgHash); + int32_t vgNum = taosArrayGetSize(dbInfo->vgArray); char db[TSDB_DB_FNAME_LEN] = {0}; tNameGetFullDbName(pTableName, db); @@ -856,6 +867,9 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName uint32_t hashValue = taosGetTbHashVal(tbFullName, (uint32_t)strlen(tbFullName), dbInfo->hashMethod, dbInfo->hashPrefix, dbInfo->hashSuffix); + vgInfo = taosArraySearch(dbInfo->vgArray, &hashValue, ctgHashValueComp, TD_EQ); + +/* void* pIter = taosHashIterate(dbInfo->vgHash, NULL); while (pIter) { vgInfo = pIter; @@ -867,10 +881,11 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName pIter = taosHashIterate(dbInfo->vgHash, pIter); vgInfo = NULL; } +*/ if (NULL == vgInfo) { ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, db, - taosHashGetSize(dbInfo->vgHash)); + (int32_t)taosArrayGetSize(dbInfo->vgArray)); CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); } @@ -883,37 +898,15 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName CTG_RET(code); } -int32_t ctgHashValueComp(void const* lp, void const* rp) { - uint32_t* key = (uint32_t*)lp; - SVgroupInfo* pVg = *(SVgroupInfo**)rp; - - if (*key < pVg->hashBegin) { - return -1; - } else if (*key > pVg->hashEnd) { - return 1; - } - - return 0; -} - -int ctgVgInfoComp(const void* lp, const void* rp) { - SVgroupInfo* pLeft = *(SVgroupInfo**)lp; - SVgroupInfo* pRight = *(SVgroupInfo**)rp; - if (pLeft->hashBegin < pRight->hashBegin) { - return -1; - } else if (pLeft->hashBegin > pRight->hashBegin) { - return 1; - } - - return 0; -} - int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo* dbInfo, SCtgTbHashsCtx* pCtx, char* dbFName, SArray* pNames, bool update) { int32_t code = 0; SCtgTask* pTask = tReq->pTask; SMetaRes res = {0}; - int32_t vgNum = taosHashGetSize(dbInfo->vgHash); + + CTG_ERR_RET(ctgMakeVgArray(dbInfo)); + + int32_t vgNum = taosArrayGetSize(dbInfo->vgArray); if (vgNum <= 0) { ctgError("db vgroup cache invalid, db:%s, vgroup number:%d", dbFName, vgNum); CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); @@ -923,20 +916,13 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo* int32_t tbNum = taosArrayGetSize(pNames); if (1 == vgNum) { - void* pIter = taosHashIterate(dbInfo->vgHash, NULL); - if (NULL == pIter) { - ctgError("empty vgHash, db:%s, vgroup number:%d", dbFName, vgNum); - CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); - } - for (int32_t i = 0; i < tbNum; ++i) { vgInfo = taosMemoryMalloc(sizeof(SVgroupInfo)); if (NULL == vgInfo) { - taosHashCancelIterate(dbInfo->vgHash, pIter); CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - *vgInfo = *(SVgroupInfo*)pIter; + *vgInfo = *(SVgroupInfo*)taosArrayGet(dbInfo->vgArray, 0); ctgDebug("Got tb hash vgroup, vgId:%d, epNum %d, current %s port %d", vgInfo->vgId, vgInfo->epSet.numOfEps, vgInfo->epSet.eps[vgInfo->epSet.inUse].fqdn, vgInfo->epSet.eps[vgInfo->epSet.inUse].port); @@ -951,19 +937,9 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo* } } - taosHashCancelIterate(dbInfo->vgHash, pIter); return TSDB_CODE_SUCCESS; } - SArray* pVgList = taosArrayInit(vgNum, POINTER_BYTES); - void* pIter = taosHashIterate(dbInfo->vgHash, NULL); - while (pIter) { - taosArrayPush(pVgList, &pIter); - pIter = taosHashIterate(dbInfo->vgHash, pIter); - } - - taosArraySort(pVgList, ctgVgInfoComp); - char tbFullName[TSDB_TABLE_FNAME_LEN]; sprintf(tbFullName, "%s.", dbFName); int32_t offset = strlen(tbFullName); @@ -979,20 +955,15 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo* uint32_t hashValue = taosGetTbHashVal(tbFullName, (uint32_t)strlen(tbFullName), dbInfo->hashMethod, dbInfo->hashPrefix, dbInfo->hashSuffix); - SVgroupInfo** p = taosArraySearch(pVgList, &hashValue, ctgHashValueComp, TD_EQ); - - if (NULL == p) { + vgInfo = taosArraySearch(dbInfo->vgArray, &hashValue, ctgHashValueComp, TD_EQ); + if (NULL == vgInfo) { ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, dbFName, - taosHashGetSize(dbInfo->vgHash)); - taosArrayDestroy(pVgList); + (int32_t)taosArrayGetSize(dbInfo->vgArray)); CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); } - vgInfo = *p; - SVgroupInfo* pNewVg = taosMemoryMalloc(sizeof(SVgroupInfo)); if (NULL == pNewVg) { - taosArrayDestroy(pVgList); CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } @@ -1012,8 +983,6 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo* } } - taosArrayDestroy(pVgList); - CTG_RET(code); } @@ -1057,7 +1026,33 @@ int32_t ctgDbVgVersionSortCompare(const void* key1, const void* key2) { } } +int32_t ctgMakeVgArray(SDBVgInfo* dbInfo) { + if (NULL == dbInfo) { + return TSDB_CODE_SUCCESS; + } + + if (dbInfo->vgHash && NULL == dbInfo->vgArray) { + dbInfo->vgArray = taosArrayInit(100, sizeof(SVgroupInfo)); + if (NULL == dbInfo->vgArray) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + + void* pIter = taosHashIterate(dbInfo->vgHash, NULL); + while (pIter) { + taosArrayPush(dbInfo->vgArray, pIter); + pIter = taosHashIterate(dbInfo->vgHash, pIter); + } + + taosArraySort(dbInfo->vgArray, ctgVgInfoComp); + } + + return TSDB_CODE_SUCCESS; +} + + int32_t ctgCloneVgInfo(SDBVgInfo* src, SDBVgInfo** dst) { + CTG_ERR_RET(ctgMakeVgArray(src)); + *dst = taosMemoryMalloc(sizeof(SDBVgInfo)); if (NULL == *dst) { qError("malloc %d failed", (int32_t)sizeof(SDBVgInfo)); @@ -1090,6 +1085,10 @@ int32_t ctgCloneVgInfo(SDBVgInfo* src, SDBVgInfo** dst) { pIter = taosHashIterate(src->vgHash, pIter); } + if (src->vgArray) { + (*dst)->vgArray = taosArrayDup(src->vgArray, NULL); + } + return TSDB_CODE_SUCCESS; } diff --git a/source/libs/command/inc/commandInt.h b/source/libs/command/inc/commandInt.h index 4d0c5389e1..6acf19218d 100644 --- a/source/libs/command/inc/commandInt.h +++ b/source/libs/command/inc/commandInt.h @@ -34,6 +34,7 @@ extern "C" { #define EXPLAIN_SYSTBL_SCAN_FORMAT "System Table Scan on %s" #define EXPLAIN_DISTBLK_SCAN_FORMAT "Block Dist Scan on %s" #define EXPLAIN_LASTROW_SCAN_FORMAT "Last Row Scan on %s" +#define EXPLAIN_TABLE_COUNT_SCAN_FORMAT "Table Count Row Scan on %s" #define EXPLAIN_PROJECTION_FORMAT "Projection" #define EXPLAIN_JOIN_FORMAT "%s" #define EXPLAIN_AGG_FORMAT "Aggragate" diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index d58c4dc6d3..5f1b87a138 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -36,7 +36,7 @@ static int32_t buildRetrieveTableRsp(SSDataBlock* pBlock, int32_t numOfCols, SRe (*pRsp)->precision = 0; (*pRsp)->compressed = 0; (*pRsp)->compLen = 0; - (*pRsp)->numOfRows = htonl(pBlock->info.rows); + (*pRsp)->numOfRows = htobe64((int64_t)pBlock->info.rows); (*pRsp)->numOfCols = htonl(numOfCols); int32_t len = blockEncode(pBlock, (*pRsp)->data, numOfCols); @@ -497,7 +497,7 @@ static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* p SColumnInfoData* pCol2 = taosArrayGet(pBlock->pDataBlock, 1); char* buf2 = taosMemoryMalloc(SHOW_CREATE_TB_RESULT_FIELD2_LEN); if (NULL == buf2) { - terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno; } diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index 410e62a18b..253718048d 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -19,6 +19,7 @@ #include "query.h" #include "tcommon.h" #include "tdatablock.h" +#include "systable.h" int32_t qExplainGenerateResNode(SPhysiNode *pNode, SExplainGroup *group, SExplainResNode **pRes); int32_t qExplainAppendGroupResRows(void *pCtx, int32_t groupId, int32_t level, bool singleChannel); @@ -76,19 +77,19 @@ int32_t qExplainInitCtx(SExplainCtx **pCtx, SHashObj *groupHash, bool verbose, d SExplainCtx *ctx = taosMemoryCalloc(1, sizeof(SExplainCtx)); if (NULL == ctx) { qError("calloc SExplainCtx failed"); - QRY_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QRY_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } SArray *rows = taosArrayInit(10, sizeof(SQueryExplainRowInfo)); if (NULL == rows) { qError("taosArrayInit SQueryExplainRowInfo failed"); - QRY_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QRY_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } char *tbuf = taosMemoryMalloc(TSDB_EXPLAIN_RESULT_ROW_SIZE); if (NULL == tbuf) { qError("malloc size %d failed", TSDB_EXPLAIN_RESULT_ROW_SIZE); - QRY_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QRY_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } ctx->mode = mode; @@ -212,6 +213,11 @@ int32_t qExplainGenerateResChildren(SPhysiNode *pNode, SExplainGroup *group, SNo pPhysiChildren = lastRowPhysiNode->scan.node.pChildren; break; } + case QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN: { + STableCountScanPhysiNode *tableCountPhysiNode = (STableCountScanPhysiNode *)pNode; + pPhysiChildren = tableCountPhysiNode->scan.node.pChildren; + break; + } case QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT: { SGroupSortPhysiNode *groupSortPhysiNode = (SGroupSortPhysiNode *)pNode; pPhysiChildren = groupSortPhysiNode->node.pChildren; @@ -229,14 +235,14 @@ int32_t qExplainGenerateResChildren(SPhysiNode *pNode, SExplainGroup *group, SNo } default: qError("not supported physical node type %d", pNode->type); - QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + QRY_ERR_RET(TSDB_CODE_APP_ERROR); } if (pPhysiChildren) { *pChildren = nodesMakeList(); if (NULL == *pChildren) { qError("nodesMakeList failed"); - QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QRY_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } } @@ -254,7 +260,7 @@ int32_t qExplainGenerateResNodeExecInfo(SPhysiNode *pNode, SArray **pExecInfo, S *pExecInfo = taosArrayInit(group->nodeNum, sizeof(SExplainExecInfo)); if (NULL == (*pExecInfo)) { qError("taosArrayInit %d explainExecInfo failed", group->nodeNum); - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } SExplainRsp *rsp = NULL; @@ -266,7 +272,7 @@ int32_t qExplainGenerateResNodeExecInfo(SPhysiNode *pNode, SArray **pExecInfo, S rsp = taosArrayGet(group->nodeExecInfo, group->nodeIdx++); if (group->physiPlanExecIdx >= rsp->numOfPlans) { qError("physiPlanIdx %d exceed plan num %d", group->physiPlanExecIdx, rsp->numOfPlans); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } taosArrayPush(*pExecInfo, rsp->subplanInfo + group->physiPlanExecIdx); @@ -275,7 +281,7 @@ int32_t qExplainGenerateResNodeExecInfo(SPhysiNode *pNode, SArray **pExecInfo, S rsp = taosArrayGet(group->nodeExecInfo, i); if (group->physiPlanExecIdx >= rsp->numOfPlans) { qError("physiPlanIdx %d exceed plan num %d", group->physiPlanExecIdx, rsp->numOfPlans); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } taosArrayPush(*pExecInfo, rsp->subplanInfo + group->physiPlanExecIdx); @@ -291,13 +297,13 @@ int32_t qExplainGenerateResNode(SPhysiNode *pNode, SExplainGroup *group, SExplai if (NULL == pNode) { *pResNode = NULL; qError("physical node is NULL"); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } SExplainResNode *resNode = taosMemoryCalloc(1, sizeof(SExplainResNode)); if (NULL == resNode) { qError("calloc SPhysiNodeExplainRes failed"); - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } int32_t code = 0; @@ -372,7 +378,7 @@ int32_t qExplainResAppendRow(SExplainCtx *ctx, char *tbuf, int32_t len, int32_t row.buf = taosMemoryMalloc(len); if (NULL == row.buf) { qError("taosMemoryMalloc %d failed", len); - QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QRY_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } memcpy(row.buf, tbuf, len); @@ -383,7 +389,7 @@ int32_t qExplainResAppendRow(SExplainCtx *ctx, char *tbuf, int32_t len, int32_t if (NULL == taosArrayPush(ctx->rows, &row)) { qError("taosArrayPush row to explain res rows failed"); taosMemoryFree(row.buf); - QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QRY_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } return TSDB_CODE_SUCCESS; @@ -401,7 +407,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i SPhysiNode *pNode = pResNode->pNode; if (NULL == pNode) { qError("pyhsical node in explain res node is NULL"); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } switch (pNode->type) { @@ -787,7 +793,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i SExplainGroup *group = taosHashGet(ctx->groupHash, &pExchNode->srcStartGroupId, sizeof(pExchNode->srcStartGroupId)); if (NULL == group) { qError("exchange src group %d not in groupHash", pExchNode->srcStartGroupId); - QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + QRY_ERR_RET(TSDB_CODE_APP_ERROR); } nodeNum += group->nodeNum; @@ -1355,6 +1361,48 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i } break; } + case QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN: { + STableCountScanPhysiNode *pLastRowNode = (STableCountScanPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_TABLE_COUNT_SCAN_FORMAT, + ('\0' != pLastRowNode->scan.tableName.tname[0] ? pLastRowNode->scan.tableName.tname : TSDB_INS_TABLE_TABLES)); + EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); + } + EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, LIST_LENGTH(pLastRowNode->scan.pScanCols)); + EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); + if (pLastRowNode->scan.pScanPseudoCols) { + EXPLAIN_ROW_APPEND(EXPLAIN_PSEUDO_COLUMNS_FORMAT, pLastRowNode->scan.pScanPseudoCols->length); + EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); + } + EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pLastRowNode->scan.node.pOutputDataBlockDesc->totalRowSize); + EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); + EXPLAIN_ROW_APPEND(EXPLAIN_RIGHT_PARENTHESIS_FORMAT); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT); + EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, + nodesGetOutputNumFromSlotList(pLastRowNode->scan.node.pOutputDataBlockDesc->pSlots)); + EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); + EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pLastRowNode->scan.node.pOutputDataBlockDesc->outputRowSize); + EXPLAIN_ROW_APPEND_LIMIT(pLastRowNode->scan.node.pLimit); + EXPLAIN_ROW_APPEND_SLIMIT(pLastRowNode->scan.node.pSlimit); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + + if (pLastRowNode->scan.node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pLastRowNode->scan.node.pConditions, tbuf + VARSTR_HEADER_SIZE, + TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + } + break; + } case QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT: { SGroupSortPhysiNode *pSortNode = (SGroupSortPhysiNode *)pNode; EXPLAIN_ROW_NEW(level, EXPLAIN_GROUP_SORT_FORMAT); @@ -1537,7 +1585,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i } default: qError("not supported physical node type %d", pNode->type); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } return TSDB_CODE_SUCCESS; @@ -1546,7 +1594,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i int32_t qExplainResNodeToRows(SExplainResNode *pResNode, SExplainCtx *ctx, int32_t level) { if (NULL == pResNode) { qError("explain res node is NULL"); - QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + QRY_ERR_RET(TSDB_CODE_APP_ERROR); } int32_t code = 0; @@ -1566,7 +1614,7 @@ int32_t qExplainAppendGroupResRows(void *pCtx, int32_t groupId, int32_t level, b SExplainGroup *group = taosHashGet(ctx->groupHash, &groupId, sizeof(groupId)); if (NULL == group) { qError("group %d not in groupHash", groupId); - QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + QRY_ERR_RET(TSDB_CODE_APP_ERROR); } group->singleChannel = singleChannel; @@ -1588,7 +1636,7 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) { int32_t rowNum = taosArrayGetSize(pCtx->rows); if (rowNum <= 0) { qError("empty explain res rows"); - QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + QRY_ERR_RET(TSDB_CODE_APP_ERROR); } SSDataBlock *pBlock = createDataBlock(); @@ -1611,11 +1659,11 @@ int32_t qExplainGetRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) { if (NULL == rsp) { qError("malloc SRetrieveTableRsp failed, size:%d", rspSize); blockDataDestroy(pBlock); - QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QRY_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } rsp->completed = 1; - rsp->numOfRows = htonl(rowNum); + rsp->numOfRows = htobe64((int64_t)rowNum); int32_t len = blockEncode(pBlock, rsp->data, taosArrayGetSize(pBlock->pDataBlock)); ASSERT(len == rspSize - sizeof(SRetrieveTableRsp)); @@ -1650,7 +1698,7 @@ int32_t qExplainPrepareCtx(SQueryPlan *pDag, SExplainCtx **pCtx) { taosHashInit(EXPLAIN_MAX_GROUP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); if (NULL == groupHash) { qError("groupHash %d failed", EXPLAIN_MAX_GROUP_NUM); - QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QRY_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } QRY_ERR_JRET( @@ -1684,7 +1732,7 @@ int32_t qExplainPrepareCtx(SQueryPlan *pDag, SExplainCtx **pCtx) { if (0 != taosHashPut(groupHash, &plan->id.groupId, sizeof(plan->id.groupId), &group, sizeof(group))) { qError("taosHashPut to explainGroupHash failed, taskIdx:%d", n); - QRY_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QRY_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } } @@ -1752,7 +1800,7 @@ int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t if (NULL == group) { qError("group %d not in groupHash", groupId); tFreeSExplainRsp(pRspMsg); - QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + QRY_ERR_RET(TSDB_CODE_APP_ERROR); } taosWLockLatch(&group->lock); @@ -1763,7 +1811,7 @@ int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t tFreeSExplainRsp(pRspMsg); taosWUnLockLatch(&group->lock); - QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QRY_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } group->physiPlanExecNum = pRspMsg->numOfPlans; @@ -1773,7 +1821,7 @@ int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t tFreeSExplainRsp(pRspMsg); taosWUnLockLatch(&group->lock); - QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + QRY_ERR_RET(TSDB_CODE_APP_ERROR); } if (group->physiPlanExecNum != pRspMsg->numOfPlans) { @@ -1782,7 +1830,7 @@ int32_t qExplainUpdateExecInfo(SExplainCtx *pCtx, SExplainRsp *pRspMsg, int32_t tFreeSExplainRsp(pRspMsg); taosWUnLockLatch(&group->lock); - QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + QRY_ERR_RET(TSDB_CODE_APP_ERROR); } taosArrayPush(group->nodeExecInfo, pRspMsg); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index f17d7f6468..b302641c94 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -46,7 +46,6 @@ extern "C" { typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int32_t order); -#define Q_STATUS_EQUAL(p, s) (((p) & (s)) != 0u) #define IS_VALID_SESSION_WIN(winInfo) ((winInfo).sessionWin.win.skey > 0) #define SET_SESSION_WIN_INVALID(winInfo) ((winInfo).sessionWin.win.skey = INT64_MIN) #define IS_INVALID_SESSION_WIN_KEY(winKey) ((winKey).win.skey <= 0) @@ -109,6 +108,7 @@ typedef int32_t (*__optr_open_fn_t)(struct SOperatorInfo* pOptr); typedef SSDataBlock* (*__optr_fn_t)(struct SOperatorInfo* pOptr); typedef void (*__optr_close_fn_t)(void* param); typedef int32_t (*__optr_explain_fn_t)(struct SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len); +typedef int32_t (*__optr_reqBuf_fn_t)(struct SOperatorInfo* pOptr); typedef struct STaskIdInfo { uint64_t queryId; // this is also a request id @@ -170,8 +170,9 @@ struct SExecTaskInfo { STaskCostInfo cost; int64_t owner; // if it is in execution int32_t code; + int32_t qbufQuota; // total available buffer (in KB) during execution query - int64_t version; // used for stream to record wal version + int64_t version; // used for stream to record wal version, why not move to sschemainfo SStreamTaskInfo streamInfo; SSchemaInfo schemaInfo; STableListInfo* pTableInfoList; // this is a table list @@ -198,6 +199,7 @@ typedef struct SOperatorFpSet { __optr_fn_t getNextFn; __optr_fn_t cleanupFn; // call this function to release the allocated resources ASAP __optr_close_fn_t closeFn; + __optr_reqBuf_fn_t reqBufFn; // total used buffer for blocking operator __optr_encode_fn_t encodeResultRow; __optr_decode_fn_t decodeResultRow; __optr_explain_fn_t getExplainFn; @@ -482,6 +484,26 @@ typedef struct { SSnapContext* sContext; } SStreamRawScanInfo; +typedef struct STableCountScanSupp { + int16_t dbNameSlotId; + int16_t stbNameSlotId; + int16_t tbCountSlotId; + bool groupByDbName; + bool groupByStbName; + char dbNameFilter[TSDB_DB_NAME_LEN]; + char stbNameFilter[TSDB_TABLE_NAME_LEN]; +} STableCountScanSupp; + +typedef struct STableCountScanOperatorInfo { + SReadHandle readHandle; + SSDataBlock* pRes; + + STableCountScanSupp supp; + + int32_t currGrpIdx; + SArray* stbUidList; // when group by db_name and/or stable_name +} STableCountScanOperatorInfo; + typedef struct SOptrBasicInfo { SResultRowInfo resultRowInfo; SSDataBlock* pRes; @@ -536,6 +558,7 @@ typedef struct SStreamIntervalOperatorInfo { SArray* pChildren; SStreamState* pState; SWinKey delKey; + uint64_t numOfDatapack; } SStreamIntervalOperatorInfo; typedef struct SDataGroupInfo { @@ -648,13 +671,14 @@ typedef struct SStreamFillOperatorInfo { #define OPTR_SET_OPENED(_optr) ((_optr)->status |= OP_OPENED) SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t cleanup, - __optr_close_fn_t closeFn, __optr_explain_fn_t explain); -int32_t operatorDummyOpenFn(SOperatorInfo* pOperator); + __optr_close_fn_t closeFn, __optr_reqBuf_fn_t reqBufFn, __optr_explain_fn_t explain); +int32_t optrDummyOpenFn(SOperatorInfo* pOperator); int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t num); void setOperatorCompleted(SOperatorInfo* pOperator); void setOperatorInfo(SOperatorInfo* pOperator, const char* name, int32_t type, bool blocking, int32_t status, void* pInfo, SExecTaskInfo* pTaskInfo); void destroyOperatorInfo(SOperatorInfo* pOperator); +int32_t optrDefaultBufFn(SOperatorInfo* pOperator); void initBasicInfo(SOptrBasicInfo* pInfo, SSDataBlock* pBlock); void cleanupBasicInfo(SOptrBasicInfo* pInfo); @@ -683,7 +707,7 @@ void applyAggFunctionOnPartialTuples(SExecTaskInfo* taskInfo, SqlFunctionCtx* pC int32_t offset, int32_t forwardStep, int32_t numOfTotal, int32_t numOfOutput); int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, char* pData, SArray* pColList, char** pNextStart); -void updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int32_t numOfRows, int32_t dataLen, int64_t startTs, +void updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int64_t numOfRows, int32_t dataLen, int64_t startTs, SOperatorInfo* pOperator); STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order); @@ -717,6 +741,8 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode* pScanPhyNode, const char* pUser, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createTableCountScanOperatorInfo(SReadHandle* handle, STableCountScanPhysiNode* pNode, SExecTaskInfo* pTaskInfo); + SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode* pNode, SExecTaskInfo* pTaskInfo); SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pNode, SExecTaskInfo* pTaskInfo); @@ -780,7 +806,7 @@ void setInputDataBlock(SExprSupp* pExprSupp, SSDataBlock* pBlock, int32_t order, int32_t checkForQueryBuf(size_t numOfTables); bool isTaskKilled(SExecTaskInfo* pTaskInfo); -void setTaskKilled(SExecTaskInfo* pTaskInfo); +void setTaskKilled(SExecTaskInfo* pTaskInfo, int32_t rspCode); void doDestroyTask(SExecTaskInfo* pTaskInfo); void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status); @@ -789,8 +815,6 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle); int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInfoList); -int32_t getMaximumIdleDurationSec(); - STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval, int32_t order); int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos, TSKEY ekey, diff --git a/source/libs/executor/src/cachescanoperator.c b/source/libs/executor/src/cachescanoperator.c index c432f3c01c..672bb09b14 100644 --- a/source/libs/executor/src/cachescanoperator.c +++ b/source/libs/executor/src/cachescanoperator.c @@ -117,7 +117,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock); pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doScanCache, NULL, destroyCacheScanOperator, NULL); + createOperatorFpSet(optrDummyOpenFn, doScanCache, NULL, destroyCacheScanOperator, optrDefaultBufFn, NULL); pOperator->cost.openCost = 0; return pOperator; diff --git a/source/libs/executor/src/dataDeleter.c b/source/libs/executor/src/dataDeleter.c index c7a2480204..12fb449238 100644 --- a/source/libs/executor/src/dataDeleter.c +++ b/source/libs/executor/src/dataDeleter.c @@ -135,12 +135,12 @@ static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput, SDataDeleterHandle* pDeleter = (SDataDeleterHandle*)pHandle; SDataDeleterBuf* pBuf = taosAllocateQitem(sizeof(SDataDeleterBuf), DEF_QITEM); if (NULL == pBuf) { - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } if (!allocBuf(pDeleter, pInput, pBuf)) { taosFreeQitem(pBuf); - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } toDataCacheEntry(pDeleter, pInput, pBuf); diff --git a/source/libs/executor/src/dataDispatcher.c b/source/libs/executor/src/dataDispatcher.c index d4248fc420..c45226e02b 100644 --- a/source/libs/executor/src/dataDispatcher.c +++ b/source/libs/executor/src/dataDispatcher.c @@ -128,12 +128,12 @@ static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput, SDataDispatchHandle* pDispatcher = (SDataDispatchHandle*)pHandle; SDataDispatchBuf* pBuf = taosAllocateQitem(sizeof(SDataDispatchBuf), DEF_QITEM); if (NULL == pBuf) { - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } if (!allocBuf(pDispatcher, pInput, pBuf)) { taosFreeQitem(pBuf); - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } toDataCacheEntry(pDispatcher, pInput, pBuf); @@ -237,8 +237,8 @@ static int32_t getCacheSize(struct SDataSinkHandle* pHandle, uint64_t* size) { int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle) { SDataDispatchHandle* dispatcher = taosMemoryCalloc(1, sizeof(SDataDispatchHandle)); if (NULL == dispatcher) { - terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; - return TSDB_CODE_QRY_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } dispatcher->sink.fPut = putDataBlock; dispatcher->sink.fEndPut = endPut; @@ -254,8 +254,8 @@ int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pD taosThreadMutexInit(&dispatcher->mutex, NULL); if (NULL == dispatcher->pDataBlocks) { taosMemoryFree(dispatcher); - terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; - return TSDB_CODE_QRY_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } *pHandle = dispatcher; return TSDB_CODE_SUCCESS; diff --git a/source/libs/executor/src/dataInserter.c b/source/libs/executor/src/dataInserter.c index 09ca1d27b9..346fcc9729 100644 --- a/source/libs/executor/src/dataInserter.c +++ b/source/libs/executor/src/dataInserter.c @@ -101,7 +101,7 @@ static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, SSubmitReq* pMs SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == pMsgSendInfo) { taosMemoryFreeClear(pMsg); - terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno; } @@ -304,8 +304,8 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat void* pParam) { SDataInserterHandle* inserter = taosMemoryCalloc(1, sizeof(SDataInserterHandle)); if (NULL == inserter) { - terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; - return TSDB_CODE_QRY_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } SQueryInserterNode* pInserterNode = (SQueryInserterNode*)pDataSink; @@ -342,8 +342,8 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat if (NULL == inserter->pDataBlocks) { destroyDataSinker((SDataSinkHandle*)inserter); taosMemoryFree(inserter); - terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; - return TSDB_CODE_QRY_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } inserter->pCols = taosHashInit(pInserterNode->pCols->length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), diff --git a/source/libs/executor/src/exchangeoperator.c b/source/libs/executor/src/exchangeoperator.c index 963a273290..8423b77906 100644 --- a/source/libs/executor/src/exchangeoperator.c +++ b/source/libs/executor/src/exchangeoperator.c @@ -70,7 +70,7 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn tsem_wait(&pExchangeInfo->ready); if (isTaskKilled(pTaskInfo)) { - longjmp(pTaskInfo->env, TSDB_CODE_TSC_QUERY_CANCELLED); + longjmp(pTaskInfo->env, pTaskInfo->code); } for (int32_t i = 0; i < totalSources; ++i) { @@ -115,14 +115,14 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn if (pRsp->completed == 1) { pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED; qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 - " execId:%d index:%d completed, blocks:%d, numOfRows:%d, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64 + " execId:%d index:%d completed, blocks:%d, numOfRows:%" PRId64 ", rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64 ", total:%.2f Kb, try next %d/%" PRIzu, GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, i, pRsp->numOfBlocks, pRsp->numOfRows, pDataInfo->totalRows, pLoadInfo->totalRows, pLoadInfo->totalSize / 1024.0, i + 1, totalSources); } else { qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 - " execId:%d blocks:%d, numOfRows:%d, totalRows:%" PRIu64 ", total:%.2f Kb", + " execId:%d blocks:%d, numOfRows:%" PRId64 ", totalRows:%" PRIu64 ", total:%.2f Kb", GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRsp->numOfBlocks, pRsp->numOfRows, pLoadInfo->totalRows, pLoadInfo->totalSize / 1024.0); } @@ -198,7 +198,7 @@ static SSDataBlock* doLoadRemoteDataImpl(SOperatorInfo* pOperator) { } } -static SSDataBlock* doLoadRemoteData(SOperatorInfo* pOperator) { +static SSDataBlock* loadRemoteData(SOperatorInfo* pOperator) { SExchangeInfo* pExchangeInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; @@ -307,7 +307,7 @@ SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pDummyBlock->pDataBlock); pOperator->fpSet = - createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, destroyExchangeOperatorInfo, NULL); + createOperatorFpSet(prepareLoadRemoteData, loadRemoteData, NULL, destroyExchangeOperatorInfo, optrDefaultBufFn, NULL); return pOperator; _error: @@ -367,14 +367,14 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) { pSourceDataInfo->pRsp = pMsg->pData; SRetrieveTableRsp* pRsp = pSourceDataInfo->pRsp; - pRsp->numOfRows = htonl(pRsp->numOfRows); + pRsp->numOfRows = htobe64(pRsp->numOfRows); pRsp->compLen = htonl(pRsp->compLen); pRsp->numOfCols = htonl(pRsp->numOfCols); pRsp->useconds = htobe64(pRsp->useconds); pRsp->numOfBlocks = htonl(pRsp->numOfBlocks); ASSERT(pRsp != NULL); - qDebug("%s fetch rsp received, index:%d, blocks:%d, rows:%d, %p", pSourceDataInfo->taskId, index, pRsp->numOfBlocks, + qDebug("%s fetch rsp received, index:%d, blocks:%d, rows:%" PRId64 ", %p", pSourceDataInfo->taskId, index, pRsp->numOfBlocks, pRsp->numOfRows, pExchangeInfo); } else { taosMemoryFree(pMsg->pData); @@ -424,20 +424,20 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas int32_t msgSize = tSerializeSResFetchReq(NULL, 0, &req); if (msgSize < 0) { - pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; taosMemoryFree(pWrapper); return pTaskInfo->code; } void* msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { - pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; taosMemoryFree(pWrapper); return pTaskInfo->code; } if (tSerializeSResFetchReq(msg, msgSize, &req) < 0) { - pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; taosMemoryFree(pWrapper); taosMemoryFree(msg); return pTaskInfo->code; @@ -453,7 +453,7 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas taosMemoryFreeClear(msg); taosMemoryFree(pWrapper); qError("%s prepare message %d failed", GET_TASKID(pTaskInfo), (int32_t)sizeof(SMsgSendInfo)); - pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; return pTaskInfo->code; } @@ -472,7 +472,7 @@ int32_t doSendFetchDataRequest(SExchangeInfo* pExchangeInfo, SExecTaskInfo* pTas return TSDB_CODE_SUCCESS; } -void updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int32_t numOfRows, int32_t dataLen, int64_t startTs, +void updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int64_t numOfRows, int32_t dataLen, int64_t startTs, SOperatorInfo* pOperator) { pInfo->totalRows += numOfRows; pInfo->totalSize += dataLen; @@ -570,13 +570,10 @@ int32_t prepareConcurrentlyLoad(SOperatorInfo* pOperator) { pOperator->status = OP_RES_TO_RETURN; pOperator->cost.openCost = taosGetTimestampUs() - startTs; - - tsem_wait(&pExchangeInfo->ready); if (isTaskKilled(pTaskInfo)) { - longjmp(pTaskInfo->env, TSDB_CODE_TSC_QUERY_CANCELLED); + longjmp(pTaskInfo->env, pTaskInfo->code); } - tsem_post(&pExchangeInfo->ready); return TSDB_CODE_SUCCESS; } @@ -621,7 +618,7 @@ int32_t seqLoadRemoteData(SOperatorInfo* pOperator) { doSendFetchDataRequest(pExchangeInfo, pTaskInfo, pExchangeInfo->current); tsem_wait(&pExchangeInfo->ready); if (isTaskKilled(pTaskInfo)) { - longjmp(pTaskInfo->env, TSDB_CODE_TSC_QUERY_CANCELLED); + longjmp(pTaskInfo->env, pTaskInfo->code); } SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, pExchangeInfo->current); @@ -655,7 +652,7 @@ int32_t seqLoadRemoteData(SOperatorInfo* pOperator) { SRetrieveTableRsp* pRetrieveRsp = pDataInfo->pRsp; if (pRsp->completed == 1) { - qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%d, rowsOfSource:%" PRIu64 + qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%" PRId64 ", rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64 ", totalBytes:%" PRIu64 " try next %d/%" PRIzu, GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRetrieveRsp->numOfRows, pDataInfo->totalRows, pLoadInfo->totalRows, pLoadInfo->totalSize, pExchangeInfo->current + 1, @@ -664,7 +661,7 @@ int32_t seqLoadRemoteData(SOperatorInfo* pOperator) { pDataInfo->status = EX_SOURCE_DATA_EXHAUSTED; pExchangeInfo->current += 1; } else { - qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%d, totalRows:%" PRIu64 + qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%" PRId64 ", totalRows:%" PRIu64 ", totalBytes:%" PRIu64, GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pSource->execId, pRetrieveRsp->numOfRows, pLoadInfo->totalRows, pLoadInfo->totalSize); diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 8a85885d98..2032cb9fce 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -129,6 +129,7 @@ void initGroupedResultInfo(SGroupResInfo* pGroupResInfo, SSHashObj* pHashmap, in void* pData = NULL; pGroupResInfo->pRows = taosArrayInit(10, POINTER_BYTES); + // todo avoid repeated malloc memory size_t keyLen = 0; int32_t iter = 0; while ((pData = tSimpleHashIterate(pHashmap, pData, &iter)) != NULL) { @@ -438,13 +439,12 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray* goto end; } } + removeInvalidTable(uidList, tags); int32_t rows = taosArrayGetSize(uidList); if (rows == 0) { goto end; } - // int64_t stt1 = taosGetTimestampUs(); - // qDebug("generate tag meta rows:%d, cost:%ld us", rows, stt1-stt); code = blockDataEnsureCapacity(pResBlock, rows); if (code != TSDB_CODE_SUCCESS) { @@ -452,7 +452,6 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray* goto end; } - // int64_t st = taosGetTimestampUs(); for (int32_t i = 0; i < rows; i++) { int64_t* uid = taosArrayGet(uidList, i); for (int32_t j = 0; j < taosArrayGetSize(pResBlock->pDataBlock); j++) { @@ -467,7 +466,9 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, int64_t suid, SArray* #endif } else { void* tag = taosHashGet(tags, uid, sizeof(int64_t)); - ASSERT(tag); + if (tag == NULL) { + continue; + } STagVal tagVal = {0}; tagVal.cid = pColInfo->info.colId; const char* p = metaGetTableTagVal(tag, pColInfo->info.type, &tagVal); @@ -923,14 +924,14 @@ static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray* return -1; } - SArray* pTbList = getTableNameList(pList); - int32_t numOfTables = taosArrayGetSize(pTbList); - SHashObj *uHash = NULL; + SArray* pTbList = getTableNameList(pList); + int32_t numOfTables = taosArrayGetSize(pTbList); + SHashObj* uHash = NULL; size_t listlen = taosArrayGetSize(list); // len > 0 means there already have uids if (listlen > 0) { uHash = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); for (int i = 0; i < listlen; i++) { - int64_t *uid = taosArrayGet(list, i); + int64_t* uid = taosArrayGet(list, i); taosHashPut(uHash, uid, sizeof(int64_t), &i, sizeof(i)); } } @@ -1241,6 +1242,7 @@ int32_t extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod } } + // set the output flag for each column in SColMatchInfo, according to the *numOfOutputCols = 0; int32_t num = LIST_LENGTH(pOutputNodeList->pSlots); for (int32_t i = 0; i < num; ++i) { @@ -1348,6 +1350,7 @@ void createExprFromOneNode(SExprInfo* pExp, SNode* pNode, int16_t slotId) { pExprNode->_function.functionId = pFuncNode->funcId; pExprNode->_function.pFunctNode = pFuncNode; + pExprNode->_function.functionType = pFuncNode->funcType; tstrncpy(pExprNode->_function.functionName, pFuncNode->functionName, tListLen(pExprNode->_function.functionName)); @@ -1455,7 +1458,7 @@ static int32_t setSelectValueColumnInfo(SqlFunctionCtx* pCtx, int32_t numOfOutpu SqlFunctionCtx* p = NULL; SqlFunctionCtx** pValCtx = taosMemoryCalloc(numOfOutput, POINTER_BYTES); if (pValCtx == NULL) { - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } for (int32_t i = 0; i < numOfOutput; ++i) { @@ -1536,8 +1539,6 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, pCtx->start.key = INT64_MIN; pCtx->end.key = INT64_MIN; pCtx->numOfParams = pExpr->base.numOfParams; - pCtx->isStream = false; - pCtx->param = pFunct->pParam; pCtx->saveHandle.currentPage = -1; } @@ -1601,20 +1602,22 @@ SColumn extractColumnFromColumnNode(SColumnNode* pColNode) { int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysiNode* pTableScanNode) { pCond->order = pTableScanNode->scanSeq[0] > 0 ? TSDB_ORDER_ASC : TSDB_ORDER_DESC; pCond->numOfCols = LIST_LENGTH(pTableScanNode->scan.pScanCols); + pCond->colList = taosMemoryCalloc(pCond->numOfCols, sizeof(SColumnInfo)); - if (pCond->colList == NULL) { - terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; + pCond->pSlotList = taosMemoryMalloc(sizeof(int32_t)*pCond->numOfCols); + if (pCond->colList == NULL || pCond->pSlotList == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + taosMemoryFreeClear(pCond->colList); + taosMemoryFreeClear(pCond->pSlotList); return terrno; } - // pCond->twindow = pTableScanNode->scanRange; // TODO: get it from stable scan node pCond->twindows = pTableScanNode->scanRange; pCond->suid = pTableScanNode->scan.suid; pCond->type = TIMEWINDOW_RANGE_CONTAINED; pCond->startVersion = -1; pCond->endVersion = -1; - // pCond->type = pTableScanNode->scanFlag; int32_t j = 0; for (int32_t i = 0; i < pCond->numOfCols; ++i) { @@ -1627,6 +1630,8 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi pCond->colList[j].type = pColNode->node.resType.type; pCond->colList[j].bytes = pColNode->node.resType.bytes; pCond->colList[j].colId = pColNode->colId; + + pCond->pSlotList[j] = pNode->slotId; j += 1; } @@ -1634,7 +1639,10 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi return TSDB_CODE_SUCCESS; } -void cleanupQueryTableDataCond(SQueryTableDataCond* pCond) { taosMemoryFreeClear(pCond->colList); } +void cleanupQueryTableDataCond(SQueryTableDataCond* pCond) { + taosMemoryFreeClear(pCond->colList); + taosMemoryFreeClear(pCond->pSlotList); +} int32_t convertFillType(int32_t mode) { int32_t type = TSDB_FILL_NONE; @@ -1964,7 +1972,7 @@ int32_t buildGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle* int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags, bool groupSort, SReadHandle* pHandle, STableListInfo* pTableListInfo, SNode* pTagCond, SNode* pTagIndexCond, - struct SExecTaskInfo* pTaskInfo) { + SExecTaskInfo* pTaskInfo) { int64_t st = taosGetTimestampUs(); const char* idStr = GET_TASKID(pTaskInfo); @@ -2011,4 +2019,4 @@ void printDataBlock(SSDataBlock* pBlock, const char* flag) { char* pBuf = NULL; qDebug("%s", dumpBlockData(pBlock, flag, &pBuf)); taosMemoryFree(pBuf); -} \ No newline at end of file +} diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 10ceb9ccee..6fca2858dc 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -35,12 +35,12 @@ static int32_t doSetSMABlock(SOperatorInfo* pOperator, void* input, size_t numOf if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { if (pOperator->numOfDownstream == 0) { qError("failed to find stream scan operator to set the input data block, %s" PRIx64, id); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } if (pOperator->numOfDownstream > 1) { // not handle this in join query qError("join not supported for stream block scan, %s" PRIx64, id); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } pOperator->status = OP_NOT_OPENED; return doSetSMABlock(pOperator->pDownstream[0], input, numOfBlocks, type, id); @@ -76,12 +76,12 @@ static int32_t doSetStreamOpOpen(SOperatorInfo* pOperator, char* id) { if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { if (pOperator->numOfDownstream == 0) { qError("failed to find stream scan operator to set the input data block, %s" PRIx64, id); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } if (pOperator->numOfDownstream > 1) { // not handle this in join query qError("join not supported for stream block scan, %s" PRIx64, id); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } pOperator->status = OP_NOT_OPENED; return doSetStreamOpOpen(pOperator->pDownstream[0], id); @@ -95,12 +95,12 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { if (pOperator->numOfDownstream == 0) { qError("failed to find stream scan operator to set the input data block, %s" PRIx64, id); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } if (pOperator->numOfDownstream > 1) { // not handle this in join query qError("join not supported for stream block scan, %s" PRIx64, id); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } pOperator->status = OP_NOT_OPENED; return doSetStreamBlock(pOperator->pDownstream[0], input, numOfBlocks, type, id); @@ -139,7 +139,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu int32_t qSetStreamOpOpen(qTaskInfo_t tinfo) { if (tinfo == NULL) { - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; @@ -156,7 +156,7 @@ int32_t qSetStreamOpOpen(qTaskInfo_t tinfo) { int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type) { if (tinfo == NULL) { - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } if (pBlocks == NULL || numOfBlocks == 0) { @@ -177,7 +177,7 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO int32_t qSetSMAInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, int32_t type) { if (tinfo == NULL) { - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } if (pBlocks == NULL || numOfBlocks == 0) { @@ -207,7 +207,7 @@ qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* n } setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED); - pTaskInfo->cost.created = taosGetTimestampMs(); + pTaskInfo->cost.created = taosGetTimestampUs(); pTaskInfo->execModel = OPTR_EXEC_MODEL_QUEUE; pTaskInfo->pRoot = createRawScanOperatorInfo(readers, pTaskInfo); if (NULL == pTaskInfo->pRoot) { @@ -503,7 +503,7 @@ int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bo } if (pTaskInfo->cost.start == 0) { - pTaskInfo->cost.start = taosGetTimestampMs(); + pTaskInfo->cost.start = taosGetTimestampUs(); } if (isTaskKilled(pTaskInfo)) { @@ -597,7 +597,7 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t* useconds) { } if (pTaskInfo->cost.start == 0) { - pTaskInfo->cost.start = taosGetTimestampMs(); + pTaskInfo->cost.start = taosGetTimestampUs(); } if (isTaskKilled(pTaskInfo)) { @@ -688,7 +688,7 @@ void qStopTaskOperators(SExecTaskInfo* pTaskInfo) { taosWUnLockLatch(&pTaskInfo->stopInfo.lock); } -int32_t qAsyncKillTask(qTaskInfo_t qinfo) { +int32_t qAsyncKillTask(qTaskInfo_t qinfo, int32_t rspCode) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)qinfo; if (pTaskInfo == NULL) { @@ -697,7 +697,7 @@ int32_t qAsyncKillTask(qTaskInfo_t qinfo) { qDebug("%s execTask async killed", GET_TASKID(pTaskInfo)); - setTaskKilled(pTaskInfo); + setTaskKilled(pTaskInfo, rspCode); qStopTaskOperators(pTaskInfo); @@ -706,15 +706,20 @@ int32_t qAsyncKillTask(qTaskInfo_t qinfo) { static void printTaskExecCostInLog(SExecTaskInfo* pTaskInfo) { STaskCostInfo* pSummary = &pTaskInfo->cost; + int64_t idleTime = pSummary->start - pSummary->created; SFileBlockLoadRecorder* pRecorder = pSummary->pRecoder; if (pSummary->pRecoder != NULL) { qDebug( - "%s :cost summary: elapsed time:%.2f ms, extract tableList:%.2f ms, createGroupIdMap:%.2f ms, total blocks:%d, " + "%s :cost summary: idle:%.2f ms, elapsed time:%.2f ms, extract tableList:%.2f ms, " + "createGroupIdMap:%.2f ms, total blocks:%d, " "load block SMA:%d, load data block:%d, total rows:%" PRId64 ", check rows:%" PRId64, - GET_TASKID(pTaskInfo), pSummary->elapsedTime / 1000.0, pSummary->extractListTime, pSummary->groupIdMapTime, - pRecorder->totalBlocks, pRecorder->loadBlockStatis, pRecorder->loadBlocks, pRecorder->totalRows, - pRecorder->totalCheckedRows); + GET_TASKID(pTaskInfo), idleTime / 1000.0, pSummary->elapsedTime / 1000.0, pSummary->extractListTime, + pSummary->groupIdMapTime, pRecorder->totalBlocks, pRecorder->loadBlockStatis, pRecorder->loadBlocks, + pRecorder->totalRows, pRecorder->totalCheckedRows); + } else { + qDebug("%s :cost summary: idle in queue:%.2f ms, elapsed time:%.2f ms", GET_TASKID(pTaskInfo), idleTime / 1000.0, + pSummary->elapsedTime / 1000.0); } } @@ -971,21 +976,27 @@ int32_t initQueryTableDataCondForTmq(SQueryTableDataCond* pCond, SSnapContext* s pCond->order = TSDB_ORDER_ASC; pCond->numOfCols = pMtInfo->schema->nCols; pCond->colList = taosMemoryCalloc(pCond->numOfCols, sizeof(SColumnInfo)); - if (pCond->colList == NULL) { - terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; + pCond->pSlotList = taosMemoryMalloc(sizeof(int32_t) * pCond->numOfCols); + if (pCond->colList == NULL || pCond->pSlotList == NULL) { + taosMemoryFreeClear(pCond->colList); + taosMemoryFreeClear(pCond->pSlotList); + terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno; } - pCond->twindows = (STimeWindow){.skey = INT64_MIN, .ekey = INT64_MAX}; + pCond->twindows = TSWINDOW_INITIALIZER; pCond->suid = pMtInfo->suid; pCond->type = TIMEWINDOW_RANGE_CONTAINED; pCond->startVersion = -1; pCond->endVersion = sContext->snapVersion; for (int32_t i = 0; i < pCond->numOfCols; ++i) { - pCond->colList[i].type = pMtInfo->schema->pSchema[i].type; - pCond->colList[i].bytes = pMtInfo->schema->pSchema[i].bytes; - pCond->colList[i].colId = pMtInfo->schema->pSchema[i].colId; + SColumnInfo* pColInfo = &pCond->colList[i]; + pColInfo->type = pMtInfo->schema->pSchema[i].type; + pColInfo->bytes = pMtInfo->schema->pSchema[i].bytes; + pColInfo->colId = pMtInfo->schema->pSchema[i].colId; + + pCond->pSlotList[i] = i; } return TSDB_CODE_SUCCESS; @@ -1078,7 +1089,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT int32_t num = tableListGetSize(pTaskInfo->pTableInfoList); if (tsdbReaderOpen(pTableScanInfo->base.readHandle.vnode, &pTableScanInfo->base.cond, pList, num, - &pTableScanInfo->base.dataReader, NULL) < 0 || + pTableScanInfo->pResBlock, &pTableScanInfo->base.dataReader, NULL) < 0 || pTableScanInfo->base.dataReader == NULL) { ASSERT(0); } @@ -1130,7 +1141,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT int32_t size = tableListGetSize(pTaskInfo->pTableInfoList); ASSERT(size == 1); - tsdbReaderOpen(pInfo->vnode, &pTaskInfo->streamInfo.tableCond, pList, size, &pInfo->dataReader, NULL); + tsdbReaderOpen(pInfo->vnode, &pTaskInfo->streamInfo.tableCond, pList, size, NULL, &pInfo->dataReader, NULL); cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond); strcpy(pTaskInfo->streamInfo.tbName, mtInfo.tbName); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index d0d8b42442..bd22e864cd 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -85,8 +85,6 @@ typedef struct SAggOperatorInfo { SExprSupp scalarExprSup; } SAggOperatorInfo; -int32_t getMaximumIdleDurationSec() { return tsShellActivityTimer * 2; } - static void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pBlock); static void releaseQueryBuf(size_t numOfTables); @@ -106,7 +104,7 @@ void setOperatorCompleted(SOperatorInfo* pOperator) { pOperator->status = OP_EXEC_DONE; ASSERT(pOperator->pTaskInfo != NULL); - pOperator->cost.totalCost = (taosGetTimestampUs() - pOperator->pTaskInfo->cost.start * 1000) / 1000.0; + pOperator->cost.totalCost = (taosGetTimestampUs() - pOperator->pTaskInfo->cost.start) / 1000.0; setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); } @@ -120,19 +118,21 @@ void setOperatorInfo(SOperatorInfo* pOperator, const char* name, int32_t type, b pOperator->pTaskInfo = pTaskInfo; } -int32_t operatorDummyOpenFn(SOperatorInfo* pOperator) { +int32_t optrDummyOpenFn(SOperatorInfo* pOperator) { OPTR_SET_OPENED(pOperator); pOperator->cost.openCost = 0; return TSDB_CODE_SUCCESS; } SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t cleanup, - __optr_close_fn_t closeFn, __optr_explain_fn_t explain) { + __optr_close_fn_t closeFn, __optr_reqBuf_fn_t reqBufFn, + __optr_explain_fn_t explain) { SOperatorFpSet fpSet = { ._openFn = openFn, .getNextFn = nextFn, .cleanupFn = cleanup, .closeFn = closeFn, + .reqBufFn = reqBufFn, .getExplainFn = explain, }; @@ -610,21 +610,10 @@ void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock* pB } bool isTaskKilled(SExecTaskInfo* pTaskInfo) { - // query has been executed more than tsShellActivityTimer, and the retrieve has not arrived - // abort current query execution. - if (pTaskInfo->owner != 0 && - ((taosGetTimestampSec() - pTaskInfo->cost.start / 1000) > 10 * getMaximumIdleDurationSec()) - /*(!needBuildResAfterQueryComplete(pTaskInfo))*/) { - assert(pTaskInfo->cost.start != 0); - // qDebug("QInfo:%" PRIu64 " retrieve not arrive beyond %d ms, abort current query execution, start:%" PRId64 - // ", current:%d", pQInfo->qId, 1, pQInfo->startExecTs, taosGetTimestampSec()); - // return true; - } - - return false; + return (0 != pTaskInfo->code) ? true : false; } -void setTaskKilled(SExecTaskInfo* pTaskInfo) { pTaskInfo->code = TSDB_CODE_TSC_QUERY_CANCELLED; } +void setTaskKilled(SExecTaskInfo* pTaskInfo, int32_t rspCode) { pTaskInfo->code = rspCode; } ///////////////////////////////////////////////////////////////////////////////////////////// STimeWindow getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int64_t key) { @@ -686,7 +675,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc if (setResultOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pBlock->info.id.uid, &win, masterScan, &pResult, groupId, pTableScanInfo->pCtx, pTableScanInfo->numOfOutput, pTableScanInfo->rowEntryInfoOffset) != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pRuntimeEnv->env, TSDB_CODE_OUT_OF_MEMORY); } } } else if (pQueryAttr->stableQuery && (!pQueryAttr->tsCompQuery) && (!pQueryAttr->diffQuery)) { // stable aggregate, not interval aggregate or normal column aggregate @@ -737,7 +726,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc if (setResultOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pBlock->info.id.uid, &win, masterScan, &pResult, groupId, pTableScanInfo->pCtx, pTableScanInfo->numOfOutput, pTableScanInfo->rowEntryInfoOffset) != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pRuntimeEnv->env, TSDB_CODE_OUT_OF_MEMORY); } } } @@ -950,10 +939,10 @@ static void setExecutionContext(SOperatorInfo* pOperator, int32_t numOfOutput, u } static void doUpdateNumOfRows(SqlFunctionCtx* pCtx, SResultRow* pRow, int32_t numOfExprs, - const int32_t* rowCellOffset) { + const int32_t* rowEntryOffset) { bool returnNotNull = false; for (int32_t j = 0; j < numOfExprs; ++j) { - struct SResultRowEntryInfo* pResInfo = getResultEntryInfo(pRow, j, rowCellOffset); + SResultRowEntryInfo* pResInfo = getResultEntryInfo(pRow, j, rowEntryOffset); if (!isRowEntryInitialized(pResInfo)) { continue; } @@ -1156,45 +1145,6 @@ void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SG } } -// void skipBlocks(STaskRuntimeEnv *pRuntimeEnv) { -// STaskAttr *pQueryAttr = pRuntimeEnv->pQueryAttr; -// -// if (pQueryAttr->limit.offset <= 0 || pQueryAttr->numOfFilterCols > 0) { -// return; -// } -// -// pQueryAttr->pos = 0; -// int32_t step = GET_FORWARD_DIRECTION_FACTOR(pQueryAttr->order.order); -// -// STableQueryInfo* pTableQueryInfo = pRuntimeEnv->current; -// TsdbQueryHandleT pTsdbReadHandle = pRuntimeEnv->pTsdbReadHandle; -// -// SDataBlockInfo blockInfo = SDATA_BLOCK_INITIALIZER; -// while (tsdbNextDataBlock(pTsdbReadHandle)) { -// if (isTaskKilled(pRuntimeEnv->qinfo)) { -// T_LONG_JMP(pRuntimeEnv->env, TSDB_CODE_TSC_QUERY_CANCELLED); -// } -// -// tsdbRetrieveDataBlockInfo(pTsdbReadHandle, &blockInfo); -// -// if (pQueryAttr->limit.offset > blockInfo.rows) { -// pQueryAttr->limit.offset -= blockInfo.rows; -// pTableQueryInfo->lastKey = (QUERY_IS_ASC_QUERY(pQueryAttr)) ? blockInfo.window.ekey : blockInfo.window.skey; -// pTableQueryInfo->lastKey += step; -// -// //qDebug("QInfo:0x%"PRIx64" skip rows:%d, offset:%" PRId64, GET_TASKID(pRuntimeEnv), blockInfo.rows, -// pQuery->limit.offset); -// } else { // find the appropriated start position in current block -// updateOffsetVal(pRuntimeEnv, &blockInfo); -// break; -// } -// } -// -// if (terrno != TSDB_CODE_SUCCESS) { -// T_LONG_JMP(pRuntimeEnv->env, terrno); -// } -// } - // static TSKEY doSkipIntervalProcess(STaskRuntimeEnv* pRuntimeEnv, STimeWindow* win, SDataBlockInfo* pBlockInfo, // STableQueryInfo* pTableQueryInfo) { // STaskAttr *pQueryAttr = pRuntimeEnv->pQueryAttr; @@ -1381,7 +1331,8 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan int32_t type = pOperator->operatorType; if (type == QUERY_NODE_PHYSICAL_PLAN_EXCHANGE || type == QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN || type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN || type == QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN || - type == QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN || type == QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN) { + type == QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN || type == QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN || + type == QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN) { *order = TSDB_ORDER_ASC; *scanFlag = MAIN_SCAN; return TSDB_CODE_SUCCESS; @@ -1418,11 +1369,11 @@ static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBloc SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx; bool hasCountFunc = false; + for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) { - if ((strcmp(pCtx[i].pExpr->pExpr->_function.functionName, "count") == 0) || - (strcmp(pCtx[i].pExpr->pExpr->_function.functionName, "hyperloglog") == 0) || - (strcmp(pCtx[i].pExpr->pExpr->_function.functionName, "_hyperloglog_partial") == 0) || - (strcmp(pCtx[i].pExpr->pExpr->_function.functionName, "_hyperloglog_merge") == 0)) { + const char* pName = pCtx[i].pExpr->pExpr->_function.functionName; + if ((strcmp(pName, "count") == 0) || (strcmp(pName, "hyperloglog") == 0) || + (strcmp(pName, "_hyperloglog_partial") == 0) || (strcmp(pName, "_hyperloglog_merge") == 0)) { hasCountFunc = true; break; } @@ -1475,7 +1426,6 @@ static void destroyDataBlockForEmptyInput(bool blockAllocated, SSDataBlock **ppB *ppBlock = NULL; } - // this is a blocking operator static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { if (OPTR_IS_OPENED(pOperator)) { @@ -1626,6 +1576,15 @@ void destroyOperatorInfo(SOperatorInfo* pOperator) { taosMemoryFreeClear(pOperator); } +// each operator should be set their own function to return total cost buffer +int32_t optrDefaultBufFn(SOperatorInfo* pOperator) { + if (pOperator->blocking) { + ASSERT(0); + } else { + return 0; + } +} + int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz) { *defaultPgsz = 4096; while (*defaultPgsz < rowSize * 4) { @@ -1651,7 +1610,7 @@ int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t n pAggSup->currentPageId = -1; pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput); pAggSup->keyBuf = taosMemoryCalloc(1, keyBufSize + POINTER_BYTES + sizeof(int64_t)); - pAggSup->pResultRowHashTable = tSimpleHashInit(10, hashFn); + pAggSup->pResultRowHashTable = tSimpleHashInit(100, hashFn); if (pAggSup->keyBuf == NULL || pAggSup->pResultRowHashTable == NULL) { return TSDB_CODE_OUT_OF_MEMORY; @@ -1806,7 +1765,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiN setOperatorInfo(pOperator, "TableAggregate", QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, true, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, destroyAggOperatorInfo, NULL); + pOperator->fpSet = createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, destroyAggOperatorInfo, optrDefaultBufFn, NULL); if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) { STableScanInfo* pTableScanInfo = downstream->info; @@ -1867,7 +1826,6 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED); pTaskInfo->schemaInfo.dbname = strdup(dbFName); - pTaskInfo->cost.created = taosGetTimestampMs(); pTaskInfo->id.queryId = queryId; pTaskInfo->execModel = model; pTaskInfo->pTableInfoList = tableListCreate(); @@ -2073,6 +2031,9 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo } else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) { SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode; pOperator = createSysTableScanOperatorInfo(pHandle, pSysScanPhyNode, pUser, pTaskInfo); + } else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN == type) { + STableCountScanPhysiNode* pTblCountScanNode = (STableCountScanPhysiNode*)pPhyNode; + pOperator = createTableCountScanOperatorInfo(pHandle, pTblCountScanNode, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN == type) { STagScanPhysiNode* pScanPhyNode = (STagScanPhysiNode*)pPhyNode; @@ -2235,12 +2196,12 @@ static int32_t extractTbscanInStreamOpTree(SOperatorInfo* pOperator, STableScanI if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { if (pOperator->numOfDownstream == 0) { qError("failed to find stream scan operator"); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } if (pOperator->numOfDownstream > 1) { qError("join not supported for stream block scan"); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } return extractTbscanInStreamOpTree(pOperator->pDownstream[0], ppInfo); } else { @@ -2258,13 +2219,13 @@ int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) { return 0; } else { ASSERT(0); - terrno = TSDB_CODE_QRY_APP_ERROR; + terrno = TSDB_CODE_APP_ERROR; return -1; } } else { if (LIST_LENGTH(pNode->pChildren) != 1) { ASSERT(0); - terrno = TSDB_CODE_QRY_APP_ERROR; + terrno = TSDB_CODE_APP_ERROR; return -1; } SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pNode->pChildren, 0); @@ -2292,7 +2253,7 @@ int32_t rebuildReader(SOperatorInfo* pOperator, SSubplan* plan, SReadHandle* pHa if (pTableScanInfo->dataReader == NULL) { ASSERT(0); qError("failed to create data reader"); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } // TODO: set uid and ts to data reader return 0; @@ -2371,6 +2332,7 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead goto _complete; } + (*pTaskInfo)->cost.created = taosGetTimestampUs(); return TSDB_CODE_SUCCESS; _complete: @@ -2466,7 +2428,7 @@ int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInf code = getOperatorExplainExecInfo(operatorInfo->pDownstream[i], pExecInfoList); if (code != TSDB_CODE_SUCCESS) { // taosMemoryFreeClear(*pRes); - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } } @@ -2483,7 +2445,7 @@ int32_t setOutputBuf(SStreamState* pState, STimeWindow* win, SResultRow** pResul int32_t size = pAggSup->resultRowSize; if (streamStateAddIfNotExist(pState, &key, (void**)&value, &size) < 0) { - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } *pResult = (SResultRow*)value; ASSERT(*pResult); diff --git a/source/libs/executor/src/filloperator.c b/source/libs/executor/src/filloperator.c index e26bfe9889..8d5af64777 100644 --- a/source/libs/executor/src/filloperator.c +++ b/source/libs/executor/src/filloperator.c @@ -381,7 +381,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* setOperatorInfo(pOperator, "FillOperator", QUERY_NODE_PHYSICAL_PLAN_FILL, false, OP_NOT_OPENED, pInfo, pTaskInfo); pOperator->exprSupp.numOfExprs = pInfo->numOfExpr; - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doFill, NULL, destroyFillOperatorInfo, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doFill, NULL, destroyFillOperatorInfo, optrDefaultBufFn, NULL); code = appendDownstream(pOperator, &downstream, 1); return pOperator; @@ -1146,7 +1146,7 @@ static void doDeleteFillResult(SOperatorInfo* pOperator) { if (delTs > nextKey.ts) { break; } - endTs = delTs; + SWinKey delKey = {.groupId = delGroupId, .ts = delTs}; if (delTs == nextKey.ts) { code = streamStateCurNext(pOperator->pTaskInfo->streamInfo.pState, pCur); @@ -1159,7 +1159,7 @@ static void doDeleteFillResult(SOperatorInfo* pOperator) { streamStateFreeCur(pCur); pCur = streamStateGetAndCheckCur(pOperator->pTaskInfo->streamInfo.pState, &nextKey); } - endTs = TMAX(ts, nextKey.ts - 1); + endTs = TMAX(delTs, nextKey.ts - 1); if (code != TSDB_CODE_SUCCESS) { break; } @@ -1478,7 +1478,7 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi pInfo->srcRowIndex = 0; setOperatorInfo(pOperator, "StreamFillOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL, false, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamFill, NULL, destroyStreamFillOperatorInfo, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doStreamFill, NULL, destroyStreamFillOperatorInfo, optrDefaultBufFn, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 4601175561..2cd1bd7dec 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -310,7 +310,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) { int32_t ret = setGroupResultOutputBuf(pOperator, &(pInfo->binfo), pOperator->exprSupp.numOfExprs, pInfo->keyBuf, len, pBlock->info.id.groupId, pInfo->aggSup.pResultBuf, &pInfo->aggSup); if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_APP_ERROR); } int32_t rowIndex = j - num; @@ -327,7 +327,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) { int32_t ret = setGroupResultOutputBuf(pOperator, &(pInfo->binfo), pOperator->exprSupp.numOfExprs, pInfo->keyBuf, len, pBlock->info.id.groupId, pInfo->aggSup.pResultBuf, &pInfo->aggSup); if (ret != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_APP_ERROR); } int32_t rowIndex = pBlock->info.rows - num; @@ -470,7 +470,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode* setOperatorInfo(pOperator, "GroupbyAggOperator", 0, true, OP_NOT_OPENED, pInfo, pTaskInfo); pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, hashGroupbyAggregate, NULL, destroyGroupOperatorInfo, NULL); + createOperatorFpSet(optrDummyOpenFn, hashGroupbyAggregate, NULL, destroyGroupOperatorInfo, optrDefaultBufFn, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -850,7 +850,7 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition pOperator->exprSupp.numOfExprs = numOfCols; pOperator->exprSupp.pExprInfo = pExprInfo; - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, hashPartition, NULL, destroyPartitionOperatorInfo, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, hashPartition, NULL, destroyPartitionOperatorInfo, optrDefaultBufFn, NULL); code = appendDownstream(pOperator, &downstream, 1); return pOperator; @@ -1142,7 +1142,7 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr pOperator->exprSupp.numOfExprs = numOfCols; pOperator->exprSupp.pExprInfo = pExprInfo; pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doStreamHashPartition, NULL, destroyStreamPartitionOperatorInfo, NULL); + createOperatorFpSet(optrDummyOpenFn, doStreamHashPartition, NULL, destroyStreamPartitionOperatorInfo, optrDefaultBufFn, NULL); initParDownStream(downstream, &pInfo->partitionSup, &pInfo->scalarSup); code = appendDownstream(pOperator, &downstream, 1); diff --git a/source/libs/executor/src/joinoperator.c b/source/libs/executor/src/joinoperator.c index e7cce39dfd..d460af971c 100644 --- a/source/libs/executor/src/joinoperator.c +++ b/source/libs/executor/src/joinoperator.c @@ -136,7 +136,7 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t pInfo->inputOrder = TSDB_ORDER_DESC; } - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doMergeJoin, NULL, destroyMergeJoinOperator, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doMergeJoin, NULL, destroyMergeJoinOperator, optrDefaultBufFn, NULL); code = appendDownstream(pOperator, pDownstream, numOfDownstream); if (code != TSDB_CODE_SUCCESS) { goto _error; diff --git a/source/libs/executor/src/projectoperator.c b/source/libs/executor/src/projectoperator.c index da77facb21..65bb40b195 100644 --- a/source/libs/executor/src/projectoperator.c +++ b/source/libs/executor/src/projectoperator.c @@ -118,8 +118,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pOperator->exprSupp.pCtx, numOfCols); setOperatorInfo(pOperator, "ProjectOperator", QUERY_NODE_PHYSICAL_PLAN_PROJECT, false, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doProjectOperation, NULL, - destroyProjectOperatorInfo, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doProjectOperation, NULL, + destroyProjectOperatorInfo, optrDefaultBufFn, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -415,7 +415,7 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pSup->pCtx, numOfExpr); setOperatorInfo(pOperator, "IndefinitOperator", QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC, false, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doApplyIndefinitFunction, NULL, destroyIndefinitOperatorInfo, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doApplyIndefinitFunction, NULL, destroyIndefinitOperatorInfo, optrDefaultBufFn, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index b6353061fb..04f5f4ecfe 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -30,7 +30,6 @@ #include "tcompare.h" #include "thash.h" #include "ttypes.h" -#include "vnode.h" #define SET_REVERSE_SCAN_FLAG(_info) ((_info)->scanFlag = REVERSE_SCAN) #define SWITCH_ORDER(n) (((n) = ((n) == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC)) @@ -224,10 +223,8 @@ static bool doFilterByBlockSMA(SFilterInfo* pFilterInfo, SColumnDataAgg** pColsA } static bool doLoadBlockSMA(STableScanBase* pTableScanInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) { - bool allColumnsHaveAgg = true; - SColumnDataAgg** pColAgg = NULL; - - int32_t code = tsdbRetrieveDatablockSMA(pTableScanInfo->dataReader, &pColAgg, &allColumnsHaveAgg); + bool allColumnsHaveAgg = true; + int32_t code = tsdbRetrieveDatablockSMA(pTableScanInfo->dataReader, &pBlock->pBlockAgg, &allColumnsHaveAgg); if (code != TSDB_CODE_SUCCESS) { T_LONG_JMP(pTaskInfo->env, code); } @@ -236,6 +233,7 @@ static bool doLoadBlockSMA(STableScanBase* pTableScanInfo, SSDataBlock* pBlock, return false; } +#if 0 // if (allColumnsHaveAgg == true) { int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); @@ -256,6 +254,7 @@ static bool doLoadBlockSMA(STableScanBase* pTableScanInfo, SSDataBlock* pBlock, pBlock->pBlockAgg[pColMatchInfo->dstSlotId] = pColAgg[i]; } +#endif return true; } @@ -285,7 +284,7 @@ void applyLimitOffset(SLimitInfo* pLimitInfo, SSDataBlock* pBlock, SExecTaskInfo if (pLimit->offset > 0 && pLimitInfo->remainOffset > 0) { if (pLimitInfo->remainOffset >= pBlock->info.rows) { pLimitInfo->remainOffset -= pBlock->info.rows; - pBlock->info.rows = 0; + blockDataEmpty(pBlock); qDebug("current block ignore due to offset, current:%" PRId64 ", %s", pLimitInfo->remainOffset, id); } else { blockDataTrimFirstNRows(pBlock, pLimitInfo->remainOffset); @@ -385,12 +384,12 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca pCost->totalCheckedRows += pBlock->info.rows; pCost->loadBlocks += 1; - SArray* pCols = tsdbRetrieveDataBlock(pTableScanInfo->dataReader, NULL); - if (pCols == NULL) { + SSDataBlock* p = tsdbRetrieveDataBlock(pTableScanInfo->dataReader, NULL); + if (p == NULL) { return terrno; } - relocateColumnData(pBlock, pTableScanInfo->matchInfo.pList, pCols, true); + ASSERT(p == pBlock); doSetTagColumnData(pTableScanInfo, pBlock, pTaskInfo, pBlock->info.rows); // restore the previous value @@ -487,10 +486,11 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int code = metaGetTableEntryByUidCache(&mr, pBlock->info.id.uid); if (code != TSDB_CODE_SUCCESS) { 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); + qWarn("failed to get table meta, table may have been dropped, uid:0x%" PRIx64 ", code:%s, %s", + pBlock->info.id.uid, tstrerror(terrno), idStr); } else { - qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.id.uid, tstrerror(terrno), idStr); + qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", pBlock->info.id.uid, tstrerror(terrno), + idStr); } metaReaderClear(&mr); return terrno; @@ -629,7 +629,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { while (tsdbNextDataBlock(pTableScanInfo->base.dataReader)) { if (isTaskKilled(pTaskInfo)) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_TSC_QUERY_CANCELLED); + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); } // process this data block based on the probabilities @@ -638,16 +638,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { continue; } - blockDataCleanup(pBlock); - SDataBlockInfo* pBInfo = &pBlock->info; - - int32_t rows = 0; - tsdbRetrieveDataBlockInfo(pTableScanInfo->base.dataReader, &rows, &pBInfo->id.uid, &pBInfo->window); - - blockDataEnsureCapacity(pBlock, rows); // todo remove it latter - pBInfo->rows = rows; - - ASSERT(pBInfo->id.uid != 0); + ASSERT(pBlock->info.id.uid != 0); pBlock->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBlock->info.id.uid); uint32_t status = 0; @@ -778,7 +769,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) { ASSERT(pInfo->base.dataReader == NULL); int32_t code = tsdbReaderOpen(pInfo->base.readHandle.vnode, &pInfo->base.cond, pList, num, - (STsdbReader**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo)); + pInfo->pResBlock, (STsdbReader**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo)); if (code != TSDB_CODE_SUCCESS) { T_LONG_JMP(pTaskInfo->env, code); } @@ -879,11 +870,11 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, pInfo->base.scanFlag = MAIN_SCAN; pInfo->base.pdInfo.interval = extractIntervalInfo(pTableScanNode); pInfo->base.readHandle = *readHandle; + pInfo->base.dataBlockLoadFlag = pTableScanNode->dataRequired; + pInfo->sample.sampleRatio = pTableScanNode->ratio; pInfo->sample.seed = taosGetTimestampSec(); - pInfo->base.dataBlockLoadFlag = pTableScanNode->dataRequired; - initResultSizeInfo(&pOperator->resultInfo, 4096); pInfo->pResBlock = createDataBlockFromDescNode(pDescNode); blockDataEnsureCapacity(pInfo->pResBlock, pOperator->resultInfo.capacity); @@ -908,8 +899,8 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, } taosLRUCacheSetStrictCapacity(pInfo->base.metaCache.pTableMetaEntryCache, false); - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScan, NULL, destroyTableScanOperatorInfo, - getTableScannerExecInfo); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doTableScan, NULL, destroyTableScanOperatorInfo, + optrDefaultBufFn, getTableScannerExecInfo); // for non-blocking operator, the open cost is always 0 pOperator->cost.openCost = 0; @@ -934,7 +925,7 @@ SOperatorInfo* createTableSeqScanOperatorInfo(void* pReadHandle, SExecTaskInfo* setOperatorInfo(pOperator, "TableSeqScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN, false, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScanImpl, NULL, NULL, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doTableScanImpl, NULL, NULL, optrDefaultBufFn, NULL); return pOperator; } @@ -994,10 +985,8 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU SExecTaskInfo* pTaskInfo = pTableScanOp->pTaskInfo; SSDataBlock* pBlock = pTableScanInfo->pResBlock; - blockDataCleanup(pBlock); - STsdbReader* pReader = NULL; - int32_t code = tsdbReaderOpen(pTableScanInfo->base.readHandle.vnode, &cond, &tblInfo, 1, (STsdbReader**)&pReader, + int32_t code = tsdbReaderOpen(pTableScanInfo->base.readHandle.vnode, &cond, &tblInfo, 1, pBlock, (STsdbReader**)&pReader, GET_TASKID(pTaskInfo)); if (code != TSDB_CODE_SUCCESS) { terrno = code; @@ -1005,21 +994,10 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU return NULL; } - bool hasBlock = tsdbNextDataBlock(pReader); - if (hasBlock) { - SDataBlockInfo* pBInfo = &pBlock->info; - - int32_t rows = 0; - tsdbRetrieveDataBlockInfo(pReader, &rows, &pBInfo->id.uid, &pBInfo->window); - - SArray* pCols = tsdbRetrieveDataBlock(pReader, NULL); - blockDataEnsureCapacity(pBlock, rows); - pBlock->info.rows = rows; - - relocateColumnData(pBlock, pTableScanInfo->base.matchInfo.pList, pCols, true); - doSetTagColumnData(&pTableScanInfo->base, pBlock, pTaskInfo, rows); - - pBlock->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBInfo->id.uid); + if (tsdbNextDataBlock(pReader)) { + /*SSDataBlock* p = */tsdbRetrieveDataBlock(pReader, NULL); + doSetTagColumnData(&pTableScanInfo->base, pBlock, pTaskInfo, pBlock->info.rows); + pBlock->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBlock->info.id.uid); } tsdbReaderClose(pReader); @@ -1113,7 +1091,7 @@ static STimeWindow getSlidingWindow(TSKEY* startTsCol, TSKEY* endTsCol, uint64_t if (hasGroup) { (*pRowIndex) += 1; } else { - while ((groupId == gpIdCol[(*pRowIndex)] && startTsCol[*pRowIndex] < endWin.ekey)) { + while ((groupId == gpIdCol[(*pRowIndex)] && startTsCol[*pRowIndex] <= endWin.ekey)) { (*pRowIndex) += 1; if ((*pRowIndex) == pDataBlockInfo->rows) { break; @@ -1436,8 +1414,8 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock NULL); if (closedWin && pInfo->partitionSup.needCalc) { gpId = calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pBlock, rowId); - appendOneRowToStreamSpecialBlock(pInfo->pUpdateDataRes, tsCol + rowId, tsCol + rowId, &pBlock->info.id.uid, &gpId, - NULL); + appendOneRowToStreamSpecialBlock(pInfo->pUpdateDataRes, tsCol + rowId, tsCol + rowId, &pBlock->info.id.uid, + &gpId, NULL); } } } @@ -2028,20 +2006,13 @@ static SSDataBlock* doRawScan(SOperatorInfo* pOperator) { qDebug("tmqsnap doRawScan called"); if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_DATA) { - SSDataBlock* pBlock = &pInfo->pRes; - if (pInfo->dataReader && tsdbNextDataBlock(pInfo->dataReader)) { if (isTaskKilled(pTaskInfo)) { - longjmp(pTaskInfo->env, TSDB_CODE_TSC_QUERY_CANCELLED); + longjmp(pTaskInfo->env, pTaskInfo->code); } - int32_t rows = 0; - tsdbRetrieveDataBlockInfo(pInfo->dataReader, &rows, &pBlock->info.id.uid, &pBlock->info.window); - pBlock->info.rows = rows; - - SArray* pCols = tsdbRetrieveDataBlock(pInfo->dataReader, NULL); - pBlock->pDataBlock = pCols; - if (pCols == NULL) { + SSDataBlock* pBlock = tsdbRetrieveDataBlock(pInfo->dataReader, NULL); + if (pBlock == NULL) { longjmp(pTaskInfo->env, terrno); } @@ -2168,7 +2139,7 @@ SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, SExecTaskInfo* pT setOperatorInfo(pOperator, "RawScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN, false, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = createOperatorFpSet(NULL, doRawScan, NULL, destroyRawScanOperatorInfo, NULL); + pOperator->fpSet = createOperatorFpSet(NULL, doRawScan, NULL, destroyRawScanOperatorInfo, optrDefaultBufFn, NULL); return pOperator; _end: @@ -2212,7 +2183,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { - terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; goto _error; } @@ -2287,7 +2258,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys if (pHandle->initTableReader) { pTSInfo->scanMode = TABLE_SCAN__TABLE_ORDER; pTSInfo->base.dataReader = NULL; - code = tsdbReaderOpen(pHandle->vnode, &pTSInfo->base.cond, pList, num, &pTSInfo->base.dataReader, NULL); + code = tsdbReaderOpen(pHandle->vnode, &pTSInfo->base.cond, pList, num, pTSInfo->pResBlock, &pTSInfo->base.dataReader, NULL); if (code != 0) { terrno = code; destroyTableScanOperatorInfo(pTableScanOp); @@ -2357,7 +2328,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock); __optr_fn_t nextFn = pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM ? doStreamScan : doQueueScan; - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, nextFn, NULL, destroyStreamScanOperatorInfo, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, nextFn, NULL, destroyStreamScanOperatorInfo, optrDefaultBufFn, NULL); return pOperator; @@ -2462,7 +2433,8 @@ static void destroyTagScanOperatorInfo(void* param) { taosMemoryFreeClear(param); } -SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo) { +SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, + SExecTaskInfo* pTaskInfo) { STagScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STagScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -2493,7 +2465,7 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi initResultSizeInfo(&pOperator->resultInfo, 4096); blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity); - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTagScan, NULL, destroyTagScanOperatorInfo, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doTagScan, NULL, destroyTagScanOperatorInfo, optrDefaultBufFn, NULL); return pOperator; @@ -2511,17 +2483,14 @@ static SSDataBlock* getTableDataBlockImpl(void* param) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; int32_t readIdx = source->readerIdx; SSDataBlock* pBlock = source->inputBlock; - STableMergeScanInfo* pTableScanInfo = pOperator->info; - SQueryTableDataCond* pQueryCond = taosArrayGet(pTableScanInfo->queryConds, readIdx); - blockDataCleanup(pBlock); + SQueryTableDataCond* pQueryCond = taosArrayGet(pInfo->queryConds, readIdx); int64_t st = taosGetTimestampUs(); - - void* p = tableListGetInfo(pTaskInfo->pTableInfoList, readIdx + pInfo->tableStartIndex); + void* p = tableListGetInfo(pTaskInfo->pTableInfoList, readIdx + pInfo->tableStartIndex); SReadHandle* pHandle = &pInfo->base.readHandle; - int32_t code = tsdbReaderOpen(pHandle->vnode, pQueryCond, p, 1, &pInfo->base.dataReader, GET_TASKID(pTaskInfo)); + int32_t code = tsdbReaderOpen(pHandle->vnode, pQueryCond, p, 1, pBlock, &pInfo->base.dataReader, GET_TASKID(pTaskInfo)); if (code != 0) { T_LONG_JMP(pTaskInfo->env, code); } @@ -2529,22 +2498,15 @@ static SSDataBlock* getTableDataBlockImpl(void* param) { STsdbReader* reader = pInfo->base.dataReader; while (tsdbNextDataBlock(reader)) { if (isTaskKilled(pTaskInfo)) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_TSC_QUERY_CANCELLED); + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); } // process this data block based on the probabilities - bool processThisBlock = processBlockWithProbability(&pTableScanInfo->sample); + bool processThisBlock = processBlockWithProbability(&pInfo->sample); if (!processThisBlock) { continue; } - blockDataCleanup(pBlock); - - int32_t rows = 0; - tsdbRetrieveDataBlockInfo(reader, &rows, &pBlock->info.id.uid, &pBlock->info.window); - blockDataEnsureCapacity(pBlock, rows); - pBlock->info.rows = rows; - if (pQueryCond->order == TSDB_ORDER_ASC) { pQueryCond->twindows.skey = pBlock->info.window.ekey + 1; } else { @@ -2552,7 +2514,7 @@ static SSDataBlock* getTableDataBlockImpl(void* param) { } uint32_t status = 0; - loadDataBlock(pOperator, &pTableScanInfo->base, pBlock, &status); + loadDataBlock(pOperator, &pInfo->base, pBlock, &status); // code = loadDataBlockFromOneTable(pOperator, pTableScanInfo, pBlock, &status); if (code != TSDB_CODE_SUCCESS) { T_LONG_JMP(pTaskInfo->env, code); @@ -2566,7 +2528,7 @@ static SSDataBlock* getTableDataBlockImpl(void* param) { pBlock->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBlock->info.id.uid); pOperator->resultInfo.totalRows += pBlock->info.rows; - pTableScanInfo->base.readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0; + pInfo->base.readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0; tsdbReaderClose(pInfo->base.dataReader); pInfo->base.dataReader = NULL; @@ -2646,6 +2608,8 @@ int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) { param.readerIdx = i; param.pOperator = pOperator; param.inputBlock = createOneDataBlock(pInfo->pResBlock, false); + blockDataEnsureCapacity(param.inputBlock, pOperator->resultInfo.capacity); + taosArrayPush(pInfo->sortSourceParams, ¶m); SQueryTableDataCond cond; @@ -2902,8 +2866,8 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN pInfo, pTaskInfo); pOperator->exprSupp.numOfExprs = numOfCols; - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableMergeScan, NULL, destroyTableMergeScanOperatorInfo, - getTableMergeScanExplainExecInfo); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doTableMergeScan, NULL, destroyTableMergeScanOperatorInfo, + optrDefaultBufFn, getTableMergeScanExplainExecInfo); pOperator->cost.openCost = 0; return pOperator; @@ -2913,3 +2877,351 @@ _error: taosMemoryFree(pOperator); return NULL; } + +// ==================================================================================================================== +// TableCountScanOperator +static SSDataBlock* doTableCountScan(SOperatorInfo* pOperator); +static void destoryTableCountScanOperator(void* param); +static void buildVnodeGroupedStbTableCount(STableCountScanOperatorInfo* pInfo, STableCountScanSupp* pSupp, + SSDataBlock* pRes, char* dbName, tb_uid_t stbUid); +static void buildVnodeGroupedNtbTableCount(STableCountScanOperatorInfo* pInfo, STableCountScanSupp* pSupp, + SSDataBlock* pRes, char* dbName); +static void buildVnodeFilteredTbCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo, + STableCountScanSupp* pSupp, SSDataBlock* pRes, char* dbName); +static void buildVnodeGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo, + STableCountScanSupp* pSupp, SSDataBlock* pRes, int32_t vgId, char* dbName); +static SSDataBlock* buildVnodeDbTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo, + STableCountScanSupp* pSupp, SSDataBlock* pRes); +static void buildSysDbGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo, + STableCountScanSupp* pSupp, SSDataBlock* pRes, size_t infodbTableNum, + size_t perfdbTableNum); +static void buildSysDbFilterTableCount(SOperatorInfo* pOperator, STableCountScanSupp* pSupp, SSDataBlock* pRes, + size_t infodbTableNum, size_t perfdbTableNum); +static const char* GROUP_TAG_DB_NAME = "db_name"; +static const char* GROUP_TAG_STABLE_NAME = "stable_name"; + +int32_t tblCountScanGetGroupTagsSlotId(const SNodeList* scanCols, STableCountScanSupp* supp) { + if (scanCols != NULL) { + SNode* pNode = NULL; + FOREACH(pNode, scanCols) { + if (nodeType(pNode) != QUERY_NODE_TARGET) { + return TSDB_CODE_QRY_SYS_ERROR; + } + STargetNode* targetNode = (STargetNode*)pNode; + if (nodeType(targetNode->pExpr) != QUERY_NODE_COLUMN) { + return TSDB_CODE_QRY_SYS_ERROR; + } + SColumnNode* colNode = (SColumnNode*)(targetNode->pExpr); + if (strcmp(colNode->colName, GROUP_TAG_DB_NAME) == 0) { + supp->dbNameSlotId = targetNode->slotId; + } else if (strcmp(colNode->colName, GROUP_TAG_STABLE_NAME) == 0) { + supp->stbNameSlotId = targetNode->slotId; + } + } + } + return TSDB_CODE_SUCCESS; +} + +int32_t tblCountScanGetCountSlotId(const SNodeList* pseudoCols, STableCountScanSupp* supp) { + if (pseudoCols != NULL) { + SNode* pNode = NULL; + FOREACH(pNode, pseudoCols) { + if (nodeType(pNode) != QUERY_NODE_TARGET) { + return TSDB_CODE_QRY_SYS_ERROR; + } + STargetNode* targetNode = (STargetNode*)pNode; + if (nodeType(targetNode->pExpr) != QUERY_NODE_FUNCTION) { + return TSDB_CODE_QRY_SYS_ERROR; + } + SFunctionNode* funcNode = (SFunctionNode*)(targetNode->pExpr); + if (funcNode->funcType == FUNCTION_TYPE_TABLE_COUNT) { + supp->tbCountSlotId = targetNode->slotId; + } + } + } + return TSDB_CODE_SUCCESS; +} + +int32_t tblCountScanGetInputs(SNodeList* groupTags, SName* tableName, STableCountScanSupp* supp) { + if (groupTags != NULL) { + SNode* pNode = NULL; + FOREACH(pNode, groupTags) { + if (nodeType(pNode) != QUERY_NODE_COLUMN) { + return TSDB_CODE_QRY_SYS_ERROR; + } + SColumnNode* colNode = (SColumnNode*)pNode; + if (strcmp(colNode->colName, GROUP_TAG_DB_NAME) == 0) { + supp->groupByDbName = true; + } + if (strcmp(colNode->colName, GROUP_TAG_STABLE_NAME) == 0) { + supp->groupByStbName = true; + } + } + } else { + strncpy(supp->dbNameFilter, tNameGetDbNameP(tableName), TSDB_DB_NAME_LEN); + strncpy(supp->stbNameFilter, tNameGetTableName(tableName), TSDB_TABLE_NAME_LEN); + } + return TSDB_CODE_SUCCESS; +} + +int32_t getTableCountScanSupp(SNodeList* groupTags, SName* tableName, SNodeList* scanCols, SNodeList* pseudoCols, + STableCountScanSupp* supp, SExecTaskInfo* taskInfo) { + int32_t code = 0; + code = tblCountScanGetInputs(groupTags, tableName, supp); + if (code != TSDB_CODE_SUCCESS) { + qError("%s get table count scan supp. get inputs error", GET_TASKID(taskInfo)); + return code; + } + supp->dbNameSlotId = -1; + supp->stbNameSlotId = -1; + supp->tbCountSlotId = -1; + + code = tblCountScanGetGroupTagsSlotId(scanCols, supp); + if (code != TSDB_CODE_SUCCESS) { + qError("%s get table count scan supp. get group tags slot id error", GET_TASKID(taskInfo)); + return code; + } + code = tblCountScanGetCountSlotId(pseudoCols, supp); + if (code != TSDB_CODE_SUCCESS) { + qError("%s get table count scan supp. get count error", GET_TASKID(taskInfo)); + return code; + } + return code; +} + +SOperatorInfo* createTableCountScanOperatorInfo(SReadHandle* readHandle, STableCountScanPhysiNode* pTblCountScanNode, + SExecTaskInfo* pTaskInfo) { + int32_t code = TSDB_CODE_SUCCESS; + + SScanPhysiNode* pScanNode = &pTblCountScanNode->scan; + STableCountScanOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STableCountScanOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + + if (!pInfo || !pOperator) { + goto _error; + } + + pInfo->readHandle = *readHandle; + + SDataBlockDescNode* pDescNode = pScanNode->node.pOutputDataBlockDesc; + initResultSizeInfo(&pOperator->resultInfo, 1); + pInfo->pRes = createDataBlockFromDescNode(pDescNode); + blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity); + + getTableCountScanSupp(pTblCountScanNode->pGroupTags, &pTblCountScanNode->scan.tableName, + pTblCountScanNode->scan.pScanCols, pTblCountScanNode->scan.pScanPseudoCols, &pInfo->supp, + pTaskInfo); + + setOperatorInfo(pOperator, "TableCountScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN, false, OP_NOT_OPENED, + pInfo, pTaskInfo); + pOperator->fpSet = + createOperatorFpSet(optrDummyOpenFn, doTableCountScan, NULL, destoryTableCountScanOperator, optrDefaultBufFn, NULL); + return pOperator; + +_error: + if (pInfo != NULL) { + destoryTableCountScanOperator(pInfo); + } + taosMemoryFreeClear(pOperator); + pTaskInfo->code = code; + return NULL; +} + +void fillTableCountScanDataBlock(STableCountScanSupp* pSupp, char* dbName, char* stbName, int64_t count, + SSDataBlock* pRes) { + if (pSupp->dbNameSlotId != -1) { + ASSERT(strlen(dbName)); + SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->dbNameSlotId); + char varDbName[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + strncpy(varDataVal(varDbName), dbName, strlen(dbName)); + varDataSetLen(varDbName, strlen(dbName)); + colDataAppend(colInfoData, 0, varDbName, false); + } + + if (pSupp->stbNameSlotId != -1) { + SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->stbNameSlotId); + if (strlen(stbName) != 0) { + char varStbName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + strncpy(varDataVal(varStbName), stbName, strlen(stbName)); + varDataSetLen(varStbName, strlen(stbName)); + colDataAppend(colInfoData, 0, varStbName, false); + } else { + colDataAppendNULL(colInfoData, 0); + } + } + + if (pSupp->tbCountSlotId != -1) { + SColumnInfoData* colInfoData = taosArrayGet(pRes->pDataBlock, pSupp->tbCountSlotId); + colDataAppend(colInfoData, 0, (char*)&count, false); + } + pRes->info.rows = 1; +} + +static SSDataBlock* buildSysDbTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo) { + STableCountScanSupp* pSupp = &pInfo->supp; + SSDataBlock* pRes = pInfo->pRes; + + size_t infodbTableNum; + getInfosDbMeta(NULL, &infodbTableNum); + size_t perfdbTableNum; + getPerfDbMeta(NULL, &perfdbTableNum); + + if (pSupp->groupByDbName) { + buildSysDbGroupedTableCount(pOperator, pInfo, pSupp, pRes, infodbTableNum, perfdbTableNum); + return (pRes->info.rows > 0) ? pRes : NULL; + } else { + buildSysDbFilterTableCount(pOperator, pSupp, pRes, infodbTableNum, perfdbTableNum); + return (pRes->info.rows > 0) ? pRes : NULL; + } +} + +static void buildSysDbFilterTableCount(SOperatorInfo* pOperator, STableCountScanSupp* pSupp, SSDataBlock* pRes, + size_t infodbTableNum, size_t perfdbTableNum) { + if (strcmp(pSupp->dbNameFilter, TSDB_INFORMATION_SCHEMA_DB) == 0) { + fillTableCountScanDataBlock(pSupp, TSDB_INFORMATION_SCHEMA_DB, "", infodbTableNum, pRes); + } else if (strcmp(pSupp->dbNameFilter, TSDB_PERFORMANCE_SCHEMA_DB) == 0) { + fillTableCountScanDataBlock(pSupp, TSDB_PERFORMANCE_SCHEMA_DB, "", perfdbTableNum, pRes); + } else if (strlen(pSupp->dbNameFilter) == 0) { + fillTableCountScanDataBlock(pSupp, "", "", infodbTableNum + perfdbTableNum, pRes); + } + setOperatorCompleted(pOperator); +} + +static void buildSysDbGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo, + STableCountScanSupp* pSupp, SSDataBlock* pRes, size_t infodbTableNum, + size_t perfdbTableNum) { + if (pInfo->currGrpIdx == 0) { + uint64_t groupId = calcGroupId(TSDB_INFORMATION_SCHEMA_DB, strlen(TSDB_INFORMATION_SCHEMA_DB)); + pRes->info.id.groupId = groupId; + fillTableCountScanDataBlock(pSupp, TSDB_INFORMATION_SCHEMA_DB, "", infodbTableNum, pRes); + } else if (pInfo->currGrpIdx == 1) { + uint64_t groupId = calcGroupId(TSDB_PERFORMANCE_SCHEMA_DB, strlen(TSDB_PERFORMANCE_SCHEMA_DB)); + pRes->info.id.groupId = groupId; + fillTableCountScanDataBlock(pSupp, TSDB_PERFORMANCE_SCHEMA_DB, "", perfdbTableNum, pRes); + } else { + setOperatorCompleted(pOperator); + } + pInfo->currGrpIdx++; +} + +static SSDataBlock* doTableCountScan(SOperatorInfo* pOperator) { + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + STableCountScanOperatorInfo* pInfo = pOperator->info; + STableCountScanSupp* pSupp = &pInfo->supp; + SSDataBlock* pRes = pInfo->pRes; + blockDataCleanup(pRes); + + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } + if (pInfo->readHandle.mnd != NULL) { + return buildSysDbTableCount(pOperator, pInfo); + } + + return buildVnodeDbTableCount(pOperator, pInfo, pSupp, pRes); +} + +static SSDataBlock* buildVnodeDbTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo, + STableCountScanSupp* pSupp, SSDataBlock* pRes) { + const char* db = NULL; + int32_t vgId = 0; + char dbName[TSDB_DB_NAME_LEN] = {0}; + + // get dbname + vnodeGetInfo(pInfo->readHandle.vnode, &db, &vgId); + SName sn = {0}; + tNameFromString(&sn, db, T_NAME_ACCT | T_NAME_DB); + tNameGetDbName(&sn, dbName); + + if (pSupp->groupByDbName) { + buildVnodeGroupedTableCount(pOperator, pInfo, pSupp, pRes, vgId, dbName); + } else { + buildVnodeFilteredTbCount(pOperator, pInfo, pSupp, pRes, dbName); + } + return pRes->info.rows > 0 ? pRes : NULL; +} + +static void buildVnodeGroupedTableCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo, + STableCountScanSupp* pSupp, SSDataBlock* pRes, int32_t vgId, char* dbName) { + if (pSupp->groupByStbName) { + if (pInfo->stbUidList == NULL) { + pInfo->stbUidList = taosArrayInit(16, sizeof(tb_uid_t)); + if (vnodeGetStbIdList(pInfo->readHandle.vnode, 0, pInfo->stbUidList) < 0) { + qError("vgId:%d, failed to get stb id list error: %s", vgId, terrstr()); + } + } + if (pInfo->currGrpIdx < taosArrayGetSize(pInfo->stbUidList)) { + tb_uid_t stbUid = *(tb_uid_t*)taosArrayGet(pInfo->stbUidList, pInfo->currGrpIdx); + buildVnodeGroupedStbTableCount(pInfo, pSupp, pRes, dbName, stbUid); + + pInfo->currGrpIdx++; + } else if (pInfo->currGrpIdx == taosArrayGetSize(pInfo->stbUidList)) { + buildVnodeGroupedNtbTableCount(pInfo, pSupp, pRes, dbName); + + pInfo->currGrpIdx++; + } else { + setOperatorCompleted(pOperator); + } + } else { + uint64_t groupId = calcGroupId(dbName, strlen(dbName)); + pRes->info.id.groupId = groupId; + int64_t dbTableCount = metaGetTbNum(pInfo->readHandle.meta); + fillTableCountScanDataBlock(pSupp, dbName, "", dbTableCount, pRes); + setOperatorCompleted(pOperator); + } +} + +static void buildVnodeFilteredTbCount(SOperatorInfo* pOperator, STableCountScanOperatorInfo* pInfo, + STableCountScanSupp* pSupp, SSDataBlock* pRes, char* dbName) { + if (strlen(pSupp->dbNameFilter) != 0) { + if (strlen(pSupp->stbNameFilter) != 0) { + tb_uid_t uid = metaGetTableEntryUidByName(pInfo->readHandle.meta, pSupp->stbNameFilter); + SMetaStbStats stats = {0}; + metaGetStbStats(pInfo->readHandle.meta, uid, &stats); + int64_t ctbNum = stats.ctbNum; + fillTableCountScanDataBlock(pSupp, dbName, pSupp->stbNameFilter, ctbNum, pRes); + } else { + int64_t tbNumVnode = metaGetTbNum(pInfo->readHandle.meta); + fillTableCountScanDataBlock(pSupp, dbName, "", tbNumVnode, pRes); + } + } else { + int64_t tbNumVnode = metaGetTbNum(pInfo->readHandle.meta); + fillTableCountScanDataBlock(pSupp, dbName, "", tbNumVnode, pRes); + } + setOperatorCompleted(pOperator); +} + +static void buildVnodeGroupedNtbTableCount(STableCountScanOperatorInfo* pInfo, STableCountScanSupp* pSupp, + SSDataBlock* pRes, char* dbName) { + char fullStbName[TSDB_TABLE_FNAME_LEN] = {0}; + snprintf(fullStbName, TSDB_TABLE_FNAME_LEN, "%s.%s", dbName, ""); + uint64_t groupId = calcGroupId(fullStbName, strlen(fullStbName)); + pRes->info.id.groupId = groupId; + int64_t ntbNum = metaGetNtbNum(pInfo->readHandle.meta); + fillTableCountScanDataBlock(pSupp, dbName, "", ntbNum, pRes); +} + +static void buildVnodeGroupedStbTableCount(STableCountScanOperatorInfo* pInfo, STableCountScanSupp* pSupp, + SSDataBlock* pRes, char* dbName, tb_uid_t stbUid) { + char stbName[TSDB_TABLE_NAME_LEN] = {0}; + metaGetTableSzNameByUid(pInfo->readHandle.meta, stbUid, stbName); + + char fullStbName[TSDB_TABLE_FNAME_LEN] = {0}; + snprintf(fullStbName, TSDB_TABLE_FNAME_LEN, "%s.%s", dbName, stbName); + uint64_t groupId = calcGroupId(fullStbName, strlen(fullStbName)); + pRes->info.id.groupId = groupId; + + SMetaStbStats stats = {0}; + metaGetStbStats(pInfo->readHandle.meta, stbUid, &stats); + int64_t ctbNum = stats.ctbNum; + + fillTableCountScanDataBlock(pSupp, dbName, stbName, ctbNum, pRes); +} + +static void destoryTableCountScanOperator(void* param) { + STableCountScanOperatorInfo* pTableCountScanInfo = param; + blockDataDestroy(pTableCountScanInfo->pRes); + + taosArrayDestroy(pTableCountScanInfo->stbUidList); + taosMemoryFreeClear(param); +} diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index ec754f31b0..005b794f0b 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -75,7 +75,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* // TODO dynamic set the available sort buffer pOperator->fpSet = - createOperatorFpSet(doOpenSortOperator, doSort, NULL, destroySortOperatorInfo, getExplainExecInfo); + createOperatorFpSet(doOpenSortOperator, doSort, NULL, destroySortOperatorInfo, optrDefaultBufFn, getExplainExecInfo); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -521,8 +521,8 @@ SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSort pInfo->pSortInfo = createSortInfo(pSortPhyNode->pSortKeys); setOperatorInfo(pOperator, "GroupSortOperator", QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT, false, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doGroupSort, NULL, destroyGroupSortOperatorInfo, - getGroupSortExplainExecInfo); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doGroupSort, NULL, destroyGroupSortOperatorInfo, + optrDefaultBufFn, getGroupSortExplainExecInfo); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -559,7 +559,7 @@ typedef struct SMultiwayMergeOperatorInfo { STupleHandle* prefetchedTuple; } SMultiwayMergeOperatorInfo; -int32_t doOpenMultiwayMergeOperator(SOperatorInfo* pOperator) { +int32_t openMultiwayMergeOperator(SOperatorInfo* pOperator) { SMultiwayMergeOperatorInfo* pInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; @@ -577,9 +577,15 @@ int32_t doOpenMultiwayMergeOperator(SOperatorInfo* pOperator) { tsortSetCompareGroupId(pInfo->pSortHandle, pInfo->groupSort); for (int32_t i = 0; i < pOperator->numOfDownstream; ++i) { + SOperatorInfo* pDownstream = pOperator->pDownstream[i]; + if (pDownstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_EXCHANGE) { + pDownstream->fpSet._openFn(pDownstream); + } + SSortSource* ps = taosMemoryCalloc(1, sizeof(SSortSource)); - ps->param = pOperator->pDownstream[i]; + ps->param = pDownstream; ps->onlyRef = true; + tsortAddSource(pInfo->pSortHandle, ps); } @@ -714,7 +720,6 @@ SSDataBlock* doMultiwayMerge(SOperatorInfo* pOperator) { } qDebug("start to merge final sorted rows, %s", GET_TASKID(pTaskInfo)); - SSDataBlock* pBlock = getMultiwaySortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, pInfo->matchInfo.pList, pOperator); if (pBlock != NULL) { pOperator->resultInfo.totalRows += pBlock->info.rows; @@ -781,7 +786,7 @@ SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, 0); SSDataBlock* pInputBlock = createDataBlockFromDescNode(pChildNode->pOutputDataBlockDesc); - initResultSizeInfo(&pOperator->resultInfo, 4096); + initResultSizeInfo(&pOperator->resultInfo, 1024); blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity); pInfo->groupSort = pMergePhyNode->groupSort; @@ -792,8 +797,8 @@ SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size pInfo->sortBufSize = pInfo->bufPageSize * (numStreams + 1); // one additional is reserved for merged result. setOperatorInfo(pOperator, "MultiwayMergeOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE, false, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = createOperatorFpSet(doOpenMultiwayMergeOperator, doMultiwayMerge, NULL, - destroyMultiwayMergeOperatorInfo, getMultiwayMergeExplainExecInfo); + pOperator->fpSet = createOperatorFpSet(openMultiwayMergeOperator, doMultiwayMerge, NULL, + destroyMultiwayMergeOperatorInfo, optrDefaultBufFn, getMultiwayMergeExplainExecInfo); code = appendDownstream(pOperator, downStreams, numStreams); if (code != TSDB_CODE_SUCCESS) { diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index 3d35326749..a88f673e0b 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -1335,7 +1335,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) { SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == pMsgSendInfo) { qError("%s prepare message %d failed", GET_TASKID(pTaskInfo), (int32_t)sizeof(SMsgSendInfo)); - pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; return NULL; } @@ -1437,7 +1437,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan setOperatorInfo(pOperator, "SysTableScanOperator", QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN, false, OP_NOT_OPENED, pInfo, pTaskInfo); pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock); - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doSysTableScan, NULL, destroySysScanOperator, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doSysTableScan, NULL, destroySysScanOperator, optrDefaultBufFn, NULL); return pOperator; _error: @@ -1874,78 +1874,80 @@ static void destroyBlockDistScanOperatorInfo(void* param) { } static int32_t initTableblockDistQueryCond(uint64_t uid, SQueryTableDataCond* pCond) { - memset(pCond, 0, sizeof(SQueryTableDataCond)); + memset(pCond, 0, sizeof(SQueryTableDataCond)); - pCond->order = TSDB_ORDER_ASC; - pCond->numOfCols = 1; - pCond->colList = taosMemoryCalloc(1, sizeof(SColumnInfo)); - if (pCond->colList == NULL) { - terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; - return terrno; - } + pCond->order = TSDB_ORDER_ASC; + pCond->numOfCols = 1; + pCond->colList = taosMemoryCalloc(1, sizeof(SColumnInfo)); + pCond->pSlotList = taosMemoryMalloc(sizeof(int32_t)); + if (pCond->colList == NULL || pCond->pSlotList == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return terrno; + } - pCond->colList->colId = 1; - pCond->colList->type = TSDB_DATA_TYPE_TIMESTAMP; - pCond->colList->bytes = sizeof(TSKEY); + pCond->colList->colId = 1; + pCond->colList->type = TSDB_DATA_TYPE_TIMESTAMP; + pCond->colList->bytes = sizeof(TSKEY); - pCond->twindows = (STimeWindow){.skey = INT64_MIN, .ekey = INT64_MAX}; - pCond->suid = uid; - pCond->type = TIMEWINDOW_RANGE_CONTAINED; - pCond->startVersion = -1; - pCond->endVersion = -1; + pCond->pSlotList[0] = 0; - return TSDB_CODE_SUCCESS; + pCond->twindows = (STimeWindow){.skey = INT64_MIN, .ekey = INT64_MAX}; + pCond->suid = uid; + pCond->type = TIMEWINDOW_RANGE_CONTAINED; + pCond->startVersion = -1; + pCond->endVersion = -1; + + return TSDB_CODE_SUCCESS; } SOperatorInfo* createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDistScanPhysiNode* pBlockScanNode, SExecTaskInfo* pTaskInfo) { - SBlockDistInfo* pInfo = taosMemoryCalloc(1, sizeof(SBlockDistInfo)); - SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); - if (pInfo == NULL || pOperator == NULL) { - pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; - goto _error; - } + SBlockDistInfo* pInfo = taosMemoryCalloc(1, sizeof(SBlockDistInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + if (pInfo == NULL || pOperator == NULL) { + pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; + goto _error; + } - { - SQueryTableDataCond cond = {0}; + pInfo->pResBlock = createDataBlockFromDescNode(pBlockScanNode->node.pOutputDataBlockDesc); + blockDataEnsureCapacity(pInfo->pResBlock, 1); - int32_t code = initTableblockDistQueryCond(pBlockScanNode->suid, &cond); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - STableListInfo* pTableListInfo = pTaskInfo->pTableInfoList; - size_t num = tableListGetSize(pTableListInfo); - void* pList = tableListGetInfo(pTableListInfo, 0); - - code = tsdbReaderOpen(readHandle->vnode, &cond, pList, num, &pInfo->pHandle, pTaskInfo->id.str); - cleanupQueryTableDataCond(&cond); - if (code != 0) { - goto _error; - } - } - - pInfo->readHandle = *readHandle; - pInfo->uid = pBlockScanNode->suid; - - pInfo->pResBlock = createDataBlockFromDescNode(pBlockScanNode->node.pOutputDataBlockDesc); - blockDataEnsureCapacity(pInfo->pResBlock, 1); - - int32_t numOfCols = 0; - SExprInfo* pExprInfo = createExprInfo(pBlockScanNode->pScanPseudoCols, NULL, &numOfCols); - int32_t code = initExprSupp(&pOperator->exprSupp, pExprInfo, numOfCols); + { + SQueryTableDataCond cond = {0}; + int32_t code = initTableblockDistQueryCond(pBlockScanNode->suid, &cond); if (code != TSDB_CODE_SUCCESS) { - goto _error; + goto _error; } - setOperatorInfo(pOperator, "DataBlockDistScanOperator", QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN, false, - OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doBlockInfoScan, NULL, destroyBlockDistScanOperatorInfo, NULL); - return pOperator; + STableListInfo* pTableListInfo = pTaskInfo->pTableInfoList; + size_t num = tableListGetSize(pTableListInfo); + void* pList = tableListGetInfo(pTableListInfo, 0); - _error: - taosMemoryFreeClear(pInfo); - taosMemoryFreeClear(pOperator); - return NULL; + code = tsdbReaderOpen(readHandle->vnode, &cond, pList, num, pInfo->pResBlock, &pInfo->pHandle, pTaskInfo->id.str); + cleanupQueryTableDataCond(&cond); + if (code != 0) { + goto _error; + } + } + + pInfo->readHandle = *readHandle; + pInfo->uid = pBlockScanNode->suid; + + int32_t numOfCols = 0; + SExprInfo* pExprInfo = createExprInfo(pBlockScanNode->pScanPseudoCols, NULL, &numOfCols); + int32_t code = initExprSupp(&pOperator->exprSupp, pExprInfo, numOfCols); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + setOperatorInfo(pOperator, "DataBlockDistScanOperator", QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN, false, + OP_NOT_OPENED, pInfo, pTaskInfo); + pOperator->fpSet = + createOperatorFpSet(optrDummyOpenFn, doBlockInfoScan, NULL, destroyBlockDistScanOperatorInfo, optrDefaultBufFn, NULL); + return pOperator; + +_error: + taosMemoryFreeClear(pInfo); + taosMemoryFreeClear(pOperator); + return NULL; } \ No newline at end of file diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index a66a5e7089..d30c1fbfa1 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -45,8 +45,18 @@ static void setNullRow(SSDataBlock* pBlock, SFillInfo* pFillInfo, int32_t rowInd if (pCol->notFillCol) { bool filled = fillIfWindowPseudoColumn(pFillInfo, pCol, pDstColInfo, rowIndex); if (!filled) { - SArray* p = FILL_IS_ASC_FILL(pFillInfo) ? pFillInfo->prev.pRowVal : pFillInfo->next.pRowVal; - SGroupKeys* pKey = taosArrayGet(p, i); + SRowVal* p = NULL; + if (FILL_IS_ASC_FILL(pFillInfo)) { + if (pFillInfo->prev.key != 0) { + p = &pFillInfo->prev; // prev has been set value + } else { // otherwise, use the value in the next row + p = &pFillInfo->next; + } + } else { + p = &pFillInfo->next; + } + + SGroupKeys* pKey = taosArrayGet(p->pRowVal, i); doSetVal(pDstColInfo, rowIndex, pKey); } } else { @@ -246,7 +256,10 @@ static void initBeforeAfterDataBuf(SFillInfo* pFillInfo) { static void saveColData(SArray* rowBuf, int32_t columnIndex, const char* src, bool isNull); -static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, int32_t rowIndex, SArray* pRow) { +static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, int32_t rowIndex, SRowVal* pRowVal) { + SColumnInfoData* pTsCol = taosArrayGet(pFillInfo->pSrcBlock->pDataBlock, pFillInfo->srcTsSlotId); + pRowVal->key = ((int64_t*)pTsCol->pData)[rowIndex]; + for (int32_t i = 0; i < pFillInfo->numOfCols; ++i) { int32_t type = pFillInfo->pFillCol[i].pExpr->pExpr->nodeType; if (type == QUERY_NODE_COLUMN || type == QUERY_NODE_OPERATOR || type == QUERY_NODE_FUNCTION) { @@ -257,7 +270,7 @@ static void copyCurrentRowIntoBuf(SFillInfo* pFillInfo, int32_t rowIndex, SArray bool isNull = colDataIsNull_s(pSrcCol, rowIndex); char* p = colDataGetData(pSrcCol, rowIndex); - saveColData(pRow, i, p, isNull); + saveColData(pRowVal->pRowVal, i, p, isNull); } else { ASSERT(0); } @@ -281,7 +294,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t // set the next value for interpolation if ((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) { - copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, pFillInfo->next.pRowVal); + copyCurrentRowIntoBuf(pFillInfo, pFillInfo->index, &pFillInfo->next); } if (((pFillInfo->currentKey < ts && ascFill) || (pFillInfo->currentKey > ts && !ascFill)) && @@ -303,7 +316,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t if (pFillInfo->type == TSDB_FILL_NEXT && (pFillInfo->index + 1) < pFillInfo->numOfRows) { int32_t nextRowIndex = pFillInfo->index + 1; - copyCurrentRowIntoBuf(pFillInfo, nextRowIndex, pFillInfo->next.pRowVal); + copyCurrentRowIntoBuf(pFillInfo, nextRowIndex, &pFillInfo->next); } // copy rows to dst buffer @@ -319,6 +332,9 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, SSDataBlock* pBlock, int32_t if (!colDataIsNull_s(pSrc, pFillInfo->index)) { colDataAppend(pDst, index, src, false); saveColData(pFillInfo->prev.pRowVal, i, src, false); + if (pFillInfo->srcTsSlotId == dstSlotId) { + pFillInfo->prev.key = *(int64_t*)src; + } } else { // the value is null if (pDst->info.type == TSDB_DATA_TYPE_TIMESTAMP) { colDataAppend(pDst, index, (const char*)&pFillInfo->currentKey, false); diff --git a/source/libs/executor/src/timesliceoperator.c b/source/libs/executor/src/timesliceoperator.c index 90f5dde7c3..2374d80bbf 100644 --- a/source/libs/executor/src/timesliceoperator.c +++ b/source/libs/executor/src/timesliceoperator.c @@ -544,7 +544,7 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode setOperatorInfo(pOperator, "TimeSliceOperator", QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC, false, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTimeslice, NULL, destroyTimeSliceOperatorInfo, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doTimeslice, NULL, destroyTimeSliceOperatorInfo, optrDefaultBufFn, NULL); blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity); diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index f2c2e24a41..d9a011a892 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -648,7 +648,7 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num int32_t ret = setTimeWindowOutputBuf(pResultRowInfo, &w, (scanFlag == MAIN_SCAN), &pResult, groupId, pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } ASSERT(!isResultRowInterpolated(pResult, RESULT_ROW_END_INTERP)); @@ -927,7 +927,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul int32_t ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } TSKEY ekey = ascScan ? win.ekey : win.skey; int32_t forwardRows = @@ -943,7 +943,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } // window start key interpolation @@ -967,7 +967,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul int32_t code = setTimeWindowOutputBuf(pResultRowInfo, &nextWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); if (code != TSDB_CODE_SUCCESS || pResult == NULL) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } ekey = ascScan ? nextWin.ekey : nextWin.skey; @@ -1049,14 +1049,14 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) { return TSDB_CODE_SUCCESS; } - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SOperatorInfo* downstream = pOperator->pDownstream[0]; + SIntervalAggOperatorInfo* pInfo = pOperator->info; SExprSupp* pSup = &pOperator->exprSupp; int32_t scanFlag = MAIN_SCAN; - - int64_t st = taosGetTimestampUs(); - SOperatorInfo* downstream = pOperator->pDownstream[0]; + int64_t st = taosGetTimestampUs(); while (1) { SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); @@ -1150,7 +1150,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI int32_t ret = setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &window, masterScan, &pResult, gid, pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_APP_ERROR); } updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &window, false); @@ -1175,7 +1175,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI int32_t ret = setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &pRowSup->win, masterScan, &pResult, gid, pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_APP_ERROR); } updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pRowSup->win, false); @@ -1268,15 +1268,11 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator) { } SSDataBlock* pBlock = pInfo->binfo.pRes; - - ASSERT(pInfo->execModel == OPTR_EXEC_MODEL_BATCH); - pTaskInfo->code = pOperator->fpSet._openFn(pOperator); if (pTaskInfo->code != TSDB_CODE_SUCCESS) { return NULL; } - blockDataEnsureCapacity(pBlock, pOperator->resultInfo.capacity); while (1) { doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); doFilter(pBlock, pOperator->exprSupp.pFilterInfo, NULL); @@ -1649,23 +1645,34 @@ static bool allInvertible(SqlFunctionCtx* pFCtx, int32_t numOfCols) { static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SIntervalAggOperatorInfo* pInfo) { // the primary timestamp column bool needed = false; - pInfo->pInterpCols = taosArrayInit(4, sizeof(SColumn)); - pInfo->pPrevValues = taosArrayInit(4, sizeof(SGroupKeys)); - { // ts column - SColumn c = {0}; - c.colId = 1; - c.slotId = pInfo->primaryTsIndex; - c.type = TSDB_DATA_TYPE_TIMESTAMP; - c.bytes = sizeof(int64_t); - taosArrayPush(pInfo->pInterpCols, &c); + for(int32_t i = 0; i < numOfCols; ++i) { + SExprInfo* pExpr = pCtx[i].pExpr; + if (fmIsIntervalInterpoFunc(pCtx[i].functionId)) { + needed = true; + break; + } + } - SGroupKeys key = {0}; - key.bytes = c.bytes; - key.type = c.type; - key.isNull = true; // to denote no value is assigned yet - key.pData = taosMemoryCalloc(1, c.bytes); - taosArrayPush(pInfo->pPrevValues, &key); + if (needed) { + pInfo->pInterpCols = taosArrayInit(4, sizeof(SColumn)); + pInfo->pPrevValues = taosArrayInit(4, sizeof(SGroupKeys)); + + { // ts column + SColumn c = {0}; + c.colId = 1; + c.slotId = pInfo->primaryTsIndex; + c.type = TSDB_DATA_TYPE_TIMESTAMP; + c.bytes = sizeof(int64_t); + taosArrayPush(pInfo->pInterpCols, &c); + + SGroupKeys key; + key.bytes = c.bytes; + key.type = c.type; + key.isNull = true; // to denote no value is assigned yet + key.pData = taosMemoryCalloc(1, c.bytes); + taosArrayPush(pInfo->pPrevValues, &key); + } } for (int32_t i = 0; i < numOfCols; ++i) { @@ -1676,7 +1683,6 @@ static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SInt SColumn c = *pParam->pCol; taosArrayPush(pInfo->pInterpCols, &c); - needed = true; SGroupKeys key = {0}; key.bytes = c.bytes; @@ -1708,7 +1714,7 @@ void initIntervalDownStream(SOperatorInfo* downstream, uint16_t type, SAggSuppor void initStreamFunciton(SqlFunctionCtx* pCtx, int32_t numOfExpr) { for (int32_t i = 0; i < numOfExpr; i++) { - pCtx[i].isStream = true; +// pCtx[i].isStream = true; } } @@ -1727,7 +1733,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh pInfo->primaryTsIndex = ((SColumnNode*)pPhyNode->window.pTspk)->slotId; size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; - initResultSizeInfo(&pOperator->resultInfo, 4096); + initResultSizeInfo(&pOperator->resultInfo, 512); + blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity); int32_t num = 0; SExprInfo* pExprInfo = createExprInfo(pPhyNode->window.pFuncs, NULL, &num); @@ -1755,7 +1762,6 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh pInfo->inputOrder = (pPhyNode->window.inputTsOrder == ORDER_ASC) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC; pInfo->resultTsOrder = (pPhyNode->window.outputTsOrder == ORDER_ASC) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC; pInfo->interval = interval; - pInfo->execModel = pTaskInfo->execModel; pInfo->twAggSup = as; pInfo->binfo.mergeResultBlock = pPhyNode->window.mergeDataBlock; @@ -1773,11 +1779,6 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh goto _error; } - if (isStream) { - ASSERT(num > 0); - initStreamFunciton(pSup->pCtx, pSup->numOfExprs); - } - initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pInfo->win); pInfo->timeWindowInterpo = timeWindowinterpNeeded(pSup->pCtx, num, pInfo); if (pInfo->timeWindowInterpo) { @@ -1792,7 +1793,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh pInfo, pTaskInfo); pOperator->fpSet = - createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, NULL, destroyIntervalOperatorInfo, NULL); + createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, NULL, destroyIntervalOperatorInfo, optrDefaultBufFn, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -1854,7 +1855,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator int32_t ret = setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &window, masterScan, &pResult, gid, pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_APP_ERROR); } // pInfo->numOfRows data belong to the current session window @@ -1873,7 +1874,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator int32_t ret = setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &pRowSup->win, masterScan, &pResult, gid, pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_APP_ERROR); } updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pRowSup->win, false); @@ -2010,7 +2011,7 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi setOperatorInfo(pOperator, "StateWindowOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE, true, OP_NOT_OPENED, pInfo, pTaskInfo); pOperator->fpSet = - createOperatorFpSet(openStateWindowAggOptr, doStateWindowAgg, NULL, destroyStateWindowOperatorInfo, NULL); + createOperatorFpSet(openStateWindowAggOptr, doStateWindowAgg, NULL, destroyStateWindowOperatorInfo, optrDefaultBufFn, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -2083,7 +2084,7 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SSessionW setOperatorInfo(pOperator, "SessionWindowAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION, true, OP_NOT_OPENED, pInfo, pTaskInfo); pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doSessionWindowAgg, NULL, destroySWindowOperatorInfo, NULL); + createOperatorFpSet(optrDummyOpenFn, doSessionWindowAgg, NULL, destroySWindowOperatorInfo, optrDefaultBufFn, NULL); pOperator->pTaskInfo = pTaskInfo; code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -2163,7 +2164,7 @@ static void rebuildIntervalWindow(SOperatorInfo* pOperator, SArray* pWinArray, S int32_t code = setOutputBuf(pInfo->pState, &parentWin, &pCurResult, pWinRes->groupId, pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup); if (code != TSDB_CODE_SUCCESS || pCurResult == NULL) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } } num++; @@ -2402,7 +2403,7 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p int32_t code = setOutputBuf(pInfo->pState, &nextWin, &pResult, groupId, pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup); if (code != TSDB_CODE_SUCCESS || pResult == NULL) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } if (IS_FINAL_OP(pInfo)) { @@ -2516,9 +2517,11 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); if (pBlock == NULL) { pOperator->status = OP_RES_TO_RETURN; - qDebug("%s return data", IS_FINAL_OP(pInfo) ? "interval final" : "interval semi"); + qDebug("===stream===return data:%s. recv datablock num:%" PRIu64 , IS_FINAL_OP(pInfo) ? "interval final" : "interval semi", pInfo->numOfDatapack); + pInfo->numOfDatapack = 0; break; } + pInfo->numOfDatapack++; printDataBlock(pBlock, IS_FINAL_OP(pInfo) ? "interval final recv" : "interval semi recv"); ASSERT(pBlock->info.type != STREAM_INVERT); @@ -2571,7 +2574,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { for (int32_t i = 0; i < chIndex + 1 - size; i++) { SOperatorInfo* pChildOp = createStreamFinalIntervalOperatorInfo(NULL, pInfo->pPhyNode, pOperator->pTaskInfo, 0); if (!pChildOp) { - T_LONG_JMP(pOperator->pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pOperator->pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } SStreamIntervalOperatorInfo* pTmpInfo = pChildOp->info; pTmpInfo->twAggSup.calTrigger = STREAM_TRIGGER_AT_ONCE; @@ -2734,6 +2737,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, pInfo->pDelWins = taosArrayInit(4, sizeof(SWinKey)); pInfo->delKey.ts = INT64_MAX; pInfo->delKey.groupId = 0; + pInfo->numOfDatapack = 0; pOperator->operatorType = pPhyNode->type; pOperator->blocking = true; @@ -2741,7 +2745,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, pOperator->info = pInfo; pOperator->fpSet = - createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, destroyStreamFinalIntervalOperatorInfo, NULL); + createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, destroyStreamFinalIntervalOperatorInfo, optrDefaultBufFn, NULL); if (pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL) { initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, &pInfo->twAggSup); } @@ -2996,7 +3000,7 @@ static int32_t doOneWindowAggImpl(SColumnInfoData* pTimeWindowData, SResultWindo SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; int32_t code = initSessionOutputBuf(pCurWin, pResult, pSup->pCtx, numOutput, pSup->rowEntryInfoOffset); if (code != TSDB_CODE_SUCCESS || (*pResult) == NULL) { - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } updateTimeWindowInfo(pTimeWindowData, &pCurWin->sessionWin.win, false); applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, pTimeWindowData, startIndex, winRows, rows, numOutput); @@ -3105,13 +3109,13 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData pAggSup->pResultRows, pStUpdated, pStDeleted); // coverity scan error if (!winInfo.pOutputBuf) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } code = doOneWindowAggImpl(&pInfo->twAggSup.timeWindowData, &winInfo, &pResult, i, winRows, rows, numOfOutput, pOperator); if (code != TSDB_CODE_SUCCESS || pResult == NULL) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } compactSessionWindow(pOperator, &winInfo, pStUpdated, pStDeleted); saveSessionOutputBuf(pAggSup, &winInfo); @@ -3119,7 +3123,7 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pStUpdated) { code = saveResult(winInfo, pStUpdated); if (code != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } } if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) { @@ -3443,7 +3447,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { SOperatorInfo* pChildOp = createStreamFinalSessionAggOperatorInfo(NULL, pInfo->pPhyNode, pOperator->pTaskInfo, 0); if (!pChildOp) { - T_LONG_JMP(pOperator->pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pOperator->pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } taosArrayPush(pInfo->pChildren, &pChildOp); } @@ -3553,7 +3557,7 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh setOperatorInfo(pOperator, "StreamSessionWindowAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION, true, OP_NOT_OPENED, pInfo, pTaskInfo); pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doStreamSessionAgg, NULL, destroyStreamSessionAggOperatorInfo, NULL); + createOperatorFpSet(optrDummyOpenFn, doStreamSessionAgg, NULL, destroyStreamSessionAggOperatorInfo, optrDefaultBufFn, NULL); if (downstream) { initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup); @@ -3697,8 +3701,8 @@ SOperatorInfo* createStreamFinalSessionAggOperatorInfo(SOperatorInfo* downstream if (pPhyNode->type != QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION) { pInfo->pUpdateRes = createSpecialDataBlock(STREAM_CLEAR); blockDataEnsureCapacity(pInfo->pUpdateRes, 128); - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamSessionSemiAgg, NULL, - destroyStreamSessionAggOperatorInfo, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doStreamSessionSemiAgg, NULL, + destroyStreamSessionAggOperatorInfo, optrDefaultBufFn, NULL); } setOperatorInfo(pOperator, name, pPhyNode->type, false, OP_NOT_OPENED, pInfo, pTaskInfo); @@ -3886,14 +3890,14 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl code = doOneWindowAggImpl(&pInfo->twAggSup.timeWindowData, &curWin.winInfo, &pResult, i, winRows, rows, numOfOutput, pOperator); if (code != TSDB_CODE_SUCCESS || pResult == NULL) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } saveSessionOutputBuf(pAggSup, &curWin.winInfo); if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) { code = saveResult(curWin.winInfo, pSeUpdated); if (code != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } } @@ -4058,7 +4062,7 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys setOperatorInfo(pOperator, "StreamStateAggOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE, true, OP_NOT_OPENED, pInfo, pTaskInfo); pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doStreamStateAgg, NULL, destroyStreamStateOperatorInfo, NULL); + createOperatorFpSet(optrDummyOpenFn, doStreamStateAgg, NULL, destroyStreamStateOperatorInfo, optrDefaultBufFn, NULL); initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -4306,12 +4310,11 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, iaInfo->win = pTaskInfo->window; iaInfo->inputOrder = TSDB_ORDER_ASC; iaInfo->interval = interval; - iaInfo->execModel = pTaskInfo->execModel; iaInfo->primaryTsIndex = ((SColumnNode*)pNode->window.pTspk)->slotId; iaInfo->binfo.mergeResultBlock = pNode->window.mergeDataBlock; size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; - initResultSizeInfo(&pOperator->resultInfo, 4096); + initResultSizeInfo(&pOperator->resultInfo, 512); int32_t num = 0; SExprInfo* pExprInfo = createExprInfo(pNode->window.pFuncs, NULL, &num); @@ -4336,7 +4339,7 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, false, OP_NOT_OPENED, miaInfo, pTaskInfo); pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, mergeAlignedIntervalAgg, NULL, destroyMAIOperatorInfo, NULL); + createOperatorFpSet(optrDummyOpenFn, mergeAlignedIntervalAgg, NULL, destroyMAIOperatorInfo, optrDefaultBufFn, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -4445,7 +4448,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx, numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } TSKEY ekey = ascScan ? win.ekey : win.skey; @@ -4462,7 +4465,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx, numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } // window start key interpolation @@ -4491,7 +4494,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* setTimeWindowOutputBuf(pResultRowInfo, &nextWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx, numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); if (code != TSDB_CODE_SUCCESS || pResult == NULL) { - T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } ekey = ascScan ? nextWin.ekey : nextWin.skey; @@ -4612,7 +4615,6 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge pIntervalInfo->win = pTaskInfo->window; pIntervalInfo->inputOrder = TSDB_ORDER_ASC; pIntervalInfo->interval = interval; - pIntervalInfo->execModel = pTaskInfo->execModel; pIntervalInfo->binfo.mergeResultBlock = pIntervalPhyNode->window.mergeDataBlock; pIntervalInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId; @@ -4642,7 +4644,7 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge setOperatorInfo(pOperator, "TimeMergeIntervalAggOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL, false, OP_NOT_OPENED, pMergeIntervalInfo, pTaskInfo); pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doMergeIntervalAgg, NULL, destroyMergeIntervalOperatorInfo, NULL); + createOperatorFpSet(optrDummyOpenFn, doMergeIntervalAgg, NULL, destroyMergeIntervalOperatorInfo, optrDefaultBufFn, NULL); code = appendDownstream(pOperator, &downstream, 1); if (code != TSDB_CODE_SUCCESS) { @@ -4700,8 +4702,11 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { while (1) { SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); if (pBlock == NULL) { + qDebug("===stream===return data:single interval. recv datablock num:%" PRIu64, pInfo->numOfDatapack); + pInfo->numOfDatapack = 0; break; } + pInfo->numOfDatapack++; printDataBlock(pBlock, "single interval recv"); if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT || @@ -4851,11 +4856,12 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys pInfo->pChildren = NULL; pInfo->delKey.ts = INT64_MAX; pInfo->delKey.groupId = 0; + pInfo->numOfDatapack = 0; setOperatorInfo(pOperator, "StreamIntervalOperator", QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL, true, OP_NOT_OPENED, pInfo, pTaskInfo); - pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doStreamIntervalAgg, NULL, destroyStreamFinalIntervalOperatorInfo, NULL); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doStreamIntervalAgg, NULL, + destroyStreamFinalIntervalOperatorInfo, optrDefaultBufFn, NULL); initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, &pInfo->twAggSup); code = appendDownstream(pOperator, &downstream, 1); diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index d5a2f77175..30911887bb 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -34,14 +34,12 @@ struct SSortHandle { int32_t pageSize; int32_t numOfPages; SDiskbasedBuf* pBuf; - - SArray* pSortInfo; - SArray* pOrderedSource; - - int32_t loops; - uint64_t sortElapsed; - int64_t startTs; - uint64_t totalElapsed; + SArray* pSortInfo; + SArray* pOrderedSource; + int32_t loops; + uint64_t sortElapsed; + int64_t startTs; + uint64_t totalElapsed; int32_t sourceId; SSDataBlock* pDataBlock; @@ -99,9 +97,9 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t page } static int32_t sortComparCleanup(SMsortComparParam* cmpParam) { + // NOTICE: pSource may be, if it is SORT_MULTISOURCE_MERGE for (int32_t i = 0; i < cmpParam->numOfSources; ++i) { - SSortSource* pSource = - cmpParam->pSources[i]; // NOTICE: pSource may be SGenericSource *, if it is SORT_MULTISOURCE_MERGE + SSortSource* pSource = cmpParam->pSources[i]; blockDataDestroy(pSource->src.pBlock); taosMemoryFreeClear(pSource); } @@ -158,7 +156,7 @@ static int32_t doAddNewExternalMemSource(SDiskbasedBuf* pBuf, SArray* pAllSource SSortSource* pSource = taosMemoryCalloc(1, sizeof(SSortSource)); if (pSource == NULL) { taosArrayDestroy(pPageIdList); - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } pSource->src.pBlock = pBlock; @@ -231,15 +229,15 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) { return doAddNewExternalMemSource(pHandle->pBuf, pHandle->pOrderedSource, pBlock, &pHandle->sourceId, pPageIdList); } -static void setCurrentSourceIsDone(SSortSource* pSource, SSortHandle* pHandle) { +static void setCurrentSourceDone(SSortSource* pSource, SSortHandle* pHandle) { pSource->src.rowIndex = -1; ++pHandle->numOfCompletedSources; } -static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int32_t startIndex, int32_t endIndex, +static int32_t sortComparInit(SMsortComparParam* pParam, SArray* pSources, int32_t startIndex, int32_t endIndex, SSortHandle* pHandle) { - cmpParam->pSources = taosArrayGet(pSources, startIndex); - cmpParam->numOfSources = (endIndex - startIndex + 1); + pParam->pSources = taosArrayGet(pSources, startIndex); + pParam->numOfSources = (endIndex - startIndex + 1); int32_t code = 0; @@ -247,7 +245,7 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int if (pHandle->pBuf == NULL) { if (!osTempSpaceAvailable()) { code = TSDB_CODE_NO_AVAIL_DISK; - qError("Sort compare init failed since %s", terrstr(code)); + qError("Sort compare init failed since %s, %s", terrstr(code), pHandle->idStr); return code; } @@ -260,12 +258,12 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int } if (pHandle->type == SORT_SINGLESOURCE_SORT) { - for (int32_t i = 0; i < cmpParam->numOfSources; ++i) { - SSortSource* pSource = cmpParam->pSources[i]; + for (int32_t i = 0; i < pParam->numOfSources; ++i) { + SSortSource* pSource = pParam->pSources[i]; // set current source is done if (taosArrayGetSize(pSource->pageIdList) == 0) { - setCurrentSourceIsDone(pSource, pHandle); + setCurrentSourceDone(pSource, pHandle); continue; } @@ -280,15 +278,21 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int releaseBufPage(pHandle->pBuf, pPage); } } else { - for (int32_t i = 0; i < cmpParam->numOfSources; ++i) { - SSortSource* pSource = cmpParam->pSources[i]; + qDebug("start init for the multiway merge sort, %s", pHandle->idStr); + int64_t st = taosGetTimestampUs(); + + for (int32_t i = 0; i < pParam->numOfSources; ++i) { + SSortSource* pSource = pParam->pSources[i]; pSource->src.pBlock = pHandle->fetchfp(pSource->param); // set current source is done if (pSource->src.pBlock == NULL) { - setCurrentSourceIsDone(pSource, pHandle); + setCurrentSourceDone(pSource, pHandle); } } + + int64_t et = taosGetTimestampUs(); + qDebug("init for merge sort completed, elapsed time:%.2f ms, %s", (et - st) / 1000.0, pHandle->idStr); } return code; diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index fe010786eb..a2a827e7e5 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -2080,6 +2080,11 @@ static int32_t translateTagsPseudoColumn(SFunctionNode* pFunc, char* pErrBuf, in return TSDB_CODE_SUCCESS; } +static int32_t translateTableCountPseudoColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT}; + return TSDB_CODE_SUCCESS; +} + // clang-format off const SBuiltinFuncDefinition funcMgtBuiltins[] = { { @@ -3241,6 +3246,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .sprocessFunc = NULL, .finalizeFunc = NULL }, + { + .name = "_table_count", + .type = FUNCTION_TYPE_TABLE_COUNT, + .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_SCAN_PC_FUNC, + .translateFunc = translateTableCountPseudoColumn, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = NULL, + .finalizeFunc = NULL + }, }; // clang-format on diff --git a/source/libs/function/src/detail/tavgfunction.c b/source/libs/function/src/detail/tavgfunction.c index f06bafafe3..1c74d22a82 100644 --- a/source/libs/function/src/detail/tavgfunction.c +++ b/source/libs/function/src/detail/tavgfunction.c @@ -270,7 +270,7 @@ static void i64VectorSumAVX2(const int64_t* plist, int32_t numOfRows, SAvgRes* p #if __AVX2__ // find the start position that are aligned to 32bytes address in memory - int32_t width = (bitWidth>>3u) / sizeof(int64_t); + int32_t width = (bitWidth >> 3u) / sizeof(int64_t); int32_t remainder = numOfRows % width; int32_t rounds = numOfRows / width; @@ -286,20 +286,11 @@ static void i64VectorSumAVX2(const int64_t* plist, int32_t numOfRows, SAvgRes* p } // let sum up the final results - if (type == TSDB_DATA_TYPE_BIGINT) { - const int64_t* q = (const int64_t*)∑ - pRes->sum.isum += q[0] + q[1] + q[2] + q[3]; + const int64_t* q = (const int64_t*)∑ + pRes->sum.isum += q[0] + q[1] + q[2] + q[3]; - for (int32_t j = 0; j < remainder; ++j) { - pRes->sum.isum += plist[j + rounds * width]; - } - } else { - const uint64_t* q = (const uint64_t*)∑ - pRes->sum.usum += q[0] + q[1] + q[2] + q[3]; - - for (int32_t j = 0; j < remainder; ++j) { - pRes->sum.usum += (uint64_t)plist[j + rounds * width]; - } + for (int32_t j = 0; j < remainder; ++j) { + pRes->sum.isum += plist[j + rounds * width]; } #endif @@ -588,14 +579,14 @@ int32_t avgFunction(SqlFunctionCtx* pCtx) { const int64_t* plist = (const int64_t*) pCol->pData; // 1. If the CPU supports AVX, let's employ AVX instructions to speedup this loop - if (simdAvailable) { + if (simdAvailable && type == TSDB_DATA_TYPE_BIGINT) { i64VectorSumAVX2(plist, numOfRows, pAvgRes); } else { for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; ++i) { if (type == TSDB_DATA_TYPE_BIGINT) { pAvgRes->sum.isum += plist[i]; } else { - pAvgRes->sum.isum += (uint64_t)plist[i]; + pAvgRes->sum.usum += (uint64_t)plist[i]; } } } diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index d87df2d0f3..afadf7401d 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -419,7 +419,7 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { if (connectRsp.epSet.numOfEps == 0) { - msgInfo->code = TSDB_CODE_MND_APP_ERROR; + msgInfo->code = TSDB_CODE_APP_ERROR; goto _return; } @@ -598,9 +598,10 @@ int32_t udfdLoadUdf(char *udfName, SUdf *udf) { return 0; } static bool udfdRpcRfp(int32_t code, tmsg_t msgType) { - if (code == TSDB_CODE_RPC_REDIRECT || code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_NODE_NOT_DEPLOYED || - code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_APP_NOT_READY || code == TSDB_CODE_RPC_BROKEN_LINK) { - if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH || msgType == TDMT_SCH_MERGE_FETCH) { + if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_SYN_NOT_LEADER || + code == TSDB_CODE_SYN_RESTORING || code == TSDB_CODE_MNODE_NOT_FOUND || code == TSDB_CODE_APP_IS_STARTING || + code == TSDB_CODE_APP_IS_STOPPING) { + if (msgType == TDMT_SCH_QUERY || msgType == TDMT_SCH_MERGE_QUERY || msgType == TDMT_SCH_FETCH || msgType == TDMT_SCH_MERGE_FETCH) { return false; } return true; diff --git a/source/libs/index/src/indexFilter.c b/source/libs/index/src/indexFilter.c index 72828e1daa..5a86bc8678 100644 --- a/source/libs/index/src/indexFilter.c +++ b/source/libs/index/src/indexFilter.c @@ -195,7 +195,7 @@ static FORCE_INLINE int32_t sifGetValueFromNode(SNode *node, char **value) { } char *tv = taosMemoryCalloc(1, valLen + 1); if (tv == NULL) { - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } memcpy(tv, pData, valLen); @@ -259,7 +259,7 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) { if (taosHashPut(ctx->pRes, &node, POINTER_BYTES, param, sizeof(*param))) { taosHashCleanup(param->pFilter); indexError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param)); - SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SIF_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } break; } @@ -269,7 +269,7 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) { SIFParam *res = (SIFParam *)taosHashGet(ctx->pRes, &node, POINTER_BYTES); if (NULL == res) { indexError("no result for node, type:%d, node:%p", nodeType(node), node); - SIF_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + SIF_ERR_RET(TSDB_CODE_APP_ERROR); } *param = *res; break; @@ -300,7 +300,7 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx SIFParam *paramList = taosMemoryCalloc(nParam, sizeof(SIFParam)); if (NULL == paramList) { - SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SIF_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } if (nodeType(node->pLeft) == QUERY_NODE_OPERATOR && @@ -319,7 +319,7 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx SIF_ERR_JRET(sifInitParam(node->pRight, ¶mList[1], ctx)); // if (paramList[0].colValType == TSDB_DATA_TYPE_JSON && // ((SOperatorNode *)(node))->opType == OP_TYPE_JSON_CONTAINS) { - // return TSDB_CODE_QRY_OUT_OF_MEMORY; + // return TSDB_CODE_OUT_OF_MEMORY; //} } *params = paramList; @@ -335,7 +335,7 @@ static int32_t sifInitParamList(SIFParam **params, SNodeList *nodeList, SIFCtx * SIFParam *tParams = taosMemoryCalloc(nodeList->length, sizeof(SIFParam)); if (tParams == NULL) { indexError("failed to calloc, nodeList: %p", nodeList); - SIF_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SIF_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } SListCell *cell = nodeList->pHead; @@ -464,7 +464,7 @@ static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFP SIndexTerm *tm = indexTermCreate(arg->suid, DEFAULT, right->colValType, left->colName, strlen(left->colName), right->condValue, strlen(right->condValue)); if (tm == NULL) { - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } SIndexMultiTermQuery *mtm = indexMultiTermQueryCreate(MUST); @@ -722,7 +722,7 @@ static EDealRes sifWalkFunction(SNode *pNode, void *context) { } if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) { - ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + ctx->code = TSDB_CODE_OUT_OF_MEMORY; return DEAL_RES_ERROR; } return DEAL_RES_CONTINUE; @@ -740,7 +740,7 @@ static EDealRes sifWalkLogic(SNode *pNode, void *context) { } if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) { - ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + ctx->code = TSDB_CODE_OUT_OF_MEMORY; return DEAL_RES_ERROR; } return DEAL_RES_CONTINUE; @@ -756,7 +756,7 @@ static EDealRes sifWalkOper(SNode *pNode, void *context) { return DEAL_RES_ERROR; } if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) { - ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + ctx->code = TSDB_CODE_OUT_OF_MEMORY; return DEAL_RES_ERROR; } @@ -807,7 +807,7 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) { if (NULL == ctx.pRes) { indexError("index-filter failed to taosHashInit"); - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } nodesWalkExprPostOrder(pNode, sifCalcWalker, &ctx); @@ -821,7 +821,7 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) { SIFParam *res = (SIFParam *)taosHashGet(ctx.pRes, (void *)&pNode, POINTER_BYTES); if (res == NULL) { indexError("no valid res in hash, node:(%p), type(%d)", (void *)&pNode, nodeType(pNode)); - SIF_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + SIF_ERR_RET(TSDB_CODE_APP_ERROR); } if (res->result != NULL) { taosArrayAddAll(pDst->result, res->result); @@ -844,7 +844,7 @@ static int32_t sifGetFltHint(SNode *pNode, SIdxFltStatus *status) { ctx.pRes = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); if (NULL == ctx.pRes) { indexError("index-filter failed to taosHashInit"); - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } nodesWalkExprPostOrder(pNode, sifCalcWalker, &ctx); @@ -856,7 +856,7 @@ static int32_t sifGetFltHint(SNode *pNode, SIdxFltStatus *status) { SIFParam *res = (SIFParam *)taosHashGet(ctx.pRes, (void *)&pNode, POINTER_BYTES); if (res == NULL) { indexError("no valid res in hash, node:(%p), type(%d)", (void *)&pNode, nodeType(pNode)); - SIF_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + SIF_ERR_RET(TSDB_CODE_APP_ERROR); } *status = res->status; sifFreeParam(res); diff --git a/source/libs/index/src/indexTfile.c b/source/libs/index/src/indexTfile.c index e002ff9c32..b34d05d297 100644 --- a/source/libs/index/src/indexTfile.c +++ b/source/libs/index/src/indexTfile.c @@ -269,7 +269,7 @@ static int32_t tfSearchPrefix(void* reader, SIndexTerm* tem, SIdxTRslt* tr) { if (ret != 0) { taosArrayDestroy(offsets); indexError("failed to find target tablelist"); - return TSDB_CODE_TDB_FILE_CORRUPTED; + return TSDB_CODE_FILE_CORRUPTED; } } taosArrayDestroy(offsets); diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 50e410b339..352e78c2fc 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -221,6 +221,8 @@ const char* nodesNodeName(ENodeType type) { return "PhysiTableScan"; case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: return "PhysiTableSeqScan"; + case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN: + return "PhysiTableMergeScan"; case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: return "PhysiSreamScan"; case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: @@ -229,8 +231,8 @@ const char* nodesNodeName(ENodeType type) { return "PhysiBlockDistScan"; case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: return "PhysiLastRowScan"; - case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN: - return "PhysiTableMergeScan"; + case QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN: + return "PhysiTableCountScan"; case QUERY_NODE_PHYSICAL_PLAN_PROJECT: return "PhysiProject"; case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN: @@ -4646,6 +4648,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: return physiScanNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: + case QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN: return physiLastRowScanNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN: @@ -4800,6 +4803,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { return jsonToLogicPlan(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: + case QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN: return jsonToPhysiScanNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: return jsonToPhysiLastRowScanNode(pJson, pObj); diff --git a/source/libs/nodes/src/nodesMsgFuncs.c b/source/libs/nodes/src/nodesMsgFuncs.c index 1e8ff8da1a..bf6cd33af7 100644 --- a/source/libs/nodes/src/nodesMsgFuncs.c +++ b/source/libs/nodes/src/nodesMsgFuncs.c @@ -3640,6 +3640,7 @@ static int32_t specificNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { code = physiScanNodeToMsg(pObj, pEncoder); break; case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: + case QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN: code = physiLastRowScanNodeToMsg(pObj, pEncoder); break; case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: @@ -3778,6 +3779,7 @@ static int32_t msgToSpecificNode(STlvDecoder* pDecoder, void* pObj) { code = msgToPhysiScanNode(pDecoder, pObj); break; case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: + case QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN: code = msgToPhysiLastRowScanNode(pDecoder, pObj); break; case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: diff --git a/source/libs/nodes/src/nodesToSQLFuncs.c b/source/libs/nodes/src/nodesToSQLFuncs.c index 9325d02886..0181da92a9 100644 --- a/source/libs/nodes/src/nodesToSQLFuncs.c +++ b/source/libs/nodes/src/nodesToSQLFuncs.c @@ -132,7 +132,7 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) { char *t = nodesGetStrValueFromNode(colNode); if (NULL == t) { nodesError("fail to get str value from valueNode"); - NODES_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + NODES_ERR_RET(TSDB_CODE_APP_ERROR); } int32_t tlen = strlen(t); @@ -229,5 +229,5 @@ int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) { } nodesError("nodesNodeToSQL unknown node = %s", nodesNodeName(pNode->type)); - NODES_RET(TSDB_CODE_QRY_APP_ERROR); + NODES_RET(TSDB_CODE_APP_ERROR); } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 8c1a85b101..de51e9d9f3 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -424,6 +424,7 @@ SNode* nodesMakeNode(ENodeType type) { case QUERY_NODE_SHOW_TRANSACTIONS_STMT: case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: case QUERY_NODE_SHOW_TAGS_STMT: + case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT: return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_SHOW_TABLE_TAGS_STMT: return makeNode(type, sizeof(SShowTableTagsStmt)); @@ -493,6 +494,8 @@ SNode* nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SBlockDistScanPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: return makeNode(type, sizeof(SLastRowScanPhysiNode)); + case QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN: + return makeNode(type, sizeof(STableCountScanPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_PROJECT: return makeNode(type, sizeof(SProjectPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN: @@ -943,7 +946,8 @@ void nodesDestroyNode(SNode* pNode) { case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: case QUERY_NODE_SHOW_TRANSACTIONS_STMT: case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: - case QUERY_NODE_SHOW_TAGS_STMT: { + case QUERY_NODE_SHOW_TAGS_STMT: + case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT: { SShowStmt* pStmt = (SShowStmt*)pNode; nodesDestroyNode(pStmt->pDbName); nodesDestroyNode(pStmt->pTbName); @@ -1118,6 +1122,7 @@ void nodesDestroyNode(SNode* pNode) { case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: + case QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN: destroyScanPhysiNode((SScanPhysiNode*)pNode); break; case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: { @@ -1558,7 +1563,7 @@ int32_t nodesSetValueNodeValue(SValueNode* pNode, void* value) { pNode->datum.p = (char*)value; break; default: - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } return TSDB_CODE_SUCCESS; diff --git a/source/libs/parser/inc/parUtil.h b/source/libs/parser/inc/parUtil.h index c53d3f9320..ce5a63f5d0 100644 --- a/source/libs/parser/inc/parUtil.h +++ b/source/libs/parser/inc/parUtil.h @@ -86,7 +86,7 @@ STableComInfo getTableInfo(const STableMeta* pTableMeta); STableMeta* tableMetaDup(const STableMeta* pTableMeta); int32_t trimString(const char* src, int32_t len, char* dst, int32_t dlen); -int32_t getInsTagsTableTargetName(int32_t acctId, SNode* pWhere, SName* pName); +int32_t getVnodeSysTableTargetName(int32_t acctId, SNode* pWhere, SName* pName); int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalogReq); int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMetaData, SParseMetaCache* pMetaCache); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index eb4f834096..6521161244 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -101,6 +101,7 @@ cmd ::= REVOKE privileges(A) ON priv_level(B) FROM user_name(C). %destructor privileges { } privileges(A) ::= ALL. { A = PRIVILEGE_TYPE_ALL; } privileges(A) ::= priv_type_list(B). { A = B; } +privileges(A) ::= SUBSCRIBE. { A = PRIVILEGE_TYPE_SUBSCRIBE; } %type priv_type_list { int64_t } %destructor priv_type_list { } @@ -116,6 +117,7 @@ priv_type(A) ::= WRITE. %destructor priv_level { } priv_level(A) ::= NK_STAR(B) NK_DOT NK_STAR. { A = B; } priv_level(A) ::= db_name(B) NK_DOT NK_STAR. { A = B; } +priv_level(A) ::= topic_name(B). { A = B; } /************************************************ create/drop/alter dnode *********************************************/ cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); } @@ -393,6 +395,7 @@ col_name(A) ::= column_name(B). /************************************************ show ****************************************************************/ cmd ::= SHOW DNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } cmd ::= SHOW USERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } +cmd ::= SHOW USER PRIVILEGES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); } cmd ::= SHOW DATABASES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } cmd ::= SHOW db_name_cond_opt(A) TABLES like_pattern_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, A, B, OP_TYPE_LIKE); } cmd ::= SHOW db_name_cond_opt(A) STABLES like_pattern_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, A, B, OP_TYPE_LIKE); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 6a8c79040d..40fb422c49 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -1815,7 +1815,7 @@ SNode* createGrantStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDbN SGrantStmt* pStmt = (SGrantStmt*)nodesMakeNode(QUERY_NODE_GRANT_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->privileges = privileges; - COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName); + COPY_STRING_FORM_ID_TOKEN(pStmt->objName, pDbName); COPY_STRING_FORM_ID_TOKEN(pStmt->userName, pUserName); return (SNode*)pStmt; } @@ -1828,7 +1828,7 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDb SRevokeStmt* pStmt = (SRevokeStmt*)nodesMakeNode(QUERY_NODE_REVOKE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->privileges = privileges; - COPY_STRING_FORM_ID_TOKEN(pStmt->dbName, pDbName); + COPY_STRING_FORM_ID_TOKEN(pStmt->objName, pDbName); COPY_STRING_FORM_ID_TOKEN(pStmt->userName, pUserName); return (SNode*)pStmt; } diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index 5aa87d780d..f90a42add3 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -140,7 +140,7 @@ static int32_t collectMetaKeyFromInsTagsImpl(SCollectMetaKeyCxt* pCxt, SName* pN static int32_t collectMetaKeyFromInsTags(SCollectMetaKeyCxt* pCxt) { SSelectStmt* pSelect = (SSelectStmt*)pCxt->pStmt; SName name = {0}; - int32_t code = getInsTagsTableTargetName(pCxt->pParseCxt->acctId, pSelect->pWhere, &name); + int32_t code = getVnodeSysTableTargetName(pCxt->pParseCxt->acctId, pSelect->pWhere, &name); if (TSDB_CODE_SUCCESS == code) { code = collectMetaKeyFromInsTagsImpl(pCxt, &name); } @@ -165,7 +165,8 @@ static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, const c if (TSDB_CODE_SUCCESS == code && (0 == strcmp(pTable, TSDB_INS_TABLE_DNODE_VARIABLES))) { code = reserveDnodeRequiredInCache(pCxt->pMetaCache); } - if (TSDB_CODE_SUCCESS == code && (0 == strcmp(pTable, TSDB_INS_TABLE_TAGS)) && + if (TSDB_CODE_SUCCESS == code && + (0 == strcmp(pTable, TSDB_INS_TABLE_TAGS) || 0 == strcmp(pTable, TSDB_INS_TABLE_TABLES)) && QUERY_NODE_SELECT_STMT == nodeType(pCxt->pStmt)) { code = collectMetaKeyFromInsTags(pCxt); } @@ -504,6 +505,11 @@ static int32_t collectMetaKeyFromShowVnodes(SCollectMetaKeyCxt* pCxt, SShowVnode pCxt->pMetaCache); } +static int32_t collectMetaKeyFromShowUserPrivileges(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { + return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_PRIVILEGES, + pCxt->pMetaCache); +} + static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SShowCreateDatabaseStmt* pStmt) { return reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache); } @@ -648,6 +654,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { return collectMetaKeyFromShowDnodeVariables(pCxt, (SShowDnodeVariablesStmt*)pStmt); case QUERY_NODE_SHOW_VNODES_STMT: return collectMetaKeyFromShowVnodes(pCxt, (SShowVnodesStmt*)pStmt); + case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT: + return collectMetaKeyFromShowUserPrivileges(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: return collectMetaKeyFromShowCreateDatabase(pCxt, (SShowCreateDatabaseStmt*)pStmt); case QUERY_NODE_SHOW_CREATE_TABLE_STMT: diff --git a/source/libs/parser/src/parInsertSml.c b/source/libs/parser/src/parInsertSml.c index e76ca7751d..358baa74cb 100644 --- a/source/libs/parser/src/parInsertSml.c +++ b/source/libs/parser/src/parInsertSml.c @@ -114,7 +114,7 @@ static int32_t smlBoundColumnData(SArray* cols, SParsedDataColInfo* pColList, SS if (!isOrdered) { pColList->colIdxInfo = taosMemoryCalloc(pColList->numOfBound, sizeof(SBoundIdxInfo)); if (NULL == pColList->colIdxInfo) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } SBoundIdxInfo* pColIdx = pColList->colIdxInfo; for (col_id_t i = 0; i < pColList->numOfBound; ++i) { @@ -150,11 +150,11 @@ static int32_t smlBuildTagRow(SArray* cols, SParsedDataColInfo* tags, SSchema* p SMsgBuf* msg) { SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal)); if (!pTagArray) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } *tagName = taosArrayInit(8, TSDB_COL_NAME_LEN); if (!*tagName) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } int32_t code = TSDB_CODE_SUCCESS; diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index 064e376894..df7a3953f2 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -236,7 +236,7 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, const char** pSql, b if (!isOrdered) { pColList->colIdxInfo = taosMemoryCalloc(pColList->numOfBound, sizeof(SBoundIdxInfo)); if (NULL == pColList->colIdxInfo) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } SBoundIdxInfo* pColIdx = pColList->colIdxInfo; for (col_id_t i = 0; i < pColList->numOfBound; ++i) { @@ -1261,7 +1261,7 @@ static int32_t allocateMemIfNeed(STableDataBlocks* pDataBlock, int32_t rowSize, // do nothing, if allocate more memory failed pDataBlock->nAllocSize = nAllocSizeOld; *numOfRows = (int32_t)(pDataBlock->nAllocSize - pDataBlock->headerSize) / rowSize; - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } } @@ -1524,7 +1524,7 @@ static int32_t checkTableClauseFirstToken(SInsertParseContext* pCxt, SVnodeModif static int32_t setStmtInfo(SInsertParseContext* pCxt, SVnodeModifOpStmt* pStmt) { SParsedDataColInfo* tags = taosMemoryMalloc(sizeof(pCxt->tags)); if (NULL == tags) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } memcpy(tags, &pCxt->tags, sizeof(pCxt->tags)); diff --git a/source/libs/parser/src/parInsertStmt.c b/source/libs/parser/src/parInsertStmt.c index e0e191b7c9..4ed72e6c14 100644 --- a/source/libs/parser/src/parInsertStmt.c +++ b/source/libs/parser/src/parInsertStmt.c @@ -50,7 +50,7 @@ int32_t qBindStmtTagsValue(void* pBlock, void* boundTags, int64_t suid, const ch int32_t code = TSDB_CODE_SUCCESS; SParsedDataColInfo* tags = (SParsedDataColInfo*)boundTags; if (NULL == tags) { - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal)); @@ -339,7 +339,7 @@ int32_t qBuildStmtTagFields(void* pBlock, void* boundTags, int32_t* fieldNum, TA STableDataBlocks* pDataBlock = (STableDataBlocks*)pBlock; SParsedDataColInfo* tags = (SParsedDataColInfo*)boundTags; if (NULL == tags) { - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } if (pDataBlock->pTableMeta->tableType != TSDB_SUPER_TABLE && pDataBlock->pTableMeta->tableType != TSDB_CHILD_TABLE) { diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index 0600accd6d..73cedfeb3d 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -198,7 +198,7 @@ static int32_t createDataBlock(size_t defaultSize, int32_t rowSize, int32_t star STableDataBlocks** dataBlocks) { STableDataBlocks* dataBuf = (STableDataBlocks*)taosMemoryCalloc(1, sizeof(STableDataBlocks)); if (dataBuf == NULL) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } dataBuf->nAllocSize = (uint32_t)defaultSize; @@ -212,7 +212,7 @@ static int32_t createDataBlock(size_t defaultSize, int32_t rowSize, int32_t star dataBuf->pData = taosMemoryMalloc(dataBuf->nAllocSize); if (dataBuf->pData == NULL) { taosMemoryFreeClear(dataBuf); - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } memset(dataBuf->pData, 0, sizeof(SSubmitBlk)); @@ -249,7 +249,7 @@ int32_t insBuildCreateTbMsg(STableDataBlocks* pBlocks, SVCreateTbReq* pCreateTbR memset(pBlocks->pData + pBlocks->size, 0, pBlocks->nAllocSize - pBlocks->size); } else { pBlocks->nAllocSize -= len + pBlocks->rowSize; - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } } @@ -350,7 +350,7 @@ static int sortRemoveDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* if (pBlkKeyInfo->pKeyTuple == NULL || pBlkKeyInfo->maxBytesAlloc < nAlloc) { char* tmp = taosMemoryRealloc(pBlkKeyInfo->pKeyTuple, nAlloc); if (tmp == NULL) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } pBlkKeyInfo->pKeyTuple = (SBlockKeyTuple*)tmp; pBlkKeyInfo->maxBytesAlloc = (int32_t)nAlloc; @@ -518,7 +518,7 @@ static int sortMergeDataBlockDupRows(STableDataBlocks* dataBuf, SBlockKeyInfo* p if (pBlkKeyInfo->pKeyTuple == NULL || pBlkKeyInfo->maxBytesAlloc < nAlloc) { char* tmp = taosMemoryRealloc(pBlkKeyInfo->pKeyTuple, nAlloc); if (tmp == NULL) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } pBlkKeyInfo->pKeyTuple = (SBlockKeyTuple*)tmp; pBlkKeyInfo->maxBytesAlloc = (int32_t)nAlloc; @@ -668,7 +668,7 @@ int32_t insMergeTableDataBlocks(SHashObj* pHashObj, SArray** pVgDataBlocks) { insDestroyBlockArrayList(pVnodeDataBlockList); taosMemoryFreeClear(dataBuf->pData); taosMemoryFreeClear(blkKeyInfo.pKeyTuple); - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } } @@ -721,7 +721,7 @@ int32_t insAllocateMemForSize(STableDataBlocks* pDataBlock, int32_t allSize) { } else { // do nothing, if allocate more memory failed pDataBlock->nAllocSize = nAllocSizeOld; - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } } @@ -938,13 +938,13 @@ int32_t insBuildOutput(SHashObj* pVgroupsHashObj, SArray* pVgDataBlocks, SArray* size_t numOfVg = taosArrayGetSize(pVgDataBlocks); *pDataBlocks = taosArrayInit(numOfVg, POINTER_BYTES); if (NULL == *pDataBlocks) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } for (size_t i = 0; i < numOfVg; ++i) { STableDataBlocks* src = taosArrayGetP(pVgDataBlocks, i); SVgDataBlocks* dst = taosMemoryCalloc(1, sizeof(SVgDataBlocks)); if (NULL == dst) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } taosHashGetDup(pVgroupsHashObj, (const char*)&src->vgId, sizeof(src->vgId), &dst->vg); dst->numOfTables = src->numOfTables; diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 88a1d39ff2..7123173161 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -161,6 +161,7 @@ static SKeyword keywordTable[] = { {"PPS", TK_PPS}, {"PRECISION", TK_PRECISION}, {"PREV", TK_PREV}, + {"PRIVILEGES", TK_PRIVILEGES}, {"QNODE", TK_QNODE}, {"QNODES", TK_QNODES}, {"QTIME", TK_QTIME}, @@ -202,6 +203,7 @@ static SKeyword keywordTable[] = { {"STREAM", TK_STREAM}, {"STREAMS", TK_STREAMS}, {"STRICT", TK_STRICT}, + {"SUBSCRIBE", TK_SUBSCRIBE}, {"SUBSCRIPTIONS", TK_SUBSCRIPTIONS}, {"SUBTABLE", TK_SUBTABLE}, {"SYSINFO", TK_SYSINFO}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 9632c097b7..049d18e20a 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -47,6 +47,7 @@ typedef struct STranslateContext { SParseMetaCache* pMetaCache; bool createStream; bool stableQuery; + bool showRewrite; } STranslateContext; typedef struct SFullDatabaseName { @@ -251,6 +252,12 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = { .numOfShowCols = 1, .pShowCols = {"*"} }, + { .showType = QUERY_NODE_SHOW_USER_PRIVILEGES_STMT, + .pDbName = TSDB_INFORMATION_SCHEMA_DB, + .pTableName = TSDB_INS_TABLE_USER_PRIVILEGES, + .numOfShowCols = 1, + .pShowCols = {"*"} + }, }; // clang-format on @@ -744,8 +751,8 @@ static bool isPrimaryKeyImpl(SNode* pExpr) { return (PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)pExpr)->colId); } else if (QUERY_NODE_FUNCTION == nodeType(pExpr)) { SFunctionNode* pFunc = (SFunctionNode*)pExpr; - if (FUNCTION_TYPE_SELECT_VALUE == pFunc->funcType || FUNCTION_TYPE_FIRST == pFunc->funcType || - FUNCTION_TYPE_LAST == pFunc->funcType) { + if (FUNCTION_TYPE_SELECT_VALUE == pFunc->funcType || FUNCTION_TYPE_GROUP_KEY == pFunc->funcType || + FUNCTION_TYPE_FIRST == pFunc->funcType || FUNCTION_TYPE_LAST == pFunc->funcType) { return isPrimaryKeyImpl(nodesListGetNode(pFunc->pParameterList, 0)); } else if (FUNCTION_TYPE_WSTART == pFunc->funcType || FUNCTION_TYPE_WEND == pFunc->funcType) { return true; @@ -2203,22 +2210,28 @@ static int32_t dnodeToVgroupsInfo(SArray* pDnodes, SVgroupsInfo** pVgsInfo) { } static bool sysTableFromVnode(const char* pTable) { - return (0 == strcmp(pTable, TSDB_INS_TABLE_TABLES)) || - (0 == strcmp(pTable, TSDB_INS_TABLE_TABLE_DISTRIBUTED) || (0 == strcmp(pTable, TSDB_INS_TABLE_TAGS))); + return ((0 == strcmp(pTable, TSDB_INS_TABLE_TABLES)) || (0 == strcmp(pTable, TSDB_INS_TABLE_TAGS))); } static bool sysTableFromDnode(const char* pTable) { return 0 == strcmp(pTable, TSDB_INS_TABLE_DNODE_VARIABLES); } -static int32_t getTagsTableVgroupListImpl(STranslateContext* pCxt, SName* pTargetName, SName* pName, - SArray** pVgroupList) { +static int32_t getVnodeSysTableVgroupListImpl(STranslateContext* pCxt, SName* pTargetName, SName* pName, + SArray** pVgroupList) { if (0 == pTargetName->type) { return getDBVgInfoImpl(pCxt, pName, pVgroupList); } + if (0 == strcmp(pTargetName->dbname, TSDB_INFORMATION_SCHEMA_DB) || + 0 == strcmp(pTargetName->dbname, TSDB_PERFORMANCE_SCHEMA_DB)) { + pTargetName->type = 0; + return TSDB_CODE_SUCCESS; + } + if (TSDB_DB_NAME_T == pTargetName->type) { int32_t code = getDBVgInfoImpl(pCxt, pTargetName, pVgroupList); - if (TSDB_CODE_MND_DB_NOT_EXIST == code || TSDB_CODE_MND_DB_IN_CREATING == code || - TSDB_CODE_MND_DB_IN_DROPPING == code) { + if (!pCxt->showRewrite && (TSDB_CODE_MND_DB_NOT_EXIST == code || TSDB_CODE_MND_DB_IN_CREATING == code || + TSDB_CODE_MND_DB_IN_DROPPING == code)) { + // system table query should not report errors code = TSDB_CODE_SUCCESS; } return code; @@ -2235,50 +2248,44 @@ static int32_t getTagsTableVgroupListImpl(STranslateContext* pCxt, SName* pTarge } } else if (TSDB_CODE_MND_DB_NOT_EXIST == code || TSDB_CODE_MND_DB_IN_CREATING == code || TSDB_CODE_MND_DB_IN_DROPPING == code) { + // system table query should not report errors code = TSDB_CODE_SUCCESS; } return code; } -static int32_t getTagsTableVgroupList(STranslateContext* pCxt, SName* pName, SArray** pVgroupList) { +static int32_t getVnodeSysTableVgroupList(STranslateContext* pCxt, SName* pName, SArray** pVgs, bool* pHasUserDbCond) { if (!isSelectStmt(pCxt->pCurrStmt)) { return TSDB_CODE_SUCCESS; } SSelectStmt* pSelect = (SSelectStmt*)pCxt->pCurrStmt; SName targetName = {0}; - int32_t code = getInsTagsTableTargetName(pCxt->pParseCxt->acctId, pSelect->pWhere, &targetName); + int32_t code = getVnodeSysTableTargetName(pCxt->pParseCxt->acctId, pSelect->pWhere, &targetName); if (TSDB_CODE_SUCCESS == code) { - code = getTagsTableVgroupListImpl(pCxt, &targetName, pName, pVgroupList); + code = getVnodeSysTableVgroupListImpl(pCxt, &targetName, pName, pVgs); } + *pHasUserDbCond = (0 != targetName.type && taosArrayGetSize(*pVgs) > 0); return code; } static int32_t setVnodeSysTableVgroupList(STranslateContext* pCxt, SName* pName, SRealTableNode* pRealTable) { - int32_t code = TSDB_CODE_SUCCESS; - SArray* vgroupList = NULL; - if (0 == strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TAGS)) { - code = getTagsTableVgroupList(pCxt, pName, &vgroupList); - } else if ('\0' != pRealTable->qualDbName[0]) { - if (0 != strcmp(pRealTable->qualDbName, TSDB_INFORMATION_SCHEMA_DB)) { - code = getDBVgInfo(pCxt, pRealTable->qualDbName, &vgroupList); - } - } else { - code = getDBVgInfoImpl(pCxt, pName, &vgroupList); - } + bool hasUserDbCond = false; + SArray* pVgs = NULL; + int32_t code = getVnodeSysTableVgroupList(pCxt, pName, &pVgs, &hasUserDbCond); if (TSDB_CODE_SUCCESS == code && 0 == strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TAGS) && - isSelectStmt(pCxt->pCurrStmt) && 0 == taosArrayGetSize(vgroupList)) { + isSelectStmt(pCxt->pCurrStmt) && 0 == taosArrayGetSize(pVgs)) { ((SSelectStmt*)pCxt->pCurrStmt)->isEmptyResult = true; } - if (TSDB_CODE_SUCCESS == code && 0 == strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TABLES)) { - code = addMnodeToVgroupList(&pCxt->pParseCxt->mgmtEpSet, &vgroupList); + if (TSDB_CODE_SUCCESS == code && 0 == strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TABLES) && !hasUserDbCond) { + code = addMnodeToVgroupList(&pCxt->pParseCxt->mgmtEpSet, &pVgs); } if (TSDB_CODE_SUCCESS == code) { - code = toVgroupsInfo(vgroupList, &pRealTable->pVgroupList); + code = toVgroupsInfo(pVgs, &pRealTable->pVgroupList); } - taosArrayDestroy(vgroupList); + taosArrayDestroy(pVgs); return code; } @@ -2303,30 +2310,39 @@ static int32_t setSysTableVgroupList(STranslateContext* pCxt, SName* pName, SRea } } +static int32_t setSuperTableVgroupList(STranslateContext* pCxt, SName* pName, SRealTableNode* pRealTable) { + SArray* vgroupList = NULL; + int32_t code = getDBVgInfoImpl(pCxt, pName, &vgroupList); + if (TSDB_CODE_SUCCESS == code) { + code = toVgroupsInfo(vgroupList, &pRealTable->pVgroupList); + } + taosArrayDestroy(vgroupList); + return code; +} + +static int32_t setNormalTableVgroupList(STranslateContext* pCxt, SName* pName, SRealTableNode* pRealTable) { + pRealTable->pVgroupList = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo)); + if (NULL == pRealTable->pVgroupList) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pRealTable->pVgroupList->numOfVgroups = 1; + return getTableHashVgroupImpl(pCxt, pName, pRealTable->pVgroupList->vgroups); +} + static int32_t setTableVgroupList(STranslateContext* pCxt, SName* pName, SRealTableNode* pRealTable) { if (pCxt->pParseCxt->topicQuery) { return TSDB_CODE_SUCCESS; } - int32_t code = TSDB_CODE_SUCCESS; if (TSDB_SUPER_TABLE == pRealTable->pMeta->tableType) { - SArray* vgroupList = NULL; - code = getDBVgInfoImpl(pCxt, pName, &vgroupList); - if (TSDB_CODE_SUCCESS == code) { - code = toVgroupsInfo(vgroupList, &pRealTable->pVgroupList); - } - taosArrayDestroy(vgroupList); - } else if (TSDB_SYSTEM_TABLE == pRealTable->pMeta->tableType) { - code = setSysTableVgroupList(pCxt, pName, pRealTable); - } else { - pRealTable->pVgroupList = taosMemoryCalloc(1, sizeof(SVgroupsInfo) + sizeof(SVgroupInfo)); - if (NULL == pRealTable->pVgroupList) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pRealTable->pVgroupList->numOfVgroups = 1; - code = getTableHashVgroupImpl(pCxt, pName, pRealTable->pVgroupList->vgroups); + return setSuperTableVgroupList(pCxt, pName, pRealTable); } - return code; + + if (TSDB_SYSTEM_TABLE == pRealTable->pMeta->tableType) { + return setSysTableVgroupList(pCxt, pName, pRealTable); + } + + return setNormalTableVgroupList(pCxt, pName, pRealTable); } static uint8_t getStmtPrecision(SNode* pStmt) { @@ -2360,7 +2376,6 @@ static bool isSingleTable(SRealTableNode* pRealTable) { int8_t tableType = pRealTable->pMeta->tableType; if (TSDB_SYSTEM_TABLE == tableType) { return 0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TABLES) && - 0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TABLE_DISTRIBUTED) && 0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_TAGS); } return (TSDB_CHILD_TABLE == tableType || TSDB_NORMAL_TABLE == tableType); @@ -5031,7 +5046,7 @@ static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt alterReq.sysInfo = pStmt->sysinfo; snprintf(alterReq.pass, sizeof(alterReq.pass), "%s", pStmt->password); if (NULL != pCxt->pParseCxt->db) { - snprintf(alterReq.dbname, sizeof(alterReq.dbname), "%s", pCxt->pParseCxt->db); + snprintf(alterReq.objname, sizeof(alterReq.objname), "%s", pCxt->pParseCxt->db); } return buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &alterReq); @@ -5667,7 +5682,7 @@ static int32_t readFromFile(char* pName, int32_t* len, char** buf) { if (s != *len) { taosCloseFile(&tfile); taosMemoryFreeClear(*buf); - return TSDB_CODE_TSC_APP_ERROR; + return TSDB_CODE_APP_ERROR; } taosCloseFile(&tfile); return TSDB_CODE_SUCCESS; @@ -5710,9 +5725,11 @@ static int32_t translateGrant(STranslateContext* pCxt, SGrantStmt* pStmt) { req.alterType = TSDB_ALTER_USER_ADD_READ_DB; } else if (PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_WRITE)) { req.alterType = TSDB_ALTER_USER_ADD_WRITE_DB; + } else if (PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_SUBSCRIBE)) { + req.alterType = TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC; } strcpy(req.user, pStmt->userName); - sprintf(req.dbname, "%d.%s", pCxt->pParseCxt->acctId, pStmt->dbName); + sprintf(req.objname, "%d.%s", pCxt->pParseCxt->acctId, pStmt->objName); return buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &req); } @@ -5726,9 +5743,11 @@ static int32_t translateRevoke(STranslateContext* pCxt, SRevokeStmt* pStmt) { req.alterType = TSDB_ALTER_USER_REMOVE_READ_DB; } else if (PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_WRITE)) { req.alterType = TSDB_ALTER_USER_REMOVE_WRITE_DB; + } else if (PRIVILEGE_TYPE_TEST_MASK(pStmt->privileges, PRIVILEGE_TYPE_SUBSCRIBE)) { + req.alterType = TSDB_ALTER_USER_REMOVE_SUBSCRIBE_TOPIC; } strcpy(req.user, pStmt->userName); - sprintf(req.dbname, "%d.%s", pCxt->pParseCxt->acctId, pStmt->dbName); + sprintf(req.objname, "%d.%s", pCxt->pParseCxt->acctId, pStmt->objName); return buildCmdMsg(pCxt, TDMT_MND_ALTER_USER, (FSerializeFunc)tSerializeSAlterUserReq, &req); } @@ -6286,6 +6305,7 @@ static int32_t rewriteShow(STranslateContext* pCxt, SQuery* pQuery) { code = createShowCondition((SShowStmt*)pQuery->pRoot, pStmt); } if (TSDB_CODE_SUCCESS == code) { + pCxt->showRewrite = true; pQuery->showRewrite = true; nodesDestroyNode(pQuery->pRoot); pQuery->pRoot = (SNode*)pStmt; @@ -6339,6 +6359,7 @@ static int32_t rewriteShowStableTags(STranslateContext* pCxt, SQuery* pQuery) { code = createShowTableTagsProjections(&pSelect->pProjectionList, &pShow->pTags); } if (TSDB_CODE_SUCCESS == code) { + pCxt->showRewrite = true; pQuery->showRewrite = true; pSelect->tagScan = true; nodesDestroyNode(pQuery->pRoot); @@ -6369,6 +6390,7 @@ static int32_t rewriteShowDnodeVariables(STranslateContext* pCxt, SQuery* pQuery } } if (TSDB_CODE_SUCCESS == code) { + pCxt->showRewrite = true; pQuery->showRewrite = true; nodesDestroyNode(pQuery->pRoot); pQuery->pRoot = (SNode*)pSelect; @@ -6388,6 +6410,7 @@ static int32_t rewriteShowVnodes(STranslateContext* pCxt, SQuery* pQuery) { } } if (TSDB_CODE_SUCCESS == code) { + pCxt->showRewrite = true; pQuery->showRewrite = true; nodesDestroyNode(pQuery->pRoot); pQuery->pRoot = (SNode*)pStmt; @@ -6429,6 +6452,7 @@ static int32_t rewriteShowTableDist(STranslateContext* pCxt, SQuery* pQuery) { code = nodesListMakeStrictAppend(&pStmt->pProjectionList, createBlockDistFunc()); } if (TSDB_CODE_SUCCESS == code) { + pCxt->showRewrite = true; pQuery->showRewrite = true; nodesDestroyNode(pQuery->pRoot); pQuery->pRoot = (SNode*)pStmt; @@ -7504,6 +7528,7 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) { case QUERY_NODE_SHOW_CONSUMERS_STMT: case QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT: case QUERY_NODE_SHOW_TAGS_STMT: + case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT: code = rewriteShow(pCxt, pQuery); break; case QUERY_NODE_SHOW_VGROUPS_STMT: diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 7a56b0e0fa..fa091901b6 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -377,7 +377,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi int32_t valLen = (int32_t)strlen(jsonValue); char* tmp = taosMemoryCalloc(1, valLen * TSDB_NCHAR_SIZE); if (!tmp) { - retCode = TSDB_CODE_TSC_OUT_OF_MEMORY; + retCode = TSDB_CODE_OUT_OF_MEMORY; goto end; } val.type = TSDB_DATA_TYPE_NCHAR; @@ -474,7 +474,7 @@ static int32_t getInsTagsTableTargetNameFromCond(int32_t acctId, SLogicCondition return TSDB_CODE_SUCCESS; } -int32_t getInsTagsTableTargetName(int32_t acctId, SNode* pWhere, SName* pName) { +int32_t getVnodeSysTableTargetName(int32_t acctId, SNode* pWhere, SName* pName) { if (NULL == pWhere) { return TSDB_CODE_SUCCESS; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index cfca98d191..616793e897 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 454 +#define YYNOCODE 456 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - ENullOrder yy153; - SNode* yy164; - bool yy193; - SAlterOption yy213; - EOrder yy238; - int32_t yy512; - int64_t yy577; - SToken yy593; - EFillMode yy638; - SNodeList* yy648; - EOperatorType yy656; - int8_t yy687; - SDataType yy720; - EJoinType yy868; + EOrder yy50; + int64_t yy93; + SNode* yy104; + bool yy185; + int32_t yy196; + EJoinType yy228; + EFillMode yy246; + SAlterOption yy557; + SNodeList* yy616; + SDataType yy640; + EOperatorType yy668; + int8_t yy695; + SToken yy737; + ENullOrder yy793; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -139,17 +139,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 704 -#define YYNRULE 535 -#define YYNTOKEN 319 -#define YY_MAX_SHIFT 703 -#define YY_MIN_SHIFTREDUCE 1044 -#define YY_MAX_SHIFTREDUCE 1578 -#define YY_ERROR_ACTION 1579 -#define YY_ACCEPT_ACTION 1580 -#define YY_NO_ACTION 1581 -#define YY_MIN_REDUCE 1582 -#define YY_MAX_REDUCE 2116 +#define YYNSTATE 707 +#define YYNRULE 538 +#define YYNTOKEN 321 +#define YY_MAX_SHIFT 706 +#define YY_MIN_SHIFTREDUCE 1049 +#define YY_MAX_SHIFTREDUCE 1586 +#define YY_ERROR_ACTION 1587 +#define YY_ACCEPT_ACTION 1588 +#define YY_NO_ACTION 1589 +#define YY_MIN_REDUCE 1590 +#define YY_MAX_REDUCE 2127 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -216,733 +216,703 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2619) +#define YY_ACTTAB_COUNT (2544) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 2034, 453, 1932, 454, 1617, 576, 158, 461, 1919, 454, - /* 10 */ 1617, 1688, 43, 41, 1509, 348, 1847, 557, 1844, 1915, - /* 20 */ 357, 2087, 1360, 36, 35, 1932, 2031, 42, 40, 39, - /* 30 */ 38, 37, 1950, 1439, 2092, 1358, 556, 174, 1386, 95, - /* 40 */ 572, 2088, 558, 1385, 168, 1901, 1077, 609, 1911, 1917, - /* 50 */ 340, 1387, 2092, 132, 593, 1950, 2087, 1434, 1094, 603, - /* 60 */ 1093, 1727, 16, 610, 1649, 329, 1833, 121, 1901, 1366, - /* 70 */ 609, 1931, 2091, 211, 491, 1966, 2088, 2090, 98, 1933, - /* 80 */ 613, 1935, 1936, 608, 1735, 603, 1081, 1082, 1095, 592, - /* 90 */ 171, 592, 2019, 62, 1931, 12, 351, 2015, 1966, 349, - /* 100 */ 1605, 98, 1933, 613, 1935, 1936, 608, 156, 603, 58, - /* 110 */ 176, 134, 1604, 143, 1990, 2019, 1737, 700, 2045, 351, - /* 120 */ 2015, 42, 40, 39, 38, 37, 593, 1568, 507, 506, - /* 130 */ 505, 1441, 1442, 39, 38, 37, 128, 501, 593, 121, - /* 140 */ 438, 500, 499, 1901, 43, 41, 496, 498, 504, 1245, - /* 150 */ 1246, 52, 357, 497, 1360, 1901, 1735, 1932, 362, 1415, - /* 160 */ 1424, 1780, 1782, 2091, 46, 1439, 111, 1358, 1735, 110, - /* 170 */ 109, 108, 107, 106, 105, 104, 103, 102, 1361, 159, - /* 180 */ 1359, 1594, 1297, 1298, 58, 1575, 402, 1950, 1726, 1434, - /* 190 */ 470, 395, 257, 394, 16, 572, 190, 189, 646, 1915, - /* 200 */ 1901, 1366, 609, 1364, 1365, 1603, 1414, 1417, 1418, 1419, - /* 210 */ 1420, 1421, 1422, 1423, 605, 601, 1432, 1433, 1435, 1436, - /* 220 */ 1437, 1438, 1440, 1443, 2, 317, 1931, 12, 1911, 1917, - /* 230 */ 1966, 33, 274, 98, 1933, 613, 1935, 1936, 608, 603, - /* 240 */ 603, 316, 552, 1383, 1385, 171, 168, 2019, 1901, 700, - /* 250 */ 432, 351, 2015, 443, 36, 35, 177, 78, 42, 40, - /* 260 */ 39, 38, 37, 1441, 1442, 258, 1388, 1919, 1834, 1386, - /* 270 */ 416, 127, 444, 2046, 1920, 418, 43, 41, 1915, 1574, - /* 280 */ 1730, 507, 506, 505, 357, 1915, 1360, 1888, 58, 128, - /* 290 */ 501, 1415, 1424, 569, 500, 499, 360, 1439, 1163, 1358, - /* 300 */ 498, 504, 592, 58, 156, 83, 497, 1911, 1917, 352, - /* 310 */ 1361, 177, 1359, 1737, 1911, 1917, 458, 330, 603, 58, - /* 320 */ 363, 1434, 1383, 131, 1513, 603, 16, 1385, 156, 406, - /* 330 */ 1385, 177, 1165, 1366, 379, 1364, 1365, 1737, 1414, 1417, - /* 340 */ 1418, 1419, 1420, 1421, 1422, 1423, 605, 601, 1432, 1433, - /* 350 */ 1435, 1436, 1437, 1438, 1440, 1443, 2, 442, 9, 12, - /* 360 */ 437, 436, 435, 434, 431, 430, 429, 428, 427, 423, - /* 370 */ 422, 421, 420, 331, 413, 412, 411, 46, 408, 407, - /* 380 */ 328, 700, 571, 172, 2027, 2028, 1449, 129, 2032, 1384, - /* 390 */ 593, 212, 1385, 36, 35, 1441, 1442, 42, 40, 39, - /* 400 */ 38, 37, 2092, 179, 593, 163, 2087, 235, 43, 41, - /* 410 */ 1444, 487, 483, 479, 475, 209, 357, 400, 1360, 560, - /* 420 */ 1735, 2034, 2091, 1415, 1424, 547, 2088, 2089, 25, 1439, - /* 430 */ 1787, 1358, 1582, 1787, 1735, 177, 638, 350, 1787, 1712, - /* 440 */ 361, 9, 1361, 7, 1359, 326, 1785, 2030, 47, 1785, - /* 450 */ 177, 9, 79, 1434, 1785, 207, 120, 119, 118, 117, - /* 460 */ 116, 115, 114, 113, 112, 1366, 177, 1364, 1365, 1416, - /* 470 */ 1414, 1417, 1418, 1419, 1420, 1421, 1422, 1423, 605, 601, - /* 480 */ 1432, 1433, 1435, 1436, 1437, 1438, 1440, 1443, 2, 11, - /* 490 */ 10, 44, 1781, 1782, 265, 266, 512, 36, 35, 1950, - /* 500 */ 1602, 42, 40, 39, 38, 37, 593, 551, 553, 548, - /* 510 */ 557, 522, 452, 700, 2087, 456, 391, 264, 1366, 401, - /* 520 */ 206, 200, 1094, 205, 1093, 225, 466, 1441, 1442, 556, - /* 530 */ 174, 1416, 593, 658, 2088, 558, 1735, 393, 389, 515, - /* 540 */ 43, 41, 198, 1901, 509, 410, 644, 550, 357, 224, - /* 550 */ 1360, 322, 1095, 1932, 319, 1415, 1424, 582, 569, 580, - /* 560 */ 593, 1439, 1735, 1358, 593, 147, 146, 641, 640, 639, - /* 570 */ 595, 569, 1991, 424, 1361, 1470, 1359, 425, 1337, 1338, - /* 580 */ 503, 502, 1601, 1950, 1482, 1434, 64, 186, 131, 63, - /* 590 */ 1735, 607, 1535, 1468, 1735, 177, 1901, 1366, 609, 1364, - /* 600 */ 1365, 131, 1414, 1417, 1418, 1419, 1420, 1421, 1422, 1423, - /* 610 */ 605, 601, 1432, 1433, 1435, 1436, 1437, 1438, 1440, 1443, - /* 620 */ 2, 569, 1931, 44, 75, 1901, 1966, 74, 1724, 307, - /* 630 */ 1933, 613, 1935, 1936, 608, 606, 603, 594, 1984, 1387, - /* 640 */ 544, 1533, 1534, 1536, 1537, 700, 30, 1469, 173, 2027, - /* 650 */ 2028, 131, 129, 2032, 460, 133, 1475, 456, 1990, 1441, - /* 660 */ 1442, 255, 2027, 568, 1600, 122, 567, 1599, 593, 2087, - /* 670 */ 36, 35, 43, 41, 42, 40, 39, 38, 37, 593, - /* 680 */ 357, 364, 1360, 89, 556, 174, 576, 1415, 1424, 2088, - /* 690 */ 558, 227, 468, 1439, 1765, 1358, 36, 35, 1735, 1845, - /* 700 */ 42, 40, 39, 38, 37, 1728, 1361, 1901, 1359, 1735, - /* 710 */ 1901, 175, 2027, 2028, 1598, 129, 2032, 1434, 32, 355, - /* 720 */ 1463, 1464, 1465, 1466, 1467, 1471, 1472, 1473, 1474, 1366, - /* 730 */ 1720, 1364, 1365, 1932, 1414, 1417, 1418, 1419, 1420, 1421, - /* 740 */ 1422, 1423, 605, 601, 1432, 1433, 1435, 1436, 1437, 1438, - /* 750 */ 1440, 1443, 2, 1597, 29, 12, 170, 1901, 1545, 593, - /* 760 */ 36, 35, 78, 1950, 42, 40, 39, 38, 37, 1774, - /* 770 */ 1360, 610, 469, 593, 1506, 593, 1901, 700, 609, 1829, - /* 780 */ 257, 1596, 403, 1358, 1525, 1731, 1732, 31, 139, 1735, - /* 790 */ 182, 1441, 1442, 36, 35, 404, 1901, 42, 40, 39, - /* 800 */ 38, 37, 1931, 1735, 1829, 1735, 1966, 671, 669, 99, - /* 810 */ 1933, 613, 1935, 1936, 608, 184, 603, 1366, 1593, 1415, - /* 820 */ 1424, 1646, 521, 2019, 1901, 36, 35, 2018, 2015, 42, - /* 830 */ 40, 39, 38, 37, 597, 519, 1991, 517, 1361, 1722, - /* 840 */ 1359, 1203, 635, 634, 633, 1207, 632, 1209, 1210, 631, - /* 850 */ 1212, 628, 1718, 1218, 625, 1220, 1221, 622, 619, 230, - /* 860 */ 1843, 1901, 312, 1364, 1365, 700, 1414, 1417, 1418, 1419, - /* 870 */ 1420, 1421, 1422, 1423, 605, 601, 1432, 1433, 1435, 1436, - /* 880 */ 1437, 1438, 1440, 1443, 2, 677, 676, 675, 674, 367, - /* 890 */ 1385, 673, 672, 135, 667, 666, 665, 664, 663, 662, - /* 900 */ 661, 660, 149, 656, 655, 654, 366, 365, 651, 650, - /* 910 */ 649, 648, 647, 157, 593, 1713, 1592, 604, 292, 396, - /* 920 */ 1932, 1388, 1787, 1591, 1590, 1589, 1361, 533, 1359, 1588, - /* 930 */ 2034, 1587, 290, 67, 1586, 1842, 66, 312, 1786, 1585, - /* 940 */ 637, 36, 35, 1932, 1735, 42, 40, 39, 38, 37, - /* 950 */ 1950, 1364, 1365, 194, 449, 447, 2029, 593, 610, 1901, - /* 960 */ 537, 6, 593, 1901, 2087, 609, 1901, 1901, 1901, 1711, - /* 970 */ 573, 1388, 1901, 1950, 1901, 269, 470, 1901, 155, 2093, - /* 980 */ 174, 610, 1901, 1829, 2088, 558, 1901, 1735, 609, 1931, - /* 990 */ 58, 334, 1735, 1966, 188, 561, 98, 1933, 613, 1935, - /* 1000 */ 1936, 608, 156, 603, 593, 659, 642, 1705, 2107, 1778, - /* 1010 */ 2019, 1738, 1931, 1505, 351, 2015, 1966, 588, 1816, 98, - /* 1020 */ 1933, 613, 1935, 1936, 608, 2053, 603, 564, 97, 1416, - /* 1030 */ 646, 2107, 1710, 2019, 1735, 354, 353, 351, 2015, 643, - /* 1040 */ 226, 1932, 1778, 286, 532, 1374, 1765, 593, 2081, 1081, - /* 1050 */ 1082, 593, 335, 644, 333, 332, 1439, 493, 1367, 65, - /* 1060 */ 590, 495, 183, 495, 591, 72, 71, 399, 2039, 1502, - /* 1070 */ 181, 1950, 147, 146, 641, 640, 639, 1735, 1369, 610, - /* 1080 */ 1434, 1735, 1689, 494, 1901, 494, 609, 1636, 315, 48, - /* 1090 */ 3, 387, 1366, 385, 381, 377, 374, 371, 80, 319, - /* 1100 */ 1932, 233, 582, 593, 580, 137, 123, 73, 600, 508, - /* 1110 */ 1931, 145, 234, 60, 1966, 1595, 275, 98, 1933, 613, - /* 1120 */ 1935, 1936, 608, 1583, 603, 1577, 1578, 11, 10, 2107, - /* 1130 */ 1950, 2019, 239, 1735, 1629, 351, 2015, 177, 610, 644, - /* 1140 */ 599, 81, 1368, 1901, 111, 609, 2038, 110, 109, 108, - /* 1150 */ 107, 106, 105, 104, 103, 102, 510, 45, 147, 146, - /* 1160 */ 641, 640, 639, 1502, 51, 217, 1532, 419, 215, 1931, - /* 1170 */ 1627, 219, 221, 1966, 218, 220, 98, 1933, 613, 1935, - /* 1180 */ 1936, 608, 262, 603, 223, 241, 1932, 222, 1994, 652, - /* 1190 */ 2019, 50, 513, 140, 351, 2015, 536, 144, 145, 60, - /* 1200 */ 1123, 1375, 2059, 1370, 45, 1922, 653, 252, 1580, 545, - /* 1210 */ 1308, 1143, 210, 562, 246, 1932, 1950, 45, 617, 1951, - /* 1220 */ 144, 368, 145, 1372, 610, 124, 1378, 1380, 1141, 1901, - /* 1230 */ 144, 609, 1838, 1618, 1124, 267, 1775, 2049, 601, 1432, - /* 1240 */ 1433, 1435, 1436, 1437, 1438, 1950, 585, 565, 570, 1460, - /* 1250 */ 271, 1196, 1476, 610, 1924, 1931, 254, 1425, 1901, 1966, - /* 1260 */ 609, 251, 98, 1933, 613, 1935, 1936, 608, 1623, 603, - /* 1270 */ 285, 1224, 372, 1228, 1992, 1235, 2019, 1932, 1233, 94, - /* 1280 */ 351, 2015, 1, 148, 1931, 4, 378, 1371, 1966, 91, - /* 1290 */ 373, 98, 1933, 613, 1935, 1936, 608, 327, 603, 282, - /* 1300 */ 1324, 187, 405, 596, 1932, 2019, 1388, 1950, 414, 351, - /* 1310 */ 2015, 1839, 409, 537, 1383, 610, 695, 2087, 440, 426, - /* 1320 */ 1901, 1831, 609, 445, 446, 191, 448, 450, 439, 433, - /* 1330 */ 441, 1932, 2093, 174, 1950, 1389, 451, 2088, 558, 459, - /* 1340 */ 1391, 197, 610, 463, 1390, 199, 1931, 1901, 1932, 609, - /* 1350 */ 1966, 462, 464, 99, 1933, 613, 1935, 1936, 608, 1392, - /* 1360 */ 603, 1950, 465, 202, 204, 467, 76, 2019, 77, 610, - /* 1370 */ 471, 598, 2015, 611, 1901, 490, 609, 1966, 1950, 1097, - /* 1380 */ 99, 1933, 613, 1935, 1936, 608, 610, 603, 208, 488, - /* 1390 */ 489, 1901, 100, 609, 2019, 524, 575, 492, 321, 2015, - /* 1400 */ 1931, 1725, 1932, 318, 1966, 283, 214, 160, 1933, 613, - /* 1410 */ 1935, 1936, 608, 1721, 603, 1878, 216, 1931, 527, 546, - /* 1420 */ 534, 1966, 528, 150, 161, 1933, 613, 1935, 1936, 608, - /* 1430 */ 151, 603, 1950, 228, 1723, 1719, 152, 537, 153, 231, - /* 1440 */ 610, 2087, 526, 531, 2050, 1901, 579, 609, 538, 2056, - /* 1450 */ 370, 2065, 2060, 541, 2064, 5, 2093, 174, 1932, 543, - /* 1460 */ 341, 2088, 558, 549, 369, 555, 542, 540, 248, 237, - /* 1470 */ 240, 1931, 2041, 245, 539, 1966, 559, 2108, 99, 1933, - /* 1480 */ 613, 1935, 1936, 608, 342, 603, 250, 249, 1950, 164, - /* 1490 */ 566, 537, 2019, 247, 563, 2087, 610, 2016, 1502, 1387, - /* 1500 */ 130, 1901, 1932, 609, 345, 537, 2035, 141, 525, 2087, - /* 1510 */ 2093, 174, 2110, 574, 259, 2088, 558, 577, 1932, 142, - /* 1520 */ 586, 2086, 578, 1877, 2093, 174, 1736, 1931, 1849, 2088, - /* 1530 */ 558, 1966, 1950, 583, 160, 1933, 613, 1935, 1936, 608, - /* 1540 */ 610, 603, 253, 347, 86, 1901, 284, 609, 1950, 537, - /* 1550 */ 88, 57, 2000, 2087, 90, 1779, 610, 615, 1706, 278, - /* 1560 */ 696, 1901, 587, 609, 301, 697, 287, 699, 2093, 174, - /* 1570 */ 311, 1931, 291, 2088, 558, 1966, 2057, 49, 300, 1933, - /* 1580 */ 613, 1935, 1936, 608, 310, 603, 1932, 1931, 309, 289, - /* 1590 */ 1895, 1966, 1894, 69, 161, 1933, 613, 1935, 1936, 608, - /* 1600 */ 1893, 603, 1892, 1932, 70, 1889, 375, 376, 1352, 1353, - /* 1610 */ 180, 380, 1887, 382, 383, 384, 1950, 1886, 386, 1885, - /* 1620 */ 388, 346, 554, 1884, 610, 390, 1883, 1327, 392, 1901, - /* 1630 */ 1326, 609, 1860, 1950, 1859, 397, 398, 1858, 1857, 1824, - /* 1640 */ 1288, 607, 415, 136, 1820, 1819, 1901, 2109, 609, 1823, - /* 1650 */ 1821, 1822, 1818, 1817, 1815, 1931, 1814, 1932, 1813, 1966, - /* 1660 */ 185, 1812, 308, 1933, 613, 1935, 1936, 608, 417, 603, - /* 1670 */ 1811, 1810, 1931, 1932, 1809, 1808, 1966, 1807, 1806, 307, - /* 1680 */ 1933, 613, 1935, 1936, 608, 1805, 603, 1950, 1985, 1804, - /* 1690 */ 1803, 1802, 356, 1801, 1800, 610, 125, 138, 1796, 1795, - /* 1700 */ 1901, 1799, 609, 1950, 1798, 1797, 1794, 1793, 358, 1792, - /* 1710 */ 1290, 610, 169, 455, 1171, 1651, 1901, 1932, 609, 1791, - /* 1720 */ 1790, 1789, 1788, 192, 1650, 193, 1931, 1648, 1614, 195, - /* 1730 */ 1966, 1084, 1083, 308, 1933, 613, 1935, 1936, 608, 1613, - /* 1740 */ 603, 457, 1931, 196, 1932, 1873, 1966, 1950, 1867, 308, - /* 1750 */ 1933, 613, 1935, 1936, 608, 610, 603, 1856, 203, 1855, - /* 1760 */ 1901, 1841, 609, 1714, 126, 201, 1647, 1645, 472, 474, - /* 1770 */ 473, 1932, 1643, 1116, 1950, 476, 477, 478, 1641, 480, - /* 1780 */ 482, 481, 610, 485, 484, 486, 523, 1901, 1639, 609, - /* 1790 */ 1966, 1626, 1625, 303, 1933, 613, 1935, 1936, 608, 1610, - /* 1800 */ 603, 1950, 1716, 1239, 59, 1715, 1238, 1160, 1162, 610, - /* 1810 */ 213, 1161, 1159, 1931, 1901, 1932, 609, 1966, 668, 1153, - /* 1820 */ 293, 1933, 613, 1935, 1936, 608, 1637, 603, 1158, 670, - /* 1830 */ 1155, 1154, 1630, 1152, 336, 337, 511, 1628, 338, 514, - /* 1840 */ 1931, 1609, 516, 1608, 1966, 1950, 518, 294, 1933, 613, - /* 1850 */ 1935, 1936, 608, 610, 603, 1607, 520, 24, 1901, 1932, - /* 1860 */ 609, 1344, 101, 1872, 1333, 1866, 529, 154, 1854, 1852, - /* 1870 */ 2092, 17, 53, 14, 530, 26, 236, 232, 1547, 1932, - /* 1880 */ 61, 56, 243, 535, 1931, 238, 1531, 18, 1966, 1950, - /* 1890 */ 1524, 295, 1933, 613, 1935, 1936, 608, 610, 603, 244, - /* 1900 */ 28, 162, 1901, 339, 609, 1922, 15, 19, 1562, 1950, - /* 1910 */ 242, 1561, 27, 82, 343, 1567, 1568, 610, 1566, 1565, - /* 1920 */ 344, 1499, 1901, 1498, 609, 55, 256, 165, 1931, 1853, - /* 1930 */ 1851, 1850, 1966, 581, 1342, 299, 1933, 613, 1935, 1936, - /* 1940 */ 608, 20, 603, 261, 1932, 1529, 263, 1341, 1931, 1848, - /* 1950 */ 1840, 268, 1966, 84, 85, 304, 1933, 613, 1935, 1936, - /* 1960 */ 608, 87, 603, 1921, 1932, 584, 91, 273, 21, 10, - /* 1970 */ 270, 54, 1451, 1376, 1950, 1407, 1450, 8, 166, 178, - /* 1980 */ 614, 1969, 610, 1429, 602, 636, 1427, 1901, 34, 609, - /* 1990 */ 1426, 13, 22, 616, 1950, 359, 1399, 23, 620, 1225, - /* 2000 */ 618, 621, 610, 1461, 1222, 1219, 623, 1901, 612, 609, - /* 2010 */ 1213, 624, 626, 1931, 627, 629, 1211, 1966, 1932, 630, - /* 2020 */ 296, 1933, 613, 1935, 1936, 608, 1217, 603, 1202, 1216, - /* 2030 */ 1215, 92, 1214, 1931, 1932, 93, 1234, 1966, 68, 276, - /* 2040 */ 305, 1933, 613, 1935, 1936, 608, 1230, 603, 1950, 1114, - /* 2050 */ 645, 1149, 1148, 1147, 1146, 1145, 610, 1144, 1142, 1169, - /* 2060 */ 1140, 1901, 1139, 609, 1950, 1138, 657, 1136, 1135, 277, - /* 2070 */ 1134, 1133, 610, 1132, 1131, 1130, 1129, 1901, 1932, 609, - /* 2080 */ 1166, 1164, 1126, 1120, 1125, 1122, 1644, 1931, 1121, 1119, - /* 2090 */ 678, 1966, 679, 1642, 297, 1933, 613, 1935, 1936, 608, - /* 2100 */ 682, 603, 680, 1931, 1640, 1932, 683, 1966, 1950, 684, - /* 2110 */ 306, 1933, 613, 1935, 1936, 608, 610, 603, 686, 687, - /* 2120 */ 688, 1901, 1638, 609, 690, 691, 692, 1624, 1606, 694, - /* 2130 */ 1074, 280, 1932, 698, 701, 1950, 1362, 288, 702, 1581, - /* 2140 */ 1581, 1581, 1581, 610, 1581, 1581, 1581, 1931, 1901, 1581, - /* 2150 */ 609, 1966, 1581, 1581, 298, 1933, 613, 1935, 1936, 608, - /* 2160 */ 1581, 603, 1950, 1581, 1581, 1581, 1581, 1581, 1581, 1581, - /* 2170 */ 610, 1581, 1581, 1581, 1931, 1901, 1932, 609, 1966, 1581, - /* 2180 */ 1581, 313, 1933, 613, 1935, 1936, 608, 1581, 603, 1581, - /* 2190 */ 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, - /* 2200 */ 1581, 1931, 1581, 1581, 1581, 1966, 1950, 1581, 314, 1933, - /* 2210 */ 613, 1935, 1936, 608, 610, 603, 1581, 1581, 1581, 1901, - /* 2220 */ 1932, 609, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, - /* 2230 */ 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, - /* 2240 */ 1932, 1581, 1581, 1581, 1581, 1931, 1581, 1581, 1581, 1966, - /* 2250 */ 1950, 1581, 1944, 1933, 613, 1935, 1936, 608, 610, 603, - /* 2260 */ 1581, 1581, 1581, 1901, 1581, 609, 1581, 1581, 1581, 1581, - /* 2270 */ 1950, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 610, 1581, - /* 2280 */ 1581, 1581, 1581, 1901, 1581, 609, 1581, 1581, 1581, 1931, - /* 2290 */ 1581, 1581, 1581, 1966, 1581, 1581, 1943, 1933, 613, 1935, - /* 2300 */ 1936, 608, 1581, 603, 1581, 1932, 1581, 1581, 1581, 1931, - /* 2310 */ 1581, 1581, 1581, 1966, 1581, 1581, 1942, 1933, 613, 1935, - /* 2320 */ 1936, 608, 1581, 603, 1581, 1932, 1581, 1581, 1581, 1581, - /* 2330 */ 1581, 1581, 1581, 1581, 1581, 1950, 1581, 1581, 1581, 1581, - /* 2340 */ 1581, 1581, 1581, 610, 1581, 1581, 1581, 1581, 1901, 1581, - /* 2350 */ 609, 1581, 1581, 1581, 1581, 1950, 1581, 1581, 1581, 1581, - /* 2360 */ 1581, 1581, 1581, 610, 1581, 1581, 1581, 1581, 1901, 1581, - /* 2370 */ 609, 1581, 1581, 1581, 1931, 1581, 1581, 1581, 1966, 1932, - /* 2380 */ 1581, 323, 1933, 613, 1935, 1936, 608, 1581, 603, 1581, - /* 2390 */ 1581, 1581, 1581, 1581, 1931, 1932, 1581, 1581, 1966, 1581, - /* 2400 */ 1581, 324, 1933, 613, 1935, 1936, 608, 1581, 603, 1950, - /* 2410 */ 1581, 1581, 1581, 1581, 1581, 1581, 1581, 610, 1581, 1581, - /* 2420 */ 1581, 1581, 1901, 1581, 609, 1950, 1581, 1581, 1581, 1581, - /* 2430 */ 1581, 1581, 1581, 610, 1581, 1581, 1581, 1581, 1901, 1932, - /* 2440 */ 609, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1931, 1581, - /* 2450 */ 1581, 1581, 1966, 703, 1581, 320, 1933, 613, 1935, 1936, - /* 2460 */ 608, 1581, 603, 1581, 1931, 1581, 1932, 281, 1966, 1950, - /* 2470 */ 1581, 325, 1933, 613, 1935, 1936, 608, 610, 603, 1581, - /* 2480 */ 1581, 167, 1901, 1581, 609, 1581, 1581, 693, 689, 685, - /* 2490 */ 681, 279, 1581, 1581, 1581, 1581, 1950, 1581, 1581, 1581, - /* 2500 */ 1581, 1581, 1581, 1581, 610, 1581, 1581, 1581, 611, 1901, - /* 2510 */ 1581, 609, 1966, 1581, 1581, 303, 1933, 613, 1935, 1936, - /* 2520 */ 608, 1581, 603, 1581, 1581, 1581, 1581, 1581, 96, 1581, - /* 2530 */ 1581, 272, 1581, 1581, 1581, 1931, 1581, 1581, 1581, 1966, - /* 2540 */ 1581, 1581, 302, 1933, 613, 1935, 1936, 608, 1581, 603, - /* 2550 */ 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, - /* 2560 */ 1581, 1581, 1581, 1581, 589, 1581, 1581, 1581, 1581, 1581, - /* 2570 */ 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, - /* 2580 */ 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, - /* 2590 */ 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 260, - /* 2600 */ 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, 1581, - /* 2610 */ 1581, 1581, 1581, 1581, 1581, 1581, 1331, 1581, 229, + /* 0 */ 396, 2103, 349, 1858, 455, 2098, 456, 1626, 33, 274, + /* 10 */ 156, 578, 43, 41, 1517, 464, 168, 456, 1626, 1747, + /* 20 */ 357, 2102, 1368, 36, 35, 2099, 2101, 42, 40, 39, + /* 30 */ 38, 37, 595, 1447, 158, 1366, 1943, 329, 1844, 1698, + /* 40 */ 524, 540, 36, 35, 579, 2098, 42, 40, 39, 38, + /* 50 */ 37, 1394, 540, 522, 348, 520, 2098, 1855, 1442, 25, + /* 60 */ 2104, 174, 370, 16, 156, 2099, 561, 1961, 1791, 1792, + /* 70 */ 1374, 2104, 174, 1748, 2103, 575, 2099, 561, 2098, 572, + /* 80 */ 1912, 595, 612, 43, 41, 42, 40, 39, 38, 37, + /* 90 */ 159, 357, 1602, 1368, 2102, 1797, 12, 322, 2099, 2100, + /* 100 */ 11, 10, 350, 540, 1447, 1942, 1366, 2098, 62, 1977, + /* 110 */ 131, 1795, 100, 1944, 616, 1946, 1947, 611, 703, 606, + /* 120 */ 258, 603, 2104, 174, 171, 212, 2030, 2099, 561, 1442, + /* 130 */ 351, 2026, 1449, 1450, 16, 39, 38, 37, 473, 1476, + /* 140 */ 163, 1374, 2045, 402, 176, 1930, 490, 486, 482, 478, + /* 150 */ 209, 362, 2056, 80, 1790, 1792, 1926, 46, 58, 1797, + /* 160 */ 85, 1423, 1432, 1252, 1253, 1797, 326, 12, 2042, 255, + /* 170 */ 2038, 571, 361, 124, 570, 1795, 1741, 2098, 1393, 226, + /* 180 */ 1369, 1795, 1367, 317, 1922, 1928, 340, 81, 555, 703, + /* 190 */ 207, 1840, 559, 174, 1477, 606, 1490, 2099, 561, 1613, + /* 200 */ 58, 461, 182, 1449, 1450, 1372, 1373, 457, 1422, 1425, + /* 210 */ 1426, 1427, 1428, 1429, 1430, 1431, 608, 604, 1440, 1441, + /* 220 */ 1443, 1444, 1445, 1446, 1448, 1451, 2, 510, 509, 508, + /* 230 */ 560, 595, 1423, 1432, 2098, 128, 504, 1395, 82, 319, + /* 240 */ 503, 502, 585, 1912, 583, 1588, 501, 507, 1514, 559, + /* 250 */ 174, 1369, 500, 1367, 2099, 561, 206, 200, 1612, 205, + /* 260 */ 438, 550, 469, 1468, 1543, 32, 355, 1471, 1472, 1473, + /* 270 */ 1474, 1475, 1479, 1480, 1481, 1482, 1372, 1373, 198, 1422, + /* 280 */ 1425, 1426, 1427, 1428, 1429, 1430, 1431, 608, 604, 1440, + /* 290 */ 1441, 1443, 1444, 1445, 1446, 1448, 1451, 2, 170, 9, + /* 300 */ 43, 41, 1912, 506, 505, 177, 177, 46, 357, 372, + /* 310 */ 1368, 1784, 547, 1541, 1542, 1544, 1545, 190, 189, 1305, + /* 320 */ 1306, 1447, 1943, 1366, 1210, 638, 637, 636, 1214, 635, + /* 330 */ 1216, 1217, 634, 1219, 631, 1393, 1225, 628, 1227, 1228, + /* 340 */ 625, 622, 391, 97, 556, 551, 1442, 1101, 177, 1100, + /* 350 */ 540, 16, 454, 1961, 2098, 459, 1632, 132, 1374, 674, + /* 360 */ 672, 613, 211, 393, 389, 1737, 1912, 567, 612, 2104, + /* 370 */ 174, 43, 41, 1452, 2099, 561, 29, 1961, 1102, 357, + /* 380 */ 257, 1368, 36, 35, 12, 554, 42, 40, 39, 38, + /* 390 */ 37, 1942, 1447, 463, 1366, 1977, 459, 1632, 160, 1944, + /* 400 */ 616, 1946, 1947, 611, 596, 606, 703, 1943, 36, 35, + /* 410 */ 2045, 58, 42, 40, 39, 38, 37, 1442, 123, 264, + /* 420 */ 1449, 1450, 647, 50, 553, 494, 36, 35, 539, 1374, + /* 430 */ 42, 40, 39, 38, 37, 1745, 2041, 1170, 1961, 541, + /* 440 */ 2067, 147, 146, 644, 643, 642, 613, 91, 579, 1423, + /* 450 */ 1432, 1912, 58, 612, 560, 44, 2050, 1510, 2098, 36, + /* 460 */ 35, 1856, 1394, 42, 40, 39, 38, 37, 1369, 1738, + /* 470 */ 1367, 1396, 1172, 559, 174, 1611, 1942, 703, 2099, 561, + /* 480 */ 1977, 1345, 1346, 161, 1944, 616, 1946, 1947, 611, 1513, + /* 490 */ 606, 1449, 1450, 1372, 1373, 47, 1422, 1425, 1426, 1427, + /* 500 */ 1428, 1429, 1430, 1431, 608, 604, 1440, 1441, 1443, 1444, + /* 510 */ 1445, 1446, 1448, 1451, 2, 1553, 1082, 1610, 1609, 1912, + /* 520 */ 1423, 1432, 1591, 113, 1087, 1088, 112, 111, 110, 109, + /* 530 */ 108, 107, 106, 105, 104, 562, 2119, 265, 266, 1369, + /* 540 */ 9, 1367, 7, 113, 1722, 1608, 112, 111, 110, 109, + /* 550 */ 108, 107, 106, 105, 104, 1084, 1393, 1087, 1088, 177, + /* 560 */ 649, 1912, 1912, 155, 1372, 1373, 1478, 1422, 1425, 1426, + /* 570 */ 1427, 1428, 1429, 1430, 1431, 608, 604, 1440, 1441, 1443, + /* 580 */ 1444, 1445, 1446, 1448, 1451, 2, 43, 41, 568, 1912, + /* 590 */ 706, 515, 1392, 1101, 357, 1100, 1368, 1840, 319, 596, + /* 600 */ 177, 585, 596, 583, 281, 1521, 525, 1447, 184, 1366, + /* 610 */ 1943, 1393, 58, 52, 235, 641, 123, 596, 1607, 167, + /* 620 */ 225, 9, 572, 499, 1102, 696, 692, 688, 684, 279, + /* 630 */ 1745, 179, 1442, 1745, 360, 518, 80, 30, 168, 1374, + /* 640 */ 512, 1961, 156, 177, 1374, 224, 661, 1483, 1745, 613, + /* 650 */ 127, 1747, 647, 131, 1912, 1659, 612, 43, 41, 1740, + /* 660 */ 1845, 1723, 1912, 596, 1606, 357, 98, 1368, 1721, 272, + /* 670 */ 44, 147, 146, 644, 643, 642, 1734, 400, 1447, 1942, + /* 680 */ 1366, 1605, 64, 1977, 1730, 63, 100, 1944, 616, 1946, + /* 690 */ 1947, 611, 703, 606, 1745, 395, 134, 394, 143, 2001, + /* 700 */ 2030, 363, 592, 1442, 351, 2026, 1449, 1450, 1912, 156, + /* 710 */ 535, 574, 172, 2038, 2039, 1374, 129, 2043, 1747, 1732, + /* 720 */ 510, 509, 508, 473, 186, 1912, 1457, 572, 128, 504, + /* 730 */ 649, 1604, 1393, 503, 502, 1423, 1432, 1601, 260, 501, + /* 740 */ 507, 12, 1590, 36, 35, 500, 1396, 42, 40, 39, + /* 750 */ 38, 37, 1424, 1396, 1369, 1339, 1367, 229, 131, 227, + /* 760 */ 177, 77, 1775, 703, 76, 1736, 122, 121, 120, 119, + /* 770 */ 118, 117, 116, 115, 114, 1912, 1926, 1449, 1450, 1372, + /* 780 */ 1373, 1912, 1422, 1425, 1426, 1427, 1428, 1429, 1430, 1431, + /* 790 */ 608, 604, 1440, 1441, 1443, 1444, 1445, 1446, 1448, 1451, + /* 800 */ 2, 316, 498, 1391, 1922, 1928, 1423, 1432, 1600, 1840, + /* 810 */ 432, 2045, 598, 445, 2002, 606, 444, 173, 2038, 2039, + /* 820 */ 188, 129, 2043, 1797, 497, 1369, 1656, 1367, 1599, 1899, + /* 830 */ 1598, 416, 1533, 446, 31, 133, 418, 2040, 2001, 1796, + /* 840 */ 36, 35, 1597, 1596, 42, 40, 39, 38, 37, 1728, + /* 850 */ 1372, 1373, 1912, 1422, 1425, 1426, 1427, 1428, 1429, 1430, + /* 860 */ 1431, 608, 604, 1440, 1441, 1443, 1444, 1445, 1446, 1448, + /* 870 */ 1451, 2, 1912, 1424, 1912, 36, 35, 379, 330, 42, + /* 880 */ 40, 39, 38, 37, 1393, 645, 1912, 1912, 1788, 183, + /* 890 */ 406, 680, 679, 678, 677, 367, 234, 676, 675, 135, + /* 900 */ 670, 669, 668, 667, 666, 665, 664, 663, 149, 659, + /* 910 */ 658, 657, 366, 365, 654, 653, 652, 651, 650, 442, + /* 920 */ 1595, 1943, 437, 436, 435, 434, 431, 430, 429, 428, + /* 930 */ 427, 423, 422, 421, 420, 331, 413, 412, 411, 2102, + /* 940 */ 408, 407, 328, 157, 600, 596, 2002, 596, 292, 36, + /* 950 */ 35, 564, 1961, 42, 40, 39, 38, 37, 596, 401, + /* 960 */ 575, 410, 290, 66, 1912, 1912, 65, 612, 1854, 369, + /* 970 */ 312, 2103, 424, 145, 1943, 1594, 1745, 1853, 1745, 312, + /* 980 */ 1593, 596, 11, 10, 194, 451, 449, 1720, 1395, 1745, + /* 990 */ 1942, 572, 596, 646, 1977, 425, 1788, 100, 1944, 616, + /* 1000 */ 1946, 1947, 611, 6, 606, 1961, 139, 1827, 230, 171, + /* 1010 */ 540, 2030, 1745, 613, 2098, 351, 2026, 1699, 1912, 1912, + /* 1020 */ 612, 58, 131, 1745, 1912, 1424, 51, 596, 286, 2104, + /* 1030 */ 174, 1775, 596, 217, 2099, 561, 215, 2057, 1931, 1583, + /* 1040 */ 607, 471, 596, 1942, 233, 219, 472, 1977, 218, 1926, + /* 1050 */ 100, 1944, 616, 1946, 1947, 611, 364, 606, 1745, 99, + /* 1060 */ 596, 1943, 2118, 1745, 2030, 1576, 354, 353, 351, 2026, + /* 1070 */ 662, 640, 1715, 1745, 1742, 1377, 1382, 1922, 1928, 2064, + /* 1080 */ 596, 175, 2038, 2039, 83, 129, 2043, 1447, 606, 1375, + /* 1090 */ 1603, 1745, 1961, 403, 536, 647, 67, 74, 73, 399, + /* 1100 */ 613, 48, 181, 3, 1943, 1912, 404, 612, 137, 2070, + /* 1110 */ 125, 1745, 1442, 548, 147, 146, 644, 643, 642, 1376, + /* 1120 */ 315, 1930, 596, 387, 1374, 385, 381, 377, 374, 371, + /* 1130 */ 1942, 257, 1926, 1582, 1977, 1961, 576, 100, 1944, 616, + /* 1140 */ 1946, 1947, 611, 613, 606, 75, 1646, 96, 1912, 2118, + /* 1150 */ 612, 2030, 252, 1745, 1639, 351, 2026, 93, 419, 210, + /* 1160 */ 1922, 1928, 352, 528, 221, 596, 2092, 220, 511, 177, + /* 1170 */ 565, 606, 602, 1942, 596, 1943, 513, 1977, 60, 269, + /* 1180 */ 100, 1944, 616, 1946, 1947, 611, 596, 606, 591, 596, + /* 1190 */ 1637, 1933, 2118, 246, 2030, 1962, 1745, 563, 351, 2026, + /* 1200 */ 593, 596, 368, 594, 540, 1745, 1961, 1510, 2098, 2049, + /* 1210 */ 1585, 1586, 516, 223, 613, 275, 222, 1745, 1943, 1912, + /* 1220 */ 1745, 612, 1380, 2104, 174, 239, 45, 262, 2099, 561, + /* 1230 */ 140, 1540, 1745, 144, 1383, 145, 1378, 60, 1849, 1627, + /* 1240 */ 1935, 1785, 573, 2060, 1942, 254, 1130, 251, 1977, 1961, + /* 1250 */ 45, 100, 1944, 616, 1946, 1947, 611, 613, 606, 1386, + /* 1260 */ 1388, 1943, 1912, 2005, 612, 2030, 1379, 45, 620, 351, + /* 1270 */ 2026, 604, 1440, 1441, 1443, 1444, 1445, 1446, 241, 1316, + /* 1280 */ 267, 1131, 4, 588, 1633, 1943, 271, 1942, 1203, 655, + /* 1290 */ 1484, 1977, 1961, 144, 100, 1944, 616, 1946, 1947, 611, + /* 1300 */ 613, 606, 1, 1433, 145, 1912, 2003, 612, 2030, 373, + /* 1310 */ 378, 1150, 351, 2026, 656, 327, 1961, 126, 144, 1368, + /* 1320 */ 285, 1231, 282, 1332, 613, 187, 405, 1396, 1850, 1912, + /* 1330 */ 1942, 612, 1366, 698, 1977, 334, 1148, 100, 1944, 616, + /* 1340 */ 1946, 1947, 611, 1943, 606, 409, 1235, 440, 414, 599, + /* 1350 */ 1391, 2030, 426, 1842, 1942, 351, 2026, 1242, 1977, 433, + /* 1360 */ 447, 101, 1944, 616, 1946, 1947, 611, 1374, 606, 439, + /* 1370 */ 1240, 148, 441, 448, 1961, 2030, 191, 450, 452, 2029, + /* 1380 */ 2026, 1397, 613, 453, 462, 1399, 1943, 1912, 465, 612, + /* 1390 */ 197, 199, 466, 1398, 467, 1400, 468, 335, 202, 333, + /* 1400 */ 332, 470, 496, 204, 474, 78, 498, 79, 208, 1104, + /* 1410 */ 491, 492, 1942, 493, 1943, 703, 1977, 1961, 495, 101, + /* 1420 */ 1944, 616, 1946, 1947, 611, 613, 606, 102, 497, 1735, + /* 1430 */ 1912, 318, 612, 2030, 214, 1731, 216, 601, 2026, 527, + /* 1440 */ 150, 151, 529, 1733, 1729, 1961, 152, 153, 228, 530, + /* 1450 */ 1889, 231, 537, 610, 549, 614, 582, 5, 1912, 1977, + /* 1460 */ 612, 2061, 101, 1944, 616, 1946, 1947, 611, 283, 606, + /* 1470 */ 534, 2071, 544, 1943, 2076, 546, 2030, 1369, 237, 1367, + /* 1480 */ 321, 2026, 240, 1942, 531, 2075, 341, 1977, 558, 552, + /* 1490 */ 307, 1944, 616, 1946, 1947, 611, 609, 606, 597, 1995, + /* 1500 */ 545, 543, 1372, 1373, 1961, 542, 250, 569, 342, 566, + /* 1510 */ 2121, 245, 613, 1510, 130, 1395, 2046, 1912, 345, 612, + /* 1520 */ 577, 141, 142, 580, 581, 1888, 1860, 586, 259, 347, + /* 1530 */ 88, 1943, 589, 248, 164, 2052, 249, 247, 1746, 590, + /* 1540 */ 90, 57, 1942, 2011, 92, 1789, 1977, 284, 1716, 101, + /* 1550 */ 1944, 616, 1946, 1947, 611, 2097, 606, 253, 287, 1943, + /* 1560 */ 618, 278, 1961, 2030, 699, 700, 49, 301, 2027, 310, + /* 1570 */ 613, 309, 702, 289, 291, 1912, 1906, 612, 1905, 311, + /* 1580 */ 71, 1904, 1903, 72, 1900, 1943, 375, 376, 1360, 1361, + /* 1590 */ 1961, 180, 1898, 380, 382, 383, 384, 1897, 613, 386, + /* 1600 */ 1942, 1896, 388, 1912, 1977, 612, 1895, 160, 1944, 616, + /* 1610 */ 1946, 1947, 611, 1894, 606, 390, 1961, 1335, 392, 1334, + /* 1620 */ 1871, 1870, 397, 1869, 613, 398, 1868, 1296, 1942, 1912, + /* 1630 */ 1835, 612, 1977, 1834, 1832, 300, 1944, 616, 1946, 1947, + /* 1640 */ 611, 136, 606, 1831, 1830, 1833, 1829, 1828, 1826, 2068, + /* 1650 */ 1825, 1824, 185, 415, 1942, 1943, 1823, 417, 1977, 1822, + /* 1660 */ 1821, 161, 1944, 616, 1946, 1947, 611, 1820, 606, 1819, + /* 1670 */ 1818, 1817, 1816, 1815, 1943, 1298, 1802, 138, 1807, 557, + /* 1680 */ 1814, 1813, 1812, 1811, 1810, 1809, 1961, 1808, 1806, 1805, + /* 1690 */ 1804, 346, 443, 1799, 613, 1803, 1801, 1800, 1798, 1912, + /* 1700 */ 1178, 612, 1661, 1660, 1658, 1961, 1622, 192, 195, 1932, + /* 1710 */ 193, 458, 169, 610, 2120, 1090, 69, 1621, 1912, 1089, + /* 1720 */ 612, 460, 1884, 1878, 1942, 1867, 196, 1866, 1977, 203, + /* 1730 */ 70, 308, 1944, 616, 1946, 1947, 611, 1943, 606, 201, + /* 1740 */ 1852, 1724, 1657, 1942, 1655, 475, 477, 1977, 1653, 479, + /* 1750 */ 307, 1944, 616, 1946, 1947, 611, 476, 606, 1943, 1996, + /* 1760 */ 480, 1651, 1649, 1123, 483, 481, 484, 485, 1961, 487, + /* 1770 */ 489, 1636, 488, 356, 1635, 1618, 613, 1726, 1246, 1245, + /* 1780 */ 1943, 1912, 1725, 612, 59, 1169, 1168, 1167, 1166, 1961, + /* 1790 */ 1165, 671, 1160, 673, 358, 1162, 1647, 613, 1161, 1159, + /* 1800 */ 336, 1943, 1912, 1640, 612, 337, 1942, 1638, 514, 338, + /* 1810 */ 1977, 1961, 213, 308, 1944, 616, 1946, 1947, 611, 613, + /* 1820 */ 606, 517, 1617, 1943, 1912, 519, 612, 1942, 1616, 521, + /* 1830 */ 1615, 1977, 1961, 523, 308, 1944, 616, 1946, 1947, 611, + /* 1840 */ 613, 606, 1352, 103, 1943, 1912, 1883, 612, 24, 526, + /* 1850 */ 1341, 1877, 1865, 1977, 1961, 532, 303, 1944, 616, 1946, + /* 1860 */ 1947, 611, 613, 606, 1863, 17, 2103, 1912, 26, 612, + /* 1870 */ 1942, 56, 14, 1555, 1977, 1961, 53, 293, 1944, 616, + /* 1880 */ 1946, 1947, 611, 613, 606, 232, 238, 1943, 1912, 236, + /* 1890 */ 612, 162, 1942, 533, 154, 339, 1977, 1539, 1532, 294, + /* 1900 */ 1944, 616, 1946, 1947, 611, 538, 606, 244, 242, 27, + /* 1910 */ 243, 28, 1933, 1942, 84, 1943, 61, 1977, 1961, 19, + /* 1920 */ 295, 1944, 616, 1946, 1947, 611, 613, 606, 1575, 1576, + /* 1930 */ 1570, 1912, 1569, 612, 343, 1574, 1573, 344, 1507, 1506, + /* 1940 */ 256, 1943, 18, 165, 1864, 1862, 1961, 55, 1861, 20, + /* 1950 */ 1350, 261, 1537, 263, 613, 1349, 1942, 54, 584, 1912, + /* 1960 */ 1977, 612, 1859, 299, 1944, 616, 1946, 1947, 611, 15, + /* 1970 */ 606, 587, 1961, 268, 86, 1851, 87, 89, 270, 93, + /* 1980 */ 613, 273, 21, 1459, 1942, 1912, 10, 612, 1977, 1384, + /* 1990 */ 1469, 304, 1944, 616, 1946, 1947, 611, 8, 606, 1943, + /* 2000 */ 1458, 1437, 1980, 605, 166, 1435, 34, 178, 1434, 1407, + /* 2010 */ 1942, 615, 13, 22, 1977, 1415, 1943, 296, 1944, 616, + /* 2020 */ 1946, 1947, 611, 1232, 606, 23, 617, 619, 621, 359, + /* 2030 */ 1961, 623, 1229, 1226, 626, 624, 627, 629, 613, 1220, + /* 2040 */ 1218, 632, 630, 1912, 1224, 612, 633, 1961, 1223, 1209, + /* 2050 */ 1222, 1221, 94, 1241, 95, 613, 276, 639, 1237, 1943, + /* 2060 */ 1912, 68, 612, 1156, 1121, 1155, 648, 1154, 1942, 1153, + /* 2070 */ 1152, 1176, 1977, 1151, 1149, 305, 1944, 616, 1946, 1947, + /* 2080 */ 611, 1147, 606, 1943, 1146, 1942, 1145, 277, 660, 1977, + /* 2090 */ 1961, 1143, 297, 1944, 616, 1946, 1947, 611, 613, 606, + /* 2100 */ 1142, 1141, 1140, 1912, 1139, 612, 1138, 1137, 1127, 1136, + /* 2110 */ 1173, 1171, 1133, 1132, 1961, 1129, 1128, 1654, 1126, 681, + /* 2120 */ 1652, 1650, 613, 682, 683, 685, 1943, 1912, 1942, 612, + /* 2130 */ 687, 691, 1977, 689, 1648, 306, 1944, 616, 1946, 1947, + /* 2140 */ 611, 693, 606, 1943, 686, 690, 695, 694, 1634, 697, + /* 2150 */ 1079, 1614, 1942, 280, 701, 705, 1977, 1961, 704, 298, + /* 2160 */ 1944, 616, 1946, 1947, 611, 613, 606, 1370, 288, 1943, + /* 2170 */ 1912, 1589, 612, 1589, 1961, 1589, 1589, 1589, 1589, 1589, + /* 2180 */ 1589, 1589, 613, 1589, 1589, 1589, 1943, 1912, 1589, 612, + /* 2190 */ 1589, 1589, 1589, 1589, 1589, 1942, 1589, 1589, 1589, 1977, + /* 2200 */ 1961, 1589, 313, 1944, 616, 1946, 1947, 611, 613, 606, + /* 2210 */ 1589, 1589, 1942, 1912, 1589, 612, 1977, 1961, 1589, 314, + /* 2220 */ 1944, 616, 1946, 1947, 611, 613, 606, 1589, 1589, 1943, + /* 2230 */ 1912, 1589, 612, 1589, 1589, 1589, 1589, 1589, 1942, 1589, + /* 2240 */ 1589, 1589, 1977, 1589, 1589, 1955, 1944, 616, 1946, 1947, + /* 2250 */ 611, 1943, 606, 1589, 1589, 1942, 1589, 1589, 1589, 1977, + /* 2260 */ 1961, 1589, 1954, 1944, 616, 1946, 1947, 611, 613, 606, + /* 2270 */ 1589, 1589, 1589, 1912, 1589, 612, 1589, 1589, 1589, 1589, + /* 2280 */ 1589, 1589, 1961, 1589, 1589, 1589, 1589, 1589, 1589, 1589, + /* 2290 */ 613, 1589, 1589, 1589, 1589, 1912, 1589, 612, 1942, 1589, + /* 2300 */ 1589, 1589, 1977, 1589, 1589, 1953, 1944, 616, 1946, 1947, + /* 2310 */ 611, 1589, 606, 1943, 1589, 1589, 1589, 1589, 1589, 1589, + /* 2320 */ 1942, 1589, 1589, 1589, 1977, 1589, 1589, 323, 1944, 616, + /* 2330 */ 1946, 1947, 611, 1589, 606, 1943, 1589, 1589, 1589, 1589, + /* 2340 */ 1589, 1589, 1589, 1589, 1961, 1589, 1589, 1589, 1589, 1589, + /* 2350 */ 1589, 1589, 613, 1589, 1589, 1589, 1589, 1912, 1589, 612, + /* 2360 */ 1589, 1589, 1589, 1589, 1589, 1589, 1961, 1589, 1589, 1589, + /* 2370 */ 1589, 1589, 1589, 1589, 613, 1589, 1589, 1589, 1589, 1912, + /* 2380 */ 1589, 612, 1942, 1589, 1589, 1589, 1977, 1589, 1589, 324, + /* 2390 */ 1944, 616, 1946, 1947, 611, 1589, 606, 1943, 1589, 1589, + /* 2400 */ 1589, 1589, 1589, 1589, 1942, 1589, 1589, 1589, 1977, 1589, + /* 2410 */ 1589, 320, 1944, 616, 1946, 1947, 611, 1943, 606, 1589, + /* 2420 */ 1589, 1589, 1589, 1589, 1589, 1589, 1589, 1589, 1961, 1589, + /* 2430 */ 1589, 1589, 1589, 1589, 1589, 1589, 613, 1589, 1589, 1589, + /* 2440 */ 1589, 1912, 1589, 612, 1589, 1589, 1589, 1589, 1961, 1589, + /* 2450 */ 1589, 1589, 1589, 1589, 1589, 1589, 613, 1589, 1589, 1589, + /* 2460 */ 1943, 1912, 1589, 612, 1589, 1589, 1942, 1589, 1589, 1589, + /* 2470 */ 1977, 1589, 1589, 325, 1944, 616, 1946, 1947, 611, 1589, + /* 2480 */ 606, 1589, 1589, 1589, 1589, 1589, 614, 1589, 1589, 1589, + /* 2490 */ 1977, 1961, 1589, 303, 1944, 616, 1946, 1947, 611, 613, + /* 2500 */ 606, 1589, 1589, 1589, 1912, 1589, 612, 1589, 1589, 1589, + /* 2510 */ 1589, 1589, 1589, 1589, 1589, 1589, 1589, 1589, 1589, 1589, + /* 2520 */ 1589, 1589, 1589, 1589, 1589, 1589, 1589, 1589, 1589, 1942, + /* 2530 */ 1589, 1589, 1589, 1977, 1589, 1589, 302, 1944, 616, 1946, + /* 2540 */ 1947, 611, 1589, 606, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 397, 326, 322, 328, 329, 367, 336, 326, 354, 328, - /* 10 */ 329, 341, 12, 13, 14, 377, 0, 424, 380, 365, - /* 20 */ 20, 428, 22, 8, 9, 322, 423, 12, 13, 14, - /* 30 */ 15, 16, 352, 33, 3, 35, 443, 444, 20, 333, - /* 40 */ 360, 448, 449, 20, 352, 365, 4, 367, 394, 395, - /* 50 */ 396, 20, 424, 347, 330, 352, 428, 57, 20, 405, - /* 60 */ 22, 355, 62, 360, 0, 373, 374, 343, 365, 69, - /* 70 */ 367, 391, 444, 35, 350, 395, 448, 449, 398, 399, - /* 80 */ 400, 401, 402, 403, 360, 405, 44, 45, 50, 20, - /* 90 */ 410, 20, 412, 4, 391, 95, 416, 417, 395, 344, - /* 100 */ 322, 398, 399, 400, 401, 402, 403, 352, 405, 95, - /* 110 */ 430, 408, 322, 410, 411, 412, 361, 117, 438, 416, - /* 120 */ 417, 12, 13, 14, 15, 16, 330, 96, 64, 65, - /* 130 */ 66, 131, 132, 14, 15, 16, 72, 73, 330, 343, - /* 140 */ 79, 77, 78, 365, 12, 13, 350, 83, 84, 131, - /* 150 */ 132, 343, 20, 89, 22, 365, 360, 322, 363, 159, - /* 160 */ 160, 366, 367, 3, 95, 33, 21, 35, 360, 24, - /* 170 */ 25, 26, 27, 28, 29, 30, 31, 32, 178, 321, - /* 180 */ 180, 323, 159, 160, 95, 170, 330, 352, 354, 57, - /* 190 */ 61, 177, 161, 179, 62, 360, 135, 136, 61, 365, - /* 200 */ 365, 69, 367, 203, 204, 322, 206, 207, 208, 209, + /* 0 */ 385, 426, 347, 0, 328, 430, 330, 331, 415, 416, + /* 10 */ 355, 385, 12, 13, 14, 328, 355, 330, 331, 364, + /* 20 */ 20, 446, 22, 8, 9, 450, 451, 12, 13, 14, + /* 30 */ 15, 16, 20, 33, 339, 35, 324, 376, 377, 344, + /* 40 */ 21, 426, 8, 9, 370, 430, 12, 13, 14, 15, + /* 50 */ 16, 20, 426, 34, 380, 36, 430, 383, 58, 44, + /* 60 */ 445, 446, 385, 63, 355, 450, 451, 355, 369, 370, + /* 70 */ 70, 445, 446, 364, 426, 363, 450, 451, 430, 332, + /* 80 */ 368, 20, 370, 12, 13, 12, 13, 14, 15, 16, + /* 90 */ 323, 20, 325, 22, 446, 355, 96, 63, 450, 451, + /* 100 */ 1, 2, 362, 426, 33, 393, 35, 430, 4, 397, + /* 110 */ 363, 371, 400, 401, 402, 403, 404, 405, 118, 407, + /* 120 */ 58, 63, 445, 446, 412, 33, 414, 450, 451, 58, + /* 130 */ 418, 419, 132, 133, 63, 14, 15, 16, 62, 105, + /* 140 */ 48, 70, 399, 332, 432, 357, 54, 55, 56, 57, + /* 150 */ 58, 366, 440, 338, 369, 370, 368, 96, 96, 355, + /* 160 */ 98, 161, 162, 132, 133, 355, 362, 96, 425, 422, + /* 170 */ 423, 424, 362, 426, 427, 371, 361, 430, 20, 128, + /* 180 */ 180, 371, 182, 372, 396, 397, 398, 95, 20, 118, + /* 190 */ 98, 363, 445, 446, 160, 407, 97, 450, 451, 324, + /* 200 */ 96, 14, 374, 132, 133, 205, 206, 20, 208, 209, /* 210 */ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, - /* 220 */ 220, 221, 222, 223, 224, 369, 391, 95, 394, 395, - /* 230 */ 395, 413, 414, 398, 399, 400, 401, 402, 403, 405, - /* 240 */ 405, 18, 20, 20, 20, 410, 352, 412, 365, 117, - /* 250 */ 27, 416, 417, 30, 8, 9, 242, 335, 12, 13, - /* 260 */ 14, 15, 16, 131, 132, 57, 20, 354, 374, 20, - /* 270 */ 47, 349, 49, 438, 354, 52, 12, 13, 365, 264, - /* 280 */ 358, 64, 65, 66, 20, 365, 22, 0, 95, 72, - /* 290 */ 73, 159, 160, 330, 77, 78, 344, 33, 35, 35, - /* 300 */ 83, 84, 20, 95, 352, 97, 89, 394, 395, 396, - /* 310 */ 178, 242, 180, 361, 394, 395, 14, 94, 405, 95, - /* 320 */ 344, 57, 20, 360, 14, 405, 62, 20, 352, 106, - /* 330 */ 20, 242, 69, 69, 47, 203, 204, 361, 206, 207, - /* 340 */ 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, - /* 350 */ 218, 219, 220, 221, 222, 223, 224, 134, 226, 95, - /* 360 */ 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, - /* 370 */ 147, 148, 149, 150, 151, 152, 153, 95, 155, 156, - /* 380 */ 157, 117, 419, 420, 421, 422, 14, 424, 425, 20, - /* 390 */ 330, 33, 20, 8, 9, 131, 132, 12, 13, 14, - /* 400 */ 15, 16, 424, 343, 330, 47, 428, 161, 12, 13, - /* 410 */ 14, 53, 54, 55, 56, 57, 20, 343, 22, 259, - /* 420 */ 360, 397, 444, 159, 160, 164, 448, 449, 43, 33, - /* 430 */ 352, 35, 0, 352, 360, 242, 106, 359, 352, 0, - /* 440 */ 359, 226, 178, 228, 180, 359, 368, 423, 95, 368, - /* 450 */ 242, 226, 94, 57, 368, 97, 24, 25, 26, 27, - /* 460 */ 28, 29, 30, 31, 32, 69, 242, 203, 204, 159, - /* 470 */ 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, - /* 480 */ 216, 217, 218, 219, 220, 221, 222, 223, 224, 1, - /* 490 */ 2, 95, 366, 367, 126, 127, 4, 8, 9, 352, - /* 500 */ 322, 12, 13, 14, 15, 16, 330, 360, 247, 248, - /* 510 */ 424, 19, 327, 117, 428, 330, 173, 126, 69, 343, - /* 520 */ 162, 163, 20, 165, 22, 33, 168, 131, 132, 443, - /* 530 */ 444, 159, 330, 69, 448, 449, 360, 194, 195, 47, - /* 540 */ 12, 13, 184, 365, 52, 343, 107, 400, 20, 57, - /* 550 */ 22, 62, 50, 322, 186, 159, 160, 189, 330, 191, - /* 560 */ 330, 33, 360, 35, 330, 126, 127, 128, 129, 130, - /* 570 */ 409, 330, 411, 343, 178, 158, 180, 343, 187, 188, - /* 580 */ 338, 339, 322, 352, 96, 57, 94, 57, 360, 97, - /* 590 */ 360, 360, 203, 104, 360, 242, 365, 69, 367, 203, - /* 600 */ 204, 360, 206, 207, 208, 209, 210, 211, 212, 213, - /* 610 */ 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, - /* 620 */ 224, 330, 391, 95, 94, 365, 395, 97, 353, 398, - /* 630 */ 399, 400, 401, 402, 403, 404, 405, 406, 407, 20, - /* 640 */ 251, 252, 253, 254, 255, 117, 229, 158, 420, 421, - /* 650 */ 422, 360, 424, 425, 327, 408, 239, 330, 411, 131, - /* 660 */ 132, 420, 421, 422, 322, 424, 425, 322, 330, 428, - /* 670 */ 8, 9, 12, 13, 12, 13, 14, 15, 16, 330, - /* 680 */ 20, 343, 22, 333, 443, 444, 367, 159, 160, 448, - /* 690 */ 449, 345, 343, 33, 348, 35, 8, 9, 360, 380, - /* 700 */ 12, 13, 14, 15, 16, 355, 178, 365, 180, 360, - /* 710 */ 365, 420, 421, 422, 322, 424, 425, 57, 229, 230, - /* 720 */ 231, 232, 233, 234, 235, 236, 237, 238, 239, 69, - /* 730 */ 353, 203, 204, 322, 206, 207, 208, 209, 210, 211, - /* 740 */ 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, - /* 750 */ 222, 223, 224, 322, 2, 95, 351, 365, 96, 330, - /* 760 */ 8, 9, 335, 352, 12, 13, 14, 15, 16, 364, - /* 770 */ 22, 360, 343, 330, 4, 330, 365, 117, 367, 360, - /* 780 */ 161, 322, 22, 35, 96, 358, 343, 2, 343, 360, - /* 790 */ 371, 131, 132, 8, 9, 35, 365, 12, 13, 14, - /* 800 */ 15, 16, 391, 360, 360, 360, 395, 338, 339, 398, - /* 810 */ 399, 400, 401, 402, 403, 371, 405, 69, 322, 159, - /* 820 */ 160, 0, 21, 412, 365, 8, 9, 416, 417, 12, - /* 830 */ 13, 14, 15, 16, 409, 34, 411, 36, 178, 353, - /* 840 */ 180, 108, 109, 110, 111, 112, 113, 114, 115, 116, - /* 850 */ 117, 118, 353, 120, 121, 122, 123, 124, 125, 353, - /* 860 */ 379, 365, 381, 203, 204, 117, 206, 207, 208, 209, - /* 870 */ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, - /* 880 */ 220, 221, 222, 223, 224, 64, 65, 66, 67, 68, - /* 890 */ 20, 70, 71, 72, 73, 74, 75, 76, 77, 78, - /* 900 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, - /* 910 */ 89, 90, 91, 18, 330, 0, 322, 353, 23, 383, - /* 920 */ 322, 20, 352, 322, 322, 322, 178, 343, 180, 322, - /* 930 */ 397, 322, 37, 38, 322, 379, 41, 381, 368, 322, - /* 940 */ 353, 8, 9, 322, 360, 12, 13, 14, 15, 16, - /* 950 */ 352, 203, 204, 58, 59, 60, 423, 330, 360, 365, - /* 960 */ 424, 39, 330, 365, 428, 367, 365, 365, 365, 0, - /* 970 */ 343, 20, 365, 352, 365, 343, 61, 365, 161, 443, - /* 980 */ 444, 360, 365, 360, 448, 449, 365, 360, 367, 391, - /* 990 */ 95, 37, 360, 395, 371, 43, 398, 399, 400, 401, - /* 1000 */ 402, 403, 352, 405, 330, 340, 362, 342, 410, 365, - /* 1010 */ 412, 361, 391, 243, 416, 417, 395, 343, 0, 398, - /* 1020 */ 399, 400, 401, 402, 403, 427, 405, 43, 133, 159, - /* 1030 */ 61, 410, 0, 412, 360, 12, 13, 416, 417, 362, - /* 1040 */ 127, 322, 365, 345, 387, 22, 348, 330, 427, 44, - /* 1050 */ 45, 330, 98, 107, 100, 101, 33, 103, 35, 106, - /* 1060 */ 343, 107, 161, 107, 343, 170, 171, 172, 240, 241, - /* 1070 */ 175, 352, 126, 127, 128, 129, 130, 360, 35, 360, - /* 1080 */ 57, 360, 341, 129, 365, 129, 367, 0, 193, 42, - /* 1090 */ 43, 196, 69, 198, 199, 200, 201, 202, 185, 186, - /* 1100 */ 322, 57, 189, 330, 191, 42, 43, 154, 62, 22, - /* 1110 */ 391, 43, 161, 43, 395, 323, 343, 398, 399, 400, - /* 1120 */ 401, 402, 403, 0, 405, 131, 132, 1, 2, 410, - /* 1130 */ 352, 412, 43, 360, 0, 416, 417, 242, 360, 107, - /* 1140 */ 117, 97, 35, 365, 21, 367, 427, 24, 25, 26, - /* 1150 */ 27, 28, 29, 30, 31, 32, 22, 43, 126, 127, - /* 1160 */ 128, 129, 130, 241, 96, 99, 96, 149, 102, 391, - /* 1170 */ 0, 99, 99, 395, 102, 102, 398, 399, 400, 401, - /* 1180 */ 402, 403, 43, 405, 99, 96, 322, 102, 410, 13, - /* 1190 */ 412, 161, 22, 43, 416, 417, 166, 43, 43, 43, - /* 1200 */ 35, 178, 375, 180, 43, 46, 13, 452, 319, 441, - /* 1210 */ 96, 35, 331, 261, 435, 322, 352, 43, 43, 352, - /* 1220 */ 43, 331, 43, 180, 360, 43, 203, 204, 35, 365, - /* 1230 */ 43, 367, 375, 329, 69, 96, 364, 375, 215, 216, - /* 1240 */ 217, 218, 219, 220, 221, 352, 96, 263, 426, 203, - /* 1250 */ 96, 96, 96, 360, 95, 391, 445, 96, 365, 395, - /* 1260 */ 367, 418, 398, 399, 400, 401, 402, 403, 0, 405, - /* 1270 */ 96, 96, 383, 96, 410, 96, 412, 322, 96, 95, - /* 1280 */ 416, 417, 429, 96, 391, 244, 47, 180, 395, 105, - /* 1290 */ 393, 398, 399, 400, 401, 402, 403, 392, 405, 385, - /* 1300 */ 176, 42, 372, 410, 322, 412, 20, 352, 370, 416, - /* 1310 */ 417, 375, 372, 424, 20, 360, 48, 428, 158, 330, - /* 1320 */ 365, 330, 367, 93, 337, 330, 330, 330, 370, 372, - /* 1330 */ 370, 322, 443, 444, 352, 20, 324, 448, 449, 324, - /* 1340 */ 20, 335, 360, 367, 20, 335, 391, 365, 322, 367, - /* 1350 */ 395, 389, 382, 398, 399, 400, 401, 402, 403, 20, - /* 1360 */ 405, 352, 384, 335, 335, 382, 335, 412, 335, 360, - /* 1370 */ 330, 416, 417, 391, 365, 324, 367, 395, 352, 51, - /* 1380 */ 398, 399, 400, 401, 402, 403, 360, 405, 335, 332, - /* 1390 */ 332, 365, 330, 367, 412, 192, 383, 352, 416, 417, - /* 1400 */ 391, 352, 322, 324, 395, 389, 352, 398, 399, 400, - /* 1410 */ 401, 402, 403, 352, 405, 365, 352, 391, 183, 250, - /* 1420 */ 330, 395, 388, 352, 398, 399, 400, 401, 402, 403, - /* 1430 */ 352, 405, 352, 333, 352, 352, 352, 424, 352, 333, - /* 1440 */ 360, 428, 390, 367, 375, 365, 249, 367, 439, 440, - /* 1450 */ 383, 434, 375, 365, 434, 256, 443, 444, 322, 365, - /* 1460 */ 365, 448, 449, 365, 383, 169, 258, 257, 432, 378, - /* 1470 */ 378, 391, 437, 436, 245, 395, 450, 451, 398, 399, - /* 1480 */ 400, 401, 402, 403, 265, 405, 393, 431, 352, 434, - /* 1490 */ 262, 424, 412, 433, 260, 428, 360, 417, 241, 20, - /* 1500 */ 360, 365, 322, 367, 382, 424, 397, 378, 383, 428, - /* 1510 */ 443, 444, 453, 330, 333, 448, 449, 365, 322, 378, - /* 1520 */ 163, 447, 365, 365, 443, 444, 360, 391, 365, 448, - /* 1530 */ 449, 395, 352, 365, 398, 399, 400, 401, 402, 403, - /* 1540 */ 360, 405, 446, 365, 333, 365, 348, 367, 352, 424, - /* 1550 */ 333, 95, 415, 428, 95, 365, 360, 356, 342, 333, - /* 1560 */ 36, 365, 376, 367, 346, 325, 330, 324, 443, 444, - /* 1570 */ 381, 391, 320, 448, 449, 395, 440, 386, 398, 399, - /* 1580 */ 400, 401, 402, 403, 346, 405, 322, 391, 346, 334, - /* 1590 */ 0, 395, 0, 185, 398, 399, 400, 401, 402, 403, - /* 1600 */ 0, 405, 0, 322, 42, 0, 35, 197, 35, 35, - /* 1610 */ 35, 197, 0, 35, 35, 197, 352, 0, 197, 0, - /* 1620 */ 35, 357, 442, 0, 360, 22, 0, 180, 35, 365, - /* 1630 */ 178, 367, 0, 352, 0, 174, 173, 0, 0, 0, - /* 1640 */ 46, 360, 35, 42, 0, 0, 365, 451, 367, 0, - /* 1650 */ 0, 0, 0, 0, 0, 391, 0, 322, 0, 395, - /* 1660 */ 149, 0, 398, 399, 400, 401, 402, 403, 149, 405, - /* 1670 */ 0, 0, 391, 322, 0, 0, 395, 0, 0, 398, - /* 1680 */ 399, 400, 401, 402, 403, 0, 405, 352, 407, 0, - /* 1690 */ 0, 0, 357, 0, 0, 360, 39, 42, 0, 0, - /* 1700 */ 365, 0, 367, 352, 0, 0, 0, 0, 357, 0, - /* 1710 */ 22, 360, 43, 46, 35, 0, 365, 322, 367, 0, - /* 1720 */ 0, 0, 0, 57, 0, 57, 391, 0, 0, 42, - /* 1730 */ 395, 14, 14, 398, 399, 400, 401, 402, 403, 0, - /* 1740 */ 405, 46, 391, 40, 322, 0, 395, 352, 0, 398, - /* 1750 */ 399, 400, 401, 402, 403, 360, 405, 0, 169, 0, - /* 1760 */ 365, 0, 367, 0, 39, 39, 0, 0, 35, 39, - /* 1770 */ 47, 322, 0, 63, 352, 35, 47, 39, 0, 35, - /* 1780 */ 39, 47, 360, 47, 35, 39, 391, 365, 0, 367, - /* 1790 */ 395, 0, 0, 398, 399, 400, 401, 402, 403, 0, - /* 1800 */ 405, 352, 0, 35, 104, 0, 22, 22, 35, 360, - /* 1810 */ 102, 35, 35, 391, 365, 322, 367, 395, 43, 22, - /* 1820 */ 398, 399, 400, 401, 402, 403, 0, 405, 35, 43, - /* 1830 */ 35, 35, 0, 35, 22, 22, 49, 0, 22, 35, - /* 1840 */ 391, 0, 35, 0, 395, 352, 35, 398, 399, 400, - /* 1850 */ 401, 402, 403, 360, 405, 0, 22, 95, 365, 322, - /* 1860 */ 367, 96, 20, 0, 35, 0, 22, 181, 0, 0, - /* 1870 */ 3, 43, 161, 246, 161, 95, 95, 163, 96, 322, - /* 1880 */ 3, 43, 43, 167, 391, 96, 96, 246, 395, 352, - /* 1890 */ 96, 398, 399, 400, 401, 402, 403, 360, 405, 46, - /* 1900 */ 43, 95, 365, 161, 367, 46, 246, 43, 35, 352, - /* 1910 */ 95, 35, 95, 95, 35, 96, 96, 360, 35, 35, - /* 1920 */ 35, 96, 365, 96, 367, 43, 46, 46, 391, 0, - /* 1930 */ 0, 0, 395, 190, 35, 398, 399, 400, 401, 402, - /* 1940 */ 403, 95, 405, 96, 322, 96, 95, 35, 391, 0, - /* 1950 */ 0, 95, 395, 95, 39, 398, 399, 400, 401, 402, - /* 1960 */ 403, 95, 405, 46, 322, 164, 105, 46, 43, 2, - /* 1970 */ 162, 240, 225, 22, 352, 22, 225, 227, 46, 46, - /* 1980 */ 106, 95, 360, 96, 95, 107, 96, 365, 95, 367, - /* 1990 */ 96, 95, 95, 35, 352, 35, 96, 95, 35, 96, - /* 2000 */ 95, 95, 360, 203, 96, 96, 35, 365, 205, 367, - /* 2010 */ 96, 95, 35, 391, 95, 35, 96, 395, 322, 95, - /* 2020 */ 398, 399, 400, 401, 402, 403, 119, 405, 22, 119, - /* 2030 */ 119, 95, 119, 391, 322, 95, 35, 395, 95, 43, - /* 2040 */ 398, 399, 400, 401, 402, 403, 22, 405, 352, 63, - /* 2050 */ 62, 35, 35, 35, 35, 35, 360, 35, 35, 69, - /* 2060 */ 35, 365, 35, 367, 352, 35, 92, 35, 35, 43, - /* 2070 */ 22, 35, 360, 22, 35, 35, 35, 365, 322, 367, - /* 2080 */ 69, 35, 35, 22, 35, 35, 0, 391, 35, 35, - /* 2090 */ 35, 395, 47, 0, 398, 399, 400, 401, 402, 403, - /* 2100 */ 35, 405, 39, 391, 0, 322, 47, 395, 352, 39, - /* 2110 */ 398, 399, 400, 401, 402, 403, 360, 405, 35, 47, - /* 2120 */ 39, 365, 0, 367, 35, 47, 39, 0, 0, 35, - /* 2130 */ 35, 22, 322, 21, 21, 352, 22, 22, 20, 454, - /* 2140 */ 454, 454, 454, 360, 454, 454, 454, 391, 365, 454, - /* 2150 */ 367, 395, 454, 454, 398, 399, 400, 401, 402, 403, - /* 2160 */ 454, 405, 352, 454, 454, 454, 454, 454, 454, 454, - /* 2170 */ 360, 454, 454, 454, 391, 365, 322, 367, 395, 454, - /* 2180 */ 454, 398, 399, 400, 401, 402, 403, 454, 405, 454, - /* 2190 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2200 */ 454, 391, 454, 454, 454, 395, 352, 454, 398, 399, - /* 2210 */ 400, 401, 402, 403, 360, 405, 454, 454, 454, 365, - /* 2220 */ 322, 367, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2230 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2240 */ 322, 454, 454, 454, 454, 391, 454, 454, 454, 395, - /* 2250 */ 352, 454, 398, 399, 400, 401, 402, 403, 360, 405, - /* 2260 */ 454, 454, 454, 365, 454, 367, 454, 454, 454, 454, - /* 2270 */ 352, 454, 454, 454, 454, 454, 454, 454, 360, 454, - /* 2280 */ 454, 454, 454, 365, 454, 367, 454, 454, 454, 391, - /* 2290 */ 454, 454, 454, 395, 454, 454, 398, 399, 400, 401, - /* 2300 */ 402, 403, 454, 405, 454, 322, 454, 454, 454, 391, - /* 2310 */ 454, 454, 454, 395, 454, 454, 398, 399, 400, 401, - /* 2320 */ 402, 403, 454, 405, 454, 322, 454, 454, 454, 454, - /* 2330 */ 454, 454, 454, 454, 454, 352, 454, 454, 454, 454, - /* 2340 */ 454, 454, 454, 360, 454, 454, 454, 454, 365, 454, - /* 2350 */ 367, 454, 454, 454, 454, 352, 454, 454, 454, 454, - /* 2360 */ 454, 454, 454, 360, 454, 454, 454, 454, 365, 454, - /* 2370 */ 367, 454, 454, 454, 391, 454, 454, 454, 395, 322, - /* 2380 */ 454, 398, 399, 400, 401, 402, 403, 454, 405, 454, - /* 2390 */ 454, 454, 454, 454, 391, 322, 454, 454, 395, 454, - /* 2400 */ 454, 398, 399, 400, 401, 402, 403, 454, 405, 352, - /* 2410 */ 454, 454, 454, 454, 454, 454, 454, 360, 454, 454, - /* 2420 */ 454, 454, 365, 454, 367, 352, 454, 454, 454, 454, - /* 2430 */ 454, 454, 454, 360, 454, 454, 454, 454, 365, 322, - /* 2440 */ 367, 454, 454, 454, 454, 454, 454, 454, 391, 454, - /* 2450 */ 454, 454, 395, 19, 454, 398, 399, 400, 401, 402, - /* 2460 */ 403, 454, 405, 454, 391, 454, 322, 33, 395, 352, - /* 2470 */ 454, 398, 399, 400, 401, 402, 403, 360, 405, 454, - /* 2480 */ 454, 47, 365, 454, 367, 454, 454, 53, 54, 55, - /* 2490 */ 56, 57, 454, 454, 454, 454, 352, 454, 454, 454, - /* 2500 */ 454, 454, 454, 454, 360, 454, 454, 454, 391, 365, - /* 2510 */ 454, 367, 395, 454, 454, 398, 399, 400, 401, 402, - /* 2520 */ 403, 454, 405, 454, 454, 454, 454, 454, 94, 454, - /* 2530 */ 454, 97, 454, 454, 454, 391, 454, 454, 454, 395, - /* 2540 */ 454, 454, 398, 399, 400, 401, 402, 403, 454, 405, - /* 2550 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2560 */ 454, 454, 454, 454, 130, 454, 454, 454, 454, 454, - /* 2570 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2580 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2590 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 165, - /* 2600 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2610 */ 454, 454, 454, 454, 454, 454, 182, 454, 184, 454, - /* 2620 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2630 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2640 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2650 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2660 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2670 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2680 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2690 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2700 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2710 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2720 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2730 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2740 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2750 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2760 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 2770 */ 454, 454, 454, + /* 220 */ 220, 221, 222, 223, 224, 225, 226, 65, 66, 67, + /* 230 */ 426, 20, 161, 162, 430, 73, 74, 20, 187, 188, + /* 240 */ 78, 79, 191, 368, 193, 321, 84, 85, 4, 445, + /* 250 */ 446, 180, 90, 182, 450, 451, 164, 165, 324, 167, + /* 260 */ 80, 166, 170, 205, 205, 231, 232, 233, 234, 235, + /* 270 */ 236, 237, 238, 239, 240, 241, 205, 206, 186, 208, + /* 280 */ 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, + /* 290 */ 219, 220, 221, 222, 223, 224, 225, 226, 354, 228, + /* 300 */ 12, 13, 368, 341, 342, 244, 244, 96, 20, 385, + /* 310 */ 22, 367, 253, 254, 255, 256, 257, 137, 138, 161, + /* 320 */ 162, 33, 324, 35, 109, 110, 111, 112, 113, 114, + /* 330 */ 115, 116, 117, 118, 119, 20, 121, 122, 123, 124, + /* 340 */ 125, 126, 175, 336, 249, 250, 58, 20, 244, 22, + /* 350 */ 426, 63, 329, 355, 430, 332, 333, 350, 70, 341, + /* 360 */ 342, 363, 35, 196, 197, 358, 368, 44, 370, 445, + /* 370 */ 446, 12, 13, 14, 450, 451, 2, 355, 51, 20, + /* 380 */ 163, 22, 8, 9, 96, 363, 12, 13, 14, 15, + /* 390 */ 16, 393, 33, 329, 35, 397, 332, 333, 400, 401, + /* 400 */ 402, 403, 404, 405, 332, 407, 118, 324, 8, 9, + /* 410 */ 399, 96, 12, 13, 14, 15, 16, 58, 346, 127, + /* 420 */ 132, 133, 108, 163, 402, 353, 8, 9, 168, 70, + /* 430 */ 12, 13, 14, 15, 16, 363, 425, 35, 355, 441, + /* 440 */ 442, 127, 128, 129, 130, 131, 363, 336, 370, 161, + /* 450 */ 162, 368, 96, 370, 426, 96, 242, 243, 430, 8, + /* 460 */ 9, 383, 20, 12, 13, 14, 15, 16, 180, 358, + /* 470 */ 182, 20, 70, 445, 446, 324, 393, 118, 450, 451, + /* 480 */ 397, 189, 190, 400, 401, 402, 403, 404, 405, 245, + /* 490 */ 407, 132, 133, 205, 206, 96, 208, 209, 210, 211, + /* 500 */ 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, + /* 510 */ 222, 223, 224, 225, 226, 97, 4, 324, 324, 368, + /* 520 */ 161, 162, 0, 21, 45, 46, 24, 25, 26, 27, + /* 530 */ 28, 29, 30, 31, 32, 452, 453, 127, 128, 180, + /* 540 */ 228, 182, 230, 21, 0, 324, 24, 25, 26, 27, + /* 550 */ 28, 29, 30, 31, 32, 43, 20, 45, 46, 244, + /* 560 */ 62, 368, 368, 163, 205, 206, 160, 208, 209, 210, + /* 570 */ 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, + /* 580 */ 221, 222, 223, 224, 225, 226, 12, 13, 265, 368, + /* 590 */ 19, 4, 20, 20, 20, 22, 22, 363, 188, 332, + /* 600 */ 244, 191, 332, 193, 33, 14, 19, 33, 374, 35, + /* 610 */ 324, 20, 96, 346, 163, 107, 346, 332, 324, 48, + /* 620 */ 33, 228, 332, 353, 51, 54, 55, 56, 57, 58, + /* 630 */ 363, 346, 58, 363, 347, 48, 338, 231, 355, 70, + /* 640 */ 53, 355, 355, 244, 70, 58, 70, 241, 363, 363, + /* 650 */ 352, 364, 108, 363, 368, 0, 370, 12, 13, 361, + /* 660 */ 377, 0, 368, 332, 324, 20, 95, 22, 0, 98, + /* 670 */ 96, 127, 128, 129, 130, 131, 356, 346, 33, 393, + /* 680 */ 35, 324, 95, 397, 356, 98, 400, 401, 402, 403, + /* 690 */ 404, 405, 118, 407, 363, 179, 410, 181, 412, 413, + /* 700 */ 414, 347, 131, 58, 418, 419, 132, 133, 368, 355, + /* 710 */ 389, 421, 422, 423, 424, 70, 426, 427, 364, 356, + /* 720 */ 65, 66, 67, 62, 58, 368, 14, 332, 73, 74, + /* 730 */ 62, 324, 20, 78, 79, 161, 162, 324, 167, 84, + /* 740 */ 85, 96, 0, 8, 9, 90, 20, 12, 13, 14, + /* 750 */ 15, 16, 161, 20, 180, 184, 182, 186, 363, 348, + /* 760 */ 244, 95, 351, 118, 98, 357, 24, 25, 26, 27, + /* 770 */ 28, 29, 30, 31, 32, 368, 368, 132, 133, 205, + /* 780 */ 206, 368, 208, 209, 210, 211, 212, 213, 214, 215, + /* 790 */ 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, + /* 800 */ 226, 18, 108, 20, 396, 397, 161, 162, 324, 363, + /* 810 */ 27, 399, 411, 30, 413, 407, 33, 422, 423, 424, + /* 820 */ 374, 426, 427, 355, 130, 180, 0, 182, 324, 0, + /* 830 */ 324, 48, 97, 50, 2, 410, 53, 425, 413, 371, + /* 840 */ 8, 9, 324, 324, 12, 13, 14, 15, 16, 356, + /* 850 */ 205, 206, 368, 208, 209, 210, 211, 212, 213, 214, + /* 860 */ 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, + /* 870 */ 225, 226, 368, 161, 368, 8, 9, 48, 95, 12, + /* 880 */ 13, 14, 15, 16, 20, 365, 368, 368, 368, 163, + /* 890 */ 107, 65, 66, 67, 68, 69, 163, 71, 72, 73, + /* 900 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, + /* 910 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 136, + /* 920 */ 324, 324, 139, 140, 141, 142, 143, 144, 145, 146, + /* 930 */ 147, 148, 149, 150, 151, 152, 153, 154, 155, 3, + /* 940 */ 157, 158, 159, 18, 411, 332, 413, 332, 23, 8, + /* 950 */ 9, 44, 355, 12, 13, 14, 15, 16, 332, 346, + /* 960 */ 363, 346, 37, 38, 368, 368, 41, 370, 382, 385, + /* 970 */ 384, 3, 346, 44, 324, 324, 363, 382, 363, 384, + /* 980 */ 324, 332, 1, 2, 59, 60, 61, 0, 20, 363, + /* 990 */ 393, 332, 332, 365, 397, 346, 368, 400, 401, 402, + /* 1000 */ 403, 404, 405, 39, 407, 355, 346, 0, 356, 412, + /* 1010 */ 426, 414, 363, 363, 430, 418, 419, 344, 368, 368, + /* 1020 */ 370, 96, 363, 363, 368, 161, 97, 332, 348, 445, + /* 1030 */ 446, 351, 332, 100, 450, 451, 103, 440, 357, 172, + /* 1040 */ 356, 346, 332, 393, 58, 100, 346, 397, 103, 368, + /* 1050 */ 400, 401, 402, 403, 404, 405, 346, 407, 363, 134, + /* 1060 */ 332, 324, 412, 363, 414, 97, 12, 13, 418, 419, + /* 1070 */ 343, 356, 345, 363, 346, 35, 22, 396, 397, 429, + /* 1080 */ 332, 422, 423, 424, 98, 426, 427, 33, 407, 35, + /* 1090 */ 325, 363, 355, 22, 346, 108, 107, 172, 173, 174, + /* 1100 */ 363, 42, 177, 44, 324, 368, 35, 370, 42, 378, + /* 1110 */ 44, 363, 58, 443, 127, 128, 129, 130, 131, 35, + /* 1120 */ 195, 357, 332, 198, 70, 200, 201, 202, 203, 204, + /* 1130 */ 393, 163, 368, 266, 397, 355, 346, 400, 401, 402, + /* 1140 */ 403, 404, 405, 363, 407, 156, 0, 96, 368, 412, + /* 1150 */ 370, 414, 454, 363, 0, 418, 419, 106, 151, 334, + /* 1160 */ 396, 397, 398, 385, 100, 332, 429, 103, 22, 244, + /* 1170 */ 263, 407, 118, 393, 332, 324, 22, 397, 44, 346, + /* 1180 */ 400, 401, 402, 403, 404, 405, 332, 407, 346, 332, + /* 1190 */ 0, 47, 412, 437, 414, 355, 363, 261, 418, 419, + /* 1200 */ 346, 332, 334, 346, 426, 363, 355, 243, 430, 429, + /* 1210 */ 132, 133, 22, 100, 363, 346, 103, 363, 324, 368, + /* 1220 */ 363, 370, 182, 445, 446, 44, 44, 44, 450, 451, + /* 1230 */ 44, 97, 363, 44, 180, 44, 182, 44, 378, 331, + /* 1240 */ 96, 367, 428, 378, 393, 447, 35, 420, 397, 355, + /* 1250 */ 44, 400, 401, 402, 403, 404, 405, 363, 407, 205, + /* 1260 */ 206, 324, 368, 412, 370, 414, 182, 44, 44, 418, + /* 1270 */ 419, 217, 218, 219, 220, 221, 222, 223, 97, 97, + /* 1280 */ 97, 70, 246, 97, 0, 324, 97, 393, 97, 13, + /* 1290 */ 97, 397, 355, 44, 400, 401, 402, 403, 404, 405, + /* 1300 */ 363, 407, 431, 97, 44, 368, 412, 370, 414, 395, + /* 1310 */ 48, 35, 418, 419, 13, 394, 355, 44, 44, 22, + /* 1320 */ 97, 97, 387, 178, 363, 42, 375, 20, 378, 368, + /* 1330 */ 393, 370, 35, 49, 397, 37, 35, 400, 401, 402, + /* 1340 */ 403, 404, 405, 324, 407, 375, 97, 160, 373, 412, + /* 1350 */ 20, 414, 332, 332, 393, 418, 419, 97, 397, 375, + /* 1360 */ 94, 400, 401, 402, 403, 404, 405, 70, 407, 373, + /* 1370 */ 97, 97, 373, 340, 355, 414, 332, 332, 332, 418, + /* 1380 */ 419, 20, 363, 326, 326, 20, 324, 368, 391, 370, + /* 1390 */ 338, 338, 370, 20, 333, 20, 386, 99, 338, 101, + /* 1400 */ 102, 333, 104, 338, 332, 338, 108, 338, 338, 52, + /* 1410 */ 335, 335, 393, 326, 324, 118, 397, 355, 355, 400, + /* 1420 */ 401, 402, 403, 404, 405, 363, 407, 332, 130, 355, + /* 1430 */ 368, 326, 370, 414, 355, 355, 355, 418, 419, 194, + /* 1440 */ 355, 355, 392, 355, 355, 355, 355, 355, 336, 185, + /* 1450 */ 368, 336, 332, 363, 252, 393, 251, 258, 368, 397, + /* 1460 */ 370, 378, 400, 401, 402, 403, 404, 405, 391, 407, + /* 1470 */ 370, 378, 368, 324, 436, 368, 414, 180, 381, 182, + /* 1480 */ 418, 419, 381, 393, 390, 436, 368, 397, 171, 368, + /* 1490 */ 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, + /* 1500 */ 260, 259, 205, 206, 355, 247, 395, 264, 267, 262, + /* 1510 */ 455, 438, 363, 243, 363, 20, 399, 368, 333, 370, + /* 1520 */ 332, 381, 381, 368, 368, 368, 368, 368, 336, 368, + /* 1530 */ 336, 324, 165, 434, 436, 439, 433, 435, 363, 379, + /* 1540 */ 336, 96, 393, 417, 96, 368, 397, 351, 345, 400, + /* 1550 */ 401, 402, 403, 404, 405, 449, 407, 448, 332, 324, + /* 1560 */ 359, 336, 355, 414, 36, 327, 388, 349, 419, 349, + /* 1570 */ 363, 349, 326, 337, 322, 368, 0, 370, 0, 384, + /* 1580 */ 187, 0, 0, 42, 0, 324, 35, 199, 35, 35, + /* 1590 */ 355, 35, 0, 199, 35, 35, 199, 0, 363, 199, + /* 1600 */ 393, 0, 35, 368, 397, 370, 0, 400, 401, 402, + /* 1610 */ 403, 404, 405, 0, 407, 22, 355, 182, 35, 180, + /* 1620 */ 0, 0, 176, 0, 363, 175, 0, 47, 393, 368, + /* 1630 */ 0, 370, 397, 0, 0, 400, 401, 402, 403, 404, + /* 1640 */ 405, 42, 407, 0, 0, 0, 0, 0, 0, 442, + /* 1650 */ 0, 0, 151, 35, 393, 324, 0, 151, 397, 0, + /* 1660 */ 0, 400, 401, 402, 403, 404, 405, 0, 407, 0, + /* 1670 */ 0, 0, 0, 0, 324, 22, 0, 42, 0, 444, + /* 1680 */ 0, 0, 0, 0, 0, 0, 355, 0, 0, 0, + /* 1690 */ 0, 360, 135, 0, 363, 0, 0, 0, 0, 368, + /* 1700 */ 35, 370, 0, 0, 0, 355, 0, 58, 42, 47, + /* 1710 */ 58, 47, 44, 363, 453, 14, 39, 0, 368, 14, + /* 1720 */ 370, 47, 0, 0, 393, 0, 40, 0, 397, 171, + /* 1730 */ 39, 400, 401, 402, 403, 404, 405, 324, 407, 39, + /* 1740 */ 0, 0, 0, 393, 0, 35, 39, 397, 0, 35, + /* 1750 */ 400, 401, 402, 403, 404, 405, 48, 407, 324, 409, + /* 1760 */ 48, 0, 0, 64, 35, 39, 48, 39, 355, 35, + /* 1770 */ 39, 0, 48, 360, 0, 0, 363, 0, 35, 22, + /* 1780 */ 324, 368, 0, 370, 105, 35, 35, 22, 35, 355, + /* 1790 */ 35, 44, 22, 44, 360, 35, 0, 363, 35, 35, + /* 1800 */ 22, 324, 368, 0, 370, 22, 393, 0, 50, 22, + /* 1810 */ 397, 355, 103, 400, 401, 402, 403, 404, 405, 363, + /* 1820 */ 407, 35, 0, 324, 368, 35, 370, 393, 0, 35, + /* 1830 */ 0, 397, 355, 22, 400, 401, 402, 403, 404, 405, + /* 1840 */ 363, 407, 97, 20, 324, 368, 0, 370, 96, 393, + /* 1850 */ 35, 0, 0, 397, 355, 22, 400, 401, 402, 403, + /* 1860 */ 404, 405, 363, 407, 0, 44, 3, 368, 96, 370, + /* 1870 */ 393, 44, 248, 97, 397, 355, 163, 400, 401, 402, + /* 1880 */ 403, 404, 405, 363, 407, 165, 97, 324, 368, 96, + /* 1890 */ 370, 96, 393, 163, 183, 163, 397, 97, 97, 400, + /* 1900 */ 401, 402, 403, 404, 405, 169, 407, 47, 96, 96, + /* 1910 */ 44, 44, 47, 393, 96, 324, 3, 397, 355, 44, + /* 1920 */ 400, 401, 402, 403, 404, 405, 363, 407, 97, 97, + /* 1930 */ 35, 368, 35, 370, 35, 35, 35, 35, 97, 97, + /* 1940 */ 47, 324, 248, 47, 0, 0, 355, 44, 0, 96, + /* 1950 */ 35, 97, 97, 96, 363, 35, 393, 242, 192, 368, + /* 1960 */ 397, 370, 0, 400, 401, 402, 403, 404, 405, 248, + /* 1970 */ 407, 166, 355, 96, 96, 0, 39, 96, 164, 106, + /* 1980 */ 363, 47, 44, 227, 393, 368, 2, 370, 397, 22, + /* 1990 */ 205, 400, 401, 402, 403, 404, 405, 229, 407, 324, + /* 2000 */ 227, 97, 96, 96, 47, 97, 96, 47, 97, 97, + /* 2010 */ 393, 207, 96, 96, 397, 22, 324, 400, 401, 402, + /* 2020 */ 403, 404, 405, 97, 407, 96, 107, 35, 96, 35, + /* 2030 */ 355, 35, 97, 97, 35, 96, 96, 35, 363, 97, + /* 2040 */ 97, 35, 96, 368, 120, 370, 96, 355, 120, 22, + /* 2050 */ 120, 120, 96, 35, 96, 363, 44, 108, 22, 324, + /* 2060 */ 368, 96, 370, 35, 64, 35, 63, 35, 393, 35, + /* 2070 */ 35, 70, 397, 35, 35, 400, 401, 402, 403, 404, + /* 2080 */ 405, 35, 407, 324, 35, 393, 35, 44, 93, 397, + /* 2090 */ 355, 35, 400, 401, 402, 403, 404, 405, 363, 407, + /* 2100 */ 35, 22, 35, 368, 22, 370, 35, 35, 22, 35, + /* 2110 */ 70, 35, 35, 35, 355, 35, 35, 0, 35, 35, + /* 2120 */ 0, 0, 363, 48, 39, 35, 324, 368, 393, 370, + /* 2130 */ 39, 39, 397, 35, 0, 400, 401, 402, 403, 404, + /* 2140 */ 405, 35, 407, 324, 48, 48, 39, 48, 0, 35, + /* 2150 */ 35, 0, 393, 22, 21, 20, 397, 355, 21, 400, + /* 2160 */ 401, 402, 403, 404, 405, 363, 407, 22, 22, 324, + /* 2170 */ 368, 456, 370, 456, 355, 456, 456, 456, 456, 456, + /* 2180 */ 456, 456, 363, 456, 456, 456, 324, 368, 456, 370, + /* 2190 */ 456, 456, 456, 456, 456, 393, 456, 456, 456, 397, + /* 2200 */ 355, 456, 400, 401, 402, 403, 404, 405, 363, 407, + /* 2210 */ 456, 456, 393, 368, 456, 370, 397, 355, 456, 400, + /* 2220 */ 401, 402, 403, 404, 405, 363, 407, 456, 456, 324, + /* 2230 */ 368, 456, 370, 456, 456, 456, 456, 456, 393, 456, + /* 2240 */ 456, 456, 397, 456, 456, 400, 401, 402, 403, 404, + /* 2250 */ 405, 324, 407, 456, 456, 393, 456, 456, 456, 397, + /* 2260 */ 355, 456, 400, 401, 402, 403, 404, 405, 363, 407, + /* 2270 */ 456, 456, 456, 368, 456, 370, 456, 456, 456, 456, + /* 2280 */ 456, 456, 355, 456, 456, 456, 456, 456, 456, 456, + /* 2290 */ 363, 456, 456, 456, 456, 368, 456, 370, 393, 456, + /* 2300 */ 456, 456, 397, 456, 456, 400, 401, 402, 403, 404, + /* 2310 */ 405, 456, 407, 324, 456, 456, 456, 456, 456, 456, + /* 2320 */ 393, 456, 456, 456, 397, 456, 456, 400, 401, 402, + /* 2330 */ 403, 404, 405, 456, 407, 324, 456, 456, 456, 456, + /* 2340 */ 456, 456, 456, 456, 355, 456, 456, 456, 456, 456, + /* 2350 */ 456, 456, 363, 456, 456, 456, 456, 368, 456, 370, + /* 2360 */ 456, 456, 456, 456, 456, 456, 355, 456, 456, 456, + /* 2370 */ 456, 456, 456, 456, 363, 456, 456, 456, 456, 368, + /* 2380 */ 456, 370, 393, 456, 456, 456, 397, 456, 456, 400, + /* 2390 */ 401, 402, 403, 404, 405, 456, 407, 324, 456, 456, + /* 2400 */ 456, 456, 456, 456, 393, 456, 456, 456, 397, 456, + /* 2410 */ 456, 400, 401, 402, 403, 404, 405, 324, 407, 456, + /* 2420 */ 456, 456, 456, 456, 456, 456, 456, 456, 355, 456, + /* 2430 */ 456, 456, 456, 456, 456, 456, 363, 456, 456, 456, + /* 2440 */ 456, 368, 456, 370, 456, 456, 456, 456, 355, 456, + /* 2450 */ 456, 456, 456, 456, 456, 456, 363, 456, 456, 456, + /* 2460 */ 324, 368, 456, 370, 456, 456, 393, 456, 456, 456, + /* 2470 */ 397, 456, 456, 400, 401, 402, 403, 404, 405, 456, + /* 2480 */ 407, 456, 456, 456, 456, 456, 393, 456, 456, 456, + /* 2490 */ 397, 355, 456, 400, 401, 402, 403, 404, 405, 363, + /* 2500 */ 407, 456, 456, 456, 368, 456, 370, 456, 456, 456, + /* 2510 */ 456, 456, 456, 456, 456, 456, 456, 456, 456, 456, + /* 2520 */ 456, 456, 456, 456, 456, 456, 456, 456, 456, 393, + /* 2530 */ 456, 456, 456, 397, 456, 456, 400, 401, 402, 403, + /* 2540 */ 404, 405, 456, 407, }; -#define YY_SHIFT_COUNT (703) +#define YY_SHIFT_COUNT (706) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2434) +#define YY_SHIFT_MAX (2151) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 895, 0, 132, 0, 264, 264, 264, 264, 264, 264, - /* 10 */ 264, 264, 264, 396, 528, 528, 660, 528, 528, 528, - /* 20 */ 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, - /* 30 */ 528, 528, 528, 528, 528, 528, 528, 528, 528, 528, - /* 40 */ 528, 528, 528, 528, 528, 528, 69, 224, 282, 14, - /* 50 */ 208, 193, 353, 193, 282, 282, 1023, 1023, 193, 1023, - /* 60 */ 1023, 89, 193, 71, 71, 23, 42, 42, 18, 71, - /* 70 */ 71, 71, 71, 71, 71, 71, 71, 71, 71, 129, - /* 80 */ 71, 71, 222, 71, 249, 71, 71, 307, 71, 71, - /* 90 */ 307, 71, 307, 307, 307, 71, 137, 223, 489, 489, - /* 100 */ 217, 145, 748, 748, 748, 748, 748, 748, 748, 748, - /* 110 */ 748, 748, 748, 748, 748, 748, 748, 748, 748, 748, - /* 120 */ 748, 954, 31, 23, 18, 302, 302, 915, 263, 619, - /* 130 */ 619, 619, 969, 215, 215, 263, 369, 369, 369, 330, - /* 140 */ 249, 16, 16, 225, 307, 307, 449, 449, 330, 464, - /* 150 */ 733, 733, 733, 733, 733, 733, 733, 2434, 64, 1123, - /* 160 */ 246, 15, 389, 38, 261, 310, 372, 502, 901, 1005, - /* 170 */ 956, 951, 828, 922, 160, 828, 1047, 770, 870, 1041, - /* 180 */ 1239, 1124, 1259, 1286, 1259, 1160, 1294, 1294, 1259, 1160, - /* 190 */ 1160, 1230, 1294, 1294, 1294, 1315, 1315, 1320, 129, 249, - /* 200 */ 129, 1324, 1339, 129, 1324, 129, 129, 129, 1294, 129, - /* 210 */ 1328, 1328, 1315, 307, 307, 307, 307, 307, 307, 307, - /* 220 */ 307, 307, 307, 307, 1294, 1315, 449, 1203, 1320, 137, - /* 230 */ 1235, 249, 137, 1294, 1286, 1286, 449, 1169, 1197, 449, - /* 240 */ 1169, 1197, 449, 449, 307, 1199, 1296, 1169, 1208, 1210, - /* 250 */ 1229, 1041, 1219, 1228, 1234, 1257, 369, 1479, 1294, 1324, - /* 260 */ 137, 1197, 449, 449, 449, 449, 449, 1197, 449, 1357, - /* 270 */ 137, 330, 137, 369, 1456, 1459, 449, 464, 1294, 137, - /* 280 */ 1524, 1315, 2619, 2619, 2619, 2619, 2619, 2619, 2619, 821, - /* 290 */ 358, 432, 492, 662, 385, 688, 752, 785, 817, 933, - /* 300 */ 933, 439, 933, 933, 933, 933, 933, 933, 933, 1032, - /* 310 */ 946, 913, 368, 109, 109, 343, 530, 61, 801, 391, - /* 320 */ 119, 488, 417, 119, 119, 119, 1068, 287, 760, 1063, - /* 330 */ 953, 1018, 1066, 1072, 1073, 1085, 1087, 1134, 1170, 1044, - /* 340 */ 1070, 1089, 994, 952, 984, 1030, 1114, 1139, 1150, 1154, - /* 350 */ 1155, 1126, 1156, 1043, 1107, 1046, 1161, 1159, 1174, 1175, - /* 360 */ 1177, 1179, 1182, 1187, 1184, 1176, 1193, 1165, 1268, 1590, - /* 370 */ 1592, 1408, 1600, 1602, 1562, 1605, 1571, 1410, 1573, 1574, - /* 380 */ 1575, 1414, 1612, 1578, 1579, 1418, 1617, 1421, 1619, 1585, - /* 390 */ 1623, 1603, 1626, 1593, 1447, 1452, 1632, 1634, 1461, 1463, - /* 400 */ 1637, 1638, 1594, 1639, 1649, 1650, 1601, 1644, 1645, 1651, - /* 410 */ 1652, 1653, 1654, 1656, 1658, 1511, 1607, 1661, 1519, 1670, - /* 420 */ 1671, 1674, 1675, 1677, 1678, 1685, 1689, 1690, 1691, 1693, - /* 430 */ 1694, 1701, 1704, 1705, 1655, 1698, 1699, 1706, 1707, 1709, - /* 440 */ 1688, 1719, 1720, 1721, 1722, 1679, 1715, 1666, 1724, 1668, - /* 450 */ 1727, 1728, 1687, 1657, 1669, 1717, 1667, 1718, 1695, 1739, - /* 460 */ 1703, 1725, 1745, 1748, 1757, 1726, 1589, 1759, 1761, 1763, - /* 470 */ 1710, 1766, 1767, 1733, 1723, 1730, 1772, 1740, 1729, 1738, - /* 480 */ 1778, 1744, 1734, 1741, 1788, 1749, 1736, 1746, 1791, 1792, - /* 490 */ 1799, 1802, 1700, 1708, 1768, 1784, 1805, 1773, 1776, 1785, - /* 500 */ 1777, 1793, 1775, 1786, 1795, 1796, 1797, 1798, 1826, 1812, - /* 510 */ 1832, 1813, 1787, 1837, 1816, 1804, 1841, 1807, 1843, 1811, - /* 520 */ 1855, 1834, 1842, 1765, 1762, 1863, 1711, 1829, 1865, 1686, - /* 530 */ 1844, 1713, 1714, 1868, 1869, 1742, 1716, 1867, 1828, 1627, - /* 540 */ 1780, 1782, 1781, 1789, 1838, 1790, 1806, 1815, 1817, 1794, - /* 550 */ 1839, 1853, 1859, 1818, 1857, 1641, 1819, 1820, 1877, 1864, - /* 560 */ 1660, 1873, 1876, 1879, 1883, 1884, 1885, 1825, 1827, 1880, - /* 570 */ 1731, 1882, 1881, 1929, 1930, 1931, 1846, 1847, 1849, 1851, - /* 580 */ 1899, 1912, 1743, 1949, 1856, 1801, 1858, 1950, 1915, 1808, - /* 590 */ 1866, 1861, 1917, 1921, 1925, 1747, 1750, 1751, 1967, 1951, - /* 600 */ 1800, 1886, 1887, 1889, 1890, 1893, 1894, 1932, 1896, 1897, - /* 610 */ 1933, 1900, 1953, 1803, 1902, 1874, 1903, 1958, 1960, 1905, - /* 620 */ 1908, 1963, 1906, 1909, 1971, 1916, 1914, 1977, 1919, 1920, - /* 630 */ 1980, 1924, 1907, 1910, 1911, 1913, 2006, 1878, 1936, 1940, - /* 640 */ 2001, 1943, 1996, 1996, 2024, 1986, 1988, 2016, 2017, 2018, - /* 650 */ 2019, 2020, 2022, 2023, 2025, 2027, 2030, 1990, 1974, 2026, - /* 660 */ 2032, 2033, 2048, 2036, 2051, 2039, 2040, 2041, 2011, 1775, - /* 670 */ 2046, 1786, 2047, 2049, 2050, 2053, 2061, 2054, 2086, 2055, - /* 680 */ 2045, 2063, 2093, 2065, 2059, 2070, 2104, 2083, 2072, 2081, - /* 690 */ 2122, 2089, 2078, 2087, 2127, 2094, 2095, 2128, 2109, 2112, - /* 700 */ 2114, 2115, 2113, 2118, + /* 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, 61, 315, 211, 516, + /* 50 */ 62, 356, 399, 356, 211, 211, 1054, 1054, 356, 1054, + /* 60 */ 1054, 104, 356, 12, 12, 512, 512, 158, 31, 187, + /* 70 */ 187, 12, 12, 12, 12, 12, 12, 12, 12, 12, + /* 80 */ 12, 76, 12, 12, 168, 12, 442, 12, 12, 536, + /* 90 */ 12, 12, 536, 12, 536, 536, 536, 12, 498, 783, + /* 100 */ 34, 34, 162, 502, 1297, 1297, 1297, 1297, 1297, 1297, + /* 110 */ 1297, 1297, 1297, 1297, 1297, 1297, 1297, 1297, 1297, 1297, + /* 120 */ 1297, 1297, 1297, 1298, 968, 158, 31, 661, 402, 217, + /* 130 */ 217, 217, 668, 312, 312, 402, 572, 572, 572, 508, + /* 140 */ 442, 3, 3, 393, 536, 536, 569, 569, 508, 576, + /* 150 */ 215, 215, 215, 215, 215, 215, 215, 571, 655, 522, + /* 160 */ 451, 867, 59, 327, 95, 591, 712, 573, 726, 479, + /* 170 */ 694, 733, 214, 964, 936, 214, 1059, 244, 864, 1036, + /* 180 */ 1262, 1145, 1283, 1307, 1283, 1187, 1330, 1330, 1283, 1187, + /* 190 */ 1187, 1266, 1330, 1330, 1330, 1361, 1361, 1365, 76, 442, + /* 200 */ 76, 1373, 1375, 76, 1373, 76, 76, 76, 1330, 76, + /* 210 */ 1357, 1357, 1361, 536, 536, 536, 536, 536, 536, 536, + /* 220 */ 536, 536, 536, 536, 1330, 1361, 569, 1245, 1365, 498, + /* 230 */ 1264, 442, 498, 1330, 1307, 1307, 569, 1202, 1205, 569, + /* 240 */ 1202, 1205, 569, 569, 536, 1199, 1317, 1202, 1240, 1242, + /* 250 */ 1258, 1036, 1241, 1243, 1247, 1270, 572, 1495, 1330, 1373, + /* 260 */ 498, 1205, 569, 569, 569, 569, 569, 1205, 569, 1367, + /* 270 */ 498, 508, 498, 572, 1445, 1448, 569, 576, 1330, 498, + /* 280 */ 1528, 1361, 2544, 2544, 2544, 2544, 2544, 2544, 2544, 826, + /* 290 */ 92, 742, 587, 418, 15, 735, 374, 832, 400, 941, + /* 300 */ 941, 544, 941, 941, 941, 941, 941, 941, 941, 987, + /* 310 */ 314, 51, 410, 73, 73, 167, 666, 180, 19, 292, + /* 320 */ 121, 99, 406, 121, 121, 121, 929, 829, 1071, 1066, + /* 330 */ 989, 1007, 933, 945, 1064, 1113, 1146, 1154, 1190, 986, + /* 340 */ 1134, 1181, 1078, 907, 323, 260, 1182, 1183, 1186, 1189, + /* 350 */ 1191, 981, 1193, 1040, 1084, 58, 1206, 1144, 1223, 1224, + /* 360 */ 1249, 1260, 1273, 1274, 1051, 1276, 1301, 1211, 1284, 1576, + /* 370 */ 1578, 1393, 1581, 1582, 1541, 1584, 1551, 1388, 1553, 1554, + /* 380 */ 1556, 1394, 1592, 1559, 1560, 1397, 1597, 1400, 1601, 1567, + /* 390 */ 1606, 1593, 1613, 1583, 1435, 1439, 1620, 1621, 1446, 1450, + /* 400 */ 1623, 1626, 1580, 1630, 1633, 1634, 1599, 1643, 1644, 1645, + /* 410 */ 1646, 1647, 1648, 1650, 1651, 1501, 1618, 1656, 1506, 1659, + /* 420 */ 1660, 1667, 1669, 1670, 1671, 1672, 1673, 1680, 1681, 1682, + /* 430 */ 1683, 1684, 1685, 1687, 1635, 1678, 1688, 1689, 1690, 1695, + /* 440 */ 1653, 1676, 1696, 1697, 1557, 1693, 1698, 1665, 1702, 1649, + /* 450 */ 1703, 1652, 1704, 1706, 1666, 1677, 1668, 1662, 1701, 1664, + /* 460 */ 1705, 1674, 1717, 1686, 1691, 1722, 1723, 1725, 1700, 1558, + /* 470 */ 1727, 1740, 1741, 1699, 1742, 1744, 1710, 1708, 1707, 1748, + /* 480 */ 1714, 1712, 1726, 1761, 1729, 1718, 1728, 1762, 1734, 1724, + /* 490 */ 1731, 1771, 1774, 1775, 1777, 1679, 1709, 1743, 1757, 1782, + /* 500 */ 1750, 1751, 1765, 1753, 1755, 1747, 1749, 1760, 1763, 1770, + /* 510 */ 1764, 1796, 1778, 1803, 1783, 1758, 1807, 1787, 1786, 1822, + /* 520 */ 1790, 1828, 1794, 1830, 1811, 1823, 1745, 1752, 1846, 1713, + /* 530 */ 1815, 1851, 1711, 1833, 1730, 1720, 1852, 1864, 1732, 1736, + /* 540 */ 1863, 1821, 1624, 1772, 1776, 1793, 1789, 1827, 1800, 1795, + /* 550 */ 1812, 1813, 1801, 1866, 1860, 1865, 1818, 1867, 1694, 1831, + /* 560 */ 1832, 1913, 1875, 1721, 1895, 1897, 1899, 1900, 1901, 1902, + /* 570 */ 1841, 1842, 1893, 1715, 1903, 1896, 1944, 1945, 1948, 1853, + /* 580 */ 1854, 1855, 1857, 1915, 1920, 1766, 1962, 1877, 1805, 1878, + /* 590 */ 1975, 1937, 1814, 1881, 1873, 1662, 1934, 1938, 1756, 1768, + /* 600 */ 1773, 1984, 1967, 1785, 1906, 1904, 1907, 1908, 1910, 1911, + /* 610 */ 1957, 1916, 1917, 1960, 1912, 1993, 1804, 1929, 1919, 1926, + /* 620 */ 1992, 1994, 1932, 1935, 1996, 1939, 1936, 1999, 1940, 1942, + /* 630 */ 2002, 1946, 1943, 2006, 1950, 1924, 1928, 1930, 1931, 2027, + /* 640 */ 1949, 1956, 1958, 2018, 1965, 2012, 2012, 2036, 2000, 2003, + /* 650 */ 2028, 2030, 2032, 2034, 2035, 2038, 2039, 2046, 2049, 2051, + /* 660 */ 2001, 1995, 2043, 2056, 2065, 2079, 2067, 2082, 2071, 2072, + /* 670 */ 2074, 2040, 1747, 2076, 1749, 2077, 2078, 2080, 2081, 2086, + /* 680 */ 2083, 2117, 2084, 2075, 2085, 2120, 2090, 2096, 2091, 2121, + /* 690 */ 2098, 2097, 2092, 2134, 2106, 2099, 2107, 2148, 2114, 2115, + /* 700 */ 2151, 2131, 2133, 2145, 2146, 2137, 2135, }; #define YY_REDUCE_COUNT (288) -#define YY_REDUCE_MIN (-407) -#define YY_REDUCE_MAX (2144) +#define YY_REDUCE_MIN (-425) +#define YY_REDUCE_MAX (2136) static const short yy_reduce_ofst[] = { - /* 0 */ 889, -320, -297, -165, 598, 621, 719, 778, 864, 893, - /* 10 */ 411, 955, 982, 231, 1009, 1026, 1080, 1136, 1180, 1196, - /* 20 */ 1264, 1281, 1335, 1351, 1395, 1422, 1449, 1493, 1537, 1557, - /* 30 */ 1622, 1642, 1696, 1712, 1756, 1783, 1810, 1854, 1898, 1918, - /* 40 */ 1983, 2003, 2057, 2073, 2117, 2144, 241, 86, -37, 536, - /* 50 */ 1013, 1067, 1081, 1125, 228, 291, -346, -87, -407, -166, - /* 60 */ -80, -372, -22, -276, -204, -308, -325, -319, -205, -192, - /* 70 */ 60, 74, 176, 202, 230, 234, 349, 429, 443, -78, - /* 80 */ 445, 584, 147, 627, -362, 632, 674, -245, 717, 721, - /* 90 */ 78, 773, -48, 81, -24, 338, -294, -144, -182, -182, - /* 100 */ -330, -142, -222, -210, -117, 178, 260, 342, 345, 392, - /* 110 */ 431, 459, 496, 594, 601, 602, 603, 607, 609, 612, - /* 120 */ 617, 405, -397, -106, 126, 185, 327, 427, 242, -397, - /* 130 */ 24, 533, 350, 161, 425, 469, 419, 444, 623, 346, - /* 140 */ 319, 481, 556, 247, 650, 570, 644, 677, 698, 665, - /* 150 */ 275, 377, 486, 499, 506, 564, 587, 657, 741, 792, - /* 160 */ 827, 755, 768, 881, 779, 867, 867, 890, 857, 904, - /* 170 */ 872, 862, 822, 822, 811, 822, 843, 853, 867, 897, - /* 180 */ 905, 914, 930, 936, 940, 938, 989, 991, 957, 958, - /* 190 */ 960, 987, 995, 996, 997, 1012, 1015, 962, 1006, 976, - /* 200 */ 1010, 970, 978, 1028, 983, 1029, 1031, 1033, 1040, 1053, - /* 210 */ 1057, 1058, 1051, 1045, 1049, 1054, 1061, 1064, 1071, 1078, - /* 220 */ 1082, 1083, 1084, 1086, 1062, 1079, 1050, 1052, 1016, 1100, - /* 230 */ 1034, 1076, 1106, 1090, 1069, 1077, 1088, 1017, 1091, 1094, - /* 240 */ 1020, 1092, 1095, 1098, 867, 1035, 1037, 1055, 1060, 1036, - /* 250 */ 1056, 1093, 1059, 1074, 1096, 822, 1140, 1109, 1183, 1122, - /* 260 */ 1181, 1129, 1152, 1157, 1158, 1163, 1168, 1141, 1178, 1186, - /* 270 */ 1211, 1198, 1217, 1166, 1137, 1201, 1190, 1216, 1236, 1226, - /* 280 */ 1240, 1243, 1191, 1189, 1218, 1238, 1242, 1255, 1252, + /* 0 */ -76, -288, 286, 597, 650, 737, 780, 851, 894, 937, + /* 10 */ 961, 1019, 1062, 1090, -2, 83, 1149, 1207, 1235, 1261, + /* 20 */ 1331, 1350, 1413, 1434, 1456, 1477, 1499, 1520, 1563, 1591, + /* 30 */ 1617, 1675, 1692, 1735, 1759, 1802, 1819, 1845, 1862, 1905, + /* 40 */ 1927, 1989, 2011, 2073, 2093, 2136, -253, -196, 290, -385, + /* 50 */ -374, -323, 584, 778, 395, 659, -212, 764, 28, 408, + /* 60 */ 681, -425, -352, 72, 270, -324, -313, -339, -215, 23, + /* 70 */ 64, 267, 285, 331, 613, 615, 626, 649, 695, 700, + /* 80 */ 728, 298, 660, 748, 22, 790, -326, 833, 842, -345, + /* 90 */ 854, 857, -260, 869, 287, -190, 354, 710, 7, -189, + /* 100 */ -407, -407, -305, -233, -125, -66, 151, 193, 194, 221, + /* 110 */ 294, 340, 357, 407, 413, 484, 504, 506, 518, 519, + /* 120 */ 596, 651, 656, -56, -257, 283, -301, -185, -38, -257, + /* 130 */ 11, 412, 111, 401, 533, 18, -172, 234, 446, 411, + /* 140 */ 78, 586, 595, 425, -291, 468, 520, 628, 680, 727, + /* 150 */ 320, 328, 363, 493, 652, 684, 715, 321, 673, 765, + /* 160 */ 731, 698, 670, 825, 756, 840, 840, 868, 860, 908, + /* 170 */ 874, 865, 814, 814, 798, 814, 827, 871, 840, 914, + /* 180 */ 921, 935, 951, 950, 970, 975, 1020, 1021, 984, 996, + /* 190 */ 999, 1033, 1044, 1045, 1046, 1057, 1058, 997, 1052, 1022, + /* 200 */ 1053, 1061, 1010, 1060, 1068, 1065, 1067, 1069, 1072, 1070, + /* 210 */ 1075, 1076, 1087, 1063, 1074, 1079, 1080, 1081, 1085, 1086, + /* 220 */ 1088, 1089, 1091, 1092, 1095, 1105, 1082, 1050, 1077, 1112, + /* 230 */ 1094, 1100, 1115, 1120, 1083, 1093, 1104, 1038, 1097, 1107, + /* 240 */ 1049, 1101, 1118, 1121, 840, 1096, 1073, 1098, 1102, 1099, + /* 250 */ 1103, 1111, 1055, 1106, 1109, 814, 1151, 1117, 1188, 1185, + /* 260 */ 1192, 1140, 1155, 1156, 1157, 1158, 1159, 1141, 1161, 1160, + /* 270 */ 1194, 1196, 1204, 1175, 1126, 1201, 1177, 1203, 1226, 1225, + /* 280 */ 1238, 1246, 1178, 1195, 1218, 1220, 1222, 1236, 1252, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 10 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 20 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 30 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 40 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 50 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 60 */ 1579, 1579, 1579, 1579, 1579, 1832, 1579, 1579, 1579, 1579, - /* 70 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1655, - /* 80 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 90 */ 1579, 1579, 1579, 1579, 1579, 1579, 1653, 1825, 2021, 1579, - /* 100 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 110 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 120 */ 1579, 1579, 2033, 1579, 1579, 1579, 1579, 1655, 1579, 2033, - /* 130 */ 2033, 2033, 1653, 1993, 1993, 1579, 1579, 1579, 1579, 1764, - /* 140 */ 1579, 1874, 1874, 1579, 1579, 1579, 1579, 1579, 1764, 1579, - /* 150 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1868, 1579, 1579, - /* 160 */ 2058, 2111, 1579, 1579, 2061, 1579, 1579, 1579, 1837, 1579, - /* 170 */ 1717, 2048, 2025, 2039, 2095, 2026, 2023, 2042, 1579, 2052, - /* 180 */ 1579, 1861, 1830, 1579, 1830, 1827, 1579, 1579, 1830, 1827, - /* 190 */ 1827, 1708, 1579, 1579, 1579, 1579, 1579, 1579, 1655, 1579, - /* 200 */ 1655, 1579, 1579, 1655, 1579, 1655, 1655, 1655, 1579, 1655, - /* 210 */ 1634, 1634, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 220 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1881, 1579, 1653, - /* 230 */ 1870, 1579, 1653, 1579, 1579, 1579, 1579, 2068, 2066, 1579, - /* 240 */ 2068, 2066, 1579, 1579, 1579, 2080, 2076, 2068, 2084, 2082, - /* 250 */ 2054, 2052, 2114, 2101, 2097, 2039, 1579, 1579, 1579, 1579, - /* 260 */ 1653, 2066, 1579, 1579, 1579, 1579, 1579, 2066, 1579, 1579, - /* 270 */ 1653, 1579, 1653, 1579, 1579, 1733, 1579, 1579, 1579, 1653, - /* 280 */ 1611, 1579, 1863, 1874, 1767, 1767, 1767, 1656, 1584, 1579, - /* 290 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 2079, - /* 300 */ 2078, 1579, 1949, 1579, 1997, 1996, 1995, 1986, 1948, 1579, - /* 310 */ 1729, 1579, 1579, 1947, 1946, 1579, 1579, 1579, 1579, 1579, - /* 320 */ 1940, 1579, 1579, 1941, 1939, 1938, 1579, 1579, 1579, 1579, - /* 330 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 340 */ 1579, 1579, 1579, 2098, 2102, 1579, 1579, 1579, 1579, 1579, - /* 350 */ 1579, 2022, 1579, 1579, 1579, 1579, 1579, 1923, 1579, 1579, - /* 360 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 370 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 380 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 390 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 400 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 410 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 420 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 430 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 440 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 450 */ 1579, 1579, 1579, 1579, 1616, 1579, 1579, 1579, 1579, 1579, - /* 460 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 470 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 480 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 490 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 500 */ 1579, 1579, 1695, 1694, 1579, 1579, 1579, 1579, 1579, 1579, - /* 510 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 520 */ 1579, 1579, 1579, 1931, 1579, 1579, 1579, 1579, 1579, 1579, - /* 530 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 2094, 2055, 1579, - /* 540 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 550 */ 1579, 1579, 1923, 1579, 2077, 1579, 1579, 2092, 1579, 2096, - /* 560 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 2032, 2028, 1579, - /* 570 */ 1579, 2024, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 580 */ 1579, 1579, 1579, 1878, 1579, 1579, 1579, 1579, 1579, 1579, - /* 590 */ 1579, 1579, 1922, 1579, 1983, 1579, 1579, 1579, 2017, 1579, - /* 600 */ 1579, 1968, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 610 */ 1579, 1931, 1579, 1934, 1579, 1579, 1579, 1579, 1579, 1761, - /* 620 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 630 */ 1579, 1579, 1746, 1744, 1743, 1742, 1579, 1739, 1579, 1579, - /* 640 */ 1579, 1579, 1770, 1769, 1579, 1579, 1579, 1579, 1579, 1579, - /* 650 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1675, - /* 660 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1666, - /* 670 */ 1579, 1665, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 680 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 690 */ 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, 1579, - /* 700 */ 1579, 1579, 1579, 1579, + /* 0 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 10 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 20 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 30 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 40 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 50 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 60 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1843, 1587, 1587, + /* 70 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 80 */ 1587, 1665, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 90 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1663, 1836, + /* 100 */ 2032, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 110 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 120 */ 1587, 1587, 1587, 1587, 2044, 1587, 1587, 1665, 1587, 2044, + /* 130 */ 2044, 2044, 1663, 2004, 2004, 1587, 1587, 1587, 1587, 1774, + /* 140 */ 1587, 1885, 1885, 1587, 1587, 1587, 1587, 1587, 1774, 1587, + /* 150 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1879, 1587, 1587, + /* 160 */ 2069, 2122, 1587, 1587, 2072, 1587, 1587, 1587, 1848, 1587, + /* 170 */ 1727, 2059, 2036, 2050, 2106, 2037, 2034, 2053, 1587, 2063, + /* 180 */ 1587, 1872, 1841, 1587, 1841, 1838, 1587, 1587, 1841, 1838, + /* 190 */ 1838, 1718, 1587, 1587, 1587, 1587, 1587, 1587, 1665, 1587, + /* 200 */ 1665, 1587, 1587, 1665, 1587, 1665, 1665, 1665, 1587, 1665, + /* 210 */ 1644, 1644, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 220 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1892, 1587, 1663, + /* 230 */ 1881, 1587, 1663, 1587, 1587, 1587, 1587, 2079, 2077, 1587, + /* 240 */ 2079, 2077, 1587, 1587, 1587, 2091, 2087, 2079, 2095, 2093, + /* 250 */ 2065, 2063, 2125, 2112, 2108, 2050, 1587, 1587, 1587, 1587, + /* 260 */ 1663, 2077, 1587, 1587, 1587, 1587, 1587, 2077, 1587, 1587, + /* 270 */ 1663, 1587, 1663, 1587, 1587, 1743, 1587, 1587, 1587, 1663, + /* 280 */ 1619, 1587, 1874, 1885, 1777, 1777, 1777, 1666, 1592, 1587, + /* 290 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 2090, + /* 300 */ 2089, 1587, 1960, 1587, 2008, 2007, 2006, 1997, 1959, 1587, + /* 310 */ 1739, 1587, 1587, 1958, 1957, 1587, 1587, 1587, 1587, 1587, + /* 320 */ 1951, 1587, 1587, 1952, 1950, 1949, 1587, 1587, 1587, 1587, + /* 330 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 340 */ 1587, 1587, 1587, 2109, 2113, 1587, 1587, 1587, 1587, 1587, + /* 350 */ 1587, 2033, 1587, 1587, 1587, 1587, 1587, 1934, 1587, 1587, + /* 360 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 370 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 380 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 390 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 400 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 410 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 420 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 430 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 440 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 450 */ 1587, 1587, 1587, 1587, 1587, 1587, 1624, 1939, 1587, 1587, + /* 460 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 470 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 480 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 490 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 500 */ 1587, 1587, 1587, 1587, 1587, 1705, 1704, 1587, 1587, 1587, + /* 510 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 520 */ 1587, 1587, 1587, 1587, 1587, 1587, 1942, 1587, 1587, 1587, + /* 530 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 540 */ 2105, 2066, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 550 */ 1587, 1587, 1587, 1587, 1587, 1934, 1587, 2088, 1587, 1587, + /* 560 */ 2103, 1587, 2107, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 570 */ 2043, 2039, 1587, 1587, 2035, 1587, 1587, 1587, 1587, 1587, + /* 580 */ 1587, 1587, 1587, 1587, 1587, 1587, 1889, 1587, 1587, 1587, + /* 590 */ 1587, 1587, 1587, 1587, 1587, 1933, 1587, 1994, 1587, 1587, + /* 600 */ 1587, 2028, 1587, 1587, 1979, 1587, 1587, 1587, 1587, 1587, + /* 610 */ 1587, 1587, 1587, 1587, 1942, 1587, 1945, 1587, 1587, 1587, + /* 620 */ 1587, 1587, 1771, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 630 */ 1587, 1587, 1587, 1587, 1587, 1756, 1754, 1753, 1752, 1587, + /* 640 */ 1749, 1587, 1587, 1587, 1587, 1780, 1779, 1587, 1587, 1587, + /* 650 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 660 */ 1587, 1587, 1685, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 670 */ 1587, 1587, 1676, 1587, 1675, 1587, 1587, 1587, 1587, 1587, + /* 680 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 690 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, 1587, + /* 700 */ 1587, 1587, 1587, 1587, 1587, 1587, 1587, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1005,6 +975,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* TO => nothing */ 0, /* REVOKE => nothing */ 0, /* FROM => nothing */ + 0, /* SUBSCRIBE => nothing */ 0, /* NK_COMMA => nothing */ 0, /* READ => nothing */ 0, /* WRITE => nothing */ @@ -1096,6 +1067,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* FIRST => nothing */ 0, /* LAST => nothing */ 0, /* SHOW => nothing */ + 0, /* PRIVILEGES => nothing */ 0, /* DATABASES => nothing */ 0, /* TABLES => nothing */ 0, /* STABLES => nothing */ @@ -1187,7 +1159,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* COUNT => nothing */ 0, /* LAST_ROW => nothing */ 0, /* CASE => nothing */ - 266, /* END => ABORT */ + 268, /* END => ABORT */ 0, /* WHEN => nothing */ 0, /* THEN => nothing */ 0, /* ELSE => nothing */ @@ -1229,58 +1201,58 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ABORT => nothing */ - 266, /* AFTER => ABORT */ - 266, /* ATTACH => ABORT */ - 266, /* BEFORE => ABORT */ - 266, /* BEGIN => ABORT */ - 266, /* BITAND => ABORT */ - 266, /* BITNOT => ABORT */ - 266, /* BITOR => ABORT */ - 266, /* BLOCKS => ABORT */ - 266, /* CHANGE => ABORT */ - 266, /* COMMA => ABORT */ - 266, /* COMPACT => ABORT */ - 266, /* CONCAT => ABORT */ - 266, /* CONFLICT => ABORT */ - 266, /* COPY => ABORT */ - 266, /* DEFERRED => ABORT */ - 266, /* DELIMITERS => ABORT */ - 266, /* DETACH => ABORT */ - 266, /* DIVIDE => ABORT */ - 266, /* DOT => ABORT */ - 266, /* EACH => ABORT */ - 266, /* FAIL => ABORT */ - 266, /* FILE => ABORT */ - 266, /* FOR => ABORT */ - 266, /* GLOB => ABORT */ - 266, /* ID => ABORT */ - 266, /* IMMEDIATE => ABORT */ - 266, /* IMPORT => ABORT */ - 266, /* INITIALLY => ABORT */ - 266, /* INSTEAD => ABORT */ - 266, /* ISNULL => ABORT */ - 266, /* KEY => ABORT */ - 266, /* MODULES => ABORT */ - 266, /* NK_BITNOT => ABORT */ - 266, /* NK_SEMI => ABORT */ - 266, /* NOTNULL => ABORT */ - 266, /* OF => ABORT */ - 266, /* PLUS => ABORT */ - 266, /* PRIVILEGE => ABORT */ - 266, /* RAISE => ABORT */ - 266, /* REPLACE => ABORT */ - 266, /* RESTRICT => ABORT */ - 266, /* ROW => ABORT */ - 266, /* SEMI => ABORT */ - 266, /* STAR => ABORT */ - 266, /* STATEMENT => ABORT */ - 266, /* STRING => ABORT */ - 266, /* TIMES => ABORT */ - 266, /* UPDATE => ABORT */ - 266, /* VALUES => ABORT */ - 266, /* VARIABLE => ABORT */ - 266, /* VIEW => ABORT */ - 266, /* WAL => ABORT */ + 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, /* STRING => ABORT */ + 268, /* TIMES => ABORT */ + 268, /* UPDATE => ABORT */ + 268, /* VALUES => ABORT */ + 268, /* VARIABLE => ABORT */ + 268, /* VIEW => ABORT */ + 268, /* WAL => ABORT */ }; #endif /* YYFALLBACK */ @@ -1411,417 +1383,419 @@ static const char *const yyTokenName[] = { /* 40 */ "TO", /* 41 */ "REVOKE", /* 42 */ "FROM", - /* 43 */ "NK_COMMA", - /* 44 */ "READ", - /* 45 */ "WRITE", - /* 46 */ "NK_DOT", - /* 47 */ "DNODE", - /* 48 */ "PORT", - /* 49 */ "DNODES", - /* 50 */ "NK_IPTOKEN", - /* 51 */ "FORCE", - /* 52 */ "LOCAL", - /* 53 */ "QNODE", - /* 54 */ "BNODE", - /* 55 */ "SNODE", - /* 56 */ "MNODE", - /* 57 */ "DATABASE", - /* 58 */ "USE", - /* 59 */ "FLUSH", - /* 60 */ "TRIM", - /* 61 */ "IF", - /* 62 */ "NOT", - /* 63 */ "EXISTS", - /* 64 */ "BUFFER", - /* 65 */ "CACHEMODEL", - /* 66 */ "CACHESIZE", - /* 67 */ "COMP", - /* 68 */ "DURATION", - /* 69 */ "NK_VARIABLE", - /* 70 */ "MAXROWS", - /* 71 */ "MINROWS", - /* 72 */ "KEEP", - /* 73 */ "PAGES", - /* 74 */ "PAGESIZE", - /* 75 */ "TSDB_PAGESIZE", - /* 76 */ "PRECISION", - /* 77 */ "REPLICA", - /* 78 */ "STRICT", - /* 79 */ "VGROUPS", - /* 80 */ "SINGLE_STABLE", - /* 81 */ "RETENTIONS", - /* 82 */ "SCHEMALESS", - /* 83 */ "WAL_LEVEL", - /* 84 */ "WAL_FSYNC_PERIOD", - /* 85 */ "WAL_RETENTION_PERIOD", - /* 86 */ "WAL_RETENTION_SIZE", - /* 87 */ "WAL_ROLL_PERIOD", - /* 88 */ "WAL_SEGMENT_SIZE", - /* 89 */ "STT_TRIGGER", - /* 90 */ "TABLE_PREFIX", - /* 91 */ "TABLE_SUFFIX", - /* 92 */ "NK_COLON", - /* 93 */ "MAX_SPEED", - /* 94 */ "TABLE", - /* 95 */ "NK_LP", - /* 96 */ "NK_RP", - /* 97 */ "STABLE", - /* 98 */ "ADD", - /* 99 */ "COLUMN", - /* 100 */ "MODIFY", - /* 101 */ "RENAME", - /* 102 */ "TAG", - /* 103 */ "SET", - /* 104 */ "NK_EQ", - /* 105 */ "USING", - /* 106 */ "TAGS", - /* 107 */ "COMMENT", - /* 108 */ "BOOL", - /* 109 */ "TINYINT", - /* 110 */ "SMALLINT", - /* 111 */ "INT", - /* 112 */ "INTEGER", - /* 113 */ "BIGINT", - /* 114 */ "FLOAT", - /* 115 */ "DOUBLE", - /* 116 */ "BINARY", - /* 117 */ "TIMESTAMP", - /* 118 */ "NCHAR", - /* 119 */ "UNSIGNED", - /* 120 */ "JSON", - /* 121 */ "VARCHAR", - /* 122 */ "MEDIUMBLOB", - /* 123 */ "BLOB", - /* 124 */ "VARBINARY", - /* 125 */ "DECIMAL", - /* 126 */ "MAX_DELAY", - /* 127 */ "WATERMARK", - /* 128 */ "ROLLUP", - /* 129 */ "TTL", - /* 130 */ "SMA", - /* 131 */ "FIRST", - /* 132 */ "LAST", - /* 133 */ "SHOW", - /* 134 */ "DATABASES", - /* 135 */ "TABLES", - /* 136 */ "STABLES", - /* 137 */ "MNODES", - /* 138 */ "QNODES", - /* 139 */ "FUNCTIONS", - /* 140 */ "INDEXES", - /* 141 */ "ACCOUNTS", - /* 142 */ "APPS", - /* 143 */ "CONNECTIONS", - /* 144 */ "LICENCES", - /* 145 */ "GRANTS", - /* 146 */ "QUERIES", - /* 147 */ "SCORES", - /* 148 */ "TOPICS", - /* 149 */ "VARIABLES", - /* 150 */ "CLUSTER", - /* 151 */ "BNODES", - /* 152 */ "SNODES", - /* 153 */ "TRANSACTIONS", - /* 154 */ "DISTRIBUTED", - /* 155 */ "CONSUMERS", - /* 156 */ "SUBSCRIPTIONS", - /* 157 */ "VNODES", - /* 158 */ "LIKE", - /* 159 */ "TBNAME", - /* 160 */ "QTAGS", - /* 161 */ "AS", - /* 162 */ "INDEX", - /* 163 */ "FUNCTION", - /* 164 */ "INTERVAL", - /* 165 */ "TOPIC", - /* 166 */ "WITH", - /* 167 */ "META", - /* 168 */ "CONSUMER", - /* 169 */ "GROUP", - /* 170 */ "DESC", - /* 171 */ "DESCRIBE", - /* 172 */ "RESET", - /* 173 */ "QUERY", - /* 174 */ "CACHE", - /* 175 */ "EXPLAIN", - /* 176 */ "ANALYZE", - /* 177 */ "VERBOSE", - /* 178 */ "NK_BOOL", - /* 179 */ "RATIO", - /* 180 */ "NK_FLOAT", - /* 181 */ "OUTPUTTYPE", - /* 182 */ "AGGREGATE", - /* 183 */ "BUFSIZE", - /* 184 */ "STREAM", - /* 185 */ "INTO", - /* 186 */ "TRIGGER", - /* 187 */ "AT_ONCE", - /* 188 */ "WINDOW_CLOSE", - /* 189 */ "IGNORE", - /* 190 */ "EXPIRED", - /* 191 */ "FILL_HISTORY", - /* 192 */ "SUBTABLE", - /* 193 */ "KILL", - /* 194 */ "CONNECTION", - /* 195 */ "TRANSACTION", - /* 196 */ "BALANCE", - /* 197 */ "VGROUP", - /* 198 */ "MERGE", - /* 199 */ "REDISTRIBUTE", - /* 200 */ "SPLIT", - /* 201 */ "DELETE", - /* 202 */ "INSERT", - /* 203 */ "NULL", - /* 204 */ "NK_QUESTION", - /* 205 */ "NK_ARROW", - /* 206 */ "ROWTS", - /* 207 */ "QSTART", - /* 208 */ "QEND", - /* 209 */ "QDURATION", - /* 210 */ "WSTART", - /* 211 */ "WEND", - /* 212 */ "WDURATION", - /* 213 */ "IROWTS", - /* 214 */ "CAST", - /* 215 */ "NOW", - /* 216 */ "TODAY", - /* 217 */ "TIMEZONE", - /* 218 */ "CLIENT_VERSION", - /* 219 */ "SERVER_VERSION", - /* 220 */ "SERVER_STATUS", - /* 221 */ "CURRENT_USER", - /* 222 */ "COUNT", - /* 223 */ "LAST_ROW", - /* 224 */ "CASE", - /* 225 */ "END", - /* 226 */ "WHEN", - /* 227 */ "THEN", - /* 228 */ "ELSE", - /* 229 */ "BETWEEN", - /* 230 */ "IS", - /* 231 */ "NK_LT", - /* 232 */ "NK_GT", - /* 233 */ "NK_LE", - /* 234 */ "NK_GE", - /* 235 */ "NK_NE", - /* 236 */ "MATCH", - /* 237 */ "NMATCH", - /* 238 */ "CONTAINS", - /* 239 */ "IN", - /* 240 */ "JOIN", - /* 241 */ "INNER", - /* 242 */ "SELECT", - /* 243 */ "DISTINCT", - /* 244 */ "WHERE", - /* 245 */ "PARTITION", - /* 246 */ "BY", - /* 247 */ "SESSION", - /* 248 */ "STATE_WINDOW", - /* 249 */ "SLIDING", - /* 250 */ "FILL", - /* 251 */ "VALUE", - /* 252 */ "NONE", - /* 253 */ "PREV", - /* 254 */ "LINEAR", - /* 255 */ "NEXT", - /* 256 */ "HAVING", - /* 257 */ "RANGE", - /* 258 */ "EVERY", - /* 259 */ "ORDER", - /* 260 */ "SLIMIT", - /* 261 */ "SOFFSET", - /* 262 */ "LIMIT", - /* 263 */ "OFFSET", - /* 264 */ "ASC", - /* 265 */ "NULLS", - /* 266 */ "ABORT", - /* 267 */ "AFTER", - /* 268 */ "ATTACH", - /* 269 */ "BEFORE", - /* 270 */ "BEGIN", - /* 271 */ "BITAND", - /* 272 */ "BITNOT", - /* 273 */ "BITOR", - /* 274 */ "BLOCKS", - /* 275 */ "CHANGE", - /* 276 */ "COMMA", - /* 277 */ "COMPACT", - /* 278 */ "CONCAT", - /* 279 */ "CONFLICT", - /* 280 */ "COPY", - /* 281 */ "DEFERRED", - /* 282 */ "DELIMITERS", - /* 283 */ "DETACH", - /* 284 */ "DIVIDE", - /* 285 */ "DOT", - /* 286 */ "EACH", - /* 287 */ "FAIL", - /* 288 */ "FILE", - /* 289 */ "FOR", - /* 290 */ "GLOB", - /* 291 */ "ID", - /* 292 */ "IMMEDIATE", - /* 293 */ "IMPORT", - /* 294 */ "INITIALLY", - /* 295 */ "INSTEAD", - /* 296 */ "ISNULL", - /* 297 */ "KEY", - /* 298 */ "MODULES", - /* 299 */ "NK_BITNOT", - /* 300 */ "NK_SEMI", - /* 301 */ "NOTNULL", - /* 302 */ "OF", - /* 303 */ "PLUS", - /* 304 */ "PRIVILEGE", - /* 305 */ "RAISE", - /* 306 */ "REPLACE", - /* 307 */ "RESTRICT", - /* 308 */ "ROW", - /* 309 */ "SEMI", - /* 310 */ "STAR", - /* 311 */ "STATEMENT", - /* 312 */ "STRING", - /* 313 */ "TIMES", - /* 314 */ "UPDATE", - /* 315 */ "VALUES", - /* 316 */ "VARIABLE", - /* 317 */ "VIEW", - /* 318 */ "WAL", - /* 319 */ "cmd", - /* 320 */ "account_options", - /* 321 */ "alter_account_options", - /* 322 */ "literal", - /* 323 */ "alter_account_option", - /* 324 */ "user_name", - /* 325 */ "sysinfo_opt", - /* 326 */ "privileges", - /* 327 */ "priv_level", - /* 328 */ "priv_type_list", - /* 329 */ "priv_type", - /* 330 */ "db_name", - /* 331 */ "dnode_endpoint", - /* 332 */ "force_opt", - /* 333 */ "not_exists_opt", - /* 334 */ "db_options", - /* 335 */ "exists_opt", - /* 336 */ "alter_db_options", - /* 337 */ "speed_opt", - /* 338 */ "integer_list", - /* 339 */ "variable_list", - /* 340 */ "retention_list", - /* 341 */ "alter_db_option", - /* 342 */ "retention", - /* 343 */ "full_table_name", - /* 344 */ "column_def_list", - /* 345 */ "tags_def_opt", - /* 346 */ "table_options", - /* 347 */ "multi_create_clause", - /* 348 */ "tags_def", - /* 349 */ "multi_drop_clause", - /* 350 */ "alter_table_clause", - /* 351 */ "alter_table_options", - /* 352 */ "column_name", - /* 353 */ "type_name", - /* 354 */ "signed_literal", - /* 355 */ "create_subtable_clause", - /* 356 */ "specific_cols_opt", - /* 357 */ "expression_list", - /* 358 */ "drop_table_clause", - /* 359 */ "col_name_list", - /* 360 */ "table_name", - /* 361 */ "column_def", - /* 362 */ "duration_list", - /* 363 */ "rollup_func_list", - /* 364 */ "alter_table_option", - /* 365 */ "duration_literal", - /* 366 */ "rollup_func_name", - /* 367 */ "function_name", - /* 368 */ "col_name", - /* 369 */ "db_name_cond_opt", - /* 370 */ "like_pattern_opt", - /* 371 */ "table_name_cond", - /* 372 */ "from_db_opt", - /* 373 */ "tag_list_opt", - /* 374 */ "tag_item", - /* 375 */ "column_alias", - /* 376 */ "index_options", - /* 377 */ "func_list", - /* 378 */ "sliding_opt", - /* 379 */ "sma_stream_opt", - /* 380 */ "func", - /* 381 */ "stream_options", - /* 382 */ "topic_name", - /* 383 */ "query_or_subquery", - /* 384 */ "cgroup_name", - /* 385 */ "analyze_opt", - /* 386 */ "explain_options", - /* 387 */ "agg_func_opt", - /* 388 */ "bufsize_opt", - /* 389 */ "stream_name", - /* 390 */ "subtable_opt", - /* 391 */ "expression", - /* 392 */ "dnode_list", - /* 393 */ "where_clause_opt", - /* 394 */ "signed", - /* 395 */ "literal_func", - /* 396 */ "literal_list", - /* 397 */ "table_alias", - /* 398 */ "expr_or_subquery", - /* 399 */ "pseudo_column", - /* 400 */ "column_reference", - /* 401 */ "function_expression", - /* 402 */ "case_when_expression", - /* 403 */ "star_func", - /* 404 */ "star_func_para_list", - /* 405 */ "noarg_func", - /* 406 */ "other_para_list", - /* 407 */ "star_func_para", - /* 408 */ "when_then_list", - /* 409 */ "case_when_else_opt", - /* 410 */ "common_expression", - /* 411 */ "when_then_expr", - /* 412 */ "predicate", - /* 413 */ "compare_op", - /* 414 */ "in_op", - /* 415 */ "in_predicate_value", - /* 416 */ "boolean_value_expression", - /* 417 */ "boolean_primary", - /* 418 */ "from_clause_opt", - /* 419 */ "table_reference_list", - /* 420 */ "table_reference", - /* 421 */ "table_primary", - /* 422 */ "joined_table", - /* 423 */ "alias_opt", - /* 424 */ "subquery", - /* 425 */ "parenthesized_joined_table", - /* 426 */ "join_type", - /* 427 */ "search_condition", - /* 428 */ "query_specification", - /* 429 */ "set_quantifier_opt", - /* 430 */ "select_list", - /* 431 */ "partition_by_clause_opt", - /* 432 */ "range_opt", - /* 433 */ "every_opt", - /* 434 */ "fill_opt", - /* 435 */ "twindow_clause_opt", - /* 436 */ "group_by_clause_opt", - /* 437 */ "having_clause_opt", - /* 438 */ "select_item", - /* 439 */ "partition_list", - /* 440 */ "partition_item", - /* 441 */ "fill_mode", - /* 442 */ "group_by_list", - /* 443 */ "query_expression", - /* 444 */ "query_simple", - /* 445 */ "order_by_clause_opt", - /* 446 */ "slimit_clause_opt", - /* 447 */ "limit_clause_opt", - /* 448 */ "union_query_expression", - /* 449 */ "query_simple_or_subquery", - /* 450 */ "sort_specification_list", - /* 451 */ "sort_specification", - /* 452 */ "ordering_specification_opt", - /* 453 */ "null_ordering_opt", + /* 43 */ "SUBSCRIBE", + /* 44 */ "NK_COMMA", + /* 45 */ "READ", + /* 46 */ "WRITE", + /* 47 */ "NK_DOT", + /* 48 */ "DNODE", + /* 49 */ "PORT", + /* 50 */ "DNODES", + /* 51 */ "NK_IPTOKEN", + /* 52 */ "FORCE", + /* 53 */ "LOCAL", + /* 54 */ "QNODE", + /* 55 */ "BNODE", + /* 56 */ "SNODE", + /* 57 */ "MNODE", + /* 58 */ "DATABASE", + /* 59 */ "USE", + /* 60 */ "FLUSH", + /* 61 */ "TRIM", + /* 62 */ "IF", + /* 63 */ "NOT", + /* 64 */ "EXISTS", + /* 65 */ "BUFFER", + /* 66 */ "CACHEMODEL", + /* 67 */ "CACHESIZE", + /* 68 */ "COMP", + /* 69 */ "DURATION", + /* 70 */ "NK_VARIABLE", + /* 71 */ "MAXROWS", + /* 72 */ "MINROWS", + /* 73 */ "KEEP", + /* 74 */ "PAGES", + /* 75 */ "PAGESIZE", + /* 76 */ "TSDB_PAGESIZE", + /* 77 */ "PRECISION", + /* 78 */ "REPLICA", + /* 79 */ "STRICT", + /* 80 */ "VGROUPS", + /* 81 */ "SINGLE_STABLE", + /* 82 */ "RETENTIONS", + /* 83 */ "SCHEMALESS", + /* 84 */ "WAL_LEVEL", + /* 85 */ "WAL_FSYNC_PERIOD", + /* 86 */ "WAL_RETENTION_PERIOD", + /* 87 */ "WAL_RETENTION_SIZE", + /* 88 */ "WAL_ROLL_PERIOD", + /* 89 */ "WAL_SEGMENT_SIZE", + /* 90 */ "STT_TRIGGER", + /* 91 */ "TABLE_PREFIX", + /* 92 */ "TABLE_SUFFIX", + /* 93 */ "NK_COLON", + /* 94 */ "MAX_SPEED", + /* 95 */ "TABLE", + /* 96 */ "NK_LP", + /* 97 */ "NK_RP", + /* 98 */ "STABLE", + /* 99 */ "ADD", + /* 100 */ "COLUMN", + /* 101 */ "MODIFY", + /* 102 */ "RENAME", + /* 103 */ "TAG", + /* 104 */ "SET", + /* 105 */ "NK_EQ", + /* 106 */ "USING", + /* 107 */ "TAGS", + /* 108 */ "COMMENT", + /* 109 */ "BOOL", + /* 110 */ "TINYINT", + /* 111 */ "SMALLINT", + /* 112 */ "INT", + /* 113 */ "INTEGER", + /* 114 */ "BIGINT", + /* 115 */ "FLOAT", + /* 116 */ "DOUBLE", + /* 117 */ "BINARY", + /* 118 */ "TIMESTAMP", + /* 119 */ "NCHAR", + /* 120 */ "UNSIGNED", + /* 121 */ "JSON", + /* 122 */ "VARCHAR", + /* 123 */ "MEDIUMBLOB", + /* 124 */ "BLOB", + /* 125 */ "VARBINARY", + /* 126 */ "DECIMAL", + /* 127 */ "MAX_DELAY", + /* 128 */ "WATERMARK", + /* 129 */ "ROLLUP", + /* 130 */ "TTL", + /* 131 */ "SMA", + /* 132 */ "FIRST", + /* 133 */ "LAST", + /* 134 */ "SHOW", + /* 135 */ "PRIVILEGES", + /* 136 */ "DATABASES", + /* 137 */ "TABLES", + /* 138 */ "STABLES", + /* 139 */ "MNODES", + /* 140 */ "QNODES", + /* 141 */ "FUNCTIONS", + /* 142 */ "INDEXES", + /* 143 */ "ACCOUNTS", + /* 144 */ "APPS", + /* 145 */ "CONNECTIONS", + /* 146 */ "LICENCES", + /* 147 */ "GRANTS", + /* 148 */ "QUERIES", + /* 149 */ "SCORES", + /* 150 */ "TOPICS", + /* 151 */ "VARIABLES", + /* 152 */ "CLUSTER", + /* 153 */ "BNODES", + /* 154 */ "SNODES", + /* 155 */ "TRANSACTIONS", + /* 156 */ "DISTRIBUTED", + /* 157 */ "CONSUMERS", + /* 158 */ "SUBSCRIPTIONS", + /* 159 */ "VNODES", + /* 160 */ "LIKE", + /* 161 */ "TBNAME", + /* 162 */ "QTAGS", + /* 163 */ "AS", + /* 164 */ "INDEX", + /* 165 */ "FUNCTION", + /* 166 */ "INTERVAL", + /* 167 */ "TOPIC", + /* 168 */ "WITH", + /* 169 */ "META", + /* 170 */ "CONSUMER", + /* 171 */ "GROUP", + /* 172 */ "DESC", + /* 173 */ "DESCRIBE", + /* 174 */ "RESET", + /* 175 */ "QUERY", + /* 176 */ "CACHE", + /* 177 */ "EXPLAIN", + /* 178 */ "ANALYZE", + /* 179 */ "VERBOSE", + /* 180 */ "NK_BOOL", + /* 181 */ "RATIO", + /* 182 */ "NK_FLOAT", + /* 183 */ "OUTPUTTYPE", + /* 184 */ "AGGREGATE", + /* 185 */ "BUFSIZE", + /* 186 */ "STREAM", + /* 187 */ "INTO", + /* 188 */ "TRIGGER", + /* 189 */ "AT_ONCE", + /* 190 */ "WINDOW_CLOSE", + /* 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 */ "STRING", + /* 315 */ "TIMES", + /* 316 */ "UPDATE", + /* 317 */ "VALUES", + /* 318 */ "VARIABLE", + /* 319 */ "VIEW", + /* 320 */ "WAL", + /* 321 */ "cmd", + /* 322 */ "account_options", + /* 323 */ "alter_account_options", + /* 324 */ "literal", + /* 325 */ "alter_account_option", + /* 326 */ "user_name", + /* 327 */ "sysinfo_opt", + /* 328 */ "privileges", + /* 329 */ "priv_level", + /* 330 */ "priv_type_list", + /* 331 */ "priv_type", + /* 332 */ "db_name", + /* 333 */ "topic_name", + /* 334 */ "dnode_endpoint", + /* 335 */ "force_opt", + /* 336 */ "not_exists_opt", + /* 337 */ "db_options", + /* 338 */ "exists_opt", + /* 339 */ "alter_db_options", + /* 340 */ "speed_opt", + /* 341 */ "integer_list", + /* 342 */ "variable_list", + /* 343 */ "retention_list", + /* 344 */ "alter_db_option", + /* 345 */ "retention", + /* 346 */ "full_table_name", + /* 347 */ "column_def_list", + /* 348 */ "tags_def_opt", + /* 349 */ "table_options", + /* 350 */ "multi_create_clause", + /* 351 */ "tags_def", + /* 352 */ "multi_drop_clause", + /* 353 */ "alter_table_clause", + /* 354 */ "alter_table_options", + /* 355 */ "column_name", + /* 356 */ "type_name", + /* 357 */ "signed_literal", + /* 358 */ "create_subtable_clause", + /* 359 */ "specific_cols_opt", + /* 360 */ "expression_list", + /* 361 */ "drop_table_clause", + /* 362 */ "col_name_list", + /* 363 */ "table_name", + /* 364 */ "column_def", + /* 365 */ "duration_list", + /* 366 */ "rollup_func_list", + /* 367 */ "alter_table_option", + /* 368 */ "duration_literal", + /* 369 */ "rollup_func_name", + /* 370 */ "function_name", + /* 371 */ "col_name", + /* 372 */ "db_name_cond_opt", + /* 373 */ "like_pattern_opt", + /* 374 */ "table_name_cond", + /* 375 */ "from_db_opt", + /* 376 */ "tag_list_opt", + /* 377 */ "tag_item", + /* 378 */ "column_alias", + /* 379 */ "index_options", + /* 380 */ "func_list", + /* 381 */ "sliding_opt", + /* 382 */ "sma_stream_opt", + /* 383 */ "func", + /* 384 */ "stream_options", + /* 385 */ "query_or_subquery", + /* 386 */ "cgroup_name", + /* 387 */ "analyze_opt", + /* 388 */ "explain_options", + /* 389 */ "agg_func_opt", + /* 390 */ "bufsize_opt", + /* 391 */ "stream_name", + /* 392 */ "subtable_opt", + /* 393 */ "expression", + /* 394 */ "dnode_list", + /* 395 */ "where_clause_opt", + /* 396 */ "signed", + /* 397 */ "literal_func", + /* 398 */ "literal_list", + /* 399 */ "table_alias", + /* 400 */ "expr_or_subquery", + /* 401 */ "pseudo_column", + /* 402 */ "column_reference", + /* 403 */ "function_expression", + /* 404 */ "case_when_expression", + /* 405 */ "star_func", + /* 406 */ "star_func_para_list", + /* 407 */ "noarg_func", + /* 408 */ "other_para_list", + /* 409 */ "star_func_para", + /* 410 */ "when_then_list", + /* 411 */ "case_when_else_opt", + /* 412 */ "common_expression", + /* 413 */ "when_then_expr", + /* 414 */ "predicate", + /* 415 */ "compare_op", + /* 416 */ "in_op", + /* 417 */ "in_predicate_value", + /* 418 */ "boolean_value_expression", + /* 419 */ "boolean_primary", + /* 420 */ "from_clause_opt", + /* 421 */ "table_reference_list", + /* 422 */ "table_reference", + /* 423 */ "table_primary", + /* 424 */ "joined_table", + /* 425 */ "alias_opt", + /* 426 */ "subquery", + /* 427 */ "parenthesized_joined_table", + /* 428 */ "join_type", + /* 429 */ "search_condition", + /* 430 */ "query_specification", + /* 431 */ "set_quantifier_opt", + /* 432 */ "select_list", + /* 433 */ "partition_by_clause_opt", + /* 434 */ "range_opt", + /* 435 */ "every_opt", + /* 436 */ "fill_opt", + /* 437 */ "twindow_clause_opt", + /* 438 */ "group_by_clause_opt", + /* 439 */ "having_clause_opt", + /* 440 */ "select_item", + /* 441 */ "partition_list", + /* 442 */ "partition_item", + /* 443 */ "fill_mode", + /* 444 */ "group_by_list", + /* 445 */ "query_expression", + /* 446 */ "query_simple", + /* 447 */ "order_by_clause_opt", + /* 448 */ "slimit_clause_opt", + /* 449 */ "limit_clause_opt", + /* 450 */ "union_query_expression", + /* 451 */ "query_simple_or_subquery", + /* 452 */ "sort_specification_list", + /* 453 */ "sort_specification", + /* 454 */ "ordering_specification_opt", + /* 455 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1864,506 +1838,509 @@ static const char *const yyRuleName[] = { /* 32 */ "cmd ::= REVOKE privileges ON priv_level FROM user_name", /* 33 */ "privileges ::= ALL", /* 34 */ "privileges ::= priv_type_list", - /* 35 */ "priv_type_list ::= priv_type", - /* 36 */ "priv_type_list ::= priv_type_list NK_COMMA priv_type", - /* 37 */ "priv_type ::= READ", - /* 38 */ "priv_type ::= WRITE", - /* 39 */ "priv_level ::= NK_STAR NK_DOT NK_STAR", - /* 40 */ "priv_level ::= db_name NK_DOT NK_STAR", - /* 41 */ "cmd ::= CREATE DNODE dnode_endpoint", - /* 42 */ "cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER", - /* 43 */ "cmd ::= DROP DNODE NK_INTEGER force_opt", - /* 44 */ "cmd ::= DROP DNODE dnode_endpoint force_opt", - /* 45 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING", - /* 46 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING", - /* 47 */ "cmd ::= ALTER ALL DNODES NK_STRING", - /* 48 */ "cmd ::= ALTER ALL DNODES NK_STRING NK_STRING", - /* 49 */ "dnode_endpoint ::= NK_STRING", - /* 50 */ "dnode_endpoint ::= NK_ID", - /* 51 */ "dnode_endpoint ::= NK_IPTOKEN", - /* 52 */ "force_opt ::=", - /* 53 */ "force_opt ::= FORCE", - /* 54 */ "cmd ::= ALTER LOCAL NK_STRING", - /* 55 */ "cmd ::= ALTER LOCAL NK_STRING NK_STRING", - /* 56 */ "cmd ::= CREATE QNODE ON DNODE NK_INTEGER", - /* 57 */ "cmd ::= DROP QNODE ON DNODE NK_INTEGER", - /* 58 */ "cmd ::= CREATE BNODE ON DNODE NK_INTEGER", - /* 59 */ "cmd ::= DROP BNODE ON DNODE NK_INTEGER", - /* 60 */ "cmd ::= CREATE SNODE ON DNODE NK_INTEGER", - /* 61 */ "cmd ::= DROP SNODE ON DNODE NK_INTEGER", - /* 62 */ "cmd ::= CREATE MNODE ON DNODE NK_INTEGER", - /* 63 */ "cmd ::= DROP MNODE ON DNODE NK_INTEGER", - /* 64 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", - /* 65 */ "cmd ::= DROP DATABASE exists_opt db_name", - /* 66 */ "cmd ::= USE db_name", - /* 67 */ "cmd ::= ALTER DATABASE db_name alter_db_options", - /* 68 */ "cmd ::= FLUSH DATABASE db_name", - /* 69 */ "cmd ::= TRIM DATABASE db_name speed_opt", - /* 70 */ "not_exists_opt ::= IF NOT EXISTS", - /* 71 */ "not_exists_opt ::=", - /* 72 */ "exists_opt ::= IF EXISTS", - /* 73 */ "exists_opt ::=", - /* 74 */ "db_options ::=", - /* 75 */ "db_options ::= db_options BUFFER NK_INTEGER", - /* 76 */ "db_options ::= db_options CACHEMODEL NK_STRING", - /* 77 */ "db_options ::= db_options CACHESIZE NK_INTEGER", - /* 78 */ "db_options ::= db_options COMP NK_INTEGER", - /* 79 */ "db_options ::= db_options DURATION NK_INTEGER", - /* 80 */ "db_options ::= db_options DURATION NK_VARIABLE", - /* 81 */ "db_options ::= db_options MAXROWS NK_INTEGER", - /* 82 */ "db_options ::= db_options MINROWS NK_INTEGER", - /* 83 */ "db_options ::= db_options KEEP integer_list", - /* 84 */ "db_options ::= db_options KEEP variable_list", - /* 85 */ "db_options ::= db_options PAGES NK_INTEGER", - /* 86 */ "db_options ::= db_options PAGESIZE NK_INTEGER", - /* 87 */ "db_options ::= db_options TSDB_PAGESIZE NK_INTEGER", - /* 88 */ "db_options ::= db_options PRECISION NK_STRING", - /* 89 */ "db_options ::= db_options REPLICA NK_INTEGER", - /* 90 */ "db_options ::= db_options STRICT NK_STRING", - /* 91 */ "db_options ::= db_options VGROUPS NK_INTEGER", - /* 92 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", - /* 93 */ "db_options ::= db_options RETENTIONS retention_list", - /* 94 */ "db_options ::= db_options SCHEMALESS NK_INTEGER", - /* 95 */ "db_options ::= db_options WAL_LEVEL NK_INTEGER", - /* 96 */ "db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER", - /* 97 */ "db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER", - /* 98 */ "db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER", - /* 99 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER", - /* 100 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER", - /* 101 */ "db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER", - /* 102 */ "db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER", - /* 103 */ "db_options ::= db_options STT_TRIGGER NK_INTEGER", - /* 104 */ "db_options ::= db_options TABLE_PREFIX NK_INTEGER", - /* 105 */ "db_options ::= db_options TABLE_SUFFIX NK_INTEGER", - /* 106 */ "alter_db_options ::= alter_db_option", - /* 107 */ "alter_db_options ::= alter_db_options alter_db_option", - /* 108 */ "alter_db_option ::= BUFFER NK_INTEGER", - /* 109 */ "alter_db_option ::= CACHEMODEL NK_STRING", - /* 110 */ "alter_db_option ::= CACHESIZE NK_INTEGER", - /* 111 */ "alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER", - /* 112 */ "alter_db_option ::= KEEP integer_list", - /* 113 */ "alter_db_option ::= KEEP variable_list", - /* 114 */ "alter_db_option ::= PAGES NK_INTEGER", - /* 115 */ "alter_db_option ::= REPLICA NK_INTEGER", - /* 116 */ "alter_db_option ::= STRICT NK_STRING", - /* 117 */ "alter_db_option ::= WAL_LEVEL NK_INTEGER", - /* 118 */ "alter_db_option ::= STT_TRIGGER NK_INTEGER", - /* 119 */ "integer_list ::= NK_INTEGER", - /* 120 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", - /* 121 */ "variable_list ::= NK_VARIABLE", - /* 122 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", - /* 123 */ "retention_list ::= retention", - /* 124 */ "retention_list ::= retention_list NK_COMMA retention", - /* 125 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", - /* 126 */ "speed_opt ::=", - /* 127 */ "speed_opt ::= MAX_SPEED NK_INTEGER", - /* 128 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 129 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 130 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 131 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 132 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 133 */ "cmd ::= ALTER TABLE alter_table_clause", - /* 134 */ "cmd ::= ALTER STABLE alter_table_clause", - /* 135 */ "alter_table_clause ::= full_table_name alter_table_options", - /* 136 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", - /* 137 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", - /* 138 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", - /* 139 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", - /* 140 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", - /* 141 */ "alter_table_clause ::= full_table_name DROP TAG column_name", - /* 142 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", - /* 143 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 144 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", - /* 145 */ "multi_create_clause ::= create_subtable_clause", - /* 146 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 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", - /* 148 */ "multi_drop_clause ::= drop_table_clause", - /* 149 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 150 */ "drop_table_clause ::= exists_opt full_table_name", - /* 151 */ "specific_cols_opt ::=", - /* 152 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", - /* 153 */ "full_table_name ::= table_name", - /* 154 */ "full_table_name ::= db_name NK_DOT table_name", - /* 155 */ "column_def_list ::= column_def", - /* 156 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 157 */ "column_def ::= column_name type_name", - /* 158 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 159 */ "type_name ::= BOOL", - /* 160 */ "type_name ::= TINYINT", - /* 161 */ "type_name ::= SMALLINT", - /* 162 */ "type_name ::= INT", - /* 163 */ "type_name ::= INTEGER", - /* 164 */ "type_name ::= BIGINT", - /* 165 */ "type_name ::= FLOAT", - /* 166 */ "type_name ::= DOUBLE", - /* 167 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 168 */ "type_name ::= TIMESTAMP", - /* 169 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 170 */ "type_name ::= TINYINT UNSIGNED", - /* 171 */ "type_name ::= SMALLINT UNSIGNED", - /* 172 */ "type_name ::= INT UNSIGNED", - /* 173 */ "type_name ::= BIGINT UNSIGNED", - /* 174 */ "type_name ::= JSON", - /* 175 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 176 */ "type_name ::= MEDIUMBLOB", - /* 177 */ "type_name ::= BLOB", - /* 178 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 179 */ "type_name ::= DECIMAL", - /* 180 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 181 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 182 */ "tags_def_opt ::=", - /* 183 */ "tags_def_opt ::= tags_def", - /* 184 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 185 */ "table_options ::=", - /* 186 */ "table_options ::= table_options COMMENT NK_STRING", - /* 187 */ "table_options ::= table_options MAX_DELAY duration_list", - /* 188 */ "table_options ::= table_options WATERMARK duration_list", - /* 189 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", - /* 190 */ "table_options ::= table_options TTL NK_INTEGER", - /* 191 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 192 */ "alter_table_options ::= alter_table_option", - /* 193 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 194 */ "alter_table_option ::= COMMENT NK_STRING", - /* 195 */ "alter_table_option ::= TTL NK_INTEGER", - /* 196 */ "duration_list ::= duration_literal", - /* 197 */ "duration_list ::= duration_list NK_COMMA duration_literal", - /* 198 */ "rollup_func_list ::= rollup_func_name", - /* 199 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", - /* 200 */ "rollup_func_name ::= function_name", - /* 201 */ "rollup_func_name ::= FIRST", - /* 202 */ "rollup_func_name ::= LAST", - /* 203 */ "col_name_list ::= col_name", - /* 204 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 205 */ "col_name ::= column_name", - /* 206 */ "cmd ::= SHOW DNODES", - /* 207 */ "cmd ::= SHOW USERS", - /* 208 */ "cmd ::= SHOW DATABASES", - /* 209 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", - /* 210 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 211 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 212 */ "cmd ::= SHOW MNODES", - /* 213 */ "cmd ::= SHOW QNODES", - /* 214 */ "cmd ::= SHOW FUNCTIONS", - /* 215 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 216 */ "cmd ::= SHOW STREAMS", - /* 217 */ "cmd ::= SHOW ACCOUNTS", - /* 218 */ "cmd ::= SHOW APPS", - /* 219 */ "cmd ::= SHOW CONNECTIONS", - /* 220 */ "cmd ::= SHOW LICENCES", - /* 221 */ "cmd ::= SHOW GRANTS", - /* 222 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 223 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 224 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 225 */ "cmd ::= SHOW QUERIES", - /* 226 */ "cmd ::= SHOW SCORES", - /* 227 */ "cmd ::= SHOW TOPICS", - /* 228 */ "cmd ::= SHOW VARIABLES", - /* 229 */ "cmd ::= SHOW CLUSTER VARIABLES", - /* 230 */ "cmd ::= SHOW LOCAL VARIABLES", - /* 231 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt", - /* 232 */ "cmd ::= SHOW BNODES", - /* 233 */ "cmd ::= SHOW SNODES", - /* 234 */ "cmd ::= SHOW CLUSTER", - /* 235 */ "cmd ::= SHOW TRANSACTIONS", - /* 236 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", - /* 237 */ "cmd ::= SHOW CONSUMERS", - /* 238 */ "cmd ::= SHOW SUBSCRIPTIONS", - /* 239 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", - /* 240 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", - /* 241 */ "cmd ::= SHOW VNODES NK_INTEGER", - /* 242 */ "cmd ::= SHOW VNODES NK_STRING", - /* 243 */ "db_name_cond_opt ::=", - /* 244 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 245 */ "like_pattern_opt ::=", - /* 246 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 247 */ "table_name_cond ::= table_name", - /* 248 */ "from_db_opt ::=", - /* 249 */ "from_db_opt ::= FROM db_name", - /* 250 */ "tag_list_opt ::=", - /* 251 */ "tag_list_opt ::= tag_item", - /* 252 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", - /* 253 */ "tag_item ::= TBNAME", - /* 254 */ "tag_item ::= QTAGS", - /* 255 */ "tag_item ::= column_name", - /* 256 */ "tag_item ::= column_name column_alias", - /* 257 */ "tag_item ::= column_name AS column_alias", - /* 258 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options", - /* 259 */ "cmd ::= DROP INDEX exists_opt full_table_name", - /* 260 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 261 */ "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", - /* 262 */ "func_list ::= func", - /* 263 */ "func_list ::= func_list NK_COMMA func", - /* 264 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 265 */ "sma_stream_opt ::=", - /* 266 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal", - /* 267 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal", - /* 268 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", - /* 269 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", - /* 270 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", - /* 271 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", - /* 272 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", - /* 273 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 274 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 275 */ "cmd ::= DESC full_table_name", - /* 276 */ "cmd ::= DESCRIBE full_table_name", - /* 277 */ "cmd ::= RESET QUERY CACHE", - /* 278 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", - /* 279 */ "analyze_opt ::=", - /* 280 */ "analyze_opt ::= ANALYZE", - /* 281 */ "explain_options ::=", - /* 282 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 283 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 284 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", - /* 285 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 286 */ "agg_func_opt ::=", - /* 287 */ "agg_func_opt ::= AGGREGATE", - /* 288 */ "bufsize_opt ::=", - /* 289 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 290 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery", - /* 291 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 292 */ "stream_options ::=", - /* 293 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 294 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 295 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 296 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 297 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 298 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", - /* 299 */ "subtable_opt ::=", - /* 300 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 301 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 302 */ "cmd ::= KILL QUERY NK_STRING", - /* 303 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 304 */ "cmd ::= BALANCE VGROUP", - /* 305 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 306 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 307 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 308 */ "dnode_list ::= DNODE NK_INTEGER", - /* 309 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 310 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 311 */ "cmd ::= query_or_subquery", - /* 312 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 313 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", - /* 314 */ "literal ::= NK_INTEGER", - /* 315 */ "literal ::= NK_FLOAT", - /* 316 */ "literal ::= NK_STRING", - /* 317 */ "literal ::= NK_BOOL", - /* 318 */ "literal ::= TIMESTAMP NK_STRING", - /* 319 */ "literal ::= duration_literal", - /* 320 */ "literal ::= NULL", - /* 321 */ "literal ::= NK_QUESTION", - /* 322 */ "duration_literal ::= NK_VARIABLE", - /* 323 */ "signed ::= NK_INTEGER", - /* 324 */ "signed ::= NK_PLUS NK_INTEGER", - /* 325 */ "signed ::= NK_MINUS NK_INTEGER", - /* 326 */ "signed ::= NK_FLOAT", - /* 327 */ "signed ::= NK_PLUS NK_FLOAT", - /* 328 */ "signed ::= NK_MINUS NK_FLOAT", - /* 329 */ "signed_literal ::= signed", - /* 330 */ "signed_literal ::= NK_STRING", - /* 331 */ "signed_literal ::= NK_BOOL", - /* 332 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 333 */ "signed_literal ::= duration_literal", - /* 334 */ "signed_literal ::= NULL", - /* 335 */ "signed_literal ::= literal_func", - /* 336 */ "signed_literal ::= NK_QUESTION", - /* 337 */ "literal_list ::= signed_literal", - /* 338 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 339 */ "db_name ::= NK_ID", - /* 340 */ "table_name ::= NK_ID", - /* 341 */ "column_name ::= NK_ID", - /* 342 */ "function_name ::= NK_ID", - /* 343 */ "table_alias ::= NK_ID", - /* 344 */ "column_alias ::= NK_ID", - /* 345 */ "user_name ::= NK_ID", - /* 346 */ "topic_name ::= NK_ID", - /* 347 */ "stream_name ::= NK_ID", - /* 348 */ "cgroup_name ::= NK_ID", - /* 349 */ "expr_or_subquery ::= expression", - /* 350 */ "expression ::= literal", - /* 351 */ "expression ::= pseudo_column", - /* 352 */ "expression ::= column_reference", - /* 353 */ "expression ::= function_expression", - /* 354 */ "expression ::= case_when_expression", - /* 355 */ "expression ::= NK_LP expression NK_RP", - /* 356 */ "expression ::= NK_PLUS expr_or_subquery", - /* 357 */ "expression ::= NK_MINUS expr_or_subquery", - /* 358 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 359 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 360 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 361 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 362 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 363 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 364 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 365 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 366 */ "expression_list ::= expr_or_subquery", - /* 367 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 368 */ "column_reference ::= column_name", - /* 369 */ "column_reference ::= table_name NK_DOT column_name", - /* 370 */ "pseudo_column ::= ROWTS", - /* 371 */ "pseudo_column ::= TBNAME", - /* 372 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 373 */ "pseudo_column ::= QSTART", - /* 374 */ "pseudo_column ::= QEND", - /* 375 */ "pseudo_column ::= QDURATION", - /* 376 */ "pseudo_column ::= WSTART", - /* 377 */ "pseudo_column ::= WEND", - /* 378 */ "pseudo_column ::= WDURATION", - /* 379 */ "pseudo_column ::= IROWTS", - /* 380 */ "pseudo_column ::= QTAGS", - /* 381 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 382 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 383 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 384 */ "function_expression ::= literal_func", - /* 385 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 386 */ "literal_func ::= NOW", - /* 387 */ "noarg_func ::= NOW", - /* 388 */ "noarg_func ::= TODAY", - /* 389 */ "noarg_func ::= TIMEZONE", - /* 390 */ "noarg_func ::= DATABASE", - /* 391 */ "noarg_func ::= CLIENT_VERSION", - /* 392 */ "noarg_func ::= SERVER_VERSION", - /* 393 */ "noarg_func ::= SERVER_STATUS", - /* 394 */ "noarg_func ::= CURRENT_USER", - /* 395 */ "noarg_func ::= USER", - /* 396 */ "star_func ::= COUNT", - /* 397 */ "star_func ::= FIRST", - /* 398 */ "star_func ::= LAST", - /* 399 */ "star_func ::= LAST_ROW", - /* 400 */ "star_func_para_list ::= NK_STAR", - /* 401 */ "star_func_para_list ::= other_para_list", - /* 402 */ "other_para_list ::= star_func_para", - /* 403 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 404 */ "star_func_para ::= expr_or_subquery", - /* 405 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 406 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 407 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 408 */ "when_then_list ::= when_then_expr", - /* 409 */ "when_then_list ::= when_then_list when_then_expr", - /* 410 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 411 */ "case_when_else_opt ::=", - /* 412 */ "case_when_else_opt ::= ELSE common_expression", - /* 413 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 414 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 415 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 416 */ "predicate ::= expr_or_subquery IS NULL", - /* 417 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 418 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 419 */ "compare_op ::= NK_LT", - /* 420 */ "compare_op ::= NK_GT", - /* 421 */ "compare_op ::= NK_LE", - /* 422 */ "compare_op ::= NK_GE", - /* 423 */ "compare_op ::= NK_NE", - /* 424 */ "compare_op ::= NK_EQ", - /* 425 */ "compare_op ::= LIKE", - /* 426 */ "compare_op ::= NOT LIKE", - /* 427 */ "compare_op ::= MATCH", - /* 428 */ "compare_op ::= NMATCH", - /* 429 */ "compare_op ::= CONTAINS", - /* 430 */ "in_op ::= IN", - /* 431 */ "in_op ::= NOT IN", - /* 432 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 433 */ "boolean_value_expression ::= boolean_primary", - /* 434 */ "boolean_value_expression ::= NOT boolean_primary", - /* 435 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 436 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 437 */ "boolean_primary ::= predicate", - /* 438 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 439 */ "common_expression ::= expr_or_subquery", - /* 440 */ "common_expression ::= boolean_value_expression", - /* 441 */ "from_clause_opt ::=", - /* 442 */ "from_clause_opt ::= FROM table_reference_list", - /* 443 */ "table_reference_list ::= table_reference", - /* 444 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 445 */ "table_reference ::= table_primary", - /* 446 */ "table_reference ::= joined_table", - /* 447 */ "table_primary ::= table_name alias_opt", - /* 448 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 449 */ "table_primary ::= subquery alias_opt", - /* 450 */ "table_primary ::= parenthesized_joined_table", - /* 451 */ "alias_opt ::=", - /* 452 */ "alias_opt ::= table_alias", - /* 453 */ "alias_opt ::= AS table_alias", - /* 454 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 455 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 456 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 457 */ "join_type ::=", - /* 458 */ "join_type ::= INNER", - /* 459 */ "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", - /* 460 */ "set_quantifier_opt ::=", - /* 461 */ "set_quantifier_opt ::= DISTINCT", - /* 462 */ "set_quantifier_opt ::= ALL", - /* 463 */ "select_list ::= select_item", - /* 464 */ "select_list ::= select_list NK_COMMA select_item", - /* 465 */ "select_item ::= NK_STAR", - /* 466 */ "select_item ::= common_expression", - /* 467 */ "select_item ::= common_expression column_alias", - /* 468 */ "select_item ::= common_expression AS column_alias", - /* 469 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 470 */ "where_clause_opt ::=", - /* 471 */ "where_clause_opt ::= WHERE search_condition", - /* 472 */ "partition_by_clause_opt ::=", - /* 473 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 474 */ "partition_list ::= partition_item", - /* 475 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 476 */ "partition_item ::= expr_or_subquery", - /* 477 */ "partition_item ::= expr_or_subquery column_alias", - /* 478 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 479 */ "twindow_clause_opt ::=", - /* 480 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 481 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 482 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 483 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 484 */ "sliding_opt ::=", - /* 485 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 486 */ "fill_opt ::=", - /* 487 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 488 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 489 */ "fill_mode ::= NONE", - /* 490 */ "fill_mode ::= PREV", - /* 491 */ "fill_mode ::= NULL", - /* 492 */ "fill_mode ::= LINEAR", - /* 493 */ "fill_mode ::= NEXT", - /* 494 */ "group_by_clause_opt ::=", - /* 495 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 496 */ "group_by_list ::= expr_or_subquery", - /* 497 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 498 */ "having_clause_opt ::=", - /* 499 */ "having_clause_opt ::= HAVING search_condition", - /* 500 */ "range_opt ::=", - /* 501 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 502 */ "every_opt ::=", - /* 503 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 504 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 505 */ "query_simple ::= query_specification", - /* 506 */ "query_simple ::= union_query_expression", - /* 507 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 508 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 509 */ "query_simple_or_subquery ::= query_simple", - /* 510 */ "query_simple_or_subquery ::= subquery", - /* 511 */ "query_or_subquery ::= query_expression", - /* 512 */ "query_or_subquery ::= subquery", - /* 513 */ "order_by_clause_opt ::=", - /* 514 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 515 */ "slimit_clause_opt ::=", - /* 516 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 517 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 518 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 519 */ "limit_clause_opt ::=", - /* 520 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 521 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 522 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 523 */ "subquery ::= NK_LP query_expression NK_RP", - /* 524 */ "subquery ::= NK_LP subquery NK_RP", - /* 525 */ "search_condition ::= common_expression", - /* 526 */ "sort_specification_list ::= sort_specification", - /* 527 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 528 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 529 */ "ordering_specification_opt ::=", - /* 530 */ "ordering_specification_opt ::= ASC", - /* 531 */ "ordering_specification_opt ::= DESC", - /* 532 */ "null_ordering_opt ::=", - /* 533 */ "null_ordering_opt ::= NULLS FIRST", - /* 534 */ "null_ordering_opt ::= NULLS LAST", + /* 35 */ "privileges ::= SUBSCRIBE", + /* 36 */ "priv_type_list ::= priv_type", + /* 37 */ "priv_type_list ::= priv_type_list NK_COMMA priv_type", + /* 38 */ "priv_type ::= READ", + /* 39 */ "priv_type ::= WRITE", + /* 40 */ "priv_level ::= NK_STAR NK_DOT NK_STAR", + /* 41 */ "priv_level ::= db_name NK_DOT NK_STAR", + /* 42 */ "priv_level ::= topic_name", + /* 43 */ "cmd ::= CREATE DNODE dnode_endpoint", + /* 44 */ "cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER", + /* 45 */ "cmd ::= DROP DNODE NK_INTEGER force_opt", + /* 46 */ "cmd ::= DROP DNODE dnode_endpoint force_opt", + /* 47 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING", + /* 48 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING", + /* 49 */ "cmd ::= ALTER ALL DNODES NK_STRING", + /* 50 */ "cmd ::= ALTER ALL DNODES NK_STRING NK_STRING", + /* 51 */ "dnode_endpoint ::= NK_STRING", + /* 52 */ "dnode_endpoint ::= NK_ID", + /* 53 */ "dnode_endpoint ::= NK_IPTOKEN", + /* 54 */ "force_opt ::=", + /* 55 */ "force_opt ::= FORCE", + /* 56 */ "cmd ::= ALTER LOCAL NK_STRING", + /* 57 */ "cmd ::= ALTER LOCAL NK_STRING NK_STRING", + /* 58 */ "cmd ::= CREATE QNODE ON DNODE NK_INTEGER", + /* 59 */ "cmd ::= DROP QNODE ON DNODE NK_INTEGER", + /* 60 */ "cmd ::= CREATE BNODE ON DNODE NK_INTEGER", + /* 61 */ "cmd ::= DROP BNODE ON DNODE NK_INTEGER", + /* 62 */ "cmd ::= CREATE SNODE ON DNODE NK_INTEGER", + /* 63 */ "cmd ::= DROP SNODE ON DNODE NK_INTEGER", + /* 64 */ "cmd ::= CREATE MNODE ON DNODE NK_INTEGER", + /* 65 */ "cmd ::= DROP MNODE ON DNODE NK_INTEGER", + /* 66 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", + /* 67 */ "cmd ::= DROP DATABASE exists_opt db_name", + /* 68 */ "cmd ::= USE db_name", + /* 69 */ "cmd ::= ALTER DATABASE db_name alter_db_options", + /* 70 */ "cmd ::= FLUSH DATABASE db_name", + /* 71 */ "cmd ::= TRIM DATABASE db_name speed_opt", + /* 72 */ "not_exists_opt ::= IF NOT EXISTS", + /* 73 */ "not_exists_opt ::=", + /* 74 */ "exists_opt ::= IF EXISTS", + /* 75 */ "exists_opt ::=", + /* 76 */ "db_options ::=", + /* 77 */ "db_options ::= db_options BUFFER NK_INTEGER", + /* 78 */ "db_options ::= db_options CACHEMODEL NK_STRING", + /* 79 */ "db_options ::= db_options CACHESIZE NK_INTEGER", + /* 80 */ "db_options ::= db_options COMP NK_INTEGER", + /* 81 */ "db_options ::= db_options DURATION NK_INTEGER", + /* 82 */ "db_options ::= db_options DURATION NK_VARIABLE", + /* 83 */ "db_options ::= db_options MAXROWS NK_INTEGER", + /* 84 */ "db_options ::= db_options MINROWS NK_INTEGER", + /* 85 */ "db_options ::= db_options KEEP integer_list", + /* 86 */ "db_options ::= db_options KEEP variable_list", + /* 87 */ "db_options ::= db_options PAGES NK_INTEGER", + /* 88 */ "db_options ::= db_options PAGESIZE NK_INTEGER", + /* 89 */ "db_options ::= db_options TSDB_PAGESIZE NK_INTEGER", + /* 90 */ "db_options ::= db_options PRECISION NK_STRING", + /* 91 */ "db_options ::= db_options REPLICA NK_INTEGER", + /* 92 */ "db_options ::= db_options STRICT NK_STRING", + /* 93 */ "db_options ::= db_options VGROUPS NK_INTEGER", + /* 94 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", + /* 95 */ "db_options ::= db_options RETENTIONS retention_list", + /* 96 */ "db_options ::= db_options SCHEMALESS NK_INTEGER", + /* 97 */ "db_options ::= db_options WAL_LEVEL NK_INTEGER", + /* 98 */ "db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER", + /* 99 */ "db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER", + /* 100 */ "db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER", + /* 101 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER", + /* 102 */ "db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER", + /* 103 */ "db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER", + /* 104 */ "db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER", + /* 105 */ "db_options ::= db_options STT_TRIGGER NK_INTEGER", + /* 106 */ "db_options ::= db_options TABLE_PREFIX NK_INTEGER", + /* 107 */ "db_options ::= db_options TABLE_SUFFIX NK_INTEGER", + /* 108 */ "alter_db_options ::= alter_db_option", + /* 109 */ "alter_db_options ::= alter_db_options alter_db_option", + /* 110 */ "alter_db_option ::= BUFFER NK_INTEGER", + /* 111 */ "alter_db_option ::= CACHEMODEL NK_STRING", + /* 112 */ "alter_db_option ::= CACHESIZE NK_INTEGER", + /* 113 */ "alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER", + /* 114 */ "alter_db_option ::= KEEP integer_list", + /* 115 */ "alter_db_option ::= KEEP variable_list", + /* 116 */ "alter_db_option ::= PAGES NK_INTEGER", + /* 117 */ "alter_db_option ::= REPLICA NK_INTEGER", + /* 118 */ "alter_db_option ::= STRICT NK_STRING", + /* 119 */ "alter_db_option ::= WAL_LEVEL NK_INTEGER", + /* 120 */ "alter_db_option ::= STT_TRIGGER NK_INTEGER", + /* 121 */ "integer_list ::= NK_INTEGER", + /* 122 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", + /* 123 */ "variable_list ::= NK_VARIABLE", + /* 124 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", + /* 125 */ "retention_list ::= retention", + /* 126 */ "retention_list ::= retention_list NK_COMMA retention", + /* 127 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", + /* 128 */ "speed_opt ::=", + /* 129 */ "speed_opt ::= MAX_SPEED NK_INTEGER", + /* 130 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 131 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 132 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 133 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 134 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 135 */ "cmd ::= ALTER TABLE alter_table_clause", + /* 136 */ "cmd ::= ALTER STABLE alter_table_clause", + /* 137 */ "alter_table_clause ::= full_table_name alter_table_options", + /* 138 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", + /* 139 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", + /* 140 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", + /* 141 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", + /* 142 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", + /* 143 */ "alter_table_clause ::= full_table_name DROP TAG column_name", + /* 144 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", + /* 145 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", + /* 146 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", + /* 147 */ "multi_create_clause ::= create_subtable_clause", + /* 148 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 149 */ "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", + /* 150 */ "multi_drop_clause ::= drop_table_clause", + /* 151 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 152 */ "drop_table_clause ::= exists_opt full_table_name", + /* 153 */ "specific_cols_opt ::=", + /* 154 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", + /* 155 */ "full_table_name ::= table_name", + /* 156 */ "full_table_name ::= db_name NK_DOT table_name", + /* 157 */ "column_def_list ::= column_def", + /* 158 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 159 */ "column_def ::= column_name type_name", + /* 160 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 161 */ "type_name ::= BOOL", + /* 162 */ "type_name ::= TINYINT", + /* 163 */ "type_name ::= SMALLINT", + /* 164 */ "type_name ::= INT", + /* 165 */ "type_name ::= INTEGER", + /* 166 */ "type_name ::= BIGINT", + /* 167 */ "type_name ::= FLOAT", + /* 168 */ "type_name ::= DOUBLE", + /* 169 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 170 */ "type_name ::= TIMESTAMP", + /* 171 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 172 */ "type_name ::= TINYINT UNSIGNED", + /* 173 */ "type_name ::= SMALLINT UNSIGNED", + /* 174 */ "type_name ::= INT UNSIGNED", + /* 175 */ "type_name ::= BIGINT UNSIGNED", + /* 176 */ "type_name ::= JSON", + /* 177 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 178 */ "type_name ::= MEDIUMBLOB", + /* 179 */ "type_name ::= BLOB", + /* 180 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 181 */ "type_name ::= DECIMAL", + /* 182 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 183 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 184 */ "tags_def_opt ::=", + /* 185 */ "tags_def_opt ::= tags_def", + /* 186 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 187 */ "table_options ::=", + /* 188 */ "table_options ::= table_options COMMENT NK_STRING", + /* 189 */ "table_options ::= table_options MAX_DELAY duration_list", + /* 190 */ "table_options ::= table_options WATERMARK duration_list", + /* 191 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", + /* 192 */ "table_options ::= table_options TTL NK_INTEGER", + /* 193 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 194 */ "alter_table_options ::= alter_table_option", + /* 195 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 196 */ "alter_table_option ::= COMMENT NK_STRING", + /* 197 */ "alter_table_option ::= TTL NK_INTEGER", + /* 198 */ "duration_list ::= duration_literal", + /* 199 */ "duration_list ::= duration_list NK_COMMA duration_literal", + /* 200 */ "rollup_func_list ::= rollup_func_name", + /* 201 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", + /* 202 */ "rollup_func_name ::= function_name", + /* 203 */ "rollup_func_name ::= FIRST", + /* 204 */ "rollup_func_name ::= LAST", + /* 205 */ "col_name_list ::= col_name", + /* 206 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 207 */ "col_name ::= column_name", + /* 208 */ "cmd ::= SHOW DNODES", + /* 209 */ "cmd ::= SHOW USERS", + /* 210 */ "cmd ::= SHOW USER PRIVILEGES", + /* 211 */ "cmd ::= SHOW DATABASES", + /* 212 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", + /* 213 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", + /* 214 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", + /* 215 */ "cmd ::= SHOW MNODES", + /* 216 */ "cmd ::= SHOW QNODES", + /* 217 */ "cmd ::= SHOW FUNCTIONS", + /* 218 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 219 */ "cmd ::= SHOW STREAMS", + /* 220 */ "cmd ::= SHOW ACCOUNTS", + /* 221 */ "cmd ::= SHOW APPS", + /* 222 */ "cmd ::= SHOW CONNECTIONS", + /* 223 */ "cmd ::= SHOW LICENCES", + /* 224 */ "cmd ::= SHOW GRANTS", + /* 225 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 226 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 227 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 228 */ "cmd ::= SHOW QUERIES", + /* 229 */ "cmd ::= SHOW SCORES", + /* 230 */ "cmd ::= SHOW TOPICS", + /* 231 */ "cmd ::= SHOW VARIABLES", + /* 232 */ "cmd ::= SHOW CLUSTER VARIABLES", + /* 233 */ "cmd ::= SHOW LOCAL VARIABLES", + /* 234 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt", + /* 235 */ "cmd ::= SHOW BNODES", + /* 236 */ "cmd ::= SHOW SNODES", + /* 237 */ "cmd ::= SHOW CLUSTER", + /* 238 */ "cmd ::= SHOW TRANSACTIONS", + /* 239 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", + /* 240 */ "cmd ::= SHOW CONSUMERS", + /* 241 */ "cmd ::= SHOW SUBSCRIPTIONS", + /* 242 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", + /* 243 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", + /* 244 */ "cmd ::= SHOW VNODES NK_INTEGER", + /* 245 */ "cmd ::= SHOW VNODES NK_STRING", + /* 246 */ "db_name_cond_opt ::=", + /* 247 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 248 */ "like_pattern_opt ::=", + /* 249 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 250 */ "table_name_cond ::= table_name", + /* 251 */ "from_db_opt ::=", + /* 252 */ "from_db_opt ::= FROM db_name", + /* 253 */ "tag_list_opt ::=", + /* 254 */ "tag_list_opt ::= tag_item", + /* 255 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", + /* 256 */ "tag_item ::= TBNAME", + /* 257 */ "tag_item ::= QTAGS", + /* 258 */ "tag_item ::= column_name", + /* 259 */ "tag_item ::= column_name column_alias", + /* 260 */ "tag_item ::= column_name AS column_alias", + /* 261 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options", + /* 262 */ "cmd ::= DROP INDEX exists_opt full_table_name", + /* 263 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 264 */ "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", + /* 265 */ "func_list ::= func", + /* 266 */ "func_list ::= func_list NK_COMMA func", + /* 267 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 268 */ "sma_stream_opt ::=", + /* 269 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal", + /* 270 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal", + /* 271 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", + /* 272 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", + /* 273 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", + /* 274 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", + /* 275 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", + /* 276 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 277 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 278 */ "cmd ::= DESC full_table_name", + /* 279 */ "cmd ::= DESCRIBE full_table_name", + /* 280 */ "cmd ::= RESET QUERY CACHE", + /* 281 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", + /* 282 */ "analyze_opt ::=", + /* 283 */ "analyze_opt ::= ANALYZE", + /* 284 */ "explain_options ::=", + /* 285 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 286 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 287 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 288 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 289 */ "agg_func_opt ::=", + /* 290 */ "agg_func_opt ::= AGGREGATE", + /* 291 */ "bufsize_opt ::=", + /* 292 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 293 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery", + /* 294 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 295 */ "stream_options ::=", + /* 296 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 297 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 298 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 299 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 300 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", + /* 301 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", + /* 302 */ "subtable_opt ::=", + /* 303 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 304 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 305 */ "cmd ::= KILL QUERY NK_STRING", + /* 306 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 307 */ "cmd ::= BALANCE VGROUP", + /* 308 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 309 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 310 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 311 */ "dnode_list ::= DNODE NK_INTEGER", + /* 312 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 313 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 314 */ "cmd ::= query_or_subquery", + /* 315 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 316 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", + /* 317 */ "literal ::= NK_INTEGER", + /* 318 */ "literal ::= NK_FLOAT", + /* 319 */ "literal ::= NK_STRING", + /* 320 */ "literal ::= NK_BOOL", + /* 321 */ "literal ::= TIMESTAMP NK_STRING", + /* 322 */ "literal ::= duration_literal", + /* 323 */ "literal ::= NULL", + /* 324 */ "literal ::= NK_QUESTION", + /* 325 */ "duration_literal ::= NK_VARIABLE", + /* 326 */ "signed ::= NK_INTEGER", + /* 327 */ "signed ::= NK_PLUS NK_INTEGER", + /* 328 */ "signed ::= NK_MINUS NK_INTEGER", + /* 329 */ "signed ::= NK_FLOAT", + /* 330 */ "signed ::= NK_PLUS NK_FLOAT", + /* 331 */ "signed ::= NK_MINUS NK_FLOAT", + /* 332 */ "signed_literal ::= signed", + /* 333 */ "signed_literal ::= NK_STRING", + /* 334 */ "signed_literal ::= NK_BOOL", + /* 335 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 336 */ "signed_literal ::= duration_literal", + /* 337 */ "signed_literal ::= NULL", + /* 338 */ "signed_literal ::= literal_func", + /* 339 */ "signed_literal ::= NK_QUESTION", + /* 340 */ "literal_list ::= signed_literal", + /* 341 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 342 */ "db_name ::= NK_ID", + /* 343 */ "table_name ::= NK_ID", + /* 344 */ "column_name ::= NK_ID", + /* 345 */ "function_name ::= NK_ID", + /* 346 */ "table_alias ::= NK_ID", + /* 347 */ "column_alias ::= NK_ID", + /* 348 */ "user_name ::= NK_ID", + /* 349 */ "topic_name ::= NK_ID", + /* 350 */ "stream_name ::= NK_ID", + /* 351 */ "cgroup_name ::= NK_ID", + /* 352 */ "expr_or_subquery ::= expression", + /* 353 */ "expression ::= literal", + /* 354 */ "expression ::= pseudo_column", + /* 355 */ "expression ::= column_reference", + /* 356 */ "expression ::= function_expression", + /* 357 */ "expression ::= case_when_expression", + /* 358 */ "expression ::= NK_LP expression NK_RP", + /* 359 */ "expression ::= NK_PLUS expr_or_subquery", + /* 360 */ "expression ::= NK_MINUS expr_or_subquery", + /* 361 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 362 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 363 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 364 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 365 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 366 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 367 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 368 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 369 */ "expression_list ::= expr_or_subquery", + /* 370 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 371 */ "column_reference ::= column_name", + /* 372 */ "column_reference ::= table_name NK_DOT column_name", + /* 373 */ "pseudo_column ::= ROWTS", + /* 374 */ "pseudo_column ::= TBNAME", + /* 375 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 376 */ "pseudo_column ::= QSTART", + /* 377 */ "pseudo_column ::= QEND", + /* 378 */ "pseudo_column ::= QDURATION", + /* 379 */ "pseudo_column ::= WSTART", + /* 380 */ "pseudo_column ::= WEND", + /* 381 */ "pseudo_column ::= WDURATION", + /* 382 */ "pseudo_column ::= IROWTS", + /* 383 */ "pseudo_column ::= QTAGS", + /* 384 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 385 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 386 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 387 */ "function_expression ::= literal_func", + /* 388 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 389 */ "literal_func ::= NOW", + /* 390 */ "noarg_func ::= NOW", + /* 391 */ "noarg_func ::= TODAY", + /* 392 */ "noarg_func ::= TIMEZONE", + /* 393 */ "noarg_func ::= DATABASE", + /* 394 */ "noarg_func ::= CLIENT_VERSION", + /* 395 */ "noarg_func ::= SERVER_VERSION", + /* 396 */ "noarg_func ::= SERVER_STATUS", + /* 397 */ "noarg_func ::= CURRENT_USER", + /* 398 */ "noarg_func ::= USER", + /* 399 */ "star_func ::= COUNT", + /* 400 */ "star_func ::= FIRST", + /* 401 */ "star_func ::= LAST", + /* 402 */ "star_func ::= LAST_ROW", + /* 403 */ "star_func_para_list ::= NK_STAR", + /* 404 */ "star_func_para_list ::= other_para_list", + /* 405 */ "other_para_list ::= star_func_para", + /* 406 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 407 */ "star_func_para ::= expr_or_subquery", + /* 408 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 409 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 410 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 411 */ "when_then_list ::= when_then_expr", + /* 412 */ "when_then_list ::= when_then_list when_then_expr", + /* 413 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 414 */ "case_when_else_opt ::=", + /* 415 */ "case_when_else_opt ::= ELSE common_expression", + /* 416 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 417 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 418 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 419 */ "predicate ::= expr_or_subquery IS NULL", + /* 420 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 421 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 422 */ "compare_op ::= NK_LT", + /* 423 */ "compare_op ::= NK_GT", + /* 424 */ "compare_op ::= NK_LE", + /* 425 */ "compare_op ::= NK_GE", + /* 426 */ "compare_op ::= NK_NE", + /* 427 */ "compare_op ::= NK_EQ", + /* 428 */ "compare_op ::= LIKE", + /* 429 */ "compare_op ::= NOT LIKE", + /* 430 */ "compare_op ::= MATCH", + /* 431 */ "compare_op ::= NMATCH", + /* 432 */ "compare_op ::= CONTAINS", + /* 433 */ "in_op ::= IN", + /* 434 */ "in_op ::= NOT IN", + /* 435 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 436 */ "boolean_value_expression ::= boolean_primary", + /* 437 */ "boolean_value_expression ::= NOT boolean_primary", + /* 438 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 439 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 440 */ "boolean_primary ::= predicate", + /* 441 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 442 */ "common_expression ::= expr_or_subquery", + /* 443 */ "common_expression ::= boolean_value_expression", + /* 444 */ "from_clause_opt ::=", + /* 445 */ "from_clause_opt ::= FROM table_reference_list", + /* 446 */ "table_reference_list ::= table_reference", + /* 447 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 448 */ "table_reference ::= table_primary", + /* 449 */ "table_reference ::= joined_table", + /* 450 */ "table_primary ::= table_name alias_opt", + /* 451 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 452 */ "table_primary ::= subquery alias_opt", + /* 453 */ "table_primary ::= parenthesized_joined_table", + /* 454 */ "alias_opt ::=", + /* 455 */ "alias_opt ::= table_alias", + /* 456 */ "alias_opt ::= AS table_alias", + /* 457 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 458 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 459 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 460 */ "join_type ::=", + /* 461 */ "join_type ::= INNER", + /* 462 */ "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", + /* 463 */ "set_quantifier_opt ::=", + /* 464 */ "set_quantifier_opt ::= DISTINCT", + /* 465 */ "set_quantifier_opt ::= ALL", + /* 466 */ "select_list ::= select_item", + /* 467 */ "select_list ::= select_list NK_COMMA select_item", + /* 468 */ "select_item ::= NK_STAR", + /* 469 */ "select_item ::= common_expression", + /* 470 */ "select_item ::= common_expression column_alias", + /* 471 */ "select_item ::= common_expression AS column_alias", + /* 472 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 473 */ "where_clause_opt ::=", + /* 474 */ "where_clause_opt ::= WHERE search_condition", + /* 475 */ "partition_by_clause_opt ::=", + /* 476 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 477 */ "partition_list ::= partition_item", + /* 478 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 479 */ "partition_item ::= expr_or_subquery", + /* 480 */ "partition_item ::= expr_or_subquery column_alias", + /* 481 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 482 */ "twindow_clause_opt ::=", + /* 483 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 484 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 485 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 486 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 487 */ "sliding_opt ::=", + /* 488 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 489 */ "fill_opt ::=", + /* 490 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 491 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 492 */ "fill_mode ::= NONE", + /* 493 */ "fill_mode ::= PREV", + /* 494 */ "fill_mode ::= NULL", + /* 495 */ "fill_mode ::= LINEAR", + /* 496 */ "fill_mode ::= NEXT", + /* 497 */ "group_by_clause_opt ::=", + /* 498 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 499 */ "group_by_list ::= expr_or_subquery", + /* 500 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 501 */ "having_clause_opt ::=", + /* 502 */ "having_clause_opt ::= HAVING search_condition", + /* 503 */ "range_opt ::=", + /* 504 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 505 */ "every_opt ::=", + /* 506 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 507 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 508 */ "query_simple ::= query_specification", + /* 509 */ "query_simple ::= union_query_expression", + /* 510 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 511 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 512 */ "query_simple_or_subquery ::= query_simple", + /* 513 */ "query_simple_or_subquery ::= subquery", + /* 514 */ "query_or_subquery ::= query_expression", + /* 515 */ "query_or_subquery ::= subquery", + /* 516 */ "order_by_clause_opt ::=", + /* 517 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 518 */ "slimit_clause_opt ::=", + /* 519 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 520 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 521 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 522 */ "limit_clause_opt ::=", + /* 523 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 524 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 525 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 526 */ "subquery ::= NK_LP query_expression NK_RP", + /* 527 */ "subquery ::= NK_LP subquery NK_RP", + /* 528 */ "search_condition ::= common_expression", + /* 529 */ "sort_specification_list ::= sort_specification", + /* 530 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 531 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 532 */ "ordering_specification_opt ::=", + /* 533 */ "ordering_specification_opt ::= ASC", + /* 534 */ "ordering_specification_opt ::= DESC", + /* 535 */ "null_ordering_opt ::=", + /* 536 */ "null_ordering_opt ::= NULLS FIRST", + /* 537 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2490,193 +2467,193 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 319: /* cmd */ - case 322: /* literal */ - case 334: /* db_options */ - case 336: /* alter_db_options */ - case 342: /* retention */ - case 343: /* full_table_name */ - case 346: /* table_options */ - case 350: /* alter_table_clause */ - case 351: /* alter_table_options */ - case 354: /* signed_literal */ - case 355: /* create_subtable_clause */ - case 358: /* drop_table_clause */ - case 361: /* column_def */ - case 365: /* duration_literal */ - case 366: /* rollup_func_name */ - case 368: /* col_name */ - case 369: /* db_name_cond_opt */ - case 370: /* like_pattern_opt */ - case 371: /* table_name_cond */ - case 372: /* from_db_opt */ - case 374: /* tag_item */ - case 376: /* index_options */ - case 378: /* sliding_opt */ - case 379: /* sma_stream_opt */ - case 380: /* func */ - case 381: /* stream_options */ - case 383: /* query_or_subquery */ - case 386: /* explain_options */ - case 390: /* subtable_opt */ - case 391: /* expression */ - case 393: /* where_clause_opt */ - case 394: /* signed */ - case 395: /* literal_func */ - case 398: /* expr_or_subquery */ - case 399: /* pseudo_column */ - case 400: /* column_reference */ - case 401: /* function_expression */ - case 402: /* case_when_expression */ - case 407: /* star_func_para */ - case 409: /* case_when_else_opt */ - case 410: /* common_expression */ - case 411: /* when_then_expr */ - case 412: /* predicate */ - case 415: /* in_predicate_value */ - case 416: /* boolean_value_expression */ - case 417: /* boolean_primary */ - case 418: /* from_clause_opt */ - case 419: /* table_reference_list */ - case 420: /* table_reference */ - case 421: /* table_primary */ - case 422: /* joined_table */ - case 424: /* subquery */ - case 425: /* parenthesized_joined_table */ - case 427: /* search_condition */ - case 428: /* query_specification */ - case 432: /* range_opt */ - case 433: /* every_opt */ - case 434: /* fill_opt */ - case 435: /* twindow_clause_opt */ - case 437: /* having_clause_opt */ - case 438: /* select_item */ - case 440: /* partition_item */ - case 443: /* query_expression */ - case 444: /* query_simple */ - case 446: /* slimit_clause_opt */ - case 447: /* limit_clause_opt */ - case 448: /* union_query_expression */ - case 449: /* query_simple_or_subquery */ - case 451: /* sort_specification */ + case 321: /* cmd */ + case 324: /* literal */ + case 337: /* db_options */ + case 339: /* alter_db_options */ + case 345: /* retention */ + case 346: /* full_table_name */ + case 349: /* table_options */ + case 353: /* alter_table_clause */ + case 354: /* alter_table_options */ + case 357: /* signed_literal */ + case 358: /* create_subtable_clause */ + case 361: /* drop_table_clause */ + case 364: /* column_def */ + case 368: /* duration_literal */ + case 369: /* rollup_func_name */ + case 371: /* col_name */ + case 372: /* db_name_cond_opt */ + case 373: /* like_pattern_opt */ + case 374: /* table_name_cond */ + case 375: /* from_db_opt */ + case 377: /* tag_item */ + case 379: /* index_options */ + case 381: /* sliding_opt */ + case 382: /* sma_stream_opt */ + case 383: /* func */ + case 384: /* stream_options */ + case 385: /* query_or_subquery */ + case 388: /* explain_options */ + case 392: /* subtable_opt */ + case 393: /* expression */ + case 395: /* where_clause_opt */ + case 396: /* signed */ + case 397: /* literal_func */ + case 400: /* expr_or_subquery */ + case 401: /* pseudo_column */ + case 402: /* column_reference */ + case 403: /* function_expression */ + case 404: /* case_when_expression */ + case 409: /* star_func_para */ + case 411: /* case_when_else_opt */ + case 412: /* common_expression */ + case 413: /* when_then_expr */ + case 414: /* predicate */ + case 417: /* in_predicate_value */ + case 418: /* boolean_value_expression */ + case 419: /* boolean_primary */ + case 420: /* from_clause_opt */ + case 421: /* table_reference_list */ + case 422: /* table_reference */ + case 423: /* table_primary */ + case 424: /* joined_table */ + case 426: /* subquery */ + case 427: /* parenthesized_joined_table */ + case 429: /* search_condition */ + case 430: /* query_specification */ + case 434: /* range_opt */ + case 435: /* every_opt */ + case 436: /* fill_opt */ + case 437: /* twindow_clause_opt */ + case 439: /* having_clause_opt */ + case 440: /* select_item */ + case 442: /* partition_item */ + case 445: /* query_expression */ + case 446: /* query_simple */ + case 448: /* slimit_clause_opt */ + case 449: /* limit_clause_opt */ + case 450: /* union_query_expression */ + case 451: /* query_simple_or_subquery */ + case 453: /* sort_specification */ { - nodesDestroyNode((yypminor->yy164)); + nodesDestroyNode((yypminor->yy104)); } break; - case 320: /* account_options */ - case 321: /* alter_account_options */ - case 323: /* alter_account_option */ - case 337: /* speed_opt */ - case 388: /* bufsize_opt */ + case 322: /* account_options */ + case 323: /* alter_account_options */ + case 325: /* alter_account_option */ + case 340: /* speed_opt */ + case 390: /* bufsize_opt */ { } break; - case 324: /* user_name */ - case 327: /* priv_level */ - case 330: /* db_name */ - case 331: /* dnode_endpoint */ - case 352: /* column_name */ - case 360: /* table_name */ - case 367: /* function_name */ - case 375: /* column_alias */ - case 382: /* topic_name */ - case 384: /* cgroup_name */ - case 389: /* stream_name */ - case 397: /* table_alias */ - case 403: /* star_func */ - case 405: /* noarg_func */ - case 423: /* alias_opt */ + case 326: /* user_name */ + case 329: /* priv_level */ + case 332: /* db_name */ + case 333: /* topic_name */ + case 334: /* dnode_endpoint */ + case 355: /* column_name */ + case 363: /* table_name */ + case 370: /* function_name */ + case 378: /* column_alias */ + case 386: /* cgroup_name */ + case 391: /* stream_name */ + case 399: /* table_alias */ + case 405: /* star_func */ + case 407: /* noarg_func */ + case 425: /* alias_opt */ { } break; - case 325: /* sysinfo_opt */ + case 327: /* sysinfo_opt */ { } break; - case 326: /* privileges */ - case 328: /* priv_type_list */ - case 329: /* priv_type */ + case 328: /* privileges */ + case 330: /* priv_type_list */ + case 331: /* priv_type */ { } break; - case 332: /* force_opt */ - case 333: /* not_exists_opt */ - case 335: /* exists_opt */ - case 385: /* analyze_opt */ - case 387: /* agg_func_opt */ - case 429: /* set_quantifier_opt */ + case 335: /* force_opt */ + case 336: /* not_exists_opt */ + case 338: /* exists_opt */ + case 387: /* analyze_opt */ + case 389: /* agg_func_opt */ + case 431: /* set_quantifier_opt */ { } break; - case 338: /* integer_list */ - case 339: /* variable_list */ - case 340: /* retention_list */ - case 344: /* column_def_list */ - case 345: /* tags_def_opt */ - case 347: /* multi_create_clause */ - case 348: /* tags_def */ - case 349: /* multi_drop_clause */ - case 356: /* specific_cols_opt */ - case 357: /* expression_list */ - case 359: /* col_name_list */ - case 362: /* duration_list */ - case 363: /* rollup_func_list */ - case 373: /* tag_list_opt */ - case 377: /* func_list */ - case 392: /* dnode_list */ - case 396: /* literal_list */ - case 404: /* star_func_para_list */ - case 406: /* other_para_list */ - case 408: /* when_then_list */ - case 430: /* select_list */ - case 431: /* partition_by_clause_opt */ - case 436: /* group_by_clause_opt */ - case 439: /* partition_list */ - case 442: /* group_by_list */ - case 445: /* order_by_clause_opt */ - case 450: /* sort_specification_list */ + case 341: /* integer_list */ + case 342: /* variable_list */ + case 343: /* retention_list */ + case 347: /* column_def_list */ + case 348: /* tags_def_opt */ + case 350: /* multi_create_clause */ + case 351: /* tags_def */ + case 352: /* multi_drop_clause */ + case 359: /* specific_cols_opt */ + case 360: /* expression_list */ + case 362: /* col_name_list */ + case 365: /* duration_list */ + case 366: /* rollup_func_list */ + case 376: /* tag_list_opt */ + case 380: /* func_list */ + case 394: /* dnode_list */ + case 398: /* literal_list */ + case 406: /* star_func_para_list */ + case 408: /* other_para_list */ + case 410: /* when_then_list */ + case 432: /* select_list */ + case 433: /* partition_by_clause_opt */ + case 438: /* group_by_clause_opt */ + case 441: /* partition_list */ + case 444: /* group_by_list */ + case 447: /* order_by_clause_opt */ + case 452: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy648)); + nodesDestroyList((yypminor->yy616)); } break; - case 341: /* alter_db_option */ - case 364: /* alter_table_option */ + case 344: /* alter_db_option */ + case 367: /* alter_table_option */ { } break; - case 353: /* type_name */ + case 356: /* type_name */ { } break; - case 413: /* compare_op */ - case 414: /* in_op */ + case 415: /* compare_op */ + case 416: /* in_op */ { } break; - case 426: /* join_type */ + case 428: /* join_type */ { } break; - case 441: /* fill_mode */ + case 443: /* fill_mode */ { } break; - case 452: /* ordering_specification_opt */ + case 454: /* ordering_specification_opt */ { } break; - case 453: /* null_ordering_opt */ + case 455: /* null_ordering_opt */ { } @@ -2975,541 +2952,544 @@ 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[] = { - { 319, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 319, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 320, 0 }, /* (2) account_options ::= */ - { 320, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 320, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 320, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 320, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 320, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 320, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 320, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 320, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 320, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 321, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 321, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 323, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 323, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 323, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 323, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 323, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 323, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 323, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 323, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 323, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 323, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 319, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ - { 319, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 319, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - { 319, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - { 319, -3 }, /* (28) cmd ::= DROP USER user_name */ - { 325, 0 }, /* (29) sysinfo_opt ::= */ - { 325, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ - { 319, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 319, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 326, -1 }, /* (33) privileges ::= ALL */ - { 326, -1 }, /* (34) privileges ::= priv_type_list */ - { 328, -1 }, /* (35) priv_type_list ::= priv_type */ - { 328, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 329, -1 }, /* (37) priv_type ::= READ */ - { 329, -1 }, /* (38) priv_type ::= WRITE */ - { 327, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 327, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ - { 319, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ - { 319, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - { 319, -4 }, /* (43) cmd ::= DROP DNODE NK_INTEGER force_opt */ - { 319, -4 }, /* (44) cmd ::= DROP DNODE dnode_endpoint force_opt */ - { 319, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 319, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 319, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ - { 319, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 331, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ - { 331, -1 }, /* (50) dnode_endpoint ::= NK_ID */ - { 331, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ - { 332, 0 }, /* (52) force_opt ::= */ - { 332, -1 }, /* (53) force_opt ::= FORCE */ - { 319, -3 }, /* (54) cmd ::= ALTER LOCAL NK_STRING */ - { 319, -4 }, /* (55) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 319, -5 }, /* (56) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 319, -5 }, /* (57) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 319, -5 }, /* (58) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 319, -5 }, /* (59) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 319, -5 }, /* (60) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 319, -5 }, /* (61) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 319, -5 }, /* (62) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 319, -5 }, /* (63) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 319, -5 }, /* (64) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 319, -4 }, /* (65) cmd ::= DROP DATABASE exists_opt db_name */ - { 319, -2 }, /* (66) cmd ::= USE db_name */ - { 319, -4 }, /* (67) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 319, -3 }, /* (68) cmd ::= FLUSH DATABASE db_name */ - { 319, -4 }, /* (69) cmd ::= TRIM DATABASE db_name speed_opt */ - { 333, -3 }, /* (70) not_exists_opt ::= IF NOT EXISTS */ - { 333, 0 }, /* (71) not_exists_opt ::= */ - { 335, -2 }, /* (72) exists_opt ::= IF EXISTS */ - { 335, 0 }, /* (73) exists_opt ::= */ - { 334, 0 }, /* (74) db_options ::= */ - { 334, -3 }, /* (75) db_options ::= db_options BUFFER NK_INTEGER */ - { 334, -3 }, /* (76) db_options ::= db_options CACHEMODEL NK_STRING */ - { 334, -3 }, /* (77) db_options ::= db_options CACHESIZE NK_INTEGER */ - { 334, -3 }, /* (78) db_options ::= db_options COMP NK_INTEGER */ - { 334, -3 }, /* (79) db_options ::= db_options DURATION NK_INTEGER */ - { 334, -3 }, /* (80) db_options ::= db_options DURATION NK_VARIABLE */ - { 334, -3 }, /* (81) db_options ::= db_options MAXROWS NK_INTEGER */ - { 334, -3 }, /* (82) db_options ::= db_options MINROWS NK_INTEGER */ - { 334, -3 }, /* (83) db_options ::= db_options KEEP integer_list */ - { 334, -3 }, /* (84) db_options ::= db_options KEEP variable_list */ - { 334, -3 }, /* (85) db_options ::= db_options PAGES NK_INTEGER */ - { 334, -3 }, /* (86) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 334, -3 }, /* (87) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ - { 334, -3 }, /* (88) db_options ::= db_options PRECISION NK_STRING */ - { 334, -3 }, /* (89) db_options ::= db_options REPLICA NK_INTEGER */ - { 334, -3 }, /* (90) db_options ::= db_options STRICT NK_STRING */ - { 334, -3 }, /* (91) db_options ::= db_options VGROUPS NK_INTEGER */ - { 334, -3 }, /* (92) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 334, -3 }, /* (93) db_options ::= db_options RETENTIONS retention_list */ - { 334, -3 }, /* (94) db_options ::= db_options SCHEMALESS NK_INTEGER */ - { 334, -3 }, /* (95) db_options ::= db_options WAL_LEVEL NK_INTEGER */ - { 334, -3 }, /* (96) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ - { 334, -3 }, /* (97) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ - { 334, -4 }, /* (98) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - { 334, -3 }, /* (99) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ - { 334, -4 }, /* (100) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - { 334, -3 }, /* (101) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ - { 334, -3 }, /* (102) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ - { 334, -3 }, /* (103) db_options ::= db_options STT_TRIGGER NK_INTEGER */ - { 334, -3 }, /* (104) db_options ::= db_options TABLE_PREFIX NK_INTEGER */ - { 334, -3 }, /* (105) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ - { 336, -1 }, /* (106) alter_db_options ::= alter_db_option */ - { 336, -2 }, /* (107) alter_db_options ::= alter_db_options alter_db_option */ - { 341, -2 }, /* (108) alter_db_option ::= BUFFER NK_INTEGER */ - { 341, -2 }, /* (109) alter_db_option ::= CACHEMODEL NK_STRING */ - { 341, -2 }, /* (110) alter_db_option ::= CACHESIZE NK_INTEGER */ - { 341, -2 }, /* (111) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ - { 341, -2 }, /* (112) alter_db_option ::= KEEP integer_list */ - { 341, -2 }, /* (113) alter_db_option ::= KEEP variable_list */ - { 341, -2 }, /* (114) alter_db_option ::= PAGES NK_INTEGER */ - { 341, -2 }, /* (115) alter_db_option ::= REPLICA NK_INTEGER */ - { 341, -2 }, /* (116) alter_db_option ::= STRICT NK_STRING */ - { 341, -2 }, /* (117) alter_db_option ::= WAL_LEVEL NK_INTEGER */ - { 341, -2 }, /* (118) alter_db_option ::= STT_TRIGGER NK_INTEGER */ - { 338, -1 }, /* (119) integer_list ::= NK_INTEGER */ - { 338, -3 }, /* (120) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 339, -1 }, /* (121) variable_list ::= NK_VARIABLE */ - { 339, -3 }, /* (122) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 340, -1 }, /* (123) retention_list ::= retention */ - { 340, -3 }, /* (124) retention_list ::= retention_list NK_COMMA retention */ - { 342, -3 }, /* (125) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 337, 0 }, /* (126) speed_opt ::= */ - { 337, -2 }, /* (127) speed_opt ::= MAX_SPEED NK_INTEGER */ - { 319, -9 }, /* (128) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 319, -3 }, /* (129) cmd ::= CREATE TABLE multi_create_clause */ - { 319, -9 }, /* (130) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 319, -3 }, /* (131) cmd ::= DROP TABLE multi_drop_clause */ - { 319, -4 }, /* (132) cmd ::= DROP STABLE exists_opt full_table_name */ - { 319, -3 }, /* (133) cmd ::= ALTER TABLE alter_table_clause */ - { 319, -3 }, /* (134) cmd ::= ALTER STABLE alter_table_clause */ - { 350, -2 }, /* (135) alter_table_clause ::= full_table_name alter_table_options */ - { 350, -5 }, /* (136) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 350, -4 }, /* (137) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 350, -5 }, /* (138) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 350, -5 }, /* (139) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 350, -5 }, /* (140) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 350, -4 }, /* (141) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 350, -5 }, /* (142) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 350, -5 }, /* (143) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 350, -6 }, /* (144) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 347, -1 }, /* (145) multi_create_clause ::= create_subtable_clause */ - { 347, -2 }, /* (146) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 355, -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 */ - { 349, -1 }, /* (148) multi_drop_clause ::= drop_table_clause */ - { 349, -2 }, /* (149) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 358, -2 }, /* (150) drop_table_clause ::= exists_opt full_table_name */ - { 356, 0 }, /* (151) specific_cols_opt ::= */ - { 356, -3 }, /* (152) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - { 343, -1 }, /* (153) full_table_name ::= table_name */ - { 343, -3 }, /* (154) full_table_name ::= db_name NK_DOT table_name */ - { 344, -1 }, /* (155) column_def_list ::= column_def */ - { 344, -3 }, /* (156) column_def_list ::= column_def_list NK_COMMA column_def */ - { 361, -2 }, /* (157) column_def ::= column_name type_name */ - { 361, -4 }, /* (158) column_def ::= column_name type_name COMMENT NK_STRING */ - { 353, -1 }, /* (159) type_name ::= BOOL */ - { 353, -1 }, /* (160) type_name ::= TINYINT */ - { 353, -1 }, /* (161) type_name ::= SMALLINT */ - { 353, -1 }, /* (162) type_name ::= INT */ - { 353, -1 }, /* (163) type_name ::= INTEGER */ - { 353, -1 }, /* (164) type_name ::= BIGINT */ - { 353, -1 }, /* (165) type_name ::= FLOAT */ - { 353, -1 }, /* (166) type_name ::= DOUBLE */ - { 353, -4 }, /* (167) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 353, -1 }, /* (168) type_name ::= TIMESTAMP */ - { 353, -4 }, /* (169) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 353, -2 }, /* (170) type_name ::= TINYINT UNSIGNED */ - { 353, -2 }, /* (171) type_name ::= SMALLINT UNSIGNED */ - { 353, -2 }, /* (172) type_name ::= INT UNSIGNED */ - { 353, -2 }, /* (173) type_name ::= BIGINT UNSIGNED */ - { 353, -1 }, /* (174) type_name ::= JSON */ - { 353, -4 }, /* (175) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 353, -1 }, /* (176) type_name ::= MEDIUMBLOB */ - { 353, -1 }, /* (177) type_name ::= BLOB */ - { 353, -4 }, /* (178) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 353, -1 }, /* (179) type_name ::= DECIMAL */ - { 353, -4 }, /* (180) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 353, -6 }, /* (181) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 345, 0 }, /* (182) tags_def_opt ::= */ - { 345, -1 }, /* (183) tags_def_opt ::= tags_def */ - { 348, -4 }, /* (184) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 346, 0 }, /* (185) table_options ::= */ - { 346, -3 }, /* (186) table_options ::= table_options COMMENT NK_STRING */ - { 346, -3 }, /* (187) table_options ::= table_options MAX_DELAY duration_list */ - { 346, -3 }, /* (188) table_options ::= table_options WATERMARK duration_list */ - { 346, -5 }, /* (189) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - { 346, -3 }, /* (190) table_options ::= table_options TTL NK_INTEGER */ - { 346, -5 }, /* (191) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 351, -1 }, /* (192) alter_table_options ::= alter_table_option */ - { 351, -2 }, /* (193) alter_table_options ::= alter_table_options alter_table_option */ - { 364, -2 }, /* (194) alter_table_option ::= COMMENT NK_STRING */ - { 364, -2 }, /* (195) alter_table_option ::= TTL NK_INTEGER */ - { 362, -1 }, /* (196) duration_list ::= duration_literal */ - { 362, -3 }, /* (197) duration_list ::= duration_list NK_COMMA duration_literal */ - { 363, -1 }, /* (198) rollup_func_list ::= rollup_func_name */ - { 363, -3 }, /* (199) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - { 366, -1 }, /* (200) rollup_func_name ::= function_name */ - { 366, -1 }, /* (201) rollup_func_name ::= FIRST */ - { 366, -1 }, /* (202) rollup_func_name ::= LAST */ - { 359, -1 }, /* (203) col_name_list ::= col_name */ - { 359, -3 }, /* (204) col_name_list ::= col_name_list NK_COMMA col_name */ - { 368, -1 }, /* (205) col_name ::= column_name */ - { 319, -2 }, /* (206) cmd ::= SHOW DNODES */ - { 319, -2 }, /* (207) cmd ::= SHOW USERS */ - { 319, -2 }, /* (208) cmd ::= SHOW DATABASES */ - { 319, -4 }, /* (209) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 319, -4 }, /* (210) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 319, -3 }, /* (211) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 319, -2 }, /* (212) cmd ::= SHOW MNODES */ - { 319, -2 }, /* (213) cmd ::= SHOW QNODES */ - { 319, -2 }, /* (214) cmd ::= SHOW FUNCTIONS */ - { 319, -5 }, /* (215) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 319, -2 }, /* (216) cmd ::= SHOW STREAMS */ - { 319, -2 }, /* (217) cmd ::= SHOW ACCOUNTS */ - { 319, -2 }, /* (218) cmd ::= SHOW APPS */ - { 319, -2 }, /* (219) cmd ::= SHOW CONNECTIONS */ - { 319, -2 }, /* (220) cmd ::= SHOW LICENCES */ - { 319, -2 }, /* (221) cmd ::= SHOW GRANTS */ - { 319, -4 }, /* (222) cmd ::= SHOW CREATE DATABASE db_name */ - { 319, -4 }, /* (223) cmd ::= SHOW CREATE TABLE full_table_name */ - { 319, -4 }, /* (224) cmd ::= SHOW CREATE STABLE full_table_name */ - { 319, -2 }, /* (225) cmd ::= SHOW QUERIES */ - { 319, -2 }, /* (226) cmd ::= SHOW SCORES */ - { 319, -2 }, /* (227) cmd ::= SHOW TOPICS */ - { 319, -2 }, /* (228) cmd ::= SHOW VARIABLES */ - { 319, -3 }, /* (229) cmd ::= SHOW CLUSTER VARIABLES */ - { 319, -3 }, /* (230) cmd ::= SHOW LOCAL VARIABLES */ - { 319, -5 }, /* (231) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ - { 319, -2 }, /* (232) cmd ::= SHOW BNODES */ - { 319, -2 }, /* (233) cmd ::= SHOW SNODES */ - { 319, -2 }, /* (234) cmd ::= SHOW CLUSTER */ - { 319, -2 }, /* (235) cmd ::= SHOW TRANSACTIONS */ - { 319, -4 }, /* (236) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - { 319, -2 }, /* (237) cmd ::= SHOW CONSUMERS */ - { 319, -2 }, /* (238) cmd ::= SHOW SUBSCRIPTIONS */ - { 319, -5 }, /* (239) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - { 319, -7 }, /* (240) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ - { 319, -3 }, /* (241) cmd ::= SHOW VNODES NK_INTEGER */ - { 319, -3 }, /* (242) cmd ::= SHOW VNODES NK_STRING */ - { 369, 0 }, /* (243) db_name_cond_opt ::= */ - { 369, -2 }, /* (244) db_name_cond_opt ::= db_name NK_DOT */ - { 370, 0 }, /* (245) like_pattern_opt ::= */ - { 370, -2 }, /* (246) like_pattern_opt ::= LIKE NK_STRING */ - { 371, -1 }, /* (247) table_name_cond ::= table_name */ - { 372, 0 }, /* (248) from_db_opt ::= */ - { 372, -2 }, /* (249) from_db_opt ::= FROM db_name */ - { 373, 0 }, /* (250) tag_list_opt ::= */ - { 373, -1 }, /* (251) tag_list_opt ::= tag_item */ - { 373, -3 }, /* (252) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ - { 374, -1 }, /* (253) tag_item ::= TBNAME */ - { 374, -1 }, /* (254) tag_item ::= QTAGS */ - { 374, -1 }, /* (255) tag_item ::= column_name */ - { 374, -2 }, /* (256) tag_item ::= column_name column_alias */ - { 374, -3 }, /* (257) tag_item ::= column_name AS column_alias */ - { 319, -8 }, /* (258) cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ - { 319, -4 }, /* (259) cmd ::= DROP INDEX exists_opt full_table_name */ - { 376, -10 }, /* (260) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - { 376, -12 }, /* (261) 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 */ - { 377, -1 }, /* (262) func_list ::= func */ - { 377, -3 }, /* (263) func_list ::= func_list NK_COMMA func */ - { 380, -4 }, /* (264) func ::= function_name NK_LP expression_list NK_RP */ - { 379, 0 }, /* (265) sma_stream_opt ::= */ - { 379, -3 }, /* (266) sma_stream_opt ::= stream_options WATERMARK duration_literal */ - { 379, -3 }, /* (267) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ - { 319, -6 }, /* (268) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - { 319, -7 }, /* (269) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 319, -9 }, /* (270) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ - { 319, -7 }, /* (271) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 319, -9 }, /* (272) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ - { 319, -4 }, /* (273) cmd ::= DROP TOPIC exists_opt topic_name */ - { 319, -7 }, /* (274) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 319, -2 }, /* (275) cmd ::= DESC full_table_name */ - { 319, -2 }, /* (276) cmd ::= DESCRIBE full_table_name */ - { 319, -3 }, /* (277) cmd ::= RESET QUERY CACHE */ - { 319, -4 }, /* (278) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - { 385, 0 }, /* (279) analyze_opt ::= */ - { 385, -1 }, /* (280) analyze_opt ::= ANALYZE */ - { 386, 0 }, /* (281) explain_options ::= */ - { 386, -3 }, /* (282) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 386, -3 }, /* (283) explain_options ::= explain_options RATIO NK_FLOAT */ - { 319, -10 }, /* (284) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 319, -4 }, /* (285) cmd ::= DROP FUNCTION exists_opt function_name */ - { 387, 0 }, /* (286) agg_func_opt ::= */ - { 387, -1 }, /* (287) agg_func_opt ::= AGGREGATE */ - { 388, 0 }, /* (288) bufsize_opt ::= */ - { 388, -2 }, /* (289) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 319, -11 }, /* (290) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery */ - { 319, -4 }, /* (291) cmd ::= DROP STREAM exists_opt stream_name */ - { 381, 0 }, /* (292) stream_options ::= */ - { 381, -3 }, /* (293) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 381, -3 }, /* (294) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 381, -4 }, /* (295) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 381, -3 }, /* (296) stream_options ::= stream_options WATERMARK duration_literal */ - { 381, -4 }, /* (297) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - { 381, -3 }, /* (298) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - { 390, 0 }, /* (299) subtable_opt ::= */ - { 390, -4 }, /* (300) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - { 319, -3 }, /* (301) cmd ::= KILL CONNECTION NK_INTEGER */ - { 319, -3 }, /* (302) cmd ::= KILL QUERY NK_STRING */ - { 319, -3 }, /* (303) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 319, -2 }, /* (304) cmd ::= BALANCE VGROUP */ - { 319, -4 }, /* (305) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 319, -4 }, /* (306) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 319, -3 }, /* (307) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 392, -2 }, /* (308) dnode_list ::= DNODE NK_INTEGER */ - { 392, -3 }, /* (309) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 319, -4 }, /* (310) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 319, -1 }, /* (311) cmd ::= query_or_subquery */ - { 319, -7 }, /* (312) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - { 319, -4 }, /* (313) cmd ::= INSERT INTO full_table_name query_or_subquery */ - { 322, -1 }, /* (314) literal ::= NK_INTEGER */ - { 322, -1 }, /* (315) literal ::= NK_FLOAT */ - { 322, -1 }, /* (316) literal ::= NK_STRING */ - { 322, -1 }, /* (317) literal ::= NK_BOOL */ - { 322, -2 }, /* (318) literal ::= TIMESTAMP NK_STRING */ - { 322, -1 }, /* (319) literal ::= duration_literal */ - { 322, -1 }, /* (320) literal ::= NULL */ - { 322, -1 }, /* (321) literal ::= NK_QUESTION */ - { 365, -1 }, /* (322) duration_literal ::= NK_VARIABLE */ - { 394, -1 }, /* (323) signed ::= NK_INTEGER */ - { 394, -2 }, /* (324) signed ::= NK_PLUS NK_INTEGER */ - { 394, -2 }, /* (325) signed ::= NK_MINUS NK_INTEGER */ - { 394, -1 }, /* (326) signed ::= NK_FLOAT */ - { 394, -2 }, /* (327) signed ::= NK_PLUS NK_FLOAT */ - { 394, -2 }, /* (328) signed ::= NK_MINUS NK_FLOAT */ - { 354, -1 }, /* (329) signed_literal ::= signed */ - { 354, -1 }, /* (330) signed_literal ::= NK_STRING */ - { 354, -1 }, /* (331) signed_literal ::= NK_BOOL */ - { 354, -2 }, /* (332) signed_literal ::= TIMESTAMP NK_STRING */ - { 354, -1 }, /* (333) signed_literal ::= duration_literal */ - { 354, -1 }, /* (334) signed_literal ::= NULL */ - { 354, -1 }, /* (335) signed_literal ::= literal_func */ - { 354, -1 }, /* (336) signed_literal ::= NK_QUESTION */ - { 396, -1 }, /* (337) literal_list ::= signed_literal */ - { 396, -3 }, /* (338) literal_list ::= literal_list NK_COMMA signed_literal */ - { 330, -1 }, /* (339) db_name ::= NK_ID */ - { 360, -1 }, /* (340) table_name ::= NK_ID */ - { 352, -1 }, /* (341) column_name ::= NK_ID */ - { 367, -1 }, /* (342) function_name ::= NK_ID */ - { 397, -1 }, /* (343) table_alias ::= NK_ID */ - { 375, -1 }, /* (344) column_alias ::= NK_ID */ - { 324, -1 }, /* (345) user_name ::= NK_ID */ - { 382, -1 }, /* (346) topic_name ::= NK_ID */ - { 389, -1 }, /* (347) stream_name ::= NK_ID */ - { 384, -1 }, /* (348) cgroup_name ::= NK_ID */ - { 398, -1 }, /* (349) expr_or_subquery ::= expression */ - { 391, -1 }, /* (350) expression ::= literal */ - { 391, -1 }, /* (351) expression ::= pseudo_column */ - { 391, -1 }, /* (352) expression ::= column_reference */ - { 391, -1 }, /* (353) expression ::= function_expression */ - { 391, -1 }, /* (354) expression ::= case_when_expression */ - { 391, -3 }, /* (355) expression ::= NK_LP expression NK_RP */ - { 391, -2 }, /* (356) expression ::= NK_PLUS expr_or_subquery */ - { 391, -2 }, /* (357) expression ::= NK_MINUS expr_or_subquery */ - { 391, -3 }, /* (358) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - { 391, -3 }, /* (359) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - { 391, -3 }, /* (360) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - { 391, -3 }, /* (361) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - { 391, -3 }, /* (362) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - { 391, -3 }, /* (363) expression ::= column_reference NK_ARROW NK_STRING */ - { 391, -3 }, /* (364) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - { 391, -3 }, /* (365) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - { 357, -1 }, /* (366) expression_list ::= expr_or_subquery */ - { 357, -3 }, /* (367) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - { 400, -1 }, /* (368) column_reference ::= column_name */ - { 400, -3 }, /* (369) column_reference ::= table_name NK_DOT column_name */ - { 399, -1 }, /* (370) pseudo_column ::= ROWTS */ - { 399, -1 }, /* (371) pseudo_column ::= TBNAME */ - { 399, -3 }, /* (372) pseudo_column ::= table_name NK_DOT TBNAME */ - { 399, -1 }, /* (373) pseudo_column ::= QSTART */ - { 399, -1 }, /* (374) pseudo_column ::= QEND */ - { 399, -1 }, /* (375) pseudo_column ::= QDURATION */ - { 399, -1 }, /* (376) pseudo_column ::= WSTART */ - { 399, -1 }, /* (377) pseudo_column ::= WEND */ - { 399, -1 }, /* (378) pseudo_column ::= WDURATION */ - { 399, -1 }, /* (379) pseudo_column ::= IROWTS */ - { 399, -1 }, /* (380) pseudo_column ::= QTAGS */ - { 401, -4 }, /* (381) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 401, -4 }, /* (382) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 401, -6 }, /* (383) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - { 401, -1 }, /* (384) function_expression ::= literal_func */ - { 395, -3 }, /* (385) literal_func ::= noarg_func NK_LP NK_RP */ - { 395, -1 }, /* (386) literal_func ::= NOW */ - { 405, -1 }, /* (387) noarg_func ::= NOW */ - { 405, -1 }, /* (388) noarg_func ::= TODAY */ - { 405, -1 }, /* (389) noarg_func ::= TIMEZONE */ - { 405, -1 }, /* (390) noarg_func ::= DATABASE */ - { 405, -1 }, /* (391) noarg_func ::= CLIENT_VERSION */ - { 405, -1 }, /* (392) noarg_func ::= SERVER_VERSION */ - { 405, -1 }, /* (393) noarg_func ::= SERVER_STATUS */ - { 405, -1 }, /* (394) noarg_func ::= CURRENT_USER */ - { 405, -1 }, /* (395) noarg_func ::= USER */ - { 403, -1 }, /* (396) star_func ::= COUNT */ - { 403, -1 }, /* (397) star_func ::= FIRST */ - { 403, -1 }, /* (398) star_func ::= LAST */ - { 403, -1 }, /* (399) star_func ::= LAST_ROW */ - { 404, -1 }, /* (400) star_func_para_list ::= NK_STAR */ - { 404, -1 }, /* (401) star_func_para_list ::= other_para_list */ - { 406, -1 }, /* (402) other_para_list ::= star_func_para */ - { 406, -3 }, /* (403) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 407, -1 }, /* (404) star_func_para ::= expr_or_subquery */ - { 407, -3 }, /* (405) star_func_para ::= table_name NK_DOT NK_STAR */ - { 402, -4 }, /* (406) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - { 402, -5 }, /* (407) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - { 408, -1 }, /* (408) when_then_list ::= when_then_expr */ - { 408, -2 }, /* (409) when_then_list ::= when_then_list when_then_expr */ - { 411, -4 }, /* (410) when_then_expr ::= WHEN common_expression THEN common_expression */ - { 409, 0 }, /* (411) case_when_else_opt ::= */ - { 409, -2 }, /* (412) case_when_else_opt ::= ELSE common_expression */ - { 412, -3 }, /* (413) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - { 412, -5 }, /* (414) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - { 412, -6 }, /* (415) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - { 412, -3 }, /* (416) predicate ::= expr_or_subquery IS NULL */ - { 412, -4 }, /* (417) predicate ::= expr_or_subquery IS NOT NULL */ - { 412, -3 }, /* (418) predicate ::= expr_or_subquery in_op in_predicate_value */ - { 413, -1 }, /* (419) compare_op ::= NK_LT */ - { 413, -1 }, /* (420) compare_op ::= NK_GT */ - { 413, -1 }, /* (421) compare_op ::= NK_LE */ - { 413, -1 }, /* (422) compare_op ::= NK_GE */ - { 413, -1 }, /* (423) compare_op ::= NK_NE */ - { 413, -1 }, /* (424) compare_op ::= NK_EQ */ - { 413, -1 }, /* (425) compare_op ::= LIKE */ - { 413, -2 }, /* (426) compare_op ::= NOT LIKE */ - { 413, -1 }, /* (427) compare_op ::= MATCH */ - { 413, -1 }, /* (428) compare_op ::= NMATCH */ - { 413, -1 }, /* (429) compare_op ::= CONTAINS */ - { 414, -1 }, /* (430) in_op ::= IN */ - { 414, -2 }, /* (431) in_op ::= NOT IN */ - { 415, -3 }, /* (432) in_predicate_value ::= NK_LP literal_list NK_RP */ - { 416, -1 }, /* (433) boolean_value_expression ::= boolean_primary */ - { 416, -2 }, /* (434) boolean_value_expression ::= NOT boolean_primary */ - { 416, -3 }, /* (435) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 416, -3 }, /* (436) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 417, -1 }, /* (437) boolean_primary ::= predicate */ - { 417, -3 }, /* (438) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 410, -1 }, /* (439) common_expression ::= expr_or_subquery */ - { 410, -1 }, /* (440) common_expression ::= boolean_value_expression */ - { 418, 0 }, /* (441) from_clause_opt ::= */ - { 418, -2 }, /* (442) from_clause_opt ::= FROM table_reference_list */ - { 419, -1 }, /* (443) table_reference_list ::= table_reference */ - { 419, -3 }, /* (444) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 420, -1 }, /* (445) table_reference ::= table_primary */ - { 420, -1 }, /* (446) table_reference ::= joined_table */ - { 421, -2 }, /* (447) table_primary ::= table_name alias_opt */ - { 421, -4 }, /* (448) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 421, -2 }, /* (449) table_primary ::= subquery alias_opt */ - { 421, -1 }, /* (450) table_primary ::= parenthesized_joined_table */ - { 423, 0 }, /* (451) alias_opt ::= */ - { 423, -1 }, /* (452) alias_opt ::= table_alias */ - { 423, -2 }, /* (453) alias_opt ::= AS table_alias */ - { 425, -3 }, /* (454) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 425, -3 }, /* (455) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 422, -6 }, /* (456) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 426, 0 }, /* (457) join_type ::= */ - { 426, -1 }, /* (458) join_type ::= INNER */ - { 428, -12 }, /* (459) 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 */ - { 429, 0 }, /* (460) set_quantifier_opt ::= */ - { 429, -1 }, /* (461) set_quantifier_opt ::= DISTINCT */ - { 429, -1 }, /* (462) set_quantifier_opt ::= ALL */ - { 430, -1 }, /* (463) select_list ::= select_item */ - { 430, -3 }, /* (464) select_list ::= select_list NK_COMMA select_item */ - { 438, -1 }, /* (465) select_item ::= NK_STAR */ - { 438, -1 }, /* (466) select_item ::= common_expression */ - { 438, -2 }, /* (467) select_item ::= common_expression column_alias */ - { 438, -3 }, /* (468) select_item ::= common_expression AS column_alias */ - { 438, -3 }, /* (469) select_item ::= table_name NK_DOT NK_STAR */ - { 393, 0 }, /* (470) where_clause_opt ::= */ - { 393, -2 }, /* (471) where_clause_opt ::= WHERE search_condition */ - { 431, 0 }, /* (472) partition_by_clause_opt ::= */ - { 431, -3 }, /* (473) partition_by_clause_opt ::= PARTITION BY partition_list */ - { 439, -1 }, /* (474) partition_list ::= partition_item */ - { 439, -3 }, /* (475) partition_list ::= partition_list NK_COMMA partition_item */ - { 440, -1 }, /* (476) partition_item ::= expr_or_subquery */ - { 440, -2 }, /* (477) partition_item ::= expr_or_subquery column_alias */ - { 440, -3 }, /* (478) partition_item ::= expr_or_subquery AS column_alias */ - { 435, 0 }, /* (479) twindow_clause_opt ::= */ - { 435, -6 }, /* (480) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 435, -4 }, /* (481) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - { 435, -6 }, /* (482) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 435, -8 }, /* (483) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 378, 0 }, /* (484) sliding_opt ::= */ - { 378, -4 }, /* (485) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 434, 0 }, /* (486) fill_opt ::= */ - { 434, -4 }, /* (487) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 434, -6 }, /* (488) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 441, -1 }, /* (489) fill_mode ::= NONE */ - { 441, -1 }, /* (490) fill_mode ::= PREV */ - { 441, -1 }, /* (491) fill_mode ::= NULL */ - { 441, -1 }, /* (492) fill_mode ::= LINEAR */ - { 441, -1 }, /* (493) fill_mode ::= NEXT */ - { 436, 0 }, /* (494) group_by_clause_opt ::= */ - { 436, -3 }, /* (495) group_by_clause_opt ::= GROUP BY group_by_list */ - { 442, -1 }, /* (496) group_by_list ::= expr_or_subquery */ - { 442, -3 }, /* (497) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - { 437, 0 }, /* (498) having_clause_opt ::= */ - { 437, -2 }, /* (499) having_clause_opt ::= HAVING search_condition */ - { 432, 0 }, /* (500) range_opt ::= */ - { 432, -6 }, /* (501) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - { 433, 0 }, /* (502) every_opt ::= */ - { 433, -4 }, /* (503) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 443, -4 }, /* (504) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 444, -1 }, /* (505) query_simple ::= query_specification */ - { 444, -1 }, /* (506) query_simple ::= union_query_expression */ - { 448, -4 }, /* (507) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - { 448, -3 }, /* (508) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - { 449, -1 }, /* (509) query_simple_or_subquery ::= query_simple */ - { 449, -1 }, /* (510) query_simple_or_subquery ::= subquery */ - { 383, -1 }, /* (511) query_or_subquery ::= query_expression */ - { 383, -1 }, /* (512) query_or_subquery ::= subquery */ - { 445, 0 }, /* (513) order_by_clause_opt ::= */ - { 445, -3 }, /* (514) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 446, 0 }, /* (515) slimit_clause_opt ::= */ - { 446, -2 }, /* (516) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 446, -4 }, /* (517) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 446, -4 }, /* (518) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 447, 0 }, /* (519) limit_clause_opt ::= */ - { 447, -2 }, /* (520) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 447, -4 }, /* (521) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 447, -4 }, /* (522) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 424, -3 }, /* (523) subquery ::= NK_LP query_expression NK_RP */ - { 424, -3 }, /* (524) subquery ::= NK_LP subquery NK_RP */ - { 427, -1 }, /* (525) search_condition ::= common_expression */ - { 450, -1 }, /* (526) sort_specification_list ::= sort_specification */ - { 450, -3 }, /* (527) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 451, -3 }, /* (528) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - { 452, 0 }, /* (529) ordering_specification_opt ::= */ - { 452, -1 }, /* (530) ordering_specification_opt ::= ASC */ - { 452, -1 }, /* (531) ordering_specification_opt ::= DESC */ - { 453, 0 }, /* (532) null_ordering_opt ::= */ - { 453, -2 }, /* (533) null_ordering_opt ::= NULLS FIRST */ - { 453, -2 }, /* (534) null_ordering_opt ::= NULLS LAST */ + { 321, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 321, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 322, 0 }, /* (2) account_options ::= */ + { 322, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 322, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 322, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 322, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 322, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 322, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 322, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 322, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 322, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 323, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 323, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 325, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 325, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 325, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 325, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 325, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 325, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 325, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 325, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 325, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 325, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 321, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ + { 321, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 321, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + { 321, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + { 321, -3 }, /* (28) cmd ::= DROP USER user_name */ + { 327, 0 }, /* (29) sysinfo_opt ::= */ + { 327, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ + { 321, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 321, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 328, -1 }, /* (33) privileges ::= ALL */ + { 328, -1 }, /* (34) privileges ::= priv_type_list */ + { 328, -1 }, /* (35) privileges ::= SUBSCRIBE */ + { 330, -1 }, /* (36) priv_type_list ::= priv_type */ + { 330, -3 }, /* (37) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 331, -1 }, /* (38) priv_type ::= READ */ + { 331, -1 }, /* (39) priv_type ::= WRITE */ + { 329, -3 }, /* (40) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 329, -3 }, /* (41) priv_level ::= db_name NK_DOT NK_STAR */ + { 329, -1 }, /* (42) priv_level ::= topic_name */ + { 321, -3 }, /* (43) cmd ::= CREATE DNODE dnode_endpoint */ + { 321, -5 }, /* (44) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + { 321, -4 }, /* (45) cmd ::= DROP DNODE NK_INTEGER force_opt */ + { 321, -4 }, /* (46) cmd ::= DROP DNODE dnode_endpoint force_opt */ + { 321, -4 }, /* (47) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 321, -5 }, /* (48) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 321, -4 }, /* (49) cmd ::= ALTER ALL DNODES NK_STRING */ + { 321, -5 }, /* (50) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 334, -1 }, /* (51) dnode_endpoint ::= NK_STRING */ + { 334, -1 }, /* (52) dnode_endpoint ::= NK_ID */ + { 334, -1 }, /* (53) dnode_endpoint ::= NK_IPTOKEN */ + { 335, 0 }, /* (54) force_opt ::= */ + { 335, -1 }, /* (55) force_opt ::= FORCE */ + { 321, -3 }, /* (56) cmd ::= ALTER LOCAL NK_STRING */ + { 321, -4 }, /* (57) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 321, -5 }, /* (58) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 321, -5 }, /* (59) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 321, -5 }, /* (60) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 321, -5 }, /* (61) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 321, -5 }, /* (62) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 321, -5 }, /* (63) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 321, -5 }, /* (64) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 321, -5 }, /* (65) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 321, -5 }, /* (66) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 321, -4 }, /* (67) cmd ::= DROP DATABASE exists_opt db_name */ + { 321, -2 }, /* (68) cmd ::= USE db_name */ + { 321, -4 }, /* (69) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 321, -3 }, /* (70) cmd ::= FLUSH DATABASE db_name */ + { 321, -4 }, /* (71) cmd ::= TRIM DATABASE db_name speed_opt */ + { 336, -3 }, /* (72) not_exists_opt ::= IF NOT EXISTS */ + { 336, 0 }, /* (73) not_exists_opt ::= */ + { 338, -2 }, /* (74) exists_opt ::= IF EXISTS */ + { 338, 0 }, /* (75) exists_opt ::= */ + { 337, 0 }, /* (76) db_options ::= */ + { 337, -3 }, /* (77) db_options ::= db_options BUFFER NK_INTEGER */ + { 337, -3 }, /* (78) db_options ::= db_options CACHEMODEL NK_STRING */ + { 337, -3 }, /* (79) db_options ::= db_options CACHESIZE NK_INTEGER */ + { 337, -3 }, /* (80) db_options ::= db_options COMP NK_INTEGER */ + { 337, -3 }, /* (81) db_options ::= db_options DURATION NK_INTEGER */ + { 337, -3 }, /* (82) db_options ::= db_options DURATION NK_VARIABLE */ + { 337, -3 }, /* (83) db_options ::= db_options MAXROWS NK_INTEGER */ + { 337, -3 }, /* (84) db_options ::= db_options MINROWS NK_INTEGER */ + { 337, -3 }, /* (85) db_options ::= db_options KEEP integer_list */ + { 337, -3 }, /* (86) db_options ::= db_options KEEP variable_list */ + { 337, -3 }, /* (87) db_options ::= db_options PAGES NK_INTEGER */ + { 337, -3 }, /* (88) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 337, -3 }, /* (89) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ + { 337, -3 }, /* (90) db_options ::= db_options PRECISION NK_STRING */ + { 337, -3 }, /* (91) db_options ::= db_options REPLICA NK_INTEGER */ + { 337, -3 }, /* (92) db_options ::= db_options STRICT NK_STRING */ + { 337, -3 }, /* (93) db_options ::= db_options VGROUPS NK_INTEGER */ + { 337, -3 }, /* (94) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 337, -3 }, /* (95) db_options ::= db_options RETENTIONS retention_list */ + { 337, -3 }, /* (96) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 337, -3 }, /* (97) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + { 337, -3 }, /* (98) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + { 337, -3 }, /* (99) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + { 337, -4 }, /* (100) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + { 337, -3 }, /* (101) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + { 337, -4 }, /* (102) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + { 337, -3 }, /* (103) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + { 337, -3 }, /* (104) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + { 337, -3 }, /* (105) db_options ::= db_options STT_TRIGGER NK_INTEGER */ + { 337, -3 }, /* (106) db_options ::= db_options TABLE_PREFIX NK_INTEGER */ + { 337, -3 }, /* (107) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ + { 339, -1 }, /* (108) alter_db_options ::= alter_db_option */ + { 339, -2 }, /* (109) alter_db_options ::= alter_db_options alter_db_option */ + { 344, -2 }, /* (110) alter_db_option ::= BUFFER NK_INTEGER */ + { 344, -2 }, /* (111) alter_db_option ::= CACHEMODEL NK_STRING */ + { 344, -2 }, /* (112) alter_db_option ::= CACHESIZE NK_INTEGER */ + { 344, -2 }, /* (113) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + { 344, -2 }, /* (114) alter_db_option ::= KEEP integer_list */ + { 344, -2 }, /* (115) alter_db_option ::= KEEP variable_list */ + { 344, -2 }, /* (116) alter_db_option ::= PAGES NK_INTEGER */ + { 344, -2 }, /* (117) alter_db_option ::= REPLICA NK_INTEGER */ + { 344, -2 }, /* (118) alter_db_option ::= STRICT NK_STRING */ + { 344, -2 }, /* (119) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + { 344, -2 }, /* (120) alter_db_option ::= STT_TRIGGER NK_INTEGER */ + { 341, -1 }, /* (121) integer_list ::= NK_INTEGER */ + { 341, -3 }, /* (122) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 342, -1 }, /* (123) variable_list ::= NK_VARIABLE */ + { 342, -3 }, /* (124) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 343, -1 }, /* (125) retention_list ::= retention */ + { 343, -3 }, /* (126) retention_list ::= retention_list NK_COMMA retention */ + { 345, -3 }, /* (127) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 340, 0 }, /* (128) speed_opt ::= */ + { 340, -2 }, /* (129) speed_opt ::= MAX_SPEED NK_INTEGER */ + { 321, -9 }, /* (130) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 321, -3 }, /* (131) cmd ::= CREATE TABLE multi_create_clause */ + { 321, -9 }, /* (132) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 321, -3 }, /* (133) cmd ::= DROP TABLE multi_drop_clause */ + { 321, -4 }, /* (134) cmd ::= DROP STABLE exists_opt full_table_name */ + { 321, -3 }, /* (135) cmd ::= ALTER TABLE alter_table_clause */ + { 321, -3 }, /* (136) cmd ::= ALTER STABLE alter_table_clause */ + { 353, -2 }, /* (137) alter_table_clause ::= full_table_name alter_table_options */ + { 353, -5 }, /* (138) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 353, -4 }, /* (139) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 353, -5 }, /* (140) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 353, -5 }, /* (141) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 353, -5 }, /* (142) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 353, -4 }, /* (143) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 353, -5 }, /* (144) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 353, -5 }, /* (145) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 353, -6 }, /* (146) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 350, -1 }, /* (147) multi_create_clause ::= create_subtable_clause */ + { 350, -2 }, /* (148) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 358, -10 }, /* (149) 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 */ + { 352, -1 }, /* (150) multi_drop_clause ::= drop_table_clause */ + { 352, -2 }, /* (151) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 361, -2 }, /* (152) drop_table_clause ::= exists_opt full_table_name */ + { 359, 0 }, /* (153) specific_cols_opt ::= */ + { 359, -3 }, /* (154) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + { 346, -1 }, /* (155) full_table_name ::= table_name */ + { 346, -3 }, /* (156) full_table_name ::= db_name NK_DOT table_name */ + { 347, -1 }, /* (157) column_def_list ::= column_def */ + { 347, -3 }, /* (158) column_def_list ::= column_def_list NK_COMMA column_def */ + { 364, -2 }, /* (159) column_def ::= column_name type_name */ + { 364, -4 }, /* (160) column_def ::= column_name type_name COMMENT NK_STRING */ + { 356, -1 }, /* (161) type_name ::= BOOL */ + { 356, -1 }, /* (162) type_name ::= TINYINT */ + { 356, -1 }, /* (163) type_name ::= SMALLINT */ + { 356, -1 }, /* (164) type_name ::= INT */ + { 356, -1 }, /* (165) type_name ::= INTEGER */ + { 356, -1 }, /* (166) type_name ::= BIGINT */ + { 356, -1 }, /* (167) type_name ::= FLOAT */ + { 356, -1 }, /* (168) type_name ::= DOUBLE */ + { 356, -4 }, /* (169) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 356, -1 }, /* (170) type_name ::= TIMESTAMP */ + { 356, -4 }, /* (171) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 356, -2 }, /* (172) type_name ::= TINYINT UNSIGNED */ + { 356, -2 }, /* (173) type_name ::= SMALLINT UNSIGNED */ + { 356, -2 }, /* (174) type_name ::= INT UNSIGNED */ + { 356, -2 }, /* (175) type_name ::= BIGINT UNSIGNED */ + { 356, -1 }, /* (176) type_name ::= JSON */ + { 356, -4 }, /* (177) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 356, -1 }, /* (178) type_name ::= MEDIUMBLOB */ + { 356, -1 }, /* (179) type_name ::= BLOB */ + { 356, -4 }, /* (180) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 356, -1 }, /* (181) type_name ::= DECIMAL */ + { 356, -4 }, /* (182) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 356, -6 }, /* (183) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 348, 0 }, /* (184) tags_def_opt ::= */ + { 348, -1 }, /* (185) tags_def_opt ::= tags_def */ + { 351, -4 }, /* (186) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 349, 0 }, /* (187) table_options ::= */ + { 349, -3 }, /* (188) table_options ::= table_options COMMENT NK_STRING */ + { 349, -3 }, /* (189) table_options ::= table_options MAX_DELAY duration_list */ + { 349, -3 }, /* (190) table_options ::= table_options WATERMARK duration_list */ + { 349, -5 }, /* (191) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + { 349, -3 }, /* (192) table_options ::= table_options TTL NK_INTEGER */ + { 349, -5 }, /* (193) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 354, -1 }, /* (194) alter_table_options ::= alter_table_option */ + { 354, -2 }, /* (195) alter_table_options ::= alter_table_options alter_table_option */ + { 367, -2 }, /* (196) alter_table_option ::= COMMENT NK_STRING */ + { 367, -2 }, /* (197) alter_table_option ::= TTL NK_INTEGER */ + { 365, -1 }, /* (198) duration_list ::= duration_literal */ + { 365, -3 }, /* (199) duration_list ::= duration_list NK_COMMA duration_literal */ + { 366, -1 }, /* (200) rollup_func_list ::= rollup_func_name */ + { 366, -3 }, /* (201) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + { 369, -1 }, /* (202) rollup_func_name ::= function_name */ + { 369, -1 }, /* (203) rollup_func_name ::= FIRST */ + { 369, -1 }, /* (204) rollup_func_name ::= LAST */ + { 362, -1 }, /* (205) col_name_list ::= col_name */ + { 362, -3 }, /* (206) col_name_list ::= col_name_list NK_COMMA col_name */ + { 371, -1 }, /* (207) col_name ::= column_name */ + { 321, -2 }, /* (208) cmd ::= SHOW DNODES */ + { 321, -2 }, /* (209) cmd ::= SHOW USERS */ + { 321, -3 }, /* (210) cmd ::= SHOW USER PRIVILEGES */ + { 321, -2 }, /* (211) cmd ::= SHOW DATABASES */ + { 321, -4 }, /* (212) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 321, -4 }, /* (213) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 321, -3 }, /* (214) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 321, -2 }, /* (215) cmd ::= SHOW MNODES */ + { 321, -2 }, /* (216) cmd ::= SHOW QNODES */ + { 321, -2 }, /* (217) cmd ::= SHOW FUNCTIONS */ + { 321, -5 }, /* (218) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 321, -2 }, /* (219) cmd ::= SHOW STREAMS */ + { 321, -2 }, /* (220) cmd ::= SHOW ACCOUNTS */ + { 321, -2 }, /* (221) cmd ::= SHOW APPS */ + { 321, -2 }, /* (222) cmd ::= SHOW CONNECTIONS */ + { 321, -2 }, /* (223) cmd ::= SHOW LICENCES */ + { 321, -2 }, /* (224) cmd ::= SHOW GRANTS */ + { 321, -4 }, /* (225) cmd ::= SHOW CREATE DATABASE db_name */ + { 321, -4 }, /* (226) cmd ::= SHOW CREATE TABLE full_table_name */ + { 321, -4 }, /* (227) cmd ::= SHOW CREATE STABLE full_table_name */ + { 321, -2 }, /* (228) cmd ::= SHOW QUERIES */ + { 321, -2 }, /* (229) cmd ::= SHOW SCORES */ + { 321, -2 }, /* (230) cmd ::= SHOW TOPICS */ + { 321, -2 }, /* (231) cmd ::= SHOW VARIABLES */ + { 321, -3 }, /* (232) cmd ::= SHOW CLUSTER VARIABLES */ + { 321, -3 }, /* (233) cmd ::= SHOW LOCAL VARIABLES */ + { 321, -5 }, /* (234) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ + { 321, -2 }, /* (235) cmd ::= SHOW BNODES */ + { 321, -2 }, /* (236) cmd ::= SHOW SNODES */ + { 321, -2 }, /* (237) cmd ::= SHOW CLUSTER */ + { 321, -2 }, /* (238) cmd ::= SHOW TRANSACTIONS */ + { 321, -4 }, /* (239) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 321, -2 }, /* (240) cmd ::= SHOW CONSUMERS */ + { 321, -2 }, /* (241) cmd ::= SHOW SUBSCRIPTIONS */ + { 321, -5 }, /* (242) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + { 321, -7 }, /* (243) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ + { 321, -3 }, /* (244) cmd ::= SHOW VNODES NK_INTEGER */ + { 321, -3 }, /* (245) cmd ::= SHOW VNODES NK_STRING */ + { 372, 0 }, /* (246) db_name_cond_opt ::= */ + { 372, -2 }, /* (247) db_name_cond_opt ::= db_name NK_DOT */ + { 373, 0 }, /* (248) like_pattern_opt ::= */ + { 373, -2 }, /* (249) like_pattern_opt ::= LIKE NK_STRING */ + { 374, -1 }, /* (250) table_name_cond ::= table_name */ + { 375, 0 }, /* (251) from_db_opt ::= */ + { 375, -2 }, /* (252) from_db_opt ::= FROM db_name */ + { 376, 0 }, /* (253) tag_list_opt ::= */ + { 376, -1 }, /* (254) tag_list_opt ::= tag_item */ + { 376, -3 }, /* (255) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ + { 377, -1 }, /* (256) tag_item ::= TBNAME */ + { 377, -1 }, /* (257) tag_item ::= QTAGS */ + { 377, -1 }, /* (258) tag_item ::= column_name */ + { 377, -2 }, /* (259) tag_item ::= column_name column_alias */ + { 377, -3 }, /* (260) tag_item ::= column_name AS column_alias */ + { 321, -8 }, /* (261) cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ + { 321, -4 }, /* (262) cmd ::= DROP INDEX exists_opt full_table_name */ + { 379, -10 }, /* (263) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + { 379, -12 }, /* (264) 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 */ + { 380, -1 }, /* (265) func_list ::= func */ + { 380, -3 }, /* (266) func_list ::= func_list NK_COMMA func */ + { 383, -4 }, /* (267) func ::= function_name NK_LP expression_list NK_RP */ + { 382, 0 }, /* (268) sma_stream_opt ::= */ + { 382, -3 }, /* (269) sma_stream_opt ::= stream_options WATERMARK duration_literal */ + { 382, -3 }, /* (270) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ + { 321, -6 }, /* (271) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + { 321, -7 }, /* (272) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 321, -9 }, /* (273) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 321, -7 }, /* (274) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 321, -9 }, /* (275) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 321, -4 }, /* (276) cmd ::= DROP TOPIC exists_opt topic_name */ + { 321, -7 }, /* (277) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 321, -2 }, /* (278) cmd ::= DESC full_table_name */ + { 321, -2 }, /* (279) cmd ::= DESCRIBE full_table_name */ + { 321, -3 }, /* (280) cmd ::= RESET QUERY CACHE */ + { 321, -4 }, /* (281) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + { 387, 0 }, /* (282) analyze_opt ::= */ + { 387, -1 }, /* (283) analyze_opt ::= ANALYZE */ + { 388, 0 }, /* (284) explain_options ::= */ + { 388, -3 }, /* (285) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 388, -3 }, /* (286) explain_options ::= explain_options RATIO NK_FLOAT */ + { 321, -10 }, /* (287) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 321, -4 }, /* (288) cmd ::= DROP FUNCTION exists_opt function_name */ + { 389, 0 }, /* (289) agg_func_opt ::= */ + { 389, -1 }, /* (290) agg_func_opt ::= AGGREGATE */ + { 390, 0 }, /* (291) bufsize_opt ::= */ + { 390, -2 }, /* (292) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 321, -11 }, /* (293) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery */ + { 321, -4 }, /* (294) cmd ::= DROP STREAM exists_opt stream_name */ + { 384, 0 }, /* (295) stream_options ::= */ + { 384, -3 }, /* (296) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 384, -3 }, /* (297) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 384, -4 }, /* (298) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 384, -3 }, /* (299) stream_options ::= stream_options WATERMARK duration_literal */ + { 384, -4 }, /* (300) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + { 384, -3 }, /* (301) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + { 392, 0 }, /* (302) subtable_opt ::= */ + { 392, -4 }, /* (303) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + { 321, -3 }, /* (304) cmd ::= KILL CONNECTION NK_INTEGER */ + { 321, -3 }, /* (305) cmd ::= KILL QUERY NK_STRING */ + { 321, -3 }, /* (306) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 321, -2 }, /* (307) cmd ::= BALANCE VGROUP */ + { 321, -4 }, /* (308) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 321, -4 }, /* (309) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 321, -3 }, /* (310) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 394, -2 }, /* (311) dnode_list ::= DNODE NK_INTEGER */ + { 394, -3 }, /* (312) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 321, -4 }, /* (313) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 321, -1 }, /* (314) cmd ::= query_or_subquery */ + { 321, -7 }, /* (315) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + { 321, -4 }, /* (316) cmd ::= INSERT INTO full_table_name query_or_subquery */ + { 324, -1 }, /* (317) literal ::= NK_INTEGER */ + { 324, -1 }, /* (318) literal ::= NK_FLOAT */ + { 324, -1 }, /* (319) literal ::= NK_STRING */ + { 324, -1 }, /* (320) literal ::= NK_BOOL */ + { 324, -2 }, /* (321) literal ::= TIMESTAMP NK_STRING */ + { 324, -1 }, /* (322) literal ::= duration_literal */ + { 324, -1 }, /* (323) literal ::= NULL */ + { 324, -1 }, /* (324) literal ::= NK_QUESTION */ + { 368, -1 }, /* (325) duration_literal ::= NK_VARIABLE */ + { 396, -1 }, /* (326) signed ::= NK_INTEGER */ + { 396, -2 }, /* (327) signed ::= NK_PLUS NK_INTEGER */ + { 396, -2 }, /* (328) signed ::= NK_MINUS NK_INTEGER */ + { 396, -1 }, /* (329) signed ::= NK_FLOAT */ + { 396, -2 }, /* (330) signed ::= NK_PLUS NK_FLOAT */ + { 396, -2 }, /* (331) signed ::= NK_MINUS NK_FLOAT */ + { 357, -1 }, /* (332) signed_literal ::= signed */ + { 357, -1 }, /* (333) signed_literal ::= NK_STRING */ + { 357, -1 }, /* (334) signed_literal ::= NK_BOOL */ + { 357, -2 }, /* (335) signed_literal ::= TIMESTAMP NK_STRING */ + { 357, -1 }, /* (336) signed_literal ::= duration_literal */ + { 357, -1 }, /* (337) signed_literal ::= NULL */ + { 357, -1 }, /* (338) signed_literal ::= literal_func */ + { 357, -1 }, /* (339) signed_literal ::= NK_QUESTION */ + { 398, -1 }, /* (340) literal_list ::= signed_literal */ + { 398, -3 }, /* (341) literal_list ::= literal_list NK_COMMA signed_literal */ + { 332, -1 }, /* (342) db_name ::= NK_ID */ + { 363, -1 }, /* (343) table_name ::= NK_ID */ + { 355, -1 }, /* (344) column_name ::= NK_ID */ + { 370, -1 }, /* (345) function_name ::= NK_ID */ + { 399, -1 }, /* (346) table_alias ::= NK_ID */ + { 378, -1 }, /* (347) column_alias ::= NK_ID */ + { 326, -1 }, /* (348) user_name ::= NK_ID */ + { 333, -1 }, /* (349) topic_name ::= NK_ID */ + { 391, -1 }, /* (350) stream_name ::= NK_ID */ + { 386, -1 }, /* (351) cgroup_name ::= NK_ID */ + { 400, -1 }, /* (352) expr_or_subquery ::= expression */ + { 393, -1 }, /* (353) expression ::= literal */ + { 393, -1 }, /* (354) expression ::= pseudo_column */ + { 393, -1 }, /* (355) expression ::= column_reference */ + { 393, -1 }, /* (356) expression ::= function_expression */ + { 393, -1 }, /* (357) expression ::= case_when_expression */ + { 393, -3 }, /* (358) expression ::= NK_LP expression NK_RP */ + { 393, -2 }, /* (359) expression ::= NK_PLUS expr_or_subquery */ + { 393, -2 }, /* (360) expression ::= NK_MINUS expr_or_subquery */ + { 393, -3 }, /* (361) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + { 393, -3 }, /* (362) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + { 393, -3 }, /* (363) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + { 393, -3 }, /* (364) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + { 393, -3 }, /* (365) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + { 393, -3 }, /* (366) expression ::= column_reference NK_ARROW NK_STRING */ + { 393, -3 }, /* (367) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + { 393, -3 }, /* (368) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + { 360, -1 }, /* (369) expression_list ::= expr_or_subquery */ + { 360, -3 }, /* (370) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + { 402, -1 }, /* (371) column_reference ::= column_name */ + { 402, -3 }, /* (372) column_reference ::= table_name NK_DOT column_name */ + { 401, -1 }, /* (373) pseudo_column ::= ROWTS */ + { 401, -1 }, /* (374) pseudo_column ::= TBNAME */ + { 401, -3 }, /* (375) pseudo_column ::= table_name NK_DOT TBNAME */ + { 401, -1 }, /* (376) pseudo_column ::= QSTART */ + { 401, -1 }, /* (377) pseudo_column ::= QEND */ + { 401, -1 }, /* (378) pseudo_column ::= QDURATION */ + { 401, -1 }, /* (379) pseudo_column ::= WSTART */ + { 401, -1 }, /* (380) pseudo_column ::= WEND */ + { 401, -1 }, /* (381) pseudo_column ::= WDURATION */ + { 401, -1 }, /* (382) pseudo_column ::= IROWTS */ + { 401, -1 }, /* (383) pseudo_column ::= QTAGS */ + { 403, -4 }, /* (384) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 403, -4 }, /* (385) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 403, -6 }, /* (386) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + { 403, -1 }, /* (387) function_expression ::= literal_func */ + { 397, -3 }, /* (388) literal_func ::= noarg_func NK_LP NK_RP */ + { 397, -1 }, /* (389) literal_func ::= NOW */ + { 407, -1 }, /* (390) noarg_func ::= NOW */ + { 407, -1 }, /* (391) noarg_func ::= TODAY */ + { 407, -1 }, /* (392) noarg_func ::= TIMEZONE */ + { 407, -1 }, /* (393) noarg_func ::= DATABASE */ + { 407, -1 }, /* (394) noarg_func ::= CLIENT_VERSION */ + { 407, -1 }, /* (395) noarg_func ::= SERVER_VERSION */ + { 407, -1 }, /* (396) noarg_func ::= SERVER_STATUS */ + { 407, -1 }, /* (397) noarg_func ::= CURRENT_USER */ + { 407, -1 }, /* (398) noarg_func ::= USER */ + { 405, -1 }, /* (399) star_func ::= COUNT */ + { 405, -1 }, /* (400) star_func ::= FIRST */ + { 405, -1 }, /* (401) star_func ::= LAST */ + { 405, -1 }, /* (402) star_func ::= LAST_ROW */ + { 406, -1 }, /* (403) star_func_para_list ::= NK_STAR */ + { 406, -1 }, /* (404) star_func_para_list ::= other_para_list */ + { 408, -1 }, /* (405) other_para_list ::= star_func_para */ + { 408, -3 }, /* (406) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 409, -1 }, /* (407) star_func_para ::= expr_or_subquery */ + { 409, -3 }, /* (408) star_func_para ::= table_name NK_DOT NK_STAR */ + { 404, -4 }, /* (409) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + { 404, -5 }, /* (410) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + { 410, -1 }, /* (411) when_then_list ::= when_then_expr */ + { 410, -2 }, /* (412) when_then_list ::= when_then_list when_then_expr */ + { 413, -4 }, /* (413) when_then_expr ::= WHEN common_expression THEN common_expression */ + { 411, 0 }, /* (414) case_when_else_opt ::= */ + { 411, -2 }, /* (415) case_when_else_opt ::= ELSE common_expression */ + { 414, -3 }, /* (416) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + { 414, -5 }, /* (417) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + { 414, -6 }, /* (418) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + { 414, -3 }, /* (419) predicate ::= expr_or_subquery IS NULL */ + { 414, -4 }, /* (420) predicate ::= expr_or_subquery IS NOT NULL */ + { 414, -3 }, /* (421) predicate ::= expr_or_subquery in_op in_predicate_value */ + { 415, -1 }, /* (422) compare_op ::= NK_LT */ + { 415, -1 }, /* (423) compare_op ::= NK_GT */ + { 415, -1 }, /* (424) compare_op ::= NK_LE */ + { 415, -1 }, /* (425) compare_op ::= NK_GE */ + { 415, -1 }, /* (426) compare_op ::= NK_NE */ + { 415, -1 }, /* (427) compare_op ::= NK_EQ */ + { 415, -1 }, /* (428) compare_op ::= LIKE */ + { 415, -2 }, /* (429) compare_op ::= NOT LIKE */ + { 415, -1 }, /* (430) compare_op ::= MATCH */ + { 415, -1 }, /* (431) compare_op ::= NMATCH */ + { 415, -1 }, /* (432) compare_op ::= CONTAINS */ + { 416, -1 }, /* (433) in_op ::= IN */ + { 416, -2 }, /* (434) in_op ::= NOT IN */ + { 417, -3 }, /* (435) in_predicate_value ::= NK_LP literal_list NK_RP */ + { 418, -1 }, /* (436) boolean_value_expression ::= boolean_primary */ + { 418, -2 }, /* (437) boolean_value_expression ::= NOT boolean_primary */ + { 418, -3 }, /* (438) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 418, -3 }, /* (439) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 419, -1 }, /* (440) boolean_primary ::= predicate */ + { 419, -3 }, /* (441) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 412, -1 }, /* (442) common_expression ::= expr_or_subquery */ + { 412, -1 }, /* (443) common_expression ::= boolean_value_expression */ + { 420, 0 }, /* (444) from_clause_opt ::= */ + { 420, -2 }, /* (445) from_clause_opt ::= FROM table_reference_list */ + { 421, -1 }, /* (446) table_reference_list ::= table_reference */ + { 421, -3 }, /* (447) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 422, -1 }, /* (448) table_reference ::= table_primary */ + { 422, -1 }, /* (449) table_reference ::= joined_table */ + { 423, -2 }, /* (450) table_primary ::= table_name alias_opt */ + { 423, -4 }, /* (451) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 423, -2 }, /* (452) table_primary ::= subquery alias_opt */ + { 423, -1 }, /* (453) table_primary ::= parenthesized_joined_table */ + { 425, 0 }, /* (454) alias_opt ::= */ + { 425, -1 }, /* (455) alias_opt ::= table_alias */ + { 425, -2 }, /* (456) alias_opt ::= AS table_alias */ + { 427, -3 }, /* (457) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 427, -3 }, /* (458) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 424, -6 }, /* (459) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 428, 0 }, /* (460) join_type ::= */ + { 428, -1 }, /* (461) join_type ::= INNER */ + { 430, -12 }, /* (462) 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 */ + { 431, 0 }, /* (463) set_quantifier_opt ::= */ + { 431, -1 }, /* (464) set_quantifier_opt ::= DISTINCT */ + { 431, -1 }, /* (465) set_quantifier_opt ::= ALL */ + { 432, -1 }, /* (466) select_list ::= select_item */ + { 432, -3 }, /* (467) select_list ::= select_list NK_COMMA select_item */ + { 440, -1 }, /* (468) select_item ::= NK_STAR */ + { 440, -1 }, /* (469) select_item ::= common_expression */ + { 440, -2 }, /* (470) select_item ::= common_expression column_alias */ + { 440, -3 }, /* (471) select_item ::= common_expression AS column_alias */ + { 440, -3 }, /* (472) select_item ::= table_name NK_DOT NK_STAR */ + { 395, 0 }, /* (473) where_clause_opt ::= */ + { 395, -2 }, /* (474) where_clause_opt ::= WHERE search_condition */ + { 433, 0 }, /* (475) partition_by_clause_opt ::= */ + { 433, -3 }, /* (476) partition_by_clause_opt ::= PARTITION BY partition_list */ + { 441, -1 }, /* (477) partition_list ::= partition_item */ + { 441, -3 }, /* (478) partition_list ::= partition_list NK_COMMA partition_item */ + { 442, -1 }, /* (479) partition_item ::= expr_or_subquery */ + { 442, -2 }, /* (480) partition_item ::= expr_or_subquery column_alias */ + { 442, -3 }, /* (481) partition_item ::= expr_or_subquery AS column_alias */ + { 437, 0 }, /* (482) twindow_clause_opt ::= */ + { 437, -6 }, /* (483) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 437, -4 }, /* (484) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + { 437, -6 }, /* (485) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 437, -8 }, /* (486) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 381, 0 }, /* (487) sliding_opt ::= */ + { 381, -4 }, /* (488) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 436, 0 }, /* (489) fill_opt ::= */ + { 436, -4 }, /* (490) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 436, -6 }, /* (491) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 443, -1 }, /* (492) fill_mode ::= NONE */ + { 443, -1 }, /* (493) fill_mode ::= PREV */ + { 443, -1 }, /* (494) fill_mode ::= NULL */ + { 443, -1 }, /* (495) fill_mode ::= LINEAR */ + { 443, -1 }, /* (496) fill_mode ::= NEXT */ + { 438, 0 }, /* (497) group_by_clause_opt ::= */ + { 438, -3 }, /* (498) group_by_clause_opt ::= GROUP BY group_by_list */ + { 444, -1 }, /* (499) group_by_list ::= expr_or_subquery */ + { 444, -3 }, /* (500) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + { 439, 0 }, /* (501) having_clause_opt ::= */ + { 439, -2 }, /* (502) having_clause_opt ::= HAVING search_condition */ + { 434, 0 }, /* (503) range_opt ::= */ + { 434, -6 }, /* (504) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + { 435, 0 }, /* (505) every_opt ::= */ + { 435, -4 }, /* (506) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 445, -4 }, /* (507) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 446, -1 }, /* (508) query_simple ::= query_specification */ + { 446, -1 }, /* (509) query_simple ::= union_query_expression */ + { 450, -4 }, /* (510) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + { 450, -3 }, /* (511) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + { 451, -1 }, /* (512) query_simple_or_subquery ::= query_simple */ + { 451, -1 }, /* (513) query_simple_or_subquery ::= subquery */ + { 385, -1 }, /* (514) query_or_subquery ::= query_expression */ + { 385, -1 }, /* (515) query_or_subquery ::= subquery */ + { 447, 0 }, /* (516) order_by_clause_opt ::= */ + { 447, -3 }, /* (517) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 448, 0 }, /* (518) slimit_clause_opt ::= */ + { 448, -2 }, /* (519) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 448, -4 }, /* (520) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 448, -4 }, /* (521) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 449, 0 }, /* (522) limit_clause_opt ::= */ + { 449, -2 }, /* (523) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 449, -4 }, /* (524) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 449, -4 }, /* (525) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 426, -3 }, /* (526) subquery ::= NK_LP query_expression NK_RP */ + { 426, -3 }, /* (527) subquery ::= NK_LP subquery NK_RP */ + { 429, -1 }, /* (528) search_condition ::= common_expression */ + { 452, -1 }, /* (529) sort_specification_list ::= sort_specification */ + { 452, -3 }, /* (530) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 453, -3 }, /* (531) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + { 454, 0 }, /* (532) ordering_specification_opt ::= */ + { 454, -1 }, /* (533) ordering_specification_opt ::= ASC */ + { 454, -1 }, /* (534) ordering_specification_opt ::= DESC */ + { 455, 0 }, /* (535) null_ordering_opt ::= */ + { 455, -2 }, /* (536) null_ordering_opt ::= NULLS FIRST */ + { 455, -2 }, /* (537) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3598,11 +3578,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,320,&yymsp[0].minor); + yy_destructor(yypParser,322,&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,321,&yymsp[0].minor); + yy_destructor(yypParser,323,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3616,20 +3596,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,320,&yymsp[-2].minor); +{ yy_destructor(yypParser,322,&yymsp[-2].minor); { } - yy_destructor(yypParser,322,&yymsp[0].minor); + yy_destructor(yypParser,324,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,323,&yymsp[0].minor); +{ yy_destructor(yypParser,325,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,321,&yymsp[-1].minor); +{ yy_destructor(yypParser,323,&yymsp[-1].minor); { } - yy_destructor(yypParser,323,&yymsp[0].minor); + yy_destructor(yypParser,325,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3643,1488 +3623,1495 @@ 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,322,&yymsp[0].minor); + yy_destructor(yypParser,324,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy593, &yymsp[-1].minor.yy0, yymsp[0].minor.yy687); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy737, &yymsp[-1].minor.yy0, yymsp[0].minor.yy695); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy593, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy737, 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.yy593, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy737, 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.yy593, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy737, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 28: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy593); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy737); } break; case 29: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy687 = 1; } +{ yymsp[1].minor.yy695 = 1; } break; case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy687 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy695 = 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.yy577, &yymsp[-2].minor.yy593, &yymsp[0].minor.yy593); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy93, &yymsp[-2].minor.yy737, &yymsp[0].minor.yy737); } break; case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy577, &yymsp[-2].minor.yy593, &yymsp[0].minor.yy593); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy93, &yymsp[-2].minor.yy737, &yymsp[0].minor.yy737); } break; case 33: /* privileges ::= ALL */ -{ yymsp[0].minor.yy577 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy93 = PRIVILEGE_TYPE_ALL; } break; case 34: /* privileges ::= priv_type_list */ - case 35: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==35); -{ yylhsminor.yy577 = yymsp[0].minor.yy577; } - yymsp[0].minor.yy577 = yylhsminor.yy577; + case 36: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==36); +{ yylhsminor.yy93 = yymsp[0].minor.yy93; } + yymsp[0].minor.yy93 = yylhsminor.yy93; break; - case 36: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy577 = yymsp[-2].minor.yy577 | yymsp[0].minor.yy577; } - yymsp[-2].minor.yy577 = yylhsminor.yy577; + case 35: /* privileges ::= SUBSCRIBE */ +{ yymsp[0].minor.yy93 = PRIVILEGE_TYPE_SUBSCRIBE; } break; - case 37: /* priv_type ::= READ */ -{ yymsp[0].minor.yy577 = PRIVILEGE_TYPE_READ; } + case 37: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ +{ yylhsminor.yy93 = yymsp[-2].minor.yy93 | yymsp[0].minor.yy93; } + yymsp[-2].minor.yy93 = yylhsminor.yy93; break; - case 38: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy577 = PRIVILEGE_TYPE_WRITE; } + case 38: /* priv_type ::= READ */ +{ yymsp[0].minor.yy93 = PRIVILEGE_TYPE_READ; } break; - case 39: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy593 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy593 = yylhsminor.yy593; + case 39: /* priv_type ::= WRITE */ +{ yymsp[0].minor.yy93 = PRIVILEGE_TYPE_WRITE; } break; - case 40: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy593 = yymsp[-2].minor.yy593; } - yymsp[-2].minor.yy593 = yylhsminor.yy593; + case 40: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ +{ yylhsminor.yy737 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy737 = yylhsminor.yy737; break; - case 41: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy593, NULL); } + case 41: /* priv_level ::= db_name NK_DOT NK_STAR */ +{ yylhsminor.yy737 = yymsp[-2].minor.yy737; } + yymsp[-2].minor.yy737 = yylhsminor.yy737; break; - case 42: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy593, &yymsp[0].minor.yy0); } + case 42: /* priv_level ::= topic_name */ + case 455: /* alias_opt ::= table_alias */ yytestcase(yyruleno==455); +{ yylhsminor.yy737 = yymsp[0].minor.yy737; } + yymsp[0].minor.yy737 = yylhsminor.yy737; break; - case 43: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy193); } + case 43: /* cmd ::= CREATE DNODE dnode_endpoint */ +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy737, NULL); } break; - case 44: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy593, yymsp[0].minor.yy193); } + case 44: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy737, &yymsp[0].minor.yy0); } break; - case 45: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + case 45: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy185); } + break; + case 46: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy737, yymsp[0].minor.yy185); } + break; + case 47: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } break; - case 46: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + case 48: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 47: /* cmd ::= ALTER ALL DNODES NK_STRING */ + case 49: /* cmd ::= ALTER ALL DNODES NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[0].minor.yy0, NULL); } break; - case 48: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + case 50: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 49: /* dnode_endpoint ::= NK_STRING */ - case 50: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==50); - case 51: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==51); - case 339: /* db_name ::= NK_ID */ yytestcase(yyruleno==339); - case 340: /* table_name ::= NK_ID */ yytestcase(yyruleno==340); - case 341: /* column_name ::= NK_ID */ yytestcase(yyruleno==341); - case 342: /* function_name ::= NK_ID */ yytestcase(yyruleno==342); - case 343: /* table_alias ::= NK_ID */ yytestcase(yyruleno==343); - case 344: /* column_alias ::= NK_ID */ yytestcase(yyruleno==344); - case 345: /* user_name ::= NK_ID */ yytestcase(yyruleno==345); - case 346: /* topic_name ::= NK_ID */ yytestcase(yyruleno==346); - case 347: /* stream_name ::= NK_ID */ yytestcase(yyruleno==347); - case 348: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==348); - case 387: /* noarg_func ::= NOW */ yytestcase(yyruleno==387); - case 388: /* noarg_func ::= TODAY */ yytestcase(yyruleno==388); - case 389: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==389); - case 390: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==390); - case 391: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==391); - case 392: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==392); - case 393: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==393); - case 394: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==394); - case 395: /* noarg_func ::= USER */ yytestcase(yyruleno==395); - case 396: /* star_func ::= COUNT */ yytestcase(yyruleno==396); - case 397: /* star_func ::= FIRST */ yytestcase(yyruleno==397); - case 398: /* star_func ::= LAST */ yytestcase(yyruleno==398); - case 399: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==399); -{ yylhsminor.yy593 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy593 = yylhsminor.yy593; + 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 342: /* db_name ::= NK_ID */ yytestcase(yyruleno==342); + case 343: /* table_name ::= NK_ID */ yytestcase(yyruleno==343); + case 344: /* column_name ::= NK_ID */ yytestcase(yyruleno==344); + case 345: /* function_name ::= NK_ID */ yytestcase(yyruleno==345); + case 346: /* table_alias ::= NK_ID */ yytestcase(yyruleno==346); + case 347: /* column_alias ::= NK_ID */ yytestcase(yyruleno==347); + case 348: /* user_name ::= NK_ID */ yytestcase(yyruleno==348); + case 349: /* topic_name ::= NK_ID */ yytestcase(yyruleno==349); + case 350: /* stream_name ::= NK_ID */ yytestcase(yyruleno==350); + case 351: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==351); + case 390: /* noarg_func ::= NOW */ yytestcase(yyruleno==390); + case 391: /* noarg_func ::= TODAY */ yytestcase(yyruleno==391); + case 392: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==392); + case 393: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==393); + case 394: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==394); + case 395: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==395); + case 396: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==396); + case 397: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==397); + case 398: /* noarg_func ::= USER */ yytestcase(yyruleno==398); + case 399: /* star_func ::= COUNT */ yytestcase(yyruleno==399); + case 400: /* star_func ::= FIRST */ yytestcase(yyruleno==400); + case 401: /* star_func ::= LAST */ yytestcase(yyruleno==401); + case 402: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==402); +{ yylhsminor.yy737 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy737 = yylhsminor.yy737; break; - case 52: /* force_opt ::= */ - case 71: /* not_exists_opt ::= */ yytestcase(yyruleno==71); - case 73: /* exists_opt ::= */ yytestcase(yyruleno==73); - case 279: /* analyze_opt ::= */ yytestcase(yyruleno==279); - case 286: /* agg_func_opt ::= */ yytestcase(yyruleno==286); - case 460: /* set_quantifier_opt ::= */ yytestcase(yyruleno==460); -{ yymsp[1].minor.yy193 = false; } + case 54: /* force_opt ::= */ + case 73: /* not_exists_opt ::= */ yytestcase(yyruleno==73); + case 75: /* exists_opt ::= */ yytestcase(yyruleno==75); + case 282: /* analyze_opt ::= */ yytestcase(yyruleno==282); + case 289: /* agg_func_opt ::= */ yytestcase(yyruleno==289); + case 463: /* set_quantifier_opt ::= */ yytestcase(yyruleno==463); +{ yymsp[1].minor.yy185 = false; } break; - case 53: /* force_opt ::= FORCE */ - case 280: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==280); - case 287: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==287); - case 461: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==461); -{ yymsp[0].minor.yy193 = true; } + case 55: /* force_opt ::= FORCE */ + case 283: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==283); + case 290: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==290); + case 464: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==464); +{ yymsp[0].minor.yy185 = true; } break; - case 54: /* cmd ::= ALTER LOCAL NK_STRING */ + case 56: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 55: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + case 57: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 56: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + case 58: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_QNODE_STMT, &yymsp[0].minor.yy0); } break; - case 57: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + case 59: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_QNODE_STMT, &yymsp[0].minor.yy0); } break; - case 58: /* cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + case 60: /* cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_BNODE_STMT, &yymsp[0].minor.yy0); } break; - case 59: /* cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + case 61: /* cmd ::= DROP BNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_BNODE_STMT, &yymsp[0].minor.yy0); } break; - case 60: /* cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + case 62: /* cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_SNODE_STMT, &yymsp[0].minor.yy0); } break; - case 61: /* cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + case 63: /* cmd ::= DROP SNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_SNODE_STMT, &yymsp[0].minor.yy0); } break; - case 62: /* cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + case 64: /* cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_MNODE_STMT, &yymsp[0].minor.yy0); } break; - case 63: /* cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + case 65: /* cmd ::= DROP MNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; - case 64: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy193, &yymsp[-1].minor.yy593, yymsp[0].minor.yy164); } + case 66: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy185, &yymsp[-1].minor.yy737, yymsp[0].minor.yy104); } break; - case 65: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy193, &yymsp[0].minor.yy593); } + case 67: /* cmd ::= DROP DATABASE exists_opt db_name */ +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy185, &yymsp[0].minor.yy737); } break; - case 66: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy593); } + case 68: /* cmd ::= USE db_name */ +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy737); } break; - case 67: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy593, yymsp[0].minor.yy164); } + case 69: /* cmd ::= ALTER DATABASE db_name alter_db_options */ +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy737, yymsp[0].minor.yy104); } break; - case 68: /* cmd ::= FLUSH DATABASE db_name */ -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy593); } + case 70: /* cmd ::= FLUSH DATABASE db_name */ +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy737); } break; - case 69: /* cmd ::= TRIM DATABASE db_name speed_opt */ -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy593, yymsp[0].minor.yy512); } + case 71: /* cmd ::= TRIM DATABASE db_name speed_opt */ +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy737, yymsp[0].minor.yy196); } break; - case 70: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy193 = true; } + case 72: /* not_exists_opt ::= IF NOT EXISTS */ +{ yymsp[-2].minor.yy185 = true; } break; - case 72: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy193 = true; } + case 74: /* exists_opt ::= IF EXISTS */ +{ yymsp[-1].minor.yy185 = true; } break; - case 74: /* db_options ::= */ -{ yymsp[1].minor.yy164 = createDefaultDatabaseOptions(pCxt); } + case 76: /* db_options ::= */ +{ yymsp[1].minor.yy104 = createDefaultDatabaseOptions(pCxt); } break; - case 75: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 77: /* db_options ::= db_options BUFFER NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 76: /* db_options ::= db_options CACHEMODEL NK_STRING */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 78: /* db_options ::= db_options CACHEMODEL NK_STRING */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 77: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 79: /* db_options ::= db_options CACHESIZE NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 78: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 80: /* db_options ::= db_options COMP NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 79: /* db_options ::= db_options DURATION NK_INTEGER */ - case 80: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==80); -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 81: /* db_options ::= db_options DURATION NK_INTEGER */ + case 82: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==82); +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 81: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 83: /* db_options ::= db_options MAXROWS NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 82: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 84: /* db_options ::= db_options MINROWS NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 83: /* db_options ::= db_options KEEP integer_list */ - case 84: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==84); -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_KEEP, yymsp[0].minor.yy648); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 85: /* db_options ::= db_options KEEP integer_list */ + case 86: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==86); +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_KEEP, yymsp[0].minor.yy616); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 85: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 87: /* db_options ::= db_options PAGES NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 86: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 88: /* db_options ::= db_options PAGESIZE NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 87: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 89: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 88: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 90: /* db_options ::= db_options PRECISION NK_STRING */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 89: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 91: /* db_options ::= db_options REPLICA NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 90: /* db_options ::= db_options STRICT NK_STRING */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 92: /* db_options ::= db_options STRICT NK_STRING */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 91: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 93: /* db_options ::= db_options VGROUPS NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 92: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 94: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 93: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_RETENTIONS, yymsp[0].minor.yy648); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 95: /* db_options ::= db_options RETENTIONS retention_list */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_RETENTIONS, yymsp[0].minor.yy616); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 94: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 96: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 95: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 97: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 96: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 98: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 97: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 99: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 98: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + case 100: /* 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.yy164 = setDatabaseOption(pCxt, yymsp[-3].minor.yy164, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-3].minor.yy104, DB_OPTION_WAL_RETENTION_PERIOD, &t); } - yymsp[-3].minor.yy164 = yylhsminor.yy164; + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 99: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 101: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 100: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + case 102: /* 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.yy164 = setDatabaseOption(pCxt, yymsp[-3].minor.yy164, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-3].minor.yy104, DB_OPTION_WAL_RETENTION_SIZE, &t); } - yymsp[-3].minor.yy164 = yylhsminor.yy164; - break; - case 101: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; - break; - case 102: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; - break; - case 103: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; - break; - case 104: /* db_options ::= db_options TABLE_PREFIX NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; - break; - case 105: /* db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ -{ yylhsminor.yy164 = setDatabaseOption(pCxt, yymsp[-2].minor.yy164, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; - break; - case 106: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy164 = createAlterDatabaseOptions(pCxt); yylhsminor.yy164 = setAlterDatabaseOption(pCxt, yylhsminor.yy164, &yymsp[0].minor.yy213); } - yymsp[0].minor.yy164 = yylhsminor.yy164; - break; - case 107: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy164 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy164, &yymsp[0].minor.yy213); } - yymsp[-1].minor.yy164 = yylhsminor.yy164; - break; - case 108: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy213.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy213.val = yymsp[0].minor.yy0; } - break; - case 109: /* alter_db_option ::= CACHEMODEL NK_STRING */ -{ yymsp[-1].minor.yy213.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy213.val = yymsp[0].minor.yy0; } - break; - case 110: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -{ yymsp[-1].minor.yy213.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy213.val = yymsp[0].minor.yy0; } - break; - case 111: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy213.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy213.val = yymsp[0].minor.yy0; } - break; - case 112: /* alter_db_option ::= KEEP integer_list */ - case 113: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==113); -{ yymsp[-1].minor.yy213.type = DB_OPTION_KEEP; yymsp[-1].minor.yy213.pList = yymsp[0].minor.yy648; } - break; - case 114: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy213.type = DB_OPTION_PAGES; yymsp[-1].minor.yy213.val = yymsp[0].minor.yy0; } - break; - case 115: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy213.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy213.val = yymsp[0].minor.yy0; } - break; - case 116: /* alter_db_option ::= STRICT NK_STRING */ -{ yymsp[-1].minor.yy213.type = DB_OPTION_STRICT; yymsp[-1].minor.yy213.val = yymsp[0].minor.yy0; } - break; - case 117: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -{ yymsp[-1].minor.yy213.type = DB_OPTION_WAL; yymsp[-1].minor.yy213.val = yymsp[0].minor.yy0; } - break; - case 118: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ -{ yymsp[-1].minor.yy213.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy213.val = yymsp[0].minor.yy0; } - break; - case 119: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy648 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy648 = yylhsminor.yy648; - break; - case 120: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 309: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==309); -{ yylhsminor.yy648 = addNodeToList(pCxt, yymsp[-2].minor.yy648, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy648 = yylhsminor.yy648; - break; - case 121: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy648 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy648 = yylhsminor.yy648; - break; - case 122: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy648 = addNodeToList(pCxt, yymsp[-2].minor.yy648, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy648 = yylhsminor.yy648; - break; - case 123: /* retention_list ::= retention */ - case 145: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==145); - case 148: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==148); - case 155: /* column_def_list ::= column_def */ yytestcase(yyruleno==155); - case 198: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==198); - case 203: /* col_name_list ::= col_name */ yytestcase(yyruleno==203); - case 251: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==251); - case 262: /* func_list ::= func */ yytestcase(yyruleno==262); - case 337: /* literal_list ::= signed_literal */ yytestcase(yyruleno==337); - case 402: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==402); - case 408: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==408); - case 463: /* select_list ::= select_item */ yytestcase(yyruleno==463); - case 474: /* partition_list ::= partition_item */ yytestcase(yyruleno==474); - case 526: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==526); -{ yylhsminor.yy648 = createNodeList(pCxt, yymsp[0].minor.yy164); } - yymsp[0].minor.yy648 = yylhsminor.yy648; - 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); - case 199: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==199); - case 204: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==204); - case 252: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==252); - case 263: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==263); - case 338: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==338); - case 403: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==403); - case 464: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==464); - case 475: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==475); - case 527: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==527); -{ yylhsminor.yy648 = addNodeToList(pCxt, yymsp[-2].minor.yy648, yymsp[0].minor.yy164); } - yymsp[-2].minor.yy648 = yylhsminor.yy648; - break; - case 125: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy164 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; - break; - case 126: /* speed_opt ::= */ - case 288: /* bufsize_opt ::= */ yytestcase(yyruleno==288); -{ yymsp[1].minor.yy512 = 0; } - break; - case 127: /* speed_opt ::= MAX_SPEED NK_INTEGER */ - case 289: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==289); -{ yymsp[-1].minor.yy512 = 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.yy193, yymsp[-5].minor.yy164, yymsp[-3].minor.yy648, yymsp[-1].minor.yy648, yymsp[0].minor.yy164); } - break; - case 129: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy648); } - break; - case 131: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy648); } - break; - case 132: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy193, yymsp[0].minor.yy164); } - break; - case 133: /* cmd ::= ALTER TABLE alter_table_clause */ - case 311: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==311); -{ pCxt->pRootNode = yymsp[0].minor.yy164; } - break; - case 134: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy164); } - break; - case 135: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy164 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy164, yymsp[0].minor.yy164); } - yymsp[-1].minor.yy164 = yylhsminor.yy164; - break; - case 136: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy164 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy164, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy593, yymsp[0].minor.yy720); } - yymsp[-4].minor.yy164 = yylhsminor.yy164; - break; - case 137: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy164 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy164, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy593); } - yymsp[-3].minor.yy164 = yylhsminor.yy164; - break; - case 138: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy164 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy164, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy593, yymsp[0].minor.yy720); } - yymsp[-4].minor.yy164 = yylhsminor.yy164; - break; - case 139: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy164 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy164, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy593, &yymsp[0].minor.yy593); } - yymsp[-4].minor.yy164 = yylhsminor.yy164; - break; - case 140: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy164 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy164, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy593, yymsp[0].minor.yy720); } - yymsp[-4].minor.yy164 = yylhsminor.yy164; - break; - case 141: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy164 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy164, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy593); } - yymsp[-3].minor.yy164 = yylhsminor.yy164; - break; - case 142: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy164 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy164, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy593, yymsp[0].minor.yy720); } - yymsp[-4].minor.yy164 = yylhsminor.yy164; - break; - case 143: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy164 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy164, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy593, &yymsp[0].minor.yy593); } - yymsp[-4].minor.yy164 = yylhsminor.yy164; - break; - case 144: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy164 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy164, &yymsp[-2].minor.yy593, yymsp[0].minor.yy164); } - yymsp[-5].minor.yy164 = yylhsminor.yy164; - 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 409: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==409); -{ yylhsminor.yy648 = addNodeToList(pCxt, yymsp[-1].minor.yy648, yymsp[0].minor.yy164); } - yymsp[-1].minor.yy648 = yylhsminor.yy648; + yymsp[-3].minor.yy104 = yylhsminor.yy104; + break; + case 103: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; + break; + case 104: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; + break; + case 105: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; + break; + case 106: /* db_options ::= db_options TABLE_PREFIX NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; + break; + case 107: /* db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; + break; + case 108: /* alter_db_options ::= alter_db_option */ +{ yylhsminor.yy104 = createAlterDatabaseOptions(pCxt); yylhsminor.yy104 = setAlterDatabaseOption(pCxt, yylhsminor.yy104, &yymsp[0].minor.yy557); } + yymsp[0].minor.yy104 = yylhsminor.yy104; + break; + case 109: /* alter_db_options ::= alter_db_options alter_db_option */ +{ yylhsminor.yy104 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy104, &yymsp[0].minor.yy557); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; + break; + case 110: /* alter_db_option ::= BUFFER NK_INTEGER */ +{ yymsp[-1].minor.yy557.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } + break; + case 111: /* alter_db_option ::= CACHEMODEL NK_STRING */ +{ yymsp[-1].minor.yy557.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } + break; + case 112: /* alter_db_option ::= CACHESIZE NK_INTEGER */ +{ yymsp[-1].minor.yy557.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } + break; + case 113: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ +{ yymsp[-1].minor.yy557.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } + break; + case 114: /* alter_db_option ::= KEEP integer_list */ + case 115: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==115); +{ yymsp[-1].minor.yy557.type = DB_OPTION_KEEP; yymsp[-1].minor.yy557.pList = yymsp[0].minor.yy616; } + break; + case 116: /* alter_db_option ::= PAGES NK_INTEGER */ +{ yymsp[-1].minor.yy557.type = DB_OPTION_PAGES; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } + break; + case 117: /* alter_db_option ::= REPLICA NK_INTEGER */ +{ yymsp[-1].minor.yy557.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } + break; + case 118: /* alter_db_option ::= STRICT NK_STRING */ +{ yymsp[-1].minor.yy557.type = DB_OPTION_STRICT; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } + break; + case 119: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ +{ yymsp[-1].minor.yy557.type = DB_OPTION_WAL; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } + break; + case 120: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ +{ yymsp[-1].minor.yy557.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } + break; + case 121: /* integer_list ::= NK_INTEGER */ +{ yylhsminor.yy616 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy616 = yylhsminor.yy616; + break; + case 122: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ + case 312: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==312); +{ yylhsminor.yy616 = addNodeToList(pCxt, yymsp[-2].minor.yy616, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy616 = yylhsminor.yy616; + break; + case 123: /* variable_list ::= NK_VARIABLE */ +{ yylhsminor.yy616 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy616 = yylhsminor.yy616; + break; + case 124: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ +{ yylhsminor.yy616 = addNodeToList(pCxt, yymsp[-2].minor.yy616, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy616 = yylhsminor.yy616; + break; + case 125: /* retention_list ::= retention */ + case 147: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==147); + case 150: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==150); + case 157: /* column_def_list ::= column_def */ yytestcase(yyruleno==157); + case 200: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==200); + case 205: /* col_name_list ::= col_name */ yytestcase(yyruleno==205); + case 254: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==254); + case 265: /* func_list ::= func */ yytestcase(yyruleno==265); + case 340: /* literal_list ::= signed_literal */ yytestcase(yyruleno==340); + case 405: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==405); + case 411: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==411); + case 466: /* select_list ::= select_item */ yytestcase(yyruleno==466); + case 477: /* partition_list ::= partition_item */ yytestcase(yyruleno==477); + case 529: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==529); +{ yylhsminor.yy616 = createNodeList(pCxt, yymsp[0].minor.yy104); } + yymsp[0].minor.yy616 = yylhsminor.yy616; + break; + case 126: /* retention_list ::= retention_list NK_COMMA retention */ + case 158: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==158); + case 201: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==201); + case 206: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==206); + case 255: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==255); + case 266: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==266); + case 341: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==341); + case 406: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==406); + case 467: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==467); + case 478: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==478); + case 530: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==530); +{ yylhsminor.yy616 = addNodeToList(pCxt, yymsp[-2].minor.yy616, yymsp[0].minor.yy104); } + yymsp[-2].minor.yy616 = yylhsminor.yy616; + break; + case 127: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ +{ yylhsminor.yy104 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; + break; + case 128: /* speed_opt ::= */ + case 291: /* bufsize_opt ::= */ yytestcase(yyruleno==291); +{ yymsp[1].minor.yy196 = 0; } + break; + case 129: /* speed_opt ::= MAX_SPEED NK_INTEGER */ + case 292: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==292); +{ yymsp[-1].minor.yy196 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + break; + case 130: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 132: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==132); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy185, yymsp[-5].minor.yy104, yymsp[-3].minor.yy616, yymsp[-1].minor.yy616, yymsp[0].minor.yy104); } + break; + case 131: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy616); } + break; + case 133: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy616); } + break; + case 134: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy185, yymsp[0].minor.yy104); } + break; + case 135: /* cmd ::= ALTER TABLE alter_table_clause */ + case 314: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==314); +{ pCxt->pRootNode = yymsp[0].minor.yy104; } + break; + case 136: /* cmd ::= ALTER STABLE alter_table_clause */ +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy104); } + break; + case 137: /* alter_table_clause ::= full_table_name alter_table_options */ +{ yylhsminor.yy104 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy104, yymsp[0].minor.yy104); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; + break; + case 138: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ +{ yylhsminor.yy104 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy104, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy737, yymsp[0].minor.yy640); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; + break; + case 139: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ +{ yylhsminor.yy104 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy104, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy737); } + yymsp[-3].minor.yy104 = yylhsminor.yy104; + break; + case 140: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ +{ yylhsminor.yy104 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy104, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy737, yymsp[0].minor.yy640); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; + break; + case 141: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ +{ yylhsminor.yy104 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy104, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy737, &yymsp[0].minor.yy737); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; + break; + case 142: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ +{ yylhsminor.yy104 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy104, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy737, yymsp[0].minor.yy640); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; + break; + case 143: /* alter_table_clause ::= full_table_name DROP TAG column_name */ +{ yylhsminor.yy104 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy104, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy737); } + yymsp[-3].minor.yy104 = yylhsminor.yy104; + break; + case 144: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ +{ yylhsminor.yy104 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy104, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy737, yymsp[0].minor.yy640); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; + break; + case 145: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ +{ yylhsminor.yy104 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy104, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy737, &yymsp[0].minor.yy737); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; + break; + case 146: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ +{ yylhsminor.yy104 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy104, &yymsp[-2].minor.yy737, yymsp[0].minor.yy104); } + yymsp[-5].minor.yy104 = yylhsminor.yy104; + break; + case 148: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 151: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==151); + case 412: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==412); +{ yylhsminor.yy616 = addNodeToList(pCxt, yymsp[-1].minor.yy616, yymsp[0].minor.yy104); } + yymsp[-1].minor.yy616 = yylhsminor.yy616; 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.yy164 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy193, yymsp[-8].minor.yy164, yymsp[-6].minor.yy164, yymsp[-5].minor.yy648, yymsp[-2].minor.yy648, yymsp[0].minor.yy164); } - yymsp[-9].minor.yy164 = yylhsminor.yy164; + case 149: /* 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.yy104 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy185, yymsp[-8].minor.yy104, yymsp[-6].minor.yy104, yymsp[-5].minor.yy616, yymsp[-2].minor.yy616, yymsp[0].minor.yy104); } + yymsp[-9].minor.yy104 = yylhsminor.yy104; break; - case 150: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy164 = createDropTableClause(pCxt, yymsp[-1].minor.yy193, yymsp[0].minor.yy164); } - yymsp[-1].minor.yy164 = yylhsminor.yy164; + case 152: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy104 = createDropTableClause(pCxt, yymsp[-1].minor.yy185, yymsp[0].minor.yy104); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 151: /* specific_cols_opt ::= */ - case 182: /* tags_def_opt ::= */ yytestcase(yyruleno==182); - case 250: /* tag_list_opt ::= */ yytestcase(yyruleno==250); - case 472: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==472); - case 494: /* group_by_clause_opt ::= */ yytestcase(yyruleno==494); - case 513: /* order_by_clause_opt ::= */ yytestcase(yyruleno==513); -{ yymsp[1].minor.yy648 = NULL; } + case 153: /* specific_cols_opt ::= */ + case 184: /* tags_def_opt ::= */ yytestcase(yyruleno==184); + case 253: /* tag_list_opt ::= */ yytestcase(yyruleno==253); + case 475: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==475); + case 497: /* group_by_clause_opt ::= */ yytestcase(yyruleno==497); + case 516: /* order_by_clause_opt ::= */ yytestcase(yyruleno==516); +{ yymsp[1].minor.yy616 = NULL; } break; - case 152: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy648 = yymsp[-1].minor.yy648; } + case 154: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy616 = yymsp[-1].minor.yy616; } break; - case 153: /* full_table_name ::= table_name */ -{ yylhsminor.yy164 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy593, NULL); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 155: /* full_table_name ::= table_name */ +{ yylhsminor.yy104 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy737, NULL); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 154: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy164 = createRealTableNode(pCxt, &yymsp[-2].minor.yy593, &yymsp[0].minor.yy593, NULL); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 156: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy104 = createRealTableNode(pCxt, &yymsp[-2].minor.yy737, &yymsp[0].minor.yy737, NULL); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 157: /* column_def ::= column_name type_name */ -{ yylhsminor.yy164 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy593, yymsp[0].minor.yy720, NULL); } - yymsp[-1].minor.yy164 = yylhsminor.yy164; + case 159: /* column_def ::= column_name type_name */ +{ yylhsminor.yy104 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy737, yymsp[0].minor.yy640, NULL); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 158: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy164 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy593, yymsp[-2].minor.yy720, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy164 = yylhsminor.yy164; + case 160: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy104 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy737, yymsp[-2].minor.yy640, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 159: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy720 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 161: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy640 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 160: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy720 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 162: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy640 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 161: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy720 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 163: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy640 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 162: /* type_name ::= INT */ - case 163: /* type_name ::= INTEGER */ yytestcase(yyruleno==163); -{ yymsp[0].minor.yy720 = createDataType(TSDB_DATA_TYPE_INT); } + case 164: /* type_name ::= INT */ + case 165: /* type_name ::= INTEGER */ yytestcase(yyruleno==165); +{ yymsp[0].minor.yy640 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 164: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy720 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 166: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy640 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 165: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy720 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 167: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy640 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 166: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy720 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 168: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy640 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 167: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy720 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 169: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy640 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 168: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy720 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 170: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy640 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 169: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy720 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 171: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy640 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 170: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy720 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 172: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy640 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 171: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy720 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 173: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy640 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 172: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy720 = createDataType(TSDB_DATA_TYPE_UINT); } + case 174: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy640 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 173: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy720 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 175: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy640 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 174: /* type_name ::= JSON */ -{ yymsp[0].minor.yy720 = createDataType(TSDB_DATA_TYPE_JSON); } + case 176: /* type_name ::= JSON */ +{ yymsp[0].minor.yy640 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 175: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy720 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 177: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy640 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 176: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy720 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 178: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy640 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 177: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy720 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 179: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy640 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 178: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy720 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 180: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy640 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 179: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy720 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 181: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy640 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 180: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy720 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 182: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy640 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 181: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy720 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 183: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy640 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 183: /* tags_def_opt ::= tags_def */ - case 401: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==401); -{ yylhsminor.yy648 = yymsp[0].minor.yy648; } - yymsp[0].minor.yy648 = yylhsminor.yy648; + case 185: /* tags_def_opt ::= tags_def */ + case 404: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==404); +{ yylhsminor.yy616 = yymsp[0].minor.yy616; } + yymsp[0].minor.yy616 = yylhsminor.yy616; break; - case 184: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy648 = yymsp[-1].minor.yy648; } + case 186: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy616 = yymsp[-1].minor.yy616; } break; - case 185: /* table_options ::= */ -{ yymsp[1].minor.yy164 = createDefaultTableOptions(pCxt); } + case 187: /* table_options ::= */ +{ yymsp[1].minor.yy104 = createDefaultTableOptions(pCxt); } break; - case 186: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy164 = setTableOption(pCxt, yymsp[-2].minor.yy164, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 188: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy104 = setTableOption(pCxt, yymsp[-2].minor.yy104, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 187: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy164 = setTableOption(pCxt, yymsp[-2].minor.yy164, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy648); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 189: /* table_options ::= table_options MAX_DELAY duration_list */ +{ yylhsminor.yy104 = setTableOption(pCxt, yymsp[-2].minor.yy104, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy616); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 188: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy164 = setTableOption(pCxt, yymsp[-2].minor.yy164, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy648); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 190: /* table_options ::= table_options WATERMARK duration_list */ +{ yylhsminor.yy104 = setTableOption(pCxt, yymsp[-2].minor.yy104, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy616); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 189: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy164 = setTableOption(pCxt, yymsp[-4].minor.yy164, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy648); } - yymsp[-4].minor.yy164 = yylhsminor.yy164; + case 191: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ +{ yylhsminor.yy104 = setTableOption(pCxt, yymsp[-4].minor.yy104, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy616); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; break; - case 190: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy164 = setTableOption(pCxt, yymsp[-2].minor.yy164, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 192: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy104 = setTableOption(pCxt, yymsp[-2].minor.yy104, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 191: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy164 = setTableOption(pCxt, yymsp[-4].minor.yy164, TABLE_OPTION_SMA, yymsp[-1].minor.yy648); } - yymsp[-4].minor.yy164 = yylhsminor.yy164; + case 193: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy104 = setTableOption(pCxt, yymsp[-4].minor.yy104, TABLE_OPTION_SMA, yymsp[-1].minor.yy616); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; break; - case 192: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy164 = createAlterTableOptions(pCxt); yylhsminor.yy164 = setTableOption(pCxt, yylhsminor.yy164, yymsp[0].minor.yy213.type, &yymsp[0].minor.yy213.val); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 194: /* alter_table_options ::= alter_table_option */ +{ yylhsminor.yy104 = createAlterTableOptions(pCxt); yylhsminor.yy104 = setTableOption(pCxt, yylhsminor.yy104, yymsp[0].minor.yy557.type, &yymsp[0].minor.yy557.val); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 193: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy164 = setTableOption(pCxt, yymsp[-1].minor.yy164, yymsp[0].minor.yy213.type, &yymsp[0].minor.yy213.val); } - yymsp[-1].minor.yy164 = yylhsminor.yy164; + case 195: /* alter_table_options ::= alter_table_options alter_table_option */ +{ yylhsminor.yy104 = setTableOption(pCxt, yymsp[-1].minor.yy104, yymsp[0].minor.yy557.type, &yymsp[0].minor.yy557.val); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 194: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy213.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy213.val = yymsp[0].minor.yy0; } + case 196: /* alter_table_option ::= COMMENT NK_STRING */ +{ yymsp[-1].minor.yy557.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } break; - case 195: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy213.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy213.val = yymsp[0].minor.yy0; } + case 197: /* alter_table_option ::= TTL NK_INTEGER */ +{ yymsp[-1].minor.yy557.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy557.val = yymsp[0].minor.yy0; } break; - case 196: /* duration_list ::= duration_literal */ - case 366: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==366); -{ yylhsminor.yy648 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy164)); } - yymsp[0].minor.yy648 = yylhsminor.yy648; + case 198: /* duration_list ::= duration_literal */ + case 369: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==369); +{ yylhsminor.yy616 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy104)); } + yymsp[0].minor.yy616 = yylhsminor.yy616; break; - case 197: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 367: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==367); -{ yylhsminor.yy648 = addNodeToList(pCxt, yymsp[-2].minor.yy648, releaseRawExprNode(pCxt, yymsp[0].minor.yy164)); } - yymsp[-2].minor.yy648 = yylhsminor.yy648; + case 199: /* duration_list ::= duration_list NK_COMMA duration_literal */ + case 370: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==370); +{ yylhsminor.yy616 = addNodeToList(pCxt, yymsp[-2].minor.yy616, releaseRawExprNode(pCxt, yymsp[0].minor.yy104)); } + yymsp[-2].minor.yy616 = yylhsminor.yy616; break; - case 200: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy164 = createFunctionNode(pCxt, &yymsp[0].minor.yy593, NULL); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 202: /* rollup_func_name ::= function_name */ +{ yylhsminor.yy104 = createFunctionNode(pCxt, &yymsp[0].minor.yy737, NULL); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 201: /* rollup_func_name ::= FIRST */ - case 202: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==202); - case 254: /* tag_item ::= QTAGS */ yytestcase(yyruleno==254); -{ yylhsminor.yy164 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 203: /* rollup_func_name ::= FIRST */ + case 204: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==204); + case 257: /* tag_item ::= QTAGS */ yytestcase(yyruleno==257); +{ yylhsminor.yy104 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 205: /* col_name ::= column_name */ - case 255: /* tag_item ::= column_name */ yytestcase(yyruleno==255); -{ yylhsminor.yy164 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy593); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 207: /* col_name ::= column_name */ + case 258: /* tag_item ::= column_name */ yytestcase(yyruleno==258); +{ yylhsminor.yy104 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy737); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 206: /* cmd ::= SHOW DNODES */ + case 208: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } break; - case 207: /* cmd ::= SHOW USERS */ + case 209: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } break; - case 208: /* cmd ::= SHOW DATABASES */ + case 210: /* cmd ::= SHOW USER PRIVILEGES */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); } + break; + case 211: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } break; - case 209: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy164, yymsp[0].minor.yy164, OP_TYPE_LIKE); } + case 212: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy104, yymsp[0].minor.yy104, OP_TYPE_LIKE); } break; - case 210: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy164, yymsp[0].minor.yy164, OP_TYPE_LIKE); } + case 213: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy104, yymsp[0].minor.yy104, OP_TYPE_LIKE); } break; - case 211: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy164, NULL, OP_TYPE_LIKE); } + case 214: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy104, NULL, OP_TYPE_LIKE); } break; - case 212: /* cmd ::= SHOW MNODES */ + case 215: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } break; - case 213: /* cmd ::= SHOW QNODES */ + case 216: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } break; - case 214: /* cmd ::= SHOW FUNCTIONS */ + case 217: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; - case 215: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy164, yymsp[-1].minor.yy164, OP_TYPE_EQUAL); } + case 218: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy104, yymsp[-1].minor.yy104, OP_TYPE_EQUAL); } break; - case 216: /* cmd ::= SHOW STREAMS */ + case 219: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } break; - case 217: /* cmd ::= SHOW ACCOUNTS */ + case 220: /* cmd ::= SHOW ACCOUNTS */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } break; - case 218: /* cmd ::= SHOW APPS */ + case 221: /* cmd ::= SHOW APPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } break; - case 219: /* cmd ::= SHOW CONNECTIONS */ + case 222: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } break; - case 220: /* cmd ::= SHOW LICENCES */ - case 221: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==221); + case 223: /* cmd ::= SHOW LICENCES */ + case 224: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==224); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } break; - case 222: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy593); } + case 225: /* cmd ::= SHOW CREATE DATABASE db_name */ +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy737); } break; - case 223: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy164); } + case 226: /* cmd ::= SHOW CREATE TABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy104); } break; - case 224: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy164); } + case 227: /* cmd ::= SHOW CREATE STABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy104); } break; - case 225: /* cmd ::= SHOW QUERIES */ + case 228: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } break; - case 226: /* cmd ::= SHOW SCORES */ + case 229: /* cmd ::= SHOW SCORES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } break; - case 227: /* cmd ::= SHOW TOPICS */ + case 230: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } break; - case 228: /* cmd ::= SHOW VARIABLES */ - case 229: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==229); + case 231: /* cmd ::= SHOW VARIABLES */ + case 232: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==232); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } break; - case 230: /* cmd ::= SHOW LOCAL VARIABLES */ + case 233: /* cmd ::= SHOW LOCAL VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } break; - case 231: /* 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.yy164); } + case 234: /* 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.yy104); } break; - case 232: /* cmd ::= SHOW BNODES */ + case 235: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } break; - case 233: /* cmd ::= SHOW SNODES */ + case 236: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } break; - case 234: /* cmd ::= SHOW CLUSTER */ + case 237: /* cmd ::= SHOW CLUSTER */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } break; - case 235: /* cmd ::= SHOW TRANSACTIONS */ + case 238: /* cmd ::= SHOW TRANSACTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; - case 236: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy164); } + case 239: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy104); } break; - case 237: /* cmd ::= SHOW CONSUMERS */ + case 240: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } break; - case 238: /* cmd ::= SHOW SUBSCRIPTIONS */ + case 241: /* cmd ::= SHOW SUBSCRIPTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; - case 239: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy164, yymsp[-1].minor.yy164, OP_TYPE_EQUAL); } + case 242: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy104, yymsp[-1].minor.yy104, OP_TYPE_EQUAL); } break; - case 240: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy164, yymsp[0].minor.yy164, yymsp[-3].minor.yy648); } + case 243: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy104, yymsp[0].minor.yy104, yymsp[-3].minor.yy616); } break; - case 241: /* cmd ::= SHOW VNODES NK_INTEGER */ + case 244: /* cmd ::= SHOW VNODES NK_INTEGER */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } break; - case 242: /* cmd ::= SHOW VNODES NK_STRING */ + case 245: /* cmd ::= SHOW VNODES NK_STRING */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, createValueNode(pCxt, TSDB_DATA_TYPE_VARCHAR, &yymsp[0].minor.yy0)); } break; - case 243: /* db_name_cond_opt ::= */ - case 248: /* from_db_opt ::= */ yytestcase(yyruleno==248); -{ yymsp[1].minor.yy164 = createDefaultDatabaseCondValue(pCxt); } + case 246: /* db_name_cond_opt ::= */ + case 251: /* from_db_opt ::= */ yytestcase(yyruleno==251); +{ yymsp[1].minor.yy104 = createDefaultDatabaseCondValue(pCxt); } break; - case 244: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy164 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy593); } - yymsp[-1].minor.yy164 = yylhsminor.yy164; + case 247: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy104 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy737); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 245: /* like_pattern_opt ::= */ - case 299: /* subtable_opt ::= */ yytestcase(yyruleno==299); - case 411: /* case_when_else_opt ::= */ yytestcase(yyruleno==411); - case 441: /* from_clause_opt ::= */ yytestcase(yyruleno==441); - case 470: /* where_clause_opt ::= */ yytestcase(yyruleno==470); - case 479: /* twindow_clause_opt ::= */ yytestcase(yyruleno==479); - case 484: /* sliding_opt ::= */ yytestcase(yyruleno==484); - case 486: /* fill_opt ::= */ yytestcase(yyruleno==486); - case 498: /* having_clause_opt ::= */ yytestcase(yyruleno==498); - case 500: /* range_opt ::= */ yytestcase(yyruleno==500); - case 502: /* every_opt ::= */ yytestcase(yyruleno==502); - case 515: /* slimit_clause_opt ::= */ yytestcase(yyruleno==515); - case 519: /* limit_clause_opt ::= */ yytestcase(yyruleno==519); -{ yymsp[1].minor.yy164 = NULL; } + case 248: /* like_pattern_opt ::= */ + case 302: /* subtable_opt ::= */ yytestcase(yyruleno==302); + case 414: /* case_when_else_opt ::= */ yytestcase(yyruleno==414); + case 444: /* from_clause_opt ::= */ yytestcase(yyruleno==444); + case 473: /* where_clause_opt ::= */ yytestcase(yyruleno==473); + case 482: /* twindow_clause_opt ::= */ yytestcase(yyruleno==482); + case 487: /* sliding_opt ::= */ yytestcase(yyruleno==487); + case 489: /* fill_opt ::= */ yytestcase(yyruleno==489); + case 501: /* having_clause_opt ::= */ yytestcase(yyruleno==501); + case 503: /* range_opt ::= */ yytestcase(yyruleno==503); + case 505: /* every_opt ::= */ yytestcase(yyruleno==505); + case 518: /* slimit_clause_opt ::= */ yytestcase(yyruleno==518); + case 522: /* limit_clause_opt ::= */ yytestcase(yyruleno==522); +{ yymsp[1].minor.yy104 = NULL; } break; - case 246: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy164 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 249: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 247: /* table_name_cond ::= table_name */ -{ yylhsminor.yy164 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy593); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 250: /* table_name_cond ::= table_name */ +{ yylhsminor.yy104 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy737); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 249: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy164 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy593); } + case 252: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy104 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy737); } break; - case 253: /* tag_item ::= TBNAME */ -{ yylhsminor.yy164 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 256: /* tag_item ::= TBNAME */ +{ yylhsminor.yy104 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 256: /* tag_item ::= column_name column_alias */ -{ yylhsminor.yy164 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy593), &yymsp[0].minor.yy593); } - yymsp[-1].minor.yy164 = yylhsminor.yy164; + case 259: /* tag_item ::= column_name column_alias */ +{ yylhsminor.yy104 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy737), &yymsp[0].minor.yy737); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 257: /* tag_item ::= column_name AS column_alias */ -{ yylhsminor.yy164 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy593), &yymsp[0].minor.yy593); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 260: /* tag_item ::= column_name AS column_alias */ +{ yylhsminor.yy104 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy737), &yymsp[0].minor.yy737); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 258: /* cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy193, yymsp[-3].minor.yy164, yymsp[-1].minor.yy164, NULL, yymsp[0].minor.yy164); } + case 261: /* cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy185, yymsp[-3].minor.yy104, yymsp[-1].minor.yy104, NULL, yymsp[0].minor.yy104); } break; - case 259: /* cmd ::= DROP INDEX exists_opt full_table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy193, yymsp[0].minor.yy164); } + case 262: /* cmd ::= DROP INDEX exists_opt full_table_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy185, yymsp[0].minor.yy104); } break; - case 260: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy164 = createIndexOption(pCxt, yymsp[-7].minor.yy648, releaseRawExprNode(pCxt, yymsp[-3].minor.yy164), NULL, yymsp[-1].minor.yy164, yymsp[0].minor.yy164); } + case 263: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-9].minor.yy104 = createIndexOption(pCxt, yymsp[-7].minor.yy616, releaseRawExprNode(pCxt, yymsp[-3].minor.yy104), NULL, yymsp[-1].minor.yy104, yymsp[0].minor.yy104); } break; - case 261: /* 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.yy164 = createIndexOption(pCxt, yymsp[-9].minor.yy648, releaseRawExprNode(pCxt, yymsp[-5].minor.yy164), releaseRawExprNode(pCxt, yymsp[-3].minor.yy164), yymsp[-1].minor.yy164, yymsp[0].minor.yy164); } + case 264: /* 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.yy104 = createIndexOption(pCxt, yymsp[-9].minor.yy616, releaseRawExprNode(pCxt, yymsp[-5].minor.yy104), releaseRawExprNode(pCxt, yymsp[-3].minor.yy104), yymsp[-1].minor.yy104, yymsp[0].minor.yy104); } break; - case 264: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy164 = createFunctionNode(pCxt, &yymsp[-3].minor.yy593, yymsp[-1].minor.yy648); } - yymsp[-3].minor.yy164 = yylhsminor.yy164; + case 267: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy104 = createFunctionNode(pCxt, &yymsp[-3].minor.yy737, yymsp[-1].minor.yy616); } + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 265: /* sma_stream_opt ::= */ - case 292: /* stream_options ::= */ yytestcase(yyruleno==292); -{ yymsp[1].minor.yy164 = createStreamOptions(pCxt); } + case 268: /* sma_stream_opt ::= */ + case 295: /* stream_options ::= */ yytestcase(yyruleno==295); +{ yymsp[1].minor.yy104 = createStreamOptions(pCxt); } break; - case 266: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ - case 296: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==296); -{ ((SStreamOptions*)yymsp[-2].minor.yy164)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy164); yylhsminor.yy164 = yymsp[-2].minor.yy164; } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 269: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ + case 299: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==299); +{ ((SStreamOptions*)yymsp[-2].minor.yy104)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy104); yylhsminor.yy104 = yymsp[-2].minor.yy104; } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 267: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy164)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy164); yylhsminor.yy164 = yymsp[-2].minor.yy164; } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 270: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy104)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy104); yylhsminor.yy104 = yymsp[-2].minor.yy104; } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 268: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy193, &yymsp[-2].minor.yy593, yymsp[0].minor.yy164); } + case 271: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy185, &yymsp[-2].minor.yy737, yymsp[0].minor.yy104); } break; - case 269: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy193, &yymsp[-3].minor.yy593, &yymsp[0].minor.yy593, false); } + case 272: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy185, &yymsp[-3].minor.yy737, &yymsp[0].minor.yy737, false); } break; - case 270: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy193, &yymsp[-5].minor.yy593, &yymsp[0].minor.yy593, true); } + case 273: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy185, &yymsp[-5].minor.yy737, &yymsp[0].minor.yy737, true); } break; - case 271: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy193, &yymsp[-3].minor.yy593, yymsp[0].minor.yy164, false); } + case 274: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy185, &yymsp[-3].minor.yy737, yymsp[0].minor.yy104, false); } break; - case 272: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy193, &yymsp[-5].minor.yy593, yymsp[0].minor.yy164, true); } + case 275: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy185, &yymsp[-5].minor.yy737, yymsp[0].minor.yy104, true); } break; - case 273: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy193, &yymsp[0].minor.yy593); } + case 276: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy185, &yymsp[0].minor.yy737); } break; - case 274: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy193, &yymsp[-2].minor.yy593, &yymsp[0].minor.yy593); } + case 277: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy185, &yymsp[-2].minor.yy737, &yymsp[0].minor.yy737); } break; - case 275: /* cmd ::= DESC full_table_name */ - case 276: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==276); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy164); } + case 278: /* cmd ::= DESC full_table_name */ + case 279: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==279); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy104); } break; - case 277: /* cmd ::= RESET QUERY CACHE */ + case 280: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 278: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy193, yymsp[-1].minor.yy164, yymsp[0].minor.yy164); } + case 281: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy185, yymsp[-1].minor.yy104, yymsp[0].minor.yy104); } break; - case 281: /* explain_options ::= */ -{ yymsp[1].minor.yy164 = createDefaultExplainOptions(pCxt); } + case 284: /* explain_options ::= */ +{ yymsp[1].minor.yy104 = createDefaultExplainOptions(pCxt); } break; - case 282: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy164 = setExplainVerbose(pCxt, yymsp[-2].minor.yy164, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 285: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy104 = setExplainVerbose(pCxt, yymsp[-2].minor.yy104, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 283: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy164 = setExplainRatio(pCxt, yymsp[-2].minor.yy164, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 286: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy104 = setExplainRatio(pCxt, yymsp[-2].minor.yy104, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 284: /* 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.yy193, yymsp[-8].minor.yy193, &yymsp[-5].minor.yy593, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy720, yymsp[0].minor.yy512); } + case 287: /* 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.yy185, yymsp[-8].minor.yy185, &yymsp[-5].minor.yy737, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy640, yymsp[0].minor.yy196); } break; - case 285: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy193, &yymsp[0].minor.yy593); } + case 288: /* cmd ::= DROP FUNCTION exists_opt function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy185, &yymsp[0].minor.yy737); } break; - case 290: /* 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.yy193, &yymsp[-7].minor.yy593, yymsp[-4].minor.yy164, yymsp[-6].minor.yy164, yymsp[-3].minor.yy648, yymsp[-2].minor.yy164, yymsp[0].minor.yy164); } + case 293: /* 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.yy185, &yymsp[-7].minor.yy737, yymsp[-4].minor.yy104, yymsp[-6].minor.yy104, yymsp[-3].minor.yy616, yymsp[-2].minor.yy104, yymsp[0].minor.yy104); } break; - case 291: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy193, &yymsp[0].minor.yy593); } + case 294: /* cmd ::= DROP STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy185, &yymsp[0].minor.yy737); } break; - case 293: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy164)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy164 = yymsp[-2].minor.yy164; } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 296: /* stream_options ::= stream_options TRIGGER AT_ONCE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy104)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy104 = yymsp[-2].minor.yy104; } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 294: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy164)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy164 = yymsp[-2].minor.yy164; } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 297: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy104)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy104 = yymsp[-2].minor.yy104; } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 295: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-3].minor.yy164)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy164)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy164); yylhsminor.yy164 = yymsp[-3].minor.yy164; } - yymsp[-3].minor.yy164 = yylhsminor.yy164; + case 298: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-3].minor.yy104)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy104)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy104); yylhsminor.yy104 = yymsp[-3].minor.yy104; } + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 297: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -{ ((SStreamOptions*)yymsp[-3].minor.yy164)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy164 = yymsp[-3].minor.yy164; } - yymsp[-3].minor.yy164 = yylhsminor.yy164; + case 300: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ +{ ((SStreamOptions*)yymsp[-3].minor.yy104)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy104 = yymsp[-3].minor.yy104; } + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 298: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ -{ ((SStreamOptions*)yymsp[-2].minor.yy164)->fillHistory = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy164 = yymsp[-2].minor.yy164; } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 301: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ +{ ((SStreamOptions*)yymsp[-2].minor.yy104)->fillHistory = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy104 = yymsp[-2].minor.yy104; } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 300: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 485: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==485); - case 503: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==503); -{ yymsp[-3].minor.yy164 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy164); } + case 303: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 488: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==488); + case 506: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==506); +{ yymsp[-3].minor.yy104 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy104); } break; - case 301: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 304: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 302: /* cmd ::= KILL QUERY NK_STRING */ + case 305: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 303: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 306: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 304: /* cmd ::= BALANCE VGROUP */ + case 307: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 305: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 308: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 306: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy648); } + case 309: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy616); } break; - case 307: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 310: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 308: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy648 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 311: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy616 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 310: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy164, yymsp[0].minor.yy164); } + case 313: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy104, yymsp[0].minor.yy104); } break; - case 312: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy164, yymsp[-2].minor.yy648, yymsp[0].minor.yy164); } + case 315: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy104, yymsp[-2].minor.yy616, yymsp[0].minor.yy104); } break; - case 313: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ -{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy164, NULL, yymsp[0].minor.yy164); } + case 316: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ +{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy104, NULL, yymsp[0].minor.yy104); } break; - case 314: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy164 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 317: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 315: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy164 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 318: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 316: /* literal ::= NK_STRING */ -{ yylhsminor.yy164 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 319: /* literal ::= NK_STRING */ +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 317: /* literal ::= NK_BOOL */ -{ yylhsminor.yy164 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 320: /* literal ::= NK_BOOL */ +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 318: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy164 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy164 = yylhsminor.yy164; + case 321: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 319: /* literal ::= duration_literal */ - case 329: /* signed_literal ::= signed */ yytestcase(yyruleno==329); - case 349: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==349); - case 350: /* expression ::= literal */ yytestcase(yyruleno==350); - case 351: /* expression ::= pseudo_column */ yytestcase(yyruleno==351); - case 352: /* expression ::= column_reference */ yytestcase(yyruleno==352); - case 353: /* expression ::= function_expression */ yytestcase(yyruleno==353); - case 354: /* expression ::= case_when_expression */ yytestcase(yyruleno==354); - case 384: /* function_expression ::= literal_func */ yytestcase(yyruleno==384); - case 433: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==433); - case 437: /* boolean_primary ::= predicate */ yytestcase(yyruleno==437); - case 439: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==439); - case 440: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==440); - case 443: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==443); - case 445: /* table_reference ::= table_primary */ yytestcase(yyruleno==445); - case 446: /* table_reference ::= joined_table */ yytestcase(yyruleno==446); - case 450: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==450); - case 505: /* query_simple ::= query_specification */ yytestcase(yyruleno==505); - case 506: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==506); - case 509: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==509); - case 511: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==511); -{ yylhsminor.yy164 = yymsp[0].minor.yy164; } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 322: /* literal ::= duration_literal */ + case 332: /* signed_literal ::= signed */ yytestcase(yyruleno==332); + case 352: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==352); + case 353: /* expression ::= literal */ yytestcase(yyruleno==353); + case 354: /* expression ::= pseudo_column */ yytestcase(yyruleno==354); + case 355: /* expression ::= column_reference */ yytestcase(yyruleno==355); + case 356: /* expression ::= function_expression */ yytestcase(yyruleno==356); + case 357: /* expression ::= case_when_expression */ yytestcase(yyruleno==357); + case 387: /* function_expression ::= literal_func */ yytestcase(yyruleno==387); + case 436: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==436); + case 440: /* boolean_primary ::= predicate */ yytestcase(yyruleno==440); + case 442: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==442); + case 443: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==443); + case 446: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==446); + case 448: /* table_reference ::= table_primary */ yytestcase(yyruleno==448); + case 449: /* table_reference ::= joined_table */ yytestcase(yyruleno==449); + case 453: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==453); + case 508: /* query_simple ::= query_specification */ yytestcase(yyruleno==508); + case 509: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==509); + case 512: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==512); + case 514: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==514); +{ yylhsminor.yy104 = yymsp[0].minor.yy104; } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 320: /* literal ::= NULL */ -{ yylhsminor.yy164 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 323: /* literal ::= NULL */ +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 321: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy164 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 324: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 322: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy164 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 325: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 323: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy164 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 326: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 324: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy164 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + case 327: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } break; - case 325: /* signed ::= NK_MINUS NK_INTEGER */ + case 328: /* 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.yy164 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy164 = yylhsminor.yy164; + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 326: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy164 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 329: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 327: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy164 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 330: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 328: /* signed ::= NK_MINUS NK_FLOAT */ + case 331: /* 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.yy164 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy164 = yylhsminor.yy164; + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 330: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy164 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 333: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 331: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy164 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 334: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 332: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy164 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 335: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 333: /* signed_literal ::= duration_literal */ - case 335: /* signed_literal ::= literal_func */ yytestcase(yyruleno==335); - case 404: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==404); - case 466: /* select_item ::= common_expression */ yytestcase(yyruleno==466); - case 476: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==476); - case 510: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==510); - case 512: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==512); - case 525: /* search_condition ::= common_expression */ yytestcase(yyruleno==525); -{ yylhsminor.yy164 = releaseRawExprNode(pCxt, yymsp[0].minor.yy164); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 336: /* signed_literal ::= duration_literal */ + case 338: /* signed_literal ::= literal_func */ yytestcase(yyruleno==338); + case 407: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==407); + case 469: /* select_item ::= common_expression */ yytestcase(yyruleno==469); + case 479: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==479); + case 513: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==513); + case 515: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==515); + case 528: /* search_condition ::= common_expression */ yytestcase(yyruleno==528); +{ yylhsminor.yy104 = releaseRawExprNode(pCxt, yymsp[0].minor.yy104); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 334: /* signed_literal ::= NULL */ -{ yylhsminor.yy164 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 337: /* signed_literal ::= NULL */ +{ yylhsminor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 336: /* signed_literal ::= NK_QUESTION */ -{ yylhsminor.yy164 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 339: /* signed_literal ::= NK_QUESTION */ +{ yylhsminor.yy104 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 355: /* expression ::= NK_LP expression NK_RP */ - case 438: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==438); - case 524: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==524); -{ yylhsminor.yy164 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy164)); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 358: /* expression ::= NK_LP expression NK_RP */ + case 441: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==441); + case 527: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==527); +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy104)); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 356: /* expression ::= NK_PLUS expr_or_subquery */ + case 359: /* expression ::= NK_PLUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy164)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy104)); } - yymsp[-1].minor.yy164 = yylhsminor.yy164; + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 357: /* expression ::= NK_MINUS expr_or_subquery */ + case 360: /* expression ::= NK_MINUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy164), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy104), NULL)); } - yymsp[-1].minor.yy164 = yylhsminor.yy164; + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 358: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + case 361: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy164); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), releaseRawExprNode(pCxt, yymsp[0].minor.yy164))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 359: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + case 362: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy164); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), releaseRawExprNode(pCxt, yymsp[0].minor.yy164))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 360: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + case 363: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy164); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), releaseRawExprNode(pCxt, yymsp[0].minor.yy164))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 361: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + case 364: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy164); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), releaseRawExprNode(pCxt, yymsp[0].minor.yy164))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 362: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ + case 365: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy164); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), releaseRawExprNode(pCxt, yymsp[0].minor.yy164))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 363: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 366: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 364: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + case 367: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy164); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), releaseRawExprNode(pCxt, yymsp[0].minor.yy164))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 365: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + case 368: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy164); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), releaseRawExprNode(pCxt, yymsp[0].minor.yy164))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 368: /* column_reference ::= column_name */ -{ yylhsminor.yy164 = createRawExprNode(pCxt, &yymsp[0].minor.yy593, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy593)); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 371: /* column_reference ::= column_name */ +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy737, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy737)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 369: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy164 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy593, &yymsp[0].minor.yy593, createColumnNode(pCxt, &yymsp[-2].minor.yy593, &yymsp[0].minor.yy593)); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 372: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy737, &yymsp[0].minor.yy737, createColumnNode(pCxt, &yymsp[-2].minor.yy737, &yymsp[0].minor.yy737)); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 370: /* pseudo_column ::= ROWTS */ - case 371: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==371); - case 373: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==373); - case 374: /* pseudo_column ::= QEND */ yytestcase(yyruleno==374); - case 375: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==375); - case 376: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==376); - case 377: /* pseudo_column ::= WEND */ yytestcase(yyruleno==377); - case 378: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==378); - case 379: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==379); - case 380: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==380); - case 386: /* literal_func ::= NOW */ yytestcase(yyruleno==386); -{ yylhsminor.yy164 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 373: /* pseudo_column ::= ROWTS */ + case 374: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==374); + case 376: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==376); + case 377: /* pseudo_column ::= QEND */ yytestcase(yyruleno==377); + case 378: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==378); + case 379: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==379); + case 380: /* pseudo_column ::= WEND */ yytestcase(yyruleno==380); + case 381: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==381); + case 382: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==382); + case 383: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==383); + case 389: /* literal_func ::= NOW */ yytestcase(yyruleno==389); +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 372: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy164 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy593, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy593)))); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 375: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy737, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy737)))); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 381: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 382: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==382); -{ yylhsminor.yy164 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy593, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy593, yymsp[-1].minor.yy648)); } - yymsp[-3].minor.yy164 = yylhsminor.yy164; + case 384: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 385: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==385); +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy737, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy737, yymsp[-1].minor.yy616)); } + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 383: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ -{ yylhsminor.yy164 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy164), yymsp[-1].minor.yy720)); } - yymsp[-5].minor.yy164 = yylhsminor.yy164; + case 386: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy104), yymsp[-1].minor.yy640)); } + yymsp[-5].minor.yy104 = yylhsminor.yy104; break; - case 385: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy164 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy593, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy593, NULL)); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 388: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy737, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy737, NULL)); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 400: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy648 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy648 = yylhsminor.yy648; + case 403: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy616 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy616 = yylhsminor.yy616; break; - case 405: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 469: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==469); -{ yylhsminor.yy164 = createColumnNode(pCxt, &yymsp[-2].minor.yy593, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 408: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 472: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==472); +{ yylhsminor.yy104 = createColumnNode(pCxt, &yymsp[-2].minor.yy737, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 406: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -{ yylhsminor.yy164 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy648, yymsp[-1].minor.yy164)); } - yymsp[-3].minor.yy164 = yylhsminor.yy164; + case 409: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy616, yymsp[-1].minor.yy104)); } + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 407: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -{ yylhsminor.yy164 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy164), yymsp[-2].minor.yy648, yymsp[-1].minor.yy164)); } - yymsp[-4].minor.yy164 = yylhsminor.yy164; + case 410: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy104), yymsp[-2].minor.yy616, yymsp[-1].minor.yy104)); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; break; - case 410: /* when_then_expr ::= WHEN common_expression THEN common_expression */ -{ yymsp[-3].minor.yy164 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), releaseRawExprNode(pCxt, yymsp[0].minor.yy164)); } + case 413: /* when_then_expr ::= WHEN common_expression THEN common_expression */ +{ yymsp[-3].minor.yy104 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104)); } break; - case 412: /* case_when_else_opt ::= ELSE common_expression */ -{ yymsp[-1].minor.yy164 = releaseRawExprNode(pCxt, yymsp[0].minor.yy164); } + case 415: /* case_when_else_opt ::= ELSE common_expression */ +{ yymsp[-1].minor.yy104 = releaseRawExprNode(pCxt, yymsp[0].minor.yy104); } break; - case 413: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 418: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==418); + case 416: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 421: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==421); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy164); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy656, releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), releaseRawExprNode(pCxt, yymsp[0].minor.yy164))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy668, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 414: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + case 417: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy164); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy164), releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), releaseRawExprNode(pCxt, yymsp[0].minor.yy164))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy104), releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-4].minor.yy164 = yylhsminor.yy164; + yymsp[-4].minor.yy104 = yylhsminor.yy104; break; - case 415: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + case 418: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy164); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy164), releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), releaseRawExprNode(pCxt, yymsp[0].minor.yy164))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy104), releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-5].minor.yy164 = yylhsminor.yy164; + yymsp[-5].minor.yy104 = yylhsminor.yy104; break; - case 416: /* predicate ::= expr_or_subquery IS NULL */ + case 419: /* predicate ::= expr_or_subquery IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), NULL)); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 417: /* predicate ::= expr_or_subquery IS NOT NULL */ + case 420: /* predicate ::= expr_or_subquery IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy164), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy104), NULL)); } - yymsp[-3].minor.yy164 = yylhsminor.yy164; + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 419: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy656 = OP_TYPE_LOWER_THAN; } + case 422: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy668 = OP_TYPE_LOWER_THAN; } break; - case 420: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy656 = OP_TYPE_GREATER_THAN; } + case 423: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy668 = OP_TYPE_GREATER_THAN; } break; - case 421: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy656 = OP_TYPE_LOWER_EQUAL; } + case 424: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy668 = OP_TYPE_LOWER_EQUAL; } break; - case 422: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy656 = OP_TYPE_GREATER_EQUAL; } + case 425: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy668 = OP_TYPE_GREATER_EQUAL; } break; - case 423: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy656 = OP_TYPE_NOT_EQUAL; } + case 426: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy668 = OP_TYPE_NOT_EQUAL; } break; - case 424: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy656 = OP_TYPE_EQUAL; } + case 427: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy668 = OP_TYPE_EQUAL; } break; - case 425: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy656 = OP_TYPE_LIKE; } + case 428: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy668 = OP_TYPE_LIKE; } break; - case 426: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy656 = OP_TYPE_NOT_LIKE; } + case 429: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy668 = OP_TYPE_NOT_LIKE; } break; - case 427: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy656 = OP_TYPE_MATCH; } + case 430: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy668 = OP_TYPE_MATCH; } break; - case 428: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy656 = OP_TYPE_NMATCH; } + case 431: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy668 = OP_TYPE_NMATCH; } break; - case 429: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy656 = OP_TYPE_JSON_CONTAINS; } + case 432: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy668 = OP_TYPE_JSON_CONTAINS; } break; - case 430: /* in_op ::= IN */ -{ yymsp[0].minor.yy656 = OP_TYPE_IN; } + case 433: /* in_op ::= IN */ +{ yymsp[0].minor.yy668 = OP_TYPE_IN; } break; - case 431: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy656 = OP_TYPE_NOT_IN; } + case 434: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy668 = OP_TYPE_NOT_IN; } break; - case 432: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -{ yylhsminor.yy164 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy648)); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 435: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy616)); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 434: /* boolean_value_expression ::= NOT boolean_primary */ + case 437: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy164), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy104), NULL)); } - yymsp[-1].minor.yy164 = yylhsminor.yy164; + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 435: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 438: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy164); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), releaseRawExprNode(pCxt, yymsp[0].minor.yy164))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 436: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 439: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy164); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy164); - yylhsminor.yy164 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), releaseRawExprNode(pCxt, yymsp[0].minor.yy164))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 442: /* from_clause_opt ::= FROM table_reference_list */ - case 471: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==471); - case 499: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==499); -{ yymsp[-1].minor.yy164 = yymsp[0].minor.yy164; } + case 445: /* from_clause_opt ::= FROM table_reference_list */ + case 474: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==474); + case 502: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==502); +{ yymsp[-1].minor.yy104 = yymsp[0].minor.yy104; } break; - case 444: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy164 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy164, yymsp[0].minor.yy164, NULL); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 447: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy104 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy104, yymsp[0].minor.yy104, NULL); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 447: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy164 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy593, &yymsp[0].minor.yy593); } - yymsp[-1].minor.yy164 = yylhsminor.yy164; + case 450: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy104 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy737, &yymsp[0].minor.yy737); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 448: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy164 = createRealTableNode(pCxt, &yymsp[-3].minor.yy593, &yymsp[-1].minor.yy593, &yymsp[0].minor.yy593); } - yymsp[-3].minor.yy164 = yylhsminor.yy164; + case 451: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy104 = createRealTableNode(pCxt, &yymsp[-3].minor.yy737, &yymsp[-1].minor.yy737, &yymsp[0].minor.yy737); } + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 449: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy164 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy164), &yymsp[0].minor.yy593); } - yymsp[-1].minor.yy164 = yylhsminor.yy164; + case 452: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy104 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy104), &yymsp[0].minor.yy737); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 451: /* alias_opt ::= */ -{ yymsp[1].minor.yy593 = nil_token; } + case 454: /* alias_opt ::= */ +{ yymsp[1].minor.yy737 = nil_token; } break; - case 452: /* alias_opt ::= table_alias */ -{ yylhsminor.yy593 = yymsp[0].minor.yy593; } - yymsp[0].minor.yy593 = yylhsminor.yy593; + case 456: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy737 = yymsp[0].minor.yy737; } break; - case 453: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy593 = yymsp[0].minor.yy593; } + case 457: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 458: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==458); +{ yymsp[-2].minor.yy104 = yymsp[-1].minor.yy104; } break; - case 454: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 455: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==455); -{ yymsp[-2].minor.yy164 = yymsp[-1].minor.yy164; } + case 459: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy104 = createJoinTableNode(pCxt, yymsp[-4].minor.yy228, yymsp[-5].minor.yy104, yymsp[-2].minor.yy104, yymsp[0].minor.yy104); } + yymsp[-5].minor.yy104 = yylhsminor.yy104; break; - case 456: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy164 = createJoinTableNode(pCxt, yymsp[-4].minor.yy868, yymsp[-5].minor.yy164, yymsp[-2].minor.yy164, yymsp[0].minor.yy164); } - yymsp[-5].minor.yy164 = yylhsminor.yy164; + case 460: /* join_type ::= */ +{ yymsp[1].minor.yy228 = JOIN_TYPE_INNER; } break; - case 457: /* join_type ::= */ -{ yymsp[1].minor.yy868 = JOIN_TYPE_INNER; } + case 461: /* join_type ::= INNER */ +{ yymsp[0].minor.yy228 = JOIN_TYPE_INNER; } break; - case 458: /* join_type ::= INNER */ -{ yymsp[0].minor.yy868 = JOIN_TYPE_INNER; } - break; - case 459: /* 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 462: /* 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.yy164 = createSelectStmt(pCxt, yymsp[-10].minor.yy193, yymsp[-9].minor.yy648, yymsp[-8].minor.yy164); - yymsp[-11].minor.yy164 = addWhereClause(pCxt, yymsp[-11].minor.yy164, yymsp[-7].minor.yy164); - yymsp[-11].minor.yy164 = addPartitionByClause(pCxt, yymsp[-11].minor.yy164, yymsp[-6].minor.yy648); - yymsp[-11].minor.yy164 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy164, yymsp[-2].minor.yy164); - yymsp[-11].minor.yy164 = addGroupByClause(pCxt, yymsp[-11].minor.yy164, yymsp[-1].minor.yy648); - yymsp[-11].minor.yy164 = addHavingClause(pCxt, yymsp[-11].minor.yy164, yymsp[0].minor.yy164); - yymsp[-11].minor.yy164 = addRangeClause(pCxt, yymsp[-11].minor.yy164, yymsp[-5].minor.yy164); - yymsp[-11].minor.yy164 = addEveryClause(pCxt, yymsp[-11].minor.yy164, yymsp[-4].minor.yy164); - yymsp[-11].minor.yy164 = addFillClause(pCxt, yymsp[-11].minor.yy164, yymsp[-3].minor.yy164); + yymsp[-11].minor.yy104 = createSelectStmt(pCxt, yymsp[-10].minor.yy185, yymsp[-9].minor.yy616, yymsp[-8].minor.yy104); + yymsp[-11].minor.yy104 = addWhereClause(pCxt, yymsp[-11].minor.yy104, yymsp[-7].minor.yy104); + yymsp[-11].minor.yy104 = addPartitionByClause(pCxt, yymsp[-11].minor.yy104, yymsp[-6].minor.yy616); + yymsp[-11].minor.yy104 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy104, yymsp[-2].minor.yy104); + yymsp[-11].minor.yy104 = addGroupByClause(pCxt, yymsp[-11].minor.yy104, yymsp[-1].minor.yy616); + yymsp[-11].minor.yy104 = addHavingClause(pCxt, yymsp[-11].minor.yy104, yymsp[0].minor.yy104); + yymsp[-11].minor.yy104 = addRangeClause(pCxt, yymsp[-11].minor.yy104, yymsp[-5].minor.yy104); + yymsp[-11].minor.yy104 = addEveryClause(pCxt, yymsp[-11].minor.yy104, yymsp[-4].minor.yy104); + yymsp[-11].minor.yy104 = addFillClause(pCxt, yymsp[-11].minor.yy104, yymsp[-3].minor.yy104); } break; - case 462: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy193 = false; } + case 465: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy185 = false; } break; - case 465: /* select_item ::= NK_STAR */ -{ yylhsminor.yy164 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy164 = yylhsminor.yy164; + case 468: /* select_item ::= NK_STAR */ +{ yylhsminor.yy104 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 467: /* select_item ::= common_expression column_alias */ - case 477: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==477); -{ yylhsminor.yy164 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy164), &yymsp[0].minor.yy593); } - yymsp[-1].minor.yy164 = yylhsminor.yy164; + case 470: /* select_item ::= common_expression column_alias */ + case 480: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==480); +{ yylhsminor.yy104 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy104), &yymsp[0].minor.yy737); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 468: /* select_item ::= common_expression AS column_alias */ - case 478: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==478); -{ yylhsminor.yy164 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), &yymsp[0].minor.yy593); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 471: /* select_item ::= common_expression AS column_alias */ + case 481: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==481); +{ yylhsminor.yy104 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), &yymsp[0].minor.yy737); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 473: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 495: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==495); - case 514: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==514); -{ yymsp[-2].minor.yy648 = yymsp[0].minor.yy648; } + case 476: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 498: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==498); + case 517: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==517); +{ yymsp[-2].minor.yy616 = yymsp[0].minor.yy616; } break; - case 480: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy164 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy164), releaseRawExprNode(pCxt, yymsp[-1].minor.yy164)); } + case 483: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy104 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy104), releaseRawExprNode(pCxt, yymsp[-1].minor.yy104)); } break; - case 481: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy164 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy164)); } + case 484: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ +{ yymsp[-3].minor.yy104 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy104)); } break; - case 482: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy164 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy164), NULL, yymsp[-1].minor.yy164, yymsp[0].minor.yy164); } + case 485: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy104 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy104), NULL, yymsp[-1].minor.yy104, yymsp[0].minor.yy104); } break; - case 483: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy164 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy164), releaseRawExprNode(pCxt, yymsp[-3].minor.yy164), yymsp[-1].minor.yy164, yymsp[0].minor.yy164); } + case 486: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy104 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy104), releaseRawExprNode(pCxt, yymsp[-3].minor.yy104), yymsp[-1].minor.yy104, yymsp[0].minor.yy104); } break; - case 487: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy164 = createFillNode(pCxt, yymsp[-1].minor.yy638, NULL); } + case 490: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy104 = createFillNode(pCxt, yymsp[-1].minor.yy246, NULL); } break; - case 488: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy164 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy648)); } + case 491: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy104 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy616)); } break; - case 489: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy638 = FILL_MODE_NONE; } + case 492: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy246 = FILL_MODE_NONE; } break; - case 490: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy638 = FILL_MODE_PREV; } + case 493: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy246 = FILL_MODE_PREV; } break; - case 491: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy638 = FILL_MODE_NULL; } + case 494: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy246 = FILL_MODE_NULL; } break; - case 492: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy638 = FILL_MODE_LINEAR; } + case 495: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy246 = FILL_MODE_LINEAR; } break; - case 493: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy638 = FILL_MODE_NEXT; } + case 496: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy246 = FILL_MODE_NEXT; } break; - case 496: /* group_by_list ::= expr_or_subquery */ -{ yylhsminor.yy648 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy164))); } - yymsp[0].minor.yy648 = yylhsminor.yy648; + case 499: /* group_by_list ::= expr_or_subquery */ +{ yylhsminor.yy616 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } + yymsp[0].minor.yy616 = yylhsminor.yy616; break; - case 497: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -{ yylhsminor.yy648 = addNodeToList(pCxt, yymsp[-2].minor.yy648, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy164))); } - yymsp[-2].minor.yy648 = yylhsminor.yy648; + case 500: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ +{ yylhsminor.yy616 = addNodeToList(pCxt, yymsp[-2].minor.yy616, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } + yymsp[-2].minor.yy616 = yylhsminor.yy616; break; - case 501: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -{ yymsp[-5].minor.yy164 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy164), releaseRawExprNode(pCxt, yymsp[-1].minor.yy164)); } + case 504: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +{ yymsp[-5].minor.yy104 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy104), releaseRawExprNode(pCxt, yymsp[-1].minor.yy104)); } break; - case 504: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 507: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy164 = addOrderByClause(pCxt, yymsp[-3].minor.yy164, yymsp[-2].minor.yy648); - yylhsminor.yy164 = addSlimitClause(pCxt, yylhsminor.yy164, yymsp[-1].minor.yy164); - yylhsminor.yy164 = addLimitClause(pCxt, yylhsminor.yy164, yymsp[0].minor.yy164); + yylhsminor.yy104 = addOrderByClause(pCxt, yymsp[-3].minor.yy104, yymsp[-2].minor.yy616); + yylhsminor.yy104 = addSlimitClause(pCxt, yylhsminor.yy104, yymsp[-1].minor.yy104); + yylhsminor.yy104 = addLimitClause(pCxt, yylhsminor.yy104, yymsp[0].minor.yy104); } - yymsp[-3].minor.yy164 = yylhsminor.yy164; + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 507: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -{ yylhsminor.yy164 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy164, yymsp[0].minor.yy164); } - yymsp[-3].minor.yy164 = yylhsminor.yy164; + case 510: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +{ yylhsminor.yy104 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy104, yymsp[0].minor.yy104); } + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 508: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -{ yylhsminor.yy164 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy164, yymsp[0].minor.yy164); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 511: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +{ yylhsminor.yy104 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy104, yymsp[0].minor.yy104); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 516: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 520: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==520); -{ yymsp[-1].minor.yy164 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 519: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 523: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==523); +{ yymsp[-1].minor.yy104 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 517: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 521: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==521); -{ yymsp[-3].minor.yy164 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 520: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 524: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==524); +{ yymsp[-3].minor.yy104 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 518: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 522: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==522); -{ yymsp[-3].minor.yy164 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 521: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 525: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==525); +{ yymsp[-3].minor.yy104 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 523: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy164 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy164); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 526: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy104); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 528: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy164 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy164), yymsp[-1].minor.yy238, yymsp[0].minor.yy153); } - yymsp[-2].minor.yy164 = yylhsminor.yy164; + case 531: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy104 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), yymsp[-1].minor.yy50, yymsp[0].minor.yy793); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 529: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy238 = ORDER_ASC; } + case 532: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy50 = ORDER_ASC; } break; - case 530: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy238 = ORDER_ASC; } + case 533: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy50 = ORDER_ASC; } break; - case 531: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy238 = ORDER_DESC; } + case 534: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy50 = ORDER_DESC; } break; - case 532: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy153 = NULL_ORDER_DEFAULT; } + case 535: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy793 = NULL_ORDER_DEFAULT; } break; - case 533: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy153 = NULL_ORDER_FIRST; } + case 536: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy793 = NULL_ORDER_FIRST; } break; - case 534: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy153 = NULL_ORDER_LAST; } + case 537: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy793 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/mockCatalog.cpp b/source/libs/parser/test/mockCatalog.cpp index 8f051c67a0..cc51beb842 100644 --- a/source/libs/parser/test/mockCatalog.cpp +++ b/source/libs/parser/test/mockCatalog.cpp @@ -65,9 +65,10 @@ void generateInformationSchema(MockCatalogService* mcs) { .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) .addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN) .done(); - mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TABLES, TSDB_SYSTEM_TABLE, 2) - .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TABLES, TSDB_SYSTEM_TABLE, 3) .addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN) + .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) + .addColumn("stable_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN) .done(); mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TABLE_DISTRIBUTED, TSDB_SYSTEM_TABLE, 2) .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) @@ -101,6 +102,10 @@ void generateInformationSchema(MockCatalogService* mcs) { .addColumn("table_name", TSDB_DATA_TYPE_BINARY, TSDB_TABLE_NAME_LEN) .addColumn("db_name", TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN) .done(); + mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_USER_PRIVILEGES, TSDB_SYSTEM_TABLE, 2) + .addColumn("user_name", TSDB_DATA_TYPE_BINARY, TSDB_USER_LEN) + .addColumn("privilege", TSDB_DATA_TYPE_BINARY, 10) + .done(); } void generatePerformanceSchema(MockCatalogService* mcs) { @@ -136,7 +141,7 @@ void generatePerformanceSchema(MockCatalogService* mcs) { void generateTestTables(MockCatalogService* mcs, const std::string& db) { mcs->createTableBuilder(db, "t1", TSDB_NORMAL_TABLE, 6) .setPrecision(TSDB_TIME_PRECISION_MILLI) - .setVgid(1) + .setVgid(2) .addColumn("ts", TSDB_DATA_TYPE_TIMESTAMP) .addColumn("c1", TSDB_DATA_TYPE_INT) .addColumn("c2", TSDB_DATA_TYPE_BINARY, 20) @@ -178,9 +183,9 @@ void generateTestStables(MockCatalogService* mcs, const std::string& db) { .addTag("tag2", TSDB_DATA_TYPE_BINARY, 20) .addTag("tag3", TSDB_DATA_TYPE_TIMESTAMP); builder.done(); - mcs->createSubTable(db, "st1", "st1s1", 1); - mcs->createSubTable(db, "st1", "st1s2", 2); - mcs->createSubTable(db, "st1", "st1s3", 1); + mcs->createSubTable(db, "st1", "st1s1", 2); + mcs->createSubTable(db, "st1", "st1s2", 3); + mcs->createSubTable(db, "st1", "st1s3", 2); } { ITableBuilder& builder = mcs->createTableBuilder(db, "st2", TSDB_SUPER_TABLE, 3, 1) @@ -190,8 +195,8 @@ void generateTestStables(MockCatalogService* mcs, const std::string& db) { .addColumn("c2", TSDB_DATA_TYPE_BINARY, 20) .addTag("jtag", TSDB_DATA_TYPE_JSON); builder.done(); - mcs->createSubTable(db, "st2", "st2s1", 1); - mcs->createSubTable(db, "st2", "st2s2", 2); + mcs->createSubTable(db, "st2", "st2s1", 2); + mcs->createSubTable(db, "st2", "st2s2", 3); } } @@ -248,8 +253,8 @@ int32_t __catalogGetTableDistVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, con return g_mockCatalogService->catalogGetTableDistVgInfo(pTableName, pVgList); } -int32_t __catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* version, int64_t* dbId, - int32_t* tableNum, int64_t* stateTs) { +int32_t __catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* version, int64_t* dbId, int32_t* tableNum, + int64_t* stateTs) { return 0; } diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp index be2e4b90b9..9cc55a7cd5 100644 --- a/source/libs/parser/test/mockCatalogService.cpp +++ b/source/libs/parser/test/mockCatalogService.cpp @@ -20,15 +20,19 @@ #include #include +#include "systable.h" +#include "tdatablock.h" +#include "tmisce.h" #include "tname.h" #include "ttypes.h" -#include "tmisce.h" + +using std::string; std::unique_ptr g_mockCatalogService; class TableBuilder : public ITableBuilder { public: - virtual TableBuilder& addColumn(const std::string& name, int8_t type, int32_t bytes) { + virtual TableBuilder& addColumn(const string& name, int8_t type, int32_t bytes) { assert(colId_ <= schema()->tableInfo.numOfTags + schema()->tableInfo.numOfColumns); SSchema* col = schema()->schema + (colId_ - 1); col->type = type; @@ -142,27 +146,16 @@ class MockCatalogServiceImpl { } int32_t catalogGetDBVgList(const char* pDbFName, SArray** pVgList) const { - std::string dbFName(pDbFName); - DbMetaCache::const_iterator it = meta_.find(dbFName.substr(std::string(pDbFName).find_last_of('.') + 1)); - if (meta_.end() == it) { - return TSDB_CODE_FAILED; + string dbName(string(pDbFName).substr(string(pDbFName).find_last_of('.') + 1)); + if (0 == dbName.compare(TSDB_INFORMATION_SCHEMA_DB) || 0 == dbName.compare(TSDB_PERFORMANCE_SCHEMA_DB)) { + return catalogGetAllDBVgList(pVgList); } - std::set vgSet; - *pVgList = taosArrayInit(it->second.size(), sizeof(SVgroupInfo)); - for (const auto& vgs : it->second) { - for (const auto& vg : vgs.second->vgs) { - if (0 == vgSet.count(vg.vgId)) { - taosArrayPush(*pVgList, &vg); - vgSet.insert(vg.vgId); - } - } - } - return TSDB_CODE_SUCCESS; + return catalogGetDBVgListImpl(dbName, pVgList); } int32_t catalogGetDBCfg(const char* pDbFName, SDbCfgInfo* pDbCfg) const { - std::string dbFName(pDbFName); - DbCfgCache::const_iterator it = dbCfg_.find(dbFName.substr(std::string(pDbFName).find_last_of('.') + 1)); + string dbFName(pDbFName); + DbCfgCache::const_iterator it = dbCfg_.find(dbFName.substr(string(pDbFName).find_last_of('.') + 1)); if (dbCfg_.end() == it) { return TSDB_CODE_FAILED; } @@ -171,7 +164,7 @@ class MockCatalogServiceImpl { return TSDB_CODE_SUCCESS; } - int32_t catalogGetUdfInfo(const std::string& funcName, SFuncInfo* pInfo) const { + int32_t catalogGetUdfInfo(const string& funcName, SFuncInfo* pInfo) const { auto it = udf_.find(funcName); if (udf_.end() == it) { return TSDB_CODE_FAILED; @@ -236,15 +229,15 @@ class MockCatalogServiceImpl { return code; } - TableBuilder& createTableBuilder(const std::string& db, const std::string& tbname, int8_t tableType, - int32_t numOfColumns, int32_t numOfTags) { + TableBuilder& createTableBuilder(const string& db, const string& tbname, int8_t tableType, int32_t numOfColumns, + int32_t numOfTags) { builder_ = TableBuilder::createTableBuilder(tableType, numOfColumns, numOfTags); meta_[db][tbname] = builder_->table(); meta_[db][tbname]->schema->uid = getNextId(); return *(builder_.get()); } - void createSubTable(const std::string& db, const std::string& stbname, const std::string& tbname, int16_t vgid) { + void createSubTable(const string& db, const string& stbname, const string& tbname, int16_t vgid) { std::unique_ptr table; if (TSDB_CODE_SUCCESS != copyTableSchemaMeta(db, stbname, &table)) { throw std::runtime_error("copyTableSchemaMeta failed"); @@ -274,13 +267,13 @@ class MockCatalogServiceImpl { // string field length #define SFL 20 // string field header -#define SH(h) CA(SFL, std::string(h)) +#define SH(h) CA(SFL, string(h)) // string field #define SF(n) CA(SFL, n) // integer field length #define IFL 10 // integer field header -#define IH(i) CA(IFL, std::string(i)) +#define IH(i) CA(IFL, string(i)) // integer field #define IF(i) CA(IFL, std::to_string(i)) // split line @@ -308,7 +301,7 @@ class MockCatalogServiceImpl { int16_t numOfFields = numOfColumns + schema->tableInfo.numOfTags; for (int16_t i = 0; i < numOfFields; ++i) { const SSchema* col = schema->schema + i; - std::cout << SF(std::string(col->name)) << SH(ftToString(i, numOfColumns)) << SH(dtToString(col->type)) + std::cout << SF(string(col->name)) << SH(ftToString(i, numOfColumns)) << SH(dtToString(col->type)) << IF(col->bytes) << std::endl; } std::cout << std::endl; @@ -316,7 +309,7 @@ class MockCatalogServiceImpl { } } - void createFunction(const std::string& func, int8_t funcType, int8_t outputType, int32_t outputLen, int32_t bufSize) { + void createFunction(const string& func, int8_t funcType, int8_t outputType, int32_t outputLen, int32_t bufSize) { std::shared_ptr info(new SFuncInfo); strcpy(info->name, func.c_str()); info->funcType = funcType; @@ -342,19 +335,19 @@ class MockCatalogServiceImpl { info.expr = strdup(pReq->expr); auto it = index_.find(pReq->stb); if (index_.end() == it) { - index_.insert(std::make_pair(std::string(pReq->stb), std::vector{info})); + index_.insert(std::make_pair(string(pReq->stb), std::vector{info})); } else { it->second.push_back(info); } } - void createDnode(int32_t dnodeId, const std::string& host, int16_t port) { + void createDnode(int32_t dnodeId, const string& host, int16_t port) { SEpSet epSet = {0}; addEpIntoEpSet(&epSet, host.c_str(), port); dnode_.insert(std::make_pair(dnodeId, epSet)); } - void createDatabase(const std::string& db, bool rollup, int8_t cacheLast) { + void createDatabase(const string& db, bool rollup, int8_t cacheLast) { SDbCfgInfo cfg = {0}; if (rollup) { cfg.pRetensions = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SRetention)); @@ -364,12 +357,12 @@ class MockCatalogServiceImpl { } private: - typedef std::map> TableMetaCache; - typedef std::map DbMetaCache; - typedef std::map> UdfMetaCache; - typedef std::map> IndexMetaCache; - typedef std::map DnodeCache; - typedef std::map DbCfgCache; + typedef std::map> TableMetaCache; + typedef std::map DbMetaCache; + typedef std::map> UdfMetaCache; + typedef std::map> IndexMetaCache; + typedef std::map DnodeCache; + typedef std::map DbCfgCache; uint64_t getNextId() { return id_++; } @@ -386,15 +379,15 @@ class MockCatalogServiceImpl { return pDst; } - std::string toDbname(const std::string& dbFullName) const { - std::string::size_type n = dbFullName.find("."); - if (n == std::string::npos) { + string toDbname(const string& dbFullName) const { + string::size_type n = dbFullName.find("."); + if (n == string::npos) { return dbFullName; } return dbFullName.substr(n + 1); } - std::string ttToString(int8_t tableType) const { + string ttToString(int8_t tableType) const { switch (tableType) { case TSDB_SUPER_TABLE: return "super table"; @@ -407,7 +400,7 @@ class MockCatalogServiceImpl { } } - std::string pToString(uint8_t precision) const { + string pToString(uint8_t precision) const { switch (precision) { case TSDB_TIME_PRECISION_MILLI: return "millisecond"; @@ -420,19 +413,18 @@ class MockCatalogServiceImpl { } } - std::string dtToString(int8_t type) const { return tDataTypes[type].name; } + string dtToString(int8_t type) const { return tDataTypes[type].name; } - std::string ftToString(int16_t colid, int16_t numOfColumns) const { + string ftToString(int16_t colid, int16_t numOfColumns) const { return (0 == colid ? "column" : (colid < numOfColumns ? "column" : "tag")); } - STableMeta* getTableSchemaMeta(const std::string& db, const std::string& tbname) const { + STableMeta* getTableSchemaMeta(const string& db, const string& tbname) const { std::shared_ptr table = getTableMeta(db, tbname); return table ? table->schema : nullptr; } - int32_t copyTableSchemaMeta(const std::string& db, const std::string& tbname, - std::unique_ptr* dst) const { + int32_t copyTableSchemaMeta(const string& db, const string& tbname, std::unique_ptr* dst) const { STableMeta* src = getTableSchemaMeta(db, tbname); if (nullptr == src) { return TSDB_CODE_TSC_INVALID_TABLE_NAME; @@ -440,13 +432,13 @@ class MockCatalogServiceImpl { int32_t len = sizeof(STableMeta) + sizeof(SSchema) * (src->tableInfo.numOfTags + src->tableInfo.numOfColumns); dst->reset((STableMeta*)taosMemoryCalloc(1, len)); if (!dst) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } memcpy(dst->get(), src, len); return TSDB_CODE_SUCCESS; } - int32_t copyTableVgroup(const std::string& db, const std::string& tbname, SVgroupInfo* vg) const { + int32_t copyTableVgroup(const string& db, const string& tbname, SVgroupInfo* vg) const { std::shared_ptr table = getTableMeta(db, tbname); if (table->vgs.empty()) { return TSDB_CODE_SUCCESS; @@ -455,7 +447,7 @@ class MockCatalogServiceImpl { return TSDB_CODE_SUCCESS; } - int32_t copyTableVgroup(const std::string& db, const std::string& tbname, SArray** vgList) const { + int32_t copyTableVgroup(const string& db, const string& tbname, SArray** vgList) const { std::shared_ptr table = getTableMeta(db, tbname); if (table->vgs.empty()) { return TSDB_CODE_SUCCESS; @@ -467,7 +459,7 @@ class MockCatalogServiceImpl { return TSDB_CODE_SUCCESS; } - std::shared_ptr getTableMeta(const std::string& db, const std::string& tbname) const { + std::shared_ptr getTableMeta(const string& db, const string& tbname) const { DbMetaCache::const_iterator it = meta_.find(db); if (meta_.end() == it) { return std::shared_ptr(); @@ -527,6 +519,40 @@ class MockCatalogServiceImpl { return code; } + int32_t catalogGetDBVgListImpl(const string& dbName, SArray** pVgList) const { + DbMetaCache::const_iterator it = meta_.find(dbName); + if (meta_.end() == it) { + return TSDB_CODE_FAILED; + } + std::set vgSet; + *pVgList = taosArrayInit(it->second.size(), sizeof(SVgroupInfo)); + for (const auto& vgs : it->second) { + for (const auto& vg : vgs.second->vgs) { + if (0 == vgSet.count(vg.vgId)) { + taosArrayPush(*pVgList, &vg); + vgSet.insert(vg.vgId); + } + } + } + return TSDB_CODE_SUCCESS; + } + + int32_t catalogGetAllDBVgList(SArray** pVgList) const { + std::set vgSet; + *pVgList = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SVgroupInfo)); + for (const auto& db : meta_) { + for (const auto& vgs : db.second) { + for (const auto& vg : vgs.second->vgs) { + if (0 == vgSet.count(vg.vgId)) { + taosArrayPush(*pVgList, &vg); + vgSet.insert(vg.vgId); + } + } + } + } + return TSDB_CODE_SUCCESS; + } + int32_t getAllDbCfg(SArray* pDbCfgReq, SArray** pDbCfgData) const { int32_t code = TSDB_CODE_SUCCESS; if (NULL != pDbCfgReq) { @@ -634,30 +660,29 @@ MockCatalogService::MockCatalogService() : impl_(new MockCatalogServiceImpl()) { MockCatalogService::~MockCatalogService() {} -ITableBuilder& MockCatalogService::createTableBuilder(const std::string& db, const std::string& tbname, - int8_t tableType, int32_t numOfColumns, int32_t numOfTags) { +ITableBuilder& MockCatalogService::createTableBuilder(const string& db, const string& tbname, int8_t tableType, + int32_t numOfColumns, int32_t numOfTags) { return impl_->createTableBuilder(db, tbname, tableType, numOfColumns, numOfTags); } -void MockCatalogService::createSubTable(const std::string& db, const std::string& stbname, const std::string& tbname, - int16_t vgid) { +void MockCatalogService::createSubTable(const string& db, const string& stbname, const string& tbname, int16_t vgid) { impl_->createSubTable(db, stbname, tbname, vgid); } void MockCatalogService::showTables() const { impl_->showTables(); } -void MockCatalogService::createFunction(const std::string& func, int8_t funcType, int8_t outputType, int32_t outputLen, +void MockCatalogService::createFunction(const string& func, int8_t funcType, int8_t outputType, int32_t outputLen, int32_t bufSize) { impl_->createFunction(func, funcType, outputType, outputLen, bufSize); } void MockCatalogService::createSmaIndex(const SMCreateSmaReq* pReq) { impl_->createSmaIndex(pReq); } -void MockCatalogService::createDnode(int32_t dnodeId, const std::string& host, int16_t port) { +void MockCatalogService::createDnode(int32_t dnodeId, const string& host, int16_t port) { impl_->createDnode(dnodeId, host, port); } -void MockCatalogService::createDatabase(const std::string& db, bool rollup, int8_t cacheLast) { +void MockCatalogService::createDatabase(const string& db, bool rollup, int8_t cacheLast) { impl_->createDatabase(db, rollup, cacheLast); } @@ -683,7 +708,7 @@ int32_t MockCatalogService::catalogGetDBCfg(const char* pDbFName, SDbCfgInfo* pD return impl_->catalogGetDBCfg(pDbFName, pDbCfg); } -int32_t MockCatalogService::catalogGetUdfInfo(const std::string& funcName, SFuncInfo* pInfo) const { +int32_t MockCatalogService::catalogGetUdfInfo(const string& funcName, SFuncInfo* pInfo) const { return impl_->catalogGetUdfInfo(funcName, pInfo); } diff --git a/source/libs/parser/test/parAlterToBalanceTest.cpp b/source/libs/parser/test/parAlterToBalanceTest.cpp index 0c8b82ddd4..ba1ba9fc83 100644 --- a/source/libs/parser/test/parAlterToBalanceTest.cpp +++ b/source/libs/parser/test/parAlterToBalanceTest.cpp @@ -613,7 +613,7 @@ TEST_F(ParserInitialATest, alterUser) { if (nullptr != pPass) { strcpy(expect.pass, pPass); } - strcpy(expect.dbname, "test"); + strcpy(expect.objname, "test"); }; setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { @@ -627,7 +627,7 @@ TEST_F(ParserInitialATest, alterUser) { ASSERT_EQ(req.enable, expect.enable); ASSERT_EQ(std::string(req.user), std::string(expect.user)); ASSERT_EQ(std::string(req.pass), std::string(expect.pass)); - ASSERT_EQ(std::string(req.dbname), std::string(expect.dbname)); + ASSERT_EQ(std::string(req.objname), std::string(expect.objname)); }); setAlterUserReq("wxy", TSDB_ALTER_USER_PASSWD, "123456"); diff --git a/source/libs/parser/test/parExplainToSyncdbTest.cpp b/source/libs/parser/test/parExplainToSyncdbTest.cpp index 72083c68ca..f88d6d316b 100644 --- a/source/libs/parser/test/parExplainToSyncdbTest.cpp +++ b/source/libs/parser/test/parExplainToSyncdbTest.cpp @@ -34,10 +34,38 @@ TEST_F(ParserExplainToSyncdbTest, explain) { TEST_F(ParserExplainToSyncdbTest, grant) { useDb("root", "test"); + SAlterUserReq expect = {0}; + + auto setAlterUserReq = [&](int8_t alterType, const string& user, const string& obj) { + expect.alterType = alterType; + snprintf(expect.user, sizeof(expect.user), "%s", user.c_str()); + snprintf(expect.objname, sizeof(expect.objname), "%s", obj.c_str()); + }; + + setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { + ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_GRANT_STMT); + ASSERT_EQ(pQuery->pCmdMsg->msgType, TDMT_MND_ALTER_USER); + SAlterUserReq req = {0}; + ASSERT_EQ(tDeserializeSAlterUserReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req), TSDB_CODE_SUCCESS); + ASSERT_EQ(req.alterType, expect.alterType); + ASSERT_EQ(string(req.user), string(expect.user)); + ASSERT_EQ(string(req.objname), string(expect.objname)); + }); + + setAlterUserReq(TSDB_ALTER_USER_ADD_ALL_DB, "wxy", "0.test"); run("GRANT ALL ON test.* TO wxy"); + + setAlterUserReq(TSDB_ALTER_USER_ADD_READ_DB, "wxy", "0.test"); run("GRANT READ ON test.* TO wxy"); + + setAlterUserReq(TSDB_ALTER_USER_ADD_WRITE_DB, "wxy", "0.test"); run("GRANT WRITE ON test.* TO wxy"); + + setAlterUserReq(TSDB_ALTER_USER_ADD_ALL_DB, "wxy", "0.test"); run("GRANT READ, WRITE ON test.* TO wxy"); + + setAlterUserReq(TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC, "wxy", "0.tp1"); + run("GRANT SUBSCRIBE ON tp1 TO wxy"); } TEST_F(ParserExplainToSyncdbTest, insert) { diff --git a/source/libs/parser/test/parShowToUse.cpp b/source/libs/parser/test/parShowToUse.cpp index e2f833cffa..b7bd0e802c 100644 --- a/source/libs/parser/test/parShowToUse.cpp +++ b/source/libs/parser/test/parShowToUse.cpp @@ -213,7 +213,13 @@ TEST_F(ParserShowToUseTest, showTags) { TEST_F(ParserShowToUseTest, showUsers) { useDb("root", "test"); - run("SHOW users"); + run("SHOW USERS"); +} + +TEST_F(ParserShowToUseTest, showUserPrivileges) { + useDb("root", "test"); + + run("SHOW USER PRIVILEGES"); } TEST_F(ParserShowToUseTest, showVariables) { diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index e0a67c32e5..dd5e283a55 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -250,11 +250,12 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols } if (NULL == pScanCols) { - return NULL == pScanPseudoCols - ? SCAN_TYPE_TABLE - : ((FUNCTION_TYPE_BLOCK_DIST_INFO == ((SFunctionNode*)nodesListGetNode(pScanPseudoCols, 0))->funcType) - ? SCAN_TYPE_BLOCK_INFO - : SCAN_TYPE_TABLE); + if (NULL == pScanPseudoCols) { + return SCAN_TYPE_TABLE; + } + return FUNCTION_TYPE_BLOCK_DIST_INFO == ((SFunctionNode*)nodesListGetNode(pScanPseudoCols, 0))->funcType + ? SCAN_TYPE_BLOCK_INFO + : SCAN_TYPE_TABLE; } return SCAN_TYPE_TABLE; @@ -333,6 +334,8 @@ static int32_t makeScanLogicNode(SLogicPlanContext* pCxt, SRealTableNode* pRealT return TSDB_CODE_SUCCESS; } +static bool needScanDefaultCol(EScanType scanType) { return SCAN_TYPE_TABLE_COUNT != scanType; } + static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable, SLogicNode** pLogicNode) { SScanLogicNode* pScan = NULL; @@ -367,7 +370,7 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect pScan->hasNormalCols = true; } - if (TSDB_CODE_SUCCESS == code) { + if (TSDB_CODE_SUCCESS == code && needScanDefaultCol(pScan->scanType)) { code = addDefaultScanCol(pRealTable->pMeta, &pScan->pScanCols); } diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index b8b6e44412..c370e2c84b 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -16,6 +16,7 @@ #include "filter.h" #include "functionMgt.h" #include "planInt.h" +#include "systable.h" #include "tglobal.h" #include "ttime.h" @@ -64,6 +65,7 @@ typedef enum ECondAction { } ECondAction; typedef bool (*FMayBeOptimized)(SLogicNode* pNode); +typedef bool (*FShouldBeOptimized)(SLogicNode* pNode, void* pInfo); static SLogicNode* optFindPossibleNode(SLogicNode* pNode, FMayBeOptimized func) { if (func(pNode)) { @@ -79,6 +81,19 @@ static SLogicNode* optFindPossibleNode(SLogicNode* pNode, FMayBeOptimized func) return NULL; } +static bool optFindEligibleNode(SLogicNode* pNode, FShouldBeOptimized func, void* pInfo) { + if (func(pNode, pInfo)) { + return true; + } + SNode* pChild; + FOREACH(pChild, pNode->pChildren) { + if (optFindEligibleNode((SLogicNode*)pChild, func, pInfo)) { + return true; + } + } + return false; +} + static void optResetParent(SLogicNode* pNode) { SNode* pChild = NULL; FOREACH(pChild, pNode->pChildren) { ((SLogicNode*)pChild)->pParent = pNode; } @@ -2454,6 +2469,243 @@ static int32_t pushDownLimitOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLog return TSDB_CODE_SUCCESS; } +typedef struct STbCntScanOptInfo { + SAggLogicNode* pAgg; + SScanLogicNode* pScan; + SName table; +} STbCntScanOptInfo; + +static bool tbCntScanOptIsEligibleGroupKeys(SNodeList* pGroupKeys) { + if (NULL == pGroupKeys) { + return true; + } + + SNode* pGroupKey = NULL; + FOREACH(pGroupKey, pGroupKeys) { + SNode* pKey = nodesListGetNode(((SGroupingSetNode*)pGroupKey)->pParameterList, 0); + if (QUERY_NODE_COLUMN != nodeType(pKey)) { + return false; + } + SColumnNode* pCol = (SColumnNode*)pKey; + if (0 != strcmp(pCol->colName, "db_name") && 0 != strcmp(pCol->colName, "stable_name")) { + return false; + } + } + + return true; +} + +static bool tbCntScanOptNotNullableExpr(SNode* pNode) { + if (QUERY_NODE_COLUMN != nodeType(pNode)) { + return false; + } + const char* pColName = ((SColumnNode*)pNode)->colName; + return 0 == strcmp(pColName, "*") || 0 == strcmp(pColName, "db_name") || 0 == strcmp(pColName, "stable_name") || + 0 == strcmp(pColName, "table_name"); +} + +static bool tbCntScanOptIsEligibleAggFuncs(SNodeList* pAggFuncs) { + SNode* pNode = NULL; + FOREACH(pNode, pAggFuncs) { + SFunctionNode* pFunc = (SFunctionNode*)nodesListGetNode(pAggFuncs, 0); + if (FUNCTION_TYPE_COUNT != pFunc->funcType || + !tbCntScanOptNotNullableExpr(nodesListGetNode(pFunc->pParameterList, 0))) { + return false; + } + } + return true; +} + +static bool tbCntScanOptIsEligibleAgg(SAggLogicNode* pAgg) { + return tbCntScanOptIsEligibleGroupKeys(pAgg->pGroupKeys) && tbCntScanOptIsEligibleAggFuncs(pAgg->pAggFuncs); +} + +static bool tbCntScanOptGetColValFromCond(SOperatorNode* pOper, SColumnNode** pCol, SValueNode** pVal) { + if (OP_TYPE_EQUAL != pOper->opType) { + return false; + } + + *pCol = NULL; + *pVal = NULL; + if (QUERY_NODE_COLUMN == nodeType(pOper->pLeft)) { + *pCol = (SColumnNode*)pOper->pLeft; + } else if (QUERY_NODE_VALUE == nodeType(pOper->pLeft)) { + *pVal = (SValueNode*)pOper->pLeft; + } + if (QUERY_NODE_COLUMN == nodeType(pOper->pRight)) { + *pCol = (SColumnNode*)pOper->pRight; + } else if (QUERY_NODE_VALUE == nodeType(pOper->pRight)) { + *pVal = (SValueNode*)pOper->pRight; + } + + return NULL != *pCol && NULL != *pVal; +} + +static bool tbCntScanOptIsEligibleLogicCond(STbCntScanOptInfo* pInfo, SLogicConditionNode* pCond) { + if (LOGIC_COND_TYPE_AND != pCond->condType) { + return false; + } + + bool hasDbCond = false; + bool hasStbCond = false; + SColumnNode* pCol = NULL; + SValueNode* pVal = NULL; + SNode* pNode = NULL; + FOREACH(pNode, pCond->pParameterList) { + if (QUERY_NODE_OPERATOR != nodeType(pNode) || !tbCntScanOptGetColValFromCond((SOperatorNode*)pNode, &pCol, &pVal)) { + return false; + } + if (!hasDbCond && 0 == strcmp(pCol->colName, "db_name")) { + hasDbCond = true; + strcpy(pInfo->table.dbname, pVal->literal); + } else if (!hasStbCond && 0 == strcmp(pCol->colName, "stable_name")) { + hasStbCond = true; + strcpy(pInfo->table.tname, pVal->literal); + } else { + return false; + } + } + return hasDbCond; +} + +static bool tbCntScanOptIsEligibleOpCond(SOperatorNode* pCond) { + SColumnNode* pCol = NULL; + SValueNode* pVal = NULL; + if (!tbCntScanOptGetColValFromCond(pCond, &pCol, &pVal)) { + return false; + } + return 0 == strcmp(pCol->colName, "db_name"); +} + +static bool tbCntScanOptIsEligibleConds(STbCntScanOptInfo* pInfo, SNode* pConditions) { + if (NULL == pConditions) { + return true; + } + + if (QUERY_NODE_LOGIC_CONDITION == nodeType(pConditions)) { + return tbCntScanOptIsEligibleLogicCond(pInfo, (SLogicConditionNode*)pConditions); + } + + if (QUERY_NODE_OPERATOR == nodeType(pConditions)) { + return tbCntScanOptIsEligibleOpCond((SOperatorNode*)pConditions); + } + + return false; +} + +static bool tbCntScanOptIsEligibleScan(STbCntScanOptInfo* pInfo) { + if (0 != strcmp(pInfo->pScan->tableName.dbname, TSDB_INFORMATION_SCHEMA_DB) || + 0 != strcmp(pInfo->pScan->tableName.tname, TSDB_INS_TABLE_TABLES) || NULL != pInfo->pScan->pGroupTags) { + return false; + } + if (1 == pInfo->pScan->pVgroupList->numOfVgroups && MNODE_HANDLE == pInfo->pScan->pVgroupList->vgroups[0].vgId) { + return false; + } + return tbCntScanOptIsEligibleConds(pInfo, pInfo->pScan->node.pConditions); +} + +static bool tbCntScanOptShouldBeOptimized(SLogicNode* pNode, STbCntScanOptInfo* pInfo) { + if (QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren) || + QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(nodesListGetNode(pNode->pChildren, 0))) { + return false; + } + + pInfo->pAgg = (SAggLogicNode*)pNode; + pInfo->pScan = (SScanLogicNode*)nodesListGetNode(pNode->pChildren, 0); + return tbCntScanOptIsEligibleAgg(pInfo->pAgg) && tbCntScanOptIsEligibleScan(pInfo); +} + +static SNode* tbCntScanOptCreateTableCountFunc() { + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); + if (NULL == pFunc) { + return NULL; + } + strcpy(pFunc->functionName, "_table_count"); + strcpy(pFunc->node.aliasName, "_table_count"); + if (TSDB_CODE_SUCCESS != fmGetFuncInfo(pFunc, NULL, 0)) { + nodesDestroyNode((SNode*)pFunc); + return NULL; + } + return (SNode*)pFunc; +} + +static int32_t tbCntScanOptRewriteScan(STbCntScanOptInfo* pInfo) { + pInfo->pScan->scanType = SCAN_TYPE_TABLE_COUNT; + strcpy(pInfo->pScan->tableName.dbname, pInfo->table.dbname); + strcpy(pInfo->pScan->tableName.tname, pInfo->table.tname); + NODES_DESTORY_LIST(pInfo->pScan->node.pTargets); + NODES_DESTORY_LIST(pInfo->pScan->pScanCols); + NODES_DESTORY_NODE(pInfo->pScan->node.pConditions); + NODES_DESTORY_LIST(pInfo->pScan->pScanPseudoCols); + int32_t code = nodesListMakeStrictAppend(&pInfo->pScan->pScanPseudoCols, tbCntScanOptCreateTableCountFunc()); + if (TSDB_CODE_SUCCESS == code) { + code = createColumnByRewriteExpr(nodesListGetNode(pInfo->pScan->pScanPseudoCols, 0), &pInfo->pScan->node.pTargets); + } + SNode* pGroupKey = NULL; + FOREACH(pGroupKey, pInfo->pAgg->pGroupKeys) { + SNode* pGroupCol = nodesListGetNode(((SGroupingSetNode*)pGroupKey)->pParameterList, 0); + code = nodesListMakeStrictAppend(&pInfo->pScan->pGroupTags, nodesCloneNode(pGroupCol)); + if (TSDB_CODE_SUCCESS == code) { + code = nodesListMakeStrictAppend(&pInfo->pScan->pScanCols, nodesCloneNode(pGroupCol)); + } + if (TSDB_CODE_SUCCESS == code) { + code = nodesListMakeStrictAppend(&pInfo->pScan->node.pTargets, nodesCloneNode(pGroupCol)); + } + if (TSDB_CODE_SUCCESS != code) { + break; + } + } + return code; +} + +static int32_t tbCntScanOptCreateSumFunc(SFunctionNode* pCntFunc, SNode* pParam, SNode** pOutput) { + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); + if (NULL == pFunc) { + return TSDB_CODE_OUT_OF_MEMORY; + } + strcpy(pFunc->functionName, "sum"); + strcpy(pFunc->node.aliasName, pCntFunc->node.aliasName); + int32_t code = createColumnByRewriteExpr(pParam, &pFunc->pParameterList); + if (TSDB_CODE_SUCCESS == code) { + code = fmGetFuncInfo(pFunc, NULL, 0); + } + if (TSDB_CODE_SUCCESS == code) { + *pOutput = (SNode*)pFunc; + } else { + nodesDestroyNode((SNode*)pFunc); + } + return code; +} + +static int32_t tbCntScanOptRewriteAgg(SAggLogicNode* pAgg) { + SScanLogicNode* pScan = (SScanLogicNode*)nodesListGetNode(pAgg->node.pChildren, 0); + SNode* pSum = NULL; + int32_t code = tbCntScanOptCreateSumFunc((SFunctionNode*)nodesListGetNode(pAgg->pAggFuncs, 0), + nodesListGetNode(pScan->pScanPseudoCols, 0), &pSum); + if (TSDB_CODE_SUCCESS == code) { + NODES_DESTORY_LIST(pAgg->pAggFuncs); + code = nodesListMakeStrictAppend(&pAgg->pAggFuncs, pSum); + } + if (TSDB_CODE_SUCCESS == code) { + code = partTagsRewriteGroupTagsToFuncs(pScan->pGroupTags, 0, pAgg); + } + NODES_DESTORY_LIST(pAgg->pGroupKeys); + return code; +} + +static int32_t tableCountScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { + STbCntScanOptInfo info = {0}; + if (!optFindEligibleNode(pLogicSubplan->pNode, (FShouldBeOptimized)tbCntScanOptShouldBeOptimized, &info)) { + return TSDB_CODE_SUCCESS; + } + + int32_t code = tbCntScanOptRewriteScan(&info); + if (TSDB_CODE_SUCCESS == code) { + code = tbCntScanOptRewriteAgg(info.pAgg); + } + return code; +} + // clang-format off static const SOptimizeRule optimizeRuleSet[] = { {.pName = "ScanPath", .optimizeFunc = scanPathOptimize}, @@ -2468,7 +2720,8 @@ static const SOptimizeRule optimizeRuleSet[] = { {.pName = "RewriteUnique", .optimizeFunc = rewriteUniqueOptimize}, {.pName = "LastRowScan", .optimizeFunc = lastRowScanOptimize}, {.pName = "TagScan", .optimizeFunc = tagScanOptimize}, - {.pName = "PushDownLimit", .optimizeFunc = pushDownLimitOptimize} + {.pName = "PushDownLimit", .optimizeFunc = pushDownLimitOptimize}, + {.pName = "TableCountScan", .optimizeFunc = tableCountScanOptimize}, }; // clang-format on diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 379bfe90c8..53c1d24df9 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -489,6 +489,8 @@ static ENodeType getScanOperatorType(EScanType scanType) { return QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN; case SCAN_TYPE_BLOCK_INFO: return QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN; + case SCAN_TYPE_TABLE_COUNT: + return QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN; default: break; } @@ -524,6 +526,24 @@ static int32_t createLastRowScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSu pScan->ignoreNull = pScanLogicNode->igLastNull; vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode); + return createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pScan, pPhyNode); +} + +static int32_t createTableCountScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, + SScanLogicNode* pScanLogicNode, SPhysiNode** pPhyNode) { + STableCountScanPhysiNode* pScan = (STableCountScanPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pScanLogicNode, + QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN); + if (NULL == pScan) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + pScan->pGroupTags = nodesCloneList(pScanLogicNode->pGroupTags); + if (NULL != pScanLogicNode->pGroupTags && NULL == pScan->pGroupTags) { + nodesDestroyNode((SNode*)pScan); + return TSDB_CODE_OUT_OF_MEMORY; + } + + pScan->groupSort = pScanLogicNode->groupSort; vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode); return createScanPhysiNodeFinalize(pCxt, pSubplan, pScanLogicNode, (SScanPhysiNode*)pScan, pPhyNode); @@ -589,7 +609,6 @@ static int32_t createSystemTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pScan->accountId = pCxt->pPlanCxt->acctId; pScan->sysInfo = pCxt->pPlanCxt->sysInfo; if (0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_TABLES) || - 0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_TABLE_DISTRIBUTED) || 0 == strcmp(pScanLogicNode->tableName.tname, TSDB_INS_TABLE_TAGS)) { vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode); } else { @@ -624,6 +643,8 @@ static int32_t createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, case SCAN_TYPE_TAG: case SCAN_TYPE_BLOCK_INFO: return createSimpleScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode); + case SCAN_TYPE_TABLE_COUNT: + return createTableCountScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode); case SCAN_TYPE_LAST_ROW: return createLastRowScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode); case SCAN_TYPE_TABLE: diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index bcf4b40e69..f5782dc937 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -292,6 +292,20 @@ static bool stbSplNeedSplitJoin(bool streamQuery, SJoinLogicNode* pJoin) { return true; } +static bool stbSplIsTableCountQuery(SLogicNode* pNode) { + if (1 != LIST_LENGTH(pNode->pChildren)) { + return false; + } + SNode* pChild = nodesListGetNode(pNode->pChildren, 0); + if (QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pChild)) { + if (1 != LIST_LENGTH(((SLogicNode*)pChild)->pChildren)) { + return false; + } + pChild = nodesListGetNode(((SLogicNode*)pChild)->pChildren, 0); + } + return QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pChild) && SCAN_TYPE_TABLE_COUNT == ((SScanLogicNode*)pChild)->scanType; +} + static SNodeList* stbSplGetPartKeys(SLogicNode* pNode) { if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) { return ((SScanLogicNode*)pNode)->pGroupTags; @@ -340,7 +354,7 @@ static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) { case QUERY_NODE_LOGIC_PLAN_AGG: return (!stbSplHasGatherExecFunc(((SAggLogicNode*)pNode)->pAggFuncs) || stbSplIsPartTableAgg((SAggLogicNode*)pNode)) && - stbSplHasMultiTbScan(streamQuery, pNode); + stbSplHasMultiTbScan(streamQuery, pNode) && !stbSplIsTableCountQuery(pNode); case QUERY_NODE_LOGIC_PLAN_WINDOW: return stbSplNeedSplitWindow(streamQuery, pNode); case QUERY_NODE_LOGIC_PLAN_SORT: diff --git a/source/libs/planner/test/planSysTbTest.cpp b/source/libs/planner/test/planSysTbTest.cpp index 6b40e381cc..fc00285a6d 100644 --- a/source/libs/planner/test/planSysTbTest.cpp +++ b/source/libs/planner/test/planSysTbTest.cpp @@ -20,13 +20,6 @@ using namespace std; class PlanSysTableTest : public PlannerTestBase {}; -TEST_F(PlanSysTableTest, show) { - useDb("root", "test"); - - run("show tables"); - run("show stables"); -} - TEST_F(PlanSysTableTest, informationSchema) { useDb("root", "information_schema"); @@ -38,3 +31,17 @@ TEST_F(PlanSysTableTest, withAgg) { run("SELECT COUNT(1) FROM ins_users"); } + +TEST_F(PlanSysTableTest, tableCount) { + useDb("root", "information_schema"); + + run("SELECT COUNT(*) FROM ins_tables"); + + run("SELECT COUNT(*) FROM ins_tables WHERE db_name = 'test'"); + + run("SELECT COUNT(*) FROM ins_tables WHERE db_name = 'test' AND stable_name = 'st1'"); + + run("SELECT db_name, COUNT(*) FROM ins_tables GROUP BY db_name"); + + run("SELECT db_name, stable_name, COUNT(*) FROM ins_tables GROUP BY db_name, stable_name"); +} diff --git a/source/libs/qcom/src/queryUtil.c b/source/libs/qcom/src/queryUtil.c index 6eadf80e3d..c74882cf23 100644 --- a/source/libs/qcom/src/queryUtil.c +++ b/source/libs/qcom/src/queryUtil.c @@ -159,7 +159,7 @@ int32_t asyncSendMsgToServerExt(void* pTransporter, SEpSet* epSet, int64_t* pTra if (NULL == pMsg) { qError("0x%" PRIx64 " msg:%s malloc failed", pInfo->requestId, TMSG_INFO(pInfo->msgType)); destroySendMsgInfo(pInfo); - terrno = TSDB_CODE_TSC_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno; } @@ -441,12 +441,25 @@ int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst) { int32_t metaSize = sizeof(STableMeta) + numOfField * sizeof(SSchema); *pDst = taosMemoryMalloc(metaSize); if (NULL == *pDst) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } memcpy(*pDst, pSrc, metaSize); return TSDB_CODE_SUCCESS; } + +void freeVgInfo(SDBVgInfo* vgInfo) { + if (NULL == vgInfo) { + return; + } + + taosHashCleanup(vgInfo->vgHash); + taosArrayDestroy(vgInfo->vgArray); + + taosMemoryFreeClear(vgInfo); +} + + int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst) { if (NULL == pSrc) { *pDst = NULL; @@ -455,7 +468,7 @@ int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst) { *pDst = taosMemoryMalloc(sizeof(*pSrc)); if (NULL == *pDst) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } memcpy(*pDst, pSrc, sizeof(*pSrc)); if (pSrc->vgHash) { @@ -463,7 +476,7 @@ int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst) { HASH_ENTRY_LOCK); if (NULL == (*pDst)->vgHash) { taosMemoryFreeClear(*pDst); - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } SVgroupInfo* vgInfo = NULL; @@ -475,8 +488,7 @@ int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst) { if (0 != taosHashPut((*pDst)->vgHash, vgId, sizeof(*vgId), vgInfo, sizeof(*vgInfo))) { qError("taosHashPut failed, vgId:%d", vgInfo->vgId); taosHashCancelIterate(pSrc->vgHash, pIter); - taosHashCleanup((*pDst)->vgHash); - taosMemoryFreeClear(*pDst); + freeVgInfo(*pDst); return TSDB_CODE_OUT_OF_MEMORY; } diff --git a/source/libs/qcom/src/querymsg.c b/source/libs/qcom/src/querymsg.c index fadc39f21d..2e4b000761 100644 --- a/source/libs/qcom/src/querymsg.c +++ b/source/libs/qcom/src/querymsg.c @@ -34,7 +34,7 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) { pOut->dbVgroup = taosMemoryCalloc(1, sizeof(SDBVgInfo)); if (NULL == pOut->dbVgroup) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } pOut->dbVgroup->vgVersion = usedbRsp->vgVersion; @@ -52,7 +52,7 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) { pOut->dbVgroup->vgHash = taosHashInit(usedbRsp->vgNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK); if (NULL == pOut->dbVgroup->vgHash) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } for (int32_t i = 0; i < usedbRsp->vgNum; ++i) { @@ -61,7 +61,7 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) { qDebug("the %dth vgroup, id %d, epNum %d, current %s port %d", i, pVgInfo->vgId, pVgInfo->epSet.numOfEps, pVgInfo->epSet.eps[pVgInfo->epSet.inUse].fqdn, pVgInfo->epSet.eps[pVgInfo->epSet.inUse].port); if (0 != taosHashPut(pOut->dbVgroup->vgHash, &pVgInfo->vgId, sizeof(int32_t), pVgInfo, sizeof(SVgroupInfo))) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } } @@ -387,7 +387,7 @@ int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta * STableMeta *pTableMeta = taosMemoryCalloc(1, metaSize); if (NULL == pTableMeta) { qError("calloc size[%d] failed", metaSize); - return TSDB_CODE_TSC_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } pTableMeta->vgId = isStb ? 0 : msg->vgId; diff --git a/source/libs/qworker/inc/qwInt.h b/source/libs/qworker/inc/qwInt.h index a0e04b6a19..af361323a7 100644 --- a/source/libs/qworker/inc/qwInt.h +++ b/source/libs/qworker/inc/qwInt.h @@ -363,7 +363,7 @@ int32_t qwAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx); int32_t qwGetTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx); int32_t qwAddAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx); void qwReleaseTaskCtx(SQWorker *mgmt, void *ctx); -int32_t qwKillTaskHandle(SQWTaskCtx *ctx); +int32_t qwKillTaskHandle(SQWTaskCtx *ctx, int32_t rspCode); int32_t qwUpdateTaskStatus(QW_FPARAMS_DEF, int8_t status); int32_t qwDropTask(QW_FPARAMS_DEF); void qwSaveTbVersionInfo(qTaskInfo_t pTaskInfo, SQWTaskCtx *ctx); diff --git a/source/libs/qworker/src/qwDbg.c b/source/libs/qworker/src/qwDbg.c index 4c4a41df82..db6e5b19fb 100644 --- a/source/libs/qworker/src/qwDbg.c +++ b/source/libs/qworker/src/qwDbg.c @@ -28,57 +28,57 @@ int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, return TSDB_CODE_SUCCESS; } - QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + QW_ERR_JRET(TSDB_CODE_APP_ERROR); } switch (oriStatus) { case JOB_TASK_STATUS_NULL: if (newStatus != JOB_TASK_STATUS_EXEC && newStatus != JOB_TASK_STATUS_FAIL && newStatus != JOB_TASK_STATUS_INIT) { - QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + QW_ERR_JRET(TSDB_CODE_APP_ERROR); } break; case JOB_TASK_STATUS_INIT: if (newStatus != JOB_TASK_STATUS_DROP && newStatus != JOB_TASK_STATUS_EXEC && newStatus != JOB_TASK_STATUS_FAIL) { - QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + QW_ERR_JRET(TSDB_CODE_APP_ERROR); } break; case JOB_TASK_STATUS_EXEC: if (newStatus != JOB_TASK_STATUS_PART_SUCC && newStatus != JOB_TASK_STATUS_SUCC && newStatus != JOB_TASK_STATUS_FAIL && newStatus != JOB_TASK_STATUS_DROP) { - QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + QW_ERR_JRET(TSDB_CODE_APP_ERROR); } break; case JOB_TASK_STATUS_PART_SUCC: if (newStatus != JOB_TASK_STATUS_EXEC && newStatus != JOB_TASK_STATUS_SUCC && newStatus != JOB_TASK_STATUS_FAIL && newStatus != JOB_TASK_STATUS_DROP) { - QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + QW_ERR_JRET(TSDB_CODE_APP_ERROR); } break; case JOB_TASK_STATUS_SUCC: if (newStatus != JOB_TASK_STATUS_DROP && newStatus != JOB_TASK_STATUS_FAIL) { - QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + QW_ERR_JRET(TSDB_CODE_APP_ERROR); } break; case JOB_TASK_STATUS_FAIL: if (newStatus != JOB_TASK_STATUS_DROP) { - QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + QW_ERR_JRET(TSDB_CODE_APP_ERROR); } break; case JOB_TASK_STATUS_DROP: if (newStatus != JOB_TASK_STATUS_FAIL && newStatus != JOB_TASK_STATUS_PART_SUCC) { - QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + QW_ERR_JRET(TSDB_CODE_APP_ERROR); } break; default: QW_TASK_ELOG("invalid task origStatus:%s", jobTaskStatusStr(oriStatus)); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } return TSDB_CODE_SUCCESS; @@ -214,20 +214,20 @@ void qwDbgSimulateRedirect(SQWMsg *qwMsg, SQWTaskCtx *ctx, bool *rsped) { epSet.eps[2].port = 7300; ctx->phase = QW_PHASE_POST_QUERY; - qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_RPC_REDIRECT, &epSet); + qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_SYN_NOT_LEADER, &epSet); *rsped = true; return; } if (TDMT_SCH_MERGE_QUERY == qwMsg->msgType && (0 == taosRand() % 3)) { QW_SET_PHASE(ctx, QW_PHASE_POST_QUERY); - qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_RPC_REDIRECT, NULL); + qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_SYN_NOT_LEADER, NULL); *rsped = true; return; } if ((TDMT_SCH_FETCH == qwMsg->msgType) && (0 == taosRand() % 9)) { - qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_RPC_REDIRECT, NULL); + qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_SYN_NOT_LEADER, NULL); *rsped = true; return; } diff --git a/source/libs/qworker/src/qwMsg.c b/source/libs/qworker/src/qwMsg.c index d9a7cea411..1a3a740b34 100644 --- a/source/libs/qworker/src/qwMsg.c +++ b/source/libs/qworker/src/qwMsg.c @@ -17,7 +17,7 @@ int32_t qwMallocFetchRsp(int8_t rpcMalloc, int32_t length, SRetrieveTableRsp **r (SRetrieveTableRsp *)(rpcMalloc ? rpcReallocCont(*rsp, msgSize) : taosMemoryRealloc(*rsp, msgSize)); if (NULL == pRsp) { qError("rpcMallocCont %d failed", msgSize); - QW_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_RET(TSDB_CODE_OUT_OF_MEMORY); } if (NULL == *rsp) { @@ -37,7 +37,7 @@ void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComplete) rsp->precision = input->precision; rsp->compressed = input->compressed; rsp->compLen = htonl(len); - rsp->numOfRows = htonl(input->numOfRows); + rsp->numOfRows = htobe64(input->numOfRows); rsp->numOfCols = htonl(input->numOfCols); rsp->numOfBlocks = htonl(input->numOfBlocks); } @@ -78,18 +78,18 @@ int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t c int32_t msgSize = tSerializeSQueryTableRsp(NULL, 0, &rsp); if (msgSize < 0) { qError("tSerializeSQueryTableRsp failed"); - QW_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_RET(TSDB_CODE_OUT_OF_MEMORY); } void *pRsp = rpcMallocCont(msgSize); if (NULL == pRsp) { qError("rpcMallocCont %d failed", msgSize); - QW_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_RET(TSDB_CODE_OUT_OF_MEMORY); } if (tSerializeSQueryTableRsp(pRsp, msgSize, &rsp) < 0) { qError("tSerializeSQueryTableRsp %d failed", msgSize); - QW_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_RET(TSDB_CODE_OUT_OF_MEMORY); } SRpcMsg rpcRsp = { @@ -212,19 +212,19 @@ int32_t qwBuildAndSendDropMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) { int32_t msgSize = tSerializeSTaskDropReq(NULL, 0, &qMsg); if (msgSize < 0) { QW_SCH_TASK_ELOG("tSerializeSTaskDropReq get size, msgSize:%d", msgSize); - QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } void *msg = rpcMallocCont(msgSize); if (NULL == msg) { QW_SCH_TASK_ELOG("rpcMallocCont %d failed", msgSize); - QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } if (tSerializeSTaskDropReq(msg, msgSize, &qMsg) < 0) { QW_SCH_TASK_ELOG("tSerializeSTaskDropReq failed, msgSize:%d", msgSize); rpcFreeCont(msg); - QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } SRpcMsg pNewMsg = { @@ -250,7 +250,7 @@ int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) { SQueryContinueReq *req = (SQueryContinueReq *)rpcMallocCont(sizeof(SQueryContinueReq)); if (NULL == req) { QW_SCH_TASK_ELOG("rpcMallocCont %d failed", (int32_t)sizeof(SQueryContinueReq)); - QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } req->header.vgId = mgmt->nodeId; @@ -291,19 +291,19 @@ int32_t qwRegisterQueryBrokenLinkArg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) { int32_t msgSize = tSerializeSTaskDropReq(NULL, 0, &qMsg); if (msgSize < 0) { QW_SCH_TASK_ELOG("tSerializeSTaskDropReq get size, msgSize:%d", msgSize); - QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } void *msg = rpcMallocCont(msgSize); if (NULL == msg) { QW_SCH_TASK_ELOG("rpcMallocCont %d failed", msgSize); - QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } if (tSerializeSTaskDropReq(msg, msgSize, &qMsg) < 0) { QW_SCH_TASK_ELOG("tSerializeSTaskDropReq failed, msgSize:%d", msgSize); rpcFreeCont(msg); - QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } SRpcMsg brokenMsg = { @@ -327,17 +327,17 @@ int32_t qwRegisterHbBrokenLinkArg(SQWorker *mgmt, uint64_t sId, SRpcHandleInfo * int32_t msgSize = tSerializeSSchedulerHbReq(NULL, 0, &req); if (msgSize < 0) { QW_SCH_ELOG("tSerializeSSchedulerHbReq hbReq failed, size:%d", msgSize); - QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } void *msg = rpcMallocCont(msgSize); if (NULL == msg) { QW_SCH_ELOG("calloc %d failed", msgSize); - QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } if (tSerializeSSchedulerHbReq(msg, msgSize, &req) < 0) { QW_SCH_ELOG("tSerializeSSchedulerHbReq hbReq failed, size:%d", msgSize); - taosMemoryFree(msg); - QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + rpcFreeCont(msg); + QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } SRpcMsg brokenMsg = { diff --git a/source/libs/qworker/src/qwUtil.c b/source/libs/qworker/src/qwUtil.c index 2c0a4072ae..ce3b493638 100644 --- a/source/libs/qworker/src/qwUtil.c +++ b/source/libs/qworker/src/qwUtil.c @@ -76,7 +76,7 @@ int32_t qwAddSchedulerImpl(SQWorker *mgmt, uint64_t sId, int32_t rwType) { taosHashInit(mgmt->cfg.maxSchTaskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); if (NULL == newSch.tasksHash) { QW_SCH_ELOG("taosHashInit %d failed", mgmt->cfg.maxSchTaskNum); - QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } QW_LOCK(QW_WRITE, &mgmt->schLock); @@ -87,7 +87,7 @@ int32_t qwAddSchedulerImpl(SQWorker *mgmt, uint64_t sId, int32_t rwType) { QW_SCH_ELOG("taosHashPut new sch to scheduleHash failed, errno:%d", errno); taosHashCleanup(newSch.tasksHash); - QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } taosHashCleanup(newSch.tasksHash); @@ -114,7 +114,7 @@ int32_t qwAcquireSchedulerImpl(SQWorker *mgmt, uint64_t sId, int32_t rwType, SQW QW_RET(TSDB_CODE_QRY_SCH_NOT_EXIST); } else { QW_SCH_ELOG("unknown notExistOpt:%d", nOpt); - QW_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + QW_ERR_RET(TSDB_CODE_APP_ERROR); } } @@ -171,7 +171,7 @@ int32_t qwAddTaskStatusImpl(QW_FPARAMS_DEF, SQWSchStatus *sch, int32_t rwType, i } } else { QW_TASK_ELOG("taosHashPut to tasksHash failed, error:%x - %s", code, tstrerror(code)); - QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } } QW_UNLOCK(QW_WRITE, &sch->tasksLock); @@ -251,7 +251,7 @@ int32_t qwAddTaskCtxImpl(QW_FPARAMS_DEF, bool acquire, SQWTaskCtx **ctx) { } } else { QW_TASK_ELOG("taosHashPut to ctxHash failed, error:%x", code); - QW_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } } @@ -279,14 +279,14 @@ void qwFreeTaskHandle(qTaskInfo_t *taskHandle) { } } -int32_t qwKillTaskHandle(SQWTaskCtx *ctx) { +int32_t qwKillTaskHandle(SQWTaskCtx *ctx, int32_t rspCode) { int32_t code = 0; // Note: free/kill may in RC qTaskInfo_t taskHandle = atomic_load_ptr(&ctx->taskHandle); if (taskHandle && atomic_val_compare_exchange_ptr(&ctx->taskHandle, taskHandle, NULL)) { qDebug("start to kill task"); - code = qAsyncKillTask(taskHandle); + code = qAsyncKillTask(taskHandle, rspCode); atomic_store_ptr(&ctx->taskHandle, taskHandle); } @@ -363,7 +363,7 @@ int32_t qwDropTaskStatus(QW_FPARAMS_DEF) { if (taosHashRemove(sch->tasksHash, id, sizeof(id))) { QW_TASK_ELOG_E("taosHashRemove task from hash failed"); - QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + QW_ERR_JRET(TSDB_CODE_APP_ERROR); } QW_TASK_DLOG_E("task status dropped"); @@ -509,7 +509,7 @@ int32_t qwOpenRef(void) { if (gQwMgmt.qwRef < 0) { taosWUnLockLatch(&gQwMgmt.lock); qError("init qworker ref failed"); - QW_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_RET(TSDB_CODE_OUT_OF_MEMORY); } } taosWUnLockLatch(&gQwMgmt.lock); diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index 0890d10b65..c5db4105d7 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -216,7 +216,7 @@ int32_t qwGenerateSchHbRsp(SQWorker *mgmt, SQWSchStatus *sch, SQWHbInfo *hbInfo) if (NULL == hbInfo->rsp.taskStatus) { QW_UNLOCK(QW_READ, &sch->tasksLock); QW_ELOG("taosArrayInit taskStatus failed, num:%d", taskNum); - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } void *key = NULL; @@ -275,7 +275,7 @@ int32_t qwGetQueryResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen, QW_ERR_RET(code); } - QW_TASK_DLOG("no more data in sink and query end, fetched blocks %d rows %d", pOutput->numOfBlocks, + QW_TASK_DLOG("no more data in sink and query end, fetched blocks %d rows %"PRId64, pOutput->numOfBlocks, pOutput->numOfRows); qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_SUCC); @@ -320,19 +320,19 @@ int32_t qwGetQueryResFromSink(QW_FPARAMS_DEF, SQWTaskCtx *ctx, int32_t *dataLen, pOutput->numOfBlocks++; if (DS_BUF_EMPTY == pOutput->bufStatus && pOutput->queryEnd) { - QW_TASK_DLOG("task all data fetched and done, fetched blocks %d rows %d", pOutput->numOfBlocks, + QW_TASK_DLOG("task all data fetched and done, fetched blocks %d rows %" PRId64, pOutput->numOfBlocks, pOutput->numOfRows); qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_SUCC); break; } if (0 == ctx->level) { - QW_TASK_DLOG("task fetched blocks %d rows %d, level %d", pOutput->numOfBlocks, pOutput->numOfRows, ctx->level); + QW_TASK_DLOG("task fetched blocks %d rows %"PRId64", level %d", pOutput->numOfBlocks, pOutput->numOfRows, ctx->level); break; } if (pOutput->numOfRows >= QW_MIN_RES_ROWS) { - QW_TASK_DLOG("task fetched blocks %d rows %d reaches the min rows", pOutput->numOfBlocks, pOutput->numOfRows); + QW_TASK_DLOG("task fetched blocks %d rows %" PRId64 " reaches the min rows", pOutput->numOfBlocks, pOutput->numOfRows); break; } } @@ -411,7 +411,7 @@ int32_t qwHandlePrePhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inpu // qwBuildAndSendDropRsp(&ctx->ctrlConnInfo, code); // QW_TASK_DLOG("drop rsp send, handle:%p, code:%x - %s", ctx->ctrlConnInfo.handle, code, tstrerror(code)); - QW_ERR_JRET(TSDB_CODE_QRY_TASK_DROPPED); + QW_ERR_JRET(ctx->rspCode); } QW_ERR_JRET(qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_EXEC)); @@ -420,7 +420,7 @@ int32_t qwHandlePrePhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inpu case QW_PHASE_PRE_FETCH: { if (QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP) || QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) { QW_TASK_WLOG("task dropping or already dropped, phase:%s", qwPhaseStr(phase)); - QW_ERR_JRET(TSDB_CODE_QRY_TASK_DROPPED); + QW_ERR_JRET(ctx->rspCode); } if (QW_EVENT_RECEIVED(ctx, QW_EVENT_FETCH)) { @@ -442,7 +442,7 @@ int32_t qwHandlePrePhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inpu case QW_PHASE_PRE_CQUERY: { if (QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) { QW_TASK_WLOG("task already dropped, phase:%s", qwPhaseStr(phase)); - QW_ERR_JRET(TSDB_CODE_QRY_TASK_DROPPED); + QW_ERR_JRET(ctx->rspCode); } if (ctx->rspCode) { @@ -456,14 +456,14 @@ int32_t qwHandlePrePhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inpu // qwBuildAndSendDropRsp(&ctx->ctrlConnInfo, code); // QW_TASK_DLOG("drop rsp send, handle:%p, code:%x - %s", ctx->ctrlConnInfo.handle, code, tstrerror(code)); - QW_ERR_JRET(TSDB_CODE_QRY_TASK_DROPPED); + QW_ERR_JRET(ctx->rspCode); } break; } default: QW_TASK_ELOG("invalid phase %s", qwPhaseStr(phase)); - QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + QW_ERR_JRET(TSDB_CODE_APP_ERROR); } if (ctx->rspCode) { @@ -502,20 +502,20 @@ int32_t qwHandlePostPhaseEvents(QW_FPARAMS_DEF, int8_t phase, SQWPhaseInput *inp if (QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) { QW_TASK_WLOG("task already dropped, phase:%s", qwPhaseStr(phase)); - QW_ERR_JRET(TSDB_CODE_QRY_TASK_DROPPED); + QW_ERR_JRET(ctx->rspCode); } if (QW_EVENT_RECEIVED(ctx, QW_EVENT_DROP)) { if (QW_PHASE_POST_FETCH == phase) { QW_TASK_WLOG("drop received at wrong phase %s", qwPhaseStr(phase)); - QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + QW_ERR_JRET(TSDB_CODE_APP_ERROR); } // qwBuildAndSendDropRsp(&ctx->ctrlConnInfo, code); // QW_TASK_DLOG("drop rsp send, handle:%p, code:%x - %s", ctx->ctrlConnInfo.handle, code, tstrerror(code)); QW_ERR_JRET(qwDropTask(QW_FPARAMS())); - QW_ERR_JRET(TSDB_CODE_QRY_TASK_DROPPED); + QW_ERR_JRET(ctx->rspCode); } if (ctx->rspCode) { @@ -629,7 +629,7 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, char *sql) { if (NULL == sinkHandle || NULL == pTaskInfo) { QW_TASK_ELOG("create task result error, taskHandle:%p, sinkHandle:%p", pTaskInfo, sinkHandle); - QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + QW_ERR_JRET(TSDB_CODE_APP_ERROR); } qwSendQueryRsp(QW_FPARAMS(), qwMsg->msgType + 1, ctx, code, true); @@ -861,7 +861,7 @@ int32_t qwProcessDrop(QW_FPARAMS_DEF, SQWMsg *qwMsg) { } if (QW_QUERY_RUNNING(ctx)) { - QW_ERR_JRET(qwKillTaskHandle(ctx)); + QW_ERR_JRET(qwKillTaskHandle(ctx, TSDB_CODE_TSC_QUERY_CANCELLED)); qwUpdateTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_DROP); } else { QW_ERR_JRET(qwDropTask(QW_FPARAMS())); @@ -869,6 +869,7 @@ int32_t qwProcessDrop(QW_FPARAMS_DEF, SQWMsg *qwMsg) { } if (!dropped) { + QW_UPDATE_RSP_CODE(ctx, TSDB_CODE_TSC_QUERY_CANCELLED); QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_DROP); } @@ -1058,7 +1059,7 @@ int32_t qwProcessDelete(QW_FPARAMS_DEF, SQWMsg *qwMsg, SDeleteRes *pRes) { if (NULL == sinkHandle || NULL == pTaskInfo) { QW_TASK_ELOG("create task result error, taskHandle:%p, sinkHandle:%p", pTaskInfo, sinkHandle); - QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + QW_ERR_JRET(TSDB_CODE_APP_ERROR); } ctx.taskHandle = pTaskInfo; @@ -1096,7 +1097,7 @@ int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, void **qWorkerMgmt, const S if (NULL == mgmt) { qError("calloc %d failed", (int32_t)sizeof(SQWorker)); atomic_sub_fetch_32(&gQwMgmt.qwNum, 1); - QW_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_RET(TSDB_CODE_OUT_OF_MEMORY); } mgmt->cfg.maxSchedulerNum = QW_DEFAULT_SCHEDULER_NUMBER; @@ -1108,20 +1109,20 @@ int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, void **qWorkerMgmt, const S if (NULL == mgmt->schHash) { taosMemoryFreeClear(mgmt); qError("init %d scheduler hash failed", mgmt->cfg.maxSchedulerNum); - QW_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } mgmt->ctxHash = taosHashInit(mgmt->cfg.maxTaskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); if (NULL == mgmt->ctxHash) { qError("init %d task ctx hash failed", mgmt->cfg.maxTaskNum); - QW_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } mgmt->timer = taosTmrInit(0, 0, 0, "qworker"); if (NULL == mgmt->timer) { qError("init timer failed, error:%s", tstrerror(terrno)); - QW_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } mgmt->nodeType = nodeType; @@ -1144,7 +1145,7 @@ int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, void **qWorkerMgmt, const S mgmt->hbTimer = taosTmrStart(qwProcessHbTimerEvent, QW_DEFAULT_HEARTBEAT_MSEC, (void *)param, mgmt->timer); if (NULL == mgmt->hbTimer) { qError("start hb timer failed"); - QW_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + QW_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } *qWorkerMgmt = mgmt; @@ -1195,8 +1196,9 @@ void qWorkerStopAllTasks(void *qWorkerMgmt) { } if (QW_QUERY_RUNNING(ctx)) { - qwKillTaskHandle(ctx); + qwKillTaskHandle(ctx, TSDB_CODE_VND_STOPPED); } else if (!QW_EVENT_PROCESSED(ctx, QW_EVENT_DROP)) { + QW_UPDATE_RSP_CODE(ctx, TSDB_CODE_VND_STOPPED); QW_SET_EVENT_RECEIVED(ctx, QW_EVENT_DROP); } @@ -1286,7 +1288,7 @@ int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64 if (NULL == sinkHandle || NULL == pTaskInfo) { QW_TASK_ELOG("create task result error, taskHandle:%p, sinkHandle:%p", pTaskInfo, sinkHandle); - QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + QW_ERR_JRET(TSDB_CODE_APP_ERROR); } ctx->level = plan->level; diff --git a/source/libs/qworker/test/qworkerTests.cpp b/source/libs/qworker/test/qworkerTests.cpp index 8a48977c77..02b341e28c 100644 --- a/source/libs/qworker/test/qworkerTests.cpp +++ b/source/libs/qworker/test/qworkerTests.cpp @@ -302,7 +302,7 @@ int32_t qwtExecTask(qTaskInfo_t tinfo, SSDataBlock **pRes, uint64_t *useconds) { return 0; } -int32_t qwtKillTask(qTaskInfo_t qinfo) { return 0; } +int32_t qwtKillTask(qTaskInfo_t qinfo, int32_t rspCode) { return 0; } void qwtDestroyTask(qTaskInfo_t qHandle) {} diff --git a/source/libs/scalar/inc/filterInt.h b/source/libs/scalar/inc/filterInt.h index e26bc59d47..2023d38777 100644 --- a/source/libs/scalar/inc/filterInt.h +++ b/source/libs/scalar/inc/filterInt.h @@ -101,6 +101,11 @@ typedef int32_t (*filter_desc_compare_func)(const void *, const void *); typedef bool (*filter_exec_func)(void *, int32_t, SColumnInfoData *, SColumnDataAgg *, int16_t, int32_t *); typedef int32_t (*filer_get_col_from_name)(void *, int32_t, char *, void **); +typedef struct SFilterDataInfo { + int32_t idx; + void* addr; +} SFilterDataInfo; + typedef struct SFilterRangeCompare { int64_t s; int64_t e; @@ -294,9 +299,9 @@ struct SFilterInfo { #define CHK_OR_OPTR(ctx) ((ctx)->isnull == true && (ctx)->notnull == true) #define CHK_AND_OPTR(ctx) ((ctx)->isnull == true && (((ctx)->notnull == true) || ((ctx)->isrange == true))) -#define FILTER_GET_FLAG(st, f) (st & f) -#define FILTER_SET_FLAG(st, f) st |= (f) -#define FILTER_CLR_FLAG(st, f) st &= (~f) +#define FILTER_GET_FLAG(st, f) ((st) & (f)) +#define FILTER_SET_FLAG(st, f) (st) |= (f) +#define FILTER_CLR_FLAG(st, f) (st) &= (~f) #define SIMPLE_COPY_VALUES(dst, src) *((int64_t *)dst) = *((int64_t *)src) #define FLT_PACKAGE_UNIT_HASH_KEY(v, op1, op2, lidx, ridx, ridx2) \ diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index 45931c209c..59e39e3f6f 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -833,7 +833,7 @@ int32_t filterGetRangeRes(void *h, SFilterRange *ra) { if (num == 0) { qError("no range result"); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } return TSDB_CODE_SUCCESS; @@ -963,16 +963,17 @@ int32_t filterGetFiledByDesc(SFilterFields *fields, int32_t type, void *v) { return -1; } -int32_t filterGetFiledByData(SFilterInfo *info, int32_t type, void *v, int32_t dataLen) { +int32_t filterGetFiledByData(SFilterInfo *info, int32_t type, void *v, int32_t dataLen, bool *sameBuf) { if (type == FLD_TYPE_VALUE) { if (info->pctx.valHash == false) { qError("value hash is empty"); return -1; } - void *hv = taosHashGet(info->pctx.valHash, v, dataLen); - if (hv) { - return *(int32_t *)hv; + SFilterDataInfo *dInfo = taosHashGet(info->pctx.valHash, v, dataLen); + if (dInfo) { + *sameBuf = (dInfo->addr == v); + return dInfo->idx; } } @@ -982,9 +983,10 @@ int32_t filterGetFiledByData(SFilterInfo *info, int32_t type, void *v, int32_t d // In the params, we should use void *data instead of void **data, there is no need to use taosMemoryFreeClear(*data) to // set *data = 0 Besides, fields data value is a pointer, so dataLen should be POINTER_BYTES for better. int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type, SFilterFieldId *fid, int32_t dataLen, - bool freeIfExists) { + bool freeIfExists, int16_t *srcFlag) { int32_t idx = -1; uint32_t *num; + bool sameBuf = false; num = &info->fields[type].num; @@ -992,7 +994,7 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type, if (type == FLD_TYPE_COLUMN) { idx = filterGetFiledByDesc(&info->fields[type], type, desc); } else if (data && (*data) && dataLen > 0 && FILTER_GET_FLAG(info->options, FLT_OPTION_NEED_UNIQE)) { - idx = filterGetFiledByData(info, type, *data, dataLen); + idx = filterGetFiledByData(info, type, *data, dataLen, &sameBuf); } } @@ -1020,11 +1022,17 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, false); } - taosHashPut(info->pctx.valHash, *data, dataLen, &idx, sizeof(idx)); + SFilterDataInfo dInfo = {idx, *data}; + taosHashPut(info->pctx.valHash, *data, dataLen, &dInfo, sizeof(dInfo)); + if (srcFlag) { + FILTER_SET_FLAG(*srcFlag, FLD_DATA_NO_FREE); + } } - } else { - if (data && freeIfExists) { + } else if (type != FLD_TYPE_COLUMN && data) { + if (freeIfExists) { taosMemoryFreeClear(*data); + } else if (sameBuf) { + FILTER_SET_FLAG(*srcFlag, FLD_DATA_NO_FREE); } } @@ -1035,7 +1043,7 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type, } static FORCE_INLINE int32_t filterAddColFieldFromField(SFilterInfo *info, SFilterField *field, SFilterFieldId *fid) { - filterAddField(info, field->desc, &field->data, FILTER_GET_TYPE(field->flag), fid, 0, false); + filterAddField(info, field->desc, &field->data, FILTER_GET_TYPE(field->flag), fid, 0, false, NULL); FILTER_SET_FLAG(field->flag, FLD_DATA_NO_FREE); @@ -1045,12 +1053,12 @@ static FORCE_INLINE int32_t filterAddColFieldFromField(SFilterInfo *info, SFilte int32_t filterAddFieldFromNode(SFilterInfo *info, SNode *node, SFilterFieldId *fid) { if (node == NULL) { fltError("empty node"); - FLT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + FLT_ERR_RET(TSDB_CODE_APP_ERROR); } if (nodeType(node) != QUERY_NODE_COLUMN && nodeType(node) != QUERY_NODE_VALUE && nodeType(node) != QUERY_NODE_NODE_LIST) { - FLT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + FLT_ERR_RET(TSDB_CODE_APP_ERROR); } int32_t type; @@ -1064,7 +1072,7 @@ int32_t filterAddFieldFromNode(SFilterInfo *info, SNode *node, SFilterFieldId *f v = node; } - filterAddField(info, v, NULL, type, fid, 0, true); + filterAddField(info, v, NULL, type, fid, 0, true, NULL); return TSDB_CODE_SUCCESS; } @@ -1117,7 +1125,7 @@ int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, int32_t paramNum = scalarGetOperatorParamNum(optr); if (1 != paramNum) { fltError("invalid right field in unit, operator:%s, rightType:%d", operatorTypeStr(optr), u->right.type); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } } @@ -1195,15 +1203,15 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) { len = tDataTypes[type].bytes; - filterAddField(info, NULL, (void **)&out.columnData->pData, FLD_TYPE_VALUE, &right, len, true); + filterAddField(info, NULL, (void **)&out.columnData->pData, FLD_TYPE_VALUE, &right, len, true, NULL); out.columnData->pData = NULL; } else { void *data = taosMemoryCalloc(1, tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes); // reserved space for simple_copy if (NULL == data) { - FLT_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } memcpy(data, nodesGetValueFromNode(valueNode), tDataTypes[type].bytes); - filterAddField(info, NULL, (void **)&data, FLD_TYPE_VALUE, &right, len, true); + filterAddField(info, NULL, (void **)&data, FLD_TYPE_VALUE, &right, len, true, NULL); } filterAddUnit(info, OP_TYPE_EQUAL, &left, &right, &uidx); @@ -1234,28 +1242,26 @@ int32_t filterAddUnitFromUnit(SFilterInfo *dst, SFilterInfo *src, SFilterUnit *u uint8_t type = FILTER_UNIT_DATA_TYPE(u); uint16_t flag = 0; - filterAddField(dst, FILTER_UNIT_COL_DESC(src, u), NULL, FLD_TYPE_COLUMN, &left, 0, false); + filterAddField(dst, FILTER_UNIT_COL_DESC(src, u), NULL, FLD_TYPE_COLUMN, &left, 0, false, NULL); SFilterField *t = FILTER_UNIT_LEFT_FIELD(src, u); if (u->right.type == FLD_TYPE_VALUE) { void *data = FILTER_UNIT_VAL_DATA(src, u); + SFilterField *rField = FILTER_UNIT_RIGHT_FIELD(src, u); + if (IS_VAR_DATA_TYPE(type)) { if (FILTER_UNIT_OPTR(u) == OP_TYPE_IN) { filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, POINTER_BYTES, - false); // POINTER_BYTES should be sizeof(SHashObj), but POINTER_BYTES is also right. + false, &rField->flag); // POINTER_BYTES should be sizeof(SHashObj), but POINTER_BYTES is also right. t = FILTER_GET_FIELD(dst, right); FILTER_SET_FLAG(t->flag, FLD_DATA_IS_HASH); } else { - filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, varDataTLen(data), false); + filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, varDataTLen(data), false, &rField->flag); } } else { - filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, false); + filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, false, &rField->flag); } - - flag = FLD_DATA_NO_FREE; - t = FILTER_UNIT_RIGHT_FIELD(src, u); - FILTER_SET_FLAG(t->flag, flag); } else { pright = NULL; } @@ -1313,17 +1319,17 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan if (func(&ra->s, &ra->e) == 0) { void *data = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data, &ra->s); - filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true); + filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true, NULL); filterAddUnit(dst, OP_TYPE_EQUAL, &left, &right, &uidx); filterAddUnitToGroup(g, uidx); return TSDB_CODE_SUCCESS; } else { void *data = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data, &ra->s); - filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true); + filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true, NULL); void *data2 = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data2, &ra->e); - filterAddField(dst, NULL, &data2, FLD_TYPE_VALUE, &right2, tDataTypes[type].bytes, true); + filterAddField(dst, NULL, &data2, FLD_TYPE_VALUE, &right2, tDataTypes[type].bytes, true, NULL); filterAddUnitImpl( dst, FILTER_GET_FLAG(ra->sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, @@ -1337,7 +1343,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan if (!FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL)) { void *data = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data, &ra->s); - filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true); + filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true, NULL); filterAddUnit(dst, FILTER_GET_FLAG(ra->sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, &right, &uidx); filterAddUnitToGroup(g, uidx); @@ -1346,7 +1352,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan if (!FILTER_GET_FLAG(ra->eflag, RANGE_FLG_NULL)) { void *data = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data, &ra->e); - filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true); + filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true, NULL); filterAddUnit(dst, FILTER_GET_FLAG(ra->eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, &left, &right, &uidx); filterAddUnitToGroup(g, uidx); @@ -1393,16 +1399,16 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan if (func(&r->ra.s, &r->ra.e) == 0) { void *data = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data, &r->ra.s); - filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true); + filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true, NULL); filterAddUnit(dst, OP_TYPE_EQUAL, &left, &right, &uidx); filterAddUnitToGroup(g, uidx); } else { void *data = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data, &r->ra.s); - filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true); + filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true, NULL); void *data2 = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data2, &r->ra.e); - filterAddField(dst, NULL, &data2, FLD_TYPE_VALUE, &right2, tDataTypes[type].bytes, true); + filterAddField(dst, NULL, &data2, FLD_TYPE_VALUE, &right2, tDataTypes[type].bytes, true, NULL); filterAddUnitImpl( dst, FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, @@ -1421,7 +1427,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan if (!FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_NULL)) { void *data = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data, &r->ra.s); - filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true); + filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true, NULL); filterAddUnit(dst, FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, &right, &uidx); filterAddUnitToGroup(g, uidx); @@ -1430,7 +1436,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan if (!FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_NULL)) { void *data = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data, &r->ra.e); - filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true); + filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true, NULL); filterAddUnit(dst, FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, &left, &right, &uidx); filterAddUnitToGroup(g, uidx); @@ -1509,7 +1515,7 @@ EDealRes fltTreeToGroup(SNode *pNode, void *pContext) { return DEAL_RES_IGNORE_CHILD; } - ctx->code = TSDB_CODE_QRY_APP_ERROR; + ctx->code = TSDB_CODE_APP_ERROR; fltError("invalid condition type, type:%d", node->condType); @@ -1940,7 +1946,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) { FLT_ERR_RET(scalarGenerateSetFromList((void **)&fi->data, fi->desc, type)); if (fi->data == NULL) { fltError("failed to convert in param"); - FLT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + FLT_ERR_RET(TSDB_CODE_APP_ERROR); } FILTER_SET_FLAG(fi->flag, FLD_DATA_IS_HASH); @@ -2008,7 +2014,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) { int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(fi->data), varDataLen(fi->data), varDataVal(newValData)); if (len < 0) { qError("filterInitValFieldData taosUcs4ToMbs error 1"); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } varDataSetLen(newValData, len); varDataCopy(fi->data, newValData); @@ -3715,12 +3721,12 @@ int32_t fltAddValueNodeToConverList(SFltTreeStat *stat, SValueNode *pNode) { if (NULL == stat->nodeList) { stat->nodeList = taosArrayInit(10, POINTER_BYTES); if (NULL == stat->nodeList) { - FLT_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } } if (NULL == taosArrayPush(stat->nodeList, &pNode)) { - FLT_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } return TSDB_CODE_SUCCESS; @@ -3841,7 +3847,7 @@ EDealRes fltReviseRewriter(SNode **pNode, void *pContext) { if (NULL == node->pRight) { if (scalarGetOperatorParamNum(node->opType) > 1) { fltError("invalid operator, pRight:%p, nodeType:%d, opType:%d", node->pRight, nodeType(node), node->opType); - stat->code = TSDB_CODE_QRY_APP_ERROR; + stat->code = TSDB_CODE_APP_ERROR; return DEAL_RES_ERROR; } @@ -3902,7 +3908,7 @@ EDealRes fltReviseRewriter(SNode **pNode, void *pContext) { if (OP_TYPE_IN == node->opType && QUERY_NODE_NODE_LIST != nodeType(node->pRight)) { fltError("invalid IN operator node, rightType:%d", nodeType(node->pRight)); - stat->code = TSDB_CODE_QRY_APP_ERROR; + stat->code = TSDB_CODE_APP_ERROR; return DEAL_RES_ERROR; } @@ -3988,7 +3994,7 @@ int32_t fltGetDataFromSlotId(void *param, int32_t id, void **data) { if (id < 0 || id >= numOfCols || id >= taosArrayGetSize(pDataBlock)) { fltError("invalid slot id, id:%d, numOfCols:%d, arraySize:%d", id, numOfCols, (int32_t)taosArrayGetSize(pDataBlock)); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } SColumnInfoData *pColInfo = taosArrayGet(pDataBlock, id); @@ -4018,14 +4024,14 @@ int32_t filterInitFromNode(SNode *pNode, SFilterInfo **pInfo, uint32_t options) int32_t code = 0; if (pNode == NULL || pInfo == NULL) { fltError("invalid param"); - FLT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + FLT_ERR_RET(TSDB_CODE_APP_ERROR); } if (*pInfo == NULL) { *pInfo = taosMemoryCalloc(1, sizeof(SFilterInfo)); if (NULL == *pInfo) { fltError("taosMemoryCalloc %d failed", (int32_t)sizeof(SFilterInfo)); - FLT_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + FLT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } } diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index 55f33b7a3e..e3436c83c1 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -83,7 +83,7 @@ int32_t sclExtendResRows(SScalarParam *pDst, SScalarParam *pSrc, SArray *pBlockL SScalarParam *pLeft = taosMemoryCalloc(1, sizeof(SScalarParam)); if (NULL == pLeft) { sclError("calloc %d failed", (int32_t)sizeof(SScalarParam)); - SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } pLeft->numOfRows = pb->info.rows; @@ -104,7 +104,7 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { SHashObj *pObj = taosHashInit(256, taosGetDefaultHashFunction(type), true, false); if (NULL == pObj) { sclError("taosHashInit failed, size:%d", 256); - SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } taosHashSetEqualFp(pObj, taosGetDefaultEqualFunction(type)); @@ -162,13 +162,10 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { if (taosHashPut(pObj, buf, (size_t)len, NULL, 0)) { sclError("taosHashPut to set failed"); - SCL_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCL_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } - colDataDestroy(out.columnData); - taosMemoryFreeClear(out.columnData); - out.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData)); - + colInfoDataCleanup(out.columnData, out.numOfRows); cell = cell->pNext; } @@ -224,7 +221,7 @@ int32_t sclCopyValueNodeValue(SValueNode *pNode, void **res) { *res = taosMemoryMalloc(pNode->node.resType.bytes); if (NULL == (*res)) { sclError("malloc %d failed", pNode->node.resType.bytes); - SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } memcpy(*res, nodesGetValueFromNode(pNode), pNode->node.resType.bytes); @@ -362,7 +359,7 @@ int32_t sclInitParam(SNode *node, SScalarParam *param, SScalarCtx *ctx, int32_t taosHashCleanup(param->pHashFilter); param->pHashFilter = NULL; sclError("taosHashPut nodeList failed, size:%d", (int32_t)sizeof(*param)); - return TSDB_CODE_QRY_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; } param->colAlloced = false; break; @@ -370,7 +367,7 @@ int32_t sclInitParam(SNode *node, SScalarParam *param, SScalarCtx *ctx, int32_t case QUERY_NODE_COLUMN: { if (NULL == ctx->pBlockList) { sclError("invalid node type for constant calculating, type:%d, src:%p", nodeType(node), ctx->pBlockList); - SCL_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + SCL_ERR_RET(TSDB_CODE_APP_ERROR); } SColumnNode *ref = (SColumnNode *)node; @@ -417,7 +414,7 @@ int32_t sclInitParam(SNode *node, SScalarParam *param, SScalarCtx *ctx, int32_t SScalarParam *res = (SScalarParam *)taosHashGet(ctx->pRes, &node, POINTER_BYTES); if (NULL == res) { sclError("no result for node, type:%d, node:%p", nodeType(node), node); - SCL_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + SCL_ERR_RET(TSDB_CODE_APP_ERROR); } *param = *res; param->colAlloced = false; @@ -459,7 +456,7 @@ int32_t sclInitParamList(SScalarParam **pParams, SNodeList *pParamList, SScalarC SScalarParam *paramList = taosMemoryCalloc(*paramNum, sizeof(SScalarParam)); if (NULL == paramList) { sclError("calloc %d failed", (int32_t)((*paramNum) * sizeof(SScalarParam))); - SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } if (pParamList) { @@ -548,7 +545,7 @@ int32_t sclInitOperatorParams(SScalarParam **pParams, SOperatorNode *node, SScal SScalarParam *paramList = taosMemoryCalloc(paramNum, sizeof(SScalarParam)); if (NULL == paramList) { sclError("calloc %d failed", (int32_t)(paramNum * sizeof(SScalarParam))); - SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } sclSetOperatorValueType(node, ctx); @@ -987,7 +984,7 @@ EDealRes sclRewriteNullInOptr(SNode **pNode, SScalarCtx *ctx, EOperatorType opTy SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE); if (NULL == res) { sclError("make value node failed"); - ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + ctx->code = TSDB_CODE_OUT_OF_MEMORY; return DEAL_RES_ERROR; } @@ -999,7 +996,7 @@ EDealRes sclRewriteNullInOptr(SNode **pNode, SScalarCtx *ctx, EOperatorType opTy SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE); if (NULL == res) { sclError("make value node failed"); - ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + ctx->code = TSDB_CODE_OUT_OF_MEMORY; return DEAL_RES_ERROR; } @@ -1126,7 +1123,7 @@ EDealRes sclRewriteFunction(SNode **pNode, SScalarCtx *ctx) { if (NULL == res) { sclError("make value node failed"); sclFreeParam(&output); - ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + ctx->code = TSDB_CODE_OUT_OF_MEMORY; return DEAL_RES_ERROR; } @@ -1178,7 +1175,7 @@ EDealRes sclRewriteLogic(SNode **pNode, SScalarCtx *ctx) { if (NULL == res) { sclError("make value node failed"); sclFreeParam(&output); - ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + ctx->code = TSDB_CODE_OUT_OF_MEMORY; return DEAL_RES_ERROR; } @@ -1218,7 +1215,7 @@ EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) { if (NULL == res) { sclError("make value node failed"); sclFreeParam(&output); - ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + ctx->code = TSDB_CODE_OUT_OF_MEMORY; return DEAL_RES_ERROR; } @@ -1270,7 +1267,7 @@ EDealRes sclRewriteCaseWhen(SNode **pNode, SScalarCtx *ctx) { if (NULL == res) { sclError("make value node failed"); sclFreeParam(&output); - ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + ctx->code = TSDB_CODE_OUT_OF_MEMORY; return DEAL_RES_ERROR; } @@ -1329,7 +1326,7 @@ EDealRes sclWalkFunction(SNode *pNode, SScalarCtx *ctx) { } if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) { - ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + ctx->code = TSDB_CODE_OUT_OF_MEMORY; return DEAL_RES_ERROR; } @@ -1346,7 +1343,7 @@ EDealRes sclWalkLogic(SNode *pNode, SScalarCtx *ctx) { } if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) { - ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + ctx->code = TSDB_CODE_OUT_OF_MEMORY; return DEAL_RES_ERROR; } @@ -1364,7 +1361,7 @@ EDealRes sclWalkOperator(SNode *pNode, SScalarCtx *ctx) { } if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) { - ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + ctx->code = TSDB_CODE_OUT_OF_MEMORY; return DEAL_RES_ERROR; } @@ -1412,7 +1409,7 @@ EDealRes sclWalkTarget(SNode *pNode, SScalarCtx *ctx) { SScalarParam *res = (SScalarParam *)taosHashGet(ctx->pRes, (void *)&target->pExpr, POINTER_BYTES); if (NULL == res) { sclError("no valid res in hash, node:%p, type:%d", target->pExpr, nodeType(target->pExpr)); - ctx->code = TSDB_CODE_QRY_APP_ERROR; + ctx->code = TSDB_CODE_APP_ERROR; return DEAL_RES_ERROR; } @@ -1434,7 +1431,7 @@ EDealRes sclWalkCaseWhen(SNode *pNode, SScalarCtx *ctx) { } if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) { - ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + ctx->code = TSDB_CODE_OUT_OF_MEMORY; return DEAL_RES_ERROR; } @@ -1485,7 +1482,7 @@ int32_t sclCalcConstants(SNode *pNode, bool dual, SNode **pRes) { ctx.pRes = taosHashInit(SCL_DEFAULT_OP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); if (NULL == ctx.pRes) { sclError("taosHashInit failed, num:%d", SCL_DEFAULT_OP_NUM); - SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } nodesRewriteExprPostOrder(&pNode, sclConstantsRewriter, (void *)&ctx); @@ -1603,7 +1600,7 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) { ctx.pRes = taosHashInit(SCL_DEFAULT_OP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); if (NULL == ctx.pRes) { sclError("taosHashInit failed, num:%d", SCL_DEFAULT_OP_NUM); - SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } nodesWalkExprPostOrder(pNode, sclCalcWalker, (void *)&ctx); @@ -1613,7 +1610,7 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) { SScalarParam *res = (SScalarParam *)taosHashGet(ctx.pRes, (void *)&pNode, POINTER_BYTES); if (NULL == res) { sclError("no valid res in hash, node:%p, type:%d", pNode, nodeType(pNode)); - SCL_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + SCL_ERR_JRET(TSDB_CODE_APP_ERROR); } if (1 == res->numOfRows) { diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index c4ff5b2b01..a1995bdf50 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -395,7 +395,7 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) { func = varToTimestamp; } else { sclError("invalid convert outType:%d", pCtx->outType); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } pCtx->pOut->numOfRows = pCtx->pIn->numOfRows; @@ -440,7 +440,7 @@ int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t *overflow) { if (len < 0) { sclError("castConvert taosUcs4ToMbs error 1"); taosMemoryFreeClear(tmp); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } tmp[len] = 0; @@ -642,7 +642,7 @@ int32_t vectorConvertToVarData(SSclVectorConvCtx *pCtx) { } } else { sclError("not supported input type:%d", pCtx->inType); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } return TSDB_CODE_SUCCESS; @@ -859,7 +859,7 @@ int32_t vectorConvertSingleColImpl(const SScalarParam *pIn, SScalarParam *pOut, } default: sclError("invalid convert output type:%d", cCtx.outType); - return TSDB_CODE_QRY_APP_ERROR; + return TSDB_CODE_APP_ERROR; } return TSDB_CODE_SUCCESS; @@ -1543,9 +1543,44 @@ void vectorBitOr(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t doVectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t startIndex, int32_t numOfRows, int32_t step, __compar_fn_t fp, int32_t optr) { int32_t num = 0; - bool * pRes = (bool *)pOut->columnData->pData; + bool *pRes = (bool *)pOut->columnData->pData; - if (GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_JSON || GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_JSON) { + if (IS_MATHABLE_TYPE(GET_PARAM_TYPE(pLeft)) && IS_MATHABLE_TYPE(GET_PARAM_TYPE(pRight))) { + if (!(pLeft->columnData->hasNull || pRight->columnData->hasNull)) { + for (int32_t i = startIndex; i < numOfRows && i >= 0; i += step) { + int32_t leftIndex = (i >= pLeft->numOfRows) ? 0 : i; + int32_t rightIndex = (i >= pRight->numOfRows) ? 0 : i; + + char *pLeftData = colDataGetData(pLeft->columnData, leftIndex); + char *pRightData = colDataGetData(pRight->columnData, rightIndex); + + pRes[i] = filterDoCompare(fp, optr, pLeftData, pRightData); + if (pRes[i]) { + ++num; + } + } + } else { + for (int32_t i = startIndex; i < numOfRows && i >= 0; i += step) { + int32_t leftIndex = (i >= pLeft->numOfRows) ? 0 : i; + int32_t rightIndex = (i >= pRight->numOfRows) ? 0 : i; + + if (colDataIsNull_f(pLeft->columnData->nullbitmap, leftIndex) || + colDataIsNull_f(pRight->columnData->nullbitmap, rightIndex)) { + pRes[i] = false; + continue; + } + + char *pLeftData = colDataGetData(pLeft->columnData, leftIndex); + char *pRightData = colDataGetData(pRight->columnData, rightIndex); + + pRes[i] = filterDoCompare(fp, optr, pLeftData, pRightData); + if (pRes[i]) { + ++num; + } + } + } + } else { + // if (GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_JSON || GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_JSON) { for (int32_t i = startIndex; i < numOfRows && i >= startIndex; i += step) { int32_t leftIndex = (i >= pLeft->numOfRows) ? 0 : i; int32_t rightIndex = (i >= pRight->numOfRows) ? 0 : i; @@ -1556,8 +1591,8 @@ int32_t doVectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarPa continue; } - char * pLeftData = colDataGetData(pLeft->columnData, leftIndex); - char * pRightData = colDataGetData(pRight->columnData, rightIndex); + char *pLeftData = colDataGetData(pLeft->columnData, leftIndex); + char *pRightData = colDataGetData(pRight->columnData, rightIndex); int64_t leftOut = 0; int64_t rightOut = 0; bool freeLeft = false; @@ -1592,25 +1627,6 @@ int32_t doVectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarPa taosMemoryFreeClear(pRightData); } } - } else { - for (int32_t i = startIndex; i < numOfRows && i >= 0; i += step) { - int32_t leftIndex = (i >= pLeft->numOfRows) ? 0 : i; - int32_t rightIndex = (i >= pRight->numOfRows) ? 0 : i; - - if (colDataIsNull_s(pLeft->columnData, leftIndex) || - colDataIsNull_s(pRight->columnData, rightIndex)) { - pRes[i] = false; - continue; - } - - char *pLeftData = colDataGetData(pLeft->columnData, leftIndex); - char *pRightData = colDataGetData(pRight->columnData, rightIndex); - - pRes[i] = filterDoCompare(fp, optr, pLeftData, pRightData); - if (pRes[i]) { - ++num; - } - } } return num; @@ -1766,7 +1782,7 @@ void vectorIsTrue(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, if (colDataIsNull_s(pOut->columnData, i)) { int8_t v = 0; colDataAppendInt8(pOut->columnData, i, &v); - colDataSetNotNull_f(pOut->columnData->nullbitmap, i); + colDataClearNull_f(pOut->columnData->nullbitmap, i); } } pOut->columnData->hasNull = false; diff --git a/source/libs/scheduler/inc/schInt.h b/source/libs/scheduler/inc/schInt.h index dfc48e7d9f..77aafa9a27 100644 --- a/source/libs/scheduler/inc/schInt.h +++ b/source/libs/scheduler/inc/schInt.h @@ -297,7 +297,7 @@ typedef struct SSchJob { SExecResult execRes; void *fetchRes; // TODO free it or not bool fetched; - int32_t resNumOfRows; + int64_t resNumOfRows; // from int32_t to int64_t SSchResInfo userRes; char *sql; SQueryProfileSummary summary; diff --git a/source/libs/scheduler/src/schFlowCtrl.c b/source/libs/scheduler/src/schFlowCtrl.c index 8980d08e89..5e4fe4b8a1 100644 --- a/source/libs/scheduler/src/schFlowCtrl.c +++ b/source/libs/scheduler/src/schFlowCtrl.c @@ -63,7 +63,7 @@ int32_t schChkJobNeedFlowCtrl(SSchJob *pJob, SSchLevel *pLevel) { taosHashInit(pJob->taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); if (NULL == pJob->flowCtrl) { SCH_JOB_ELOG("taosHashInit %d flowCtrl failed", pJob->taskNum); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } SCH_SET_JOB_NEED_FLOW_CTRL(pJob); @@ -122,7 +122,7 @@ int32_t schCheckIncTaskFlowQuota(SSchJob *pJob, SSchTask *pTask, bool *enough) { } SCH_TASK_ELOG("taosHashPut flowCtrl failed, size:%d", (int32_t)sizeof(nctrl)); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } SCH_TASK_DLOG("task quota added, fqdn:%s, port:%d, tableNum:%d, remainNum:%d, remainExecTaskNum:%d", ep->fqdn, @@ -156,13 +156,13 @@ int32_t schCheckIncTaskFlowQuota(SSchJob *pJob, SSchTask *pTask, bool *enough) { ctrl->taskList = taosArrayInit(pLevel->taskNum, POINTER_BYTES); if (NULL == ctrl->taskList) { SCH_TASK_ELOG("taosArrayInit taskList failed, size:%d", (int32_t)pLevel->taskNum); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } } if (NULL == taosArrayPush(ctrl->taskList, &pTask)) { SCH_TASK_ELOG("taosArrayPush to taskList failed, size:%d", (int32_t)taosArrayGetSize(ctrl->taskList)); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } *enough = false; diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index 0eb29a3667..2d41cc287c 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -89,34 +89,34 @@ int32_t schUpdateJobStatus(SSchJob *pJob, int8_t newStatus) { switch (oriStatus) { case JOB_TASK_STATUS_NULL: if (newStatus != JOB_TASK_STATUS_INIT) { - SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + SCH_ERR_JRET(TSDB_CODE_APP_ERROR); } break; case JOB_TASK_STATUS_INIT: if (newStatus != JOB_TASK_STATUS_EXEC && newStatus != JOB_TASK_STATUS_DROP) { - SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + SCH_ERR_JRET(TSDB_CODE_APP_ERROR); } break; case JOB_TASK_STATUS_EXEC: if (newStatus != JOB_TASK_STATUS_PART_SUCC && newStatus != JOB_TASK_STATUS_FAIL && newStatus != JOB_TASK_STATUS_DROP) { - SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + SCH_ERR_JRET(TSDB_CODE_APP_ERROR); } break; case JOB_TASK_STATUS_PART_SUCC: if (newStatus != JOB_TASK_STATUS_FAIL && newStatus != JOB_TASK_STATUS_SUCC && newStatus != JOB_TASK_STATUS_DROP && newStatus != JOB_TASK_STATUS_EXEC) { - SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + SCH_ERR_JRET(TSDB_CODE_APP_ERROR); } break; case JOB_TASK_STATUS_SUCC: case JOB_TASK_STATUS_FAIL: if (newStatus != JOB_TASK_STATUS_DROP) { - SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + SCH_ERR_JRET(TSDB_CODE_APP_ERROR); } break; @@ -125,7 +125,7 @@ int32_t schUpdateJobStatus(SSchJob *pJob, int8_t newStatus) { default: SCH_JOB_ELOG("invalid job status:%s", jobTaskStatusStr(oriStatus)); - SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); + SCH_ERR_JRET(TSDB_CODE_APP_ERROR); } if (oriStatus != atomic_val_compare_exchange_8(&pJob->status, oriStatus, newStatus)) { @@ -168,7 +168,7 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { pTask->children = taosArrayInit(childNum, POINTER_BYTES); if (NULL == pTask->children) { SCH_TASK_ELOG("taosArrayInit %d children failed", childNum); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } } @@ -182,7 +182,7 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { if (NULL == taosArrayPush(pTask->children, childTask)) { SCH_TASK_ELOG("taosArrayPush childTask failed, level:%d, taskIdx:%d, childIdx:%d", i, m, n); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } SCH_TASK_DLOG("children info, the %d child TID 0x%" PRIx64, n, (*childTask)->taskId); @@ -197,7 +197,7 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { pTask->parents = taosArrayInit(parentNum, POINTER_BYTES); if (NULL == pTask->parents) { SCH_TASK_ELOG("taosArrayInit %d parents failed", parentNum); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } } else { if (0 != pLevel->level) { @@ -216,7 +216,7 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { if (NULL == taosArrayPush(pTask->parents, parentTask)) { SCH_TASK_ELOG("taosArrayPush parentTask failed, level:%d, taskIdx:%d, childIdx:%d", i, m, n); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } SCH_TASK_DLOG("parents info, the %d parent TID 0x%" PRIx64, n, (*parentTask)->taskId); @@ -278,13 +278,13 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { HASH_NO_LOCK); if (NULL == planToTask) { SCH_JOB_ELOG("taosHashInit %d failed", SCHEDULE_DEFAULT_MAX_TASK_NUM); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } pJob->levels = taosArrayInit(levelNum, sizeof(SSchLevel)); if (NULL == pJob->levels) { SCH_JOB_ELOG("taosArrayInit %d failed", levelNum); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } pJob->levelNum = levelNum; @@ -300,7 +300,7 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { for (int32_t i = 0; i < levelNum; ++i) { if (NULL == taosArrayPush(pJob->levels, &level)) { SCH_JOB_ELOG("taosArrayPush level failed, level:%d", i); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } pLevel = taosArrayGet(pJob->levels, i); @@ -323,7 +323,7 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { pLevel->subTasks = taosArrayInit(taskNum, sizeof(SSchTask)); if (NULL == pLevel->subTasks) { SCH_JOB_ELOG("taosArrayInit %d failed", taskNum); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } for (int32_t n = 0; n < taskNum; ++n) { @@ -335,7 +335,7 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { SSchTask *pTask = taosArrayPush(pLevel->subTasks, &task); if (NULL == pTask) { SCH_TASK_ELOG("taosArrayPush task to level failed, level:%d, taskIdx:%d", pLevel->level, n); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } SCH_ERR_JRET(schInitTask(pJob, pTask, plan, pLevel)); @@ -344,12 +344,12 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { if (0 != taosHashPut(planToTask, &plan, POINTER_BYTES, &pTask, POINTER_BYTES)) { SCH_TASK_ELOG("taosHashPut to planToTaks failed, taskIdx:%d", n); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } if (0 != taosHashPut(pJob->taskList, &pTask->taskId, sizeof(pTask->taskId), &pTask, POINTER_BYTES)) { SCH_TASK_ELOG("taosHashPut to taskList failed, taskIdx:%d", n); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } ++pJob->taskNum; @@ -412,7 +412,7 @@ int32_t schDumpJobFetchRes(SSchJob *pJob, void **pData) { SCH_JOB_DLOG("empty res and set query complete, code:%x", code); } - SCH_JOB_DLOG("fetch done, totalRows:%d", pJob->resNumOfRows); + SCH_JOB_DLOG("fetch done, totalRows:%" PRId64, pJob->resNumOfRows); _return: @@ -526,9 +526,9 @@ int32_t schProcessOnJobPartialSuccess(SSchJob *pJob) { void schProcessOnDataFetched(SSchJob *pJob) { schPostJobRes(pJob, SCH_OP_FETCH); } int32_t schProcessOnExplainDone(SSchJob *pJob, SSchTask *pTask, SRetrieveTableRsp *pRsp) { - SCH_TASK_DLOG("got explain rsp, rows:%d, complete:%d", htonl(pRsp->numOfRows), pRsp->completed); + SCH_TASK_DLOG("got explain rsp, rows:%" PRId64 ", complete:%d", htobe64(pRsp->numOfRows), pRsp->completed); - atomic_store_32(&pJob->resNumOfRows, htonl(pRsp->numOfRows)); + atomic_store_64(&pJob->resNumOfRows, htobe64(pRsp->numOfRows)); atomic_store_ptr(&pJob->fetchRes, pRsp); SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_SUCC); @@ -702,7 +702,7 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) { SSchJob *pJob = taosMemoryCalloc(1, sizeof(SSchJob)); if (NULL == pJob) { qError("QID:0x%" PRIx64 " calloc %d failed", pReq->pDag->queryId, (int32_t)sizeof(SSchJob)); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } pJob->attr.explainMode = pReq->pDag->explainInfo.mode; @@ -728,7 +728,7 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) { HASH_ENTRY_LOCK); if (NULL == pJob->taskList) { SCH_JOB_ELOG("taosHashInit %d taskList failed", pReq->pDag->numOfSubplans); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } SCH_ERR_JRET(schValidateAndBuildJob(pReq->pDag, pJob)); @@ -741,7 +741,7 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) { HASH_ENTRY_LOCK); if (NULL == pJob->execTasks) { SCH_JOB_ELOG("taosHashInit %d execTasks failed", pReq->pDag->numOfSubplans); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } tsem_init(&pJob->rspSem, 0, 0); @@ -865,8 +865,8 @@ int32_t schProcessOnOpBegin(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq *pReq if (SCH_OP_NULL != atomic_val_compare_exchange_32(&pJob->opStatus.op, SCH_OP_NULL, type)) { SCH_JOB_ELOG("job already in %s operation", schGetOpStr(pJob->opStatus.op)); SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock); - schDirectPostJobRes(pReq, TSDB_CODE_TSC_APP_ERROR); - SCH_ERR_RET(TSDB_CODE_TSC_APP_ERROR); + schDirectPostJobRes(pReq, TSDB_CODE_APP_ERROR); + SCH_ERR_RET(TSDB_CODE_APP_ERROR); } SCH_JOB_DLOG("job start %s operation", schGetOpStr(pJob->opStatus.op)); @@ -879,8 +879,8 @@ int32_t schProcessOnOpBegin(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq *pReq if (SCH_OP_NULL != atomic_val_compare_exchange_32(&pJob->opStatus.op, SCH_OP_NULL, type)) { SCH_JOB_ELOG("job already in %s operation", schGetOpStr(pJob->opStatus.op)); SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock); - schDirectPostJobRes(pReq, TSDB_CODE_TSC_APP_ERROR); - SCH_ERR_RET(TSDB_CODE_TSC_APP_ERROR); + schDirectPostJobRes(pReq, TSDB_CODE_APP_ERROR); + SCH_ERR_RET(TSDB_CODE_APP_ERROR); } SCH_JOB_DLOG("job start %s operation", schGetOpStr(pJob->opStatus.op)); @@ -894,7 +894,7 @@ int32_t schProcessOnOpBegin(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq *pReq if (!SCH_JOB_NEED_FETCH(pJob)) { SCH_JOB_ELOG("no need to fetch data, status:%s", SCH_GET_JOB_STATUS_STR(pJob)); - SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + SCH_ERR_RET(TSDB_CODE_APP_ERROR); } if (status != JOB_TASK_STATUS_PART_SUCC) { @@ -911,7 +911,7 @@ int32_t schProcessOnOpBegin(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq *pReq return TSDB_CODE_SUCCESS; default: SCH_JOB_ELOG("unknown operation type %d", type); - SCH_ERR_RET(TSDB_CODE_TSC_APP_ERROR); + SCH_ERR_RET(TSDB_CODE_APP_ERROR); } if (schJobNeedToStop(pJob, &status)) { diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index 1a6d7df349..560ce0bdc3 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -108,13 +108,13 @@ int32_t schProcessFetchRsp(SSchJob *pJob, SSchTask *pTask, char *msg, int32_t rs } atomic_store_ptr(&pJob->fetchRes, rsp); - atomic_add_fetch_32(&pJob->resNumOfRows, htonl(rsp->numOfRows)); + atomic_add_fetch_64(&pJob->resNumOfRows, htobe64(rsp->numOfRows)); if (rsp->completed) { SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_SUCC); } - SCH_TASK_DLOG("got fetch rsp, rows:%d, complete:%d", htonl(rsp->numOfRows), rsp->completed); + SCH_TASK_DLOG("got fetch rsp, rows:%" PRId64 ", complete:%d", htobe64(rsp->numOfRows), rsp->completed); msg = NULL; schProcessOnDataFetched(pJob); @@ -279,7 +279,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa } } - atomic_add_fetch_32(&pJob->resNumOfRows, rsp->affectedRows); + atomic_add_fetch_64(&pJob->resNumOfRows, rsp->affectedRows); SCH_TASK_DLOG("submit succeed, affectedRows:%d, blocks:%d", rsp->affectedRows, rsp->nBlocks); SCH_LOCK(SCH_WRITE, &pJob->resLock); @@ -317,7 +317,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa tDecodeSVDeleteRsp(&coder, &rsp); tDecoderClear(&coder); - atomic_add_fetch_32(&pJob->resNumOfRows, rsp.affectedRows); + atomic_add_fetch_64(&pJob->resNumOfRows, rsp.affectedRows); SCH_TASK_DLOG("delete succeed, affectedRows:%" PRId64, rsp.affectedRows); } @@ -344,7 +344,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa SCH_ERR_JRET(schSaveJobExecRes(pJob, &rsp)); - atomic_add_fetch_32(&pJob->resNumOfRows, rsp.affectedRows); + atomic_add_fetch_64(&pJob->resNumOfRows, rsp.affectedRows); taosMemoryFreeClear(msg); @@ -371,7 +371,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDa SExplainRsp rsp = {0}; if (tDeserializeSExplainRsp(msg, msgSize, &rsp)) { tFreeSExplainRsp(&rsp); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } SCH_ERR_JRET(schProcessExplainRsp(pJob, pTask, &rsp)); @@ -506,7 +506,7 @@ int32_t schMakeCallbackParam(SSchJob *pJob, SSchTask *pTask, int32_t msgType, bo SSchTaskCallbackParam *param = taosMemoryCalloc(1, sizeof(SSchTaskCallbackParam)); if (NULL == param) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SSchTaskCallbackParam)); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } param->queryId = pJob->queryId; @@ -523,7 +523,7 @@ int32_t schMakeCallbackParam(SSchJob *pJob, SSchTask *pTask, int32_t msgType, bo SSchHbCallbackParam *param = taosMemoryCalloc(1, sizeof(SSchHbCallbackParam)); if (NULL == param) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SSchHbCallbackParam)); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } param->head.isHbParam = true; @@ -543,7 +543,7 @@ int32_t schMakeCallbackParam(SSchJob *pJob, SSchTask *pTask, int32_t msgType, bo SSchTaskCallbackParam *param = taosMemoryCalloc(1, sizeof(SSchTaskCallbackParam)); if (NULL == param) { qError("calloc SSchTaskCallbackParam failed"); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } param->pTrans = trans->pTrans; @@ -558,7 +558,7 @@ int32_t schGenerateCallBackInfo(SSchJob *pJob, SSchTask *pTask, void *msg, uint3 SMsgSendInfo *msgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == msgSendInfo) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SMsgSendInfo)); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } msgSendInfo->paramFreeFp = taosMemoryFree; @@ -621,7 +621,7 @@ int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp) { break; default: qError("unknown msg type for callback, msgType:%d", msgType); - SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + SCH_ERR_RET(TSDB_CODE_APP_ERROR); } return TSDB_CODE_SUCCESS; @@ -632,7 +632,7 @@ int32_t schMakeHbCallbackParam(SSchJob *pJob, SSchTask *pTask, void **pParam) { SSchHbCallbackParam *param = taosMemoryCalloc(1, sizeof(SSchHbCallbackParam)); if (NULL == param) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SSchHbCallbackParam)); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } param->head.isHbParam = true; @@ -662,7 +662,7 @@ int32_t schCloneHbRpcCtx(SRpcCtx *pSrc, SRpcCtx *pDst) { pDst->args = taosHashInit(1, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_ENTRY_LOCK); if (NULL == pDst->args) { qError("taosHashInit %d RpcCtx failed", 1); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } SRpcCtxVal dst = {0}; @@ -679,7 +679,7 @@ int32_t schCloneHbRpcCtx(SRpcCtx *pSrc, SRpcCtx *pDst) { if (taosHashPut(pDst->args, msgType, sizeof(*msgType), &dst, sizeof(dst))) { qError("taosHashPut msg %d to rpcCtx failed", *msgType); (*pSrc->freeFunc)(dst.val); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } pIter = taosHashIterate(pSrc->args, pIter); @@ -706,19 +706,19 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { pCtx->args = taosHashInit(1, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_ENTRY_LOCK); if (NULL == pCtx->args) { SCH_TASK_ELOG("taosHashInit %d RpcCtx failed", 1); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); if (NULL == pMsgSendInfo) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SMsgSendInfo)); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } param = taosMemoryCalloc(1, sizeof(SSchHbCallbackParam)); if (NULL == param) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SSchHbCallbackParam)); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } int32_t msgType = TDMT_SCH_QUERY_HEARTBEAT_RSP; @@ -735,7 +735,7 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { SRpcCtxVal ctxVal = {.val = pMsgSendInfo, .clone = schCloneSMsgSendInfo}; if (taosHashPut(pCtx->args, &msgType, sizeof(msgType), &ctxVal, sizeof(ctxVal))) { SCH_TASK_ELOG("taosHashPut msg %d to rpcCtx failed", msgType); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } SCH_ERR_JRET(schMakeBrokenLinkVal(pJob, pTask, &pCtx->brokenVal, true)); @@ -780,7 +780,7 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { pCtx->args = taosHashInit(1, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_ENTRY_LOCK); if (NULL == pCtx->args) { SCH_TASK_ELOG("taosHashInit %d RpcCtx failed", 1); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } SSchTrans trans = {.pTrans = pJob->conn.pTrans, .pHandle = SCH_GET_TASK_HANDLE(pTask)}; @@ -790,7 +790,7 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { SRpcCtxVal ctxVal = {.val = pExplainMsgSendInfo, .clone = schCloneSMsgSendInfo}; if (taosHashPut(pCtx->args, &msgType, sizeof(msgType), &ctxVal, sizeof(ctxVal))) { SCH_TASK_ELOG("taosHashPut msg %d to rpcCtx failed", msgType); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } SCH_ERR_JRET(schMakeBrokenLinkVal(pJob, pTask, &pCtx->brokenVal, false)); @@ -815,7 +815,7 @@ int32_t schCloneCallbackParam(SSchCallbackParamHeader *pSrc, SSchCallbackParamHe SSchHbCallbackParam *dst = taosMemoryMalloc(sizeof(SSchHbCallbackParam)); if (NULL == dst) { qError("malloc SSchHbCallbackParam failed"); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } memcpy(dst, pSrc, sizeof(*dst)); @@ -827,7 +827,7 @@ int32_t schCloneCallbackParam(SSchCallbackParamHeader *pSrc, SSchCallbackParamHe SSchTaskCallbackParam *dst = taosMemoryMalloc(sizeof(SSchTaskCallbackParam)); if (NULL == dst) { qError("malloc SSchTaskCallbackParam failed"); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } memcpy(dst, pSrc, sizeof(*dst)); @@ -842,7 +842,7 @@ int32_t schCloneSMsgSendInfo(void *src, void **dst) { SMsgSendInfo *pDst = taosMemoryMalloc(sizeof(*pSrc)); if (NULL == pDst) { qError("malloc SMsgSendInfo for rpcCtx failed, len:%d", (int32_t)sizeof(*pSrc)); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } memcpy(pDst, pSrc, sizeof(*pSrc)); @@ -959,17 +959,17 @@ int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId, SArray *taskAction) { int32_t msgSize = tSerializeSSchedulerHbReq(NULL, 0, &req); if (msgSize < 0) { qError("tSerializeSSchedulerHbReq hbReq failed, size:%d", msgSize); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } void *msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { qError("calloc hb req %d failed", msgSize); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } if (tSerializeSSchedulerHbReq(msg, msgSize, &req) < 0) { qError("tSerializeSSchedulerHbReq hbReq failed, size:%d", msgSize); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } int64_t transporterId = 0; @@ -1016,7 +1016,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } memcpy(msg, pTask->msg, msgSize); @@ -1037,7 +1037,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } tSerializeSVDeleteReq(msg, msgSize, &req); @@ -1067,19 +1067,19 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msgSize = tSerializeSSubQueryMsg(NULL, 0, &qMsg); if (msgSize < 0) { SCH_TASK_ELOG("tSerializeSSubQueryMsg get size, msgSize:%d", msgSize); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } if (tSerializeSSubQueryMsg(msg, msgSize, &qMsg) < 0) { SCH_TASK_ELOG("tSerializeSSubQueryMsg failed, msgSize:%d", msgSize); taosMemoryFree(msg); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } persistHandle = true; @@ -1098,18 +1098,18 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msgSize = tSerializeSResFetchReq(NULL, 0, &req); if (msgSize < 0) { SCH_TASK_ELOG("tSerializeSResFetchReq get size, msgSize:%d", msgSize); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } if (tSerializeSResFetchReq(msg, msgSize, &req) < 0) { SCH_TASK_ELOG("tSerializeSResFetchReq %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } break; } @@ -1126,19 +1126,19 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msgSize = tSerializeSTaskDropReq(NULL, 0, &qMsg); if (msgSize < 0) { SCH_TASK_ELOG("tSerializeSTaskDropReq get size, msgSize:%d", msgSize); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } if (tSerializeSTaskDropReq(msg, msgSize, &qMsg) < 0) { SCH_TASK_ELOG("tSerializeSTaskDropReq failed, msgSize:%d", msgSize); taosMemoryFree(msg); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } break; } @@ -1154,16 +1154,16 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, msgSize = tSerializeSSchedulerHbReq(NULL, 0, &req); if (msgSize < 0) { SCH_JOB_ELOG("tSerializeSSchedulerHbReq hbReq failed, size:%d", msgSize); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } msg = taosMemoryCalloc(1, msgSize); if (NULL == msg) { SCH_JOB_ELOG("calloc %d failed", msgSize); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } if (tSerializeSSchedulerHbReq(msg, msgSize, &req) < 0) { SCH_JOB_ELOG("tSerializeSSchedulerHbReq hbReq failed, size:%d", msgSize); - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } persistHandle = true; diff --git a/source/libs/scheduler/src/schTask.c b/source/libs/scheduler/src/schTask.c index 9a7f3332b3..0f15002d9b 100644 --- a/source/libs/scheduler/src/schTask.c +++ b/source/libs/scheduler/src/schTask.c @@ -73,7 +73,7 @@ int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel * taosHashInit(pTask->maxExecTimes, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); pTask->profile.execTime = taosArrayInit(pTask->maxExecTimes, sizeof(int64_t)); if (NULL == pTask->execNodes || NULL == pTask->profile.execTime) { - SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_INIT); @@ -112,7 +112,7 @@ int32_t schAppendTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *ad if (taosHashPut(pTask->execNodes, &execId, sizeof(execId), &nodeInfo, sizeof(nodeInfo))) { SCH_TASK_ELOG("taosHashPut nodeInfo to execNodes failed, errno:%d", errno); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } SCH_TASK_DLOG("task execNode added, execId:%d, handle:%p", execId, nodeInfo.handle); @@ -391,6 +391,8 @@ int32_t schChkUpdateRedirectCtx(SSchJob *pJob, SSchTask *pTask, SEpSet *pEpSet) int64_t leftTime = tsMaxRetryWaitTime - lastTime; pTask->delayExecMs = leftTime < pCtx->periodMs ? leftTime : pCtx->periodMs; + pCtx->roundTimes = 0; + goto _return; } @@ -407,7 +409,7 @@ _return: int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode) { int32_t code = 0; - SCH_TASK_DLOG("task will be redirected now, status:%s", SCH_GET_TASK_STATUS_STR(pTask)); + SCH_TASK_DLOG("task will be redirected now, status:%s, code:%s", SCH_GET_TASK_STATUS_STR(pTask), tstrerror(rspCode)); if (NULL == pData) { pTask->retryTimes = 0; @@ -430,15 +432,15 @@ int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32 if (SCH_IS_DATA_BIND_TASK(pTask)) { if (pData && pData->pEpSet) { SCH_ERR_JRET(schUpdateTaskCandidateAddr(pJob, pTask, pData->pEpSet)); - } else if (SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(rspCode)) { + } else if (SYNC_SELF_LEADER_REDIRECT_ERROR(rspCode)) { + SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx); + SEp *pEp = &addr->epSet.eps[addr->epSet.inUse]; + SCH_TASK_DLOG("task retry node %d current ep, idx:%d/%d,%s:%d, code:%s", addr->nodeId, addr->epSet.inUse, + addr->epSet.numOfEps, pEp->fqdn, pEp->port, tstrerror(rspCode)); + } else { SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx); SCH_SWITCH_EPSET(addr); SCH_TASK_DLOG("switch task target node %d epset to %d/%d", addr->nodeId, addr->epSet.inUse, addr->epSet.numOfEps); - } else { - SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx); - SEp *pEp = &addr->epSet.eps[addr->epSet.inUse]; - SCH_TASK_DLOG("task retry node %d current ep, idx:%d/%d,%s:%d", addr->nodeId, addr->epSet.inUse, - addr->epSet.numOfEps, pEp->fqdn, pEp->port); } if (SCH_TASK_NEED_FLOW_CTRL(pJob, pTask)) { @@ -528,7 +530,7 @@ int32_t schPushTaskToExecList(SSchJob *pJob, SSchTask *pTask) { } SCH_TASK_ELOG("taosHashPut task to execTask list failed, errno:%d", errno); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } SCH_TASK_DLOG("task added to execTask list, numOfTasks:%d", taosHashGetSize(pJob->execTasks)); @@ -553,7 +555,7 @@ int32_t schMoveTaskToSuccList(SSchJob *pJob, SSchTask *pTask, bool *moved) { } SCH_TASK_ELOG("taosHashPut task to succTask list failed, errno:%d", errno); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } *moved = true; @@ -580,7 +582,7 @@ int32_t schMoveTaskToFailList(SSchJob *pJob, SSchTask *pTask, bool *moved) { } SCH_TASK_ELOG("taosHashPut task to failTask list failed, errno:%d", errno); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } *moved = true; @@ -605,7 +607,7 @@ int32_t schMoveTaskToExecList(SSchJob *pJob, SSchTask *pTask, bool *moved) { } SCH_TASK_ELOG("taosHashPut task to execTask list failed, errno:%d", errno); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } *moved = true; @@ -710,7 +712,7 @@ int32_t schSetAddrsFromNodeList(SSchJob *pJob, SSchTask *pTask) { if (NULL == taosArrayPush(pTask->candidateAddrs, naddr)) { SCH_TASK_ELOG("taosArrayPush execNode to candidate addrs failed, addNum:%d, errno:%d", addNum, errno); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } SCH_TASK_TLOG("set %dth candidate addr, id %d, inUse:%d/%d, fqdn:%s, port:%d", i, naddr->nodeId, @@ -738,13 +740,13 @@ int32_t schSetTaskCandidateAddrs(SSchJob *pJob, SSchTask *pTask) { pTask->candidateAddrs = taosArrayInit(SCHEDULE_DEFAULT_MAX_NODE_NUM, sizeof(SQueryNodeAddr)); if (NULL == pTask->candidateAddrs) { SCH_TASK_ELOG("taosArrayInit %d condidate addrs failed", SCHEDULE_DEFAULT_MAX_NODE_NUM); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } if (pTask->plan->execNode.epSet.numOfEps > 0) { if (NULL == taosArrayPush(pTask->candidateAddrs, &pTask->plan->execNode)) { SCH_TASK_ELOG("taosArrayPush execNode to candidate addrs failed, errno:%d", errno); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } SCH_TASK_DLOG("use execNode in plan as candidate addr, numOfEps:%d", pTask->plan->execNode.epSet.numOfEps); @@ -754,7 +756,7 @@ int32_t schSetTaskCandidateAddrs(SSchJob *pJob, SSchTask *pTask) { if (SCH_IS_DATA_BIND_TASK(pTask)) { SCH_TASK_ELOG("no execNode specifed for data src task, numOfEps:%d", pTask->plan->execNode.epSet.numOfEps); - SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + SCH_ERR_RET(TSDB_CODE_APP_ERROR); } SCH_ERR_RET(schSetAddrsFromNodeList(pJob, pTask)); @@ -1171,7 +1173,7 @@ int32_t schDelayLaunchTask(SSchJob *pJob, SSchTask *pTask) { SSchTimerParam *param = taosMemoryMalloc(sizeof(SSchTimerParam)); if (NULL == param) { SCH_TASK_ELOG("taosMemoryMalloc %d failed", (int)sizeof(SSchTimerParam)); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } param->rId = pJob->refId; @@ -1182,7 +1184,7 @@ int32_t schDelayLaunchTask(SSchJob *pJob, SSchTask *pTask) { pTask->delayTimer = taosTmrStart(schHandleTimerEvent, pTask->delayExecMs, (void *)param, schMgmt.timer); if (NULL == pTask->delayTimer) { SCH_TASK_ELOG("start delay timer failed, handle:%p", schMgmt.timer); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } return TSDB_CODE_SUCCESS; diff --git a/source/libs/scheduler/src/schUtil.c b/source/libs/scheduler/src/schUtil.c index a5a15cd1c6..0582184730 100644 --- a/source/libs/scheduler/src/schUtil.c +++ b/source/libs/scheduler/src/schUtil.c @@ -235,7 +235,7 @@ int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchTrans *trans) { if (NULL == hb) { SCH_UNLOCK(SCH_READ, &schMgmt.hbLock); qError("taosHashGet hb connection failed, nodeId:%d, fqdn:%s, port:%d", epId->nodeId, epId->ep.fqdn, epId->ep.port); - SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + SCH_ERR_RET(TSDB_CODE_APP_ERROR); } SCH_LOCK(SCH_WRITE, &hb->lock); diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 91c3b5d7a1..1926c26dc9 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -39,19 +39,19 @@ int32_t schedulerInit() { schMgmt.jobRef = taosOpenRef(schMgmt.cfg.maxJobNum, schFreeJobImpl); if (schMgmt.jobRef < 0) { qError("init schduler jobRef failed, num:%u", schMgmt.cfg.maxJobNum); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } schMgmt.hbConnections = taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); if (NULL == schMgmt.hbConnections) { qError("taosHashInit hb connections failed"); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } schMgmt.timer = taosTmrInit(0, 0, 0, "scheduler"); if (NULL == schMgmt.timer) { qError("init timer failed, error:%s", tstrerror(terrno)); - SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } if (taosGetSystemUUID((char *)&schMgmt.sId, sizeof(schMgmt.sId))) { diff --git a/source/libs/stream/inc/streamInc.h b/source/libs/stream/inc/streamInc.h index 5ff49502df..66496f11f8 100644 --- a/source/libs/stream/inc/streamInc.h +++ b/source/libs/stream/inc/streamInc.h @@ -17,7 +17,6 @@ #define _STREAM_INC_H_ #include "executor.h" -#include "tref.h" #include "tstream.h" #ifdef __cplusplus @@ -25,9 +24,8 @@ extern "C" { #endif typedef struct { - int8_t inited; - int32_t refPool; - void* timer; + int8_t inited; + void* timer; } SStreamGlobalEnv; static SStreamGlobalEnv streamEnv; diff --git a/source/libs/stream/src/streamCheckpoint.c b/source/libs/stream/src/streamCheckpoint.c new file mode 100644 index 0000000000..efd19074da --- /dev/null +++ b/source/libs/stream/src/streamCheckpoint.c @@ -0,0 +1,194 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "streamInc.h" + +int32_t tEncodeSStreamCheckpointSourceReq(SEncoder* pEncoder, const SStreamCheckpointSourceReq* pReq) { + if (tStartEncode(pEncoder) < 0) return -1; + if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1; + if (tEncodeI64(pEncoder, pReq->checkpointId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->taskId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->nodeId) < 0) return -1; + if (tEncodeI64(pEncoder, pReq->expireTime) < 0) return -1; + tEndEncode(pEncoder); + return pEncoder->pos; +} + +int32_t tDecodeSStreamCheckpointSourceReq(SDecoder* pDecoder, SStreamCheckpointSourceReq* pReq) { + if (tStartDecode(pDecoder) < 0) return -1; + if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1; + if (tDecodeI64(pDecoder, &pReq->checkpointId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->taskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->nodeId) < 0) return -1; + if (tDecodeI64(pDecoder, &pReq->expireTime) < 0) return -1; + tEndDecode(pDecoder); + return 0; +} + +int32_t tEncodeSStreamCheckpointSourceRsp(SEncoder* pEncoder, const SStreamCheckpointSourceRsp* pRsp) { + if (tStartEncode(pEncoder) < 0) return -1; + if (tEncodeI64(pEncoder, pRsp->streamId) < 0) return -1; + if (tEncodeI64(pEncoder, pRsp->checkpointId) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->taskId) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->nodeId) < 0) return -1; + if (tEncodeI64(pEncoder, pRsp->expireTime) < 0) return -1; + tEndEncode(pEncoder); + return pEncoder->pos; +} + +int32_t tDecodeSStreamCheckpointSourceRsp(SDecoder* pDecoder, SStreamCheckpointSourceRsp* pRsp) { + if (tStartDecode(pDecoder) < 0) return -1; + if (tDecodeI64(pDecoder, &pRsp->streamId) < 0) return -1; + if (tDecodeI64(pDecoder, &pRsp->checkpointId) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->taskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->nodeId) < 0) return -1; + if (tDecodeI64(pDecoder, &pRsp->expireTime) < 0) return -1; + tEndDecode(pDecoder); + return 0; +} + +int32_t tEncodeSStreamCheckpointReq(SEncoder* pEncoder, const SStreamCheckpointReq* pReq) { + if (tStartEncode(pEncoder) < 0) return -1; + if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1; + if (tEncodeI64(pEncoder, pReq->checkpointId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->downstreamTaskId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->downstreamNodeId) < 0) return -1; + if (tEncodeI64(pEncoder, pReq->upstreamTaskId) < 0) return -1; + if (tEncodeI64(pEncoder, pReq->upstreamNodeId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->childId) < 0) return -1; + if (tEncodeI64(pEncoder, pReq->expireTime) < 0) return -1; + if (tEncodeI8(pEncoder, pReq->taskLevel) < 0) return -1; + tEndEncode(pEncoder); + return pEncoder->pos; +} + +int32_t tDecodeSStreamCheckpointReq(SDecoder* pDecoder, SStreamCheckpointReq* pReq) { + if (tStartDecode(pDecoder) < 0) return -1; + if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1; + if (tDecodeI64(pDecoder, &pReq->checkpointId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->downstreamTaskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->downstreamNodeId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->upstreamTaskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->upstreamNodeId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->childId) < 0) return -1; + if (tDecodeI64(pDecoder, &pReq->expireTime) < 0) return -1; + if (tDecodeI8(pDecoder, &pReq->taskLevel) < 0) return -1; + tEndDecode(pDecoder); + return 0; +} + +int32_t tEncodeSStreamCheckpointRsp(SEncoder* pEncoder, const SStreamCheckpointRsp* pRsp) { + if (tStartEncode(pEncoder) < 0) return -1; + if (tEncodeI64(pEncoder, pRsp->streamId) < 0) return -1; + if (tEncodeI64(pEncoder, pRsp->checkpointId) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->downstreamTaskId) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->downstreamNodeId) < 0) return -1; + if (tEncodeI64(pEncoder, pRsp->upstreamTaskId) < 0) return -1; + if (tEncodeI64(pEncoder, pRsp->upstreamNodeId) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->childId) < 0) return -1; + if (tEncodeI64(pEncoder, pRsp->expireTime) < 0) return -1; + if (tEncodeI8(pEncoder, pRsp->taskLevel) < 0) return -1; + tEndEncode(pEncoder); + return pEncoder->pos; +} + +int32_t tDecodeSStreamCheckpointRsp(SDecoder* pDecoder, SStreamCheckpointRsp* pRsp) { + if (tStartDecode(pDecoder) < 0) return -1; + if (tDecodeI64(pDecoder, &pRsp->streamId) < 0) return -1; + if (tDecodeI64(pDecoder, &pRsp->checkpointId) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->downstreamTaskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->downstreamNodeId) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->upstreamTaskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->upstreamNodeId) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->childId) < 0) return -1; + if (tDecodeI64(pDecoder, &pRsp->expireTime) < 0) return -1; + if (tDecodeI8(pDecoder, &pRsp->taskLevel) < 0) return -1; + tEndDecode(pDecoder); + return 0; +} + +static int32_t streamAlignCheckpoint(SStreamTask* pTask, int64_t checkpointId, int32_t childId) { + if (pTask->checkpointingId == 0) { + pTask->checkpointingId = checkpointId; + pTask->checkpointAlignCnt = taosArrayGetSize(pTask->childEpInfo); + } + + ASSERT(pTask->checkpointingId == checkpointId); + + return atomic_sub_fetch_32(&pTask->checkpointAlignCnt, 1); +} + +static int32_t streamDoCheckpoint(SStreamMeta* pMeta, SStreamTask* pTask, int64_t checkpointId) { + // commit tdb state + streamStateCommit(pTask->pState); + // commit non-tdb state + // copy and save new state + // report to mnode + // send checkpoint req to downstream + return 0; +} + +static int32_t streamDoSourceCheckpoint(SStreamMeta* pMeta, SStreamTask* pTask, int64_t checkpointId) { + // ref wal + // set status checkpointing + // do checkpoint + return 0; +} +int32_t streamProcessCheckpointSourceReq(SStreamMeta* pMeta, SStreamTask* pTask, SStreamCheckpointSourceReq* pReq) { + int32_t code; + int64_t checkpointId = pReq->checkpointId; + + code = streamDoSourceCheckpoint(pMeta, pTask, checkpointId); + if (code < 0) { + // rsp error + return -1; + } + + return 0; +} + +int32_t streamProcessCheckpointReq(SStreamMeta* pMeta, SStreamTask* pTask, SStreamCheckpointReq* pReq) { + int32_t code; + int64_t checkpointId = pReq->checkpointId; + int32_t childId = pReq->childId; + + if (taosArrayGetSize(pTask->childEpInfo) > 0) { + code = streamAlignCheckpoint(pTask, checkpointId, childId); + if (code > 0) { + return 0; + } + if (code < 0) { + ASSERT(0); + return -1; + } + } + + code = streamDoCheckpoint(pMeta, pTask, checkpointId); + if (code < 0) { + // rsp error + return -1; + } + + // send rsp to all children + + return 0; +} + +int32_t streamProcessCheckpointRsp(SStreamMeta* pMeta, SStreamTask* pTask, SStreamCheckpointRsp* pRsp) { + // recover step2, scan from wal + // unref wal + // set status normal + return 0; +} diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 2c36c299ee..4e0b0630bc 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -112,7 +112,7 @@ int32_t streamBroadcastToChildren(SStreamTask* pTask, const SSDataBlock* pBlock) pRetrieve->compressed = 0; pRetrieve->completed = 1; pRetrieve->streamBlockType = pBlock->info.type; - pRetrieve->numOfRows = htonl(pBlock->info.rows); + pRetrieve->numOfRows = htobe64((int64_t)pBlock->info.rows); pRetrieve->numOfCols = htonl(numOfCols); pRetrieve->skey = htobe64(pBlock->info.window.skey); pRetrieve->ekey = htobe64(pBlock->info.window.ekey); @@ -189,7 +189,7 @@ static int32_t streamAddBlockToDispatchMsg(const SSDataBlock* pBlock, SStreamDis pRetrieve->compressed = 0; pRetrieve->completed = 1; pRetrieve->streamBlockType = pBlock->info.type; - pRetrieve->numOfRows = htonl(pBlock->info.rows); + pRetrieve->numOfRows = htobe64((int64_t)pBlock->info.rows); pRetrieve->skey = htobe64(pBlock->info.window.skey); pRetrieve->ekey = htobe64(pBlock->info.window.ekey); pRetrieve->version = htobe64(pBlock->info.version); diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index a864814a74..afad78c5e5 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -69,8 +69,8 @@ _err: } void streamMetaClose(SStreamMeta* pMeta) { - tdbCommit(pMeta->db, &pMeta->txn); - tdbPostCommit(pMeta->db, &pMeta->txn); + tdbCommit(pMeta->db, pMeta->txn); + tdbPostCommit(pMeta->db, pMeta->txn); tdbTbClose(pMeta->pTaskDb); tdbTbClose(pMeta->pCheckpointDb); tdbClose(pMeta->db); @@ -115,7 +115,7 @@ int32_t streamMetaAddSerializedTask(SStreamMeta* pMeta, int64_t ver, char* msg, goto FAIL; } - if (tdbTbUpsert(pMeta->pTaskDb, &pTask->taskId, sizeof(int32_t), msg, msgLen, &pMeta->txn) < 0) { + if (tdbTbUpsert(pMeta->pTaskDb, &pTask->taskId, sizeof(int32_t), msg, msgLen, pMeta->txn) < 0) { taosHashRemove(pMeta->pTasks, &pTask->taskId, sizeof(int32_t)); ASSERT(0); goto FAIL; @@ -152,7 +152,7 @@ int32_t streamMetaAddTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTask) { tEncodeSStreamTask(&encoder, pTask); tEncoderClear(&encoder); - if (tdbTbUpsert(pMeta->pTaskDb, &pTask->taskId, sizeof(int32_t), buf, len, &pMeta->txn) < 0) { + if (tdbTbUpsert(pMeta->pTaskDb, &pTask->taskId, sizeof(int32_t), buf, len, pMeta->txn) < 0) { ASSERT(0); return -1; } @@ -202,7 +202,7 @@ void streamMetaReleaseTask(SStreamMeta* pMeta, SStreamTask* pTask) { } } -void streamMetaRemoveTask1(SStreamMeta* pMeta, int32_t taskId) { +void streamMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId) { SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasks, &taskId, sizeof(int32_t)); if (ppTask) { SStreamTask* pTask = *ppTask; @@ -219,72 +219,36 @@ void streamMetaRemoveTask1(SStreamMeta* pMeta, int32_t taskId) { } } -int32_t streamMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId) { - SStreamTask** ppTask = (SStreamTask**)taosHashGet(pMeta->pTasks, &taskId, sizeof(int32_t)); - if (ppTask) { - SStreamTask* pTask = *ppTask; - taosHashRemove(pMeta->pTasks, &taskId, sizeof(int32_t)); - atomic_store_8(&pTask->taskStatus, TASK_STATUS__DROPPING); - - if (tdbTbDelete(pMeta->pTaskDb, &taskId, sizeof(int32_t), &pMeta->txn) < 0) { - /*return -1;*/ - } - - if (pTask->triggerParam != 0) { - taosTmrStop(pTask->timer); - } - - while (1) { - int8_t schedStatus = - atomic_val_compare_exchange_8(&pTask->schedStatus, TASK_SCHED_STATUS__INACTIVE, TASK_SCHED_STATUS__DROPPING); - if (schedStatus != TASK_SCHED_STATUS__ACTIVE) { - tFreeSStreamTask(pTask); - break; - } - taosMsleep(10); - } - } - - return 0; -} - int32_t streamMetaBegin(SStreamMeta* pMeta) { - if (tdbTxnOpen(&pMeta->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < - 0) { - return -1; - } - - if (tdbBegin(pMeta->db, &pMeta->txn) < 0) { + if (tdbBegin(pMeta->db, &pMeta->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, + TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { return -1; } return 0; } int32_t streamMetaCommit(SStreamMeta* pMeta) { - if (tdbCommit(pMeta->db, &pMeta->txn) < 0) { + if (tdbCommit(pMeta->db, pMeta->txn) < 0) { return -1; } - memset(&pMeta->txn, 0, sizeof(TXN)); - if (tdbTxnOpen(&pMeta->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < - 0) { + if (tdbPostCommit(pMeta->db, pMeta->txn) < 0) { return -1; } - if (tdbBegin(pMeta->db, &pMeta->txn) < 0) { + + if (tdbBegin(pMeta->db, &pMeta->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, + TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { return -1; } return 0; } int32_t streamMetaAbort(SStreamMeta* pMeta) { - if (tdbAbort(pMeta->db, &pMeta->txn) < 0) { + if (tdbAbort(pMeta->db, pMeta->txn) < 0) { return -1; } - memset(&pMeta->txn, 0, sizeof(TXN)); - if (tdbTxnOpen(&pMeta->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < - 0) { - return -1; - } - if (tdbBegin(pMeta->db, &pMeta->txn) < 0) { + + if (tdbBegin(pMeta->db, &pMeta->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, + TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { return -1; } return 0; diff --git a/source/libs/stream/src/streamRecover.c b/source/libs/stream/src/streamRecover.c index 7eee95a580..6889a870d1 100644 --- a/source/libs/stream/src/streamRecover.c +++ b/source/libs/stream/src/streamRecover.c @@ -325,46 +325,3 @@ int32_t tDecodeSStreamRecoverFinishReq(SDecoder* pDecoder, SStreamRecoverFinishR tEndDecode(pDecoder); return 0; } - -int32_t tEncodeSStreamCheckpointInfo(SEncoder* pEncoder, const SStreamCheckpointInfo* pCheckpoint) { - if (tEncodeI32(pEncoder, pCheckpoint->srcNodeId) < 0) return -1; - if (tEncodeI32(pEncoder, pCheckpoint->srcChildId) < 0) return -1; - if (tEncodeI64(pEncoder, pCheckpoint->stateProcessedVer) < 0) return -1; - return 0; -} - -int32_t tDecodeSStreamCheckpointInfo(SDecoder* pDecoder, SStreamCheckpointInfo* pCheckpoint) { - if (tDecodeI32(pDecoder, &pCheckpoint->srcNodeId) < 0) return -1; - if (tDecodeI32(pDecoder, &pCheckpoint->srcChildId) < 0) return -1; - if (tDecodeI64(pDecoder, &pCheckpoint->stateProcessedVer) < 0) return -1; - return 0; -} - -int32_t tEncodeSStreamMultiVgCheckpointInfo(SEncoder* pEncoder, const SStreamMultiVgCheckpointInfo* pCheckpoint) { - if (tEncodeI64(pEncoder, pCheckpoint->streamId) < 0) return -1; - if (tEncodeI64(pEncoder, pCheckpoint->checkTs) < 0) return -1; - if (tEncodeI32(pEncoder, pCheckpoint->checkpointId) < 0) return -1; - if (tEncodeI32(pEncoder, pCheckpoint->taskId) < 0) return -1; - int32_t sz = taosArrayGetSize(pCheckpoint->checkpointVer); - if (tEncodeI32(pEncoder, sz) < 0) return -1; - for (int32_t i = 0; i < sz; i++) { - SStreamCheckpointInfo* pOneVgCkpoint = taosArrayGet(pCheckpoint->checkpointVer, i); - if (tEncodeSStreamCheckpointInfo(pEncoder, pOneVgCkpoint) < 0) return -1; - } - return 0; -} - -int32_t tDecodeSStreamMultiVgCheckpointInfo(SDecoder* pDecoder, SStreamMultiVgCheckpointInfo* pCheckpoint) { - if (tDecodeI64(pDecoder, &pCheckpoint->streamId) < 0) return -1; - if (tDecodeI64(pDecoder, &pCheckpoint->checkTs) < 0) return -1; - if (tDecodeI32(pDecoder, &pCheckpoint->checkpointId) < 0) return -1; - if (tDecodeI32(pDecoder, &pCheckpoint->taskId) < 0) return -1; - int32_t sz; - if (tDecodeI32(pDecoder, &sz) < 0) return -1; - for (int32_t i = 0; i < sz; i++) { - SStreamCheckpointInfo oneVgCheckpoint; - if (tDecodeSStreamCheckpointInfo(pDecoder, &oneVgCheckpoint) < 0) return -1; - taosArrayPush(pCheckpoint->checkpointVer, &oneVgCheckpoint); - } - return 0; -} diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c index ea31347db5..af1d738de0 100644 --- a/source/libs/stream/src/streamState.c +++ b/source/libs/stream/src/streamState.c @@ -179,8 +179,8 @@ _err: } void streamStateClose(SStreamState* pState) { - tdbCommit(pState->pTdbState->db, &pState->pTdbState->txn); - tdbPostCommit(pState->pTdbState->db, &pState->pTdbState->txn); + tdbCommit(pState->pTdbState->db, pState->pTdbState->txn); + tdbPostCommit(pState->pTdbState->db, pState->pTdbState->txn); tdbTbClose(pState->pTdbState->pStateDb); tdbTbClose(pState->pTdbState->pFuncStateDb); tdbTbClose(pState->pTdbState->pFillStateDb); @@ -192,71 +192,61 @@ void streamStateClose(SStreamState* pState) { } int32_t streamStateBegin(SStreamState* pState) { - if (tdbTxnOpen(&pState->pTdbState->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, - TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { - return -1; - } - - if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn) < 0) { - tdbTxnClose(&pState->pTdbState->txn); + if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, + TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { + tdbAbort(pState->pTdbState->db, pState->pTdbState->txn); return -1; } return 0; } int32_t streamStateCommit(SStreamState* pState) { - if (tdbCommit(pState->pTdbState->db, &pState->pTdbState->txn) < 0) { + if (tdbCommit(pState->pTdbState->db, pState->pTdbState->txn) < 0) { return -1; } - if (tdbPostCommit(pState->pTdbState->db, &pState->pTdbState->txn) < 0) { + if (tdbPostCommit(pState->pTdbState->db, pState->pTdbState->txn) < 0) { return -1; } - memset(&pState->pTdbState->txn, 0, sizeof(TXN)); - if (tdbTxnOpen(&pState->pTdbState->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, - TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { - return -1; - } - if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn) < 0) { + + if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, + TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { return -1; } return 0; } int32_t streamStateAbort(SStreamState* pState) { - if (tdbAbort(pState->pTdbState->db, &pState->pTdbState->txn) < 0) { + if (tdbAbort(pState->pTdbState->db, pState->pTdbState->txn) < 0) { return -1; } - memset(&pState->pTdbState->txn, 0, sizeof(TXN)); - if (tdbTxnOpen(&pState->pTdbState->txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, - TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { - return -1; - } - if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn) < 0) { + + if (tdbBegin(pState->pTdbState->db, &pState->pTdbState->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, + TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { return -1; } return 0; } int32_t streamStateFuncPut(SStreamState* pState, const STupleKey* key, const void* value, int32_t vLen) { - return tdbTbUpsert(pState->pTdbState->pFuncStateDb, key, sizeof(STupleKey), value, vLen, &pState->pTdbState->txn); + return tdbTbUpsert(pState->pTdbState->pFuncStateDb, key, sizeof(STupleKey), value, vLen, pState->pTdbState->txn); } int32_t streamStateFuncGet(SStreamState* pState, const STupleKey* key, void** pVal, int32_t* pVLen) { return tdbTbGet(pState->pTdbState->pFuncStateDb, key, sizeof(STupleKey), pVal, pVLen); } int32_t streamStateFuncDel(SStreamState* pState, const STupleKey* key) { - return tdbTbDelete(pState->pTdbState->pFuncStateDb, key, sizeof(STupleKey), &pState->pTdbState->txn); + return tdbTbDelete(pState->pTdbState->pFuncStateDb, key, sizeof(STupleKey), pState->pTdbState->txn); } // todo refactor int32_t streamStatePut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen) { SStateKey sKey = {.key = *key, .opNum = pState->number}; - return tdbTbUpsert(pState->pTdbState->pStateDb, &sKey, sizeof(SStateKey), value, vLen, &pState->pTdbState->txn); + return tdbTbUpsert(pState->pTdbState->pStateDb, &sKey, sizeof(SStateKey), value, vLen, pState->pTdbState->txn); } // todo refactor int32_t streamStateFillPut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen) { - return tdbTbUpsert(pState->pTdbState->pFillStateDb, key, sizeof(SWinKey), value, vLen, &pState->pTdbState->txn); + return tdbTbUpsert(pState->pTdbState->pFillStateDb, key, sizeof(SWinKey), value, vLen, pState->pTdbState->txn); } // todo refactor @@ -273,7 +263,7 @@ int32_t streamStateFillGet(SStreamState* pState, const SWinKey* key, void** pVal // todo refactor int32_t streamStateDel(SStreamState* pState, const SWinKey* key) { SStateKey sKey = {.key = *key, .opNum = pState->number}; - return tdbTbDelete(pState->pTdbState->pStateDb, &sKey, sizeof(SStateKey), &pState->pTdbState->txn); + return tdbTbDelete(pState->pTdbState->pStateDb, &sKey, sizeof(SStateKey), pState->pTdbState->txn); } int32_t streamStateClear(SStreamState* pState) { @@ -297,7 +287,7 @@ void streamStateSetNumber(SStreamState* pState, int32_t number) { pState->number // todo refactor int32_t streamStateFillDel(SStreamState* pState, const SWinKey* key) { - return tdbTbDelete(pState->pTdbState->pFillStateDb, key, sizeof(SWinKey), &pState->pTdbState->txn); + return tdbTbDelete(pState->pTdbState->pFillStateDb, key, sizeof(SWinKey), pState->pTdbState->txn); } int32_t streamStateAddIfNotExist(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen) { @@ -531,7 +521,7 @@ void streamFreeVal(void* val) { tdbFree(val); } int32_t streamStateSessionPut(SStreamState* pState, const SSessionKey* key, const void* value, int32_t vLen) { SStateSessionKey sKey = {.key = *key, .opNum = pState->number}; return tdbTbUpsert(pState->pTdbState->pSessionStateDb, &sKey, sizeof(SStateSessionKey), value, vLen, - &pState->pTdbState->txn); + pState->pTdbState->txn); } int32_t streamStateSessionGet(SStreamState* pState, SSessionKey* key, void** pVal, int32_t* pVLen) { @@ -554,7 +544,7 @@ int32_t streamStateSessionGet(SStreamState* pState, SSessionKey* key, void** pVa int32_t streamStateSessionDel(SStreamState* pState, const SSessionKey* key) { SStateSessionKey sKey = {.key = *key, .opNum = pState->number}; - return tdbTbDelete(pState->pTdbState->pSessionStateDb, &sKey, sizeof(SStateSessionKey), &pState->pTdbState->txn); + return tdbTbDelete(pState->pTdbState->pSessionStateDb, &sKey, sizeof(SStateSessionKey), pState->pTdbState->txn); } SStreamStateCur* streamStateSessionSeekKeyCurrentPrev(SStreamState* pState, const SSessionKey* key) { @@ -833,7 +823,7 @@ _end: int32_t streamStatePutParName(SStreamState* pState, int64_t groupId, const char tbname[TSDB_TABLE_NAME_LEN]) { tdbTbUpsert(pState->pTdbState->pParNameDb, &groupId, sizeof(int64_t), tbname, TSDB_TABLE_NAME_LEN, - &pState->pTdbState->txn); + pState->pTdbState->txn); return 0; } diff --git a/source/libs/sync/inc/syncCommit.h b/source/libs/sync/inc/syncCommit.h index d3ba556f82..7d638a7336 100644 --- a/source/libs/sync/inc/syncCommit.h +++ b/source/libs/sync/inc/syncCommit.h @@ -47,8 +47,13 @@ extern "C" { // void syncOneReplicaAdvance(SSyncNode* pSyncNode); void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode); + bool syncAgreeIndex(SSyncNode* pSyncNode, SRaftId* pRaftId, SyncIndex index); bool syncAgree(SSyncNode* pSyncNode, SyncIndex index); +bool syncNodeAgreedUpon(SSyncNode* pNode, SyncIndex index); + +int64_t syncNodeUpdateCommitIndex(SSyncNode* ths, SyncIndex commitIndex); +int64_t syncNodeCheckCommitIndex(SSyncNode* ths, SyncIndex indexLikely); #ifdef __cplusplus } diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h index 145880fa3e..dee0bf95c7 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -50,6 +50,8 @@ typedef struct SyncPreSnapshotReply SyncPreSnapshotReply; typedef struct SyncHeartbeatReply SyncHeartbeatReply; typedef struct SyncHeartbeat SyncHeartbeat; typedef struct SyncPreSnapshot SyncPreSnapshot; +typedef struct SSyncLogBuffer SSyncLogBuffer; +typedef struct SSyncLogReplMgr SSyncLogReplMgr; typedef struct SRaftId { SyncNodeId addr; @@ -97,6 +99,7 @@ typedef struct SSyncNode { char configPath[TSDB_FILENAME_LEN * 2]; // sync io + SSyncLogBuffer* pLogBuf; SWal* pWal; const SMsgCb* msgcb; int32_t (*syncSendMSg)(const SEpSet* pEpSet, SRpcMsg* pMsg); @@ -179,6 +182,9 @@ typedef struct SSyncNode { SSyncSnapshotSender* senders[TSDB_MAX_REPLICA]; SSyncSnapshotReceiver* pNewNodeReceiver; + // log replication mgr + SSyncLogReplMgr* logReplMgrs[TSDB_MAX_REPLICA]; + SPeerState peerStates[TSDB_MAX_REPLICA]; // is config changing @@ -205,11 +211,12 @@ typedef struct SSyncNode { // open/close -------------- SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo); -void syncNodeStart(SSyncNode* pSyncNode); -void syncNodeStartStandBy(SSyncNode* pSyncNode); +int32_t syncNodeStart(SSyncNode* pSyncNode); +int32_t syncNodeStartStandBy(SSyncNode* pSyncNode); void syncNodeClose(SSyncNode* pSyncNode); void syncNodePreClose(SSyncNode* pSyncNode); int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak); +int32_t syncNodeRestore(SSyncNode* pSyncNode); void syncHbTimerDataFree(SSyncHbTimerData* pData); // on message --------------------- @@ -244,6 +251,7 @@ int32_t syncCacheEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry, LRUHa bool syncNodeHeartbeatReplyTimeout(SSyncNode* pSyncNode); bool syncNodeSnapshotSending(SSyncNode* pSyncNode); bool syncNodeSnapshotRecving(SSyncNode* pSyncNode); +bool syncNodeIsReadyForRead(SSyncNode* pSyncNode); // raft state change -------------- void syncNodeUpdateTerm(SSyncNode* pSyncNode, SyncTerm term); @@ -260,6 +268,9 @@ void syncNodeCandidate2Follower(SSyncNode* pSyncNode); void syncNodeVoteForTerm(SSyncNode* pSyncNode, SyncTerm term, SRaftId* pRaftId); void syncNodeVoteForSelf(SSyncNode* pSyncNode); +// log replication +SSyncLogReplMgr* syncNodeGetLogReplMgr(SSyncNode* pNode, SRaftId* pDestId); + // snapshot -------------- bool syncNodeHasSnapshot(SSyncNode* pSyncNode); void syncNodeMaybeUpdateCommitBySnapshot(SSyncNode* pSyncNode); diff --git a/source/libs/sync/inc/syncMessage.h b/source/libs/sync/inc/syncMessage.h index 6535f77fbe..cf63df371d 100644 --- a/source/libs/sync/inc/syncMessage.h +++ b/source/libs/sync/inc/syncMessage.h @@ -106,7 +106,7 @@ typedef struct SyncAppendEntriesReply { SRaftId destId; // private data SyncTerm term; - SyncTerm privateTerm; + SyncTerm lastMatchTerm; bool success; SyncIndex matchIndex; SyncIndex lastSendIndex; @@ -246,6 +246,8 @@ int32_t syncBuildRequestVote(SRpcMsg* pMsg, int32_t vgId); int32_t syncBuildRequestVoteReply(SRpcMsg* pMsg, int32_t vgId); int32_t syncBuildAppendEntries(SRpcMsg* pMsg, int32_t dataLen, int32_t vgId); int32_t syncBuildAppendEntriesReply(SRpcMsg* pMsg, int32_t vgId); +int32_t syncBuildAppendEntriesFromRaftLog(SSyncNode* pNode, SSyncRaftEntry* pEntry, SyncTerm prevLogTerm, + SRpcMsg* pRpcMsg); int32_t syncBuildHeartbeat(SRpcMsg* pMsg, int32_t vgId); int32_t syncBuildHeartbeatReply(SRpcMsg* pMsg, int32_t vgId); int32_t syncBuildPreSnapshot(SRpcMsg* pMsg, int32_t vgId); diff --git a/source/libs/sync/inc/syncPipeline.h b/source/libs/sync/inc/syncPipeline.h new file mode 100644 index 0000000000..8c7edf85ff --- /dev/null +++ b/source/libs/sync/inc/syncPipeline.h @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_LIBS_SYNC_PIPELINE_H +#define _TD_LIBS_SYNC_PIPELINE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "syncInt.h" + +typedef struct SSyncReplInfo { + bool barrier; + bool acked; + int64_t timeMs; + int64_t term; +} SSyncReplInfo; + +typedef struct SSyncLogReplMgr { + SSyncReplInfo states[TSDB_SYNC_LOG_BUFFER_SIZE]; + int64_t startIndex; + int64_t matchIndex; + int64_t endIndex; + int64_t size; + bool restored; + int64_t peerStartTime; + int32_t retryBackoff; + int32_t peerId; +} SSyncLogReplMgr; + +typedef struct SSyncLogBufEntry { + SSyncRaftEntry* pItem; + SyncIndex prevLogIndex; + SyncTerm prevLogTerm; +} SSyncLogBufEntry; + +typedef struct SSyncLogBuffer { + SSyncLogBufEntry entries[TSDB_SYNC_LOG_BUFFER_SIZE]; + int64_t startIndex; + int64_t commitIndex; + int64_t matchIndex; + int64_t endIndex; + int64_t size; + TdThreadMutex mutex; + TdThreadMutexAttr attr; +} SSyncLogBuffer; + +// SSyncLogRepMgr +SSyncLogReplMgr* syncLogReplMgrCreate(); +void syncLogReplMgrDestroy(SSyncLogReplMgr* pMgr); +int32_t syncLogReplMgrReset(SSyncLogReplMgr* pMgr); + +int32_t syncNodeLogReplMgrInit(SSyncNode* pNode); +void syncNodeLogReplMgrDestroy(SSyncNode* pNode); + +// access +static FORCE_INLINE int64_t syncLogGetRetryBackoffTimeMs(SSyncLogReplMgr* pMgr) { + return (1 << pMgr->retryBackoff) * SYNC_LOG_REPL_RETRY_WAIT_MS; +} + +static FORCE_INLINE int32_t syncLogGetNextRetryBackoff(SSyncLogReplMgr* pMgr) { + return TMIN(pMgr->retryBackoff + 1, SYNC_MAX_RETRY_BACKOFF); +} + +SyncTerm syncLogReplMgrGetPrevLogTerm(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index); + +int32_t syncLogReplMgrReplicateOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode); +int32_t syncLogBufferReplicateOneTo(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index, SyncTerm* pTerm, + SRaftId* pDestId, bool* pBarrier); +int32_t syncLogReplMgrReplicateAttemptedOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode); +int32_t syncLogReplMgrReplicateProbeOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index); + +int32_t syncLogReplMgrProcessReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg); +int32_t syncLogReplMgrProcessReplyInRecoveryMode(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg); +int32_t syncLogReplMgrProcessReplyInNormalMode(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg); + +int32_t syncLogReplMgrProcessHeartbeatReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncHeartbeatReply* pMsg); +int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode); + +// SSyncLogBuffer +SSyncLogBuffer* syncLogBufferCreate(); +void syncLogBufferDestroy(SSyncLogBuffer* pBuf); +int32_t syncLogBufferInit(SSyncLogBuffer* pBuf, SSyncNode* pNode); +int32_t syncLogBufferReInit(SSyncLogBuffer* pBuf, SSyncNode* pNode); + +// access +int64_t syncLogBufferGetEndIndex(SSyncLogBuffer* pBuf); +int32_t syncLogBufferAppend(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEntry* pEntry); +int32_t syncLogBufferAccept(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEntry* pEntry, SyncTerm prevTerm); +int64_t syncLogBufferProceed(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncTerm* pMatchTerm); +int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t commitIndex); +int32_t syncLogBufferReset(SSyncLogBuffer* pBuf, SSyncNode* pNode); + +// private +SSyncRaftEntry* syncLogBufferGetOneEntry(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncIndex index, bool* pInBuf); +int32_t syncLogBufferValidate(SSyncLogBuffer* pBuf); +int32_t syncLogBufferRollback(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncIndex toIndex); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_LIBS_SYNC_PIPELINE_H*/ diff --git a/source/libs/sync/inc/syncRaftEntry.h b/source/libs/sync/inc/syncRaftEntry.h index 2a73b95e4d..58944eb08c 100644 --- a/source/libs/sync/inc/syncRaftEntry.h +++ b/source/libs/sync/inc/syncRaftEntry.h @@ -42,9 +42,13 @@ SSyncRaftEntry* syncEntryBuildFromClientRequest(const SyncClientRequest* pMsg, S SSyncRaftEntry* syncEntryBuildFromRpcMsg(const SRpcMsg* pMsg, SyncTerm term, SyncIndex index); SSyncRaftEntry* syncEntryBuildFromAppendEntries(const SyncAppendEntries* pMsg); SSyncRaftEntry* syncEntryBuildNoop(SyncTerm term, SyncIndex index, int32_t vgId); -void syncEntryDestory(SSyncRaftEntry* pEntry); +void syncEntryDestroy(SSyncRaftEntry* pEntry); void syncEntry2OriginalRpc(const SSyncRaftEntry* pEntry, SRpcMsg* pRpcMsg); // step 7 +static FORCE_INLINE bool syncLogIsReplicationBarrier(SSyncRaftEntry* pEntry) { + return pEntry->originalRpcType == TDMT_SYNC_NOOP; +} + typedef struct SRaftEntryHashCache { SHashObj* pEntryHash; int32_t maxCount; diff --git a/source/libs/sync/inc/syncReplication.h b/source/libs/sync/inc/syncReplication.h index 7da610a9ed..f2e240344f 100644 --- a/source/libs/sync/inc/syncReplication.h +++ b/source/libs/sync/inc/syncReplication.h @@ -52,6 +52,10 @@ int32_t syncNodeSendHeartbeat(SSyncNode* pSyncNode, const SRaftId* pDestId, SRpc int32_t syncNodeReplicate(SSyncNode* pSyncNode); int32_t syncNodeReplicateOne(SSyncNode* pSyncNode, SRaftId* pDestId, bool snapshot); +int32_t syncNodeReplicateWithoutLock(SSyncNode* pNode); + +int32_t syncNodeSendAppendEntries(SSyncNode* pNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg); +int32_t syncNodeMaybeSendAppendEntries(SSyncNode* pNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg); #ifdef __cplusplus } diff --git a/source/libs/sync/inc/syncSnapshot.h b/source/libs/sync/inc/syncSnapshot.h index 7b8e768391..1f9675a3cd 100644 --- a/source/libs/sync/inc/syncSnapshot.h +++ b/source/libs/sync/inc/syncSnapshot.h @@ -87,6 +87,8 @@ void snapshotReceiverForceStop(SSyncSnapshotReceiver *pReceive int32_t syncNodeOnSnapshot(SSyncNode *ths, const SRpcMsg *pMsg); int32_t syncNodeOnSnapshotReply(SSyncNode *ths, const SRpcMsg *pMsg); +SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode *pSyncNode, SyncIndex snapshotLastApplyIndex); + // start #ifdef __cplusplus diff --git a/source/libs/sync/inc/syncUtil.h b/source/libs/sync/inc/syncUtil.h index ce6ff25c89..f198f3809d 100644 --- a/source/libs/sync/inc/syncUtil.h +++ b/source/libs/sync/inc/syncUtil.h @@ -94,11 +94,12 @@ void syncLogRecvLocalCmd(SSyncNode* pSyncNode, const SyncLocalCmd* pMsg, const c void syncLogSendAppendEntriesReply(SSyncNode* pSyncNode, const SyncAppendEntriesReply* pMsg, const char* s); void syncLogRecvAppendEntriesReply(SSyncNode* pSyncNode, const SyncAppendEntriesReply* pMsg, const char* s); -void syncLogSendHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, bool printX, int64_t timerElapsed, int64_t execTime); -void syncLogRecvHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, int64_t timeDiff); +void syncLogSendHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, bool printX, int64_t timerElapsed, + int64_t execTime); +void syncLogRecvHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, int64_t timeDiff, const char* s); void syncLogSendHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* pMsg, const char* s); -void syncLogRecvHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* pMsg, int64_t timeDiff); +void syncLogRecvHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* pMsg, int64_t timeDiff, const char* s); void syncLogSendSyncPreSnapshot(SSyncNode* pSyncNode, const SyncPreSnapshot* pMsg, const char* s); void syncLogRecvSyncPreSnapshot(SSyncNode* pSyncNode, const SyncPreSnapshot* pMsg, const char* s); diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index fbf096589d..1dc6905b88 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -15,10 +15,13 @@ #define _DEFAULT_SOURCE #include "syncAppendEntries.h" +#include "syncPipeline.h" #include "syncMessage.h" #include "syncRaftLog.h" #include "syncRaftStore.h" +#include "syncReplication.h" #include "syncUtil.h" +#include "syncCommit.h" // TLA+ Spec // HandleAppendEntriesRequest(i, j, m) == @@ -124,9 +127,113 @@ int32_t syncNodeFollowerCommit(SSyncNode* ths, SyncIndex newCommitIndex) { return 0; } +SSyncRaftEntry* syncLogAppendEntriesToRaftEntry(const SyncAppendEntries* pMsg) { + SSyncRaftEntry* pEntry = taosMemoryMalloc(pMsg->dataLen); + if (pEntry == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + (void)memcpy(pEntry, pMsg->data, pMsg->dataLen); + ASSERT(pEntry->bytes == pMsg->dataLen); + return pEntry; +} + int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) { SyncAppendEntries* pMsg = pRpcMsg->pCont; SRpcMsg rpcRsp = {0}; + bool accepted = false; + // if already drop replica, do not process + if (!syncNodeInRaftGroup(ths, &(pMsg->srcId))) { + syncLogRecvAppendEntries(ths, pMsg, "not in my config"); + goto _IGNORE; + } + + int32_t code = syncBuildAppendEntriesReply(&rpcRsp, ths->vgId); + if (code != 0) { + syncLogRecvAppendEntries(ths, pMsg, "build rsp error"); + goto _IGNORE; + } + + SyncAppendEntriesReply* pReply = rpcRsp.pCont; + // prepare response msg + pReply->srcId = ths->myRaftId; + pReply->destId = pMsg->srcId; + pReply->term = ths->pRaftStore->currentTerm; + pReply->success = false; + pReply->matchIndex = SYNC_INDEX_INVALID; + pReply->lastSendIndex = pMsg->prevLogIndex + 1; + pReply->startTime = ths->startTime; + + if (pMsg->term < ths->pRaftStore->currentTerm) { + goto _SEND_RESPONSE; + } + + if (pMsg->term > ths->pRaftStore->currentTerm) { + pReply->term = pMsg->term; + } + + syncNodeStepDown(ths, pMsg->term); + syncNodeResetElectTimer(ths); + + if (pMsg->dataLen < (int32_t)sizeof(SSyncRaftEntry)) { + sError("vgId:%d, incomplete append entries received. prev index:%" PRId64 ", term:%" PRId64 ", datalen:%d", + ths->vgId, pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->dataLen); + goto _IGNORE; + } + + SSyncRaftEntry* pEntry = syncLogAppendEntriesToRaftEntry(pMsg); + + if (pEntry == NULL) { + sError("vgId:%d, failed to get raft entry from append entries since %s", ths->vgId, terrstr()); + goto _IGNORE; + } + + if (pMsg->prevLogIndex + 1 != pEntry->index || pEntry->term < 0) { + sError("vgId:%d, invalid previous log index in msg. index:%" PRId64 ", term:%" PRId64 ", prevLogIndex:%" PRId64 + ", prevLogTerm:%" PRId64, + ths->vgId, pEntry->index, pEntry->term, pMsg->prevLogIndex, pMsg->prevLogTerm); + goto _IGNORE; + } + + sTrace("vgId:%d, recv append entries msg. index:%" PRId64 ", term:%" PRId64 ", preLogIndex:%" PRId64 + ", prevLogTerm:%" PRId64 " commitIndex:%" PRId64 "", + pMsg->vgId, pMsg->prevLogIndex + 1, pMsg->term, pMsg->prevLogIndex, pMsg->prevLogTerm, pMsg->commitIndex); + + // accept + if (syncLogBufferAccept(ths->pLogBuf, ths, pEntry, pMsg->prevLogTerm) < 0) { + goto _SEND_RESPONSE; + } + accepted = true; + +_SEND_RESPONSE: + pReply->matchIndex = syncLogBufferProceed(ths->pLogBuf, ths, &pReply->lastMatchTerm); + bool matched = (pReply->matchIndex >= pReply->lastSendIndex); + if (accepted && matched) { + pReply->success = true; + // update commit index only after matching + (void)syncNodeUpdateCommitIndex(ths, pMsg->commitIndex); + } + + // ack, i.e. send response + (void)syncNodeSendMsgById(&pReply->destId, ths, &rpcRsp); + + // commit index, i.e. leader notice me + if (syncLogBufferCommit(ths->pLogBuf, ths, ths->commitIndex) < 0) { + sError("vgId:%d, failed to commit raft fsm log since %s.", ths->vgId, terrstr()); + goto _out; + } + +_out: + return 0; + +_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))) { @@ -233,18 +340,20 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) { if (hLocal) { taosLRUCacheRelease(ths->pLogStore->pCache, hLocal, false); } else { - syncEntryDestory(pLocalEntry); + syncEntryDestroy(pLocalEntry); } if (hAppend) { taosLRUCacheRelease(ths->pLogStore->pCache, hAppend, false); } else { - syncEntryDestory(pAppendEntry); + syncEntryDestroy(pAppendEntry); } goto _IGNORE; } + ASSERT(pAppendEntry->index == appendIndex); + // append code = ths->pLogStore->syncLogAppendEntry(ths->pLogStore, pAppendEntry); if (code != 0) { @@ -255,13 +364,13 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) { if (hLocal) { taosLRUCacheRelease(ths->pLogStore->pCache, hLocal, false); } else { - syncEntryDestory(pLocalEntry); + syncEntryDestroy(pLocalEntry); } if (hAppend) { taosLRUCacheRelease(ths->pLogStore->pCache, hAppend, false); } else { - syncEntryDestory(pAppendEntry); + syncEntryDestroy(pAppendEntry); } goto _IGNORE; @@ -281,8 +390,8 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) { snprintf(logBuf, sizeof(logBuf), "ignore, log not exist, truncate error, append-index:%" PRId64, appendIndex); syncLogRecvAppendEntries(ths, pMsg, logBuf); - syncEntryDestory(pLocalEntry); - syncEntryDestory(pAppendEntry); + syncEntryDestroy(pLocalEntry); + syncEntryDestroy(pAppendEntry); goto _IGNORE; } @@ -296,13 +405,13 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) { if (hLocal) { taosLRUCacheRelease(ths->pLogStore->pCache, hLocal, false); } else { - syncEntryDestory(pLocalEntry); + syncEntryDestroy(pLocalEntry); } if (hAppend) { taosLRUCacheRelease(ths->pLogStore->pCache, hAppend, false); } else { - syncEntryDestory(pAppendEntry); + syncEntryDestroy(pAppendEntry); } goto _IGNORE; @@ -320,13 +429,13 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) { if (hLocal) { taosLRUCacheRelease(ths->pLogStore->pCache, hLocal, false); } else { - syncEntryDestory(pLocalEntry); + syncEntryDestroy(pLocalEntry); } if (hAppend) { taosLRUCacheRelease(ths->pLogStore->pCache, hAppend, false); } else { - syncEntryDestory(pAppendEntry); + syncEntryDestroy(pAppendEntry); } goto _IGNORE; @@ -339,13 +448,13 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) { if (hLocal) { taosLRUCacheRelease(ths->pLogStore->pCache, hLocal, false); } else { - syncEntryDestory(pLocalEntry); + syncEntryDestroy(pLocalEntry); } if (hAppend) { taosLRUCacheRelease(ths->pLogStore->pCache, hAppend, false); } else { - syncEntryDestory(pAppendEntry); + syncEntryDestroy(pAppendEntry); } } else { @@ -373,4 +482,4 @@ _SEND_RESPONSE: // send response syncNodeSendMsgById(&pReply->destId, ths, &rpcRsp); return 0; -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index c602788b19..524abf3c2a 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -17,7 +17,9 @@ #include "syncAppendEntriesReply.h" #include "syncCommit.h" #include "syncIndexMgr.h" +#include "syncPipeline.h" #include "syncMessage.h" +#include "syncRaftEntry.h" #include "syncRaftStore.h" #include "syncReplication.h" #include "syncSnapshot.h" @@ -38,8 +40,58 @@ // int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) { - int32_t ret = 0; SyncAppendEntriesReply* pMsg = pRpcMsg->pCont; + 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->pRaftStore->currentTerm) { + syncLogRecvAppendEntriesReply(ths, pMsg, "drop stale response"); + return 0; + } + + if (ths->state == TAOS_SYNC_STATE_LEADER) { + if (pMsg->term > ths->pRaftStore->currentTerm) { + syncLogRecvAppendEntriesReply(ths, pMsg, "error term"); + syncNodeStepDown(ths, pMsg->term); + return -1; + } + + ASSERT(pMsg->term == ths->pRaftStore->currentTerm); + + sTrace("vgId:%d received append entries reply. srcId:0x%016" PRIx64 ", term:%" PRId64 ", matchIndex:%" PRId64 "", + pMsg->vgId, pMsg->srcId.addr, pMsg->term, pMsg->matchIndex); + + if (pMsg->success) { + SyncIndex oldMatchIndex = syncIndexMgrGetIndex(ths->pMatchIndex, &(pMsg->srcId)); + if (pMsg->matchIndex > oldMatchIndex) { + syncIndexMgrSetIndex(ths->pMatchIndex, &(pMsg->srcId), pMsg->matchIndex); + } + + // commit if needed + SyncIndex indexLikely = TMIN(pMsg->matchIndex, ths->pLogBuf->matchIndex); + SyncIndex commitIndex = syncNodeCheckCommitIndex(ths, indexLikely); + (void)syncLogBufferCommit(ths->pLogBuf, ths, commitIndex); + } + + // replicate log + SSyncLogReplMgr* pMgr = syncNodeGetLogReplMgr(ths, &pMsg->srcId); + if (pMgr == NULL) { + sError("vgId:%d, failed to get log repl mgr for src addr: 0x%016" PRIx64, ths->vgId, pMsg->srcId.addr); + return -1; + } + (void)syncLogReplMgrProcessReply(pMgr, ths, pMsg); + } + 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))) { diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 7d77361b3c..07b1101256 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -84,6 +84,7 @@ void syncOneReplicaAdvance(SSyncNode* pSyncNode) { } void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { + ASSERT(false && "deprecated"); if (pSyncNode == NULL) { sError("pSyncNode is NULL"); return; @@ -138,7 +139,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { if (h) { taosLRUCacheRelease(pCache, h, false); } else { - syncEntryDestory(pEntry); + syncEntryDestroy(pEntry); } break; @@ -150,7 +151,7 @@ void syncMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { if (h) { taosLRUCacheRelease(pCache, h, false); } else { - syncEntryDestory(pEntry); + syncEntryDestroy(pEntry); } } } @@ -286,15 +287,48 @@ bool syncAgree(SSyncNode* pSyncNode, SyncIndex index) { } */ -bool syncAgree(SSyncNode* pSyncNode, SyncIndex index) { +bool syncNodeAgreedUpon(SSyncNode* pNode, SyncIndex index) { + int count = 0; + SSyncIndexMgr* pMatches = pNode->pMatchIndex; + ASSERT(pNode->replicaNum == pMatches->replicaNum); + + for (int i = 0; i < pNode->replicaNum; i++) { + SyncIndex matchIndex = pMatches->index[i]; + if (matchIndex >= index) { + count++; + } + } + + return count >= pNode->quorum; +} + +bool syncAgree(SSyncNode* pNode, SyncIndex index) { int agreeCount = 0; - for (int i = 0; i < pSyncNode->replicaNum; ++i) { - if (syncAgreeIndex(pSyncNode, &(pSyncNode->replicasId[i]), index)) { + for (int i = 0; i < pNode->replicaNum; ++i) { + if (syncAgreeIndex(pNode, &(pNode->replicasId[i]), index)) { ++agreeCount; } - if (agreeCount >= pSyncNode->quorum) { + if (agreeCount >= pNode->quorum) { return true; } } return false; } + +int64_t syncNodeUpdateCommitIndex(SSyncNode* ths, SyncIndex commitIndex) { + SyncIndex lastVer = ths->pLogStore->syncLogLastIndex(ths->pLogStore); + commitIndex = TMAX(commitIndex, ths->commitIndex); + ths->commitIndex = TMIN(commitIndex, lastVer); + ths->pLogStore->syncLogUpdateCommitIndex(ths->pLogStore, ths->commitIndex); + return ths->commitIndex; +} + +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, + ths->pRaftStore->currentTerm, commitIndex); + } + return ths->commitIndex; +} diff --git a/source/libs/sync/src/syncEnv.c b/source/libs/sync/src/syncEnv.c index 43685f6496..28ae8711a8 100644 --- a/source/libs/sync/src/syncEnv.c +++ b/source/libs/sync/src/syncEnv.c @@ -100,7 +100,9 @@ SSyncNode *syncNodeAcquire(int64_t rid) { return pNode; } -void syncNodeRelease(SSyncNode *pNode) { taosReleaseRef(gNodeRefId, pNode->rid); } +void syncNodeRelease(SSyncNode *pNode) { + if (pNode) taosReleaseRef(gNodeRefId, pNode->rid); +} int64_t syncHbTimerDataAdd(SSyncHbTimerData *pData) { pData->rid = taosAddRef(gHbDataRefId, pData); diff --git a/source/libs/sync/src/syncIndexMgr.c b/source/libs/sync/src/syncIndexMgr.c index 830e50fc4f..7933258e53 100644 --- a/source/libs/sync/src/syncIndexMgr.c +++ b/source/libs/sync/src/syncIndexMgr.c @@ -81,6 +81,15 @@ void syncIndexMgrSetIndex(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId, index); } +SSyncLogReplMgr *syncNodeGetLogReplMgr(SSyncNode *pNode, SRaftId *pDestId) { + for (int i = 0; i < pNode->replicaNum; i++) { + if (syncUtilSameId(&(pNode->replicasId[i]), pDestId)) { + return pNode->logReplMgrs[i]; + } + } + return NULL; +} + SyncIndex syncIndexMgrGetIndex(SSyncIndexMgr *pSyncIndexMgr, const SRaftId *pRaftId) { if (pSyncIndexMgr == NULL) { return SYNC_INDEX_INVALID; diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index b08bcfb6fc..a00b639a9c 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -23,6 +23,7 @@ #include "syncIndexMgr.h" #include "syncInt.h" #include "syncMessage.h" +#include "syncPipeline.h" #include "syncRaftCfg.h" #include "syncRaftLog.h" #include "syncRaftStore.h" @@ -34,6 +35,8 @@ #include "syncTimeout.h" #include "syncUtil.h" #include "syncVoteMgr.h" +#include "tglobal.h" +#include "tref.h" static void syncNodeEqPingTimer(void* param, void* tmrId); static void syncNodeEqElectTimer(void* param, void* tmrId); @@ -56,7 +59,6 @@ static int32_t syncNodeLeaderTransferTo(SSyncNode* pSyncNode, SNodeInfo newLeade static int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* pEntry); static ESyncStrategy syncNodeStrategy(SSyncNode* pSyncNode); -static SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode* pSyncNode, SyncIndex snapshotLastApplyIndex); int64_t syncOpen(SSyncInfo* pSyncInfo) { SSyncNode* pSyncNode = syncNodeOpen(pSyncInfo); @@ -80,12 +82,29 @@ int64_t syncOpen(SSyncInfo* pSyncInfo) { return pSyncNode->rid; } -void syncStart(int64_t rid) { +int32_t syncStart(int64_t rid) { SSyncNode* pSyncNode = syncNodeAcquire(rid); - if (pSyncNode != NULL) { - syncNodeStart(pSyncNode); - syncNodeRelease(pSyncNode); + if (pSyncNode == NULL) { + sError("failed to acquire rid: %" PRId64 " of tsNodeReftId for pSyncNode", rid); + return -1; } + + if (syncNodeRestore(pSyncNode) < 0) { + sError("vgId:%d, failed to restore sync log buffer since %s", pSyncNode->vgId, terrstr()); + goto _err; + } + + if (syncNodeStart(pSyncNode) < 0) { + sError("vgId:%d, failed to start sync node since %s", pSyncNode->vgId, terrstr()); + goto _err; + } + + syncNodeRelease(pSyncNode); + return 0; + +_err: + syncNodeRelease(pSyncNode); + return -1; } void syncStop(int64_t rid) { @@ -381,6 +400,69 @@ int32_t syncStepDown(int64_t rid, SyncTerm newTerm) { return 0; } +bool syncNodeIsReadyForRead(SSyncNode* pSyncNode) { + if (pSyncNode == NULL) { + terrno = TSDB_CODE_SYN_INTERNAL_ERROR; + sError("sync ready for read error"); + return false; + } + + if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { + terrno = TSDB_CODE_SYN_NOT_LEADER; + return false; + } + + if (pSyncNode->restoreFinish) { + return true; + } + + bool ready = false; + if (!pSyncNode->pFsm->FpApplyQueueEmptyCb(pSyncNode->pFsm)) { + // apply queue not empty + ready = false; + + } else { + if (!pSyncNode->pLogStore->syncLogIsEmpty(pSyncNode->pLogStore)) { + SyncIndex lastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); + SSyncRaftEntry* pEntry = NULL; + SLRUCache* pCache = pSyncNode->pLogStore->pCache; + LRUHandle* h = taosLRUCacheLookup(pCache, &lastIndex, sizeof(lastIndex)); + 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", lastIndex, pEntry->bytes, pEntry); + + } else { + pSyncNode->pLogStore->cacheMiss++; + sNTrace(pSyncNode, "miss cache index:%" PRId64, lastIndex); + + code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, lastIndex, &pEntry); + } + + if (code == 0 && pEntry != NULL) { + if (pEntry->originalRpcType == TDMT_SYNC_NOOP && pEntry->term == pSyncNode->pRaftStore->currentTerm) { + ready = true; + } + + if (h) { + taosLRUCacheRelease(pCache, h, false); + } else { + syncEntryDestroy(pEntry); + } + } + } + } + + if (!ready) { + terrno = TSDB_CODE_SYN_RESTORING; + } + + return ready; +} + bool syncIsReadyForRead(int64_t rid) { SSyncNode* pSyncNode = syncNodeAcquire(rid); if (pSyncNode == NULL) { @@ -388,60 +470,7 @@ bool syncIsReadyForRead(int64_t rid) { return false; } - if (pSyncNode->state == TAOS_SYNC_STATE_LEADER && pSyncNode->restoreFinish) { - syncNodeRelease(pSyncNode); - return true; - } - - bool ready = false; - if (pSyncNode->state == TAOS_SYNC_STATE_LEADER && !pSyncNode->restoreFinish) { - if (!pSyncNode->pFsm->FpApplyQueueEmptyCb(pSyncNode->pFsm)) { - // apply queue not empty - ready = false; - - } else { - if (!pSyncNode->pLogStore->syncLogIsEmpty(pSyncNode->pLogStore)) { - SyncIndex lastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); - SSyncRaftEntry* pEntry = NULL; - SLRUCache* pCache = pSyncNode->pLogStore->pCache; - LRUHandle* h = taosLRUCacheLookup(pCache, &lastIndex, sizeof(lastIndex)); - 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", lastIndex, pEntry->bytes, pEntry); - - } else { - pSyncNode->pLogStore->cacheMiss++; - sNTrace(pSyncNode, "miss cache index:%" PRId64, lastIndex); - - code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, lastIndex, &pEntry); - } - - if (code == 0 && pEntry != NULL) { - if (pEntry->originalRpcType == TDMT_SYNC_NOOP && pEntry->term == pSyncNode->pRaftStore->currentTerm) { - ready = true; - } - - if (h) { - taosLRUCacheRelease(pCache, h, false); - } else { - syncEntryDestory(pEntry); - } - } - } - } - } - - if (!ready) { - if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { - terrno = TSDB_CODE_SYN_NOT_LEADER; - } else { - terrno = TSDB_CODE_APP_NOT_READY; - } - } + bool ready = syncNodeIsReadyForRead(pSyncNode); syncNodeRelease(pSyncNode); return ready; @@ -521,6 +550,11 @@ SSyncState syncGetState(int64_t rid) { if (pSyncNode != NULL) { state.state = pSyncNode->state; state.restored = pSyncNode->restoreFinish; + if (pSyncNode->vgId != 1) { + state.canRead = syncNodeIsReadyForRead(pSyncNode); + } else { + state.canRead = state.restored; + } syncNodeRelease(pSyncNode); } @@ -543,7 +577,7 @@ int32_t syncGetSnapshotByIndex(int64_t rid, SyncIndex index, SSnapshot* pSnapsho int32_t code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, index, &pEntry); if (code != 0) { if (pEntry != NULL) { - syncEntryDestory(pEntry); + syncEntryDestroy(pEntry); } syncNodeRelease(pSyncNode); return -1; @@ -555,7 +589,7 @@ int32_t syncGetSnapshotByIndex(int64_t rid, SyncIndex index, SSnapshot* pSnapsho pSnapshot->lastApplyTerm = pEntry->term; pSnapshot->lastConfigIndex = syncNodeGetSnapshotConfigIndex(pSyncNode, index); - syncEntryDestory(pEntry); + syncEntryDestroy(pEntry); syncNodeRelease(pSyncNode); return 0; } @@ -626,7 +660,7 @@ void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet) { tstrncpy(pEp->fqdn, pSyncNode->pRaftCfg->cfg.nodeInfo[i].nodeFqdn, TSDB_FQDN_LEN); pEp->port = (pSyncNode->pRaftCfg->cfg.nodeInfo)[i].nodePort; pEpSet->numOfEps++; - sInfo("vgId:%d, sync get retry epset, index:%d %s:%d", pSyncNode->vgId, i, pEp->fqdn, pEp->port); + sDebug("vgId:%d, sync get retry epset, index:%d %s:%d", pSyncNode->vgId, i, pEp->fqdn, pEp->port); } if (pEpSet->numOfEps > 0) { pEpSet->inUse = (pSyncNode->pRaftCfg->cfg.myIndex + 1) % pEpSet->numOfEps; @@ -756,6 +790,29 @@ static int32_t syncHbTimerStop(SSyncNode* pSyncNode, SSyncTimer* pSyncTimer) { return ret; } +int32_t syncNodeLogStoreRestoreOnNeed(SSyncNode* pNode) { + ASSERT(pNode->pLogStore != NULL && "log store not created"); + ASSERT(pNode->pFsm != NULL && "pFsm not registered"); + ASSERT(pNode->pFsm->FpGetSnapshotInfo != NULL && "FpGetSnapshotInfo not registered"); + SSnapshot snapshot; + if (pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot) < 0) { + sError("vgId:%d, failed to get snapshot info since %s", pNode->vgId, terrstr()); + return -1; + } + SyncIndex commitIndex = snapshot.lastApplyIndex; + SyncIndex firstVer = pNode->pLogStore->syncLogBeginIndex(pNode->pLogStore); + 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, + pNode->vgId, terrstr(), lastVer, commitIndex); + return -1; + } + } + return 0; +} + +// open/close -------------- SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { SSyncNode* pSyncNode = taosMemoryCalloc(1, sizeof(SSyncNode)); if (pSyncNode == NULL) { @@ -831,6 +888,13 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { pSyncNode->syncEqMsg = pSyncInfo->syncEqMsg; pSyncNode->syncEqCtrlMsg = pSyncInfo->syncEqCtrlMsg; + // create raft log ring buffer + pSyncNode->pLogBuf = syncLogBufferCreate(); + if (pSyncNode->pLogBuf == NULL) { + sError("failed to init sync log buffer since %s. vgId:%d", terrstr(), pSyncNode->vgId); + goto _error; + } + // init raft config pSyncNode->pRaftCfg = raftCfgOpen(pSyncNode->configPath); if (pSyncNode->pRaftCfg == NULL) { @@ -956,6 +1020,9 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { } pSyncNode->commitIndex = commitIndex; + if (syncNodeLogStoreRestoreOnNeed(pSyncNode) < 0) { + goto _error; + } // timer ms init pSyncNode->pingBaseLine = PING_TIMER_MS; pSyncNode->electBaseLine = ELECT_TIMER_MS_MIN; @@ -1013,9 +1080,13 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { // is config changing pSyncNode->changing = false; + // replication mgr + syncNodeLogReplMgrInit(pSyncNode); + // peer state syncNodePeerStateInit(pSyncNode); + // // min match index pSyncNode->minMatchIndex = SYNC_INDEX_INVALID; @@ -1031,6 +1102,12 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { // snapshotting atomic_store_64(&pSyncNode->snapshottingIndex, SYNC_INDEX_INVALID); + // init log buffer + if (syncLogBufferInit(pSyncNode->pLogBuf, pSyncNode) < 0) { + sError("vgId:%d, failed to init sync log buffer since %s", pSyncNode->vgId, terrstr()); + goto _error; + } + pSyncNode->isStart = true; pSyncNode->electNum = 0; pSyncNode->becomeLeaderNum = 0; @@ -1039,7 +1116,9 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) { pSyncNode->hbrSlowNum = 0; pSyncNode->tmrRoutineNum = 0; - sNTrace(pSyncNode, "sync open, node:%p", pSyncNode); + sNInfo(pSyncNode, "sync open, node:%p", pSyncNode); + sTrace("vgId:%d, tsElectInterval:%d, tsHeartbeatInterval:%d, tsHeartbeatTimeout:%d", pSyncNode->vgId, tsElectInterval, + tsHeartbeatInterval, tsHeartbeatTimeout); return pSyncNode; @@ -1064,7 +1143,49 @@ void syncNodeMaybeUpdateCommitBySnapshot(SSyncNode* pSyncNode) { } } -void syncNodeStart(SSyncNode* pSyncNode) { +int32_t syncNodeRestore(SSyncNode* pSyncNode) { + ASSERT(pSyncNode->pLogStore != NULL && "log store not created"); + ASSERT(pSyncNode->pLogBuf != NULL && "ring log buffer not created"); + + SyncIndex lastVer = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); + SyncIndex commitIndex = pSyncNode->pLogStore->syncLogCommitIndex(pSyncNode->pLogStore); + 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 "", + pSyncNode->vgId, terrstr(), endIndex - 1, lastVer); + return -1; + } + + ASSERT(endIndex == lastVer + 1); + commitIndex = TMAX(pSyncNode->commitIndex, commitIndex); + + if (syncLogBufferCommit(pSyncNode->pLogBuf, pSyncNode, commitIndex) < 0) { + return -1; + } + + return 0; +} + +int32_t syncNodeStart(SSyncNode* pSyncNode) { + // start raft + if (pSyncNode->replicaNum == 1) { + raftStoreNextTerm(pSyncNode->pRaftStore); + syncNodeBecomeLeader(pSyncNode, "one replica start"); + + // Raft 3.6.2 Committing entries from previous terms + syncNodeAppendNoop(pSyncNode); + } else { + syncNodeBecomeFollower(pSyncNode, "first start"); + } + + int32_t ret = 0; + ret = syncNodeStartPingTimer(pSyncNode); + ASSERT(ret == 0); + return ret; +} + +void syncNodeStartOld(SSyncNode* pSyncNode) { // start raft if (pSyncNode->replicaNum == 1) { raftStoreNextTerm(pSyncNode->pRaftStore); @@ -1083,7 +1204,7 @@ void syncNodeStart(SSyncNode* pSyncNode) { ASSERT(ret == 0); } -void syncNodeStartStandBy(SSyncNode* pSyncNode) { +int32_t syncNodeStartStandBy(SSyncNode* pSyncNode) { // state change pSyncNode->state = TAOS_SYNC_STATE_FOLLOWER; syncNodeStopHeartbeatTimer(pSyncNode); @@ -1096,6 +1217,7 @@ void syncNodeStartStandBy(SSyncNode* pSyncNode) { ret = 0; ret = syncNodeStartPingTimer(pSyncNode); ASSERT(ret == 0); + return ret; } void syncNodePreClose(SSyncNode* pSyncNode) { @@ -1110,12 +1232,13 @@ void syncHbTimerDataFree(SSyncHbTimerData* pData) { taosMemoryFree(pData); } void syncNodeClose(SSyncNode* pSyncNode) { if (pSyncNode == NULL) return; - sNTrace(pSyncNode, "sync close, data:%p", pSyncNode); + sNInfo(pSyncNode, "sync close, node:%p", pSyncNode); int32_t ret = raftStoreClose(pSyncNode->pRaftStore); ASSERT(ret == 0); pSyncNode->pRaftStore = NULL; + syncNodeLogReplMgrDestroy(pSyncNode); syncRespMgrDestroy(pSyncNode->pSyncRespMgr); pSyncNode->pSyncRespMgr = NULL; voteGrantedDestroy(pSyncNode->pVotesGranted); @@ -1128,6 +1251,8 @@ void syncNodeClose(SSyncNode* pSyncNode) { pSyncNode->pMatchIndex = NULL; logStoreDestory(pSyncNode->pLogStore); pSyncNode->pLogStore = NULL; + syncLogBufferDestroy(pSyncNode->pLogBuf); + pSyncNode->pLogBuf = NULL; raftCfgClose(pSyncNode->pRaftCfg); pSyncNode->pRaftCfg = NULL; @@ -1529,7 +1654,7 @@ void syncNodeDoConfigChange(SSyncNode* pSyncNode, SSyncCfg* pNewConfig, SyncInde // Raft 3.6.2 Committing entries from previous terms syncNodeAppendNoop(pSyncNode); - syncMaybeAdvanceCommitIndex(pSyncNode); + // syncMaybeAdvanceCommitIndex(pSyncNode); } else { syncNodeBecomeFollower(pSyncNode, tmpbuf); @@ -1617,6 +1742,9 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) { // min match index pSyncNode->minMatchIndex = SYNC_INDEX_INVALID; + // reset log buffer + syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); + // trace log sNTrace(pSyncNode, "become follower %s", debugStr); } @@ -1712,6 +1840,9 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) { // min match index pSyncNode->minMatchIndex = SYNC_INDEX_INVALID; + // reset log buffer + syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); + // trace log sNInfo(pSyncNode, "become leader %s", debugStr); } @@ -1723,6 +1854,22 @@ void syncNodeCandidate2Leader(SSyncNode* pSyncNode) { sNTrace(pSyncNode, "state change syncNodeCandidate2Leader"); + int32_t ret = syncNodeAppendNoop(pSyncNode); + if (ret < 0) { + sError("vgId:%d, failed to append noop entry since %s", pSyncNode->vgId, terrstr()); + } + + SyncIndex lastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); + ASSERT(lastIndex >= 0); + sInfo("vgId:%d, become leader. term: %" PRId64 ", commit index: %" PRId64 ", last index: %" PRId64 "", + pSyncNode->vgId, pSyncNode->pRaftStore->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); @@ -1746,18 +1893,30 @@ int32_t syncNodePeerStateInit(SSyncNode* pSyncNode) { 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, + pSyncNode->vgId, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, lastIndex); + sNTrace(pSyncNode, "follower to candidate"); } 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, + pSyncNode->vgId, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, lastIndex); + sNTrace(pSyncNode, "leader to follower"); } 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, + pSyncNode->vgId, pSyncNode->pRaftStore->currentTerm, pSyncNode->commitIndex, lastIndex); + sNTrace(pSyncNode, "candidate to follower"); } @@ -1911,7 +2070,7 @@ SyncTerm syncNodeGetPreTerm(SSyncNode* pSyncNode, SyncIndex index) { if (h) { taosLRUCacheRelease(pCache, h, false); } else { - syncEntryDestory(pPreEntry); + syncEntryDestroy(pPreEntry); } return preTerm; @@ -2153,7 +2312,7 @@ static int32_t syncNodeEqNoop(SSyncNode* pNode) { SRpcMsg rpcMsg = {0}; int32_t code = syncBuildClientRequestFromNoopEntry(&rpcMsg, pEntry, pNode->vgId); - syncEntryDestory(pEntry); + syncEntryDestroy(pEntry); sNTrace(pNode, "propose msg, type:noop"); code = (*pNode->syncEqMsg)(pNode->msgcb, &rpcMsg); @@ -2181,6 +2340,37 @@ int32_t syncCacheEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry, LRUHand return code; } +int32_t syncNodeAppend(SSyncNode* ths, SSyncRaftEntry* pEntry) { + // append to log buffer + if (syncLogBufferAppend(ths->pLogBuf, ths, pEntry) < 0) { + sError("vgId:%d, failed to enqueue sync log buffer. index:%" PRId64 "", ths->vgId, pEntry->index); + return -1; + } + + // 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 + ", %" PRId64 ")", + ths->vgId, pEntry->index, pEntry->term, ths->pLogBuf->startIndex, ths->pLogBuf->commitIndex, + ths->pLogBuf->matchIndex, ths->pLogBuf->endIndex); + + // multi replica + if (ths->replicaNum > 1) { + return 0; + } + + // single replica + (void)syncNodeUpdateCommitIndex(ths, matchIndex); + + if (syncLogBufferCommit(ths->pLogBuf, ths, ths->commitIndex) < 0) { + sError("vgId:%d, failed to commit until commitIndex:%" PRId64 "", ths->vgId, ths->commitIndex); + return -1; + } + + return 0; +} + bool syncNodeHeartbeatReplyTimeout(SSyncNode* pSyncNode) { if (pSyncNode->replicaNum == 1) { return false; @@ -2224,6 +2414,20 @@ bool syncNodeSnapshotRecving(SSyncNode* pSyncNode) { } static int32_t syncNodeAppendNoop(SSyncNode* ths) { + SyncIndex index = syncLogBufferGetEndIndex(ths->pLogBuf); + SyncTerm term = ths->pRaftStore->currentTerm; + + SSyncRaftEntry* pEntry = syncEntryBuildNoop(term, index, ths->vgId); + if (pEntry == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + int32_t ret = syncNodeAppend(ths, pEntry); + return 0; +} + +static int32_t syncNodeAppendNoopOld(SSyncNode* ths) { int32_t ret = 0; SyncIndex index = ths->pLogStore->syncLogWriteIndex(ths->pLogStore); @@ -2246,7 +2450,7 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths) { if (h) { taosLRUCacheRelease(ths->pLogStore->pCache, h, false); } else { - syncEntryDestory(pEntry); + syncEntryDestroy(pEntry); } return ret; @@ -2255,9 +2459,13 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths) { int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { SyncHeartbeat* pMsg = pRpcMsg->pCont; + const STraceId* trace = &pRpcMsg->info.traceId; + char tbuf[40] = {0}; + TRACE_TO_STR(trace, tbuf); + int64_t tsMs = taosGetTimestampMs(); int64_t timeDiff = tsMs - pMsg->timeStamp; - syncLogRecvHeartbeat(ths, pMsg, timeDiff); + syncLogRecvHeartbeat(ths, pMsg, timeDiff, tbuf); SRpcMsg rpcMsg = {0}; (void)syncBuildHeartbeatReply(&rpcMsg, ths->vgId); @@ -2267,6 +2475,7 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { pMsgReply->srcId = ths->myRaftId; pMsgReply->term = ths->pRaftStore->currentTerm; pMsgReply->privateTerm = 8864; // magic number + pMsgReply->startTime = ths->startTime; pMsgReply->timeStamp = tsMs; if (pMsg->term == ths->pRaftStore->currentTerm && ths->state != TAOS_SYNC_STATE_LEADER) { @@ -2330,11 +2539,35 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { } int32_t syncNodeOnHeartbeatReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) { + const STraceId* trace = &pRpcMsg->info.traceId; + char tbuf[40] = {0}; + TRACE_TO_STR(trace, tbuf); + SyncHeartbeatReply* pMsg = pRpcMsg->pCont; + SSyncLogReplMgr* pMgr = syncNodeGetLogReplMgr(ths, &pMsg->srcId); + if (pMgr == NULL) { + sError("vgId:%d, failed to get log repl mgr for the peer at addr 0x016%" PRIx64 "", ths->vgId, pMsg->srcId.addr); + return -1; + } + + int64_t tsMs = taosGetTimestampMs(); + syncLogRecvHeartbeatReply(ths, pMsg, tsMs - pMsg->timeStamp, tbuf); + + syncIndexMgrSetRecvTime(ths->pMatchIndex, &pMsg->srcId, tsMs); + + return syncLogReplMgrProcessHeartbeatReply(pMgr, ths, pMsg); +} + +int32_t syncNodeOnHeartbeatReplyOld(SSyncNode* ths, const SRpcMsg* pRpcMsg) { + SyncHeartbeatReply* pMsg = pRpcMsg->pCont; + + const STraceId* trace = &pRpcMsg->info.traceId; + char tbuf[40] = {0}; + TRACE_TO_STR(trace, tbuf); int64_t tsMs = taosGetTimestampMs(); int64_t timeDiff = tsMs - pMsg->timeStamp; - syncLogRecvHeartbeatReply(ths, pMsg, timeDiff); + syncLogRecvHeartbeatReply(ths, pMsg, timeDiff, tbuf); // update last reply time, make decision whether the other node is alive or not syncIndexMgrSetRecvTime(ths->pMatchIndex, &pMsg->srcId, tsMs); @@ -2345,6 +2578,26 @@ int32_t syncNodeOnLocalCmd(SSyncNode* ths, const SRpcMsg* pRpcMsg) { SyncLocalCmd* pMsg = pRpcMsg->pCont; syncLogRecvLocalCmd(ths, pMsg, ""); + if (pMsg->cmd == SYNC_LOCAL_CMD_STEP_DOWN) { + syncNodeStepDown(ths, pMsg->sdNewTerm); + + } else if (pMsg->cmd == SYNC_LOCAL_CMD_FOLLOWER_CMT) { + (void)syncNodeUpdateCommitIndex(ths, pMsg->fcIndex); + if (syncLogBufferCommit(ths->pLogBuf, ths, ths->commitIndex) < 0) { + sError("vgId:%d, failed to commit raft log since %s. commit index: %" PRId64 "", ths->vgId, terrstr(), + ths->commitIndex); + } + } else { + sError("error local cmd"); + } + + return 0; +} + +int32_t syncNodeOnLocalCmdOld(SSyncNode* ths, const SRpcMsg* pRpcMsg) { + SyncLocalCmd* pMsg = pRpcMsg->pCont; + syncLogRecvLocalCmd(ths, pMsg, ""); + if (pMsg->cmd == SYNC_LOCAL_CMD_STEP_DOWN) { syncNodeStepDown(ths, pMsg->sdNewTerm); @@ -2372,6 +2625,35 @@ int32_t syncNodeOnLocalCmd(SSyncNode* ths, const SRpcMsg* pRpcMsg) { int32_t syncNodeOnClientRequest(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIndex) { sNTrace(ths, "on client request"); + int32_t code = 0; + + SyncIndex index = syncLogBufferGetEndIndex(ths->pLogBuf); + SyncTerm term = ths->pRaftStore->currentTerm; + SSyncRaftEntry* pEntry = NULL; + if (pMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) { + pEntry = syncEntryBuildFromClientRequest(pMsg->pCont, term, index); + } else { + pEntry = syncEntryBuildFromRpcMsg(pMsg, term, index); + } + + if (ths->state == TAOS_SYNC_STATE_LEADER) { + if (pRetIndex) { + (*pRetIndex) = index; + } + + int32_t code = syncNodeAppend(ths, pEntry); + if (code < 0 && ths->vgId != 1 && vnodeIsMsgBlock(pEntry->originalRpcType)) { + ASSERT(false && "failed to append blocking msg"); + } + return code; + } + + return -1; +} + +int32_t syncNodeOnClientRequestOld(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIndex) { + sNTrace(ths, "on client request"); + int32_t ret = 0; int32_t code = 0; @@ -2395,7 +2677,7 @@ int32_t syncNodeOnClientRequest(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIn if (h) { taosLRUCacheRelease(ths->pLogStore->pCache, h, false); } else { - syncEntryDestory(pEntry); + syncEntryDestroy(pEntry); } return -1; @@ -2418,7 +2700,7 @@ int32_t syncNodeOnClientRequest(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIn if (h) { taosLRUCacheRelease(ths->pLogStore->pCache, h, false); } else { - syncEntryDestory(pEntry); + syncEntryDestroy(pEntry); } return -1; @@ -2453,7 +2735,7 @@ int32_t syncNodeOnClientRequest(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIn if (h) { taosLRUCacheRelease(ths->pLogStore->pCache, h, false); } else { - syncEntryDestory(pEntry); + syncEntryDestroy(pEntry); } return ret; @@ -2563,6 +2845,7 @@ bool syncNodeIsOptimizedOneReplica(SSyncNode* ths, SRpcMsg* pMsg) { } int32_t syncNodeDoCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endIndex, uint64_t flag) { + ASSERT(false); if (beginIndex > endIndex) { return 0; } @@ -2676,7 +2959,7 @@ int32_t syncNodeDoCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endInde if (h) { taosLRUCacheRelease(pCache, h, false); } else { - syncEntryDestory(pEntry); + syncEntryDestroy(pEntry); } } } diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c index 28a8a2e995..467b4e2219 100644 --- a/source/libs/sync/src/syncMessage.c +++ b/source/libs/sync/src/syncMessage.c @@ -16,6 +16,7 @@ #define _DEFAULT_SOURCE #include "syncMessage.h" #include "syncRaftEntry.h" +#include "syncRaftStore.h" int32_t syncBuildTimeout(SRpcMsg* pMsg, ESyncTimeoutType timeoutType, uint64_t logicClock, int32_t timerMS, SSyncNode* pNode) { @@ -153,6 +154,34 @@ int32_t syncBuildAppendEntriesReply(SRpcMsg* pMsg, int32_t vgId) { return 0; } +int32_t syncBuildAppendEntriesFromRaftLog(SSyncNode* pNode, SSyncRaftEntry* pEntry, SyncTerm prevLogTerm, + SRpcMsg* pRpcMsg) { + uint32_t dataLen = pEntry->bytes; + uint32_t bytes = sizeof(SyncAppendEntries) + dataLen; + pRpcMsg->contLen = bytes; + pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen); + if (pRpcMsg->pCont == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + SyncAppendEntries* pMsg = pRpcMsg->pCont; + pMsg->bytes = pRpcMsg->contLen; + pMsg->msgType = pRpcMsg->msgType = TDMT_SYNC_APPEND_ENTRIES; + pMsg->dataLen = dataLen; + + (void)memcpy(pMsg->data, pEntry, dataLen); + + pMsg->prevLogIndex = pEntry->index - 1; + pMsg->prevLogTerm = prevLogTerm; + pMsg->vgId = pNode->vgId; + pMsg->srcId = pNode->myRaftId; + pMsg->term = pNode->pRaftStore->currentTerm; + pMsg->commitIndex = pNode->commitIndex; + pMsg->privateTerm = 0; + return 0; +} + int32_t syncBuildHeartbeat(SRpcMsg* pMsg, int32_t vgId) { int32_t bytes = sizeof(SyncHeartbeat); pMsg->pCont = rpcMallocCont(bytes); diff --git a/source/libs/sync/src/syncPipeline.c b/source/libs/sync/src/syncPipeline.c new file mode 100644 index 0000000000..5d6905f99e --- /dev/null +++ b/source/libs/sync/src/syncPipeline.c @@ -0,0 +1,1111 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE + +#include "syncPipeline.h" +#include "syncCommit.h" +#include "syncIndexMgr.h" +#include "syncInt.h" +#include "syncRaftEntry.h" +#include "syncRaftStore.h" +#include "syncReplication.h" +#include "syncRespMgr.h" +#include "syncSnapshot.h" +#include "syncUtil.h" + +int64_t syncLogBufferGetEndIndex(SSyncLogBuffer* pBuf) { + taosThreadMutexLock(&pBuf->mutex); + int64_t index = pBuf->endIndex; + taosThreadMutexUnlock(&pBuf->mutex); + return index; +} + +int32_t syncLogBufferAppend(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEntry* pEntry) { + taosThreadMutexLock(&pBuf->mutex); + syncLogBufferValidate(pBuf); + SyncIndex index = pEntry->index; + + if (index - pBuf->startIndex >= pBuf->size) { + sError("vgId:%d, failed to append due to sync log buffer full. index:%" PRId64 "", pNode->vgId, index); + goto _out; + } + + ASSERT(index == pBuf->endIndex); + + SSyncRaftEntry* pExist = pBuf->entries[index % pBuf->size].pItem; + ASSERT(pExist == NULL); + + // initial log buffer with at least one item, e.g. commitIndex + SSyncRaftEntry* pMatch = pBuf->entries[(index - 1 + pBuf->size) % pBuf->size].pItem; + ASSERT(pMatch != NULL && "no matched log entry"); + ASSERT(pMatch->index + 1 == index); + + SSyncLogBufEntry tmp = {.pItem = pEntry, .prevLogIndex = pMatch->index, .prevLogTerm = pMatch->term}; + pBuf->entries[index % pBuf->size] = tmp; + pBuf->endIndex = index + 1; + + syncLogBufferValidate(pBuf); + taosThreadMutexUnlock(&pBuf->mutex); + return 0; + +_out: + syncLogBufferValidate(pBuf); + syncEntryDestroy(pEntry); + taosThreadMutexUnlock(&pBuf->mutex); + return -1; +} + +SyncTerm syncLogReplMgrGetPrevLogTerm(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index) { + SSyncLogBuffer* pBuf = pNode->pLogBuf; + SSyncRaftEntry* pEntry = NULL; + SyncIndex prevIndex = index - 1; + SyncTerm prevLogTerm = -1; + terrno = TSDB_CODE_SUCCESS; + + if (prevIndex == -1 && pNode->pLogStore->syncLogBeginIndex(pNode->pLogStore) == 0) return 0; + + if (prevIndex > pBuf->matchIndex) { + terrno = TSDB_CODE_WAL_LOG_NOT_EXIST; + return -1; + } + + ASSERT(index - 1 == prevIndex); + + if (prevIndex >= pBuf->startIndex) { + pEntry = pBuf->entries[(prevIndex + pBuf->size) % pBuf->size].pItem; + ASSERT(pEntry != NULL && "no log entry found"); + prevLogTerm = pEntry->term; + return prevLogTerm; + } + + if (pMgr && pMgr->startIndex <= prevIndex && prevIndex < pMgr->endIndex) { + int64_t timeMs = pMgr->states[(prevIndex + pMgr->size) % pMgr->size].timeMs; + ASSERT(timeMs != 0 && "no log entry found"); + prevLogTerm = pMgr->states[(prevIndex + pMgr->size) % pMgr->size].term; + ASSERT(prevIndex == 0 || prevLogTerm != 0); + return prevLogTerm; + } + + SSnapshot snapshot; + if (pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot) == 0 && prevIndex == snapshot.lastApplyIndex) { + return snapshot.lastApplyTerm; + } + + if (pNode->pLogStore->syncLogGetEntry(pNode->pLogStore, prevIndex, &pEntry) == 0) { + prevLogTerm = pEntry->term; + syncEntryDestroy(pEntry); + pEntry = NULL; + return prevLogTerm; + } + + sError("vgId:%d, failed to get log term since %s. index: %" PRId64 "", pNode->vgId, terrstr(), prevIndex); + terrno = TSDB_CODE_WAL_LOG_NOT_EXIST; + return -1; +} + +SSyncRaftEntry* syncEntryBuildDummy(SyncTerm term, SyncIndex index, int32_t vgId) { + return syncEntryBuildNoop(term, index, 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 "", + 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 "", + pNode->vgId, lastVer, commitIndex); + return -1; + } + + return 0; +} + +int32_t syncLogBufferInitWithoutLock(SSyncLogBuffer* pBuf, SSyncNode* pNode) { + ASSERT(pNode->pLogStore != NULL && "log store not created"); + ASSERT(pNode->pFsm != NULL && "pFsm not registered"); + ASSERT(pNode->pFsm->FpGetSnapshotInfo != NULL && "FpGetSnapshotInfo not registered"); + + SSnapshot snapshot; + if (pNode->pFsm->FpGetSnapshotInfo(pNode->pFsm, &snapshot) < 0) { + sError("vgId:%d, failed to get snapshot info since %s", pNode->vgId, terrstr()); + goto _err; + } + SyncIndex commitIndex = snapshot.lastApplyIndex; + SyncTerm commitTerm = TMAX(snapshot.lastApplyTerm, 0); + if (syncLogValidateAlignmentOfCommit(pNode, commitIndex)) { + terrno = TSDB_CODE_WAL_LOG_INCOMPLETE; + goto _err; + } + + SyncIndex lastVer = pNode->pLogStore->syncLogLastIndex(pNode->pLogStore); + ASSERT(lastVer >= commitIndex); + SyncIndex toIndex = lastVer; + // update match index + pBuf->commitIndex = commitIndex; + pBuf->matchIndex = toIndex; + pBuf->endIndex = toIndex + 1; + + // load log entries in reverse order + SSyncLogStore* pLogStore = pNode->pLogStore; + SyncIndex index = toIndex; + SSyncRaftEntry* pEntry = NULL; + bool takeDummy = false; + + while (true) { + if (index <= pBuf->commitIndex) { + takeDummy = true; + break; + } + + if (pLogStore->syncLogGetEntry(pLogStore, index, &pEntry) < 0) { + sError("vgId:%d, failed to get log entry since %s. index:%" PRId64 "", pNode->vgId, terrstr(), index); + break; + } + + bool taken = false; + int emptySize = 5; + if (toIndex - index + 1 <= pBuf->size - emptySize) { + SSyncLogBufEntry tmp = {.pItem = pEntry, .prevLogIndex = -1, .prevLogTerm = -1}; + pBuf->entries[index % pBuf->size] = tmp; + taken = true; + } + + if (index < toIndex) { + pBuf->entries[(index + 1) % pBuf->size].prevLogIndex = pEntry->index; + pBuf->entries[(index + 1) % pBuf->size].prevLogTerm = pEntry->term; + } + + if (!taken) { + syncEntryDestroy(pEntry); + pEntry = NULL; + break; + } + + index--; + } + + // put a dummy record at commitIndex if present in log buffer + if (takeDummy) { + ASSERT(index == pBuf->commitIndex); + + SSyncRaftEntry* pDummy = syncEntryBuildDummy(commitTerm, commitIndex, pNode->vgId); + if (pDummy == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + SSyncLogBufEntry tmp = {.pItem = pDummy, .prevLogIndex = commitIndex - 1, .prevLogTerm = commitTerm}; + pBuf->entries[(commitIndex + pBuf->size) % pBuf->size] = tmp; + + if (index < toIndex) { + pBuf->entries[(index + 1) % pBuf->size].prevLogIndex = commitIndex; + pBuf->entries[(index + 1) % pBuf->size].prevLogTerm = commitTerm; + } + } + + // update startIndex + pBuf->startIndex = takeDummy ? index : index + 1; + + sInfo("vgId:%d, init sync log buffer. buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", pNode->vgId, + pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); + + // validate + syncLogBufferValidate(pBuf); + return 0; + +_err: + return -1; +} + +int32_t syncLogBufferInit(SSyncLogBuffer* pBuf, SSyncNode* pNode) { + taosThreadMutexLock(&pBuf->mutex); + int32_t ret = syncLogBufferInitWithoutLock(pBuf, pNode); + taosThreadMutexUnlock(&pBuf->mutex); + return ret; +} + +int32_t syncLogBufferReInit(SSyncLogBuffer* pBuf, SSyncNode* pNode) { + taosThreadMutexLock(&pBuf->mutex); + for (SyncIndex index = pBuf->startIndex; index < pBuf->endIndex; index++) { + SSyncRaftEntry* pEntry = pBuf->entries[(index + pBuf->size) % pBuf->size].pItem; + if (pEntry == NULL) continue; + syncEntryDestroy(pEntry); + pEntry = NULL; + memset(&pBuf->entries[(index + pBuf->size) % pBuf->size], 0, sizeof(pBuf->entries[0])); + } + pBuf->startIndex = pBuf->commitIndex = pBuf->matchIndex = pBuf->endIndex = 0; + int32_t ret = syncLogBufferInitWithoutLock(pBuf, pNode); + if (ret < 0) { + sError("vgId:%d, failed to re-initialize sync log buffer since %s.", pNode->vgId, terrstr()); + } + taosThreadMutexUnlock(&pBuf->mutex); + return ret; +} + +FORCE_INLINE SyncTerm syncLogBufferGetLastMatchTerm(SSyncLogBuffer* pBuf) { + SyncIndex index = pBuf->matchIndex; + SSyncRaftEntry* pEntry = pBuf->entries[(index + pBuf->size) % pBuf->size].pItem; + ASSERT(pEntry != NULL); + return pEntry->term; +} + +int32_t syncLogBufferAccept(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEntry* pEntry, SyncTerm prevTerm) { + taosThreadMutexLock(&pBuf->mutex); + syncLogBufferValidate(pBuf); + int32_t ret = -1; + SyncIndex index = pEntry->index; + SyncIndex prevIndex = pEntry->index - 1; + SyncTerm lastMatchTerm = syncLogBufferGetLastMatchTerm(pBuf); + + if (index <= pBuf->commitIndex) { + 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); + SyncTerm term = syncLogReplMgrGetPrevLogTerm(NULL, pNode, index + 1); + ASSERT(pEntry->term >= 0); + if (term == pEntry->term) { + ret = 0; + } + goto _out; + } + + if (index - pBuf->startIndex >= pBuf->size) { + 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); + goto _out; + } + + 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 ")", + pNode->vgId, pEntry->index, pEntry->term, prevTerm, lastMatchTerm, pBuf->startIndex, pBuf->commitIndex, + pBuf->matchIndex, pBuf->endIndex); + goto _out; + } + + // check current in buffer + SSyncRaftEntry* pExist = pBuf->entries[index % pBuf->size].pItem; + if (pExist != NULL) { + ASSERT(pEntry->index == pExist->index); + + 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 + " %" PRId64 " %" PRId64 ", %" PRId64 ")", + pNode->vgId, pEntry->index, pEntry->term, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, + pBuf->endIndex); + SyncTerm existPrevTerm = pBuf->entries[index % pBuf->size].prevLogTerm; + ASSERT(pEntry->term == pExist->term && prevTerm == existPrevTerm); + ret = 0; + goto _out; + } + } + + // update + SSyncLogBufEntry tmp = {.pItem = pEntry, .prevLogIndex = prevIndex, .prevLogTerm = prevTerm}; + pEntry = NULL; + pBuf->entries[index % pBuf->size] = tmp; + + // update end index + pBuf->endIndex = TMAX(index + 1, pBuf->endIndex); + + // success + ret = 0; + +_out: + syncEntryDestroy(pEntry); + syncLogBufferValidate(pBuf); + taosThreadMutexUnlock(&pBuf->mutex); + return ret; +} + +int32_t syncLogStorePersist(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) { + ASSERT(pEntry->index >= 0); + SyncIndex lastVer = pLogStore->syncLogLastIndex(pLogStore); + if (lastVer >= pEntry->index && pLogStore->syncLogTruncate(pLogStore, pEntry->index) < 0) { + sError("failed to truncate log store since %s. from index:%" PRId64 "", terrstr(), pEntry->index); + return -1; + } + lastVer = pLogStore->syncLogLastIndex(pLogStore); + ASSERT(pEntry->index == lastVer + 1); + + if (pLogStore->syncLogAppendEntry(pLogStore, pEntry) < 0) { + sError("failed to append sync log entry since %s. index:%" PRId64 ", term:%" PRId64 "", terrstr(), pEntry->index, + pEntry->term); + return -1; + } + + lastVer = pLogStore->syncLogLastIndex(pLogStore); + ASSERT(pEntry->index == lastVer); + return 0; +} + +int64_t syncLogBufferProceed(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncTerm* pMatchTerm) { + taosThreadMutexLock(&pBuf->mutex); + syncLogBufferValidate(pBuf); + + SSyncLogStore* pLogStore = pNode->pLogStore; + int64_t matchIndex = pBuf->matchIndex; + + while (pBuf->matchIndex + 1 < pBuf->endIndex) { + int64_t index = pBuf->matchIndex + 1; + ASSERT(index >= 0); + + // try to proceed + SSyncLogBufEntry* pBufEntry = &pBuf->entries[index % pBuf->size]; + SyncIndex prevLogIndex = pBufEntry->prevLogIndex; + SyncTerm prevLogTerm = pBufEntry->prevLogTerm; + SSyncRaftEntry* pEntry = pBufEntry->pItem; + if (pEntry == NULL) { + sTrace("vgId:%d, cannot proceed match index in log buffer. no raft entry at next pos of matchIndex:%" PRId64, + pNode->vgId, pBuf->matchIndex); + goto _out; + } + + ASSERT(index == pEntry->index); + + // match + SSyncRaftEntry* pMatch = pBuf->entries[(pBuf->matchIndex + pBuf->size) % pBuf->size].pItem; + ASSERT(pMatch != NULL); + ASSERT(pMatch->index == pBuf->matchIndex); + ASSERT(pMatch->index + 1 == pEntry->index); + ASSERT(prevLogIndex == pMatch->index); + + if (pMatch->term != prevLogTerm) { + sInfo( + "vgId:%d, mismatching sync log entries encountered. " + "{ index:%" PRId64 ", term:%" PRId64 + " } " + "{ index:%" PRId64 ", term:%" PRId64 ", prevLogIndex:%" PRId64 ", prevLogTerm:%" PRId64 " } ", + pNode->vgId, pMatch->index, pMatch->term, pEntry->index, pEntry->term, prevLogIndex, prevLogTerm); + goto _out; + } + + // increase match index + pBuf->matchIndex = index; + + 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 + (void)syncNodeReplicateWithoutLock(pNode); + + // persist + if (syncLogStorePersist(pLogStore, pEntry) < 0) { + sError("vgId:%d, failed to persist sync log entry from buffer since %s. index:%" PRId64, pNode->vgId, terrstr(), + pEntry->index); + goto _out; + } + ASSERT(pEntry->index == pBuf->matchIndex); + + // update my match index + matchIndex = pBuf->matchIndex; + syncIndexMgrSetIndex(pNode->pMatchIndex, &pNode->myRaftId, pBuf->matchIndex); + } // end of while + +_out: + pBuf->matchIndex = matchIndex; + if (pMatchTerm) { + *pMatchTerm = pBuf->entries[(matchIndex + pBuf->size) % pBuf->size].pItem->term; + } + syncLogBufferValidate(pBuf); + taosThreadMutexUnlock(&pBuf->mutex); + return matchIndex; +} + +int32_t syncLogFsmExecute(SSyncNode* pNode, SSyncFSM* pFsm, ESyncState role, SyncTerm term, SSyncRaftEntry* pEntry) { + ASSERT(pFsm->FpCommitCb != NULL && "No commit cb registered for the FSM"); + + if ((pNode->replicaNum == 1) && pNode->restoreFinish && pNode->vgId != 1) { + return 0; + } + + if (pNode->vgId != 1 && vnodeIsMsgBlock(pEntry->originalRpcType)) { + sTrace("vgId:%d, blocking msg ready to execute. index:%" PRId64 ", term: %" PRId64 ", type: %s", pNode->vgId, + pEntry->index, pEntry->term, TMSG_INFO(pEntry->originalRpcType)); + } + + SRpcMsg rpcMsg = {0}; + syncEntry2OriginalRpc(pEntry, &rpcMsg); + + SFsmCbMeta cbMeta = {0}; + cbMeta.index = pEntry->index; + cbMeta.lastConfigIndex = syncNodeGetSnapshotConfigIndex(pNode, pEntry->index); + cbMeta.isWeak = pEntry->isWeak; + cbMeta.code = 0; + cbMeta.state = role; + cbMeta.seqNum = pEntry->seqNum; + cbMeta.term = pEntry->term; + cbMeta.currentTerm = term; + cbMeta.flag = -1; + + (void)syncRespMgrGetAndDel(pNode->pSyncRespMgr, cbMeta.seqNum, &rpcMsg.info); + int32_t code = pFsm->FpCommitCb(pFsm, &rpcMsg, &cbMeta); + ASSERT(rpcMsg.pCont == NULL); + return code; +} + +int32_t syncLogBufferValidate(SSyncLogBuffer* pBuf) { + ASSERT(pBuf->startIndex <= pBuf->matchIndex); + ASSERT(pBuf->commitIndex <= pBuf->matchIndex); + ASSERT(pBuf->matchIndex < pBuf->endIndex); + ASSERT(pBuf->endIndex - pBuf->startIndex <= pBuf->size); + ASSERT(pBuf->entries[(pBuf->matchIndex + pBuf->size) % pBuf->size].pItem); + return 0; +} + +int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t commitIndex) { + taosThreadMutexLock(&pBuf->mutex); + syncLogBufferValidate(pBuf); + + SSyncLogStore* pLogStore = pNode->pLogStore; + SSyncFSM* pFsm = pNode->pFsm; + ESyncState role = pNode->state; + SyncTerm term = pNode->pRaftStore->currentTerm; + SyncGroupId vgId = pNode->vgId; + int32_t ret = -1; + int64_t upperIndex = TMIN(commitIndex, pBuf->matchIndex); + SSyncRaftEntry* pEntry = NULL; + bool inBuf = false; + + if (commitIndex <= pBuf->commitIndex) { + sDebug("vgId:%d, stale commit index. current:%" PRId64 ", notified:%" PRId64 "", vgId, pBuf->commitIndex, + commitIndex); + ret = 0; + goto _out; + } + + 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 + for (int64_t index = pBuf->commitIndex + 1; index <= upperIndex; index++) { + // get a log entry + pEntry = syncLogBufferGetOneEntry(pBuf, pNode, index, &inBuf); + if (pEntry == NULL) { + goto _out; + } + + // execute it + if (!syncUtilUserCommit(pEntry->originalRpcType)) { + sInfo("vgId:%d, commit sync barrier. index: %" PRId64 ", term:%" PRId64 ", type: %s", vgId, pEntry->index, + pEntry->term, TMSG_INFO(pEntry->originalRpcType)); + pBuf->commitIndex = index; + if (!inBuf) { + syncEntryDestroy(pEntry); + pEntry = NULL; + } + continue; + } + if (syncLogFsmExecute(pNode, pFsm, role, term, pEntry) != 0) { + sError("vgId:%d, failed to execute sync log entry. index:%" PRId64 ", 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, + pEntry->index, pEntry->term, role, term); + + if (!inBuf) { + syncEntryDestroy(pEntry); + pEntry = NULL; + } + } + + // recycle + SyncIndex until = pBuf->commitIndex - (pBuf->size >> 4); + for (SyncIndex index = pBuf->startIndex; index < until; index++) { + SSyncRaftEntry* pEntry = pBuf->entries[(index + pBuf->size) % pBuf->size].pItem; + ASSERT(pEntry != NULL); + syncEntryDestroy(pEntry); + memset(&pBuf->entries[(index + pBuf->size) % pBuf->size], 0, sizeof(pBuf->entries[0])); + pBuf->startIndex = index + 1; + } + + ret = 0; +_out: + // mark as restored if needed + if (!pNode->restoreFinish && pBuf->commitIndex >= pNode->commitIndex) { + pNode->pFsm->FpRestoreFinishCb(pNode->pFsm); + pNode->restoreFinish = true; + sInfo("vgId:%d, restore finished. log buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", pNode->vgId, + pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); + } + + if (!inBuf) { + syncEntryDestroy(pEntry); + pEntry = NULL; + } + syncLogBufferValidate(pBuf); + taosThreadMutexUnlock(&pBuf->mutex); + return ret; +} + +int32_t syncLogReplMgrReset(SSyncLogReplMgr* pMgr) { + ASSERT(pMgr->startIndex >= 0); + for (SyncIndex index = pMgr->startIndex; index < pMgr->endIndex; index++) { + memset(&pMgr->states[index % pMgr->size], 0, sizeof(pMgr->states[0])); + } + pMgr->startIndex = 0; + pMgr->matchIndex = 0; + pMgr->endIndex = 0; + pMgr->restored = false; + pMgr->retryBackoff = 0; + return 0; +} + +int32_t syncLogReplMgrRetryOnNeed(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { + if (pMgr->endIndex <= pMgr->startIndex) { + return 0; + } + + 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, + pDestId->addr); + return -1; + } + + int32_t ret = -1; + bool retried = false; + int64_t retryWaitMs = syncLogGetRetryBackoffTimeMs(pMgr); + int64_t nowMs = taosGetMonoTimestampMs(); + int count = 0; + int64_t firstIndex = -1; + SyncTerm term = -1; + + for (SyncIndex index = pMgr->startIndex; index < pMgr->endIndex; index++) { + int64_t pos = index % pMgr->size; + ASSERT(!pMgr->states[pos].barrier || (index == pMgr->startIndex || index + 1 == pMgr->endIndex)); + + if (nowMs < pMgr->states[pos].timeMs + retryWaitMs) { + break; + } + + if (pMgr->states[pos].acked) { + continue; + } + + bool barrier = false; + if (syncLogBufferReplicateOneTo(pMgr, pNode, index, &term, pDestId, &barrier) < 0) { + sError("vgId:%d, failed to replicate sync log entry since %s. index: %" PRId64 ", dest: %" PRIx64 "", pNode->vgId, + terrstr(), index, pDestId->addr); + goto _out; + } + ASSERT(barrier == pMgr->states[pos].barrier); + pMgr->states[pos].timeMs = nowMs; + pMgr->states[pos].term = term; + pMgr->states[pos].acked = false; + + retried = true; + if (firstIndex == -1) firstIndex = index; + count++; + } + + ret = 0; +_out: + if (retried) { + pMgr->retryBackoff = syncLogGetNextRetryBackoff(pMgr); + sInfo("vgId:%d, resent %d sync log entries. dest: %" PRIx64 ", indexes: %" PRId64 " ..., terms: ... %" PRId64 + ", retryWaitMs: %" PRId64 ", repl mgr: [%" PRId64 " %" PRId64 ", %" PRId64 ")", + pNode->vgId, count, pDestId->addr, firstIndex, term, retryWaitMs, pMgr->startIndex, pMgr->matchIndex, + pMgr->endIndex); + } + return ret; +} + +int32_t syncLogReplMgrProcessReplyInRecoveryMode(SSyncLogReplMgr* pMgr, SSyncNode* pNode, + SyncAppendEntriesReply* pMsg) { + SSyncLogBuffer* pBuf = pNode->pLogBuf; + SRaftId destId = pMsg->srcId; + ASSERT(pMgr->restored == false); + char host[64]; + uint16_t port; + syncUtilU642Addr(destId.addr, host, sizeof(host), &port); + + if (pMgr->endIndex == 0) { + ASSERT(pMgr->startIndex == 0); + ASSERT(pMgr->matchIndex == 0); + if (pMsg->matchIndex < 0) { + pMgr->restored = true; + sInfo("vgId:%d, sync log repl mgr restored. peer: %s:%d (%" PRIx64 "), mgr: rs(%d) [%" PRId64 " %" PRId64 + ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", + pNode->vgId, host, port, destId.addr, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, + pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); + return 0; + } + } else { + if (pMsg->lastSendIndex < pMgr->startIndex || pMsg->lastSendIndex >= pMgr->endIndex) { + syncLogReplMgrRetryOnNeed(pMgr, pNode); + return 0; + } + + pMgr->states[pMsg->lastSendIndex % pMgr->size].acked = true; + + if (pMsg->success && pMsg->matchIndex == pMsg->lastSendIndex) { + pMgr->matchIndex = pMsg->matchIndex; + pMgr->restored = true; + sInfo("vgId:%d, sync log repl mgr restored. peer: %s:%d (%" PRIx64 "), mgr: rs(%d) [%" PRId64 " %" PRId64 + ", %" PRId64 "), buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", + pNode->vgId, host, port, destId.addr, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, + pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); + return 0; + } + + if (pMsg->success == false && pMsg->matchIndex >= pMsg->lastSendIndex) { + sWarn("vgId:%d, failed to rollback match index. peer: %s:%d, match index: %" PRId64 ", last sent: %" PRId64, + pNode->vgId, host, port, pMsg->matchIndex, pMsg->lastSendIndex); + if (syncNodeStartSnapshot(pNode, &destId) < 0) { + sError("vgId:%d, failed to start snapshot for peer %s:%d", pNode->vgId, host, port); + return -1; + } + sInfo("vgId:%d, snapshot replication to peer %s:%d", pNode->vgId, host, port); + return 0; + } + } + + // check last match term + SyncTerm term = -1; + SyncIndex firstVer = pNode->pLogStore->syncLogBeginIndex(pNode->pLogStore); + SyncIndex index = TMIN(pMsg->matchIndex, pNode->pLogBuf->matchIndex); + + if (pMsg->matchIndex < pNode->pLogBuf->matchIndex) { + term = syncLogReplMgrGetPrevLogTerm(pMgr, pNode, index + 1); + if (term < 0 || (term != pMsg->lastMatchTerm && (index + 1 == firstVer || index == firstVer))) { + ASSERT(term >= 0 || terrno == TSDB_CODE_WAL_LOG_NOT_EXIST); + if (syncNodeStartSnapshot(pNode, &destId) < 0) { + sError("vgId:%d, failed to start snapshot for peer %s:%d", pNode->vgId, host, port); + return -1; + } + sInfo("vgId:%d, snapshot replication to peer %s:%d", pNode->vgId, host, port); + return 0; + } + + ASSERT(index + 1 >= firstVer); + + if (term == pMsg->lastMatchTerm) { + index = index + 1; + ASSERT(index <= pNode->pLogBuf->matchIndex); + } else { + ASSERT(index > firstVer); + } + } + + // attempt to replicate the raft log at index + (void)syncLogReplMgrReset(pMgr); + return syncLogReplMgrReplicateProbeOnce(pMgr, pNode, index); +} + +int32_t syncLogReplMgrProcessHeartbeatReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncHeartbeatReply* pMsg) { + 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 "", + pNode->vgId, pMsg->srcId.addr, pMsg->startTime, pMgr->peerStartTime); + syncLogReplMgrReset(pMgr); + pMgr->peerStartTime = pMsg->startTime; + } + taosThreadMutexUnlock(&pBuf->mutex); + return 0; +} + +int32_t syncLogReplMgrProcessReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg) { + 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 + ", old:%" PRId64, + pNode->vgId, pMsg->srcId.addr, pMsg->startTime, pMgr->peerStartTime); + syncLogReplMgrReset(pMgr); + pMgr->peerStartTime = pMsg->startTime; + } + + if (pMgr->restored) { + (void)syncLogReplMgrProcessReplyInNormalMode(pMgr, pNode, pMsg); + } else { + (void)syncLogReplMgrProcessReplyInRecoveryMode(pMgr, pNode, pMsg); + } + taosThreadMutexUnlock(&pBuf->mutex); + return 0; +} + +int32_t syncLogReplMgrReplicateOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { + if (pMgr->restored) { + (void)syncLogReplMgrReplicateAttemptedOnce(pMgr, pNode); + } else { + (void)syncLogReplMgrReplicateProbeOnce(pMgr, pNode, pNode->pLogBuf->matchIndex); + } + return 0; +} + +int32_t syncLogReplMgrReplicateProbeOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index) { + ASSERT(!pMgr->restored); + ASSERT(pMgr->startIndex >= 0); + int64_t retryMaxWaitMs = SYNC_LOG_REPL_RETRY_WAIT_MS * (1 << SYNC_MAX_RETRY_BACKOFF); + int64_t nowMs = taosGetMonoTimestampMs(); + + if (pMgr->endIndex > pMgr->startIndex && + nowMs < pMgr->states[pMgr->startIndex % pMgr->size].timeMs + retryMaxWaitMs) { + return 0; + } + (void)syncLogReplMgrReset(pMgr); + + SRaftId* pDestId = &pNode->replicasId[pMgr->peerId]; + bool barrier = false; + SyncTerm term = -1; + if (syncLogBufferReplicateOneTo(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, + terrstr(), index, pDestId->addr); + return -1; + } + + ASSERT(index >= 0); + pMgr->states[index % pMgr->size].barrier = barrier; + pMgr->states[index % pMgr->size].timeMs = nowMs; + pMgr->states[index % pMgr->size].term = term; + pMgr->states[index % pMgr->size].acked = false; + + pMgr->startIndex = index; + pMgr->endIndex = index + 1; + + SSyncLogBuffer* pBuf = pNode->pLogBuf; + sTrace("vgId:%d, attempted to probe the %d'th peer with msg of index:%" PRId64 " term: %" PRId64 + ". pMgr(rs:%d): [%" PRId64 " %" PRId64 ", %" PRId64 "), pBuf: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 + ")", + pNode->vgId, pMgr->peerId, index, term, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, + pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); + return 0; +} + +int32_t syncLogReplMgrReplicateAttemptedOnce(SSyncLogReplMgr* pMgr, SSyncNode* pNode) { + ASSERT(pMgr->restored); + SRaftId* pDestId = &pNode->replicasId[pMgr->peerId]; + int32_t batchSize = TMAX(1, pMgr->size / 20); + int32_t count = 0; + int64_t nowMs = taosGetMonoTimestampMs(); + int64_t limit = pMgr->size >> 1; + + for (SyncIndex index = pMgr->endIndex; index <= pNode->pLogBuf->matchIndex; index++) { + if (batchSize < count++ || limit <= index - pMgr->startIndex) { + break; + } + if (pMgr->startIndex + 1 < index && pMgr->states[(index - 1) % pMgr->size].barrier) { + break; + } + int64_t pos = index % pMgr->size; + SRaftId* pDestId = &pNode->replicasId[pMgr->peerId]; + bool barrier = false; + SyncTerm term = -1; + if (syncLogBufferReplicateOneTo(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, + terrstr(), index, pDestId->addr); + return -1; + } + pMgr->states[pos].barrier = barrier; + pMgr->states[pos].timeMs = nowMs; + pMgr->states[pos].term = term; + pMgr->states[pos].acked = false; + + pMgr->endIndex = index + 1; + if (barrier) { + 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); + break; + } + } + + syncLogReplMgrRetryOnNeed(pMgr, pNode); + + SSyncLogBuffer* pBuf = pNode->pLogBuf; + sTrace("vgId:%d, attempted to replicate %d msgs to the %d'th peer. pMgr(rs:%d): [%" PRId64 " %" PRId64 ", %" PRId64 + "), pBuf: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", + pNode->vgId, count, pMgr->peerId, pMgr->restored, pMgr->startIndex, pMgr->matchIndex, pMgr->endIndex, + pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); + return 0; +} + +int32_t syncLogReplMgrProcessReplyInNormalMode(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg) { + ASSERT(pMgr->restored == true); + if (pMgr->startIndex <= pMsg->lastSendIndex && pMsg->lastSendIndex < pMgr->endIndex) { + if (pMgr->startIndex < pMgr->matchIndex && pMgr->retryBackoff > 0) { + int64_t firstSentMs = pMgr->states[pMgr->startIndex % pMgr->size].timeMs; + int64_t lastSentMs = pMgr->states[(pMgr->endIndex - 1) % pMgr->size].timeMs; + int64_t timeDiffMs = lastSentMs - firstSentMs; + if (timeDiffMs > 0 && timeDiffMs < (SYNC_LOG_REPL_RETRY_WAIT_MS << (pMgr->retryBackoff - 1))) { + pMgr->retryBackoff -= 1; + } + } + pMgr->states[pMsg->lastSendIndex % pMgr->size].acked = true; + pMgr->matchIndex = TMAX(pMgr->matchIndex, pMsg->matchIndex); + for (SyncIndex index = pMgr->startIndex; index < pMgr->matchIndex; index++) { + memset(&pMgr->states[index % pMgr->size], 0, sizeof(pMgr->states[0])); + } + pMgr->startIndex = pMgr->matchIndex; + } + + return syncLogReplMgrReplicateAttemptedOnce(pMgr, pNode); +} + +SSyncLogReplMgr* syncLogReplMgrCreate() { + SSyncLogReplMgr* pMgr = taosMemoryCalloc(1, sizeof(SSyncLogReplMgr)); + if (pMgr == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + + pMgr->size = sizeof(pMgr->states) / sizeof(pMgr->states[0]); + + ASSERT(pMgr->size == TSDB_SYNC_LOG_BUFFER_SIZE); + + return pMgr; + +_err: + taosMemoryFree(pMgr); + return NULL; +} + +void syncLogReplMgrDestroy(SSyncLogReplMgr* pMgr) { + if (pMgr == NULL) { + return; + } + (void)taosMemoryFree(pMgr); + return; +} + +int32_t syncNodeLogReplMgrInit(SSyncNode* pNode) { + for (int i = 0; i < TSDB_MAX_REPLICA; i++) { + ASSERT(pNode->logReplMgrs[i] == NULL); + pNode->logReplMgrs[i] = syncLogReplMgrCreate(); + pNode->logReplMgrs[i]->peerId = i; + ASSERT(pNode->logReplMgrs[i] != NULL && "Out of memory."); + } + return 0; +} + +void syncNodeLogReplMgrDestroy(SSyncNode* pNode) { + for (int i = 0; i < TSDB_MAX_REPLICA; i++) { + syncLogReplMgrDestroy(pNode->logReplMgrs[i]); + pNode->logReplMgrs[i] = NULL; + } +} + +SSyncLogBuffer* syncLogBufferCreate() { + SSyncLogBuffer* pBuf = taosMemoryCalloc(1, sizeof(SSyncLogBuffer)); + if (pBuf == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + + pBuf->size = sizeof(pBuf->entries) / sizeof(pBuf->entries[0]); + + ASSERT(pBuf->size == TSDB_SYNC_LOG_BUFFER_SIZE); + + if (taosThreadMutexAttrInit(&pBuf->attr) < 0) { + sError("failed to init log buffer mutexattr due to %s", strerror(errno)); + terrno = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + + if (taosThreadMutexAttrSetType(&pBuf->attr, PTHREAD_MUTEX_RECURSIVE) < 0) { + sError("failed to set log buffer mutexattr type due to %s", strerror(errno)); + terrno = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + + if (taosThreadMutexInit(&pBuf->mutex, &pBuf->attr) < 0) { + sError("failed to init log buffer mutex due to %s", strerror(errno)); + terrno = TAOS_SYSTEM_ERROR(errno); + goto _err; + } + + return pBuf; + +_err: + taosMemoryFree(pBuf); + return NULL; +} + +void syncLogBufferClear(SSyncLogBuffer* pBuf) { + taosThreadMutexLock(&pBuf->mutex); + for (SyncIndex index = pBuf->startIndex; index < pBuf->endIndex; index++) { + SSyncRaftEntry* pEntry = pBuf->entries[(index + pBuf->size) % pBuf->size].pItem; + if (pEntry == NULL) continue; + syncEntryDestroy(pEntry); + pEntry = NULL; + memset(&pBuf->entries[(index + pBuf->size) % pBuf->size], 0, sizeof(pBuf->entries[0])); + } + pBuf->startIndex = pBuf->commitIndex = pBuf->matchIndex = pBuf->endIndex = 0; + taosThreadMutexUnlock(&pBuf->mutex); +} + +void syncLogBufferDestroy(SSyncLogBuffer* pBuf) { + if (pBuf == NULL) { + return; + } + syncLogBufferClear(pBuf); + (void)taosThreadMutexDestroy(&pBuf->mutex); + (void)taosThreadMutexAttrDestroy(&pBuf->attr); + (void)taosMemoryFree(pBuf); + return; +} + +int32_t syncLogBufferRollback(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncIndex toIndex) { + ASSERT(pBuf->commitIndex < toIndex && toIndex <= pBuf->endIndex); + + 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); + + // trunc buffer + SyncIndex index = pBuf->endIndex - 1; + while (index >= toIndex) { + SSyncRaftEntry* pEntry = pBuf->entries[index % pBuf->size].pItem; + if (pEntry != NULL) { + (void)syncEntryDestroy(pEntry); + pEntry = NULL; + memset(&pBuf->entries[index % pBuf->size], 0, sizeof(pBuf->entries[0])); + } + index--; + } + pBuf->endIndex = toIndex; + pBuf->matchIndex = TMIN(pBuf->matchIndex, index); + ASSERT(index + 1 == toIndex); + + // trunc wal + SyncIndex lastVer = pNode->pLogStore->syncLogLastIndex(pNode->pLogStore); + if (lastVer >= toIndex && pNode->pLogStore->syncLogTruncate(pNode->pLogStore, toIndex) < 0) { + sError("vgId:%d, failed to truncate log store since %s. from index:%" PRId64 "", pNode->vgId, terrstr(), toIndex); + return -1; + } + lastVer = pNode->pLogStore->syncLogLastIndex(pNode->pLogStore); + ASSERT(toIndex == lastVer + 1); + + syncLogBufferValidate(pBuf); + return 0; +} + +int32_t syncLogBufferReset(SSyncLogBuffer* pBuf, SSyncNode* pNode) { + taosThreadMutexLock(&pBuf->mutex); + SyncIndex lastVer = pNode->pLogStore->syncLogLastIndex(pNode->pLogStore); + ASSERT(lastVer == pBuf->matchIndex); + SyncIndex index = pBuf->endIndex - 1; + + (void)syncLogBufferRollback(pBuf, pNode, pBuf->matchIndex + 1); + + sInfo("vgId:%d, reset sync log buffer. buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", pNode->vgId, + pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); + + pBuf->endIndex = pBuf->matchIndex + 1; + + // reset repl mgr + for (int i = 0; i < pNode->replicaNum; i++) { + SSyncLogReplMgr* pMgr = pNode->logReplMgrs[i]; + syncLogReplMgrReset(pMgr); + } + taosThreadMutexUnlock(&pBuf->mutex); + return 0; +} + +SSyncRaftEntry* syncLogBufferGetOneEntry(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncIndex index, bool* pInBuf) { + SSyncRaftEntry* pEntry = NULL; + if (index >= pBuf->endIndex) { + return NULL; + } + if (index > pBuf->startIndex) { // startIndex might be dummy + *pInBuf = true; + pEntry = pBuf->entries[index % pBuf->size].pItem; + } else { + *pInBuf = false; + if (pNode->pLogStore->syncLogGetEntry(pNode->pLogStore, index, &pEntry) < 0) { + sError("vgId:%d, failed to get log entry since %s. index:%" PRId64 "", pNode->vgId, terrstr(), index); + } + } + return pEntry; +} + +int32_t syncLogBufferReplicateOneTo(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncIndex index, SyncTerm* pTerm, + SRaftId* pDestId, bool* pBarrier) { + SSyncRaftEntry* pEntry = NULL; + SRpcMsg msgOut = {0}; + bool inBuf = false; + int32_t ret = -1; + SyncTerm prevLogTerm = -1; + SSyncLogBuffer* pBuf = pNode->pLogBuf; + + pEntry = syncLogBufferGetOneEntry(pBuf, pNode, index, &inBuf); + if (pEntry == NULL) { + 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, + pDestId->addr, terrstr(), index); + (void)syncLogReplMgrReset(pMgr); + } + } + goto _err; + } + *pBarrier = syncLogIsReplicationBarrier(pEntry); + + 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); + goto _err; + } + if (pTerm) *pTerm = pEntry->term; + + int32_t code = syncBuildAppendEntriesFromRaftLog(pNode, pEntry, prevLogTerm, &msgOut); + if (code < 0) { + sError("vgId:%d, failed to get append entries for index:%" PRId64 "", pNode->vgId, index); + goto _err; + } + + (void)syncNodeSendAppendEntries(pNode, pDestId, &msgOut); + ret = 0; + + 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) { + syncEntryDestroy(pEntry); + pEntry = NULL; + } + return 0; + +_err: + rpcFreeCont(msgOut.pCont); + msgOut.pCont = NULL; + if (!inBuf) { + syncEntryDestroy(pEntry); + pEntry = NULL; + } + return -1; +} diff --git a/source/libs/sync/src/syncRaftCfg.c b/source/libs/sync/src/syncRaftCfg.c index b425b0dba7..c609bfba93 100644 --- a/source/libs/sync/src/syncRaftCfg.c +++ b/source/libs/sync/src/syncRaftCfg.c @@ -395,4 +395,3 @@ int32_t raftCfgFromStr(const char *s, SRaftCfg *pRaftCfg) { cJSON_Delete(pRoot); return 0; } - diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c index 4329722958..988a86cc67 100644 --- a/source/libs/sync/src/syncRaftEntry.c +++ b/source/libs/sync/src/syncRaftEntry.c @@ -20,7 +20,7 @@ SSyncRaftEntry* syncEntryBuild(int32_t dataLen) { int32_t bytes = sizeof(SSyncRaftEntry) + dataLen; - SSyncRaftEntry* pEntry = taosMemoryMalloc(bytes); + SSyncRaftEntry* pEntry = taosMemoryCalloc(1, bytes); if (pEntry == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; @@ -89,7 +89,7 @@ SSyncRaftEntry* syncEntryBuildNoop(SyncTerm term, SyncIndex index, int32_t vgId) return pEntry; } -void syncEntryDestory(SSyncRaftEntry* pEntry) { +void syncEntryDestroy(SSyncRaftEntry* pEntry) { if (pEntry != NULL) { sTrace("free entry: %p", pEntry); taosMemoryFree(pEntry); @@ -265,7 +265,7 @@ static int cmpFn(const void* p1, const void* p2) { return memcmp(p1, p2, sizeof( static void freeRaftEntry(void* param) { SSyncRaftEntry* pEntry = (SSyncRaftEntry*)param; - syncEntryDestory(pEntry); + syncEntryDestroy(pEntry); } SRaftEntryCache* raftEntryCacheCreate(SSyncNode* pSyncNode, int32_t maxCount) { @@ -395,7 +395,7 @@ int32_t raftEntryCacheClear(struct SRaftEntryCache* pCache, int32_t count) { SSkipListNode* pNode = tSkipListIterGet(pIter); ASSERT(pNode != NULL); SSyncRaftEntry* pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(pNode); - syncEntryDestory(pEntry); + syncEntryDestroy(pEntry); ++returnCnt; } tSkipListDestroyIter(pIter); @@ -424,7 +424,7 @@ int32_t raftEntryCacheClear(struct SRaftEntryCache* pCache, int32_t count) { ++returnCnt; SSyncRaftEntry* pEntry = (SSyncRaftEntry*)SL_GET_NODE_DATA(pNode); - // syncEntryDestory(pEntry); + // syncEntryDestroy(pEntry); taosRemoveRef(pCache->refMgr, pEntry->rid); } tSkipListDestroyIter(pIter); diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index 60fc3a9bf7..f51fe344df 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -41,7 +41,7 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) { pLogStore->pCache = taosLRUCacheInit(30 * 1024 * 1024, 1, .5); if (pLogStore->pCache == NULL) { taosMemoryFree(pLogStore); - terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } @@ -201,9 +201,8 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr syncMeta.isWeek = pEntry->isWeak; syncMeta.seqNum = pEntry->seqNum; syncMeta.term = pEntry->term; - int64_t tsWriteBegin = taosGetTimestampNs(); - index = walAppendLog(pWal, pEntry->originalRpcType, syncMeta, pEntry->data, pEntry->dataLen); + index = walAppendLog(pWal, pEntry->index, pEntry->originalRpcType, syncMeta, pEntry->data, pEntry->dataLen); int64_t tsWriteEnd = taosGetTimestampNs(); int64_t tsElapsed = tsWriteEnd - tsWriteBegin; @@ -217,7 +216,8 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr pEntry->index, err, err, errStr, sysErr, sysErrStr); return -1; } - pEntry->index = index; + + ASSERT(pEntry->index == index); sNTrace(pData->pSyncNode, "write index:%" PRId64 ", type:%s, origin type:%s, elapsed:%" PRId64, pEntry->index, TMSG_INFO(pEntry->msgType), TMSG_INFO(pEntry->originalRpcType), tsElapsed); @@ -344,8 +344,6 @@ static int32_t raftLogTruncate(struct SSyncLogStore* pLogStore, SyncIndex fromIn const char* sysErrStr = strerror(errno); sError("vgId:%d, wal truncate error, from-index:%" PRId64 ", err:%d %X, msg:%s, syserr:%d, sysmsg:%s", pData->pSyncNode->vgId, fromIndex, err, err, errStr, sysErr, sysErrStr); - - // ASSERT(0); } // event log @@ -397,8 +395,6 @@ int32_t raftLogUpdateCommitIndex(SSyncLogStore* pLogStore, SyncIndex index) { const char* sysErrStr = strerror(errno); sError("vgId:%d, wal update commit index error, index:%" PRId64 ", err:%d %X, msg:%s, syserr:%d, sysmsg:%s", pData->pSyncNode->vgId, index, err, err, errStr, sysErr, sysErrStr); - - ASSERT(0); return -1; } return 0; diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index 23d83b14e6..0f56921ec7 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -16,13 +16,11 @@ #define _DEFAULT_SOURCE #include "syncReplication.h" #include "syncIndexMgr.h" +#include "syncPipeline.h" #include "syncRaftEntry.h" #include "syncRaftStore.h" #include "syncUtil.h" -static int32_t syncNodeSendAppendEntries(SSyncNode* pNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg); -static int32_t syncNodeMaybeSendAppendEntries(SSyncNode* pNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg); - // TLA+ Spec // AppendEntries(i, j) == // /\ i /= j @@ -48,7 +46,10 @@ static int32_t syncNodeMaybeSendAppendEntries(SSyncNode* pNode, const SRaftId* d // mdest |-> j]) // /\ UNCHANGED <> +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); @@ -117,7 +118,7 @@ int32_t syncNodeReplicateOne(SSyncNode* pSyncNode, SRaftId* pDestId, bool snapsh if (h) { taosLRUCacheRelease(pCache, h, false); } else { - syncEntryDestory(pEntry); + syncEntryDestroy(pEntry); } // prepare msg @@ -136,7 +137,29 @@ int32_t syncNodeReplicateOne(SSyncNode* pSyncNode, SRaftId* pDestId, bool snapsh return 0; } -int32_t syncNodeReplicate(SSyncNode* pSyncNode) { +int32_t syncNodeReplicate(SSyncNode* pNode) { + SSyncLogBuffer* pBuf = pNode->pLogBuf; + taosThreadMutexLock(&pBuf->mutex); + int32_t ret = syncNodeReplicateWithoutLock(pNode); + taosThreadMutexUnlock(&pBuf->mutex); + return ret; +} + +int32_t syncNodeReplicateWithoutLock(SSyncNode* pNode) { + if (pNode->state != TAOS_SYNC_STATE_LEADER || pNode->replicaNum == 1) { + return -1; + } + for (int32_t i = 0; i < pNode->replicaNum; i++) { + if (syncUtilSameId(&pNode->replicasId[i], &pNode->myRaftId)) { + continue; + } + SSyncLogReplMgr* pMgr = pNode->logReplMgrs[i]; + (void)syncLogReplMgrReplicateOnce(pMgr, pNode); + } + return 0; +} + +int32_t syncNodeReplicateOld(SSyncNode* pSyncNode) { if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { return -1; } @@ -159,6 +182,14 @@ int32_t syncNodeReplicate(SSyncNode* pSyncNode) { } int32_t syncNodeSendAppendEntries(SSyncNode* pSyncNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg) { + SyncAppendEntries* pMsg = pRpcMsg->pCont; + int32_t ret = 0; + pMsg->destId = *destRaftId; + syncNodeSendMsgById(destRaftId, pSyncNode, pRpcMsg); + return 0; +} + +int32_t syncNodeSendAppendEntriesOld(SSyncNode* pSyncNode, const SRaftId* destRaftId, SRpcMsg* pRpcMsg) { int32_t ret = 0; SyncAppendEntries* pMsg = pRpcMsg->pCont; if (pMsg == NULL) { @@ -237,4 +268,4 @@ int32_t syncNodeHeartbeatPeers(SSyncNode* pSyncNode) { } return 0; -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncRequestVote.c b/source/libs/sync/src/syncRequestVote.c index 5c38ba1c1a..773befe1e4 100644 --- a/source/libs/sync/src/syncRequestVote.c +++ b/source/libs/sync/src/syncRequestVote.c @@ -124,7 +124,7 @@ int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) { // send msg SRpcMsg rpcMsg = {0}; ret = syncBuildRequestVoteReply(&rpcMsg, ths->vgId); - ASSERT(ret == 0 ); + ASSERT(ret == 0); SyncRequestVoteReply* pReply = rpcMsg.pCont; pReply->srcId = ths->myRaftId; diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 3722b0f6f5..b8ecbe7515 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -16,6 +16,7 @@ #define _DEFAULT_SOURCE #include "syncSnapshot.h" #include "syncIndexMgr.h" +#include "syncPipeline.h" #include "syncRaftCfg.h" #include "syncRaftLog.h" #include "syncRaftStore.h" @@ -273,6 +274,11 @@ int32_t syncNodeStartSnapshot(SSyncNode *pSyncNode, SRaftId *pDestId) { return 1; } + char host[64]; + uint16_t port; + syncUtilU642Addr(pDestId->addr, host, sizeof(host), &port); + sInfo("vgId:%d, start snapshot for peer: %s:%d", pSyncNode->vgId, host, port); + code = snapshotSenderStart(pSender); if (code != 0) { sNError(pSyncNode, "snapshot sender start error"); @@ -372,7 +378,10 @@ int32_t snapshotReceiverStartWriter(SSyncSnapshotReceiver *pReceiver, SyncSnapsh } int32_t snapshotReceiverStart(SSyncSnapshotReceiver *pReceiver, SyncSnapshotSend *pPreMsg) { - ASSERT(!snapshotReceiverIsStart(pReceiver)); + if (snapshotReceiverIsStart(pReceiver)) { + sWarn("vgId:%d, snapshot receiver has started.", pReceiver->pSyncNode->vgId); + return 0; + } pReceiver->start = true; pReceiver->ack = SYNC_SNAPSHOT_SEQ_PRE_SNAPSHOT; @@ -539,6 +548,7 @@ _START_RECEIVER: sNTrace(pSyncNode, "snapshot receiver pre waitting for true time, now:%" PRId64 ", stime:%" PRId64, timeNow, pMsg->startTime); taosMsleep(10); + timeNow = taosGetTimestampMs(); } if (snapshotReceiverIsStart(pReceiver)) { @@ -742,6 +752,7 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_END) { syncNodeOnSnapshotEnd(pSyncNode, pMsg); + (void)syncLogBufferReInit(pSyncNode->pLogBuf, pSyncNode); } else if (pMsg->seq == SYNC_SNAPSHOT_SEQ_FORCE_CLOSE) { // force close, no response @@ -873,11 +884,10 @@ int32_t syncNodeOnSnapshotReply(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { // receive ack is finish, close sender if (pMsg->ack == SYNC_SNAPSHOT_SEQ_END) { snapshotSenderStop(pSender, true); - - // update next-index - syncIndexMgrSetIndex(pSyncNode->pNextIndex, &(pMsg->srcId), pMsg->lastIndex + 1); - syncNodeReplicateOne(pSyncNode, &(pMsg->srcId), false); - + SSyncLogReplMgr *pMgr = syncNodeGetLogReplMgr(pSyncNode, &pMsg->srcId); + if (pMgr) { + syncLogReplMgrReset(pMgr); + } return 0; } diff --git a/source/libs/sync/src/syncTimeout.c b/source/libs/sync/src/syncTimeout.c index 0b58f1080f..cf933d98b2 100644 --- a/source/libs/sync/src/syncTimeout.c +++ b/source/libs/sync/src/syncTimeout.c @@ -131,4 +131,4 @@ int32_t syncNodeOnTimeout(SSyncNode* ths, const SRpcMsg* pRpc) { } return ret; -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index 4cd3a53283..7787438dfe 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -278,20 +278,21 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo terrno = errCode; if (pNode != NULL && pNode->pRaftCfg != NULL) { - taosPrintLog( - flags, level, dflag, - "vgId:%d, sync %s " - "%s" - ", tm:%" PRIu64 ", cmt:%" PRId64 ", fst:%" PRId64 ", lst:%" PRId64 ", min:%" PRId64 ", snap:%" PRId64 - ", snap-tm:%" PRIu64 - ", elt-num:%d, bl-num:%d, cc-num:%d, hit:%d, mis:%d, hb-slow:%d, hbr-slow:%d, aq:%d, snaping:%" PRId64 - ", r-num:%d, lcfg:%" PRId64 ", chging:%d, rsto:%d, dquorum:%d, elt:%" PRId64 ", hb:%" PRId64 ", %s, %s, %s, %s", - pNode->vgId, syncStr(pNode->state), eventLog, currentTerm, pNode->commitIndex, logBeginIndex, logLastIndex, - pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm, pNode->electNum, pNode->becomeLeaderNum, - pNode->configChangeNum, cacheHit, cacheMiss, pNode->hbSlowNum, pNode->hbrSlowNum, aqItems, - pNode->snapshottingIndex, pNode->replicaNum, pNode->pRaftCfg->lastConfigIndex, pNode->changing, - pNode->restoreFinish, quorum, pNode->electTimerLogicClock, pNode->heartbeatTimerLogicClockUser, peerStr, cfgStr, - hbTimeStr, hbrTimeStr); + taosPrintLog(flags, level, dflag, + "vgId:%d, sync %s " + "%s" + ", term:%" PRIu64 ", commit-index:%" PRId64 ", first-ver:%" PRId64 ", last-ver:%" PRId64 + ", min:%" PRId64 ", snap:%" PRId64 ", snap-term:%" PRIu64 + ", elect-times:%d, as-leader-times:%d, cfg-ch-times:%d, hit:%d, mis:%d, hb-slow:%d, hbr-slow:%d, " + "aq-items:%d, snaping:%" PRId64 ", replicas:%d, last-cfg:%" PRId64 + ", chging:%d, restore:%d, quorum:%d, elect-lc-timer:%" PRId64 ", hb:%" PRId64 ", %s, %s, %s, %s", + pNode->vgId, syncStr(pNode->state), eventLog, currentTerm, pNode->commitIndex, logBeginIndex, + logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm, pNode->electNum, + pNode->becomeLeaderNum, pNode->configChangeNum, cacheHit, cacheMiss, pNode->hbSlowNum, + pNode->hbrSlowNum, aqItems, pNode->snapshottingIndex, pNode->replicaNum, + pNode->pRaftCfg->lastConfigIndex, pNode->changing, pNode->restoreFinish, quorum, + pNode->electTimerLogicClock, pNode->heartbeatTimerLogicClockUser, peerStr, cfgStr, hbTimeStr, + hbrTimeStr); } } @@ -427,7 +428,7 @@ void syncLogSendAppendEntriesReply(SSyncNode* pSyncNode, const SyncAppendEntries sNTrace(pSyncNode, "send sync-append-entries-reply to %s:%d, {term:%" PRId64 ", pterm:%" PRId64 ", success:%d, lsend-index:%" PRId64 ", match:%" PRId64 "}, %s", - host, port, pMsg->term, pMsg->privateTerm, pMsg->success, pMsg->lastSendIndex, pMsg->matchIndex, s); + host, port, pMsg->term, pMsg->lastMatchTerm, pMsg->success, pMsg->lastSendIndex, pMsg->matchIndex, s); } void syncLogRecvAppendEntriesReply(SSyncNode* pSyncNode, const SyncAppendEntriesReply* pMsg, const char* s) { @@ -440,7 +441,7 @@ void syncLogRecvAppendEntriesReply(SSyncNode* pSyncNode, const SyncAppendEntries sNTrace(pSyncNode, "recv sync-append-entries-reply from %s:%d {term:%" PRId64 ", pterm:%" PRId64 ", success:%d, lsend-index:%" PRId64 ", match:%" PRId64 "}, %s", - host, port, pMsg->term, pMsg->privateTerm, pMsg->success, pMsg->lastSendIndex, pMsg->matchIndex, s); + host, port, pMsg->term, pMsg->lastMatchTerm, pMsg->success, pMsg->lastSendIndex, pMsg->matchIndex, s); } void syncLogSendHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, bool printX, int64_t timerElapsed, @@ -464,7 +465,7 @@ void syncLogSendHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, bool } } -void syncLogRecvHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, int64_t timeDiff) { +void syncLogRecvHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, int64_t timeDiff, const char* s) { if (timeDiff > SYNC_HEARTBEAT_SLOW_MS) { pSyncNode->hbSlowNum++; @@ -473,8 +474,8 @@ void syncLogRecvHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, int64 syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); sNInfo(pSyncNode, "recv sync-heartbeat from %s:%d slow {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 ", ts:%" PRId64 - "}, net elapsed:%" PRId64, - host, port, pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, timeDiff); + "}, %s, net elapsed:%" PRId64, + host, port, pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, s, timeDiff); } if (!(sDebugFlag & DEBUG_TRACE)) return; @@ -484,8 +485,8 @@ void syncLogRecvHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, int64 syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); sNTrace(pSyncNode, "recv sync-heartbeat from %s:%d {term:%" PRId64 ", cmt:%" PRId64 ", min-match:%" PRId64 ", ts:%" PRId64 - "}, net elapsed:%" PRId64, - host, port, pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, timeDiff); + "}, %s, net elapsed:%" PRId64, + host, port, pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, s, timeDiff); } void syncLogSendHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* pMsg, const char* s) { @@ -499,7 +500,7 @@ void syncLogSendHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* p pMsg->term, pMsg->timeStamp, s); } -void syncLogRecvHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* pMsg, int64_t timeDiff) { +void syncLogRecvHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* pMsg, int64_t timeDiff, const char* s) { if (timeDiff > SYNC_HEARTBEAT_REPLY_SLOW_MS) { pSyncNode->hbrSlowNum++; @@ -507,8 +508,8 @@ void syncLogRecvHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* p uint16_t port; syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); sNTrace(pSyncNode, - "recv sync-heartbeat-reply from %s:%d slow {term:%" PRId64 ", ts:%" PRId64 "}, net elapsed:%" PRId64, host, - port, pMsg->term, pMsg->timeStamp, timeDiff); + "recv sync-heartbeat-reply from %s:%d slow {term:%" PRId64 ", ts:%" PRId64 "}, %s, net elapsed:%" PRId64, + host, port, pMsg->term, pMsg->timeStamp, s, timeDiff); } if (!(sDebugFlag & DEBUG_TRACE)) return; @@ -516,8 +517,9 @@ void syncLogRecvHeartbeatReply(SSyncNode* pSyncNode, const SyncHeartbeatReply* p char host[64]; uint16_t port; syncUtilU642Addr(pMsg->srcId.addr, host, sizeof(host), &port); - sNTrace(pSyncNode, "recv sync-heartbeat-reply from %s:%d {term:%" PRId64 ", ts:%" PRId64 "}, net elapsed:%" PRId64, - host, port, pMsg->term, pMsg->timeStamp, timeDiff); + sNTrace(pSyncNode, + "recv sync-heartbeat-reply from %s:%d {term:%" PRId64 ", ts:%" PRId64 "}, %s, net elapsed:%" PRId64, host, + port, pMsg->term, pMsg->timeStamp, s, timeDiff); } void syncLogSendSyncPreSnapshot(SSyncNode* pSyncNode, const SyncPreSnapshot* pMsg, const char* s) { diff --git a/source/libs/sync/test/syncAppendEntriesBatchTest.cpp b/source/libs/sync/test/syncAppendEntriesBatchTest.cpp index 964d991bb0..5534803c9c 100644 --- a/source/libs/sync/test/syncAppendEntriesBatchTest.cpp +++ b/source/libs/sync/test/syncAppendEntriesBatchTest.cpp @@ -1,5 +1,5 @@ -#include "syncTest.h" #include "syncBatch.h" +#include "syncTest.h" void logTest() { sTrace("--- sync log test: trace"); diff --git a/source/libs/sync/test/syncEnvTest.cpp b/source/libs/sync/test/syncEnvTest.cpp index 3cd6048428..15200c8a63 100644 --- a/source/libs/sync/test/syncEnvTest.cpp +++ b/source/libs/sync/test/syncEnvTest.cpp @@ -21,12 +21,12 @@ int main() { assert(ret == 0); for (int i = 0; i < 5; ++i) { - //ret = syncEnvStartTimer(); + // ret = syncEnvStartTimer(); assert(ret == 0); taosMsleep(5000); - //ret = syncEnvStopTimer(); + // ret = syncEnvStopTimer(); assert(ret == 0); taosMsleep(5000); diff --git a/source/libs/sync/test/syncLocalCmdTest.cpp b/source/libs/sync/test/syncLocalCmdTest.cpp index fa0d91d45f..8003cce7cc 100644 --- a/source/libs/sync/test/syncLocalCmdTest.cpp +++ b/source/libs/sync/test/syncLocalCmdTest.cpp @@ -31,8 +31,8 @@ void test1() { void test2() { SyncLocalCmd *pMsg = createMsg(); - uint32_t len = pMsg->bytes; - char *serialized = (char *)taosMemoryMalloc(len); + uint32_t len = pMsg->bytes; + char *serialized = (char *)taosMemoryMalloc(len); syncLocalCmdSerialize(pMsg, serialized, len); SyncLocalCmd *pMsg2 = syncLocalCmdBuild(1000); syncLocalCmdDeserialize(serialized, len, pMsg2); @@ -45,8 +45,8 @@ void test2() { void test3() { SyncLocalCmd *pMsg = createMsg(); - uint32_t len; - char *serialized = syncLocalCmdSerialize2(pMsg, &len); + uint32_t len; + char *serialized = syncLocalCmdSerialize2(pMsg, &len); SyncLocalCmd *pMsg2 = syncLocalCmdDeserialize2(serialized, len); syncLocalCmdLog2((char *)"test3: syncLocalCmdSerialize3 -> syncLocalCmdDeserialize2 ", pMsg2); @@ -57,7 +57,7 @@ void test3() { void test4() { SyncLocalCmd *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncLocalCmd2RpcMsg(pMsg, &rpcMsg); SyncLocalCmd *pMsg2 = (SyncLocalCmd *)taosMemoryMalloc(rpcMsg.contLen); syncLocalCmdFromRpcMsg(&rpcMsg, pMsg2); @@ -70,7 +70,7 @@ void test4() { void test5() { SyncLocalCmd *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncLocalCmd2RpcMsg(pMsg, &rpcMsg); SyncLocalCmd *pMsg2 = syncLocalCmdFromRpcMsg2(&rpcMsg); syncLocalCmdLog2((char *)"test5: syncLocalCmd2RpcMsg -> syncLocalCmdFromRpcMsg2 ", pMsg2); diff --git a/source/libs/sync/test/syncPreSnapshotReplyTest.cpp b/source/libs/sync/test/syncPreSnapshotReplyTest.cpp index e5175f1101..3b7bbe7ef7 100644 --- a/source/libs/sync/test/syncPreSnapshotReplyTest.cpp +++ b/source/libs/sync/test/syncPreSnapshotReplyTest.cpp @@ -30,8 +30,8 @@ void test1() { void test2() { SyncPreSnapshotReply *pMsg = createMsg(); - uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + uint32_t len = pMsg->bytes; + char *serialized = (char *)taosMemoryMalloc(len); syncPreSnapshotReplySerialize(pMsg, serialized, len); SyncPreSnapshotReply *pMsg2 = syncPreSnapshotReplyBuild(789); syncPreSnapshotReplyDeserialize(serialized, len, pMsg2); @@ -44,8 +44,8 @@ void test2() { void test3() { SyncPreSnapshotReply *pMsg = createMsg(); - uint32_t len; - char * serialized = syncPreSnapshotReplySerialize2(pMsg, &len); + uint32_t len; + char *serialized = syncPreSnapshotReplySerialize2(pMsg, &len); SyncPreSnapshotReply *pMsg2 = syncPreSnapshotReplyDeserialize2(serialized, len); syncPreSnapshotReplyLog2((char *)"test3: syncPreSnapshotReplySerialize2 -> syncPreSnapshotReplyDeserialize2 ", pMsg2); @@ -56,7 +56,7 @@ void test3() { void test4() { SyncPreSnapshotReply *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncPreSnapshotReply2RpcMsg(pMsg, &rpcMsg); SyncPreSnapshotReply *pMsg2 = (SyncPreSnapshotReply *)taosMemoryMalloc(rpcMsg.contLen); syncPreSnapshotReplyFromRpcMsg(&rpcMsg, pMsg2); @@ -69,7 +69,7 @@ void test4() { void test5() { SyncPreSnapshotReply *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncPreSnapshotReply2RpcMsg(pMsg, &rpcMsg); SyncPreSnapshotReply *pMsg2 = syncPreSnapshotReplyFromRpcMsg2(&rpcMsg); syncPreSnapshotReplyLog2((char *)"test5: syncPreSnapshotReply2RpcMsg -> syncPreSnapshotReplyFromRpcMsg2 ", pMsg2); diff --git a/source/libs/sync/test/syncPreSnapshotTest.cpp b/source/libs/sync/test/syncPreSnapshotTest.cpp index 2ce95abea3..4279c23e33 100644 --- a/source/libs/sync/test/syncPreSnapshotTest.cpp +++ b/source/libs/sync/test/syncPreSnapshotTest.cpp @@ -28,8 +28,8 @@ void test1() { void test2() { SyncPreSnapshot *pMsg = createMsg(); - uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + uint32_t len = pMsg->bytes; + char *serialized = (char *)taosMemoryMalloc(len); syncPreSnapshotSerialize(pMsg, serialized, len); SyncPreSnapshot *pMsg2 = syncPreSnapshotBuild(789); syncPreSnapshotDeserialize(serialized, len, pMsg2); @@ -42,8 +42,8 @@ void test2() { void test3() { SyncPreSnapshot *pMsg = createMsg(); - uint32_t len; - char * serialized = syncPreSnapshotSerialize2(pMsg, &len); + uint32_t len; + char *serialized = syncPreSnapshotSerialize2(pMsg, &len); SyncPreSnapshot *pMsg2 = syncPreSnapshotDeserialize2(serialized, len); syncPreSnapshotLog2((char *)"test3: syncPreSnapshotSerialize2 -> syncPreSnapshotDeserialize2 ", pMsg2); @@ -54,7 +54,7 @@ void test3() { void test4() { SyncPreSnapshot *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncPreSnapshot2RpcMsg(pMsg, &rpcMsg); SyncPreSnapshot *pMsg2 = (SyncPreSnapshot *)taosMemoryMalloc(rpcMsg.contLen); syncPreSnapshotFromRpcMsg(&rpcMsg, pMsg2); @@ -67,7 +67,7 @@ void test4() { void test5() { SyncPreSnapshot *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncPreSnapshot2RpcMsg(pMsg, &rpcMsg); SyncPreSnapshot *pMsg2 = syncPreSnapshotFromRpcMsg2(&rpcMsg); syncPreSnapshotLog2((char *)"test5: syncPreSnapshot2RpcMsg -> syncPreSnapshotFromRpcMsg2 ", pMsg2); diff --git a/source/libs/sync/test/syncRespMgrTest.cpp b/source/libs/sync/test/syncRespMgrTest.cpp index b609ef1a0e..74246abf62 100644 --- a/source/libs/sync/test/syncRespMgrTest.cpp +++ b/source/libs/sync/test/syncRespMgrTest.cpp @@ -63,7 +63,7 @@ void syncRespMgrGetAndDelTest(uint64_t i) { SRpcHandleInfo stub; int32_t ret = syncRespMgrGetAndDel(pMgr, i, &stub); if (ret == 1) { - //printStub(&stub); + // printStub(&stub); } else if (ret == 0) { printf("%" PRId64 " notFound \n", i); } diff --git a/source/libs/sync/test/syncSnapshotSenderTest.cpp b/source/libs/sync/test/syncSnapshotSenderTest.cpp index 9a234d412e..bb697d541a 100644 --- a/source/libs/sync/test/syncSnapshotSenderTest.cpp +++ b/source/libs/sync/test/syncSnapshotSenderTest.cpp @@ -32,7 +32,7 @@ SSyncSnapshotSender* createSender() { pSyncNode->pRaftStore = (SRaftStore*)taosMemoryMalloc(sizeof(*(pSyncNode->pRaftStore))); pSyncNode->pFsm = (SSyncFSM*)taosMemoryMalloc(sizeof(*(pSyncNode->pFsm))); - #if 0 +#if 0 pSyncNode->pFsm->FpSnapshotStartRead = SnapshotStartRead; pSyncNode->pFsm->FpSnapshotStopRead = SnapshotStopRead; pSyncNode->pFsm->FpSnapshotDoRead = SnapshotDoRead; @@ -52,8 +52,8 @@ SSyncSnapshotSender* createSender() { pSender->snapshot.lastApplyTerm = 88; pSender->sendingMS = 77; pSender->term = 66; - - //pSender->privateTerm = 99; + + // pSender->privateTerm = 99; return pSender; } diff --git a/source/libs/sync/test/syncSnapshotTest.cpp b/source/libs/sync/test/syncSnapshotTest.cpp index 000348bf1b..27022f5c3f 100644 --- a/source/libs/sync/test/syncSnapshotTest.cpp +++ b/source/libs/sync/test/syncSnapshotTest.cpp @@ -76,7 +76,6 @@ void initFsm() { pFsm->FpRollBackCb = RollBackCb; pFsm->FpGetSnapshotInfo = GetSnapshotCb; #endif - } SSyncNode *syncNodeInit() { diff --git a/source/libs/sync/test/syncTest.cpp b/source/libs/sync/test/syncTest.cpp index 55480802da..9ae79e11fb 100644 --- a/source/libs/sync/test/syncTest.cpp +++ b/source/libs/sync/test/syncTest.cpp @@ -1,5 +1,5 @@ -#include #include "syncTest.h" +#include /* typedef enum { diff --git a/source/libs/sync/test/syncWriteTest.cpp b/source/libs/sync/test/syncWriteTest.cpp index aae1862681..6aec4c0d6d 100644 --- a/source/libs/sync/test/syncWriteTest.cpp +++ b/source/libs/sync/test/syncWriteTest.cpp @@ -54,7 +54,6 @@ void initFsm() { pFsm->FpPreCommitCb = PreCommitCb; pFsm->FpRollBackCb = RollBackCb; #endif - } SSyncNode *syncNodeInit() { diff --git a/source/libs/sync/test/sync_test_lib/inc/syncTest.h b/source/libs/sync/test/sync_test_lib/inc/syncTest.h index 443d3a45d6..ae4cc6ed6f 100644 --- a/source/libs/sync/test/sync_test_lib/inc/syncTest.h +++ b/source/libs/sync/test/sync_test_lib/inc/syncTest.h @@ -25,7 +25,6 @@ extern "C" { #include "tref.h" #include "wal.h" -#include "tref.h" #include "syncEnv.h" #include "syncIO.h" #include "syncIndexMgr.h" @@ -39,6 +38,7 @@ extern "C" { #include "syncSnapshot.h" #include "syncUtil.h" #include "syncVoteMgr.h" +#include "tref.h" extern void addEpIntoEpSet(SEpSet* pEpSet, const char* fqdn, uint16_t port); @@ -125,12 +125,12 @@ char* snapshotSender2Str(SSyncSnapshotSender* pSender); cJSON* snapshotReceiver2Json(SSyncSnapshotReceiver* pReceiver); char* snapshotReceiver2Str(SSyncSnapshotReceiver* pReceiver); -cJSON* syncIndexMgr2Json(SSyncIndexMgr* pSyncIndexMgr); -char* syncIndexMgr2Str(SSyncIndexMgr* pSyncIndexMgr); -void syncIndexMgrPrint(SSyncIndexMgr* pObj); -void syncIndexMgrPrint2(char* s, SSyncIndexMgr* pObj); -void syncIndexMgrLog(SSyncIndexMgr* pObj); -void syncIndexMgrLog2(char* s, SSyncIndexMgr* pObj); +cJSON* syncIndexMgr2Json(SSyncIndexMgr* pSyncIndexMgr); +char* syncIndexMgr2Str(SSyncIndexMgr* pSyncIndexMgr); +void syncIndexMgrPrint(SSyncIndexMgr* pObj); +void syncIndexMgrPrint2(char* s, SSyncIndexMgr* pObj); +void syncIndexMgrLog(SSyncIndexMgr* pObj); +void syncIndexMgrLog2(char* s, SSyncIndexMgr* pObj); cJSON* syncRpcMsg2Json(SRpcMsg* pRpcMsg); cJSON* syncRpcUnknownMsg2Json(); @@ -140,7 +140,6 @@ void syncRpcMsgPrint2(char* s, SRpcMsg* pMsg); void syncRpcMsgLog(SRpcMsg* pMsg); void syncRpcMsgLog2(char* s, SRpcMsg* pMsg); - // origin syncMessage typedef struct SyncPing { uint32_t bytes; @@ -153,7 +152,6 @@ typedef struct SyncPing { char data[]; } SyncPing; - SyncPing* syncPingBuild(uint32_t dataLen); SyncPing* syncPingBuild2(const SRaftId* srcId, const SRaftId* destId, int32_t vgId, const char* str); SyncPing* syncPingBuild3(const SRaftId* srcId, const SRaftId* destId, int32_t vgId); diff --git a/source/libs/sync/test/sync_test_lib/src/syncBatch.c b/source/libs/sync/test/sync_test_lib/src/syncBatch.c index b2db1e084a..cb4bed1e67 100644 --- a/source/libs/sync/test/sync_test_lib/src/syncBatch.c +++ b/source/libs/sync/test/sync_test_lib/src/syncBatch.c @@ -14,8 +14,8 @@ */ #define _DEFAULT_SOURCE -#include "syncTest.h" #include "syncBatch.h" +#include "syncTest.h" // ---- message process SyncClientRequestBatch---- diff --git a/source/libs/sync/test/sync_test_lib/src/syncRaftStoreDebug.c b/source/libs/sync/test/sync_test_lib/src/syncRaftStoreDebug.c index 0c4dd95e48..c462b3275d 100644 --- a/source/libs/sync/test/sync_test_lib/src/syncRaftStoreDebug.c +++ b/source/libs/sync/test/sync_test_lib/src/syncRaftStoreDebug.c @@ -14,8 +14,8 @@ */ #define _DEFAULT_SOURCE -#include "syncTest.h" #include "cJSON.h" +#include "syncTest.h" int32_t raftStoreFromJson(SRaftStore *pRaftStore, cJSON *pJson) { return 0; } diff --git a/source/libs/tdb/inc/tdb.h b/source/libs/tdb/inc/tdb.h index 7ab2bc3995..c728e29641 100644 --- a/source/libs/tdb/inc/tdb.h +++ b/source/libs/tdb/inc/tdb.h @@ -17,6 +17,7 @@ #define _TD_TDB_H_ #include "os.h" +#include "tdbOs.h" #ifdef __cplusplus extern "C" { @@ -33,7 +34,8 @@ typedef struct STxn TXN; // TDB int32_t tdbOpen(const char *dbname, int szPage, int pages, TDB **ppDb, int8_t rollback); int32_t tdbClose(TDB *pDb); -int32_t tdbBegin(TDB *pDb, TXN *pTxn); +int32_t tdbBegin(TDB *pDb, TXN **pTxn, void *(*xMalloc)(void *, size_t), void (*xFree)(void *, void *), void *xArg, + int flags); int32_t tdbCommit(TDB *pDb, TXN *pTxn); int32_t tdbPostCommit(TDB *pDb, TXN *pTxn); int32_t tdbPrepareAsyncCommit(TDB *pDb, TXN *pTxn); @@ -77,12 +79,16 @@ int32_t tdbTxnClose(TXN *pTxn); // other void tdbFree(void *); +typedef struct hashset_st *hashset_t; + struct STxn { int flags; int64_t txnId; void *(*xMalloc)(void *, size_t); void (*xFree)(void *, void *); - void *xArg; + void *xArg; + tdb_fd_t jfd; + hashset_t jPageSet; }; // error code diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index fcf9d6ce3e..8c62f89b64 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -69,7 +69,7 @@ static int tdbBtreeCellSize(const SPage *pPage, SCell *pCell, int dropOfp, TXN * static int tdbBtcMoveDownward(SBTC *pBtc); static int tdbBtcMoveUpward(SBTC *pBtc); -int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPgno pgno, tdb_cmpr_fn_t kcmpr, +int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPgno pgno, tdb_cmpr_fn_t kcmpr, TDB *pEnv, SBTree **ppBt) { SBTree *pBt; int ret; @@ -106,22 +106,26 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg if (pgno == 0) { // fetch page & insert into main db SPage *pPage; - TXN txn; - tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); + TXN *txn; - pPager->inTran = 1; + ret = tdbBegin(pEnv, &txn, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); + if (ret < 0) { + return -1; + } SBtreeInitPageArg zArg; zArg.flags = 0x1 | 0x2; // root leaf node; zArg.pBt = pBt; - ret = tdbPagerFetchPage(pPager, &pgno, &pPage, tdbBtreeInitPage, &zArg, &txn); + ret = tdbPagerFetchPage(pPager, &pgno, &pPage, tdbBtreeInitPage, &zArg, txn); if (ret < 0) { + tdbAbort(pEnv, txn); return -1; } ret = tdbPagerWrite(pPager, pPage); if (ret < 0) { tdbError("failed to write page since %s", terrstr()); + tdbAbort(pEnv, txn); return -1; } @@ -130,18 +134,18 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg pBt->info.nLevel = 1; pBt->info.nData = 0; pBt->tbname = (char *)tbname; - // ret = tdbTbInsert(pPager->pEnv->pMainDb, tbname, strlen(tbname) + 1, &pgno, sizeof(SPgno), &txn); - ret = tdbTbInsert(pPager->pEnv->pMainDb, tbname, strlen(tbname) + 1, &pBt->info, sizeof(pBt->info), &txn); + + ret = tdbTbInsert(pPager->pEnv->pMainDb, tbname, strlen(tbname) + 1, &pBt->info, sizeof(pBt->info), txn); if (ret < 0) { + tdbAbort(pEnv, txn); return -1; } } - // tdbUnrefPage(pPage); - tdbPCacheRelease(pPager->pCache, pPage, &txn); - tdbCommit(pPager->pEnv, &txn); - tdbPostCommit(pPager->pEnv, &txn); - tdbTxnClose(&txn); + tdbPCacheRelease(pPager->pCache, pPage, txn); + + tdbCommit(pPager->pEnv, txn); + tdbPostCommit(pPager->pEnv, txn); } ASSERT(pgno != 0); @@ -195,7 +199,8 @@ int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, in btc.idx++; } else if (c == 0) { // dup key not allowed - ASSERT(0); + tdbError("unable to insert dup key. pKey: %p, kLen: %d, btc: %p, pTxn: %p", pKey, kLen, &btc, pTxn); + // ASSERT(0); return -1; } } @@ -1533,10 +1538,21 @@ int tdbBtcOpen(SBTC *pBtc, SBTree *pBt, TXN *pTxn) { memset(&pBtc->coder, 0, sizeof(SCellDecoder)); if (pTxn == NULL) { - pBtc->pTxn = &pBtc->txn; - tdbTxnOpen(pBtc->pTxn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0); + TXN *pTxn = tdbOsCalloc(1, sizeof(*pTxn)); + if (!pTxn) { + return -1; + } + + if (tdbTxnOpen(pTxn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0) < 0) { + tdbOsFree(pTxn); + return -1; + } + + pBtc->pTxn = pTxn; + pBtc->freeTxn = 1; } else { pBtc->pTxn = pTxn; + pBtc->freeTxn = 0; } return 0; @@ -2230,6 +2246,10 @@ int tdbBtcClose(SBTC *pBtc) { tdbFree(pBtc->coder.pVal); } + if (pBtc->freeTxn) { + tdbTxnClose(pBtc->pTxn); + } + return 0; } diff --git a/source/libs/tdb/src/db/tdbDb.c b/source/libs/tdb/src/db/tdbDb.c index 5aff5b7bb2..c79279c658 100644 --- a/source/libs/tdb/src/db/tdbDb.c +++ b/source/libs/tdb/src/db/tdbDb.c @@ -99,19 +99,37 @@ int tdbClose(TDB *pDb) { int32_t tdbAlter(TDB *pDb, int pages) { return tdbPCacheAlter(pDb->pCache, pages); } -int32_t tdbBegin(TDB *pDb, TXN *pTxn) { +int32_t tdbBegin(TDB *pDb, TXN **ppTxn, void *(*xMalloc)(void *, size_t), void (*xFree)(void *, void *), void *xArg, + int flags) { SPager *pPager; int ret; + int64_t txnId = ++pDb->txnId; + if (txnId == INT64_MAX) { + pDb->txnId = 0; + } + + TXN *pTxn = tdbOsCalloc(1, sizeof(*pTxn)); + if (!pTxn) { + return -1; + } + + if (tdbTxnOpen(pTxn, txnId, xMalloc, xFree, xArg, flags) < 0) { + tdbOsFree(pTxn); + return -1; + } for (pPager = pDb->pgrList; pPager; pPager = pPager->pNext) { ret = tdbPagerBegin(pPager, pTxn); if (ret < 0) { tdbError("failed to begin pager since %s. dbName:%s, txnId:%" PRId64, tstrerror(terrno), pDb->dbName, pTxn->txnId); + tdbTxnClose(pTxn); return -1; } } + *ppTxn = pTxn; + return 0; } @@ -144,6 +162,8 @@ int32_t tdbPostCommit(TDB *pDb, TXN *pTxn) { } } + tdbTxnClose(pTxn); + return 0; } @@ -176,6 +196,8 @@ int32_t tdbAbort(TDB *pDb, TXN *pTxn) { } } + tdbTxnClose(pTxn); + return 0; } diff --git a/source/libs/tdb/src/db/tdbPage.c b/source/libs/tdb/src/db/tdbPage.c index 016ad65cf3..0653b6fc36 100644 --- a/source/libs/tdb/src/db/tdbPage.c +++ b/source/libs/tdb/src/db/tdbPage.c @@ -69,14 +69,15 @@ int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t) *ppPage = pPage; - tdbDebug("page/create: %p %p", pPage, xMalloc); + tdbTrace("page/create: %p/%d %p", pPage, pPage->id, xMalloc); return 0; } int tdbPageDestroy(SPage *pPage, void (*xFree)(void *arg, void *ptr), void *arg) { u8 *ptr; - tdbDebug("page/destroy: %p %p", pPage, xFree); + tdbTrace("page/destroy: %p/%d %p", pPage, pPage->id, xFree); + ASSERT(!pPage->isDirty); ASSERT(xFree); for (int iOvfl = 0; iOvfl < pPage->nOverflow; iOvfl++) { diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index ea67986da2..7f0fdf9efc 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -142,7 +142,7 @@ int hashset_contains(hashset_t set, void *item) { static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage *, void *, int), void *arg, u8 loadPage); static int tdbPagerWritePageToJournal(SPager *pPager, SPage *pPage); -static int tdbPagerWritePageToDB(SPager *pPager, SPage *pPage); +static int tdbPagerPWritePageToDB(SPager *pPager, SPage *pPage); static FORCE_INLINE int32_t pageCmpFn(const SRBTreeNode *lhs, const SRBTreeNode *rhs) { SPage *pPageL = (SPage *)(((uint8_t *)lhs) - offsetof(SPage, node)); @@ -219,80 +219,22 @@ int tdbPagerOpen(SPCache *pCache, const char *fileName, SPager **ppPager) { int tdbPagerClose(SPager *pPager) { if (pPager) { + /* if (pPager->inTran) { tdbOsClose(pPager->jfd); } + */ tdbOsClose(pPager->fd); tdbOsFree(pPager); } return 0; } -/* -int tdbPagerOpenDB(SPager *pPager, SPgno *ppgno, bool toCreate, SBTree *pBt) { - SPgno pgno; - SPage *pPage; - int ret; - if (pPager->dbOrigSize > 0) { - pgno = 1; - } else { - pgno = 0; - } - - { - // TODO: try to search the main DB to get the page number - // pgno = 0; - } - - if (pgno == 0 && toCreate) { - // allocate a new child page - TXN txn; - tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0); - - pPager->inTran = 1; - - SBtreeInitPageArg zArg; - zArg.flags = 0x1 | 0x2; // root leaf node; - zArg.pBt = pBt; - ret = tdbPagerFetchPage(pPager, &pgno, &pPage, tdbBtreeInitPage, &zArg, &txn); - if (ret < 0) { - return -1; - } - - // ret = tdbPagerAllocPage(pPager, &pPage, &pgno); - // if (ret < 0) { - // return -1; - //} - - // TODO: Need to zero the page - - ret = tdbPagerWrite(pPager, pPage); - if (ret < 0) { - tdbError("failed to write page since %s", terrstr()); - return -1; - } - - tdbTxnClose(&txn); - } - - *ppgno = pgno; - return 0; -} -*/ int tdbPagerWrite(SPager *pPager, SPage *pPage) { int ret; SPage **ppPage; - ASSERT(pPager->inTran); -#if 0 - if (pPager->inTran == 0) { - ret = tdbPagerBegin(pPager); - if (ret < 0) { - return -1; - } - } -#endif - + // ASSERT(pPager->inTran); if (pPage->isDirty) return 0; // ref page one more time so the page will not be release @@ -322,15 +264,16 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) { // Write page to journal if neccessary if (TDB_PAGE_PGNO(pPage) <= pPager->dbOrigSize && - (pPager->jPageSet == NULL || !hashset_contains(pPager->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))))) { + (pPager->pActiveTxn->jPageSet == NULL || + !hashset_contains(pPager->pActiveTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))))) { ret = tdbPagerWritePageToJournal(pPager, pPage); if (ret < 0) { tdbError("failed to write page to journal since %s", tstrerror(terrno)); return -1; } - if (pPager->jPageSet) { - hashset_add(pPager->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); + if (pPager->pActiveTxn->jPageSet) { + hashset_add(pPager->pActiveTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); } } @@ -338,23 +281,28 @@ int tdbPagerWrite(SPager *pPager, SPage *pPage) { } int tdbPagerBegin(SPager *pPager, TXN *pTxn) { + /* if (pPager->inTran) { return 0; } - + */ // Open the journal - pPager->jfd = tdbOsOpen(pPager->jFileName, TDB_O_CREAT | TDB_O_RDWR, 0755); - if (TDB_FD_INVALID(pPager->jfd)) { + char jTxnFileName[TDB_FILENAME_LEN]; + sprintf(jTxnFileName, "%s.%" PRId64, pPager->jFileName, pTxn->txnId); + pTxn->jfd = tdbOsOpen(jTxnFileName, TDB_O_CREAT | TDB_O_RDWR, 0755); + if (TDB_FD_INVALID(pTxn->jfd)) { tdbError("failed to open file due to %s. jFileName:%s", strerror(errno), pPager->jFileName); terrno = TAOS_SYSTEM_ERROR(errno); return -1; } - pPager->jPageSet = hashset_create(); + pTxn->jPageSet = hashset_create(); + + pPager->pActiveTxn = pTxn; // TODO: write the size of the file - + /* pPager->inTran = 1; - + */ return 0; } @@ -363,9 +311,9 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) { int ret; // sync the journal file - ret = tdbOsFSync(pPager->jfd); + ret = tdbOsFSync(pTxn->jfd); if (ret < 0) { - tdbError("failed to fsync jfd due to %s. jFileName:%s", strerror(errno), pPager->jFileName); + tdbError("failed to fsync: %s. jFileName:%s, %" PRId64, strerror(errno), pPager->jFileName, pTxn->txnId); terrno = TAOS_SYSTEM_ERROR(errno); return -1; } @@ -377,7 +325,7 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) { pPage = (SPage *)pNode; ASSERT(pPage->nOverflow == 0); - ret = tdbPagerWritePageToDB(pPager, pPage); + ret = tdbPagerPWritePageToDB(pPager, pPage); if (ret < 0) { tdbError("failed to write page to db since %s", tstrerror(terrno)); return -1; @@ -395,8 +343,8 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) { pPage->isDirty = 0; tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage); - if (pPager->jPageSet) { - hashset_remove(pPager->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); + if (pTxn->jPageSet) { + hashset_remove(pTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); } tdbPCacheRelease(pPager->pCache, pPage, pTxn); } @@ -415,35 +363,39 @@ int tdbPagerCommit(SPager *pPager, TXN *pTxn) { } int tdbPagerPostCommit(SPager *pPager, TXN *pTxn) { + char jTxnFileName[TDB_FILENAME_LEN]; + sprintf(jTxnFileName, "%s.%" PRId64, pPager->jFileName, pTxn->txnId); + // remove the journal file - if (tdbOsClose(pPager->jfd) < 0) { - tdbError("failed to close jfd due to %s. file:%s", strerror(errno), pPager->jFileName); + if (tdbOsClose(pTxn->jfd) < 0) { + tdbError("failed to close jfd: %s. file:%s, %" PRId64, strerror(errno), pPager->jFileName, pTxn->txnId); terrno = TAOS_SYSTEM_ERROR(errno); return -1; } - if (tdbOsRemove(pPager->jFileName) < 0 && errno != ENOENT) { - tdbError("failed to remove file due to %s. file:%s", strerror(errno), pPager->jFileName); + if (tdbOsRemove(jTxnFileName) < 0 && errno != ENOENT) { + tdbError("failed to remove file due to %s. file:%s", strerror(errno), jTxnFileName); terrno = TAOS_SYSTEM_ERROR(errno); return -1; } - if (pPager->jPageSet) { - hashset_destroy(pPager->jPageSet); + if (pTxn->jPageSet) { + hashset_destroy(pTxn->jPageSet); } - pPager->inTran = 0; + // pPager->inTran = 0; return 0; } int tdbPagerPrepareAsyncCommit(SPager *pPager, TXN *pTxn) { SPage *pPage; + SPgno maxPgno = pPager->dbOrigSize; int ret; // sync the journal file - ret = tdbOsFSync(pPager->jfd); + ret = tdbOsFSync(pTxn->jfd); if (ret < 0) { - tdbError("failed to fsync jfd due to %s. jFileName:%s", strerror(errno), pPager->jFileName); + tdbError("failed to fsync jfd: %s. jfile:%s, %" PRId64, strerror(errno), pPager->jFileName, pTxn->txnId); terrno = TAOS_SYSTEM_ERROR(errno); return -1; } @@ -454,7 +406,12 @@ int tdbPagerPrepareAsyncCommit(SPager *pPager, TXN *pTxn) { while ((pNode = tRBTreeIterNext(&iter)) != NULL) { pPage = (SPage *)pNode; if (pPage->isLocal) continue; - ret = tdbPagerWritePageToDB(pPager, pPage); + + SPgno pgno = TDB_PAGE_PGNO(pPage); + if (pgno > maxPgno) { + maxPgno = pgno; + } + ret = tdbPagerPWritePageToDB(pPager, pPage); if (ret < 0) { tdbError("failed to write page to db since %s", tstrerror(terrno)); return -1; @@ -462,7 +419,8 @@ int tdbPagerPrepareAsyncCommit(SPager *pPager, TXN *pTxn) { } tdbTrace("tdbttl commit:%p, %d/%d", pPager, pPager->dbOrigSize, pPager->dbFileSize); - pPager->dbOrigSize = pPager->dbFileSize; + pPager->dbOrigSize = maxPgno; + // pPager->dbOrigSize = pPager->dbFileSize; // release the page iter = tRBTreeIterCreate(&pPager->rbt, 1); @@ -474,6 +432,7 @@ int tdbPagerPrepareAsyncCommit(SPager *pPager, TXN *pTxn) { tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage); tdbPCacheRelease(pPager->pCache, pPage, pTxn); } + /* tdbTrace("reset dirty tree: %p", &pPager->rbt); tRBTreeCreate(&pPager->rbt, pageCmpFn); @@ -495,15 +454,15 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) { SPgno journalSize = 0; int ret; - // 0, sync the journal file - ret = tdbOsFSync(pPager->jfd); + // sync the journal file + ret = tdbOsFSync(pTxn->jfd); if (ret < 0) { - tdbError("failed to fsync jfd due to %s. file:%s", strerror(errno), pPager->jFileName); + tdbError("failed to fsync jfd: %s. jfile:%s, %" PRId64, strerror(errno), pPager->jFileName, pTxn->txnId); terrno = TAOS_SYSTEM_ERROR(errno); return -1; } - tdb_fd_t jfd = pPager->jfd; + tdb_fd_t jfd = pTxn->jfd; ret = tdbGetFileSize(jfd, pPager->pageSize, &journalSize); if (ret < 0) { @@ -567,7 +526,7 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) { pPage->isDirty = 0; tRBTreeDrop(&pPager->rbt, (SRBTreeNode *)pPage); - hashset_remove(pPager->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); + hashset_remove(pTxn->jPageSet, (void *)((long)TDB_PAGE_PGNO(pPage))); tdbPCacheRelease(pPager->pCache, pPage, pTxn); } @@ -575,11 +534,24 @@ int tdbPagerAbort(SPager *pPager, TXN *pTxn) { tRBTreeCreate(&pPager->rbt, pageCmpFn); // 4, remove the journal file - tdbOsClose(pPager->jfd); - (void)tdbOsRemove(pPager->jFileName); - hashset_destroy(pPager->jPageSet); + if (tdbOsClose(pTxn->jfd) < 0) { + tdbError("failed to close jfd: %s. file:%s, %" PRId64, strerror(errno), pPager->jFileName, pTxn->txnId); + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } - pPager->inTran = 0; + char jTxnFileName[TDB_FILENAME_LEN]; + sprintf(jTxnFileName, "%s.%" PRId64, pPager->jFileName, pTxn->txnId); + + if (tdbOsRemove(jTxnFileName) < 0 && errno != ENOENT) { + tdbError("failed to remove file due to %s. file:%s", strerror(errno), jTxnFileName); + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + + hashset_destroy(pTxn->jPageSet); + + // pPager->inTran = 0; return 0; } @@ -604,7 +576,7 @@ int tdbPagerFlushPage(SPager *pPager, TXN *pTxn) { if (pgno > maxPgno) { maxPgno = pgno; } - ret = tdbPagerWritePageToDB(pPager, pPage); + ret = tdbPagerPWritePageToDB(pPager, pPage); if (ret < 0) { tdbError("failed to write page to db since %s", tstrerror(terrno)); return -1; @@ -802,17 +774,18 @@ static int tdbPagerWritePageToJournal(SPager *pPager, SPage *pPage) { pgno = TDB_PAGE_PGNO(pPage); - ret = tdbOsWrite(pPager->jfd, &pgno, sizeof(pgno)); + ret = tdbOsWrite(pPager->pActiveTxn->jfd, &pgno, sizeof(pgno)); if (ret < 0) { - tdbError("failed to write pgno due to %s. file:%s, pgno:%u", strerror(errno), pPager->jFileName, pgno); + tdbError("failed to write pgno due to %s. file:%s, pgno:%u, txnId:%" PRId64, strerror(errno), pPager->jFileName, + pgno, pPager->pActiveTxn->txnId); terrno = TAOS_SYSTEM_ERROR(errno); return -1; } - ret = tdbOsWrite(pPager->jfd, pPage->pData, pPage->pageSize); + ret = tdbOsWrite(pPager->pActiveTxn->jfd, pPage->pData, pPage->pageSize); if (ret < 0) { - tdbError("failed to write page data due to %s. file:%s, pageSize:%ld", strerror(errno), pPager->jFileName, - (long)pPage->pageSize); + tdbError("failed to write page data due to %s. file:%s, pageSize:%d, txnId:%" PRId64, strerror(errno), + pPager->jFileName, pPage->pageSize, pPager->pActiveTxn->txnId); terrno = TAOS_SYSTEM_ERROR(errno); return -1; } @@ -820,13 +793,6 @@ static int tdbPagerWritePageToJournal(SPager *pPager, SPage *pPage) { return 0; } /* -struct TdFile { - TdThreadRwlock rwlock; - int refId; - int fd; - FILE *fp; -} TdFile; -*/ static int tdbPagerWritePageToDB(SPager *pPager, SPage *pPage) { i64 offset; int ret; @@ -846,16 +812,32 @@ static int tdbPagerWritePageToDB(SPager *pPager, SPage *pPage) { return -1; } - // pwrite(pPager->fd->fd, pPage->pData, pPage->pageSize, offset); + return 0; +} +*/ +static int tdbPagerPWritePageToDB(SPager *pPager, SPage *pPage) { + i64 offset; + int ret; + + offset = (i64)pPage->pageSize * (TDB_PAGE_PGNO(pPage) - 1); + + ret = tdbOsPWrite(pPager->fd, pPage->pData, pPage->pageSize, offset); + if (ret < 0) { + tdbError("failed to pwrite page data due to %s. file:%s, pageSize:%d", strerror(errno), pPager->dbFileName, + pPage->pageSize); + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + return 0; } -int tdbPagerRestore(SPager *pPager, SBTree *pBt) { +static int tdbPagerRestore(SPager *pPager, SBTree *pBt, const char *jFileName) { int ret = 0; SPgno journalSize = 0; u8 *pageBuf = NULL; - tdb_fd_t jfd = tdbOsOpen(pPager->jFileName, TDB_O_RDWR, 0755); + tdb_fd_t jfd = tdbOsOpen(jFileName, TDB_O_RDWR, 0755); if (jfd == NULL) { return 0; } @@ -928,12 +910,50 @@ int tdbPagerRestore(SPager *pPager, SBTree *pBt) { return 0; } -int tdbPagerRollback(SPager *pPager) { - if (tdbOsRemove(pPager->jFileName) < 0 && errno != ENOENT) { - tdbError("failed to remove file due to %s. jFileName:%s", strerror(errno), pPager->jFileName); - terrno = TAOS_SYSTEM_ERROR(errno); +int tdbPagerRestoreJournals(SPager *pPager, SBTree *pBt) { + tdbDirEntryPtr pDirEntry; + tdbDirPtr pDir = taosOpenDir(pPager->pEnv->dbName); + if (pDir == NULL) { + tdbError("failed to open %s since %s", pPager->pEnv->dbName, strerror(errno)); return -1; } + while ((pDirEntry = tdbReadDir(pDir)) != NULL) { + char *name = tdbDirEntryBaseName(tdbGetDirEntryName(pDirEntry)); + if (strncmp(TDB_MAINDB_NAME "-journal", name, 16) == 0) { + if (tdbPagerRestore(pPager, pBt, name) < 0) { + tdbError("failed to restore file due to %s. jFileName:%s", strerror(errno), name); + return -1; + } + } + } + + tdbCloseDir(&pDir); + + return 0; +} + +int tdbPagerRollback(SPager *pPager) { + tdbDirEntryPtr pDirEntry; + tdbDirPtr pDir = taosOpenDir(pPager->pEnv->dbName); + if (pDir == NULL) { + tdbError("failed to open %s since %s", pPager->pEnv->dbName, strerror(errno)); + return -1; + } + + while ((pDirEntry = tdbReadDir(pDir)) != NULL) { + char *name = tdbDirEntryBaseName(tdbGetDirEntryName(pDirEntry)); + + if (strncmp(TDB_MAINDB_NAME "-journal", name, 16) == 0) { + if (tdbOsRemove(name) < 0 && errno != ENOENT) { + tdbError("failed to remove file due to %s. jFileName:%s", strerror(errno), name); + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + } + } + + tdbCloseDir(&pDir); + return 0; } diff --git a/source/libs/tdb/src/db/tdbTable.c b/source/libs/tdb/src/db/tdbTable.c index 8b029b06d6..c5c2d6aebe 100644 --- a/source/libs/tdb/src/db/tdbTable.c +++ b/source/libs/tdb/src/db/tdbTable.c @@ -108,7 +108,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF ASSERT(pPager != NULL); // pTb->pBt - ret = tdbBtreeOpen(keyLen, valLen, pPager, tbname, pgno, keyCmprFn, &(pTb->pBt)); + ret = tdbBtreeOpen(keyLen, valLen, pPager, tbname, pgno, keyCmprFn, pEnv, &(pTb->pBt)); if (ret < 0) { tdbOsFree(pTb); return -1; @@ -117,7 +117,7 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF if (rollback) { tdbPagerRollback(pPager); } else { - ret = tdbPagerRestore(pPager, pTb->pBt); + ret = tdbPagerRestoreJournals(pPager, pTb->pBt); if (ret < 0) { tdbOsFree(pTb); return -1; diff --git a/source/libs/tdb/src/db/tdbTxn.c b/source/libs/tdb/src/db/tdbTxn.c index f173d89779..77c87d18f2 100644 --- a/source/libs/tdb/src/db/tdbTxn.c +++ b/source/libs/tdb/src/db/tdbTxn.c @@ -28,4 +28,10 @@ int tdbTxnOpen(TXN *pTxn, int64_t txnid, void *(*xMalloc)(void *, size_t), void return 0; } -int tdbTxnClose(TXN *pTxn) { return 0; } \ No newline at end of file +int tdbTxnClose(TXN *pTxn) { + if (pTxn) { + tdbOsFree(pTxn); + } + + return 0; +} diff --git a/source/libs/tdb/src/inc/tdbInt.h b/source/libs/tdb/src/inc/tdbInt.h index 731b1927e7..055a8a1062 100644 --- a/source/libs/tdb/src/inc/tdbInt.h +++ b/source/libs/tdb/src/inc/tdbInt.h @@ -147,11 +147,11 @@ struct SBTC { SPage *pgStack[BTREE_MAX_DEPTH + 1]; SCellDecoder coder; TXN *pTxn; - TXN txn; + i8 freeTxn; }; // SBTree -int tdbBtreeOpen(int keyLen, int valLen, SPager *pFile, char const *tbname, SPgno pgno, tdb_cmpr_fn_t kcmpr, +int tdbBtreeOpen(int keyLen, int valLen, SPager *pFile, char const *tbname, SPgno pgno, tdb_cmpr_fn_t kcmpr, TDB *pEnv, SBTree **ppBt); int tdbBtreeClose(SBTree *pBt); int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, int vLen, TXN *pTxn); @@ -197,7 +197,7 @@ int tdbPagerFetchPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initP TXN *pTxn); void tdbPagerReturnPage(SPager *pPager, SPage *pPage, TXN *pTxn); int tdbPagerAllocPage(SPager *pPager, SPgno *ppgno); -int tdbPagerRestore(SPager *pPager, SBTree *pBt); +int tdbPagerRestoreJournals(SPager *pPager, SBTree *pBt); int tdbPagerRollback(SPager *pPager); // tdbPCache.c ==================================== @@ -382,26 +382,24 @@ struct STDB { #ifdef USE_MAINDB TTB *pMainDb; #endif + int64_t txnId; }; -typedef struct hashset_st *hashset_t; - struct SPager { char *dbFileName; char *jFileName; int pageSize; uint8_t fid[TDB_FILE_ID_LEN]; tdb_fd_t fd; - tdb_fd_t jfd; SPCache *pCache; SPgno dbFileSize; SPgno dbOrigSize; - //SPage *pDirty; - hashset_t jPageSet; - SRBTree rbt; - u8 inTran; - SPager *pNext; // used by TDB - SPager *pHashNext; // used by TDB + // SPage *pDirty; + SRBTree rbt; + // u8 inTran; + TXN *pActiveTxn; + SPager *pNext; // used by TDB + SPager *pHashNext; // used by TDB #ifdef USE_MAINDB TDB *pEnv; #endif diff --git a/source/libs/tdb/src/inc/tdbOs.h b/source/libs/tdb/src/inc/tdbOs.h index b5dd27052c..db4283e267 100644 --- a/source/libs/tdb/src/inc/tdbOs.h +++ b/source/libs/tdb/src/inc/tdbOs.h @@ -47,15 +47,21 @@ typedef TdFilePtr tdb_fd_t; #define TDB_O_RDWR (TD_FILE_WRITE) | (TD_FILE_READ) #define tdbOsOpen(PATH, OPTION, MODE) taosOpenFile((PATH), (OPTION)) - -#define tdbOsClose(FD) taosCloseFile(&(FD)) -#define tdbOsRead taosReadFile -#define tdbOsPRead taosPReadFile -#define tdbOsWrite taosWriteFile -#define tdbOsFSync taosFsyncFile -#define tdbOsLSeek taosLSeekFile -#define tdbOsRemove remove -#define tdbOsFileSize(FD, PSIZE) taosFStatFile(FD, PSIZE, NULL) +#define tdbOsClose(FD) taosCloseFile(&(FD)) +#define tdbOsRead taosReadFile +#define tdbOsPRead taosPReadFile +#define tdbOsWrite taosWriteFile +#define tdbOsPWrite taosPWriteFile +#define tdbOsFSync taosFsyncFile +#define tdbOsLSeek taosLSeekFile +#define tdbDirPtr TdDirPtr +#define tdbDirEntryPtr TdDirEntryPtr +#define tdbReadDir taosReadDir +#define tdbGetDirEntryName taosGetDirEntryName +#define tdbDirEntryBaseName taosDirEntryBaseName +#define tdbCloseDir taosCloseDir +#define tdbOsRemove remove +#define tdbOsFileSize(FD, PSIZE) taosFStatFile(FD, PSIZE, NULL) /* directory */ #define tdbOsMkdir taosMkDir diff --git a/source/libs/tdb/test/tdbExOVFLTest.cpp b/source/libs/tdb/test/tdbExOVFLTest.cpp index 305e91f62c..f4f09b20b8 100644 --- a/source/libs/tdb/test/tdbExOVFLTest.cpp +++ b/source/libs/tdb/test/tdbExOVFLTest.cpp @@ -170,11 +170,9 @@ static void insertOfp(void) { SPoolMem *pPool = openPool(); // start a transaction - TXN txn; - int64_t txnid = 0; - ++txnid; - tdbTxnOpen(&txn, txnid, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); - tdbBegin(pEnv, &txn); + 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) @@ -185,12 +183,12 @@ static void insertOfp(void) { // insert the generated big data // char const *key = "key1"; char const *key = "key123456789"; - ret = tdbTbInsert(pDb, key, strlen(key), val, valLen, &txn); + ret = tdbTbInsert(pDb, key, strlen(key), val, valLen, txn); GTEST_ASSERT_EQ(ret, 0); // commit current transaction - tdbCommit(pEnv, &txn); - tdbTxnClose(&txn); + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); } // TEST(TdbOVFLPagesTest, DISABLED_TbInsertTest) { @@ -258,11 +256,9 @@ TEST(TdbOVFLPagesTest, TbDeleteTest) { SPoolMem *pPool = openPool(); // start a transaction - TXN txn; - int64_t txnid = 0; - ++txnid; - tdbTxnOpen(&txn, txnid, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); - tdbBegin(pEnv, &txn); + 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) @@ -271,7 +267,7 @@ TEST(TdbOVFLPagesTest, TbDeleteTest) { generateBigVal(val, valLen); { // insert the generated big data - ret = tdbTbInsert(pDb, "key1", strlen("key1"), val, valLen, &txn); + ret = tdbTbInsert(pDb, "key1", strlen("key1"), val, valLen, txn); GTEST_ASSERT_EQ(ret, 0); } @@ -297,7 +293,7 @@ tdbTxnOpen(&txn, txnid, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_REA tdbBegin(pEnv, &txn); */ { // upsert the data - ret = tdbTbUpsert(pDb, "key1", strlen("key1"), "value1", strlen("value1"), &txn); + ret = tdbTbUpsert(pDb, "key1", strlen("key1"), "value1", strlen("value1"), txn); GTEST_ASSERT_EQ(ret, 0); } @@ -316,7 +312,7 @@ tdbBegin(pEnv, &txn); } { // delete the data - ret = tdbTbDelete(pDb, "key1", strlen("key1"), &txn); + ret = tdbTbDelete(pDb, "key1", strlen("key1"), txn); GTEST_ASSERT_EQ(ret, 0); } @@ -335,8 +331,8 @@ tdbBegin(pEnv, &txn); } // commit current transaction - tdbCommit(pEnv, &txn); - tdbTxnClose(&txn); + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); } // TEST(tdb_test, DISABLED_simple_insert1) { @@ -346,7 +342,7 @@ TEST(tdb_test, simple_insert1) { TTB *pDb; tdb_cmpr_fn_t compFunc; int nData = 1; - TXN txn; + TXN *txn; int const pageSize = 4096; taosRemoveDir("tdb"); @@ -365,16 +361,13 @@ TEST(tdb_test, simple_insert1) { // 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 - int64_t txnid = 0; SPoolMem *pPool; // open the pool pPool = openPool(); // start a transaction - txnid++; - tdbTxnOpen(&txn, txnid, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); - tdbBegin(pEnv, &txn); + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); for (int iData = 1; iData <= nData; iData++) { sprintf(key, "key0"); @@ -393,26 +386,25 @@ TEST(tdb_test, simple_insert1) { val[i] = c; } - ret = tdbTbInsert(pDb, "key1", strlen("key1"), val, valLen, &txn); + 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); - tdbTxnClose(&txn); + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); // start a new transaction clearPool(pPool); - txnid++; - tdbTxnOpen(&txn, txnid, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); - tdbBegin(pEnv, &txn); + + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); } } // commit the transaction - tdbCommit(pEnv, &txn); - tdbTxnClose(&txn); + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); { // Query the data void *pVal = NULL; diff --git a/source/libs/tdb/test/tdbTest.cpp b/source/libs/tdb/test/tdbTest.cpp index f3a301cf5b..54e80a0009 100644 --- a/source/libs/tdb/test/tdbTest.cpp +++ b/source/libs/tdb/test/tdbTest.cpp @@ -125,7 +125,7 @@ TEST(tdb_test, DISABLED_simple_insert1) { TTB *pDb; tdb_cmpr_fn_t compFunc; int nData = 1000000; - TXN txn; + TXN *txn; taosRemoveDir("tdb"); @@ -142,40 +142,35 @@ TEST(tdb_test, DISABLED_simple_insert1) { char key[64]; char val[64]; int64_t poolLimit = 4096; // 1M pool limit - int64_t txnid = 0; SPoolMem *pPool; // open the pool pPool = openPool(); // start a transaction - txnid++; - tdbTxnOpen(&txn, txnid, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); - tdbBegin(pEnv, &txn); + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); for (int iData = 1; iData <= nData; iData++) { sprintf(key, "key%d", iData); sprintf(val, "value%d", iData); - ret = tdbTbInsert(pDb, key, strlen(key), val, strlen(val), &txn); + ret = tdbTbInsert(pDb, key, strlen(key), val, strlen(val), 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); - tdbTxnClose(&txn); + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); // start a new transaction clearPool(pPool); - txnid++; - tdbTxnOpen(&txn, txnid, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); - tdbBegin(pEnv, &txn); + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); } } // commit the transaction - tdbCommit(pEnv, &txn); - tdbTxnClose(&txn); + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); { // Query the data void *pVal = NULL; @@ -245,7 +240,7 @@ TEST(tdb_test, DISABLED_simple_insert2) { TTB *pDb; tdb_cmpr_fn_t compFunc; int nData = 1000000; - TXN txn; + TXN *txn; taosRemoveDir("tdb"); @@ -261,21 +256,18 @@ TEST(tdb_test, DISABLED_simple_insert2) { { char key[64]; char val[64]; - int64_t txnid = 0; SPoolMem *pPool; // open the pool pPool = openPool(); // start a transaction - txnid++; - tdbTxnOpen(&txn, txnid, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); - tdbBegin(pEnv, &txn); + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); for (int iData = 1; iData <= nData; iData++) { sprintf(key, "key%d", iData); sprintf(val, "value%d", iData); - ret = tdbTbInsert(pDb, key, strlen(key), val, strlen(val), &txn); + ret = tdbTbInsert(pDb, key, strlen(key), val, strlen(val), txn); GTEST_ASSERT_EQ(ret, 0); } @@ -312,8 +304,8 @@ TEST(tdb_test, DISABLED_simple_insert2) { } // commit the transaction - tdbCommit(pEnv, &txn); - tdbTxnClose(&txn); + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); ret = tdbTbDrop(pDb); GTEST_ASSERT_EQ(ret, 0); @@ -331,7 +323,7 @@ TEST(tdb_test, DISABLED_simple_delete1) { TTB *pDb; char key[128]; char data[128]; - TXN txn; + TXN *txn; TDB *pEnv; SPoolMem *pPool; void *pKey = NULL; @@ -353,14 +345,13 @@ TEST(tdb_test, DISABLED_simple_delete1) { ret = tdbTbOpen("db.db", -1, -1, tKeyCmpr, pEnv, &pDb, 0); GTEST_ASSERT_EQ(ret, 0); - tdbTxnOpen(&txn, 0, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); - tdbBegin(pEnv, &txn); + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); // loop to insert batch data for (int iData = 0; iData < nKV; iData++) { sprintf(key, "key%d", iData); sprintf(data, "data%d", iData); - ret = tdbTbInsert(pDb, key, strlen(key), data, strlen(data), &txn); + ret = tdbTbInsert(pDb, key, strlen(key), data, strlen(data), txn); GTEST_ASSERT_EQ(ret, 0); } @@ -378,7 +369,7 @@ TEST(tdb_test, DISABLED_simple_delete1) { for (int iData = nKV - 1; iData > 30; iData--) { sprintf(key, "key%d", iData); - ret = tdbTbDelete(pDb, key, strlen(key), &txn); + ret = tdbTbDelete(pDb, key, strlen(key), txn); GTEST_ASSERT_EQ(ret, 0); } @@ -413,7 +404,8 @@ TEST(tdb_test, DISABLED_simple_delete1) { tdbTbcClose(pDbc); - tdbCommit(pEnv, &txn); + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); closePool(pPool); @@ -430,7 +422,7 @@ TEST(tdb_test, DISABLED_simple_upsert1) { char data[64]; void *pData = NULL; SPoolMem *pPool; - TXN txn; + TXN *txn; taosRemoveDir("tdb"); @@ -444,13 +436,12 @@ TEST(tdb_test, DISABLED_simple_upsert1) { pPool = openPool(); // insert some data - tdbTxnOpen(&txn, 0, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); - tdbBegin(pEnv, &txn); + 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(data, "data%d", iData); - ret = tdbTbInsert(pDb, key, strlen(key), data, strlen(data), &txn); + ret = tdbTbInsert(pDb, key, strlen(key), data, strlen(data), txn); GTEST_ASSERT_EQ(ret, 0); } @@ -467,11 +458,12 @@ TEST(tdb_test, DISABLED_simple_upsert1) { for (int iData = 0; iData < nData; iData++) { sprintf(key, "key%d", iData); sprintf(data, "data%d-u", iData); - ret = tdbTbUpsert(pDb, key, strlen(key), data, strlen(data), &txn); + ret = tdbTbUpsert(pDb, key, strlen(key), data, strlen(data), txn); GTEST_ASSERT_EQ(ret, 0); } - tdbCommit(pEnv, &txn); + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); // query the data for (int iData = 0; iData < nData; iData++) { @@ -492,7 +484,7 @@ TEST(tdb_test, multi_thread_query) { TTB *pDb; tdb_cmpr_fn_t compFunc; int nData = 1000000; - TXN txn; + TXN *txn; taosRemoveDir("tdb"); @@ -508,26 +500,18 @@ TEST(tdb_test, multi_thread_query) { char key[64]; char val[64]; int64_t poolLimit = 4096 * 20; // 1M pool limit - int64_t txnid = 0; SPoolMem *pPool; // open the pool pPool = openPool(); // start a transaction - txnid++; - txn.flags = TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED; - txn.txnId = -1; - txn.xMalloc = poolMalloc; - txn.xFree = poolFree; - txn.xArg = pPool; - // tdbTxnOpen(&txn, txnid, poolMalloc, poolFree, pPool, ); - tdbBegin(pEnv, &txn); + tdbBegin(pEnv, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); for (int iData = 1; iData <= nData; iData++) { sprintf(key, "key%d", iData); sprintf(val, "value%d", iData); - ret = tdbTbInsert(pDb, key, strlen(key), val, strlen(val), &txn); + ret = tdbTbInsert(pDb, key, strlen(key), val, strlen(val), txn); GTEST_ASSERT_EQ(ret, 0); } @@ -578,7 +562,7 @@ TEST(tdb_test, multi_thread_query) { std::vector threads; for (int i = 0; i < nThreads; i++) { if (i == 0) { - threads.push_back(std::thread(tdbCommit, pEnv, &txn)); + threads.push_back(std::thread(tdbCommit, pEnv, txn)); } else { threads.push_back(std::thread(f, pDb, nData)); } @@ -589,8 +573,8 @@ TEST(tdb_test, multi_thread_query) { } // commit the transaction - tdbCommit(pEnv, &txn); - tdbTxnClose(&txn); + tdbCommit(pEnv, txn); + tdbPostCommit(pEnv, txn); // Close a database tdbTbClose(pDb); @@ -621,17 +605,12 @@ TEST(tdb_test, DISABLED_multi_thread1) { GTEST_ASSERT_EQ(ret, 0); auto insert = [](TDB *pDb, TTB *pTb, int nData, int *stop, std::shared_timed_mutex *mu) { - TXN txn = {0}; + TXN *txn = NULL; char key[128]; char val[128]; SPoolMem *pPool = openPool(); - txn.flags = TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED; - txn.txnId = -1; - txn.xMalloc = poolMalloc; - txn.xFree = poolFree; - txn.xArg = pPool; - tdbBegin(pDb, &txn); + tdbBegin(pDb, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); for (int iData = 1; iData <= nData; iData++) { sprintf(key, "key%d", iData); sprintf(val, "value%d", iData); @@ -644,14 +623,17 @@ TEST(tdb_test, DISABLED_multi_thread1) { } if (pPool->size > 1024 * 1024) { - tdbCommit(pDb, &txn); + tdbCommit(pDb, txn); + tdbPostCommit(pDb, txn); clearPool(pPool); - tdbBegin(pDb, &txn); + tdbBegin(pDb, &txn, poolMalloc, poolFree, pPool, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); } } - tdbCommit(pDb, &txn); + tdbCommit(pDb, txn); + tdbPostCommit(pDb, txn); + closePool(pPool); *stop = 1; diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index 479c1a5af7..bf9a6c0051 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -151,8 +151,8 @@ typedef struct { int64_t retryNextInterval; bool retryInit; int32_t retryStep; - - int8_t epsetRetryCnt; + int8_t epsetRetryCnt; + int32_t retryCode; int hThrdIdx; } STransConnCtx; diff --git a/source/libs/transport/src/tmsgcb.c b/source/libs/transport/src/tmsgcb.c index 0d1644be2d..95bc532994 100644 --- a/source/libs/transport/src/tmsgcb.c +++ b/source/libs/transport/src/tmsgcb.c @@ -16,6 +16,7 @@ #define _DEFAULT_SOURCE #include "tmsgcb.h" #include "taoserror.h" +#include "transLog.h" #include "trpc.h" static SMsgCb defaultMsgCb; @@ -23,6 +24,7 @@ static SMsgCb defaultMsgCb; void tmsgSetDefault(const SMsgCb* msgcb) { defaultMsgCb = *msgcb; } int32_t tmsgPutToQueue(const SMsgCb* msgcb, EQueueType qtype, SRpcMsg* pMsg) { + ASSERT(msgcb != NULL); int32_t code = (*msgcb->putToQueueFp)(msgcb->mgmt, qtype, pMsg); if (code != 0) { rpcFreeCont(pMsg->pCont); @@ -52,8 +54,6 @@ void tmsgSendRsp(SRpcMsg* pMsg) { #endif } -void tmsgSendRedirectRsp(SRpcMsg* pMsg, const SEpSet* pNewEpSet) { (*defaultMsgCb.sendRedirectRspFp)(pMsg, pNewEpSet); } - void tmsgRegisterBrokenLinkArg(SRpcMsg* pMsg) { (*defaultMsgCb.registerBrokenLinkArgFp)(pMsg); } void tmsgReleaseHandle(SRpcHandleInfo* pHandle, int8_t type) { (*defaultMsgCb.releaseHandleFp)(pHandle, type); } diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index fbcc1fb525..7339d487d1 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -1020,7 +1020,6 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) { char tbuf[256] = {0}; EPSET_DEBUG_STR(&pCtx->epSet, tbuf); - tDebug("current epset %s", tbuf); if (!EPSET_IS_VALID(&pCtx->epSet)) { tError("invalid epset"); @@ -1500,34 +1499,48 @@ bool cliGenRetryRule(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { pCtx->retryNextInterval = pCtx->retryMinInterval; pCtx->retryStep = 0; pCtx->retryInit = true; + pCtx->retryCode = TSDB_CODE_SUCCESS; } + if (-1 != pCtx->retryMaxTimeout && taosGetTimestampMs() - pCtx->retryInitTimestamp >= pCtx->retryMaxTimeout) { return false; } + // code, msgType + + // A: epset, leader, not self + // B: epset, not know leader + // C: no epset, leader but not serivce + bool noDelay = false; if (code == TSDB_CODE_RPC_BROKEN_LINK || code == TSDB_CODE_RPC_NETWORK_UNAVAIL) { - tDebug("code str %s, contlen:%d 0", tstrerror(code), pResp->contLen); + tTrace("code str %s, contlen:%d 0", tstrerror(code), pResp->contLen); noDelay = cliResetEpset(pCtx, pResp, false); transFreeMsg(pResp->pCont); transUnrefCliHandle(pConn); } else if (code == TSDB_CODE_SYN_NOT_LEADER || code == TSDB_CODE_SYN_INTERNAL_ERROR || - code == TSDB_CODE_SYN_PROPOSE_NOT_READY || code == TSDB_CODE_RPC_REDIRECT) { - tDebug("code str %s, contlen:%d 1", tstrerror(code), pResp->contLen); + code == TSDB_CODE_SYN_PROPOSE_NOT_READY || code == TSDB_CODE_VND_STOPPED || + code == TSDB_CODE_MNODE_NOT_FOUND || code == TSDB_CODE_APP_IS_STARTING || + code == TSDB_CODE_APP_IS_STOPPING) { + tTrace("code str %s, contlen:%d 1", tstrerror(code), pResp->contLen); noDelay = cliResetEpset(pCtx, pResp, true); transFreeMsg(pResp->pCont); addConnToPool(pThrd->pool, pConn); } else if (code == TSDB_CODE_SYN_RESTORING) { - tDebug("code str %s, contlen:%d 0", tstrerror(code), pResp->contLen); + tTrace("code str %s, contlen:%d 0", tstrerror(code), pResp->contLen); noDelay = cliResetEpset(pCtx, pResp, false); addConnToPool(pThrd->pool, pConn); transFreeMsg(pResp->pCont); } else { - tDebug("code str %s, contlen:%d 0", tstrerror(code), pResp->contLen); + tTrace("code str %s, contlen:%d 0", tstrerror(code), pResp->contLen); noDelay = cliResetEpset(pCtx, pResp, false); addConnToPool(pThrd->pool, pConn); transFreeMsg(pResp->pCont); } + if (code != TSDB_CODE_RPC_BROKEN_LINK && code != TSDB_CODE_RPC_NETWORK_UNAVAIL && code != TSDB_CODE_SUCCESS) { + // save one internal code + pCtx->retryCode = code; + } if (noDelay == false) { pCtx->epsetRetryCnt = 1; @@ -1556,29 +1569,36 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { STrans* pTransInst = pThrd->pTransInst; if (pMsg == NULL || pMsg->ctx == NULL) { - tDebug("%s conn %p handle resp", pTransInst->label, pConn); + tTrace("%s conn %p handle resp", pTransInst->label, pConn); pTransInst->cfp(pTransInst->parent, pResp, NULL); return 0; } STransConnCtx* pCtx = pMsg->ctx; - int32_t code = pResp->code; bool retry = cliGenRetryRule(pConn, pResp, pMsg); if (retry == true) { return -1; } - STraceId* trace = &pResp->info.traceId; - bool hasEpSet = cliTryExtractEpSet(pResp, &pCtx->epSet); + if (pCtx->retryCode != TSDB_CODE_SUCCESS) { + int32_t code = pResp->code; + // return internal code app + if (code == TSDB_CODE_RPC_NETWORK_UNAVAIL || code == TSDB_CODE_RPC_BROKEN_LINK) { + pResp->code = pCtx->retryCode; + } + } + + STraceId* trace = &pResp->info.traceId; + bool hasEpSet = cliTryExtractEpSet(pResp, &pCtx->epSet); if (hasEpSet) { char tbuf[256] = {0}; EPSET_DEBUG_STR(&pCtx->epSet, tbuf); - tGDebug("%s conn %p extract epset from msg", CONN_GET_INST_LABEL(pConn), pConn); + tGTrace("%s conn %p extract epset from msg", CONN_GET_INST_LABEL(pConn), pConn); } if (pCtx->pSem != NULL) { - tGDebug("%s conn %p(sync) handle resp", CONN_GET_INST_LABEL(pConn), pConn); + tGTrace("%s conn %p(sync) handle resp", CONN_GET_INST_LABEL(pConn), pConn); if (pCtx->pRsp == NULL) { tGTrace("%s conn %p(sync) failed to resp, ignore", CONN_GET_INST_LABEL(pConn), pConn); } else { @@ -1587,11 +1607,11 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { tsem_post(pCtx->pSem); pCtx->pRsp = NULL; } else { - tGDebug("%s conn %p handle resp", CONN_GET_INST_LABEL(pConn), pConn); + tGTrace("%s conn %p handle resp", CONN_GET_INST_LABEL(pConn), pConn); if (retry == false && hasEpSet == true) { pTransInst->cfp(pTransInst->parent, pResp, &pCtx->epSet); } else { - if (!cliIsEpsetUpdated(code, pCtx)) { + if (!cliIsEpsetUpdated(pResp->code, pCtx)) { pTransInst->cfp(pTransInst->parent, pResp, NULL); } else { pTransInst->cfp(pTransInst->parent, pResp, &pCtx->epSet); diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index a600b2a61a..73c6dc4011 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -250,9 +250,9 @@ static bool uvHandleReq(SSvrConn* pConn) { transLabel(pTransInst), pConn, TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, msgLen, pHead->noResp, transMsg.code, (int)(cost)); } else { - tGWarn("%s conn %p %s received from %s, local info:%s, len:%d, resp:%d, code:%d, cost:%dus", - transLabel(pTransInst), pConn, TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, msgLen, pHead->noResp, - transMsg.code, (int)(cost)); + tGDebug("%s conn %p %s received from %s, local info:%s, len:%d, resp:%d, code:%d, cost:%dus", + transLabel(pTransInst), pConn, TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, msgLen, pHead->noResp, + transMsg.code, (int)(cost)); } } @@ -1259,6 +1259,7 @@ _return2: tDebug("handle %p failed to send to release handle", exh); return -1; } + int transSendResponse(const STransMsg* msg) { if (msg->info.noResp) { rpcFreeCont(msg->pCont); diff --git a/source/libs/wal/src/walMeta.c b/source/libs/wal/src/walMeta.c index 6cac4b6093..64dde15e76 100644 --- a/source/libs/wal/src/walMeta.c +++ b/source/libs/wal/src/walMeta.c @@ -105,7 +105,7 @@ static FORCE_INLINE int64_t walScanLogGetLastVer(SWal* pWal, int32_t fileIdx) { void* ptr = taosMemoryRealloc(buf, capacity); if (ptr == NULL) { - terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; goto _err; } buf = ptr; @@ -285,6 +285,9 @@ void walAlignVersions(SWal* pWal) { if (pWal->vers.lastVer < pWal->vers.snapshotVer) { wWarn("vgId:%d, lastVer:%" PRId64 " is less than snapshotVer:%" PRId64 ". align with it.", pWal->cfg.vgId, pWal->vers.lastVer, pWal->vers.snapshotVer); + if (pWal->vers.lastVer < pWal->vers.firstVer) { + pWal->vers.firstVer = pWal->vers.snapshotVer + 1; + } pWal->vers.lastVer = pWal->vers.snapshotVer; } if (pWal->vers.commitVer < pWal->vers.snapshotVer) { @@ -629,7 +632,7 @@ int walRollFileInfo(SWal* pWal) { // TODO: change to emplace back SWalFileInfo* pNewInfo = taosMemoryMalloc(sizeof(SWalFileInfo)); if (pNewInfo == NULL) { - terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } pNewInfo->firstVer = pWal->vers.lastVer + 1; @@ -661,7 +664,7 @@ char* walMetaSerialize(SWal* pWal) { if (pFiles) { cJSON_Delete(pFiles); } - terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } cJSON_AddItemToObject(pRoot, "meta", pMeta); @@ -892,7 +895,7 @@ int walLoadMeta(SWal* pWal) { int size = (int)fileSize; char* buf = taosMemoryMalloc(size + 5); if (buf == NULL) { - terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } memset(buf, 0, size + 5); diff --git a/source/libs/wal/src/walMgmt.c b/source/libs/wal/src/walMgmt.c index 5d0f020b02..a683ceb2b1 100644 --- a/source/libs/wal/src/walMgmt.c +++ b/source/libs/wal/src/walMgmt.c @@ -168,7 +168,7 @@ _err: } int32_t walAlter(SWal *pWal, SWalCfg *pCfg) { - if (pWal == NULL) return TSDB_CODE_WAL_APP_ERROR; + if (pWal == NULL) return TSDB_CODE_APP_ERROR; if (pWal->cfg.level == pCfg->level && pWal->cfg.fsyncPeriod == pCfg->fsyncPeriod) { wDebug("vgId:%d, old walLevel:%d fsync:%d, new walLevel:%d fsync:%d not change", pWal->cfg.vgId, pWal->cfg.level, diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index 1350ca0c37..76266d338b 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -48,7 +48,7 @@ SWalReader *walOpenReader(SWal *pWal, SWalFilterCond *cond) { pReader->pHead = taosMemoryMalloc(sizeof(SWalCkHead)); if (pReader->pHead == NULL) { - terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; taosMemoryFree(pReader); return NULL; } @@ -280,7 +280,7 @@ static int32_t walFetchBodyNew(SWalReader *pRead) { if (pRead->capacity < pReadHead->bodyLen) { SWalCkHead *ptr = (SWalCkHead *)taosMemoryRealloc(pRead->pHead, sizeof(SWalCkHead) + pReadHead->bodyLen); if (ptr == NULL) { - terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } pRead->pHead = ptr; @@ -437,7 +437,7 @@ int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead) { if (pRead->capacity < pReadHead->bodyLen) { SWalCkHead *ptr = (SWalCkHead *)taosMemoryRealloc(*ppHead, sizeof(SWalCkHead) + pReadHead->bodyLen); if (ptr == NULL) { - terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } *ppHead = ptr; @@ -546,7 +546,7 @@ int32_t walReadVer(SWalReader *pReader, int64_t ver) { SWalCkHead *ptr = (SWalCkHead *)taosMemoryRealloc(pReader->pHead, sizeof(SWalCkHead) + pReader->pHead->head.bodyLen); if (ptr == NULL) { - terrno = TSDB_CODE_WAL_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; taosThreadMutexUnlock(&pReader->mutex); return -1; } diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index c5c8173f63..2dde0de39b 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -70,7 +70,7 @@ int32_t walRestoreFromSnapshot(SWal *pWal, int64_t ver) { pWal->lastRollSeq = -1; taosArrayClear(pWal->fileInfoSet); - pWal->vers.firstVer = -1; + pWal->vers.firstVer = ver + 1; pWal->vers.lastVer = ver; pWal->vers.commitVer = ver; pWal->vers.snapshotVer = ver; @@ -554,10 +554,15 @@ END: return -1; } -int64_t walAppendLog(SWal *pWal, tmsg_t msgType, SWalSyncInfo syncMeta, const void *body, int32_t bodyLen) { +int64_t walAppendLog(SWal *pWal, int64_t index, tmsg_t msgType, SWalSyncInfo syncMeta, const void *body, + int32_t bodyLen) { taosThreadMutexLock(&pWal->mutex); - int64_t index = pWal->vers.lastVer + 1; + if (index != pWal->vers.lastVer + 1) { + terrno = TSDB_CODE_WAL_INVALID_VER; + taosThreadMutexUnlock(&pWal->mutex); + return -1; + } if (walCheckAndRoll(pWal) < 0) { taosThreadMutexUnlock(&pWal->mutex); diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index c3283ffe84..68365be481 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -491,6 +491,28 @@ int64_t taosWriteFile(TdFilePtr pFile, const void *buf, int64_t count) { return count; } +int64_t taosPWriteFile(TdFilePtr pFile, const void *buf, int64_t count, int64_t offset) { + if (pFile == NULL) { + return 0; + } +#if FILE_WITH_LOCK + taosThreadRwlockWrlock(&(pFile->rwlock)); +#endif + assert(pFile->fd >= 0); // Please check if you have closed the file. +#ifdef WINDOWS + size_t pos = _lseeki64(pFile->fd, 0, SEEK_CUR); + _lseeki64(pFile->fd, offset, SEEK_SET); + int64_t ret = _write(pFile->fd, buf, count); + _lseeki64(pFile->fd, pos, SEEK_SET); +#else + int64_t ret = pwrite(pFile->fd, buf, count, offset); +#endif +#if FILE_WITH_LOCK + taosThreadRwlockUnlock(&(pFile->rwlock)); +#endif + return ret; +} + int64_t taosLSeekFile(TdFilePtr pFile, int64_t offset, int32_t whence) { #if FILE_WITH_LOCK taosThreadRwlockRdlock(&(pFile->rwlock)); diff --git a/source/os/src/osMemory.c b/source/os/src/osMemory.c index 2f30e8977a..230ca5b968 100644 --- a/source/os/src/osMemory.c +++ b/source/os/src/osMemory.c @@ -351,7 +351,8 @@ void* taosMemoryMallocAlign(uint32_t alignment, int64_t size) { ASSERT(0); #else #if defined(LINUX) - return memalign(alignment, size); + void* p = memalign(alignment, size); + return p; #else return taosMemoryMalloc(size); #endif diff --git a/source/os/src/osSemaphore.c b/source/os/src/osSemaphore.c index bfce8b3151..2f947d3252 100644 --- a/source/os/src/osSemaphore.c +++ b/source/os/src/osSemaphore.c @@ -75,20 +75,16 @@ int32_t tsem_wait(tsem_t* sem) { return ret; } -int32_t tsem_timewait(tsem_t* sem, int64_t milis) { - return 0; - /*return tsem_wait(sem);*/ -#if 0 +int32_t tsem_timewait(tsem_t* sem, int64_t ms) { struct timespec ts; - timespec_get(&ts); + taosClockGetTime(0, &ts); + ts.tv_nsec += ms * 1000000; ts.tv_sec += ts.tv_nsec / 1000000000; ts.tv_nsec %= 1000000000; - - /*GetSystemTimeAsFileTime(&ft_before);*/ - // errno = 0; - rc = sem_timedwait(sem, ts); - + int rc; + while ((rc = sem_timedwait(sem, &ts)) == -1 && errno == EINTR) continue; + return rc; /* This should have timed out */ // assert(errno == ETIMEDOUT); // assert(rc != 0); @@ -103,8 +99,6 @@ int32_t tsem_timewait(tsem_t* sem, int64_t milis) { // printf("time must advance during sem_timedwait."); // return 1; // } - return rc; -#endif } #elif defined(_TD_DARWIN_64) diff --git a/source/util/src/tarray.c b/source/util/src/tarray.c index ae25786375..4bd8294423 100644 --- a/source/util/src/tarray.c +++ b/source/util/src/tarray.c @@ -319,9 +319,9 @@ SArray* taosArrayDup(const SArray* pSrc, __array_item_dup_fn_t fn) { } else { ASSERT(pSrc->elemSize == sizeof(void*)); - for(int32_t i = 0; i < pSrc->size; ++i) { + for (int32_t i = 0; i < pSrc->size; ++i) { void* p = fn(taosArrayGetP(pSrc, i)); - memcpy(((char*)dst->pData )+ i * dst->elemSize, &p, dst->elemSize); + memcpy(((char*)dst->pData) + i * dst->elemSize, &p, dst->elemSize); } } diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index 586586f742..3d05f80acf 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -294,8 +294,8 @@ static int32_t cfgSetTfsItem(SConfig *pCfg, const char *name, const char *value, SDiskCfg cfg = {0}; tstrncpy(cfg.dir, value, sizeof(cfg.dir)); - cfg.level = atoi(level); - cfg.primary = atoi(primary); + cfg.level = level ? atoi(level) : 0; + cfg.primary = primary ? atoi(primary) : 1; void *ret = taosArrayPush(pItem->array, &cfg); if (ret == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -660,13 +660,12 @@ int32_t cfgLoadFromEnvVar(SConfig *pConfig) { if (vlen3 != 0) value3[vlen3] = 0; } - if (value2 != NULL && value3 != NULL && value2[0] != 0 && value3[0] != 0 && strcasecmp(name, "dataDir") == 0) { + if (strcasecmp(name, "dataDir") == 0) { code = cfgSetTfsItem(pConfig, name, value, value2, value3, CFG_STYPE_ENV_VAR); if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; - } else { - code = cfgSetItem(pConfig, name, value, CFG_STYPE_ENV_VAR); - if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; } + code = cfgSetItem(pConfig, name, value, CFG_STYPE_ENV_VAR); + if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; } uInfo("load from env variables cfg success"); @@ -703,13 +702,12 @@ int32_t cfgLoadFromEnvCmd(SConfig *pConfig, const char **envCmd) { if (vlen3 != 0) value3[vlen3] = 0; } - if (value2 != NULL && value3 != NULL && value2[0] != 0 && value3[0] != 0 && strcasecmp(name, "dataDir") == 0) { + if (strcasecmp(name, "dataDir") == 0) { code = cfgSetTfsItem(pConfig, name, value, value2, value3, CFG_STYPE_ENV_CMD); if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; - } else { - code = cfgSetItem(pConfig, name, value, CFG_STYPE_ENV_CMD); - if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; } + code = cfgSetItem(pConfig, name, value, CFG_STYPE_ENV_CMD); + if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; } uInfo("load from env cmd cfg success"); @@ -768,13 +766,12 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) { if (vlen3 != 0) value3[vlen3] = 0; } - if (value2 != NULL && value3 != NULL && value2[0] != 0 && value3[0] != 0 && strcasecmp(name, "dataDir") == 0) { + if (strcasecmp(name, "dataDir") == 0) { code = cfgSetTfsItem(pConfig, name, value, value2, value3, CFG_STYPE_ENV_FILE); if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; - } else { - code = cfgSetItem(pConfig, name, value, CFG_STYPE_ENV_FILE); - if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; } + code = cfgSetItem(pConfig, name, value, CFG_STYPE_ENV_FILE); + if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; } taosCloseFile(&pFile); @@ -828,13 +825,12 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { if (vlen3 != 0) value3[vlen3] = 0; } - if (value2 != NULL && value3 != NULL && value2[0] != 0 && value3[0] != 0 && strcasecmp(name, "dataDir") == 0) { + if (strcasecmp(name, "dataDir") == 0) { code = cfgSetTfsItem(pConfig, name, value, value2, value3, CFG_STYPE_CFG_FILE); if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; - } else { - code = cfgSetItem(pConfig, name, value, CFG_STYPE_CFG_FILE); - if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; } + code = cfgSetItem(pConfig, name, value, CFG_STYPE_CFG_FILE); + if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; } taosCloseFile(&pFile); @@ -895,7 +891,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { // code = cfgSetItem(pConfig, name, value, CFG_STYPE_CFG_FILE); // if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; -// if (value2 != NULL && value3 != NULL && value2[0] != 0 && value3[0] != 0 && strcasecmp(name, "dataDir") == 0) { +// if (strcasecmp(name, "dataDir") == 0) { // code = cfgSetTfsItem(pConfig, name, value, value2, value3, CFG_STYPE_CFG_FILE); // if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; // } @@ -993,13 +989,12 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { paGetToken(value2 + vlen2 + 1, &value3, &vlen3); if (vlen3 != 0) value3[vlen3] = 0; } - if (value2 != NULL && value3 != NULL && value2[0] != 0 && value3[0] != 0 && strcasecmp(name, "dataDir") == 0) { + if (strcasecmp(name, "dataDir") == 0) { code = cfgSetTfsItem(pConfig, name, value, value2, value3, CFG_STYPE_APOLLO_URL); if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; - } else { - code = cfgSetItem(pConfig, name, value, CFG_STYPE_APOLLO_URL); - if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; } + code = cfgSetItem(pConfig, name, value, CFG_STYPE_APOLLO_URL); + if (code != 0 && terrno != TSDB_CODE_CFG_NOT_FOUND) break; } } tjsonDelete(pJson); diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 1901e48c50..479cb027c7 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -46,8 +46,6 @@ STaosError errors[] = { #endif // rpc -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_AUTH_FAILURE, "Authentication failure") -TAOS_DEFINE_ERROR(TSDB_CODE_RPC_REDIRECT, "Database not ready, need retry") TAOS_DEFINE_ERROR(TSDB_CODE_RPC_NETWORK_UNAVAIL, "Unable to establish connection") TAOS_DEFINE_ERROR(TSDB_CODE_RPC_FQDN_ERROR, "Unable to resolve FQDN") TAOS_DEFINE_ERROR(TSDB_CODE_RPC_PORT_EADDRINUSE, "Port already in use") @@ -56,9 +54,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RPC_TIMEOUT, "Conn read timeout") //common & util TAOS_DEFINE_ERROR(TSDB_CODE_TIME_UNSYNCED, "Client and server's time is not synchronized") -TAOS_DEFINE_ERROR(TSDB_CODE_APP_NOT_READY, "Database not ready") TAOS_DEFINE_ERROR(TSDB_CODE_OPS_NOT_SUPPORT, "Operation not supported") -TAOS_DEFINE_ERROR(TSDB_CODE_MEMORY_CORRUPTED, "Memory corrupted") TAOS_DEFINE_ERROR(TSDB_CODE_OUT_OF_MEMORY, "Out of Memory") TAOS_DEFINE_ERROR(TSDB_CODE_FILE_CORRUPTED, "Data file corrupted") TAOS_DEFINE_ERROR(TSDB_CODE_REF_NO_MEMORY, "Ref out of memory") @@ -67,11 +63,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_REF_ID_REMOVED, "Ref ID is removed") TAOS_DEFINE_ERROR(TSDB_CODE_REF_INVALID_ID, "Invalid Ref ID") TAOS_DEFINE_ERROR(TSDB_CODE_REF_ALREADY_EXIST, "Ref is already there") TAOS_DEFINE_ERROR(TSDB_CODE_REF_NOT_EXIST, "Ref is not there") + TAOS_DEFINE_ERROR(TSDB_CODE_APP_ERROR, "Unexpected generic error") TAOS_DEFINE_ERROR(TSDB_CODE_ACTION_IN_PROGRESS, "Action in progress") TAOS_DEFINE_ERROR(TSDB_CODE_OUT_OF_RANGE, "Out of range") -TAOS_DEFINE_ERROR(TSDB_CODE_OUT_OF_SHM_MEM, "Out of Shared memory") -TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_SHM_ID, "Invalid SHM ID") TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG, "Invalid message") TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_MSG_LEN, "Invalid message len") TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_PTR, "Invalid pointer") @@ -83,6 +78,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VERSION_NUMBER, "Invalid version numbe TAOS_DEFINE_ERROR(TSDB_CODE_INVALID_VERSION_STRING, "Invalid version string") TAOS_DEFINE_ERROR(TSDB_CODE_VERSION_NOT_COMPATIBLE, "Version not compatible") TAOS_DEFINE_ERROR(TSDB_CODE_CHECKSUM_ERROR, "Checksum error") + TAOS_DEFINE_ERROR(TSDB_CODE_COMPRESS_ERROR, "Failed to compress msg") TAOS_DEFINE_ERROR(TSDB_CODE_MSG_NOT_PROCESSED, "Message not processed") TAOS_DEFINE_ERROR(TSDB_CODE_CFG_NOT_FOUND, "Config not found") @@ -97,6 +93,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_NOT_FOUND, "Not found") TAOS_DEFINE_ERROR(TSDB_CODE_NO_DISKSPACE, "Out of disk space") TAOS_DEFINE_ERROR(TSDB_CODE_TIMEOUT_ERROR, "Operation timeout") +TAOS_DEFINE_ERROR(TSDB_CODE_APP_IS_STARTING, "Database is starting up") +TAOS_DEFINE_ERROR(TSDB_CODE_APP_IS_STOPPING, "Database is closing down") + //client TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_OPERATION, "Invalid operation") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_QHANDLE, "Invalid qhandle") @@ -110,11 +109,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_PASS_LENGTH, "Invalid password") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_DB_LENGTH, "Database name too long") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH, "Table name too long") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_CONNECTION, "Invalid connection") -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_OUT_OF_MEMORY, "System out of memory") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_QUERY_CACHE_ERASED, "Query cache erased") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_QUERY_CANCELLED, "Query terminated") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_SORTED_RES_TOO_MANY, "Result set too large to be sorted") // too many result for ordered super table projection query -TAOS_DEFINE_ERROR(TSDB_CODE_TSC_APP_ERROR, "Application error") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_ACTION_IN_PROGRESS, "Action in progress") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_DISCONNECTED, "Disconnected from service") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_WRITE_AUTH, "No write permission") @@ -143,7 +140,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NOT_STABLE_ERROR, "Table is not a super // mnode-common TAOS_DEFINE_ERROR(TSDB_CODE_MND_NO_RIGHTS, "Insufficient privilege for operation") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_APP_ERROR, "Mnode internal error") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_CONNECTION, "Invalid message connection") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SHOWOBJ, "Data expired") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_QUERY_ID, "Invalid query id") @@ -158,7 +154,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_USER_DISABLED, "User is disabled") // mnode-sdb TAOS_DEFINE_ERROR(TSDB_CODE_SDB_OBJ_ALREADY_THERE, "Object already there") -TAOS_DEFINE_ERROR(TSDB_CODE_SDB_APP_ERROR, "Unexpected generic error in sdb") TAOS_DEFINE_ERROR(TSDB_CODE_SDB_INVALID_TABLE_TYPE, "Invalid table type") TAOS_DEFINE_ERROR(TSDB_CODE_SDB_OBJ_NOT_THERE, "Object not there") TAOS_DEFINE_ERROR(TSDB_CODE_SDB_INVALID_KEY_TYPE, "Invalid key type") @@ -272,6 +267,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_INVALID_STAGE, "Invalid stage to kill TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_CONFLICT, "Conflict transaction not completed") TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_UNKNOW_ERROR, "Unknown transaction error") TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_CLOG_IS_NULL, "Transaction commitlog is null") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_LAST_TRANS_NOT_FINISHED, "Last Transaction not finished") TAOS_DEFINE_ERROR(TSDB_CODE_MND_TRANS_NETWORK_UNAVAILL, "Unable to establish connection While execute transaction") // mnode-mq @@ -303,19 +299,30 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_SMA_NOT_EXIST, "SMA does not exist") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SMA_OPTION, "Invalid sma option") // dnode -TAOS_DEFINE_ERROR(TSDB_CODE_NODE_OFFLINE, "Node is offline") -TAOS_DEFINE_ERROR(TSDB_CODE_NODE_ALREADY_DEPLOYED, "Node already deployed") -TAOS_DEFINE_ERROR(TSDB_CODE_NODE_NOT_DEPLOYED, "Node not deployed") +TAOS_DEFINE_ERROR(TSDB_CODE_DNODE_OFFLINE, "Dnode is offline") +TAOS_DEFINE_ERROR(TSDB_CODE_MNODE_NOT_FOUND, "Mnode not found") +TAOS_DEFINE_ERROR(TSDB_CODE_MNODE_ALREADY_DEPLOYED, "Mnode already deployed") +TAOS_DEFINE_ERROR(TSDB_CODE_MNODE_NOT_DEPLOYED, "Mnode not deployed") +TAOS_DEFINE_ERROR(TSDB_CODE_QNODE_NOT_FOUND, "Qnode not found") +TAOS_DEFINE_ERROR(TSDB_CODE_QNODE_ALREADY_DEPLOYED, "Qnode already deployed") +TAOS_DEFINE_ERROR(TSDB_CODE_QNODE_NOT_DEPLOYED, "Qnode not deployed") +TAOS_DEFINE_ERROR(TSDB_CODE_SNODE_NOT_FOUND, "Snode not found") +TAOS_DEFINE_ERROR(TSDB_CODE_SNODE_ALREADY_DEPLOYED, "Snode already deployed") +TAOS_DEFINE_ERROR(TSDB_CODE_SNODE_NOT_DEPLOYED, "Snode not deployed") // vnode -TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_VGROUP_ID, "Invalid Vgroup ID") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_VGROUP_ID, "Vnode moved to another dnode or was deleted") TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_WRITE_AUTH, "Database write operation denied") -TAOS_DEFINE_ERROR(TSDB_CODE_VND_HASH_MISMATCH, "Hash value mismatch") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_NOT_EXIST, "Vnode not exist") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_ALREADY_EXIST, "Vnode already exist") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_HASH_MISMATCH, "Vnode hash mismatch") TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_TABLE_ACTION, "Invalid table action") TAOS_DEFINE_ERROR(TSDB_CODE_VND_COL_ALREADY_EXISTS, "Table column already exists") TAOS_DEFINE_ERROR(TSDB_CODE_VND_COL_NOT_EXISTS, "Table column not exists") TAOS_DEFINE_ERROR(TSDB_CODE_VND_COL_SUBSCRIBED, "Table column is subscribed") TAOS_DEFINE_ERROR(TSDB_CODE_VND_NO_AVAIL_BUFPOOL, "No availabe buffer pool") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_STOPPED, "Vnode stopped") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_DUP_REQUEST, "Duplicate write request") // tsdb TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_ID, "Invalid table ID") @@ -325,8 +332,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TABLE_ALREADY_EXIST, "Table already exists" TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_CONFIG, "Invalid configuration") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INIT_FAILED, "Tsdb init failed") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_DISK_PERMISSIONS, "No permission for disk files") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_FILE_CORRUPTED, "Data file(s) corrupted") -TAOS_DEFINE_ERROR(TSDB_CODE_TDB_OUT_OF_MEMORY, "Out of memory") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TAG_VER_OUT_OF_DATE, "Tag too old") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TIMESTAMP_OUT_OF_RANGE, "Timestamp data out of range") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_SUBMIT_MSG_MSSED_UP, "Submit message is messed up") @@ -350,8 +355,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TABLE_IN_OTHER_STABLE, "Table already exists // query TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_QHANDLE, "Invalid handle") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_MSG, "Invalid message") // failed to validate the sql expression msg by vnode -TAOS_DEFINE_ERROR(TSDB_CODE_QRY_OUT_OF_MEMORY, "System out of memory") -TAOS_DEFINE_ERROR(TSDB_CODE_QRY_APP_ERROR, "Unexpected generic error in query") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_DUP_JOIN_KEY, "Duplicated join key") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_EXCEED_TAGS_LIMIT, "Tag conditon too many") TAOS_DEFINE_ERROR(TSDB_CODE_QRY_NOT_READY, "Query not ready") @@ -416,7 +419,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TQ_INVALID_CONFIG, "TQ invalid config") TAOS_DEFINE_ERROR(TSDB_CODE_TQ_INIT_FAILED, "TQ init falied") TAOS_DEFINE_ERROR(TSDB_CODE_TQ_NO_DISK_PERMISSIONS, "TQ no disk permissions") TAOS_DEFINE_ERROR(TSDB_CODE_TQ_FILE_CORRUPTED, "TQ file corrupted") -TAOS_DEFINE_ERROR(TSDB_CODE_TQ_OUT_OF_MEMORY, "TQ out of memory") TAOS_DEFINE_ERROR(TSDB_CODE_TQ_FILE_ALREADY_EXISTS, "TQ file already exists") TAOS_DEFINE_ERROR(TSDB_CODE_TQ_FAILED_TO_CREATE_DIR, "TQ failed to create dir") TAOS_DEFINE_ERROR(TSDB_CODE_TQ_META_NO_SUCH_KEY, "TQ meta no such key") @@ -427,11 +429,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND, "TQ table schema not f TAOS_DEFINE_ERROR(TSDB_CODE_TQ_NO_COMMITTED_OFFSET, "TQ no commited offset") // wal -TAOS_DEFINE_ERROR(TSDB_CODE_WAL_APP_ERROR, "WAL unexpected generic error") TAOS_DEFINE_ERROR(TSDB_CODE_WAL_FILE_CORRUPTED, "WAL file is corrupted") TAOS_DEFINE_ERROR(TSDB_CODE_WAL_SIZE_LIMIT, "WAL size exceeds limit") TAOS_DEFINE_ERROR(TSDB_CODE_WAL_INVALID_VER, "WAL use invalid version") -TAOS_DEFINE_ERROR(TSDB_CODE_WAL_OUT_OF_MEMORY, "WAL out of memory") TAOS_DEFINE_ERROR(TSDB_CODE_WAL_LOG_NOT_EXIST, "WAL log not exist") TAOS_DEFINE_ERROR(TSDB_CODE_WAL_CHKSUM_MISMATCH, "WAL checksum mismatch") TAOS_DEFINE_ERROR(TSDB_CODE_WAL_LOG_INCOMPLETE, "WAL log incomplete") @@ -445,7 +445,6 @@ TAOS_DEFINE_ERROR(TSDB_CODE_FS_NO_MOUNT_AT_TIER, "tfs no mount at tier" TAOS_DEFINE_ERROR(TSDB_CODE_FS_FILE_ALREADY_EXISTS, "tfs file already exists") TAOS_DEFINE_ERROR(TSDB_CODE_FS_INVLD_LEVEL, "tfs invalid level") TAOS_DEFINE_ERROR(TSDB_CODE_FS_NO_VALID_DISK, "tfs no valid disk") -TAOS_DEFINE_ERROR(TSDB_CODE_FS_APP_ERROR, "tfs out of memory") // catalog TAOS_DEFINE_ERROR(TSDB_CODE_CTG_INTERNAL_ERROR, "catalog internal error") @@ -519,7 +518,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_FIRST_COLUMN, "First column must b TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN, "Invalid binary/nchar column length") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_TAGS_NUM, "Invalid number of tag columns") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_PERMISSION_DENIED, "Permission denied") -TAOS_DEFINE_ERROR(TSDB_CODE_PAR_PERMISSION_DENIED, "Invalid stream query") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Invalid stream query") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_INTERNAL_PK, "Invalid _c0 or _rowts expression") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_TIMELINE_FUNC, "Invalid timeline function") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_PASSWD, "Invalid password") diff --git a/source/util/src/thash.c b/source/util/src/thash.c index a0411483ca..e9548613aa 100644 --- a/source/util/src/thash.c +++ b/source/util/src/thash.c @@ -244,7 +244,7 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool update, SHashLockTyp capacity = 4; } - SHashObj *pHashObj = (SHashObj *)taosMemoryCalloc(1, sizeof(SHashObj)); + SHashObj *pHashObj = (SHashObj *)taosMemoryMalloc(sizeof(SHashObj)); if (pHashObj == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; @@ -264,7 +264,7 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool update, SHashLockTyp ASSERT((pHashObj->capacity & (pHashObj->capacity - 1)) == 0); - pHashObj->hashList = (SHashEntry **)taosMemoryCalloc(pHashObj->capacity, sizeof(void *)); + pHashObj->hashList = (SHashEntry **)taosMemoryMalloc(pHashObj->capacity * sizeof(void *)); if (pHashObj->hashList == NULL) { taosMemoryFree(pHashObj); terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -279,7 +279,7 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool update, SHashLockTyp return NULL; } - void *p = taosMemoryCalloc(pHashObj->capacity, sizeof(SHashEntry)); + void *p = taosMemoryMalloc(pHashObj->capacity * sizeof(SHashEntry)); if (p == NULL) { taosArrayDestroy(pHashObj->pMemBlock); taosMemoryFree(pHashObj->hashList); @@ -290,6 +290,9 @@ SHashObj *taosHashInit(size_t capacity, _hash_fn_t fn, bool update, SHashLockTyp for (int32_t i = 0; i < pHashObj->capacity; ++i) { pHashObj->hashList[i] = (void *)((char *)p + i * sizeof(SHashEntry)); + pHashObj->hashList[i]->num = 0; + pHashObj->hashList[i]->latch = 0; + pHashObj->hashList[i]->next = NULL; } taosArrayPush(pHashObj->pMemBlock, &p); diff --git a/source/util/src/tpagedbuf.c b/source/util/src/tpagedbuf.c index e1a43ace47..37874ae250 100644 --- a/source/util/src/tpagedbuf.c +++ b/source/util/src/tpagedbuf.c @@ -30,6 +30,7 @@ struct SDiskbasedBuf { TdFilePtr pFile; int32_t allocateId; // allocated page id char* path; // file path + char* prefix; // file name prefix int32_t pageSize; // current used page size int32_t inMemPages; // numOfPages that are allocated in memory SList* freePgList; // free page list @@ -48,6 +49,12 @@ struct SDiskbasedBuf { }; static int32_t createDiskFile(SDiskbasedBuf* pBuf) { + 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); + } + pBuf->pFile = taosOpenFile(pBuf->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC | TD_FILE_AUTO_DEL); if (pBuf->pFile == NULL) { @@ -356,10 +363,7 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMem pPBuf->assistBuf = taosMemoryMalloc(pPBuf->pageSize + 2); // EXTRA BYTES pPBuf->all = taosHashInit(10, fn, true, false); - - char path[PATH_MAX] = {0}; - taosGetTmpfilePath(dir, "paged-buf", path); - pPBuf->path = strdup(path); + pPBuf->prefix = (char*) dir; pPBuf->emptyDummyIdList = taosArrayInit(1, sizeof(int32_t)); @@ -507,7 +511,9 @@ void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) { dBufPrintStatis(pBuf); + bool needRemoveFile = false; if (pBuf->pFile != NULL) { + 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", @@ -534,9 +540,13 @@ void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) { } } - if (taosRemoveFile(pBuf->path) < 0) { - uDebug("WARNING tPage remove file failed. path=%s", pBuf->path); + if (needRemoveFile) { + int32_t ret = taosRemoveFile(pBuf->path); + if (ret != 0) { // print the error and discard this error info + uDebug("WARNING tPage remove file failed. path=%s, code:%s", pBuf->path, strerror(errno)); + } } + taosMemoryFreeClear(pBuf->path); size_t n = taosArrayGetSize(pBuf->pIdList); diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/demo.py b/tests/develop-test/5-taos-tools/taosbenchmark/demo.py index 6be5117b08..25a8d92f7e 100644 --- a/tests/develop-test/5-taos-tools/taosbenchmark/demo.py +++ b/tests/develop-test/5-taos-tools/taosbenchmark/demo.py @@ -28,7 +28,7 @@ class TDTestCase: return def init(self, conn, logSql, replicaVar=1): - self.replicaVar = int(replicaVar) + # comment off by Shuduo for CI self.replicaVar = int(replicaVar) tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/invalid_commandline.py b/tests/develop-test/5-taos-tools/taosbenchmark/invalid_commandline.py index 73894d5e33..e5a2551e63 100644 --- a/tests/develop-test/5-taos-tools/taosbenchmark/invalid_commandline.py +++ b/tests/develop-test/5-taos-tools/taosbenchmark/invalid_commandline.py @@ -25,7 +25,7 @@ class TDTestCase: return def init(self, conn, logSql, replicaVar=1): - self.replicaVar = int(replicaVar) + # comment off by Shuduo for CI self.replicaVar = int(replicaVar) tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 6c5c1718b2..c90b2499a4 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -113,7 +113,6 @@ ,,y,script,./test.sh -f tsim/parser/first_last.sim ,,y,script,./test.sh -f tsim/parser/fill_stb.sim ,,y,script,./test.sh -f tsim/parser/interp.sim -#,,y,script,./test.sh -f tsim/parser/limit2.sim ,,y,script,./test.sh -f tsim/parser/fourArithmetic-basic.sim ,,y,script,./test.sh -f tsim/parser/function.sim ,,y,script,./test.sh -f tsim/parser/groupby-basic.sim @@ -624,12 +623,12 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/union1.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/concat2.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/json_tag.py -,,,system-test,python3 ./test.py -f 2-query/nestedQuery.py -,,,system-test,python3 ./test.py -f 2-query/nestedQuery_str.py -,,,system-test,python3 ./test.py -f 2-query/nestedQuery_math.py -,,,system-test,python3 ./test.py -f 2-query/nestedQuery_time.py -,,,system-test,python3 ./test.py -f 2-query/stablity.py -,,,system-test,python3 ./test.py -f 2-query/stablity_1.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity_1.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/elapsed.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/csum.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/function_diff.py @@ -789,12 +788,12 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/arctan.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/interp.py -Q 2 -,,,system-test,python3 ./test.py -f 2-query/nestedQuery.py -Q 2 -,,,system-test,python3 ./test.py -f 2-query/nestedQuery_str.py -Q 2 -,,,system-test,python3 ./test.py -f 2-query/nestedQuery_math.py -Q 2 -,,,system-test,python3 ./test.py -f 2-query/nestedQuery_time.py -Q 2 -,,,system-test,python3 ./test.py -f 2-query/stablity.py -Q 2 -,,,system-test,python3 ./test.py -f 2-query/stablity_1.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity_1.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/avg.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/elapsed.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/csum.py -Q 2 @@ -882,12 +881,12 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/arccos.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/arctan.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 3 -,,,system-test,python3 ./test.py -f 2-query/nestedQuery.py -Q 3 -,,,system-test,python3 ./test.py -f 2-query/nestedQuery_str.py -Q 3 -,,,system-test,python3 ./test.py -f 2-query/nestedQuery_math.py -Q 3 -,,,system-test,python3 ./test.py -f 2-query/nestedQuery_time.py -Q 3 -,,,system-test,python3 ./test.py -f 2-query/stablity.py -Q 3 -,,,system-test,python3 ./test.py -f 2-query/stablity_1.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity_1.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/avg.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/elapsed.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/csum.py -Q 3 @@ -975,10 +974,10 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/arccos.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/arctan.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 4 -,,,system-test,python3 ./test.py -f 2-query/nestedQuery.py -Q 4 -,,,system-test,python3 ./test.py -f 2-query/nestedQuery_str.py -Q 4 -,,,system-test,python3 ./test.py -f 2-query/nestedQuery_math.py -Q 4 -,,,system-test,python3 ./test.py -f 2-query/nestedQuery_time.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity_1.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/avg.py -Q 4 @@ -1023,9 +1022,9 @@ ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/auto_create_table_json.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/custom_col_tag.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/default_json.py -,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/demo.py +#,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/demo.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/insert_alltypes_json.py -,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/invalid_commandline.py +#,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/invalid_commandline.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/json_tag.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/query_json.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/sample_csv_json.py diff --git a/tests/pytest/crash_gen/crash_gen_main.py b/tests/pytest/crash_gen/crash_gen_main.py index 4140728dcd..3c39b05e69 100755 --- a/tests/pytest/crash_gen/crash_gen_main.py +++ b/tests/pytest/crash_gen/crash_gen_main.py @@ -2022,11 +2022,10 @@ class TdSuperTable: conf.set("group.id", "tg2") conf.set("td.connect.user", "root") conf.set("td.connect.pass", "taosdata") - conf.set("enable.auto. - ", "true") - def tmq_commit_cb_print(tmq, resp, offset, param=None): - print(f"commit: {resp}, tmq: {tmq}, offset: {offset}, param: {param}") - conf.set_auto_commit_cb(tmq_commit_cb_print, None) +# 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}") +# conf.set_auto_commit_cb(tmq_commit_cb_print, None) consumer = conf.new_consumer() topic_list = TaosTmqList() for topic in current_topic_list: diff --git a/tests/pytest/util/cases.py b/tests/pytest/util/cases.py index 3eb5cf2548..82aa552359 100644 --- a/tests/pytest/util/cases.py +++ b/tests/pytest/util/cases.py @@ -63,7 +63,7 @@ class TDCases: tdLog.info("total %d Linux test case(s) executed" % (runNum)) - def runOneLinux(self, conn, fileName, replicaVar): + def runOneLinux(self, conn, fileName, replicaVar=1): testModule = self.__dynamicLoadModule(fileName) runNum = 0 diff --git a/tests/script/tsim/parser/groupby-basic.sim b/tests/script/tsim/parser/groupby-basic.sim index 4c70399e4b..2e436945e0 100644 --- a/tests/script/tsim/parser/groupby-basic.sim +++ b/tests/script/tsim/parser/groupby-basic.sim @@ -78,8 +78,8 @@ $ts2 = $tb2 . .ts print ===============================groupby_operation print -print ==== select count(*), c1 from group_tb0 group by c1 -sql select count(*), c1 from group_tb0 group by c1 +print ==== select count(*), c1 from group_tb0 group by c1 order by c1 +sql select count(*), c1 from group_tb0 group by c1 order by c1 print rows: $rows print $data00 $data01 $data02 $data03 print $data10 $data11 $data12 $data13 @@ -98,18 +98,18 @@ endi if $data90 != 10 then return -1 endi -if $data01 != 7 then +if $data01 != 0 then return -1 endi -if $data11 != 6 then +if $data11 != 1 then return -1 endi -if $data91 != 3 then +if $data91 != 9 then return -1 endi -print ==== select first(ts),c1 from group_tb0 group by c1; -sql select first(ts),c1 from group_tb0 group by c1; +print ==== select first(ts),c1 from group_tb0 group by c1 order by c1; +sql select first(ts),c1 from group_tb0 group by c1 order by c1; print rows: $rows print $data00 $data01 $data02 $data03 print $data10 $data11 $data12 $data13 @@ -120,16 +120,16 @@ if $row != 10 then return -1 endi -if $data00 != @22-01-01 00:00:00.007@ then +if $data00 != @22-01-01 00:00:00.000@ then return -1 endi -if $data01 != 7 then +if $data01 != 0 then return -1 endi -if $data90 != @22-01-01 00:00:00.003@ then +if $data90 != @22-01-01 00:00:00.009@ then return -1 endi -if $data91 != 3 then +if $data91 != 9 then return -1 endi diff --git a/tests/script/tsim/parser/lastrow_query.sim b/tests/script/tsim/parser/lastrow_query.sim index a1b14c7a0e..3af5ade10a 100644 --- a/tests/script/tsim/parser/lastrow_query.sim +++ b/tests/script/tsim/parser/lastrow_query.sim @@ -70,10 +70,10 @@ sql select _wstart, t1,t1,count(*),t1,t1 from lr_stb0 where ts>'2018-09-24 00:00 if $row != 2 then return -1 endi -if $data01 != NULL then +if $data01 != 8 then return -1 endi -if $data02 != NULL then +if $data02 != 8 then return -1 endi if $data03 != NULL then diff --git a/tests/script/tsim/user/privilege_db.sim b/tests/script/tsim/user/privilege_db.sim index 83933e0e47..79e3754c2f 100644 --- a/tests/script/tsim/user/privilege_db.sim +++ b/tests/script/tsim/user/privilege_db.sim @@ -5,6 +5,10 @@ sql connect print =============== create db sql create database d1 vgroups 1; +sql use d1 +sql create table stb (ts timestamp, i int) tags (j int) +sql create topic topic_1 as select ts, i from stb + sql create database d2 vgroups 1; sql create database d3 vgroups 1; sql select * from information_schema.ins_databases @@ -89,5 +93,6 @@ sql_error drop database d2; sql_error create stable d1.st (ts timestamp, i int) tags (j int) sql create stable d2.st (ts timestamp, i int) tags (j int) +sql_error create topic topic_2 as select ts, i from stb system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/valgrind/checkUdf.sim b/tests/script/tsim/valgrind/checkUdf.sim index 594d649714..caf316bd86 100644 --- a/tests/script/tsim/valgrind/checkUdf.sim +++ b/tests/script/tsim/valgrind/checkUdf.sim @@ -121,12 +121,13 @@ if $data01 != 152.420471066 then return -1 endi -sql select udf2(f2) from udf.t2 group by 1-udf1(f1); +sql select udf2(f2) from udf.t2 group by 1-udf1(f1) order by 1-udf1(f1) print $rows , $data00 , $data10 if $rows != 2 then return -1 endi if $data00 != 2.000000000 then + print expect 2.000000000 , actual: $data00 return -1 endi if $data10 != 12.083045974 then diff --git a/tests/system-test/0-others/compatibility.py b/tests/system-test/0-others/compatibility.py index 287370f5ed..7220088369 100644 --- a/tests/system-test/0-others/compatibility.py +++ b/tests/system-test/0-others/compatibility.py @@ -62,7 +62,7 @@ class TDTestCase: # os.system(f"mv {self.getBuildPath()}/build/lib/libtaos.so.1 {self.getBuildPath()}/build/lib/libtaos.so.1_bak ") packagePath = "/usr/local/src/" - + dataPath = cPath + "/../data/" packageName = "TDengine-server-"+ BASEVERSION + "-Linux-x64.tar.gz" packageTPath = packageName.split("-Linux-")[0] my_file = Path(f"{packagePath}/{packageName}") @@ -72,22 +72,21 @@ class TDTestCase: os.system(f"cd {packagePath} && wget https://www.tdengine.com/assets-download/3.0/{packageName}") else: print(f"{packageName} has been exists") - os.system(f"cd {packagePath} && tar xvf {packageName} && cd {packageTPath} && ./install.sh -e no " ) + os.system(f" cd {packagePath} && tar xvf {packageName} && cd {packageTPath} && ./install.sh -e no " ) tdDnodes.stop(1) - print(f"start taosd: nohup taosd -c {cPath} & ") - os.system(f" nohup taosd -c {cPath} & " ) + print(f"start taosd: rm -rf {dataPath}/* && nohup taosd -c {cPath} & ") + os.system(f"rm -rf {dataPath}/* && nohup taosd -c {cPath} & " ) sleep(5) - def buildTaosd(self,bPath): # os.system(f"mv {bPath}/build_bak {bPath}/build ") os.system(f" cd {bPath} && make install ") def run(self): - bPath=self.getBuildPath() - cPath=self.getCfgPath() + bPath = self.getBuildPath() + cPath = self.getCfgPath() dbname = "test" stb = f"{dbname}.meters" self.installTaosd(bPath,cPath) @@ -95,6 +94,7 @@ class TDTestCase: tableNumbers=100 recordNumbers1=100 recordNumbers2=1000 + # tdsqlF=tdCom.newTdSql() # print(tdsqlF) # tdsqlF.query(f"SELECT SERVER_VERSION();") @@ -106,6 +106,7 @@ class TDTestCase: # oldClientVersion=tdsqlF.queryResult[0][0] # tdLog.info(f"Base client version is {oldClientVersion}") # baseVersion = "3.0.1.8" + tdLog.printNoPrefix(f"==========step1:prepare and check data in old version-{BASEVERSION}") tdLog.info(f" LD_LIBRARY_PATH=/usr/lib taosBenchmark -t {tableNumbers} -n {recordNumbers1} -y ") os.system(f"LD_LIBRARY_PATH=/usr/lib taosBenchmark -t {tableNumbers} -n {recordNumbers1} -y ") diff --git a/tests/system-test/0-others/taosShell.py b/tests/system-test/0-others/taosShell.py index e3095e8b93..5c7bb0443a 100644 --- a/tests/system-test/0-others/taosShell.py +++ b/tests/system-test/0-others/taosShell.py @@ -62,8 +62,8 @@ def taos_command (buildPath, key, value, expectString, cfgDir, sqlString='', key print ('taos login success! Here can run sql, taos> ') if len(sqlString) != 0: child.sendline (sqlString) - w = child.expect(["Query OK", taosExpect.TIMEOUT, taosExpect.EOF], timeout=10) - if w == 0: + w = child.expect(["Query OK", "Create OK", "Insert OK", "Drop OK", taosExpect.TIMEOUT, taosExpect.EOF], timeout=10) + if w == 0 or w == 1 or w == 2: return "TAOS_OK" else: print(1) @@ -233,7 +233,7 @@ class TDTestCase: tdLog.printNoPrefix("================================ parameter: -s") newDbName="dbss" keyDict['s'] = "\"create database " + newDbName + "\"" - retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + retCode = taos_command(buildPath, "s", keyDict['s'], "Create OK", keyDict['c'], '', '', '') if retCode != "TAOS_OK": tdLog.exit("taos -s fail") @@ -246,17 +246,17 @@ class TDTestCase: tdLog.exit("create db fail after taos -s %s fail"%(keyDict['s'])) keyDict['s'] = "\"create table " + newDbName + ".stb (ts timestamp, c int) tags (t int)\"" - retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + retCode = taos_command(buildPath, "s", keyDict['s'], "Create OK", keyDict['c'], '', '', '') if retCode != "TAOS_OK": tdLog.exit("taos -s create table fail") keyDict['s'] = "\"create table " + newDbName + ".ctb0 using " + newDbName + ".stb tags (0) " + newDbName + ".ctb1 using " + newDbName + ".stb tags (1)\"" - retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + retCode = taos_command(buildPath, "s", keyDict['s'], "Create OK", keyDict['c'], '', '', '') if retCode != "TAOS_OK": tdLog.exit("taos -s create table fail") keyDict['s'] = "\"insert into " + newDbName + ".ctb0 values('2021-04-01 08:00:00.000', 10)('2021-04-01 08:00:01.000', 20) " + newDbName + ".ctb1 values('2021-04-01 08:00:00.000', 11)('2021-04-01 08:00:01.000', 21)\"" - retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + retCode = taos_command(buildPath, "s", keyDict['s'], "Insert OK", keyDict['c'], '', '', '') if retCode != "TAOS_OK": tdLog.exit("taos -s insert data fail") @@ -401,27 +401,27 @@ class TDTestCase: tdLog.printNoPrefix("================================ parameter: -w") newDbName="dbw" keyDict['s'] = "\"create database " + newDbName + "\"" - retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + retCode = taos_command(buildPath, "s", keyDict['s'], "Create OK", keyDict['c'], '', '', '') if retCode != "TAOS_OK": tdLog.exit("taos -w fail") keyDict['s'] = "\"create table " + newDbName + ".ntb (ts timestamp, c binary(128))\"" - retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + retCode = taos_command(buildPath, "s", keyDict['s'], "Create OK", keyDict['c'], '', '', '') if retCode != "TAOS_OK": tdLog.exit("taos -w create table fail") keyDict['s'] = "\"insert into " + newDbName + ".ntb values('2021-04-01 08:00:00.001', 'abcd0123456789')('2021-04-01 08:00:00.002', 'abcd012345678901234567890123456789') \"" - retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + retCode = taos_command(buildPath, "s", keyDict['s'], "Insert OK", keyDict['c'], '', '', '') if retCode != "TAOS_OK": tdLog.exit("taos -w insert data fail") keyDict['s'] = "\"insert into " + newDbName + ".ntb values('2021-04-01 08:00:00.003', 'aaaaaaaaaaaaaaaaaaaa')('2021-04-01 08:00:01.004', 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb') \"" - retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + retCode = taos_command(buildPath, "s", keyDict['s'], "Insert OK", keyDict['c'], '', '', '') if retCode != "TAOS_OK": tdLog.exit("taos -w insert data fail") keyDict['s'] = "\"insert into " + newDbName + ".ntb values('2021-04-01 08:00:00.005', 'cccccccccccccccccccc')('2021-04-01 08:00:01.006', 'dddddddddddddddddddddddddddddddddddddddd') \"" - retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", keyDict['c'], '', '', '') + retCode = taos_command(buildPath, "s", keyDict['s'], "Insert OK", keyDict['c'], '', '', '') if retCode != "TAOS_OK": tdLog.exit("taos -w insert data fail") diff --git a/tests/system-test/0-others/taosdShell.py b/tests/system-test/0-others/taosdShell.py index 581448a6d9..7ad7e4d0ef 100644 --- a/tests/system-test/0-others/taosdShell.py +++ b/tests/system-test/0-others/taosdShell.py @@ -166,7 +166,7 @@ class TDTestCase: # keyDict['c'] = cfgPath # keyDict['P'] = self.serverPort tdDnodes=cluster.dnodes - for i in range(5): + for i in range(len(tdDnodes)): tdDnodes[i].stoptaosd() diff --git a/tests/system-test/1-insert/mutil_stage.py b/tests/system-test/1-insert/mutil_stage.py index 3e2bec130e..8780ecc477 100644 --- a/tests/system-test/1-insert/mutil_stage.py +++ b/tests/system-test/1-insert/mutil_stage.py @@ -147,19 +147,20 @@ class TDTestCase: def __current_cfg(self): cfg_list = [] current_case1 = [ - f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {PRIMARY_DIR}", + #f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {PRIMARY_DIR}", f"dataDir {self.taos_data_dir}/{DATA_PRE0}1 {L0} {NON_PRIMARY_DIR}", f"dataDir {self.taos_data_dir}/{DATA_PRE1}1 {L1} {NON_PRIMARY_DIR}", f"dataDir {self.taos_data_dir}/{DATA_PRE2}2 {L2} {NON_PRIMARY_DIR}" ] - current_case2 = [f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {PRIMARY_DIR}"] + #current_case2 = [f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 {L0} {PRIMARY_DIR}"] + current_case2 = [] for i in range(9): current_case2.append(f"dataDir {self.taos_data_dir}/{DATA_PRE0}{i+1} {L0} {NON_PRIMARY_DIR}") # TD-17773bug current_case3 = [ - f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 ", + #f"dataDir {self.taos_data_dir}/{DATA_PRE0}0 ", f"dataDir {self.taos_data_dir}/{DATA_PRE0}1 {L0} {NON_PRIMARY_DIR}", f"dataDir {self.taos_data_dir}/{DATA_PRE1}0 {L1} {NON_PRIMARY_DIR}", f"dataDir {self.taos_data_dir}/{DATA_PRE2}0 {L2} {NON_PRIMARY_DIR}", diff --git a/tests/system-test/2-query/unique.py b/tests/system-test/2-query/unique.py index 2b0336d2d7..6af9b130ef 100644 --- a/tests/system-test/2-query/unique.py +++ b/tests/system-test/2-query/unique.py @@ -429,10 +429,10 @@ class TDTestCase: tdSql.checkRows(2) # nest query - tdSql.query(f"select unique(c1) from (select _rowts , t1 ,c1 , tbname from {dbname}.stb1 ) ") + tdSql.query(f"select unique(c1) v from (select _rowts , t1 ,c1 , tbname from {dbname}.stb1 ) order by v") tdSql.checkRows(11) - tdSql.checkData(0,0,6) - tdSql.checkData(10,0,3) + tdSql.checkData(1,0,0) + tdSql.checkData(10,0,9) tdSql.query(f"select unique(t1) from (select _rowts , t1 , tbname from {dbname}.stb1 )") tdSql.checkRows(2) tdSql.checkData(0,0,4) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py index 19239513d6..139be74a08 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_createDb_replica1.py @@ -62,7 +62,7 @@ class TDTestCase: # only for 1 mnode mnode_name = k - if v[2] in ['leader', 'leader*']: + if v[2] in ['leader', 'leader*', 'leader**']: is_leader=True if count==1 and is_leader: @@ -111,12 +111,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader', 'leader*', 'follower']: + if role in ['leader', 'leader*', 'leader**', 'follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0] in ['leader', 'leader*']: + if len(v) ==1 and v[0] in ['leader', 'leader*', 'leader**']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py index f27c343329..4a0522ad35 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas.py @@ -116,12 +116,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','leader*','follower']: + if role in ['leader', 'leader*', 'leader**', 'follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0] in ['leader', 'leader*']: + if len(v) == 1 and v[0] in ['leader', 'leader*', 'leader**']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.notice(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py index 671010db9a..82ba256122 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica1_insertdatas_querys.py @@ -117,12 +117,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','leader*','follower']: + if role in ['leader', 'leader*', 'leader**', 'follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0] in ['leader', 'leader*']: + if len(v) == 1 and v[0] in ['leader', 'leader*', 'leader**']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.notice(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py index 0537d824b9..3751391d65 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py @@ -116,12 +116,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','leader*','follower']: + if role in ['leader', 'leader*', 'leader**', 'follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0] in ['leader', 'leader*']: + if len(v) == 1 and v[0] in ['leader', 'leader*', 'leader**']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.notice(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py index d054e25e46..24b4ff63dd 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py @@ -117,12 +117,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','leader*','follower']: + if role in ['leader', 'leader*', 'leader**', 'follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0] in ['leader', 'leader*']: + if len(v) == 1 and v[0] in ['leader', 'leader*', 'leader**']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.notice(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py index 2eb631d433..6ef239382b 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_all_vnode.py @@ -120,12 +120,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','leader*','follower']: + if role in ['leader', 'leader*', 'leader**', 'follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0] in ['leader', 'leader*']: + if len(v) == 1 and v[0] in ['leader', 'leader*', 'leader**']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py index 2993ce3a4a..35ea3f392c 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_follower.py @@ -120,12 +120,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','leader*','follower']: + if role in ['leader', 'leader*', 'leader**', 'follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0] in ['leader', 'leader*']: + if len(v) == 1 and v[0] in ['leader', 'leader*', 'leader**']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.notice(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py index d9a84db6a2..ab5d05f362 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys_loop_restart_leader.py @@ -120,12 +120,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','leader*','follower']: + if role in ['leader', 'leader*', 'leader**', 'follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0] in ['leader', 'leader*']: + if len(v) == 1 and v[0] in ['leader', 'leader*', 'leader**']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.notice(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py index 74181bc563..6e9aacebc2 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_sync.py @@ -125,12 +125,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','leader*','follower']: + if role in ['leader', 'leader*', 'leader**', 'follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0] in ['leader', 'leader*']: + if len(v) == 1 and v[0] in ['leader', 'leader*', 'leader**']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.notice(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py index f1275dcecc..a55bc3c39f 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync.py @@ -125,12 +125,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','leader*','follower']: + if role in ['leader', 'leader*', 'leader**', 'follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0] in ['leader', 'leader*']: + if len(v) == 1 and v[0] in ['leader', 'leader*', 'leader**']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.notice(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py index b48fed77ee..dd8b6b374a 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_follower_unsync_force_stop.py @@ -125,12 +125,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','leader*','follower']: + if role in ['leader','leader*', 'leader**','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0] in ['leader', 'leader*']: + if len(v) == 1 and v[0] in ['leader', 'leader*', 'leader**']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.info(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py index 6308e67068..124bf838bb 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_stop_leader_forece_stop.py @@ -208,12 +208,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','leader*','follower']: + if role in ['leader','leader*', 'leader**','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0] in ['leader', 'leader*']: + if len(v) == 1 and v[0] in ['leader', 'leader*', 'leader**']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.notice(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py index ea5c4679a9..791b58d28d 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_mnode3_insertdatas_querys.py @@ -117,12 +117,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','leader*','follower']: + if role in ['leader','leader*', 'leader**','follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0] in ['leader', 'leader*']: + if len(v) == 1 and v[0] in ['leader', 'leader*', 'leader**']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.exit(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py index 1f994e3350..53a9463d64 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py @@ -116,12 +116,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','leader*','follower']: + if role in ['leader', 'leader*', 'leader**', 'follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0] in ['leader', 'leader*']: + if len(v) == 1 and v[0] in ['leader', 'leader*', 'leader**']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.notice(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py index 56131f24be..ddb765085a 100644 --- a/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py +++ b/tests/system-test/6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups_stopOne.py @@ -119,12 +119,12 @@ class TDTestCase: vgroup_id = vgroup_info[0] tmp_list = [] for role in vgroup_info[3:-4]: - if role in ['leader','leader*','follower']: + if role in ['leader', 'leader*', 'leader**', 'follower']: tmp_list.append(role) vgroups_infos[vgroup_id]=tmp_list for k , v in vgroups_infos.items(): - if len(v) ==1 and v[0] in ['leader', 'leader*']: + if len(v) == 1 and v[0] in ['leader', 'leader*', 'leader**']: tdLog.notice(" === create database replica only 1 role leader check success of vgroup_id {} ======".format(k)) else: tdLog.notice(" === create database replica only 1 role leader check fail of vgroup_id {} ======".format(k)) diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 28578e48a2..5be46fe54a 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -214,6 +214,18 @@ void shellRunSingleCommandImp(char *command) { return; } + // pre string + char * pre = "Query OK"; + if (shellRegexMatch(command, "^\\s*delete\\s*from\\s*.*", REG_EXTENDED | REG_ICASE)) { + pre = "Delete OK"; + } else if(shellRegexMatch(command, "^\\s*insert\\s*into\\s*.*", REG_EXTENDED | REG_ICASE)) { + pre = "Insert OK"; + } else if(shellRegexMatch(command, "^\\s*create\\s*.*", REG_EXTENDED | REG_ICASE)) { + pre = "Create OK"; + } else if(shellRegexMatch(command, "^\\s*drop\\s*.*", REG_EXTENDED | REG_ICASE)) { + pre = "Drop OK"; + } + TAOS_FIELD *pFields = taos_fetch_fields(pSql); if (pFields != NULL) { // select and show kinds of commands int32_t error_no = 0; @@ -229,10 +241,10 @@ void shellRunSingleCommandImp(char *command) { } taos_free_result(pSql); } else { - int32_t num_rows_affacted = taos_affected_rows(pSql); + int64_t num_rows_affacted = taos_affected_rows64(pSql); taos_free_result(pSql); et = taosGetTimestampUs(); - printf("Query OK, %d row(s) affected (%.6fs)\r\n", num_rows_affacted, (et - st) / 1E6); + printf("%s, %" PRId64 " row(s) affected (%.6fs)\r\n", pre, num_rows_affacted, (et - st) / 1E6); // call auto tab callbackAutoTab(command, NULL, false); @@ -935,7 +947,7 @@ void shellGetGrantInfo() { int32_t code = taos_errno(tres); if (code != TSDB_CODE_SUCCESS) { - if (code != TSDB_CODE_OPS_NOT_SUPPORT && code != TSDB_CODE_MND_NO_RIGHTS) { + if (code != TSDB_CODE_OPS_NOT_SUPPORT && code != TSDB_CODE_MND_NO_RIGHTS && code != TSDB_CODE_PAR_PERMISSION_DENIED) { fprintf(stderr, "Failed to check Server Edition, Reason:0x%04x:%s\r\n\r\n", code, taos_errstr(tres)); } return;