diff --git a/deps/mips/dm_static/libdmodule.a b/deps/mips/dm_static/libdmodule.a new file mode 100644 index 0000000000..d4b0582498 Binary files /dev/null and b/deps/mips/dm_static/libdmodule.a differ diff --git a/docs/zh/07-develop/07-tmq.mdx b/docs/zh/07-develop/07-tmq.mdx index 50913e87c8..df651eab96 100644 --- a/docs/zh/07-develop/07-tmq.mdx +++ b/docs/zh/07-develop/07-tmq.mdx @@ -15,334 +15,62 @@ import Node from "./_sub_node.mdx"; import CSharp from "./_sub_cs.mdx"; import CDemo from "./_sub_c.mdx"; -为了帮助应用实时获取写入 TDengine 的数据,或者以事件到达顺序处理数据,TDengine 提供了类似消息队列产品的数据订阅、消费接口。这样在很多场景下,采用 TDengine 的时序数据处理系统不再需要集成消息队列产品,比如 kafka, 从而简化系统设计的复杂度,降低运营维护成本。 -与 kafka 一样,你需要定义 *topic*, 但 TDengine 的 *topic* 是基于一个已经存在的超级表、子表或普通表的查询条件,即一个 `SELECT` 语句。你可以使用 SQL 对标签、表名、列、表达式等条件进行过滤,以及对数据进行标量函数与 UDF 计算(不包括数据聚合)。与其他消息队列软件相比,这是 TDengine 数据订阅功能的最大的优势,它提供了更大的灵活性,数据的颗粒度可以由应用随时调整,而且数据的过滤与预处理交给 TDengine,而不是应用完成,有效的减少传输的数据量与应用的复杂度。 +为了帮助应用实时获取写入 TDengine 的数据,或者以事件到达顺序处理数据,TDengine 提供了类似 kafka 的数据订阅功能。这样在很多场景下,采用 TDengine 的时序数据处理系统不再需要集成消息队列产品,比如 kafka, 从而简化系统设计的复杂度,降低运营维护成本。 -消费者订阅 *topic* 后,可以实时获得最新的数据。多个消费者可以组成一个消费者组 (consumer group), 一个消费者组里的多个消费者共享消费进度,便于多线程、分布式地消费数据,提高消费速度。但不同消费者组中的消费者即使消费同一个 topic, 并不共享消费进度。一个消费者可以订阅多个 topic。如果订阅的是超级表,数据可能会分布在多个不同的 vnode 上,也就是多个 shard 上,这样一个消费组里有多个消费者可以提高消费效率。TDengine 的消息队列提供了消息的 ACK 机制,在宕机、重启等复杂环境下确保 at least once 消费。 +# 介绍 +## 主题 +与 kafka 一样,你需要定义 topic, TDengine 的 topic 有三种,可以是数据库,超级表,或者一个 `SELECT` 语句,具体的语法参见 [CREATE TOPIC](../../12-taos-sql/13-tmq)。与其他消息队列软件相比,这是 TDengine 数据订阅功能的最大的优势,它提供了更大的灵活性,数据的颗粒度可以由应用随时调整,而且数据的过滤与预处理交给 TDengine,而不是应用完成,有效的减少传输的数据量与应用的复杂度。 -为了实现上述功能,TDengine 会为 WAL (Write-Ahead-Log) 文件自动创建索引以支持快速随机访问,并提供了灵活可配置的文件切换与保留机制:用户可以按需指定 WAL 文件保留的时间以及大小(详见 create database 语句)。通过以上方式将 WAL 改造成了一个保留事件到达顺序的、可持久化的存储引擎(但由于 TSDB 具有远比 WAL 更高的压缩率,我们不推荐保留太长时间,一般来说,不超过几天)。 对于以 topic 形式创建的查询,TDengine 将对接 WAL 而不是 TSDB 作为其存储引擎。在消费时,TDengine 根据当前消费进度从 WAL 直接读取数据,并使用统一的查询引擎实现过滤、变换等操作,将数据推送给消费者。 +如下图,每个 topic 涉及到的数据表可能分布在多个 vnode(相当于 kafka 里的 partition) 上,每个 vnode 上的数据保存在 WAL(Write-Ahead-Log) 文件中,WAL 文件里的数据是顺序写入的(由于 WAL 文件中存储的不只有数据,还有元数据,写入消息等,所以数据的版本号不是连续的)。 -下面为关于数据订阅的一些说明,需要对TDengine的架构有一些了解,结合各个语言链接器的接口使用。(可使用时再了解) -- 一个消费组消费同一个topic下的所有数据,不同消费组之间相互独立; -- 一个消费组消费同一个topic所有的vgroup,消费组可由多个消费者组成,但一个vgroup仅被一个消费者消费,如果消费者数量超过了vgroup数量,多余的消费者不消费数据; -- 在服务端每个vgroup仅保存一个offset,每个vgroup的offset是单调递增的,但不一定连续。各个vgroup的offset之间没有关联; -- 每次poll服务端会返回一个结果block,该block属于一个vgroup,可能包含多个wal版本的数据,可以通过 offset 接口获得是该block第一条记录的offset; -- 一个消费组如果从未commit过offset,当其成员消费者重启重新拉取数据时,均从参数auto.offset.reset设定值开始消费;在一个消费者生命周期中,客户端本地记录了最近一次拉取数据的offset,不会拉取重复数据; -- 消费者如果异常终止(没有调用tmq_close),需等约12秒后触发其所属消费组rebalance,该消费者在服务端状态变为LOST,约1天后该消费者自动被删除;正常退出,退出后就会删除消费者;新增消费者,需等约2秒触发rebalance,该消费者在服务端状态变为ready; -- 消费组rebalance会对该组所有ready状态的消费者成员重新进行vgroup分配,消费者仅能对自己负责的vgroup进行assignment/seek/commit/poll操作; -- 消费者可利用 position 获得当前消费的offset,并seek到指定offset,重新消费; -- seek将position指向指定offset,不执行commit操作,一旦seek成功,可poll拉取指定offset及以后的数据; -- seek 操作之前须调用 assignment 接口获取该consumer的vgroup ID和offset范围。seek 操作会检测vgroup ID 和 offset是否合法,如非法将报错; -- position是获取当前的消费位置,是下次要取的位置,不是当前消费到的位置 -- commit是提交消费位置,不带参数的话,是提交当前消费位置(下次要取的位置,不是当前消费到的位置),带参数的话,是提交参数里的位置(也即下次退出重启后要取的位置) -- seek是设置consumer消费位置,seek到哪,position就返回哪,都是下次要取的位置 -- seek不会影响commit,commit不影响seek,相互独立,两个是不同的概念 -- begin接口为wal 第一条数据的offset,end 接口为wal 最后一条数据的offset + 1 -- offset接口获取的是记录所在结果block块里的第一条数据的offset,当seek至该offset时,将消费到这个block里的全部数据。参见第四点; -- 由于存在 WAL 过期删除机制,即使seek 操作成功,poll数据时有可能offset已失效。如果poll 的offset 小于 WAL 最小版本号,将会从WAL最小版本号消费; -- 数据订阅是从 WAL 消费数据,如果一些 WAL 文件被基于 WAL 保留策略删除,则已经删除的 WAL 文件中的数据就无法再消费到。需要根据业务需要在创建数据库时合理设置 `WAL_RETENTION_PERIOD` 或 `WAL_RETENTION_SIZE` ,并确保应用及时消费数据,这样才不会产生数据丢失的现象。数据订阅的行为与 Kafka 等广泛使用的消息队列类产品的行为相似; +![img_5.png](img_5.png) -本文档不对消息队列本身的知识做更多的介绍,如果需要了解,请自行搜索。 +TDengine 会为 WAL 文件自动创建索引以支持快速随机访问,并提供了灵活可配置的文件切换与保留机制,用户可以按需指定 WAL 文件保留的时间以及大小(详见 [CREATE DATABASE](../../12-taos-sql/02-database) 语句,由于消费是通过 WAL 实现的,所以应该根据写入消费速度来确定 WAL 的保存时长)。通过以上方式将 WAL 改造成了一个保留事件到达顺序的、可持久化的存储引擎。 -说明: +对于 `SELECT` 语句形式的 topic,在消费时,TDengine 根据当前消费进度从 WAL 直接读取数据,并使用统一的查询引擎实现过滤、变换等操作,将数据推送给消费者。 + +## 生产者 +写入 topic 相关联的数据表中数据的都是生产者,生产者实际生产的数据写入到了子表或普通表中,即表所在 vnode 的 WAL 里。 + +## 消费者 +### 消费者组 +消费者订阅 topic 后,可以消费 topic 里的所有数据(这些数据所在的表可能分布在多个 vnode 上,即 db 所在的所有 vnode)。订阅 topic 时,需要指定一个消费者组 (consumer group),如果这个消费者组里只有一个消费者,那么这个消费者会顺序的消费这些 vnode 上的数据。 + +为了提高消费速度,便于多线程、分布式地消费数据,可以在一个消费组里添加多个消费者,这些消费者将均分数据所在的 vnode 进行消费(比如数据分布在 4 个 vnode 上,有 2 个消费者的话,那么每个消费者消费 2 个 vnode;有 3 个消费者的话,2 个消费者各消费 1 个 vnode,1 个消费者消费 2 个 vnode;有 5 个消费者的话,4 个各分配 1 个 vnode 消费,另外 1 个不消费),如下图: + +![img_6.png](img_6.png) + +在一个消费组里添加一个消费者后,在 Mnode 上通过 rebalance 的机制实现消费者的重新分配,该操作对用户是透明的。 + +一个消费者可以订阅多个 topic。TDengine 的数据订阅在宕机、重启等复杂环境下确保 at least once 消费。 +### 消费进度 +在 topic 的一个消费组的一个 vnode 上有消费进度。消费者消费的同时,可以提交消费进度,消费进度即 vnode 上 WAL 的版本号(对于 kafka 里的 offset),消费进度可以手动提交,也可以通过参数(auto.commit.interval.ms)设置为周期性自动提交。 + +首次消费数据时通过订阅参数(auto.offset.reset)来确定消费位置为最新数据(latest)还是最旧数据(earliest)。 + +消费进度在一个 vnode 上对于同一个 topic 和 消费者组是唯一的。所以如果同一个 topic 和 消费者组在一个 vnode 上的消费者退出了,并且提交了消费进度。然后同一个 topic 和 消费者组里重新建了一个新的消费者消费这个 vnode,那么这个新消费者将继承之前的消费进度继续消费。 + +如果之前的消费者没有提交消费进度,那个新的消费者将根据订阅参数(auto.offset.reset)设置的值来确定起始消费位置。 + +不同消费者组中的消费者即使消费同一个 topic, 并不共享消费进度。 + +![img_7.png](img_7.png) + +作为一个数据库产品, WAL 文件中存储的不全是数据,也包括其他写入消息,元数据等,所以消费进度不是连续的。 + +##说明 从3.2.0.0版本开始,数据订阅支持vnode迁移和分裂。 -由于数据订阅依赖wal文件,而在vnode迁移和分裂的过程中,wal并不会同步过去,所以迁移或分裂后,之前没消费完的wal数据后消费不到。所以请保证之前把数据全部消费完后,再进行vnode迁移或分裂,否则,消费会丢失数据。 -## 主要数据结构和 API +由于数据订阅依赖wal文件,而在vnode迁移和分裂的过程中,wal并不会同步过去,所以迁移或分裂后,之前没消费完的wal数据后消费不到。所以请保证迁移和分裂之前把数据全部消费完后,再进行vnode迁移或分裂,否则,消费会丢失数据。 -不同语言下, TMQ 订阅相关的 API 及数据结构如下(注意consumer结构不是线程安全的,在一个线程使用consumer时,不要在另一个线程close这个consumer): +# 语法说明 - - +具体的语法参见 [数据订阅](../../12-taos-sql/13-tmq) -```c - typedef struct tmq_t tmq_t; - typedef struct tmq_conf_t tmq_conf_t; - typedef struct tmq_list_t tmq_list_t; +# 消费参数 - typedef void(tmq_commit_cb(tmq_t *tmq, int32_t code, void *param)); - - typedef enum tmq_conf_res_t { - TMQ_CONF_UNKNOWN = -2, - TMQ_CONF_INVALID = -1, - TMQ_CONF_OK = 0, - } tmq_conf_res_t; - - typedef struct tmq_topic_assignment { - int32_t vgId; - int64_t currentOffset; - int64_t begin; - int64_t end; - } tmq_topic_assignment; - - DLL_EXPORT tmq_conf_t *tmq_conf_new(); - DLL_EXPORT tmq_conf_res_t tmq_conf_set(tmq_conf_t *conf, const char *key, const char *value); - DLL_EXPORT void tmq_conf_destroy(tmq_conf_t *conf); - DLL_EXPORT void tmq_conf_set_auto_commit_cb(tmq_conf_t *conf, tmq_commit_cb *cb, void *param); - - DLL_EXPORT tmq_list_t *tmq_list_new(); - DLL_EXPORT int32_t tmq_list_append(tmq_list_t *, const char *); - DLL_EXPORT void tmq_list_destroy(tmq_list_t *); - DLL_EXPORT int32_t tmq_list_get_size(const tmq_list_t *); - DLL_EXPORT char **tmq_list_to_c_array(const tmq_list_t *); - - DLL_EXPORT tmq_t *tmq_consumer_new(tmq_conf_t *conf, char *errstr, int32_t errstrLen); - DLL_EXPORT int32_t tmq_subscribe(tmq_t *tmq, const tmq_list_t *topic_list); - DLL_EXPORT int32_t tmq_unsubscribe(tmq_t *tmq); - DLL_EXPORT int32_t tmq_subscription(tmq_t *tmq, tmq_list_t **topics); - DLL_EXPORT TAOS_RES *tmq_consumer_poll(tmq_t *tmq, int64_t timeout); - DLL_EXPORT int32_t tmq_consumer_close(tmq_t *tmq); - DLL_EXPORT int32_t tmq_commit_sync(tmq_t *tmq, const TAOS_RES *msg); - DLL_EXPORT void tmq_commit_async(tmq_t *tmq, const TAOS_RES *msg, tmq_commit_cb *cb, void *param); - DLL_EXPORT int32_t tmq_commit_offset_sync(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset); - DLL_EXPORT void tmq_commit_offset_async(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset, tmq_commit_cb *cb, void *param); - DLL_EXPORT int32_t tmq_get_topic_assignment(tmq_t *tmq, const char *pTopicName, tmq_topic_assignment **assignment,int32_t *numOfAssignment); - DLL_EXPORT void tmq_free_assignment(tmq_topic_assignment* pAssignment); - DLL_EXPORT int32_t tmq_offset_seek(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset); - DLL_EXPORT int64_t tmq_position(tmq_t *tmq, const char *pTopicName, int32_t vgId); - DLL_EXPORT int64_t tmq_committed(tmq_t *tmq, const char *pTopicName, int32_t vgId); - - DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res); - DLL_EXPORT const char *tmq_get_db_name(TAOS_RES *res); - DLL_EXPORT int32_t tmq_get_vgroup_id(TAOS_RES *res); - DLL_EXPORT int64_t tmq_get_vgroup_offset(TAOS_RES* res); - DLL_EXPORT const char *tmq_err2str(int32_t code); -``` - -下面介绍一下它们的具体用法(超级表和子表结构请参考“数据建模”一节),完整的示例代码请见下面 C 语言的示例代码。 - - - - -```java -void subscribe(Collection topics) throws SQLException; - -void unsubscribe() throws SQLException; - -Set subscription() throws SQLException; - -ConsumerRecords poll(Duration timeout) throws SQLException; - -Set assignment() throws SQLException; -long position(TopicPartition partition) throws SQLException; -Map position(String topic) throws SQLException; -Map beginningOffsets(String topic) throws SQLException; -Map endOffsets(String topic) throws SQLException; -Map committed(Set partitions) throws SQLException; - -void seek(TopicPartition partition, long offset) throws SQLException; -void seekToBeginning(Collection partitions) throws SQLException; -void seekToEnd(Collection partitions) throws SQLException; - -void commitSync() throws SQLException; -void commitSync(Map offsets) throws SQLException; - -void close() throws SQLException; -``` - - - - - -```python -class Consumer: - def subscribe(self, topics): - pass - - def unsubscribe(self): - pass - - def poll(self, timeout: float = 1.0): - pass - - def assignment(self): - pass - - def seek(self, partition): - pass - - def close(self): - pass - - def commit(self, message): - pass -``` - - - - - -```go -func NewConsumer(conf *tmq.ConfigMap) (*Consumer, error) - -// 出于兼容目的保留 rebalanceCb 参数,当前未使用 -func (c *Consumer) Subscribe(topic string, rebalanceCb RebalanceCb) error - -// 出于兼容目的保留 rebalanceCb 参数,当前未使用 -func (c *Consumer) SubscribeTopics(topics []string, rebalanceCb RebalanceCb) error - -func (c *Consumer) Poll(timeoutMs int) tmq.Event - -// 出于兼容目的保留 tmq.TopicPartition 参数,当前未使用 -func (c *Consumer) Commit() ([]tmq.TopicPartition, error) - -func (c *Consumer) Unsubscribe() error - -func (c *Consumer) Close() error -``` - - - - - -```rust -impl TBuilder for TmqBuilder - fn from_dsn(dsn: D) -> Result - fn build(&self) -> Result - -impl AsAsyncConsumer for Consumer - async fn subscribe, I: IntoIterator + Send>( - &mut self, - topics: I, - ) -> Result<(), Self::Error>; - fn stream( - &self, - ) -> Pin< - Box< - dyn '_ - + Send - + futures::Stream< - Item = Result<(Self::Offset, MessageSet), Self::Error>, - >, - >, - >; - async fn commit(&self, offset: Self::Offset) -> Result<(), Self::Error>; - - async fn unsubscribe(self); -``` - -可在 上查看详细 API 说明。 - - - - - -```js -function TMQConsumer(config) - -function subscribe(topic) - -function consume(timeout) - -function subscription() - -function unsubscribe() - -function commit(msg) - -function close() -``` - - - - - -```csharp -class ConsumerBuilder - -ConsumerBuilder(IEnumerable> config) - -public IConsumer Build() - -void Subscribe(IEnumerable topics) - -void Subscribe(string topic) - -ConsumeResult Consume(int millisecondsTimeout) - -List Subscription() - -void Unsubscribe() - -List Commit() - -void Close() -``` - - - - -## 写入数据 - -首先完成建库、建一张超级表和多张子表操作,然后就可以写入数据了,比如: - -```sql -DROP DATABASE IF EXISTS tmqdb; -CREATE DATABASE tmqdb WAL_RETENTION_PERIOD 3600; -CREATE TABLE tmqdb.stb (ts TIMESTAMP, c1 INT, c2 FLOAT, c3 VARCHAR(16)) TAGS(t1 INT, t3 VARCHAR(16)); -CREATE TABLE tmqdb.ctb0 USING tmqdb.stb TAGS(0, "subtable0"); -CREATE TABLE tmqdb.ctb1 USING tmqdb.stb TAGS(1, "subtable1"); -INSERT INTO tmqdb.ctb0 VALUES(now, 0, 0, 'a0')(now+1s, 0, 0, 'a00'); -INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); -``` - -## 创建 *topic* - -TDengine 使用 SQL 创建一个 topic: - -```sql -CREATE TOPIC topic_name AS SELECT ts, c1, c2, c3 FROM tmqdb.stb WHERE c1 > 1; -``` -- topic创建个数有上限,通过参数 tmqMaxTopicNum 控制,默认 20 个 - -TMQ 支持多种订阅类型: - -### 列订阅 - -语法: - -```sql -CREATE TOPIC topic_name as subquery -``` - -通过 `SELECT` 语句订阅(包括 `SELECT *`,或 `SELECT ts, c1` 等指定列订阅,可以带条件过滤、标量函数计算,但不支持聚合函数、不支持时间窗口聚合)。需要注意的是: - -- 该类型 TOPIC 一旦创建则订阅数据的结构确定。 -- 被订阅或用于计算的列或标签不可被删除(`ALTER table DROP`)、修改(`ALTER table MODIFY`)。 -- 若发生表结构变更,新增的列不出现在结果中。 - -### 超级表订阅 - -语法: - -```sql -CREATE TOPIC topic_name [with meta] AS STABLE stb_name [where_condition] -``` - -与 `SELECT * from stbName` 订阅的区别是: - -- 不会限制用户的表结构变更。 -- 返回的是非结构化的数据:返回数据的结构会随之超级表的表结构变化而变化。 -- with meta 参数可选,选择时将返回创建超级表,子表等语句,主要用于taosx做超级表迁移 -- where_condition 参数可选,选择时将用来过滤符合条件的子表,订阅这些子表。where 条件里不能有普通列,只能是tag或tbname,where条件里可以用函数,用来过滤tag,但是不能是聚合函数,因为子表tag值无法做聚合。也可以是常量表达式,比如 2 > 1(订阅全部子表),或者 false(订阅0个子表) -- 返回数据不包含标签。 - -### 数据库订阅 - -语法: - -```sql -CREATE TOPIC topic_name [with meta] AS DATABASE db_name; -``` - -通过该语句可创建一个包含数据库所有表数据的订阅 - -- with meta 参数可选,选择时将返回创建数据库里所有超级表,子表的语句,主要用于taosx做数据库迁移 - -## 创建消费者 *consumer* - -消费者需要通过一系列配置选项创建,基础配置项如下表所示: +消费参数主要用于消费者创建时指定,基础配置项如下表所示: | 参数名称 | 类型 | 参数说明 | 备注 | | :----------------------------: | :-----: | -------------------------------------------------------- | ------------------------------------------- | @@ -358,515 +86,714 @@ CREATE TOPIC topic_name [with meta] AS DATABASE db_name; | `msg.with.table.name` | boolean | 是否允许从消息中解析表名, 不适用于列订阅(列订阅时可将 tbname 作为列写入 subquery 语句)(从3.2.0.0版本该参数废弃,恒为true) |默认关闭 | | `enable.replay` | boolean | 是否开启数据回放功能 |默认关闭 | -对于不同编程语言,其设置方式如下: +# 主要数据结构和 API 接口 + +不同语言下, TMQ 订阅相关的 API 及数据结构如下(详细的接口说明可以参考连接器章节,注意consumer结构不是线程安全的,在一个线程使用consumer时,不要在另一个线程close这个consumer): - + -```c -/* 根据需要,设置消费组 (group.id)、自动提交 (enable.auto.commit)、 - 自动提交时间间隔 (auto.commit.interval.ms)、用户名 (td.connect.user)、密码 (td.connect.pass) 等参数 */ -tmq_conf_t* conf = tmq_conf_new(); -tmq_conf_set(conf, "enable.auto.commit", "true"); -tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); -tmq_conf_set(conf, "group.id", "cgrpName"); -tmq_conf_set(conf, "td.connect.user", "root"); -tmq_conf_set(conf, "td.connect.pass", "taosdata"); -tmq_conf_set(conf, "auto.offset.reset", "latest"); -tmq_conf_set(conf, "msg.with.table.name", "true"); -tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); + ```c + typedef struct tmq_t tmq_t; + typedef struct tmq_conf_t tmq_conf_t; + typedef struct tmq_list_t tmq_list_t; -tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); -tmq_conf_destroy(conf); + typedef void(tmq_commit_cb(tmq_t *tmq, int32_t code, void *param)); + + typedef enum tmq_conf_res_t { + TMQ_CONF_UNKNOWN = -2, + TMQ_CONF_INVALID = -1, + TMQ_CONF_OK = 0, + } tmq_conf_res_t; + + typedef struct tmq_topic_assignment { + int32_t vgId; + int64_t currentOffset; + int64_t begin; + int64_t end; + } tmq_topic_assignment; + + DLL_EXPORT tmq_conf_t *tmq_conf_new(); + DLL_EXPORT tmq_conf_res_t tmq_conf_set(tmq_conf_t *conf, const char *key, const char *value); + DLL_EXPORT void tmq_conf_destroy(tmq_conf_t *conf); + DLL_EXPORT void tmq_conf_set_auto_commit_cb(tmq_conf_t *conf, tmq_commit_cb *cb, void *param); + + DLL_EXPORT tmq_list_t *tmq_list_new(); + DLL_EXPORT int32_t tmq_list_append(tmq_list_t *, const char *); + DLL_EXPORT void tmq_list_destroy(tmq_list_t *); + DLL_EXPORT int32_t tmq_list_get_size(const tmq_list_t *); + DLL_EXPORT char **tmq_list_to_c_array(const tmq_list_t *); + + DLL_EXPORT tmq_t *tmq_consumer_new(tmq_conf_t *conf, char *errstr, int32_t errstrLen); + DLL_EXPORT int32_t tmq_subscribe(tmq_t *tmq, const tmq_list_t *topic_list); + DLL_EXPORT int32_t tmq_unsubscribe(tmq_t *tmq); + DLL_EXPORT int32_t tmq_subscription(tmq_t *tmq, tmq_list_t **topics); + DLL_EXPORT TAOS_RES *tmq_consumer_poll(tmq_t *tmq, int64_t timeout); + DLL_EXPORT int32_t tmq_consumer_close(tmq_t *tmq); + DLL_EXPORT int32_t tmq_commit_sync(tmq_t *tmq, const TAOS_RES *msg); + DLL_EXPORT void tmq_commit_async(tmq_t *tmq, const TAOS_RES *msg, tmq_commit_cb *cb, void *param); + DLL_EXPORT int32_t tmq_commit_offset_sync(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset); + DLL_EXPORT void tmq_commit_offset_async(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset, tmq_commit_cb *cb, void *param); + DLL_EXPORT int32_t tmq_get_topic_assignment(tmq_t *tmq, const char *pTopicName, tmq_topic_assignment **assignment,int32_t *numOfAssignment); + DLL_EXPORT void tmq_free_assignment(tmq_topic_assignment* pAssignment); + DLL_EXPORT int32_t tmq_offset_seek(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset); + DLL_EXPORT int64_t tmq_position(tmq_t *tmq, const char *pTopicName, int32_t vgId); + DLL_EXPORT int64_t tmq_committed(tmq_t *tmq, const char *pTopicName, int32_t vgId); + + DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res); + DLL_EXPORT const char *tmq_get_db_name(TAOS_RES *res); + DLL_EXPORT int32_t tmq_get_vgroup_id(TAOS_RES *res); + DLL_EXPORT int64_t tmq_get_vgroup_offset(TAOS_RES* res); + DLL_EXPORT const char *tmq_err2str(int32_t code); + ``` + + + + + ```java + void subscribe(Collection topics) throws SQLException; + + void unsubscribe() throws SQLException; + + Set subscription() throws SQLException; + + ConsumerRecords poll(Duration timeout) throws SQLException; + + Set assignment() throws SQLException; + long position(TopicPartition partition) throws SQLException; + Map position(String topic) throws SQLException; + Map beginningOffsets(String topic) throws SQLException; + Map endOffsets(String topic) throws SQLException; + Map committed(Set partitions) throws SQLException; + + void seek(TopicPartition partition, long offset) throws SQLException; + void seekToBeginning(Collection partitions) throws SQLException; + void seekToEnd(Collection partitions) throws SQLException; + + void commitSync() throws SQLException; + void commitSync(Map offsets) throws SQLException; + + void close() throws SQLException; + ``` + + + + + + ```python + class Consumer: + def subscribe(self, topics): + pass + + def unsubscribe(self): + pass + + def poll(self, timeout: float = 1.0): + pass + + def assignment(self): + pass + + def seek(self, partition): + pass + + def close(self): + pass + + def commit(self, message): + pass + ``` + + + + + + ```go + func NewConsumer(conf *tmq.ConfigMap) (*Consumer, error) + + // 出于兼容目的保留 rebalanceCb 参数,当前未使用 + func (c *Consumer) Subscribe(topic string, rebalanceCb RebalanceCb) error + + // 出于兼容目的保留 rebalanceCb 参数,当前未使用 + func (c *Consumer) SubscribeTopics(topics []string, rebalanceCb RebalanceCb) error + + func (c *Consumer) Poll(timeoutMs int) tmq.Event + + // 出于兼容目的保留 tmq.TopicPartition 参数,当前未使用 + func (c *Consumer) Commit() ([]tmq.TopicPartition, error) + + func (c *Consumer) Unsubscribe() error + + func (c *Consumer) Close() error + ``` + + + + + + ```rust + impl TBuilder for TmqBuilder + fn from_dsn(dsn: D) -> Result + fn build(&self) -> Result + + impl AsAsyncConsumer for Consumer + async fn subscribe, I: IntoIterator + Send>( + &mut self, + topics: I, + ) -> Result<(), Self::Error>; + fn stream( + &self, + ) -> Pin< + Box< + dyn '_ + + Send + + futures::Stream< + Item = Result<(Self::Offset, MessageSet), Self::Error>, + >, + >, + >; + async fn commit(&self, offset: Self::Offset) -> Result<(), Self::Error>; + + async fn unsubscribe(self); + ``` + + 可在 上查看详细 API 说明。 + + + + + + ```js + function TMQConsumer(config) + + function subscribe(topic) + + function consume(timeout) + + function subscription() + + function unsubscribe() + + function commit(msg) + + function close() + ``` + + + + + + ```csharp + class ConsumerBuilder + + ConsumerBuilder(IEnumerable> config) + + public IConsumer Build() + + void Subscribe(IEnumerable topics) + + void Subscribe(string topic) + + ConsumeResult Consume(int millisecondsTimeout) + + List Subscription() + + void Unsubscribe() + + List Commit() + + void Close() + ``` + + + + + # 数据订阅示例 + ## 写入数据 + + 首先完成建库、建一张超级表和多张子表操作,然后就可以写入数据了,比如: + + ```sql + DROP DATABASE IF EXISTS tmqdb; + CREATE DATABASE tmqdb WAL_RETENTION_PERIOD 3600; + CREATE TABLE tmqdb.stb (ts TIMESTAMP, c1 INT, c2 FLOAT, c3 VARCHAR(16)) TAGS(t1 INT, t3 VARCHAR(16)); + CREATE TABLE tmqdb.ctb0 USING tmqdb.stb TAGS(0, "subtable0"); + CREATE TABLE tmqdb.ctb1 USING tmqdb.stb TAGS(1, "subtable1"); + INSERT INTO tmqdb.ctb0 VALUES(now, 0, 0, 'a0')(now+1s, 0, 0, 'a00'); +INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); ``` +## 创建 topic - - + 使用 SQL 创建一个 topic: -对于 Java 程序,还可以使用如下配置项: + ```sql + CREATE TOPIC topic_name AS SELECT ts, c1, c2, c3 FROM tmqdb.stb WHERE c1 > 1; + ``` -| 参数名称 | 类型 | 参数说明 | -| ----------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------- | -| `td.connect.type` | string | 连接类型,"jni" 指原生连接,"ws" 指 websocket 连接,默认值为 "jni" | -| `bootstrap.servers` | string | 连接地址,如 `localhost:6030` | -| `value.deserializer` | string | 值解析方法,使用此方法应实现 `com.taosdata.jdbc.tmq.Deserializer` 接口或继承 `com.taosdata.jdbc.tmq.ReferenceDeserializer` 类 | -| `value.deserializer.encoding` | string | 指定字符串解析的字符集 | | + ## 创建消费者 *consumer* -需要注意:此处使用 `bootstrap.servers` 替代 `td.connect.ip` 和 `td.connect.port`,以提供与 Kafka 一致的接口。 + 对于不同编程语言,其设置方式如下: -```java -Properties properties = new Properties(); -properties.setProperty("enable.auto.commit", "true"); -properties.setProperty("auto.commit.interval.ms", "1000"); -properties.setProperty("group.id", "cgrpName"); -properties.setProperty("bootstrap.servers", "127.0.0.1:6030"); -properties.setProperty("td.connect.user", "root"); -properties.setProperty("td.connect.pass", "taosdata"); -properties.setProperty("auto.offset.reset", "latest"); -properties.setProperty("msg.with.table.name", "true"); -properties.setProperty("value.deserializer", "com.taos.example.MetersDeserializer"); + + -TaosConsumer consumer = new TaosConsumer<>(properties); + ```c + /* 根据需要,设置消费组 (group.id)、自动提交 (enable.auto.commit)、 + 自动提交时间间隔 (auto.commit.interval.ms)、用户名 (td.connect.user)、密码 (td.connect.pass) 等参数 */ + tmq_conf_t* conf = tmq_conf_new(); + tmq_conf_set(conf, "enable.auto.commit", "true"); + tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); + tmq_conf_set(conf, "group.id", "cgrpName"); + tmq_conf_set(conf, "td.connect.user", "root"); + tmq_conf_set(conf, "td.connect.pass", "taosdata"); + tmq_conf_set(conf, "auto.offset.reset", "latest"); + tmq_conf_set(conf, "msg.with.table.name", "true"); + tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); -/* value deserializer definition. */ -import com.taosdata.jdbc.tmq.ReferenceDeserializer; + tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); + tmq_conf_destroy(conf); + ``` -public class MetersDeserializer extends ReferenceDeserializer { -} -``` + + - + 对于 Java 程序,还可以使用如下配置项: - + | 参数名称 | 类型 | 参数说明 | + | ----------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------- | + | `td.connect.type` | string | 连接类型,"jni" 指原生连接,"ws" 指 websocket 连接,默认值为 "jni" | + | `bootstrap.servers` | string | 连接地址,如 `localhost:6030` | + | `value.deserializer` | string | 值解析方法,使用此方法应实现 `com.taosdata.jdbc.tmq.Deserializer` 接口或继承 `com.taosdata.jdbc.tmq.ReferenceDeserializer` 类 | + | `value.deserializer.encoding` | string | 指定字符串解析的字符集 | | -```go -conf := &tmq.ConfigMap{ - "group.id": "test", - "auto.offset.reset": "latest", - "td.connect.ip": "127.0.0.1", - "td.connect.user": "root", - "td.connect.pass": "taosdata", - "td.connect.port": "6030", - "client.id": "test_tmq_c", - "enable.auto.commit": "false", - "msg.with.table.name": "true", -} -consumer, err := NewConsumer(conf) -``` + 需要注意:此处使用 `bootstrap.servers` 替代 `td.connect.ip` 和 `td.connect.port`,以提供与 Kafka 一致的接口。 - + ```java + Properties properties = new Properties(); + properties.setProperty("enable.auto.commit", "true"); + properties.setProperty("auto.commit.interval.ms", "1000"); + properties.setProperty("group.id", "cgrpName"); + properties.setProperty("bootstrap.servers", "127.0.0.1:6030"); + properties.setProperty("td.connect.user", "root"); + properties.setProperty("td.connect.pass", "taosdata"); + properties.setProperty("auto.offset.reset", "latest"); + properties.setProperty("msg.with.table.name", "true"); + properties.setProperty("value.deserializer", "com.taos.example.MetersDeserializer"); - + TaosConsumer consumer = new TaosConsumer<>(properties); -```rust -let mut dsn: Dsn = "taos://".parse()?; -dsn.set("group.id", "group1"); -dsn.set("client.id", "test"); -dsn.set("auto.offset.reset", "latest"); + /* value deserializer definition. */ + import com.taosdata.jdbc.tmq.ReferenceDeserializer; -let tmq = TmqBuilder::from_dsn(dsn)?; + public class MetersDeserializer extends ReferenceDeserializer { + } + ``` -let mut consumer = tmq.build()?; -``` + - + - + ```go + conf := &tmq.ConfigMap{ + "group.id": "test", + "auto.offset.reset": "latest", + "td.connect.ip": "127.0.0.1", + "td.connect.user": "root", + "td.connect.pass": "taosdata", + "td.connect.port": "6030", + "client.id": "test_tmq_c", + "enable.auto.commit": "false", + "msg.with.table.name": "true", + } + consumer, err := NewConsumer(conf) + ``` -Python 语言下引入 `taos` 库的 `Consumer` 类,创建一个 Consumer 示例: + -```python -from taos.tmq import Consumer + -# Syntax: `consumer = Consumer(configs)` -# -# Example: -consumer = Consumer( - { - "group.id": "local", - "client.id": "1", - "enable.auto.commit": "true", - "auto.commit.interval.ms": "1000", - "td.connect.ip": "127.0.0.1", - "td.connect.user": "root", - "td.connect.pass": "taosdata", - "auto.offset.reset": "latest", - "msg.with.table.name": "true", - } -) -``` + ```rust + let mut dsn: Dsn = "taos://".parse()?; + dsn.set("group.id", "group1"); + dsn.set("client.id", "test"); + dsn.set("auto.offset.reset", "latest"); - + let tmq = TmqBuilder::from_dsn(dsn)?; - + let mut consumer = tmq.build()?; + ``` -```js -// 根据需要,设置消费组 (group.id)、自动提交 (enable.auto.commit)、 -// 自动提交时间间隔 (auto.commit.interval.ms)、用户名 (td.connect.user)、密码 (td.connect.pass) 等参数 + -let consumer = taos.consumer({ - 'enable.auto.commit': 'true', + + + Python 语言下引入 `taos` 库的 `Consumer` 类,创建一个 Consumer 示例: + + ```python + from taos.tmq import Consumer + + # Syntax: `consumer = Consumer(configs)` + # + # Example: + consumer = Consumer( + { + "group.id": "local", + "client.id": "1", + "enable.auto.commit": "true", + "auto.commit.interval.ms": "1000", + "td.connect.ip": "127.0.0.1", + "td.connect.user": "root", + "td.connect.pass": "taosdata", + "auto.offset.reset": "latest", + "msg.with.table.name": "true", + } + ) + ``` + + + + + + ```js + // 根据需要,设置消费组 (group.id)、自动提交 (enable.auto.commit)、 + // 自动提交时间间隔 (auto.commit.interval.ms)、用户名 (td.connect.user)、密码 (td.connect.pass) 等参数 + + let consumer = taos.consumer({ +'enable.auto.commit': 'true', 'auto.commit.interval.ms','1000', - 'group.id': 'tg2', + 'group.id': 'tg2', 'td.connect.user': 'root', 'td.connect.pass': 'taosdata', 'auto.offset.reset','latest', 'msg.with.table.name': 'true', 'td.connect.ip','127.0.0.1', - 'td.connect.port','6030' - }); -``` + 'td.connect.port','6030' + }); + ``` -```csharp -var cfg = new Dictionary() -{ - { "group.id", "group1" }, - { "auto.offset.reset", "latest" }, - { "td.connect.ip", "127.0.0.1" }, - { "td.connect.user", "root" }, - { "td.connect.pass", "taosdata" }, - { "td.connect.port", "6030" }, - { "client.id", "tmq_example" }, - { "enable.auto.commit", "true" }, - { "msg.with.table.name", "false" }, -}; -var consumer = new ConsumerBuilder>(cfg).Build(); -``` + ```csharp + var cfg = new Dictionary() + { + { "group.id", "group1" }, + { "auto.offset.reset", "latest" }, + { "td.connect.ip", "127.0.0.1" }, + { "td.connect.user", "root" }, + { "td.connect.pass", "taosdata" }, + { "td.connect.port", "6030" }, + { "client.id", "tmq_example" }, + { "enable.auto.commit", "true" }, + { "msg.with.table.name", "false" }, + }; + var consumer = new ConsumerBuilder>(cfg).Build(); + ``` - + - + -上述配置中包括 consumer group ID,如果多个 consumer 指定的 consumer group ID 一样,则自动形成一个 consumer group,共享消费进度。 + 上述配置中包括 consumer group ID,如果多个 consumer 指定的 consumer group ID 一样,则自动形成一个 consumer group,共享消费进度。 -数据回放功能说明: -- 订阅增加 replay 功能,按照数据写入的时间回放。 - 比如,如下时间写入三条数据 - ```sql - 2023/09/22 00:00:00.000 - 2023/09/22 00:00:05.000 - 2023/09/22 00:00:08.000 - ``` - 则订阅出第一条数据 5s 后返回第二条数据,获取第二条数据 3s 后返回第三条数据。 -- 仅列订阅支持数据回放 - - 回放需要保证独立时间线 - - 如果是子表订阅或者普通表订阅,只有一个vnode上有数据,保证是一个时间线 - - 如果超级表订阅,则需保证该 DB 只有一个vnode,否则报错(因为多个vnode上订阅出的数据不在一个时间线上) -- 超级表和库订阅不支持回放 -- 增加 enable.replay 参数,true表示开启订阅回放功能,false表示不开启订阅回放功能,默认不开启。 -- 回放不支持进度保存,所以回放参数 enable.replay = true 时,auto commit 自动关闭 -- 因为数据回放本身需要处理时间,所以回放的精度存在几十ms的误差 + ## 订阅 *topics* -## 订阅 *topics* + 一个 consumer 支持同时订阅多个 topic。 -一个 consumer 支持同时订阅多个 topic。 - - - + + ```c -// 创建订阅 topics 列表 -tmq_list_t* topicList = tmq_list_new(); -tmq_list_append(topicList, "topicName"); -// 启动订阅 -tmq_subscribe(tmq, topicList); -tmq_list_destroy(topicList); - -``` + // 创建订阅 topics 列表 + tmq_list_t* topicList = tmq_list_new(); + tmq_list_append(topicList, "topicName"); + // 启动订阅 + tmq_subscribe(tmq, topicList); + tmq_list_destroy(topicList); + + ``` -```java -List topics = new ArrayList<>(); -topics.add("tmq_topic"); -consumer.subscribe(topics); -``` + ```java + List topics = new ArrayList<>(); + topics.add("tmq_topic"); + consumer.subscribe(topics); + ``` -```go -err = consumer.Subscribe("example_tmq_topic", nil) -if err != nil { - panic(err) -} -``` + ```go + err = consumer.Subscribe("example_tmq_topic", nil) + if err != nil { + panic(err) + } + ``` - - + + ```rust -consumer.subscribe(["tmq_meters"]).await?; -``` + consumer.subscribe(["tmq_meters"]).await?; + ``` - + - + ```python -consumer.subscribe(['topic1', 'topic2']) -``` + consumer.subscribe(['topic1', 'topic2']) + ``` - + - + ```js -// 创建订阅 topics 列表 -let topics = ['topic_test'] + // 创建订阅 topics 列表 + let topics = ['topic_test'] -// 启动订阅 -consumer.subscribe(topics); -``` + // 启动订阅 + consumer.subscribe(topics); + ``` - + - + ```csharp -// 创建订阅 topics 列表 -List topics = new List(); -topics.add("tmq_topic"); -// 启动订阅 -consumer.Subscribe(topics); -``` + // 创建订阅 topics 列表 + List topics = new List(); + topics.add("tmq_topic"); + // 启动订阅 + consumer.Subscribe(topics); + ``` - + - + -## 消费 + ## 消费 -以下代码展示了不同语言下如何对 TMQ 消息进行消费。 + 以下代码展示了不同语言下如何对 TMQ 消息进行消费。 - - + + ```c -// 消费数据 -while (running) { - TAOS_RES* msg = tmq_consumer_poll(tmq, timeOut); - msg_process(msg); -} -``` + // 消费数据 + while (running) { + TAOS_RES* msg = tmq_consumer_poll(tmq, timeOut); + msg_process(msg); + } + ``` 这里是一个 **while** 循环,每调用一次 tmq_consumer_poll(),获取一个消息,该消息与普通查询返回的结果集完全相同,可以使用相同的解析 API 完成消息内容的解析。 -```java -while(running){ - ConsumerRecords meters = consumer.poll(Duration.ofMillis(100)); - for (Meters meter : meters) { - processMsg(meter); - } -} -``` + ```java + while(running){ + ConsumerRecords meters = consumer.poll(Duration.ofMillis(100)); + for (Meters meter : meters) { + processMsg(meter); + } + } + ``` -```go -for { - ev := consumer.Poll(0) - if ev != nil { - switch e := ev.(type) { - case *tmqcommon.DataMessage: - fmt.Println(e.Value()) - case tmqcommon.Error: - fmt.Fprintf(os.Stderr, "%% Error: %v: %v\n", e.Code(), e) - panic(e) - } - consumer.Commit() - } -} -``` + ```go + for { + ev := consumer.Poll(0) + if ev != nil { + switch e := ev.(type) { + case *tmqcommon.DataMessage: + fmt.Println(e.Value()) + case tmqcommon.Error: + fmt.Fprintf(os.Stderr, "%% Error: %v: %v\n", e.Code(), e) + panic(e) + } + consumer.Commit() + } + } + ``` -```rust -{ - let mut stream = consumer.stream(); + ```rust + { + let mut stream = consumer.stream(); - while let Some((offset, message)) = stream.try_next().await? { - // get information from offset + while let Some((offset, message)) = stream.try_next().await? { + // get information from offset - // the topic - let topic = offset.topic(); - // the vgroup id, like partition id in kafka. - let vgroup_id = offset.vgroup_id(); - println!("* in vgroup id {vgroup_id} of topic {topic}\n"); + // the topic + let topic = offset.topic(); + // the vgroup id, like partition id in kafka. + let vgroup_id = offset.vgroup_id(); + println!("* in vgroup id {vgroup_id} of topic {topic}\n"); - if let Some(data) = message.into_data() { + if let Some(data) = message.into_data() { while let Some(block) = data.fetch_raw_block().await? { - // one block for one table, get table name if needed - let name = block.table_name(); - let records: Vec = block.deserialize().try_collect()?; - println!( - "** table: {}, got {} records: {:#?}\n", - name.unwrap(), - records.len(), - records - ); - } + // one block for one table, get table name if needed + let name = block.table_name(); + let records: Vec = block.deserialize().try_collect()?; + println!( + "** table: {}, got {} records: {:#?}\n", + name.unwrap(), + records.len(), + records + ); } - consumer.commit(offset).await?; - } -} -``` + } + consumer.commit(offset).await?; + } + } + ``` -```python -while True: - res = consumer.poll(100) - if not res: + ```python + while True: + res = consumer.poll(100) + if not res: continue - err = res.error() - if err is not None: + err = res.error() + if err is not None: raise err - val = res.value() + val = res.value() - for block in val: + for block in val: print(block.fetchall()) -``` + ``` -```js -while(true){ - msg = consumer.consume(200); - // process message(consumeResult) - console.log(msg.topicPartition); - console.log(msg.block); - console.log(msg.fields) -} -``` + ```js + while(true){ + msg = consumer.consume(200); + // process message(consumeResult) + console.log(msg.topicPartition); + console.log(msg.block); + console.log(msg.fields) + } + ``` - + - + ```csharp -// 消费数据 -while (true) -{ - using (var result = consumer.Consume(500)) - { - if (result == null) continue; - ProcessMsg(result); - consumer.Commit(); - } -} -``` + // 消费数据 + while (true) + { + using (var result = consumer.Consume(500)) + { + if (result == null) continue; + ProcessMsg(result); + consumer.Commit(); + } + } + ``` - + - + -## 结束消费 + ## 结束消费 -消费结束后,应当取消订阅。 + 消费结束后,应当取消订阅。 - - + + ```c -/* 取消订阅 */ -tmq_unsubscribe(tmq); + /* 取消订阅 */ + tmq_unsubscribe(tmq); -/* 关闭消费者对象 */ -tmq_consumer_close(tmq); -``` + /* 关闭消费者对象 */ + tmq_consumer_close(tmq); + ``` - - + + ```java -/* 取消订阅 */ -consumer.unsubscribe(); + /* 取消订阅 */ + consumer.unsubscribe(); -/* 关闭消费 */ -consumer.close(); -``` + /* 关闭消费 */ + consumer.close(); + ``` - + - + ```go -/* Unsubscribe */ -_ = consumer.Unsubscribe() + /* Unsubscribe */ + _ = consumer.Unsubscribe() -/* Close consumer */ -_ = consumer.Close() -``` + /* Close consumer */ + _ = consumer.Close() + ``` - + - + ```rust -consumer.unsubscribe().await; -``` + consumer.unsubscribe().await; + ``` - + - + ```py -# 取消订阅 -consumer.unsubscribe() -# 关闭消费 -consumer.close() -``` + # 取消订阅 + consumer.unsubscribe() + # 关闭消费 + consumer.close() + ``` - - + + ```js -consumer.unsubscribe(); -consumer.close(); -``` + consumer.unsubscribe(); + consumer.close(); + ``` - + - + ```csharp -// 取消订阅 -consumer.Unsubscribe(); + // 取消订阅 + consumer.Unsubscribe(); -// 关闭消费 -consumer.Close(); -``` + // 关闭消费 + consumer.Close(); + ``` -## 删除 *topic* - -如果不再需要订阅数据,可以删除 topic,需要注意:只有当前未在订阅中的 TOPIC 才能被删除。 - -```sql -/* 删除 topic */ -DROP TOPIC topic_name; -``` - -## 状态查看 - -1、*topics*:查询已经创建的 topic - -```sql -SHOW TOPICS; -``` - -2、consumers:查询 consumer 的状态及其订阅的 topic - -```sql -SHOW CONSUMERS; -``` - -3、subscriptions:查询 consumer 与 vgroup 之间的分配关系 - -```sql -SHOW SUBSCRIPTIONS; -``` - -## 示例代码 +## 完整示例代码 以下是各语言的完整示例代码。 @@ -908,3 +835,22 @@ SHOW SUBSCRIPTIONS; + +#订阅高级功能 +##数据回放 +- 订阅支持 replay 功能,按照数据写入的时间回放。 + 比如,如下时间写入三条数据 + ```sql + 2023/09/22 00:00:00.000 + 2023/09/22 00:00:05.000 + 2023/09/22 00:00:08.000 + ``` + 则订阅出第一条数据 5s 后返回第二条数据,获取第二条数据 3s 后返回第三条数据。 +- 仅查询订阅支持数据回放 + - 回放需要保证独立时间线 + - 如果是子表订阅或者普通表订阅,只有一个vnode上有数据,保证是一个时间线 + - 如果超级表订阅,则需保证该 DB 只有一个vnode,否则报错(因为多个vnode上订阅出的数据不在一个时间线上) +- 超级表和库订阅不支持回放 +- enable.replay 参数,true表示开启订阅回放功能,false表示不开启订阅回放功能,默认不开启。 +- 回放不支持进度保存,所以回放参数 enable.replay = true 时,auto commit 自动关闭 +- 因为数据回放本身需要处理时间,所以回放的精度存在几十ms的误差 \ No newline at end of file diff --git a/docs/zh/07-develop/img_5.png b/docs/zh/07-develop/img_5.png new file mode 100644 index 0000000000..d9306cdb74 Binary files /dev/null and b/docs/zh/07-develop/img_5.png differ diff --git a/docs/zh/07-develop/img_6.png b/docs/zh/07-develop/img_6.png new file mode 100644 index 0000000000..0c9a061107 Binary files /dev/null and b/docs/zh/07-develop/img_6.png differ diff --git a/docs/zh/07-develop/img_7.png b/docs/zh/07-develop/img_7.png new file mode 100644 index 0000000000..0ddb005d66 Binary files /dev/null and b/docs/zh/07-develop/img_7.png differ diff --git a/docs/zh/12-taos-sql/13-tmq.md b/docs/zh/12-taos-sql/13-tmq.md index 571300ad8c..61135a3422 100644 --- a/docs/zh/12-taos-sql/13-tmq.md +++ b/docs/zh/12-taos-sql/13-tmq.md @@ -6,32 +6,68 @@ description: TDengine 消息队列提供的数据订阅功能 TDengine 3.0.0.0 开始对消息队列做了大幅的优化和增强以简化用户的解决方案。 -## 创建订阅主题 +## 创建 topic + +TDengine 创建 topic 的个数上限通过参数 tmqMaxTopicNum 控制,默认 20 个。 + +TDengine 使用 SQL 创建一个 topic,共有三种类型的 topic: + +### 查询 topic + +语法: ```sql -CREATE TOPIC [IF NOT EXISTS] topic_name AS subquery; +CREATE TOPIC [IF NOT EXISTS] topic_name as subquery ``` +通过 `SELECT` 语句订阅(包括 `SELECT *`,或 `SELECT ts, c1` 等指定查询订阅,可以带条件过滤、标量函数计算,但不支持聚合函数、不支持时间窗口聚合)。需要注意的是: -TOPIC 支持过滤和标量函数和 UDF 标量函数,不支持 JOIN、GROUP BY、窗口切分子句、聚合函数和 UDF 聚合函数。列订阅规则如下: +- 该类型 TOPIC 一旦创建则订阅数据的结构确定。 +- 被订阅或用于计算的列或标签不可被删除(`ALTER table DROP`)、修改(`ALTER table MODIFY`)。 +- 若发生表结构变更,新增的列不出现在结果中。 +- 对于 select \*,则订阅展开为创建时所有的列(子表、普通表为数据列,超级表为数据列加标签列) +### 超级表 topic -1. TOPIC 一旦创建则返回结果的字段确定 -2. 被订阅或用于计算的列不可被删除、修改 -3. 列可以新增,但新增的列不出现在订阅结果字段中 -4. 对于 select \*,则订阅展开为创建时所有的列(子表、普通表为数据列,超级表为数据列加标签列) - - -## 删除订阅主题 +语法: ```sql +CREATE TOPIC [IF NOT EXISTS] topic_name [with meta] AS STABLE stb_name [where_condition] +``` + +与 `SELECT * from stbName` 订阅的区别是: + +- 不会限制用户的表结构变更。 +- 返回的是非结构化的数据:返回数据的结构会随之超级表的表结构变化而变化。 +- with meta 参数可选,选择时将返回创建超级表,子表等语句,主要用于taosx做超级表迁移 +- where_condition 参数可选,选择时将用来过滤符合条件的子表,订阅这些子表。where 条件里不能有普通列,只能是tag或tbname,where条件里可以用函数,用来过滤tag,但是不能是聚合函数,因为子表tag值无法做聚合。也可以是常量表达式,比如 2 > 1(订阅全部子表),或者 false(订阅0个子表) +- 返回数据不包含标签。 + +### 数据库 topic + +语法: + +```sql +CREATE TOPIC [IF NOT EXISTS] topic_name [with meta] AS DATABASE db_name; +``` + +通过该语句可创建一个包含数据库所有表数据的订阅 + +- with meta 参数可选,选择时将返回创建数据库里所有超级表,子表的语句,主要用于taosx做数据库迁移 + +说明: 超级表订阅和库订阅属于高级订阅模式,容易出错,如确实要使用,请咨询专业人员。 + +## 删除 topic + +如果不再需要订阅数据,可以删除 topic,需要注意:只有当前未在订阅中的 TOPIC 才能被删除。 + +```sql +/* 删除 topic */ DROP TOPIC [IF EXISTS] topic_name; ``` 此时如果该订阅主题上存在 consumer,则此 consumer 会收到一个错误。 -## 查看订阅主题 - -## SHOW TOPICS +## 查看 topic ```sql SHOW TOPICS; @@ -58,3 +94,11 @@ SHOW CONSUMERS; ``` 显示当前数据库下所有活跃的消费者的信息。 + +## 查看订阅信息 + +```sql +SHOW SUBSCRIPTIONS; +``` + +显示 consumer 与 vgroup 之间的分配关系和消费信息 \ No newline at end of file diff --git a/include/common/tcommon.h b/include/common/tcommon.h index d4537ddc89..7e7e9b0481 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -171,6 +171,7 @@ typedef enum EStreamType { STREAM_CHECKPOINT, STREAM_CREATE_CHILD_TABLE, STREAM_TRANS_STATE, + STREAM_MID_RETRIEVE, } EStreamType; #pragma pack(push, 1) diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 04e9b5a380..ef3e61e1a2 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -211,6 +211,7 @@ extern int32_t tsUptimeInterval; extern bool tsDisableStream; extern int64_t tsStreamBufferSize; +extern int tsStreamAggCnt; extern bool tsFilterScalarMode; extern int32_t tsMaxStreamBackendCache; extern int32_t tsPQSortMemThreshold; diff --git a/include/common/tgrant.h b/include/common/tgrant.h index 2fa6dde8f6..6d11608d21 100644 --- a/include/common/tgrant.h +++ b/include/common/tgrant.h @@ -58,60 +58,34 @@ typedef enum { TSDB_GRANT_BACKUP_RESTORE, } EGrantType; -int32_t grantCheck(EGrantType grant); // less -int32_t grantCheckLE(EGrantType grant); // less or equal +int32_t grantCheck(EGrantType grant); +int32_t grantCheckExpire(EGrantType grant); char* tGetMachineId(); -#ifndef TD_UNIQ_GRANT -int32_t grantAlterActiveCode(int32_t did, const char* old, const char* newer, char* out, int8_t type); +#ifdef TD_UNIQ_GRANT +int32_t grantCheckLE(EGrantType grant); #endif // #ifndef GRANTS_CFG #ifdef TD_ENTERPRISE -#ifdef TD_UNIQ_GRANT #define GRANTS_SCHEMA \ static const SSysDbTableSchema grantsSchema[] = { \ {.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "service_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "state", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ + {.name = "state", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "cpu_cores", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ } #else -#define GRANTS_SCHEMA \ - static const SSysDbTableSchema grantsSchema[] = { \ - {.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "storage", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "databases", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "users", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "accounts", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "connections", .bytes = 11 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "streams", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "cpu_cores", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "speed", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "querytime", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "opc_da", .bytes = GRANTS_COL_MAX_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "opc_ua", .bytes = GRANTS_COL_MAX_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "pi", .bytes = GRANTS_COL_MAX_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "kafka", .bytes = GRANTS_COL_MAX_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "influxdb", .bytes = GRANTS_COL_MAX_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "mqtt", .bytes = GRANTS_COL_MAX_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - } -#endif -#else #define GRANTS_SCHEMA \ static const SSysDbTableSchema grantsSchema[] = { \ {.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "service_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "state", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ + {.name = "state", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ {.name = "cpu_cores", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 9cd9acaee4..e24d4a71b0 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -431,7 +431,8 @@ typedef enum ENodeType { QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT, QUERY_NODE_PHYSICAL_PLAN_HASH_JOIN, QUERY_NODE_PHYSICAL_PLAN_GROUP_CACHE, - QUERY_NODE_PHYSICAL_PLAN_DYN_QUERY_CTRL + QUERY_NODE_PHYSICAL_PLAN_DYN_QUERY_CTRL, + QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL } ENodeType; typedef struct { @@ -3638,6 +3639,7 @@ typedef struct { int64_t timeout; STqOffsetVal reqOffset; int8_t enableReplay; + int8_t sourceExcluded; } SMqPollReq; int32_t tSerializeSMqPollReq(void* buf, int32_t bufLen, SMqPollReq* pReq); @@ -3767,6 +3769,7 @@ typedef struct { int32_t vgId; STqOffsetVal offset; int64_t rows; + int64_t ever; } OffsetRows; typedef struct { @@ -3924,6 +3927,9 @@ int32_t tDeserializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq); #define SUBMIT_REQ_COLUMN_DATA_FORMAT 0x2 #define SUBMIT_REQ_FROM_FILE 0x4 +#define SOURCE_NULL 0 +#define SOURCE_TAOSX 1 + typedef struct { int32_t flags; SVCreateTbReq* pCreateTbReq; @@ -3934,7 +3940,8 @@ typedef struct { SArray* aRowP; SArray* aCol; }; - int64_t ctimeMs; + int64_t ctimeMs; + int8_t source; } SSubmitTbData; typedef struct { diff --git a/include/libs/executor/executor.h b/include/libs/executor/executor.h index f78b7a3126..e06a08acba 100644 --- a/include/libs/executor/executor.h +++ b/include/libs/executor/executor.h @@ -197,6 +197,8 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT void qStreamSetOpen(qTaskInfo_t tinfo); +void qStreamSetSourceExcluded(qTaskInfo_t tinfo, int8_t sourceExcluded); + void qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset); SMqMetaRsp* qStreamExtractMetaMsg(qTaskInfo_t tinfo); diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index 3c5f23af6b..3836c631d5 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -244,7 +244,7 @@ bool fmIsSkipScanCheckFunc(int32_t funcId); void getLastCacheDataType(SDataType* pType); SFunctionNode* createFunction(const char* pName, SNodeList* pParameterList); -int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc); +int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMidFunc, SFunctionNode** pMergeFunc); typedef enum EFuncDataRequired { FUNC_DATA_REQUIRED_DATA_LOAD = 1, diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 84934b4f4f..447e8725c7 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -257,6 +257,7 @@ typedef enum EWindowAlgorithm { SESSION_ALGO_STREAM_FINAL, SESSION_ALGO_STREAM_SINGLE, SESSION_ALGO_MERGE, + INTERVAL_ALGO_STREAM_MID, } EWindowAlgorithm; typedef struct SWindowLogicNode { @@ -587,6 +588,7 @@ typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode; typedef SIntervalPhysiNode SStreamIntervalPhysiNode; typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode; typedef SIntervalPhysiNode SStreamSemiIntervalPhysiNode; +typedef SIntervalPhysiNode SStreamMidIntervalPhysiNode; typedef struct SFillPhysiNode { SPhysiNode node; diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index 2135bb706b..d6d89d1d30 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -747,7 +747,6 @@ int32_t tEncodeStreamDispatchReq(SEncoder* pEncoder, const SStreamDispatchReq* p int32_t tDecodeStreamDispatchReq(SDecoder* pDecoder, SStreamDispatchReq* pReq); int32_t tDecodeStreamRetrieveReq(SDecoder* pDecoder, SStreamRetrieveReq* pReq); -void tDeleteStreamRetrieveReq(SStreamRetrieveReq* pReq); void tDeleteStreamDispatchReq(SStreamDispatchReq* pReq); typedef struct SStreamTaskCheckpointReq { @@ -764,7 +763,7 @@ int32_t streamSetupScheduleTrigger(SStreamTask* pTask); int32_t streamProcessDispatchMsg(SStreamTask* pTask, SStreamDispatchReq* pReq, SRpcMsg* pMsg); int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, int32_t code); -int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, SRpcMsg* pMsg); +int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq); SStreamChildEpInfo* streamTaskGetUpstreamTaskEpInfo(SStreamTask* pTask, int32_t taskId); void streamTaskInputFail(SStreamTask* pTask); @@ -890,6 +889,9 @@ int32_t buildCheckpointSourceRsp(SStreamCheckpointSourceReq* pReq, SRpcHandleInf SStreamTaskSM* streamCreateStateMachine(SStreamTask* pTask); void* streamDestroyStateMachine(SStreamTaskSM* pSM); + +int32_t broadcastRetrieveMsg(SStreamTask* pTask, SStreamRetrieveReq *req); +void sendRetrieveRsp(SStreamRetrieveReq *pReq, SRpcMsg* pRsp); #ifdef __cplusplus } #endif diff --git a/include/os/osThread.h b/include/os/osThread.h index f0b79ac2c9..4ef4550419 100644 --- a/include/os/osThread.h +++ b/include/os/osThread.h @@ -69,6 +69,19 @@ typedef pthread_key_t TdThreadKey; #define taosThreadCleanupPush pthread_cleanup_push #define taosThreadCleanupPop pthread_cleanup_pop +#if !defined(WINDOWS) +#if defined(_TD_DARWIN_64) // MACOS +#define taosThreadRwlockAttrSetKindNP(A, B) ((void)0) +#else // LINUX +#if _XOPEN_SOURCE >= 500 || _POSIX_C_SOURCE >= 200809L +#define taosThreadRwlockAttrSetKindNP(A, B) pthread_rwlockattr_setkind_np(A, B) +#else +#define taosThreadRwlockAttrSetKindNP(A, B) ((void)0) +#endif +#endif +#else // WINDOWS +#define taosThreadRwlockAttrSetKindNP(A, B) ((void)0) +#endif #if defined(WINDOWS) && !defined(__USE_PTHREAD) #define TD_PTHREAD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER_FORBID diff --git a/include/util/tdef.h b/include/util/tdef.h index f136005026..3fe3214ac4 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -287,7 +287,7 @@ typedef enum ELogicConditionType { #define TSDB_DNODE_VALUE_LEN 256 #define TSDB_CLUSTER_VALUE_LEN 1000 -#define TSDB_GRANT_LOG_COL_LEN 15072 +#define TSDB_GRANT_LOG_COL_LEN 15600 #define TSDB_ACTIVE_KEY_LEN 109 #define TSDB_CONN_ACTIVE_KEY_LEN 255 diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index f1e9e36433..87f8c6be67 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -681,8 +681,9 @@ void taos_init_imp(void) { snprintf(logDirName, 64, "taoslog"); #endif if (taosCreateLog(logDirName, 10, configDir, NULL, NULL, NULL, NULL, 1) != 0) { - // ignore create log failed, only print printf(" WARING: Create %s failed:%s. configDir=%s\n", logDirName, strerror(errno), configDir); + tscInitRes = -1; + return; } if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1) != 0) { @@ -750,8 +751,11 @@ int taos_options_imp(TSDB_OPTION option, const char *str) { tstrncpy(configDir, str, PATH_MAX); tscInfo("set cfg:%s to %s", configDir, str); return 0; - } else { - taos_init(); // initialize global config + } + + // initialize global config + if (taos_init() != 0) { + return -1; } SConfig *pCfg = taosGetCfg(); diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index c29dcda781..3c3aee3032 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -63,6 +63,7 @@ struct tmq_conf_t { int8_t withTbName; int8_t snapEnable; int8_t replayEnable; + int8_t sourceExcluded; // do not consume, bit uint16_t port; int32_t autoCommitInterval; char* ip; @@ -82,6 +83,7 @@ struct tmq_t { int32_t autoCommitInterval; int8_t resetOffsetCfg; int8_t replayEnable; + int8_t sourceExcluded; // do not consume, bit uint64_t consumerId; tmq_commit_cb* commitCb; void* commitCbUserParam; @@ -385,6 +387,10 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value return TMQ_CONF_INVALID; } } + if (strcasecmp(key, "msg.consume.excluded") == 0) { + conf->sourceExcluded = taosStr2int64(value); + return TMQ_CONF_OK; + } if (strcasecmp(key, "td.connect.db") == 0) { return TMQ_CONF_OK; @@ -783,27 +789,26 @@ void tmqSendHbReq(void* param, void* tmrId) { req.consumerId = tmq->consumerId; req.epoch = tmq->epoch; taosRLockLatch(&tmq->lock); -// if(tmq->needReportOffsetRows){ - req.topics = taosArrayInit(taosArrayGetSize(tmq->clientTopics), sizeof(TopicOffsetRows)); - for(int i = 0; i < taosArrayGetSize(tmq->clientTopics); i++){ - SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); - int32_t numOfVgroups = taosArrayGetSize(pTopic->vgs); - TopicOffsetRows* data = taosArrayReserve(req.topics, 1); - strcpy(data->topicName, pTopic->topicName); - data->offsetRows = taosArrayInit(numOfVgroups, sizeof(OffsetRows)); - for(int j = 0; j < numOfVgroups; j++){ - SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); - OffsetRows* offRows = taosArrayReserve(data->offsetRows, 1); - offRows->vgId = pVg->vgId; - offRows->rows = pVg->numOfRows; - offRows->offset = pVg->offsetInfo.beginOffset; - char buf[TSDB_OFFSET_LEN] = {0}; - tFormatOffset(buf, TSDB_OFFSET_LEN, &offRows->offset); - tscInfo("consumer:0x%" PRIx64 ",report offset: vgId:%d, offset:%s, rows:%"PRId64, tmq->consumerId, offRows->vgId, buf, offRows->rows); - } + req.topics = taosArrayInit(taosArrayGetSize(tmq->clientTopics), sizeof(TopicOffsetRows)); + for(int i = 0; i < taosArrayGetSize(tmq->clientTopics); i++){ + SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); + int32_t numOfVgroups = taosArrayGetSize(pTopic->vgs); + TopicOffsetRows* data = taosArrayReserve(req.topics, 1); + strcpy(data->topicName, pTopic->topicName); + data->offsetRows = taosArrayInit(numOfVgroups, sizeof(OffsetRows)); + for(int j = 0; j < numOfVgroups; j++){ + SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); + OffsetRows* offRows = taosArrayReserve(data->offsetRows, 1); + offRows->vgId = pVg->vgId; + offRows->rows = pVg->numOfRows; + offRows->offset = pVg->offsetInfo.endOffset; + offRows->ever = pVg->offsetInfo.walVerEnd; + char buf[TSDB_OFFSET_LEN] = {0}; + tFormatOffset(buf, TSDB_OFFSET_LEN, &offRows->offset); + tscInfo("consumer:0x%" PRIx64 ",report offset, group:%s vgId:%d, offset:%s/%"PRId64", rows:%"PRId64, + tmq->consumerId, tmq->groupId, offRows->vgId, buf, offRows->ever, offRows->rows); } -// tmq->needReportOffsetRows = false; -// } + } taosRUnLockLatch(&tmq->lock); int32_t tlen = tSerializeSMqHbReq(NULL, 0, &req); @@ -1108,6 +1113,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) { pTmq->commitCbUserParam = conf->commitCbUserParam; pTmq->resetOffsetCfg = conf->resetOffset; pTmq->replayEnable = conf->replayEnable; + pTmq->sourceExcluded = conf->sourceExcluded; if(conf->replayEnable){ pTmq->autoCommit = false; } @@ -1576,6 +1582,7 @@ void tmqBuildConsumeReqImpl(SMqPollReq* pReq, tmq_t* tmq, int64_t timeout, SMqCl pReq->useSnapshot = tmq->useSnapshot; pReq->reqId = generateRequestId(); pReq->enableReplay = tmq->replayEnable; + pReq->sourceExcluded = tmq->sourceExcluded; } SMqMetaRspObj* tmqBuildMetaRspFromWrapper(SMqPollRspWrapper* pWrapper) { diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 9ddf22ca49..ee85a909e7 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -265,6 +265,7 @@ bool tsDisableStream = false; int64_t tsStreamBufferSize = 128 * 1024 * 1024; bool tsFilterScalarMode = false; int tsResolveFQDNRetryTime = 100; // seconds +int tsStreamAggCnt = 1000; char tsS3Endpoint[TSDB_FQDN_LEN] = ""; char tsS3AccessKey[TSDB_FQDN_LEN] = ""; @@ -750,6 +751,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddBool(pCfg, "disableStream", tsDisableStream, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1; if (cfgAddInt64(pCfg, "streamBufferSize", tsStreamBufferSize, 0, INT64_MAX, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1; + if (cfgAddInt64(pCfg, "streamAggCnt", tsStreamAggCnt, 2, INT32_MAX, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) + return -1; if (cfgAddInt32(pCfg, "checkpointInterval", tsStreamCheckpointInterval, 60, 1200, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) @@ -1213,6 +1216,8 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsDisableStream = cfgGetItem(pCfg, "disableStream")->bval; tsStreamBufferSize = cfgGetItem(pCfg, "streamBufferSize")->i64; + tsStreamAggCnt = cfgGetItem(pCfg, "streamAggCnt")->i32; + tsStreamBufferSize = cfgGetItem(pCfg, "streamBufferSize")->i64; tsStreamCheckpointInterval = cfgGetItem(pCfg, "checkpointInterval")->i32; tsSinkDataRate = cfgGetItem(pCfg, "streamSinkDataRate")->fval; diff --git a/source/common/src/tgrant.c b/source/common/src/tgrant.c index 8e4fe9febb..2b5d91788e 100644 --- a/source/common/src/tgrant.c +++ b/source/common/src/tgrant.c @@ -18,7 +18,14 @@ #ifndef _GRANT -int32_t grantCheck(EGrantType grant) {return TSDB_CODE_SUCCESS;} -int32_t grantCheckLE(EGrantType grant) {return TSDB_CODE_SUCCESS;} +int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; } +int32_t grantCheckExpire(EGrantType grant) { return TSDB_CODE_SUCCESS; } +#ifdef TD_UNIQ_GRANT +int32_t grantCheckLE(EGrantType grant) { return TSDB_CODE_SUCCESS; } +#endif +#else +#ifdef TD_UNIQ_GRANT +int32_t grantCheckExpire(EGrantType grant) { return TSDB_CODE_SUCCESS; } +#endif #endif \ No newline at end of file diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index af1c1c4923..2ffa12f2c1 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -6252,6 +6252,7 @@ int32_t tSerializeSMqHbReq(void *buf, int32_t bufLen, SMqHbReq *pReq) { if (tEncodeI32(&encoder, offRows->vgId) < 0) return -1; if (tEncodeI64(&encoder, offRows->rows) < 0) return -1; if (tEncodeSTqOffsetVal(&encoder, &offRows->offset) < 0) return -1; + if (tEncodeI64(&encoder, offRows->ever) < 0) return -1; } } @@ -6289,6 +6290,7 @@ int32_t tDeserializeSMqHbReq(void *buf, int32_t bufLen, SMqHbReq *pReq) { if (tDecodeI32(&decoder, &offRows->vgId) < 0) return -1; if (tDecodeI64(&decoder, &offRows->rows) < 0) return -1; if (tDecodeSTqOffsetVal(&decoder, &offRows->offset) < 0) return -1; + if (tDecodeI64(&decoder, &offRows->ever) < 0) return -1; } } } @@ -6600,6 +6602,7 @@ int32_t tSerializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq) { if (tEncodeI64(&encoder, pReq->timeout) < 0) return -1; if (tSerializeSTqOffsetVal(&encoder, &pReq->reqOffset) < 0) return -1; if (tEncodeI8(&encoder, pReq->enableReplay) < 0) return -1; + if (tEncodeI8(&encoder, pReq->sourceExcluded) < 0) return -1; tEndEncode(&encoder); @@ -6640,6 +6643,10 @@ int32_t tDeserializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq) { if (tDecodeI8(&decoder, &pReq->enableReplay) < 0) return -1; } + if (!tDecodeIsEnd(&decoder)) { + if (tDecodeI8(&decoder, &pReq->sourceExcluded) < 0) return -1; + } + tEndDecode(&decoder); tDecoderClear(&decoder); @@ -8663,6 +8670,7 @@ static int32_t tEncodeSSubmitTbData(SEncoder *pCoder, const SSubmitTbData *pSubm } } if (tEncodeI64(pCoder, pSubmitTbData->ctimeMs) < 0) return -1; + if (tEncodeI8(pCoder, pSubmitTbData->source) < 0) return -1; tEndEncode(pCoder); return 0; @@ -8750,6 +8758,12 @@ static int32_t tDecodeSSubmitTbData(SDecoder *pCoder, SSubmitTbData *pSubmitTbDa goto _exit; } } + if (!tDecodeIsEnd(pCoder)) { + if (tDecodeI8(pCoder, &pSubmitTbData->source) < 0) { + code = TSDB_CODE_INVALID_MSG; + goto _exit; + } + } tEndDecode(pCoder); diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 554205decb..19de4561d6 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -697,6 +697,8 @@ typedef struct { // 3.0.5. int64_t checkpointId; + + int32_t indexForMultiAggBalance; char reserve[256]; } SStreamObj; diff --git a/source/dnode/mnode/impl/inc/mndGrant.h b/source/dnode/mnode/impl/inc/mndGrant.h index 82b3260860..3d51738c70 100644 --- a/source/dnode/mnode/impl/inc/mndGrant.h +++ b/source/dnode/mnode/impl/inc/mndGrant.h @@ -36,10 +36,8 @@ int32_t mndGrantActionDelete(SSdb * pSdb, SGrantLogObj * pGrant); int32_t mndGrantActionUpdate(SSdb * pSdb, SGrantLogObj * pOldGrant, SGrantLogObj * pNewGrant); -#ifdef TD_UNIQ_GRANT int32_t grantAlterActiveCode(SMnode * pMnode, SGrantLogObj * pObj, const char *oldActive, const char *newActive, char **mergeActive); -#endif int32_t mndProcessConfigGrantReq(SMnode * pMnode, SRpcMsg * pReq, SMCfgClusterReq * pCfg); int32_t mndProcessUpdGrantLog(SMnode * pMnode, SRpcMsg * pReq, SArray * pMachines, SGrantState * pState); diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 753076f1f3..c7ae36b02c 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -107,7 +107,7 @@ static int32_t validateTopics(STrans *pTrans, const SArray *pTopicList, SMnode * goto FAILED; } - if ((terrno = grantCheckLE(TSDB_GRANT_SUBSCRIPTION)) < 0) { + if ((terrno = grantCheckExpire(TSDB_GRANT_SUBSCRIPTION)) < 0) { code = terrno; goto FAILED; } @@ -241,7 +241,7 @@ static int32_t checkPrivilege(SMnode *pMnode, SMqConsumerObj *pConsumer, SMqHbR STopicPrivilege *data = taosArrayReserve(rsp->topicPrivileges, 1); strcpy(data->topic, topic); if (mndCheckTopicPrivilege(pMnode, user, MND_OPER_SUBSCRIBE, pTopic) != 0 || - grantCheckLE(TSDB_GRANT_SUBSCRIPTION) < 0) { + grantCheckExpire(TSDB_GRANT_SUBSCRIPTION) < 0) { data->noPrivilege = 1; } else { data->noPrivilege = 0; diff --git a/source/dnode/mnode/impl/src/mndDef.c b/source/dnode/mnode/impl/src/mndDef.c index 172c3952ad..d59354286d 100644 --- a/source/dnode/mnode/impl/src/mndDef.c +++ b/source/dnode/mnode/impl/src/mndDef.c @@ -422,27 +422,12 @@ void *tDecodeSMqConsumerObj(const void *buf, SMqConsumerObj *pConsumer, int8_t s return (void *)buf; } -// SMqConsumerEp *tCloneSMqConsumerEp(const SMqConsumerEp *pConsumerEpOld) { -// SMqConsumerEp *pConsumerEpNew = taosMemoryMalloc(sizeof(SMqConsumerEp)); -// if (pConsumerEpNew == NULL) return NULL; -// pConsumerEpNew->consumerId = pConsumerEpOld->consumerId; -// pConsumerEpNew->vgs = taosArrayDup(pConsumerEpOld->vgs, NULL); -// return pConsumerEpNew; -// } -// -// void tDeleteSMqConsumerEp(void *data) { -// SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)data; -// taosArrayDestroy(pConsumerEp->vgs); -// } - -int32_t tEncodeSMqConsumerEp(void **buf, const SMqConsumerEp *pConsumerEp) { +int32_t tEncodeOffRows(void **buf, SArray *offsetRows){ int32_t tlen = 0; - tlen += taosEncodeFixedI64(buf, pConsumerEp->consumerId); - tlen += taosEncodeArray(buf, pConsumerEp->vgs, (FEncode)tEncodeSMqVgEp); - int32_t szVgs = taosArrayGetSize(pConsumerEp->offsetRows); + int32_t szVgs = taosArrayGetSize(offsetRows); tlen += taosEncodeFixedI32(buf, szVgs); for (int32_t j = 0; j < szVgs; ++j) { - OffsetRows *offRows = taosArrayGet(pConsumerEp->offsetRows, j); + OffsetRows *offRows = taosArrayGet(offsetRows, j); tlen += taosEncodeFixedI32(buf, offRows->vgId); tlen += taosEncodeFixedI64(buf, offRows->rows); tlen += taosEncodeFixedI8(buf, offRows->offset.type); @@ -454,53 +439,54 @@ int32_t tEncodeSMqConsumerEp(void **buf, const SMqConsumerEp *pConsumerEp) { } else { // do nothing } + tlen += taosEncodeFixedI64(buf, offRows->ever); } - // #if 0 - // int32_t sz = taosArrayGetSize(pConsumerEp->vgs); - // tlen += taosEncodeFixedI32(buf, sz); - // for (int32_t i = 0; i < sz; i++) { - // SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, i); - // tlen += tEncodeSMqVgEp(buf, pVgEp); - // } - // #endif + return tlen; } +int32_t tEncodeSMqConsumerEp(void **buf, const SMqConsumerEp *pConsumerEp) { + int32_t tlen = 0; + tlen += taosEncodeFixedI64(buf, pConsumerEp->consumerId); + tlen += taosEncodeArray(buf, pConsumerEp->vgs, (FEncode)tEncodeSMqVgEp); + + + return tlen + tEncodeOffRows(buf, pConsumerEp->offsetRows); +} + +void *tDecodeOffRows(const void *buf, SArray **offsetRows, int8_t sver){ + int32_t szVgs = 0; + buf = taosDecodeFixedI32(buf, &szVgs); + if (szVgs > 0) { + *offsetRows = taosArrayInit(szVgs, sizeof(OffsetRows)); + if (NULL == *offsetRows) return NULL; + for (int32_t j = 0; j < szVgs; ++j) { + OffsetRows *offRows = taosArrayReserve(*offsetRows, 1); + buf = taosDecodeFixedI32(buf, &offRows->vgId); + buf = taosDecodeFixedI64(buf, &offRows->rows); + buf = taosDecodeFixedI8(buf, &offRows->offset.type); + if (offRows->offset.type == TMQ_OFFSET__SNAPSHOT_DATA || offRows->offset.type == TMQ_OFFSET__SNAPSHOT_META) { + buf = taosDecodeFixedI64(buf, &offRows->offset.uid); + buf = taosDecodeFixedI64(buf, &offRows->offset.ts); + } else if (offRows->offset.type == TMQ_OFFSET__LOG) { + buf = taosDecodeFixedI64(buf, &offRows->offset.version); + } else { + // do nothing + } + if(sver > 2){ + buf = taosDecodeFixedI64(buf, &offRows->ever); + } + } + } + return (void *)buf; +} + void *tDecodeSMqConsumerEp(const void *buf, SMqConsumerEp *pConsumerEp, int8_t sver) { buf = taosDecodeFixedI64(buf, &pConsumerEp->consumerId); buf = taosDecodeArray(buf, &pConsumerEp->vgs, (FDecode)tDecodeSMqVgEp, sizeof(SMqVgEp), sver); if (sver > 1) { - int32_t szVgs = 0; - buf = taosDecodeFixedI32(buf, &szVgs); - if (szVgs > 0) { - pConsumerEp->offsetRows = taosArrayInit(szVgs, sizeof(OffsetRows)); - if (NULL == pConsumerEp->offsetRows) return NULL; - for (int32_t j = 0; j < szVgs; ++j) { - OffsetRows *offRows = taosArrayReserve(pConsumerEp->offsetRows, 1); - buf = taosDecodeFixedI32(buf, &offRows->vgId); - buf = taosDecodeFixedI64(buf, &offRows->rows); - buf = taosDecodeFixedI8(buf, &offRows->offset.type); - if (offRows->offset.type == TMQ_OFFSET__SNAPSHOT_DATA || offRows->offset.type == TMQ_OFFSET__SNAPSHOT_META) { - buf = taosDecodeFixedI64(buf, &offRows->offset.uid); - buf = taosDecodeFixedI64(buf, &offRows->offset.ts); - } else if (offRows->offset.type == TMQ_OFFSET__LOG) { - buf = taosDecodeFixedI64(buf, &offRows->offset.version); - } else { - // do nothing - } - } - } + buf = tDecodeOffRows(buf, &pConsumerEp->offsetRows, sver); } - // #if 0 - // int32_t sz; - // buf = taosDecodeFixedI32(buf, &sz); - // pConsumerEp->vgs = taosArrayInit(sz, sizeof(void *)); - // for (int32_t i = 0; i < sz; i++) { - // SMqVgEp *pVgEp = taosMemoryMalloc(sizeof(SMqVgEp)); - // buf = tDecodeSMqVgEp(buf, pVgEp); - // taosArrayPush(pConsumerEp->vgs, &pVgEp); - // } - // #endif return (void *)buf; } @@ -596,22 +582,7 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) { tlen += taosEncodeArray(buf, pSub->unassignedVgs, (FEncode)tEncodeSMqVgEp); tlen += taosEncodeString(buf, pSub->dbName); - int32_t szVgs = taosArrayGetSize(pSub->offsetRows); - tlen += taosEncodeFixedI32(buf, szVgs); - for (int32_t j = 0; j < szVgs; ++j) { - OffsetRows *offRows = taosArrayGet(pSub->offsetRows, j); - tlen += taosEncodeFixedI32(buf, offRows->vgId); - tlen += taosEncodeFixedI64(buf, offRows->rows); - tlen += taosEncodeFixedI8(buf, offRows->offset.type); - if (offRows->offset.type == TMQ_OFFSET__SNAPSHOT_DATA || offRows->offset.type == TMQ_OFFSET__SNAPSHOT_META) { - tlen += taosEncodeFixedI64(buf, offRows->offset.uid); - tlen += taosEncodeFixedI64(buf, offRows->offset.ts); - } else if (offRows->offset.type == TMQ_OFFSET__LOG) { - tlen += taosEncodeFixedI64(buf, offRows->offset.version); - } else { - // do nothing - } - } + tlen += tEncodeOffRows(buf, pSub->offsetRows); tlen += taosEncodeString(buf, pSub->qmsg); return tlen; } @@ -639,26 +610,7 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub, int8_t sver) { buf = taosDecodeStringTo(buf, pSub->dbName); if (sver > 1) { - int32_t szVgs = 0; - buf = taosDecodeFixedI32(buf, &szVgs); - if (szVgs > 0) { - pSub->offsetRows = taosArrayInit(szVgs, sizeof(OffsetRows)); - if (NULL == pSub->offsetRows) return NULL; - for (int32_t j = 0; j < szVgs; ++j) { - OffsetRows *offRows = taosArrayReserve(pSub->offsetRows, 1); - buf = taosDecodeFixedI32(buf, &offRows->vgId); - buf = taosDecodeFixedI64(buf, &offRows->rows); - buf = taosDecodeFixedI8(buf, &offRows->offset.type); - if (offRows->offset.type == TMQ_OFFSET__SNAPSHOT_DATA || offRows->offset.type == TMQ_OFFSET__SNAPSHOT_META) { - buf = taosDecodeFixedI64(buf, &offRows->offset.uid); - buf = taosDecodeFixedI64(buf, &offRows->offset.ts); - } else if (offRows->offset.type == TMQ_OFFSET__LOG) { - buf = taosDecodeFixedI64(buf, &offRows->offset.version); - } else { - // do nothing - } - } - } + buf = tDecodeOffRows(buf, &pSub->offsetRows, sver); buf = taosDecodeString(buf, &pSub->qmsg); } else { pSub->qmsg = taosStrdup(""); diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index f4a712e85f..cb8a24e675 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -141,7 +141,7 @@ static int32_t mndCreateDefaultDnode(SMnode *pMnode) { memcpy(dnodeObj.machineId, machineId, TSDB_MACHINE_ID_LEN); taosMemoryFreeClear(machineId); } else { -#ifdef TD_UNIQ_GRANT +#ifdef TD_ENTERPRISE terrno = TSDB_CODE_DNODE_NO_MACHINE_CODE; goto _OVER; #endif diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index 1d8b2cf5d3..88d326a5c4 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -27,9 +27,6 @@ #define SINK_NODE_LEVEL (0) extern bool tsDeployOnSnode; -static int32_t doAddSinkTask(SStreamObj* pStream, SArray* pTaskList, SMnode* pMnode, int32_t vgId, SVgObj* pVgroup, - SEpSet* pEpset, bool isFillhistory); - int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64_t uid, int8_t triggerType, int64_t watermark, int64_t deleteMark) { SNode* pAst = NULL; @@ -89,6 +86,8 @@ END: int32_t mndSetSinkTaskInfo(SStreamObj* pStream, SStreamTask* pTask) { STaskOutputInfo* pInfo = &pTask->outputInfo; + mDebug("mndSetSinkTaskInfo to sma or table, taskId:%s", pTask->id.idStr); + if (pStream->smaId != 0) { pInfo->type = TASK_OUTPUT__SMA; pInfo->smaSink.smaId = pStream->smaId; @@ -157,12 +156,7 @@ int32_t mndAssignStreamTaskToVgroup(SMnode* pMnode, SStreamTask* pTask, SSubplan plan->execNode.nodeId = pTask->info.nodeId; plan->execNode.epSet = pTask->info.epSet; - if (qSubPlanToString(plan, &pTask->exec.qmsg, &msgLen) < 0) { - terrno = TSDB_CODE_QRY_INVALID_INPUT; - return -1; - } - - return 0; + return qSubPlanToString(plan, &pTask->exec.qmsg, &msgLen); } SSnodeObj* mndSchedFetchOneSnode(SMnode* pMnode) { @@ -184,32 +178,79 @@ int32_t mndAssignStreamTaskToSnode(SMnode* pMnode, SStreamTask* pTask, SSubplan* plan->execNode.epSet = pTask->info.epSet; mDebug("s-task:0x%x set the agg task to snode:%d", pTask->id.taskId, SNODE_HANDLE); - if (qSubPlanToString(plan, &pTask->exec.qmsg, &msgLen) < 0) { - terrno = TSDB_CODE_QRY_INVALID_INPUT; - return -1; - } - return 0; + return qSubPlanToString(plan, &pTask->exec.qmsg, &msgLen); } -// todo random choose a node to do compute -SVgObj* mndSchedFetchOneVg(SMnode* pMnode, int64_t dbUid) { +// random choose a node to do compute +SVgObj* mndSchedFetchOneVg(SMnode* pMnode, SStreamObj* pStream) { + SDbObj* pDbObj = mndAcquireDb(pMnode, pStream->sourceDb); + if (pDbObj == NULL) { + terrno = TSDB_CODE_QRY_INVALID_INPUT; + return NULL; + } + + if(pStream->indexForMultiAggBalance == -1){ + taosSeedRand(taosSafeRand()); + pStream->indexForMultiAggBalance = taosRand() % pDbObj->cfg.numOfVgroups; + } + + int32_t index = 0; void* pIter = NULL; SVgObj* pVgroup = NULL; while (1) { pIter = sdbFetch(pMnode->pSdb, SDB_VGROUP, pIter, (void**)&pVgroup); if (pIter == NULL) break; - if (pVgroup->dbUid != dbUid) { + if (pVgroup->dbUid != pStream->sourceDbUid) { sdbRelease(pMnode->pSdb, pVgroup); continue; } - sdbCancelFetch(pMnode->pSdb, pIter); - return pVgroup; + if (index++ == pStream->indexForMultiAggBalance){ + pStream->indexForMultiAggBalance++; + pStream->indexForMultiAggBalance %= pDbObj->cfg.numOfVgroups; + sdbCancelFetch(pMnode->pSdb, pIter); + break; + } + sdbRelease(pMnode->pSdb, pVgroup); } + sdbRelease(pMnode->pSdb, pDbObj); + return pVgroup; } +static int32_t doAddSinkTask(SStreamObj* pStream, SMnode* pMnode, SVgObj* pVgroup, + SEpSet* pEpset, bool isFillhistory) { + int64_t uid = (isFillhistory) ? pStream->hTaskUid : pStream->uid; + SArray** pTaskList = (isFillhistory) ? taosArrayGetLast(pStream->pHTasksList) : taosArrayGetLast(pStream->tasks); + + SStreamTask* pTask = tNewStreamTask(uid, TASK_LEVEL__SINK, pEpset, isFillhistory, 0, *pTaskList, pStream->conf.fillHistory); + if (pTask == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return terrno; + } + + mDebug("doAddSinkTask taskId:%s, vgId:%d, isFillHistory:%d", pTask->id.idStr, pVgroup->vgId, isFillhistory); + + pTask->info.nodeId = pVgroup->vgId; + pTask->info.epSet = mndGetVgroupEpset(pMnode, pVgroup); + return mndSetSinkTaskInfo(pStream, pTask); +} + +static int32_t doAddSinkTaskToVg(SMnode* pMnode, SStreamObj* pStream, SEpSet* pEpset, SVgObj* vgObj){ + int32_t code = doAddSinkTask(pStream, pMnode, vgObj, pEpset, false); + if (code != 0) { + return code; + } + if(pStream->conf.fillHistory){ + code = doAddSinkTask(pStream, pMnode, vgObj, pEpset, true); + if (code != 0) { + return code; + } + } + return TDB_CODE_SUCCESS; +} + // create sink node for each vgroup. -int32_t doAddShuffleSinkTask(SMnode* pMnode, SArray* pTaskList, SStreamObj* pStream, SEpSet* pEpset, bool fillHistory) { +static int32_t doAddShuffleSinkTask(SMnode* pMnode, SStreamObj* pStream, SEpSet* pEpset) { SSdb* pSdb = pMnode->pSdb; void* pIter = NULL; @@ -225,27 +266,16 @@ int32_t doAddShuffleSinkTask(SMnode* pMnode, SArray* pTaskList, SStreamObj* pStr continue; } - doAddSinkTask(pStream, pTaskList, pMnode, pVgroup->vgId, pVgroup, pEpset, fillHistory); + int32_t code = doAddSinkTaskToVg(pMnode, pStream, pEpset, pVgroup); + if(code != 0){ + sdbRelease(pSdb, pVgroup); + return code; + } + sdbRelease(pSdb, pVgroup); } - return 0; -} - -int32_t doAddSinkTask(SStreamObj* pStream, SArray* pTaskList, SMnode* pMnode, int32_t vgId, SVgObj* pVgroup, - SEpSet* pEpset, bool isFillhistory) { - int64_t uid = (isFillhistory) ? pStream->hTaskUid : pStream->uid; - SStreamTask* pTask = - tNewStreamTask(uid, TASK_LEVEL__SINK, pEpset, isFillhistory, 0, pTaskList, pStream->conf.fillHistory); - if (pTask == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - pTask->info.nodeId = vgId; - pTask->info.epSet = mndGetVgroupEpset(pMnode, pVgroup); - mndSetSinkTaskInfo(pStream, pTask); - return 0; + return TDB_CODE_SUCCESS; } static int64_t getVgroupLastVer(const SArray* pList, int32_t vgId) { @@ -290,44 +320,35 @@ static void streamTaskSetDataRange(SStreamTask* pTask, int64_t skey, SArray* pVe } } -static int32_t addSourceTask(SMnode* pMnode, SVgObj* pVgroup, SArray* pTaskList, SArray* pSinkTaskList, - SStreamObj* pStream, SSubplan* plan, uint64_t uid, SEpSet* pEpset, int64_t skey, - SArray* pVerList, bool fillHistory, bool hasExtraSink, bool hasFillHistory) { - int64_t t = pStream->conf.triggerParam; - SStreamTask* pTask = tNewStreamTask(uid, TASK_LEVEL__SOURCE, pEpset, fillHistory, t, pTaskList, hasFillHistory); +static SStreamTask* buildSourceTask(SStreamObj* pStream, SEpSet* pEpset, + bool isFillhistory, bool useTriggerParam) { + uint64_t uid = (isFillhistory) ? pStream->hTaskUid : pStream->uid; + SArray** pTaskList = (isFillhistory) ? taosArrayGetLast(pStream->pHTasksList) : taosArrayGetLast(pStream->tasks); + + SStreamTask* pTask = tNewStreamTask(uid, TASK_LEVEL__SOURCE, pEpset, + isFillhistory, useTriggerParam ? pStream->conf.triggerParam : 0, + *pTaskList, pStream->conf.fillHistory); if (pTask == NULL) { - return terrno; + return NULL; } - streamTaskSetDataRange(pTask, skey, pVerList, pVgroup->vgId); - - // sink or dispatch - if (hasExtraSink) { - mndAddDispatcherForInternalTask(pMnode, pStream, pSinkTaskList, pTask); - } else { - mndSetSinkTaskInfo(pStream, pTask); - } - - if (mndAssignStreamTaskToVgroup(pMnode, pTask, plan, pVgroup) < 0) { - return terrno; - } - - for(int32_t i = 0; i < taosArrayGetSize(pSinkTaskList); ++i) { - SStreamTask* pSinkTask = taosArrayGetP(pSinkTaskList, i); - streamTaskSetUpstreamInfo(pSinkTask, pTask); - } - - return TSDB_CODE_SUCCESS; + return pTask; } -static SArray* addNewTaskList(SArray* pTasksList) { +static void addNewTaskList(SStreamObj* pStream){ SArray* pTaskList = taosArrayInit(0, POINTER_BYTES); - taosArrayPush(pTasksList, &pTaskList); - return pTaskList; + taosArrayPush(pStream->tasks, &pTaskList); + if (pStream->conf.fillHistory) { + pTaskList = taosArrayInit(0, POINTER_BYTES); + taosArrayPush(pStream->pHTasksList, &pTaskList); + } } // set the history task id -static void setHTasksId(SArray* pTaskList, const SArray* pHTaskList) { +static void setHTasksId(SStreamObj* pStream) { + SArray* pTaskList = *(SArray**)taosArrayGetLast(pStream->tasks); + SArray* pHTaskList = *(SArray**)taosArrayGetLast(pStream->pHTasksList); + for (int32_t i = 0; i < taosArrayGetSize(pTaskList); ++i) { SStreamTask** pStreamTask = taosArrayGet(pTaskList, i); SStreamTask** pHTask = taosArrayGet(pHTaskList, i); @@ -343,30 +364,63 @@ static void setHTasksId(SArray* pTaskList, const SArray* pHTaskList) { } } -static int32_t addSourceTasksForOneLevelStream(SMnode* pMnode, const SQueryPlan* pPlan, SStreamObj* pStream, - SEpSet* pEpset, bool hasExtraSink, int64_t skey, SArray* pVerList) { - // create exec stream task, since only one level, the exec task is also the source task - SArray* pTaskList = addNewTaskList(pStream->tasks); - SSdb* pSdb = pMnode->pSdb; - - SArray* pHTaskList = NULL; - if (pStream->conf.fillHistory) { - pHTaskList = addNewTaskList(pStream->pHTasksList); +static int32_t doAddSourceTask(SMnode* pMnode, SSubplan* plan, SStreamObj* pStream, SEpSet* pEpset, + int64_t skey, SArray* pVerList, SVgObj* pVgroup, bool isFillhistory, bool useTriggerParam ){ + // new stream task + SStreamTask* pTask = buildSourceTask(pStream, pEpset, isFillhistory, useTriggerParam); + if(pTask == NULL){ + terrno = TSDB_CODE_OUT_OF_MEMORY; + return terrno; } + mDebug("doAddSourceTask taskId:%s, vgId:%d, isFillHistory:%d", pTask->id.idStr, pVgroup->vgId, isFillhistory); - SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0); + streamTaskSetDataRange(pTask, skey, pVerList, pVgroup->vgId); + + int32_t code = mndAssignStreamTaskToVgroup(pMnode, pTask, plan, pVgroup); + if(code != 0){ + terrno = code; + return terrno; + } + return TDB_CODE_SUCCESS; +} + +static SSubplan* getScanSubPlan(const SQueryPlan* pPlan){ + int32_t numOfPlanLevel = LIST_LENGTH(pPlan->pSubplans); + SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, numOfPlanLevel - 1); if (LIST_LENGTH(inner->pNodeList) != 1) { terrno = TSDB_CODE_QRY_INVALID_INPUT; - return -1; + return NULL; } SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0); if (plan->subplanType != SUBPLAN_TYPE_SCAN) { terrno = TSDB_CODE_QRY_INVALID_INPUT; - return -1; + return NULL; + } + return plan; +} + +static SSubplan* getAggSubPlan(const SQueryPlan* pPlan, int index){ + SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, index); + if (LIST_LENGTH(inner->pNodeList) != 1) { + terrno = TSDB_CODE_QRY_INVALID_INPUT; + return NULL; } + SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0); + if (plan->subplanType != SUBPLAN_TYPE_MERGE) { + terrno = TSDB_CODE_QRY_INVALID_INPUT; + return NULL; + } + return plan; +} + +static int32_t addSourceTask(SMnode* pMnode, SSubplan* plan, SStreamObj* pStream, + SEpSet* pEpset, int64_t nextWindowSkey, SArray* pVerList, bool useTriggerParam) { + addNewTaskList(pStream); + void* pIter = NULL; + SSdb* pSdb = pMnode->pSdb; while (1) { SVgObj* pVgroup; pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup); @@ -379,187 +433,15 @@ static int32_t addSourceTasksForOneLevelStream(SMnode* pMnode, const SQueryPlan* continue; } - // new stream task - SArray** pSinkTaskList = taosArrayGet(pStream->tasks, SINK_NODE_LEVEL); - int32_t code = addSourceTask(pMnode, pVgroup, pTaskList, *pSinkTaskList, pStream, plan, pStream->uid, pEpset, skey, - pVerList, false, hasExtraSink, pStream->conf.fillHistory); - if (code != TSDB_CODE_SUCCESS) { + int code = doAddSourceTask(pMnode, plan, pStream, pEpset, nextWindowSkey, pVerList, pVgroup, false, useTriggerParam); + if(code != 0){ sdbRelease(pSdb, pVgroup); - return -1; - } - - if (pStream->conf.fillHistory) { - SArray** pHSinkTaskList = taosArrayGet(pStream->pHTasksList, SINK_NODE_LEVEL); - code = addSourceTask(pMnode, pVgroup, pHTaskList, *pHSinkTaskList, pStream, plan, pStream->hTaskUid, pEpset, skey, - pVerList, true, hasExtraSink, true); - } - - sdbRelease(pSdb, pVgroup); - if (code != TSDB_CODE_SUCCESS) { - return -1; - } - } - - if (pStream->conf.fillHistory) { - setHTasksId(pTaskList, pHTaskList); - } - - return TSDB_CODE_SUCCESS; -} - -static int32_t addSourceTaskForMultiLevelStream(SArray* pTaskList, bool isFillhistory, int64_t uid, - SStreamTask* pDownstreamTask, SMnode* pMnode, SSubplan* pPlan, - SVgObj* pVgroup, SEpSet* pEpset, int64_t skey, SArray* pVerList, - bool hasFillHistory) { - SStreamTask* pTask = tNewStreamTask(uid, TASK_LEVEL__SOURCE, pEpset, isFillhistory, 0, pTaskList, hasFillHistory); - if (pTask == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - streamTaskSetDataRange(pTask, skey, pVerList, pVgroup->vgId); - - // all the source tasks dispatch result to a single agg node. - streamTaskSetFixedDownstreamInfo(pTask, pDownstreamTask); - if (mndAssignStreamTaskToVgroup(pMnode, pTask, pPlan, pVgroup) < 0) { - return -1; - } - - return streamTaskSetUpstreamInfo(pDownstreamTask, pTask); -} - -static int32_t doAddAggTask(uint64_t uid, SArray* pTaskList, SArray* pSinkNodeList, SMnode* pMnode, SStreamObj* pStream, - SEpSet* pEpset, bool fillHistory, SStreamTask** pAggTask, bool hasFillhistory) { - *pAggTask = tNewStreamTask(uid, TASK_LEVEL__AGG, pEpset, fillHistory, pStream->conf.triggerParam, pTaskList, hasFillhistory); - if (*pAggTask == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - // dispatch - if (mndAddDispatcherForInternalTask(pMnode, pStream, pSinkNodeList, *pAggTask) < 0) { - return -1; - } - - return 0; -} - -static int32_t addAggTask(SStreamObj* pStream, SMnode* pMnode, SQueryPlan* pPlan, SEpSet* pEpset, - SStreamTask** pAggTask, SStreamTask** pHAggTask) { - SArray* pAggTaskList = addNewTaskList(pStream->tasks); - SSdb* pSdb = pMnode->pSdb; - - SNodeListNode* pInnerNode = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 0); - SSubplan* plan = (SSubplan*)nodesListGetNode(pInnerNode->pNodeList, 0); - if (plan->subplanType != SUBPLAN_TYPE_MERGE) { - terrno = TSDB_CODE_QRY_INVALID_INPUT; - return -1; - } - - *pAggTask = NULL; - SArray* pSinkNodeList = taosArrayGetP(pStream->tasks, SINK_NODE_LEVEL); - - int32_t code = doAddAggTask(pStream->uid, pAggTaskList, pSinkNodeList, pMnode, pStream, pEpset, false, pAggTask, - pStream->conf.fillHistory); - if (code != TSDB_CODE_SUCCESS) { - return -1; - } - - SVgObj* pVgroup = NULL; - SSnodeObj* pSnode = NULL; - - if (tsDeployOnSnode) { - pSnode = mndSchedFetchOneSnode(pMnode); - if (pSnode == NULL) { - pVgroup = mndSchedFetchOneVg(pMnode, pStream->sourceDbUid); - } - } else { - pVgroup = mndSchedFetchOneVg(pMnode, pStream->sourceDbUid); - } - - if (pSnode != NULL) { - code = mndAssignStreamTaskToSnode(pMnode, *pAggTask, plan, pSnode); - } else { - code = mndAssignStreamTaskToVgroup(pMnode, *pAggTask, plan, pVgroup); - } - - if (pStream->conf.fillHistory) { - SArray* pHAggTaskList = addNewTaskList(pStream->pHTasksList); - SArray* pHSinkNodeList = taosArrayGetP(pStream->pHTasksList, SINK_NODE_LEVEL); - - *pHAggTask = NULL; - code = doAddAggTask(pStream->hTaskUid, pHAggTaskList, pHSinkNodeList, pMnode, pStream, pEpset, pStream->conf.fillHistory, - pHAggTask, pStream->conf.fillHistory); - if (code != TSDB_CODE_SUCCESS) { - if (pSnode != NULL) { - sdbRelease(pSdb, pSnode); - } else { - sdbRelease(pSdb, pVgroup); - } return code; } - if (pSnode != NULL) { - code = mndAssignStreamTaskToSnode(pMnode, *pHAggTask, plan, pSnode); - } else { - code = mndAssignStreamTaskToVgroup(pMnode, *pHAggTask, plan, pVgroup); - } - - setHTasksId(pAggTaskList, pHAggTaskList); - } - - if (pSnode != NULL) { - sdbRelease(pSdb, pSnode); - } else { - sdbRelease(pSdb, pVgroup); - } - - return code; -} - -static int32_t addSourceTasksForMultiLevelStream(SMnode* pMnode, SQueryPlan* pPlan, SStreamObj* pStream, - SStreamTask* pDownstreamTask, SStreamTask* pHDownstreamTask, - SEpSet* pEpset, int64_t skey, SArray* pVerList) { - SArray* pSourceTaskList = addNewTaskList(pStream->tasks); - - SArray* pHSourceTaskList = NULL; - if (pStream->conf.fillHistory) { - pHSourceTaskList = addNewTaskList(pStream->pHTasksList); - } - - SSdb* pSdb = pMnode->pSdb; - SNodeListNode* inner = (SNodeListNode*)nodesListGetNode(pPlan->pSubplans, 1); - SSubplan* plan = (SSubplan*)nodesListGetNode(inner->pNodeList, 0); - if (plan->subplanType != SUBPLAN_TYPE_SCAN) { - terrno = TSDB_CODE_QRY_INVALID_INPUT; - return -1; - } - - void* pIter = NULL; - while (1) { - SVgObj* pVgroup; - pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup); - if (pIter == NULL) { - break; - } - - if (!mndVgroupInDb(pVgroup, pStream->sourceDbUid)) { - sdbRelease(pSdb, pVgroup); - continue; - } - - int32_t code = addSourceTaskForMultiLevelStream(pSourceTaskList, false, pStream->uid, pDownstreamTask, pMnode, plan, pVgroup, pEpset, - skey, pVerList, pStream->conf.fillHistory); - if (code != TSDB_CODE_SUCCESS) { - sdbRelease(pSdb, pVgroup); - terrno = code; - return -1; - } - if (pStream->conf.fillHistory) { - code = addSourceTaskForMultiLevelStream(pHSourceTaskList, true, pStream->hTaskUid, pHDownstreamTask, pMnode, plan, pVgroup, pEpset, - skey, pVerList, pStream->conf.fillHistory); - if (code != TSDB_CODE_SUCCESS) { + code = doAddSourceTask(pMnode, plan, pStream, pEpset, nextWindowSkey, pVerList, pVgroup, true, useTriggerParam); + if(code != 0){ sdbRelease(pSdb, pVgroup); return code; } @@ -569,49 +451,160 @@ static int32_t addSourceTasksForMultiLevelStream(SMnode* pMnode, SQueryPlan* pPl } if (pStream->conf.fillHistory) { - setHTasksId(pSourceTaskList, pHSourceTaskList); + setHTasksId(pStream); } return TSDB_CODE_SUCCESS; } -static int32_t addSinkTasks(SArray* pTasksList, SMnode* pMnode, SStreamObj* pStream, SArray** pCreatedTaskList, - SEpSet* pEpset, bool fillHistory) { - SArray* pSinkTaskList = addNewTaskList(pTasksList); - if (pStream->fixedSinkVgId == 0) { - if (doAddShuffleSinkTask(pMnode, pSinkTaskList, pStream, pEpset, fillHistory) < 0) { - // TODO free - return -1; +static SStreamTask* buildAggTask(SStreamObj* pStream, SEpSet* pEpset, bool isFillhistory, bool useTriggerParam) { + uint64_t uid = (isFillhistory) ? pStream->hTaskUid : pStream->uid; + SArray** pTaskList = (isFillhistory) ? taosArrayGetLast(pStream->pHTasksList) : taosArrayGetLast(pStream->tasks); + + SStreamTask* pAggTask = tNewStreamTask(uid, TASK_LEVEL__AGG, pEpset, isFillhistory, + useTriggerParam ? pStream->conf.triggerParam : 0, + *pTaskList, pStream->conf.fillHistory); + if (pAggTask == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + + return pAggTask; +} + +static int32_t doAddAggTask(SStreamObj* pStream, SMnode* pMnode, SSubplan* plan, SEpSet* pEpset, + SVgObj* pVgroup, SSnodeObj* pSnode, bool isFillhistory, bool useTriggerParam){ + int32_t code = 0; + SStreamTask* pTask = buildAggTask(pStream, pEpset, isFillhistory, useTriggerParam); + if (pTask == NULL) { + return terrno; + } + if (pSnode != NULL) { + code = mndAssignStreamTaskToSnode(pMnode, pTask, plan, pSnode); + mDebug("doAddAggTask taskId:%s, snode id:%d, isFillHistory:%d", pTask->id.idStr, pSnode->id, isFillhistory); + + } else { + code = mndAssignStreamTaskToVgroup(pMnode, pTask, plan, pVgroup); + mDebug("doAddAggTask taskId:%s, vgId:%d, isFillHistory:%d", pTask->id.idStr, pVgroup->vgId, isFillhistory); + } + return code; +} + +static int32_t addAggTask(SStreamObj* pStream, SMnode* pMnode, SSubplan* plan, SEpSet* pEpset, bool useTriggerParam){ + SVgObj* pVgroup = NULL; + SSnodeObj* pSnode = NULL; + int32_t code = 0; + if (tsDeployOnSnode) { + pSnode = mndSchedFetchOneSnode(pMnode); + if (pSnode == NULL) { + pVgroup = mndSchedFetchOneVg(pMnode, pStream); } } else { - if (doAddSinkTask(pStream, pSinkTaskList, pMnode, pStream->fixedSinkVgId, &pStream->fixedSinkVg, pEpset, - fillHistory) < 0) { - // TODO free - return -1; + pVgroup = mndSchedFetchOneVg(pMnode, pStream); + } + + code = doAddAggTask(pStream, pMnode, plan, pEpset, pVgroup, pSnode, false, useTriggerParam); + if(code != 0){ + goto END; + } + + if (pStream->conf.fillHistory) { + code = doAddAggTask(pStream, pMnode, plan, pEpset, pVgroup, pSnode, true, useTriggerParam); + if(code != 0){ + goto END; + } + + setHTasksId(pStream); + } + + END: + if (pSnode != NULL) { + sdbRelease(pMnode->pSdb, pSnode); + } else { + sdbRelease(pMnode->pSdb, pVgroup); + } + return code; +} + +static int32_t addSinkTask(SMnode* pMnode, SStreamObj* pStream, SEpSet* pEpset){ + int32_t code = 0; + addNewTaskList(pStream); + + if (pStream->fixedSinkVgId == 0) { + code = doAddShuffleSinkTask(pMnode, pStream, pEpset); + if (code != 0) { + return code; + } + } else { + code = doAddSinkTaskToVg(pMnode, pStream, pEpset, &pStream->fixedSinkVg); + if (code != 0) { + return code; } } - *pCreatedTaskList = pSinkTaskList; - return TSDB_CODE_SUCCESS; + if (pStream->conf.fillHistory) { + setHTasksId(pStream); + } + return TDB_CODE_SUCCESS; } -static void setSinkTaskUpstreamInfo(SArray* pTasksList, const SStreamTask* pUpstreamTask) { - if (taosArrayGetSize(pTasksList) < SINK_NODE_LEVEL || pUpstreamTask == NULL) { - return; +static void bindTaskToSinkTask(SStreamObj* pStream, SMnode* pMnode, SArray* pSinkTaskList, SStreamTask* task){ + mndAddDispatcherForInternalTask(pMnode, pStream, pSinkTaskList, task); + for(int32_t k = 0; k < taosArrayGetSize(pSinkTaskList); k++) { + SStreamTask* pSinkTask = taosArrayGetP(pSinkTaskList, k); + streamTaskSetUpstreamInfo(pSinkTask, task); } + mDebug("bindTaskToSinkTask taskId:%s to sink task list", task->id.idStr); +} - SArray* pSinkTaskList = taosArrayGetP(pTasksList, SINK_NODE_LEVEL); - for(int32_t i = 0; i < taosArrayGetSize(pSinkTaskList); ++i) { - SStreamTask* pSinkTask = taosArrayGetP(pSinkTaskList, i); - streamTaskSetUpstreamInfo(pSinkTask, pUpstreamTask); +static void bindAggSink(SStreamObj* pStream, SMnode* pMnode, SArray* tasks) { + SArray* pSinkTaskList = taosArrayGetP(tasks, SINK_NODE_LEVEL); + SArray** pAggTaskList = taosArrayGetLast(tasks); + + for(int i = 0; i < taosArrayGetSize(*pAggTaskList); i++){ + SStreamTask* pAggTask = taosArrayGetP(*pAggTaskList, i); + bindTaskToSinkTask(pStream, pMnode, pSinkTaskList, pAggTask); + mDebug("bindAggSink taskId:%s to sink task list", pAggTask->id.idStr); } } +static void bindSourceSink(SStreamObj* pStream, SMnode* pMnode, SArray* tasks, bool hasExtraSink) { + SArray* pSinkTaskList = taosArrayGetP(tasks, SINK_NODE_LEVEL); + SArray* pSourceTaskList = taosArrayGetP(tasks, hasExtraSink ? SINK_NODE_LEVEL + 1 : SINK_NODE_LEVEL); + + for(int i = 0; i < taosArrayGetSize(pSourceTaskList); i++){ + SStreamTask* pSourceTask = taosArrayGetP(pSourceTaskList, i); + mDebug("bindSourceSink taskId:%s to sink task list", pSourceTask->id.idStr); + + if (hasExtraSink) { + bindTaskToSinkTask(pStream, pMnode, pSinkTaskList, pSourceTask); + } else { + mndSetSinkTaskInfo(pStream, pSourceTask); + } + } +} + +static void bindTwoLevel(SArray* tasks, int32_t begin, int32_t end) { + size_t size = taosArrayGetSize(tasks); + ASSERT(size >= 2); + SArray* pDownTaskList = taosArrayGetP(tasks, size - 1); + SArray* pUpTaskList = taosArrayGetP(tasks, size - 2); + + SStreamTask** pDownTask = taosArrayGetLast(pDownTaskList); + end = end > taosArrayGetSize(pUpTaskList) ? taosArrayGetSize(pUpTaskList): end; + for(int i = begin; i < end; i++){ + SStreamTask* pUpTask = taosArrayGetP(pUpTaskList, i); + pUpTask->info.selfChildId = i - begin; + streamTaskSetFixedDownstreamInfo(pUpTask, *pDownTask); + streamTaskSetUpstreamInfo(*pDownTask, pUpTask); + } + mDebug("bindTwoLevel task list(%d-%d) to taskId:%s", begin, end - 1, (*(pDownTask))->id.idStr); +} + static int32_t doScheduleStream(SStreamObj* pStream, SMnode* pMnode, SQueryPlan* pPlan, SEpSet* pEpset, int64_t skey, SArray* pVerList) { SSdb* pSdb = pMnode->pSdb; int32_t numOfPlanLevel = LIST_LENGTH(pPlan->pSubplans); - bool hasExtraSink = false; bool externalTargetDB = strcmp(pStream->sourceDb, pStream->targetDb) != 0; SDbObj* pDbObj = mndAcquireDb(pMnode, pStream->targetDb); @@ -623,54 +616,90 @@ static int32_t doScheduleStream(SStreamObj* pStream, SMnode* pMnode, SQueryPlan* bool multiTarget = (pDbObj->cfg.numOfVgroups > 1); sdbRelease(pSdb, pDbObj); + mDebug("doScheduleStream numOfPlanLevel:%d, exDb:%d, multiTarget:%d, fix vgId:%d, physicalPlan:%s", + numOfPlanLevel, externalTargetDB, multiTarget, pStream->fixedSinkVgId, pStream->physicalPlan); pStream->tasks = taosArrayInit(numOfPlanLevel + 1, POINTER_BYTES); pStream->pHTasksList = taosArrayInit(numOfPlanLevel + 1, POINTER_BYTES); - if (numOfPlanLevel == 2 || externalTargetDB || multiTarget || pStream->fixedSinkVgId) { + if (numOfPlanLevel > 1 || externalTargetDB || multiTarget || pStream->fixedSinkVgId) { // add extra sink hasExtraSink = true; - - SArray* pSinkTaskList = NULL; - int32_t code = addSinkTasks(pStream->tasks, pMnode, pStream, &pSinkTaskList, pEpset, 0); + int32_t code = addSinkTask(pMnode, pStream, pEpset); if (code != TSDB_CODE_SUCCESS) { return code; } - - // check for fill history - if (pStream->conf.fillHistory) { - SArray* pHSinkTaskList = NULL; - code = addSinkTasks(pStream->pHTasksList, pMnode, pStream, &pHSinkTaskList, pEpset, 1); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - setHTasksId(pSinkTaskList, pHSinkTaskList); - } } pStream->totalLevel = numOfPlanLevel + hasExtraSink; - if (numOfPlanLevel > 1) { - SStreamTask* pAggTask = NULL; - SStreamTask* pHAggTask = NULL; - - int32_t code = addAggTask(pStream, pMnode, pPlan, pEpset, &pAggTask, &pHAggTask); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - setSinkTaskUpstreamInfo(pStream->tasks, pAggTask); - if (pHAggTask != NULL) { - setSinkTaskUpstreamInfo(pStream->pHTasksList, pHAggTask); - } - - // source level - return addSourceTasksForMultiLevelStream(pMnode, pPlan, pStream, pAggTask, pHAggTask, pEpset, skey, pVerList); - } else if (numOfPlanLevel == 1) { - return addSourceTasksForOneLevelStream(pMnode, pPlan, pStream, pEpset, hasExtraSink, skey, pVerList); + SSubplan* plan = getScanSubPlan(pPlan); // source plan + if (plan == NULL) { + return terrno; + } + int32_t code = addSourceTask(pMnode, plan, pStream, pEpset, skey, pVerList, numOfPlanLevel == 1); + if (code != TSDB_CODE_SUCCESS) { + return code; } - return 0; + if (numOfPlanLevel == 1) { + bindSourceSink(pStream, pMnode, pStream->tasks, hasExtraSink); + if (pStream->conf.fillHistory) { + bindSourceSink(pStream, pMnode, pStream->pHTasksList, hasExtraSink); + } + return TDB_CODE_SUCCESS; + } + + if(numOfPlanLevel == 3){ + plan = getAggSubPlan(pPlan, 1); // middle agg plan + if (plan == NULL) { + return terrno; + } + do{ + SArray** list = taosArrayGetLast(pStream->tasks); + float size = (float)taosArrayGetSize(*list); + size_t cnt = (size_t)ceil(size/tsStreamAggCnt); + if(cnt <= 1) break; + + mDebug("doScheduleStream add middle agg, size:%d, cnt:%d", (int)size, (int)cnt); + addNewTaskList(pStream); + + for(int j = 0; j < cnt; j++){ + code = addAggTask(pStream, pMnode, plan, pEpset, false); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + bindTwoLevel(pStream->tasks, j*tsStreamAggCnt, (j+1)*tsStreamAggCnt); + if (pStream->conf.fillHistory) { + bindTwoLevel(pStream->pHTasksList, j*tsStreamAggCnt, (j+1)*tsStreamAggCnt); + } + } + }while(1); + } + + plan = getAggSubPlan(pPlan, 0); + if (plan == NULL) { + return terrno; + } + + mDebug("doScheduleStream add final agg"); + SArray** list = taosArrayGetLast(pStream->tasks); + size_t size = taosArrayGetSize(*list); + addNewTaskList(pStream); + code = addAggTask(pStream, pMnode, plan, pEpset, true); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + bindTwoLevel(pStream->tasks, 0, size); + if (pStream->conf.fillHistory) { + bindTwoLevel(pStream->pHTasksList, 0, size); + } + + bindAggSink(pStream, pMnode, pStream->tasks); + if (pStream->conf.fillHistory) { + bindAggSink(pStream, pMnode, pStream->pHTasksList); + } + return TDB_CODE_SUCCESS; } int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream, int64_t skey, SArray* pVgVerList) { diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index cfd7ecf054..1e92b1a181 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -566,6 +566,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea streamObj.conf.trigger = STREAM_TRIGGER_WINDOW_CLOSE; streamObj.conf.triggerParam = pCreate->maxDelay; streamObj.ast = taosStrdup(smaObj.ast); + streamObj.indexForMultiAggBalance = -1; // check the maxDelay if (streamObj.conf.triggerParam < TSDB_MIN_ROLLUP_MAX_DELAY) { diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 0a78914011..190b4f28ce 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -297,6 +297,7 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj, pObj->updateTime = pObj->createTime; pObj->version = 1; pObj->smaId = 0; + pObj->indexForMultiAggBalance = -1; pObj->uid = mndGenerateUid(pObj->name, strlen(pObj->name)); @@ -1616,7 +1617,7 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; SStreamObj *pStream = NULL; - if(grantCheckLE(TSDB_GRANT_STREAMS) < 0){ + if(grantCheckExpire(TSDB_GRANT_STREAMS) < 0){ terrno = TSDB_CODE_GRANT_EXPIRED; return -1; } diff --git a/source/dnode/mnode/impl/src/mndStreamHb.c b/source/dnode/mnode/impl/src/mndStreamHb.c index 97474fa851..5de442951c 100644 --- a/source/dnode/mnode/impl/src/mndStreamHb.c +++ b/source/dnode/mnode/impl/src/mndStreamHb.c @@ -225,7 +225,7 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) { SArray *pFailedTasks = taosArrayInit(4, sizeof(SFailedCheckpointInfo)); SArray *pOrphanTasks = taosArrayInit(3, sizeof(SOrphanTask)); - if(grantCheckLE(TSDB_GRANT_STREAMS) < 0){ + if(grantCheckExpire(TSDB_GRANT_STREAMS) < 0){ if(suspendAllStreams(pMnode, &pReq->info) < 0){ return -1; } diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index 0909003201..fbdfd81cdf 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -24,7 +24,7 @@ #include "tcompare.h" #include "tname.h" -#define MND_SUBSCRIBE_VER_NUMBER 2 +#define MND_SUBSCRIBE_VER_NUMBER 3 #define MND_SUBSCRIBE_RESERVE_SIZE 64 #define MND_CONSUMER_LOST_HB_CNT 6 @@ -530,51 +530,50 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR } } -// if(taosHashGetSize(pOutput->pSub->consumerHash) == 0) { // if all consumer is removed - SMqSubscribeObj *pSub = mndAcquireSubscribeByKey(pMnode, pInput->pRebInfo->key); // put all offset rows - if (pSub) { - taosRLockLatch(&pSub->lock); - if (pOutput->pSub->offsetRows == NULL) { - pOutput->pSub->offsetRows = taosArrayInit(4, sizeof(OffsetRows)); - } - pIter = NULL; - while (1) { - pIter = taosHashIterate(pSub->consumerHash, pIter); - if (pIter == NULL) break; - SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; - SMqConsumerEp *pConsumerEpNew = taosHashGet(pOutput->pSub->consumerHash, &pConsumerEp->consumerId, sizeof(int64_t)); + SMqSubscribeObj *pSub = mndAcquireSubscribeByKey(pMnode, pInput->pRebInfo->key); // put all offset rows + if (pSub) { + taosRLockLatch(&pSub->lock); + if (pOutput->pSub->offsetRows == NULL) { + pOutput->pSub->offsetRows = taosArrayInit(4, sizeof(OffsetRows)); + } + pIter = NULL; + while (1) { + pIter = taosHashIterate(pSub->consumerHash, pIter); + if (pIter == NULL) break; + SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; + SMqConsumerEp *pConsumerEpNew = taosHashGet(pOutput->pSub->consumerHash, &pConsumerEp->consumerId, sizeof(int64_t)); - for (int j = 0; j < taosArrayGetSize(pConsumerEp->offsetRows); j++) { - OffsetRows *d1 = taosArrayGet(pConsumerEp->offsetRows, j); - bool jump = false; - for (int i = 0; pConsumerEpNew && i < taosArrayGetSize(pConsumerEpNew->vgs); i++){ - SMqVgEp *pVgEp = taosArrayGetP(pConsumerEpNew->vgs, i); - if(pVgEp->vgId == d1->vgId){ - jump = true; - mInfo("pSub->offsetRows jump, because consumer id:0x%"PRIx64 " and vgId:%d not change", pConsumerEp->consumerId, pVgEp->vgId); - break; - } - } - if(jump) continue; - bool find = false; - for (int i = 0; i < taosArrayGetSize(pOutput->pSub->offsetRows); i++) { - OffsetRows *d2 = taosArrayGet(pOutput->pSub->offsetRows, i); - if (d1->vgId == d2->vgId) { - d2->rows += d1->rows; - d2->offset = d1->offset; - find = true; - mInfo("pSub->offsetRows add vgId:%d, after:%"PRId64", before:%"PRId64, d2->vgId, d2->rows, d1->rows); - break; - } - } - if(!find){ - taosArrayPush(pOutput->pSub->offsetRows, d1); + for (int j = 0; j < taosArrayGetSize(pConsumerEp->offsetRows); j++) { + OffsetRows *d1 = taosArrayGet(pConsumerEp->offsetRows, j); + bool jump = false; + for (int i = 0; pConsumerEpNew && i < taosArrayGetSize(pConsumerEpNew->vgs); i++){ + SMqVgEp *pVgEp = taosArrayGetP(pConsumerEpNew->vgs, i); + if(pVgEp->vgId == d1->vgId){ + jump = true; + mInfo("pSub->offsetRows jump, because consumer id:0x%"PRIx64 " and vgId:%d not change", pConsumerEp->consumerId, pVgEp->vgId); + break; } } + if(jump) continue; + bool find = false; + for (int i = 0; i < taosArrayGetSize(pOutput->pSub->offsetRows); i++) { + OffsetRows *d2 = taosArrayGet(pOutput->pSub->offsetRows, i); + if (d1->vgId == d2->vgId) { + d2->rows += d1->rows; + d2->offset = d1->offset; + d2->ever = d1->ever; + find = true; + mInfo("pSub->offsetRows add vgId:%d, after:%"PRId64", before:%"PRId64, d2->vgId, d2->rows, d1->rows); + break; + } + } + if(!find){ + taosArrayPush(pOutput->pSub->offsetRows, d1); + } } - taosRUnLockLatch(&pSub->lock); - mndReleaseSubscribe(pMnode, pSub); -// } + } + taosRUnLockLatch(&pSub->lock); + mndReleaseSubscribe(pMnode, pSub); } // 8. generate logs @@ -1405,8 +1404,9 @@ static int32_t buildResult(SSDataBlock *pBlock, int32_t* numOfRows, int64_t cons } if(data){ // vg id - char buf[TSDB_OFFSET_LEN + VARSTR_HEADER_SIZE] = {0}; + char buf[TSDB_OFFSET_LEN*2 + VARSTR_HEADER_SIZE] = {0}; tFormatOffset(varDataVal(buf), TSDB_OFFSET_LEN, &data->offset); + sprintf(varDataVal(buf) + strlen(varDataVal(buf)), "/%"PRId64, data->ever); varDataSetLen(buf, strlen(varDataVal(buf))); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataSetVal(pColInfo, *numOfRows, (const char *)buf, false); diff --git a/source/dnode/mnode/impl/test/stream/CMakeLists.txt b/source/dnode/mnode/impl/test/stream/CMakeLists.txt index b1bb62735f..bfc138c9d7 100644 --- a/source/dnode/mnode/impl/test/stream/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/stream/CMakeLists.txt @@ -4,7 +4,7 @@ aux_source_directory(. MNODE_STREAM_TEST_SRC) add_executable(streamTest ${MNODE_STREAM_TEST_SRC}) target_link_libraries( streamTest - PRIVATE dnode gtest + PRIVATE dnode nodes planner gtest qcom ) add_test( diff --git a/source/dnode/mnode/impl/test/stream/stream.cpp b/source/dnode/mnode/impl/test/stream/stream.cpp index a3babad80c..e3bfdb5d6c 100644 --- a/source/dnode/mnode/impl/test/stream/stream.cpp +++ b/source/dnode/mnode/impl/test/stream/stream.cpp @@ -15,6 +15,8 @@ #include #include +#include "nodes.h" +#include "planner.h" #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wwrite-strings" @@ -152,4 +154,37 @@ TEST(mndHbTest, handle_error_in_hb) { rpcFreeCont(msg.pCont); } +TEST(testCase, plan_Test) { + char* ast = "{\"NodeType\":\"101\",\"Name\":\"SelectStmt\",\"SelectStmt\":{\"Distinct\":false,\"Projections\":[{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"9\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"#expr_1\",\"UserAlias\":\"_wstart\",\"Name\":\"_wstart\",\"Id\":\"89\",\"Type\":\"3505\",\"UdfBufSize\":\"0\"}},{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"5\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"#expr_2\",\"UserAlias\":\"sum(voltage)\",\"Name\":\"sum\",\"Id\":\"1\",\"Type\":\"14\",\"Parameters\":[{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"4\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"4\"},\"AliasName\":\"voltage\",\"UserAlias\":\"voltage\",\"TableId\":\"6555383776122680534\",\"TableType\":\"1\",\"ColId\":\"3\",\"ProjId\":\"0\",\"ColType\":\"1\",\"DbName\":\"test\",\"TableName\":\"meters\",\"TableAlias\":\"meters\",\"ColName\":\"voltage\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"4\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"4\"},\"AliasName\":\"#expr_3\",\"UserAlias\":\"groupid\",\"Name\":\"_group_key\",\"Id\":\"96\",\"Type\":\"3754\",\"Parameters\":[{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"4\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"4\"},\"AliasName\":\"#expr_3\",\"UserAlias\":\"groupid\",\"TableId\":\"6555383776122680534\",\"TableType\":\"1\",\"ColId\":\"5\",\"ProjId\":\"0\",\"ColType\":\"2\",\"DbName\":\"test\",\"TableName\":\"meters\",\"TableAlias\":\"meters\",\"ColName\":\"groupid\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}}],\"UdfBufSize\":\"0\"}}],\"From\":{\"NodeType\":\"6\",\"Name\":\"RealTable\",\"RealTable\":{\"DataType\":{\"Type\":\"0\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"0\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"DbName\":\"test\",\"tableName\":\"meters\",\"tableAlias\":\"meters\",\"MetaSize\":\"475\",\"Meta\":{\"VgId\":\"0\",\"TableType\":\"1\",\"Uid\":\"6555383776122680534\",\"Suid\":\"6555383776122680534\",\"Sversion\":\"1\",\"Tversion\":\"1\",\"ComInfo\":{\"NumOfTags\":\"2\",\"Precision\":\"0\",\"NumOfColumns\":\"4\",\"RowSize\":\"20\"},\"ColSchemas\":[{\"Type\":\"9\",\"ColId\":\"1\",\"bytes\":\"8\",\"Name\":\"ts\"},{\"Type\":\"6\",\"ColId\":\"2\",\"bytes\":\"4\",\"Name\":\"current\"},{\"Type\":\"4\",\"ColId\":\"3\",\"bytes\":\"4\",\"Name\":\"voltage\"},{\"Type\":\"6\",\"ColId\":\"4\",\"bytes\":\"4\",\"Name\":\"phase\"},{\"Type\":\"4\",\"ColId\":\"5\",\"bytes\":\"4\",\"Name\":\"groupid\"},{\"Type\":\"8\",\"ColId\":\"6\",\"bytes\":\"26\",\"Name\":\"location\"}]},\"VgroupsInfoSize\":\"1340\",\"VgroupsInfo\":{\"Num\":\"2\",\"Vgroups\":[{\"VgId\":\"2\",\"HashBegin\":\"0\",\"HashEnd\":\"2147483646\",\"EpSet\":{\"InUse\":\"0\",\"NumOfEps\":\"1\",\"Eps\":[{\"Fqdn\":\"localhost\",\"Port\":\"6030\"}]},\"NumOfTable\":\"0\"},{\"VgId\":\"3\",\"HashBegin\":\"2147483647\",\"HashEnd\":\"4294967295\",\"EpSet\":{\"InUse\":\"0\",\"NumOfEps\":\"1\",\"Eps\":[{\"Fqdn\":\"localhost\",\"Port\":\"6030\"}]},\"NumOfTable\":\"0\"}]}}},\"PartitionBy\":[{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"4\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"4\"},\"AliasName\":\"groupid\",\"UserAlias\":\"groupid\",\"TableId\":\"6555383776122680534\",\"TableType\":\"1\",\"ColId\":\"5\",\"ProjId\":\"0\",\"ColType\":\"2\",\"DbName\":\"test\",\"TableName\":\"meters\",\"TableAlias\":\"meters\",\"ColName\":\"groupid\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}}],\"Window\":{\"NodeType\":\"14\",\"Name\":\"IntervalWindow\",\"IntervalWindow\":{\"Interval\":{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"5\",\"Precision\":\"0\",\"Scale\":\"115\",\"Bytes\":\"8\"},\"AliasName\":\"c804c3a15ebe05b5baf40ad5ee12be1f\",\"UserAlias\":\"2s\",\"LiteralSize\":\"2\",\"Literal\":\"2s\",\"Duration\":true,\"Translate\":true,\"NotReserved\":false,\"IsNull\":false,\"Unit\":\"115\",\"Datum\":\"2000\"}},\"TsPk\":{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"9\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"ts\",\"UserAlias\":\"ts\",\"TableId\":\"6555383776122680534\",\"TableType\":\"1\",\"ColId\":\"1\",\"ProjId\":\"0\",\"ColType\":\"1\",\"DbName\":\"test\",\"TableName\":\"meters\",\"TableAlias\":\"meters\",\"ColName\":\"ts\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}}}},\"StmtName\":\"0x1580095ba\",\"HasAggFuncs\":true}}"; + // char* ast = "{\"NodeType\":\"101\",\"Name\":\"SelectStmt\",\"SelectStmt\":{\"Distinct\":false,\"Projections\":[{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"9\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"#expr_1\",\"UserAlias\":\"wstart\",\"Name\":\"_wstart\",\"Id\":\"89\",\"Type\":\"3505\",\"UdfBufSize\":\"0\"}},{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"2\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"#expr_2\",\"UserAlias\":\"min(c1)\",\"Name\":\"min\",\"Id\":\"2\",\"Type\":\"8\",\"Parameters\":[{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"2\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"c1\",\"UserAlias\":\"c1\",\"TableId\":\"5129202035162885657\",\"TableType\":\"1\",\"ColId\":\"2\",\"ProjId\":\"0\",\"ColType\":\"1\",\"DbName\":\"test\",\"TableName\":\"at_once_interval_ext_stb\",\"TableAlias\":\"at_once_interval_ext_stb\",\"ColName\":\"c1\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"3\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"2\"},\"AliasName\":\"#expr_3\",\"UserAlias\":\"max(c2)\",\"Name\":\"max\",\"Id\":\"3\",\"Type\":\"7\",\"Parameters\":[{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"3\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"2\"},\"AliasName\":\"c2\",\"UserAlias\":\"c2\",\"TableId\":\"5129202035162885657\",\"TableType\":\"1\",\"ColId\":\"3\",\"ProjId\":\"0\",\"ColType\":\"1\",\"DbName\":\"test\",\"TableName\":\"at_once_interval_ext_stb\",\"TableAlias\":\"at_once_interval_ext_stb\",\"ColName\":\"c2\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"4\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"4\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"Name\":\"cast\",\"Id\":\"77\",\"Type\":\"2000\",\"Parameters\":[{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"5\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"#expr_4\",\"UserAlias\":\"sum(c3)\",\"Name\":\"sum\",\"Id\":\"1\",\"Type\":\"14\",\"Parameters\":[{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"4\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"4\"},\"AliasName\":\"c3\",\"UserAlias\":\"c3\",\"TableId\":\"5129202035162885657\",\"TableType\":\"1\",\"ColId\":\"4\",\"ProjId\":\"0\",\"ColType\":\"1\",\"DbName\":\"test\",\"TableName\":\"at_once_interval_ext_stb\",\"TableAlias\":\"at_once_interval_ext_stb\",\"ColName\":\"c3\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"2\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":true,\"NotReserved\":true,\"IsNull\":false,\"Unit\":\"0\",\"Datum\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"5\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"#expr_5\",\"UserAlias\":\"first(c4)\",\"Name\":\"first\",\"Id\":\"33\",\"Type\":\"504\",\"Parameters\":[{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"5\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"c4\",\"UserAlias\":\"c4\",\"TableId\":\"5129202035162885657\",\"TableType\":\"1\",\"ColId\":\"5\",\"ProjId\":\"0\",\"ColType\":\"1\",\"DbName\":\"test\",\"TableName\":\"at_once_interval_ext_stb\",\"TableAlias\":\"at_once_interval_ext_stb\",\"ColName\":\"c4\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}},{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"9\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"ts\",\"UserAlias\":\"ts\",\"TableId\":\"5129202035162885657\",\"TableType\":\"1\",\"ColId\":\"1\",\"ProjId\":\"0\",\"ColType\":\"1\",\"DbName\":\"test\",\"TableName\":\"at_once_interval_ext_stb\",\"TableAlias\":\"at_once_interval_ext_stb\",\"ColName\":\"ts\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"11\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"#expr_6\",\"UserAlias\":\"last(c5)\",\"Name\":\"last\",\"Id\":\"36\",\"Type\":\"506\",\"Parameters\":[{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"11\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"c5\",\"UserAlias\":\"c5\",\"TableId\":\"5129202035162885657\",\"TableType\":\"1\",\"ColId\":\"6\",\"ProjId\":\"0\",\"ColType\":\"1\",\"DbName\":\"test\",\"TableName\":\"at_once_interval_ext_stb\",\"TableAlias\":\"at_once_interval_ext_stb\",\"ColName\":\"c5\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}},{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"9\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"ts\",\"UserAlias\":\"ts\",\"TableId\":\"5129202035162885657\",\"TableType\":\"1\",\"ColId\":\"1\",\"ProjId\":\"0\",\"ColType\":\"1\",\"DbName\":\"test\",\"TableName\":\"at_once_interval_ext_stb\",\"TableAlias\":\"at_once_interval_ext_stb\",\"ColName\":\"ts\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"12\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"2\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"Name\":\"cast\",\"Id\":\"77\",\"Type\":\"2000\",\"Parameters\":[{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"7\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"#expr_7\",\"UserAlias\":\"apercentile(c6, 50)\",\"Name\":\"apercentile\",\"Id\":\"12\",\"Type\":\"1\",\"Parameters\":[{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"12\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"2\"},\"AliasName\":\"c6\",\"UserAlias\":\"c6\",\"TableId\":\"5129202035162885657\",\"TableType\":\"1\",\"ColId\":\"7\",\"ProjId\":\"0\",\"ColType\":\"1\",\"DbName\":\"test\",\"TableName\":\"at_once_interval_ext_stb\",\"TableAlias\":\"at_once_interval_ext_stb\",\"ColName\":\"c6\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"5\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"c0c7c76d30bd3dcaefc96f40275bdc0a\",\"UserAlias\":\"50\",\"LiteralSize\":\"2\",\"Literal\":\"50\",\"Duration\":false,\"Translate\":true,\"NotReserved\":true,\"IsNull\":false,\"Unit\":\"0\",\"Datum\":\"50\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"2\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":true,\"NotReserved\":true,\"IsNull\":false,\"Unit\":\"0\",\"Datum\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"13\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"4\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"Name\":\"cast\",\"Id\":\"77\",\"Type\":\"2000\",\"Parameters\":[{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"7\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"#expr_8\",\"UserAlias\":\"avg(c7)\",\"Name\":\"avg\",\"Id\":\"8\",\"Type\":\"2\",\"Parameters\":[{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"13\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"4\"},\"AliasName\":\"c7\",\"UserAlias\":\"c7\",\"TableId\":\"5129202035162885657\",\"TableType\":\"1\",\"ColId\":\"8\",\"ProjId\":\"0\",\"ColType\":\"1\",\"DbName\":\"test\",\"TableName\":\"at_once_interval_ext_stb\",\"TableAlias\":\"at_once_interval_ext_stb\",\"ColName\":\"c7\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"2\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":true,\"NotReserved\":true,\"IsNull\":false,\"Unit\":\"0\",\"Datum\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"14\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"Name\":\"cast\",\"Id\":\"77\",\"Type\":\"2000\",\"Parameters\":[{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"5\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"#expr_9\",\"UserAlias\":\"count(c8)\",\"Name\":\"count\",\"Id\":\"0\",\"Type\":\"3\",\"Parameters\":[{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"14\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"c8\",\"UserAlias\":\"c8\",\"TableId\":\"5129202035162885657\",\"TableType\":\"1\",\"ColId\":\"9\",\"ProjId\":\"0\",\"ColType\":\"1\",\"DbName\":\"test\",\"TableName\":\"at_once_interval_ext_stb\",\"TableAlias\":\"at_once_interval_ext_stb\",\"ColName\":\"c8\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"2\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":true,\"NotReserved\":true,\"IsNull\":false,\"Unit\":\"0\",\"Datum\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"6\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"4\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"Name\":\"cast\",\"Id\":\"77\",\"Type\":\"2000\",\"Parameters\":[{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"7\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"#expr_10\",\"UserAlias\":\"spread(c1)\",\"Name\":\"spread\",\"Id\":\"17\",\"Type\":\"11\",\"Parameters\":[{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"2\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"c1\",\"UserAlias\":\"c1\",\"TableId\":\"5129202035162885657\",\"TableType\":\"1\",\"ColId\":\"2\",\"ProjId\":\"0\",\"ColType\":\"1\",\"DbName\":\"test\",\"TableName\":\"at_once_interval_ext_stb\",\"TableAlias\":\"at_once_interval_ext_stb\",\"ColName\":\"c1\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"2\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":true,\"NotReserved\":true,\"IsNull\":false,\"Unit\":\"0\",\"Datum\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"7\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"#expr_11\",\"UserAlias\":\"stddev(c2)\",\"Name\":\"stddev\",\"Id\":\"4\",\"Type\":\"12\",\"Parameters\":[{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"3\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"2\"},\"AliasName\":\"c2\",\"UserAlias\":\"c2\",\"TableId\":\"5129202035162885657\",\"TableType\":\"1\",\"ColId\":\"3\",\"ProjId\":\"0\",\"ColType\":\"1\",\"DbName\":\"test\",\"TableName\":\"at_once_interval_ext_stb\",\"TableAlias\":\"at_once_interval_ext_stb\",\"ColName\":\"c2\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"8\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"Name\":\"cast\",\"Id\":\"77\",\"Type\":\"2000\",\"Parameters\":[{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"5\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"#expr_12\",\"UserAlias\":\"hyperloglog(c11)\",\"Name\":\"hyperloglog\",\"Id\":\"43\",\"Type\":\"17\",\"Parameters\":[{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"8\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"c11\",\"UserAlias\":\"c11\",\"TableId\":\"5129202035162885657\",\"TableType\":\"1\",\"ColId\":\"12\",\"ProjId\":\"0\",\"ColType\":\"1\",\"DbName\":\"test\",\"TableName\":\"at_once_interval_ext_stb\",\"TableAlias\":\"at_once_interval_ext_stb\",\"ColName\":\"c11\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"2\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":true,\"NotReserved\":true,\"IsNull\":false,\"Unit\":\"0\",\"Datum\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"10\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"26\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"Name\":\"cast\",\"Id\":\"77\",\"Type\":\"2000\",\"Parameters\":[{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"5\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"#expr_13\",\"UserAlias\":\"timediff(1, 0, 1h)\",\"Name\":\"timediff\",\"Id\":\"81\",\"Type\":\"2501\",\"Parameters\":[{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"5\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"c4ca4238a0b923820dcc509a6f75849b\",\"UserAlias\":\"1\",\"LiteralSize\":\"1\",\"Literal\":\"1\",\"Duration\":false,\"Translate\":true,\"NotReserved\":false,\"IsNull\":false,\"Unit\":\"0\",\"Datum\":\"1\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"5\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"cfcd208495d565ef66e7dff9f98764da\",\"UserAlias\":\"0\",\"LiteralSize\":\"1\",\"Literal\":\"0\",\"Duration\":false,\"Translate\":true,\"NotReserved\":false,\"IsNull\":false,\"Unit\":\"0\",\"Datum\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"5\",\"Precision\":\"0\",\"Scale\":\"104\",\"Bytes\":\"8\"},\"AliasName\":\"7c68645d71b803bf0ba2f22519f73e08\",\"UserAlias\":\"1h\",\"LiteralSize\":\"2\",\"Literal\":\"1h\",\"Duration\":true,\"Translate\":true,\"NotReserved\":false,\"IsNull\":false,\"Unit\":\"104\",\"Datum\":\"3600000\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"2\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":true,\"NotReserved\":true,\"IsNull\":false,\"Unit\":\"0\",\"Datum\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"2\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":true,\"NotReserved\":true,\"IsNull\":false,\"Unit\":\"0\",\"Datum\":\"0\"}}],\"UdfBufSize\":\"0\"}},{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"1\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"Name\":\"cast\",\"Id\":\"77\",\"Type\":\"2000\",\"Parameters\":[{\"NodeType\":\"5\",\"Name\":\"Function\",\"Function\":{\"DataType\":{\"Type\":\"8\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"96\"},\"AliasName\":\"#expr_14\",\"UserAlias\":\"timezone()\",\"Name\":\"timezone\",\"Id\":\"84\",\"Type\":\"2503\",\"UdfBufSize\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"2\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":true,\"NotReserved\":true,\"IsNull\":false,\"Unit\":\"0\",\"Datum\":\"0\"}}],\"UdfBufSize\":\"0\"}}],\"From\":{\"NodeType\":\"6\",\"Name\":\"RealTable\",\"RealTable\":{\"DataType\":{\"Type\":\"0\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"0\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"DbName\":\"test\",\"tableName\":\"at_once_interval_ext_stb\",\"tableAlias\":\"at_once_interval_ext_stb\",\"MetaSize\":\"2008\",\"Meta\":{\"VgId\":\"0\",\"TableType\":\"1\",\"Uid\":\"5129202035162885657\",\"Suid\":\"5129202035162885657\",\"Sversion\":\"1\",\"Tversion\":\"1\",\"ComInfo\":{\"NumOfTags\":\"13\",\"Precision\":\"0\",\"NumOfColumns\":\"14\",\"RowSize\":\"85\"},\"ColSchemas\":[{\"Type\":\"9\",\"ColId\":\"1\",\"bytes\":\"8\",\"Name\":\"ts\"},{\"Type\":\"2\",\"ColId\":\"2\",\"bytes\":\"1\",\"Name\":\"c1\"},{\"Type\":\"3\",\"ColId\":\"3\",\"bytes\":\"2\",\"Name\":\"c2\"},{\"Type\":\"4\",\"ColId\":\"4\",\"bytes\":\"4\",\"Name\":\"c3\"},{\"Type\":\"5\",\"ColId\":\"5\",\"bytes\":\"8\",\"Name\":\"c4\"},{\"Type\":\"11\",\"ColId\":\"6\",\"bytes\":\"1\",\"Name\":\"c5\"},{\"Type\":\"12\",\"ColId\":\"7\",\"bytes\":\"2\",\"Name\":\"c6\"},{\"Type\":\"13\",\"ColId\":\"8\",\"bytes\":\"4\",\"Name\":\"c7\"},{\"Type\":\"14\",\"ColId\":\"9\",\"bytes\":\"8\",\"Name\":\"c8\"},{\"Type\":\"6\",\"ColId\":\"10\",\"bytes\":\"4\",\"Name\":\"c9\"},{\"Type\":\"7\",\"ColId\":\"11\",\"bytes\":\"8\",\"Name\":\"c10\"},{\"Type\":\"8\",\"ColId\":\"12\",\"bytes\":\"8\",\"Name\":\"c11\"},{\"Type\":\"10\",\"ColId\":\"13\",\"bytes\":\"26\",\"Name\":\"c12\"},{\"Type\":\"1\",\"ColId\":\"14\",\"bytes\":\"1\",\"Name\":\"c13\"},{\"Type\":\"2\",\"ColId\":\"15\",\"bytes\":\"1\",\"Name\":\"t1\"},{\"Type\":\"3\",\"ColId\":\"16\",\"bytes\":\"2\",\"Name\":\"t2\"},{\"Type\":\"4\",\"ColId\":\"17\",\"bytes\":\"4\",\"Name\":\"t3\"},{\"Type\":\"5\",\"ColId\":\"18\",\"bytes\":\"8\",\"Name\":\"t4\"},{\"Type\":\"11\",\"ColId\":\"19\",\"bytes\":\"1\",\"Name\":\"t5\"},{\"Type\":\"12\",\"ColId\":\"20\",\"bytes\":\"2\",\"Name\":\"t6\"},{\"Type\":\"13\",\"ColId\":\"21\",\"bytes\":\"4\",\"Name\":\"t7\"},{\"Type\":\"14\",\"ColId\":\"22\",\"bytes\":\"8\",\"Name\":\"t8\"},{\"Type\":\"6\",\"ColId\":\"23\",\"bytes\":\"4\",\"Name\":\"t9\"},{\"Type\":\"7\",\"ColId\":\"24\",\"bytes\":\"8\",\"Name\":\"t10\"},{\"Type\":\"8\",\"ColId\":\"25\",\"bytes\":\"8\",\"Name\":\"t11\"},{\"Type\":\"10\",\"ColId\":\"26\",\"bytes\":\"26\",\"Name\":\"t12\"},{\"Type\":\"1\",\"ColId\":\"27\",\"bytes\":\"1\",\"Name\":\"t13\"}]},\"VgroupsInfoSize\":\"1340\",\"VgroupsInfo\":{\"Num\":\"2\",\"Vgroups\":[{\"VgId\":\"14\",\"HashBegin\":\"0\",\"HashEnd\":\"2147483646\",\"EpSet\":{\"InUse\":\"0\",\"NumOfEps\":\"1\",\"Eps\":[{\"Fqdn\":\"localhost\",\"Port\":\"6030\"}]},\"NumOfTable\":\"0\"},{\"VgId\":\"15\",\"HashBegin\":\"2147483647\",\"HashEnd\":\"4294967295\",\"EpSet\":{\"InUse\":\"0\",\"NumOfEps\":\"1\",\"Eps\":[{\"Fqdn\":\"localhost\",\"Port\":\"6030\"}]},\"NumOfTable\":\"0\"}]}}},\"Tags\":[{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"0\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":false,\"NotReserved\":false,\"IsNull\":true,\"Unit\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"0\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":false,\"NotReserved\":false,\"IsNull\":true,\"Unit\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"0\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":false,\"NotReserved\":false,\"IsNull\":true,\"Unit\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"0\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":false,\"NotReserved\":false,\"IsNull\":true,\"Unit\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"0\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":false,\"NotReserved\":false,\"IsNull\":true,\"Unit\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"0\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":false,\"NotReserved\":false,\"IsNull\":true,\"Unit\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"0\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":false,\"NotReserved\":false,\"IsNull\":true,\"Unit\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"0\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":false,\"NotReserved\":false,\"IsNull\":true,\"Unit\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"0\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":false,\"NotReserved\":false,\"IsNull\":true,\"Unit\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"0\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":false,\"NotReserved\":false,\"IsNull\":true,\"Unit\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"0\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":false,\"NotReserved\":false,\"IsNull\":true,\"Unit\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"0\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":false,\"NotReserved\":false,\"IsNull\":true,\"Unit\":\"0\"}},{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"0\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"1\"},\"AliasName\":\"\",\"UserAlias\":\"\",\"LiteralSize\":\"0\",\"Duration\":false,\"Translate\":false,\"NotReserved\":false,\"IsNull\":true,\"Unit\":\"0\"}}],\"Window\":{\"NodeType\":\"14\",\"Name\":\"IntervalWindow\",\"IntervalWindow\":{\"Interval\":{\"NodeType\":\"2\",\"Name\":\"Value\",\"Value\":{\"DataType\":{\"Type\":\"5\",\"Precision\":\"0\",\"Scale\":\"115\",\"Bytes\":\"8\"},\"AliasName\":\"1fd7635317edfeca9054894ac9ef9b5e\",\"UserAlias\":\"14s\",\"LiteralSize\":\"3\",\"Literal\":\"14s\",\"Duration\":true,\"Translate\":true,\"NotReserved\":false,\"IsNull\":false,\"Unit\":\"115\",\"Datum\":\"14000\"}},\"TsPk\":{\"NodeType\":\"1\",\"Name\":\"Column\",\"Column\":{\"DataType\":{\"Type\":\"9\",\"Precision\":\"0\",\"Scale\":\"0\",\"Bytes\":\"8\"},\"AliasName\":\"ts\",\"UserAlias\":\"ts\",\"TableId\":\"5129202035162885657\",\"TableType\":\"1\",\"ColId\":\"1\",\"ProjId\":\"0\",\"ColType\":\"1\",\"DbName\":\"test\",\"TableName\":\"at_once_interval_ext_stb\",\"TableAlias\":\"at_once_interval_ext_stb\",\"ColName\":\"ts\",\"DataBlockId\":\"0\",\"SlotId\":\"0\"}}}},\"StmtName\":\"0x150146d14\",\"HasAggFuncs\":true}}"; + SNode * pAst = NULL; + SQueryPlan *pPlan = NULL; + + if (taosCreateLog("taoslog", 10, "/etc/taos", NULL, NULL, NULL, NULL, 1) != 0) { + // ignore create log failed, only print + printf(" WARING: Create failed:%s. configDir\n", strerror(errno)); + } + + if (nodesStringToNode(ast, &pAst) < 0) { + ASSERT(0); + } + + SPlanContext cxt = { 0 }; + cxt.pAstRoot = pAst; + cxt.topicQuery = false; + cxt.streamQuery = true; + cxt.triggerType = STREAM_TRIGGER_WINDOW_CLOSE; + cxt.watermark = 1; + cxt.igExpired = 1; + cxt.deleteMark = 1; + cxt.igCheckUpdate = 1; + + // using ast and param to build physical plan + if (qCreateQueryPlan(&cxt, &pPlan, NULL) < 0) { + ASSERT(0); + } + if (pAst != NULL) nodesDestroyNode(pAst); + nodesDestroyNode((SNode *)pPlan); +} + #pragma GCC diagnostic pop \ No newline at end of file diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 3c334be2f2..294e75602e 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -223,7 +223,7 @@ bool tqReaderIsQueriedTable(STqReader *pReader, uint64_t uid); bool tqCurrentBlockConsumed(const STqReader *pReader); int32_t tqReaderSeek(STqReader *pReader, int64_t ver, const char *id); -bool tqNextBlockInWal(STqReader *pReader, const char *idstr); +bool tqNextBlockInWal(STqReader *pReader, const char *idstr, int sourceExcluded); bool tqNextBlockImpl(STqReader *pReader, const char *idstr); SWalReader *tqGetWalReader(STqReader *pReader); SSDataBlock *tqGetResultBlock(STqReader *pReader); diff --git a/source/dnode/vnode/src/inc/tq.h b/source/dnode/vnode/src/inc/tq.h index 475a26aff5..2a076cfc61 100644 --- a/source/dnode/vnode/src/inc/tq.h +++ b/source/dnode/vnode/src/inc/tq.h @@ -118,7 +118,7 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* int32_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, uint64_t reqId); // tqExec -int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp, int32_t* totalRows); +int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp, int32_t* totalRows, int8_t sourceExcluded); int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision); int32_t tqSendDataRsp(STqHandle* pHandle, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp, int32_t type, int32_t vgId); diff --git a/source/dnode/vnode/src/meta/metaOpen.c b/source/dnode/vnode/src/meta/metaOpen.c index c09253dd6a..8055d6e139 100644 --- a/source/dnode/vnode/src/meta/metaOpen.c +++ b/source/dnode/vnode/src/meta/metaOpen.c @@ -27,7 +27,14 @@ static int taskIdxKeyCmpr(const void *pKey1, int kLen1, const void *pKey2, int k static int btimeIdxCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2); static int ncolIdxCmpr(const void *pKey1, int kLen1, const void *pKey2, int kLen2); -static int32_t metaInitLock(SMeta *pMeta) { return taosThreadRwlockInit(&pMeta->lock, NULL); } +static int32_t metaInitLock(SMeta *pMeta) { + TdThreadRwlockAttr attr; + taosThreadRwlockAttrInit(&attr); + taosThreadRwlockAttrSetKindNP(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP); + taosThreadRwlockInit(&pMeta->lock, &attr); + taosThreadRwlockAttrDestroy(&attr); + return 0; +} static int32_t metaDestroyLock(SMeta *pMeta) { return taosThreadRwlockDestroy(&pMeta->lock); } static void metaCleanup(SMeta **ppMeta); diff --git a/source/dnode/vnode/src/sma/smaTimeRange.c b/source/dnode/vnode/src/sma/smaTimeRange.c index 767ea47e21..54d859992c 100644 --- a/source/dnode/vnode/src/sma/smaTimeRange.c +++ b/source/dnode/vnode/src/sma/smaTimeRange.c @@ -193,7 +193,7 @@ int32_t smaBlockToSubmit(SVnode *pVnode, const SArray *pBlocks, const STSchema * continue; } - SSubmitTbData tbData = {.suid = suid, .uid = 0, .sver = pTSchema->version, .flags = SUBMIT_REQ_AUTO_CREATE_TABLE,}; + SSubmitTbData tbData = {.suid = suid, .uid = 0, .sver = pTSchema->version, .flags = SUBMIT_REQ_AUTO_CREATE_TABLE, .source = SOURCE_NULL}; int32_t cid = taosArrayGetSize(pDataBlock->pDataBlock) + 1; tbData.pCreateTbReq = buildAutoCreateTableReq(stbFullName, suid, cid, pDataBlock, tagArray, true); diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 8392f4c479..3ae007ce34 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -368,7 +368,7 @@ int32_t extractMsgFromWal(SWalReader* pReader, void** pItem, int64_t maxVer, con } // todo ignore the error in wal? -bool tqNextBlockInWal(STqReader* pReader, const char* id) { +bool tqNextBlockInWal(STqReader* pReader, const char* id, int sourceExcluded) { SWalReader* pWalReader = pReader->pWalReader; SSDataBlock* pDataBlock = NULL; @@ -391,7 +391,10 @@ bool tqNextBlockInWal(STqReader* pReader, const char* id) { numOfBlocks, pReader->msg.msgLen, pReader->msg.ver); SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk); - + if ((pSubmitTbData->source & sourceExcluded) != 0){ + pReader->nextBlk += 1; + continue; + } if (pReader->tbIdHash == NULL || taosHashGet(pReader->tbIdHash, &pSubmitTbData->uid, sizeof(int64_t)) != NULL) { tqTrace("tq reader return submit block, uid:%" PRId64, pSubmitTbData->uid); SSDataBlock* pRes = NULL; diff --git a/source/dnode/vnode/src/tq/tqScan.c b/source/dnode/vnode/src/tq/tqScan.c index 5432637482..d86c0a0474 100644 --- a/source/dnode/vnode/src/tq/tqScan.c +++ b/source/dnode/vnode/src/tq/tqScan.c @@ -93,6 +93,7 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* return -1; } + qStreamSetSourceExcluded(task, pRequest->sourceExcluded); while (1) { SSDataBlock* pDataBlock = NULL; code = getDataBlock(task, pHandle, vgId, &pDataBlock); @@ -249,7 +250,7 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta return 0; } -int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp, int32_t* totalRows) { +int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp, int32_t* totalRows, int8_t sourceExcluded) { STqExecHandle* pExec = &pHandle->execHandle; SArray* pBlocks = taosArrayInit(0, sizeof(SSDataBlock)); SArray* pSchemas = taosArrayInit(0, sizeof(void*)); @@ -264,6 +265,10 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR if (tqRetrieveTaosxBlock(pReader, pBlocks, pSchemas, &pSubmitTbDataRet) < 0) { if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) goto loop_table; } + + if ((pSubmitTbDataRet->source & sourceExcluded) != 0){ + goto loop_table; + } if (pRsp->withTbName) { int64_t uid = pExec->pTqReader->lastBlkUid; if (tqAddTbNameToRsp(pTq, uid, pRsp, taosArrayGetSize(pBlocks)) < 0) { @@ -328,6 +333,10 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR if (tqRetrieveTaosxBlock(pReader, pBlocks, pSchemas, &pSubmitTbDataRet) < 0) { if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) goto loop_db; } + + if ((pSubmitTbDataRet->source & sourceExcluded) != 0){ + goto loop_db; + } if (pRsp->withTbName) { int64_t uid = pExec->pTqReader->lastBlkUid; if (tqAddTbNameToRsp(pTq, uid, pRsp, taosArrayGetSize(pBlocks)) < 0) { diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index 7050870c57..b438b2dc0a 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -815,7 +815,7 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) { return; } - SSubmitTbData tbData = {.suid = suid, .uid = 0, .sver = pTSchema->version}; + SSubmitTbData tbData = {.suid = suid, .uid = 0, .sver = pTSchema->version, .source = SOURCE_NULL}; code = setDstTableDataUid(pVnode, pTask, pDataBlock, stbFullName, &tbData); if (code != TSDB_CODE_SUCCESS) { continue; @@ -859,7 +859,7 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) { pTask->execInfo.sink.numOfBlocks += 1; uint64_t groupId = pDataBlock->info.id.groupId; - SSubmitTbData tbData = {.suid = suid, .uid = 0, .sver = pTSchema->version}; + SSubmitTbData tbData = {.suid = suid, .uid = 0, .sver = pTSchema->version, .source = SOURCE_NULL}; int32_t* index = taosHashGet(pTableIndexMap, &groupId, sizeof(groupId)); if (index == NULL) { // no data yet, append it diff --git a/source/dnode/vnode/src/tq/tqUtil.c b/source/dnode/vnode/src/tq/tqUtil.c index b9f578a74b..72a73c0ff2 100644 --- a/source/dnode/vnode/src/tq/tqUtil.c +++ b/source/dnode/vnode/src/tq/tqUtil.c @@ -250,7 +250,7 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, .ver = pHead->version, }; - code = tqTaosxScanLog(pTq, pHandle, submit, &taosxRsp, &totalRows); + code = tqTaosxScanLog(pTq, pHandle, submit, &taosxRsp, &totalRows, pRequest->sourceExcluded); if (code < 0) { tqError("tmq poll: tqTaosxScanLog error %" PRId64 ", in vgId:%d, subkey %s", pRequest->consumerId, vgId, pRequest->subKey); diff --git a/source/dnode/vnode/src/tqCommon/tqCommon.c b/source/dnode/vnode/src/tqCommon/tqCommon.c index c4973b7c1e..9a22bc303b 100644 --- a/source/dnode/vnode/src/tqCommon/tqCommon.c +++ b/source/dnode/vnode/src/tqCommon/tqCommon.c @@ -317,15 +317,25 @@ int32_t tqStreamTaskProcessRetrieveReq(SStreamMeta* pMeta, SRpcMsg* pMsg) { if (pTask == NULL) { tqError("vgId:%d process retrieve req, failed to acquire task:0x%x, it may have been dropped already", pMeta->vgId, req.dstTaskId); + taosMemoryFree(req.pRetrieve); return -1; } + int32_t code = 0; + if(pTask->info.taskLevel == TASK_LEVEL__SOURCE){ + code = streamProcessRetrieveReq(pTask, &req); + }else{ + req.srcNodeId = pTask->info.nodeId; + req.srcTaskId = pTask->id.taskId; + code = broadcastRetrieveMsg(pTask, &req); + } + SRpcMsg rsp = {.info = pMsg->info, .code = 0}; - streamProcessRetrieveReq(pTask, &req, &rsp); + sendRetrieveRsp(&req, &rsp); streamMetaReleaseTask(pMeta, pTask); - tDeleteStreamRetrieveReq(&req); - return 0; + taosMemoryFree(req.pRetrieve); + return code; } int32_t tqStreamTaskProcessCheckReq(SStreamMeta* pMeta, SRpcMsg* pMsg) { diff --git a/source/libs/executor/inc/executorInt.h b/source/libs/executor/inc/executorInt.h index fa178b6488..3306cb3b53 100644 --- a/source/libs/executor/inc/executorInt.h +++ b/source/libs/executor/inc/executorInt.h @@ -556,6 +556,11 @@ typedef struct SStreamIntervalOperatorInfo { bool reCkBlock; SSDataBlock* pCheckpointRes; struct SUpdateInfo* pUpdateInfo; + bool recvRetrive; + SSDataBlock* pMidRetriveRes; + bool recvPullover; + SSDataBlock* pMidPulloverRes; + bool clearState; } SStreamIntervalOperatorInfo; typedef struct SDataGroupInfo { diff --git a/source/libs/executor/inc/querytask.h b/source/libs/executor/inc/querytask.h index fcafd5a4e3..0c9a5e3197 100644 --- a/source/libs/executor/inc/querytask.h +++ b/source/libs/executor/inc/querytask.h @@ -59,6 +59,7 @@ typedef struct STaskStopInfo { typedef struct { STqOffsetVal currentOffset; // for tmq SMqMetaRsp metaRsp; // for tmq fetching meta + int8_t sourceExcluded; int64_t snapshotVer; SSchemaWrapper* schema; char tbName[TSDB_TABLE_NAME_LEN]; // this is the current scan table: todo refactor diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 1751109ff3..8bd83ee0fb 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -2229,6 +2229,8 @@ char* getStreamOpName(uint16_t opType) { return "interval final"; case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: return "interval semi"; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL: + return "interval mid"; case QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL: return "stream fill"; case QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION: diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index fc0589031a..6d80b79d9d 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -947,7 +947,7 @@ int32_t qSetStreamOperatorOptionForScanHistory(qTaskInfo_t tinfo) { while (1) { int32_t type = pOperator->operatorType; if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL || type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL || - type == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL) { + type == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL || type == QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL) { SStreamIntervalOperatorInfo* pInfo = pOperator->info; STimeWindowAggSupp* pSup = &pInfo->twAggSup; @@ -1035,7 +1035,7 @@ int32_t qRestoreStreamOperatorOption(qTaskInfo_t tinfo) { while (1) { uint16_t type = pOperator->operatorType; if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL || type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL || - type == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL) { + type == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL || type == QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL) { SStreamIntervalOperatorInfo* pInfo = pOperator->info; pInfo->twAggSup.calTrigger = pInfo->twAggSup.calTriggerSaved; pInfo->twAggSup.deleteMark = pInfo->twAggSup.deleteMarkSaved; @@ -1152,6 +1152,11 @@ void qStreamSetOpen(qTaskInfo_t tinfo) { pOperator->status = OP_NOT_OPENED; } +void qStreamSetSourceExcluded(qTaskInfo_t tinfo, int8_t sourceExcluded) { + SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; + pTaskInfo->streamInfo.sourceExcluded = sourceExcluded; +} + int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subType) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; SStorageAPI* pAPI = &pTaskInfo->storageAPI; diff --git a/source/libs/executor/src/operator.c b/source/libs/executor/src/operator.c index 69a8acb3d7..fd4b3cd7db 100644 --- a/source/libs/executor/src/operator.c +++ b/source/libs/executor/src/operator.c @@ -489,6 +489,9 @@ SOperatorInfo* createOperator(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SR } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL == type) { int32_t children = 0; pOptr = createStreamFinalIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo, children, pHandle); + } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL == type) { + int32_t children = pHandle->numOfVgroups; + pOptr = createStreamFinalIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo, children, pHandle); } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL == type) { int32_t children = pHandle->numOfVgroups; pOptr = createStreamFinalIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo, children, pHandle); diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index d54fb27224..cb6ec56235 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -1272,6 +1272,7 @@ static bool isStateWindow(SStreamScanInfo* pInfo) { static bool isIntervalWindow(SStreamScanInfo* pInfo) { return pInfo->windowSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL || pInfo->windowSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL || + pInfo->windowSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL || pInfo->windowSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL; } @@ -2010,7 +2011,7 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { if (pTaskInfo->streamInfo.currentOffset.type == TMQ_OFFSET__LOG) { while (1) { - bool hasResult = pAPI->tqReaderFn.tqReaderNextBlockInWal(pInfo->tqReader, id); + bool hasResult = pAPI->tqReaderFn.tqReaderNextBlockInWal(pInfo->tqReader, id, pTaskInfo->streamInfo.sourceExcluded); SSDataBlock* pRes = pAPI->tqReaderFn.tqGetResultBlock(pInfo->tqReader); struct SWalReader* pWalReader = pAPI->tqReaderFn.tqReaderGetWalReader(pInfo->tqReader); diff --git a/source/libs/executor/src/streamtimewindowoperator.c b/source/libs/executor/src/streamtimewindowoperator.c index f26ff7156b..b3f18d08ac 100644 --- a/source/libs/executor/src/streamtimewindowoperator.c +++ b/source/libs/executor/src/streamtimewindowoperator.c @@ -28,6 +28,7 @@ #include "ttime.h" #define IS_FINAL_INTERVAL_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL) +#define IS_MID_INTERVAL_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL) #define IS_FINAL_SESSION_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION) #define DEAULT_DELETE_MARK INT64_MAX #define STREAM_INTERVAL_OP_STATE_NAME "StreamIntervalHistoryState" @@ -48,6 +49,8 @@ typedef struct SPullWindowInfo { STimeWindow calWin; } SPullWindowInfo; +static SSDataBlock* doStreamMidIntervalAgg(SOperatorInfo* pOperator); + typedef int32_t (*__compare_fn_t)(void* pKey, void* data, int32_t index); static int32_t binarySearchCom(void* keyList, int num, void* pKey, int order, __compare_fn_t comparefn) { @@ -235,7 +238,7 @@ static void doDeleteWindows(SOperatorInfo* pOperator, SInterval* pInterval, SSDa dumyInfo.cur.pageId = -1; STimeWindow win = {0}; - if (IS_FINAL_INTERVAL_OP(pOperator)) { + if (IS_FINAL_INTERVAL_OP(pOperator) || IS_MID_INTERVAL_OP(pOperator)) { win.skey = startTsCols[i]; win.ekey = endTsCols[i]; } else { @@ -407,6 +410,8 @@ void destroyStreamFinalIntervalOperatorInfo(void* param) { blockDataDestroy(pInfo->pPullDataRes); taosArrayDestroy(pInfo->pDelWins); blockDataDestroy(pInfo->pDelRes); + blockDataDestroy(pInfo->pMidRetriveRes); + blockDataDestroy(pInfo->pMidPulloverRes); pInfo->stateStore.streamFileStateDestroy(pInfo->pState->pFileState); if (pInfo->pState->dump == 1) { @@ -599,7 +604,7 @@ static void doBuildPullDataBlock(SArray* array, int32_t* pIndex, SSDataBlock* pB blockDataUpdateTsWindow(pBlock, 0); } -void processPullOver(SSDataBlock* pBlock, SHashObj* pMap, SHashObj* pFinalMap, SInterval* pInterval, SArray* pPullWins, +static bool processPullOver(SSDataBlock* pBlock, SHashObj* pMap, SHashObj* pFinalMap, SInterval* pInterval, SArray* pPullWins, int32_t numOfCh, SOperatorInfo* pOperator) { SColumnInfoData* pStartCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX); TSKEY* tsData = (TSKEY*)pStartCol->pData; @@ -608,6 +613,7 @@ void processPullOver(SSDataBlock* pBlock, SHashObj* pMap, SHashObj* pFinalMap, S SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); uint64_t* groupIdData = (uint64_t*)pGroupCol->pData; int32_t chId = getChildIndex(pBlock); + bool res = false; for (int32_t i = 0; i < pBlock->info.rows; i++) { TSKEY winTs = tsData[i]; while (winTs <= tsEndData[i]) { @@ -623,6 +629,7 @@ void processPullOver(SSDataBlock* pBlock, SHashObj* pMap, SHashObj* pFinalMap, S // pull data is over taosArrayDestroy(chArray); taosHashRemove(pMap, &winRes, sizeof(SWinKey)); + res =true; qDebug("===stream===retrive pull data over.window %" PRId64, winRes.ts); void* pFinalCh = taosHashGet(pFinalMap, &winRes, sizeof(SWinKey)); @@ -646,6 +653,7 @@ void processPullOver(SSDataBlock* pBlock, SHashObj* pMap, SHashObj* pFinalMap, S winTs = taosTimeAdd(winTs, pInterval->sliding, pInterval->slidingUnit, pInterval->precision); } } + return res; } static void addRetriveWindow(SArray* wins, SStreamIntervalOperatorInfo* pInfo, int32_t childId) { @@ -1182,6 +1190,12 @@ static SSDataBlock* buildIntervalResult(SOperatorInfo* pOperator) { printDataBlock(pInfo->binfo.pRes, getStreamOpName(opType), GET_TASKID(pTaskInfo)); return pInfo->binfo.pRes; } + + if (pInfo->recvPullover) { + pInfo->recvPullover = false; + printDataBlock(pInfo->pMidPulloverRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pInfo->pMidPulloverRes; + } return NULL; } @@ -1236,11 +1250,15 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { return NULL; } else { if (!IS_FINAL_INTERVAL_OP(pOperator)) { - doBuildDeleteResult(pInfo, pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes); - if (pInfo->pDelRes->info.rows != 0) { - // process the rest of the data - printDataBlock(pInfo->pDelRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); - return pInfo->pDelRes; + SSDataBlock* resBlock = buildIntervalResult(pOperator); + if (resBlock != NULL) { + return resBlock; + } + + if (pInfo->recvRetrive) { + pInfo->recvRetrive = false; + printDataBlock(pInfo->pMidRetriveRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pInfo->pMidRetriveRes; } } } @@ -1314,9 +1332,12 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { pInfo->recvGetAll = true; getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pInfo->pUpdatedMap); continue; - } else if (pBlock->info.type == STREAM_RETRIEVE && !IS_FINAL_INTERVAL_OP(pOperator)) { - doDeleteWindows(pOperator, &pInfo->interval, pBlock, NULL, pInfo->pUpdatedMap); - if (taosArrayGetSize(pInfo->pUpdated) > 0) { + } else if (pBlock->info.type == STREAM_RETRIEVE) { + if(!IS_FINAL_INTERVAL_OP(pOperator)) { + pInfo->recvRetrive = true; + copyDataBlock(pInfo->pMidRetriveRes, pBlock); + pInfo->pMidRetriveRes->info.type = STREAM_MID_RETRIEVE; + doDeleteWindows(pOperator, &pInfo->interval, pBlock, NULL, pInfo->pUpdatedMap); break; } continue; @@ -1331,6 +1352,8 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { doStreamIntervalSaveCheckpoint(pOperator); copyDataBlock(pInfo->pCheckpointRes, pBlock); continue; + } else if (IS_FINAL_INTERVAL_OP(pOperator) && pBlock->info.type == STREAM_MID_RETRIEVE) { + continue; } else { ASSERTS(pBlock->info.type == STREAM_INVALID, "invalid SSDataBlock type"); } @@ -1359,7 +1382,18 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { pInfo->pUpdated = NULL; blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity); - return buildIntervalResult(pOperator); + SSDataBlock* resBlock = buildIntervalResult(pOperator); + if (resBlock != NULL) { + return resBlock; + } + + if (pInfo->recvRetrive) { + pInfo->recvRetrive = false; + printDataBlock(pInfo->pMidRetriveRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pInfo->pMidRetriveRes; + } + + return NULL; } int64_t getDeleteMark(SWindowPhysiNode* pWinPhyNode, int64_t interval) { @@ -1400,7 +1434,8 @@ static int32_t getMaxFunResSize(SExprSupp* pSup, int32_t numOfCols) { } static void streamIntervalReleaseState(SOperatorInfo* pOperator) { - if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL) { + if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL && + pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL) { SStreamIntervalOperatorInfo* pInfo = pOperator->info; int32_t resSize = sizeof(TSKEY); pInfo->stateStore.streamStateSaveInfo(pInfo->pState, STREAM_INTERVAL_OP_STATE_NAME, @@ -1417,7 +1452,8 @@ static void streamIntervalReleaseState(SOperatorInfo* pOperator) { void streamIntervalReloadState(SOperatorInfo* pOperator) { SStreamIntervalOperatorInfo* pInfo = pOperator->info; - if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL) { + if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL && + pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL) { int32_t size = 0; void* pBuf = NULL; int32_t code = pInfo->stateStore.streamStateGetInfo(pInfo->pState, STREAM_INTERVAL_OP_STATE_NAME, @@ -1442,6 +1478,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode; SStreamIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamIntervalOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + int32_t code = 0; if (pInfo == NULL || pOperator == NULL) { goto _error; } @@ -1471,7 +1508,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, if (pIntervalPhyNode->window.pExprs != NULL) { int32_t numOfScalar = 0; SExprInfo* pScalarExprInfo = createExprInfo(pIntervalPhyNode->window.pExprs, NULL, &numOfScalar); - int32_t code = initExprSupp(&pInfo->scalarSupp, pScalarExprInfo, numOfScalar, &pTaskInfo->storageAPI.functionStore); + code = initExprSupp(&pInfo->scalarSupp, pScalarExprInfo, numOfScalar, &pTaskInfo->storageAPI.functionStore); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -1490,7 +1527,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, qInfo("copy state %p to %p", pTaskInfo->streamInfo.pState, pInfo->pState); pAPI->stateStore.streamStateSetNumber(pInfo->pState, -1); - int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str, + code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str, pInfo->pState, &pTaskInfo->storageAPI.functionStore); if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -1526,6 +1563,10 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, pInfo->stateStore = pTaskInfo->storageAPI.stateStore; pInfo->recvGetAll = false; pInfo->pCheckpointRes = createSpecialDataBlock(STREAM_CHECKPOINT); + pInfo->recvRetrive = false; + pInfo->pMidRetriveRes = createSpecialDataBlock(STREAM_MID_RETRIEVE); + pInfo->pMidPulloverRes = createSpecialDataBlock(STREAM_MID_RETRIEVE); + pInfo->clearState = false; pOperator->operatorType = pPhyNode->type; if (!IS_FINAL_INTERVAL_OP(pOperator) || numOfChild == 0) { @@ -1536,10 +1577,16 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, pOperator->status = OP_NOT_OPENED; pOperator->info = pInfo; - pOperator->fpSet = createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, destroyStreamFinalIntervalOperatorInfo, - optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL); + if (pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL) { + pOperator->fpSet = createOperatorFpSet(NULL, doStreamMidIntervalAgg, NULL, destroyStreamFinalIntervalOperatorInfo, + optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL); + } else { + pOperator->fpSet = createOperatorFpSet(NULL, doStreamFinalIntervalAgg, NULL, destroyStreamFinalIntervalOperatorInfo, + optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL); + } setOperatorStreamStateFn(pOperator, streamIntervalReleaseState, streamIntervalReloadState); - if (pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL) { + if (pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL || + pPhyNode->type == QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL) { initIntervalDownStream(downstream, pPhyNode->type, pInfo); } code = appendDownstream(pOperator, &downstream, 1); @@ -4114,6 +4161,285 @@ _error: return NULL; } +static void doStreamMidIntervalAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBlock, SSHashObj* pUpdatedMap) { + SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperator->info; + pInfo->dataVersion = TMAX(pInfo->dataVersion, pSDataBlock->info.version); + + SResultRowInfo* pResultRowInfo = &(pInfo->binfo.resultRowInfo); + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SExprSupp* pSup = &pOperator->exprSupp; + int32_t numOfOutput = pSup->numOfExprs; + int32_t step = 1; + SRowBuffPos* pResPos = NULL; + SResultRow* pResult = NULL; + int32_t forwardRows = 1; + uint64_t groupId = pSDataBlock->info.id.groupId; + SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); + TSKEY* tsCol = (int64_t*)pColDataInfo->pData; + + int32_t startPos = 0; + TSKEY ts = getStartTsKey(&pSDataBlock->info.window, tsCol); + STimeWindow nextWin = getFinalTimeWindow(ts, &pInfo->interval); + + while (1) { + SWinKey key = { + .ts = nextWin.skey, + .groupId = groupId, + }; + void* chIds = taosHashGet(pInfo->pPullDataMap, &key, sizeof(SWinKey)); + int32_t index = -1; + SArray* chArray = NULL; + int32_t chId = 0; + if (chIds) { + chArray = *(void**)chIds; + chId = getChildIndex(pSDataBlock); + index = taosArraySearchIdx(chArray, &chId, compareInt32Val, TD_EQ); + } + if (!(index == -1 || pSDataBlock->info.type == STREAM_PULL_DATA)) { + startPos = getNextQualifiedFinalWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCol, startPos); + if (startPos < 0) { + break; + } + continue; + } + + if (!inSlidingWindow(&pInfo->interval, &nextWin, &pSDataBlock->info)) { + startPos = getNexWindowPos(&pInfo->interval, &pSDataBlock->info, tsCol, startPos, nextWin.ekey, &nextWin); + if (startPos < 0) { + break; + } + continue; + } + + int32_t code = setIntervalOutputBuf(pInfo->pState, &nextWin, &pResPos, groupId, pSup->pCtx, numOfOutput, + pSup->rowEntryInfoOffset, &pInfo->aggSup, &pInfo->stateStore); + pResult = (SResultRow*)pResPos->pRowBuff; + if (code != TSDB_CODE_SUCCESS || pResult == NULL) { + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); + } + + if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) { + saveWinResult(&key, pResPos, pUpdatedMap); + } + + if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) { + tSimpleHashPut(pInfo->aggSup.pResultRowHashTable, &key, sizeof(SWinKey), &pResPos, POINTER_BYTES); + } + + updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, 1); + applyAggFunctionOnPartialTuples(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, + pSDataBlock->info.rows, numOfOutput); + key.ts = nextWin.skey; + + if (pInfo->delKey.ts > key.ts) { + pInfo->delKey = key; + } + int32_t prevEndPos = (forwardRows - 1) * step + startPos; + if (pSDataBlock->info.window.skey <= 0 || pSDataBlock->info.window.ekey <= 0) { + qError("table uid %" PRIu64 " data block timestamp range may not be calculated! minKey %" PRId64 + ",maxKey %" PRId64, + pSDataBlock->info.id.uid, pSDataBlock->info.window.skey, pSDataBlock->info.window.ekey); + blockDataUpdateTsWindow(pSDataBlock, 0); + + // timestamp of the data is incorrect + if (pSDataBlock->info.window.skey <= 0 || pSDataBlock->info.window.ekey <= 0) { + qError("table uid %" PRIu64 " data block timestamp is out of range! minKey %" PRId64 ",maxKey %" PRId64, + pSDataBlock->info.id.uid, pSDataBlock->info.window.skey, pSDataBlock->info.window.ekey); + } + } + startPos = getNextQualifiedFinalWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCol, prevEndPos); + if (startPos < 0) { + break; + } + } +} + +static void addMidRetriveWindow(SArray* wins, SHashObj* pMidPullMap, int32_t numOfChild) { + int32_t size = taosArrayGetSize(wins); + for (int32_t i = 0; i < size; i++) { + SWinKey* winKey = taosArrayGet(wins, i); + void* chIds = taosHashGet(pMidPullMap, winKey, sizeof(SWinKey)); + if (!chIds) { + addPullWindow(pMidPullMap, winKey, numOfChild); + qDebug("===stream===prepare mid operator retrive for delete %" PRId64 ", size:%d", winKey->ts, numOfChild); + } + } +} + +static SSDataBlock* doStreamMidIntervalAgg(SOperatorInfo* pOperator) { + SStreamIntervalOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SStorageAPI* pAPI = &pOperator->pTaskInfo->storageAPI; + SOperatorInfo* downstream = pOperator->pDownstream[0]; + SExprSupp* pSup = &pOperator->exprSupp; + + qDebug("stask:%s %s status: %d", GET_TASKID(pTaskInfo), getStreamOpName(pOperator->operatorType), pOperator->status); + + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } else if (pOperator->status == OP_RES_TO_RETURN) { + SSDataBlock* resBlock = buildIntervalResult(pOperator); + if (resBlock != NULL) { + return resBlock; + } + + setOperatorCompleted(pOperator); + clearFunctionContext(&pOperator->exprSupp); + clearStreamIntervalOperator(pInfo); + qDebug("stask:%s ===stream===%s clear", GET_TASKID(pTaskInfo), getStreamOpName(pOperator->operatorType)); + return NULL; + } else { + SSDataBlock* resBlock = buildIntervalResult(pOperator); + if (resBlock != NULL) { + return resBlock; + } + + if (pInfo->recvRetrive) { + pInfo->recvRetrive = false; + printDataBlock(pInfo->pMidRetriveRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pInfo->pMidRetriveRes; + } + + if (pInfo->clearState) { + pInfo->clearState = false; + clearFunctionContext(&pOperator->exprSupp); + clearStreamIntervalOperator(pInfo); + } + } + + if (!pInfo->pUpdated) { + pInfo->pUpdated = taosArrayInit(4096, POINTER_BYTES); + } + if (!pInfo->pUpdatedMap) { + _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); + pInfo->pUpdatedMap = tSimpleHashInit(4096, hashFn); + } + + while (1) { + if (isTaskKilled(pTaskInfo)) { + if (pInfo->pUpdated != NULL) { + pInfo->pUpdated = taosArrayDestroy(pInfo->pUpdated); + } + + if (pInfo->pUpdatedMap != NULL) { + tSimpleHashCleanup(pInfo->pUpdatedMap); + pInfo->pUpdatedMap = NULL; + } + + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); + } + + SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); + if (pBlock == NULL) { + pOperator->status = OP_RES_TO_RETURN; + qDebug("===stream===return data:%s. recv datablock num:%" PRIu64, getStreamOpName(pOperator->operatorType), + pInfo->numOfDatapack); + pInfo->numOfDatapack = 0; + break; + } + pInfo->numOfDatapack++; + printSpecDataBlock(pBlock, getStreamOpName(pOperator->operatorType), "recv", GET_TASKID(pTaskInfo)); + + if (pBlock->info.type == STREAM_NORMAL || pBlock->info.type == STREAM_PULL_DATA) { + pInfo->binfo.pRes->info.type = pBlock->info.type; + } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT || + pBlock->info.type == STREAM_CLEAR) { + SArray* delWins = taosArrayInit(8, sizeof(SWinKey)); + doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap); + removeResults(delWins, pInfo->pUpdatedMap); + taosArrayAddAll(pInfo->pDelWins, delWins); + taosArrayDestroy(delWins); + + doBuildDeleteResult(pInfo, pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes); + if (pInfo->pDelRes->info.rows != 0) { + // process the rest of the data + printDataBlock(pInfo->pDelRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + if (pBlock->info.type == STREAM_CLEAR) { + pInfo->pDelRes->info.type = STREAM_CLEAR; + } else { + pInfo->pDelRes->info.type = STREAM_DELETE_RESULT; + } + ASSERT(taosArrayGetSize(pInfo->pUpdated) == 0); + return pInfo->pDelRes; + } + continue; + } else if (pBlock->info.type == STREAM_CREATE_CHILD_TABLE) { + return pBlock; + } else if (pBlock->info.type == STREAM_PULL_OVER) { + pInfo->recvPullover = processPullOver(pBlock, pInfo->pPullDataMap, pInfo->pFinalPullDataMap, &pInfo->interval, + pInfo->pPullWins, pInfo->numOfChild, pOperator); + if (pInfo->recvPullover) { + copyDataBlock(pInfo->pMidPulloverRes, pBlock); + pInfo->clearState = true; + break; + } + continue; + } else if (pBlock->info.type == STREAM_CHECKPOINT) { + pAPI->stateStore.streamStateCommit(pInfo->pState); + doStreamIntervalSaveCheckpoint(pOperator); + copyDataBlock(pInfo->pCheckpointRes, pBlock); + continue; + } else if (pBlock->info.type == STREAM_MID_RETRIEVE) { + SArray* delWins = taosArrayInit(8, sizeof(SWinKey)); + doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap); + addMidRetriveWindow(delWins, pInfo->pPullDataMap, pInfo->numOfChild); + taosArrayDestroy(delWins); + pInfo->recvRetrive = true; + copyDataBlock(pInfo->pMidRetriveRes, pBlock); + pInfo->pMidRetriveRes->info.type = STREAM_MID_RETRIEVE; + pInfo->clearState = true; + break; + } else { + ASSERTS(pBlock->info.type == STREAM_INVALID, "invalid SSDataBlock type"); + } + + if (pInfo->scalarSupp.pExprInfo != NULL) { + SExprSupp* pExprSup = &pInfo->scalarSupp; + projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL); + } + setInputDataBlock(pSup, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true); + doStreamMidIntervalAggImpl(pOperator, pBlock, pInfo->pUpdatedMap); + pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey); + pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.watermark); + pInfo->twAggSup.minTs = TMIN(pInfo->twAggSup.minTs, pBlock->info.window.skey); + } + + removeDeleteResults(pInfo->pUpdatedMap, pInfo->pDelWins); + pInfo->binfo.pRes->info.watermark = pInfo->twAggSup.maxTs; + + void* pIte = NULL; + int32_t iter = 0; + while ((pIte = tSimpleHashIterate(pInfo->pUpdatedMap, pIte, &iter)) != NULL) { + taosArrayPush(pInfo->pUpdated, pIte); + } + + tSimpleHashCleanup(pInfo->pUpdatedMap); + pInfo->pUpdatedMap = NULL; + taosArraySort(pInfo->pUpdated, winPosCmprImpl); + + initMultiResInfoFromArrayList(&pInfo->groupResInfo, pInfo->pUpdated); + pInfo->pUpdated = NULL; + blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity); + + SSDataBlock* resBlock = buildIntervalResult(pOperator); + if (resBlock != NULL) { + return resBlock; + } + + if (pInfo->recvRetrive) { + pInfo->recvRetrive = false; + printDataBlock(pInfo->pMidRetriveRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pInfo->pMidRetriveRes; + } + + if (pInfo->clearState) { + pInfo->clearState = false; + clearFunctionContext(&pOperator->exprSupp); + clearStreamIntervalOperator(pInfo); + } + return NULL; +} + void setStreamOperatorCompleted(SOperatorInfo* pOperator) { setOperatorCompleted(pOperator); qDebug("stask:%s %s status: %d. set completed", GET_TASKID(pOperator->pTaskInfo), getStreamOpName(pOperator->operatorType), pOperator->status); diff --git a/source/libs/function/inc/builtins.h b/source/libs/function/inc/builtins.h index 6181a9b929..4c1e46dbba 100644 --- a/source/libs/function/inc/builtins.h +++ b/source/libs/function/inc/builtins.h @@ -45,6 +45,7 @@ typedef struct SBuiltinFuncDefinition { #endif FExecCombine combineFunc; const char* pPartialFunc; + const char* pMiddleFunc; const char* pMergeFunc; FCreateMergeFuncParameters createMergeParaFuc; FEstimateReturnRows estimateReturnRowsFunc; diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index ac26f6fe26..b4af77fafc 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -433,6 +433,20 @@ static int32_t translateAvgPartial(SFunctionNode* pFunc, char* pErrBuf, int32_t return TSDB_CODE_SUCCESS; } +static int32_t translateAvgMiddle(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + if (TSDB_DATA_TYPE_BINARY != paraType) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType){.bytes = getAvgInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; + return TSDB_CODE_SUCCESS; +} + static int32_t translateAvgMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { if (1 != LIST_LENGTH(pFunc->pParameterList)) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); @@ -2515,6 +2529,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { #endif .combineFunc = avgCombine, .pPartialFunc = "_avg_partial", + .pMiddleFunc = "_avg_middle", .pMergeFunc = "_avg_merge" }, { @@ -3775,6 +3790,21 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .sprocessFunc = toCharFunction, .finalizeFunc = NULL }, + { + .name = "_avg_middle", + .type = FUNCTION_TYPE_AVG_PARTIAL, + .classification = FUNC_MGT_AGG_FUNC, + .translateFunc = translateAvgMiddle, + .dataRequiredFunc = statisDataRequired, + .getEnvFunc = getAvgFuncEnv, + .initFunc = avgFunctionSetup, + .processFunc = avgFunctionMerge, + .finalizeFunc = avgPartialFinalize, +#ifdef BUILD_NO_CALL + .invertFunc = avgInvertFunction, +#endif + .combineFunc = avgCombine, + }, { .name = "_vgver", .type = FUNCTION_TYPE_VGVER, @@ -3785,7 +3815,6 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .sprocessFunc = qPseudoTagFunction, .finalizeFunc = NULL } - }; // clang-format on diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index 7bb863839a..068d1532c0 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -424,6 +424,35 @@ static int32_t createMergeFuncPara(const SFunctionNode* pSrcFunc, const SFunctio } } +static int32_t createMidFunction(const SFunctionNode* pSrcFunc, const SFunctionNode* pPartialFunc, + SFunctionNode** pMidFunc) { + SNodeList* pParameterList = NULL; + SFunctionNode* pFunc = NULL; + + int32_t code = createMergeFuncPara(pSrcFunc, pPartialFunc, &pParameterList); + if (TSDB_CODE_SUCCESS == code) { + if(funcMgtBuiltins[pSrcFunc->funcId].pMiddleFunc != NULL){ + pFunc = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pMiddleFunc, pParameterList); + }else{ + pFunc = createFunction(funcMgtBuiltins[pSrcFunc->funcId].pMergeFunc, pParameterList); + } + if (NULL == pFunc) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + if (TSDB_CODE_SUCCESS == code) { + strcpy(pFunc->node.aliasName, pPartialFunc->node.aliasName); + } + + if (TSDB_CODE_SUCCESS == code) { + *pMidFunc = pFunc; + } else { + nodesDestroyList(pParameterList); + } + + return code; +} + static int32_t createMergeFunction(const SFunctionNode* pSrcFunc, const SFunctionNode* pPartialFunc, SFunctionNode** pMergeFunc) { SNodeList* pParameterList = NULL; @@ -453,18 +482,22 @@ static int32_t createMergeFunction(const SFunctionNode* pSrcFunc, const SFunctio return code; } -int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc) { +int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMidFunc, SFunctionNode** pMergeFunc) { if (!fmIsDistExecFunc(pFunc->funcId)) { return TSDB_CODE_FAILED; } int32_t code = createPartialFunction(pFunc, pPartialFunc); + if (TSDB_CODE_SUCCESS == code) { + code = createMidFunction(pFunc, *pPartialFunc, pMidFunc); + } if (TSDB_CODE_SUCCESS == code) { code = createMergeFunction(pFunc, *pPartialFunc, pMergeFunc); } if (TSDB_CODE_SUCCESS != code) { nodesDestroyNode((SNode*)*pPartialFunc); + nodesDestroyNode((SNode*)*pMidFunc); nodesDestroyNode((SNode*)*pMergeFunc); } diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index bc9839792c..f559d90604 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -959,6 +959,7 @@ SNode* nodesCloneNode(const SNode* pNode) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL: code = physiIntervalCopy((const SIntervalPhysiNode*)pNode, (SIntervalPhysiNode*)pDst); break; case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION: diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 7533d00704..0e491c777d 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -369,6 +369,8 @@ const char* nodesNodeName(ENodeType type) { return "PhysiStreamFinalInterval"; case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: return "PhysiStreamSemiInterval"; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL: + return "PhysiStreamMidInterval"; case QUERY_NODE_PHYSICAL_PLAN_FILL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL: return "PhysiFill"; @@ -7206,6 +7208,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL: return physiIntervalNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_FILL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL: @@ -7545,6 +7548,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL: return jsonToPhysiIntervalNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_FILL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL: diff --git a/source/libs/nodes/src/nodesMsgFuncs.c b/source/libs/nodes/src/nodesMsgFuncs.c index 7d8cd72cdb..cdbf87b8e3 100644 --- a/source/libs/nodes/src/nodesMsgFuncs.c +++ b/source/libs/nodes/src/nodesMsgFuncs.c @@ -4179,6 +4179,7 @@ static int32_t specificNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL: code = physiIntervalNodeToMsg(pObj, pEncoder); break; case QUERY_NODE_PHYSICAL_PLAN_FILL: @@ -4333,6 +4334,7 @@ static int32_t msgToSpecificNode(STlvDecoder* pDecoder, void* pObj) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL: code = msgToPhysiIntervalNode(pDecoder, pObj); break; case QUERY_NODE_PHYSICAL_PLAN_FILL: diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 14973da9e5..c9169c12fe 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -564,6 +564,8 @@ SNode* nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SStreamFinalIntervalPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: return makeNode(type, sizeof(SStreamSemiIntervalPhysiNode)); + case QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL: + return makeNode(type, sizeof(SStreamMidIntervalPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_FILL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL: return makeNode(type, sizeof(SFillPhysiNode)); @@ -1391,6 +1393,7 @@ void nodesDestroyNode(SNode* pNode) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL: destroyWinodwPhysiNode((SWindowPhysiNode*)pNode); break; case QUERY_NODE_PHYSICAL_PLAN_FILL: diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index d2d120fa93..d607287af3 100755 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -516,7 +516,7 @@ cmd ::= SHOW VNODES. // show alive cmd ::= SHOW db_name_cond_opt(A) ALIVE. { pCxt->pRootNode = createShowAliveStmt(pCxt, A, QUERY_NODE_SHOW_DB_ALIVE_STMT); } cmd ::= SHOW CLUSTER ALIVE. { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } -cmd ::= SHOW db_name_cond_opt(A) VIEWS. { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, A, NULL, OP_TYPE_LIKE); } +cmd ::= SHOW db_name_cond_opt(A) VIEWS like_pattern_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, A, B, OP_TYPE_LIKE); } cmd ::= SHOW CREATE VIEW full_table_name(A). { pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, A); } cmd ::= SHOW COMPACTS. { pCxt->pRootNode = createShowCompactsStmt(pCxt, QUERY_NODE_SHOW_COMPACTS_STMT); } cmd ::= SHOW COMPACT NK_INTEGER(A). { pCxt->pRootNode = createShowCompactDetailsStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &A)); } diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index 6b655bfae6..a1f682f4cf 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -211,6 +211,7 @@ static int32_t createTableDataCxt(STableMeta* pTableMeta, SVCreateTbReq** pCreat bool colMode, bool ignoreColVals) { STableDataCxt* pTableCxt = taosMemoryCalloc(1, sizeof(STableDataCxt)); if (NULL == pTableCxt) { + *pOutput = NULL; return TSDB_CODE_OUT_OF_MEMORY; } @@ -268,12 +269,8 @@ static int32_t createTableDataCxt(STableMeta* pTableMeta, SVCreateTbReq** pCreat } } - if (TSDB_CODE_SUCCESS == code) { - *pOutput = pTableCxt; - qDebug("tableDataCxt created, uid:%" PRId64 ", vgId:%d", pTableMeta->uid, pTableMeta->vgId); - } else { - taosMemoryFree(pTableCxt); - } + *pOutput = pTableCxt; + qDebug("tableDataCxt created, code:%d, uid:%" PRId64 ", vgId:%d", code, pTableMeta->uid, pTableMeta->vgId); return code; } @@ -288,6 +285,7 @@ static int32_t rebuildTableData(SSubmitTbData* pSrc, SSubmitTbData** pDst) { pTmp->suid = pSrc->suid; pTmp->uid = pSrc->uid; pTmp->sver = pSrc->sver; + pTmp->source = pSrc->source; pTmp->pCreateTbReq = NULL; if (pTmp->flags & SUBMIT_REQ_AUTO_CREATE_TABLE) { if (pSrc->pCreateTbReq) { @@ -344,6 +342,10 @@ int32_t insGetTableDataCxt(SHashObj* pHash, void* id, int32_t idLen, STableMeta* void* pData = *pTableCxt; // deal scan coverity code = taosHashPut(pHash, id, idLen, &pData, POINTER_BYTES); } + + if (TSDB_CODE_SUCCESS != code) { + insDestroyTableDataCxt(*pTableCxt); + } return code; } @@ -651,6 +653,7 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate goto end; } + pTableCxt->pData->source = SOURCE_TAOSX; if(tmp == NULL){ ret = initTableColSubmitData(pTableCxt); if (ret != TSDB_CODE_SUCCESS) { diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 960796d345..c4c4b0824a 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -9399,7 +9399,20 @@ static int32_t createOperatorNode(EOperatorType opType, const char* pColName, SN } static const char* getTbNameColName(ENodeType type) { - return (QUERY_NODE_SHOW_STABLES_STMT == type ? "stable_name" : "table_name"); + const char* colName; + switch (type) + { + case QUERY_NODE_SHOW_VIEWS_STMT: + colName = "view_name"; + break; + case QUERY_NODE_SHOW_STABLES_STMT: + colName = "stable_name"; + break; + default: + colName = "table_name"; + break; + } + return colName; } static int32_t createLogicCondNode(SNode* pCond1, SNode* pCond2, SNode** pCond, ELogicConditionType logicCondType) { diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 25862bb079..63159a10ae 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -1,3 +1,5 @@ +/* This file is automatically generated by Lemon from input grammar +** source file "sql.y". */ /* ** 2000-05-29 ** @@ -22,9 +24,8 @@ ** The following is the concatenation of all %include directives from the ** input grammar file: */ -#include -#include /************ Begin %include sections from the grammar ************************/ +#line 11 "sql.y" #include #include @@ -41,12 +42,362 @@ #include "parAst.h" #define YYSTACKDEPTH 0 +#line 46 "sql.c" /**************** End of %include directives **********************************/ -/* These constants specify the various numeric values for terminal symbols -** in a format understandable to "makeheaders". This section is blank unless -** "lemon" is run with the "-m" command-line option. -***************** Begin makeheaders token definitions *************************/ -/**************** End makeheaders token definitions ***************************/ +/* These constants specify the various numeric values for terminal symbols. +***************** Begin token definitions *************************************/ +#ifndef TK_OR +#define TK_OR 1 +#define TK_AND 2 +#define TK_UNION 3 +#define TK_ALL 4 +#define TK_MINUS 5 +#define TK_EXCEPT 6 +#define TK_INTERSECT 7 +#define TK_NK_BITAND 8 +#define TK_NK_BITOR 9 +#define TK_NK_LSHIFT 10 +#define TK_NK_RSHIFT 11 +#define TK_NK_PLUS 12 +#define TK_NK_MINUS 13 +#define TK_NK_STAR 14 +#define TK_NK_SLASH 15 +#define TK_NK_REM 16 +#define TK_NK_CONCAT 17 +#define TK_CREATE 18 +#define TK_ACCOUNT 19 +#define TK_NK_ID 20 +#define TK_PASS 21 +#define TK_NK_STRING 22 +#define TK_ALTER 23 +#define TK_PPS 24 +#define TK_TSERIES 25 +#define TK_STORAGE 26 +#define TK_STREAMS 27 +#define TK_QTIME 28 +#define TK_DBS 29 +#define TK_USERS 30 +#define TK_CONNS 31 +#define TK_STATE 32 +#define TK_NK_COMMA 33 +#define TK_HOST 34 +#define TK_USER 35 +#define TK_ENABLE 36 +#define TK_NK_INTEGER 37 +#define TK_SYSINFO 38 +#define TK_ADD 39 +#define TK_DROP 40 +#define TK_GRANT 41 +#define TK_ON 42 +#define TK_TO 43 +#define TK_REVOKE 44 +#define TK_FROM 45 +#define TK_SUBSCRIBE 46 +#define TK_READ 47 +#define TK_WRITE 48 +#define TK_NK_DOT 49 +#define TK_WITH 50 +#define TK_DNODE 51 +#define TK_PORT 52 +#define TK_DNODES 53 +#define TK_RESTORE 54 +#define TK_NK_IPTOKEN 55 +#define TK_FORCE 56 +#define TK_UNSAFE 57 +#define TK_CLUSTER 58 +#define TK_LOCAL 59 +#define TK_QNODE 60 +#define TK_BNODE 61 +#define TK_SNODE 62 +#define TK_MNODE 63 +#define TK_VNODE 64 +#define TK_DATABASE 65 +#define TK_USE 66 +#define TK_FLUSH 67 +#define TK_TRIM 68 +#define TK_COMPACT 69 +#define TK_IF 70 +#define TK_NOT 71 +#define TK_EXISTS 72 +#define TK_BUFFER 73 +#define TK_CACHEMODEL 74 +#define TK_CACHESIZE 75 +#define TK_COMP 76 +#define TK_DURATION 77 +#define TK_NK_VARIABLE 78 +#define TK_MAXROWS 79 +#define TK_MINROWS 80 +#define TK_KEEP 81 +#define TK_PAGES 82 +#define TK_PAGESIZE 83 +#define TK_TSDB_PAGESIZE 84 +#define TK_PRECISION 85 +#define TK_REPLICA 86 +#define TK_VGROUPS 87 +#define TK_SINGLE_STABLE 88 +#define TK_RETENTIONS 89 +#define TK_SCHEMALESS 90 +#define TK_WAL_LEVEL 91 +#define TK_WAL_FSYNC_PERIOD 92 +#define TK_WAL_RETENTION_PERIOD 93 +#define TK_WAL_RETENTION_SIZE 94 +#define TK_WAL_ROLL_PERIOD 95 +#define TK_WAL_SEGMENT_SIZE 96 +#define TK_STT_TRIGGER 97 +#define TK_TABLE_PREFIX 98 +#define TK_TABLE_SUFFIX 99 +#define TK_KEEP_TIME_OFFSET 100 +#define TK_NK_COLON 101 +#define TK_BWLIMIT 102 +#define TK_START 103 +#define TK_TIMESTAMP 104 +#define TK_END 105 +#define TK_TABLE 106 +#define TK_NK_LP 107 +#define TK_NK_RP 108 +#define TK_STABLE 109 +#define TK_COLUMN 110 +#define TK_MODIFY 111 +#define TK_RENAME 112 +#define TK_TAG 113 +#define TK_SET 114 +#define TK_NK_EQ 115 +#define TK_USING 116 +#define TK_TAGS 117 +#define TK_BOOL 118 +#define TK_TINYINT 119 +#define TK_SMALLINT 120 +#define TK_INT 121 +#define TK_INTEGER 122 +#define TK_BIGINT 123 +#define TK_FLOAT 124 +#define TK_DOUBLE 125 +#define TK_BINARY 126 +#define TK_NCHAR 127 +#define TK_UNSIGNED 128 +#define TK_JSON 129 +#define TK_VARCHAR 130 +#define TK_MEDIUMBLOB 131 +#define TK_BLOB 132 +#define TK_VARBINARY 133 +#define TK_GEOMETRY 134 +#define TK_DECIMAL 135 +#define TK_COMMENT 136 +#define TK_MAX_DELAY 137 +#define TK_WATERMARK 138 +#define TK_ROLLUP 139 +#define TK_TTL 140 +#define TK_SMA 141 +#define TK_DELETE_MARK 142 +#define TK_FIRST 143 +#define TK_LAST 144 +#define TK_SHOW 145 +#define TK_PRIVILEGES 146 +#define TK_DATABASES 147 +#define TK_TABLES 148 +#define TK_STABLES 149 +#define TK_MNODES 150 +#define TK_QNODES 151 +#define TK_FUNCTIONS 152 +#define TK_INDEXES 153 +#define TK_ACCOUNTS 154 +#define TK_APPS 155 +#define TK_CONNECTIONS 156 +#define TK_LICENCES 157 +#define TK_GRANTS 158 +#define TK_FULL 159 +#define TK_LOGS 160 +#define TK_MACHINES 161 +#define TK_QUERIES 162 +#define TK_SCORES 163 +#define TK_TOPICS 164 +#define TK_VARIABLES 165 +#define TK_BNODES 166 +#define TK_SNODES 167 +#define TK_TRANSACTIONS 168 +#define TK_DISTRIBUTED 169 +#define TK_CONSUMERS 170 +#define TK_SUBSCRIPTIONS 171 +#define TK_VNODES 172 +#define TK_ALIVE 173 +#define TK_VIEWS 174 +#define TK_VIEW 175 +#define TK_COMPACTS 176 +#define TK_NORMAL 177 +#define TK_CHILD 178 +#define TK_LIKE 179 +#define TK_TBNAME 180 +#define TK_QTAGS 181 +#define TK_AS 182 +#define TK_SYSTEM 183 +#define TK_INDEX 184 +#define TK_FUNCTION 185 +#define TK_INTERVAL 186 +#define TK_COUNT 187 +#define TK_LAST_ROW 188 +#define TK_META 189 +#define TK_ONLY 190 +#define TK_TOPIC 191 +#define TK_CONSUMER 192 +#define TK_GROUP 193 +#define TK_DESC 194 +#define TK_DESCRIBE 195 +#define TK_RESET 196 +#define TK_QUERY 197 +#define TK_CACHE 198 +#define TK_EXPLAIN 199 +#define TK_ANALYZE 200 +#define TK_VERBOSE 201 +#define TK_NK_BOOL 202 +#define TK_RATIO 203 +#define TK_NK_FLOAT 204 +#define TK_OUTPUTTYPE 205 +#define TK_AGGREGATE 206 +#define TK_BUFSIZE 207 +#define TK_LANGUAGE 208 +#define TK_REPLACE 209 +#define TK_STREAM 210 +#define TK_INTO 211 +#define TK_PAUSE 212 +#define TK_RESUME 213 +#define TK_TRIGGER 214 +#define TK_AT_ONCE 215 +#define TK_WINDOW_CLOSE 216 +#define TK_IGNORE 217 +#define TK_EXPIRED 218 +#define TK_FILL_HISTORY 219 +#define TK_UPDATE 220 +#define TK_SUBTABLE 221 +#define TK_UNTREATED 222 +#define TK_KILL 223 +#define TK_CONNECTION 224 +#define TK_TRANSACTION 225 +#define TK_BALANCE 226 +#define TK_VGROUP 227 +#define TK_LEADER 228 +#define TK_MERGE 229 +#define TK_REDISTRIBUTE 230 +#define TK_SPLIT 231 +#define TK_DELETE 232 +#define TK_INSERT 233 +#define TK_NULL 234 +#define TK_NK_QUESTION 235 +#define TK_NK_ALIAS 236 +#define TK_NK_ARROW 237 +#define TK_ROWTS 238 +#define TK_QSTART 239 +#define TK_QEND 240 +#define TK_QDURATION 241 +#define TK_WSTART 242 +#define TK_WEND 243 +#define TK_WDURATION 244 +#define TK_IROWTS 245 +#define TK_ISFILLED 246 +#define TK_CAST 247 +#define TK_NOW 248 +#define TK_TODAY 249 +#define TK_TIMEZONE 250 +#define TK_CLIENT_VERSION 251 +#define TK_SERVER_VERSION 252 +#define TK_SERVER_STATUS 253 +#define TK_CURRENT_USER 254 +#define TK_CASE 255 +#define TK_WHEN 256 +#define TK_THEN 257 +#define TK_ELSE 258 +#define TK_BETWEEN 259 +#define TK_IS 260 +#define TK_NK_LT 261 +#define TK_NK_GT 262 +#define TK_NK_LE 263 +#define TK_NK_GE 264 +#define TK_NK_NE 265 +#define TK_MATCH 266 +#define TK_NMATCH 267 +#define TK_CONTAINS 268 +#define TK_IN 269 +#define TK_JOIN 270 +#define TK_INNER 271 +#define TK_SELECT 272 +#define TK_NK_HINT 273 +#define TK_DISTINCT 274 +#define TK_WHERE 275 +#define TK_PARTITION 276 +#define TK_BY 277 +#define TK_SESSION 278 +#define TK_STATE_WINDOW 279 +#define TK_EVENT_WINDOW 280 +#define TK_SLIDING 281 +#define TK_FILL 282 +#define TK_VALUE 283 +#define TK_VALUE_F 284 +#define TK_NONE 285 +#define TK_PREV 286 +#define TK_NULL_F 287 +#define TK_LINEAR 288 +#define TK_NEXT 289 +#define TK_HAVING 290 +#define TK_RANGE 291 +#define TK_EVERY 292 +#define TK_ORDER 293 +#define TK_SLIMIT 294 +#define TK_SOFFSET 295 +#define TK_LIMIT 296 +#define TK_OFFSET 297 +#define TK_ASC 298 +#define TK_NULLS 299 +#define TK_ABORT 300 +#define TK_AFTER 301 +#define TK_ATTACH 302 +#define TK_BEFORE 303 +#define TK_BEGIN 304 +#define TK_BITAND 305 +#define TK_BITNOT 306 +#define TK_BITOR 307 +#define TK_BLOCKS 308 +#define TK_CHANGE 309 +#define TK_COMMA 310 +#define TK_CONCAT 311 +#define TK_CONFLICT 312 +#define TK_COPY 313 +#define TK_DEFERRED 314 +#define TK_DELIMITERS 315 +#define TK_DETACH 316 +#define TK_DIVIDE 317 +#define TK_DOT 318 +#define TK_EACH 319 +#define TK_FAIL 320 +#define TK_FILE 321 +#define TK_FOR 322 +#define TK_GLOB 323 +#define TK_ID 324 +#define TK_IMMEDIATE 325 +#define TK_IMPORT 326 +#define TK_INITIALLY 327 +#define TK_INSTEAD 328 +#define TK_ISNULL 329 +#define TK_KEY 330 +#define TK_MODULES 331 +#define TK_NK_BITNOT 332 +#define TK_NK_SEMI 333 +#define TK_NOTNULL 334 +#define TK_OF 335 +#define TK_PLUS 336 +#define TK_PRIVILEGE 337 +#define TK_RAISE 338 +#define TK_RESTRICT 339 +#define TK_ROW 340 +#define TK_SEMI 341 +#define TK_STAR 342 +#define TK_STATEMENT 343 +#define TK_STRICT 344 +#define TK_STRING 345 +#define TK_TIMES 346 +#define TK_VALUES 347 +#define TK_VARIABLE 348 +#define TK_WAL 349 +#endif +/**************** End token definitions ***************************************/ /* The next sections is a series of control #defines. ** various aspects of the generated parser. @@ -142,18 +493,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 846 +#define YYNSTATE 847 #define YYNRULE 647 #define YYNRULE_WITH_ACTION 647 #define YYNTOKEN 350 -#define YY_MAX_SHIFT 845 -#define YY_MIN_SHIFTREDUCE 1248 -#define YY_MAX_SHIFTREDUCE 1894 -#define YY_ERROR_ACTION 1895 -#define YY_ACCEPT_ACTION 1896 -#define YY_NO_ACTION 1897 -#define YY_MIN_REDUCE 1898 -#define YY_MAX_REDUCE 2544 +#define YY_MAX_SHIFT 846 +#define YY_MIN_SHIFTREDUCE 1249 +#define YY_MAX_SHIFTREDUCE 1895 +#define YY_ERROR_ACTION 1896 +#define YY_ACCEPT_ACTION 1897 +#define YY_NO_ACTION 1898 +#define YY_MIN_REDUCE 1899 +#define YY_MAX_REDUCE 2545 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -222,315 +573,315 @@ typedef union { *********** Begin parsing tables **********************************************/ #define YY_ACTTAB_COUNT (3083) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 1921, 2322, 565, 2077, 466, 566, 1941, 14, 13, 465, - /* 10 */ 2175, 2305, 48, 46, 1818, 2330, 2520, 34, 411, 2515, - /* 20 */ 417, 1684, 1659, 41, 40, 2326, 171, 47, 45, 44, - /* 30 */ 43, 42, 2073, 645, 2090, 1744, 1984, 1657, 2519, 731, - /* 40 */ 2088, 698, 2516, 2518, 2515, 2346, 38, 320, 643, 582, - /* 50 */ 641, 269, 268, 2312, 673, 710, 146, 2515, 713, 137, - /* 60 */ 112, 673, 697, 203, 2515, 1739, 608, 2516, 699, 2328, - /* 70 */ 414, 19, 174, 2226, 1910, 2521, 203, 147, 1665, 741, - /* 80 */ 2516, 699, 2521, 203, 2226, 2080, 2364, 2516, 699, 41, - /* 90 */ 40, 2224, 718, 47, 45, 44, 43, 42, 2312, 410, - /* 100 */ 747, 585, 2223, 718, 842, 583, 2219, 15, 473, 817, - /* 110 */ 816, 815, 814, 429, 1787, 813, 812, 151, 807, 806, - /* 120 */ 805, 804, 803, 802, 801, 150, 795, 794, 793, 428, - /* 130 */ 427, 790, 789, 788, 183, 182, 787, 2064, 1314, 2345, - /* 140 */ 1313, 63, 2383, 1746, 1747, 114, 2347, 751, 2349, 2350, - /* 150 */ 746, 730, 741, 532, 530, 142, 366, 186, 573, 2436, - /* 160 */ 217, 566, 1941, 413, 2432, 300, 2444, 709, 570, 138, - /* 170 */ 708, 509, 2515, 1315, 567, 508, 184, 2141, 205, 2520, - /* 180 */ 1719, 1729, 2515, 507, 382, 656, 2466, 1745, 1748, 1860, - /* 190 */ 697, 203, 2139, 710, 146, 2516, 699, 1898, 384, 688, - /* 200 */ 2206, 2519, 1660, 63, 1658, 2516, 2517, 786, 196, 710, - /* 210 */ 146, 41, 40, 731, 2088, 47, 45, 44, 43, 42, - /* 220 */ 2128, 136, 135, 134, 133, 132, 131, 130, 129, 128, - /* 230 */ 730, 482, 2202, 208, 1663, 1664, 1716, 52, 1718, 1721, - /* 240 */ 1722, 1723, 1724, 1725, 1726, 1727, 1728, 743, 739, 1737, - /* 250 */ 1738, 1740, 1741, 1742, 1743, 2, 48, 46, 581, 2520, - /* 260 */ 1685, 364, 698, 1682, 417, 2515, 1659, 731, 2088, 99, - /* 270 */ 516, 237, 2346, 535, 376, 568, 1687, 1949, 534, 1744, - /* 280 */ 219, 1657, 692, 697, 203, 745, 272, 56, 2516, 699, - /* 290 */ 271, 694, 689, 682, 496, 450, 536, 464, 1687, 463, - /* 300 */ 1606, 365, 498, 202, 2444, 2445, 304, 144, 2449, 1739, - /* 310 */ 2364, 657, 476, 2364, 1684, 19, 1452, 51, 1773, 204, - /* 320 */ 2444, 2445, 1665, 144, 2449, 2312, 68, 747, 3, 462, - /* 330 */ 1443, 776, 775, 774, 1447, 773, 1449, 1450, 772, 769, - /* 340 */ 54, 1458, 766, 1460, 1461, 763, 760, 757, 842, 385, - /* 350 */ 1684, 15, 784, 161, 160, 781, 780, 779, 158, 98, - /* 360 */ 484, 1987, 371, 2451, 1884, 397, 2345, 647, 304, 2383, - /* 370 */ 2185, 691, 356, 2347, 751, 2349, 2350, 746, 744, 741, - /* 380 */ 732, 2401, 1774, 1578, 1579, 575, 2265, 1746, 1747, 2448, - /* 390 */ 2213, 2192, 1920, 523, 522, 521, 520, 515, 514, 513, - /* 400 */ 512, 368, 304, 710, 146, 502, 501, 500, 499, 493, - /* 410 */ 492, 491, 480, 486, 485, 383, 797, 731, 2088, 477, - /* 420 */ 1546, 1547, 173, 454, 1719, 1729, 1565, 1577, 1580, 63, - /* 430 */ 2027, 1745, 1748, 1297, 627, 626, 625, 137, 302, 1683, - /* 440 */ 730, 617, 143, 621, 613, 2312, 1660, 620, 1658, 184, - /* 450 */ 456, 452, 619, 624, 392, 391, 488, 2202, 618, 1684, - /* 460 */ 302, 614, 37, 415, 1768, 1769, 1770, 1771, 1772, 1776, - /* 470 */ 1777, 1778, 1779, 2207, 1558, 1559, 390, 389, 1663, 1664, - /* 480 */ 1716, 799, 1718, 1721, 1722, 1723, 1724, 1725, 1726, 1727, - /* 490 */ 1728, 743, 739, 1737, 1738, 1740, 1741, 1742, 1743, 2, - /* 500 */ 12, 48, 46, 2346, 738, 221, 2135, 2136, 2322, 417, - /* 510 */ 1720, 1659, 712, 201, 2444, 2445, 748, 144, 2449, 239, - /* 520 */ 159, 1685, 2079, 568, 1744, 1949, 1657, 51, 12, 36, - /* 530 */ 10, 2322, 2326, 95, 2346, 41, 40, 731, 2088, 47, - /* 540 */ 45, 44, 43, 42, 2364, 2331, 63, 713, 388, 387, - /* 550 */ 386, 610, 731, 2088, 1739, 2326, 2312, 470, 747, 2083, - /* 560 */ 19, 627, 626, 625, 731, 2088, 1717, 1665, 617, 143, - /* 570 */ 621, 693, 471, 612, 620, 2364, 2328, 611, 2519, 619, - /* 580 */ 624, 392, 391, 2141, 490, 618, 741, 2312, 614, 747, - /* 590 */ 398, 604, 603, 842, 304, 55, 15, 2345, 2139, 2328, - /* 600 */ 2383, 2346, 786, 114, 2347, 751, 2349, 2350, 746, 741, - /* 610 */ 741, 1317, 1318, 149, 748, 156, 2407, 2436, 9, 41, - /* 620 */ 40, 413, 2432, 47, 45, 44, 43, 42, 2345, 654, - /* 630 */ 1896, 2383, 1746, 1747, 114, 2347, 751, 2349, 2350, 746, - /* 640 */ 2274, 741, 2364, 1822, 1487, 1488, 186, 657, 2436, 1684, - /* 650 */ 518, 2202, 413, 2432, 2312, 127, 747, 1899, 126, 125, - /* 660 */ 124, 123, 122, 121, 120, 119, 118, 1765, 422, 1719, - /* 670 */ 1729, 2134, 2136, 1754, 2451, 2467, 1745, 1748, 127, 1684, + /* 0 */ 1922, 2323, 566, 2078, 467, 567, 1942, 14, 13, 466, + /* 10 */ 2176, 2306, 48, 46, 1819, 2331, 2521, 34, 412, 2516, + /* 20 */ 418, 1685, 1660, 41, 40, 2327, 171, 47, 45, 44, + /* 30 */ 43, 42, 2074, 646, 2091, 1745, 1985, 1658, 2520, 732, + /* 40 */ 2089, 699, 2517, 2519, 2516, 2347, 38, 321, 644, 583, + /* 50 */ 642, 270, 269, 2313, 674, 711, 146, 2516, 714, 137, + /* 60 */ 112, 674, 698, 203, 2516, 1740, 609, 2517, 700, 2329, + /* 70 */ 415, 19, 174, 2227, 1911, 2522, 203, 147, 1666, 742, + /* 80 */ 2517, 700, 2522, 203, 2227, 2081, 2365, 2517, 700, 41, + /* 90 */ 40, 2225, 719, 47, 45, 44, 43, 42, 2313, 411, + /* 100 */ 748, 586, 2224, 719, 843, 584, 2220, 15, 474, 818, + /* 110 */ 817, 816, 815, 430, 1788, 814, 813, 151, 808, 807, + /* 120 */ 806, 805, 804, 803, 802, 150, 796, 795, 794, 429, + /* 130 */ 428, 791, 790, 789, 183, 182, 788, 2065, 1315, 2346, + /* 140 */ 1314, 63, 2384, 1747, 1748, 114, 2348, 752, 2350, 2351, + /* 150 */ 747, 731, 742, 533, 531, 142, 367, 186, 574, 2437, + /* 160 */ 217, 567, 1942, 414, 2433, 301, 2445, 710, 571, 138, + /* 170 */ 709, 510, 2516, 1316, 568, 509, 184, 2142, 205, 2521, + /* 180 */ 1720, 1730, 2516, 508, 383, 657, 2467, 1746, 1749, 1861, + /* 190 */ 698, 203, 2140, 711, 146, 2517, 700, 1899, 385, 689, + /* 200 */ 2207, 2520, 1661, 63, 1659, 2517, 2518, 787, 196, 711, + /* 210 */ 146, 41, 40, 732, 2089, 47, 45, 44, 43, 42, + /* 220 */ 2129, 136, 135, 134, 133, 132, 131, 130, 129, 128, + /* 230 */ 731, 483, 2203, 208, 1664, 1665, 1717, 52, 1719, 1722, + /* 240 */ 1723, 1724, 1725, 1726, 1727, 1728, 1729, 744, 740, 1738, + /* 250 */ 1739, 1741, 1742, 1743, 1744, 2, 48, 46, 582, 2521, + /* 260 */ 1686, 365, 699, 1683, 418, 2516, 1660, 732, 2089, 99, + /* 270 */ 517, 238, 2347, 536, 377, 569, 1688, 1950, 535, 1745, + /* 280 */ 219, 1658, 693, 698, 203, 746, 273, 56, 2517, 700, + /* 290 */ 272, 695, 690, 683, 497, 451, 537, 465, 1688, 464, + /* 300 */ 1607, 366, 499, 202, 2445, 2446, 305, 144, 2450, 1740, + /* 310 */ 2365, 658, 477, 2365, 1685, 19, 1453, 51, 1774, 204, + /* 320 */ 2445, 2446, 1666, 144, 2450, 2313, 68, 748, 3, 463, + /* 330 */ 1444, 777, 776, 775, 1448, 774, 1450, 1451, 773, 770, + /* 340 */ 54, 1459, 767, 1461, 1462, 764, 761, 758, 843, 386, + /* 350 */ 1685, 15, 785, 161, 160, 782, 781, 780, 158, 98, + /* 360 */ 485, 1988, 372, 2452, 1885, 398, 2346, 648, 305, 2384, + /* 370 */ 2186, 692, 357, 2348, 752, 2350, 2351, 747, 745, 742, + /* 380 */ 733, 2402, 1775, 1579, 1580, 576, 2266, 1747, 1748, 2449, + /* 390 */ 2214, 2193, 1921, 524, 523, 522, 521, 516, 515, 514, + /* 400 */ 513, 369, 305, 711, 146, 503, 502, 501, 500, 494, + /* 410 */ 493, 492, 481, 487, 486, 384, 798, 732, 2089, 478, + /* 420 */ 1547, 1548, 173, 455, 1720, 1730, 1566, 1578, 1581, 63, + /* 430 */ 2028, 1746, 1749, 1298, 628, 627, 626, 137, 303, 1684, + /* 440 */ 731, 618, 143, 622, 614, 2313, 1661, 621, 1659, 184, + /* 450 */ 457, 453, 620, 625, 393, 392, 489, 2203, 619, 1685, + /* 460 */ 303, 615, 37, 416, 1769, 1770, 1771, 1772, 1773, 1777, + /* 470 */ 1778, 1779, 1780, 2208, 1559, 1560, 391, 390, 1664, 1665, + /* 480 */ 1717, 800, 1719, 1722, 1723, 1724, 1725, 1726, 1727, 1728, + /* 490 */ 1729, 744, 740, 1738, 1739, 1741, 1742, 1743, 1744, 2, + /* 500 */ 12, 48, 46, 2347, 739, 221, 2136, 2137, 2323, 418, + /* 510 */ 1721, 1660, 713, 201, 2445, 2446, 749, 144, 2450, 240, + /* 520 */ 159, 1686, 2080, 569, 1745, 1950, 1658, 51, 12, 36, + /* 530 */ 10, 2323, 2327, 95, 2347, 41, 40, 732, 2089, 47, + /* 540 */ 45, 44, 43, 42, 2365, 2332, 63, 714, 389, 388, + /* 550 */ 387, 611, 732, 2089, 1740, 2327, 2313, 471, 748, 2084, + /* 560 */ 19, 628, 627, 626, 732, 2089, 1718, 1666, 618, 143, + /* 570 */ 622, 694, 472, 613, 621, 2365, 2329, 612, 2520, 620, + /* 580 */ 625, 393, 392, 2142, 491, 619, 742, 2313, 615, 748, + /* 590 */ 399, 605, 604, 843, 305, 55, 15, 2346, 2140, 2329, + /* 600 */ 2384, 2347, 787, 114, 2348, 752, 2350, 2351, 747, 742, + /* 610 */ 742, 1318, 1319, 149, 749, 156, 2408, 2437, 9, 41, + /* 620 */ 40, 414, 2433, 47, 45, 44, 43, 42, 2346, 655, + /* 630 */ 1897, 2384, 1747, 1748, 114, 2348, 752, 2350, 2351, 747, + /* 640 */ 2275, 742, 2365, 1823, 1488, 1489, 186, 658, 2437, 1685, + /* 650 */ 519, 2203, 414, 2433, 2313, 127, 748, 1900, 126, 125, + /* 660 */ 124, 123, 122, 121, 120, 119, 118, 1766, 423, 1720, + /* 670 */ 1730, 2135, 2137, 1755, 2452, 2468, 1746, 1749, 127, 1685, /* 680 */ 12, 126, 125, 124, 123, 122, 121, 120, 119, 118, - /* 690 */ 672, 1660, 304, 1658, 274, 2345, 731, 2088, 2383, 226, - /* 700 */ 2447, 114, 2347, 751, 2349, 2350, 746, 1919, 741, 432, - /* 710 */ 420, 304, 777, 2411, 431, 2436, 503, 159, 171, 413, - /* 720 */ 2432, 659, 2265, 1663, 1664, 1716, 2090, 1718, 1721, 1722, - /* 730 */ 1723, 1724, 1725, 1726, 1727, 1728, 743, 739, 1737, 1738, - /* 740 */ 1740, 1741, 1742, 1743, 2, 48, 46, 1749, 2346, 420, - /* 750 */ 426, 425, 634, 417, 1407, 1659, 1841, 168, 423, 673, - /* 760 */ 2312, 748, 2515, 1951, 399, 2090, 171, 646, 1744, 1406, - /* 770 */ 1657, 1842, 2139, 2159, 2090, 1666, 731, 2088, 2346, 106, - /* 780 */ 2521, 203, 95, 270, 1775, 2516, 699, 1716, 1314, 2364, - /* 790 */ 1313, 748, 1622, 2474, 223, 2141, 504, 1688, 1739, 637, - /* 800 */ 1395, 2312, 407, 747, 2081, 1891, 631, 629, 2084, 1720, - /* 810 */ 2139, 1665, 1840, 267, 47, 45, 44, 43, 42, 2364, - /* 820 */ 41, 40, 61, 1315, 47, 45, 44, 43, 42, 526, - /* 830 */ 670, 2312, 1688, 747, 1688, 90, 537, 842, 89, 1720, - /* 840 */ 49, 1397, 2345, 731, 2088, 2383, 2346, 1807, 114, 2347, - /* 850 */ 751, 2349, 2350, 746, 72, 741, 1659, 71, 1665, 748, - /* 860 */ 2535, 2487, 2436, 505, 35, 1717, 413, 2432, 701, 731, - /* 870 */ 2088, 1657, 2345, 1849, 1780, 2383, 1746, 1747, 114, 2347, - /* 880 */ 751, 2349, 2350, 746, 273, 741, 1918, 2364, 2065, 584, - /* 890 */ 2535, 227, 2436, 2141, 562, 1717, 413, 2432, 1815, 2312, - /* 900 */ 412, 747, 334, 560, 88, 2118, 556, 552, 2139, 1890, - /* 910 */ 731, 2088, 1665, 1719, 1729, 525, 524, 1917, 325, 1411, - /* 920 */ 1745, 1748, 685, 684, 1847, 1848, 1850, 1851, 1852, 2141, - /* 930 */ 2085, 1295, 511, 510, 1410, 1660, 421, 1658, 842, 2312, - /* 940 */ 2345, 612, 1669, 2383, 2139, 611, 114, 2347, 751, 2349, - /* 950 */ 2350, 746, 1916, 741, 1915, 1293, 1294, 1914, 2535, 194, - /* 960 */ 2436, 2075, 1627, 1628, 413, 2432, 2071, 1663, 1664, 1716, - /* 970 */ 2312, 1718, 1721, 1722, 1723, 1724, 1725, 1726, 1727, 1728, - /* 980 */ 743, 739, 1737, 1738, 1740, 1741, 1742, 1743, 2, 48, - /* 990 */ 46, 2346, 606, 605, 199, 2063, 198, 417, 733, 1659, - /* 1000 */ 2408, 539, 623, 622, 748, 2312, 680, 2312, 800, 2092, - /* 1010 */ 2312, 2049, 1744, 1689, 1657, 41, 40, 731, 2088, 47, - /* 1020 */ 45, 44, 43, 42, 784, 161, 160, 781, 780, 779, - /* 1030 */ 158, 171, 2364, 44, 43, 42, 1660, 275, 1658, 2091, - /* 1040 */ 30, 2451, 1739, 280, 2312, 1688, 747, 1913, 1689, 1684, - /* 1050 */ 1689, 311, 312, 41, 40, 1665, 310, 47, 45, 44, - /* 1060 */ 43, 42, 731, 2088, 1288, 1912, 2293, 2446, 1663, 1664, - /* 1070 */ 41, 40, 1909, 2346, 47, 45, 44, 43, 42, 731, - /* 1080 */ 2088, 842, 283, 1295, 49, 2345, 748, 148, 2383, 2346, - /* 1090 */ 2407, 114, 2347, 751, 2349, 2350, 746, 2141, 741, 716, - /* 1100 */ 2312, 702, 748, 2535, 2508, 2436, 1290, 1293, 1294, 413, - /* 1110 */ 2432, 735, 717, 2408, 2364, 1861, 811, 809, 2312, 401, - /* 1120 */ 1746, 1747, 2066, 731, 2088, 2312, 2312, 197, 747, 1908, - /* 1130 */ 2364, 784, 161, 160, 781, 780, 779, 158, 742, 2141, - /* 1140 */ 731, 2088, 2312, 315, 747, 76, 731, 2088, 2141, 731, - /* 1150 */ 2088, 731, 2088, 1834, 726, 152, 1907, 1719, 1729, 778, - /* 1160 */ 424, 1906, 2132, 2140, 1745, 1748, 728, 2345, 1814, 729, - /* 1170 */ 2383, 321, 2028, 357, 2347, 751, 2349, 2350, 746, 1660, - /* 1180 */ 741, 1658, 2312, 2345, 1905, 1904, 2383, 2456, 1807, 114, - /* 1190 */ 2347, 751, 2349, 2350, 746, 1911, 741, 87, 2306, 1903, - /* 1200 */ 652, 2535, 782, 2436, 1902, 2132, 1901, 413, 2432, 2312, - /* 1210 */ 284, 1663, 1664, 1716, 2312, 1718, 1721, 1722, 1723, 1724, - /* 1220 */ 1725, 1726, 1727, 1728, 743, 739, 1737, 1738, 1740, 1741, - /* 1230 */ 1742, 1743, 2, 48, 46, 139, 783, 2312, 2312, 2132, - /* 1240 */ 1971, 417, 615, 1659, 170, 1926, 837, 86, 673, 2296, - /* 1250 */ 673, 2515, 2312, 2515, 100, 2346, 1744, 2312, 1657, 2312, - /* 1260 */ 616, 1689, 628, 255, 260, 1717, 1392, 258, 748, 2521, - /* 1270 */ 203, 2521, 203, 1969, 2516, 699, 2516, 699, 262, 178, - /* 1280 */ 264, 261, 266, 263, 1390, 265, 1739, 1960, 602, 598, - /* 1290 */ 594, 590, 1958, 254, 210, 630, 2364, 41, 40, 1665, - /* 1300 */ 439, 47, 45, 44, 43, 42, 2480, 159, 2312, 632, - /* 1310 */ 747, 649, 705, 648, 635, 50, 50, 2333, 172, 187, - /* 1320 */ 1893, 1894, 1668, 340, 159, 842, 14, 13, 15, 50, - /* 1330 */ 309, 75, 2346, 297, 96, 686, 1667, 252, 1350, 658, - /* 1340 */ 338, 74, 157, 159, 73, 748, 66, 2455, 791, 2345, - /* 1350 */ 792, 141, 2383, 50, 367, 175, 2347, 751, 2349, 2350, - /* 1360 */ 746, 111, 741, 703, 1746, 1747, 235, 547, 545, 542, - /* 1370 */ 108, 291, 1369, 2364, 1367, 2335, 2025, 714, 2365, 1351, - /* 1380 */ 2024, 2211, 1625, 50, 1942, 2312, 2470, 747, 683, 673, - /* 1390 */ 1846, 1845, 2515, 403, 289, 690, 400, 674, 2477, 715, - /* 1400 */ 720, 1719, 1729, 242, 1575, 313, 723, 63, 1745, 1748, - /* 1410 */ 2521, 203, 251, 244, 1948, 2516, 699, 317, 1437, 249, - /* 1420 */ 579, 1781, 430, 1660, 2212, 1658, 2345, 673, 1730, 2383, - /* 1430 */ 2515, 1952, 114, 2347, 751, 2349, 2350, 746, 241, 741, - /* 1440 */ 755, 157, 2129, 159, 2535, 64, 2436, 140, 2521, 203, - /* 1450 */ 413, 2432, 157, 2516, 699, 1663, 1664, 1716, 333, 1718, - /* 1460 */ 1721, 1722, 1723, 1724, 1725, 1726, 1727, 1728, 743, 739, - /* 1470 */ 1737, 1738, 1740, 1741, 1742, 1743, 2, 666, 2471, 296, - /* 1480 */ 2481, 426, 425, 835, 2346, 711, 303, 299, 2050, 1671, - /* 1490 */ 5, 1673, 438, 433, 84, 83, 469, 748, 380, 216, - /* 1500 */ 446, 1692, 447, 1670, 1744, 458, 1666, 457, 212, 214, - /* 1510 */ 460, 2346, 461, 459, 1599, 1465, 1469, 211, 1476, 328, - /* 1520 */ 1682, 474, 1474, 363, 748, 2364, 448, 162, 1683, 445, - /* 1530 */ 441, 437, 434, 462, 1739, 481, 225, 2312, 483, 747, - /* 1540 */ 487, 489, 528, 506, 494, 517, 2204, 1665, 519, 527, - /* 1550 */ 529, 540, 2364, 541, 538, 230, 543, 229, 544, 232, - /* 1560 */ 546, 548, 1690, 563, 2312, 4, 747, 571, 564, 572, - /* 1570 */ 574, 240, 304, 737, 92, 1685, 706, 243, 2345, 576, - /* 1580 */ 2346, 2383, 1691, 577, 114, 2347, 751, 2349, 2350, 746, - /* 1590 */ 1693, 741, 578, 748, 246, 1694, 2409, 580, 2436, 248, - /* 1600 */ 93, 586, 413, 2432, 607, 2345, 2220, 94, 2383, 253, - /* 1610 */ 360, 114, 2347, 751, 2349, 2350, 746, 609, 741, 638, - /* 1620 */ 116, 2364, 639, 734, 2283, 2436, 2078, 651, 257, 413, - /* 1630 */ 2432, 2074, 259, 2312, 653, 747, 164, 165, 2076, 2072, - /* 1640 */ 97, 153, 166, 276, 167, 2280, 1686, 2279, 661, 329, - /* 1650 */ 2266, 662, 660, 281, 279, 687, 2486, 721, 668, 665, - /* 1660 */ 8, 667, 677, 2485, 696, 675, 404, 678, 676, 2458, - /* 1670 */ 2538, 1674, 294, 1669, 2345, 290, 179, 2383, 707, 293, - /* 1680 */ 115, 2347, 751, 2349, 2350, 746, 286, 741, 288, 295, - /* 1690 */ 292, 2514, 704, 1807, 2436, 2346, 655, 145, 2435, 2432, - /* 1700 */ 1687, 1812, 298, 1677, 1679, 2452, 1810, 1, 748, 719, - /* 1710 */ 190, 305, 154, 2234, 845, 724, 155, 739, 1737, 1738, - /* 1720 */ 1740, 1741, 1742, 1743, 2233, 2232, 330, 2346, 331, 409, - /* 1730 */ 327, 725, 105, 2133, 2089, 332, 2364, 62, 107, 2417, - /* 1740 */ 748, 206, 1272, 335, 753, 839, 193, 836, 2312, 841, - /* 1750 */ 747, 323, 163, 372, 53, 833, 829, 825, 821, 359, - /* 1760 */ 324, 373, 2346, 339, 2304, 337, 2303, 2302, 2364, 344, - /* 1770 */ 81, 358, 348, 2297, 435, 748, 436, 1650, 1651, 209, - /* 1780 */ 2312, 440, 747, 2295, 442, 443, 444, 1649, 2294, 2345, - /* 1790 */ 381, 2292, 2383, 449, 2291, 115, 2347, 751, 2349, 2350, - /* 1800 */ 746, 113, 741, 2364, 318, 451, 2290, 453, 2289, 2436, - /* 1810 */ 1638, 455, 2270, 736, 2432, 2312, 213, 747, 2269, 215, - /* 1820 */ 1602, 749, 82, 1601, 2383, 2247, 2246, 115, 2347, 751, - /* 1830 */ 2349, 2350, 746, 2245, 741, 2346, 727, 467, 468, 2244, - /* 1840 */ 2243, 2436, 2194, 2191, 472, 375, 2432, 1545, 748, 2190, - /* 1850 */ 475, 2184, 479, 478, 2181, 2180, 2345, 2179, 2346, 2383, - /* 1860 */ 218, 2178, 176, 2347, 751, 2349, 2350, 746, 85, 741, - /* 1870 */ 2183, 748, 2182, 220, 2177, 2176, 2364, 2174, 2346, 307, - /* 1880 */ 222, 495, 2171, 497, 2169, 2168, 306, 2173, 2312, 2172, - /* 1890 */ 747, 748, 2167, 2346, 2166, 2189, 2165, 2164, 2163, 2364, - /* 1900 */ 2187, 2170, 2162, 2161, 2160, 277, 748, 2158, 2157, 2156, - /* 1910 */ 2155, 2312, 2154, 747, 224, 2152, 700, 2536, 2153, 2364, - /* 1920 */ 2151, 91, 2150, 2149, 402, 2188, 2186, 2148, 2147, 2345, - /* 1930 */ 2146, 2312, 2383, 747, 2364, 115, 2347, 751, 2349, 2350, - /* 1940 */ 746, 1551, 741, 2145, 228, 2144, 2312, 531, 747, 2436, - /* 1950 */ 533, 2143, 2345, 2142, 2433, 2383, 1408, 1412, 175, 2347, - /* 1960 */ 751, 2349, 2350, 746, 1990, 741, 369, 370, 1404, 1989, - /* 1970 */ 231, 233, 2345, 1988, 1986, 2383, 234, 1983, 357, 2347, - /* 1980 */ 751, 2349, 2350, 746, 549, 741, 551, 2345, 1982, 2346, - /* 1990 */ 2383, 550, 553, 350, 2347, 751, 2349, 2350, 746, 554, - /* 2000 */ 741, 2478, 748, 555, 1975, 557, 1962, 558, 559, 561, - /* 2010 */ 1937, 185, 236, 78, 2332, 1296, 1936, 2268, 79, 195, - /* 2020 */ 2264, 2254, 238, 2242, 569, 2346, 245, 247, 2241, 250, - /* 2030 */ 2364, 2218, 2067, 1985, 1343, 1981, 587, 588, 748, 695, - /* 2040 */ 589, 1979, 2312, 592, 747, 591, 1977, 593, 595, 597, - /* 2050 */ 1974, 596, 599, 600, 601, 1957, 1955, 2346, 1956, 1954, - /* 2060 */ 1933, 2069, 1481, 256, 65, 1480, 2364, 1394, 1972, 1380, - /* 2070 */ 745, 408, 2068, 1393, 1391, 1389, 1388, 1387, 2312, 1386, - /* 2080 */ 747, 1385, 808, 2345, 810, 1382, 2383, 393, 1970, 176, - /* 2090 */ 2347, 751, 2349, 2350, 746, 394, 741, 1961, 2364, 1381, - /* 2100 */ 1379, 395, 1959, 396, 1932, 633, 636, 1931, 1930, 1929, - /* 2110 */ 2312, 640, 747, 642, 1928, 644, 117, 1632, 2267, 2345, - /* 2120 */ 1634, 1631, 2383, 57, 278, 357, 2347, 751, 2349, 2350, - /* 2130 */ 746, 29, 741, 69, 2346, 1636, 2263, 1608, 1612, 58, - /* 2140 */ 2253, 1610, 663, 169, 2537, 664, 2240, 748, 2239, 669, - /* 2150 */ 2346, 2345, 2520, 1863, 2383, 20, 17, 356, 2347, 751, - /* 2160 */ 2349, 2350, 746, 748, 741, 1587, 2402, 282, 2346, 1586, - /* 2170 */ 671, 31, 21, 285, 6, 2364, 679, 7, 287, 200, - /* 2180 */ 416, 748, 2333, 22, 177, 681, 1844, 2312, 189, 747, - /* 2190 */ 33, 2364, 188, 32, 67, 24, 418, 1833, 80, 2238, - /* 2200 */ 1883, 23, 1884, 2312, 1878, 747, 1877, 405, 1882, 2364, - /* 2210 */ 18, 1881, 406, 1804, 1803, 301, 59, 60, 2217, 101, - /* 2220 */ 102, 2312, 180, 747, 25, 2216, 108, 103, 2345, 308, - /* 2230 */ 191, 2383, 314, 2346, 357, 2347, 751, 2349, 2350, 746, - /* 2240 */ 1839, 741, 70, 722, 2345, 104, 748, 2383, 26, 319, - /* 2250 */ 357, 2347, 751, 2349, 2350, 746, 1756, 741, 1755, 13, - /* 2260 */ 11, 1675, 650, 1766, 1734, 2383, 2386, 2346, 352, 2347, - /* 2270 */ 751, 2349, 2350, 746, 2364, 741, 1732, 181, 192, 316, - /* 2280 */ 748, 1709, 752, 740, 39, 754, 2312, 1731, 747, 1701, - /* 2290 */ 2346, 750, 1457, 16, 27, 28, 1341, 1466, 419, 756, - /* 2300 */ 758, 1463, 759, 748, 1462, 761, 1459, 764, 2364, 762, - /* 2310 */ 765, 767, 1453, 768, 770, 1451, 771, 109, 1456, 322, - /* 2320 */ 2312, 110, 747, 77, 1475, 1455, 1471, 2345, 1376, 1454, - /* 2330 */ 2383, 2364, 1373, 342, 2347, 751, 2349, 2350, 746, 1372, - /* 2340 */ 741, 207, 785, 2312, 1371, 747, 1370, 2346, 1368, 1366, - /* 2350 */ 1365, 1364, 796, 798, 1402, 1362, 1401, 1361, 1360, 1359, - /* 2360 */ 748, 2345, 1358, 1357, 2383, 1356, 1398, 341, 2347, 751, - /* 2370 */ 2349, 2350, 746, 1396, 741, 1353, 1352, 1349, 1348, 1347, - /* 2380 */ 1346, 1980, 818, 819, 2345, 823, 820, 2383, 2364, 1978, - /* 2390 */ 343, 2347, 751, 2349, 2350, 746, 822, 741, 824, 1976, - /* 2400 */ 2312, 826, 747, 827, 828, 1973, 830, 832, 1953, 831, - /* 2410 */ 834, 1285, 1927, 1273, 326, 838, 840, 1897, 1661, 336, - /* 2420 */ 2346, 843, 844, 1897, 1897, 1897, 1897, 1897, 1897, 1897, - /* 2430 */ 1897, 1897, 1897, 748, 1897, 1897, 1897, 1897, 1897, 1897, - /* 2440 */ 2346, 2345, 1897, 1897, 2383, 1897, 1897, 349, 2347, 751, - /* 2450 */ 2349, 2350, 746, 748, 741, 1897, 1897, 1897, 1897, 1897, - /* 2460 */ 1897, 2364, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, - /* 2470 */ 1897, 1897, 1897, 2312, 1897, 747, 1897, 1897, 1897, 1897, - /* 2480 */ 1897, 2364, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, - /* 2490 */ 1897, 1897, 1897, 2312, 1897, 747, 1897, 1897, 2346, 1897, - /* 2500 */ 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, - /* 2510 */ 1897, 748, 1897, 2346, 2345, 1897, 1897, 2383, 1897, 1897, - /* 2520 */ 353, 2347, 751, 2349, 2350, 746, 748, 741, 1897, 1897, - /* 2530 */ 1897, 1897, 1897, 1897, 2345, 2346, 1897, 2383, 1897, 2364, - /* 2540 */ 345, 2347, 751, 2349, 2350, 746, 1897, 741, 748, 1897, - /* 2550 */ 1897, 2312, 1897, 747, 2364, 1897, 1897, 1897, 1897, 1897, - /* 2560 */ 1897, 1897, 1897, 1897, 1897, 1897, 2312, 1897, 747, 1897, - /* 2570 */ 1897, 1897, 1897, 1897, 1897, 1897, 2364, 1897, 1897, 1897, - /* 2580 */ 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 2312, 1897, - /* 2590 */ 747, 1897, 2345, 2346, 1897, 2383, 1897, 1897, 354, 2347, - /* 2600 */ 751, 2349, 2350, 746, 1897, 741, 748, 2345, 2346, 1897, - /* 2610 */ 2383, 1897, 1897, 346, 2347, 751, 2349, 2350, 746, 1897, - /* 2620 */ 741, 748, 1897, 1897, 1897, 1897, 1897, 1897, 2346, 2345, - /* 2630 */ 1897, 1897, 2383, 1897, 2364, 355, 2347, 751, 2349, 2350, - /* 2640 */ 746, 748, 741, 1897, 1897, 1897, 2312, 1897, 747, 2364, - /* 2650 */ 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, - /* 2660 */ 1897, 2312, 1897, 747, 1897, 1897, 1897, 1897, 1897, 2364, - /* 2670 */ 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, - /* 2680 */ 1897, 2312, 1897, 747, 1897, 1897, 1897, 2345, 1897, 1897, - /* 2690 */ 2383, 1897, 1897, 347, 2347, 751, 2349, 2350, 746, 1897, - /* 2700 */ 741, 2346, 2345, 1897, 1897, 2383, 1897, 1897, 361, 2347, - /* 2710 */ 751, 2349, 2350, 746, 748, 741, 1897, 1897, 1897, 1897, - /* 2720 */ 1897, 2346, 2345, 1897, 1897, 2383, 1897, 1897, 362, 2347, - /* 2730 */ 751, 2349, 2350, 746, 748, 741, 1897, 1897, 2346, 1897, - /* 2740 */ 1897, 1897, 2364, 1897, 1897, 1897, 1897, 1897, 1897, 1897, - /* 2750 */ 1897, 748, 1897, 1897, 2312, 1897, 747, 1897, 1897, 1897, - /* 2760 */ 1897, 1897, 2364, 1897, 1897, 1897, 1897, 1897, 1897, 1897, - /* 2770 */ 1897, 1897, 1897, 1897, 2312, 1897, 747, 1897, 1897, 2364, - /* 2780 */ 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, - /* 2790 */ 1897, 2312, 1897, 747, 1897, 2345, 1897, 1897, 2383, 1897, - /* 2800 */ 1897, 2358, 2347, 751, 2349, 2350, 746, 2346, 741, 1897, - /* 2810 */ 1897, 1897, 1897, 1897, 1897, 2345, 1897, 1897, 2383, 1897, - /* 2820 */ 748, 2357, 2347, 751, 2349, 2350, 746, 1897, 741, 1897, - /* 2830 */ 1897, 1897, 2345, 1897, 1897, 2383, 1897, 1897, 2356, 2347, - /* 2840 */ 751, 2349, 2350, 746, 1897, 741, 1897, 1897, 2364, 1897, - /* 2850 */ 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, - /* 2860 */ 2312, 1897, 747, 1897, 1897, 2346, 1897, 1897, 1897, 1897, - /* 2870 */ 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 748, 1897, - /* 2880 */ 2346, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, - /* 2890 */ 1897, 1897, 1897, 748, 1897, 1897, 1897, 1897, 1897, 1897, - /* 2900 */ 1897, 2345, 2346, 1897, 2383, 1897, 2364, 377, 2347, 751, - /* 2910 */ 2349, 2350, 746, 1897, 741, 748, 1897, 1897, 2312, 1897, - /* 2920 */ 747, 2364, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, - /* 2930 */ 1897, 1897, 1897, 2312, 1897, 747, 1897, 1897, 1897, 1897, - /* 2940 */ 1897, 1897, 1897, 2364, 1897, 1897, 1897, 1897, 1897, 1897, - /* 2950 */ 1897, 1897, 1897, 1897, 1897, 2312, 1897, 747, 1897, 2345, - /* 2960 */ 2346, 1897, 2383, 1897, 1897, 378, 2347, 751, 2349, 2350, - /* 2970 */ 746, 1897, 741, 748, 2345, 2346, 1897, 2383, 1897, 1897, - /* 2980 */ 374, 2347, 751, 2349, 2350, 746, 1897, 741, 748, 1897, - /* 2990 */ 1897, 1897, 1897, 1897, 1897, 1897, 2345, 1897, 1897, 2383, - /* 3000 */ 1897, 2364, 379, 2347, 751, 2349, 2350, 746, 1897, 741, - /* 3010 */ 1897, 1897, 1897, 2312, 1897, 747, 2364, 1897, 1897, 1897, - /* 3020 */ 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 2312, 1897, - /* 3030 */ 747, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, - /* 3040 */ 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, 1897, - /* 3050 */ 1897, 1897, 1897, 1897, 749, 1897, 1897, 2383, 1897, 1897, - /* 3060 */ 352, 2347, 751, 2349, 2350, 746, 1897, 741, 1897, 2345, - /* 3070 */ 1897, 1897, 2383, 1897, 1897, 351, 2347, 751, 2349, 2350, - /* 3080 */ 746, 1897, 741, + /* 690 */ 673, 1661, 305, 1659, 275, 2346, 732, 2089, 2384, 226, + /* 700 */ 2448, 114, 2348, 752, 2350, 2351, 747, 1920, 742, 433, + /* 710 */ 421, 305, 778, 2412, 432, 2437, 504, 159, 171, 414, + /* 720 */ 2433, 660, 2266, 1664, 1665, 1717, 2091, 1719, 1722, 1723, + /* 730 */ 1724, 1725, 1726, 1727, 1728, 1729, 744, 740, 1738, 1739, + /* 740 */ 1741, 1742, 1743, 1744, 2, 48, 46, 1750, 2347, 421, + /* 750 */ 427, 426, 635, 418, 1408, 1660, 1842, 168, 424, 674, + /* 760 */ 2313, 749, 2516, 1952, 400, 2091, 171, 647, 1745, 1407, + /* 770 */ 1658, 1843, 2140, 2160, 2091, 1667, 732, 2089, 2347, 106, + /* 780 */ 2522, 203, 95, 271, 1776, 2517, 700, 1717, 1315, 2365, + /* 790 */ 1314, 749, 1623, 2475, 223, 2142, 505, 1689, 1740, 638, + /* 800 */ 1396, 2313, 408, 748, 2082, 1892, 632, 630, 2085, 1721, + /* 810 */ 2140, 1666, 1841, 268, 47, 45, 44, 43, 42, 2365, + /* 820 */ 41, 40, 61, 1316, 47, 45, 44, 43, 42, 527, + /* 830 */ 671, 2313, 1689, 748, 1689, 90, 538, 843, 89, 1721, + /* 840 */ 49, 1398, 2346, 732, 2089, 2384, 2347, 1808, 114, 2348, + /* 850 */ 752, 2350, 2351, 747, 72, 742, 1660, 71, 1666, 749, + /* 860 */ 2536, 2488, 2437, 506, 35, 1718, 414, 2433, 702, 732, + /* 870 */ 2089, 1658, 2346, 1850, 1781, 2384, 1747, 1748, 114, 2348, + /* 880 */ 752, 2350, 2351, 747, 274, 742, 1919, 2365, 2066, 585, + /* 890 */ 2536, 228, 2437, 2142, 563, 1718, 414, 2433, 1816, 2313, + /* 900 */ 413, 748, 335, 561, 88, 2119, 557, 553, 2140, 1891, + /* 910 */ 732, 2089, 1666, 1720, 1730, 526, 227, 1918, 326, 1412, + /* 920 */ 1746, 1749, 686, 685, 1848, 1849, 1851, 1852, 1853, 2142, + /* 930 */ 2086, 1296, 512, 511, 1411, 1661, 422, 1659, 843, 2313, + /* 940 */ 2346, 613, 1670, 2384, 2140, 612, 114, 2348, 752, 2350, + /* 950 */ 2351, 747, 1917, 742, 1916, 1294, 1295, 1915, 2536, 194, + /* 960 */ 2437, 2076, 1628, 1629, 414, 2433, 2072, 1664, 1665, 1717, + /* 970 */ 2313, 1719, 1722, 1723, 1724, 1725, 1726, 1727, 1728, 1729, + /* 980 */ 744, 740, 1738, 1739, 1741, 1742, 1743, 1744, 2, 48, + /* 990 */ 46, 2347, 607, 606, 199, 2064, 198, 418, 734, 1660, + /* 1000 */ 2409, 540, 624, 623, 749, 2313, 681, 2313, 801, 2093, + /* 1010 */ 2313, 2050, 1745, 1690, 1658, 41, 40, 732, 2089, 47, + /* 1020 */ 45, 44, 43, 42, 785, 161, 160, 782, 781, 780, + /* 1030 */ 158, 171, 2365, 44, 43, 42, 1661, 276, 1659, 2092, + /* 1040 */ 30, 2452, 1740, 281, 2313, 1689, 748, 1914, 1690, 1685, + /* 1050 */ 1690, 312, 313, 41, 40, 1666, 311, 47, 45, 44, + /* 1060 */ 43, 42, 732, 2089, 1289, 1913, 2294, 2447, 1664, 1665, + /* 1070 */ 41, 40, 1910, 2347, 47, 45, 44, 43, 42, 732, + /* 1080 */ 2089, 843, 284, 1296, 49, 2346, 749, 148, 2384, 2347, + /* 1090 */ 2408, 114, 2348, 752, 2350, 2351, 747, 2142, 742, 717, + /* 1100 */ 2313, 703, 749, 2536, 2509, 2437, 1291, 1294, 1295, 414, + /* 1110 */ 2433, 736, 718, 2409, 2365, 1862, 812, 810, 2313, 402, + /* 1120 */ 1747, 1748, 2067, 732, 2089, 2313, 2313, 197, 748, 1909, + /* 1130 */ 2365, 785, 161, 160, 782, 781, 780, 158, 743, 2142, + /* 1140 */ 732, 2089, 2313, 316, 748, 76, 732, 2089, 2142, 732, + /* 1150 */ 2089, 732, 2089, 1835, 727, 152, 1908, 1720, 1730, 779, + /* 1160 */ 425, 1907, 2133, 2141, 1746, 1749, 729, 2346, 1815, 730, + /* 1170 */ 2384, 322, 2029, 358, 2348, 752, 2350, 2351, 747, 1661, + /* 1180 */ 742, 1659, 2313, 2346, 1906, 1905, 2384, 2457, 1808, 114, + /* 1190 */ 2348, 752, 2350, 2351, 747, 1912, 742, 87, 2307, 1904, + /* 1200 */ 653, 2536, 783, 2437, 1903, 2133, 1902, 414, 2433, 2313, + /* 1210 */ 285, 1664, 1665, 1717, 2313, 1719, 1722, 1723, 1724, 1725, + /* 1220 */ 1726, 1727, 1728, 1729, 744, 740, 1738, 1739, 1741, 1742, + /* 1230 */ 1743, 1744, 2, 48, 46, 139, 784, 2313, 2313, 2133, + /* 1240 */ 1972, 418, 616, 1660, 170, 1927, 838, 86, 674, 2297, + /* 1250 */ 674, 2516, 2313, 2516, 100, 2347, 1745, 2313, 1658, 2313, + /* 1260 */ 617, 1690, 629, 256, 261, 1718, 1393, 259, 749, 2522, + /* 1270 */ 203, 2522, 203, 1970, 2517, 700, 2517, 700, 263, 178, + /* 1280 */ 265, 262, 267, 264, 1391, 266, 1740, 1961, 603, 599, + /* 1290 */ 595, 591, 1959, 255, 210, 631, 2365, 41, 40, 1666, + /* 1300 */ 440, 47, 45, 44, 43, 42, 2481, 159, 2313, 633, + /* 1310 */ 748, 650, 706, 649, 636, 50, 50, 2334, 172, 187, + /* 1320 */ 1894, 1895, 1669, 341, 159, 843, 14, 13, 15, 50, + /* 1330 */ 310, 75, 2347, 298, 96, 687, 1668, 253, 1351, 659, + /* 1340 */ 339, 74, 157, 159, 73, 749, 66, 2456, 792, 2346, + /* 1350 */ 793, 141, 2384, 50, 368, 175, 2348, 752, 2350, 2351, + /* 1360 */ 747, 111, 742, 704, 1747, 1748, 236, 548, 546, 543, + /* 1370 */ 108, 292, 1370, 2365, 1368, 2336, 2026, 715, 2366, 1352, + /* 1380 */ 2025, 2212, 1626, 50, 1943, 2313, 2471, 748, 684, 674, + /* 1390 */ 1847, 1846, 2516, 404, 290, 691, 401, 675, 2478, 716, + /* 1400 */ 721, 1720, 1730, 243, 1576, 314, 724, 63, 1746, 1749, + /* 1410 */ 2522, 203, 252, 245, 1949, 2517, 700, 318, 1438, 250, + /* 1420 */ 580, 1782, 431, 1661, 2213, 1659, 2346, 674, 1731, 2384, + /* 1430 */ 2516, 1953, 114, 2348, 752, 2350, 2351, 747, 242, 742, + /* 1440 */ 756, 157, 2130, 159, 2536, 64, 2437, 140, 2522, 203, + /* 1450 */ 414, 2433, 157, 2517, 700, 1664, 1665, 1717, 334, 1719, + /* 1460 */ 1722, 1723, 1724, 1725, 1726, 1727, 1728, 1729, 744, 740, + /* 1470 */ 1738, 1739, 1741, 1742, 1743, 1744, 2, 667, 2472, 297, + /* 1480 */ 2482, 427, 426, 836, 2347, 712, 304, 300, 2051, 1672, + /* 1490 */ 5, 1674, 439, 434, 84, 83, 470, 749, 381, 216, + /* 1500 */ 447, 1693, 448, 1671, 1745, 459, 1667, 458, 212, 214, + /* 1510 */ 461, 2347, 462, 460, 1600, 1466, 1470, 211, 1477, 329, + /* 1520 */ 1683, 475, 1475, 364, 749, 2365, 449, 162, 1684, 446, + /* 1530 */ 442, 438, 435, 463, 1740, 482, 225, 2313, 484, 748, + /* 1540 */ 488, 490, 529, 507, 495, 518, 2205, 1666, 520, 525, + /* 1550 */ 528, 530, 2365, 541, 542, 539, 231, 230, 544, 545, + /* 1560 */ 233, 547, 549, 1691, 2313, 564, 748, 4, 565, 572, + /* 1570 */ 573, 575, 305, 738, 241, 92, 707, 1686, 2346, 577, + /* 1580 */ 2347, 2384, 1692, 244, 114, 2348, 752, 2350, 2351, 747, + /* 1590 */ 578, 742, 1694, 749, 579, 1695, 2410, 581, 2437, 247, + /* 1600 */ 249, 587, 414, 2433, 2221, 2346, 93, 94, 2384, 254, + /* 1610 */ 608, 114, 2348, 752, 2350, 2351, 747, 639, 742, 640, + /* 1620 */ 116, 2365, 361, 735, 2284, 2437, 2281, 652, 610, 414, + /* 1630 */ 2433, 2079, 258, 2313, 654, 748, 2075, 260, 164, 165, + /* 1640 */ 2077, 97, 2073, 277, 166, 167, 153, 2280, 1687, 282, + /* 1650 */ 662, 330, 2267, 661, 663, 688, 280, 2487, 669, 722, + /* 1660 */ 8, 666, 678, 2486, 697, 676, 405, 679, 2459, 668, + /* 1670 */ 677, 1675, 2539, 1670, 2346, 179, 291, 2384, 708, 293, + /* 1680 */ 115, 2348, 752, 2350, 2351, 747, 287, 742, 296, 289, + /* 1690 */ 2515, 705, 294, 1808, 2437, 2347, 656, 299, 2436, 2433, + /* 1700 */ 295, 1688, 145, 1678, 1680, 1813, 1811, 1, 749, 2453, + /* 1710 */ 190, 306, 154, 720, 846, 725, 155, 740, 1738, 1739, + /* 1720 */ 1741, 1742, 1743, 1744, 2235, 2234, 331, 2347, 2233, 332, + /* 1730 */ 328, 726, 410, 105, 2090, 333, 2365, 62, 107, 2418, + /* 1740 */ 749, 336, 206, 324, 754, 1273, 193, 2134, 2313, 840, + /* 1750 */ 748, 837, 163, 842, 53, 834, 830, 826, 822, 360, + /* 1760 */ 325, 338, 2347, 373, 340, 345, 2305, 2304, 2365, 359, + /* 1770 */ 2303, 349, 374, 81, 2298, 749, 436, 437, 1651, 1652, + /* 1780 */ 2313, 209, 748, 441, 2296, 443, 444, 445, 1650, 2346, + /* 1790 */ 2295, 382, 2384, 2293, 450, 115, 2348, 752, 2350, 2351, + /* 1800 */ 747, 113, 742, 2365, 319, 2292, 452, 2291, 454, 2437, + /* 1810 */ 2290, 1639, 456, 737, 2433, 2313, 2271, 748, 213, 2270, + /* 1820 */ 215, 750, 82, 1603, 2384, 1602, 2248, 115, 2348, 752, + /* 1830 */ 2350, 2351, 747, 2247, 742, 2347, 728, 2246, 468, 469, + /* 1840 */ 2245, 2437, 2244, 473, 2195, 376, 2433, 1546, 749, 2192, + /* 1850 */ 476, 2191, 2185, 480, 479, 2182, 2346, 218, 2347, 2384, + /* 1860 */ 2181, 2180, 176, 2348, 752, 2350, 2351, 747, 85, 742, + /* 1870 */ 2179, 749, 2184, 220, 2183, 2178, 2365, 2177, 2347, 308, + /* 1880 */ 222, 496, 2172, 498, 2170, 2169, 307, 2175, 2313, 2174, + /* 1890 */ 748, 749, 2173, 2347, 2168, 2167, 2190, 2166, 2165, 2365, + /* 1900 */ 2164, 2188, 2171, 2163, 2162, 278, 749, 2161, 2159, 2158, + /* 1910 */ 2157, 2313, 2156, 748, 224, 2153, 701, 2537, 2155, 2365, + /* 1920 */ 2154, 91, 2152, 2151, 403, 2150, 2189, 2187, 2149, 2346, + /* 1930 */ 2148, 2313, 2384, 748, 2365, 115, 2348, 752, 2350, 2351, + /* 1940 */ 747, 1552, 742, 2147, 229, 2146, 2313, 532, 748, 2437, + /* 1950 */ 2145, 2144, 2346, 2143, 2434, 2384, 1409, 534, 175, 2348, + /* 1960 */ 752, 2350, 2351, 747, 1413, 742, 370, 371, 1991, 1405, + /* 1970 */ 232, 1990, 2346, 1989, 1987, 2384, 234, 1984, 358, 2348, + /* 1980 */ 752, 2350, 2351, 747, 550, 742, 235, 2346, 552, 2347, + /* 1990 */ 2384, 551, 1983, 351, 2348, 752, 2350, 2351, 747, 554, + /* 2000 */ 742, 2479, 749, 555, 1976, 556, 558, 559, 560, 1963, + /* 2010 */ 1938, 185, 562, 2333, 78, 237, 195, 1297, 1937, 239, + /* 2020 */ 2269, 2265, 79, 2255, 2243, 2347, 246, 248, 570, 2242, + /* 2030 */ 2365, 251, 2219, 2068, 1986, 1982, 588, 1344, 749, 696, + /* 2040 */ 589, 1980, 2313, 590, 748, 592, 593, 594, 1978, 596, + /* 2050 */ 1975, 597, 600, 598, 1958, 602, 1956, 2347, 601, 1957, + /* 2060 */ 1955, 1934, 2070, 65, 1482, 1481, 2365, 257, 2069, 1381, + /* 2070 */ 746, 409, 1973, 1395, 1394, 1392, 1390, 1389, 2313, 1388, + /* 2080 */ 748, 1387, 1386, 2346, 809, 811, 2384, 394, 1971, 176, + /* 2090 */ 2348, 752, 2350, 2351, 747, 1383, 742, 395, 2365, 1962, + /* 2100 */ 1382, 1380, 396, 1960, 397, 1933, 634, 637, 1932, 1931, + /* 2110 */ 2313, 641, 748, 1930, 643, 1929, 645, 117, 1633, 2346, + /* 2120 */ 1635, 1632, 2384, 2268, 1637, 358, 2348, 752, 2350, 2351, + /* 2130 */ 747, 57, 742, 29, 2347, 69, 2264, 58, 1613, 279, + /* 2140 */ 1611, 1609, 2254, 169, 2538, 283, 664, 749, 2241, 2240, + /* 2150 */ 2347, 2346, 20, 2521, 2384, 17, 31, 357, 2348, 752, + /* 2160 */ 2350, 2351, 747, 749, 742, 665, 2403, 1588, 2347, 1587, + /* 2170 */ 670, 6, 7, 21, 1864, 2365, 286, 672, 680, 682, + /* 2180 */ 417, 749, 200, 2334, 22, 189, 288, 2313, 33, 748, + /* 2190 */ 23, 2365, 67, 1845, 1834, 24, 419, 1884, 177, 188, + /* 2200 */ 32, 18, 80, 2313, 1885, 748, 1879, 1878, 406, 2365, + /* 2210 */ 1883, 1882, 407, 302, 1805, 1804, 60, 180, 2239, 2218, + /* 2220 */ 102, 2313, 309, 748, 101, 2217, 103, 59, 2346, 320, + /* 2230 */ 317, 2384, 25, 2347, 358, 2348, 752, 2350, 2351, 747, + /* 2240 */ 1840, 742, 191, 723, 2346, 315, 749, 2384, 70, 26, + /* 2250 */ 358, 2348, 752, 2350, 2351, 747, 13, 742, 1676, 108, + /* 2260 */ 104, 1757, 651, 11, 1756, 2384, 1735, 2347, 353, 2348, + /* 2270 */ 752, 2350, 2351, 747, 2365, 742, 181, 192, 1710, 2387, + /* 2280 */ 749, 755, 753, 741, 420, 1733, 2313, 1732, 748, 1767, + /* 2290 */ 2347, 1458, 39, 16, 27, 759, 1702, 28, 762, 1467, + /* 2300 */ 757, 765, 1464, 749, 760, 768, 1463, 763, 2365, 1460, + /* 2310 */ 766, 771, 1454, 769, 323, 1452, 751, 772, 1472, 109, + /* 2320 */ 2313, 110, 748, 1457, 1456, 1476, 1377, 2346, 77, 1342, + /* 2330 */ 2384, 2365, 1374, 343, 2348, 752, 2350, 2351, 747, 1455, + /* 2340 */ 742, 786, 1373, 2313, 1372, 748, 1371, 2347, 1369, 1367, + /* 2350 */ 1366, 1365, 797, 799, 1403, 1402, 207, 1363, 1362, 1361, + /* 2360 */ 749, 2346, 1360, 1359, 2384, 1358, 1357, 342, 2348, 752, + /* 2370 */ 2350, 2351, 747, 1397, 742, 1399, 1354, 1348, 1353, 1350, + /* 2380 */ 1349, 1347, 1981, 819, 2346, 820, 1979, 2384, 2365, 821, + /* 2390 */ 344, 2348, 752, 2350, 2351, 747, 823, 742, 825, 1977, + /* 2400 */ 2313, 824, 748, 827, 828, 829, 1974, 831, 832, 833, + /* 2410 */ 1954, 835, 1286, 1928, 1274, 327, 839, 841, 845, 1662, + /* 2420 */ 2347, 1898, 337, 844, 1898, 1898, 1898, 1898, 1898, 1898, + /* 2430 */ 1898, 1898, 1898, 749, 1898, 1898, 1898, 1898, 1898, 1898, + /* 2440 */ 2347, 2346, 1898, 1898, 2384, 1898, 1898, 350, 2348, 752, + /* 2450 */ 2350, 2351, 747, 749, 742, 1898, 1898, 1898, 1898, 1898, + /* 2460 */ 1898, 2365, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, + /* 2470 */ 1898, 1898, 1898, 2313, 1898, 748, 1898, 1898, 1898, 1898, + /* 2480 */ 1898, 2365, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, + /* 2490 */ 1898, 1898, 1898, 2313, 1898, 748, 1898, 1898, 2347, 1898, + /* 2500 */ 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, + /* 2510 */ 1898, 749, 1898, 2347, 2346, 1898, 1898, 2384, 1898, 1898, + /* 2520 */ 354, 2348, 752, 2350, 2351, 747, 749, 742, 1898, 1898, + /* 2530 */ 1898, 1898, 1898, 1898, 2346, 2347, 1898, 2384, 1898, 2365, + /* 2540 */ 346, 2348, 752, 2350, 2351, 747, 1898, 742, 749, 1898, + /* 2550 */ 1898, 2313, 1898, 748, 2365, 1898, 1898, 1898, 1898, 1898, + /* 2560 */ 1898, 1898, 1898, 1898, 1898, 1898, 2313, 1898, 748, 1898, + /* 2570 */ 1898, 1898, 1898, 1898, 1898, 1898, 2365, 1898, 1898, 1898, + /* 2580 */ 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 2313, 1898, + /* 2590 */ 748, 1898, 2346, 2347, 1898, 2384, 1898, 1898, 355, 2348, + /* 2600 */ 752, 2350, 2351, 747, 1898, 742, 749, 2346, 2347, 1898, + /* 2610 */ 2384, 1898, 1898, 347, 2348, 752, 2350, 2351, 747, 1898, + /* 2620 */ 742, 749, 1898, 1898, 1898, 1898, 1898, 1898, 2347, 2346, + /* 2630 */ 1898, 1898, 2384, 1898, 2365, 356, 2348, 752, 2350, 2351, + /* 2640 */ 747, 749, 742, 1898, 1898, 1898, 2313, 1898, 748, 2365, + /* 2650 */ 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, + /* 2660 */ 1898, 2313, 1898, 748, 1898, 1898, 1898, 1898, 1898, 2365, + /* 2670 */ 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, + /* 2680 */ 1898, 2313, 1898, 748, 1898, 1898, 1898, 2346, 1898, 1898, + /* 2690 */ 2384, 1898, 1898, 348, 2348, 752, 2350, 2351, 747, 1898, + /* 2700 */ 742, 2347, 2346, 1898, 1898, 2384, 1898, 1898, 362, 2348, + /* 2710 */ 752, 2350, 2351, 747, 749, 742, 1898, 1898, 1898, 1898, + /* 2720 */ 1898, 2347, 2346, 1898, 1898, 2384, 1898, 1898, 363, 2348, + /* 2730 */ 752, 2350, 2351, 747, 749, 742, 1898, 1898, 2347, 1898, + /* 2740 */ 1898, 1898, 2365, 1898, 1898, 1898, 1898, 1898, 1898, 1898, + /* 2750 */ 1898, 749, 1898, 1898, 2313, 1898, 748, 1898, 1898, 1898, + /* 2760 */ 1898, 1898, 2365, 1898, 1898, 1898, 1898, 1898, 1898, 1898, + /* 2770 */ 1898, 1898, 1898, 1898, 2313, 1898, 748, 1898, 1898, 2365, + /* 2780 */ 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, + /* 2790 */ 1898, 2313, 1898, 748, 1898, 2346, 1898, 1898, 2384, 1898, + /* 2800 */ 1898, 2359, 2348, 752, 2350, 2351, 747, 2347, 742, 1898, + /* 2810 */ 1898, 1898, 1898, 1898, 1898, 2346, 1898, 1898, 2384, 1898, + /* 2820 */ 749, 2358, 2348, 752, 2350, 2351, 747, 1898, 742, 1898, + /* 2830 */ 1898, 1898, 2346, 1898, 1898, 2384, 1898, 1898, 2357, 2348, + /* 2840 */ 752, 2350, 2351, 747, 1898, 742, 1898, 1898, 2365, 1898, + /* 2850 */ 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, + /* 2860 */ 2313, 1898, 748, 1898, 1898, 2347, 1898, 1898, 1898, 1898, + /* 2870 */ 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 749, 1898, + /* 2880 */ 2347, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, + /* 2890 */ 1898, 1898, 1898, 749, 1898, 1898, 1898, 1898, 1898, 1898, + /* 2900 */ 1898, 2346, 2347, 1898, 2384, 1898, 2365, 378, 2348, 752, + /* 2910 */ 2350, 2351, 747, 1898, 742, 749, 1898, 1898, 2313, 1898, + /* 2920 */ 748, 2365, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, + /* 2930 */ 1898, 1898, 1898, 2313, 1898, 748, 1898, 1898, 1898, 1898, + /* 2940 */ 1898, 1898, 1898, 2365, 1898, 1898, 1898, 1898, 1898, 1898, + /* 2950 */ 1898, 1898, 1898, 1898, 1898, 2313, 1898, 748, 1898, 2346, + /* 2960 */ 2347, 1898, 2384, 1898, 1898, 379, 2348, 752, 2350, 2351, + /* 2970 */ 747, 1898, 742, 749, 2346, 2347, 1898, 2384, 1898, 1898, + /* 2980 */ 375, 2348, 752, 2350, 2351, 747, 1898, 742, 749, 1898, + /* 2990 */ 1898, 1898, 1898, 1898, 1898, 1898, 2346, 1898, 1898, 2384, + /* 3000 */ 1898, 2365, 380, 2348, 752, 2350, 2351, 747, 1898, 742, + /* 3010 */ 1898, 1898, 1898, 2313, 1898, 748, 2365, 1898, 1898, 1898, + /* 3020 */ 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 2313, 1898, + /* 3030 */ 748, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, + /* 3040 */ 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, 1898, + /* 3050 */ 1898, 1898, 1898, 1898, 750, 1898, 1898, 2384, 1898, 1898, + /* 3060 */ 353, 2348, 752, 2350, 2351, 747, 1898, 742, 1898, 2346, + /* 3070 */ 1898, 1898, 2384, 1898, 1898, 352, 2348, 752, 2350, 2351, + /* 3080 */ 747, 1898, 742, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 353, 382, 360, 395, 429, 363, 364, 1, 2, 434, @@ -688,38 +1039,38 @@ static const YYCODETYPE yy_lookahead[] = { /* 1520 */ 20, 365, 108, 223, 366, 394, 226, 108, 20, 229, /* 1530 */ 230, 231, 232, 233, 65, 366, 45, 406, 415, 408, /* 1540 */ 366, 415, 179, 365, 412, 366, 365, 78, 415, 412, - /* 1550 */ 412, 105, 394, 378, 103, 365, 102, 377, 376, 365, - /* 1560 */ 365, 365, 20, 358, 406, 50, 408, 358, 362, 362, - /* 1570 */ 441, 374, 272, 104, 374, 20, 297, 374, 447, 408, - /* 1580 */ 353, 450, 20, 367, 453, 454, 455, 456, 457, 458, - /* 1590 */ 20, 460, 431, 366, 374, 20, 465, 367, 467, 374, - /* 1600 */ 374, 365, 471, 472, 358, 447, 422, 374, 450, 374, - /* 1610 */ 358, 453, 454, 455, 456, 457, 458, 394, 460, 356, - /* 1620 */ 365, 394, 356, 465, 406, 467, 394, 221, 394, 471, + /* 1550 */ 412, 412, 394, 105, 378, 103, 365, 377, 102, 376, + /* 1560 */ 365, 365, 365, 20, 406, 358, 408, 50, 362, 358, + /* 1570 */ 362, 441, 272, 104, 374, 374, 297, 20, 447, 408, + /* 1580 */ 353, 450, 20, 374, 453, 454, 455, 456, 457, 458, + /* 1590 */ 367, 460, 20, 366, 431, 20, 465, 367, 467, 374, + /* 1600 */ 374, 365, 471, 472, 422, 447, 374, 374, 450, 374, + /* 1610 */ 358, 453, 454, 455, 456, 457, 458, 356, 460, 356, + /* 1620 */ 365, 394, 358, 465, 406, 467, 406, 221, 394, 471, /* 1630 */ 472, 394, 394, 406, 445, 408, 394, 394, 394, 394, - /* 1640 */ 107, 443, 394, 372, 394, 406, 20, 406, 208, 441, - /* 1650 */ 440, 438, 207, 372, 437, 282, 490, 281, 365, 408, - /* 1660 */ 290, 430, 406, 490, 193, 276, 299, 292, 291, 493, - /* 1670 */ 510, 202, 487, 204, 447, 492, 490, 450, 296, 488, - /* 1680 */ 453, 454, 455, 456, 457, 458, 424, 460, 424, 430, - /* 1690 */ 489, 504, 294, 271, 467, 353, 1, 366, 471, 472, - /* 1700 */ 20, 117, 503, 234, 235, 452, 273, 485, 366, 406, + /* 1640 */ 394, 107, 394, 372, 394, 394, 443, 406, 20, 372, + /* 1650 */ 208, 441, 440, 207, 438, 282, 437, 490, 365, 281, + /* 1660 */ 290, 408, 406, 490, 193, 276, 299, 292, 493, 430, + /* 1670 */ 291, 202, 510, 204, 447, 490, 492, 450, 296, 489, + /* 1680 */ 453, 454, 455, 456, 457, 458, 424, 460, 430, 424, + /* 1690 */ 504, 294, 488, 271, 467, 353, 1, 503, 471, 472, + /* 1700 */ 487, 20, 366, 234, 235, 117, 273, 485, 366, 452, /* 1710 */ 367, 372, 372, 406, 19, 185, 372, 248, 249, 250, - /* 1720 */ 251, 252, 253, 254, 406, 406, 424, 353, 424, 406, - /* 1730 */ 35, 420, 372, 406, 366, 390, 394, 107, 107, 470, - /* 1740 */ 366, 483, 22, 365, 398, 355, 51, 38, 406, 358, - /* 1750 */ 408, 372, 359, 425, 433, 60, 61, 62, 63, 442, - /* 1760 */ 65, 425, 353, 351, 0, 373, 0, 0, 394, 388, - /* 1770 */ 45, 388, 388, 0, 37, 366, 227, 37, 37, 37, - /* 1780 */ 406, 227, 408, 0, 37, 37, 227, 37, 0, 447, - /* 1790 */ 227, 0, 450, 37, 0, 453, 454, 455, 456, 457, - /* 1800 */ 458, 106, 460, 394, 109, 37, 0, 22, 0, 467, - /* 1810 */ 222, 37, 0, 471, 472, 406, 210, 408, 0, 210, - /* 1820 */ 204, 447, 211, 202, 450, 0, 0, 453, 454, 455, - /* 1830 */ 456, 457, 458, 0, 460, 353, 141, 198, 197, 0, - /* 1840 */ 0, 467, 148, 0, 49, 471, 472, 49, 366, 0, - /* 1850 */ 37, 0, 51, 37, 0, 0, 447, 0, 353, 450, - /* 1860 */ 49, 0, 453, 454, 455, 456, 457, 458, 45, 460, + /* 1720 */ 251, 252, 253, 254, 406, 406, 424, 353, 406, 424, + /* 1730 */ 35, 420, 406, 372, 366, 390, 394, 107, 107, 470, + /* 1740 */ 366, 365, 483, 372, 398, 22, 51, 406, 406, 355, + /* 1750 */ 408, 38, 359, 358, 433, 60, 61, 62, 63, 442, + /* 1760 */ 65, 373, 353, 425, 351, 388, 0, 0, 394, 388, + /* 1770 */ 0, 388, 425, 45, 0, 366, 37, 227, 37, 37, + /* 1780 */ 406, 37, 408, 227, 0, 37, 37, 227, 37, 447, + /* 1790 */ 0, 227, 450, 0, 37, 453, 454, 455, 456, 457, + /* 1800 */ 458, 106, 460, 394, 109, 0, 37, 0, 22, 467, + /* 1810 */ 0, 222, 37, 471, 472, 406, 0, 408, 210, 0, + /* 1820 */ 210, 447, 211, 204, 450, 202, 0, 453, 454, 455, + /* 1830 */ 456, 457, 458, 0, 460, 353, 141, 0, 198, 197, + /* 1840 */ 0, 467, 0, 49, 148, 471, 472, 49, 366, 0, + /* 1850 */ 37, 0, 0, 51, 37, 0, 447, 49, 353, 450, + /* 1860 */ 0, 0, 453, 454, 455, 456, 457, 458, 45, 460, /* 1870 */ 0, 366, 0, 49, 0, 0, 394, 0, 353, 184, /* 1880 */ 165, 37, 0, 165, 0, 0, 191, 0, 406, 0, /* 1890 */ 408, 366, 0, 353, 0, 0, 0, 0, 0, 394, @@ -728,54 +1079,54 @@ static const YYCODETYPE yy_lookahead[] = { /* 1920 */ 0, 45, 0, 0, 399, 0, 0, 0, 0, 447, /* 1930 */ 0, 406, 450, 408, 394, 453, 454, 455, 456, 457, /* 1940 */ 458, 22, 460, 0, 148, 0, 406, 147, 408, 467, - /* 1950 */ 146, 0, 447, 0, 472, 450, 22, 22, 453, 454, - /* 1960 */ 455, 456, 457, 458, 0, 460, 50, 50, 37, 0, - /* 1970 */ 65, 65, 447, 0, 0, 450, 65, 0, 453, 454, - /* 1980 */ 455, 456, 457, 458, 37, 460, 42, 447, 0, 353, - /* 1990 */ 450, 51, 37, 453, 454, 455, 456, 457, 458, 51, - /* 2000 */ 460, 496, 366, 42, 0, 37, 0, 51, 42, 37, - /* 2010 */ 0, 33, 45, 42, 49, 14, 0, 0, 42, 49, - /* 2020 */ 0, 0, 43, 0, 49, 353, 42, 193, 0, 49, - /* 2030 */ 394, 0, 0, 0, 72, 0, 37, 51, 366, 499, - /* 2040 */ 42, 0, 406, 51, 408, 37, 0, 42, 37, 42, - /* 2050 */ 0, 51, 37, 51, 42, 0, 0, 353, 0, 0, - /* 2060 */ 0, 0, 37, 113, 115, 22, 394, 37, 0, 22, + /* 1950 */ 0, 0, 447, 0, 472, 450, 22, 146, 453, 454, + /* 1960 */ 455, 456, 457, 458, 22, 460, 50, 50, 0, 37, + /* 1970 */ 65, 0, 447, 0, 0, 450, 65, 0, 453, 454, + /* 1980 */ 455, 456, 457, 458, 37, 460, 65, 447, 42, 353, + /* 1990 */ 450, 51, 0, 453, 454, 455, 456, 457, 458, 37, + /* 2000 */ 460, 496, 366, 51, 0, 42, 37, 51, 42, 0, + /* 2010 */ 0, 33, 37, 49, 42, 45, 49, 14, 0, 43, + /* 2020 */ 0, 0, 42, 0, 0, 353, 42, 193, 49, 0, + /* 2030 */ 394, 49, 0, 0, 0, 0, 37, 72, 366, 499, + /* 2040 */ 51, 0, 406, 42, 408, 37, 51, 42, 0, 37, + /* 2050 */ 0, 51, 37, 42, 0, 42, 0, 353, 51, 0, + /* 2060 */ 0, 0, 0, 115, 37, 22, 394, 113, 0, 22, /* 2070 */ 366, 399, 0, 37, 37, 37, 37, 37, 406, 37, - /* 2080 */ 408, 37, 33, 447, 33, 37, 450, 22, 0, 453, - /* 2090 */ 454, 455, 456, 457, 458, 22, 460, 0, 394, 37, - /* 2100 */ 37, 22, 0, 22, 0, 53, 37, 0, 0, 0, - /* 2110 */ 406, 37, 408, 37, 0, 22, 20, 37, 0, 447, - /* 2120 */ 37, 37, 450, 182, 49, 453, 454, 455, 456, 457, - /* 2130 */ 458, 107, 460, 107, 353, 108, 0, 37, 209, 182, - /* 2140 */ 0, 22, 22, 205, 508, 182, 0, 366, 0, 189, - /* 2150 */ 353, 447, 3, 108, 450, 33, 277, 453, 454, 455, - /* 2160 */ 456, 457, 458, 366, 460, 182, 462, 185, 353, 182, - /* 2170 */ 189, 107, 33, 107, 50, 394, 105, 50, 108, 49, - /* 2180 */ 399, 366, 49, 33, 107, 103, 108, 406, 33, 408, - /* 2190 */ 33, 394, 107, 107, 3, 33, 399, 108, 107, 0, - /* 2200 */ 108, 277, 108, 406, 37, 408, 37, 37, 37, 394, - /* 2210 */ 277, 37, 37, 108, 108, 49, 270, 33, 0, 107, - /* 2220 */ 42, 406, 49, 408, 107, 0, 116, 42, 447, 108, - /* 2230 */ 107, 450, 107, 353, 453, 454, 455, 456, 457, 458, - /* 2240 */ 108, 460, 107, 186, 447, 107, 366, 450, 33, 49, - /* 2250 */ 453, 454, 455, 456, 457, 458, 105, 460, 105, 2, - /* 2260 */ 257, 22, 447, 234, 108, 450, 107, 353, 453, 454, - /* 2270 */ 455, 456, 457, 458, 394, 460, 108, 49, 49, 184, - /* 2280 */ 366, 22, 117, 107, 107, 37, 406, 108, 408, 108, - /* 2290 */ 353, 237, 128, 107, 107, 107, 72, 108, 37, 107, - /* 2300 */ 37, 108, 107, 366, 108, 37, 108, 37, 394, 107, - /* 2310 */ 107, 37, 108, 107, 37, 108, 107, 107, 128, 33, - /* 2320 */ 406, 107, 408, 107, 37, 128, 22, 447, 37, 128, - /* 2330 */ 450, 394, 37, 453, 454, 455, 456, 457, 458, 37, - /* 2340 */ 460, 33, 71, 406, 37, 408, 37, 353, 37, 37, - /* 2350 */ 37, 37, 101, 101, 78, 37, 78, 37, 37, 22, - /* 2360 */ 366, 447, 37, 37, 450, 37, 78, 453, 454, 455, - /* 2370 */ 456, 457, 458, 37, 460, 37, 37, 37, 37, 22, - /* 2380 */ 37, 0, 37, 51, 447, 51, 42, 450, 394, 0, + /* 2080 */ 408, 37, 37, 447, 33, 33, 450, 22, 0, 453, + /* 2090 */ 454, 455, 456, 457, 458, 37, 460, 22, 394, 0, + /* 2100 */ 37, 37, 22, 0, 22, 0, 53, 37, 0, 0, + /* 2110 */ 406, 37, 408, 0, 37, 0, 22, 20, 37, 447, + /* 2120 */ 37, 37, 450, 0, 108, 453, 454, 455, 456, 457, + /* 2130 */ 458, 182, 460, 107, 353, 107, 0, 182, 209, 49, + /* 2140 */ 22, 37, 0, 205, 508, 185, 22, 366, 0, 0, + /* 2150 */ 353, 447, 33, 3, 450, 277, 107, 453, 454, 455, + /* 2160 */ 456, 457, 458, 366, 460, 182, 462, 182, 353, 182, + /* 2170 */ 189, 50, 50, 33, 108, 394, 107, 189, 105, 103, + /* 2180 */ 399, 366, 49, 49, 33, 33, 108, 406, 33, 408, + /* 2190 */ 277, 394, 3, 108, 108, 33, 399, 108, 107, 107, + /* 2200 */ 107, 277, 107, 406, 108, 408, 37, 37, 37, 394, + /* 2210 */ 37, 37, 37, 49, 108, 108, 33, 49, 0, 0, + /* 2220 */ 42, 406, 108, 408, 107, 0, 42, 270, 447, 49, + /* 2230 */ 184, 450, 107, 353, 453, 454, 455, 456, 457, 458, + /* 2240 */ 108, 460, 107, 186, 447, 107, 366, 450, 107, 33, + /* 2250 */ 453, 454, 455, 456, 457, 458, 2, 460, 22, 116, + /* 2260 */ 107, 105, 447, 257, 105, 450, 108, 353, 453, 454, + /* 2270 */ 455, 456, 457, 458, 394, 460, 49, 49, 22, 107, + /* 2280 */ 366, 37, 117, 107, 37, 108, 406, 108, 408, 234, + /* 2290 */ 353, 128, 107, 107, 107, 37, 108, 107, 37, 108, + /* 2300 */ 107, 37, 108, 366, 107, 37, 108, 107, 394, 108, + /* 2310 */ 107, 37, 108, 107, 33, 108, 237, 107, 22, 107, + /* 2320 */ 406, 107, 408, 128, 128, 37, 37, 447, 107, 72, + /* 2330 */ 450, 394, 37, 453, 454, 455, 456, 457, 458, 128, + /* 2340 */ 460, 71, 37, 406, 37, 408, 37, 353, 37, 37, + /* 2350 */ 37, 37, 101, 101, 78, 78, 33, 37, 37, 37, + /* 2360 */ 366, 447, 22, 37, 450, 37, 37, 453, 454, 455, + /* 2370 */ 456, 457, 458, 37, 460, 78, 37, 22, 37, 37, + /* 2380 */ 37, 37, 0, 37, 447, 51, 0, 450, 394, 42, /* 2390 */ 453, 454, 455, 456, 457, 458, 37, 460, 42, 0, - /* 2400 */ 406, 37, 408, 51, 42, 0, 37, 42, 0, 51, - /* 2410 */ 37, 37, 0, 22, 22, 33, 21, 511, 22, 22, - /* 2420 */ 353, 21, 20, 511, 511, 511, 511, 511, 511, 511, + /* 2400 */ 406, 51, 408, 37, 51, 42, 0, 37, 51, 42, + /* 2410 */ 0, 37, 37, 0, 22, 22, 33, 21, 20, 22, + /* 2420 */ 353, 511, 22, 21, 511, 511, 511, 511, 511, 511, /* 2430 */ 511, 511, 511, 366, 511, 511, 511, 511, 511, 511, /* 2440 */ 353, 447, 511, 511, 450, 511, 511, 453, 454, 455, /* 2450 */ 456, 457, 458, 366, 460, 511, 511, 511, 511, 511, @@ -878,9 +1229,9 @@ static const YYCODETYPE yy_lookahead[] = { /* 3420 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, /* 3430 */ 350, 350, 350, }; -#define YY_SHIFT_COUNT (845) +#define YY_SHIFT_COUNT (846) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2412) +#define YY_SHIFT_MAX (2413) static const unsigned short int yy_shift_ofst[] = { /* 0 */ 1300, 0, 244, 0, 489, 489, 489, 489, 489, 489, /* 10 */ 489, 489, 489, 489, 489, 489, 733, 977, 977, 1221, @@ -904,71 +1255,71 @@ static const unsigned short int yy_shift_ofst[] = { /* 190 */ 640, 734, 330, 768, 1025, 419, 805, 94, 1025, 1025, /* 200 */ 1029, 917, 576, 575, 917, 295, 894, 403, 1215, 1441, /* 210 */ 1458, 1481, 1290, 31, 1481, 31, 1314, 1500, 1508, 1491, - /* 220 */ 1508, 1491, 1363, 1500, 1508, 1500, 1491, 1363, 1363, 1446, - /* 230 */ 1451, 1500, 1454, 1500, 1500, 1500, 1542, 1515, 1542, 1515, - /* 240 */ 1481, 31, 31, 1555, 31, 1562, 1570, 31, 1562, 31, - /* 250 */ 1575, 31, 31, 1500, 31, 1542, 1, 1, 1, 1, - /* 260 */ 1, 1, 1, 1, 1, 1, 1, 1500, 884, 884, - /* 270 */ 1542, 780, 780, 780, 1406, 1533, 1481, 532, 1626, 1440, - /* 280 */ 1445, 1555, 532, 1215, 1500, 780, 1373, 1376, 1373, 1376, - /* 290 */ 1370, 1471, 1373, 1375, 1377, 1389, 1215, 1367, 1382, 1398, - /* 300 */ 1422, 1508, 1680, 1584, 1433, 1562, 532, 532, 1376, 780, - /* 310 */ 780, 780, 780, 1376, 780, 1530, 532, 595, 532, 1508, - /* 320 */ 1630, 1631, 780, 1500, 532, 1720, 1709, 1542, 3083, 3083, - /* 330 */ 3083, 3083, 3083, 3083, 3083, 3083, 3083, 36, 1228, 197, - /* 340 */ 748, 1007, 81, 1045, 888, 15, 527, 1062, 995, 1289, - /* 350 */ 1289, 1289, 1289, 1289, 1289, 1289, 1289, 1289, 216, 148, - /* 360 */ 12, 802, 802, 226, 729, 10, 742, 843, 773, 732, - /* 370 */ 897, 747, 914, 914, 1019, 6, 605, 1019, 1019, 1019, - /* 380 */ 1249, 1066, 487, 370, 1202, 1028, 1122, 1154, 1168, 1170, - /* 390 */ 1172, 1229, 1247, 1240, 1273, 1287, 1292, 1093, 684, 1274, - /* 400 */ 1145, 1282, 1283, 1286, 1177, 1068, 1279, 1291, 1296, 1297, - /* 410 */ 1298, 1309, 1310, 1325, 1313, 433, 1320, 1268, 1350, 1407, - /* 420 */ 1408, 1410, 1414, 1419, 1254, 1285, 1299, 1335, 1337, 1301, - /* 430 */ 1431, 1764, 1766, 1767, 1725, 1773, 1737, 1549, 1740, 1741, - /* 440 */ 1742, 1554, 1783, 1747, 1748, 1559, 1750, 1788, 1563, 1791, - /* 450 */ 1756, 1794, 1768, 1806, 1785, 1808, 1774, 1588, 1812, 1606, - /* 460 */ 1818, 1609, 1611, 1616, 1621, 1825, 1826, 1833, 1639, 1641, - /* 470 */ 1839, 1840, 1694, 1795, 1798, 1843, 1813, 1849, 1851, 1816, - /* 480 */ 1801, 1854, 1811, 1855, 1823, 1857, 1861, 1870, 1824, 1872, - /* 490 */ 1874, 1875, 1877, 1887, 1889, 1715, 1844, 1882, 1718, 1884, - /* 500 */ 1885, 1892, 1894, 1895, 1896, 1897, 1898, 1900, 1901, 1902, - /* 510 */ 1903, 1904, 1907, 1908, 1909, 1910, 1912, 1918, 1865, 1915, - /* 520 */ 1876, 1920, 1922, 1923, 1925, 1926, 1927, 1928, 1919, 1930, - /* 530 */ 1796, 1943, 1800, 1945, 1804, 1951, 1953, 1934, 1916, 1935, - /* 540 */ 1917, 1964, 1905, 1931, 1969, 1906, 1973, 1911, 1974, 1977, - /* 550 */ 1947, 1940, 1944, 1988, 1955, 1948, 1961, 2004, 1968, 1956, - /* 560 */ 1966, 2006, 1972, 2010, 1967, 1971, 1978, 1965, 1970, 2001, - /* 570 */ 1975, 2016, 1979, 1976, 2017, 2020, 2021, 2023, 1984, 1834, - /* 580 */ 2028, 1965, 1980, 2031, 2032, 1962, 2033, 2035, 1999, 1986, - /* 590 */ 1998, 2041, 2008, 1992, 2005, 2046, 2011, 2000, 2007, 2050, - /* 600 */ 2015, 2002, 2012, 2055, 2056, 2058, 2059, 2060, 2061, 1949, - /* 610 */ 1950, 2025, 2043, 2072, 2030, 2036, 2037, 2038, 2039, 2040, - /* 620 */ 2042, 2044, 2049, 2051, 2048, 2062, 2047, 2063, 2068, 2065, - /* 630 */ 2088, 2073, 2097, 2079, 2052, 2102, 2081, 2069, 2104, 2107, - /* 640 */ 2108, 2074, 2109, 2076, 2114, 2093, 2096, 2080, 2083, 2084, - /* 650 */ 2027, 2024, 2118, 1941, 2026, 1929, 1965, 2075, 2136, 1957, - /* 660 */ 2100, 2119, 2140, 1938, 2120, 1963, 1982, 2146, 2148, 1983, - /* 670 */ 1960, 1987, 1981, 2149, 2122, 1879, 2064, 2045, 2066, 2124, - /* 680 */ 2071, 2127, 2082, 2070, 2139, 2150, 2078, 2077, 2085, 2086, - /* 690 */ 2089, 2155, 2130, 2133, 2091, 2157, 1924, 2092, 2094, 2191, - /* 700 */ 2162, 1933, 2167, 2169, 2170, 2171, 2174, 2175, 2105, 2106, - /* 710 */ 2166, 1946, 2184, 2173, 2199, 2218, 2112, 2178, 2117, 2121, - /* 720 */ 2132, 2123, 2125, 2057, 2135, 2225, 2185, 2095, 2138, 2110, - /* 730 */ 1965, 2200, 2215, 2151, 2003, 2153, 2257, 2239, 2029, 2159, - /* 740 */ 2156, 2176, 2168, 2177, 2179, 2228, 2186, 2187, 2229, 2181, - /* 750 */ 2259, 2054, 2188, 2165, 2189, 2248, 2261, 2192, 2193, 2263, - /* 760 */ 2195, 2196, 2268, 2202, 2198, 2270, 2203, 2204, 2274, 2206, - /* 770 */ 2207, 2277, 2209, 2164, 2190, 2197, 2201, 2210, 2286, 2214, - /* 780 */ 2287, 2216, 2286, 2286, 2304, 2224, 2271, 2291, 2295, 2302, - /* 790 */ 2307, 2309, 2311, 2312, 2313, 2314, 2276, 2251, 2278, 2252, - /* 800 */ 2308, 2318, 2320, 2321, 2337, 2325, 2326, 2328, 2288, 2049, - /* 810 */ 2336, 2051, 2338, 2339, 2340, 2341, 2357, 2343, 2381, 2345, - /* 820 */ 2332, 2344, 2389, 2359, 2334, 2356, 2399, 2364, 2352, 2362, - /* 830 */ 2405, 2369, 2358, 2365, 2408, 2373, 2374, 2412, 2391, 2382, - /* 840 */ 2392, 2395, 2396, 2397, 2400, 2402, + /* 220 */ 1508, 1491, 1363, 1500, 1508, 1500, 1491, 1363, 1363, 1363, + /* 230 */ 1448, 1452, 1500, 1456, 1500, 1500, 1500, 1543, 1517, 1543, + /* 240 */ 1517, 1481, 31, 31, 1557, 31, 1562, 1572, 31, 1562, + /* 250 */ 31, 1575, 31, 31, 1500, 31, 1543, 1, 1, 1, + /* 260 */ 1, 1, 1, 1, 1, 1, 1, 1, 1500, 884, + /* 270 */ 884, 1543, 780, 780, 780, 1406, 1534, 1481, 532, 1628, + /* 280 */ 1442, 1446, 1557, 532, 1215, 1500, 780, 1373, 1378, 1373, + /* 290 */ 1378, 1370, 1471, 1373, 1375, 1379, 1389, 1215, 1367, 1382, + /* 300 */ 1397, 1422, 1508, 1681, 1588, 1433, 1562, 532, 532, 1378, + /* 310 */ 780, 780, 780, 780, 1378, 780, 1530, 532, 595, 532, + /* 320 */ 1508, 1630, 1631, 780, 1500, 532, 1723, 1713, 1543, 3083, + /* 330 */ 3083, 3083, 3083, 3083, 3083, 3083, 3083, 3083, 36, 1228, + /* 340 */ 197, 748, 1007, 81, 1045, 888, 15, 527, 1062, 995, + /* 350 */ 1289, 1289, 1289, 1289, 1289, 1289, 1289, 1289, 1289, 216, + /* 360 */ 148, 12, 802, 802, 226, 729, 10, 742, 843, 773, + /* 370 */ 732, 897, 747, 914, 914, 1019, 6, 605, 1019, 1019, + /* 380 */ 1019, 1249, 1066, 487, 370, 1202, 1028, 1122, 1154, 1168, + /* 390 */ 1170, 1172, 1229, 1247, 1240, 1273, 1287, 1292, 1093, 684, + /* 400 */ 1274, 1145, 1282, 1283, 1286, 1177, 1068, 1279, 1291, 1296, + /* 410 */ 1297, 1298, 1309, 1310, 1325, 1313, 433, 1320, 1268, 1350, + /* 420 */ 1407, 1408, 1410, 1414, 1419, 1254, 1285, 1299, 1335, 1337, + /* 430 */ 1301, 1431, 1766, 1767, 1770, 1728, 1774, 1739, 1550, 1741, + /* 440 */ 1742, 1744, 1556, 1784, 1748, 1749, 1560, 1751, 1790, 1564, + /* 450 */ 1793, 1757, 1805, 1769, 1807, 1786, 1810, 1775, 1589, 1816, + /* 460 */ 1608, 1819, 1610, 1611, 1619, 1623, 1826, 1833, 1837, 1640, + /* 470 */ 1642, 1840, 1842, 1696, 1794, 1798, 1849, 1813, 1851, 1852, + /* 480 */ 1817, 1802, 1855, 1808, 1860, 1823, 1861, 1870, 1872, 1824, + /* 490 */ 1874, 1875, 1877, 1887, 1889, 1892, 1715, 1844, 1882, 1718, + /* 500 */ 1884, 1885, 1894, 1895, 1896, 1897, 1898, 1900, 1901, 1902, + /* 510 */ 1903, 1904, 1907, 1908, 1909, 1910, 1912, 1918, 1920, 1865, + /* 520 */ 1915, 1876, 1922, 1923, 1925, 1926, 1927, 1928, 1930, 1919, + /* 530 */ 1943, 1796, 1945, 1800, 1950, 1811, 1951, 1953, 1934, 1916, + /* 540 */ 1942, 1917, 1968, 1905, 1932, 1971, 1911, 1973, 1921, 1974, + /* 550 */ 1977, 1947, 1940, 1946, 1992, 1962, 1952, 1963, 2004, 1969, + /* 560 */ 1956, 1966, 2009, 1975, 2010, 1970, 1972, 1978, 1964, 1967, + /* 570 */ 2003, 1979, 2018, 1976, 1980, 2020, 2021, 2023, 2024, 1984, + /* 580 */ 1834, 2029, 1964, 1982, 2032, 2033, 1965, 2034, 2035, 1999, + /* 590 */ 1989, 2001, 2041, 2008, 1995, 2005, 2048, 2012, 2000, 2011, + /* 600 */ 2050, 2015, 2007, 2013, 2054, 2056, 2059, 2060, 2061, 2062, + /* 610 */ 1948, 1954, 2027, 2043, 2068, 2036, 2037, 2038, 2039, 2040, + /* 620 */ 2042, 2044, 2045, 2051, 2052, 2058, 2063, 2047, 2064, 2072, + /* 630 */ 2065, 2088, 2075, 2099, 2080, 2053, 2103, 2082, 2070, 2105, + /* 640 */ 2108, 2109, 2074, 2113, 2077, 2115, 2094, 2097, 2081, 2083, + /* 650 */ 2084, 2016, 2026, 2123, 1949, 2028, 1929, 1964, 2090, 2136, + /* 660 */ 1955, 2104, 2118, 2142, 1938, 2124, 1983, 1960, 2148, 2149, + /* 670 */ 1985, 1981, 1987, 1988, 2150, 2119, 1878, 2049, 2066, 2069, + /* 680 */ 2121, 2073, 2122, 2076, 2078, 2140, 2151, 2085, 2091, 2092, + /* 690 */ 2093, 2086, 2152, 2133, 2134, 2095, 2155, 1913, 2089, 2096, + /* 700 */ 2189, 2162, 1924, 2169, 2170, 2171, 2173, 2174, 2175, 2106, + /* 710 */ 2107, 2164, 1957, 2183, 2168, 2218, 2219, 2117, 2178, 2125, + /* 720 */ 2114, 2132, 2135, 2138, 2057, 2141, 2225, 2184, 2046, 2153, + /* 730 */ 2143, 1964, 2180, 2216, 2156, 2006, 2159, 2254, 2236, 2055, + /* 740 */ 2172, 2158, 2176, 2177, 2185, 2179, 2227, 2186, 2187, 2228, + /* 750 */ 2188, 2256, 2079, 2190, 2165, 2191, 2244, 2247, 2193, 2194, + /* 760 */ 2258, 2197, 2198, 2261, 2200, 2201, 2264, 2203, 2204, 2268, + /* 770 */ 2206, 2207, 2274, 2210, 2163, 2195, 2196, 2211, 2212, 2281, + /* 780 */ 2214, 2288, 2221, 2281, 2281, 2296, 2257, 2270, 2289, 2295, + /* 790 */ 2305, 2307, 2309, 2311, 2312, 2313, 2314, 2276, 2251, 2277, + /* 800 */ 2252, 2323, 2320, 2321, 2322, 2340, 2326, 2328, 2329, 2297, + /* 810 */ 2051, 2336, 2052, 2339, 2341, 2342, 2343, 2355, 2344, 2382, + /* 820 */ 2346, 2334, 2347, 2386, 2359, 2350, 2356, 2399, 2366, 2353, + /* 830 */ 2363, 2406, 2370, 2357, 2367, 2410, 2374, 2375, 2413, 2392, + /* 840 */ 2383, 2393, 2396, 2397, 2400, 2402, 2398, }; -#define YY_REDUCE_COUNT (336) +#define YY_REDUCE_COUNT (337) #define YY_REDUCE_MIN (-463) #define YY_REDUCE_MAX (2622) static const short yy_reduce_ofst[] = { @@ -994,105 +1345,105 @@ static const short yy_reduce_ofst[] = { /* 190 */ 968, 903, 984, 1053, 1005, 1048, 1037, 1041, 1059, 1061, /* 200 */ 984, 1004, 1004, 985, 1004, 1006, 1002, 1104, 1063, 1049, /* 210 */ 1054, 1064, 1071, 1134, 1069, 1135, 1087, 1156, 1169, 1123, - /* 220 */ 1174, 1126, 1132, 1178, 1179, 1181, 1133, 1137, 1138, 1175, - /* 230 */ 1180, 1190, 1182, 1194, 1195, 1196, 1205, 1206, 1209, 1207, - /* 240 */ 1129, 1197, 1200, 1171, 1203, 1216, 1161, 1220, 1230, 1225, - /* 250 */ 1184, 1226, 1233, 1236, 1235, 1246, 1223, 1232, 1234, 1237, - /* 260 */ 1238, 1242, 1243, 1244, 1245, 1248, 1250, 1255, 1263, 1266, - /* 270 */ 1252, 1218, 1239, 1241, 1189, 1198, 1208, 1271, 1210, 1213, - /* 280 */ 1217, 1251, 1281, 1231, 1293, 1256, 1166, 1262, 1173, 1264, - /* 290 */ 1176, 1183, 1186, 1201, 1191, 1185, 1259, 1160, 1187, 1199, - /* 300 */ 1004, 1331, 1253, 1222, 1258, 1343, 1339, 1340, 1302, 1303, - /* 310 */ 1307, 1318, 1319, 1304, 1323, 1311, 1344, 1345, 1360, 1368, - /* 320 */ 1269, 1346, 1327, 1378, 1379, 1390, 1393, 1391, 1321, 1317, - /* 330 */ 1328, 1336, 1381, 1383, 1384, 1392, 1412, + /* 220 */ 1174, 1126, 1132, 1178, 1179, 1181, 1133, 1137, 1138, 1139, + /* 230 */ 1176, 1180, 1191, 1183, 1195, 1196, 1197, 1207, 1206, 1211, + /* 240 */ 1208, 1130, 1200, 1201, 1171, 1209, 1223, 1163, 1225, 1230, + /* 250 */ 1226, 1182, 1232, 1233, 1236, 1235, 1252, 1234, 1237, 1238, + /* 260 */ 1242, 1243, 1244, 1245, 1246, 1248, 1250, 1251, 1255, 1261, + /* 270 */ 1263, 1264, 1218, 1220, 1241, 1189, 1203, 1210, 1271, 1212, + /* 280 */ 1216, 1219, 1253, 1277, 1239, 1293, 1256, 1167, 1262, 1173, + /* 290 */ 1265, 1175, 1184, 1185, 1190, 1204, 1213, 1258, 1162, 1186, + /* 300 */ 1194, 1004, 1336, 1257, 1222, 1259, 1343, 1339, 1340, 1302, + /* 310 */ 1307, 1318, 1319, 1322, 1305, 1326, 1311, 1344, 1345, 1361, + /* 320 */ 1368, 1269, 1346, 1341, 1376, 1371, 1394, 1393, 1395, 1321, + /* 330 */ 1317, 1338, 1347, 1377, 1381, 1383, 1388, 1413, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 10 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 20 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 30 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 40 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 50 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 60 */ 1895, 2235, 1895, 1895, 2198, 1895, 1895, 1895, 1895, 1895, - /* 70 */ 1895, 1895, 1895, 1895, 1895, 1895, 2205, 1895, 1895, 1895, - /* 80 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 90 */ 1895, 1895, 1895, 1895, 1895, 1895, 1994, 1895, 1895, 1895, - /* 100 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 110 */ 1895, 1895, 1895, 1992, 2438, 1895, 1895, 1895, 1895, 1895, - /* 120 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 130 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 2450, 1895, - /* 140 */ 1895, 1966, 1966, 1895, 2450, 2450, 2450, 1992, 2410, 2410, - /* 150 */ 1895, 1895, 1994, 2273, 1895, 1895, 1895, 1895, 1895, 1895, - /* 160 */ 1895, 1895, 2117, 1925, 1895, 1895, 1895, 1895, 2141, 1895, - /* 170 */ 1895, 1895, 2261, 1895, 1895, 2479, 2539, 1895, 1895, 2482, - /* 180 */ 1895, 1895, 1895, 1895, 2210, 1895, 2469, 1895, 1895, 1895, - /* 190 */ 1895, 1895, 1895, 1895, 1895, 1895, 2070, 2255, 1895, 1895, - /* 200 */ 1895, 2442, 2456, 2523, 2443, 2440, 2463, 1895, 2473, 1895, - /* 210 */ 2298, 1895, 2287, 1994, 1895, 1994, 2248, 2193, 1895, 2203, - /* 220 */ 1895, 2203, 2200, 1895, 1895, 1895, 2203, 2200, 2200, 2059, - /* 230 */ 2055, 1895, 2053, 1895, 1895, 1895, 1895, 1950, 1895, 1950, - /* 240 */ 1895, 1994, 1994, 1895, 1994, 1895, 1895, 1994, 1895, 1994, - /* 250 */ 1895, 1994, 1994, 1895, 1994, 1895, 1895, 1895, 1895, 1895, - /* 260 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 270 */ 1895, 1895, 1895, 1895, 2285, 2271, 1895, 1992, 1895, 2259, - /* 280 */ 2257, 1895, 1992, 2473, 1895, 1895, 2493, 2488, 2493, 2488, - /* 290 */ 2507, 2503, 2493, 2512, 2509, 2475, 2473, 2542, 2529, 2525, - /* 300 */ 2456, 1895, 1895, 2461, 2459, 1895, 1992, 1992, 2488, 1895, - /* 310 */ 1895, 1895, 1895, 2488, 1895, 1895, 1992, 1895, 1992, 1895, - /* 320 */ 1895, 2086, 1895, 1895, 1992, 1895, 1934, 1895, 2250, 2276, - /* 330 */ 2231, 2231, 2120, 2120, 2120, 1995, 1900, 1895, 1895, 1895, - /* 340 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 2506, - /* 350 */ 2505, 2363, 1895, 2414, 2413, 2412, 2403, 2362, 2082, 1895, - /* 360 */ 1895, 2361, 2360, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 370 */ 1895, 1895, 2222, 2221, 2354, 1895, 1895, 2355, 2353, 2352, - /* 380 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 390 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 400 */ 1895, 1895, 1895, 1895, 1895, 2526, 2530, 1895, 1895, 1895, - /* 410 */ 1895, 1895, 1895, 2439, 1895, 1895, 1895, 2334, 1895, 1895, - /* 420 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 430 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 440 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 450 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 460 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 470 */ 1895, 1895, 2199, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 480 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 490 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 500 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 510 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 520 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 530 */ 1895, 1895, 1895, 1895, 2214, 1895, 1895, 1895, 1895, 1895, - /* 540 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 550 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 560 */ 1895, 1895, 1895, 1895, 1895, 1895, 1939, 2341, 1895, 1895, - /* 570 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 580 */ 1895, 2344, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 590 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 600 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 610 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 620 */ 1895, 1895, 2034, 2033, 1895, 1895, 1895, 1895, 1895, 1895, - /* 630 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 640 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 650 */ 2345, 1895, 1895, 1895, 1895, 1895, 2336, 1895, 1895, 1895, - /* 660 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 670 */ 1895, 1895, 1895, 2522, 2476, 1895, 1895, 1895, 1895, 1895, - /* 680 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 690 */ 1895, 1895, 1895, 2334, 1895, 2504, 1895, 1895, 2520, 1895, - /* 700 */ 2524, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 2449, 2445, - /* 710 */ 1895, 1895, 2441, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 720 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 730 */ 2333, 1895, 2400, 1895, 1895, 1895, 2434, 1895, 1895, 2385, - /* 740 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 2345, - /* 750 */ 1895, 2348, 1895, 1895, 1895, 1895, 1895, 2114, 1895, 1895, - /* 760 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 770 */ 1895, 1895, 1895, 2098, 2096, 2095, 2094, 1895, 2127, 1895, - /* 780 */ 1895, 1895, 2123, 2122, 1895, 1895, 1895, 1895, 1895, 1895, - /* 790 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 800 */ 2013, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 2005, - /* 810 */ 1895, 2004, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 820 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, - /* 830 */ 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1895, 1924, - /* 840 */ 1895, 1895, 1895, 1895, 1895, 1895, + /* 0 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 10 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 20 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 30 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 40 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 50 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 60 */ 1896, 2236, 1896, 1896, 2199, 1896, 1896, 1896, 1896, 1896, + /* 70 */ 1896, 1896, 1896, 1896, 1896, 1896, 2206, 1896, 1896, 1896, + /* 80 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 90 */ 1896, 1896, 1896, 1896, 1896, 1896, 1995, 1896, 1896, 1896, + /* 100 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 110 */ 1896, 1896, 1896, 1993, 2439, 1896, 1896, 1896, 1896, 1896, + /* 120 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 130 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 2451, 1896, + /* 140 */ 1896, 1967, 1967, 1896, 2451, 2451, 2451, 1993, 2411, 2411, + /* 150 */ 1896, 1896, 1995, 2274, 1896, 1896, 1896, 1896, 1896, 1896, + /* 160 */ 1896, 1896, 2118, 1926, 1896, 1896, 1896, 1896, 2142, 1896, + /* 170 */ 1896, 1896, 2262, 1896, 1896, 2480, 2540, 1896, 1896, 2483, + /* 180 */ 1896, 1896, 1896, 1896, 2211, 1896, 2470, 1896, 1896, 1896, + /* 190 */ 1896, 1896, 1896, 1896, 1896, 1896, 2071, 2256, 1896, 1896, + /* 200 */ 1896, 2443, 2457, 2524, 2444, 2441, 2464, 1896, 2474, 1896, + /* 210 */ 2299, 1896, 2288, 1995, 1896, 1995, 2249, 2194, 1896, 2204, + /* 220 */ 1896, 2204, 2201, 1896, 1896, 1896, 2204, 2201, 2201, 2201, + /* 230 */ 2060, 2056, 1896, 2054, 1896, 1896, 1896, 1896, 1951, 1896, + /* 240 */ 1951, 1896, 1995, 1995, 1896, 1995, 1896, 1896, 1995, 1896, + /* 250 */ 1995, 1896, 1995, 1995, 1896, 1995, 1896, 1896, 1896, 1896, + /* 260 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 270 */ 1896, 1896, 1896, 1896, 1896, 2286, 2272, 1896, 1993, 1896, + /* 280 */ 2260, 2258, 1896, 1993, 2474, 1896, 1896, 2494, 2489, 2494, + /* 290 */ 2489, 2508, 2504, 2494, 2513, 2510, 2476, 2474, 2543, 2530, + /* 300 */ 2526, 2457, 1896, 1896, 2462, 2460, 1896, 1993, 1993, 2489, + /* 310 */ 1896, 1896, 1896, 1896, 2489, 1896, 1896, 1993, 1896, 1993, + /* 320 */ 1896, 1896, 2087, 1896, 1896, 1993, 1896, 1935, 1896, 2251, + /* 330 */ 2277, 2232, 2232, 2121, 2121, 2121, 1996, 1901, 1896, 1896, + /* 340 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 350 */ 2507, 2506, 2364, 1896, 2415, 2414, 2413, 2404, 2363, 2083, + /* 360 */ 1896, 1896, 2362, 2361, 1896, 1896, 1896, 1896, 1896, 1896, + /* 370 */ 1896, 1896, 1896, 2223, 2222, 2355, 1896, 1896, 2356, 2354, + /* 380 */ 2353, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 390 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 400 */ 1896, 1896, 1896, 1896, 1896, 1896, 2527, 2531, 1896, 1896, + /* 410 */ 1896, 1896, 1896, 1896, 2440, 1896, 1896, 1896, 2335, 1896, + /* 420 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 430 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 440 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 450 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 460 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 470 */ 1896, 1896, 1896, 2200, 1896, 1896, 1896, 1896, 1896, 1896, + /* 480 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 490 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 500 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 510 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 520 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 530 */ 1896, 1896, 1896, 1896, 1896, 2215, 1896, 1896, 1896, 1896, + /* 540 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 550 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 560 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1940, 2342, 1896, + /* 570 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 580 */ 1896, 1896, 2345, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 590 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 600 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 610 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 620 */ 1896, 1896, 1896, 2035, 2034, 1896, 1896, 1896, 1896, 1896, + /* 630 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 640 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 650 */ 1896, 2346, 1896, 1896, 1896, 1896, 1896, 2337, 1896, 1896, + /* 660 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 670 */ 1896, 1896, 1896, 1896, 2523, 2477, 1896, 1896, 1896, 1896, + /* 680 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 690 */ 1896, 1896, 1896, 1896, 2335, 1896, 2505, 1896, 1896, 2521, + /* 700 */ 1896, 2525, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 2450, + /* 710 */ 2446, 1896, 1896, 2442, 1896, 1896, 1896, 1896, 1896, 1896, + /* 720 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 730 */ 1896, 2334, 1896, 2401, 1896, 1896, 1896, 2435, 1896, 1896, + /* 740 */ 2386, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 750 */ 2346, 1896, 2349, 1896, 1896, 1896, 1896, 1896, 2115, 1896, + /* 760 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 770 */ 1896, 1896, 1896, 1896, 2099, 2097, 2096, 2095, 1896, 2128, + /* 780 */ 1896, 1896, 1896, 2124, 2123, 1896, 1896, 1896, 1896, 1896, + /* 790 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 800 */ 1896, 2014, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 810 */ 2006, 1896, 2005, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 820 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 830 */ 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, 1896, + /* 840 */ 1925, 1896, 1896, 1896, 1896, 1896, 1896, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1513,6 +1864,7 @@ struct yyParser { }; typedef struct yyParser yyParser; +#include #ifndef NDEBUG #include static FILE *yyTraceFILE = 0; @@ -2357,7 +2709,7 @@ static const char *const yyRuleName[] = { /* 287 */ "cmd ::= SHOW VNODES", /* 288 */ "cmd ::= SHOW db_name_cond_opt ALIVE", /* 289 */ "cmd ::= SHOW CLUSTER ALIVE", - /* 290 */ "cmd ::= SHOW db_name_cond_opt VIEWS", + /* 290 */ "cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt", /* 291 */ "cmd ::= SHOW CREATE VIEW full_table_name", /* 292 */ "cmd ::= SHOW COMPACTS", /* 293 */ "cmd ::= SHOW COMPACT NK_INTEGER", @@ -2917,7 +3269,9 @@ static void yy_destructor( case 506: /* query_simple_or_subquery */ case 508: /* sort_specification */ { +#line 7 "sql.y" nodesDestroyNode((yypminor->yy490)); +#line 3274 "sql.c" } break; case 351: /* account_options */ @@ -2927,7 +3281,9 @@ static void yy_destructor( case 428: /* with_meta */ case 437: /* bufsize_opt */ { +#line 54 "sql.y" +#line 3286 "sql.c" } break; case 355: /* ip_range_list */ @@ -2964,7 +3320,9 @@ static void yy_destructor( case 502: /* order_by_clause_opt */ case 507: /* sort_specification_list */ { +#line 85 "sql.y" nodesDestroyList((yypminor->yy502)); +#line 3325 "sql.c" } break; case 358: /* user_name */ @@ -2987,24 +3345,32 @@ static void yy_destructor( case 460: /* noarg_func */ case 478: /* alias_opt */ { +#line 819 "sql.y" +#line 3350 "sql.c" } break; case 359: /* sysinfo_opt */ { +#line 112 "sql.y" +#line 3357 "sql.c" } break; case 360: /* privileges */ case 363: /* priv_type_list */ case 364: /* priv_type */ { +#line 121 "sql.y" +#line 3366 "sql.c" } break; case 361: /* priv_level */ { +#line 138 "sql.y" +#line 3373 "sql.c" } break; case 370: /* force_opt */ @@ -3018,55 +3384,75 @@ static void yy_destructor( case 484: /* set_quantifier_opt */ case 485: /* tag_mode_opt */ { +#line 167 "sql.y" +#line 3389 "sql.c" } break; case 383: /* alter_db_option */ case 405: /* alter_table_option */ { +#line 269 "sql.y" +#line 3397 "sql.c" } break; case 395: /* type_name */ { +#line 392 "sql.y" +#line 3404 "sql.c" } break; case 410: /* db_kind_opt */ case 417: /* table_kind */ { +#line 560 "sql.y" +#line 3412 "sql.c" } break; case 411: /* table_kind_db_name_cond_opt */ { +#line 525 "sql.y" +#line 3419 "sql.c" } break; case 468: /* compare_op */ case 469: /* in_op */ { +#line 1009 "sql.y" +#line 3427 "sql.c" } break; case 481: /* join_type */ { +#line 1085 "sql.y" +#line 3434 "sql.c" } break; case 498: /* fill_mode */ { +#line 1176 "sql.y" +#line 3441 "sql.c" } break; case 509: /* ordering_specification_opt */ { +#line 1261 "sql.y" +#line 3448 "sql.c" } break; case 510: /* null_ordering_opt */ { +#line 1267 "sql.y" +#line 3455 "sql.c" } break; /********* End destructor definitions *****************************************/ @@ -3233,7 +3619,7 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ - assert( i>=0 && i=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) ); return yy_action[i]; } }while(1); @@ -3645,7 +4031,7 @@ static const YYCODETYPE yyRuleInfoLhs[] = { 350, /* (287) cmd ::= SHOW VNODES */ 350, /* (288) cmd ::= SHOW db_name_cond_opt ALIVE */ 350, /* (289) cmd ::= SHOW CLUSTER ALIVE */ - 350, /* (290) cmd ::= SHOW db_name_cond_opt VIEWS */ + 350, /* (290) cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ 350, /* (291) cmd ::= SHOW CREATE VIEW full_table_name */ 350, /* (292) cmd ::= SHOW COMPACTS */ 350, /* (293) cmd ::= SHOW COMPACT NK_INTEGER */ @@ -4297,7 +4683,7 @@ static const signed char yyRuleInfoNRhs[] = { -2, /* (287) cmd ::= SHOW VNODES */ -3, /* (288) cmd ::= SHOW db_name_cond_opt ALIVE */ -3, /* (289) cmd ::= SHOW CLUSTER ALIVE */ - -3, /* (290) cmd ::= SHOW db_name_cond_opt VIEWS */ + -4, /* (290) cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ -4, /* (291) cmd ::= SHOW CREATE VIEW full_table_name */ -2, /* (292) cmd ::= SHOW COMPACTS */ -3, /* (293) cmd ::= SHOW COMPACT NK_INTEGER */ @@ -4683,54 +5069,6 @@ static YYACTIONTYPE yy_reduce( (void)yyLookahead; (void)yyLookaheadToken; yymsp = yypParser->yytos; -#ifndef NDEBUG - if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ - yysize = yyRuleInfoNRhs[yyruleno]; - if( yysize ){ - fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", - yyTracePrompt, - yyruleno, yyRuleName[yyruleno], - yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ - yypParser->yyhwm++; - assert( yypParser->yyhwm == (int)(yypParser->yytos - yypParser->yystack)); - } -#endif -#if YYSTACKDEPTH>0 - if( yypParser->yytos>=yypParser->yystackEnd ){ - yyStackOverflow(yypParser); - /* The call to yyStackOverflow() above pops the stack until it is - ** empty, causing the main parser loop to exit. So the return value - ** is never used and does not matter. */ - return 0; - } -#else - if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ - if( yyGrowStack(yypParser) ){ - yyStackOverflow(yypParser); - /* The call to yyStackOverflow() above pops the stack until it is - ** empty, causing the main parser loop to exit. So the return value - ** is never used and does not matter. */ - return 0; - } - yymsp = yypParser->yytos; - } -#endif - } switch( yyruleno ){ /* Beginning here are the reduction cases. A typical example @@ -4744,15 +5082,21 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ +#line 50 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } +#line 5087 "sql.c" yy_destructor(yypParser,351,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ +#line 51 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } +#line 5093 "sql.c" yy_destructor(yypParser,352,&yymsp[0].minor); break; case 2: /* account_options ::= */ +#line 55 "sql.y" { } +#line 5099 "sql.c" break; case 3: /* account_options ::= account_options PPS literal */ case 4: /* account_options ::= account_options TSERIES literal */ yytestcase(yyruleno==4); @@ -4764,18 +5108,24 @@ static YYACTIONTYPE yy_reduce( case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); { yy_destructor(yypParser,351,&yymsp[-2].minor); +#line 56 "sql.y" { } +#line 5113 "sql.c" yy_destructor(yypParser,353,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ { yy_destructor(yypParser,354,&yymsp[0].minor); +#line 68 "sql.y" { } +#line 5121 "sql.c" } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ { yy_destructor(yypParser,352,&yymsp[-1].minor); +#line 69 "sql.y" { } +#line 5128 "sql.c" yy_destructor(yypParser,354,&yymsp[0].minor); } break; @@ -4789,19 +5139,27 @@ static YYACTIONTYPE yy_reduce( case 21: /* alter_account_option ::= USERS literal */ yytestcase(yyruleno==21); case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); +#line 73 "sql.y" { } +#line 5144 "sql.c" yy_destructor(yypParser,353,&yymsp[0].minor); break; case 24: /* ip_range_list ::= NK_STRING */ +#line 86 "sql.y" { yylhsminor.yy502 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 5150 "sql.c" yymsp[0].minor.yy502 = yylhsminor.yy502; break; case 25: /* ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ +#line 87 "sql.y" { yylhsminor.yy502 = addNodeToList(pCxt, yymsp[-2].minor.yy502, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 5156 "sql.c" yymsp[-2].minor.yy502 = yylhsminor.yy502; break; case 26: /* white_list ::= HOST ip_range_list */ +#line 91 "sql.y" { yymsp[-1].minor.yy502 = yymsp[0].minor.yy502; } +#line 5162 "sql.c" break; case 27: /* white_list_opt ::= */ case 188: /* specific_cols_opt ::= */ yytestcase(yyruleno==188); @@ -4812,89 +5170,137 @@ static YYACTIONTYPE yy_reduce( case 577: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==577); case 605: /* group_by_clause_opt ::= */ yytestcase(yyruleno==605); case 625: /* order_by_clause_opt ::= */ yytestcase(yyruleno==625); +#line 95 "sql.y" { yymsp[1].minor.yy502 = NULL; } +#line 5175 "sql.c" break; case 28: /* white_list_opt ::= white_list */ case 220: /* tags_def_opt ::= tags_def */ yytestcase(yyruleno==220); case 376: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==376); case 502: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==502); +#line 96 "sql.y" { yylhsminor.yy502 = yymsp[0].minor.yy502; } +#line 5183 "sql.c" yymsp[0].minor.yy502 = yylhsminor.yy502; break; case 29: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ +#line 100 "sql.y" { pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-4].minor.yy561, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy1013); pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy502); } +#line 5192 "sql.c" break; case 30: /* cmd ::= ALTER USER user_name PASS NK_STRING */ +#line 104 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy561, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +#line 5197 "sql.c" break; case 31: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ +#line 105 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy561, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +#line 5202 "sql.c" break; case 32: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ +#line 106 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy561, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +#line 5207 "sql.c" break; case 33: /* cmd ::= ALTER USER user_name ADD white_list */ +#line 107 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy561, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy502); } +#line 5212 "sql.c" break; case 34: /* cmd ::= ALTER USER user_name DROP white_list */ +#line 108 "sql.y" { pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy561, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy502); } +#line 5217 "sql.c" break; case 35: /* cmd ::= DROP USER user_name */ +#line 109 "sql.y" { pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy561); } +#line 5222 "sql.c" break; case 36: /* sysinfo_opt ::= */ +#line 113 "sql.y" { yymsp[1].minor.yy1013 = 1; } +#line 5227 "sql.c" break; case 37: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ +#line 114 "sql.y" { yymsp[-1].minor.yy1013 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +#line 5232 "sql.c" break; case 38: /* cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ +#line 117 "sql.y" { pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy277, &yymsp[-3].minor.yy483, &yymsp[0].minor.yy561, yymsp[-2].minor.yy490); } +#line 5237 "sql.c" break; case 39: /* cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ +#line 118 "sql.y" { pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy277, &yymsp[-3].minor.yy483, &yymsp[0].minor.yy561, yymsp[-2].minor.yy490); } +#line 5242 "sql.c" break; case 40: /* privileges ::= ALL */ +#line 122 "sql.y" { yymsp[0].minor.yy277 = PRIVILEGE_TYPE_ALL; } +#line 5247 "sql.c" break; case 41: /* privileges ::= priv_type_list */ case 43: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==43); +#line 123 "sql.y" { yylhsminor.yy277 = yymsp[0].minor.yy277; } +#line 5253 "sql.c" yymsp[0].minor.yy277 = yylhsminor.yy277; break; case 42: /* privileges ::= SUBSCRIBE */ +#line 124 "sql.y" { yymsp[0].minor.yy277 = PRIVILEGE_TYPE_SUBSCRIBE; } +#line 5259 "sql.c" break; case 44: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ +#line 129 "sql.y" { yylhsminor.yy277 = yymsp[-2].minor.yy277 | yymsp[0].minor.yy277; } +#line 5264 "sql.c" yymsp[-2].minor.yy277 = yylhsminor.yy277; break; case 45: /* priv_type ::= READ */ +#line 133 "sql.y" { yymsp[0].minor.yy277 = PRIVILEGE_TYPE_READ; } +#line 5270 "sql.c" break; case 46: /* priv_type ::= WRITE */ +#line 134 "sql.y" { yymsp[0].minor.yy277 = PRIVILEGE_TYPE_WRITE; } +#line 5275 "sql.c" break; case 47: /* priv_type ::= ALTER */ +#line 135 "sql.y" { yymsp[0].minor.yy277 = PRIVILEGE_TYPE_ALTER; } +#line 5280 "sql.c" break; case 48: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ +#line 139 "sql.y" { yylhsminor.yy483.first = yymsp[-2].minor.yy0; yylhsminor.yy483.second = yymsp[0].minor.yy0; } +#line 5285 "sql.c" yymsp[-2].minor.yy483 = yylhsminor.yy483; break; case 49: /* priv_level ::= db_name NK_DOT NK_STAR */ +#line 140 "sql.y" { yylhsminor.yy483.first = yymsp[-2].minor.yy561; yylhsminor.yy483.second = yymsp[0].minor.yy0; } +#line 5291 "sql.c" yymsp[-2].minor.yy483 = yylhsminor.yy483; break; case 50: /* priv_level ::= db_name NK_DOT table_name */ +#line 141 "sql.y" { yylhsminor.yy483.first = yymsp[-2].minor.yy561; yylhsminor.yy483.second = yymsp[0].minor.yy561; } +#line 5297 "sql.c" yymsp[-2].minor.yy483 = yylhsminor.yy483; break; case 51: /* priv_level ::= topic_name */ +#line 142 "sql.y" { yylhsminor.yy483.first = yymsp[0].minor.yy561; yylhsminor.yy483.second = nil_token; } +#line 5303 "sql.c" yymsp[0].minor.yy483 = yylhsminor.yy483; break; case 52: /* with_opt ::= */ @@ -4913,46 +5319,72 @@ static YYACTIONTYPE yy_reduce( case 614: /* every_opt ::= */ yytestcase(yyruleno==614); case 627: /* slimit_clause_opt ::= */ yytestcase(yyruleno==627); case 631: /* limit_clause_opt ::= */ yytestcase(yyruleno==631); +#line 144 "sql.y" { yymsp[1].minor.yy490 = NULL; } +#line 5324 "sql.c" break; case 53: /* with_opt ::= WITH search_condition */ case 543: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==543); case 576: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==576); case 610: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==610); +#line 145 "sql.y" { yymsp[-1].minor.yy490 = yymsp[0].minor.yy490; } +#line 5332 "sql.c" break; case 54: /* cmd ::= CREATE DNODE dnode_endpoint */ +#line 148 "sql.y" { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy561, NULL); } +#line 5337 "sql.c" break; case 55: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ +#line 149 "sql.y" { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy0); } +#line 5342 "sql.c" break; case 56: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ +#line 150 "sql.y" { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy845, false); } +#line 5347 "sql.c" break; case 57: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ +#line 151 "sql.y" { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy561, yymsp[0].minor.yy845, false); } +#line 5352 "sql.c" break; case 58: /* cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ +#line 152 "sql.y" { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy845); } +#line 5357 "sql.c" break; case 59: /* cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ +#line 153 "sql.y" { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy561, false, yymsp[0].minor.yy845); } +#line 5362 "sql.c" break; case 60: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ +#line 154 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } +#line 5367 "sql.c" break; case 61: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ +#line 155 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 5372 "sql.c" break; case 62: /* cmd ::= ALTER ALL DNODES NK_STRING */ +#line 156 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[0].minor.yy0, NULL); } +#line 5377 "sql.c" break; case 63: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ +#line 157 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 5382 "sql.c" break; case 64: /* cmd ::= RESTORE DNODE NK_INTEGER */ +#line 158 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_DNODE_STMT, &yymsp[0].minor.yy0); } +#line 5387 "sql.c" break; case 65: /* dnode_endpoint ::= NK_STRING */ case 66: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==66); @@ -4987,7 +5419,9 @@ static YYACTIONTYPE yy_reduce( case 498: /* star_func ::= FIRST */ yytestcase(yyruleno==498); case 499: /* star_func ::= LAST */ yytestcase(yyruleno==499); case 500: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==500); +#line 162 "sql.y" { yylhsminor.yy561 = yymsp[0].minor.yy0; } +#line 5424 "sql.c" yymsp[0].minor.yy561 = yylhsminor.yy561; break; case 68: /* force_opt ::= */ @@ -4999,7 +5433,9 @@ static YYACTIONTYPE yy_reduce( case 389: /* ignore_opt ::= */ yytestcase(yyruleno==389); case 563: /* tag_mode_opt ::= */ yytestcase(yyruleno==563); case 565: /* set_quantifier_opt ::= */ yytestcase(yyruleno==565); +#line 168 "sql.y" { yymsp[1].minor.yy845 = false; } +#line 5438 "sql.c" break; case 69: /* force_opt ::= FORCE */ case 70: /* unsafe_opt ::= UNSAFE */ yytestcase(yyruleno==70); @@ -5007,288 +5443,440 @@ static YYACTIONTYPE yy_reduce( case 358: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==358); case 564: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==564); case 566: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==566); +#line 169 "sql.y" { yymsp[0].minor.yy845 = true; } +#line 5448 "sql.c" break; case 71: /* cmd ::= ALTER CLUSTER NK_STRING */ +#line 176 "sql.y" { pCxt->pRootNode = createAlterClusterStmt(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 5453 "sql.c" break; case 72: /* cmd ::= ALTER CLUSTER NK_STRING NK_STRING */ +#line 177 "sql.y" { pCxt->pRootNode = createAlterClusterStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 5458 "sql.c" break; case 73: /* cmd ::= ALTER LOCAL NK_STRING */ +#line 180 "sql.y" { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 5463 "sql.c" break; case 74: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ +#line 181 "sql.y" { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 5468 "sql.c" break; case 75: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ +#line 184 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_QNODE_STMT, &yymsp[0].minor.yy0); } +#line 5473 "sql.c" break; case 76: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ +#line 185 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_QNODE_STMT, &yymsp[0].minor.yy0); } +#line 5478 "sql.c" break; case 77: /* cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ +#line 186 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_QNODE_STMT, &yymsp[0].minor.yy0); } +#line 5483 "sql.c" break; case 78: /* cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ +#line 189 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_BNODE_STMT, &yymsp[0].minor.yy0); } +#line 5488 "sql.c" break; case 79: /* cmd ::= DROP BNODE ON DNODE NK_INTEGER */ +#line 190 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_BNODE_STMT, &yymsp[0].minor.yy0); } +#line 5493 "sql.c" break; case 80: /* cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ +#line 193 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_SNODE_STMT, &yymsp[0].minor.yy0); } +#line 5498 "sql.c" break; case 81: /* cmd ::= DROP SNODE ON DNODE NK_INTEGER */ +#line 194 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_SNODE_STMT, &yymsp[0].minor.yy0); } +#line 5503 "sql.c" break; case 82: /* cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ +#line 197 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_MNODE_STMT, &yymsp[0].minor.yy0); } +#line 5508 "sql.c" break; case 83: /* cmd ::= DROP MNODE ON DNODE NK_INTEGER */ +#line 198 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } +#line 5513 "sql.c" break; case 84: /* cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ +#line 199 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_MNODE_STMT, &yymsp[0].minor.yy0); } +#line 5518 "sql.c" break; case 85: /* cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ +#line 202 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_VNODE_STMT, &yymsp[0].minor.yy0); } +#line 5523 "sql.c" break; case 86: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ +#line 205 "sql.y" { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy845, &yymsp[-1].minor.yy561, yymsp[0].minor.yy490); } +#line 5528 "sql.c" break; case 87: /* cmd ::= DROP DATABASE exists_opt db_name */ +#line 206 "sql.y" { pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy561); } +#line 5533 "sql.c" break; case 88: /* cmd ::= USE db_name */ +#line 207 "sql.y" { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy561); } +#line 5538 "sql.c" break; case 89: /* cmd ::= ALTER DATABASE db_name alter_db_options */ +#line 208 "sql.y" { pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy561, yymsp[0].minor.yy490); } +#line 5543 "sql.c" break; case 90: /* cmd ::= FLUSH DATABASE db_name */ +#line 209 "sql.y" { pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy561); } +#line 5548 "sql.c" break; case 91: /* cmd ::= TRIM DATABASE db_name speed_opt */ +#line 210 "sql.y" { pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy561, yymsp[0].minor.yy774); } +#line 5553 "sql.c" break; case 92: /* cmd ::= COMPACT DATABASE db_name start_opt end_opt */ +#line 211 "sql.y" { pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy561, yymsp[-1].minor.yy490, yymsp[0].minor.yy490); } +#line 5558 "sql.c" break; case 93: /* not_exists_opt ::= IF NOT EXISTS */ +#line 215 "sql.y" { yymsp[-2].minor.yy845 = true; } +#line 5563 "sql.c" break; case 95: /* exists_opt ::= IF EXISTS */ case 364: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==364); case 390: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==390); +#line 220 "sql.y" { yymsp[-1].minor.yy845 = true; } +#line 5570 "sql.c" break; case 97: /* db_options ::= */ +#line 223 "sql.y" { yymsp[1].minor.yy490 = createDefaultDatabaseOptions(pCxt); } +#line 5575 "sql.c" break; case 98: /* db_options ::= db_options BUFFER NK_INTEGER */ +#line 224 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } +#line 5580 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 99: /* db_options ::= db_options CACHEMODEL NK_STRING */ +#line 225 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } +#line 5586 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 100: /* db_options ::= db_options CACHESIZE NK_INTEGER */ +#line 226 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } +#line 5592 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 101: /* db_options ::= db_options COMP NK_INTEGER */ +#line 227 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_COMP, &yymsp[0].minor.yy0); } +#line 5598 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 102: /* db_options ::= db_options DURATION NK_INTEGER */ case 103: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==103); +#line 228 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } +#line 5605 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 104: /* db_options ::= db_options MAXROWS NK_INTEGER */ +#line 230 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } +#line 5611 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 105: /* db_options ::= db_options MINROWS NK_INTEGER */ +#line 231 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } +#line 5617 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 106: /* db_options ::= db_options KEEP integer_list */ case 107: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==107); +#line 232 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_KEEP, yymsp[0].minor.yy502); } +#line 5624 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 108: /* db_options ::= db_options PAGES NK_INTEGER */ +#line 234 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } +#line 5630 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 109: /* db_options ::= db_options PAGESIZE NK_INTEGER */ +#line 235 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } +#line 5636 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 110: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ +#line 236 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } +#line 5642 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 111: /* db_options ::= db_options PRECISION NK_STRING */ +#line 237 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } +#line 5648 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 112: /* db_options ::= db_options REPLICA NK_INTEGER */ +#line 238 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } +#line 5654 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 113: /* db_options ::= db_options VGROUPS NK_INTEGER */ +#line 240 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } +#line 5660 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 114: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ +#line 241 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } +#line 5666 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 115: /* db_options ::= db_options RETENTIONS retention_list */ +#line 242 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_RETENTIONS, yymsp[0].minor.yy502); } +#line 5672 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 116: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ +#line 243 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } +#line 5678 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 117: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ +#line 244 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_WAL, &yymsp[0].minor.yy0); } +#line 5684 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 118: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ +#line 245 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } +#line 5690 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 119: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ +#line 246 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } +#line 5696 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 120: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ +#line 247 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-3].minor.yy490, DB_OPTION_WAL_RETENTION_PERIOD, &t); } +#line 5706 "sql.c" yymsp[-3].minor.yy490 = yylhsminor.yy490; break; case 121: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ +#line 252 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } +#line 5712 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 122: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ +#line 253 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-3].minor.yy490, DB_OPTION_WAL_RETENTION_SIZE, &t); } +#line 5722 "sql.c" yymsp[-3].minor.yy490 = yylhsminor.yy490; break; case 123: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ +#line 258 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } +#line 5728 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 124: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ +#line 259 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } +#line 5734 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 125: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ +#line 260 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } +#line 5740 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 126: /* db_options ::= db_options TABLE_PREFIX signed */ +#line 261 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy490); } +#line 5746 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 127: /* db_options ::= db_options TABLE_SUFFIX signed */ +#line 262 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy490); } +#line 5752 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 128: /* db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ +#line 263 "sql.y" { yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } +#line 5758 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 129: /* alter_db_options ::= alter_db_option */ +#line 265 "sql.y" { yylhsminor.yy490 = createAlterDatabaseOptions(pCxt); yylhsminor.yy490 = setAlterDatabaseOption(pCxt, yylhsminor.yy490, &yymsp[0].minor.yy529); } +#line 5764 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 130: /* alter_db_options ::= alter_db_options alter_db_option */ +#line 266 "sql.y" { yylhsminor.yy490 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy490, &yymsp[0].minor.yy529); } +#line 5770 "sql.c" yymsp[-1].minor.yy490 = yylhsminor.yy490; break; case 131: /* alter_db_option ::= BUFFER NK_INTEGER */ +#line 270 "sql.y" { yymsp[-1].minor.yy529.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +#line 5776 "sql.c" break; case 132: /* alter_db_option ::= CACHEMODEL NK_STRING */ +#line 271 "sql.y" { yymsp[-1].minor.yy529.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +#line 5781 "sql.c" break; case 133: /* alter_db_option ::= CACHESIZE NK_INTEGER */ +#line 272 "sql.y" { yymsp[-1].minor.yy529.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +#line 5786 "sql.c" break; case 134: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ +#line 273 "sql.y" { yymsp[-1].minor.yy529.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +#line 5791 "sql.c" break; case 135: /* alter_db_option ::= KEEP integer_list */ case 136: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==136); +#line 274 "sql.y" { yymsp[-1].minor.yy529.type = DB_OPTION_KEEP; yymsp[-1].minor.yy529.pList = yymsp[0].minor.yy502; } +#line 5797 "sql.c" break; case 137: /* alter_db_option ::= PAGES NK_INTEGER */ +#line 276 "sql.y" { yymsp[-1].minor.yy529.type = DB_OPTION_PAGES; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +#line 5802 "sql.c" break; case 138: /* alter_db_option ::= REPLICA NK_INTEGER */ +#line 277 "sql.y" { yymsp[-1].minor.yy529.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +#line 5807 "sql.c" break; case 139: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ +#line 279 "sql.y" { yymsp[-1].minor.yy529.type = DB_OPTION_WAL; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +#line 5812 "sql.c" break; case 140: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ +#line 280 "sql.y" { yymsp[-1].minor.yy529.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +#line 5817 "sql.c" break; case 141: /* alter_db_option ::= MINROWS NK_INTEGER */ +#line 281 "sql.y" { yymsp[-1].minor.yy529.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +#line 5822 "sql.c" break; case 142: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ +#line 282 "sql.y" { yymsp[-1].minor.yy529.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +#line 5827 "sql.c" break; case 143: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ +#line 283 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yymsp[-2].minor.yy529.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy529.val = t; } +#line 5836 "sql.c" break; case 144: /* alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ +#line 288 "sql.y" { yymsp[-1].minor.yy529.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +#line 5841 "sql.c" break; case 145: /* alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ +#line 289 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yymsp[-2].minor.yy529.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy529.val = t; } +#line 5850 "sql.c" break; case 146: /* alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ +#line 294 "sql.y" { yymsp[-1].minor.yy529.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +#line 5855 "sql.c" break; case 147: /* integer_list ::= NK_INTEGER */ +#line 298 "sql.y" { yylhsminor.yy502 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 5860 "sql.c" yymsp[0].minor.yy502 = yylhsminor.yy502; break; case 148: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ case 403: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==403); +#line 299 "sql.y" { yylhsminor.yy502 = addNodeToList(pCxt, yymsp[-2].minor.yy502, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 5867 "sql.c" yymsp[-2].minor.yy502 = yylhsminor.yy502; break; case 149: /* variable_list ::= NK_VARIABLE */ +#line 303 "sql.y" { yylhsminor.yy502 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 5873 "sql.c" yymsp[0].minor.yy502 = yylhsminor.yy502; break; case 150: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ +#line 304 "sql.y" { yylhsminor.yy502 = addNodeToList(pCxt, yymsp[-2].minor.yy502, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 5879 "sql.c" yymsp[-2].minor.yy502 = yylhsminor.yy502; break; case 151: /* retention_list ::= retention */ @@ -5305,7 +5893,9 @@ static YYACTIONTYPE yy_reduce( case 568: /* select_list ::= select_item */ yytestcase(yyruleno==568); case 579: /* partition_list ::= partition_item */ yytestcase(yyruleno==579); case 638: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==638); +#line 308 "sql.y" { yylhsminor.yy502 = createNodeList(pCxt, yymsp[0].minor.yy490); } +#line 5898 "sql.c" yymsp[0].minor.yy502 = yylhsminor.yy502; break; case 152: /* retention_list ::= retention_list NK_COMMA retention */ @@ -5320,704 +5910,1106 @@ static YYACTIONTYPE yy_reduce( case 569: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==569); case 580: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==580); case 639: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==639); +#line 309 "sql.y" { yylhsminor.yy502 = addNodeToList(pCxt, yymsp[-2].minor.yy502, yymsp[0].minor.yy490); } +#line 5915 "sql.c" yymsp[-2].minor.yy502 = yylhsminor.yy502; break; case 153: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ case 154: /* retention ::= NK_MINUS NK_COLON NK_VARIABLE */ yytestcase(yyruleno==154); +#line 311 "sql.y" { yylhsminor.yy490 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 5922 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 155: /* speed_opt ::= */ case 359: /* bufsize_opt ::= */ yytestcase(yyruleno==359); +#line 316 "sql.y" { yymsp[1].minor.yy774 = 0; } +#line 5929 "sql.c" break; case 156: /* speed_opt ::= BWLIMIT NK_INTEGER */ case 360: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==360); +#line 317 "sql.y" { yymsp[-1].minor.yy774 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } +#line 5935 "sql.c" break; case 158: /* start_opt ::= START WITH NK_INTEGER */ case 162: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==162); +#line 320 "sql.y" { yymsp[-2].minor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +#line 5941 "sql.c" break; case 159: /* start_opt ::= START WITH NK_STRING */ case 163: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==163); +#line 321 "sql.y" { yymsp[-2].minor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 5947 "sql.c" break; case 160: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ case 164: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==164); +#line 322 "sql.y" { yymsp[-3].minor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 5953 "sql.c" break; case 165: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 167: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==167); +#line 331 "sql.y" { pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy845, yymsp[-5].minor.yy490, yymsp[-3].minor.yy502, yymsp[-1].minor.yy502, yymsp[0].minor.yy490); } +#line 5959 "sql.c" break; case 166: /* cmd ::= CREATE TABLE multi_create_clause */ +#line 332 "sql.y" { pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy502); } +#line 5964 "sql.c" break; case 168: /* cmd ::= DROP TABLE multi_drop_clause */ +#line 335 "sql.y" { pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy502); } +#line 5969 "sql.c" break; case 169: /* cmd ::= DROP STABLE exists_opt full_table_name */ +#line 336 "sql.y" { pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy845, yymsp[0].minor.yy490); } +#line 5974 "sql.c" break; case 170: /* cmd ::= ALTER TABLE alter_table_clause */ case 405: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==405); case 406: /* cmd ::= insert_query */ yytestcase(yyruleno==406); +#line 338 "sql.y" { pCxt->pRootNode = yymsp[0].minor.yy490; } +#line 5981 "sql.c" break; case 171: /* cmd ::= ALTER STABLE alter_table_clause */ +#line 339 "sql.y" { pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy490); } +#line 5986 "sql.c" break; case 172: /* alter_table_clause ::= full_table_name alter_table_options */ +#line 341 "sql.y" { yylhsminor.yy490 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy490, yymsp[0].minor.yy490); } +#line 5991 "sql.c" yymsp[-1].minor.yy490 = yylhsminor.yy490; break; case 173: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ +#line 343 "sql.y" { yylhsminor.yy490 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy490, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy561, yymsp[0].minor.yy826); } +#line 5997 "sql.c" yymsp[-4].minor.yy490 = yylhsminor.yy490; break; case 174: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ +#line 344 "sql.y" { yylhsminor.yy490 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy490, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy561); } +#line 6003 "sql.c" yymsp[-3].minor.yy490 = yylhsminor.yy490; break; case 175: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ +#line 346 "sql.y" { yylhsminor.yy490 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy490, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy561, yymsp[0].minor.yy826); } +#line 6009 "sql.c" yymsp[-4].minor.yy490 = yylhsminor.yy490; break; case 176: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ +#line 348 "sql.y" { yylhsminor.yy490 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy490, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy561, &yymsp[0].minor.yy561); } +#line 6015 "sql.c" yymsp[-4].minor.yy490 = yylhsminor.yy490; break; case 177: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ +#line 350 "sql.y" { yylhsminor.yy490 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy490, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy561, yymsp[0].minor.yy826); } +#line 6021 "sql.c" yymsp[-4].minor.yy490 = yylhsminor.yy490; break; case 178: /* alter_table_clause ::= full_table_name DROP TAG column_name */ +#line 351 "sql.y" { yylhsminor.yy490 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy490, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy561); } +#line 6027 "sql.c" yymsp[-3].minor.yy490 = yylhsminor.yy490; break; case 179: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ +#line 353 "sql.y" { yylhsminor.yy490 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy490, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy561, yymsp[0].minor.yy826); } +#line 6033 "sql.c" yymsp[-4].minor.yy490 = yylhsminor.yy490; break; case 180: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ +#line 355 "sql.y" { yylhsminor.yy490 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy490, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy561, &yymsp[0].minor.yy561); } +#line 6039 "sql.c" yymsp[-4].minor.yy490 = yylhsminor.yy490; break; case 181: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ +#line 357 "sql.y" { yylhsminor.yy490 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy490, &yymsp[-2].minor.yy561, yymsp[0].minor.yy490); } +#line 6045 "sql.c" yymsp[-5].minor.yy490 = yylhsminor.yy490; break; case 183: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 510: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==510); +#line 362 "sql.y" { yylhsminor.yy502 = addNodeToList(pCxt, yymsp[-1].minor.yy502, yymsp[0].minor.yy490); } +#line 6052 "sql.c" yymsp[-1].minor.yy502 = yylhsminor.yy502; break; case 184: /* 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 */ +#line 366 "sql.y" { yylhsminor.yy490 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy845, yymsp[-8].minor.yy490, yymsp[-6].minor.yy490, yymsp[-5].minor.yy502, yymsp[-2].minor.yy502, yymsp[0].minor.yy490); } +#line 6058 "sql.c" yymsp[-9].minor.yy490 = yylhsminor.yy490; break; case 187: /* drop_table_clause ::= exists_opt full_table_name */ +#line 373 "sql.y" { yylhsminor.yy490 = createDropTableClause(pCxt, yymsp[-1].minor.yy845, yymsp[0].minor.yy490); } +#line 6064 "sql.c" yymsp[-1].minor.yy490 = yylhsminor.yy490; break; case 189: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ case 374: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==374); +#line 378 "sql.y" { yymsp[-2].minor.yy502 = yymsp[-1].minor.yy502; } +#line 6071 "sql.c" break; case 190: /* full_table_name ::= table_name */ +#line 380 "sql.y" { yylhsminor.yy490 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy561, NULL); } +#line 6076 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 191: /* full_table_name ::= db_name NK_DOT table_name */ +#line 381 "sql.y" { yylhsminor.yy490 = createRealTableNode(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy561, NULL); } +#line 6082 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 194: /* column_def ::= column_name type_name */ +#line 388 "sql.y" { yylhsminor.yy490 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy561, yymsp[0].minor.yy826, NULL); } +#line 6088 "sql.c" yymsp[-1].minor.yy490 = yylhsminor.yy490; break; case 195: /* type_name ::= BOOL */ +#line 393 "sql.y" { yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_BOOL); } +#line 6094 "sql.c" break; case 196: /* type_name ::= TINYINT */ +#line 394 "sql.y" { yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_TINYINT); } +#line 6099 "sql.c" break; case 197: /* type_name ::= SMALLINT */ +#line 395 "sql.y" { yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +#line 6104 "sql.c" break; case 198: /* type_name ::= INT */ case 199: /* type_name ::= INTEGER */ yytestcase(yyruleno==199); +#line 396 "sql.y" { yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_INT); } +#line 6110 "sql.c" break; case 200: /* type_name ::= BIGINT */ +#line 398 "sql.y" { yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_BIGINT); } +#line 6115 "sql.c" break; case 201: /* type_name ::= FLOAT */ +#line 399 "sql.y" { yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_FLOAT); } +#line 6120 "sql.c" break; case 202: /* type_name ::= DOUBLE */ +#line 400 "sql.y" { yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +#line 6125 "sql.c" break; case 203: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +#line 401 "sql.y" { yymsp[-3].minor.yy826 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +#line 6130 "sql.c" break; case 204: /* type_name ::= TIMESTAMP */ +#line 402 "sql.y" { yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +#line 6135 "sql.c" break; case 205: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +#line 403 "sql.y" { yymsp[-3].minor.yy826 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +#line 6140 "sql.c" break; case 206: /* type_name ::= TINYINT UNSIGNED */ +#line 404 "sql.y" { yymsp[-1].minor.yy826 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +#line 6145 "sql.c" break; case 207: /* type_name ::= SMALLINT UNSIGNED */ +#line 405 "sql.y" { yymsp[-1].minor.yy826 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +#line 6150 "sql.c" break; case 208: /* type_name ::= INT UNSIGNED */ +#line 406 "sql.y" { yymsp[-1].minor.yy826 = createDataType(TSDB_DATA_TYPE_UINT); } +#line 6155 "sql.c" break; case 209: /* type_name ::= BIGINT UNSIGNED */ +#line 407 "sql.y" { yymsp[-1].minor.yy826 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +#line 6160 "sql.c" break; case 210: /* type_name ::= JSON */ +#line 408 "sql.y" { yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_JSON); } +#line 6165 "sql.c" break; case 211: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +#line 409 "sql.y" { yymsp[-3].minor.yy826 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +#line 6170 "sql.c" break; case 212: /* type_name ::= MEDIUMBLOB */ +#line 410 "sql.y" { yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +#line 6175 "sql.c" break; case 213: /* type_name ::= BLOB */ +#line 411 "sql.y" { yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_BLOB); } +#line 6180 "sql.c" break; case 214: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +#line 412 "sql.y" { yymsp[-3].minor.yy826 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +#line 6185 "sql.c" break; case 215: /* type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ +#line 413 "sql.y" { yymsp[-3].minor.yy826 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } +#line 6190 "sql.c" break; case 216: /* type_name ::= DECIMAL */ +#line 414 "sql.y" { yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 6195 "sql.c" break; case 217: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +#line 415 "sql.y" { yymsp[-3].minor.yy826 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 6200 "sql.c" break; case 218: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +#line 416 "sql.y" { yymsp[-5].minor.yy826 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 6205 "sql.c" break; case 221: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ case 377: /* tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ yytestcase(yyruleno==377); +#line 425 "sql.y" { yymsp[-3].minor.yy502 = yymsp[-1].minor.yy502; } +#line 6211 "sql.c" break; case 222: /* table_options ::= */ +#line 427 "sql.y" { yymsp[1].minor.yy490 = createDefaultTableOptions(pCxt); } +#line 6216 "sql.c" break; case 223: /* table_options ::= table_options COMMENT NK_STRING */ +#line 428 "sql.y" { yylhsminor.yy490 = setTableOption(pCxt, yymsp[-2].minor.yy490, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } +#line 6221 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 224: /* table_options ::= table_options MAX_DELAY duration_list */ +#line 429 "sql.y" { yylhsminor.yy490 = setTableOption(pCxt, yymsp[-2].minor.yy490, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy502); } +#line 6227 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 225: /* table_options ::= table_options WATERMARK duration_list */ +#line 430 "sql.y" { yylhsminor.yy490 = setTableOption(pCxt, yymsp[-2].minor.yy490, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy502); } +#line 6233 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 226: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ +#line 431 "sql.y" { yylhsminor.yy490 = setTableOption(pCxt, yymsp[-4].minor.yy490, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy502); } +#line 6239 "sql.c" yymsp[-4].minor.yy490 = yylhsminor.yy490; break; case 227: /* table_options ::= table_options TTL NK_INTEGER */ +#line 432 "sql.y" { yylhsminor.yy490 = setTableOption(pCxt, yymsp[-2].minor.yy490, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } +#line 6245 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 228: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +#line 433 "sql.y" { yylhsminor.yy490 = setTableOption(pCxt, yymsp[-4].minor.yy490, TABLE_OPTION_SMA, yymsp[-1].minor.yy502); } +#line 6251 "sql.c" yymsp[-4].minor.yy490 = yylhsminor.yy490; break; case 229: /* table_options ::= table_options DELETE_MARK duration_list */ +#line 434 "sql.y" { yylhsminor.yy490 = setTableOption(pCxt, yymsp[-2].minor.yy490, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy502); } +#line 6257 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 230: /* alter_table_options ::= alter_table_option */ +#line 436 "sql.y" { yylhsminor.yy490 = createAlterTableOptions(pCxt); yylhsminor.yy490 = setTableOption(pCxt, yylhsminor.yy490, yymsp[0].minor.yy529.type, &yymsp[0].minor.yy529.val); } +#line 6263 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 231: /* alter_table_options ::= alter_table_options alter_table_option */ +#line 437 "sql.y" { yylhsminor.yy490 = setTableOption(pCxt, yymsp[-1].minor.yy490, yymsp[0].minor.yy529.type, &yymsp[0].minor.yy529.val); } +#line 6269 "sql.c" yymsp[-1].minor.yy490 = yylhsminor.yy490; break; case 232: /* alter_table_option ::= COMMENT NK_STRING */ +#line 441 "sql.y" { yymsp[-1].minor.yy529.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +#line 6275 "sql.c" break; case 233: /* alter_table_option ::= TTL NK_INTEGER */ +#line 442 "sql.y" { yymsp[-1].minor.yy529.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +#line 6280 "sql.c" break; case 234: /* duration_list ::= duration_literal */ case 464: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==464); +#line 446 "sql.y" { yylhsminor.yy502 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy490)); } +#line 6286 "sql.c" yymsp[0].minor.yy502 = yylhsminor.yy502; break; case 235: /* duration_list ::= duration_list NK_COMMA duration_literal */ case 465: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==465); +#line 447 "sql.y" { yylhsminor.yy502 = addNodeToList(pCxt, yymsp[-2].minor.yy502, releaseRawExprNode(pCxt, yymsp[0].minor.yy490)); } +#line 6293 "sql.c" yymsp[-2].minor.yy502 = yylhsminor.yy502; break; case 238: /* rollup_func_name ::= function_name */ +#line 454 "sql.y" { yylhsminor.yy490 = createFunctionNode(pCxt, &yymsp[0].minor.yy561, NULL); } +#line 6299 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 239: /* rollup_func_name ::= FIRST */ case 240: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==240); case 311: /* tag_item ::= QTAGS */ yytestcase(yyruleno==311); +#line 455 "sql.y" { yylhsminor.yy490 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 6307 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 243: /* col_name ::= column_name */ case 312: /* tag_item ::= column_name */ yytestcase(yyruleno==312); +#line 463 "sql.y" { yylhsminor.yy490 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy561); } +#line 6314 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 244: /* cmd ::= SHOW DNODES */ +#line 466 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } +#line 6320 "sql.c" break; case 245: /* cmd ::= SHOW USERS */ +#line 467 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } +#line 6325 "sql.c" break; case 246: /* cmd ::= SHOW USER PRIVILEGES */ +#line 468 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); } +#line 6330 "sql.c" break; case 247: /* cmd ::= SHOW db_kind_opt DATABASES */ +#line 469 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy579); } +#line 6338 "sql.c" break; case 248: /* cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ +#line 473 "sql.y" { pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy961, yymsp[0].minor.yy490, OP_TYPE_LIKE); } +#line 6345 "sql.c" break; case 249: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ +#line 476 "sql.y" { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy490, yymsp[0].minor.yy490, OP_TYPE_LIKE); } +#line 6350 "sql.c" break; case 250: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ +#line 477 "sql.y" { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy490, NULL, OP_TYPE_LIKE); } +#line 6355 "sql.c" break; case 251: /* cmd ::= SHOW MNODES */ +#line 478 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } +#line 6360 "sql.c" break; case 252: /* cmd ::= SHOW QNODES */ +#line 480 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } +#line 6365 "sql.c" break; case 253: /* cmd ::= SHOW FUNCTIONS */ +#line 481 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } +#line 6370 "sql.c" break; case 254: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ +#line 482 "sql.y" { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy490, yymsp[-1].minor.yy490, OP_TYPE_EQUAL); } +#line 6375 "sql.c" break; case 255: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ +#line 483 "sql.y" { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy561), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy561), OP_TYPE_EQUAL); } +#line 6380 "sql.c" break; case 256: /* cmd ::= SHOW STREAMS */ +#line 484 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } +#line 6385 "sql.c" break; case 257: /* cmd ::= SHOW ACCOUNTS */ +#line 485 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } +#line 6390 "sql.c" break; case 258: /* cmd ::= SHOW APPS */ +#line 486 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } +#line 6395 "sql.c" break; case 259: /* cmd ::= SHOW CONNECTIONS */ +#line 487 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } +#line 6400 "sql.c" break; case 260: /* cmd ::= SHOW LICENCES */ case 261: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==261); +#line 488 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } +#line 6406 "sql.c" break; case 262: /* cmd ::= SHOW GRANTS FULL */ +#line 490 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_FULL_STMT); } +#line 6411 "sql.c" break; case 263: /* cmd ::= SHOW GRANTS LOGS */ +#line 491 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_LOGS_STMT); } +#line 6416 "sql.c" break; case 264: /* cmd ::= SHOW CLUSTER MACHINES */ +#line 492 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT); } +#line 6421 "sql.c" break; case 265: /* cmd ::= SHOW CREATE DATABASE db_name */ +#line 493 "sql.y" { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy561); } +#line 6426 "sql.c" break; case 266: /* cmd ::= SHOW CREATE TABLE full_table_name */ +#line 494 "sql.y" { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy490); } +#line 6431 "sql.c" break; case 267: /* cmd ::= SHOW CREATE STABLE full_table_name */ +#line 495 "sql.y" { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy490); } +#line 6436 "sql.c" break; case 268: /* cmd ::= SHOW QUERIES */ +#line 496 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } +#line 6441 "sql.c" break; case 269: /* cmd ::= SHOW SCORES */ +#line 497 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } +#line 6446 "sql.c" break; case 270: /* cmd ::= SHOW TOPICS */ +#line 498 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } +#line 6451 "sql.c" break; case 271: /* cmd ::= SHOW VARIABLES */ case 272: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==272); +#line 499 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } +#line 6457 "sql.c" break; case 273: /* cmd ::= SHOW LOCAL VARIABLES */ +#line 501 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } +#line 6462 "sql.c" break; case 274: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ +#line 502 "sql.y" { pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy490); } +#line 6467 "sql.c" break; case 275: /* cmd ::= SHOW BNODES */ +#line 503 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } +#line 6472 "sql.c" break; case 276: /* cmd ::= SHOW SNODES */ +#line 504 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } +#line 6477 "sql.c" break; case 277: /* cmd ::= SHOW CLUSTER */ +#line 505 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } +#line 6482 "sql.c" break; case 278: /* cmd ::= SHOW TRANSACTIONS */ +#line 506 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } +#line 6487 "sql.c" break; case 279: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ +#line 507 "sql.y" { pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy490); } +#line 6492 "sql.c" break; case 280: /* cmd ::= SHOW CONSUMERS */ +#line 508 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } +#line 6497 "sql.c" break; case 281: /* cmd ::= SHOW SUBSCRIPTIONS */ +#line 509 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } +#line 6502 "sql.c" break; case 282: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ +#line 510 "sql.y" { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy490, yymsp[-1].minor.yy490, OP_TYPE_EQUAL); } +#line 6507 "sql.c" break; case 283: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ +#line 511 "sql.y" { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy561), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy561), OP_TYPE_EQUAL); } +#line 6512 "sql.c" break; case 284: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ +#line 512 "sql.y" { pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy490, yymsp[0].minor.yy490, yymsp[-3].minor.yy502); } +#line 6517 "sql.c" break; case 285: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ +#line 513 "sql.y" { pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy561), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy561), yymsp[-4].minor.yy502); } +#line 6522 "sql.c" break; case 286: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ +#line 514 "sql.y" { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } +#line 6527 "sql.c" break; case 287: /* cmd ::= SHOW VNODES */ +#line 515 "sql.y" { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, NULL); } +#line 6532 "sql.c" break; case 288: /* cmd ::= SHOW db_name_cond_opt ALIVE */ +#line 517 "sql.y" { pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy490, QUERY_NODE_SHOW_DB_ALIVE_STMT); } +#line 6537 "sql.c" break; case 289: /* cmd ::= SHOW CLUSTER ALIVE */ +#line 518 "sql.y" { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } +#line 6542 "sql.c" break; - case 290: /* cmd ::= SHOW db_name_cond_opt VIEWS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-1].minor.yy490, NULL, OP_TYPE_LIKE); } + case 290: /* cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ +#line 519 "sql.y" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-2].minor.yy490, yymsp[0].minor.yy490, OP_TYPE_LIKE); } +#line 6547 "sql.c" break; case 291: /* cmd ::= SHOW CREATE VIEW full_table_name */ +#line 520 "sql.y" { pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy490); } +#line 6552 "sql.c" break; case 292: /* cmd ::= SHOW COMPACTS */ +#line 521 "sql.y" { pCxt->pRootNode = createShowCompactsStmt(pCxt, QUERY_NODE_SHOW_COMPACTS_STMT); } +#line 6557 "sql.c" break; case 293: /* cmd ::= SHOW COMPACT NK_INTEGER */ +#line 522 "sql.y" { pCxt->pRootNode = createShowCompactDetailsStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 6562 "sql.c" break; case 294: /* table_kind_db_name_cond_opt ::= */ +#line 526 "sql.y" { yymsp[1].minor.yy961.kind = SHOW_KIND_ALL; yymsp[1].minor.yy961.dbName = nil_token; } +#line 6567 "sql.c" break; case 295: /* table_kind_db_name_cond_opt ::= table_kind */ +#line 527 "sql.y" { yylhsminor.yy961.kind = yymsp[0].minor.yy579; yylhsminor.yy961.dbName = nil_token; } +#line 6572 "sql.c" yymsp[0].minor.yy961 = yylhsminor.yy961; break; case 296: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ +#line 528 "sql.y" { yylhsminor.yy961.kind = SHOW_KIND_ALL; yylhsminor.yy961.dbName = yymsp[-1].minor.yy561; } +#line 6578 "sql.c" yymsp[-1].minor.yy961 = yylhsminor.yy961; break; case 297: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ +#line 529 "sql.y" { yylhsminor.yy961.kind = yymsp[-2].minor.yy579; yylhsminor.yy961.dbName = yymsp[-1].minor.yy561; } +#line 6584 "sql.c" yymsp[-2].minor.yy961 = yylhsminor.yy961; break; case 298: /* table_kind ::= NORMAL */ +#line 533 "sql.y" { yymsp[0].minor.yy579 = SHOW_KIND_TABLES_NORMAL; } +#line 6590 "sql.c" break; case 299: /* table_kind ::= CHILD */ +#line 534 "sql.y" { yymsp[0].minor.yy579 = SHOW_KIND_TABLES_CHILD; } +#line 6595 "sql.c" break; case 300: /* db_name_cond_opt ::= */ case 305: /* from_db_opt ::= */ yytestcase(yyruleno==305); +#line 536 "sql.y" { yymsp[1].minor.yy490 = createDefaultDatabaseCondValue(pCxt); } +#line 6601 "sql.c" break; case 301: /* db_name_cond_opt ::= db_name NK_DOT */ +#line 537 "sql.y" { yylhsminor.yy490 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy561); } +#line 6606 "sql.c" yymsp[-1].minor.yy490 = yylhsminor.yy490; break; case 303: /* like_pattern_opt ::= LIKE NK_STRING */ +#line 540 "sql.y" { yymsp[-1].minor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +#line 6612 "sql.c" break; case 304: /* table_name_cond ::= table_name */ +#line 542 "sql.y" { yylhsminor.yy490 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy561); } +#line 6617 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 306: /* from_db_opt ::= FROM db_name */ +#line 545 "sql.y" { yymsp[-1].minor.yy490 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy561); } +#line 6623 "sql.c" break; case 310: /* tag_item ::= TBNAME */ +#line 553 "sql.y" { yylhsminor.yy490 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } +#line 6628 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 313: /* tag_item ::= column_name column_alias */ +#line 556 "sql.y" { yylhsminor.yy490 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy561), &yymsp[0].minor.yy561); } +#line 6634 "sql.c" yymsp[-1].minor.yy490 = yylhsminor.yy490; break; case 314: /* tag_item ::= column_name AS column_alias */ +#line 557 "sql.y" { yylhsminor.yy490 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy561), &yymsp[0].minor.yy561); } +#line 6640 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 315: /* db_kind_opt ::= */ +#line 561 "sql.y" { yymsp[1].minor.yy579 = SHOW_KIND_ALL; } +#line 6646 "sql.c" break; case 316: /* db_kind_opt ::= USER */ +#line 562 "sql.y" { yymsp[0].minor.yy579 = SHOW_KIND_DATABASES_USER; } +#line 6651 "sql.c" break; case 317: /* db_kind_opt ::= SYSTEM */ +#line 563 "sql.y" { yymsp[0].minor.yy579 = SHOW_KIND_DATABASES_SYSTEM; } +#line 6656 "sql.c" break; case 318: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ +#line 567 "sql.y" { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy845, yymsp[-3].minor.yy490, yymsp[-1].minor.yy490, NULL, yymsp[0].minor.yy490); } +#line 6661 "sql.c" break; case 319: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ +#line 569 "sql.y" { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy845, yymsp[-5].minor.yy490, yymsp[-3].minor.yy490, yymsp[-1].minor.yy502, NULL); } +#line 6666 "sql.c" break; case 320: /* cmd ::= DROP INDEX exists_opt full_index_name */ +#line 570 "sql.y" { pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy845, yymsp[0].minor.yy490); } +#line 6671 "sql.c" break; case 321: /* full_index_name ::= index_name */ +#line 572 "sql.y" { yylhsminor.yy490 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy561); } +#line 6676 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 322: /* full_index_name ::= db_name NK_DOT index_name */ +#line 573 "sql.y" { yylhsminor.yy490 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy561); } +#line 6682 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 323: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +#line 576 "sql.y" { yymsp[-9].minor.yy490 = createIndexOption(pCxt, yymsp[-7].minor.yy502, releaseRawExprNode(pCxt, yymsp[-3].minor.yy490), NULL, yymsp[-1].minor.yy490, yymsp[0].minor.yy490); } +#line 6688 "sql.c" break; case 324: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ +#line 579 "sql.y" { yymsp[-11].minor.yy490 = createIndexOption(pCxt, yymsp[-9].minor.yy502, releaseRawExprNode(pCxt, yymsp[-5].minor.yy490), releaseRawExprNode(pCxt, yymsp[-3].minor.yy490), yymsp[-1].minor.yy490, yymsp[0].minor.yy490); } +#line 6693 "sql.c" break; case 327: /* func ::= sma_func_name NK_LP expression_list NK_RP */ +#line 586 "sql.y" { yylhsminor.yy490 = createFunctionNode(pCxt, &yymsp[-3].minor.yy561, yymsp[-1].minor.yy502); } +#line 6698 "sql.c" yymsp[-3].minor.yy490 = yylhsminor.yy490; break; case 328: /* sma_func_name ::= function_name */ case 553: /* alias_opt ::= table_alias */ yytestcase(yyruleno==553); +#line 590 "sql.y" { yylhsminor.yy561 = yymsp[0].minor.yy561; } +#line 6705 "sql.c" yymsp[0].minor.yy561 = yylhsminor.yy561; break; case 333: /* sma_stream_opt ::= */ case 378: /* stream_options ::= */ yytestcase(yyruleno==378); +#line 596 "sql.y" { yymsp[1].minor.yy490 = createStreamOptions(pCxt); } +#line 6712 "sql.c" break; case 334: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ +#line 597 "sql.y" { ((SStreamOptions*)yymsp[-2].minor.yy490)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = yymsp[-2].minor.yy490; } +#line 6717 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 335: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ +#line 598 "sql.y" { ((SStreamOptions*)yymsp[-2].minor.yy490)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = yymsp[-2].minor.yy490; } +#line 6723 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 336: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ +#line 599 "sql.y" { ((SStreamOptions*)yymsp[-2].minor.yy490)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = yymsp[-2].minor.yy490; } +#line 6729 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 337: /* with_meta ::= AS */ +#line 604 "sql.y" { yymsp[0].minor.yy774 = 0; } +#line 6735 "sql.c" break; case 338: /* with_meta ::= WITH META AS */ +#line 605 "sql.y" { yymsp[-2].minor.yy774 = 1; } +#line 6740 "sql.c" break; case 339: /* with_meta ::= ONLY META AS */ +#line 606 "sql.y" { yymsp[-2].minor.yy774 = 2; } +#line 6745 "sql.c" break; case 340: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ +#line 608 "sql.y" { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy845, &yymsp[-2].minor.yy561, yymsp[0].minor.yy490); } +#line 6750 "sql.c" break; case 341: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ +#line 610 "sql.y" { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy845, &yymsp[-3].minor.yy561, &yymsp[0].minor.yy561, yymsp[-2].minor.yy774); } +#line 6755 "sql.c" break; case 342: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ +#line 612 "sql.y" { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy845, &yymsp[-4].minor.yy561, yymsp[-1].minor.yy490, yymsp[-3].minor.yy774, yymsp[0].minor.yy490); } +#line 6760 "sql.c" break; case 343: /* cmd ::= DROP TOPIC exists_opt topic_name */ +#line 614 "sql.y" { pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy561); } +#line 6765 "sql.c" break; case 344: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +#line 615 "sql.y" { pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy845, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy561); } +#line 6770 "sql.c" break; case 345: /* cmd ::= DESC full_table_name */ case 346: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==346); +#line 618 "sql.y" { pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy490); } +#line 6776 "sql.c" break; case 347: /* cmd ::= RESET QUERY CACHE */ +#line 622 "sql.y" { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } +#line 6781 "sql.c" break; case 348: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ case 349: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==349); +#line 625 "sql.y" { pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy845, yymsp[-1].minor.yy490, yymsp[0].minor.yy490); } +#line 6787 "sql.c" break; case 352: /* explain_options ::= */ +#line 633 "sql.y" { yymsp[1].minor.yy490 = createDefaultExplainOptions(pCxt); } +#line 6792 "sql.c" break; case 353: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +#line 634 "sql.y" { yylhsminor.yy490 = setExplainVerbose(pCxt, yymsp[-2].minor.yy490, &yymsp[0].minor.yy0); } +#line 6797 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 354: /* explain_options ::= explain_options RATIO NK_FLOAT */ +#line 635 "sql.y" { yylhsminor.yy490 = setExplainRatio(pCxt, yymsp[-2].minor.yy490, &yymsp[0].minor.yy0); } +#line 6803 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 355: /* cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ +#line 640 "sql.y" { pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy845, yymsp[-9].minor.yy845, &yymsp[-6].minor.yy561, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy826, yymsp[-1].minor.yy774, &yymsp[0].minor.yy561, yymsp[-10].minor.yy845); } +#line 6809 "sql.c" break; case 356: /* cmd ::= DROP FUNCTION exists_opt function_name */ +#line 641 "sql.y" { pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy561); } +#line 6814 "sql.c" break; case 361: /* language_opt ::= */ case 400: /* on_vgroup_id ::= */ yytestcase(yyruleno==400); +#line 655 "sql.y" { yymsp[1].minor.yy561 = nil_token; } +#line 6820 "sql.c" break; case 362: /* language_opt ::= LANGUAGE NK_STRING */ case 401: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==401); +#line 656 "sql.y" { yymsp[-1].minor.yy561 = yymsp[0].minor.yy0; } +#line 6826 "sql.c" break; case 365: /* cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ +#line 665 "sql.y" { pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy845, yymsp[-2].minor.yy490, &yymsp[-1].minor.yy0, yymsp[0].minor.yy490); } +#line 6831 "sql.c" break; case 366: /* cmd ::= DROP VIEW exists_opt full_view_name */ +#line 666 "sql.y" { pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy845, yymsp[0].minor.yy490); } +#line 6836 "sql.c" break; case 367: /* full_view_name ::= view_name */ +#line 668 "sql.y" { yylhsminor.yy490 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy561); } +#line 6841 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 368: /* full_view_name ::= db_name NK_DOT view_name */ +#line 669 "sql.y" { yylhsminor.yy490 = createViewNode(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy561); } +#line 6847 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 369: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ +#line 674 "sql.y" { pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy845, &yymsp[-8].minor.yy561, yymsp[-5].minor.yy490, yymsp[-7].minor.yy490, yymsp[-3].minor.yy502, yymsp[-2].minor.yy490, yymsp[0].minor.yy490, yymsp[-4].minor.yy502); } +#line 6853 "sql.c" break; case 370: /* cmd ::= DROP STREAM exists_opt stream_name */ +#line 675 "sql.y" { pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy561); } +#line 6858 "sql.c" break; case 371: /* cmd ::= PAUSE STREAM exists_opt stream_name */ +#line 676 "sql.y" { pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy561); } +#line 6863 "sql.c" break; case 372: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ +#line 677 "sql.y" { pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy845, yymsp[-1].minor.yy845, &yymsp[0].minor.yy561); } +#line 6868 "sql.c" break; case 379: /* stream_options ::= stream_options TRIGGER AT_ONCE */ case 380: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==380); +#line 691 "sql.y" { yylhsminor.yy490 = setStreamOptions(pCxt, yymsp[-2].minor.yy490, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } +#line 6874 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 381: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +#line 693 "sql.y" { yylhsminor.yy490 = setStreamOptions(pCxt, yymsp[-3].minor.yy490, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy490)); } +#line 6880 "sql.c" yymsp[-3].minor.yy490 = yylhsminor.yy490; break; case 382: /* stream_options ::= stream_options WATERMARK duration_literal */ +#line 694 "sql.y" { yylhsminor.yy490 = setStreamOptions(pCxt, yymsp[-2].minor.yy490, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy490)); } +#line 6886 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 383: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ +#line 695 "sql.y" { yylhsminor.yy490 = setStreamOptions(pCxt, yymsp[-3].minor.yy490, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } +#line 6892 "sql.c" yymsp[-3].minor.yy490 = yylhsminor.yy490; break; case 384: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ +#line 696 "sql.y" { yylhsminor.yy490 = setStreamOptions(pCxt, yymsp[-2].minor.yy490, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } +#line 6898 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 385: /* stream_options ::= stream_options DELETE_MARK duration_literal */ +#line 697 "sql.y" { yylhsminor.yy490 = setStreamOptions(pCxt, yymsp[-2].minor.yy490, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy490)); } +#line 6904 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 386: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ +#line 698 "sql.y" { yylhsminor.yy490 = setStreamOptions(pCxt, yymsp[-3].minor.yy490, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } +#line 6910 "sql.c" yymsp[-3].minor.yy490 = yylhsminor.yy490; break; case 388: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ case 591: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==591); case 615: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==615); +#line 701 "sql.y" { yymsp[-3].minor.yy490 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy490); } +#line 6918 "sql.c" break; case 391: /* cmd ::= KILL CONNECTION NK_INTEGER */ +#line 709 "sql.y" { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } +#line 6923 "sql.c" break; case 392: /* cmd ::= KILL QUERY NK_STRING */ +#line 710 "sql.y" { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } +#line 6928 "sql.c" break; case 393: /* cmd ::= KILL TRANSACTION NK_INTEGER */ +#line 711 "sql.y" { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } +#line 6933 "sql.c" break; case 394: /* cmd ::= KILL COMPACT NK_INTEGER */ +#line 712 "sql.y" { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_COMPACT_STMT, &yymsp[0].minor.yy0); } +#line 6938 "sql.c" break; case 395: /* cmd ::= BALANCE VGROUP */ +#line 715 "sql.y" { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } +#line 6943 "sql.c" break; case 396: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ +#line 716 "sql.y" { pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy561); } +#line 6948 "sql.c" break; case 397: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ +#line 717 "sql.y" { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 6953 "sql.c" break; case 398: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +#line 718 "sql.y" { pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy502); } +#line 6958 "sql.c" break; case 399: /* cmd ::= SPLIT VGROUP NK_INTEGER */ +#line 719 "sql.y" { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } +#line 6963 "sql.c" break; case 402: /* dnode_list ::= DNODE NK_INTEGER */ +#line 728 "sql.y" { yymsp[-1].minor.yy502 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 6968 "sql.c" break; case 404: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +#line 735 "sql.y" { pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy490, yymsp[0].minor.yy490); } +#line 6973 "sql.c" break; case 407: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ +#line 744 "sql.y" { yymsp[-6].minor.yy490 = createInsertStmt(pCxt, yymsp[-4].minor.yy490, yymsp[-2].minor.yy502, yymsp[0].minor.yy490); } +#line 6978 "sql.c" break; case 408: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ +#line 745 "sql.y" { yymsp[-3].minor.yy490 = createInsertStmt(pCxt, yymsp[-1].minor.yy490, NULL, yymsp[0].minor.yy490); } +#line 6983 "sql.c" break; case 409: /* literal ::= NK_INTEGER */ +#line 748 "sql.y" { yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } +#line 6988 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 410: /* literal ::= NK_FLOAT */ +#line 749 "sql.y" { yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } +#line 6994 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 411: /* literal ::= NK_STRING */ +#line 750 "sql.y" { yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 7000 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 412: /* literal ::= NK_BOOL */ +#line 751 "sql.y" { yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } +#line 7006 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 413: /* literal ::= TIMESTAMP NK_STRING */ +#line 752 "sql.y" { yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } +#line 7012 "sql.c" yymsp[-1].minor.yy490 = yylhsminor.yy490; break; case 414: /* literal ::= duration_literal */ @@ -6040,64 +7032,90 @@ static YYACTIONTYPE yy_reduce( case 618: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==618); case 621: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==621); case 623: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==623); +#line 753 "sql.y" { yylhsminor.yy490 = yymsp[0].minor.yy490; } +#line 7037 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 415: /* literal ::= NULL */ +#line 754 "sql.y" { yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } +#line 7043 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 416: /* literal ::= NK_QUESTION */ +#line 755 "sql.y" { yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 7049 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 417: /* duration_literal ::= NK_VARIABLE */ case 592: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==592); case 593: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==593); case 594: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==594); +#line 757 "sql.y" { yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 7058 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 418: /* signed ::= NK_INTEGER */ +#line 759 "sql.y" { yylhsminor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } +#line 7064 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 419: /* signed ::= NK_PLUS NK_INTEGER */ +#line 760 "sql.y" { yymsp[-1].minor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } +#line 7070 "sql.c" break; case 420: /* signed ::= NK_MINUS NK_INTEGER */ +#line 761 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } +#line 7079 "sql.c" yymsp[-1].minor.yy490 = yylhsminor.yy490; break; case 421: /* signed ::= NK_FLOAT */ +#line 766 "sql.y" { yylhsminor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +#line 7085 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 422: /* signed ::= NK_PLUS NK_FLOAT */ +#line 767 "sql.y" { yymsp[-1].minor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +#line 7091 "sql.c" break; case 423: /* signed ::= NK_MINUS NK_FLOAT */ +#line 768 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; yylhsminor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } +#line 7100 "sql.c" yymsp[-1].minor.yy490 = yylhsminor.yy490; break; case 425: /* signed_literal ::= NK_STRING */ +#line 775 "sql.y" { yylhsminor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +#line 7106 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 426: /* signed_literal ::= NK_BOOL */ +#line 776 "sql.y" { yylhsminor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } +#line 7112 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 427: /* signed_literal ::= TIMESTAMP NK_STRING */ +#line 777 "sql.y" { yymsp[-1].minor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 7118 "sql.c" break; case 428: /* signed_literal ::= duration_literal */ case 430: /* signed_literal ::= literal_func */ yytestcase(yyruleno==430); @@ -6107,118 +7125,156 @@ static YYACTIONTYPE yy_reduce( case 622: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==622); case 624: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==624); case 637: /* search_condition ::= common_expression */ yytestcase(yyruleno==637); +#line 778 "sql.y" { yylhsminor.yy490 = releaseRawExprNode(pCxt, yymsp[0].minor.yy490); } +#line 7130 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 429: /* signed_literal ::= NULL */ +#line 779 "sql.y" { yylhsminor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } +#line 7136 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 431: /* signed_literal ::= NK_QUESTION */ +#line 781 "sql.y" { yylhsminor.yy490 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } +#line 7142 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 449: /* expression ::= pseudo_column */ +#line 843 "sql.y" { yylhsminor.yy490 = yymsp[0].minor.yy490; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy490, true); } +#line 7148 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 453: /* expression ::= NK_LP expression NK_RP */ case 539: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==539); case 636: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==636); +#line 847 "sql.y" { yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy490)); } +#line 7156 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 454: /* expression ::= NK_PLUS expr_or_subquery */ +#line 848 "sql.y" { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy490)); } +#line 7165 "sql.c" yymsp[-1].minor.yy490 = yylhsminor.yy490; break; case 455: /* expression ::= NK_MINUS expr_or_subquery */ +#line 852 "sql.y" { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy490), NULL)); } +#line 7174 "sql.c" yymsp[-1].minor.yy490 = yylhsminor.yy490; break; case 456: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ +#line 856 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy490); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), releaseRawExprNode(pCxt, yymsp[0].minor.yy490))); } +#line 7184 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 457: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ +#line 861 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy490); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), releaseRawExprNode(pCxt, yymsp[0].minor.yy490))); } +#line 7194 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 458: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ +#line 866 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy490); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), releaseRawExprNode(pCxt, yymsp[0].minor.yy490))); } +#line 7204 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 459: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ +#line 871 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy490); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), releaseRawExprNode(pCxt, yymsp[0].minor.yy490))); } +#line 7214 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 460: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ +#line 876 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy490); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), releaseRawExprNode(pCxt, yymsp[0].minor.yy490))); } +#line 7224 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 461: /* expression ::= column_reference NK_ARROW NK_STRING */ +#line 881 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } +#line 7233 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 462: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ +#line 885 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy490); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), releaseRawExprNode(pCxt, yymsp[0].minor.yy490))); } +#line 7243 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 463: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ +#line 890 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy490); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), releaseRawExprNode(pCxt, yymsp[0].minor.yy490))); } +#line 7253 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 466: /* column_reference ::= column_name */ +#line 901 "sql.y" { yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy561, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy561)); } +#line 7259 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 467: /* column_reference ::= table_name NK_DOT column_name */ +#line 902 "sql.y" { yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy561, createColumnNode(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy561)); } +#line 7265 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 468: /* column_reference ::= NK_ALIAS */ +#line 903 "sql.y" { yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } +#line 7271 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 469: /* column_reference ::= table_name NK_DOT NK_ALIAS */ +#line 904 "sql.y" { yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy0)); } +#line 7277 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 470: /* pseudo_column ::= ROWTS */ @@ -6233,191 +7289,278 @@ static YYACTIONTYPE yy_reduce( case 480: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==480); case 481: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==481); case 487: /* literal_func ::= NOW */ yytestcase(yyruleno==487); +#line 906 "sql.y" { yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } +#line 7294 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 472: /* pseudo_column ::= table_name NK_DOT TBNAME */ +#line 908 "sql.y" { yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy561)))); } +#line 7300 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 482: /* function_expression ::= function_name NK_LP expression_list NK_RP */ case 483: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==483); +#line 919 "sql.y" { yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy561, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy561, yymsp[-1].minor.yy502)); } +#line 7307 "sql.c" yymsp[-3].minor.yy490 = yylhsminor.yy490; break; case 484: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ +#line 922 "sql.y" { yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy490), yymsp[-1].minor.yy826)); } +#line 7313 "sql.c" yymsp[-5].minor.yy490 = yylhsminor.yy490; break; case 486: /* literal_func ::= noarg_func NK_LP NK_RP */ +#line 925 "sql.y" { yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy561, NULL)); } +#line 7319 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 501: /* star_func_para_list ::= NK_STAR */ +#line 949 "sql.y" { yylhsminor.yy502 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } +#line 7325 "sql.c" yymsp[0].minor.yy502 = yylhsminor.yy502; break; case 506: /* star_func_para ::= table_name NK_DOT NK_STAR */ case 574: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==574); +#line 958 "sql.y" { yylhsminor.yy490 = createColumnNode(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy0); } +#line 7332 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 507: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ +#line 961 "sql.y" { yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy502, yymsp[-1].minor.yy490)); } +#line 7338 "sql.c" yymsp[-3].minor.yy490 = yylhsminor.yy490; break; case 508: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ +#line 963 "sql.y" { yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy490), yymsp[-2].minor.yy502, yymsp[-1].minor.yy490)); } +#line 7344 "sql.c" yymsp[-4].minor.yy490 = yylhsminor.yy490; break; case 511: /* when_then_expr ::= WHEN common_expression THEN common_expression */ +#line 970 "sql.y" { yymsp[-3].minor.yy490 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), releaseRawExprNode(pCxt, yymsp[0].minor.yy490)); } +#line 7350 "sql.c" break; case 513: /* case_when_else_opt ::= ELSE common_expression */ +#line 973 "sql.y" { yymsp[-1].minor.yy490 = releaseRawExprNode(pCxt, yymsp[0].minor.yy490); } +#line 7355 "sql.c" break; case 514: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ case 519: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==519); +#line 976 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy490); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy30, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), releaseRawExprNode(pCxt, yymsp[0].minor.yy490))); } +#line 7365 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 515: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ +#line 983 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy490); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy490), releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), releaseRawExprNode(pCxt, yymsp[0].minor.yy490))); } +#line 7375 "sql.c" yymsp[-4].minor.yy490 = yylhsminor.yy490; break; case 516: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ +#line 989 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy490); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy490), releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), releaseRawExprNode(pCxt, yymsp[0].minor.yy490))); } +#line 7385 "sql.c" yymsp[-5].minor.yy490 = yylhsminor.yy490; break; case 517: /* predicate ::= expr_or_subquery IS NULL */ +#line 994 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), NULL)); } +#line 7394 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 518: /* predicate ::= expr_or_subquery IS NOT NULL */ +#line 998 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy490), NULL)); } +#line 7403 "sql.c" yymsp[-3].minor.yy490 = yylhsminor.yy490; break; case 520: /* compare_op ::= NK_LT */ +#line 1010 "sql.y" { yymsp[0].minor.yy30 = OP_TYPE_LOWER_THAN; } +#line 7409 "sql.c" break; case 521: /* compare_op ::= NK_GT */ +#line 1011 "sql.y" { yymsp[0].minor.yy30 = OP_TYPE_GREATER_THAN; } +#line 7414 "sql.c" break; case 522: /* compare_op ::= NK_LE */ +#line 1012 "sql.y" { yymsp[0].minor.yy30 = OP_TYPE_LOWER_EQUAL; } +#line 7419 "sql.c" break; case 523: /* compare_op ::= NK_GE */ +#line 1013 "sql.y" { yymsp[0].minor.yy30 = OP_TYPE_GREATER_EQUAL; } +#line 7424 "sql.c" break; case 524: /* compare_op ::= NK_NE */ +#line 1014 "sql.y" { yymsp[0].minor.yy30 = OP_TYPE_NOT_EQUAL; } +#line 7429 "sql.c" break; case 525: /* compare_op ::= NK_EQ */ +#line 1015 "sql.y" { yymsp[0].minor.yy30 = OP_TYPE_EQUAL; } +#line 7434 "sql.c" break; case 526: /* compare_op ::= LIKE */ +#line 1016 "sql.y" { yymsp[0].minor.yy30 = OP_TYPE_LIKE; } +#line 7439 "sql.c" break; case 527: /* compare_op ::= NOT LIKE */ +#line 1017 "sql.y" { yymsp[-1].minor.yy30 = OP_TYPE_NOT_LIKE; } +#line 7444 "sql.c" break; case 528: /* compare_op ::= MATCH */ +#line 1018 "sql.y" { yymsp[0].minor.yy30 = OP_TYPE_MATCH; } +#line 7449 "sql.c" break; case 529: /* compare_op ::= NMATCH */ +#line 1019 "sql.y" { yymsp[0].minor.yy30 = OP_TYPE_NMATCH; } +#line 7454 "sql.c" break; case 530: /* compare_op ::= CONTAINS */ +#line 1020 "sql.y" { yymsp[0].minor.yy30 = OP_TYPE_JSON_CONTAINS; } +#line 7459 "sql.c" break; case 531: /* in_op ::= IN */ +#line 1024 "sql.y" { yymsp[0].minor.yy30 = OP_TYPE_IN; } +#line 7464 "sql.c" break; case 532: /* in_op ::= NOT IN */ +#line 1025 "sql.y" { yymsp[-1].minor.yy30 = OP_TYPE_NOT_IN; } +#line 7469 "sql.c" break; case 533: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +#line 1027 "sql.y" { yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy502)); } +#line 7474 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 535: /* boolean_value_expression ::= NOT boolean_primary */ +#line 1031 "sql.y" { SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy490), NULL)); } +#line 7483 "sql.c" yymsp[-1].minor.yy490 = yylhsminor.yy490; break; case 536: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ +#line 1036 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy490); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), releaseRawExprNode(pCxt, yymsp[0].minor.yy490))); } +#line 7493 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 537: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ +#line 1042 "sql.y" { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy490); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), releaseRawExprNode(pCxt, yymsp[0].minor.yy490))); } +#line 7503 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 545: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +#line 1060 "sql.y" { yylhsminor.yy490 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy490, yymsp[0].minor.yy490, NULL); } +#line 7509 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 548: /* table_primary ::= table_name alias_opt */ +#line 1066 "sql.y" { yylhsminor.yy490 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy561, &yymsp[0].minor.yy561); } +#line 7515 "sql.c" yymsp[-1].minor.yy490 = yylhsminor.yy490; break; case 549: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +#line 1067 "sql.y" { yylhsminor.yy490 = createRealTableNode(pCxt, &yymsp[-3].minor.yy561, &yymsp[-1].minor.yy561, &yymsp[0].minor.yy561); } +#line 7521 "sql.c" yymsp[-3].minor.yy490 = yylhsminor.yy490; break; case 550: /* table_primary ::= subquery alias_opt */ +#line 1068 "sql.y" { yylhsminor.yy490 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy490), &yymsp[0].minor.yy561); } +#line 7527 "sql.c" yymsp[-1].minor.yy490 = yylhsminor.yy490; break; case 552: /* alias_opt ::= */ +#line 1073 "sql.y" { yymsp[1].minor.yy561 = nil_token; } +#line 7533 "sql.c" break; case 554: /* alias_opt ::= AS table_alias */ +#line 1075 "sql.y" { yymsp[-1].minor.yy561 = yymsp[0].minor.yy561; } +#line 7538 "sql.c" break; case 555: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ case 556: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==556); +#line 1077 "sql.y" { yymsp[-2].minor.yy490 = yymsp[-1].minor.yy490; } +#line 7544 "sql.c" break; case 557: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +#line 1082 "sql.y" { yylhsminor.yy490 = createJoinTableNode(pCxt, yymsp[-4].minor.yy246, yymsp[-5].minor.yy490, yymsp[-2].minor.yy490, yymsp[0].minor.yy490); } +#line 7549 "sql.c" yymsp[-5].minor.yy490 = yylhsminor.yy490; break; case 558: /* join_type ::= */ +#line 1086 "sql.y" { yymsp[1].minor.yy246 = JOIN_TYPE_INNER; } +#line 7555 "sql.c" break; case 559: /* join_type ::= INNER */ +#line 1087 "sql.y" { yymsp[0].minor.yy246 = JOIN_TYPE_INNER; } +#line 7560 "sql.c" break; case 560: /* query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ +#line 1093 "sql.y" { yymsp[-13].minor.yy490 = createSelectStmt(pCxt, yymsp[-11].minor.yy845, yymsp[-9].minor.yy502, yymsp[-8].minor.yy490, yymsp[-12].minor.yy502); yymsp[-13].minor.yy490 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy490, yymsp[-10].minor.yy845); @@ -6430,145 +7573,224 @@ static YYACTIONTYPE yy_reduce( yymsp[-13].minor.yy490 = addEveryClause(pCxt, yymsp[-13].minor.yy490, yymsp[-4].minor.yy490); yymsp[-13].minor.yy490 = addFillClause(pCxt, yymsp[-13].minor.yy490, yymsp[-3].minor.yy490); } +#line 7576 "sql.c" break; case 561: /* hint_list ::= */ +#line 1108 "sql.y" { yymsp[1].minor.yy502 = createHintNodeList(pCxt, NULL); } +#line 7581 "sql.c" break; case 562: /* hint_list ::= NK_HINT */ +#line 1109 "sql.y" { yylhsminor.yy502 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } +#line 7586 "sql.c" yymsp[0].minor.yy502 = yylhsminor.yy502; break; case 567: /* set_quantifier_opt ::= ALL */ +#line 1120 "sql.y" { yymsp[0].minor.yy845 = false; } +#line 7592 "sql.c" break; case 570: /* select_item ::= NK_STAR */ +#line 1127 "sql.y" { yylhsminor.yy490 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } +#line 7597 "sql.c" yymsp[0].minor.yy490 = yylhsminor.yy490; break; case 572: /* select_item ::= common_expression column_alias */ case 582: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==582); +#line 1129 "sql.y" { yylhsminor.yy490 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy490), &yymsp[0].minor.yy561); } +#line 7604 "sql.c" yymsp[-1].minor.yy490 = yylhsminor.yy490; break; case 573: /* select_item ::= common_expression AS column_alias */ case 583: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==583); +#line 1130 "sql.y" { yylhsminor.yy490 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), &yymsp[0].minor.yy561); } +#line 7611 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 578: /* partition_by_clause_opt ::= PARTITION BY partition_list */ case 606: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==606); case 626: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==626); +#line 1139 "sql.y" { yymsp[-2].minor.yy502 = yymsp[0].minor.yy502; } +#line 7619 "sql.c" break; case 585: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ +#line 1152 "sql.y" { yymsp[-5].minor.yy490 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy490), releaseRawExprNode(pCxt, yymsp[-1].minor.yy490)); } +#line 7624 "sql.c" break; case 586: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ +#line 1153 "sql.y" { yymsp[-3].minor.yy490 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy490)); } +#line 7629 "sql.c" break; case 587: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ +#line 1155 "sql.y" { yymsp[-5].minor.yy490 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy490), NULL, yymsp[-1].minor.yy490, yymsp[0].minor.yy490); } +#line 7634 "sql.c" break; case 588: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ +#line 1159 "sql.y" { yymsp[-7].minor.yy490 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy490), releaseRawExprNode(pCxt, yymsp[-3].minor.yy490), yymsp[-1].minor.yy490, yymsp[0].minor.yy490); } +#line 7639 "sql.c" break; case 589: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ +#line 1161 "sql.y" { yymsp[-6].minor.yy490 = createEventWindowNode(pCxt, yymsp[-3].minor.yy490, yymsp[0].minor.yy490); } +#line 7644 "sql.c" break; case 596: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +#line 1171 "sql.y" { yymsp[-3].minor.yy490 = createFillNode(pCxt, yymsp[-1].minor.yy718, NULL); } +#line 7649 "sql.c" break; case 597: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ +#line 1172 "sql.y" { yymsp[-5].minor.yy490 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy502)); } +#line 7654 "sql.c" break; case 598: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ +#line 1173 "sql.y" { yymsp[-5].minor.yy490 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy502)); } +#line 7659 "sql.c" break; case 599: /* fill_mode ::= NONE */ +#line 1177 "sql.y" { yymsp[0].minor.yy718 = FILL_MODE_NONE; } +#line 7664 "sql.c" break; case 600: /* fill_mode ::= PREV */ +#line 1178 "sql.y" { yymsp[0].minor.yy718 = FILL_MODE_PREV; } +#line 7669 "sql.c" break; case 601: /* fill_mode ::= NULL */ +#line 1179 "sql.y" { yymsp[0].minor.yy718 = FILL_MODE_NULL; } +#line 7674 "sql.c" break; case 602: /* fill_mode ::= NULL_F */ +#line 1180 "sql.y" { yymsp[0].minor.yy718 = FILL_MODE_NULL_F; } +#line 7679 "sql.c" break; case 603: /* fill_mode ::= LINEAR */ +#line 1181 "sql.y" { yymsp[0].minor.yy718 = FILL_MODE_LINEAR; } +#line 7684 "sql.c" break; case 604: /* fill_mode ::= NEXT */ +#line 1182 "sql.y" { yymsp[0].minor.yy718 = FILL_MODE_NEXT; } +#line 7689 "sql.c" break; case 607: /* group_by_list ::= expr_or_subquery */ +#line 1191 "sql.y" { yylhsminor.yy502 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy490))); } +#line 7694 "sql.c" yymsp[0].minor.yy502 = yylhsminor.yy502; break; case 608: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ +#line 1192 "sql.y" { yylhsminor.yy502 = addNodeToList(pCxt, yymsp[-2].minor.yy502, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy490))); } +#line 7700 "sql.c" yymsp[-2].minor.yy502 = yylhsminor.yy502; break; case 612: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +#line 1199 "sql.y" { yymsp[-5].minor.yy490 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy490), releaseRawExprNode(pCxt, yymsp[-1].minor.yy490)); } +#line 7706 "sql.c" break; case 613: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ +#line 1201 "sql.y" { yymsp[-3].minor.yy490 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy490)); } +#line 7711 "sql.c" break; case 616: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ +#line 1208 "sql.y" { yylhsminor.yy490 = addOrderByClause(pCxt, yymsp[-3].minor.yy490, yymsp[-2].minor.yy502); yylhsminor.yy490 = addSlimitClause(pCxt, yylhsminor.yy490, yymsp[-1].minor.yy490); yylhsminor.yy490 = addLimitClause(pCxt, yylhsminor.yy490, yymsp[0].minor.yy490); } +#line 7720 "sql.c" yymsp[-3].minor.yy490 = yylhsminor.yy490; break; case 619: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +#line 1218 "sql.y" { yylhsminor.yy490 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy490, yymsp[0].minor.yy490); } +#line 7726 "sql.c" yymsp[-3].minor.yy490 = yylhsminor.yy490; break; case 620: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +#line 1220 "sql.y" { yylhsminor.yy490 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy490, yymsp[0].minor.yy490); } +#line 7732 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 628: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ case 632: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==632); +#line 1234 "sql.y" { yymsp[-1].minor.yy490 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 7739 "sql.c" break; case 629: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ case 633: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==633); +#line 1235 "sql.y" { yymsp[-3].minor.yy490 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } +#line 7745 "sql.c" break; case 630: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ case 634: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==634); +#line 1236 "sql.y" { yymsp[-3].minor.yy490 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } +#line 7751 "sql.c" break; case 635: /* subquery ::= NK_LP query_expression NK_RP */ +#line 1244 "sql.y" { yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy490); } +#line 7756 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 640: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ +#line 1258 "sql.y" { yylhsminor.yy490 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), yymsp[-1].minor.yy876, yymsp[0].minor.yy361); } +#line 7762 "sql.c" yymsp[-2].minor.yy490 = yylhsminor.yy490; break; case 641: /* ordering_specification_opt ::= */ +#line 1262 "sql.y" { yymsp[1].minor.yy876 = ORDER_ASC; } +#line 7768 "sql.c" break; case 642: /* ordering_specification_opt ::= ASC */ +#line 1263 "sql.y" { yymsp[0].minor.yy876 = ORDER_ASC; } +#line 7773 "sql.c" break; case 643: /* ordering_specification_opt ::= DESC */ +#line 1264 "sql.y" { yymsp[0].minor.yy876 = ORDER_DESC; } +#line 7778 "sql.c" break; case 644: /* null_ordering_opt ::= */ +#line 1268 "sql.y" { yymsp[1].minor.yy361 = NULL_ORDER_DEFAULT; } +#line 7783 "sql.c" break; case 645: /* null_ordering_opt ::= NULLS FIRST */ +#line 1269 "sql.y" { yymsp[-1].minor.yy361 = NULL_ORDER_FIRST; } +#line 7788 "sql.c" break; case 646: /* null_ordering_opt ::= NULLS LAST */ +#line 1270 "sql.y" { yymsp[-1].minor.yy361 = NULL_ORDER_LAST; } +#line 7793 "sql.c" break; default: break; @@ -6630,6 +7852,7 @@ static void yy_syntax_error( ParseCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ +#line 29 "sql.y" if (TSDB_CODE_SUCCESS == pCxt->errCode) { if(TOKEN.z) { @@ -6640,6 +7863,7 @@ static void yy_syntax_error( } else if (TSDB_CODE_PAR_DB_NOT_SPECIFIED == pCxt->errCode && TK_NK_FLOAT == TOKEN.type) { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z); } +#line 7866 "sql.c" /************ End %syntax_error code ******************************************/ ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ ParseCTX_STORE @@ -6725,12 +7949,56 @@ void Parse( } #endif - do{ + while(1){ /* Exit by "break" */ + assert( yypParser->yytos>=yypParser->yystack ); assert( yyact==yypParser->yytos->stateno ); yyact = yy_find_shift_action((YYCODETYPE)yymajor,yyact); if( yyact >= YY_MIN_REDUCE ){ - yyact = yy_reduce(yypParser,yyact-YY_MIN_REDUCE,yymajor, - yyminor ParseCTX_PARAM); + unsigned int yyruleno = yyact - YY_MIN_REDUCE; /* Reduce by this rule */ +#ifndef NDEBUG + assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); + if( yyTraceFILE ){ + int yysize = yyRuleInfoNRhs[yyruleno]; + if( yysize ){ + fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", + yyTracePrompt, + yyruleno, yyRuleName[yyruleno], + yyrulenoyytos[yysize].stateno); + }else{ + fprintf(yyTraceFILE, "%sReduce %d [%s]%s.\n", + yyTracePrompt, yyruleno, yyRuleName[yyruleno], + yyrulenoyytos - yypParser->yystack)>yypParser->yyhwm ){ + yypParser->yyhwm++; + assert( yypParser->yyhwm == + (int)(yypParser->yytos - yypParser->yystack)); + } +#endif +#if YYSTACKDEPTH>0 + if( yypParser->yytos>=yypParser->yystackEnd ){ + yyStackOverflow(yypParser); + break; + } +#else + if( yypParser->yytos>=&yypParser->yystack[yypParser->yystksz-1] ){ + if( yyGrowStack(yypParser) ){ + yyStackOverflow(yypParser); + break; + } + } +#endif + } + yyact = yy_reduce(yypParser,yyruleno,yymajor,yyminor ParseCTX_PARAM); }else if( yyact <= YY_MAX_SHIFTREDUCE ){ yy_shift(yypParser,yyact,(YYCODETYPE)yymajor,yyminor); #ifndef YYNOERRORRECOVERY @@ -6786,14 +8054,13 @@ void Parse( yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion); yymajor = YYNOCODE; }else{ - while( yypParser->yytos >= yypParser->yystack - && (yyact = yy_find_reduce_action( - yypParser->yytos->stateno, - YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE - ){ + while( yypParser->yytos > yypParser->yystack ){ + yyact = yy_find_reduce_action(yypParser->yytos->stateno, + YYERRORSYMBOL); + if( yyact<=YY_MAX_SHIFTREDUCE ) break; yy_pop_parser_stack(yypParser); } - if( yypParser->yytos < yypParser->yystack || yymajor==0 ){ + if( yypParser->yytos <= yypParser->yystack || yymajor==0 ){ yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); yy_parse_failed(yypParser); #ifndef YYNOERRORRECOVERY @@ -6843,7 +8110,7 @@ void Parse( break; #endif } - }while( yypParser->yytos>yypParser->yystack ); + } #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 4b0024d098..dde3b23b29 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1617,6 +1617,8 @@ static ENodeType getIntervalOperatorType(EWindowAlgorithm windowAlgo) { return QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL; case INTERVAL_ALGO_STREAM_SEMI: return QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL; + case INTERVAL_ALGO_STREAM_MID: + return QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL; case INTERVAL_ALGO_STREAM_SINGLE: return QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL; case SESSION_ALGO_STREAM_FINAL: diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 28e31b7a4f..4099f2be42 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -344,11 +344,12 @@ static bool stbSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SL return false; } -static int32_t stbSplRewriteFuns(const SNodeList* pFuncs, SNodeList** pPartialFuncs, SNodeList** pMergeFuncs) { +static int32_t stbSplRewriteFuns(const SNodeList* pFuncs, SNodeList** pPartialFuncs, SNodeList** pMidFuncs, SNodeList** pMergeFuncs) { SNode* pNode = NULL; FOREACH(pNode, pFuncs) { SFunctionNode* pFunc = (SFunctionNode*)pNode; SFunctionNode* pPartFunc = NULL; + SFunctionNode* pMidFunc = NULL; SFunctionNode* pMergeFunc = NULL; int32_t code = TSDB_CODE_SUCCESS; if (fmIsWindowPseudoColumnFunc(pFunc->funcId)) { @@ -359,18 +360,33 @@ static int32_t stbSplRewriteFuns(const SNodeList* pFuncs, SNodeList** pPartialFu nodesDestroyNode((SNode*)pMergeFunc); code = TSDB_CODE_OUT_OF_MEMORY; } + if(pMidFuncs != NULL){ + pMidFunc = (SFunctionNode*)nodesCloneNode(pNode); + if (NULL == pMidFunc) { + nodesDestroyNode((SNode*)pMidFunc); + code = TSDB_CODE_OUT_OF_MEMORY; + } + } } else { - code = fmGetDistMethod(pFunc, &pPartFunc, &pMergeFunc); + code = fmGetDistMethod(pFunc, &pPartFunc, &pMidFunc, &pMergeFunc); } if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(pPartialFuncs, (SNode*)pPartFunc); } + if (TSDB_CODE_SUCCESS == code) { + if(pMidFuncs != NULL){ + code = nodesListMakeStrictAppend(pMidFuncs, (SNode*)pMidFunc); + }else{ + nodesDestroyNode((SNode*)pMidFunc); + } + } if (TSDB_CODE_SUCCESS == code) { code = nodesListMakeStrictAppend(pMergeFuncs, (SNode*)pMergeFunc); } if (TSDB_CODE_SUCCESS != code) { - nodesDestroyList(*pPartialFuncs); - nodesDestroyList(*pMergeFuncs); + nodesDestroyNode((SNode*)pPartFunc); + nodesDestroyNode((SNode*)pMidFunc); + nodesDestroyNode((SNode*)pMergeFunc); return code; } } @@ -463,7 +479,7 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic splSetParent((SLogicNode*)pPartWin); int32_t index = 0; - int32_t code = stbSplRewriteFuns(pFunc, &pPartWin->pFuncs, &pMergeWindow->pFuncs); + int32_t code = stbSplRewriteFuns(pFunc, &pPartWin->pFuncs, NULL, &pMergeWindow->pFuncs); if (TSDB_CODE_SUCCESS == code) { code = stbSplAppendWStart(pPartWin->pFuncs, &index, ((SColumnNode*)pMergeWindow->pTspk)->node.resType.precision); } @@ -488,6 +504,85 @@ static int32_t stbSplCreatePartWindowNode(SWindowLogicNode* pMergeWindow, SLogic return code; } +static int32_t stbSplCreatePartMidWindowNode(SWindowLogicNode* pMergeWindow, SLogicNode** pPartWindow, SLogicNode** pMidWindow) { + SNodeList* pFunc = pMergeWindow->pFuncs; + pMergeWindow->pFuncs = NULL; + SNodeList* pTargets = pMergeWindow->node.pTargets; + pMergeWindow->node.pTargets = NULL; + SNodeList* pChildren = pMergeWindow->node.pChildren; + pMergeWindow->node.pChildren = NULL; + SNode* pConditions = pMergeWindow->node.pConditions; + pMergeWindow->node.pConditions = NULL; + + SWindowLogicNode* pPartWin = (SWindowLogicNode*)nodesCloneNode((SNode*)pMergeWindow); + if (NULL == pPartWin) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + SWindowLogicNode* pMidWin = (SWindowLogicNode*)nodesCloneNode((SNode*)pMergeWindow); + if (NULL == pMidWin) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + pPartWin->node.groupAction = GROUP_ACTION_KEEP; + pMidWin->node.groupAction = GROUP_ACTION_KEEP; + pMergeWindow->node.pTargets = pTargets; + pMergeWindow->node.pConditions = pConditions; + + pPartWin->node.pChildren = pChildren; + splSetParent((SLogicNode*)pPartWin); + + SNodeList* pFuncPart = NULL; + SNodeList* pFuncMid = NULL; + SNodeList* pFuncMerge = NULL; + int32_t code = stbSplRewriteFuns(pFunc, &pFuncPart, &pFuncMid, &pFuncMerge); + pPartWin->pFuncs = pFuncPart; + pMidWin->pFuncs = pFuncMid; + pMergeWindow->pFuncs = pFuncMerge; + + int32_t index = 0; + if (TSDB_CODE_SUCCESS == code) { + code = stbSplAppendWStart(pPartWin->pFuncs, &index, ((SColumnNode*)pMergeWindow->pTspk)->node.resType.precision); + } + if (TSDB_CODE_SUCCESS == code) { + code = createColumnByRewriteExprs(pPartWin->pFuncs, &pPartWin->node.pTargets); + } + + if (TSDB_CODE_SUCCESS == code) { + nodesDestroyNode(pMidWin->pTspk); + pMidWin->pTspk = nodesCloneNode(nodesListGetNode(pPartWin->node.pTargets, index)); + if (NULL == pMidWin->pTspk) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + + if (TSDB_CODE_SUCCESS == code) { + code = stbSplAppendWStart(pMidWin->pFuncs, &index, ((SColumnNode*)pMergeWindow->pTspk)->node.resType.precision); + } + if (TSDB_CODE_SUCCESS == code) { + code = createColumnByRewriteExprs(pMidWin->pFuncs, &pMidWin->node.pTargets); + } + + if (TSDB_CODE_SUCCESS == code) { + nodesDestroyNode(pMergeWindow->pTspk); + pMergeWindow->pTspk = nodesCloneNode(nodesListGetNode(pMidWin->node.pTargets, index)); + if (NULL == pMergeWindow->pTspk) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + + nodesDestroyList(pFunc); + if (TSDB_CODE_SUCCESS == code) { + *pPartWindow = (SLogicNode*)pPartWin; + *pMidWindow = (SLogicNode*)pMidWin; + } else { + nodesDestroyNode((SNode*)pPartWin); + nodesDestroyNode((SNode*)pMidWin); + } + + return code; +} + static int32_t stbSplGetNumOfVgroups(SLogicNode* pNode) { if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) { return ((SScanLogicNode*)pNode)->pVgroupList->numOfVgroups; @@ -635,18 +730,31 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo return code; } -static int32_t stbSplSplitIntervalForStream(SSplitContext* pCxt, SStableSplitInfo* pInfo) { +static int32_t stbSplSplitIntervalForStreamMultiAgg(SSplitContext* pCxt, SStableSplitInfo* pInfo) { SLogicNode* pPartWindow = NULL; - int32_t code = stbSplCreatePartWindowNode((SWindowLogicNode*)pInfo->pSplitNode, &pPartWindow); + SLogicNode* pMidWindow = NULL; + int32_t code = stbSplCreatePartMidWindowNode((SWindowLogicNode*)pInfo->pSplitNode, &pPartWindow, &pMidWindow); if (TSDB_CODE_SUCCESS == code) { - ((SWindowLogicNode*)pPartWindow)->windowAlgo = INTERVAL_ALGO_STREAM_SEMI; + ((SWindowLogicNode*)pMidWindow)->windowAlgo = INTERVAL_ALGO_STREAM_MID; ((SWindowLogicNode*)pInfo->pSplitNode)->windowAlgo = INTERVAL_ALGO_STREAM_FINAL; - code = stbSplCreateExchangeNode(pCxt, pInfo->pSplitNode, pPartWindow); + ((SWindowLogicNode*)pPartWindow)->windowAlgo = INTERVAL_ALGO_STREAM_SEMI; + code = stbSplCreateExchangeNode(pCxt, pInfo->pSplitNode, pMidWindow); + if (TSDB_CODE_SUCCESS == code) { + code = stbSplCreateExchangeNode(pCxt, pMidWindow, pPartWindow); + } } + if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, + SNode* subPlan = (SNode*)splCreateSubplan(pCxt, pMidWindow); + ((SLogicSubplan*)subPlan)->subplanType = SUBPLAN_TYPE_MERGE; + + code = nodesListMakeStrictAppend(&((SLogicSubplan*)subPlan)->pChildren, (SNode*)splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT)); + if (TSDB_CODE_SUCCESS == code) { + code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, subPlan); + } } + pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; ++(pCxt->groupId); return code; @@ -654,7 +762,7 @@ static int32_t stbSplSplitIntervalForStream(SSplitContext* pCxt, SStableSplitInf static int32_t stbSplSplitInterval(SSplitContext* pCxt, SStableSplitInfo* pInfo) { if (pCxt->pPlanCxt->streamQuery) { - return stbSplSplitIntervalForStream(pCxt, pInfo); + return stbSplSplitIntervalForStreamMultiAgg(pCxt, pInfo); } else { return stbSplSplitIntervalForBatch(pCxt, pInfo); } @@ -860,7 +968,7 @@ static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pO pPartAgg->node.pChildren = pChildren; splSetParent((SLogicNode*)pPartAgg); - code = stbSplRewriteFuns(pFunc, &pPartAgg->pAggFuncs, &pMergeAgg->pAggFuncs); + code = stbSplRewriteFuns(pFunc, &pPartAgg->pAggFuncs, NULL, &pMergeAgg->pAggFuncs); } if (TSDB_CODE_SUCCESS == code) { code = createColumnByRewriteExprs(pPartAgg->pAggFuncs, &pPartAgg->node.pTargets); diff --git a/source/libs/planner/src/planValidator.c b/source/libs/planner/src/planValidator.c index a5d729ab84..4fcd064e56 100755 --- a/source/libs/planner/src/planValidator.c +++ b/source/libs/planner/src/planValidator.c @@ -95,6 +95,7 @@ int32_t doValidatePhysiNode(SValidatePlanContext* pCxt, SNode* pNode) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_FILL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL: case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION: diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index 6e312f0e6f..e50ec64d54 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -66,7 +66,7 @@ FORCE_INLINE bool schJobNeedToStop(SSchJob *pJob, int8_t *pStatus) { return true; } - if ((*pJob->chkKillFp)(pJob->chkKillParam)) { + if (pJob->chkKillFp && (*pJob->chkKillFp)(pJob->chkKillParam)) { schUpdateJobErrCode(pJob, TSDB_CODE_TSC_QUERY_KILLED); return true; } diff --git a/source/libs/scheduler/test/schedulerTests.cpp b/source/libs/scheduler/test/schedulerTests.cpp index 793bc20024..b73de83a82 100644 --- a/source/libs/scheduler/test/schedulerTests.cpp +++ b/source/libs/scheduler/test/schedulerTests.cpp @@ -54,9 +54,8 @@ namespace { -extern "C" int32_t schHandleResponseMsg(SSchJob *job, SSchTask *task, int32_t msgType, char *msg, int32_t msgSize, - int32_t rspCode); -extern "C" int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, int32_t rspCode); +extern "C" int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDataBuf *pMsg, int32_t rspCode); +extern "C" int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t rspCode); int64_t insertJobRefId = 0; int64_t queryJobRefId = 0; @@ -67,7 +66,7 @@ uint64_t schtQueryId = 1; bool schtTestStop = false; bool schtTestDeadLoop = false; -int32_t schtTestMTRunSec = 10; +int32_t schtTestMTRunSec = 1; int32_t schtTestPrintNum = 1000; int32_t schtStartFetch = 0; @@ -85,10 +84,69 @@ void schtInitLogFile() { } void schtQueryCb(SExecResult *pResult, void *param, int32_t code) { - assert(TSDB_CODE_SUCCESS == code); *(int32_t *)param = 1; } +int32_t schtBuildQueryRspMsg(uint32_t *msize, void** rspMsg) { + SQueryTableRsp rsp = {0}; + rsp.code = 0; + rsp.affectedRows = 0; + rsp.tbVerInfo = NULL; + + int32_t msgSize = tSerializeSQueryTableRsp(NULL, 0, &rsp); + if (msgSize < 0) { + qError("tSerializeSQueryTableRsp failed"); + return TSDB_CODE_OUT_OF_MEMORY; + } + + void *pRsp = taosMemoryCalloc(msgSize, 1); + if (NULL == pRsp) { + qError("rpcMallocCont %d failed", msgSize); + return TSDB_CODE_OUT_OF_MEMORY; + } + + if (tSerializeSQueryTableRsp(pRsp, msgSize, &rsp) < 0) { + qError("tSerializeSQueryTableRsp %d failed", msgSize); + return TSDB_CODE_OUT_OF_MEMORY; + } + + *rspMsg = pRsp; + *msize = msgSize; + + return TSDB_CODE_SUCCESS; +} + + +int32_t schtBuildFetchRspMsg(uint32_t *msize, void** rspMsg) { + SRetrieveTableRsp* rsp = (SRetrieveTableRsp*)taosMemoryCalloc(sizeof(SRetrieveTableRsp), 1); + rsp->completed = 1; + rsp->numOfRows = 10; + rsp->compLen = 0; + + *rspMsg = rsp; + *msize = sizeof(SRetrieveTableRsp); + + return TSDB_CODE_SUCCESS; +} + +int32_t schtBuildSubmitRspMsg(uint32_t *msize, void** rspMsg) { + SSubmitRsp2 submitRsp = {0}; + int32_t msgSize = 0, ret = 0; + SEncoder ec = {0}; + + tEncodeSize(tEncodeSSubmitRsp2, &submitRsp, msgSize, ret); + void* msg = taosMemoryCalloc(1, msgSize); + tEncoderInit(&ec, (uint8_t*)msg, msgSize); + tEncodeSSubmitRsp2(&ec, &submitRsp); + tEncoderClear(&ec); + + *rspMsg = msg; + *msize = msgSize; + + return TSDB_CODE_SUCCESS; +} + + void schtBuildQueryDag(SQueryPlan *dag) { uint64_t qId = schtQueryId; @@ -98,8 +156,8 @@ void schtBuildQueryDag(SQueryPlan *dag) { SNodeListNode *scan = (SNodeListNode *)nodesMakeNode(QUERY_NODE_NODE_LIST); SNodeListNode *merge = (SNodeListNode *)nodesMakeNode(QUERY_NODE_NODE_LIST); - SSubplan *scanPlan = (SSubplan *)taosMemoryCalloc(1, sizeof(SSubplan)); - SSubplan *mergePlan = (SSubplan *)taosMemoryCalloc(1, sizeof(SSubplan)); + SSubplan *scanPlan = (SSubplan*)nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN); + SSubplan *mergePlan = (SSubplan*)nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN); scanPlan->id.queryId = qId; scanPlan->id.groupId = 0x0000000000000002; @@ -113,7 +171,7 @@ void schtBuildQueryDag(SQueryPlan *dag) { scanPlan->pChildren = NULL; scanPlan->level = 1; scanPlan->pParents = nodesMakeList(); - scanPlan->pNode = (SPhysiNode *)taosMemoryCalloc(1, sizeof(SPhysiNode)); + scanPlan->pNode = (SPhysiNode *)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN); scanPlan->msgType = TDMT_SCH_QUERY; mergePlan->id.queryId = qId; @@ -125,7 +183,7 @@ void schtBuildQueryDag(SQueryPlan *dag) { mergePlan->pChildren = nodesMakeList(); mergePlan->pParents = NULL; - mergePlan->pNode = (SPhysiNode *)taosMemoryCalloc(1, sizeof(SPhysiNode)); + mergePlan->pNode = (SPhysiNode *)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_MERGE); mergePlan->msgType = TDMT_SCH_QUERY; merge->pNodeList = nodesMakeList(); @@ -151,8 +209,7 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) { SNodeListNode *scan = (SNodeListNode *)nodesMakeNode(QUERY_NODE_NODE_LIST); SNodeListNode *merge = (SNodeListNode *)nodesMakeNode(QUERY_NODE_NODE_LIST); - SSubplan *scanPlan = (SSubplan *)taosMemoryCalloc(scanPlanNum, sizeof(SSubplan)); - SSubplan *mergePlan = (SSubplan *)taosMemoryCalloc(1, sizeof(SSubplan)); + SSubplan *mergePlan = (SSubplan*)nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN); merge->pNodeList = nodesMakeList(); scan->pNodeList = nodesMakeList(); @@ -160,29 +217,30 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) { mergePlan->pChildren = nodesMakeList(); for (int32_t i = 0; i < scanPlanNum; ++i) { - scanPlan[i].id.queryId = qId; - scanPlan[i].id.groupId = 0x0000000000000002; - scanPlan[i].id.subplanId = 0x0000000000000003 + i; - scanPlan[i].subplanType = SUBPLAN_TYPE_SCAN; + SSubplan *scanPlan = (SSubplan*)nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN); + scanPlan->id.queryId = qId; + scanPlan->id.groupId = 0x0000000000000002; + scanPlan->id.subplanId = 0x0000000000000003 + i; + scanPlan->subplanType = SUBPLAN_TYPE_SCAN; - scanPlan[i].execNode.nodeId = 1 + i; - scanPlan[i].execNode.epSet.inUse = 0; - scanPlan[i].execNodeStat.tableNum = taosRand() % 30; - addEpIntoEpSet(&scanPlan[i].execNode.epSet, "ep0", 6030); - addEpIntoEpSet(&scanPlan[i].execNode.epSet, "ep1", 6030); - addEpIntoEpSet(&scanPlan[i].execNode.epSet, "ep2", 6030); - scanPlan[i].execNode.epSet.inUse = taosRand() % 3; + scanPlan->execNode.nodeId = 1 + i; + scanPlan->execNode.epSet.inUse = 0; + scanPlan->execNodeStat.tableNum = taosRand() % 30; + addEpIntoEpSet(&scanPlan->execNode.epSet, "ep0", 6030); + addEpIntoEpSet(&scanPlan->execNode.epSet, "ep1", 6030); + addEpIntoEpSet(&scanPlan->execNode.epSet, "ep2", 6030); + scanPlan->execNode.epSet.inUse = taosRand() % 3; - scanPlan[i].pChildren = NULL; - scanPlan[i].level = 1; - scanPlan[i].pParents = nodesMakeList(); - scanPlan[i].pNode = (SPhysiNode *)taosMemoryCalloc(1, sizeof(SPhysiNode)); - scanPlan[i].msgType = TDMT_SCH_QUERY; + scanPlan->pChildren = NULL; + scanPlan->level = 1; + scanPlan->pParents = nodesMakeList(); + scanPlan->pNode = (SPhysiNode *)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN); + scanPlan->msgType = TDMT_SCH_QUERY; - nodesListAppend(scanPlan[i].pParents, (SNode *)mergePlan); - nodesListAppend(mergePlan->pChildren, (SNode *)(scanPlan + i)); + nodesListAppend(scanPlan->pParents, (SNode *)mergePlan); + nodesListAppend(mergePlan->pChildren, (SNode *)scanPlan); - nodesListAppend(scan->pNodeList, (SNode *)(scanPlan + i)); + nodesListAppend(scan->pNodeList, (SNode *)scanPlan); } mergePlan->id.queryId = qId; @@ -193,7 +251,7 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) { mergePlan->execNode.epSet.numOfEps = 0; mergePlan->pParents = NULL; - mergePlan->pNode = (SPhysiNode *)taosMemoryCalloc(1, sizeof(SPhysiNode)); + mergePlan->pNode = (SPhysiNode *)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_MERGE); mergePlan->msgType = TDMT_SCH_QUERY; nodesListAppend(merge->pNodeList, (SNode *)mergePlan); @@ -211,45 +269,50 @@ void schtBuildInsertDag(SQueryPlan *dag) { dag->numOfSubplans = 2; dag->pSubplans = nodesMakeList(); SNodeListNode *inserta = (SNodeListNode *)nodesMakeNode(QUERY_NODE_NODE_LIST); - - SSubplan *insertPlan = (SSubplan *)taosMemoryCalloc(2, sizeof(SSubplan)); - - insertPlan[0].id.queryId = qId; - insertPlan[0].id.groupId = 0x0000000000000003; - insertPlan[0].id.subplanId = 0x0000000000000004; - insertPlan[0].subplanType = SUBPLAN_TYPE_MODIFY; - insertPlan[0].level = 0; - - insertPlan[0].execNode.nodeId = 1; - insertPlan[0].execNode.epSet.inUse = 0; - addEpIntoEpSet(&insertPlan[0].execNode.epSet, "ep0", 6030); - - insertPlan[0].pChildren = NULL; - insertPlan[0].pParents = NULL; - insertPlan[0].pNode = NULL; - insertPlan[0].pDataSink = (SDataSinkNode *)taosMemoryCalloc(1, sizeof(SDataSinkNode)); - insertPlan[0].msgType = TDMT_VND_SUBMIT; - - insertPlan[1].id.queryId = qId; - insertPlan[1].id.groupId = 0x0000000000000003; - insertPlan[1].id.subplanId = 0x0000000000000005; - insertPlan[1].subplanType = SUBPLAN_TYPE_MODIFY; - insertPlan[1].level = 0; - - insertPlan[1].execNode.nodeId = 1; - insertPlan[1].execNode.epSet.inUse = 0; - addEpIntoEpSet(&insertPlan[1].execNode.epSet, "ep0", 6030); - - insertPlan[1].pChildren = NULL; - insertPlan[1].pParents = NULL; - insertPlan[1].pNode = NULL; - insertPlan[1].pDataSink = (SDataSinkNode *)taosMemoryCalloc(1, sizeof(SDataSinkNode)); - insertPlan[1].msgType = TDMT_VND_SUBMIT; - inserta->pNodeList = nodesMakeList(); + SSubplan *insertPlan = (SSubplan*)nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN); + + insertPlan->id.queryId = qId; + insertPlan->id.groupId = 0x0000000000000003; + insertPlan->id.subplanId = 0x0000000000000004; + insertPlan->subplanType = SUBPLAN_TYPE_MODIFY; + insertPlan->level = 0; + + insertPlan->execNode.nodeId = 1; + insertPlan->execNode.epSet.inUse = 0; + addEpIntoEpSet(&insertPlan->execNode.epSet, "ep0", 6030); + + insertPlan->pChildren = NULL; + insertPlan->pParents = NULL; + insertPlan->pNode = NULL; + insertPlan->pDataSink = (SDataSinkNode*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_INSERT); + ((SDataInserterNode*)insertPlan->pDataSink)->size = 1; + ((SDataInserterNode*)insertPlan->pDataSink)->pData = taosMemoryCalloc(1, 1); + insertPlan->msgType = TDMT_VND_SUBMIT; + nodesListAppend(inserta->pNodeList, (SNode *)insertPlan); - insertPlan += 1; + + insertPlan = (SSubplan*)nodesMakeNode(QUERY_NODE_PHYSICAL_SUBPLAN); + + insertPlan->id.queryId = qId; + insertPlan->id.groupId = 0x0000000000000003; + insertPlan->id.subplanId = 0x0000000000000005; + insertPlan->subplanType = SUBPLAN_TYPE_MODIFY; + insertPlan->level = 0; + + insertPlan->execNode.nodeId = 1; + insertPlan->execNode.epSet.inUse = 0; + addEpIntoEpSet(&insertPlan->execNode.epSet, "ep0", 6030); + + insertPlan->pChildren = NULL; + insertPlan->pParents = NULL; + insertPlan->pNode = NULL; + insertPlan->pDataSink = (SDataSinkNode*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_INSERT); + ((SDataInserterNode*)insertPlan->pDataSink)->size = 1; + ((SDataInserterNode*)insertPlan->pDataSink)->pData = taosMemoryCalloc(1, 1); + insertPlan->msgType = TDMT_VND_SUBMIT; + nodesListAppend(inserta->pNodeList, (SNode *)insertPlan); nodesListAppend(dag->pSubplans, (SNode *)inserta); @@ -325,7 +388,7 @@ void schtSetRpcSendRequest() { } } -int32_t schtAsyncSendMsgToServer(void *pTransporter, SEpSet *epSet, int64_t *pTransporterId, SMsgSendInfo *pInfo) { +int32_t schtAsyncSendMsgToServer(void *pTransporter, SEpSet *epSet, int64_t *pTransporterId, SMsgSendInfo *pInfo, bool persistHandle, void* rpcCtx) { if (pInfo) { taosMemoryFreeClear(pInfo->param); taosMemoryFreeClear(pInfo->msgInfo.pData); @@ -336,17 +399,17 @@ int32_t schtAsyncSendMsgToServer(void *pTransporter, SEpSet *epSet, int64_t *pTr void schtSetAsyncSendMsgToServer() { static Stub stub; - stub.set(asyncSendMsgToServer, schtAsyncSendMsgToServer); + stub.set(asyncSendMsgToServerExt, schtAsyncSendMsgToServer); { #ifdef WINDOWS AddrAny any; std::map result; - any.get_func_addr("asyncSendMsgToServer", result); + any.get_func_addr("asyncSendMsgToServerExt", result); #endif #ifdef LINUX AddrAny any("libtransport.so"); std::map result; - any.get_global_func_addr_dynsym("^asyncSendMsgToServer$", result); + any.get_global_func_addr_dynsym("^asyncSendMsgToServerExt$", result); #endif for (const auto &f : result) { stub.set(f.second, schtAsyncSendMsgToServer); @@ -374,9 +437,13 @@ void *schtSendRsp(void *param) { while (pIter) { SSchTask *task = *(SSchTask **)pIter; - SSubmitRsp rsp = {0}; - rsp.affectedRows = 10; - schHandleResponseMsg(pJob, task, TDMT_VND_SUBMIT_RSP, (char *)&rsp, sizeof(rsp), 0); + SDataBuf msg = {0}; + void* rmsg = NULL; + schtBuildSubmitRspMsg(&msg.len, &rmsg); + msg.msgType = TDMT_VND_SUBMIT_RSP; + msg.pData = rmsg; + + schHandleResponseMsg(pJob, task, task->execId, &msg, 0); pIter = taosHashIterate(pJob->execTasks, pIter); } @@ -393,11 +460,13 @@ void *schtCreateFetchRspThread(void *param) { taosSsleep(1); int32_t code = 0; - SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)taosMemoryCalloc(1, sizeof(SRetrieveTableRsp)); - rsp->completed = 1; - rsp->numOfRows = 10; - - code = schHandleResponseMsg(pJob, pJob->fetchTask, TDMT_SCH_FETCH_RSP, (char *)rsp, sizeof(*rsp), 0); + SDataBuf msg = {0}; + void* rmsg = NULL; + schtBuildFetchRspMsg(&msg.len, &rmsg); + msg.msgType = TDMT_SCH_MERGE_FETCH_RSP; + msg.pData = rmsg; + + code = schHandleResponseMsg(pJob, pJob->fetchTask, pJob->fetchTask->execId, &msg, 0); schReleaseJob(job); @@ -414,7 +483,7 @@ void *schtFetchRspThread(void *aa) { continue; } - taosUsleep(1); + taosUsleep(100); param = (SSchTaskCallbackParam *)taosMemoryCalloc(1, sizeof(*param)); @@ -426,10 +495,11 @@ void *schtFetchRspThread(void *aa) { rsp->completed = 1; rsp->numOfRows = 10; + dataBuf.msgType = TDMT_SCH_FETCH_RSP; dataBuf.pData = rsp; dataBuf.len = sizeof(*rsp); - code = schHandleCallback(param, &dataBuf, TDMT_SCH_FETCH_RSP, 0); + code = schHandleCallback(param, &dataBuf, 0); assert(code == 0 || code); } @@ -456,7 +526,7 @@ void *schtRunJobThread(void *aa) { char *dbname = "1.db1"; char *tablename = "table1"; SVgroupInfo vgInfo = {0}; - SQueryPlan dag; + SQueryPlan* dag = (SQueryPlan*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN); schtInitLogFile(); @@ -470,19 +540,19 @@ void *schtRunJobThread(void *aa) { SSchJob *pJob = NULL; SSchTaskCallbackParam *param = NULL; SHashObj *execTasks = NULL; - SDataBuf dataBuf = {0}; uint32_t jobFinished = 0; int32_t queryDone = 0; while (!schtTestStop) { - schtBuildQueryDag(&dag); + schtBuildQueryDag(dag); - SArray *qnodeList = taosArrayInit(1, sizeof(SEp)); + SArray *qnodeList = taosArrayInit(1, sizeof(SQueryNodeLoad)); - SEp qnodeAddr = {0}; - strcpy(qnodeAddr.fqdn, "qnode0.ep"); - qnodeAddr.port = 6031; - taosArrayPush(qnodeList, &qnodeAddr); + SQueryNodeLoad load = {0}; + load.addr.epSet.numOfEps = 1; + strcpy(load.addr.epSet.eps[0].fqdn, "qnode0.ep"); + load.addr.epSet.eps[0].port = 6031; + taosArrayPush(qnodeList, &load); queryDone = 0; @@ -492,7 +562,7 @@ void *schtRunJobThread(void *aa) { req.syncReq = false; req.pConn = &conn; req.pNodeList = qnodeList; - req.pDag = &dag; + req.pDag = dag; req.sql = "select * from tb"; req.execFp = schtQueryCb; req.cbParam = &queryDone; @@ -503,7 +573,7 @@ void *schtRunJobThread(void *aa) { pJob = schAcquireJob(queryJobRefId); if (NULL == pJob) { taosArrayDestroy(qnodeList); - schtFreeQueryDag(&dag); + schtFreeQueryDag(dag); continue; } @@ -526,11 +596,14 @@ void *schtRunJobThread(void *aa) { SSchTask *task = (SSchTask *)pIter; param->taskId = task->taskId; - SQueryTableRsp rsp = {0}; - dataBuf.pData = &rsp; - dataBuf.len = sizeof(rsp); - code = schHandleCallback(param, &dataBuf, TDMT_SCH_QUERY_RSP, 0); + SDataBuf msg = {0}; + void* rmsg = NULL; + schtBuildQueryRspMsg(&msg.len, &rmsg); + msg.msgType = TDMT_SCH_QUERY_RSP; + msg.pData = rmsg; + + code = schHandleCallback(param, &msg, 0); assert(code == 0 || code); pIter = taosHashIterate(execTasks, pIter); @@ -545,11 +618,13 @@ void *schtRunJobThread(void *aa) { SSchTask *task = (SSchTask *)pIter; param->taskId = task->taskId - 1; - SQueryTableRsp rsp = {0}; - dataBuf.pData = &rsp; - dataBuf.len = sizeof(rsp); + SDataBuf msg = {0}; + void* rmsg = NULL; + schtBuildQueryRspMsg(&msg.len, &rmsg); + msg.msgType = TDMT_SCH_QUERY_RSP; + msg.pData = rmsg; - code = schHandleCallback(param, &dataBuf, TDMT_SCH_QUERY_RSP, 0); + code = schHandleCallback(param, &msg, 0); assert(code == 0 || code); pIter = taosHashIterate(execTasks, pIter); @@ -575,7 +650,6 @@ void *schtRunJobThread(void *aa) { if (0 == code) { SRetrieveTableRsp *pRsp = (SRetrieveTableRsp *)data; assert(pRsp->completed == 1); - assert(pRsp->numOfRows == 10); } data = NULL; @@ -587,7 +661,7 @@ void *schtRunJobThread(void *aa) { taosHashCleanup(execTasks); taosArrayDestroy(qnodeList); - schtFreeQueryDag(&dag); + schtFreeQueryDag(dag); if (++jobFinished % schtTestPrintNum == 0) { printf("jobFinished:%d\n", jobFinished); @@ -609,6 +683,7 @@ void *schtFreeJobThread(void *aa) { return NULL; } + } // namespace TEST(queryTest, normalCase) { @@ -618,21 +693,20 @@ TEST(queryTest, normalCase) { char *tablename = "table1"; SVgroupInfo vgInfo = {0}; int64_t job = 0; - SQueryPlan dag; + SQueryPlan* dag = (SQueryPlan*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN); - memset(&dag, 0, sizeof(dag)); + SArray *qnodeList = taosArrayInit(1, sizeof(SQueryNodeLoad)); - SArray *qnodeList = taosArrayInit(1, sizeof(SEp)); - - SEp qnodeAddr = {0}; - strcpy(qnodeAddr.fqdn, "qnode0.ep"); - qnodeAddr.port = 6031; - taosArrayPush(qnodeList, &qnodeAddr); + SQueryNodeLoad load = {0}; + load.addr.epSet.numOfEps = 1; + strcpy(load.addr.epSet.eps[0].fqdn, "qnode0.ep"); + load.addr.epSet.eps[0].port = 6031; + taosArrayPush(qnodeList, &load); int32_t code = schedulerInit(); ASSERT_EQ(code, 0); - schtBuildQueryDag(&dag); + schtBuildQueryDag(dag); schtSetPlanToString(); schtSetExecNode(); @@ -645,7 +719,7 @@ TEST(queryTest, normalCase) { SSchedulerReq req = {0}; req.pConn = &conn; req.pNodeList = qnodeList; - req.pDag = &dag; + req.pDag = dag; req.sql = "select * from tb"; req.execFp = schtQueryCb; req.cbParam = &queryDone; @@ -659,9 +733,14 @@ TEST(queryTest, normalCase) { while (pIter) { SSchTask *task = *(SSchTask **)pIter; - SQueryTableRsp rsp = {0}; - code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); - + SDataBuf msg = {0}; + void* rmsg = NULL; + schtBuildQueryRspMsg(&msg.len, &rmsg); + msg.msgType = TDMT_SCH_QUERY_RSP; + msg.pData = rmsg; + + code = schHandleResponseMsg(pJob, task, task->execId, &msg, 0); + ASSERT_EQ(code, 0); pIter = taosHashIterate(pJob->execTasks, pIter); } @@ -669,11 +748,18 @@ TEST(queryTest, normalCase) { pIter = taosHashIterate(pJob->execTasks, NULL); while (pIter) { SSchTask *task = *(SSchTask **)pIter; + if (JOB_TASK_STATUS_EXEC == task->status) { + SDataBuf msg = {0}; + void* rmsg = NULL; + schtBuildQueryRspMsg(&msg.len, &rmsg); + msg.msgType = TDMT_SCH_QUERY_RSP; + msg.pData = rmsg; + + code = schHandleResponseMsg(pJob, task, task->execId, &msg, 0); + + ASSERT_EQ(code, 0); + } - SQueryTableRsp rsp = {0}; - code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); - - ASSERT_EQ(code, 0); pIter = taosHashIterate(pJob->execTasks, pIter); } @@ -703,18 +789,12 @@ TEST(queryTest, normalCase) { ASSERT_EQ(pRsp->numOfRows, 10); taosMemoryFreeClear(data); - data = NULL; - code = schedulerFetchRows(job, &req); - ASSERT_EQ(code, 0); - ASSERT_TRUE(data == NULL); - schReleaseJob(job); + + schedulerDestroy(); schedulerFreeJob(&job, 0); - schtFreeQueryDag(&dag); - - schedulerDestroy(); } TEST(queryTest, readyFirstCase) { @@ -724,21 +804,20 @@ TEST(queryTest, readyFirstCase) { char *tablename = "table1"; SVgroupInfo vgInfo = {0}; int64_t job = 0; - SQueryPlan dag; + SQueryPlan* dag = (SQueryPlan*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN); - memset(&dag, 0, sizeof(dag)); + SArray *qnodeList = taosArrayInit(1, sizeof(SQueryNodeLoad)); - SArray *qnodeList = taosArrayInit(1, sizeof(SEp)); - - SEp qnodeAddr = {0}; - strcpy(qnodeAddr.fqdn, "qnode0.ep"); - qnodeAddr.port = 6031; - taosArrayPush(qnodeList, &qnodeAddr); + SQueryNodeLoad load = {0}; + load.addr.epSet.numOfEps = 1; + strcpy(load.addr.epSet.eps[0].fqdn, "qnode0.ep"); + load.addr.epSet.eps[0].port = 6031; + taosArrayPush(qnodeList, &load); int32_t code = schedulerInit(); ASSERT_EQ(code, 0); - schtBuildQueryDag(&dag); + schtBuildQueryDag(dag); schtSetPlanToString(); schtSetExecNode(); @@ -751,7 +830,7 @@ TEST(queryTest, readyFirstCase) { SSchedulerReq req = {0}; req.pConn = &conn; req.pNodeList = qnodeList; - req.pDag = &dag; + req.pDag = dag; req.sql = "select * from tb"; req.execFp = schtQueryCb; req.cbParam = &queryDone; @@ -764,8 +843,13 @@ TEST(queryTest, readyFirstCase) { while (pIter) { SSchTask *task = *(SSchTask **)pIter; - SQueryTableRsp rsp = {0}; - code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); + SDataBuf msg = {0}; + void* rmsg = NULL; + schtBuildQueryRspMsg(&msg.len, &rmsg); + msg.msgType = TDMT_SCH_QUERY_RSP; + msg.pData = rmsg; + + code = schHandleResponseMsg(pJob, task, task->execId, &msg, 0); ASSERT_EQ(code, 0); pIter = taosHashIterate(pJob->execTasks, pIter); @@ -775,10 +859,18 @@ TEST(queryTest, readyFirstCase) { while (pIter) { SSchTask *task = *(SSchTask **)pIter; - SQueryTableRsp rsp = {0}; - code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); + if (JOB_TASK_STATUS_EXEC == task->status) { + SDataBuf msg = {0}; + void* rmsg = NULL; + schtBuildQueryRspMsg(&msg.len, &rmsg); + msg.msgType = TDMT_SCH_QUERY_RSP; + msg.pData = rmsg; + + code = schHandleResponseMsg(pJob, task, task->execId, &msg, 0); + + ASSERT_EQ(code, 0); + } - ASSERT_EQ(code, 0); pIter = taosHashIterate(pJob->execTasks, pIter); } @@ -807,18 +899,11 @@ TEST(queryTest, readyFirstCase) { ASSERT_EQ(pRsp->numOfRows, 10); taosMemoryFreeClear(data); - data = NULL; - code = schedulerFetchRows(job, &req); - ASSERT_EQ(code, 0); - ASSERT_TRUE(data == NULL); - schReleaseJob(job); - schedulerFreeJob(&job, 0); - - schtFreeQueryDag(&dag); - schedulerDestroy(); + + schedulerFreeJob(&job, 0); } TEST(queryTest, flowCtrlCase) { @@ -828,35 +913,39 @@ TEST(queryTest, flowCtrlCase) { char *tablename = "table1"; SVgroupInfo vgInfo = {0}; int64_t job = 0; - SQueryPlan dag; + SQueryPlan* dag = (SQueryPlan*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN); schtInitLogFile(); taosSeedRand(taosGetTimestampSec()); - SArray *qnodeList = taosArrayInit(1, sizeof(SEp)); + SArray *qnodeList = taosArrayInit(1, sizeof(SQueryNodeLoad)); + + SQueryNodeLoad load = {0}; + load.addr.epSet.numOfEps = 1; + strcpy(load.addr.epSet.eps[0].fqdn, "qnode0.ep"); + load.addr.epSet.eps[0].port = 6031; + taosArrayPush(qnodeList, &load); - SEp qnodeAddr = {0}; - strcpy(qnodeAddr.fqdn, "qnode0.ep"); - qnodeAddr.port = 6031; - taosArrayPush(qnodeList, &qnodeAddr); int32_t code = schedulerInit(); ASSERT_EQ(code, 0); - schtBuildQueryFlowCtrlDag(&dag); + schtBuildQueryFlowCtrlDag(dag); schtSetPlanToString(); schtSetExecNode(); schtSetAsyncSendMsgToServer(); + initTaskQueue(); + int32_t queryDone = 0; SRequestConnInfo conn = {0}; conn.pTrans = mockPointer; SSchedulerReq req = {0}; req.pConn = &conn; req.pNodeList = qnodeList; - req.pDag = &dag; + req.pDag = dag; req.sql = "select * from tb"; req.execFp = schtQueryCb; req.cbParam = &queryDone; @@ -866,41 +955,27 @@ TEST(queryTest, flowCtrlCase) { SSchJob *pJob = schAcquireJob(job); - bool qDone = false; - - while (!qDone) { + while (!queryDone) { void *pIter = taosHashIterate(pJob->execTasks, NULL); - if (NULL == pIter) { - break; - } - while (pIter) { SSchTask *task = *(SSchTask **)pIter; - taosHashCancelIterate(pJob->execTasks, pIter); - - if (task->lastMsgType == TDMT_SCH_QUERY) { - SQueryTableRsp rsp = {0}; - code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); - + if (JOB_TASK_STATUS_EXEC == task->status && 0 != task->lastMsgType) { + SDataBuf msg = {0}; + void* rmsg = NULL; + schtBuildQueryRspMsg(&msg.len, &rmsg); + msg.msgType = TDMT_SCH_QUERY_RSP; + msg.pData = rmsg; + + code = schHandleResponseMsg(pJob, task, task->execId, &msg, 0); + ASSERT_EQ(code, 0); - } else { - qDone = true; - break; } - pIter = NULL; + pIter = taosHashIterate(pJob->execTasks, pIter); } } - while (true) { - if (queryDone) { - break; - } - - taosUsleep(10000); - } - TdThreadAttr thattr; taosThreadAttrInit(&thattr); @@ -918,18 +993,11 @@ TEST(queryTest, flowCtrlCase) { ASSERT_EQ(pRsp->numOfRows, 10); taosMemoryFreeClear(data); - data = NULL; - code = schedulerFetchRows(job, &req); - ASSERT_EQ(code, 0); - ASSERT_TRUE(data == NULL); - schReleaseJob(job); - schedulerFreeJob(&job, 0); - - schtFreeQueryDag(&dag); - schedulerDestroy(); + + schedulerFreeJob(&job, 0); } TEST(insertTest, normalCase) { @@ -938,20 +1006,21 @@ TEST(insertTest, normalCase) { char *dbname = "1.db1"; char *tablename = "table1"; SVgroupInfo vgInfo = {0}; - SQueryPlan dag; + SQueryPlan* dag = (SQueryPlan*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN); uint64_t numOfRows = 0; - SArray *qnodeList = taosArrayInit(1, sizeof(SEp)); + SArray *qnodeList = taosArrayInit(1, sizeof(SQueryNodeLoad)); - SEp qnodeAddr = {0}; - strcpy(qnodeAddr.fqdn, "qnode0.ep"); - qnodeAddr.port = 6031; - taosArrayPush(qnodeList, &qnodeAddr); + SQueryNodeLoad load = {0}; + load.addr.epSet.numOfEps = 1; + strcpy(load.addr.epSet.eps[0].fqdn, "qnode0.ep"); + load.addr.epSet.eps[0].port = 6031; + taosArrayPush(qnodeList, &load); int32_t code = schedulerInit(); ASSERT_EQ(code, 0); - schtBuildInsertDag(&dag); + schtBuildInsertDag(dag); schtSetPlanToString(); schtSetAsyncSendMsgToServer(); @@ -962,21 +1031,19 @@ TEST(insertTest, normalCase) { TdThread thread1; taosThreadCreate(&(thread1), &thattr, schtSendRsp, &insertJobRefId); - SExecResult res = {0}; - + int32_t queryDone = 0; SRequestConnInfo conn = {0}; conn.pTrans = mockPointer; SSchedulerReq req = {0}; req.pConn = &conn; req.pNodeList = qnodeList; - req.pDag = &dag; + req.pDag = dag; req.sql = "insert into tb values(now,1)"; req.execFp = schtQueryCb; - req.cbParam = NULL; + req.cbParam = &queryDone; code = schedulerExecJob(&req, &insertJobRefId); ASSERT_EQ(code, 0); - ASSERT_EQ(res.numOfRows, 20); schedulerFreeJob(&insertJobRefId, 0); @@ -989,7 +1056,7 @@ TEST(multiThread, forceFree) { TdThread thread1, thread2, thread3; taosThreadCreate(&(thread1), &thattr, schtRunJobThread, NULL); - taosThreadCreate(&(thread2), &thattr, schtFreeJobThread, NULL); +// taosThreadCreate(&(thread2), &thattr, schtFreeJobThread, NULL); taosThreadCreate(&(thread3), &thattr, schtFetchRspThread, NULL); while (true) { @@ -1002,7 +1069,7 @@ TEST(multiThread, forceFree) { } schtTestStop = true; - taosSsleep(3); + //taosSsleep(3); } TEST(otherTest, otherCase) { diff --git a/source/libs/stream/inc/streamInt.h b/source/libs/stream/inc/streamInt.h index fd9c8b61d1..300b0a7f24 100644 --- a/source/libs/stream/inc/streamInt.h +++ b/source/libs/stream/inc/streamInt.h @@ -107,7 +107,7 @@ SStreamDataBlock* createStreamBlockFromResults(SStreamQueueItem* pItem, SStreamT void destroyStreamDataBlock(SStreamDataBlock* pBlock); int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock* pData); -int32_t streamBroadcastToChildren(SStreamTask* pTask, const SSDataBlock* pBlock); +int32_t streamBroadcastToUpTasks(SStreamTask* pTask, const SSDataBlock* pBlock); int32_t tEncodeStreamRetrieveReq(SEncoder* pEncoder, const SStreamRetrieveReq* pReq); diff --git a/source/libs/stream/src/stream.c b/source/libs/stream/src/stream.c index c3373c1e7f..7830bbdd39 100644 --- a/source/libs/stream/src/stream.c +++ b/source/libs/stream/src/stream.c @@ -181,7 +181,7 @@ static int32_t streamTaskAppendInputBlocks(SStreamTask* pTask, const SStreamDisp return status; } -int32_t streamTaskEnqueueRetrieve(SStreamTask* pTask, SStreamRetrieveReq* pReq, SRpcMsg* pRsp) { +int32_t streamTaskEnqueueRetrieve(SStreamTask* pTask, SStreamRetrieveReq* pReq) { SStreamDataBlock* pData = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, sizeof(SStreamDataBlock)); int8_t status = TASK_INPUT_STATUS__NORMAL; @@ -203,17 +203,6 @@ int32_t streamTaskEnqueueRetrieve(SStreamTask* pTask, SStreamRetrieveReq* pReq, /*status = TASK_INPUT_STATUS__FAILED;*/ } - // rsp by input status - void* buf = rpcMallocCont(sizeof(SMsgHead) + sizeof(SStreamRetrieveRsp)); - ((SMsgHead*)buf)->vgId = htonl(pReq->srcNodeId); - SStreamRetrieveRsp* pCont = POINTER_SHIFT(buf, sizeof(SMsgHead)); - pCont->streamId = pReq->streamId; - pCont->rspToTaskId = pReq->srcTaskId; - pCont->rspFromTaskId = pReq->dstTaskId; - pRsp->pCont = buf; - pRsp->contLen = sizeof(SMsgHead) + sizeof(SStreamRetrieveRsp); - tmsgSendRsp(pRsp); - return status == TASK_INPUT_STATUS__NORMAL ? 0 : -1; } @@ -295,11 +284,12 @@ int32_t streamProcessDispatchMsg(SStreamTask* pTask, SStreamDispatchReq* pReq, S return 0; } -int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, SRpcMsg* pRsp) { - streamTaskEnqueueRetrieve(pTask, pReq, pRsp); - ASSERT(pTask->info.taskLevel != TASK_LEVEL__SINK); - streamSchedExec(pTask); - return 0; +int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq) { + int32_t code = streamTaskEnqueueRetrieve(pTask, pReq); + if(code != 0){ + return code; + } + return streamSchedExec(pTask); } void streamTaskInputFail(SStreamTask* pTask) { atomic_store_8(&pTask->inputq.status, TASK_INPUT_STATUS__FAILED); } diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 6b7c0fc69a..98d9a29c87 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -162,16 +162,71 @@ int32_t tDecodeStreamRetrieveReq(SDecoder* pDecoder, SStreamRetrieveReq* pReq) { return 0; } -void tDeleteStreamRetrieveReq(SStreamRetrieveReq* pReq) { taosMemoryFree(pReq->pRetrieve); } +void sendRetrieveRsp(SStreamRetrieveReq *pReq, SRpcMsg* pRsp){ + void* buf = rpcMallocCont(sizeof(SMsgHead) + sizeof(SStreamRetrieveRsp)); + ((SMsgHead*)buf)->vgId = htonl(pReq->srcNodeId); + SStreamRetrieveRsp* pCont = POINTER_SHIFT(buf, sizeof(SMsgHead)); + pCont->streamId = pReq->streamId; + pCont->rspToTaskId = pReq->srcTaskId; + pCont->rspFromTaskId = pReq->dstTaskId; + pRsp->pCont = buf; + pRsp->contLen = sizeof(SMsgHead) + sizeof(SStreamRetrieveRsp); + tmsgSendRsp(pRsp); +} -int32_t streamBroadcastToChildren(SStreamTask* pTask, const SSDataBlock* pBlock) { - int32_t code = -1; +int32_t broadcastRetrieveMsg(SStreamTask* pTask, SStreamRetrieveReq *req){ + int32_t code = 0; + void* buf = NULL; + int32_t sz = taosArrayGetSize(pTask->upstreamInfo.pList); + ASSERT(sz > 0); + for (int32_t i = 0; i < sz; i++) { + req->reqId = tGenIdPI64(); + SStreamChildEpInfo* pEpInfo = taosArrayGetP(pTask->upstreamInfo.pList, i); + req->dstNodeId = pEpInfo->nodeId; + req->dstTaskId = pEpInfo->taskId; + int32_t len; + tEncodeSize(tEncodeStreamRetrieveReq, req, len, code); + if (code != 0) { + ASSERT(0); + return code; + } + + buf = rpcMallocCont(sizeof(SMsgHead) + len); + if (buf == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + return code; + } + + ((SMsgHead*)buf)->vgId = htonl(pEpInfo->nodeId); + void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); + SEncoder encoder; + tEncoderInit(&encoder, abuf, len); + tEncodeStreamRetrieveReq(&encoder, req); + tEncoderClear(&encoder); + + SRpcMsg rpcMsg = {0}; + initRpcMsg(&rpcMsg, TDMT_STREAM_RETRIEVE, buf, len + sizeof(SMsgHead)); + + code = tmsgSendReq(&pEpInfo->epSet, &rpcMsg); + if (code != 0) { + ASSERT(0); + rpcFreeCont(buf); + return code; + } + + buf = NULL; + stDebug("s-task:%s (child %d) send retrieve req to task:0x%x (vgId:%d), reqId:0x%" PRIx64, pTask->id.idStr, + pTask->info.selfChildId, pEpInfo->taskId, pEpInfo->nodeId, req->reqId); + } + return code; +} + +static int32_t buildStreamRetrieveReq(SStreamTask* pTask, const SSDataBlock* pBlock, SStreamRetrieveReq* req){ SRetrieveTableRsp* pRetrieve = NULL; - void* buf = NULL; int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); pRetrieve = taosMemoryCalloc(1, dataStrLen); - if (pRetrieve == NULL) return -1; + if (pRetrieve == NULL) return TSDB_CODE_OUT_OF_MEMORY; int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); pRetrieve->useconds = 0; @@ -187,57 +242,24 @@ int32_t streamBroadcastToChildren(SStreamTask* pTask, const SSDataBlock* pBlock) int32_t actualLen = blockEncode(pBlock, pRetrieve->data, numOfCols); - SStreamRetrieveReq req = { - .streamId = pTask->id.streamId, - .srcNodeId = pTask->info.nodeId, - .srcTaskId = pTask->id.taskId, - .pRetrieve = pRetrieve, - .retrieveLen = dataStrLen, - }; + req->streamId = pTask->id.streamId; + req->srcNodeId = pTask->info.nodeId; + req->srcTaskId = pTask->id.taskId; + req->pRetrieve = pRetrieve; + req->retrieveLen = dataStrLen; + return 0; +} - int32_t sz = taosArrayGetSize(pTask->upstreamInfo.pList); - ASSERT(sz > 0); - for (int32_t i = 0; i < sz; i++) { - req.reqId = tGenIdPI64(); - SStreamChildEpInfo* pEpInfo = taosArrayGetP(pTask->upstreamInfo.pList, i); - req.dstNodeId = pEpInfo->nodeId; - req.dstTaskId = pEpInfo->taskId; - int32_t len; - tEncodeSize(tEncodeStreamRetrieveReq, &req, len, code); - if (code < 0) { - ASSERT(0); - return -1; - } - - buf = rpcMallocCont(sizeof(SMsgHead) + len); - if (buf == NULL) { - goto CLEAR; - } - - ((SMsgHead*)buf)->vgId = htonl(pEpInfo->nodeId); - void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); - SEncoder encoder; - tEncoderInit(&encoder, abuf, len); - tEncodeStreamRetrieveReq(&encoder, &req); - tEncoderClear(&encoder); - - SRpcMsg rpcMsg = {0}; - initRpcMsg(&rpcMsg, TDMT_STREAM_RETRIEVE, buf, len + sizeof(SMsgHead)); - - if (tmsgSendReq(&pEpInfo->epSet, &rpcMsg) < 0) { - ASSERT(0); - goto CLEAR; - } - - buf = NULL; - stDebug("s-task:%s (child %d) send retrieve req to task:0x%x (vgId:%d), reqId:0x%" PRIx64, pTask->id.idStr, - pTask->info.selfChildId, pEpInfo->taskId, pEpInfo->nodeId, req.reqId); +int32_t streamBroadcastToUpTasks(SStreamTask* pTask, const SSDataBlock* pBlock) { + SStreamRetrieveReq req; + int32_t code = buildStreamRetrieveReq(pTask, pBlock, &req); + if(code != 0){ + return code; } - code = 0; -CLEAR: - taosMemoryFree(pRetrieve); - rpcFreeCont(buf); + code = broadcastRetrieveMsg(pTask, &req); + taosMemoryFree(req.pRetrieve); + return code; } diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index 7fb8095acd..840a7678f2 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -138,7 +138,7 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, SStreamQueueItem* pItem, i } if (output->info.type == STREAM_RETRIEVE) { - if (streamBroadcastToChildren(pTask, output) < 0) { + if (streamBroadcastToUpTasks(pTask, output) < 0) { // TODO } continue; diff --git a/source/libs/stream/src/streamTask.c b/source/libs/stream/src/streamTask.c index fef733c9f3..9f08a55b21 100644 --- a/source/libs/stream/src/streamTask.c +++ b/source/libs/stream/src/streamTask.c @@ -104,7 +104,7 @@ SStreamTask* tNewStreamTask(int64_t streamId, int8_t taskLevel, SEpSet* pEpset, } char buf[128] = {0}; - sprintf(buf, "0x%" PRIx64 "-%d", pTask->id.streamId, pTask->id.taskId); + sprintf(buf, "0x%" PRIx64 "-0x%x", pTask->id.streamId, pTask->id.taskId); pTask->id.idStr = taosStrdup(buf); pTask->status.schedStatus = TASK_SCHED_STATUS__INACTIVE; diff --git a/source/libs/stream/src/streamUpdate.c b/source/libs/stream/src/streamUpdate.c index d607f26de3..454ed4297c 100644 --- a/source/libs/stream/src/streamUpdate.c +++ b/source/libs/stream/src/streamUpdate.c @@ -261,6 +261,7 @@ void updateInfoDestroy(SUpdateInfo *pInfo) { taosArrayDestroy(pInfo->pTsSBFs); taosHashCleanup(pInfo->pMap); + updateInfoDestoryColseWinSBF(pInfo); taosMemoryFree(pInfo); } diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 7510b89736..8c73604727 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -450,10 +450,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_IVLD_ACTIVE, "Invalid active code") TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_IVLD_KEY, "Invalid key to parse active code") TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_DEC_IVLD_KEY, "Invalid key to decode active code") TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_DEC_IVLD_KLEN, "Invalid klen to decode active code") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_IVLD_KEY, "Invalid key to gen active code") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_ACTIVE_LEN, "Exceeded active len to gen active code") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_IVLD_KEY, "Invalid key to generate active code") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_ACTIVE_LEN, "Exceeded active len to generate active code") TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_GEN_ENC_IVLD_KLEN, "Invalid klen to encode active code") -TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_IVLD_DIST, "Invalid dist to parse active code") +TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_PAR_IVLD_DIST, "Invalid distribution time to parse active code") TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_UNLICENSED_CLUSTER, "Illegal operation, the license is being used by an unlicensed cluster") TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_LACK_OF_BASIC, "Lack of basic functions in active code") TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_OBJ_NOT_EXIST, "Grant object not exist") diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 103e67be46..d43a9a7ee6 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -4,12 +4,8 @@ #unit-test -archOs=$(arch) -if [[ $archOs =~ "aarch64" ]]; then ,,n,unit-test,bash test.sh -else -,,y,unit-test,bash test.sh -fi + # # army-test @@ -25,10 +21,10 @@ fi ,,n,army,python3 ./test.py -f community/cmdline/fullopt.py ,,y,army,./pytest.sh python3 ./test.py -f community/storage/oneStageComp.py -N 3 -L 3 -D 1 - # # system test # +,,y,system-test,./pytest.sh python3 ./test.py -f 8-stream/stream_multi_agg.py ,,y,system-test,./pytest.sh python3 ./test.py -f 8-stream/stream_basic.py ,,y,system-test,./pytest.sh python3 ./test.py -f 8-stream/scalar_function.py ,,y,system-test,./pytest.sh python3 ./test.py -f 8-stream/at_once_interval.py diff --git a/tests/script/tsim/parser/like.sim b/tests/script/tsim/parser/like.sim index 5cac026b57..298dbce0e5 100644 --- a/tests/script/tsim/parser/like.sim +++ b/tests/script/tsim/parser/like.sim @@ -51,6 +51,22 @@ if $rows != 1 then return -1 endi +$view1 = view1_name +$view2 = view2_name + +sql CREATE VIEW $view1 as select * from $table1 +sql CREATE VIEW $view2 AS select * from $table2 + +sql show views like 'view%' +if $rows != 2 then + return -1 +endi + +sql show views like 'view1%' +if $rows != 1 then + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/distributeInterval0.sim b/tests/script/tsim/stream/distributeInterval0.sim index a4e7941c28..cc8b7227d7 100644 --- a/tests/script/tsim/stream/distributeInterval0.sim +++ b/tests/script/tsim/stream/distributeInterval0.sim @@ -475,6 +475,8 @@ sql create table ts1 using st tags(1,1,1); sql create table ts2 using st tags(2,2,2); sql create stream stream_t3 trigger at_once into streamtST3 as select ts, min(a) c6, a, b, c, ta, tb, tc from st interval(10s) ; +sleep 1000 + sql insert into ts1 values(1648791211000,1,2,3); sleep 50 sql insert into ts1 values(1648791222001,2,2,3); @@ -488,6 +490,9 @@ $loop_count = 0 loop3: sql select * from streamtST3; +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 + sleep 1000 $loop_count = $loop_count + 1 if $loop_count == 30 then diff --git a/tests/script/tsim/stream/fillHistoryBasic2.sim b/tests/script/tsim/stream/fillHistoryBasic2.sim index 01019334a2..b3dd947eb9 100644 --- a/tests/script/tsim/stream/fillHistoryBasic2.sim +++ b/tests/script/tsim/stream/fillHistoryBasic2.sim @@ -243,6 +243,8 @@ sql create table ts1 using st tags(1,1,1); sql create table ts2 using st tags(2,2,2); sql create stream stream_t3 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamtST3 as select ts, min(a) c6, a, b, c, ta, tb, tc from st interval(10s) ; +sleep 1000 + sql insert into ts1 values(1648791211000,1,2,3); sleep 50 sql insert into ts1 values(1648791222001,2,2,3); diff --git a/tests/system-test/0-others/information_schema.py b/tests/system-test/0-others/information_schema.py index 79d010cd7d..a7995762d8 100644 --- a/tests/system-test/0-others/information_schema.py +++ b/tests/system-test/0-others/information_schema.py @@ -263,6 +263,54 @@ class TDTestCase: tdSql.error(f'select c_active_code from information_schema.ins_dnodes') tdSql.error('alter all dnodes "cActiveCode" ""') + def ins_grants_check(self): + grant_name_dict = { + 'stream':'stream', + 'subscription':'subscription', + 'view':'view', + 'audit':'audit', + 'csv':'csv', + 'storage':'multi_tier_storage', + 'backup_restore':'backup_restore', + 'opc_da':'OPC_DA', + 'opc_ua':'OPC_UA', + 'pi':'Pi', + 'kafka':'Kafka', + 'influxdb':'InfluxDB', + 'mqtt':'MQTT', + 'avevahistorian':'avevaHistorian', + 'opentsdb':'OpenTSDB', + 'td2.6':'TDengine2.6', + 'td3.0':'TDengine3.0' + } + + tdSql.execute('drop database if exists db2') + tdSql.execute('create database if not exists db2 vgroups 1 replica 1') + tdSql.query(f'select * from information_schema.ins_grants_full') + result = tdSql.queryResult + index = 0 + for i in range(0, len(result)): + if result[i][0] in grant_name_dict: + tdSql.checkEqual(result[i][1], grant_name_dict[result[i][0]]) + index += 1 + tdSql.checkEqual(index, 17) + tdSql.query(f'select * from information_schema.ins_grants_logs') + result = tdSql.queryResult + tdSql.checkEqual(True, len(result) >= 0) + if(len(result) > 0): + tdSql.checkEqual(True, result[0][0].find(",init,ungranted,ungranted") >= 16) + tdSql.checkEqual(True, len(result[0][1]) == 0) + tdSql.checkEqual(True, len(result[0][2]) >= 46) + + tdSql.query(f'select * from information_schema.ins_machines') + tdSql.checkRows(1) + tdSql.execute('alter cluster "activeCode" "revoked"') + tdSql.execute('alter cluster "activeCode" "revoked"') + tdSql.error('alter cluster "activeCode" ""') + tdSql.error('alter cluster "activeCode" "abc"') + tdSql.error('alter cluster "activeCode" ""') + tdSql.execute('alter cluster "activeCode" "revoked"') + def run(self): self.prepare_data() self.count_check() @@ -271,6 +319,7 @@ class TDTestCase: self.ins_stable_check() self.ins_stable_check2() self.ins_dnodes_check() + self.ins_grants_check() def stop(self): diff --git a/tests/system-test/7-tmq/tmqParamsTest.py b/tests/system-test/7-tmq/tmqParamsTest.py index 9286b69278..82a5d42b47 100644 --- a/tests/system-test/7-tmq/tmqParamsTest.py +++ b/tests/system-test/7-tmq/tmqParamsTest.py @@ -133,13 +133,17 @@ class TDTestCase: if snapshot_value == "true": if offset_value != "earliest" and offset_value != "": if offset_value == "latest": - offset_value_list = list(map(lambda x: int(x[-2].replace("wal:", "").replace("earliest", "0").replace("latest", "0").replace(offset_value, "0")), subscription_info)) - tdSql.checkEqual(sum(offset_value_list) >= 0, True) + offset_value_list = list(map(lambda x: (x[-2].replace("wal:", "").replace("earliest", "0").replace("latest", "0").replace(offset_value, "0")), subscription_info)) + offset_value_list1 = list(map(lambda x: int(x.split("/")[0]), offset_value_list)) + offset_value_list2 = list(map(lambda x: int(x.split("/")[1]), offset_value_list)) + tdSql.checkEqual(offset_value_list1 == offset_value_list2, True) + tdSql.checkEqual(sum(offset_value_list1) >= 0, True) rows_value_list = list(map(lambda x: int(x[-1]), subscription_info)) tdSql.checkEqual(sum(rows_value_list), expected_res) elif offset_value == "none": offset_value_list = list(map(lambda x: x[-2], subscription_info)) - tdSql.checkEqual(offset_value_list, ['none']*len(subscription_info)) + offset_value_list1 = list(map(lambda x: (x.split("/")[0]), offset_value_list)) + tdSql.checkEqual(offset_value_list1, ['none']*len(subscription_info)) rows_value_list = list(map(lambda x: x[-1], subscription_info)) tdSql.checkEqual(rows_value_list, [0]*len(subscription_info)) else: @@ -151,18 +155,23 @@ class TDTestCase: # tdSql.checkEqual(sum(rows_value_list), expected_res) else: offset_value_list = list(map(lambda x: x[-2], subscription_info)) - tdSql.checkEqual(offset_value_list, [None]*len(subscription_info)) + offset_value_list1 = list(map(lambda x: (x.split("/")[0]), offset_value_list)) + tdSql.checkEqual(offset_value_list1, [None]*len(subscription_info)) rows_value_list = list(map(lambda x: x[-1], subscription_info)) tdSql.checkEqual(rows_value_list, [None]*len(subscription_info)) else: if offset_value != "none": - offset_value_list = list(map(lambda x: int(x[-2].replace("wal:", "").replace("earliest", "0").replace("latest", "0").replace(offset_value, "0")), subscription_info)) - tdSql.checkEqual(sum(offset_value_list) >= 0, True) + offset_value_list = list(map(lambda x: (x[-2].replace("wal:", "").replace("earliest", "0").replace("latest", "0").replace(offset_value, "0")), subscription_info)) + offset_value_list1 = list(map(lambda x: int(x.split("/")[0]), offset_value_list)) + offset_value_list2 = list(map(lambda x: int(x.split("/")[1]), offset_value_list)) + tdSql.checkEqual(offset_value_list1 == offset_value_list2, True) + tdSql.checkEqual(sum(offset_value_list1) >= 0, True) rows_value_list = list(map(lambda x: int(x[-1]), subscription_info)) tdSql.checkEqual(sum(rows_value_list), expected_res) else: offset_value_list = list(map(lambda x: x[-2], subscription_info)) - tdSql.checkEqual(offset_value_list, ['none']*len(subscription_info)) + offset_value_list1 = list(map(lambda x: (x.split("/")[0]), offset_value_list)) + tdSql.checkEqual(offset_value_list1, ['none']*len(subscription_info)) rows_value_list = list(map(lambda x: x[-1], subscription_info)) tdSql.checkEqual(rows_value_list, [0]*len(subscription_info)) tdSql.execute(f"drop topic if exists {topic_name}") diff --git a/tests/system-test/7-tmq/tmq_taosx.py b/tests/system-test/7-tmq/tmq_taosx.py index 86c40fdc72..5bd70a5d60 100644 --- a/tests/system-test/7-tmq/tmq_taosx.py +++ b/tests/system-test/7-tmq/tmq_taosx.py @@ -11,6 +11,7 @@ from util.sql import * from util.cases import * from util.dnodes import * from util.common import * +from taos.tmq import * sys.path.append("./7-tmq") from tmqCommon import * @@ -310,6 +311,43 @@ class TDTestCase: return + def consumeExcluded(self): + tdSql.execute(f'create topic topic_excluded as database db_taosx') + consumer_dict = { + "group.id": "g1", + "td.connect.user": "root", + "td.connect.pass": "taosdata", + "auto.offset.reset": "earliest", + "msg.consume.excluded": 1 + } + consumer = Consumer(consumer_dict) + + tdLog.debug("test subscribe topic created by other user") + exceptOccured = False + try: + consumer.subscribe(["topic_excluded"]) + except TmqError: + exceptOccured = True + + if exceptOccured: + tdLog.exit(f"subscribe error") + + try: + while True: + res = consumer.poll(1) + if not res: + break + err = res.error() + if err is not None: + raise err + val = res.value() + + for block in val: + print(block.fetchall()) + + finally: + consumer.close() + def run(self): tdSql.prepare() self.checkWal1VgroupOnlyMeta() @@ -324,6 +362,8 @@ class TDTestCase: self.checkSnapshotMultiVgroups() self.checkWalMultiVgroupsWithDropTable() + # self.consumeExcluded() + self.checkSnapshotMultiVgroupsWithDropTable() def stop(self): diff --git a/tests/system-test/8-stream/stream_multi_agg.py b/tests/system-test/8-stream/stream_multi_agg.py new file mode 100644 index 0000000000..3532825493 --- /dev/null +++ b/tests/system-test/8-stream/stream_multi_agg.py @@ -0,0 +1,100 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + + +from util.log import * +from util.cases import * +from util.sql import * +from util.common import * +from util.sqlset import * +from util.autogen import * + +import random +import time +import traceback +import os +from os import path + + +class TDTestCase: + updatecfgDict = {'debugFlag': 135, 'asynclog': 0, 'streamAggCnt': 2} + # init + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), True) + + def case1(self): + tdLog.debug("========case1 start========") + + os.system("nohup taosBenchmark -y -B 1 -t 40 -S 1000 -n 10 -i 1000 -v 5 > /dev/null 2>&1 &") + time.sleep(10) + tdSql.query("use test") + tdSql.query("create stream if not exists s1 trigger at_once ignore expired 0 ignore update 0 fill_history 1 into st1 as select _wstart,sum(voltage),groupid from meters partition by groupid interval(2s)") + tdLog.debug("========create stream and insert data ok========") + time.sleep(15) + + tdSql.query("select _wstart,sum(voltage),groupid from meters partition by groupid interval(2s) order by groupid,_wstart") + rowCnt = tdSql.getRows() + results = [] + for i in range(rowCnt): + results.append(tdSql.getData(i,1)) + + tdSql.query("select * from st1 order by groupid,_wstart") + tdSql.checkRows(rowCnt) + for i in range(rowCnt): + data1 = tdSql.getData(i,1) + data2 = results[i] + if data1 != data2: + tdLog.info("num: %d, act data: %d, expect data: %d"%(i, data1, data2)) + tdLog.exit("check data error!") + + tdLog.debug("case1 end") + + def case2(self): + tdLog.debug("========case2 start========") + + os.system("taosBenchmark -d db -t 20 -v 6 -n 1000 -y > /dev/null 2>&1") + # create stream + tdSql.execute("use db") + tdSql.execute("create stream stream1 fill_history 1 into sta as select count(*) as cnt from meters interval(10a);",show=True) + time.sleep(5) + + sql = "select count(*) from sta" + # loop wait max 60s to check count is ok + tdLog.info("loop wait result ...") + tdSql.checkDataLoop(0, 0, 100, sql, loopCount=10, waitTime=0.5) + + # check all data is correct + sql = "select * from sta where cnt != 200;" + tdSql.query(sql) + tdSql.checkRows(0) + + # check ts interval is correct + sql = "select * from ( select diff(_wstart) as tsdif from sta ) where tsdif != 10;" + tdSql.query(sql) + tdSql.checkRows(0) + tdLog.debug("case2 end") + +# run + def run(self): + self.case1() + self.case2() + + # stop + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/test.py b/tests/system-test/test.py index 795132b14e..301622cd28 100644 --- a/tests/system-test/test.py +++ b/tests/system-test/test.py @@ -683,6 +683,6 @@ if __name__ == "__main__": if conn is not None: conn.close() if asan: - tdDnodes.StopAllSigint() + # tdDnodes.StopAllSigint() tdLog.info("Address sanitizer mode finished") sys.exit(0) diff --git a/tests/unit-test/test.sh b/tests/unit-test/test.sh index 292767e00c..71f5189551 100755 --- a/tests/unit-test/test.sh +++ b/tests/unit-test/test.sh @@ -40,7 +40,7 @@ pgrep taosd || taosd >> /dev/null 2>&1 & sleep 10 -ctest -E "smlTest|funcTest|profileTest|sdbTest|showTest|geomTest|idxFstUtilUT|idxTest|idxUtilUT|idxFstUT|parserTest|plannerTest|transUT|transUtilUt" -j8 +ctest -j8 ret=$? exit $ret diff --git a/tools/shell/src/shellMain.c b/tools/shell/src/shellMain.c index 18f4ca21d1..d3ca60ab87 100644 --- a/tools/shell/src/shellMain.c +++ b/tools/shell/src/shellMain.c @@ -28,7 +28,7 @@ void shellCrashHandler(int signum, void *sigInfo, void *context) { #if !defined(WINDOWS) taosIgnSignal(SIGBUS); -#endif +#endif taosIgnSignal(SIGABRT); taosIgnSignal(SIGFPE); taosIgnSignal(SIGSEGV); @@ -82,7 +82,9 @@ int main(int argc, char *argv[]) { #ifdef WEBSOCKET shellCheckConnectMode(); #endif - taos_init(); + if (taos_init() != 0) { + return -1; + } // kill heart-beat thread when quit taos_set_hb_quit(1); @@ -105,7 +107,7 @@ int main(int argc, char *argv[]) { return 0; } - // support port feature + // support port feature shellAutoInit(); int32_t ret = shellExecute(); shellAutoExit(); diff --git a/utils/test/c/tmq_taosx_ci.c b/utils/test/c/tmq_taosx_ci.c index 8a7074844a..056b7dc6cf 100644 --- a/utils/test/c/tmq_taosx_ci.c +++ b/utils/test/c/tmq_taosx_ci.c @@ -909,6 +909,88 @@ void initLogFile() { taosCloseFile(&pFile2); } +void testConsumeExcluded(int topic_type){ + TAOS* pConn = use_db(); + TAOS_RES *pRes = NULL; + + if(topic_type == 1){ + char *topic = "create topic topic_excluded with meta as database db_taosx"; + pRes = taos_query(pConn, topic); + if (taos_errno(pRes) != 0) { + printf("failed to create topic topic_excluded, reason:%s\n", taos_errstr(pRes)); + taos_close(pConn); + return; + } + taos_free_result(pRes); + }else if(topic_type == 2){ + char *topic = "create topic topic_excluded as select * from stt"; + pRes = taos_query(pConn, topic); + if (taos_errno(pRes) != 0) { + printf("failed to create topic topic_excluded, reason:%s\n", taos_errstr(pRes)); + taos_close(pConn); + return; + } + taos_free_result(pRes); + } + taos_close(pConn); + + tmq_conf_t* conf = tmq_conf_new(); + tmq_conf_set(conf, "group.id", "tg2"); + tmq_conf_set(conf, "client.id", "my app 1"); + tmq_conf_set(conf, "td.connect.user", "root"); + tmq_conf_set(conf, "td.connect.pass", "taosdata"); + tmq_conf_set(conf, "msg.with.table.name", "true"); + tmq_conf_set(conf, "enable.auto.commit", "true"); + tmq_conf_set(conf, "auto.offset.reset", "earliest"); + tmq_conf_set(conf, "msg.consume.excluded", "1"); + + + tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); + tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); + assert(tmq); + tmq_conf_destroy(conf); + + tmq_list_t* topic_list = tmq_list_new(); + tmq_list_append(topic_list, "topic_excluded"); + + int32_t code = 0; + + if ((code = tmq_subscribe(tmq, topic_list))) { + fprintf(stderr, "%% Failed to start consuming topics: %s\n", tmq_err2str(code)); + printf("subscribe err\n"); + return; + } + while (running) { + TAOS_RES* msg = tmq_consumer_poll(tmq, 1000); + if (msg) { + tmq_raw_data raw = {0}; + tmq_get_raw(msg, &raw); + if(topic_type == 1){ + assert(raw.raw_type != 2 && raw.raw_type != 4); + }else if(topic_type == 2){ + assert(0); + } +// printf("write raw data type: %d\n", raw.raw_type); + tmq_free_raw(raw); + + taos_free_result(msg); + } else { + break; + } + } + + tmq_consumer_close(tmq); + tmq_list_destroy(topic_list); + + pConn = use_db(); + pRes = taos_query(pConn, "drop topic if exists topic_excluded"); + if (taos_errno(pRes) != 0) { + printf("error in drop topic, reason:%s\n", taos_errstr(pRes)); + taos_close(pConn); + return; + } + taos_free_result(pRes); +} int main(int argc, char* argv[]) { for (int32_t i = 1; i < argc; i++) { if (strcmp(argv[i], "-c") == 0) { @@ -942,5 +1024,8 @@ int main(int argc, char* argv[]) { tmq_list_t* topic_list = build_topic_list(); basic_consume_loop(tmq, topic_list); tmq_list_destroy(topic_list); + + testConsumeExcluded(1); + testConsumeExcluded(2); taosCloseFile(&g_fp); }