diff --git a/docs/zh/07-develop/07-tmq.mdx b/docs/zh/07-develop/07-tmq.mdx index df651eab96..a852e71ff4 100644 --- a/docs/zh/07-develop/07-tmq.mdx +++ b/docs/zh/07-develop/07-tmq.mdx @@ -91,6 +91,7 @@ TDengine 会为 WAL 文件自动创建索引以支持快速随机访问,并提 不同语言下, TMQ 订阅相关的 API 及数据结构如下(详细的接口说明可以参考连接器章节,注意consumer结构不是线程安全的,在一个线程使用consumer时,不要在另一个线程close这个consumer): + ```c @@ -101,17 +102,17 @@ TDengine 会为 WAL 文件自动创建索引以支持快速随机访问,并提 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; + 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; + 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); @@ -146,7 +147,6 @@ TDengine 会为 WAL 文件自动创建索引以支持快速随机访问,并提 DLL_EXPORT int64_t tmq_get_vgroup_offset(TAOS_RES* res); DLL_EXPORT const char *tmq_err2str(int32_t code); ``` - @@ -250,281 +250,280 @@ TDengine 会为 WAL 文件自动创建索引以支持快速随机访问,并提 + futures::Stream< Item = Result<(Self::Offset, MessageSet), Self::Error>, >, - >, - >; - async fn commit(&self, offset: Self::Offset) -> Result<(), Self::Error>; + >, + >; + async fn commit(&self, offset: Self::Offset) -> Result<(), Self::Error>; - async fn unsubscribe(self); - ``` + async fn unsubscribe(self); + ``` - 可在 上查看详细 API 说明。 + 可在 上查看详细 API 说明。 - + - + - ```js - function TMQConsumer(config) + ```js + function TMQConsumer(config) + + function subscribe(topic) + + function consume(timeout) + + function subscription() + + function unsubscribe() + + function commit(msg) + + function close() + ``` - function subscribe(topic) + - function consume(timeout) + - function subscription() + ```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() + ``` + + - 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'); +```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: +使用 SQL 创建一个 topic: - ```sql - CREATE TOPIC topic_name AS SELECT ts, c1, c2, c3 FROM tmqdb.stb WHERE c1 > 1; - ``` +```sql +CREATE TOPIC topic_name AS SELECT ts, c1, c2, c3 FROM tmqdb.stb WHERE c1 > 1; +``` - ## 创建消费者 *consumer* +## 创建消费者 *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 + /* 根据需要,设置消费组 (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); - tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); - tmq_conf_destroy(conf); - ``` - - - - - 对于 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 | 指定字符串解析的字符集 | | - - 需要注意:此处使用 `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); - - /* value deserializer definition. */ - import com.taosdata.jdbc.tmq.ReferenceDeserializer; - - public class MetersDeserializer extends ReferenceDeserializer { - } - ``` - - - - - - ```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) - ``` - - - - - - ```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()?; - ``` - - - - - - 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', - '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' - }); + tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); + tmq_conf_destroy(conf); ``` + - + - - - ```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(); + 对于 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 | 指定字符串解析的字符集 | | + + 需要注意:此处使用 `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); + + /* value deserializer definition. */ + import com.taosdata.jdbc.tmq.ReferenceDeserializer; + + public class MetersDeserializer extends ReferenceDeserializer { + } ``` + - + + + ```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) + ``` + + - + + + ```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()?; + ``` + + - 上述配置中包括 consumer group ID,如果多个 consumer 指定的 consumer group ID 一样,则自动形成一个 consumer group,共享消费进度。 + + + 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", + } + ) + ``` + + - ## 订阅 *topics* + + + ```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', + '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' + }); + ``` + + - 一个 consumer 支持同时订阅多个 topic。 + + + ```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,共享消费进度。 + +## 订阅 *topics* - - +一个 consumer 支持同时订阅多个 topic。 + + -```c + + + ```c // 创建订阅 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); ``` - - - + + + ```go err = consumer.Subscribe("example_tmq_topic", nil) @@ -533,26 +532,26 @@ INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); } ``` - - + + -```rust + ```rust consumer.subscribe(["tmq_meters"]).await?; ``` - + - + -```python + ```python consumer.subscribe(['topic1', 'topic2']) ``` - + - + -```js + ```js // 创建订阅 topics 列表 let topics = ['topic_test'] @@ -560,11 +559,11 @@ INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); consumer.subscribe(topics); ``` - + - + -```csharp + ```csharp // 创建订阅 topics 列表 List topics = new List(); topics.add("tmq_topic"); @@ -572,18 +571,19 @@ INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); consumer.Subscribe(topics); ``` - + - + - ## 消费 +## 消费 - 以下代码展示了不同语言下如何对 TMQ 消息进行消费。 +以下代码展示了不同语言下如何对 TMQ 消息进行消费。 - - + -```c + + + ```c // 消费数据 while (running) { TAOS_RES* msg = tmq_consumer_poll(tmq, timeOut); @@ -591,11 +591,11 @@ INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); } ``` -这里是一个 **while** 循环,每调用一次 tmq_consumer_poll(),获取一个消息,该消息与普通查询返回的结果集完全相同,可以使用相同的解析 API 完成消息内容的解析。 - - - + 这里是一个 **while** 循环,每调用一次 tmq_consumer_poll(),获取一个消息,该消息与普通查询返回的结果集完全相同,可以使用相同的解析 API 完成消息内容的解析。 + + + ```java while(running){ ConsumerRecords meters = consumer.poll(Duration.ofMillis(100)); @@ -604,10 +604,10 @@ INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); } } ``` + + - - - + ```go for { @@ -625,9 +625,9 @@ INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); } ``` - + - + ```rust { @@ -660,8 +660,8 @@ INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); } ``` - - + + ```python while True: @@ -677,9 +677,9 @@ INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); print(block.fetchall()) ``` - + - + ```js while(true){ @@ -691,11 +691,11 @@ INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); } ``` - + - + -```csharp + ```csharp // 消费数据 while (true) { @@ -708,18 +708,19 @@ INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); } ``` - + - + - ## 结束消费 +## 结束消费 - 消费结束后,应当取消订阅。 +消费结束后,应当取消订阅。 - - + + + -```c + ```c /* 取消订阅 */ tmq_unsubscribe(tmq); @@ -727,10 +728,10 @@ INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); tmq_consumer_close(tmq); ``` - - + + -```java + ```java /* 取消订阅 */ consumer.unsubscribe(); @@ -738,11 +739,11 @@ INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); consumer.close(); ``` - + + + - - -```go + ```go /* Unsubscribe */ _ = consumer.Unsubscribe() @@ -750,38 +751,38 @@ INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); _ = consumer.Close() ``` - + + + - - -```rust + ```rust consumer.unsubscribe().await; ``` - + - + -```py + ```py # 取消订阅 consumer.unsubscribe() # 关闭消费 consumer.close() ``` - - + + -```js + ```js consumer.unsubscribe(); consumer.close(); ``` - + - + -```csharp + ```csharp // 取消订阅 consumer.Unsubscribe(); @@ -789,7 +790,7 @@ INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); consumer.Close(); ``` - + @@ -799,41 +800,41 @@ INSERT INTO tmqdb.ctb1 VALUES(now, 1, 1, 'a1')(now+1s, 11, 11, 'a11'); - - - + + + - - - - - - - - - - + + + + + + + + + + - - - + + + - - - + + + - - - + + + - - - - - - - + + + + + + + #订阅高级功能 diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 7e7e9b0481..ccad689710 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -54,6 +54,8 @@ typedef struct SSessionKey { uint64_t groupId; } SSessionKey; +typedef int64_t COUNT_TYPE; + typedef struct SVersionRange { int64_t minVer; int64_t maxVer; diff --git a/include/common/tmsg.h b/include/common/tmsg.h index e24d4a71b0..1b438ba026 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -247,6 +247,7 @@ typedef enum ENodeType { QUERY_NODE_EVENT_WINDOW, QUERY_NODE_HINT, QUERY_NODE_VIEW, + QUERY_NODE_COUNT_WINDOW, // Statement nodes are used in parser and planner module. QUERY_NODE_SET_OPERATOR = 100, @@ -432,7 +433,9 @@ typedef enum ENodeType { QUERY_NODE_PHYSICAL_PLAN_HASH_JOIN, QUERY_NODE_PHYSICAL_PLAN_GROUP_CACHE, QUERY_NODE_PHYSICAL_PLAN_DYN_QUERY_CTRL, - QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL + QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT, + QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT, + QUERY_NODE_PHYSICAL_PLAN_STREAM_MID_INTERVAL, } ENodeType; typedef struct { @@ -1400,7 +1403,7 @@ void tFreeSCompactDbReq(SCompactDbReq* pReq); typedef struct { int32_t compactId; - int8_t bAccepted; + int8_t bAccepted; } SCompactDbRsp; int32_t tSerializeSCompactDbRsp(void* buf, int32_t bufLen, SCompactDbRsp* pRsp); @@ -1414,7 +1417,7 @@ typedef struct { int32_t tSerializeSKillCompactReq(void* buf, int32_t bufLen, SKillCompactReq* pReq); int32_t tDeserializeSKillCompactReq(void* buf, int32_t bufLen, SKillCompactReq* pReq); -void tFreeSKillCompactReq(SKillCompactReq *pReq); +void tFreeSKillCompactReq(SKillCompactReq* pReq); typedef struct { char name[TSDB_FUNC_NAME_LEN]; @@ -1751,9 +1754,9 @@ int32_t tSerializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* int32_t tDeserializeSCompactVnodeReq(void* buf, int32_t bufLen, SCompactVnodeReq* pReq); typedef struct { - int32_t compactId; - int32_t vgId; - int32_t dnodeId; + int32_t compactId; + int32_t vgId; + int32_t dnodeId; } SVKillCompactReq; int32_t tSerializeSVKillCompactReq(void* buf, int32_t bufLen, SVKillCompactReq* pReq); @@ -1954,9 +1957,9 @@ typedef struct { char db[TSDB_DB_FNAME_LEN]; char tb[TSDB_TABLE_NAME_LEN]; char user[TSDB_USER_LEN]; - char filterTb[TSDB_TABLE_NAME_LEN]; // for ins_columns + char filterTb[TSDB_TABLE_NAME_LEN]; // for ins_columns int64_t showId; - int64_t compactId; // for compact + int64_t compactId; // for compact } SRetrieveTableReq; typedef struct SSysTableSchema { @@ -3182,18 +3185,11 @@ typedef struct { typedef struct { SMsgHead head; - int64_t leftForVer; + int64_t resetRelHalt; // reset related stream task halt status int64_t streamId; int32_t taskId; } SVDropStreamTaskReq; -typedef struct { - SMsgHead head; - int64_t streamId; - int32_t taskId; - int64_t dataVer; -} SVStreamTaskVerUpdateReq; - typedef struct { int8_t reserved; } SVDropStreamTaskRsp; @@ -3784,12 +3780,12 @@ typedef struct { } SMqHbReq; typedef struct { - char topic[TSDB_TOPIC_FNAME_LEN]; - int8_t noPrivilege; + char topic[TSDB_TOPIC_FNAME_LEN]; + int8_t noPrivilege; } STopicPrivilege; typedef struct { - SArray* topicPrivileges; // SArray + SArray* topicPrivileges; // SArray } SMqHbRsp; typedef struct { @@ -3927,8 +3923,8 @@ 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 +#define SOURCE_NULL 0 +#define SOURCE_TAOSX 1 typedef struct { int32_t flags; @@ -3940,8 +3936,8 @@ typedef struct { SArray* aRowP; SArray* aCol; }; - int64_t ctimeMs; - int8_t source; + int64_t ctimeMs; + int8_t source; } SSubmitTbData; typedef struct { diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 5f0538ce17..f4a1c79081 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -297,75 +297,77 @@ #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 +#define TK_COUNT_WINDOW 281 +#define TK_SLIDING 282 +#define TK_FILL 283 +#define TK_VALUE 284 +#define TK_VALUE_F 285 +#define TK_NONE 286 +#define TK_PREV 287 +#define TK_NULL_F 288 +#define TK_LINEAR 289 +#define TK_NEXT 290 +#define TK_HAVING 291 +#define TK_RANGE 292 +#define TK_EVERY 293 +#define TK_ORDER 294 +#define TK_SLIMIT 295 +#define TK_SOFFSET 296 +#define TK_LIMIT 297 +#define TK_OFFSET 298 +#define TK_ASC 299 +#define TK_NULLS 300 +#define TK_ABORT 301 +#define TK_AFTER 302 +#define TK_ATTACH 303 +#define TK_BEFORE 304 +#define TK_BEGIN 305 +#define TK_BITAND 306 +#define TK_BITNOT 307 +#define TK_BITOR 308 +#define TK_BLOCKS 309 +#define TK_CHANGE 310 +#define TK_COMMA 311 +#define TK_CONCAT 312 +#define TK_CONFLICT 313 +#define TK_COPY 314 +#define TK_DEFERRED 315 +#define TK_DELIMITERS 316 +#define TK_DETACH 317 +#define TK_DIVIDE 318 +#define TK_DOT 319 +#define TK_EACH 320 +#define TK_FAIL 321 +#define TK_FILE 322 +#define TK_FOR 323 +#define TK_GLOB 324 +#define TK_ID 325 +#define TK_IMMEDIATE 326 +#define TK_IMPORT 327 +#define TK_INITIALLY 328 +#define TK_INSTEAD 329 +#define TK_ISNULL 330 +#define TK_KEY 331 +#define TK_MODULES 332 +#define TK_NK_BITNOT 333 +#define TK_NK_SEMI 334 +#define TK_NOTNULL 335 +#define TK_OF 336 +#define TK_PLUS 337 +#define TK_PRIVILEGE 338 +#define TK_RAISE 339 +#define TK_RESTRICT 340 +#define TK_ROW 341 +#define TK_SEMI 342 +#define TK_STAR 343 +#define TK_STATEMENT 344 +#define TK_STRICT 345 +#define TK_STRING 346 +#define TK_TIMES 347 +#define TK_VALUES 348 +#define TK_VARIABLE 349 +#define TK_WAL 350 + #define TK_NK_SPACE 600 #define TK_NK_COMMENT 601 diff --git a/include/libs/executor/executor.h b/include/libs/executor/executor.h index e06a08acba..fe20639c77 100644 --- a/include/libs/executor/executor.h +++ b/include/libs/executor/executor.h @@ -215,7 +215,6 @@ int32_t qSetStreamOperatorOptionForScanHistory(qTaskInfo_t tinfo); int32_t qStreamSourceScanParamForHistoryScanStep1(qTaskInfo_t tinfo, SVersionRange *pVerRange, STimeWindow* pWindow); int32_t qStreamSourceScanParamForHistoryScanStep2(qTaskInfo_t tinfo, SVersionRange *pVerRange, STimeWindow* pWindow); int32_t qStreamRecoverFinish(qTaskInfo_t tinfo); -int32_t qRestoreStreamOperatorOption(qTaskInfo_t tinfo); bool qStreamScanhistoryFinished(qTaskInfo_t tinfo); int32_t qStreamInfoResetTimewindowFilter(qTaskInfo_t tinfo); void resetTaskInfo(qTaskInfo_t tinfo); diff --git a/include/libs/executor/storageapi.h b/include/libs/executor/storageapi.h index 9987dab166..e66ffe5521 100644 --- a/include/libs/executor/storageapi.h +++ b/include/libs/executor/storageapi.h @@ -352,14 +352,19 @@ typedef struct SStateStore { int32_t (*streamStateSessionPut)(SStreamState* pState, const SSessionKey* key, void* value, int32_t vLen); int32_t (*streamStateSessionGet)(SStreamState* pState, SSessionKey* key, void** pVal, int32_t* pVLen); int32_t (*streamStateSessionDel)(SStreamState* pState, const SSessionKey* key); + int32_t (*streamStateSessionReset)(SStreamState* pState, void* pVal); int32_t (*streamStateSessionClear)(SStreamState* pState); int32_t (*streamStateSessionGetKVByCur)(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen); int32_t (*streamStateStateAddIfNotExist)(SStreamState* pState, SSessionKey* key, char* pKeyData, int32_t keyDataLen, state_key_cmpr_fn fn, void** pVal, int32_t* pVLen); int32_t (*streamStateSessionGetKeyByRange)(SStreamState* pState, const SSessionKey* range, SSessionKey* curKey); + int32_t (*streamStateCountGetKeyByRange)(SStreamState* pState, const SSessionKey* range, SSessionKey* curKey); int32_t (*streamStateSessionAllocWinBuffByNextPosition)(SStreamState* pState, SStreamStateCur* pCur, const SSessionKey* pKey, void** pVal, int32_t* pVLen); + int32_t (*streamStateCountWinAddIfNotExist)(SStreamState* pState, SSessionKey* pKey, COUNT_TYPE winCount, void** ppVal, int32_t* pVLen); + int32_t (*streamStateCountWinAdd)(SStreamState* pState, SSessionKey* pKey, void** pVal, int32_t* pVLen); + SUpdateInfo* (*updateInfoInit)(int64_t interval, int32_t precision, int64_t watermark, bool igUp); TSKEY (*updateInfoFillBlockData)(SUpdateInfo* pInfo, SSDataBlock* pBlock, int32_t primaryTsCol); bool (*updateInfoIsUpdated)(SUpdateInfo* pInfo, uint64_t tableId, TSKEY ts); @@ -377,6 +382,7 @@ typedef struct SStateStore { int32_t (*updateInfoDeserialize)(void* buf, int32_t bufLen, SUpdateInfo* pInfo); SStreamStateCur* (*streamStateSessionSeekKeyNext)(SStreamState* pState, const SSessionKey* key); + SStreamStateCur* (*streamStateCountSeekKeyPrev)(SStreamState* pState, const SSessionKey* pKey, COUNT_TYPE count); SStreamStateCur* (*streamStateSessionSeekKeyCurrentPrev)(SStreamState* pState, const SSessionKey* key); SStreamStateCur* (*streamStateSessionSeekKeyCurrentNext)(SStreamState* pState, const SSessionKey* key); diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 447e8725c7..0e717369d4 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -244,7 +244,8 @@ typedef enum EWindowType { WINDOW_TYPE_INTERVAL = 1, WINDOW_TYPE_SESSION, WINDOW_TYPE_STATE, - WINDOW_TYPE_EVENT + WINDOW_TYPE_EVENT, + WINDOW_TYPE_COUNT } EWindowType; typedef enum EWindowAlgorithm { @@ -282,6 +283,8 @@ typedef struct SWindowLogicNode { int8_t igCheckUpdate; EWindowAlgorithm windowAlgo; bool isPartTb; + int64_t windowCount; + int64_t windowSliding; } SWindowLogicNode; typedef struct SFillLogicNode { @@ -631,6 +634,14 @@ typedef struct SEventWinodwPhysiNode { typedef SEventWinodwPhysiNode SStreamEventWinodwPhysiNode; +typedef struct SCountWinodwPhysiNode { + SWindowPhysiNode window; + int64_t windowCount; + int64_t windowSliding; +} SCountWinodwPhysiNode; + +typedef SCountWinodwPhysiNode SStreamCountWinodwPhysiNode; + typedef struct SSortPhysiNode { SPhysiNode node; SNodeList* pExprs; // these are expression list of order_by_clause and parameter expression of aggregate function diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 9647c0adac..ebe98e58c0 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -278,6 +278,13 @@ typedef struct SEventWindowNode { SNode* pEndCond; } SEventWindowNode; +typedef struct SCountWindowNode { + ENodeType type; // QUERY_NODE_EVENT_WINDOW + SNode* pCol; // timestamp primary key + int64_t windowCount; + int64_t windowSliding; +} SCountWindowNode; + typedef enum EFillMode { FILL_MODE_NONE = 1, FILL_MODE_VALUE, diff --git a/include/libs/stream/streamState.h b/include/libs/stream/streamState.h index c2f7c6de2f..c603f9f5ac 100644 --- a/include/libs/stream/streamState.h +++ b/include/libs/stream/streamState.h @@ -55,13 +55,16 @@ int32_t streamStateSessionAddIfNotExist(SStreamState* pState, SSessionKey* key, int32_t streamStateSessionPut(SStreamState* pState, const SSessionKey* key, void* value, int32_t vLen); int32_t streamStateSessionGet(SStreamState* pState, SSessionKey* key, void** pVal, int32_t* pVLen); int32_t streamStateSessionDel(SStreamState* pState, const SSessionKey* key); +int32_t streamStateSessionReset(SStreamState* pState, void* pVal); int32_t streamStateSessionClear(SStreamState* pState); int32_t streamStateSessionGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen); int32_t streamStateSessionGetKeyByRange(SStreamState* pState, const SSessionKey* range, SSessionKey* curKey); +int32_t streamStateCountGetKeyByRange(SStreamState* pState, const SSessionKey* range, SSessionKey* curKey); int32_t streamStateSessionAllocWinBuffByNextPosition(SStreamState* pState, SStreamStateCur* pCur, const SSessionKey* pKey, void** pVal, int32_t* pVLen); SStreamStateCur* streamStateSessionSeekKeyNext(SStreamState* pState, const SSessionKey* key); +SStreamStateCur* streamStateCountSeekKeyPrev(SStreamState* pState, const SSessionKey* pKey, COUNT_TYPE count); SStreamStateCur* streamStateSessionSeekKeyCurrentPrev(SStreamState* pState, const SSessionKey* key); SStreamStateCur* streamStateSessionSeekKeyCurrentNext(SStreamState* pState, const SSessionKey* key); @@ -79,6 +82,10 @@ int32_t streamStateReleaseBuf(SStreamState* pState, void* pVal, bool used); int32_t streamStateClearBuff(SStreamState* pState, void* pVal); void streamStateFreeVal(void* val); +// count window +int32_t streamStateCountWinAddIfNotExist(SStreamState* pState, SSessionKey* pKey, COUNT_TYPE winCount, void** ppVal, int32_t* pVLen); +int32_t streamStateCountWinAdd(SStreamState* pState, SSessionKey* pKey, void** pVal, int32_t* pVLen); + SStreamStateCur* streamStateGetAndCheckCur(SStreamState* pState, SWinKey* key); SStreamStateCur* streamStateSeekKeyNext(SStreamState* pState, const SWinKey* key); SStreamStateCur* streamStateFillSeekKeyNext(SStreamState* pState, const SWinKey* key); @@ -128,10 +135,6 @@ int sessionRangeKeyCmpr(const SSessionKey* pWin1, const SSessionKey* pWin2); int sessionWinKeyCmpr(const SSessionKey* pWin1, const SSessionKey* pWin2); int stateSessionKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2); int stateKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2); -#if 0 -char* streamStateSessionDump(SStreamState* pState); -char* streamStateIntervalDump(SStreamState* pState); -#endif #ifdef __cplusplus } diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index d6d89d1d30..64ce735843 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -50,21 +50,21 @@ extern "C" { (_t)->hTaskInfo.id.streamId = 0; \ } while (0) -#define STREAM_EXEC_T_EXTRACT_WAL_DATA (-1) -#define STREAM_EXEC_T_START_ALL_TASKS (-2) -#define STREAM_EXEC_T_START_ONE_TASK (-3) -#define STREAM_EXEC_T_RESTART_ALL_TASKS (-4) -#define STREAM_EXEC_T_STOP_ALL_TASKS (-5) -#define STREAM_EXEC_T_RESUME_TASK (-6) -#define STREAM_EXEC_T_UPDATE_TASK_EPSET (-7) +#define STREAM_EXEC_T_EXTRACT_WAL_DATA (-1) +#define STREAM_EXEC_T_START_ALL_TASKS (-2) +#define STREAM_EXEC_T_START_ONE_TASK (-3) +#define STREAM_EXEC_T_RESTART_ALL_TASKS (-4) +#define STREAM_EXEC_T_STOP_ALL_TASKS (-5) +#define STREAM_EXEC_T_RESUME_TASK (-6) +#define STREAM_EXEC_T_UPDATE_TASK_EPSET (-7) typedef struct SStreamTask SStreamTask; typedef struct SStreamQueue SStreamQueue; typedef struct SStreamTaskSM SStreamTaskSM; -#define SSTREAM_TASK_VER 3 -#define SSTREAM_TASK_INCOMPATIBLE_VER 1 -#define SSTREAM_TASK_NEED_CONVERT_VER 2 +#define SSTREAM_TASK_VER 3 +#define SSTREAM_TASK_INCOMPATIBLE_VER 1 +#define SSTREAM_TASK_NEED_CONVERT_VER 2 #define SSTREAM_TASK_SUBTABLE_CHANGED_VER 3 enum { @@ -405,8 +405,8 @@ typedef struct SHistoryTaskInfo { int32_t tickCount; int32_t retryTimes; int32_t waitInterval; - int64_t haltVer; // offset in wal when halt the stream task - bool operatorOpen; // false by default + int64_t haltVer; // offset in wal when halt the stream task + bool operatorOpen; // false by default } SHistoryTaskInfo; typedef struct STaskOutputInfo { @@ -463,21 +463,22 @@ struct SStreamTask { struct SStreamMeta* pMeta; SSHashObj* pNameMap; void* pBackend; - char reserve[256]; + int8_t subtableWithoutMd5; + char reserve[255]; }; typedef int32_t (*startComplete_fn_t)(struct SStreamMeta*); typedef struct STaskStartInfo { - int64_t startTs; - int64_t readyTs; - int32_t tasksWillRestart; - int32_t taskStarting; // restart flag, sentinel to guard the restart procedure. - SHashObj* pReadyTaskSet; // tasks that are all ready for running stream processing - SHashObj* pFailedTaskSet; // tasks that are done the check downstream process, may be successful or failed - int64_t elapsedTime; - int32_t restartCount; // restart task counter - startComplete_fn_t completeFn; // complete callback function + int64_t startTs; + int64_t readyTs; + int32_t tasksWillRestart; + int32_t taskStarting; // restart flag, sentinel to guard the restart procedure. + SHashObj* pReadyTaskSet; // tasks that are all ready for running stream processing + SHashObj* pFailedTaskSet; // tasks that are done the check downstream process, may be successful or failed + int64_t elapsedTime; + int32_t restartCount; // restart task counter + startComplete_fn_t completeFn; // complete callback function } STaskStartInfo; typedef struct STaskUpdateInfo { @@ -504,7 +505,7 @@ typedef struct SStreamMeta { int32_t vgId; int64_t stage; int32_t role; - bool sendMsgBeforeClosing; // send hb to mnode before close all tasks when switch to follower. + bool sendMsgBeforeClosing; // send hb to mnode before close all tasks when switch to follower. STaskStartInfo startInfo; TdThreadRwlock lock; SScanWalInfo scanInfo; @@ -532,7 +533,7 @@ int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo) int32_t tDecodeStreamEpInfo(SDecoder* pDecoder, SStreamChildEpInfo* pInfo); SStreamTask* tNewStreamTask(int64_t streamId, int8_t taskLevel, SEpSet* pEpset, bool fillHistory, int64_t triggerParam, - SArray* pTaskList, bool hasFillhistory); + SArray* pTaskList, bool hasFillhistory, int8_t subtableWithoutMd5); int32_t tEncodeStreamTask(SEncoder* pEncoder, const SStreamTask* pTask); int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask); void tFreeStreamTask(SStreamTask* pTask); @@ -656,7 +657,6 @@ int32_t tEncodeStreamCheckpointSourceReq(SEncoder* pEncoder, const SStreamCheckp int32_t tDecodeStreamCheckpointSourceReq(SDecoder* pDecoder, SStreamCheckpointSourceReq* pReq); int32_t tEncodeStreamCheckpointSourceRsp(SEncoder* pEncoder, const SStreamCheckpointSourceRsp* pRsp); -int32_t tDecodeStreamCheckpointSourceRsp(SDecoder* pDecoder, SStreamCheckpointSourceRsp* pRsp); typedef struct { SMsgHead msgHead; @@ -678,18 +678,18 @@ typedef struct STaskStatusEntry { int32_t statusLastDuration; // to record the last duration of current status int64_t stage; int32_t nodeId; - int64_t verStart; // start version in WAL, only valid for source task - int64_t verEnd; // end version in WAL, only valid for source task - int64_t processedVer; // only valid for source task - int64_t checkpointId; // current active checkpoint id - int32_t chkpointTransId; // checkpoint trans id - int8_t checkpointFailed; // denote if the checkpoint is failed or not - bool inputQChanging; // inputQ is changing or not + int64_t verStart; // start version in WAL, only valid for source task + int64_t verEnd; // end version in WAL, only valid for source task + int64_t processedVer; // only valid for source task + int64_t checkpointId; // current active checkpoint id + int32_t chkpointTransId; // checkpoint trans id + int8_t checkpointFailed; // denote if the checkpoint is failed or not + bool inputQChanging; // inputQ is changing or not int64_t inputQUnchangeCounter; - double inputQUsed; // in MiB + double inputQUsed; // in MiB double inputRate; - double sinkQuota; // existed quota size for sink task - double sinkDataSize; // sink to dst data size + double sinkQuota; // existed quota size for sink task + double sinkDataSize; // sink to dst data size } STaskStatusEntry; typedef struct SStreamHbMsg { @@ -720,23 +720,10 @@ int32_t tEncodeStreamTaskUpdateMsg(SEncoder* pEncoder, const SStreamTaskNodeUpda int32_t tDecodeStreamTaskUpdateMsg(SDecoder* pDecoder, SStreamTaskNodeUpdateMsg* pMsg); typedef struct SStreamTaskState { - ETaskStatus state; - char* name; + ETaskStatus state; + char* name; } SStreamTaskState; -typedef struct { - int64_t streamId; - int32_t downstreamTaskId; - int32_t taskId; -} SStreamRecoverDownstreamReq; - -typedef struct { - int64_t streamId; - int32_t downstreamTaskId; - int32_t taskId; - SArray* checkpointVer; // SArray -} SStreamRecoverDownstreamRsp; - int32_t tEncodeStreamTaskCheckReq(SEncoder* pEncoder, const SStreamTaskCheckReq* pReq); int32_t tDecodeStreamTaskCheckReq(SDecoder* pDecoder, SStreamTaskCheckReq* pReq); @@ -745,10 +732,12 @@ int32_t tDecodeStreamTaskCheckRsp(SDecoder* pDecoder, SStreamTaskCheckRsp* pRsp) int32_t tEncodeStreamDispatchReq(SEncoder* pEncoder, const SStreamDispatchReq* pReq); int32_t tDecodeStreamDispatchReq(SDecoder* pDecoder, SStreamDispatchReq* pReq); - -int32_t tDecodeStreamRetrieveReq(SDecoder* pDecoder, SStreamRetrieveReq* pReq); void tDeleteStreamDispatchReq(SStreamDispatchReq* pReq); +int32_t tEncodeStreamRetrieveReq(SEncoder* pEncoder, const SStreamRetrieveReq* pReq); +int32_t tDecodeStreamRetrieveReq(SDecoder* pDecoder, SStreamRetrieveReq* pReq); +void tDeleteStreamRetrieveReq(SStreamRetrieveReq* pReq); + typedef struct SStreamTaskCheckpointReq { int64_t streamId; int32_t taskId; @@ -787,21 +776,19 @@ void initRpcMsg(SRpcMsg* pMsg, int32_t msgType, void* pCont, int32_t contLen); // recover and fill history void streamTaskCheckDownstream(SStreamTask* pTask); -int32_t streamTaskCheckStatus(SStreamTask* pTask, int32_t upstreamTaskId, int32_t vgId, int64_t stage, - int64_t* oldStage); +int32_t streamTaskCheckStatus(SStreamTask* pTask, int32_t upstreamId, int32_t vgId, int64_t stage, int64_t* oldStage); int32_t streamTaskUpdateEpsetInfo(SStreamTask* pTask, SArray* pNodeList); void streamTaskResetUpstreamStageInfo(SStreamTask* pTask); bool streamTaskIsAllUpstreamClosed(SStreamTask* pTask); bool streamTaskSetSchedStatusWait(SStreamTask* pTask); int8_t streamTaskSetSchedStatusActive(SStreamTask* pTask); int8_t streamTaskSetSchedStatusInactive(SStreamTask* pTask); -int32_t streamTaskClearHTaskAttr(SStreamTask* pTask, bool metaLock); +int32_t streamTaskClearHTaskAttr(SStreamTask* pTask, int32_t clearRelHalt, bool metaLock); int32_t streamTaskHandleEvent(SStreamTaskSM* pSM, EStreamTaskEvent event); int32_t streamTaskOnHandleEventSuccess(SStreamTaskSM* pSM, EStreamTaskEvent event); void streamTaskRestoreStatus(SStreamTask* pTask); -int32_t streamTaskStop(SStreamTask* pTask); int32_t streamSendCheckRsp(const SStreamMeta* pMeta, const SStreamTaskCheckReq* pReq, SStreamTaskCheckRsp* pRsp, SRpcHandleInfo* pRpcInfo, int32_t taskId); int32_t streamProcessCheckRsp(SStreamTask* pTask, const SStreamTaskCheckRsp* pRsp); @@ -813,9 +800,9 @@ bool streamHistoryTaskSetVerRangeStep2(SStreamTask* pTask, int64_t latestVer) int32_t streamQueueGetNumOfItems(const SStreamQueue* pQueue); // common -int32_t streamRestoreParam(SStreamTask* pTask); void streamTaskPause(SStreamMeta* pMeta, SStreamTask* pTask); void streamTaskResume(SStreamTask* pTask); +int32_t streamTaskStop(SStreamTask* pTask); int32_t streamTaskSetUpstreamInfo(SStreamTask* pTask, const SStreamTask* pUpstreamTask); void streamTaskUpdateUpstreamInfo(SStreamTask* pTask, int32_t nodeId, const SEpSet* pEpSet); void streamTaskUpdateDownstreamInfo(SStreamTask* pTask, int32_t nodeId, const SEpSet* pEpSet); @@ -839,7 +826,8 @@ SScanhistoryDataInfo streamScanHistoryData(SStreamTask* pTask, int64_t st); // stream task meta void streamMetaInit(); void streamMetaCleanup(); -SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandFunc, int32_t vgId, int64_t stage, startComplete_fn_t fn); +SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskExpand expandFunc, int32_t vgId, int64_t stage, + startComplete_fn_t fn); void streamMetaClose(SStreamMeta* streamMeta); int32_t streamMetaSaveTask(SStreamMeta* pMeta, SStreamTask* pTask); // save to stream meta store int32_t streamMetaRemoveTask(SStreamMeta* pMeta, STaskId* pKey); @@ -858,22 +846,22 @@ void streamMetaNotifyClose(SStreamMeta* pMeta); void streamMetaStartHb(SStreamMeta* pMeta); bool streamMetaTaskInTimer(SStreamMeta* pMeta); int32_t streamMetaAddTaskLaunchResult(SStreamMeta* pMeta, int64_t streamId, int32_t taskId, int64_t startTs, - int64_t endTs, bool ready); + int64_t endTs, bool ready); int32_t streamMetaResetTaskStatus(SStreamMeta* pMeta); -void streamMetaRLock(SStreamMeta* pMeta); -void streamMetaRUnLock(SStreamMeta* pMeta); -void streamMetaWLock(SStreamMeta* pMeta); -void streamMetaWUnLock(SStreamMeta* pMeta); -void streamMetaResetStartInfo(STaskStartInfo* pMeta); -SArray* streamMetaSendMsgBeforeCloseTasks(SStreamMeta* pMeta); -void streamMetaUpdateStageRole(SStreamMeta* pMeta, int64_t stage, bool isLeader); -int32_t streamMetaLoadAllTasks(SStreamMeta* pMeta); -int32_t streamMetaStartAllTasks(SStreamMeta* pMeta); -int32_t streamMetaStopAllTasks(SStreamMeta* pMeta); -int32_t streamMetaStartOneTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId); -bool streamMetaAllTasksReady(const SStreamMeta* pMeta); -tmr_h streamTimerGetInstance(); +void streamMetaRLock(SStreamMeta* pMeta); +void streamMetaRUnLock(SStreamMeta* pMeta); +void streamMetaWLock(SStreamMeta* pMeta); +void streamMetaWUnLock(SStreamMeta* pMeta); +void streamMetaResetStartInfo(STaskStartInfo* pMeta); +SArray* streamMetaSendMsgBeforeCloseTasks(SStreamMeta* pMeta); +void streamMetaUpdateStageRole(SStreamMeta* pMeta, int64_t stage, bool isLeader); +int32_t streamMetaLoadAllTasks(SStreamMeta* pMeta); +int32_t streamMetaStartAllTasks(SStreamMeta* pMeta); +int32_t streamMetaStopAllTasks(SStreamMeta* pMeta); +int32_t streamMetaStartOneTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId); +bool streamMetaAllTasksReady(const SStreamMeta* pMeta); +tmr_h streamTimerGetInstance(); // checkpoint int32_t streamProcessCheckpointSourceReq(SStreamTask* pTask, SStreamCheckpointSourceReq* pReq); @@ -881,7 +869,7 @@ int32_t streamProcessCheckpointReadyMsg(SStreamTask* pTask); int32_t streamTaskBuildCheckpoint(SStreamTask* pTask); void streamTaskClearCheckInfo(SStreamTask* pTask, bool clearChkpReadyMsg); int32_t streamAlignTransferState(SStreamTask* pTask); -int32_t streamBuildAndSendDropTaskMsg(SMsgCb* pMsgCb, int32_t vgId, SStreamTaskId* pTaskId); +int32_t streamBuildAndSendDropTaskMsg(SMsgCb* pMsgCb, int32_t vgId, SStreamTaskId* pTaskId, int64_t resetRelHalt); int32_t streamAddCheckpointSourceRspMsg(SStreamCheckpointSourceReq* pReq, SRpcHandleInfo* pRpcInfo, SStreamTask* pTask, int8_t isSucceed); int32_t buildCheckpointSourceRsp(SStreamCheckpointSourceReq* pReq, SRpcHandleInfo* pRpcInfo, SRpcMsg* pMsg, @@ -892,6 +880,7 @@ void* streamDestroyStateMachine(SStreamTaskSM* pSM); int32_t broadcastRetrieveMsg(SStreamTask* pTask, SStreamRetrieveReq *req); void sendRetrieveRsp(SStreamRetrieveReq *pReq, SRpcMsg* pRsp); + #ifdef __cplusplus } #endif diff --git a/include/libs/stream/tstreamFileState.h b/include/libs/stream/tstreamFileState.h index 2a129c1830..a9a198d194 100644 --- a/include/libs/stream/tstreamFileState.h +++ b/include/libs/stream/tstreamFileState.h @@ -41,6 +41,8 @@ typedef int32_t (*_state_file_remove_fn)(SStreamFileState* pFileState, const voi typedef int32_t (*_state_file_get_fn)(SStreamFileState* pFileState, void* pKey, void* data, int32_t* pDataLen); typedef int32_t (*_state_file_clear_fn)(SStreamState* pState); +typedef int32_t (*range_cmpr_fn)(const SSessionKey* pWin1, const SSessionKey* pWin2); + SStreamFileState* streamFileStateInit(int64_t memSize, uint32_t keySize, uint32_t rowSize, uint32_t selectRowSize, GetTsFun fp, void* pFile, TSKEY delMark, const char* taskId, int64_t checkpointId, int8_t type); @@ -90,14 +92,19 @@ void sessionWinStateCleanup(void* pBuff); SStreamStateCur* sessionWinStateSeekKeyCurrentPrev(SStreamFileState* pFileState, const SSessionKey* pWinKey); SStreamStateCur* sessionWinStateSeekKeyCurrentNext(SStreamFileState* pFileState, const SSessionKey* pWinKey); SStreamStateCur* sessionWinStateSeekKeyNext(SStreamFileState* pFileState, const SSessionKey* pWinKey); +SStreamStateCur* countWinStateSeekKeyPrev(SStreamFileState* pFileState, const SSessionKey* pWinKey, COUNT_TYPE count); int32_t sessionWinStateGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen); int32_t sessionWinStateMoveToNext(SStreamStateCur* pCur); -int32_t sessionWinStateGetKeyByRange(SStreamFileState* pFileState, const SSessionKey* key, SSessionKey* curKey); +int32_t sessionWinStateGetKeyByRange(SStreamFileState* pFileState, const SSessionKey* key, SSessionKey* curKey, range_cmpr_fn cmpFn); // state window int32_t getStateWinResultBuff(SStreamFileState* pFileState, SSessionKey* key, char* pKeyData, int32_t keyDataLen, state_key_cmpr_fn fn, void** pVal, int32_t* pVLen); +// count window +int32_t getCountWinResultBuff(SStreamFileState* pFileState, SSessionKey* pKey, COUNT_TYPE winCount, void** pVal, int32_t* pVLen); +int32_t createCountWinResultBuff(SStreamFileState* pFileState, SSessionKey* pKey, void** pVal, int32_t* pVLen); + #ifdef __cplusplus } #endif diff --git a/include/os/osFile.h b/include/os/osFile.h index 4d760a791f..eb0862a719 100644 --- a/include/os/osFile.h +++ b/include/os/osFile.h @@ -119,6 +119,8 @@ int32_t taosSetFileHandlesLimit(); int32_t taosLinkFile(char *src, char *dst); +bool lastErrorIsFileNotExist(); + #ifdef __cplusplus } #endif diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index d3d8ee1dc1..971ed407f9 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -2121,6 +2121,9 @@ int32_t setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32 pStart += colLength[i]; } + // bool blankFill = *(bool*)p; + p += sizeof(bool); + if (convertUcs4) { code = doConvertUCS4(pResultInfo, numOfRows, numOfCols, colLength); } diff --git a/source/client/src/clientRawBlockWrite.c b/source/client/src/clientRawBlockWrite.c index 1ea3eaf219..448243cc3d 100644 --- a/source/client/src/clientRawBlockWrite.c +++ b/source/client/src/clientRawBlockWrite.c @@ -21,8 +21,8 @@ #include "tglobal.h" #include "tmsgtype.h" -#define LOG_ID_TAG "connId:0x%"PRIx64",reqId:0x%"PRIx64 -#define LOG_ID_VALUE *(int64_t*)taos,pRequest->requestId +#define LOG_ID_TAG "connId:0x%" PRIx64 ",reqId:0x%" PRIx64 +#define LOG_ID_VALUE *(int64_t*)taos, pRequest->requestId static tb_uid_t processSuid(tb_uid_t suid, char* db) { return suid + MurmurHash3_32(db, strlen(db)); } @@ -31,8 +31,7 @@ static char* buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* sch char* string = NULL; cJSON* json = cJSON_CreateObject(); if (json == NULL) { - uError("create json object failed") - return NULL; + uError("create json object failed") return NULL; } cJSON* type = cJSON_CreateString("create"); cJSON_AddItemToObject(json, "type", type); @@ -56,7 +55,7 @@ static char* buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* sch cJSON_AddItemToObject(column, "name", cname); cJSON* ctype = cJSON_CreateNumber(s->type); cJSON_AddItemToObject(column, "type", ctype); - if (s->type == TSDB_DATA_TYPE_BINARY || s->type == TSDB_DATA_TYPE_VARBINARY|| s->type == TSDB_DATA_TYPE_GEOMETRY) { + if (s->type == TSDB_DATA_TYPE_BINARY || s->type == TSDB_DATA_TYPE_VARBINARY || s->type == TSDB_DATA_TYPE_GEOMETRY) { int32_t length = s->bytes - VARSTR_HEADER_SIZE; cJSON* cbytes = cJSON_CreateNumber(length); cJSON_AddItemToObject(column, "length", cbytes); @@ -131,7 +130,8 @@ static char* buildAlterSTableJson(void* alterData, int32_t alterDataLen) { cJSON* colType = cJSON_CreateNumber(field->type); cJSON_AddItemToObject(json, "colType", colType); - if (field->type == TSDB_DATA_TYPE_BINARY || field->type == TSDB_DATA_TYPE_VARBINARY || field->type == TSDB_DATA_TYPE_GEOMETRY) { + if (field->type == TSDB_DATA_TYPE_BINARY || field->type == TSDB_DATA_TYPE_VARBINARY || + field->type == TSDB_DATA_TYPE_GEOMETRY) { int32_t length = field->bytes - VARSTR_HEADER_SIZE; cJSON* cbytes = cJSON_CreateNumber(length); cJSON_AddItemToObject(json, "colLength", cbytes); @@ -156,7 +156,8 @@ static char* buildAlterSTableJson(void* alterData, int32_t alterDataLen) { cJSON_AddItemToObject(json, "colName", colName); cJSON* colType = cJSON_CreateNumber(field->type); cJSON_AddItemToObject(json, "colType", colType); - if (field->type == TSDB_DATA_TYPE_BINARY || field->type == TSDB_DATA_TYPE_VARBINARY || field->type == TSDB_DATA_TYPE_GEOMETRY) { + if (field->type == TSDB_DATA_TYPE_BINARY || field->type == TSDB_DATA_TYPE_VARBINARY || + field->type == TSDB_DATA_TYPE_GEOMETRY) { int32_t length = field->bytes - VARSTR_HEADER_SIZE; cJSON* cbytes = cJSON_CreateNumber(length); cJSON_AddItemToObject(json, "colLength", cbytes); @@ -182,7 +183,7 @@ static char* buildAlterSTableJson(void* alterData, int32_t alterDataLen) { } string = cJSON_PrintUnformatted(json); - end: +end: cJSON_Delete(json); tFreeSMAltertbReq(&req); return string; @@ -295,9 +296,9 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) { cJSON* tvalue = NULL; if (IS_VAR_DATA_TYPE(pTagVal->type)) { char* buf = NULL; - if(pTagVal->type == TSDB_DATA_TYPE_VARBINARY){ - buf = taosMemoryCalloc(pTagVal->nData*2 + 2 + 3, 1); - }else{ + if (pTagVal->type == TSDB_DATA_TYPE_VARBINARY) { + buf = taosMemoryCalloc(pTagVal->nData * 2 + 2 + 3, 1); + } else { buf = taosMemoryCalloc(pTagVal->nData + 3, 1); } @@ -315,7 +316,7 @@ static void buildChildElement(cJSON* json, SVCreateTbReq* pCreateReq) { cJSON_AddItemToArray(tags, tag); } - end: +end: cJSON_AddItemToObject(json, "tags", tags); taosArrayDestroy(pTagVals); } @@ -469,7 +470,8 @@ static char* processAlterTable(SMqMetaRsp* metaRsp) { cJSON* colType = cJSON_CreateNumber(vAlterTbReq.type); cJSON_AddItemToObject(json, "colType", colType); - if (vAlterTbReq.type == TSDB_DATA_TYPE_BINARY || vAlterTbReq.type == TSDB_DATA_TYPE_VARBINARY || vAlterTbReq.type == TSDB_DATA_TYPE_GEOMETRY) { + if (vAlterTbReq.type == TSDB_DATA_TYPE_BINARY || vAlterTbReq.type == TSDB_DATA_TYPE_VARBINARY || + vAlterTbReq.type == TSDB_DATA_TYPE_GEOMETRY) { int32_t length = vAlterTbReq.bytes - VARSTR_HEADER_SIZE; cJSON* cbytes = cJSON_CreateNumber(length); cJSON_AddItemToObject(json, "colLength", cbytes); @@ -490,7 +492,8 @@ static char* processAlterTable(SMqMetaRsp* metaRsp) { cJSON_AddItemToObject(json, "colName", colName); cJSON* colType = cJSON_CreateNumber(vAlterTbReq.colModType); cJSON_AddItemToObject(json, "colType", colType); - if (vAlterTbReq.colModType == TSDB_DATA_TYPE_BINARY || vAlterTbReq.colModType == TSDB_DATA_TYPE_VARBINARY || vAlterTbReq.colModType == TSDB_DATA_TYPE_GEOMETRY) { + if (vAlterTbReq.colModType == TSDB_DATA_TYPE_BINARY || vAlterTbReq.colModType == TSDB_DATA_TYPE_VARBINARY || + vAlterTbReq.colModType == TSDB_DATA_TYPE_GEOMETRY) { int32_t length = vAlterTbReq.colModBytes - VARSTR_HEADER_SIZE; cJSON* cbytes = cJSON_CreateNumber(length); cJSON_AddItemToObject(json, "colLength", cbytes); @@ -527,9 +530,9 @@ static char* processAlterTable(SMqMetaRsp* metaRsp) { } buf = parseTagDatatoJson(vAlterTbReq.pTagVal); } else { - if(vAlterTbReq.tagType == TSDB_DATA_TYPE_VARBINARY){ - buf = taosMemoryCalloc(vAlterTbReq.nTagVal*2 + 2 + 3, 1); - }else{ + if (vAlterTbReq.tagType == TSDB_DATA_TYPE_VARBINARY) { + buf = taosMemoryCalloc(vAlterTbReq.nTagVal * 2 + 2 + 3, 1); + } else { buf = taosMemoryCalloc(vAlterTbReq.nTagVal + 3, 1); } dataConverToStr(buf, vAlterTbReq.tagType, vAlterTbReq.pTagVal, vAlterTbReq.nTagVal, NULL); @@ -677,7 +680,7 @@ _exit: } static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) { - if(taos == NULL || meta == NULL) { + if (taos == NULL || meta == NULL) { terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -692,7 +695,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) { terrno = code; return code; } - uDebug(LOG_ID_TAG" create stable, meta:%p, metaLen:%d", LOG_ID_VALUE, meta, metaLen); + uDebug(LOG_ID_TAG " create stable, meta:%p, metaLen:%d", LOG_ID_VALUE, meta, metaLen); pRequest->syncQuery = true; if (!pRequest->pDb) { code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; @@ -731,8 +734,8 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) { pReq.source = TD_REQ_FROM_TAOX; pReq.igExists = true; - uDebug(LOG_ID_TAG" create stable name:%s suid:%" PRId64 " processSuid:%" PRId64, - LOG_ID_VALUE, req.name, req.suid, pReq.suid); + uDebug(LOG_ID_TAG " create stable name:%s suid:%" PRId64 " processSuid:%" PRId64, LOG_ID_VALUE, req.name, req.suid, + pReq.suid); STscObj* pTscObj = pRequest->pTscObj; SName tableName; tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name); @@ -766,7 +769,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) { taosMemoryFree(pCmdMsg.pMsg); end: - uDebug(LOG_ID_TAG" create stable return, msg:%s", LOG_ID_VALUE, tstrerror(code)); + uDebug(LOG_ID_TAG " create stable return, msg:%s", LOG_ID_VALUE, tstrerror(code)); destroyRequest(pRequest); tFreeSMCreateStbReq(&pReq); tDecoderClear(&coder); @@ -775,7 +778,7 @@ end: } static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) { - if(taos == NULL || meta == NULL) { + if (taos == NULL || meta == NULL) { terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -791,7 +794,7 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) { return code; } - uDebug(LOG_ID_TAG" drop stable, meta:%p, metaLen:%d", LOG_ID_VALUE, meta, metaLen); + uDebug(LOG_ID_TAG " drop stable, meta:%p, metaLen:%d", LOG_ID_VALUE, meta, metaLen); pRequest->syncQuery = true; if (!pRequest->pDb) { code = TSDB_CODE_PAR_DB_NOT_SPECIFIED; @@ -812,9 +815,9 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) { goto end; } SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter, - .requestId = pRequest->requestId, - .requestObjRefId = pRequest->self, - .mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp)}; + .requestId = pRequest->requestId, + .requestObjRefId = pRequest->self, + .mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp)}; SName pName = {0}; toName(pRequest->pTscObj->acctId, pRequest->pDb, req.name, &pName); STableMeta* pTableMeta = NULL; @@ -835,8 +838,8 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) { pReq.source = TD_REQ_FROM_TAOX; // pReq.suid = processSuid(req.suid, pRequest->pDb); - uDebug(LOG_ID_TAG" drop stable name:%s suid:%" PRId64 " new suid:%" PRId64, - LOG_ID_VALUE, req.name, req.suid, pReq.suid); + uDebug(LOG_ID_TAG " drop stable name:%s suid:%" PRId64 " new suid:%" PRId64, LOG_ID_VALUE, req.name, req.suid, + pReq.suid); STscObj* pTscObj = pRequest->pTscObj; SName tableName = {0}; tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name); @@ -870,7 +873,7 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) { taosMemoryFree(pCmdMsg.pMsg); end: - uDebug(LOG_ID_TAG" drop stable return, msg:%s", LOG_ID_VALUE, tstrerror(code)); + uDebug(LOG_ID_TAG " drop stable return, msg:%s", LOG_ID_VALUE, tstrerror(code)); destroyRequest(pRequest); tDecoderClear(&coder); terrno = code; @@ -889,7 +892,7 @@ static void destroyCreateTbReqBatch(void* data) { } static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { - if(taos == NULL || meta == NULL) { + if (taos == NULL || meta == NULL) { terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -939,9 +942,9 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { taosHashSetFreeFp(pVgroupHashmap, destroyCreateTbReqBatch); SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter, - .requestId = pRequest->requestId, - .requestObjRefId = pRequest->self, - .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; + .requestId = pRequest->requestId, + .requestObjRefId = pRequest->self, + .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; pRequest->tableList = taosArrayInit(req.nReqs, sizeof(SName)); // loop to create table @@ -1033,7 +1036,7 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { code = pRequest->code; end: - uDebug(LOG_ID_TAG" create table return, msg:%s", LOG_ID_VALUE, tstrerror(code)); + uDebug(LOG_ID_TAG " create table return, msg:%s", LOG_ID_VALUE, tstrerror(code)); for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { pCreateReq = req.pReqs + iReq; taosMemoryFreeClear(pCreateReq->comment); @@ -1062,7 +1065,7 @@ static void destroyDropTbReqBatch(void* data) { } static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) { - if(taos == NULL || meta == NULL) { + if (taos == NULL || meta == NULL) { terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -1111,9 +1114,9 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) { taosHashSetFreeFp(pVgroupHashmap, destroyDropTbReqBatch); SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter, - .requestId = pRequest->requestId, - .requestObjRefId = pRequest->self, - .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; + .requestId = pRequest->requestId, + .requestObjRefId = pRequest->self, + .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; pRequest->tableList = taosArrayInit(req.nReqs, sizeof(SName)); // loop to create table for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { @@ -1142,7 +1145,8 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) { tb_uid_t oldSuid = pDropReq->suid; pDropReq->suid = pTableMeta->suid; taosMemoryFreeClear(pTableMeta); - uDebug(LOG_ID_TAG" drop table name:%s suid:%" PRId64 " new suid:%" PRId64, LOG_ID_VALUE, pDropReq->name, oldSuid, pDropReq->suid); + uDebug(LOG_ID_TAG " drop table name:%s suid:%" PRId64 " new suid:%" PRId64, LOG_ID_VALUE, pDropReq->name, oldSuid, + pDropReq->suid); taosArrayPush(pRequest->tableList, &pName); SVgroupDropTableBatch* pTableBatch = taosHashGet(pVgroupHashmap, &pInfo.vgId, sizeof(pInfo.vgId)); @@ -1185,7 +1189,7 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) { code = pRequest->code; end: - uDebug(LOG_ID_TAG" drop table return, msg:%s", LOG_ID_VALUE, tstrerror(code)); + uDebug(LOG_ID_TAG " drop table return, msg:%s", LOG_ID_VALUE, tstrerror(code)); taosHashCleanup(pVgroupHashmap); destroyRequest(pRequest); tDecoderClear(&coder); @@ -1227,16 +1231,16 @@ end: //} static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) { - if(taos == NULL || meta == NULL) { + if (taos == NULL || meta == NULL) { terrno = TSDB_CODE_INVALID_PARA; return terrno; } - SDeleteRes req = {0}; - SDecoder coder = {0}; + SDeleteRes req = {0}; + SDecoder coder = {0}; char sql[256] = {0}; int32_t code = TSDB_CODE_SUCCESS; - uDebug("connId:0x%"PRIx64" delete data, meta:%p, len:%d", *(int64_t*)taos, meta, metaLen); + uDebug("connId:0x%" PRIx64 " delete data, meta:%p, len:%d", *(int64_t*)taos, meta, metaLen); // decode and process req void* data = POINTER_SHIFT(meta, sizeof(SMsgHead)); @@ -1260,14 +1264,14 @@ static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) { taos_free_result(res); end: - uDebug("connId:0x%"PRIx64" delete data sql:%s, code:%s", *(int64_t*)taos, sql, tstrerror(code)); + uDebug("connId:0x%" PRIx64 " delete data sql:%s, code:%s", *(int64_t*)taos, sql, tstrerror(code)); tDecoderClear(&coder); terrno = code; return code; } static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) { - if(taos == NULL || meta == NULL) { + if (taos == NULL || meta == NULL) { terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -1312,9 +1316,9 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) { } SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter, - .requestId = pRequest->requestId, - .requestObjRefId = pRequest->self, - .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; + .requestId = pRequest->requestId, + .requestObjRefId = pRequest->self, + .mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)}; SVgroupInfo pInfo = {0}; SName pName = {0}; @@ -1394,8 +1398,8 @@ int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const ch return taos_write_raw_block_with_fields_with_reqid(taos, rows, pData, tbname, fields, numFields, 0); } -int taos_write_raw_block_with_fields_with_reqid(TAOS *taos, int rows, char *pData, const char *tbname, - TAOS_FIELD *fields, int numFields, int64_t reqid){ +int taos_write_raw_block_with_fields_with_reqid(TAOS* taos, int rows, char* pData, const char* tbname, + TAOS_FIELD* fields, int numFields, int64_t reqid) { if (!taos || !pData || !tbname) { terrno = TSDB_CODE_INVALID_PARA; return terrno; @@ -1410,8 +1414,8 @@ int taos_write_raw_block_with_fields_with_reqid(TAOS *taos, int rows, char *pDat return terrno; } - uDebug(LOG_ID_TAG " write raw block with field, rows:%d, pData:%p, tbname:%s, fields:%p, numFields:%d", - LOG_ID_VALUE, rows, pData, tbname, fields, numFields); + uDebug(LOG_ID_TAG " write raw block with field, rows:%d, pData:%p, tbname:%s, fields:%p, numFields:%d", LOG_ID_VALUE, + rows, pData, tbname, fields, numFields); pRequest->syncQuery = true; if (!pRequest->pDb) { @@ -1562,12 +1566,12 @@ end: return code; } -static void* getRawDataFromRes(void *pRetrieve){ +static void* getRawDataFromRes(void* pRetrieve) { void* rawData = NULL; // deal with compatibility - if(*(int64_t*)pRetrieve == 0){ + if (*(int64_t*)pRetrieve == 0) { rawData = ((SRetrieveTableRsp*)pRetrieve)->data; - }else if(*(int64_t*)pRetrieve == 1){ + } else if (*(int64_t*)pRetrieve == 1) { rawData = ((SRetrieveTableRspForTmq*)pRetrieve)->data; } ASSERT(rawData != NULL); @@ -1575,7 +1579,7 @@ static void* getRawDataFromRes(void *pRetrieve){ } static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { - if(taos == NULL || data == NULL){ + if (taos == NULL || data == NULL) { terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -1644,11 +1648,11 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { strcpy(pName.tname, tbName); code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta); -// if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) { -// uError("WriteRaw:catalogGetTableMeta table not exist. table name: %s", tbName); -// code = TSDB_CODE_SUCCESS; -// continue; -// } + // if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) { + // uError("WriteRaw:catalogGetTableMeta table not exist. table name: %s", tbName); + // code = TSDB_CODE_SUCCESS; + // continue; + // } if (code != TSDB_CODE_SUCCESS) { goto end; } @@ -1704,7 +1708,7 @@ end: } static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) { - if(taos == NULL || data == NULL){ + if (taos == NULL || data == NULL) { terrno = TSDB_CODE_INVALID_PARA; return terrno; } @@ -1757,7 +1761,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) } pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); - uDebug(LOG_ID_TAG" write raw metadata block num:%d", LOG_ID_VALUE, rspObj.rsp.blockNum); + uDebug(LOG_ID_TAG " write raw metadata block num:%d", LOG_ID_VALUE, rspObj.rsp.blockNum); while (++rspObj.resIter < rspObj.rsp.blockNum) { void* pRetrieve = taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter); if (!rspObj.rsp.withSchema) { @@ -1770,7 +1774,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) goto end; } - uDebug(LOG_ID_TAG" write raw metadata block tbname:%s", LOG_ID_VALUE, tbName); + uDebug(LOG_ID_TAG " write raw metadata block tbname:%s", LOG_ID_VALUE, tbName); SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}}; strcpy(pName.dbname, pRequest->pDb); strcpy(pName.tname, tbName); @@ -1817,11 +1821,11 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) strcpy(pName.tname, pCreateReqDst->ctb.stbName); } code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta); -// if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) { -// uError("WriteRaw:catalogGetTableMeta table not exist. table name: %s", tbName); -// code = TSDB_CODE_SUCCESS; -// continue; -// } + // if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) { + // uError("WriteRaw:catalogGetTableMeta table not exist. table name: %s", tbName); + // code = TSDB_CODE_SUCCESS; + // continue; + // } if (code != TSDB_CODE_SUCCESS) { goto end; } diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index 3c3aee3032..1904874a0b 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -26,7 +26,7 @@ #define EMPTY_BLOCK_POLL_IDLE_DURATION 10 #define DEFAULT_AUTO_COMMIT_INTERVAL 5000 -#define DEFAULT_HEARTBEAT_INTERVAL 3000 +#define DEFAULT_HEARTBEAT_INTERVAL 3000 struct SMqMgmt { int8_t inited; @@ -63,7 +63,7 @@ struct tmq_conf_t { int8_t withTbName; int8_t snapEnable; int8_t replayEnable; - int8_t sourceExcluded; // do not consume, bit + int8_t sourceExcluded; // do not consume, bit uint16_t port; int32_t autoCommitInterval; char* ip; @@ -83,15 +83,15 @@ struct tmq_t { int32_t autoCommitInterval; int8_t resetOffsetCfg; int8_t replayEnable; - int8_t sourceExcluded; // do not consume, bit + int8_t sourceExcluded; // do not consume, bit uint64_t consumerId; tmq_commit_cb* commitCb; void* commitCbUserParam; // status - SRWLatch lock; - int8_t status; - int32_t epoch; + SRWLatch lock; + int8_t status; + int32_t epoch; // poll info int64_t pollCnt; int64_t totalRows; @@ -132,8 +132,8 @@ enum { typedef struct SVgOffsetInfo { STqOffsetVal committedOffset; - STqOffsetVal endOffset; // the last version in TAOS_RES + 1 - STqOffsetVal beginOffset; // the first version in TAOS_RES + STqOffsetVal endOffset; // the last version in TAOS_RES + 1 + STqOffsetVal beginOffset; // the first version in TAOS_RES int64_t walVerBegin; int64_t walVerEnd; } SVgOffsetInfo; @@ -144,11 +144,11 @@ typedef struct { SVgOffsetInfo offsetInfo; int32_t vgId; int32_t vgStatus; - int32_t vgSkipCnt; // here used to mark the slow vgroups - int64_t emptyBlockReceiveTs; // once empty block is received, idle for ignoreCnt then start to poll data - int64_t blockReceiveTs; // once empty block is received, idle for ignoreCnt then start to poll data - int64_t blockSleepForReplay; // once empty block is received, idle for ignoreCnt then start to poll data - bool seekUpdated; // offset is updated by seek operator, therefore, not update by vnode rsp. + int32_t vgSkipCnt; // here used to mark the slow vgroups + int64_t emptyBlockReceiveTs; // once empty block is received, idle for ignoreCnt then start to poll data + int64_t blockReceiveTs; // once empty block is received, idle for ignoreCnt then start to poll data + int64_t blockSleepForReplay; // once empty block is received, idle for ignoreCnt then start to poll data + bool seekUpdated; // offset is updated by seek operator, therefore, not update by vnode rsp. SEpSet epSet; } SMqClientVg; @@ -178,23 +178,23 @@ typedef struct { } SMqPollRspWrapper; typedef struct { -// int64_t refId; -// int32_t epoch; + // int64_t refId; + // int32_t epoch; tsem_t rspSem; int32_t rspErr; } SMqSubscribeCbParam; typedef struct { - int64_t refId; - bool sync; - void* pParam; + int64_t refId; + bool sync; + void* pParam; } SMqAskEpCbParam; typedef struct { - int64_t refId; - char topicName[TSDB_TOPIC_FNAME_LEN]; - int32_t vgId; - uint64_t requestId; // request id for debug purpose + int64_t refId; + char topicName[TSDB_TOPIC_FNAME_LEN]; + int32_t vgId; + uint64_t requestId; // request id for debug purpose } SMqPollCbParam; typedef struct SMqVgCommon { @@ -208,14 +208,14 @@ typedef struct SMqVgCommon { } SMqVgCommon; typedef struct SMqSeekParam { - tsem_t sem; - int32_t code; + tsem_t sem; + int32_t code; } SMqSeekParam; typedef struct SMqCommittedParam { - tsem_t sem; - int32_t code; - SMqVgOffset vgOffset; + tsem_t sem; + int32_t code; + SMqVgOffset vgOffset; } SMqCommittedParam; typedef struct SMqVgWalInfoParam { @@ -238,10 +238,10 @@ typedef struct { typedef struct { SMqCommitCbParamSet* params; -// SMqVgOffset* pOffset; - char topicName[TSDB_TOPIC_FNAME_LEN]; - int32_t vgId; - tmq_t* pTmq; + // SMqVgOffset* pOffset; + char topicName[TSDB_TOPIC_FNAME_LEN]; + int32_t vgId; + tmq_t* pTmq; } SMqCommitCbParam; typedef struct SSyncCommitInfo { @@ -252,7 +252,8 @@ typedef struct SSyncCommitInfo { static int32_t syncAskEp(tmq_t* tmq); static int32_t makeTopicVgroupKey(char* dst, const char* topicName, int32_t vg); static int32_t tmqCommitDone(SMqCommitCbParamSet* pParamSet); -static int32_t doSendCommitMsg(tmq_t* tmq, int32_t vgId, SEpSet* epSet, STqOffsetVal* offset, const char* pTopicName, SMqCommitCbParamSet* pParamSet); +static int32_t doSendCommitMsg(tmq_t* tmq, int32_t vgId, SEpSet* epSet, STqOffsetVal* offset, const char* pTopicName, + SMqCommitCbParamSet* pParamSet); static void commitRspCountDown(SMqCommitCbParamSet* pParamSet, int64_t consumerId, const char* pTopic, int32_t vgId); static void askEp(tmq_t* pTmq, void* param, bool sync, bool updateEpset); @@ -287,7 +288,7 @@ void tmq_conf_destroy(tmq_conf_t* conf) { } tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value) { - if (conf == NULL || key == NULL || value == NULL){ + if (conf == NULL || key == NULL || value == NULL) { return TMQ_CONF_INVALID; } if (strcasecmp(key, "group.id") == 0) { @@ -402,7 +403,7 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value tmq_list_t* tmq_list_new() { return (tmq_list_t*)taosArrayInit(0, sizeof(void*)); } int32_t tmq_list_append(tmq_list_t* list, const char* src) { - if(list == NULL) return -1; + if (list == NULL) return -1; SArray* container = &list->container; if (src == NULL || src[0] == 0) return -1; char* topic = taosStrdup(src); @@ -411,19 +412,19 @@ int32_t tmq_list_append(tmq_list_t* list, const char* src) { } void tmq_list_destroy(tmq_list_t* list) { - if(list == NULL) return; + if (list == NULL) return; SArray* container = &list->container; taosArrayDestroyP(container, taosMemoryFree); } int32_t tmq_list_get_size(const tmq_list_t* list) { - if(list == NULL) return -1; + if (list == NULL) return -1; const SArray* container = &list->container; return taosArrayGetSize(container); } char** tmq_list_to_c_array(const tmq_list_t* list) { - if(list == NULL) return NULL; + if (list == NULL) return NULL; const SArray* container = &list->container; return container->pData; } @@ -439,7 +440,8 @@ static int32_t tmqCommitCb(void* param, SDataBuf* pBuf, int32_t code) { return 0; } -static int32_t doSendCommitMsg(tmq_t* tmq, int32_t vgId, SEpSet* epSet, STqOffsetVal* offset, const char* pTopicName, SMqCommitCbParamSet* pParamSet) { +static int32_t doSendCommitMsg(tmq_t* tmq, int32_t vgId, SEpSet* epSet, STqOffsetVal* offset, const char* pTopicName, + SMqCommitCbParamSet* pParamSet) { SMqVgOffset pOffset = {0}; pOffset.consumerId = tmq->consumerId; @@ -479,7 +481,7 @@ static int32_t doSendCommitMsg(tmq_t* tmq, int32_t vgId, SEpSet* epSet, STqOffse } pParam->params = pParamSet; -// pParam->pOffset = pOffset; + // pParam->pOffset = pOffset; pParam->vgId = vgId; pParam->pTmq = tmq; @@ -493,7 +495,7 @@ static int32_t doSendCommitMsg(tmq_t* tmq, int32_t vgId, SEpSet* epSet, STqOffse return TSDB_CODE_OUT_OF_MEMORY; } - pMsgSendInfo->msgInfo = (SDataBuf) { .pData = buf, .len = sizeof(SMsgHead) + len, .handle = NULL }; + pMsgSendInfo->msgInfo = (SDataBuf){.pData = buf, .len = sizeof(SMsgHead) + len, .handle = NULL}; pMsgSendInfo->requestId = generateRequestId(); pMsgSendInfo->requestObjRefId = 0; @@ -505,7 +507,7 @@ static int32_t doSendCommitMsg(tmq_t* tmq, int32_t vgId, SEpSet* epSet, STqOffse int64_t transporterId = 0; atomic_add_fetch_32(&pParamSet->waitingRspNum, 1); code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, epSet, &transporterId, pMsgSendInfo); - if(code != 0){ + if (code != 0) { atomic_sub_fetch_32(&pParamSet->waitingRspNum, 1); return code; } @@ -527,7 +529,8 @@ static SMqClientTopic* getTopicByName(tmq_t* tmq, const char* pTopicName) { return NULL; } -static SMqCommitCbParamSet* prepareCommitCbParamSet(tmq_t* tmq, tmq_commit_cb* pCommitFp, void* userParam, int32_t rspNum){ +static SMqCommitCbParamSet* prepareCommitCbParamSet(tmq_t* tmq, tmq_commit_cb* pCommitFp, void* userParam, + int32_t rspNum) { SMqCommitCbParamSet* pParamSet = taosMemoryCalloc(1, sizeof(SMqCommitCbParamSet)); if (pParamSet == NULL) { return NULL; @@ -542,14 +545,14 @@ static SMqCommitCbParamSet* prepareCommitCbParamSet(tmq_t* tmq, tmq_commit_cb* p return pParamSet; } -static int32_t getClientVg(tmq_t* tmq, char* pTopicName, int32_t vgId, SMqClientVg** pVg){ +static int32_t getClientVg(tmq_t* tmq, char* pTopicName, int32_t vgId, SMqClientVg** pVg) { SMqClientTopic* pTopic = getTopicByName(tmq, pTopicName); if (pTopic == NULL) { tscError("consumer:0x%" PRIx64 " invalid topic name:%s", tmq->consumerId, pTopicName); return TSDB_CODE_TMQ_INVALID_TOPIC; } - int32_t numOfVgs = taosArrayGetSize(pTopic->vgs); + int32_t numOfVgs = taosArrayGetSize(pTopic->vgs); for (int32_t i = 0; i < numOfVgs; ++i) { SMqClientVg* pClientVg = taosArrayGet(pTopic->vgs, i); if (pClientVg->vgId == vgId) { @@ -561,19 +564,20 @@ static int32_t getClientVg(tmq_t* tmq, char* pTopicName, int32_t vgId, SMqClient return *pVg == NULL ? TSDB_CODE_TMQ_INVALID_VGID : TSDB_CODE_SUCCESS; } -static int32_t asyncCommitOffset(tmq_t* tmq, char* pTopicName, int32_t vgId, STqOffsetVal* offsetVal, tmq_commit_cb* pCommitFp, void* userParam) { +static int32_t asyncCommitOffset(tmq_t* tmq, char* pTopicName, int32_t vgId, STqOffsetVal* offsetVal, + tmq_commit_cb* pCommitFp, void* userParam) { tscInfo("consumer:0x%" PRIx64 " do manual commit offset for %s, vgId:%d", tmq->consumerId, pTopicName, vgId); taosRLockLatch(&tmq->lock); SMqClientVg* pVg = NULL; - int32_t code = getClientVg(tmq, pTopicName, vgId, &pVg); - if(code != 0){ + int32_t code = getClientVg(tmq, pTopicName, vgId, &pVg); + if (code != 0) { goto end; } if (offsetVal->type <= 0) { code = TSDB_CODE_TMQ_INVALID_MSG; goto end; } - if (tOffsetEqual(offsetVal, &pVg->offsetInfo.committedOffset)){ + if (tOffsetEqual(offsetVal, &pVg->offsetInfo.committedOffset)) { code = TSDB_CODE_TMQ_SAME_COMMITTED_VALUE; goto end; } @@ -605,11 +609,11 @@ end: return code; } -static void asyncCommitFromResult(tmq_t* tmq, const TAOS_RES* pRes, tmq_commit_cb* pCommitFp, void* userParam){ - char* pTopicName = NULL; - int32_t vgId = 0; +static void asyncCommitFromResult(tmq_t* tmq, const TAOS_RES* pRes, tmq_commit_cb* pCommitFp, void* userParam) { + char* pTopicName = NULL; + int32_t vgId = 0; STqOffsetVal offsetVal = {0}; - int32_t code = 0; + int32_t code = 0; if (pRes == NULL || tmq == NULL) { code = TSDB_CODE_INVALID_PARA; @@ -639,8 +643,8 @@ static void asyncCommitFromResult(tmq_t* tmq, const TAOS_RES* pRes, tmq_commit_c code = asyncCommitOffset(tmq, pTopicName, vgId, &offsetVal, pCommitFp, userParam); end: - if(code != TSDB_CODE_SUCCESS && pCommitFp != NULL){ - if(code == TSDB_CODE_TMQ_SAME_COMMITTED_VALUE) code = TSDB_CODE_SUCCESS; + if (code != TSDB_CODE_SUCCESS && pCommitFp != NULL) { + if (code == TSDB_CODE_TMQ_SAME_COMMITTED_VALUE) code = TSDB_CODE_SUCCESS; pCommitFp(tmq, code, userParam); } } @@ -662,11 +666,13 @@ static void asyncCommitAllOffsets(tmq_t* tmq, tmq_commit_cb* pCommitFp, void* us SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); int32_t numOfVgroups = taosArrayGetSize(pTopic->vgs); - tscInfo("consumer:0x%" PRIx64 " commit offset for topics:%s, numOfVgs:%d", tmq->consumerId, pTopic->topicName, numOfVgroups); + tscInfo("consumer:0x%" PRIx64 " commit offset for topics:%s, numOfVgs:%d", tmq->consumerId, pTopic->topicName, + numOfVgroups); for (int32_t j = 0; j < numOfVgroups; j++) { SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); - if (pVg->offsetInfo.endOffset.type > 0 && !tOffsetEqual(&pVg->offsetInfo.endOffset, &pVg->offsetInfo.committedOffset)) { + if (pVg->offsetInfo.endOffset.type > 0 && + !tOffsetEqual(&pVg->offsetInfo.endOffset, &pVg->offsetInfo.committedOffset)) { char offsetBuf[TSDB_OFFSET_LEN] = {0}; tFormatOffset(offsetBuf, tListLen(offsetBuf), &pVg->offsetInfo.endOffset); @@ -675,23 +681,27 @@ static void asyncCommitAllOffsets(tmq_t* tmq, tmq_commit_cb* pCommitFp, void* us code = doSendCommitMsg(tmq, pVg->vgId, &pVg->epSet, &pVg->offsetInfo.endOffset, pTopic->topicName, pParamSet); if (code != TSDB_CODE_SUCCESS) { - tscError("consumer:0x%" PRIx64 " topic:%s on vgId:%d end commit msg failed, send offset:%s committed:%s, code:%s ordinal:%d/%d", - tmq->consumerId, pTopic->topicName, pVg->vgId, offsetBuf, commitBuf, tstrerror(terrno), j + 1, numOfVgroups); + tscError("consumer:0x%" PRIx64 + " topic:%s on vgId:%d end commit msg failed, send offset:%s committed:%s, code:%s ordinal:%d/%d", + tmq->consumerId, pTopic->topicName, pVg->vgId, offsetBuf, commitBuf, tstrerror(terrno), j + 1, + numOfVgroups); continue; } - tscInfo("consumer:0x%" PRIx64 " topic:%s on vgId:%d send commit msg success, send offset:%s committed:%s, ordinal:%d/%d", + tscInfo("consumer:0x%" PRIx64 + " topic:%s on vgId:%d send commit msg success, send offset:%s committed:%s, ordinal:%d/%d", tmq->consumerId, pTopic->topicName, pVg->vgId, offsetBuf, commitBuf, j + 1, numOfVgroups); pVg->offsetInfo.committedOffset = pVg->offsetInfo.endOffset; } else { tscInfo("consumer:0x%" PRIx64 " topic:%s vgId:%d, no commit, current:%" PRId64 ", ordinal:%d/%d", - tmq->consumerId, pTopic->topicName, pVg->vgId, pVg->offsetInfo.endOffset.version, j + 1, numOfVgroups); + tmq->consumerId, pTopic->topicName, pVg->vgId, pVg->offsetInfo.endOffset.version, j + 1, numOfVgroups); } } } taosRUnLockLatch(&tmq->lock); - tscInfo("consumer:0x%" PRIx64 " total commit:%d for %d topics", tmq->consumerId, pParamSet->waitingRspNum - 1, numOfTopics); + tscInfo("consumer:0x%" PRIx64 " total commit:%d for %d topics", tmq->consumerId, pParamSet->waitingRspNum - 1, + numOfTopics); // request is sent if (pParamSet->waitingRspNum != 1) { @@ -702,7 +712,7 @@ static void asyncCommitAllOffsets(tmq_t* tmq, tmq_commit_cb* pCommitFp, void* us end: taosMemoryFree(pParamSet); - if(pCommitFp != NULL) { + if (pCommitFp != NULL) { pCommitFp(tmq, code, userParam); } return; @@ -710,10 +720,10 @@ end: static void generateTimedTask(int64_t refId, int32_t type) { tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId); - if(tmq == NULL) return; + if (tmq == NULL) return; int8_t* pTaskType = taosAllocateQitem(sizeof(int8_t), DEF_QITEM, 0); - if(pTaskType == NULL) return; + if (pTaskType == NULL) return; *pTaskType = type; taosWriteQitem(tmq->delayedTask, pTaskType); @@ -729,8 +739,8 @@ void tmqAssignAskEpTask(void* param, void* tmrId) { void tmqReplayTask(void* param, void* tmrId) { int64_t refId = *(int64_t*)param; - tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId); - if(tmq == NULL) goto END; + tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId); + if (tmq == NULL) goto END; tsem_post(&tmq->rspSem); taosReleaseRef(tmqMgmt.rsetId, refId); @@ -753,13 +763,13 @@ int32_t tmqHbCb(void* param, SDataBuf* pMsg, int32_t code) { tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId); if (tmq != NULL) { taosWLockLatch(&tmq->lock); - for(int32_t i = 0; i < taosArrayGetSize(rsp.topicPrivileges); i++){ + for (int32_t i = 0; i < taosArrayGetSize(rsp.topicPrivileges); i++) { STopicPrivilege* privilege = taosArrayGet(rsp.topicPrivileges, i); - if(privilege->noPrivilege == 1){ + if (privilege->noPrivilege == 1) { int32_t topicNumCur = taosArrayGetSize(tmq->clientTopics); for (int32_t j = 0; j < topicNumCur; j++) { SMqClientTopic* pTopicCur = taosArrayGet(tmq->clientTopics, j); - if(strcmp(pTopicCur->topicName, privilege->topic) == 0){ + if (strcmp(pTopicCur->topicName, privilege->topic) == 0) { tscInfo("consumer:0x%" PRIx64 ", has no privilege, topic:%s", tmq->consumerId, privilege->topic); pTopicCur->noPrivilege = 1; } @@ -790,22 +800,22 @@ void tmqSendHbReq(void* param, void* tmrId) { req.epoch = tmq->epoch; taosRLockLatch(&tmq->lock); 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); + 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++){ + for (int j = 0; j < numOfVgroups; j++) { SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); - OffsetRows* offRows = taosArrayReserve(data->offsetRows, 1); + OffsetRows* offRows = taosArrayReserve(data->offsetRows, 1); offRows->vgId = pVg->vgId; offRows->rows = pVg->numOfRows; offRows->offset = pVg->offsetInfo.endOffset; - offRows->ever = pVg->offsetInfo.walVerEnd; + 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, + 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); } } @@ -835,13 +845,13 @@ void tmqSendHbReq(void* param, void* tmrId) { goto OVER; } - sendInfo->msgInfo = (SDataBuf){ .pData = pReq, .len = tlen, .handle = NULL }; + sendInfo->msgInfo = (SDataBuf){.pData = pReq, .len = tlen, .handle = NULL}; sendInfo->requestId = generateRequestId(); sendInfo->requestObjRefId = 0; sendInfo->paramFreeFp = taosMemoryFree; sendInfo->param = taosMemoryMalloc(sizeof(int64_t)); - *(int64_t *)sendInfo->param = refId; + *(int64_t*)sendInfo->param = refId; sendInfo->fp = tmqHbCb; sendInfo->msgType = TDMT_MND_TMQ_HB; @@ -972,7 +982,7 @@ int32_t tmqSubscribeCb(void* param, SDataBuf* pMsg, int32_t code) { } int32_t tmq_subscription(tmq_t* tmq, tmq_list_t** topics) { - if(tmq == NULL) return TSDB_CODE_INVALID_PARA; + if (tmq == NULL) return TSDB_CODE_INVALID_PARA; if (*topics == NULL) { *topics = tmq_list_new(); } @@ -986,7 +996,7 @@ int32_t tmq_subscription(tmq_t* tmq, tmq_list_t** topics) { } int32_t tmq_unsubscribe(tmq_t* tmq) { - if(tmq == NULL) return TSDB_CODE_INVALID_PARA; + if (tmq == NULL) return TSDB_CODE_INVALID_PARA; if (tmq->status != TMQ_CONSUMER_STATUS__READY) { tscInfo("consumer:0x%" PRIx64 " not in ready state, unsubscribe it directly", tmq->consumerId); return 0; @@ -1060,9 +1070,10 @@ static void tmqMgmtInit(void) { } } -#define SET_ERROR_MSG(MSG) if(errstr!=NULL)snprintf(errstr,errstrLen,MSG); +#define SET_ERROR_MSG(MSG) \ + if (errstr != NULL) snprintf(errstr, errstrLen, MSG); tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) { - if(conf == NULL) { + if (conf == NULL) { SET_ERROR_MSG("configure is null") return NULL; } @@ -1114,7 +1125,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) { pTmq->resetOffsetCfg = conf->resetOffset; pTmq->replayEnable = conf->replayEnable; pTmq->sourceExcluded = conf->sourceExcluded; - if(conf->replayEnable){ + if (conf->replayEnable) { pTmq->autoCommit = false; } taosInitRWLatch(&pTmq->lock); @@ -1154,7 +1165,8 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) { tFormatOffset(buf, tListLen(buf), &offset); tscInfo("consumer:0x%" PRIx64 " is setup, refId:%" PRId64 ", groupId:%s, snapshot:%d, autoCommit:%d, commitInterval:%dms, offset:%s", - pTmq->consumerId, pTmq->refId, pTmq->groupId, pTmq->useSnapshot, pTmq->autoCommit, pTmq->autoCommitInterval, buf); + pTmq->consumerId, pTmq->refId, pTmq->groupId, pTmq->useSnapshot, pTmq->autoCommit, pTmq->autoCommitInterval, + buf); return pTmq; @@ -1164,7 +1176,7 @@ _failed: } int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) { - if(tmq == NULL || topic_list == NULL) return TSDB_CODE_INVALID_PARA; + if (tmq == NULL || topic_list == NULL) return TSDB_CODE_INVALID_PARA; const int32_t MAX_RETRY_COUNT = 120 * 2; // let's wait for 2 mins at most const SArray* container = &topic_list->container; int32_t sz = taosArrayGetSize(container); @@ -1224,7 +1236,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) { goto FAIL; } - SMqSubscribeCbParam param = { .rspErr = 0}; + SMqSubscribeCbParam param = {.rspErr = 0}; if (tsem_init(¶m.rspSem, 0, 0) != 0) { code = TSDB_CODE_TSC_INTERNAL_ERROR; goto FAIL; @@ -1242,7 +1254,7 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) { int64_t transporterId = 0; code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); - if(code != 0){ + if (code != 0) { goto FAIL; } @@ -1293,20 +1305,20 @@ FAIL: } void tmq_conf_set_auto_commit_cb(tmq_conf_t* conf, tmq_commit_cb* cb, void* param) { - if(conf == NULL) return; + if (conf == NULL) return; conf->commitCb = cb; conf->commitCbUserParam = param; } -static SMqClientVg* getVgInfo(tmq_t* tmq, char* topicName, int32_t vgId){ +static SMqClientVg* getVgInfo(tmq_t* tmq, char* topicName, int32_t vgId) { int32_t topicNumCur = taosArrayGetSize(tmq->clientTopics); - for(int i = 0; i < topicNumCur; i++){ + for (int i = 0; i < topicNumCur; i++) { SMqClientTopic* pTopicCur = taosArrayGet(tmq->clientTopics, i); - if(strcmp(pTopicCur->topicName, topicName) == 0){ + if (strcmp(pTopicCur->topicName, topicName) == 0) { int32_t vgNumCur = taosArrayGetSize(pTopicCur->vgs); for (int32_t j = 0; j < vgNumCur; j++) { SMqClientVg* pVgCur = taosArrayGet(pTopicCur->vgs, j); - if(pVgCur->vgId == vgId){ + if (pVgCur->vgId == vgId) { return pVgCur; } } @@ -1315,21 +1327,21 @@ static SMqClientVg* getVgInfo(tmq_t* tmq, char* topicName, int32_t vgId){ return NULL; } -static SMqClientTopic* getTopicInfo(tmq_t* tmq, char* topicName){ +static SMqClientTopic* getTopicInfo(tmq_t* tmq, char* topicName) { int32_t topicNumCur = taosArrayGetSize(tmq->clientTopics); - for(int i = 0; i < topicNumCur; i++){ + for (int i = 0; i < topicNumCur; i++) { SMqClientTopic* pTopicCur = taosArrayGet(tmq->clientTopics, i); - if(strcmp(pTopicCur->topicName, topicName) == 0){ + if (strcmp(pTopicCur->topicName, topicName) == 0) { return pTopicCur; } } return NULL; } -static void setVgIdle(tmq_t* tmq, char* topicName, int32_t vgId){ +static void setVgIdle(tmq_t* tmq, char* topicName, int32_t vgId) { taosWLockLatch(&tmq->lock); SMqClientVg* pVg = getVgInfo(tmq, topicName, vgId); - if(pVg){ + if (pVg) { atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); } taosWUnLockLatch(&tmq->lock); @@ -1337,10 +1349,10 @@ static void setVgIdle(tmq_t* tmq, char* topicName, int32_t vgId){ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { SMqPollCbParam* pParam = (SMqPollCbParam*)param; - int64_t refId = pParam->refId; - int32_t vgId = pParam->vgId; - uint64_t requestId = pParam->requestId; - tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId); + int64_t refId = pParam->refId; + int32_t vgId = pParam->vgId; + uint64_t requestId = pParam->requestId; + tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId); if (tmq == NULL) { code = TSDB_CODE_TMQ_CONSUMER_CLOSED; goto FAIL; @@ -1354,7 +1366,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { goto FAIL; } - if(code != 0){ + if (code != 0) { goto END; } @@ -1363,7 +1375,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { if (msgEpoch < clientEpoch) { // do not write into queue since updating epoch reset tscWarn("consumer:0x%" PRIx64 - " msg discard from vgId:%d since from earlier epoch, rsp epoch %d, current epoch %d, reqId:0x%" PRIx64, + " msg discard from vgId:%d since from earlier epoch, rsp epoch %d, current epoch %d, reqId:0x%" PRIx64, tmq->consumerId, vgId, msgEpoch, clientEpoch, requestId); code = -1; goto END; @@ -1416,10 +1428,10 @@ END: taosReleaseRef(tmqMgmt.rsetId, refId); FAIL: - if(tmq) tsem_post(&tmq->rspSem); + if (tmq) tsem_post(&tmq->rspSem); taosMemoryFree(pParam); - if(pMsg) taosMemoryFreeClear(pMsg->pData); - if(pMsg) taosMemoryFreeClear(pMsg->pEpSet); + if (pMsg) taosMemoryFreeClear(pMsg->pData); + if (pMsg) taosMemoryFreeClear(pMsg->pEpSet); return code; } @@ -1456,7 +1468,8 @@ static void initClientTopicFromRsp(SMqClientTopic* pTopic, SMqSubTopicEp* pTopic STqOffsetVal offsetNew = {0}; offsetNew.type = tmq->resetOffsetCfg; - tscInfo("consumer:0x%" PRIx64 ", update topic:%s, new numOfVgs:%d, num:%d, port:%d", tmq->consumerId, pTopic->topicName, vgNumGet, pVgEp->epSet.numOfEps,pVgEp->epSet.eps[pVgEp->epSet.inUse].port); + tscInfo("consumer:0x%" PRIx64 ", update topic:%s, new numOfVgs:%d, num:%d, port:%d", tmq->consumerId, + pTopic->topicName, vgNumGet, pVgEp->epSet.numOfEps, pVgEp->epSet.eps[pVgEp->epSet.inUse].port); SMqClientVg clientVg = { .pollCnt = 0, @@ -1495,9 +1508,9 @@ static bool doUpdateLocalEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) int32_t topicNumGet = taosArrayGetSize(pRsp->topics); if (epoch < tmq->epoch || (epoch == tmq->epoch && topicNumGet == 0)) { - tscInfo("consumer:0x%" PRIx64 " no update ep epoch from %d to epoch %d, incoming topics:%d", - tmq->consumerId, tmq->epoch, epoch, topicNumGet); - if(atomic_load_8(&tmq->status) == TMQ_CONSUMER_STATUS__RECOVER){ + tscInfo("consumer:0x%" PRIx64 " no update ep epoch from %d to epoch %d, incoming topics:%d", tmq->consumerId, + tmq->epoch, epoch, topicNumGet); + if (atomic_load_8(&tmq->status) == TMQ_CONSUMER_STATUS__RECOVER) { atomic_store_8(&tmq->status, TMQ_CONSUMER_STATUS__READY); } return false; @@ -1533,10 +1546,12 @@ static bool doUpdateLocalEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) char buf[TSDB_OFFSET_LEN] = {0}; tFormatOffset(buf, TSDB_OFFSET_LEN, &pVgCur->offsetInfo.endOffset); tscInfo("consumer:0x%" PRIx64 ", epoch:%d vgId:%d vgKey:%s, offset:%s", tmq->consumerId, epoch, pVgCur->vgId, - vgKey, buf); + vgKey, buf); - SVgroupSaveInfo info = {.currentOffset = pVgCur->offsetInfo.endOffset, .seekOffset = pVgCur->offsetInfo.beginOffset, - .commitOffset = pVgCur->offsetInfo.committedOffset, .numOfRows = pVgCur->numOfRows, + SVgroupSaveInfo info = {.currentOffset = pVgCur->offsetInfo.endOffset, + .seekOffset = pVgCur->offsetInfo.beginOffset, + .commitOffset = pVgCur->offsetInfo.committedOffset, + .numOfRows = pVgCur->numOfRows, .vgStatus = pVgCur->vgStatus}; taosHashPut(pVgOffsetHashMap, vgKey, strlen(vgKey), &info, sizeof(SVgroupSaveInfo)); } @@ -1616,16 +1631,16 @@ SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, pRspObj->rsp.withSchema = true; pRspObj->rsp.blockSchema = taosArrayInit(pRspObj->rsp.blockNum, sizeof(void*)); } - // extract the rows in this data packet + // extract the rows in this data packet for (int32_t i = 0; i < pRspObj->rsp.blockNum; ++i) { SRetrieveTableRspForTmq* pRetrieve = (SRetrieveTableRspForTmq*)taosArrayGetP(pRspObj->rsp.blockData, i); - int64_t rows = htobe64(pRetrieve->numOfRows); + int64_t rows = htobe64(pRetrieve->numOfRows); pVg->numOfRows += rows; (*numOfRows) += rows; - if (needTransformSchema) { //withSchema is false if subscribe subquery, true if subscribe db or stable - SSchemaWrapper *schema = tCloneSSchemaWrapper(&pWrapper->topicHandle->schema); - if(schema){ + if (needTransformSchema) { // withSchema is false if subscribe subquery, true if subscribe db or stable + SSchemaWrapper* schema = tCloneSSchemaWrapper(&pWrapper->topicHandle->schema); + if (schema) { taosArrayPush(pRspObj->rsp.blockSchema, &schema); } } @@ -1649,7 +1664,7 @@ SMqTaosxRspObj* tmqBuildTaosxRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClie // extract the rows in this data packet for (int32_t i = 0; i < pRspObj->rsp.blockNum; ++i) { SRetrieveTableRspForTmq* pRetrieve = (SRetrieveTableRspForTmq*)taosArrayGetP(pRspObj->rsp.blockData, i); - int64_t rows = htobe64(pRetrieve->numOfRows); + int64_t rows = htobe64(pRetrieve->numOfRows); pVg->numOfRows += rows; (*numOfRows) += rows; } @@ -1657,15 +1672,15 @@ SMqTaosxRspObj* tmqBuildTaosxRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClie } static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* pVg, int64_t timeout) { - SMqPollReq req = {0}; - char* msg = NULL; + SMqPollReq req = {0}; + char* msg = NULL; SMqPollCbParam* pParam = NULL; - SMsgSendInfo* sendInfo = NULL; - int code = 0; + SMsgSendInfo* sendInfo = NULL; + int code = 0; tmqBuildConsumeReqImpl(&req, pTmq, timeout, pTopic, pVg); int32_t msgSize = tSerializeSMqPollReq(NULL, 0, &req); - if (msgSize < 0){ + if (msgSize < 0) { code = TSDB_CODE_INVALID_MSG; goto FAIL; } @@ -1709,14 +1724,14 @@ static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* p char offsetFormatBuf[TSDB_OFFSET_LEN] = {0}; tFormatOffset(offsetFormatBuf, tListLen(offsetFormatBuf), &pVg->offsetInfo.endOffset); code = asyncSendMsgToServer(pTmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo); - tscDebug("consumer:0x%" PRIx64 " send poll to %s vgId:%d, code:%d, epoch %d, req:%s, reqId:0x%" PRIx64, pTmq->consumerId, - pTopic->topicName, pVg->vgId, code, pTmq->epoch, offsetFormatBuf, req.reqId); - if(code != 0){ + tscDebug("consumer:0x%" PRIx64 " send poll to %s vgId:%d, code:%d, epoch %d, req:%s, reqId:0x%" PRIx64, + pTmq->consumerId, pTopic->topicName, pVg->vgId, code, pTmq->epoch, offsetFormatBuf, req.reqId); + if (code != 0) { goto FAIL; } pVg->pollCnt++; - pVg->seekUpdated = false; // reset this flag. + pVg->seekUpdated = false; // reset this flag. pTmq->pollCnt++; return 0; @@ -1727,7 +1742,7 @@ FAIL: // broadcast the poll request to all related vnodes static int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) { - if(atomic_load_8(&tmq->status) == TMQ_CONSUMER_STATUS__RECOVER){ + if (atomic_load_8(&tmq->status) == TMQ_CONSUMER_STATUS__RECOVER) { return 0; } int32_t code = 0; @@ -1739,7 +1754,7 @@ static int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) { for (int i = 0; i < numOfTopics; i++) { SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); int32_t numOfVg = taosArrayGetSize(pTopic->vgs); - if(pTopic->noPrivilege){ + if (pTopic->noPrivilege) { tscDebug("consumer:0x%" PRIx64 " has no privilegr for topic:%s", tmq->consumerId, pTopic->topicName); continue; } @@ -1751,9 +1766,10 @@ static int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) { continue; } - if (tmq->replayEnable && taosGetTimestampMs() - pVg->blockReceiveTs < pVg->blockSleepForReplay) { // less than 10ms - tscTrace("consumer:0x%" PRIx64 " epoch %d, vgId:%d idle for %" PRId64 "ms before start next poll when replay", tmq->consumerId, - tmq->epoch, pVg->vgId, pVg->blockSleepForReplay); + if (tmq->replayEnable && + taosGetTimestampMs() - pVg->blockReceiveTs < pVg->blockSleepForReplay) { // less than 10ms + tscTrace("consumer:0x%" PRIx64 " epoch %d, vgId:%d idle for %" PRId64 "ms before start next poll when replay", + tmq->consumerId, tmq->epoch, pVg->vgId, pVg->blockSleepForReplay); continue; } @@ -1779,13 +1795,14 @@ end: return code; } -static void updateVgInfo(SMqClientVg* pVg, STqOffsetVal* reqOffset, STqOffsetVal* rspOffset, int64_t sver, int64_t ever, int64_t consumerId, bool hasData){ +static void updateVgInfo(SMqClientVg* pVg, STqOffsetVal* reqOffset, STqOffsetVal* rspOffset, int64_t sver, int64_t ever, + int64_t consumerId, bool hasData) { if (!pVg->seekUpdated) { - tscDebug("consumer:0x%" PRIx64" local offset is update, since seekupdate not set", consumerId); - if(hasData) pVg->offsetInfo.beginOffset = *reqOffset; + tscDebug("consumer:0x%" PRIx64 " local offset is update, since seekupdate not set", consumerId); + if (hasData) pVg->offsetInfo.beginOffset = *reqOffset; pVg->offsetInfo.endOffset = *rspOffset; } else { - tscDebug("consumer:0x%" PRIx64" local offset is NOT update, since seekupdate is set", consumerId); + tscDebug("consumer:0x%" PRIx64 " local offset is NOT update, since seekupdate is set", consumerId); } // update the status @@ -1820,17 +1837,19 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) { tscDebug("consumer:0x%" PRIx64 " wait for the re-balance, set status to be RECOVER", tmq->consumerId); } else if (pRspWrapper->code == TSDB_CODE_TQ_NO_COMMITTED_OFFSET) { terrno = pRspWrapper->code; - tscError("consumer:0x%" PRIx64 " unexpected rsp from poll, code:%s", tmq->consumerId, tstrerror(pRspWrapper->code)); + tscError("consumer:0x%" PRIx64 " unexpected rsp from poll, code:%s", tmq->consumerId, + tstrerror(pRspWrapper->code)); taosFreeQitem(pRspWrapper); return NULL; - } else{ - if(pRspWrapper->code == TSDB_CODE_VND_INVALID_VGROUP_ID){ // for vnode transform + } else { + if (pRspWrapper->code == TSDB_CODE_VND_INVALID_VGROUP_ID) { // for vnode transform askEp(tmq, NULL, false, true); } - tscError("consumer:0x%" PRIx64 " msg from vgId:%d discarded, since %s", tmq->consumerId, pollRspWrapper->vgId, tstrerror(pRspWrapper->code)); + tscError("consumer:0x%" PRIx64 " msg from vgId:%d discarded, since %s", tmq->consumerId, pollRspWrapper->vgId, + tstrerror(pRspWrapper->code)); taosWLockLatch(&tmq->lock); SMqClientVg* pVg = getVgInfo(tmq, pollRspWrapper->topicName, pollRspWrapper->vgId); - if(pVg) pVg->emptyBlockReceiveTs = taosGetTimestampMs(); + if (pVg) pVg->emptyBlockReceiveTs = taosGetTimestampMs(); taosWUnLockLatch(&tmq->lock); } setVgIdle(tmq, pollRspWrapper->topicName, pollRspWrapper->vgId); @@ -1846,7 +1865,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) { SMqClientVg* pVg = getVgInfo(tmq, pollRspWrapper->topicName, pollRspWrapper->vgId); pollRspWrapper->vgHandle = pVg; pollRspWrapper->topicHandle = getTopicInfo(tmq, pollRspWrapper->topicName); - if(pollRspWrapper->vgHandle == NULL || pollRspWrapper->topicHandle == NULL){ + if (pollRspWrapper->vgHandle == NULL || pollRspWrapper->topicHandle == NULL) { tscError("consumer:0x%" PRIx64 " get vg or topic error, topic:%s vgId:%d", tmq->consumerId, pollRspWrapper->topicName, pollRspWrapper->vgId); taosWUnLockLatch(&tmq->lock); @@ -1861,7 +1880,8 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) { pVg->epSet = *pollRspWrapper->pEpset; } - updateVgInfo(pVg, &pDataRsp->reqOffset, &pDataRsp->rspOffset, pDataRsp->head.walsver, pDataRsp->head.walever, tmq->consumerId, pDataRsp->blockNum != 0); + updateVgInfo(pVg, &pDataRsp->reqOffset, &pDataRsp->rspOffset, pDataRsp->head.walsver, pDataRsp->head.walever, + tmq->consumerId, pDataRsp->blockNum != 0); char buf[TSDB_OFFSET_LEN] = {0}; tFormatOffset(buf, TSDB_OFFSET_LEN, &pDataRsp->rspOffset); @@ -1878,10 +1898,10 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) { SMqRspObj* pRsp = tmqBuildRspFromWrapper(pollRspWrapper, pVg, &numOfRows); tmq->totalRows += numOfRows; pVg->emptyBlockReceiveTs = 0; - if(tmq->replayEnable){ + if (tmq->replayEnable) { pVg->blockReceiveTs = taosGetTimestampMs(); pVg->blockSleepForReplay = pRsp->rsp.sleepTime; - if(pVg->blockSleepForReplay > 0){ + if (pVg->blockSleepForReplay > 0) { int64_t* pRefId1 = taosMemoryMalloc(sizeof(int64_t)); *pRefId1 = tmq->refId; taosTmrStart(tmqReplayTask, pVg->blockSleepForReplay, pRefId1, tmqMgmt.timer); @@ -1897,7 +1917,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) { } } else { tscInfo("consumer:0x%" PRIx64 " vgId:%d msg discard since epoch mismatch: msg epoch %d, consumer epoch %d", - tmq->consumerId, pollRspWrapper->vgId, pDataRsp->head.epoch, consumerEpoch); + tmq->consumerId, pollRspWrapper->vgId, pDataRsp->head.epoch, consumerEpoch); setVgIdle(tmq, pollRspWrapper->topicName, pollRspWrapper->vgId); tmqFreeRspWrapper(pRspWrapper); taosFreeQitem(pRspWrapper); @@ -1913,14 +1933,15 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) { SMqClientVg* pVg = getVgInfo(tmq, pollRspWrapper->topicName, pollRspWrapper->vgId); pollRspWrapper->vgHandle = pVg; pollRspWrapper->topicHandle = getTopicInfo(tmq, pollRspWrapper->topicName); - if(pollRspWrapper->vgHandle == NULL || pollRspWrapper->topicHandle == NULL){ + if (pollRspWrapper->vgHandle == NULL || pollRspWrapper->topicHandle == NULL) { tscError("consumer:0x%" PRIx64 " get vg or topic error, topic:%s vgId:%d", tmq->consumerId, pollRspWrapper->topicName, pollRspWrapper->vgId); taosWUnLockLatch(&tmq->lock); return NULL; } - updateVgInfo(pVg, &pollRspWrapper->metaRsp.rspOffset, &pollRspWrapper->metaRsp.rspOffset, pollRspWrapper->metaRsp.head.walsver, pollRspWrapper->metaRsp.head.walever, tmq->consumerId, true); + updateVgInfo(pVg, &pollRspWrapper->metaRsp.rspOffset, &pollRspWrapper->metaRsp.rspOffset, + pollRspWrapper->metaRsp.head.walsver, pollRspWrapper->metaRsp.head.walever, tmq->consumerId, true); // build rsp SMqMetaRspObj* pRsp = tmqBuildMetaRspFromWrapper(pollRspWrapper); taosFreeQitem(pRspWrapper); @@ -1928,7 +1949,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) { return pRsp; } else { tscInfo("consumer:0x%" PRIx64 " vgId:%d msg discard since epoch mismatch: msg epoch %d, consumer epoch %d", - tmq->consumerId, pollRspWrapper->vgId, pollRspWrapper->metaRsp.head.epoch, consumerEpoch); + tmq->consumerId, pollRspWrapper->vgId, pollRspWrapper->metaRsp.head.epoch, consumerEpoch); setVgIdle(tmq, pollRspWrapper->topicName, pollRspWrapper->vgId); tmqFreeRspWrapper(pRspWrapper); taosFreeQitem(pRspWrapper); @@ -1942,14 +1963,16 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) { SMqClientVg* pVg = getVgInfo(tmq, pollRspWrapper->topicName, pollRspWrapper->vgId); pollRspWrapper->vgHandle = pVg; pollRspWrapper->topicHandle = getTopicInfo(tmq, pollRspWrapper->topicName); - if(pollRspWrapper->vgHandle == NULL || pollRspWrapper->topicHandle == NULL){ + if (pollRspWrapper->vgHandle == NULL || pollRspWrapper->topicHandle == NULL) { tscError("consumer:0x%" PRIx64 " get vg or topic error, topic:%s vgId:%d", tmq->consumerId, pollRspWrapper->topicName, pollRspWrapper->vgId); taosWUnLockLatch(&tmq->lock); return NULL; } - updateVgInfo(pVg, &pollRspWrapper->taosxRsp.reqOffset, &pollRspWrapper->taosxRsp.rspOffset, pollRspWrapper->taosxRsp.head.walsver, pollRspWrapper->taosxRsp.head.walever, tmq->consumerId, pollRspWrapper->taosxRsp.blockNum != 0); + updateVgInfo(pVg, &pollRspWrapper->taosxRsp.reqOffset, &pollRspWrapper->taosxRsp.rspOffset, + pollRspWrapper->taosxRsp.head.walsver, pollRspWrapper->taosxRsp.head.walever, tmq->consumerId, + pollRspWrapper->taosxRsp.blockNum != 0); if (pollRspWrapper->taosxRsp.blockNum == 0) { tscDebug("consumer:0x%" PRIx64 " taosx empty block received, vgId:%d, vg total:%" PRId64 ", reqId:0x%" PRIx64, @@ -1967,7 +1990,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) { void* pRsp = NULL; int64_t numOfRows = 0; if (pollRspWrapper->taosxRsp.createTableNum == 0) { - tscError("consumer:0x%" PRIx64" createTableNum should > 0 if rsp type is data_meta", tmq->consumerId); + tscError("consumer:0x%" PRIx64 " createTableNum should > 0 if rsp type is data_meta", tmq->consumerId); } else { pRsp = tmqBuildTaosxRspFromWrapper(pollRspWrapper, pVg, &numOfRows); } @@ -1977,7 +2000,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) { char buf[TSDB_OFFSET_LEN] = {0}; tFormatOffset(buf, TSDB_OFFSET_LEN, &pVg->offsetInfo.endOffset); tscDebug("consumer:0x%" PRIx64 " process taosx poll rsp, vgId:%d, offset:%s, blocks:%d, rows:%" PRId64 - ", vg total:%" PRId64 ", total:%" PRId64 ", reqId:0x%" PRIx64, + ", vg total:%" PRId64 ", total:%" PRId64 ", reqId:0x%" PRIx64, tmq->consumerId, pVg->vgId, buf, pollRspWrapper->dataRsp.blockNum, numOfRows, pVg->numOfRows, tmq->totalRows, pollRspWrapper->reqId); @@ -1986,12 +2009,12 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) { return pRsp; } else { tscInfo("consumer:0x%" PRIx64 " vgId:%d msg discard since epoch mismatch: msg epoch %d, consumer epoch %d", - tmq->consumerId, pollRspWrapper->vgId, pollRspWrapper->taosxRsp.head.epoch, consumerEpoch); + tmq->consumerId, pollRspWrapper->vgId, pollRspWrapper->taosxRsp.head.epoch, consumerEpoch); setVgIdle(tmq, pollRspWrapper->topicName, pollRspWrapper->vgId); tmqFreeRspWrapper(pRspWrapper); taosFreeQitem(pRspWrapper); } - } else if(pRspWrapper->tmqRspType == TMQ_MSG_TYPE__EP_RSP){ + } else if (pRspWrapper->tmqRspType == TMQ_MSG_TYPE__EP_RSP) { tscDebug("consumer:0x%" PRIx64 " ep msg received", tmq->consumerId); SMqAskEpRspWrapper* pEpRspWrapper = (SMqAskEpRspWrapper*)pRspWrapper; SMqAskEpRsp* rspMsg = &pEpRspWrapper->msg; @@ -2005,7 +2028,7 @@ static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout) { } TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) { - if(tmq == NULL) return NULL; + if (tmq == NULL) return NULL; void* rspObj = NULL; int64_t startTime = taosGetTimestampMs(); @@ -2021,7 +2044,7 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) { } while (1) { - if(atomic_load_8(&tmq->status) != TMQ_CONSUMER_STATUS__RECOVER){ + if (atomic_load_8(&tmq->status) != TMQ_CONSUMER_STATUS__RECOVER) { break; } tscInfo("consumer:0x%" PRIx64 " tmq status is recover", tmq->consumerId); @@ -2091,7 +2114,7 @@ static void displayConsumeStatistics(tmq_t* pTmq) { } int32_t tmq_consumer_close(tmq_t* tmq) { - if(tmq == NULL) return TSDB_CODE_INVALID_PARA; + if (tmq == NULL) return TSDB_CODE_INVALID_PARA; tscInfo("consumer:0x%" PRIx64 " start to close consumer, status:%d", tmq->consumerId, tmq->status); displayConsumeStatistics(tmq); @@ -2138,7 +2161,7 @@ const char* tmq_err2str(int32_t err) { } tmq_res_t tmq_get_res_type(TAOS_RES* res) { - if (res == NULL){ + if (res == NULL) { return TMQ_RES_INVALID; } if (TD_RES_TMQ(res)) { @@ -2153,7 +2176,7 @@ tmq_res_t tmq_get_res_type(TAOS_RES* res) { } const char* tmq_get_topic_name(TAOS_RES* res) { - if (res == NULL){ + if (res == NULL) { return NULL; } if (TD_RES_TMQ(res)) { @@ -2171,7 +2194,7 @@ const char* tmq_get_topic_name(TAOS_RES* res) { } const char* tmq_get_db_name(TAOS_RES* res) { - if (res == NULL){ + if (res == NULL) { return NULL; } @@ -2190,7 +2213,7 @@ const char* tmq_get_db_name(TAOS_RES* res) { } int32_t tmq_get_vgroup_id(TAOS_RES* res) { - if (res == NULL){ + if (res == NULL) { return -1; } if (TD_RES_TMQ(res)) { @@ -2208,15 +2231,15 @@ int32_t tmq_get_vgroup_id(TAOS_RES* res) { } int64_t tmq_get_vgroup_offset(TAOS_RES* res) { - if (res == NULL){ + if (res == NULL) { return TSDB_CODE_INVALID_PARA; } if (TD_RES_TMQ(res)) { - SMqRspObj* pRspObj = (SMqRspObj*) res; + SMqRspObj* pRspObj = (SMqRspObj*)res; STqOffsetVal* pOffset = &pRspObj->rsp.reqOffset; if (pOffset->type == TMQ_OFFSET__LOG) { return pRspObj->rsp.reqOffset.version; - }else{ + } else { tscError("invalid offset type:%d", pOffset->type); } } else if (TD_RES_TMQ_META(res)) { @@ -2225,11 +2248,11 @@ int64_t tmq_get_vgroup_offset(TAOS_RES* res) { return pRspObj->metaRsp.rspOffset.version; } } else if (TD_RES_TMQ_METADATA(res)) { - SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*) res; + SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)res; if (pRspObj->rsp.reqOffset.type == TMQ_OFFSET__LOG) { return pRspObj->rsp.reqOffset.version; } - } else{ + } else { tscError("invalid tmq type:%d", *(int8_t*)res); } @@ -2238,7 +2261,7 @@ int64_t tmq_get_vgroup_offset(TAOS_RES* res) { } const char* tmq_get_table_name(TAOS_RES* res) { - if (res == NULL){ + if (res == NULL) { return NULL; } if (TD_RES_TMQ(res)) { @@ -2262,7 +2285,7 @@ const char* tmq_get_table_name(TAOS_RES* res) { void tmq_commit_async(tmq_t* tmq, const TAOS_RES* pRes, tmq_commit_cb* cb, void* param) { if (tmq == NULL) { tscError("invalid tmq handle, null"); - if(cb != NULL) { + if (cb != NULL) { cb(tmq, TSDB_CODE_INVALID_PARA, param); } return; @@ -2274,8 +2297,8 @@ void tmq_commit_async(tmq_t* tmq, const TAOS_RES* pRes, tmq_commit_cb* cb, void* } } -static void commitCallBackFn(tmq_t *UNUSED_PARAM(tmq), int32_t code, void* param) { - SSyncCommitInfo* pInfo = (SSyncCommitInfo*) param; +static void commitCallBackFn(tmq_t* UNUSED_PARAM(tmq), int32_t code, void* param) { + SSyncCommitInfo* pInfo = (SSyncCommitInfo*)param; pInfo->code = code; tsem_post(&pInfo->sem); } @@ -2309,34 +2332,35 @@ int32_t tmq_commit_sync(tmq_t* tmq, const TAOS_RES* pRes) { } // wal range will be ok after calling tmq_get_topic_assignment or poll interface -static int32_t checkWalRange(SVgOffsetInfo* offset, int64_t value){ +static int32_t checkWalRange(SVgOffsetInfo* offset, int64_t value) { if (offset->walVerBegin == -1 || offset->walVerEnd == -1) { tscError("Assignment or poll interface need to be called first"); return TSDB_CODE_TMQ_NEED_INITIALIZED; } if (value != -1 && (value < offset->walVerBegin || value > offset->walVerEnd)) { - tscError("invalid seek params, offset:%" PRId64 ", valid range:[%" PRId64 ", %" PRId64 "]", value, offset->walVerBegin, offset->walVerEnd); + tscError("invalid seek params, offset:%" PRId64 ", valid range:[%" PRId64 ", %" PRId64 "]", value, + offset->walVerBegin, offset->walVerEnd); return TSDB_CODE_TMQ_VERSION_OUT_OF_RANGE; } return 0; } -int32_t tmq_commit_offset_sync(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset){ +int32_t tmq_commit_offset_sync(tmq_t* tmq, const char* pTopicName, int32_t vgId, int64_t offset) { if (tmq == NULL || pTopicName == NULL) { tscError("invalid tmq handle, null"); return TSDB_CODE_INVALID_PARA; } int32_t accId = tmq->pTscObj->acctId; - char tname[TSDB_TOPIC_FNAME_LEN] = {0}; + char tname[TSDB_TOPIC_FNAME_LEN] = {0}; sprintf(tname, "%d.%s", accId, pTopicName); taosWLockLatch(&tmq->lock); SMqClientVg* pVg = NULL; - int32_t code = getClientVg(tmq, tname, vgId, &pVg); - if(code != 0){ + int32_t code = getClientVg(tmq, tname, vgId, &pVg); + if (code != 0) { taosWUnLockLatch(&tmq->lock); return code; } @@ -2353,7 +2377,7 @@ int32_t tmq_commit_offset_sync(tmq_t *tmq, const char *pTopicName, int32_t vgId, SSyncCommitInfo* pInfo = taosMemoryMalloc(sizeof(SSyncCommitInfo)); if (pInfo == NULL) { - tscError("consumer:0x%"PRIx64" failed to prepare seek operation", tmq->consumerId); + tscError("consumer:0x%" PRIx64 " failed to prepare seek operation", tmq->consumerId); return TSDB_CODE_OUT_OF_MEMORY; } @@ -2361,36 +2385,38 @@ int32_t tmq_commit_offset_sync(tmq_t *tmq, const char *pTopicName, int32_t vgId, pInfo->code = 0; code = asyncCommitOffset(tmq, tname, vgId, &offsetVal, commitCallBackFn, pInfo); - if(code == 0){ + if (code == 0) { tsem_wait(&pInfo->sem); code = pInfo->code; } - if(code == TSDB_CODE_TMQ_SAME_COMMITTED_VALUE) code = TSDB_CODE_SUCCESS; + if (code == TSDB_CODE_TMQ_SAME_COMMITTED_VALUE) code = TSDB_CODE_SUCCESS; tsem_destroy(&pInfo->sem); taosMemoryFree(pInfo); - tscInfo("consumer:0x%" PRIx64 " sync send commit to vgId:%d, offset:%" PRId64" code:%s", tmq->consumerId, vgId, offset, tstrerror(code)); + tscInfo("consumer:0x%" PRIx64 " sync send commit to vgId:%d, offset:%" PRId64 " code:%s", tmq->consumerId, vgId, + offset, tstrerror(code)); return code; } -void tmq_commit_offset_async(tmq_t *tmq, const char *pTopicName, int32_t vgId, int64_t offset, tmq_commit_cb *cb, void *param){ +void tmq_commit_offset_async(tmq_t* tmq, const char* pTopicName, int32_t vgId, int64_t offset, tmq_commit_cb* cb, + void* param) { int32_t code = 0; if (tmq == NULL || pTopicName == NULL) { tscError("invalid tmq handle, null"); code = TSDB_CODE_INVALID_PARA; - goto end; + goto end; } int32_t accId = tmq->pTscObj->acctId; - char tname[TSDB_TOPIC_FNAME_LEN] = {0}; + char tname[TSDB_TOPIC_FNAME_LEN] = {0}; sprintf(tname, "%d.%s", accId, pTopicName); taosWLockLatch(&tmq->lock); SMqClientVg* pVg = NULL; code = getClientVg(tmq, tname, vgId, &pVg); - if(code != 0){ + if (code != 0) { taosWUnLockLatch(&tmq->lock); goto end; } @@ -2407,11 +2433,12 @@ void tmq_commit_offset_async(tmq_t *tmq, const char *pTopicName, int32_t vgId, i code = asyncCommitOffset(tmq, tname, vgId, &offsetVal, cb, param); - tscInfo("consumer:0x%" PRIx64 " async send commit to vgId:%d, offset:%" PRId64" code:%s", tmq->consumerId, vgId, offset, tstrerror(code)); + tscInfo("consumer:0x%" PRIx64 " async send commit to vgId:%d, offset:%" PRId64 " code:%s", tmq->consumerId, vgId, + offset, tstrerror(code)); end: - if(code != 0 && cb != NULL){ - if(code == TSDB_CODE_TMQ_SAME_COMMITTED_VALUE) code = TSDB_CODE_SUCCESS; + if (code != 0 && cb != NULL) { + if (code == TSDB_CODE_TMQ_SAME_COMMITTED_VALUE) code = TSDB_CODE_SUCCESS; cb(tmq, code, param); } } @@ -2431,14 +2458,13 @@ int32_t askEpCb(void* param, SDataBuf* pMsg, int32_t code) { SMqRspHead* head = pMsg->pData; int32_t epoch = atomic_load_32(&tmq->epoch); - tscInfo("consumer:0x%" PRIx64 ", recv ep, msg epoch %d, current epoch %d", tmq->consumerId, - head->epoch, epoch); - if(pParam->sync){ + tscInfo("consumer:0x%" PRIx64 ", recv ep, msg epoch %d, current epoch %d", tmq->consumerId, head->epoch, epoch); + if (pParam->sync) { SMqAskEpRsp rsp = {0}; tDecodeSMqAskEpRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &rsp); doUpdateLocalEp(tmq, head->epoch, &rsp); tDeleteSMqAskEpRsp(&rsp); - }else{ + } else { SMqAskEpRspWrapper* pWrapper = taosAllocateQitem(sizeof(SMqAskEpRspWrapper), DEF_QITEM, 0); if (pWrapper == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; @@ -2457,7 +2483,7 @@ END: taosReleaseRef(tmqMgmt.rsetId, pParam->refId); FAIL: - if(pParam->sync){ + if (pParam->sync) { SAskEpInfo* pInfo = pParam->pParam; pInfo->code = code; tsem_post(&pInfo->sem); @@ -2485,11 +2511,11 @@ int32_t syncAskEp(tmq_t* pTmq) { void askEp(tmq_t* pTmq, void* param, bool sync, bool updateEpSet) { SMqAskEpReq req = {0}; req.consumerId = pTmq->consumerId; - req.epoch = updateEpSet ? -1 :pTmq->epoch; + req.epoch = updateEpSet ? -1 : pTmq->epoch; strcpy(req.cgroup, pTmq->groupId); - int code = 0; + int code = 0; SMqAskEpCbParam* pParam = NULL; - void* pReq = NULL; + void* pReq = NULL; int32_t tlen = tSerializeSMqAskEpReq(NULL, 0, &req); if (tlen < 0) { @@ -2541,7 +2567,7 @@ void askEp(tmq_t* pTmq, void* param, bool sync, bool updateEpSet) { int64_t transporterId = 0; code = asyncSendMsgToServer(pTmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); - if(code == 0){ + if (code == 0) { return; } @@ -2566,7 +2592,7 @@ int32_t tmqCommitDone(SMqCommitCbParamSet* pParamSet) { } // if no more waiting rsp - if(pParamSet->callbackFn != NULL){ + if (pParamSet->callbackFn != NULL) { pParamSet->callbackFn(tmq, pParamSet->code, pParamSet->userParam); } @@ -2578,10 +2604,12 @@ int32_t tmqCommitDone(SMqCommitCbParamSet* pParamSet) { void commitRspCountDown(SMqCommitCbParamSet* pParamSet, int64_t consumerId, const char* pTopic, int32_t vgId) { int32_t waitingRspNum = atomic_sub_fetch_32(&pParamSet->waitingRspNum, 1); if (waitingRspNum == 0) { - tscInfo("consumer:0x%" PRIx64 " topic:%s vgId:%d all commit-rsp received, commit completed", consumerId, pTopic, vgId); + tscInfo("consumer:0x%" PRIx64 " topic:%s vgId:%d all commit-rsp received, commit completed", consumerId, pTopic, + vgId); tmqCommitDone(pParamSet); } else { - tscInfo("consumer:0x%" PRIx64 " topic:%s vgId:%d commit-rsp received, remain:%d", consumerId, pTopic, vgId, waitingRspNum); + tscInfo("consumer:0x%" PRIx64 " topic:%s vgId:%d commit-rsp received, remain:%d", consumerId, pTopic, vgId, + waitingRspNum); } } @@ -2590,7 +2618,8 @@ SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4) { pRspObj->resIter++; if (pRspObj->resIter < pRspObj->rsp.blockNum) { - SRetrieveTableRspForTmq* pRetrieveTmq = (SRetrieveTableRspForTmq*)taosArrayGetP(pRspObj->rsp.blockData, pRspObj->resIter); + SRetrieveTableRspForTmq* pRetrieveTmq = + (SRetrieveTableRspForTmq*)taosArrayGetP(pRspObj->rsp.blockData, pRspObj->resIter); if (pRspObj->rsp.withSchema) { SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(pRspObj->rsp.blockSchema, pRspObj->resIter); setResSchemaInfo(&pRspObj->resInfo, pSW->pSchema, pSW->nCols); @@ -2609,7 +2638,7 @@ SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4) { // TODO handle the compressed case pRspObj->resInfo.totalRows += pRspObj->resInfo.numOfRows; setResultDataPtr(&pRspObj->resInfo, pRspObj->resInfo.fields, pRspObj->resInfo.numOfCols, pRspObj->resInfo.numOfRows, - convertUcs4); + convertUcs4); return &pRspObj->resInfo; } @@ -2619,7 +2648,7 @@ SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4) { static int32_t tmqGetWalInfoCb(void* param, SDataBuf* pMsg, int32_t code) { SMqVgWalInfoParam* pParam = param; - SMqVgCommon* pCommon = pParam->pCommon; + SMqVgCommon* pCommon = pParam->pCommon; int32_t total = atomic_add_fetch_32(&pCommon->numOfRsp, 1); if (code != TSDB_CODE_SUCCESS) { @@ -2628,7 +2657,7 @@ static int32_t tmqGetWalInfoCb(void* param, SDataBuf* pMsg, int32_t code) { pCommon->code = code; } else { SMqDataRsp rsp; - SDecoder decoder; + SDecoder decoder; tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead)); tDecodeMqDataRsp(&decoder, &rsp); tDecoderClear(&decoder); @@ -2656,7 +2685,7 @@ static int32_t tmqGetWalInfoCb(void* param, SDataBuf* pMsg, int32_t code) { } static void destroyCommonInfo(SMqVgCommon* pCommon) { - if(pCommon == NULL){ + if (pCommon == NULL) { return; } taosArrayDestroy(pCommon->pList); @@ -2666,7 +2695,7 @@ static void destroyCommonInfo(SMqVgCommon* pCommon) { taosMemoryFree(pCommon); } -static bool isInSnapshotMode(int8_t type, bool useSnapshot){ +static bool isInSnapshotMode(int8_t type, bool useSnapshot) { if ((type < TMQ_OFFSET__LOG && useSnapshot) || type > TMQ_OFFSET__LOG) { return true; } @@ -2676,7 +2705,7 @@ static bool isInSnapshotMode(int8_t type, bool useSnapshot){ static int32_t tmCommittedCb(void* param, SDataBuf* pMsg, int32_t code) { SMqCommittedParam* pParam = param; - if (code != 0){ + if (code != 0) { goto end; } if (pMsg) { @@ -2689,8 +2718,8 @@ static int32_t tmCommittedCb(void* param, SDataBuf* pMsg, int32_t code) { tDecoderClear(&decoder); } - end: - if(pMsg){ +end: + if (pMsg) { taosMemoryFree(pMsg->pData); taosMemoryFree(pMsg->pEpSet); } @@ -2699,8 +2728,8 @@ static int32_t tmCommittedCb(void* param, SDataBuf* pMsg, int32_t code) { return 0; } -int64_t getCommittedFromServer(tmq_t *tmq, char* tname, int32_t vgId, SEpSet* epSet){ - int32_t code = 0; +int64_t getCommittedFromServer(tmq_t* tmq, char* tname, int32_t vgId, SEpSet* epSet) { + int32_t code = 0; SMqVgOffset pOffset = {0}; pOffset.consumerId = tmq->consumerId; @@ -2753,7 +2782,7 @@ int64_t getCommittedFromServer(tmq_t *tmq, char* tname, int32_t vgId, SEpSet* ep int64_t transporterId = 0; code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, epSet, &transporterId, sendInfo); - if(code != 0){ + if (code != 0) { taosMemoryFree(buf); taosMemoryFree(sendInfo); tsem_destroy(&pParam->sem); @@ -2763,10 +2792,10 @@ int64_t getCommittedFromServer(tmq_t *tmq, char* tname, int32_t vgId, SEpSet* ep tsem_wait(&pParam->sem); code = pParam->code; - if(code == TSDB_CODE_SUCCESS){ - if(pParam->vgOffset.offset.val.type == TMQ_OFFSET__LOG){ + if (code == TSDB_CODE_SUCCESS) { + if (pParam->vgOffset.offset.val.type == TMQ_OFFSET__LOG) { code = pParam->vgOffset.offset.val.version; - }else{ + } else { code = TSDB_CODE_TMQ_SNAPSHOT_ERROR; } } @@ -2776,27 +2805,27 @@ int64_t getCommittedFromServer(tmq_t *tmq, char* tname, int32_t vgId, SEpSet* ep return code; } -int64_t tmq_position(tmq_t *tmq, const char *pTopicName, int32_t vgId){ +int64_t tmq_position(tmq_t* tmq, const char* pTopicName, int32_t vgId) { if (tmq == NULL || pTopicName == NULL) { tscError("invalid tmq handle, null"); return TSDB_CODE_INVALID_PARA; } int32_t accId = tmq->pTscObj->acctId; - char tname[TSDB_TOPIC_FNAME_LEN] = {0}; + char tname[TSDB_TOPIC_FNAME_LEN] = {0}; sprintf(tname, "%d.%s", accId, pTopicName); taosWLockLatch(&tmq->lock); SMqClientVg* pVg = NULL; - int32_t code = getClientVg(tmq, tname, vgId, &pVg); - if(code != 0){ + int32_t code = getClientVg(tmq, tname, vgId, &pVg); + if (code != 0) { taosWUnLockLatch(&tmq->lock); return code; } SVgOffsetInfo* pOffsetInfo = &pVg->offsetInfo; - int32_t type = pOffsetInfo->endOffset.type; + int32_t type = pOffsetInfo->endOffset.type; if (isInSnapshotMode(type, tmq->useSnapshot)) { tscError("consumer:0x%" PRIx64 " offset type:%d not wal version, position error", tmq->consumerId, type); taosWUnLockLatch(&tmq->lock); @@ -2808,26 +2837,26 @@ int64_t tmq_position(tmq_t *tmq, const char *pTopicName, int32_t vgId){ taosWUnLockLatch(&tmq->lock); return code; } - SEpSet epSet = pVg->epSet; + SEpSet epSet = pVg->epSet; int64_t begin = pVg->offsetInfo.walVerBegin; int64_t end = pVg->offsetInfo.walVerEnd; taosWUnLockLatch(&tmq->lock); int64_t position = 0; - if(type == TMQ_OFFSET__LOG){ + if (type == TMQ_OFFSET__LOG) { position = pOffsetInfo->endOffset.version; - }else if(type == TMQ_OFFSET__RESET_EARLIEST || type == TMQ_OFFSET__RESET_LATEST){ + } else if (type == TMQ_OFFSET__RESET_EARLIEST || type == TMQ_OFFSET__RESET_LATEST) { code = getCommittedFromServer(tmq, tname, vgId, &epSet); - if(code == TSDB_CODE_TMQ_NO_COMMITTED){ - if(type == TMQ_OFFSET__RESET_EARLIEST){ + if (code == TSDB_CODE_TMQ_NO_COMMITTED) { + if (type == TMQ_OFFSET__RESET_EARLIEST) { position = begin; - } else if(type == TMQ_OFFSET__RESET_LATEST){ + } else if (type == TMQ_OFFSET__RESET_LATEST) { position = end; } - }else{ + } else { position = code; } - }else{ + } else { tscError("consumer:0x%" PRIx64 " offset type:%d can not be reach here", tmq->consumerId, type); } @@ -2835,40 +2864,42 @@ int64_t tmq_position(tmq_t *tmq, const char *pTopicName, int32_t vgId){ return position; } -int64_t tmq_committed(tmq_t *tmq, const char *pTopicName, int32_t vgId){ +int64_t tmq_committed(tmq_t* tmq, const char* pTopicName, int32_t vgId) { if (tmq == NULL || pTopicName == NULL) { tscError("invalid tmq handle, null"); return TSDB_CODE_INVALID_PARA; } int32_t accId = tmq->pTscObj->acctId; - char tname[TSDB_TOPIC_FNAME_LEN] = {0}; + char tname[TSDB_TOPIC_FNAME_LEN] = {0}; sprintf(tname, "%d.%s", accId, pTopicName); taosWLockLatch(&tmq->lock); SMqClientVg* pVg = NULL; - int32_t code = getClientVg(tmq, tname, vgId, &pVg); - if(code != 0){ + int32_t code = getClientVg(tmq, tname, vgId, &pVg); + if (code != 0) { taosWUnLockLatch(&tmq->lock); return code; } SVgOffsetInfo* pOffsetInfo = &pVg->offsetInfo; if (isInSnapshotMode(pOffsetInfo->endOffset.type, tmq->useSnapshot)) { - tscError("consumer:0x%" PRIx64 " offset type:%d not wal version, committed error", tmq->consumerId, pOffsetInfo->endOffset.type); + tscError("consumer:0x%" PRIx64 " offset type:%d not wal version, committed error", tmq->consumerId, + pOffsetInfo->endOffset.type); taosWUnLockLatch(&tmq->lock); return TSDB_CODE_TMQ_SNAPSHOT_ERROR; } if (isInSnapshotMode(pOffsetInfo->committedOffset.type, tmq->useSnapshot)) { - tscError("consumer:0x%" PRIx64 " offset type:%d not wal version, committed error", tmq->consumerId, pOffsetInfo->committedOffset.type); + tscError("consumer:0x%" PRIx64 " offset type:%d not wal version, committed error", tmq->consumerId, + pOffsetInfo->committedOffset.type); taosWUnLockLatch(&tmq->lock); return TSDB_CODE_TMQ_SNAPSHOT_ERROR; } int64_t committed = 0; - if(pOffsetInfo->committedOffset.type == TMQ_OFFSET__LOG){ + if (pOffsetInfo->committedOffset.type == TMQ_OFFSET__LOG) { committed = pOffsetInfo->committedOffset.version; taosWUnLockLatch(&tmq->lock); goto end; @@ -2885,7 +2916,7 @@ end: int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_assignment** assignment, int32_t* numOfAssignment) { - if(tmq == NULL || pTopicName == NULL || assignment == NULL || numOfAssignment == NULL){ + if (tmq == NULL || pTopicName == NULL || assignment == NULL || numOfAssignment == NULL) { tscError("invalid tmq handle, null"); return TSDB_CODE_INVALID_PARA; } @@ -2909,7 +2940,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a *numOfAssignment = taosArrayGetSize(pTopic->vgs); for (int32_t j = 0; j < (*numOfAssignment); ++j) { SMqClientVg* pClientVg = taosArrayGet(pTopic->vgs, j); - int32_t type = pClientVg->offsetInfo.beginOffset.type; + int32_t type = pClientVg->offsetInfo.beginOffset.type; if (isInSnapshotMode(type, tmq->useSnapshot)) { tscError("consumer:0x%" PRIx64 " offset type:%d not wal version, assignment not allowed", tmq->consumerId, type); code = TSDB_CODE_TMQ_SNAPSHOT_ERROR; @@ -2939,8 +2970,8 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a pAssignment->begin = pClientVg->offsetInfo.walVerBegin; pAssignment->end = pClientVg->offsetInfo.walVerEnd; pAssignment->vgId = pClientVg->vgId; - tscInfo("consumer:0x%" PRIx64 " get assignment from local:%d->%" PRId64, tmq->consumerId, - pAssignment->vgId, pAssignment->currentOffset); + tscInfo("consumer:0x%" PRIx64 " get assignment from local:%d->%" PRId64, tmq->consumerId, pAssignment->vgId, + pAssignment->currentOffset); } if (needFetch) { @@ -2951,7 +2982,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a goto end; } - pCommon->pList= taosArrayInit(4, sizeof(tmq_topic_assignment)); + pCommon->pList = taosArrayInit(4, sizeof(tmq_topic_assignment)); tsem_init(&pCommon->rsp, 0, 0); taosThreadMutexInit(&pCommon->mutex, 0); pCommon->pTopicName = taosStrdup(pTopic->topicName); @@ -3019,7 +3050,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a tscInfo("consumer:0x%" PRIx64 " %s retrieve wal info vgId:%d, epoch %d, req:%s, reqId:0x%" PRIx64, tmq->consumerId, pTopic->topicName, pClientVg->vgId, tmq->epoch, offsetFormatBuf, req.reqId); code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pClientVg->epSet, &transporterId, sendInfo); - if(code != 0){ + if (code != 0) { taosMemoryFree(pParam); taosMemoryFree(msg); goto end; @@ -3034,7 +3065,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a goto end; } int32_t num = taosArrayGetSize(pCommon->pList); - for(int32_t i = 0; i < num; ++i) { + for (int32_t i = 0; i < num; ++i) { (*assignment)[i] = *(tmq_topic_assignment*)taosArrayGet(pCommon->pList, i); } *numOfAssignment = num; @@ -3042,14 +3073,15 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a for (int32_t j = 0; j < (*numOfAssignment); ++j) { tmq_topic_assignment* p = &(*assignment)[j]; - for(int32_t i = 0; i < taosArrayGetSize(pTopic->vgs); ++i) { + for (int32_t i = 0; i < taosArrayGetSize(pTopic->vgs); ++i) { SMqClientVg* pClientVg = taosArrayGet(pTopic->vgs, i); if (pClientVg->vgId != p->vgId) { continue; } SVgOffsetInfo* pOffsetInfo = &pClientVg->offsetInfo; - tscInfo("consumer:0x%" PRIx64 " %s vgId:%d offset is update to:%"PRId64, tmq->consumerId, pTopic->topicName, p->vgId, p->currentOffset); + tscInfo("consumer:0x%" PRIx64 " %s vgId:%d offset is update to:%" PRId64, tmq->consumerId, pTopic->topicName, + p->vgId, p->currentOffset); pOffsetInfo->walVerBegin = p->begin; pOffsetInfo->walVerEnd = p->end; @@ -3058,7 +3090,7 @@ int32_t tmq_get_topic_assignment(tmq_t* tmq, const char* pTopicName, tmq_topic_a } end: - if(code != TSDB_CODE_SUCCESS){ + if (code != TSDB_CODE_SUCCESS) { taosMemoryFree(*assignment); *assignment = NULL; *numOfAssignment = 0; @@ -3069,11 +3101,11 @@ end: } void tmq_free_assignment(tmq_topic_assignment* pAssignment) { - if (pAssignment == NULL) { - return; - } + if (pAssignment == NULL) { + return; + } - taosMemoryFree(pAssignment); + taosMemoryFree(pAssignment); } static int32_t tmqSeekCb(void* param, SDataBuf* pMsg, int32_t code) { @@ -3087,7 +3119,8 @@ static int32_t tmqSeekCb(void* param, SDataBuf* pMsg, int32_t code) { return 0; } -// seek interface have to send msg to server to cancel push handle if needed, because consumer may be in wait status if there is no data to poll +// seek interface have to send msg to server to cancel push handle if needed, because consumer may be in wait status if +// there is no data to poll int32_t tmq_offset_seek(tmq_t* tmq, const char* pTopicName, int32_t vgId, int64_t offset) { if (tmq == NULL || pTopicName == NULL) { tscError("invalid tmq handle, null"); @@ -3095,14 +3128,14 @@ int32_t tmq_offset_seek(tmq_t* tmq, const char* pTopicName, int32_t vgId, int64_ } int32_t accId = tmq->pTscObj->acctId; - char tname[TSDB_TOPIC_FNAME_LEN] = {0}; + char tname[TSDB_TOPIC_FNAME_LEN] = {0}; sprintf(tname, "%d.%s", accId, pTopicName); taosWLockLatch(&tmq->lock); SMqClientVg* pVg = NULL; - int32_t code = getClientVg(tmq, tname, vgId, &pVg); - if(code != 0){ + int32_t code = getClientVg(tmq, tname, vgId, &pVg); + if (code != 0) { taosWUnLockLatch(&tmq->lock); return code; } @@ -3174,7 +3207,7 @@ int32_t tmq_offset_seek(tmq_t* tmq, const char* pTopicName, int32_t vgId, int64_ int64_t transporterId = 0; code = asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); - if(code != 0){ + if (code != 0) { taosMemoryFree(msg); taosMemoryFree(sendInfo); tsem_destroy(&pParam->sem); @@ -3192,9 +3225,9 @@ int32_t tmq_offset_seek(tmq_t* tmq, const char* pTopicName, int32_t vgId, int64_ return code; } -TAOS *tmq_get_connect(tmq_t *tmq){ +TAOS* tmq_get_connect(tmq_t* tmq) { if (tmq && tmq->pTscObj) { - return (TAOS *)(&(tmq->pTscObj->id)); + return (TAOS*)(&(tmq->pTscObj->id)); } return NULL; } diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 5382259899..d364a58494 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -866,9 +866,9 @@ size_t blockDataGetRowSize(SSDataBlock* pBlock) { * @return */ size_t blockDataGetSerialMetaSize(uint32_t numOfCols) { - // | version | total length | total rows | total columns | flag seg| block group id | column schema + // | version | total length | total rows | blankFull | total columns | flag seg| block group id | column schema // | each column length | - return sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(uint64_t) + + return sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(bool) + sizeof(int32_t) + sizeof(int32_t) + sizeof(uint64_t) + numOfCols * (sizeof(int8_t) + sizeof(int32_t)) + numOfCols * sizeof(int32_t); } @@ -1436,6 +1436,7 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData) { pBlock->info.capacity = 0; pBlock->info.rowSize = 0; pBlock->info.id = pDataBlock->info.id; + pBlock->info.blankFill = pDataBlock->info.blankFill; size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock); for (int32_t i = 0; i < numOfCols; ++i) { @@ -2282,6 +2283,10 @@ int32_t blockEncode(const SSDataBlock* pBlock, char* data, int32_t numOfCols) { // htonl(colSizes[col]), colSizes[col]); } + bool* blankFill = (bool*)data; + *blankFill = pBlock->info.blankFill; + data += sizeof(bool); + *actualLen = dataLen; *groupId = pBlock->info.id.groupId; ASSERT(dataLen > 0); @@ -2375,8 +2380,12 @@ const char* blockDecode(SSDataBlock* pBlock, const char* pData) { pStart += colLen[i]; } + bool blankFill = *(bool*)pStart; + pStart += sizeof(bool); + pBlock->info.dataLoad = 1; pBlock->info.rows = numOfRows; + pBlock->info.blankFill = blankFill; ASSERT(pStart - pData == dataLen); return pStart; } diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index baa2a233d5..ee85a909e7 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -1606,10 +1606,6 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, char *name) { tsTempSpace.reserved = (int64_t)(((double)pItem->fval) * 1024 * 1024 * 1024); uInfo("%s set to %" PRId64, name, tsTempSpace.reserved); matched = true; - } else if (strcasecmp("minimalDataDirGB", name) == 0) { - tsDataSpace.reserved = (int64_t)(((double)pItem->fval) * 1024 * 1024 * 1024); - uInfo("%s set to %" PRId64, name, tsDataSpace.reserved); - matched = true; } else if (strcasecmp("minimalLogDirGB", name) == 0) { tsLogSpace.reserved = (int64_t)(((double)pItem->fval) * 1024 * 1024 * 1024); uInfo("%s set to %" PRId64, name, tsLogSpace.reserved); @@ -1680,10 +1676,6 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, char *name) { return -1; } matched = true; - } else if (strcasecmp("telemetryServer", name) == 0) { - uInfo("%s set from %s to %s", name, pItem->str, tsTelemServer); - tstrncpy(tsTelemServer, pItem->str, TSDB_FQDN_LEN); - matched = true; } break; } diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 19de4561d6..fc58fabad5 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -699,6 +699,7 @@ typedef struct { int64_t checkpointId; int32_t indexForMultiAggBalance; + int8_t subTableWithoutMd5; char reserve[256]; } SStreamObj; @@ -776,8 +777,8 @@ typedef enum { GRANT_STATE_REASON_MAX, } EGrantStateReason; -#define GRANT_STATE_NUM 30 -#define GRANT_ACTIVE_NUM 10 +#define GRANT_STATE_NUM 30 +#define GRANT_ACTIVE_NUM 10 #define GRANT_ACTIVE_HEAD_LEN 30 typedef struct { @@ -812,7 +813,7 @@ typedef struct { int64_t id : 24; }; }; - char machine[TSDB_MACHINE_ID_LEN + 1]; + char machine[TSDB_MACHINE_ID_LEN + 1]; } SGrantMachine; typedef struct { diff --git a/source/dnode/mnode/impl/inc/mndStream.h b/source/dnode/mnode/impl/inc/mndStream.h index 4d1125a340..1084340dc2 100644 --- a/source/dnode/mnode/impl/inc/mndStream.h +++ b/source/dnode/mnode/impl/inc/mndStream.h @@ -24,7 +24,7 @@ extern "C" { #endif #define MND_STREAM_RESERVE_SIZE 64 -#define MND_STREAM_VER_NUMBER 4 +#define MND_STREAM_VER_NUMBER 5 #define MND_STREAM_CREATE_NAME "stream-create" #define MND_STREAM_CHECKPOINT_NAME "stream-checkpoint" diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index c7ae36b02c..f60d8035e3 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -15,20 +15,20 @@ #define _DEFAULT_SOURCE #include "mndConsumer.h" -#include "mndPrivilege.h" -#include "mndVgroup.h" -#include "mndShow.h" #include "mndDb.h" +#include "mndPrivilege.h" +#include "mndShow.h" #include "mndSubscribe.h" #include "mndTopic.h" #include "mndTrans.h" +#include "mndVgroup.h" #include "tcompare.h" #include "tname.h" #define MND_CONSUMER_VER_NUMBER 2 #define MND_CONSUMER_RESERVE_SIZE 64 -#define MND_MAX_GROUP_PER_TOPIC 100 +#define MND_MAX_GROUP_PER_TOPIC 100 static int32_t mndConsumerActionInsert(SSdb *pSdb, SMqConsumerObj *pConsumer); static int32_t mndConsumerActionDelete(SSdb *pSdb, SMqConsumerObj *pConsumer); @@ -56,7 +56,7 @@ int32_t mndInitConsumer(SMnode *pMnode) { mndSetMsgHandle(pMnode, TDMT_MND_TMQ_SUBSCRIBE, mndProcessSubscribeReq); mndSetMsgHandle(pMnode, TDMT_MND_TMQ_HB, mndProcessMqHbReq); mndSetMsgHandle(pMnode, TDMT_MND_TMQ_ASK_EP, mndProcessAskEpReq); -// mndSetMsgHandle(pMnode, TDMT_MND_TMQ_TIMER, mndProcessMqTimerMsg); + // mndSetMsgHandle(pMnode, TDMT_MND_TMQ_TIMER, mndProcessMqTimerMsg); mndSetMsgHandle(pMnode, TDMT_MND_TMQ_CONSUMER_RECOVER, mndProcessConsumerRecoverMsg); mndSetMsgHandle(pMnode, TDMT_MND_TMQ_LOST_CONSUMER_CLEAR, mndProcessConsumerClearMsg); @@ -68,10 +68,11 @@ int32_t mndInitConsumer(SMnode *pMnode) { void mndCleanupConsumer(SMnode *pMnode) {} -void mndDropConsumerFromSdb(SMnode *pMnode, int64_t consumerId, SRpcHandleInfo* info){ +void mndDropConsumerFromSdb(SMnode *pMnode, int64_t consumerId, SRpcHandleInfo *info) { SMqConsumerClearMsg *pClearMsg = rpcMallocCont(sizeof(SMqConsumerClearMsg)); if (pClearMsg == NULL) { - mError("consumer:0x%"PRIx64" failed to clear consumer due to out of memory. alloc size:%d", consumerId, (int32_t)sizeof(SMqConsumerClearMsg)); + mError("consumer:0x%" PRIx64 " failed to clear consumer due to out of memory. alloc size:%d", consumerId, + (int32_t)sizeof(SMqConsumerClearMsg)); return; } @@ -88,13 +89,14 @@ void mndDropConsumerFromSdb(SMnode *pMnode, int64_t consumerId, SRpcHandleInfo* return; } -static int32_t validateTopics(STrans *pTrans, const SArray *pTopicList, SMnode *pMnode, const char *pUser, bool enableReplay) { +static int32_t validateTopics(STrans *pTrans, const SArray *pTopicList, SMnode *pMnode, const char *pUser, + bool enableReplay) { SMqTopicObj *pTopic = NULL; - int32_t code = 0; + int32_t code = 0; int32_t numOfTopics = taosArrayGetSize(pTopicList); for (int32_t i = 0; i < numOfTopics; i++) { - char *pOneTopic = taosArrayGetP(pTopicList, i); + char *pOneTopic = taosArrayGetP(pTopicList, i); pTopic = mndAcquireTopic(pMnode, pOneTopic); if (pTopic == NULL) { // terrno has been set by callee function code = -1; @@ -112,11 +114,11 @@ static int32_t validateTopics(STrans *pTrans, const SArray *pTopicList, SMnode * goto FAILED; } - if(enableReplay){ - if(pTopic->subType != TOPIC_SUB_TYPE__COLUMN){ + if (enableReplay) { + if (pTopic->subType != TOPIC_SUB_TYPE__COLUMN) { code = TSDB_CODE_TMQ_REPLAY_NOT_SUPPORT; goto FAILED; - }else if(pTopic->ntbUid == 0 && pTopic->ctbStbUid == 0) { + } else if (pTopic->ntbUid == 0 && pTopic->ctbStbUid == 0) { SDbObj *pDb = mndAcquireDb(pMnode, pTopic->db); if (pDb == NULL) { code = -1; @@ -132,7 +134,7 @@ static int32_t validateTopics(STrans *pTrans, const SArray *pTopicList, SMnode * } mndTransSetDbName(pTrans, pOneTopic, NULL); - if(mndTransCheckConflict(pMnode, pTrans) != 0){ + if (mndTransCheckConflict(pMnode, pTrans) != 0) { code = -1; goto FAILED; } @@ -172,7 +174,7 @@ static int32_t mndProcessConsumerRecoverMsg(SRpcMsg *pMsg) { if (pTrans == NULL) { goto FAIL; } - if(validateTopics(pTrans, pConsumer->assignedTopics, pMnode, pMsg->info.conn.user, false) != 0){ + if (validateTopics(pTrans, pConsumer->assignedTopics, pMnode, pMsg->info.conn.user, false) != 0) { goto FAIL; } @@ -197,7 +199,7 @@ static int32_t mndProcessConsumerClearMsg(SRpcMsg *pMsg) { SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, pClearMsg->consumerId); if (pConsumer == NULL) { - mError("consumer:0x%"PRIx64" failed to be found to clear it", pClearMsg->consumerId); + mError("consumer:0x%" PRIx64 " failed to be found to clear it", pClearMsg->consumerId); return 0; } @@ -226,15 +228,15 @@ FAIL: return -1; } -static int32_t checkPrivilege(SMnode *pMnode, SMqConsumerObj *pConsumer, SMqHbRsp *rsp, char* user){ +static int32_t checkPrivilege(SMnode *pMnode, SMqConsumerObj *pConsumer, SMqHbRsp *rsp, char *user) { rsp->topicPrivileges = taosArrayInit(taosArrayGetSize(pConsumer->currentTopics), sizeof(STopicPrivilege)); - if(rsp->topicPrivileges == NULL){ + if (rsp->topicPrivileges == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno; } - for(int32_t i = 0; i < taosArrayGetSize(pConsumer->currentTopics); i++){ - char *topic = taosArrayGetP(pConsumer->currentTopics, i); - SMqTopicObj* pTopic = mndAcquireTopic(pMnode, topic); + for (int32_t i = 0; i < taosArrayGetSize(pConsumer->currentTopics); i++) { + char *topic = taosArrayGetP(pConsumer->currentTopics, i); + SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); if (pTopic == NULL) { // terrno has been set by callee function continue; } @@ -252,10 +254,10 @@ static int32_t checkPrivilege(SMnode *pMnode, SMqConsumerObj *pConsumer, SMqHbR } static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { - int32_t code = 0; - SMnode *pMnode = pMsg->info.node; - SMqHbReq req = {0}; - SMqHbRsp rsp = {0}; + int32_t code = 0; + SMnode *pMnode = pMsg->info.node; + SMqHbReq req = {0}; + SMqHbRsp rsp = {0}; SMqConsumerObj *pConsumer = NULL; if (tDeserializeSMqHbReq(pMsg->pCont, pMsg->contLen, &req) < 0) { @@ -264,7 +266,7 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { goto end; } - int64_t consumerId = req.consumerId; + int64_t consumerId = req.consumerId; pConsumer = mndAcquireConsumer(pMnode, consumerId); if (pConsumer == NULL) { mError("consumer:0x%" PRIx64 " not exist", consumerId); @@ -273,7 +275,7 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { goto end; } code = checkPrivilege(pMnode, pConsumer, &rsp, pMsg->info.conn.user); - if(code != 0){ + if (code != 0) { goto end; } @@ -295,12 +297,12 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &pRpcMsg); } - for(int i = 0; i < taosArrayGetSize(req.topics); i++){ - TopicOffsetRows* data = taosArrayGet(req.topics, i); + for (int i = 0; i < taosArrayGetSize(req.topics); i++) { + TopicOffsetRows *data = taosArrayGet(req.topics, i); mInfo("heartbeat report offset rows.%s:%s", pConsumer->cgroup, data->topicName); SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, pConsumer->cgroup, data->topicName); - if(pSub == NULL){ + if (pSub == NULL) { #ifdef TMQ_DEBUG ASSERT(0); #endif @@ -308,7 +310,7 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { } taosWLockLatch(&pSub->lock); SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &consumerId, sizeof(int64_t)); - if(pConsumerEp){ + if (pConsumerEp) { taosArrayDestroy(pConsumerEp->offsetRows); pConsumerEp->offsetRows = data->offsetRows; data->offsetRows = NULL; @@ -413,7 +415,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) { char *topic = taosArrayGetP(pConsumer->currentTopics, i); SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, pConsumer->cgroup, topic); // txn guarantees pSub is created - if(pSub == NULL) { + if (pSub == NULL) { #ifdef TMQ_DEBUG ASSERT(0); #endif @@ -426,7 +428,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) { // 2.1 fetch topic schema SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); - if(pTopic == NULL) { + if (pTopic == NULL) { #ifdef TMQ_DEBUG ASSERT(0); #endif @@ -460,12 +462,12 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) { for (int32_t j = 0; j < vgNum; j++) { SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, j); -// char offsetKey[TSDB_PARTITION_KEY_LEN]; -// mndMakePartitionKey(offsetKey, pConsumer->cgroup, topic, pVgEp->vgId); + // char offsetKey[TSDB_PARTITION_KEY_LEN]; + // mndMakePartitionKey(offsetKey, pConsumer->cgroup, topic, pVgEp->vgId); - if(epoch == -1){ + if (epoch == -1) { SVgObj *pVgroup = mndAcquireVgroup(pMnode, pVgEp->vgId); - if(pVgroup){ + if (pVgroup) { pVgEp->epSet = mndGetVgroupEpset(pMnode, pVgroup); mndReleaseVgroup(pMnode, pVgroup); } @@ -495,7 +497,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) { goto FAIL; } - SMqRspHead* pHead = buf; + SMqRspHead *pHead = buf; pHead->mqMsgType = TMQ_MSG_TYPE__EP_RSP; pHead->epoch = serverEpoch; @@ -503,7 +505,6 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) { pHead->walsver = 0; pHead->walever = 0; - void *abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead)); tEncodeSMqAskEpRsp(&abuf, &rsp); @@ -552,29 +553,23 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { char *msgStr = pMsg->pCont; int32_t code = -1; - if ((terrno = grantCheck(TSDB_GRANT_SUBSCRIPTION)) < 0) { - code = terrno; - return code; - } - SCMSubscribeReq subscribe = {0}; tDeserializeSCMSubscribeReq(msgStr, &subscribe); - int64_t consumerId = subscribe.consumerId; + int64_t consumerId = subscribe.consumerId; char *cgroup = subscribe.cgroup; SMqConsumerObj *pExistedConsumer = NULL; SMqConsumerObj *pConsumerNew = NULL; - STrans *pTrans = NULL; + STrans *pTrans = NULL; - SArray *pTopicList = subscribe.topicNames; taosArraySort(pTopicList, taosArrayCompareString); taosArrayRemoveDuplicate(pTopicList, taosArrayCompareString, freeItem); int32_t newTopicNum = taosArrayGetSize(pTopicList); - for(int i = 0; i < newTopicNum; i++){ - int32_t gNum = mndGetGroupNumByTopic(pMnode, (const char*)taosArrayGetP(pTopicList, i)); - if(gNum >= MND_MAX_GROUP_PER_TOPIC){ + for (int i = 0; i < newTopicNum; i++) { + int32_t gNum = mndGetGroupNumByTopic(pMnode, (const char *)taosArrayGetP(pTopicList, i)); + if (gNum >= MND_MAX_GROUP_PER_TOPIC) { terrno = TSDB_CODE_TMQ_GROUP_OUT_OF_RANGE; code = terrno; goto _over; @@ -605,7 +600,7 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { pConsumerNew->autoCommitInterval = subscribe.autoCommitInterval; pConsumerNew->resetOffsetCfg = subscribe.resetOffsetCfg; -// pConsumerNew->updateType = CONSUMER_UPDATE_SUB; // use insert logic + // pConsumerNew->updateType = CONSUMER_UPDATE_SUB; // use insert logic taosArrayDestroy(pConsumerNew->assignedTopics); pConsumerNew->assignedTopics = taosArrayDup(pTopicList, topicNameDup); @@ -792,16 +787,15 @@ CM_DECODE_OVER: } static int32_t mndConsumerActionInsert(SSdb *pSdb, SMqConsumerObj *pConsumer) { - mInfo("consumer:0x%" PRIx64 " sub insert, cgroup:%s status:%d(%s) epoch:%d", - pConsumer->consumerId, pConsumer->cgroup, pConsumer->status, mndConsumerStatusName(pConsumer->status), - pConsumer->epoch); + mInfo("consumer:0x%" PRIx64 " sub insert, cgroup:%s status:%d(%s) epoch:%d", pConsumer->consumerId, pConsumer->cgroup, + pConsumer->status, mndConsumerStatusName(pConsumer->status), pConsumer->epoch); pConsumer->subscribeTime = pConsumer->createTime; return 0; } static int32_t mndConsumerActionDelete(SSdb *pSdb, SMqConsumerObj *pConsumer) { mInfo("consumer:0x%" PRIx64 " perform delete action, status:(%d)%s", pConsumer->consumerId, pConsumer->status, - mndConsumerStatusName(pConsumer->status)); + mndConsumerStatusName(pConsumer->status)); tDeleteSMqConsumerObj(pConsumer, false); return 0; } @@ -828,7 +822,7 @@ static void removeFromNewTopicList(SMqConsumerObj *pConsumer, const char *pTopic taosMemoryFree(p); mInfo("consumer:0x%" PRIx64 " remove new topic:%s in the topic list, remain newTopics:%d", pConsumer->consumerId, - pTopic, (int)taosArrayGetSize(pConsumer->rebNewTopics)); + pTopic, (int)taosArrayGetSize(pConsumer->rebNewTopics)); break; } } @@ -844,7 +838,7 @@ static void removeFromRemoveTopicList(SMqConsumerObj *pConsumer, const char *pTo taosMemoryFree(p); mInfo("consumer:0x%" PRIx64 " remove topic:%s in the removed topic list, remain removedTopics:%d", - pConsumer->consumerId, pTopic, (int)taosArrayGetSize(pConsumer->rebRemovedTopics)); + pConsumer->consumerId, pTopic, (int)taosArrayGetSize(pConsumer->rebRemovedTopics)); break; } } @@ -859,13 +853,13 @@ static void removeFromCurrentTopicList(SMqConsumerObj *pConsumer, const char *pT taosMemoryFree(topic); mInfo("consumer:0x%" PRIx64 " remove topic:%s in the current topic list, remain currentTopics:%d", - pConsumer->consumerId, pTopic, (int)taosArrayGetSize(pConsumer->currentTopics)); + pConsumer->consumerId, pTopic, (int)taosArrayGetSize(pConsumer->currentTopics)); break; } } } -static bool existInCurrentTopicList(const SMqConsumerObj* pConsumer, const char* pTopic) { +static bool existInCurrentTopicList(const SMqConsumerObj *pConsumer, const char *pTopic) { bool existing = false; int32_t size = taosArrayGetSize(pConsumer->currentTopics); for (int32_t i = 0; i < size; i++) { @@ -882,7 +876,7 @@ static bool existInCurrentTopicList(const SMqConsumerObj* pConsumer, const char* static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, SMqConsumerObj *pNewConsumer) { mInfo("consumer:0x%" PRIx64 " perform update action, update type:%d, subscribe-time:%" PRId64 ", createTime:%" PRId64, - pOldConsumer->consumerId, pNewConsumer->updateType, pOldConsumer->subscribeTime, pOldConsumer->createTime); + pOldConsumer->consumerId, pNewConsumer->updateType, pOldConsumer->subscribeTime, pOldConsumer->createTime); taosWLockLatch(&pOldConsumer->lock); @@ -893,19 +887,21 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, pOldConsumer->subscribeTime = taosGetTimestampMs(); pOldConsumer->status = MQ_CONSUMER_STATUS_REBALANCE; - mInfo("consumer:0x%" PRIx64 " sub update, modify existed consumer",pOldConsumer->consumerId); -// } else if (pNewConsumer->updateType == CONSUMER_UPDATE_TIMER_LOST) { -// int32_t sz = taosArrayGetSize(pOldConsumer->currentTopics); -// for (int32_t i = 0; i < sz; i++) { -// char *topic = taosStrdup(taosArrayGetP(pOldConsumer->currentTopics, i)); -// taosArrayPush(pOldConsumer->rebRemovedTopics, &topic); -// } -// -// int32_t prevStatus = pOldConsumer->status; -// pOldConsumer->status = MQ_CONSUMER_STATUS_LOST; -// mInfo("consumer:0x%" PRIx64 " timer update, timer lost. state %s -> %s, reb-time:%" PRId64 ", reb-removed-topics:%d", -// pOldConsumer->consumerId, mndConsumerStatusName(prevStatus), mndConsumerStatusName(pOldConsumer->status), -// pOldConsumer->rebalanceTime, (int)taosArrayGetSize(pOldConsumer->rebRemovedTopics)); + mInfo("consumer:0x%" PRIx64 " sub update, modify existed consumer", pOldConsumer->consumerId); + // } else if (pNewConsumer->updateType == CONSUMER_UPDATE_TIMER_LOST) { + // int32_t sz = taosArrayGetSize(pOldConsumer->currentTopics); + // for (int32_t i = 0; i < sz; i++) { + // char *topic = taosStrdup(taosArrayGetP(pOldConsumer->currentTopics, i)); + // taosArrayPush(pOldConsumer->rebRemovedTopics, &topic); + // } + // + // int32_t prevStatus = pOldConsumer->status; + // pOldConsumer->status = MQ_CONSUMER_STATUS_LOST; + // mInfo("consumer:0x%" PRIx64 " timer update, timer lost. state %s -> %s, reb-time:%" PRId64 ", + // reb-removed-topics:%d", + // pOldConsumer->consumerId, mndConsumerStatusName(prevStatus), + // mndConsumerStatusName(pOldConsumer->status), pOldConsumer->rebalanceTime, + // (int)taosArrayGetSize(pOldConsumer->rebRemovedTopics)); } else if (pNewConsumer->updateType == CONSUMER_UPDATE_REC) { int32_t sz = taosArrayGetSize(pOldConsumer->assignedTopics); for (int32_t i = 0; i < sz; i++) { @@ -914,7 +910,7 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, } pOldConsumer->status = MQ_CONSUMER_STATUS_REBALANCE; - mInfo("consumer:0x%" PRIx64 " timer update, timer recover",pOldConsumer->consumerId); + mInfo("consumer:0x%" PRIx64 " timer update, timer recover", pOldConsumer->consumerId); } else if (pNewConsumer->updateType == CONSUMER_UPDATE_REB) { atomic_add_fetch_32(&pOldConsumer->epoch, 1); @@ -945,11 +941,11 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, atomic_add_fetch_32(&pOldConsumer->epoch, 1); mInfo("consumer:0x%" PRIx64 " reb update add, state (%d)%s -> (%d)%s, new epoch:%d, reb-time:%" PRId64 - ", current topics:%d, newTopics:%d, removeTopics:%d", - pOldConsumer->consumerId, status, mndConsumerStatusName(status), pOldConsumer->status, - mndConsumerStatusName(pOldConsumer->status), pOldConsumer->epoch, pOldConsumer->rebalanceTime, - (int)taosArrayGetSize(pOldConsumer->currentTopics), (int)taosArrayGetSize(pOldConsumer->rebNewTopics), - (int)taosArrayGetSize(pOldConsumer->rebRemovedTopics)); + ", current topics:%d, newTopics:%d, removeTopics:%d", + pOldConsumer->consumerId, status, mndConsumerStatusName(status), pOldConsumer->status, + mndConsumerStatusName(pOldConsumer->status), pOldConsumer->epoch, pOldConsumer->rebalanceTime, + (int)taosArrayGetSize(pOldConsumer->currentTopics), (int)taosArrayGetSize(pOldConsumer->rebNewTopics), + (int)taosArrayGetSize(pOldConsumer->rebRemovedTopics)); } else if (pNewConsumer->updateType == CONSUMER_REMOVE_REB) { char *removedTopic = taosArrayGetP(pNewConsumer->rebRemovedTopics, 0); @@ -968,11 +964,11 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, atomic_add_fetch_32(&pOldConsumer->epoch, 1); mInfo("consumer:0x%" PRIx64 " reb update remove, state (%d)%s -> (%d)%s, new epoch:%d, reb-time:%" PRId64 - ", current topics:%d, newTopics:%d, removeTopics:%d", - pOldConsumer->consumerId, status, mndConsumerStatusName(status), pOldConsumer->status, - mndConsumerStatusName(pOldConsumer->status), pOldConsumer->epoch, pOldConsumer->rebalanceTime, - (int)taosArrayGetSize(pOldConsumer->currentTopics), (int)taosArrayGetSize(pOldConsumer->rebNewTopics), - (int)taosArrayGetSize(pOldConsumer->rebRemovedTopics)); + ", current topics:%d, newTopics:%d, removeTopics:%d", + pOldConsumer->consumerId, status, mndConsumerStatusName(status), pOldConsumer->status, + mndConsumerStatusName(pOldConsumer->status), pOldConsumer->epoch, pOldConsumer->rebalanceTime, + (int)taosArrayGetSize(pOldConsumer->currentTopics), (int)taosArrayGetSize(pOldConsumer->rebNewTopics), + (int)taosArrayGetSize(pOldConsumer->rebRemovedTopics)); } taosWUnLockLatch(&pOldConsumer->lock); @@ -1030,8 +1026,8 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock * int32_t cols = 0; // consumer id - char consumerIdHex[32] = {0}; - sprintf(varDataVal(consumerIdHex), "0x%"PRIx64, pConsumer->consumerId); + char consumerIdHex[32] = {0}; + sprintf(varDataVal(consumerIdHex), "0x%" PRIx64, pConsumer->consumerId); varDataSetLen(consumerIdHex, strlen(varDataVal(consumerIdHex))); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); @@ -1086,12 +1082,13 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock * pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataSetVal(pColInfo, numOfRows, (const char *)&pConsumer->rebalanceTime, pConsumer->rebalanceTime == 0); - char buf[TSDB_OFFSET_LEN] = {0}; + char buf[TSDB_OFFSET_LEN] = {0}; STqOffsetVal pVal = {.type = pConsumer->resetOffsetCfg}; tFormatOffset(buf, TSDB_OFFSET_LEN, &pVal); char parasStr[64 + TSDB_OFFSET_LEN + VARSTR_HEADER_SIZE] = {0}; - sprintf(varDataVal(parasStr), "tbname:%d,commit:%d,interval:%dms,reset:%s", pConsumer->withTbName, pConsumer->autoCommit, pConsumer->autoCommitInterval, buf); + sprintf(varDataVal(parasStr), "tbname:%d,commit:%d,interval:%dms,reset:%s", pConsumer->withTbName, + pConsumer->autoCommit, pConsumer->autoCommitInterval, buf); varDataSetLen(parasStr, strlen(varDataVal(parasStr))); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); diff --git a/source/dnode/mnode/impl/src/mndDef.c b/source/dnode/mnode/impl/src/mndDef.c index d59354286d..5be641d1c2 100644 --- a/source/dnode/mnode/impl/src/mndDef.c +++ b/source/dnode/mnode/impl/src/mndDef.c @@ -85,6 +85,7 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) { // 3.0.50 ver = 3 if (tEncodeI64(pEncoder, pObj->checkpointId) < 0) return -1; + if (tEncodeI8(pEncoder, pObj->subTableWithoutMd5) < 0) return -1; if (tEncodeCStrWithLen(pEncoder, pObj->reserve, sizeof(pObj->reserve) - 1) < 0) return -1; @@ -168,6 +169,10 @@ int32_t tDecodeSStreamObj(SDecoder *pDecoder, SStreamObj *pObj, int32_t sver) { if (sver >= 3) { if (tDecodeI64(pDecoder, &pObj->checkpointId) < 0) return -1; } + + if (sver >= 5) { + if (tDecodeI8(pDecoder, &pObj->subTableWithoutMd5) < 0) return -1; + } if (tDecodeCStrTo(pDecoder, pObj->reserve) < 0) return -1; tEndDecode(pDecoder); diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index 88d326a5c4..cbc0ace75d 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -14,19 +14,41 @@ */ #include "mndScheduler.h" -#include "tmisce.h" -#include "mndMnode.h" #include "mndDb.h" +#include "mndMnode.h" #include "mndSnode.h" #include "mndVgroup.h" #include "parser.h" #include "tcompare.h" +#include "tmisce.h" #include "tname.h" #include "tuuid.h" #define SINK_NODE_LEVEL (0) extern bool tsDeployOnSnode; +static bool hasCountWindowNode(SPhysiNode* pNode) { + if (nodeType(pNode) == QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT) { + return true; + } else { + size_t size = LIST_LENGTH(pNode->pChildren); + + for (int32_t i = 0; i < size; ++i) { + SPhysiNode* pChild = (SPhysiNode*)nodesListGetNode(pNode->pChildren, i); + if (hasCountWindowNode(pChild)) { + return true; + } + } + + return false; + } +} + +static bool countWindowStreamTask(SSubplan* pPlan) { + SPhysiNode* pNode = pPlan->pNode; + return hasCountWindowNode(pNode); +} + 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; @@ -189,7 +211,7 @@ SVgObj* mndSchedFetchOneVg(SMnode* pMnode, SStreamObj* pStream) { return NULL; } - if(pStream->indexForMultiAggBalance == -1){ + if (pStream->indexForMultiAggBalance == -1) { taosSeedRand(taosSafeRand()); pStream->indexForMultiAggBalance = taosRand() % pDbObj->cfg.numOfVgroups; } @@ -204,7 +226,7 @@ SVgObj* mndSchedFetchOneVg(SMnode* pMnode, SStreamObj* pStream) { sdbRelease(pMnode->pSdb, pVgroup); continue; } - if (index++ == pStream->indexForMultiAggBalance){ + if (index++ == pStream->indexForMultiAggBalance) { pStream->indexForMultiAggBalance++; pStream->indexForMultiAggBalance %= pDbObj->cfg.numOfVgroups; sdbCancelFetch(pMnode->pSdb, pIter); @@ -217,12 +239,12 @@ SVgObj* mndSchedFetchOneVg(SMnode* pMnode, SStreamObj* pStream) { return pVgroup; } -static int32_t doAddSinkTask(SStreamObj* pStream, SMnode* pMnode, SVgObj* pVgroup, - SEpSet* pEpset, bool isFillhistory) { - int64_t uid = (isFillhistory) ? pStream->hTaskUid : pStream->uid; +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); + SStreamTask* pTask = tNewStreamTask(uid, TASK_LEVEL__SINK, pEpset, isFillhistory, 0, *pTaskList, + pStream->conf.fillHistory, pStream->subTableWithoutMd5); if (pTask == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno; @@ -235,12 +257,12 @@ static int32_t doAddSinkTask(SStreamObj* pStream, SMnode* pMnode, SVgObj* pVgrou return mndSetSinkTaskInfo(pStream, pTask); } -static int32_t doAddSinkTaskToVg(SMnode* pMnode, SStreamObj* pStream, SEpSet* pEpset, SVgObj* vgObj){ +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){ + if (pStream->conf.fillHistory) { code = doAddSinkTask(pStream, pMnode, vgObj, pEpset, true); if (code != 0) { return code; @@ -267,7 +289,7 @@ static int32_t doAddShuffleSinkTask(SMnode* pMnode, SStreamObj* pStream, SEpSet* } int32_t code = doAddSinkTaskToVg(pMnode, pStream, pEpset, pVgroup); - if(code != 0){ + if (code != 0) { sdbRelease(pSdb, pVgroup); return code; } @@ -279,7 +301,7 @@ static int32_t doAddShuffleSinkTask(SMnode* pMnode, SStreamObj* pStream, SEpSet* } static int64_t getVgroupLastVer(const SArray* pList, int32_t vgId) { - for(int32_t i = 0; i < taosArrayGetSize(pList); ++i) { + for (int32_t i = 0; i < taosArrayGetSize(pList); ++i) { SVgroupVer* pVer = taosArrayGet(pList, i); if (pVer->vgId == vgId) { return pVer->ver; @@ -315,19 +337,29 @@ static void streamTaskSetDataRange(SStreamTask* pTask, int64_t skey, SArray* pVe pRange->range.minVer = latestVer + 1; pRange->range.maxVer = INT64_MAX; - mDebug("add source task 0x%x timeWindow:%" PRId64 "-%" PRId64 " verRange:%" PRId64 "-%" PRId64, - pTask->id.taskId, pWindow->skey, pWindow->ekey, pRange->range.minVer, pRange->range.maxVer); + mDebug("add source task 0x%x timeWindow:%" PRId64 "-%" PRId64 " verRange:%" PRId64 "-%" PRId64, pTask->id.taskId, + pWindow->skey, pWindow->ekey, pRange->range.minVer, pRange->range.maxVer); } } -static SStreamTask* buildSourceTask(SStreamObj* pStream, SEpSet* pEpset, - bool isFillhistory, bool useTriggerParam) { +static void haltInitialTaskStatus(SStreamTask* pTask, SSubplan* pPlan) { + bool hasCountWindowNode = countWindowStreamTask(pPlan); + bool isRelStreamTask = (pTask->hTaskInfo.id.taskId != 0); + if (hasCountWindowNode && isRelStreamTask) { + SStreamStatus* pStatus = &pTask->status; + mDebug("s-task:0x%x status is set to %s from %s for count window agg task with fill-history option set", + pTask->id.taskId, streamTaskGetStatusStr(pStatus->taskStatus), streamTaskGetStatusStr(TASK_STATUS__HALT)); + pStatus->taskStatus = TASK_STATUS__HALT; + } +} + +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); + SStreamTask* pTask = + tNewStreamTask(uid, TASK_LEVEL__SOURCE, pEpset, isFillhistory, useTriggerParam ? pStream->conf.triggerParam : 0, + *pTaskList, pStream->conf.fillHistory, pStream->subTableWithoutMd5); if (pTask == NULL) { return NULL; } @@ -335,7 +367,7 @@ static SStreamTask* buildSourceTask(SStreamObj* pStream, SEpSet* pEpset, return pTask; } -static void addNewTaskList(SStreamObj* pStream){ +static void addNewTaskList(SStreamObj* pStream) { SArray* pTaskList = taosArrayInit(0, POINTER_BYTES); taosArrayPush(pStream->tasks, &pTaskList); if (pStream->conf.fillHistory) { @@ -364,28 +396,30 @@ static void setHTasksId(SStreamObj* pStream) { } } -static int32_t doAddSourceTask(SMnode* pMnode, SSubplan* plan, SStreamObj* pStream, SEpSet* pEpset, - int64_t skey, SArray* pVerList, SVgObj* pVgroup, bool isFillhistory, bool useTriggerParam ){ +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){ + 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); + haltInitialTaskStatus(pTask, plan); + streamTaskSetDataRange(pTask, skey, pVerList, pVgroup->vgId); int32_t code = mndAssignStreamTaskToVgroup(pMnode, pTask, plan, pVgroup); - if(code != 0){ + if (code != 0) { terrno = code; return terrno; } return TDB_CODE_SUCCESS; } -static SSubplan* getScanSubPlan(const SQueryPlan* pPlan){ - int32_t numOfPlanLevel = LIST_LENGTH(pPlan->pSubplans); +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; @@ -400,7 +434,7 @@ static SSubplan* getScanSubPlan(const SQueryPlan* pPlan){ return plan; } -static SSubplan* getAggSubPlan(const SQueryPlan* pPlan, int index){ +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; @@ -415,8 +449,8 @@ static SSubplan* getAggSubPlan(const SQueryPlan* pPlan, int index){ return plan; } -static int32_t addSourceTask(SMnode* pMnode, SSubplan* plan, SStreamObj* pStream, - SEpSet* pEpset, int64_t nextWindowSkey, SArray* pVerList, bool useTriggerParam) { +static int32_t addSourceTask(SMnode* pMnode, SSubplan* plan, SStreamObj* pStream, SEpSet* pEpset, + int64_t nextWindowSkey, SArray* pVerList, bool useTriggerParam) { addNewTaskList(pStream); void* pIter = NULL; @@ -433,15 +467,16 @@ static int32_t addSourceTask(SMnode* pMnode, SSubplan* plan, SStreamObj* pStream continue; } - int code = doAddSourceTask(pMnode, plan, pStream, pEpset, nextWindowSkey, pVerList, pVgroup, false, useTriggerParam); - if(code != 0){ + int code = + doAddSourceTask(pMnode, plan, pStream, pEpset, nextWindowSkey, pVerList, pVgroup, false, useTriggerParam); + if (code != 0) { sdbRelease(pSdb, pVgroup); return code; } if (pStream->conf.fillHistory) { code = doAddSourceTask(pMnode, plan, pStream, pEpset, nextWindowSkey, pVerList, pVgroup, true, useTriggerParam); - if(code != 0){ + if (code != 0) { sdbRelease(pSdb, pVgroup); return code; } @@ -461,9 +496,9 @@ static SStreamTask* buildAggTask(SStreamObj* pStream, SEpSet* pEpset, bool isFil 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); + SStreamTask* pAggTask = + tNewStreamTask(uid, TASK_LEVEL__AGG, pEpset, isFillhistory, useTriggerParam ? pStream->conf.triggerParam : 0, + *pTaskList, pStream->conf.fillHistory, pStream->subTableWithoutMd5); if (pAggTask == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; @@ -472,8 +507,8 @@ static SStreamTask* buildAggTask(SStreamObj* pStream, SEpSet* pEpset, bool isFil return pAggTask; } -static int32_t doAddAggTask(SStreamObj* pStream, SMnode* pMnode, SSubplan* plan, SEpSet* pEpset, - SVgObj* pVgroup, SSnodeObj* pSnode, bool isFillhistory, bool useTriggerParam){ +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) { @@ -490,7 +525,7 @@ static int32_t doAddAggTask(SStreamObj* pStream, SMnode* pMnode, SSubplan* plan, return code; } -static int32_t addAggTask(SStreamObj* pStream, SMnode* pMnode, SSubplan* plan, SEpSet* pEpset, bool useTriggerParam){ +static int32_t addAggTask(SStreamObj* pStream, SMnode* pMnode, SSubplan* plan, SEpSet* pEpset, bool useTriggerParam) { SVgObj* pVgroup = NULL; SSnodeObj* pSnode = NULL; int32_t code = 0; @@ -504,20 +539,20 @@ static int32_t addAggTask(SStreamObj* pStream, SMnode* pMnode, SSubplan* plan, S } code = doAddAggTask(pStream, pMnode, plan, pEpset, pVgroup, pSnode, false, useTriggerParam); - if(code != 0){ + if (code != 0) { goto END; } if (pStream->conf.fillHistory) { code = doAddAggTask(pStream, pMnode, plan, pEpset, pVgroup, pSnode, true, useTriggerParam); - if(code != 0){ + if (code != 0) { goto END; } setHTasksId(pStream); } - END: +END: if (pSnode != NULL) { sdbRelease(pMnode->pSdb, pSnode); } else { @@ -526,7 +561,7 @@ static int32_t addAggTask(SStreamObj* pStream, SMnode* pMnode, SSubplan* plan, S return code; } -static int32_t addSinkTask(SMnode* pMnode, SStreamObj* pStream, SEpSet* pEpset){ +static int32_t addSinkTask(SMnode* pMnode, SStreamObj* pStream, SEpSet* pEpset) { int32_t code = 0; addNewTaskList(pStream); @@ -548,9 +583,9 @@ static int32_t addSinkTask(SMnode* pMnode, SStreamObj* pStream, SEpSet* pEpset){ return TDB_CODE_SUCCESS; } -static void bindTaskToSinkTask(SStreamObj* pStream, SMnode* pMnode, SArray* pSinkTaskList, SStreamTask* task){ +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++) { + for (int32_t k = 0; k < taosArrayGetSize(pSinkTaskList); k++) { SStreamTask* pSinkTask = taosArrayGetP(pSinkTaskList, k); streamTaskSetUpstreamInfo(pSinkTask, task); } @@ -558,10 +593,10 @@ static void bindTaskToSinkTask(SStreamObj* pStream, SMnode* pMnode, SArray* pSin } static void bindAggSink(SStreamObj* pStream, SMnode* pMnode, SArray* tasks) { - SArray* pSinkTaskList = taosArrayGetP(tasks, SINK_NODE_LEVEL); + SArray* pSinkTaskList = taosArrayGetP(tasks, SINK_NODE_LEVEL); SArray** pAggTaskList = taosArrayGetLast(tasks); - for(int i = 0; i < taosArrayGetSize(*pAggTaskList); i++){ + 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); @@ -572,7 +607,7 @@ static void bindSourceSink(SStreamObj* pStream, SMnode* pMnode, SArray* tasks, b 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++){ + for (int i = 0; i < taosArrayGetSize(pSourceTaskList); i++) { SStreamTask* pSourceTask = taosArrayGetP(pSourceTaskList, i); mDebug("bindSourceSink taskId:%s to sink task list", pSourceTask->id.idStr); @@ -591,8 +626,8 @@ static void bindTwoLevel(SArray* tasks, int32_t begin, int32_t end) { SArray* pUpTaskList = taosArrayGetP(tasks, size - 2); SStreamTask** pDownTask = taosArrayGetLast(pDownTaskList); - end = end > taosArrayGetSize(pUpTaskList) ? taosArrayGetSize(pUpTaskList): end; - for(int i = begin; i < end; i++){ + 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); @@ -616,8 +651,8 @@ 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); + 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); @@ -632,7 +667,7 @@ static int32_t doScheduleStream(SStreamObj* pStream, SMnode* pMnode, SQueryPlan* pStream->totalLevel = numOfPlanLevel + hasExtraSink; - SSubplan* plan = getScanSubPlan(pPlan); // source plan + SSubplan* plan = getScanSubPlan(pPlan); // source plan if (plan == NULL) { return terrno; } @@ -649,32 +684,32 @@ static int32_t doScheduleStream(SStreamObj* pStream, SMnode* pMnode, SQueryPlan* return TDB_CODE_SUCCESS; } - if(numOfPlanLevel == 3){ + if (numOfPlanLevel == 3) { plan = getAggSubPlan(pPlan, 1); // middle agg plan if (plan == NULL) { return terrno; } - do{ + do { SArray** list = taosArrayGetLast(pStream->tasks); - float size = (float)taosArrayGetSize(*list); - size_t cnt = (size_t)ceil(size/tsStreamAggCnt); - if(cnt <= 1) break; + 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++){ + 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); + bindTwoLevel(pStream->tasks, j * tsStreamAggCnt, (j + 1) * tsStreamAggCnt); if (pStream->conf.fillHistory) { - bindTwoLevel(pStream->pHTasksList, j*tsStreamAggCnt, (j+1)*tsStreamAggCnt); + bindTwoLevel(pStream->pHTasksList, j * tsStreamAggCnt, (j + 1) * tsStreamAggCnt); } } - }while(1); + } while (1); } plan = getAggSubPlan(pPlan, 0); @@ -684,7 +719,7 @@ static int32_t doScheduleStream(SStreamObj* pStream, SMnode* pMnode, SQueryPlan* mDebug("doScheduleStream add final agg"); SArray** list = taosArrayGetLast(pStream->tasks); - size_t size = taosArrayGetSize(*list); + size_t size = taosArrayGetSize(*list); addNewTaskList(pStream); code = addAggTask(pStream, pMnode, plan, pEpset, true); if (code != TSDB_CODE_SUCCESS) { diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index 1e92b1a181..05189d5a53 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -567,6 +567,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea streamObj.conf.triggerParam = pCreate->maxDelay; streamObj.ast = taosStrdup(smaObj.ast); streamObj.indexForMultiAggBalance = -1; + streamObj.subTableWithoutMd5 = 1; // check the maxDelay if (streamObj.conf.triggerParam < TSDB_MIN_ROLLUP_MAX_DELAY) { @@ -898,11 +899,11 @@ _OVER: } int32_t mndDropSmasByStb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb) { - SSdb *pSdb = pMnode->pSdb; - SSmaObj *pSma = NULL; - void *pIter = NULL; - SVgObj *pVgroup = NULL; - int32_t code = -1; + SSdb *pSdb = pMnode->pSdb; + SSmaObj *pSma = NULL; + void *pIter = NULL; + SVgObj *pVgroup = NULL; + int32_t code = -1; while (1) { pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma); diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 190b4f28ce..f8a79c8522 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -27,7 +27,7 @@ #include "tmisce.h" #include "tname.h" -#define MND_STREAM_MAX_NUM 60 +#define MND_STREAM_MAX_NUM 60 typedef struct SMStreamNodeCheckMsg { int8_t placeHolder; // // to fix windows compile error, define place holder @@ -192,7 +192,7 @@ SSdbRow *mndStreamActionDecode(SSdbRaw *pRaw) { STREAM_DECODE_OVER: taosMemoryFreeClear(buf); if (terrno != TSDB_CODE_SUCCESS) { - char* p = (pStream == NULL) ? "null" : pStream->name; + char *p = (pStream == NULL) ? "null" : pStream->name; mError("stream:%s, failed to decode from raw:%p since %s", p, pRaw, terrstr()); taosMemoryFreeClear(pRow); return NULL; @@ -634,7 +634,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { terrno = TSDB_CODE_SUCCESS; if ((terrno = grantCheck(TSDB_GRANT_STREAMS)) < 0) { - goto _OVER; + return terrno; } SCMCreateStreamReq createReq = {0}; @@ -802,8 +802,7 @@ static int32_t mndProcessStreamCheckpointTmr(SRpcMsg *pReq) { } static int32_t mndBuildStreamCheckpointSourceReq(void **pBuf, int32_t *pLen, int32_t nodeId, int64_t checkpointId, - int64_t streamId, int32_t taskId, int32_t transId, - int8_t mndTrigger) { + int64_t streamId, int32_t taskId, int32_t transId, int8_t mndTrigger) { SStreamCheckpointSourceReq req = {0}; req.checkpointId = checkpointId; req.nodeId = nodeId; @@ -878,11 +877,10 @@ static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStre int32_t code = -1; int64_t ts = taosGetTimestampMs(); if (mndTrigger == 1 && (ts - pStream->checkpointFreq < tsStreamCheckpointInterval * 1000)) { -// mWarn("checkpoint interval less than the threshold, ignore it"); + // mWarn("checkpoint interval less than the threshold, ignore it"); return -1; } - bool conflict = mndStreamTransConflictCheck(pMnode, pStream->uid, MND_STREAM_CHECKPOINT_NAME, lock); if (conflict) { mndAddtoCheckpointWaitingList(pStream, checkpointId); @@ -1144,7 +1142,7 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) { return -1; } - STrans* pTrans = doCreateTrans(pMnode, pStream, pReq, MND_STREAM_DROP_NAME, "drop stream"); + STrans *pTrans = doCreateTrans(pMnode, pStream, pReq, MND_STREAM_DROP_NAME, "drop stream"); if (pTrans == NULL) { mError("stream:%s, failed to drop since %s", dropReq.name, terrstr()); sdbRelease(pMnode->pSdb, pStream); @@ -1570,7 +1568,7 @@ static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq) { return -1; } - STrans* pTrans = doCreateTrans(pMnode, pStream, pReq, MND_STREAM_PAUSE_NAME, "pause the stream"); + STrans *pTrans = doCreateTrans(pMnode, pStream, pReq, MND_STREAM_PAUSE_NAME, "pause the stream"); if (pTrans == NULL) { mError("stream:%s failed to pause stream since %s", pauseReq.name, terrstr()); sdbRelease(pMnode->pSdb, pStream); @@ -1590,7 +1588,7 @@ static int32_t mndProcessPauseStreamReq(SRpcMsg *pReq) { // pause stream taosWLockLatch(&pStream->lock); pStream->status = STREAM_STATUS__PAUSE; - if (mndPersistTransLog(pStream, pTrans,SDB_STATUS_READY) < 0) { + if (mndPersistTransLog(pStream, pTrans, SDB_STATUS_READY) < 0) { taosWUnLockLatch(&pStream->lock); sdbRelease(pMnode->pSdb, pStream); @@ -1617,7 +1615,7 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; SStreamObj *pStream = NULL; - if(grantCheckExpire(TSDB_GRANT_STREAMS) < 0){ + if (grantCheckExpire(TSDB_GRANT_STREAMS) < 0) { terrno = TSDB_CODE_GRANT_EXPIRED; return -1; } @@ -1659,7 +1657,7 @@ static int32_t mndProcessResumeStreamReq(SRpcMsg *pReq) { return -1; } - STrans* pTrans = doCreateTrans(pMnode, pStream, pReq, MND_STREAM_RESUME_NAME, "resume the stream"); + STrans *pTrans = doCreateTrans(pMnode, pStream, pReq, MND_STREAM_RESUME_NAME, "resume the stream"); if (pTrans == NULL) { mError("stream:%s, failed to resume stream since %s", resumeReq.name, terrstr()); sdbRelease(pMnode->pSdb, pStream); @@ -2106,10 +2104,10 @@ void removeStreamTasksInBuf(SStreamObj *pStream, SStreamExecInfo *pExecNode) { ASSERT(taosHashGetSize(pExecNode->pTaskMap) == taosArrayGetSize(pExecNode->pTaskList)); } -static void doAddTaskId(SArray* pList, int32_t taskId, int64_t uid, int32_t numOfTotal) { +static void doAddTaskId(SArray *pList, int32_t taskId, int64_t uid, int32_t numOfTotal) { int32_t num = taosArrayGetSize(pList); - for(int32_t i = 0; i < num; ++i) { - int32_t* pId = taosArrayGet(pList, i); + for (int32_t i = 0; i < num; ++i) { + int32_t *pId = taosArrayGet(pList, i); if (taskId == *pId) { return; } @@ -2122,7 +2120,7 @@ static void doAddTaskId(SArray* pList, int32_t taskId, int64_t uid, int32_t numO } int32_t mndProcessStreamReqCheckpoint(SRpcMsg *pReq) { - SMnode *pMnode = pReq->info.node; + SMnode *pMnode = pReq->info.node; SStreamTaskCheckpointReq req = {0}; SDecoder decoder = {0}; @@ -2143,7 +2141,7 @@ int32_t mndProcessStreamReqCheckpoint(SRpcMsg *pReq) { SStreamObj *pStream = mndGetStreamObj(pMnode, req.streamId); if (pStream == NULL) { - mError("failed to find the stream:0x%"PRIx64" not handle the checkpoint req", req.streamId); + mError("failed to find the stream:0x%" PRIx64 " not handle the checkpoint req", req.streamId); terrno = TSDB_CODE_MND_STREAM_NOT_EXIST; taosThreadMutexUnlock(&execInfo.lock); @@ -2151,13 +2149,13 @@ int32_t mndProcessStreamReqCheckpoint(SRpcMsg *pReq) { } int32_t numOfTasks = mndGetNumOfStreamTasks(pStream); - SArray **pReqTaskList = (SArray**)taosHashGet(execInfo.pTransferStateStreams, &req.streamId, sizeof(req.streamId)); + SArray **pReqTaskList = (SArray **)taosHashGet(execInfo.pTransferStateStreams, &req.streamId, sizeof(req.streamId)); if (pReqTaskList == NULL) { SArray *pList = taosArrayInit(4, sizeof(int32_t)); doAddTaskId(pList, req.taskId, pStream->uid, numOfTasks); taosHashPut(execInfo.pTransferStateStreams, &req.streamId, sizeof(int64_t), &pList, sizeof(void *)); - pReqTaskList = (SArray**)taosHashGet(execInfo.pTransferStateStreams, &req.streamId, sizeof(req.streamId)); + pReqTaskList = (SArray **)taosHashGet(execInfo.pTransferStateStreams, &req.streamId, sizeof(req.streamId)); } else { doAddTaskId(*pReqTaskList, req.taskId, pStream->uid, numOfTasks); } diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 0d23db09e5..de543f4256 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -564,6 +564,10 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) { return code; } + if ((terrno = grantCheck(TSDB_GRANT_SUBSCRIPTION)) < 0) { + return code; + } + if (tDeserializeSCMCreateTopicReq(pReq->pCont, pReq->contLen, &createTopicReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; goto _OVER; diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index f173c327c7..9a017e7074 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -85,8 +85,9 @@ int32_t sndExpandTask(SSnode *pSnode, SStreamTask *pTask, int64_t nextProcessVer SCheckpointInfo *pChkInfo = &pTask->chkInfo; // checkpoint ver is the kept version, handled data should be the next version. - if (pTask->chkInfo.checkpointId != 0) { - pTask->chkInfo.nextProcessVer = pTask->chkInfo.checkpointVer + 1; + if (pChkInfo->checkpointId != 0) { + pChkInfo->nextProcessVer = pChkInfo->checkpointVer + 1; + pChkInfo->processedVer = pChkInfo->checkpointVer; sndInfo("s-task:%s restore from the checkpointId:%" PRId64 " ver:%" PRId64 " nextProcessVer:%" PRId64, pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer); } diff --git a/source/dnode/snode/src/snodeInitApi.c b/source/dnode/snode/src/snodeInitApi.c index c605a8373e..3b60ef3427 100644 --- a/source/dnode/snode/src/snodeInitApi.c +++ b/source/dnode/snode/src/snodeInitApi.c @@ -67,12 +67,17 @@ void initStateStoreAPI(SStateStore* pStore) { pStore->streamStateSessionPut = streamStateSessionPut; pStore->streamStateSessionGet = streamStateSessionGet; pStore->streamStateSessionDel = streamStateSessionDel; + pStore->streamStateSessionReset = streamStateSessionReset; pStore->streamStateSessionClear = streamStateSessionClear; pStore->streamStateSessionGetKVByCur = streamStateSessionGetKVByCur; pStore->streamStateStateAddIfNotExist = streamStateStateAddIfNotExist; pStore->streamStateSessionGetKeyByRange = streamStateSessionGetKeyByRange; + pStore->streamStateCountGetKeyByRange = streamStateCountGetKeyByRange; pStore->streamStateSessionAllocWinBuffByNextPosition = streamStateSessionAllocWinBuffByNextPosition; + pStore->streamStateCountWinAddIfNotExist = streamStateCountWinAddIfNotExist; + pStore->streamStateCountWinAdd = streamStateCountWinAdd; + pStore->updateInfoInit = updateInfoInit; pStore->updateInfoFillBlockData = updateInfoFillBlockData; pStore->updateInfoIsUpdated = updateInfoIsUpdated; @@ -89,6 +94,7 @@ void initStateStoreAPI(SStateStore* pStore) { pStore->updateInfoDeserialize = updateInfoDeserialize; pStore->streamStateSessionSeekKeyNext = streamStateSessionSeekKeyNext; + pStore->streamStateCountSeekKeyPrev = streamStateCountSeekKeyPrev; pStore->streamStateSessionSeekKeyCurrentPrev = streamStateSessionSeekKeyCurrentPrev; pStore->streamStateSessionSeekKeyCurrentNext = streamStateSessionSeekKeyCurrentNext; diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index bde6889ecd..6b7420b55f 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -14,8 +14,8 @@ */ #include "tq.h" -#include "vnd.h" #include "tqCommon.h" +#include "vnd.h" // 0: not init // 1: already inited @@ -835,36 +835,37 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t nextProcessVer) { // checkpoint ver is the kept version, handled data should be the next version. if (pChkInfo->checkpointId != 0) { pChkInfo->nextProcessVer = pChkInfo->checkpointVer + 1; + pChkInfo->processedVer = pChkInfo->checkpointVer; tqInfo("s-task:%s restore from the checkpointId:%" PRId64 " ver:%" PRId64 " currentVer:%" PRId64, pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer); } char* p = streamTaskGetStatus(pTask)->name; + const char* pNext = streamTaskGetStatusStr(pTask->status.taskStatus); if (pTask->info.fillHistory) { tqInfo("vgId:%d expand stream task, s-task:%s, checkpointId:%" PRId64 " checkpointVer:%" PRId64 " nextProcessVer:%" PRId64 - " child id:%d, level:%d, status:%s fill-history:%d, related stream task:0x%x trigger:%" PRId64 - " ms, inputVer:%" PRId64, + " child id:%d, level:%d, cur-status:%s, next-status:%s fill-history:%d, related stream task:0x%x " + "trigger:%" PRId64 " ms, inputVer:%" PRId64, vgId, pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer, - pTask->info.selfChildId, pTask->info.taskLevel, p, pTask->info.fillHistory, + pTask->info.selfChildId, pTask->info.taskLevel, p, pNext, pTask->info.fillHistory, (int32_t)pTask->streamTaskId.taskId, pTask->info.triggerParam, nextProcessVer); } else { - tqInfo("vgId:%d expand stream task, s-task:%s, checkpointId:%" PRId64 " checkpointVer:%" PRId64 - " nextProcessVer:%" PRId64 - " child id:%d, level:%d, status:%s fill-history:%d, related fill-task:0x%x trigger:%" PRId64 - " ms, inputVer:%" PRId64, - vgId, pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer, - pTask->info.selfChildId, pTask->info.taskLevel, p, pTask->info.fillHistory, - (int32_t)pTask->hTaskInfo.id.taskId, pTask->info.triggerParam, nextProcessVer); + tqInfo( + "vgId:%d expand stream task, s-task:%s, checkpointId:%" PRId64 " checkpointVer:%" PRId64 + " nextProcessVer:%" PRId64 + " child id:%d, level:%d, cur-status:%s next-status:%s fill-history:%d, related fill-task:0x%x trigger:%" PRId64 + " ms, inputVer:%" PRId64, + vgId, pTask->id.idStr, pChkInfo->checkpointId, pChkInfo->checkpointVer, pChkInfo->nextProcessVer, + pTask->info.selfChildId, pTask->info.taskLevel, p, pNext, pTask->info.fillHistory, + (int32_t)pTask->hTaskInfo.id.taskId, pTask->info.triggerParam, nextProcessVer); } return 0; } -int32_t tqProcessTaskCheckReq(STQ* pTq, SRpcMsg* pMsg) { - return tqStreamTaskProcessCheckReq(pTq->pStreamMeta, pMsg); -} +int32_t tqProcessTaskCheckReq(STQ* pTq, SRpcMsg* pMsg) { return tqStreamTaskProcessCheckReq(pTq->pStreamMeta, pMsg); } int32_t tqProcessTaskCheckRsp(STQ* pTq, SRpcMsg* pMsg) { return tqStreamTaskProcessCheckRsp(pTq->pStreamMeta, pMsg, vnodeIsRoleLeader(pTq->pVnode)); @@ -988,7 +989,7 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) { streamReExecScanHistoryFuture(pTask, retInfo.idleTime); } else { SStreamTaskState* p = streamTaskGetStatus(pTask); - ETaskStatus s = p->state; + ETaskStatus s = p->state; if (s == TASK_STATUS__PAUSE) { tqDebug("s-task:%s is paused in the step1, elapsed time:%.2fs total:%.2fs, sched-status:%d", pTask->id.idStr, @@ -1015,8 +1016,8 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) { tqError("failed to find s-task:0x%" PRIx64 ", it may have been destroyed, drop related fill-history task:%s", pTask->streamTaskId.taskId, pTask->id.idStr); - tqDebug("s-task:%s fill-history task set status to be dropping", id); - streamBuildAndSendDropTaskMsg(pTask->pMsgCb, pMeta->vgId, &pTask->id); + tqDebug("s-task:%s fill-history task set status to be dropping and drop it", id); + streamBuildAndSendDropTaskMsg(pTask->pMsgCb, pMeta->vgId, &pTask->id, 0); atomic_store_32(&pTask->status.inScanHistorySentinel, 0); streamMetaReleaseTask(pMeta, pTask); @@ -1062,7 +1063,7 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) { } int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) { - return tqStreamTaskProcessDispatchReq(pTq->pStreamMeta, pMsg); + return tqStreamTaskProcessDispatchReq(pTq->pStreamMeta, pMsg); } int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) { @@ -1101,7 +1102,7 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) pRsp->info.handle = NULL; SStreamCheckpointSourceReq req = {0}; - SDecoder decoder; + SDecoder decoder; tDecoderInit(&decoder, (uint8_t*)msg, len); if (tDecodeStreamCheckpointSourceReq(&decoder, &req) < 0) { code = TSDB_CODE_MSG_DECODE_ERROR; @@ -1192,8 +1193,8 @@ int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) streamProcessCheckpointSourceReq(pTask, &req); taosThreadMutexUnlock(&pTask->lock); - qInfo("s-task:%s (vgId:%d) level:%d receive checkpoint-source msg chkpt:%" PRId64 ", transId:%d", - pTask->id.idStr, vgId, pTask->info.taskLevel, req.checkpointId, req.transId); + qInfo("s-task:%s (vgId:%d) level:%d receive checkpoint-source msg chkpt:%" PRId64 ", transId:%d", pTask->id.idStr, + vgId, pTask->info.taskLevel, req.checkpointId, req.transId); code = streamAddCheckpointSourceRspMsg(&req, &pMsg->info, pTask, 1); if (code != TSDB_CODE_SUCCESS) { diff --git a/source/dnode/vnode/src/tq/tqHandleSnapshot.c b/source/dnode/vnode/src/tq/tqHandleSnapshot.c index 3ce838ce8b..28fd315eb6 100644 --- a/source/dnode/vnode/src/tq/tqHandleSnapshot.c +++ b/source/dnode/vnode/src/tq/tqHandleSnapshot.c @@ -74,11 +74,11 @@ int32_t tqSnapReaderClose(STqSnapReader** ppReader) { } int32_t tqSnapRead(STqSnapReader* pReader, uint8_t** ppData) { - int32_t code = 0; - void* pKey = NULL; - void* pVal = NULL; - int32_t kLen = 0; - int32_t vLen = 0; + int32_t code = 0; + void* pKey = NULL; + void* pVal = NULL; + int32_t kLen = 0; + int32_t vLen = 0; if (tdbTbcNext(pReader->pCur, &pKey, &kLen, &pVal, &vLen)) { goto _exit; diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 3ae007ce34..727157a2f8 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -207,8 +207,8 @@ int32_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, uint64_t goto END; } - tqDebug("vgId:%d, consumer:0x%" PRIx64 " taosx get msg ver %" PRId64 ", type: %s, reqId:0x%" PRIx64" 0x%"PRIx64, vgId, - pHandle->consumerId, offset, TMSG_INFO(pHandle->pWalReader->pHead->head.msgType), reqId, id); + tqDebug("vgId:%d, consumer:0x%" PRIx64 " taosx get msg ver %" PRId64 ", type: %s, reqId:0x%" PRIx64 " 0x%" PRIx64, + vgId, pHandle->consumerId, offset, TMSG_INFO(pHandle->pWalReader->pHead->head.msgType), reqId, id); if (pHandle->pWalReader->pHead->head.msgType == TDMT_VND_SUBMIT) { code = walFetchBody(pHandle->pWalReader); @@ -303,7 +303,7 @@ int32_t tqReaderSeek(STqReader* pReader, int64_t ver, const char* id) { int32_t extractMsgFromWal(SWalReader* pReader, void** pItem, int64_t maxVer, const char* id) { int32_t code = 0; - while(1) { + while (1) { code = walNextValidMsg(pReader); if (code != TSDB_CODE_SUCCESS) { return code; @@ -322,7 +322,8 @@ int32_t extractMsgFromWal(SWalReader* pReader, void** pItem, int64_t maxVer, con void* data = taosMemoryMalloc(len); if (data == NULL) { - // todo: for all stream in this vnode, keep this offset in the offset files, and wait for a moment, and then retry + // todo: for all stream in this vnode, keep this offset in the offset files, and wait for a moment, and then + // retry code = TSDB_CODE_OUT_OF_MEMORY; terrno = code; @@ -369,7 +370,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, int sourceExcluded) { - SWalReader* pWalReader = pReader->pWalReader; + SWalReader* pWalReader = pReader->pWalReader; SSDataBlock* pDataBlock = NULL; uint64_t st = taosGetTimestampMs(); @@ -387,22 +388,22 @@ bool tqNextBlockInWal(STqReader* pReader, const char* id, int sourceExcluded) { pReader->nextBlk = 0; int32_t numOfBlocks = taosArrayGetSize(pReader->submit.aSubmitTbData); while (pReader->nextBlk < numOfBlocks) { - tqTrace("tq reader next data block %d/%d, len:%d %" PRId64, pReader->nextBlk, - numOfBlocks, pReader->msg.msgLen, pReader->msg.ver); + tqTrace("tq reader next data block %d/%d, len:%d %" PRId64, pReader->nextBlk, numOfBlocks, pReader->msg.msgLen, + pReader->msg.ver); SSubmitTbData* pSubmitTbData = taosArrayGet(pReader->submit.aSubmitTbData, pReader->nextBlk); - if ((pSubmitTbData->source & sourceExcluded) != 0){ + 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; - int32_t code = tqRetrieveDataBlock(pReader, &pRes, NULL); + int32_t code = tqRetrieveDataBlock(pReader, &pRes, NULL); if (code == TSDB_CODE_SUCCESS && pRes->info.rows > 0) { - if(pDataBlock == NULL){ + if (pDataBlock == NULL) { pDataBlock = createOneDataBlock(pRes, true); - }else{ + } else { blockDataMerge(pDataBlock, pRes); } } @@ -414,16 +415,16 @@ bool tqNextBlockInWal(STqReader* pReader, const char* id, int sourceExcluded) { tDestroySubmitReq(&pReader->submit, TSDB_MSG_FLG_DECODE); pReader->msg.msgStr = NULL; - if(pDataBlock != NULL){ + if (pDataBlock != NULL) { blockDataCleanup(pReader->pResBlock); copyDataBlock(pReader->pResBlock, pDataBlock); blockDataDestroy(pDataBlock); return true; - }else{ + } else { qTrace("stream scan return empty, all %d submit blocks consumed, %s", numOfBlocks, id); } - if(taosGetTimestampMs() - st > 1000){ + if (taosGetTimestampMs() - st > 1000) { return false; } } @@ -448,17 +449,11 @@ int32_t tqReaderSetSubmitMsg(STqReader* pReader, void* msgStr, int32_t msgLen, i return 0; } -SWalReader* tqGetWalReader(STqReader* pReader) { - return pReader->pWalReader; -} +SWalReader* tqGetWalReader(STqReader* pReader) { return pReader->pWalReader; } -SSDataBlock* tqGetResultBlock (STqReader* pReader) { - return pReader->pResBlock; -} +SSDataBlock* tqGetResultBlock(STqReader* pReader) { return pReader->pResBlock; } -int64_t tqGetResultBlockTime(STqReader *pReader){ - return pReader->lastTs; -} +int64_t tqGetResultBlockTime(STqReader* pReader) { return pReader->lastTs; } bool tqNextBlockImpl(STqReader* pReader, const char* idstr) { if (pReader->msg.msgStr == NULL) { @@ -599,7 +594,7 @@ static int32_t doSetVal(SColumnInfoData* pColumnInfoData, int32_t rowIndex, SCol if (IS_STR_DATA_TYPE(pColVal->type)) { char val[65535 + 2] = {0}; - if(COL_VAL_IS_VALUE(pColVal)){ + if (COL_VAL_IS_VALUE(pColVal)) { if (pColVal->value.pData != NULL) { memcpy(varDataVal(val), pColVal->value.pData, pColVal->value.nData); } @@ -874,7 +869,7 @@ int32_t tqRetrieveTaosxBlock(STqReader* pReader, SArray* blocks, SArray* schemas sourceIdx++; } else if (pCol->cid == pColData->info.colId) { tColDataGetValue(pCol, i, &colVal); - if(doSetVal(pColData, curRow - lastRow, &colVal) != TDB_CODE_SUCCESS){ + if (doSetVal(pColData, curRow - lastRow, &colVal) != TDB_CODE_SUCCESS) { goto FAIL; } sourceIdx++; @@ -958,10 +953,10 @@ int32_t tqRetrieveTaosxBlock(STqReader* pReader, SArray* blocks, SArray* schemas if (colVal.cid < pColData->info.colId) { sourceIdx++; } else if (colVal.cid == pColData->info.colId) { - if(doSetVal(pColData, curRow - lastRow, &colVal) != TDB_CODE_SUCCESS){ + if (doSetVal(pColData, curRow - lastRow, &colVal) != TDB_CODE_SUCCESS) { goto FAIL; } - sourceIdx++; + sourceIdx++; targetIdx++; } } @@ -1001,7 +996,7 @@ int tqReaderSetTbUidList(STqReader* pReader, const SArray* tbUidList, const char taosHashPut(pReader->tbIdHash, pKey, sizeof(int64_t), NULL, 0); } - tqDebug("s-task:%s %d tables are set to be queried target table", id, (int32_t) taosArrayGetSize(tbUidList)); + tqDebug("s-task:%s %d tables are set to be queried target table", id, (int32_t)taosArrayGetSize(tbUidList)); return 0; } @@ -1027,9 +1022,7 @@ bool tqReaderIsQueriedTable(STqReader* pReader, uint64_t uid) { return taosHashGet(pReader->tbIdHash, &uid, sizeof(uint64_t)); } -bool tqCurrentBlockConsumed(const STqReader* pReader) { - return pReader->msg.msgStr == NULL; -} +bool tqCurrentBlockConsumed(const STqReader* pReader) { return pReader->msg.msgStr == NULL; } int tqReaderRemoveTbUidList(STqReader* pReader, const SArray* tbUidList) { for (int32_t i = 0; i < taosArrayGetSize(tbUidList); i++) { @@ -1071,9 +1064,11 @@ int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd) { } else if (pTqHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) { if (isAdd) { SArray* list = NULL; - int ret = qGetTableList(pTqHandle->execHandle.execTb.suid, pTq->pVnode, pTqHandle->execHandle.execTb.node, &list, pTqHandle->execHandle.task); - if(ret != TDB_CODE_SUCCESS) { - tqError("qGetTableList in tqUpdateTbUidList error:%d handle %s consumer:0x%" PRIx64, ret, pTqHandle->subKey, pTqHandle->consumerId); + int ret = qGetTableList(pTqHandle->execHandle.execTb.suid, pTq->pVnode, pTqHandle->execHandle.execTb.node, + &list, pTqHandle->execHandle.task); + if (ret != TDB_CODE_SUCCESS) { + tqError("qGetTableList in tqUpdateTbUidList error:%d handle %s consumer:0x%" PRIx64, ret, pTqHandle->subKey, + pTqHandle->consumerId); taosArrayDestroy(list); taosHashCancelIterate(pTq->pHandle, pIter); taosWUnLockLatch(&pTq->lock); diff --git a/source/dnode/vnode/src/tq/tqScan.c b/source/dnode/vnode/src/tq/tqScan.c index d86c0a0474..f108cedcf5 100644 --- a/source/dnode/vnode/src/tq/tqScan.c +++ b/source/dnode/vnode/src/tq/tqScan.c @@ -63,8 +63,8 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, STaosxRsp* pRsp, in return 0; } -int32_t getDataBlock(qTaskInfo_t task, const STqHandle* pHandle, int32_t vgId, SSDataBlock** res){ - uint64_t ts = 0; +int32_t getDataBlock(qTaskInfo_t task, const STqHandle* pHandle, int32_t vgId, SSDataBlock** res) { + uint64_t ts = 0; qStreamSetOpen(task); tqDebug("consumer:0x%" PRIx64 " vgId:%d, tmq one task start execute", pHandle->consumerId, vgId); @@ -97,27 +97,27 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* while (1) { SSDataBlock* pDataBlock = NULL; code = getDataBlock(task, pHandle, vgId, &pDataBlock); - if (code != 0){ + if (code != 0) { return code; } - if(pRequest->enableReplay){ - if(IS_OFFSET_RESET_TYPE(pRequest->reqOffset.type) && pHandle->block != NULL){ + if (pRequest->enableReplay) { + if (IS_OFFSET_RESET_TYPE(pRequest->reqOffset.type) && pHandle->block != NULL) { blockDataDestroy(pHandle->block); pHandle->block = NULL; } - if(pHandle->block == NULL){ + if (pHandle->block == NULL) { if (pDataBlock == NULL) { break; } STqOffsetVal offset = {0}; qStreamExtractOffset(task, &offset); pHandle->block = createOneDataBlock(pDataBlock, true); -// pHandle->block = createDataBlock(); -// copyDataBlock(pHandle->block, pDataBlock); + // pHandle->block = createDataBlock(); + // copyDataBlock(pHandle->block, pDataBlock); pHandle->blockTime = offset.ts; code = getDataBlock(task, pHandle, vgId, &pDataBlock); - if (code != 0){ + if (code != 0) { return code; } } @@ -132,7 +132,7 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* if (pDataBlock == NULL) { blockDataDestroy(pHandle->block); pHandle->block = NULL; - }else{ + } else { copyDataBlock(pHandle->block, pDataBlock); STqOffsetVal offset = {0}; @@ -141,7 +141,7 @@ int32_t tqScanData(STQ* pTq, STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* pHandle->blockTime = offset.ts; } break; - }else{ + } else { if (pDataBlock == NULL) { break; } @@ -250,7 +250,8 @@ 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, int8_t sourceExcluded) { +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*)); @@ -266,7 +267,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) goto loop_table; } - if ((pSubmitTbDataRet->source & sourceExcluded) != 0){ + if ((pSubmitTbDataRet->source & sourceExcluded) != 0) { goto loop_table; } if (pRsp->withTbName) { @@ -303,7 +304,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR tEncoderClear(&encoder); } - if (pHandle->fetchMeta == ONLY_META && pSubmitTbDataRet->pCreateTbReq == NULL){ + if (pHandle->fetchMeta == ONLY_META && pSubmitTbDataRet->pCreateTbReq == NULL) { goto loop_table; } for (int32_t i = 0; i < taosArrayGetSize(pBlocks); i++) { @@ -334,7 +335,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) goto loop_db; } - if ((pSubmitTbDataRet->source & sourceExcluded) != 0){ + if ((pSubmitTbDataRet->source & sourceExcluded) != 0) { goto loop_db; } if (pRsp->withTbName) { @@ -371,7 +372,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR tEncoderClear(&encoder); } - if (pHandle->fetchMeta == ONLY_META && pSubmitTbDataRet->pCreateTbReq == NULL){ + if (pHandle->fetchMeta == ONLY_META && pSubmitTbDataRet->pCreateTbReq == NULL) { goto loop_db; } for (int32_t i = 0; i < taosArrayGetSize(pBlocks); i++) { diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index b438b2dc0a..b56bf3e0fe 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -33,15 +33,18 @@ static int32_t doBuildAndSendDeleteMsg(SVnode* pVnode, char* stbFullName, SSData int64_t suid); static int32_t doBuildAndSendSubmitMsg(SVnode* pVnode, SStreamTask* pTask, SSubmitReq2* pReq, int32_t numOfBlocks); static int32_t buildSubmitMsgImpl(SSubmitReq2* pSubmitReq, int32_t vgId, void** pMsg, int32_t* msgLen); -static int32_t doConvertRows(SSubmitTbData* pTableData, const STSchema* pTSchema, SSDataBlock* pDataBlock, const char* id); +static int32_t doConvertRows(SSubmitTbData* pTableData, const STSchema* pTSchema, SSDataBlock* pDataBlock, + const char* id); static int32_t doWaitForDstTableCreated(SVnode* pVnode, SStreamTask* pTask, STableSinkInfo* pTableSinkInfo, const char* dstTableName, int64_t* uid); -static int32_t doPutIntoCache(SSHashObj* pSinkTableMap, STableSinkInfo* pTableSinkInfo, uint64_t groupId, const char* id); +static int32_t doPutIntoCache(SSHashObj* pSinkTableMap, STableSinkInfo* pTableSinkInfo, uint64_t groupId, + const char* id); static bool isValidDstChildTable(SMetaReader* pReader, int32_t vgId, const char* ctbName, int64_t suid); -static int32_t initCreateTableMsg(SVCreateTbReq* pCreateTableReq, uint64_t suid, const char* stbFullName, int32_t numOfTags); +static int32_t initCreateTableMsg(SVCreateTbReq* pCreateTableReq, uint64_t suid, const char* stbFullName, + int32_t numOfTags); static SArray* createDefaultTagColName(); -static void setCreateTableMsgTableName(SVCreateTbReq* pCreateTableReq, SSDataBlock* pDataBlock, const char* stbFullName, - int64_t gid, bool newSubTableRule); +static void setCreateTableMsgTableName(SVCreateTbReq* pCreateTableReq, SSDataBlock* pDataBlock, const char* stbFullName, + int64_t gid, bool newSubTableRule); int32_t tqBuildDeleteReq(STQ* pTq, const char* stbFullName, const SSDataBlock* pDataBlock, SBatchDeleteReq* deleteReq, const char* pIdStr, bool newSubTableRule) { @@ -68,10 +71,7 @@ int32_t tqBuildDeleteReq(STQ* pTq, const char* stbFullName, const SSDataBlock* p if (varTbName != NULL && varTbName != (void*)-1) { name = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN); memcpy(name, varDataVal(varTbName), varDataLen(varTbName)); - if(newSubTableRule && - !isAutoTableName(name) && - !alreadyAddGroupId(name) && - groupId != 0) { + if (newSubTableRule && !isAutoTableName(name) && !alreadyAddGroupId(name) && groupId != 0) { buildCtbNameAddGruopId(name, groupId); } } else if (stbFullName) { @@ -134,7 +134,7 @@ end: return ret; } -static bool tqGetTableInfo(SSHashObj* pTableInfoMap,uint64_t groupId, STableSinkInfo** pInfo) { +static bool tqGetTableInfo(SSHashObj* pTableInfoMap, uint64_t groupId, STableSinkInfo** pInfo) { void* pVal = tSimpleHashGet(pTableInfoMap, &groupId, sizeof(uint64_t)); if (pVal) { *pInfo = *(STableSinkInfo**)pVal; @@ -149,7 +149,7 @@ static int32_t tqPutReqToQueue(SVnode* pVnode, SVCreateTbBatchReq* pReqs) { int32_t tlen = 0; encodeCreateChildTableForRPC(pReqs, TD_VID(pVnode), &buf, &tlen); - SRpcMsg msg = { .msgType = TDMT_VND_CREATE_TABLE, .pCont = buf, .contLen = tlen }; + SRpcMsg msg = {.msgType = TDMT_VND_CREATE_TABLE, .pCont = buf, .contLen = tlen}; if (tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &msg) != 0) { tqError("failed to put into write-queue since %s", terrstr()); } @@ -181,14 +181,12 @@ SArray* createDefaultTagColName() { void setCreateTableMsgTableName(SVCreateTbReq* pCreateTableReq, SSDataBlock* pDataBlock, const char* stbFullName, int64_t gid, bool newSubTableRule) { if (pDataBlock->info.parTbName[0]) { - if(newSubTableRule && - !isAutoTableName(pDataBlock->info.parTbName) && - !alreadyAddGroupId(pDataBlock->info.parTbName) && - gid != 0) { + if (newSubTableRule && !isAutoTableName(pDataBlock->info.parTbName) && + !alreadyAddGroupId(pDataBlock->info.parTbName) && gid != 0) { pCreateTableReq->name = taosMemoryCalloc(1, TSDB_TABLE_NAME_LEN); strcpy(pCreateTableReq->name, pDataBlock->info.parTbName); buildCtbNameAddGruopId(pCreateTableReq->name, gid); - }else{ + } else { pCreateTableReq->name = taosStrdup(pDataBlock->info.parTbName); } } else { @@ -196,17 +194,18 @@ void setCreateTableMsgTableName(SVCreateTbReq* pCreateTableReq, SSDataBlock* pDa } } -static int32_t doBuildAndSendCreateTableMsg(SVnode* pVnode, char* stbFullName, SSDataBlock* pDataBlock, SStreamTask* pTask, - int64_t suid) { +static int32_t doBuildAndSendCreateTableMsg(SVnode* pVnode, char* stbFullName, SSDataBlock* pDataBlock, + SStreamTask* pTask, int64_t suid) { tqDebug("s-task:%s build create table msg", pTask->id.idStr); STSchema* pTSchema = pTask->outputInfo.tbSink.pTSchema; int32_t rows = pDataBlock->info.rows; - SArray* tagArray = taosArrayInit(4, sizeof(STagVal));; - int32_t code = 0; + SArray* tagArray = taosArrayInit(4, sizeof(STagVal)); + ; + int32_t code = 0; SVCreateTbBatchReq reqs = {0}; - SArray* crTblArray = reqs.pArray = taosArrayInit(1, sizeof(SVCreateTbReq)); + SArray* crTblArray = reqs.pArray = taosArrayInit(1, sizeof(SVCreateTbReq)); if (NULL == reqs.pArray) { tqError("s-task:%s failed to init create table msg, code:%s", pTask->id.idStr, tstrerror(terrno)); goto _end; @@ -262,7 +261,8 @@ static int32_t doBuildAndSendCreateTableMsg(SVnode* pVnode, char* stbFullName, S ASSERT(gid == *(int64_t*)pGpIdData); } - setCreateTableMsgTableName(pCreateTbReq, pDataBlock, stbFullName, gid, pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER); + setCreateTableMsgTableName(pCreateTbReq, pDataBlock, stbFullName, gid, + pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER && pTask->subtableWithoutMd5 != 1); taosArrayPush(reqs.pArray, pCreateTbReq); tqDebug("s-task:%s build create table:%s msg complete", pTask->id.idStr, pCreateTbReq->name); @@ -274,7 +274,7 @@ static int32_t doBuildAndSendCreateTableMsg(SVnode* pVnode, char* stbFullName, S tqError("s-task:%s failed to send create table msg", pTask->id.idStr); } - _end: +_end: taosArrayDestroy(tagArray); taosArrayDestroyEx(crTblArray, (FDelete)tdDestroySVCreateTbReq); return code; @@ -361,7 +361,8 @@ int32_t doMergeExistedRows(SSubmitTbData* pExisted, const SSubmitTbData* pNew, c pExisted->aRowP = pFinal; tqTrace("s-task:%s rows merged, final rows:%d, uid:%" PRId64 ", existed auto-create table:%d, new-block:%d", id, - (int32_t)taosArrayGetSize(pFinal), pExisted->uid, (pExisted->pCreateTbReq != NULL), (pNew->pCreateTbReq != NULL)); + (int32_t)taosArrayGetSize(pFinal), pExisted->uid, (pExisted->pCreateTbReq != NULL), + (pNew->pCreateTbReq != NULL)); tdDestroySVCreateTbReq(pNew->pCreateTbReq); taosMemoryFree(pNew->pCreateTbReq); @@ -373,7 +374,7 @@ int32_t doBuildAndSendDeleteMsg(SVnode* pVnode, char* stbFullName, SSDataBlock* SBatchDeleteReq deleteReq = {.suid = suid, .deleteReqs = taosArrayInit(0, sizeof(SSingleDeleteReq))}; int32_t code = tqBuildDeleteReq(pVnode->pTq, stbFullName, pDataBlock, &deleteReq, pTask->id.idStr, - pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER); + pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER && pTask->subtableWithoutMd5 != 1); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -416,8 +417,8 @@ bool isValidDstChildTable(SMetaReader* pReader, int32_t vgId, const char* ctbNam } if (pReader->me.ctbEntry.suid != suid) { - tqError("vgId:%d, failed to write into %s, since suid mismatch, expect suid:%" PRId64 ", actual:%" PRId64, - vgId, ctbName, suid, pReader->me.ctbEntry.suid); + tqError("vgId:%d, failed to write into %s, since suid mismatch, expect suid:%" PRId64 ", actual:%" PRId64, vgId, + ctbName, suid, pReader->me.ctbEntry.suid); terrno = TSDB_CODE_TDB_TABLE_IN_OTHER_STABLE; return false; } @@ -437,10 +438,10 @@ SVCreateTbReq* buildAutoCreateTableReq(const char* stbFullName, int64_t suid, in taosArrayClear(pTagArray); initCreateTableMsg(pCreateTbReq, suid, stbFullName, 1); - STagVal tagVal = { .cid = numOfCols, .type = TSDB_DATA_TYPE_UBIGINT, .i64 = pDataBlock->info.id.groupId}; + STagVal tagVal = {.cid = numOfCols, .type = TSDB_DATA_TYPE_UBIGINT, .i64 = pDataBlock->info.id.groupId}; taosArrayPush(pTagArray, &tagVal); - tTagNew(pTagArray, 1, false, (STag**) &pCreateTbReq->ctb.pTag); + tTagNew(pTagArray, 1, false, (STag**)&pCreateTbReq->ctb.pTag); if (pCreateTbReq->ctb.pTag == NULL) { tdDestroySVCreateTbReq(pCreateTbReq); @@ -513,13 +514,13 @@ int32_t buildSubmitMsgImpl(SSubmitReq2* pSubmitReq, int32_t vgId, void** pMsg, i } int32_t tsAscendingSortFn(const void* p1, const void* p2) { - SRow* pRow1 = *(SRow**) p1; - SRow* pRow2 = *(SRow**) p2; + SRow* pRow1 = *(SRow**)p1; + SRow* pRow2 = *(SRow**)p2; if (pRow1->ts == pRow2->ts) { return 0; } else { - return pRow1->ts > pRow2->ts? 1:-1; + return pRow1->ts > pRow2->ts ? 1 : -1; } } @@ -563,7 +564,7 @@ int32_t doConvertRows(SSubmitTbData* pTableData, const STSchema* pTSchema, SSDat void* colData = colDataGetData(pColData, j); if (IS_STR_DATA_TYPE(pCol->type)) { // address copy, no value - SValue sv = (SValue){.nData = varDataLen(colData), .pData = (uint8_t*) varDataVal(colData)}; + SValue sv = (SValue){.nData = varDataLen(colData), .pData = (uint8_t*)varDataVal(colData)}; SColVal cv = COL_VAL_VALUE(pCol->colId, pCol->type, sv); taosArrayPush(pVals, &cv); } else { @@ -666,11 +667,9 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat if (dstTableName[0] == 0) { memset(dstTableName, 0, TSDB_TABLE_NAME_LEN); buildCtbNameByGroupIdImpl(stbFullName, groupId, dstTableName); - }else{ - if(pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER && - !isAutoTableName(dstTableName) && - !alreadyAddGroupId(dstTableName) && - groupId != 0) { + } else { + if (pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER && pTask->subtableWithoutMd5 != 1 && + !isAutoTableName(dstTableName) && !alreadyAddGroupId(dstTableName) && groupId != 0) { buildCtbNameAddGruopId(dstTableName, groupId); } } @@ -693,7 +692,7 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat tqTrace("s-task:%s cached tableInfo uid is invalid, acquire it from meta", id); return doWaitForDstTableCreated(pVnode, pTask, pTableSinkInfo, dstTableName, &pTableData->uid); } else { - tqTrace("s-task:%s set the dstTable uid from cache:%"PRId64, id, pTableData->uid); + tqTrace("s-task:%s set the dstTable uid from cache:%" PRId64, id, pTableData->uid); } } else { // The auto-create option will always set to be open for those submit messages, which arrive during the period @@ -714,7 +713,8 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat pTableData->flags = SUBMIT_REQ_AUTO_CREATE_TABLE; pTableData->pCreateTbReq = - buildAutoCreateTableReq(stbFullName, suid, pTSchema->numOfCols + 1, pDataBlock, pTagArray, pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER); + buildAutoCreateTableReq(stbFullName, suid, pTSchema->numOfCols + 1, pDataBlock, pTagArray, + pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER && pTask->subtableWithoutMd5 != 1); taosArrayDestroy(pTagArray); if (pTableData->pCreateTbReq == NULL) { @@ -746,12 +746,12 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat return TDB_CODE_SUCCESS; } -int32_t tqSetDstTableDataPayload(uint64_t suid, const STSchema *pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock, - SSubmitTbData* pTableData, const char* id) { +int32_t tqSetDstTableDataPayload(uint64_t suid, const STSchema* pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock, + SSubmitTbData* pTableData, const char* id) { int32_t numOfRows = pDataBlock->info.rows; - tqDebug("s-task:%s sink data pipeline, build submit msg from %dth resBlock, including %d rows, dst suid:%" PRId64, - id, blockIndex + 1, numOfRows, suid); + tqDebug("s-task:%s sink data pipeline, build submit msg from %dth resBlock, including %d rows, dst suid:%" PRId64, id, + blockIndex + 1, numOfRows, suid); char* dstTableName = pDataBlock->info.parTbName; // convert all rows @@ -767,14 +767,14 @@ int32_t tqSetDstTableDataPayload(uint64_t suid, const STSchema *pTSchema, int32_ } bool hasOnlySubmitData(const SArray* pBlocks, int32_t numOfBlocks) { - for(int32_t i = 0; i < numOfBlocks; ++i) { + for (int32_t i = 0; i < numOfBlocks; ++i) { SSDataBlock* p = taosArrayGet(pBlocks, i); if (p->info.type == STREAM_DELETE_RESULT || p->info.type == STREAM_CREATE_CHILD_TABLE) { return false; } } - return true; + return true; } void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) { @@ -793,7 +793,7 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) { tqDebug("vgId:%d, s-task:%s write %d stream resBlock(s) into table, has delete block, submit one-by-one", vgId, id, numOfBlocks); - for(int32_t i = 0; i < numOfBlocks; ++i) { + for (int32_t i = 0; i < numOfBlocks; ++i) { if (streamTaskShouldStop(pTask)) { return; } @@ -832,7 +832,8 @@ void tqSinkDataIntoDstTable(SStreamTask* pTask, void* vnode, void* data) { } } else { tqDebug("vgId:%d, s-task:%s write %d stream resBlock(s) into table, merge submit msg", vgId, id, numOfBlocks); - SHashObj* pTableIndexMap = taosHashInit(numOfBlocks, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); + SHashObj* pTableIndexMap = + taosHashInit(numOfBlocks, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); SSubmitReq2 submitReq = {.aSubmitTbData = taosArrayInit(1, sizeof(SSubmitTbData))}; if (submitReq.aSubmitTbData == NULL) { diff --git a/source/dnode/vnode/src/tq/tqUtil.c b/source/dnode/vnode/src/tq/tqUtil.c index 72a73c0ff2..31267dbf52 100644 --- a/source/dnode/vnode/src/tq/tqUtil.c +++ b/source/dnode/vnode/src/tq/tqUtil.c @@ -72,10 +72,11 @@ static int32_t tqInitTaosxRsp(STaosxRsp* pRsp, STqOffsetVal pOffset) { return 0; } -static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg, bool* pBlockReturned) { - uint64_t consumerId = pRequest->consumerId; - STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, pRequest->subKey); - int32_t vgId = TD_VID(pTq->pVnode); +static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, + SRpcMsg* pMsg, bool* pBlockReturned) { + uint64_t consumerId = pRequest->consumerId; + STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, pRequest->subKey); + int32_t vgId = TD_VID(pTq->pVnode); *pBlockReturned = false; // In this vnode, data has been polled by consumer for this topic, so let's continue from the last offset value. @@ -132,7 +133,7 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle, SRpcMsg* pMsg, STqOffsetVal* pOffset) { uint64_t consumerId = pRequest->consumerId; int32_t vgId = TD_VID(pTq->pVnode); - terrno = 0; + terrno = 0; SMqDataRsp dataRsp = {0}; tqInitDataRsp(&dataRsp, *pOffset); @@ -156,7 +157,7 @@ static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle, taosWUnLockLatch(&pTq->lock); } - dataRsp.reqOffset = *pOffset; // reqOffset represents the current date offset, may be changed if wal not exists + dataRsp.reqOffset = *pOffset; // reqOffset represents the current date offset, may be changed if wal not exists code = tqSendDataRsp(pHandle, pMsg, pRequest, (SMqDataRsp*)&dataRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId); end : { @@ -167,15 +168,15 @@ end : { consumerId, pHandle->subKey, vgId, dataRsp.blockNum, buf, pRequest->reqId, code); tDeleteMqDataRsp(&dataRsp); return code; - } +} } static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg, STqOffsetVal* offset) { - int code = 0; - int32_t vgId = TD_VID(pTq->pVnode); - SMqMetaRsp metaRsp = {0}; - STaosxRsp taosxRsp = {0}; + int code = 0; + int32_t vgId = TD_VID(pTq->pVnode); + SMqMetaRsp metaRsp = {0}; + STaosxRsp taosxRsp = {0}; tqInitTaosxRsp(&taosxRsp, *offset); if (offset->type != TMQ_OFFSET__LOG) { @@ -211,14 +212,16 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, int64_t fetchVer = offset->version; uint64_t st = taosGetTimestampMs(); - int totalRows = 0; + int totalRows = 0; while (1) { int32_t savedEpoch = atomic_load_32(&pHandle->epoch); ASSERT(savedEpoch <= pRequest->epoch); if (tqFetchLog(pTq, pHandle, &fetchVer, pRequest->reqId) < 0) { tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer); - code = tqSendDataRsp(pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId); + code = tqSendDataRsp( + pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, + taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId); goto end; } @@ -230,7 +233,9 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, if (pHead->msgType != TDMT_VND_SUBMIT) { if (totalRows > 0) { tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer); - code = tqSendDataRsp(pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, TMQ_MSG_TYPE__POLL_DATA_RSP, vgId); + code = tqSendDataRsp( + pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, + taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId); goto end; } @@ -257,9 +262,11 @@ static int32_t extractDataAndRspForDbStbSubscribe(STQ* pTq, STqHandle* pHandle, goto end; } - if (totalRows >= 4096 || taosxRsp.createTableNum > 0 || (taosGetTimestampMs() - st > 1000)) { + if (totalRows >= 4096 || (taosGetTimestampMs() - st > 1000)) { tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer + 1); - code = tqSendDataRsp(pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId); + code = tqSendDataRsp( + pHandle, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, + taosxRsp.createTableNum > 0 ? TMQ_MSG_TYPE__POLL_DATA_META_RSP : TMQ_MSG_TYPE__POLL_DATA_RSP, vgId); goto end; } else { fetchVer++; @@ -279,7 +286,7 @@ int32_t tqExtractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequ // 1. reset the offset if needed if (IS_OFFSET_RESET_TYPE(pRequest->reqOffset.type)) { // handle the reset offset cases, according to the consumer's choice. - bool blockReturned = false; + bool blockReturned = false; int32_t code = extractResetOffsetVal(&reqOffset, pTq, pHandle, pRequest, pMsg, &blockReturned); if (code != 0) { return code; @@ -289,7 +296,7 @@ int32_t tqExtractDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequ if (blockReturned) { return 0; } - } else if(reqOffset.type == 0){ // use the consumer specified offset + } else if (reqOffset.type == 0) { // use the consumer specified offset uError("req offset type is 0"); return TSDB_CODE_TMQ_INVALID_MSG; } @@ -452,8 +459,8 @@ int32_t tqExtractDelDataBlock(const void* pData, int32_t len, int64_t ver, void* int32_t tqGetStreamExecInfo(SVnode* pVnode, int64_t streamId, int64_t* pDelay, bool* fhFinished) { SStreamMeta* pMeta = pVnode->pTq->pStreamMeta; - int32_t numOfTasks = taosArrayGetSize(pMeta->pTaskList); - int32_t code = TSDB_CODE_SUCCESS; + int32_t numOfTasks = taosArrayGetSize(pMeta->pTaskList); + int32_t code = TSDB_CODE_SUCCESS; if (pDelay != NULL) { *pDelay = 0; diff --git a/source/dnode/vnode/src/tqCommon/tqCommon.c b/source/dnode/vnode/src/tqCommon/tqCommon.c index 9a22bc303b..cb940aa56c 100644 --- a/source/dnode/vnode/src/tqCommon/tqCommon.c +++ b/source/dnode/vnode/src/tqCommon/tqCommon.c @@ -317,14 +317,14 @@ 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); + tDeleteStreamRetrieveReq(&req); return -1; } int32_t code = 0; - if(pTask->info.taskLevel == TASK_LEVEL__SOURCE){ + if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) { code = streamProcessRetrieveReq(pTask, &req); - }else{ + } else { req.srcNodeId = pTask->info.nodeId; req.srcTaskId = pTask->id.taskId; code = broadcastRetrieveMsg(pTask, &req); @@ -334,7 +334,7 @@ int32_t tqStreamTaskProcessRetrieveReq(SStreamMeta* pMeta, SRpcMsg* pMsg) { sendRetrieveRsp(&req, &rsp); streamMetaReleaseTask(pMeta, pTask); - taosMemoryFree(req.pRetrieve); + tDeleteStreamRetrieveReq(&req); return code; } @@ -612,6 +612,10 @@ int32_t tqStreamTaskProcessDropReq(SStreamMeta* pMeta, char* msg, int32_t msgLen streamMetaReleaseTask(pMeta, pTask); } + streamMetaWLock(pMeta); + streamTaskClearHTaskAttr(pTask, pReq->resetRelHalt, false); + streamMetaWUnLock(pMeta); + // drop the stream task now streamMetaUnregisterTask(pMeta, pReq->streamId, pReq->taskId); diff --git a/source/dnode/vnode/src/vnd/vnodeAsync.c b/source/dnode/vnode/src/vnd/vnodeAsync.c index 66668b60df..313603b19f 100644 --- a/source/dnode/vnode/src/vnd/vnodeAsync.c +++ b/source/dnode/vnode/src/vnd/vnodeAsync.c @@ -433,10 +433,12 @@ static int32_t vnodeAsyncLaunchWorker(SVAsync *async) { return 0; } +#ifdef BUILD_NO_CALL int32_t vnodeAsync(SVAsync *async, EVAPriority priority, int32_t (*execute)(void *), void (*complete)(void *), void *arg, int64_t *taskId) { return vnodeAsyncC(async, 0, priority, execute, complete, arg, taskId); } +#endif int32_t vnodeAsyncC(SVAsync *async, int64_t channelId, EVAPriority priority, int32_t (*execute)(void *), void (*complete)(void *), void *arg, int64_t *taskId) { diff --git a/source/dnode/vnode/src/vnd/vnodeInitApi.c b/source/dnode/vnode/src/vnd/vnodeInitApi.c index 2392716bbf..aff7e4642b 100644 --- a/source/dnode/vnode/src/vnd/vnodeInitApi.c +++ b/source/dnode/vnode/src/vnd/vnodeInitApi.c @@ -181,12 +181,17 @@ void initStateStoreAPI(SStateStore* pStore) { pStore->streamStateSessionPut = streamStateSessionPut; pStore->streamStateSessionGet = streamStateSessionGet; pStore->streamStateSessionDel = streamStateSessionDel; + pStore->streamStateSessionReset = streamStateSessionReset; pStore->streamStateSessionClear = streamStateSessionClear; pStore->streamStateSessionGetKVByCur = streamStateSessionGetKVByCur; pStore->streamStateStateAddIfNotExist = streamStateStateAddIfNotExist; pStore->streamStateSessionGetKeyByRange = streamStateSessionGetKeyByRange; + pStore->streamStateCountGetKeyByRange = streamStateCountGetKeyByRange; pStore->streamStateSessionAllocWinBuffByNextPosition = streamStateSessionAllocWinBuffByNextPosition; + pStore->streamStateCountWinAddIfNotExist = streamStateCountWinAddIfNotExist; + pStore->streamStateCountWinAdd = streamStateCountWinAdd; + pStore->updateInfoInit = updateInfoInit; pStore->updateInfoFillBlockData = updateInfoFillBlockData; pStore->updateInfoIsUpdated = updateInfoIsUpdated; @@ -203,6 +208,7 @@ void initStateStoreAPI(SStateStore* pStore) { pStore->updateInfoDeserialize = updateInfoDeserialize; pStore->streamStateSessionSeekKeyNext = streamStateSessionSeekKeyNext; + pStore->streamStateCountSeekKeyPrev = streamStateCountSeekKeyPrev; pStore->streamStateSessionSeekKeyCurrentPrev = streamStateSessionSeekKeyCurrentPrev; pStore->streamStateSessionSeekKeyCurrentNext = streamStateSessionSeekKeyCurrentNext; diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index f9f4ee7dfc..dc30e88b29 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -848,6 +848,7 @@ typedef struct SCtgCacheItemInfo { do { \ CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); \ CTG_API_DEBUG("CTG API leave %s", __FUNCTION__); \ + return; \ } while (0) #define CTG_API_ENTER() \ diff --git a/source/libs/command/inc/commandInt.h b/source/libs/command/inc/commandInt.h index d7ded9d6f1..f8f932903f 100644 --- a/source/libs/command/inc/commandInt.h +++ b/source/libs/command/inc/commandInt.h @@ -69,6 +69,10 @@ extern "C" { #define EXPLAIN_EVENT_END_FORMAT "End Cond: " #define EXPLAIN_GROUP_CACHE_FORMAT "Group Cache" #define EXPLAIN_DYN_QRY_CTRL_FORMAT "Dynamic Query Control for %s" +#define EXPLAIN_COUNT_FORMAT "Count" +#define EXPLAIN_COUNT_INFO_FORMAT "Window Count Info" +#define EXPLAIN_COUNT_NUM_FORMAT "Window Count=%" PRId64 +#define EXPLAIN_COUNT_SLIDING_FORMAT "Window Sliding=%" PRId64 #define EXPLAIN_PLANNING_TIME_FORMAT "Planning Time: %.3f ms" #define EXPLAIN_EXEC_TIME_FORMAT "Execution Time: %.3f ms" diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index 66b50bcb47..ebe8543fae 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -1735,6 +1735,31 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i } break; } + case QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT: { + SCountWinodwPhysiNode *pCountNode = (SCountWinodwPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_COUNT_FORMAT); + EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); + } + EXPLAIN_ROW_APPEND(EXPLAIN_FUNCTIONS_FORMAT, pCountNode->window.pFuncs->length); + EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); + EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pCountNode->window.node.pOutputDataBlockDesc->totalRowSize); + EXPLAIN_ROW_APPEND(EXPLAIN_RIGHT_PARENTHESIS_FORMAT); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_COUNT_NUM_FORMAT, pCountNode->windowCount); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_COUNT_SLIDING_FORMAT, pCountNode->windowSliding); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + break; + } default: qError("not supported physical node type %d", pNode->type); return TSDB_CODE_APP_ERROR; diff --git a/source/libs/executor/inc/executorInt.h b/source/libs/executor/inc/executorInt.h index 3306cb3b53..6b0b806adb 100644 --- a/source/libs/executor/inc/executorInt.h +++ b/source/libs/executor/inc/executorInt.h @@ -371,6 +371,8 @@ typedef struct SStreamAggSupporter { STimeWindow winRange; SStorageAPI* pSessionAPI; struct SUpdateInfo* pUpdateInfo; + int32_t windowCount; + int32_t windowSliding; } SStreamAggSupporter; typedef struct SWindowSupporter { @@ -663,6 +665,27 @@ typedef struct SStreamEventAggOperatorInfo { SFilterInfo* pEndCondInfo; } SStreamEventAggOperatorInfo; +typedef struct SStreamCountAggOperatorInfo { + SOptrBasicInfo binfo; + SStreamAggSupporter streamAggSup; + SExprSupp scalarSupp; // supporter for perform scalar function + SGroupResInfo groupResInfo; + int32_t primaryTsIndex; // primary timestamp slot id + STimeWindowAggSupp twAggSup; + SSDataBlock* pDelRes; + SSHashObj* pStDeleted; + void* pDelIterator; + bool ignoreExpiredData; + bool ignoreExpiredDataSaved; + SArray* pUpdated; + SSHashObj* pStUpdated; + int64_t dataVersion; + SArray* historyWins; + bool reCkBlock; + bool recvGetAll; + SSDataBlock* pCheckpointRes; +} SStreamCountAggOperatorInfo; + typedef struct SStreamPartitionOperatorInfo { SOptrBasicInfo binfo; SPartitionBySupporter partitionSup; @@ -799,6 +822,9 @@ bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, void* pState, ST SStateStore* pStore); void appendOneRowToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid, uint64_t* pGp, void* pTbName); +void appendAllColumnToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, TSKEY* pCalStartTs, + TSKEY* pCalEndTs, uint64_t* pUid, uint64_t* pGp, void* pTbName); + uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId); int32_t finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition, SExprSupp* pSup, @@ -863,7 +889,7 @@ void resetWinRange(STimeWindow* winRange); bool checkExpiredData(SStateStore* pAPI, SUpdateInfo* pUpdateInfo, STimeWindowAggSupp* pTwSup, uint64_t tableId, TSKEY ts); int64_t getDeleteMark(SWindowPhysiNode* pWinPhyNode, int64_t interval); void resetUnCloseSessionWinInfo(SSHashObj* winMap); -void setStreamOperatorCompleted(struct SOperatorInfo* pOperator); +void setStreamOperatorCompleted(struct SOperatorInfo* pOperator); void reloadAggSupFromDownStream(struct SOperatorInfo* downstream, SStreamAggSupporter* pAggSup); int32_t encodeSSessionKey(void** buf, SSessionKey* key); @@ -880,11 +906,18 @@ void freeExchangeGetBasicOperatorParam(void* pParam); void freeOperatorParam(SOperatorParam* pParam, SOperatorParamType type); void freeResetOperatorParams(struct SOperatorInfo* pOperator, SOperatorParamType type, bool allFree); SSDataBlock* getNextBlockFromDownstreamImpl(struct SOperatorInfo* pOperator, int32_t idx, bool clearParam); +void getCountWinRange(SStreamAggSupporter* pAggSup, const SSessionKey* pKey, EStreamType mode, SSessionKey* pDelRange); +bool doDeleteSessionWindow(SStreamAggSupporter* pAggSup, SSessionKey* pKey); + +void saveDeleteInfo(SArray* pWins, SSessionKey key); +void removeSessionResults(SStreamAggSupporter* pAggSup, SSHashObj* pHashMap, SArray* pWins); +void copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted); bool inSlidingWindow(SInterval* pInterval, STimeWindow* pWin, SDataBlockInfo* pBlockInfo); bool inCalSlidingWindow(SInterval* pInterval, STimeWindow* pWin, TSKEY calStart, TSKEY calEnd, EStreamType blockType); bool compareVal(const char* v, const SStateKeys* pKey); bool inWinRange(STimeWindow* range, STimeWindow* cur); +void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SArray* result); int32_t getNextQualifiedWindow(SInterval* pInterval, STimeWindow* pNext, SDataBlockInfo* pDataBlockInfo, TSKEY* primaryKeys, int32_t prevPosition, int32_t order); diff --git a/source/libs/executor/inc/operator.h b/source/libs/executor/inc/operator.h index 0858a7e595..95208545bd 100644 --- a/source/libs/executor/inc/operator.h +++ b/source/libs/executor/inc/operator.h @@ -154,10 +154,14 @@ SOperatorInfo* createStreamFillOperatorInfo(SOperatorInfo* downstream, SStreamFi SOperatorInfo* createStreamEventAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle); +SOperatorInfo* createStreamCountAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle); + SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSortPhysiNode* pSortPhyNode, SExecTaskInfo* pTaskInfo); SOperatorInfo* createEventwindowOperatorInfo(SOperatorInfo* downstream, SPhysiNode* physiNode, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createCountwindowOperatorInfo(SOperatorInfo* downstream, SPhysiNode* physiNode, SExecTaskInfo* pTaskInfo); + SOperatorInfo* createGroupCacheOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream, SGroupCachePhysiNode* pPhyciNode, SExecTaskInfo* pTaskInfo); SOperatorInfo* createDynQueryCtrlOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream, SDynQueryCtrlPhysiNode* pPhyciNode, SExecTaskInfo* pTaskInfo); diff --git a/source/libs/executor/inc/querytask.h b/source/libs/executor/inc/querytask.h index 0c9a5e3197..886ce9705d 100644 --- a/source/libs/executor/inc/querytask.h +++ b/source/libs/executor/inc/querytask.h @@ -64,8 +64,6 @@ typedef struct { SSchemaWrapper* schema; char tbName[TSDB_TABLE_NAME_LEN]; // this is the current scan table: todo refactor int8_t recoverStep; -// bool recoverStep1Finished; -// bool recoverStep2Finished; int8_t recoverScanFinished; SQueryTableDataCond tableCond; SVersionRange fillHistoryVer; @@ -84,7 +82,6 @@ struct SExecTaskInfo { int64_t version; // used for stream to record wal version, why not move to sschemainfo SStreamTaskInfo streamInfo; SArray* schemaInfos; - SSchemaInfo schemaInfo; const char* sql; // query sql string jmp_buf env; // jump to this position when error happens. EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] diff --git a/source/libs/executor/src/countwindowoperator.c b/source/libs/executor/src/countwindowoperator.c new file mode 100644 index 0000000000..3980e5ae4d --- /dev/null +++ b/source/libs/executor/src/countwindowoperator.c @@ -0,0 +1,271 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "executorInt.h" +#include "filter.h" +#include "function.h" +#include "functionMgt.h" +#include "operator.h" +#include "querytask.h" +#include "tcommon.h" +#include "tcompare.h" +#include "tdatablock.h" +#include "ttime.h" + +typedef struct SCountWindowResult { + int32_t winRows; + SResultRow row; +} SCountWindowResult; + +typedef struct SCountWindowSupp { + SArray* pWinStates; + int32_t stateIndex; +} SCountWindowSupp; + +typedef struct SCountWindowOperatorInfo { + SOptrBasicInfo binfo; + SAggSupporter aggSup; + SExprSupp scalarSup; + int32_t tsSlotId; // primary timestamp column slot id + STimeWindowAggSupp twAggSup; + uint64_t groupId; // current group id, used to identify the data block from different groups + SResultRow* pRow; + int32_t windowCount; + int32_t windowSliding; + SCountWindowSupp countSup; +} SCountWindowOperatorInfo; + +void destroyCountWindowOperatorInfo(void* param) { + SCountWindowOperatorInfo* pInfo = (SCountWindowOperatorInfo*)param; + if (pInfo == NULL) { + return; + } + cleanupBasicInfo(&pInfo->binfo); + colDataDestroy(&pInfo->twAggSup.timeWindowData); + + cleanupAggSup(&pInfo->aggSup); + cleanupExprSupp(&pInfo->scalarSup); + taosArrayDestroy(pInfo->countSup.pWinStates); + taosMemoryFreeClear(param); +} + +static void clearWinStateBuff(SCountWindowResult* pBuff) { + pBuff->winRows = 0; +} + +static SCountWindowResult* getCountWinStateInfo(SCountWindowSupp* pCountSup) { + SCountWindowResult* pBuffInfo = taosArrayGet(pCountSup->pWinStates, pCountSup->stateIndex); + pCountSup->stateIndex = (pCountSup->stateIndex + 1) % taosArrayGetSize(pCountSup->pWinStates); + return pBuffInfo; +} + +static SCountWindowResult* setCountWindowOutputBuff(SExprSupp* pExprSup, SCountWindowSupp* pCountSup, SResultRow** pResult) { + SCountWindowResult* pBuff = getCountWinStateInfo(pCountSup); + (*pResult) = &pBuff->row; + setResultRowInitCtx(*pResult, pExprSup->pCtx, pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset); + return pBuff; +} + +static int32_t updateCountWindowInfo(int32_t start, int32_t blockRows, int32_t countWinRows, int32_t* pCurrentRows) { + int32_t rows = TMIN(countWinRows - (*pCurrentRows), blockRows - start); + (*pCurrentRows) += rows; + return rows; +} + +int32_t doCountWindowAggImpl(SOperatorInfo* pOperator, SSDataBlock* pBlock) { + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SExprSupp* pExprSup = &pOperator->exprSupp; + SCountWindowOperatorInfo* pInfo = pOperator->info; + SSDataBlock* pRes = pInfo->binfo.pRes; + SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pInfo->tsSlotId); + TSKEY* tsCols = (TSKEY*)pColInfoData->pData; + int32_t code = TSDB_CODE_SUCCESS; + + for (int32_t i = 0; i < pBlock->info.rows;) { + int32_t step = pInfo->windowSliding; + SCountWindowResult* pBuffInfo = setCountWindowOutputBuff(pExprSup, &pInfo->countSup, &pInfo->pRow); + int32_t prevRows = pBuffInfo->winRows; + int32_t num = updateCountWindowInfo(i, pBlock->info.rows, pInfo->windowCount, &pBuffInfo->winRows); + if (prevRows == 0) { + pInfo->pRow->win.skey = tsCols[i]; + } + pInfo->pRow->win.ekey = tsCols[num + i - 1]; + + updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pInfo->pRow->win, 0); + applyAggFunctionOnPartialTuples(pTaskInfo, pExprSup->pCtx, &pInfo->twAggSup.timeWindowData, i, num, + pBlock->info.rows, pExprSup->numOfExprs); + if (pBuffInfo->winRows == pInfo->windowCount) { + doUpdateNumOfRows(pExprSup->pCtx, pInfo->pRow, pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset); + copyResultrowToDataBlock(pExprSup->pExprInfo, pExprSup->numOfExprs, pInfo->pRow, pExprSup->pCtx, pRes, + pExprSup->rowEntryInfoOffset, pTaskInfo); + pRes->info.rows += pInfo->pRow->numOfRows; + clearWinStateBuff(pBuffInfo); + clearResultRowInitFlag(pExprSup->pCtx, pExprSup->numOfExprs); + } + if (pInfo->windowCount != pInfo->windowSliding) { + if (prevRows <= pInfo->windowSliding) { + if (pBuffInfo->winRows > pInfo->windowSliding) { + step = pInfo->windowSliding - prevRows; + } + } else { + step = 0; + } + } + i += step; + } + + return code; +} + +static void buildCountResult(SExprSupp* pExprSup, SCountWindowSupp* pCountSup, SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock) { + SResultRow* pResultRow = NULL; + for (int32_t i = 0; i < taosArrayGetSize(pCountSup->pWinStates); i++) { + SCountWindowResult* pBuff = setCountWindowOutputBuff(pExprSup, pCountSup, &pResultRow); + if (pBuff->winRows == 0) { + continue;; + } + doUpdateNumOfRows(pExprSup->pCtx, pResultRow, pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset); + copyResultrowToDataBlock(pExprSup->pExprInfo, pExprSup->numOfExprs, pResultRow, pExprSup->pCtx, pBlock, + pExprSup->rowEntryInfoOffset, pTaskInfo); + pBlock->info.rows += pResultRow->numOfRows; + clearWinStateBuff(pBuff); + clearResultRowInitFlag(pExprSup->pCtx, pExprSup->numOfExprs); + } +} + +static SSDataBlock* countWindowAggregate(SOperatorInfo* pOperator) { + SCountWindowOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SExprSupp* pExprSup = &pOperator->exprSupp; + int32_t order = pInfo->binfo.inputTsOrder; + SSDataBlock* pRes = pInfo->binfo.pRes; + SOperatorInfo* downstream = pOperator->pDownstream[0]; + + blockDataCleanup(pRes); + + while (1) { + SSDataBlock* pBlock = getNextBlockFromDownstream(pOperator, 0); + if (pBlock == NULL) { + break; + } + + pRes->info.scanFlag = pBlock->info.scanFlag; + setInputDataBlock(pExprSup, pBlock, order, MAIN_SCAN, true); + blockDataUpdateTsWindow(pBlock, pInfo->tsSlotId); + + // there is an scalar expression that needs to be calculated right before apply the group aggregation. + if (pInfo->scalarSup.pExprInfo != NULL) { + pTaskInfo->code = projectApplyFunctions(pInfo->scalarSup.pExprInfo, pBlock, pBlock, pInfo->scalarSup.pCtx, + pInfo->scalarSup.numOfExprs, NULL); + if (pTaskInfo->code != TSDB_CODE_SUCCESS) { + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); + } + } + + if (pInfo->groupId == 0) { + pInfo->groupId = pBlock->info.id.groupId; + } else if (pInfo->groupId != pBlock->info.id.groupId) { + buildCountResult(pExprSup, &pInfo->countSup, pTaskInfo, pRes); + pInfo->groupId = pBlock->info.id.groupId; + } + + doCountWindowAggImpl(pOperator, pBlock); + if (pRes->info.rows >= pOperator->resultInfo.threshold) { + return pRes; + } + } + + buildCountResult(pExprSup, &pInfo->countSup, pTaskInfo, pRes); + return pRes->info.rows == 0 ? NULL : pRes; +} + +SOperatorInfo* createCountwindowOperatorInfo(SOperatorInfo* downstream, SPhysiNode* physiNode, + SExecTaskInfo* pTaskInfo) { + SCountWindowOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SCountWindowOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + if (pInfo == NULL || pOperator == NULL) { + goto _error; + } + + int32_t code = TSDB_CODE_SUCCESS; + SCountWinodwPhysiNode* pCountWindowNode = (SCountWinodwPhysiNode*)physiNode; + + pInfo->tsSlotId = ((SColumnNode*)pCountWindowNode->window.pTspk)->slotId; + + if (pCountWindowNode->window.pExprs != NULL) { + int32_t numOfScalarExpr = 0; + SExprInfo* pScalarExprInfo = createExprInfo(pCountWindowNode->window.pExprs, NULL, &numOfScalarExpr); + code = initExprSupp(&pInfo->scalarSup, pScalarExprInfo, numOfScalarExpr, &pTaskInfo->storageAPI.functionStore); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + } + + size_t keyBufSize = 0; + int32_t num = 0; + SExprInfo* pExprInfo = createExprInfo(pCountWindowNode->window.pFuncs, NULL, &num); + initResultSizeInfo(&pOperator->resultInfo, 4096); + + code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str, + pTaskInfo->streamInfo.pState, &pTaskInfo->storageAPI.functionStore); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + SSDataBlock* pResBlock = createDataBlockFromDescNode(pCountWindowNode->window.node.pOutputDataBlockDesc); + blockDataEnsureCapacity(pResBlock, pOperator->resultInfo.capacity); + + initBasicInfo(&pInfo->binfo, pResBlock); + initResultRowInfo(&pInfo->binfo.resultRowInfo); + pInfo->binfo.inputTsOrder = physiNode->inputTsOrder; + pInfo->binfo.outputTsOrder = physiNode->outputTsOrder; + pInfo->windowCount = pCountWindowNode->windowCount; + pInfo->windowSliding = pCountWindowNode->windowSliding; + //sizeof(SCountWindowResult) + int32_t itemSize = sizeof(int32_t) + pInfo->aggSup.resultRowSize; + int32_t numOfItem = 1; + if (pInfo->windowCount != pInfo->windowSliding) { + numOfItem = pInfo->windowCount / pInfo->windowSliding + 1; + } + pInfo->countSup.pWinStates = taosArrayInit_s(itemSize, numOfItem); + if (!pInfo->countSup.pWinStates) { + goto _error; + } + + pInfo->countSup.stateIndex = 0; + + initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window); + + setOperatorInfo(pOperator, "CountWindowOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT, true, OP_NOT_OPENED, pInfo, + pTaskInfo); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, countWindowAggregate, NULL, destroyCountWindowOperatorInfo, + optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL); + + code = appendDownstream(pOperator, &downstream, 1); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + return pOperator; + +_error: + if (pInfo != NULL) { + destroyCountWindowOperatorInfo(pInfo); + } + + taosMemoryFreeClear(pOperator); + pTaskInfo->code = code; + return NULL; +} diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 8bd83ee0fb..bb89fb587b 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -2245,6 +2245,8 @@ char* getStreamOpName(uint16_t opType) { return "stream partitionby"; case QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT: return "stream event"; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT: + return "stream count"; } return ""; } diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 6d80b79d9d..2534c5e9f0 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -1027,52 +1027,6 @@ int32_t qSetStreamOperatorOptionForScanHistory(qTaskInfo_t tinfo) { return 0; } -int32_t qRestoreStreamOperatorOption(qTaskInfo_t tinfo) { - SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - const char* id = GET_TASKID(pTaskInfo); - SOperatorInfo* pOperator = pTaskInfo->pRoot; - - 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_MID_INTERVAL) { - SStreamIntervalOperatorInfo* pInfo = pOperator->info; - pInfo->twAggSup.calTrigger = pInfo->twAggSup.calTriggerSaved; - pInfo->twAggSup.deleteMark = pInfo->twAggSup.deleteMarkSaved; - pInfo->ignoreExpiredData = pInfo->ignoreExpiredDataSaved; - qInfo("%s restore stream agg executors param for interval: %d, %" PRId64, id, pInfo->twAggSup.calTrigger, - pInfo->twAggSup.deleteMark); - } else if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION || - type == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION || - type == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION) { - SStreamSessionAggOperatorInfo* pInfo = pOperator->info; - pInfo->twAggSup.calTrigger = pInfo->twAggSup.calTriggerSaved; - pInfo->twAggSup.deleteMark = pInfo->twAggSup.deleteMarkSaved; - pInfo->ignoreExpiredData = pInfo->ignoreExpiredDataSaved; - qInfo("%s restore stream agg executor param for session: %d, %" PRId64, id, pInfo->twAggSup.calTrigger, - pInfo->twAggSup.deleteMark); - } else if (type == QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE) { - SStreamStateAggOperatorInfo* pInfo = pOperator->info; - pInfo->twAggSup.calTrigger = pInfo->twAggSup.calTriggerSaved; - pInfo->twAggSup.deleteMark = pInfo->twAggSup.deleteMarkSaved; - pInfo->ignoreExpiredData = pInfo->ignoreExpiredDataSaved; - qInfo("%s restore stream agg executor param for state: %d, %" PRId64, id, pInfo->twAggSup.calTrigger, - pInfo->twAggSup.deleteMark); - } - - // iterate operator tree - if (pOperator->numOfDownstream != 1 || pOperator->pDownstream[0] == NULL) { - if (pOperator->numOfDownstream > 1) { - qError("unexpected stream, multiple downstream"); - return -1; - } - return 0; - } else { - pOperator = pOperator->pDownstream[0]; - } - } -} - bool qStreamScanhistoryFinished(qTaskInfo_t tinfo) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; return pTaskInfo->streamInfo.recoverScanFinished; diff --git a/source/libs/executor/src/operator.c b/source/libs/executor/src/operator.c index fd4b3cd7db..494794f8c2 100644 --- a/source/libs/executor/src/operator.c +++ b/source/libs/executor/src/operator.c @@ -542,6 +542,10 @@ SOperatorInfo* createOperator(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SR pOptr = createGroupCacheOperatorInfo(ops, size, (SGroupCachePhysiNode*)pPhyNode, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_DYN_QUERY_CTRL == type) { pOptr = createDynQueryCtrlOperatorInfo(ops, size, (SDynQueryCtrlPhysiNode*)pPhyNode, pTaskInfo); + } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT == type) { + pOptr = createStreamCountAggOperatorInfo(ops[0], pPhyNode, pTaskInfo, pHandle); + } else if (QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT == type) { + pOptr = createCountwindowOperatorInfo(ops[0], pPhyNode, pTaskInfo); } else { terrno = TSDB_CODE_INVALID_PARA; pTaskInfo->code = terrno; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index cb6ec56235..3e256c651b 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -1284,6 +1284,14 @@ static bool isSlidingWindow(SStreamScanInfo* pInfo) { return isIntervalWindow(pInfo) && pInfo->interval.interval != pInfo->interval.sliding; } +static bool isCountSlidingWindow(SStreamScanInfo* pInfo) { + return pInfo->windowSup.pStreamAggSup && (pInfo->windowSup.pStreamAggSup->windowCount != pInfo->windowSup.pStreamAggSup->windowSliding); +} + +static bool isCountWindow(SStreamScanInfo* pInfo) { + return pInfo->windowSup.parentType == QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT; +} + static void setGroupId(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_t groupColIndex, int32_t rowIndex) { SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, groupColIndex); uint64_t* groupCol = (uint64_t*)pColInfo->pData; @@ -1394,7 +1402,7 @@ static bool prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_ TSKEY* calEndData = (TSKEY*)pCalEndTsCol->pData; setGroupId(pInfo, pBlock, GROUPID_COLUMN_INDEX, *pRowIndex); - if (isSlidingWindow(pInfo)) { + if (isSlidingWindow(pInfo) || isCountSlidingWindow(pInfo)) { pInfo->updateWin.skey = calStartData[*pRowIndex]; pInfo->updateWin.ekey = calEndData[*pRowIndex]; } @@ -1588,6 +1596,47 @@ static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSr return TSDB_CODE_SUCCESS; } +static int32_t generateCountScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock, EStreamType mode) { + blockDataCleanup(pDestBlock); + if (pSrcBlock->info.rows == 0) { + return TSDB_CODE_SUCCESS; + } + int32_t code = blockDataEnsureCapacity(pDestBlock, pSrcBlock->info.rows); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + ASSERT(taosArrayGetSize(pSrcBlock->pDataBlock) >= 3); + SColumnInfoData* pStartTsCol = taosArrayGet(pSrcBlock->pDataBlock, START_TS_COLUMN_INDEX); + TSKEY* startData = (TSKEY*)pStartTsCol->pData; + SColumnInfoData* pEndTsCol = taosArrayGet(pSrcBlock->pDataBlock, END_TS_COLUMN_INDEX); + TSKEY* endData = (TSKEY*)pEndTsCol->pData; + SColumnInfoData* pUidCol = taosArrayGet(pSrcBlock->pDataBlock, UID_COLUMN_INDEX); + uint64_t* uidCol = (uint64_t*)pUidCol->pData; + + SColumnInfoData* pDestStartCol = taosArrayGet(pDestBlock->pDataBlock, START_TS_COLUMN_INDEX); + SColumnInfoData* pDestEndCol = taosArrayGet(pDestBlock->pDataBlock, END_TS_COLUMN_INDEX); + SColumnInfoData* pDestUidCol = taosArrayGet(pDestBlock->pDataBlock, UID_COLUMN_INDEX); + SColumnInfoData* pDestGpCol = taosArrayGet(pDestBlock->pDataBlock, GROUPID_COLUMN_INDEX); + SColumnInfoData* pDestCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX); + SColumnInfoData* pDestCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX); + int64_t ver = pSrcBlock->info.version - 1; + for (int32_t i = 0; i < pSrcBlock->info.rows; i++) { + uint64_t groupId = getGroupIdByData(pInfo, uidCol[i], startData[i], ver); + SSessionKey startWin = {.win.skey = startData[i], .win.ekey = endData[i], .groupId = groupId}; + SSessionKey range = {0}; + getCountWinRange(pInfo->windowSup.pStreamAggSup, &startWin, mode, &range); + colDataSetVal(pDestStartCol, i, (const char*)&range.win.skey, false); + colDataSetVal(pDestEndCol, i, (const char*)&range.win.ekey, false); + + colDataSetNULL(pDestUidCol, i); + colDataSetVal(pDestGpCol, i, (const char*)&groupId, false); + colDataSetVal(pDestCalStartTsCol, i, (const char*)&range.win.skey, false); + colDataSetVal(pDestCalEndTsCol, i, (const char*)&range.win.ekey, false); + pDestBlock->info.rows++; + } + return TSDB_CODE_SUCCESS; +} + static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) { blockDataCleanup(pDestBlock); int32_t rows = pSrcBlock->info.rows; @@ -1724,12 +1773,14 @@ static int32_t generateDeleteResultBlock(SStreamScanInfo* pInfo, SSDataBlock* pS return TSDB_CODE_SUCCESS; } -static int32_t generateScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) { +static int32_t generateScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock, EStreamType type) { int32_t code = TSDB_CODE_SUCCESS; if (isIntervalWindow(pInfo)) { code = generateIntervalScanRange(pInfo, pSrcBlock, pDestBlock); } else if (isSessionWindow(pInfo) || isStateWindow(pInfo)) { code = generateSessionScanRange(pInfo, pSrcBlock, pDestBlock); + } else if (isCountWindow(pInfo)) { + code = generateCountScanRange(pInfo, pSrcBlock, pDestBlock, type); } else { code = generateDeleteResultBlock(pInfo, pSrcBlock, pDestBlock); } @@ -1742,6 +1793,11 @@ static int32_t generateScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, void appendOneRowToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid, uint64_t* pGp, void* pTbName) { + appendAllColumnToStreamSpecialBlock(pBlock, pStartTs, pEndTs, pStartTs, pEndTs, pUid, pGp, pTbName); +} + +void appendAllColumnToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, TSKEY* pCalStartTs, + TSKEY* pCalEndTs, uint64_t* pUid, uint64_t* pGp, void* pTbName) { SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX); SColumnInfoData* pUidCol = taosArrayGet(pBlock->pDataBlock, UID_COLUMN_INDEX); @@ -1753,8 +1809,8 @@ void appendOneRowToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKE colDataSetVal(pEndTsCol, pBlock->info.rows, (const char*)pEndTs, false); colDataSetVal(pUidCol, pBlock->info.rows, (const char*)pUid, false); colDataSetVal(pGpCol, pBlock->info.rows, (const char*)pGp, false); - colDataSetVal(pCalStartCol, pBlock->info.rows, (const char*)pStartTs, false); - colDataSetVal(pCalEndCol, pBlock->info.rows, (const char*)pEndTs, false); + colDataSetVal(pCalStartCol, pBlock->info.rows, (const char*)pCalStartTs, false); + colDataSetVal(pCalEndCol, pBlock->info.rows, (const char*)pCalEndTs, false); colDataSetVal(pTableCol, pBlock->info.rows, (const char*)pTbName, pTbName == NULL); pBlock->info.rows++; } @@ -2159,6 +2215,14 @@ void streamScanOperatorDecode(void* pBuff, int32_t len, SStreamScanInfo* pInfo) taosMemoryFree(pUpInfo); } } +static bool hasScanRange(SStreamScanInfo* pInfo) { + SStreamAggSupporter* pSup = pInfo->windowSup.pStreamAggSup; + return pSup && pSup->pScanBlock->info.rows > 0 && (isStateWindow(pInfo) || isCountWindow(pInfo)); +} + +static bool isStreamWindow(SStreamScanInfo* pInfo) { + return isIntervalWindow(pInfo) || isSessionWindow(pInfo) || isStateWindow(pInfo) || isCountWindow(pInfo); +} static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { // NOTE: this operator does never check if current status is done or not @@ -2307,7 +2371,7 @@ FETCH_NEXT_BLOCK: goto FETCH_NEXT_BLOCK; } - if (!isIntervalWindow(pInfo) && !isSessionWindow(pInfo) && !isStateWindow(pInfo)) { + if (!isStreamWindow(pInfo)) { generateDeleteResultBlock(pInfo, pDelBlock, pInfo->pDeleteDataRes); pInfo->pDeleteDataRes->info.type = STREAM_DELETE_RESULT; printSpecDataBlock(pDelBlock, getStreamOpName(pOperator->operatorType), "delete result", GET_TASKID(pTaskInfo)); @@ -2321,7 +2385,7 @@ FETCH_NEXT_BLOCK: } else { pInfo->blockType = STREAM_INPUT__DATA_SUBMIT; pInfo->updateResIndex = 0; - generateScanRange(pInfo, pDelBlock, pInfo->pUpdateRes); + generateScanRange(pInfo, pDelBlock, pInfo->pUpdateRes, STREAM_DELETE_DATA); prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex); copyDataBlock(pInfo->pDeleteDataRes, pInfo->pUpdateRes); pInfo->pDeleteDataRes->info.type = STREAM_DELETE_DATA; @@ -2359,7 +2423,7 @@ FETCH_NEXT_BLOCK: } } break; case STREAM_SCAN_FROM_DELETE_DATA: { - generateScanRange(pInfo, pInfo->pUpdateDataRes, pInfo->pUpdateRes); + generateScanRange(pInfo, pInfo->pUpdateDataRes, pInfo->pUpdateRes, STREAM_DELETE_DATA); prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex); pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE; copyDataBlock(pInfo->pDeleteDataRes, pInfo->pUpdateRes); @@ -2367,7 +2431,7 @@ FETCH_NEXT_BLOCK: return pInfo->pDeleteDataRes; } break; case STREAM_SCAN_FROM_UPDATERES: { - generateScanRange(pInfo, pInfo->pUpdateDataRes, pInfo->pUpdateRes); + generateScanRange(pInfo, pInfo->pUpdateDataRes, pInfo->pUpdateRes, STREAM_CLEAR); prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex); pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE; return pInfo->pUpdateRes; @@ -2392,10 +2456,10 @@ FETCH_NEXT_BLOCK: break; } - SStreamAggSupporter* pSup = pInfo->windowSup.pStreamAggSup; - if (isStateWindow(pInfo) && pSup->pScanBlock->info.rows > 0) { + if (hasScanRange(pInfo)) { pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE; pInfo->updateResIndex = 0; + SStreamAggSupporter* pSup = pInfo->windowSup.pStreamAggSup; copyDataBlock(pInfo->pUpdateRes, pSup->pScanBlock); blockDataCleanup(pSup->pScanBlock); prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex); diff --git a/source/libs/executor/src/streamcountwindowoperator.c b/source/libs/executor/src/streamcountwindowoperator.c new file mode 100644 index 0000000000..706b4c5a01 --- /dev/null +++ b/source/libs/executor/src/streamcountwindowoperator.c @@ -0,0 +1,714 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "executorInt.h" +#include "function.h" +#include "functionMgt.h" +#include "operator.h" +#include "querytask.h" +#include "tchecksum.h" +#include "tcommon.h" +#include "tdatablock.h" +#include "tglobal.h" +#include "tlog.h" +#include "ttime.h" + +#define IS_FINAL_COUNT_OP(op) ((op)->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_COUNT) +#define STREAM_COUNT_OP_STATE_NAME "StreamCountHistoryState" +#define STREAM_COUNT_OP_CHECKPOINT_NAME "StreamCountOperator_Checkpoint" + +typedef struct SCountWindowInfo { + SResultWindowInfo winInfo; + COUNT_TYPE* pWindowCount; +} SCountWindowInfo; + +typedef enum { + NONE_WINDOW = 0, + CREATE_NEW_WINDOW, + MOVE_NEXT_WINDOW, +} BuffOp; +typedef struct SBuffInfo { + bool rebuildWindow; + BuffOp winBuffOp; + SStreamStateCur* pCur; +} SBuffInfo; + +void destroyStreamCountAggOperatorInfo(void* param) { + SStreamCountAggOperatorInfo* pInfo = (SStreamCountAggOperatorInfo*)param; + cleanupBasicInfo(&pInfo->binfo); + destroyStreamAggSupporter(&pInfo->streamAggSup); + cleanupExprSupp(&pInfo->scalarSupp); + clearGroupResInfo(&pInfo->groupResInfo); + + colDataDestroy(&pInfo->twAggSup.timeWindowData); + blockDataDestroy(pInfo->pDelRes); + tSimpleHashCleanup(pInfo->pStUpdated); + tSimpleHashCleanup(pInfo->pStDeleted); + pInfo->pUpdated = taosArrayDestroy(pInfo->pUpdated); + cleanupGroupResInfo(&pInfo->groupResInfo); + + taosArrayDestroy(pInfo->historyWins); + blockDataDestroy(pInfo->pCheckpointRes); + + taosMemoryFreeClear(param); +} + +bool isSlidingCountWindow(SStreamAggSupporter* pAggSup) { + return pAggSup->windowCount != pAggSup->windowSliding; +} + +void setCountOutputBuf(SStreamAggSupporter* pAggSup, TSKEY ts, uint64_t groupId, SCountWindowInfo* pCurWin, + SBuffInfo* pBuffInfo) { + int32_t code = TSDB_CODE_SUCCESS; + int32_t size = pAggSup->resultRowSize; + pCurWin->winInfo.sessionWin.groupId = groupId; + pCurWin->winInfo.sessionWin.win.skey = ts; + pCurWin->winInfo.sessionWin.win.ekey = ts; + + if (isSlidingCountWindow(pAggSup)) { + if (pBuffInfo->winBuffOp == CREATE_NEW_WINDOW) { + pAggSup->stateStore.streamStateCountWinAdd(pAggSup->pState, &pCurWin->winInfo.sessionWin, + (void**)&pCurWin->winInfo.pStatePos, &size); + code = TSDB_CODE_FAILED; + } else if (pBuffInfo->winBuffOp == MOVE_NEXT_WINDOW) { + ASSERT(pBuffInfo->pCur); + pAggSup->stateStore.streamStateCurNext(pAggSup->pState, pBuffInfo->pCur); + code = pAggSup->stateStore.streamStateSessionGetKVByCur(pBuffInfo->pCur, &pCurWin->winInfo.sessionWin, + (void**)&pCurWin->winInfo.pStatePos, &size); + if (code == TSDB_CODE_FAILED) { + pAggSup->stateStore.streamStateCountWinAdd(pAggSup->pState, &pCurWin->winInfo.sessionWin, + (void**)&pCurWin->winInfo.pStatePos, &size); + } + } else { + pBuffInfo->pCur = pAggSup->stateStore.streamStateCountSeekKeyPrev(pAggSup->pState, &pCurWin->winInfo.sessionWin, pAggSup->windowCount); + code = pAggSup->stateStore.streamStateSessionGetKVByCur(pBuffInfo->pCur, &pCurWin->winInfo.sessionWin, + (void**)&pCurWin->winInfo.pStatePos, &size); + if (code == TSDB_CODE_FAILED) { + pAggSup->stateStore.streamStateCountWinAdd(pAggSup->pState, &pCurWin->winInfo.sessionWin, + (void**)&pCurWin->winInfo.pStatePos, &size); + } + } + } else { + code = pAggSup->stateStore.streamStateCountWinAddIfNotExist( + pAggSup->pState, &pCurWin->winInfo.sessionWin, pAggSup->windowCount, (void**)&pCurWin->winInfo.pStatePos, &size); + } + + if (code == TSDB_CODE_SUCCESS) { + pCurWin->winInfo.isOutput = true; + } + pCurWin->pWindowCount= + (COUNT_TYPE*) ((char*)pCurWin->winInfo.pStatePos->pRowBuff + (pAggSup->resultRowSize - sizeof(COUNT_TYPE))); + + if (*pCurWin->pWindowCount == pAggSup->windowCount) { + pBuffInfo->rebuildWindow = true; + } +} + +static int32_t updateCountWindowInfo(SStreamAggSupporter* pAggSup, SCountWindowInfo* pWinInfo, TSKEY* pTs, int32_t start, int32_t rows, int32_t maxRows, + SSHashObj* pStDeleted, bool* pRebuild) { + SSessionKey sWinKey = pWinInfo->winInfo.sessionWin; + int32_t num = 0; + for (int32_t i = start; i < rows; i++) { + if (pTs[i] < pWinInfo->winInfo.sessionWin.win.ekey) { + num++; + } else { + break; + } + } + int32_t maxNum = TMIN(maxRows - *pWinInfo->pWindowCount, rows - start); + if (num > maxNum) { + *pRebuild = true; + } + *pWinInfo->pWindowCount += maxNum; + bool needDelState = false; + if (pWinInfo->winInfo.sessionWin.win.skey > pTs[start]) { + needDelState = true; + if (pStDeleted && pWinInfo->winInfo.isOutput) { + saveDeleteRes(pStDeleted, pWinInfo->winInfo.sessionWin); + } + + pWinInfo->winInfo.sessionWin.win.skey = pTs[start]; + } + + if (pWinInfo->winInfo.sessionWin.win.ekey < pTs[maxNum + start - 1]) { + needDelState = true; + pWinInfo->winInfo.sessionWin.win.ekey = pTs[maxNum + start - 1]; + } + + if (needDelState) { + memcpy(pWinInfo->winInfo.pStatePos->pKey, &pWinInfo->winInfo.sessionWin, sizeof(SSessionKey)); + if (pWinInfo->winInfo.pStatePos->needFree) { + pAggSup->stateStore.streamStateSessionDel(pAggSup->pState, &sWinKey); + } + } + + return maxNum; +} + +void getCountWinRange(SStreamAggSupporter* pAggSup, const SSessionKey* pKey, EStreamType mode, SSessionKey* pDelRange) { + *pDelRange = *pKey; + SStreamStateCur* pCur = NULL; + if (isSlidingCountWindow(pAggSup)) { + pCur = pAggSup->stateStore.streamStateCountSeekKeyPrev(pAggSup->pState, pKey, pAggSup->windowCount); + } else { + pCur = pAggSup->stateStore.streamStateSessionSeekKeyCurrentNext(pAggSup->pState, pKey); + } + SSessionKey tmpKey = {0}; + int32_t code = pAggSup->stateStore.streamStateSessionGetKVByCur(pCur, &tmpKey, NULL, 0); + if (code != TSDB_CODE_SUCCESS) { + pAggSup->stateStore.streamStateFreeCur(pCur); + return; + } + pDelRange->win = tmpKey.win; + while (mode == STREAM_DELETE_DATA) { + pAggSup->stateStore.streamStateCurNext(pAggSup->pState, pCur); + code = pAggSup->stateStore.streamStateSessionGetKVByCur(pCur, &tmpKey, NULL, 0); + if (code != TSDB_CODE_SUCCESS) { + break; + } + pDelRange->win.ekey = TMAX(pDelRange->win.ekey, tmpKey.win.ekey); + } + pAggSup->stateStore.streamStateFreeCur(pCur); +} + +static void destroySBuffInfo(SStreamAggSupporter* pAggSup, SBuffInfo* pBuffInfo) { + pAggSup->stateStore.streamStateFreeCur(pBuffInfo->pCur); +} + +bool inCountCalSlidingWindow(SStreamAggSupporter* pAggSup, STimeWindow* pWin, TSKEY sKey, TSKEY eKey) { + if (pAggSup->windowCount == pAggSup->windowSliding) { + return true; + } + if (sKey <= pWin->skey && pWin->ekey <= eKey) { + return true; + } + return false; +} + +bool inCountSlidingWindow(SStreamAggSupporter* pAggSup, STimeWindow* pWin, SDataBlockInfo* pBlockInfo) { + return inCountCalSlidingWindow(pAggSup, pWin, pBlockInfo->calWin.skey, pBlockInfo->calWin.ekey); +} + +static void doStreamCountAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBlock, SSHashObj* pStUpdated, + SSHashObj* pStDeleted) { + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SStreamCountAggOperatorInfo* pInfo = pOperator->info; + int32_t numOfOutput = pOperator->exprSupp.numOfExprs; + uint64_t groupId = pSDataBlock->info.id.groupId; + int64_t code = TSDB_CODE_SUCCESS; + SResultRow* pResult = NULL; + int32_t rows = pSDataBlock->info.rows; + int32_t winRows = 0; + SStreamAggSupporter* pAggSup = &pInfo->streamAggSup; + SBuffInfo buffInfo = {.rebuildWindow = false, .winBuffOp = NONE_WINDOW, .pCur = NULL}; + + pInfo->dataVersion = TMAX(pInfo->dataVersion, pSDataBlock->info.version); + pAggSup->winRange = pTaskInfo->streamInfo.fillHistoryWindow; + if (pAggSup->winRange.ekey <= 0) { + pAggSup->winRange.ekey = INT64_MAX; + } + + SColumnInfoData* pStartTsCol = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); + TSKEY* startTsCols = (int64_t*)pStartTsCol->pData; + blockDataEnsureCapacity(pAggSup->pScanBlock, rows * 2); + SStreamStateCur* pCur = NULL; + COUNT_TYPE slidingRows = 0; + + for (int32_t i = 0; i < rows;) { + if (pInfo->ignoreExpiredData && + checkExpiredData(&pInfo->streamAggSup.stateStore, pInfo->streamAggSup.pUpdateInfo, &pInfo->twAggSup, + pSDataBlock->info.id.uid, startTsCols[i])) { + i++; + continue; + } + SCountWindowInfo curWin = {0}; + buffInfo.rebuildWindow = false; + setCountOutputBuf(pAggSup, startTsCols[i], groupId, &curWin, &buffInfo); + if (!inCountSlidingWindow(pAggSup, &curWin.winInfo.sessionWin.win, &pSDataBlock->info)) { + buffInfo.winBuffOp = MOVE_NEXT_WINDOW; + continue; + } + setSessionWinOutputInfo(pStUpdated, &curWin.winInfo); + slidingRows = *curWin.pWindowCount; + if (!buffInfo.rebuildWindow) { + winRows = updateCountWindowInfo(pAggSup, &curWin, startTsCols, i, rows, pAggSup->windowCount, pStDeleted, &buffInfo.rebuildWindow); + } + if (buffInfo.rebuildWindow) { + SSessionKey range = {0}; + if (isSlidingCountWindow(pAggSup)) { + curWin.winInfo.sessionWin.win.skey = startTsCols[i]; + curWin.winInfo.sessionWin.win.ekey = startTsCols[i]; + } + getCountWinRange(pAggSup, &curWin.winInfo.sessionWin, STREAM_DELETE_DATA, &range); + range.win.skey = TMIN(startTsCols[i], range.win.skey); + range.win.ekey = TMAX(startTsCols[rows-1], range.win.ekey); + uint64_t uid = 0; + appendOneRowToStreamSpecialBlock(pAggSup->pScanBlock, &range.win.skey, &range.win.ekey, &uid, &range.groupId, NULL); + break; + } + code = doOneWindowAggImpl(&pInfo->twAggSup.timeWindowData, &curWin.winInfo, &pResult, i, winRows, rows, numOfOutput, + pOperator, 0); + if (code != TSDB_CODE_SUCCESS || pResult == NULL) { + qError("%s do stream count aggregate impl error, code %s", GET_TASKID(pTaskInfo), tstrerror(code)); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); + } + saveSessionOutputBuf(pAggSup, &curWin.winInfo); + + if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pStUpdated) { + code = saveResult(curWin.winInfo, pStUpdated); + if (code != TSDB_CODE_SUCCESS) { + qError("%s do stream count aggregate impl, set result error, code %s", GET_TASKID(pTaskInfo), + tstrerror(code)); + T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); + } + } + if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE) { + SSessionKey key = {0}; + getSessionHashKey(&curWin.winInfo.sessionWin, &key); + tSimpleHashPut(pAggSup->pResultRows, &key, sizeof(SSessionKey), &curWin.winInfo, sizeof(SResultWindowInfo)); + } + + if (isSlidingCountWindow(pAggSup)) { + if (slidingRows <= pAggSup->windowSliding) { + if (slidingRows + winRows > pAggSup->windowSliding) { + buffInfo.winBuffOp = CREATE_NEW_WINDOW; + winRows = pAggSup->windowSliding - slidingRows; + ASSERT(i >= 0); + } + } else { + buffInfo.winBuffOp = MOVE_NEXT_WINDOW; + winRows = 0; + } + } + i += winRows; + } + destroySBuffInfo(pAggSup, &buffInfo); +} + +static SSDataBlock* buildCountResult(SOperatorInfo* pOperator) { + SStreamCountAggOperatorInfo* pInfo = pOperator->info; + SStreamAggSupporter* pAggSup = &pInfo->streamAggSup; + SOptrBasicInfo* pBInfo = &pInfo->binfo; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + doBuildDeleteDataBlock(pOperator, pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator); + if (pInfo->pDelRes->info.rows > 0) { + printDataBlock(pInfo->pDelRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pInfo->pDelRes; + } + + doBuildSessionResult(pOperator, pAggSup->pState, &pInfo->groupResInfo, pBInfo->pRes); + if (pBInfo->pRes->info.rows > 0) { + printDataBlock(pBInfo->pRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pBInfo->pRes; + } + return NULL; +} + +int32_t doStreamCountEncodeOpState(void** buf, int32_t len, SOperatorInfo* pOperator, bool isParent) { + SStreamCountAggOperatorInfo* pInfo = pOperator->info; + if (!pInfo) { + return 0; + } + + void* pData = (buf == NULL) ? NULL : *buf; + + // 1.streamAggSup.pResultRows + int32_t tlen = 0; + int32_t mapSize = tSimpleHashGetSize(pInfo->streamAggSup.pResultRows); + tlen += taosEncodeFixedI32(buf, mapSize); + void* pIte = NULL; + size_t keyLen = 0; + int32_t iter = 0; + while ((pIte = tSimpleHashIterate(pInfo->streamAggSup.pResultRows, pIte, &iter)) != NULL) { + void* key = taosHashGetKey(pIte, &keyLen); + tlen += encodeSSessionKey(buf, key); + tlen += encodeSResultWindowInfo(buf, pIte, pInfo->streamAggSup.resultRowSize); + } + + // 2.twAggSup + tlen += encodeSTimeWindowAggSupp(buf, &pInfo->twAggSup); + + // 3.dataVersion + tlen += taosEncodeFixedI32(buf, pInfo->dataVersion); + + // 4.checksum + if (isParent) { + if (buf) { + uint32_t cksum = taosCalcChecksum(0, pData, len - sizeof(uint32_t)); + tlen += taosEncodeFixedU32(buf, cksum); + } else { + tlen += sizeof(uint32_t); + } + } + + return tlen; +} + +void* doStreamCountDecodeOpState(void* buf, int32_t len, SOperatorInfo* pOperator, bool isParent) { + SStreamCountAggOperatorInfo* pInfo = pOperator->info; + if (!pInfo) { + return buf; + } + + // 4.checksum + if (isParent) { + int32_t dataLen = len - sizeof(uint32_t); + void* pCksum = POINTER_SHIFT(buf, dataLen); + if (taosCheckChecksum(buf, dataLen, *(uint32_t*)pCksum) != TSDB_CODE_SUCCESS) { + qError("stream count state is invalid"); + return buf; + } + } + + // 1.streamAggSup.pResultRows + int32_t mapSize = 0; + buf = taosDecodeFixedI32(buf, &mapSize); + for (int32_t i = 0; i < mapSize; i++) { + SSessionKey key = {0}; + SResultWindowInfo winfo = {0}; + buf = decodeSSessionKey(buf, &key); + buf = decodeSResultWindowInfo(buf, &winfo, pInfo->streamAggSup.resultRowSize); + tSimpleHashPut(pInfo->streamAggSup.pResultRows, &key, sizeof(SSessionKey), &winfo, sizeof(SResultWindowInfo)); + } + + // 2.twAggSup + buf = decodeSTimeWindowAggSupp(buf, &pInfo->twAggSup); + + // 3.dataVersion + buf = taosDecodeFixedI64(buf, &pInfo->dataVersion); + return buf; +} + +void doStreamCountSaveCheckpoint(SOperatorInfo* pOperator) { + SStreamCountAggOperatorInfo* pInfo = pOperator->info; + int32_t len = doStreamCountEncodeOpState(NULL, 0, pOperator, true); + void* buf = taosMemoryCalloc(1, len); + void* pBuf = buf; + len = doStreamCountEncodeOpState(&pBuf, len, pOperator, true); + pInfo->streamAggSup.stateStore.streamStateSaveInfo(pInfo->streamAggSup.pState, STREAM_COUNT_OP_CHECKPOINT_NAME, + strlen(STREAM_COUNT_OP_CHECKPOINT_NAME), buf, len); + taosMemoryFree(buf); +} + +void doResetCountWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock) { + SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); + TSKEY* startDatas = (TSKEY*)pStartTsCol->pData; + SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX); + TSKEY* endDatas = (TSKEY*)pEndTsCol->pData; + SColumnInfoData* pCalStartTsCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX); + TSKEY* calStartDatas = (TSKEY*)pStartTsCol->pData; + SColumnInfoData* pCalEndTsCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX); + TSKEY* calEndDatas = (TSKEY*)pEndTsCol->pData; + SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); + uint64_t* gpDatas = (uint64_t*)pGroupCol->pData; + + SRowBuffPos* pPos = NULL; + int32_t size = 0; + for (int32_t i = 0; i < pBlock->info.rows; i++) { + SSessionKey key = {.groupId = gpDatas[i], .win.skey = startDatas[i], .win.ekey = endDatas[i]}; + SStreamStateCur* pCur = NULL; + if (isSlidingCountWindow(pAggSup)) { + pCur = pAggSup->stateStore.streamStateCountSeekKeyPrev(pAggSup->pState, &key, pAggSup->windowCount); + } else { + pCur = pAggSup->stateStore.streamStateSessionSeekKeyCurrentNext(pAggSup->pState, &key); + } + while (1) { + SSessionKey tmpKey = {0}; + int32_t code = pAggSup->stateStore.streamStateSessionGetKVByCur(pCur, &tmpKey, (void **)&pPos, &size); + if (code != TSDB_CODE_SUCCESS || tmpKey.win.skey > endDatas[i]) { + pAggSup->stateStore.streamStateFreeCur(pCur); + break; + } + if (!inCountCalSlidingWindow(pAggSup, &tmpKey.win, calStartDatas[i], calEndDatas[i])) { + pAggSup->stateStore.streamStateCurNext(pAggSup->pState, pCur); + continue; + } + pAggSup->stateStore.streamStateSessionReset(pAggSup->pState, pPos->pRowBuff); + pAggSup->stateStore.streamStateCurNext(pAggSup->pState, pCur); + } + } +} + +void doDeleteCountWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SArray* result) { + SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); + TSKEY* startDatas = (TSKEY*)pStartTsCol->pData; + SColumnInfoData* pEndTsCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX); + TSKEY* endDatas = (TSKEY*)pEndTsCol->pData; + SColumnInfoData* pCalStartTsCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX); + TSKEY* calStartDatas = (TSKEY*)pStartTsCol->pData; + SColumnInfoData* pCalEndTsCol = taosArrayGet(pBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX); + TSKEY* calEndDatas = (TSKEY*)pEndTsCol->pData; + SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX); + uint64_t* gpDatas = (uint64_t*)pGroupCol->pData; + for (int32_t i = 0; i < pBlock->info.rows; i++) { + SSessionKey key = {.win.skey = startDatas[i], .win.ekey = endDatas[i], .groupId = gpDatas[i]}; + while (1) { + SSessionKey curWin = {0}; + int32_t code = pAggSup->stateStore.streamStateCountGetKeyByRange(pAggSup->pState, &key, &curWin); + if (code == TSDB_CODE_FAILED) { + break; + } + doDeleteSessionWindow(pAggSup, &curWin); + if (result) { + saveDeleteInfo(result, curWin); + } + } + } +} + +void deleteCountWinState(SStreamAggSupporter* pAggSup, SSDataBlock* pBlock, SSHashObj* pMapUpdate, + SSHashObj* pMapDelete) { + SArray* pWins = taosArrayInit(16, sizeof(SSessionKey)); + if (isSlidingCountWindow(pAggSup)) { + doDeleteCountWindows(pAggSup, pBlock, pWins); + } else { + doDeleteTimeWindows(pAggSup, pBlock, pWins); + } + removeSessionResults(pAggSup, pMapUpdate, pWins); + copyDeleteWindowInfo(pWins, pMapDelete); + taosArrayDestroy(pWins); +} + +static SSDataBlock* doStreamCountAgg(SOperatorInfo* pOperator) { + SExprSupp* pSup = &pOperator->exprSupp; + SStreamCountAggOperatorInfo* pInfo = pOperator->info; + SOptrBasicInfo* pBInfo = &pInfo->binfo; + SStreamAggSupporter* pAggSup = &pInfo->streamAggSup; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + 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* opRes = buildCountResult(pOperator); + if (opRes) { + return opRes; + } + + if (pInfo->recvGetAll) { + pInfo->recvGetAll = false; + resetUnCloseSessionWinInfo(pInfo->streamAggSup.pResultRows); + } + + if (pInfo->reCkBlock) { + pInfo->reCkBlock = false; + printDataBlock(pInfo->pCheckpointRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pInfo->pCheckpointRes; + } + + setStreamOperatorCompleted(pOperator); + return NULL; + } + + SOperatorInfo* downstream = pOperator->pDownstream[0]; + if (!pInfo->pUpdated) { + pInfo->pUpdated = taosArrayInit(16, sizeof(SResultWindowInfo)); + } + if (!pInfo->pStUpdated) { + _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); + pInfo->pStUpdated = tSimpleHashInit(64, hashFn); + } + while (1) { + SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); + if (pBlock == NULL) { + break; + } + printSpecDataBlock(pBlock, getStreamOpName(pOperator->operatorType), "recv", GET_TASKID(pTaskInfo)); + + if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) { + deleteCountWinState(&pInfo->streamAggSup, pBlock, pInfo->pStUpdated, pInfo->pStDeleted); + continue; + } else if (pBlock->info.type == STREAM_CLEAR) { + doResetCountWindows(&pInfo->streamAggSup, pBlock); + continue; + } else if (pBlock->info.type == STREAM_GET_ALL) { + pInfo->recvGetAll = true; + getAllSessionWindow(pAggSup->pResultRows, pInfo->pStUpdated); + continue; + } else if (pBlock->info.type == STREAM_CREATE_CHILD_TABLE) { + return pBlock; + } else if (pBlock->info.type == STREAM_CHECKPOINT) { + pAggSup->stateStore.streamStateCommit(pAggSup->pState); + doStreamCountSaveCheckpoint(pOperator); + copyDataBlock(pInfo->pCheckpointRes, pBlock); + continue; + } else { + ASSERTS(pBlock->info.type == STREAM_NORMAL || 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); + } + // the pDataBlock are always the same one, no need to call this again + setInputDataBlock(pSup, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true); + doStreamCountAggImpl(pOperator, pBlock, pInfo->pStUpdated, pInfo->pStDeleted); + pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey); + pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.watermark); + } + // restore the value + pOperator->status = OP_RES_TO_RETURN; + + closeSessionWindow(pAggSup->pResultRows, &pInfo->twAggSup, pInfo->pStUpdated); + copyUpdateResult(&pInfo->pStUpdated, pInfo->pUpdated, sessionKeyCompareAsc); + removeSessionDeleteResults(pInfo->pStDeleted, pInfo->pUpdated); + initGroupResInfoFromArrayList(&pInfo->groupResInfo, pInfo->pUpdated); + pInfo->pUpdated = NULL; + blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity); + + SSDataBlock* opRes = buildCountResult(pOperator); + if (opRes) { + return opRes; + } + + setStreamOperatorCompleted(pOperator); + return NULL; +} + +void streamCountReleaseState(SOperatorInfo* pOperator) { + SStreamEventAggOperatorInfo* pInfo = pOperator->info; + int32_t resSize = sizeof(TSKEY); + char* pBuff = taosMemoryCalloc(1, resSize); + memcpy(pBuff, &pInfo->twAggSup.maxTs, sizeof(TSKEY)); + qDebug("===stream=== count window operator relase state. "); + pInfo->streamAggSup.stateStore.streamStateSaveInfo(pInfo->streamAggSup.pState, STREAM_COUNT_OP_STATE_NAME, + strlen(STREAM_COUNT_OP_STATE_NAME), pBuff, resSize); + pInfo->streamAggSup.stateStore.streamStateCommit(pInfo->streamAggSup.pState); + taosMemoryFreeClear(pBuff); + SOperatorInfo* downstream = pOperator->pDownstream[0]; + if (downstream->fpSet.releaseStreamStateFn) { + downstream->fpSet.releaseStreamStateFn(downstream); + } +} + +void streamCountReloadState(SOperatorInfo* pOperator) { + SStreamCountAggOperatorInfo* pInfo = pOperator->info; + SStreamAggSupporter* pAggSup = &pInfo->streamAggSup; + int32_t size = 0; + void* pBuf = NULL; + + int32_t code = pAggSup->stateStore.streamStateGetInfo(pAggSup->pState, STREAM_COUNT_OP_STATE_NAME, + strlen(STREAM_COUNT_OP_STATE_NAME), &pBuf, &size); + TSKEY ts = *(TSKEY*)pBuf; + pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, ts); + taosMemoryFree(pBuf); + + SOperatorInfo* downstream = pOperator->pDownstream[0]; + if (downstream->fpSet.reloadStreamStateFn) { + downstream->fpSet.reloadStreamStateFn(downstream); + } + reloadAggSupFromDownStream(downstream, &pInfo->streamAggSup); +} + +SOperatorInfo* createStreamCountAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, + SExecTaskInfo* pTaskInfo, SReadHandle* pHandle) { + SCountWinodwPhysiNode* pCountNode = (SCountWinodwPhysiNode*)pPhyNode; + int32_t numOfCols = 0; + int32_t code = TSDB_CODE_OUT_OF_MEMORY; + SStreamCountAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamCountAggOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + if (pInfo == NULL || pOperator == NULL) { + goto _error; + } + + pOperator->pTaskInfo = pTaskInfo; + + initResultSizeInfo(&pOperator->resultInfo, 4096); + if (pCountNode->window.pExprs != NULL) { + int32_t numOfScalar = 0; + SExprInfo* pScalarExprInfo = createExprInfo(pCountNode->window.pExprs, NULL, &numOfScalar); + code = initExprSupp(&pInfo->scalarSupp, pScalarExprInfo, numOfScalar, &pTaskInfo->storageAPI.functionStore); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + } + SExprSupp* pExpSup = &pOperator->exprSupp; + + SExprInfo* pExprInfo = createExprInfo(pCountNode->window.pFuncs, NULL, &numOfCols); + SSDataBlock* pResBlock = createDataBlockFromDescNode(pPhyNode->pOutputDataBlockDesc); + code = initBasicInfoEx(&pInfo->binfo, pExpSup, pExprInfo, numOfCols, pResBlock, &pTaskInfo->storageAPI.functionStore); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + code = initStreamAggSupporter(&pInfo->streamAggSup, pExpSup, numOfCols, 0, + pTaskInfo->streamInfo.pState, sizeof(COUNT_TYPE), 0, &pTaskInfo->storageAPI.stateStore, pHandle, + &pInfo->twAggSup, GET_TASKID(pTaskInfo), &pTaskInfo->storageAPI); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + pInfo->streamAggSup.windowCount = pCountNode->windowCount; + pInfo->streamAggSup.windowSliding = pCountNode->windowSliding; + + pInfo->twAggSup = (STimeWindowAggSupp){ + .waterMark = pCountNode->window.watermark, + .calTrigger = pCountNode->window.triggerType, + .maxTs = INT64_MIN, + .minTs = INT64_MAX, + }; + + initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window); + + pInfo->primaryTsIndex = ((SColumnNode*)pCountNode->window.pTspk)->slotId; + + pInfo->binfo.pRes = pResBlock; + _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); + pInfo->pStDeleted = tSimpleHashInit(64, hashFn); + pInfo->pDelIterator = NULL; + pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT); + pInfo->ignoreExpiredData = pCountNode->window.igExpired; + pInfo->ignoreExpiredDataSaved = false; + pInfo->pUpdated = NULL; + pInfo->pStUpdated = NULL; + pInfo->dataVersion = 0; + pInfo->historyWins = taosArrayInit(4, sizeof(SSessionKey)); + if (!pInfo->historyWins) { + goto _error; + } + + pInfo->pCheckpointRes = createSpecialDataBlock(STREAM_CHECKPOINT); + pInfo->recvGetAll = false; + + pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT; + // for stream + void* buff = NULL; + int32_t len = 0; + int32_t res = + pInfo->streamAggSup.stateStore.streamStateGetInfo(pInfo->streamAggSup.pState, STREAM_COUNT_OP_CHECKPOINT_NAME, + strlen(STREAM_COUNT_OP_CHECKPOINT_NAME), &buff, &len); + if (res == TSDB_CODE_SUCCESS) { + doStreamCountDecodeOpState(buff, len, pOperator, true); + taosMemoryFree(buff); + } + setOperatorInfo(pOperator, getStreamOpName(pOperator->operatorType), QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT, true, + OP_NOT_OPENED, pInfo, pTaskInfo); + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doStreamCountAgg, NULL, destroyStreamCountAggOperatorInfo, + optrDefaultBufFn, NULL, optrDefaultGetNextExtFn, NULL); + setOperatorStreamStateFn(pOperator, streamCountReleaseState, streamCountReloadState); + + if (downstream) { + initDownStream(downstream, &pInfo->streamAggSup, pOperator->operatorType, pInfo->primaryTsIndex, &pInfo->twAggSup); + code = appendDownstream(pOperator, &downstream, 1); + } + return pOperator; + +_error: + if (pInfo != NULL) { + destroyStreamCountAggOperatorInfo(pInfo); + } + + taosMemoryFreeClear(pOperator); + pTaskInfo->code = code; + return NULL; +} + diff --git a/source/libs/executor/src/streamtimewindowoperator.c b/source/libs/executor/src/streamtimewindowoperator.c index b3f18d08ac..2838d005ab 100644 --- a/source/libs/executor/src/streamtimewindowoperator.c +++ b/source/libs/executor/src/streamtimewindowoperator.c @@ -1945,7 +1945,7 @@ int32_t doOneWindowAggImpl(SColumnInfoData* pTimeWindowData, SResultWindowInfo* return TSDB_CODE_SUCCESS; } -static bool doDeleteSessionWindow(SStreamAggSupporter* pAggSup, SSessionKey* pKey) { +bool doDeleteSessionWindow(SStreamAggSupporter* pAggSup, SSessionKey* pKey) { pAggSup->stateStore.streamStateSessionDel(pAggSup->pState, pKey); SSessionKey hashKey = {0}; getSessionHashKey(pKey, &hashKey); @@ -2343,7 +2343,7 @@ int32_t getAllSessionWindow(SSHashObj* pHashMap, SSHashObj* pStUpdated) { return TSDB_CODE_SUCCESS; } -static void copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted) { +void copyDeleteWindowInfo(SArray* pResWins, SSHashObj* pStDeleted) { int32_t size = taosArrayGetSize(pResWins); for (int32_t i = 0; i < size; i++) { SSessionKey* pWinKey = taosArrayGet(pResWins, i); diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 3559e57ebc..fde5f22aaa 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -1043,7 +1043,7 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SBlockO return 0; } -static SSDataBlock* getRowsBlockWithinMergeLimit(const SSortHandle* pHandle, SSHashObj* mTableNumRows, SSDataBlock* pOrigBlk, bool* pExtractedBlock) { +static SSDataBlock* getRowsBlockWithinMergeLimit(const SSortHandle* pHandle, SSHashObj* mTableNumRows, SSDataBlock* pOrigBlk, bool* pExtractedBlock, bool *pSkipBlock) { int64_t nRows = 0; int64_t prevRows = 0; void* pNum = tSimpleHashGet(mTableNumRows, &pOrigBlk->info.id.uid, sizeof(pOrigBlk->info.id.uid)); @@ -1062,9 +1062,15 @@ static SSDataBlock* getRowsBlockWithinMergeLimit(const SSortHandle* pHandle, SSH if (pHandle->mergeLimitReachedFn) { pHandle->mergeLimitReachedFn(pOrigBlk->info.id.uid, pHandle->mergeLimitReachedParam); } - keepRows = pHandle->mergeLimit - prevRows; + keepRows = pHandle->mergeLimit > prevRows ? (pHandle->mergeLimit - prevRows) : 0; } - + + if (keepRows == 0) { + *pSkipBlock = true; + return pOrigBlk; + } + + *pSkipBlock = false; SSDataBlock* pBlock = NULL; if (keepRows != pOrigBlk->info.rows) { pBlock = blockDataExtractBlock(pOrigBlk, 0, keepRows); @@ -1106,8 +1112,12 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) { int64_t p = taosGetTimestampUs(); bool bExtractedBlock = false; + bool bSkipBlock = false; if (pBlk != NULL && pHandle->mergeLimit > 0) { - pBlk = getRowsBlockWithinMergeLimit(pHandle, mTableNumRows, pBlk, &bExtractedBlock); + pBlk = getRowsBlockWithinMergeLimit(pHandle, mTableNumRows, pBlk, &bExtractedBlock, &bSkipBlock); + if (bSkipBlock) { + continue; + } } if (pBlk != NULL) { @@ -1121,7 +1131,6 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) { if (pBlk != NULL) { szSort += blockDataGetSize(pBlk); - void* ppBlk = tSimpleHashGet(mUidBlk, &pBlk->info.id.uid, sizeof(pBlk->info.id.uid)); if (ppBlk != NULL) { SSDataBlock* tBlk = *(SSDataBlock**)(ppBlk); @@ -1138,7 +1147,6 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) { if ((pBlk != NULL && szSort > maxBufSize) || (pBlk == NULL && szSort > 0)) { tSimpleHashClear(mUidBlk); - code = sortBlocksToExtSource(pHandle, aBlkSort, pOrder, aExtSrc); if (code != TSDB_CODE_SUCCESS) { tSimpleHashCleanup(mUidBlk); diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index f559d90604..0ad454a8ee 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -329,6 +329,13 @@ static int32_t eventWindowNodeCopy(const SEventWindowNode* pSrc, SEventWindowNod return TSDB_CODE_SUCCESS; } +static int32_t countWindowNodeCopy(const SCountWindowNode* pSrc, SCountWindowNode* pDst) { + CLONE_NODE_FIELD(pCol); + COPY_SCALAR_FIELD(windowCount); + COPY_SCALAR_FIELD(windowSliding); + return TSDB_CODE_SUCCESS; +} + static int32_t sessionWindowNodeCopy(const SSessionWindowNode* pSrc, SSessionWindowNode* pDst) { CLONE_NODE_FIELD_EX(pCol, SColumnNode*); CLONE_NODE_FIELD_EX(pGap, SValueNode*); @@ -551,6 +558,8 @@ static int32_t logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* p COPY_SCALAR_FIELD(igExpired); COPY_SCALAR_FIELD(igCheckUpdate); COPY_SCALAR_FIELD(windowAlgo); + COPY_SCALAR_FIELD(windowCount); + COPY_SCALAR_FIELD(windowSliding); return TSDB_CODE_SUCCESS; } @@ -853,6 +862,9 @@ SNode* nodesCloneNode(const SNode* pNode) { case QUERY_NODE_EVENT_WINDOW: code = eventWindowNodeCopy((const SEventWindowNode*)pNode, (SEventWindowNode*)pDst); break; + case QUERY_NODE_COUNT_WINDOW: + code = countWindowNodeCopy((const SCountWindowNode*)pNode, (SCountWindowNode*)pDst); + break; case QUERY_NODE_SESSION_WINDOW: code = sessionWindowNodeCopy((const SSessionWindowNode*)pNode, (SSessionWindowNode*)pDst); break; diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 0e491c777d..28c7c511ed 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -91,6 +91,8 @@ const char* nodesNodeName(ENodeType type) { return "CaseWhen"; case QUERY_NODE_EVENT_WINDOW: return "EventWindow"; + case QUERY_NODE_COUNT_WINDOW: + return "CountWindow"; case QUERY_NODE_SET_OPERATOR: return "SetOperator"; case QUERY_NODE_SELECT_STMT: @@ -343,6 +345,10 @@ const char* nodesNodeName(ENodeType type) { return "PhysiMergeEventWindow"; case QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT: return "PhysiStreamEventWindow"; + case QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT: + return "PhysiMergeCountWindow"; + case QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT: + return "PhysiStreamCountWindow"; case QUERY_NODE_PHYSICAL_PLAN_PROJECT: return "PhysiProject"; case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN: @@ -2745,6 +2751,36 @@ static int32_t jsonToPhysiEventWindowNode(const SJson* pJson, void* pObj) { return code; } +static const char* jkCountWindowPhysiPlanWindowCount = "WindowCount"; +static const char* jkCountWindowPhysiPlanWindowSliding = "WindowSliding"; + +static int32_t physiCountWindowNodeToJson(const void* pObj, SJson* pJson) { + const SCountWinodwPhysiNode* pNode = (const SCountWinodwPhysiNode*)pObj; + + int32_t code = physiWindowNodeToJson(pObj, pJson); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkCountWindowPhysiPlanWindowCount, pNode->windowCount); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkCountWindowPhysiPlanWindowSliding, pNode->windowSliding); + } + return code; +} + +static int32_t jsonToPhysiCountWindowNode(const SJson* pJson, void* pObj) { + SCountWinodwPhysiNode* pNode = (SCountWinodwPhysiNode*)pObj; + + int32_t code = jsonToPhysiWindowNode(pJson, pObj); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBigIntValue(pJson, jkCountWindowPhysiPlanWindowCount, &pNode->windowCount); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBigIntValue(pJson, jkCountWindowPhysiPlanWindowSliding, &pNode->windowSliding); + } + + return code; +} + static const char* jkPartitionPhysiPlanExprs = "Exprs"; static const char* jkPartitionPhysiPlanPartitionKeys = "PartitionKeys"; static const char* jkPartitionPhysiPlanTargets = "Targets"; @@ -4408,6 +4444,36 @@ static int32_t jsonToEventWindowNode(const SJson* pJson, void* pObj) { return code; } +static const char* jkCountWindowTsPrimaryKey = "CountTsPrimaryKey"; +static const char* jkCountWindowCount = "CountWindowCount"; +static const char* jkCountWindowSliding = "CountWindowSliding"; + +static int32_t countWindowNodeToJson(const void* pObj, SJson* pJson) { + const SCountWindowNode* pNode = (const SCountWindowNode*)pObj; + + int32_t code = tjsonAddObject(pJson, jkCountWindowTsPrimaryKey, nodeToJson, pNode->pCol); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkCountWindowCount, pNode->windowCount); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkCountWindowSliding, pNode->windowSliding); + } + return code; +} + +static int32_t jsonToCountWindowNode(const SJson* pJson, void* pObj) { + SCountWindowNode* pNode = (SCountWindowNode*)pObj; + + int32_t code = jsonToNodeObject(pJson, jkCountWindowTsPrimaryKey, &pNode->pCol); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBigIntValue(pJson, jkCountWindowCount, &pNode->windowCount); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBigIntValue(pJson, jkCountWindowSliding, &pNode->windowSliding); + } + return code; +} + static const char* jkIntervalWindowInterval = "Interval"; static const char* jkIntervalWindowOffset = "Offset"; static const char* jkIntervalWindowSliding = "Sliding"; @@ -6985,6 +7051,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { return caseWhenNodeToJson(pObj, pJson); case QUERY_NODE_EVENT_WINDOW: return eventWindowNodeToJson(pObj, pJson); + case QUERY_NODE_COUNT_WINDOW: + return countWindowNodeToJson(pObj, pJson); case QUERY_NODE_SET_OPERATOR: return setOperatorToJson(pObj, pJson); case QUERY_NODE_SELECT_STMT: @@ -7224,6 +7292,9 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { case QUERY_NODE_PHYSICAL_PLAN_MERGE_EVENT: case QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT: return physiEventWindowNodeToJson(pObj, pJson); + case QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT: + return physiCountWindowNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_PARTITION: return physiPartitionNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: @@ -7317,6 +7388,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { return jsonToCaseWhenNode(pJson, pObj); case QUERY_NODE_EVENT_WINDOW: return jsonToEventWindowNode(pJson, pObj); + case QUERY_NODE_COUNT_WINDOW: + return jsonToCountWindowNode(pJson, pObj); case QUERY_NODE_SET_OPERATOR: return jsonToSetOperator(pJson, pObj); case QUERY_NODE_SELECT_STMT: @@ -7564,6 +7637,9 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { case QUERY_NODE_PHYSICAL_PLAN_MERGE_EVENT: case QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT: return jsonToPhysiEventWindowNode(pJson, pObj); + case QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT: + return jsonToPhysiCountWindowNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_PARTITION: return jsonToPhysiPartitionNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: diff --git a/source/libs/nodes/src/nodesMsgFuncs.c b/source/libs/nodes/src/nodesMsgFuncs.c index cdbf87b8e3..2c8fb4141a 100644 --- a/source/libs/nodes/src/nodesMsgFuncs.c +++ b/source/libs/nodes/src/nodesMsgFuncs.c @@ -3210,6 +3210,46 @@ static int32_t msgToPhysiEventWindowNode(STlvDecoder* pDecoder, void* pObj) { return code; } +enum { PHY_COUNT_CODE_WINDOW = 1, PHY_COUNT_CODE_WINDOW_COUNT, PHY_COUNT_CODE_WINDOW_SLIDING }; + +static int32_t physiCountWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { + const SCountWinodwPhysiNode* pNode = (const SCountWinodwPhysiNode*)pObj; + + int32_t code = tlvEncodeObj(pEncoder, PHY_COUNT_CODE_WINDOW, physiWindowNodeToMsg, &pNode->window); + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeI64(pEncoder, PHY_COUNT_CODE_WINDOW_COUNT, pNode->windowCount); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeI64(pEncoder, PHY_COUNT_CODE_WINDOW_SLIDING, pNode->windowSliding); + } + + return code; +} + +static int32_t msgToPhysiCountWindowNode(STlvDecoder* pDecoder, void* pObj) { + SCountWinodwPhysiNode* pNode = (SCountWinodwPhysiNode*)pObj; + + int32_t code = TSDB_CODE_SUCCESS; + STlv* pTlv = NULL; + tlvForEach(pDecoder, pTlv, code) { + switch (pTlv->type) { + case PHY_COUNT_CODE_WINDOW: + code = tlvDecodeObjFromTlv(pTlv, msgToPhysiWindowNode, &pNode->window); + break; + case PHY_COUNT_CODE_WINDOW_COUNT: + code = tlvDecodeI64(pTlv, &pNode->windowCount); + break; + case PHY_COUNT_CODE_WINDOW_SLIDING: + code = tlvDecodeI64(pTlv, &pNode->windowSliding); + break; + default: + break; + } + } + + return code; +} + enum { PHY_PARTITION_CODE_BASE_NODE = 1, PHY_PARTITION_CODE_EXPR, @@ -4200,6 +4240,10 @@ static int32_t specificNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT: code = physiEventWindowNodeToMsg(pObj, pEncoder); break; + case QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT: + code = physiCountWindowNodeToMsg(pObj, pEncoder); + break; case QUERY_NODE_PHYSICAL_PLAN_PARTITION: code = physiPartitionNodeToMsg(pObj, pEncoder); break; @@ -4355,6 +4399,10 @@ static int32_t msgToSpecificNode(STlvDecoder* pDecoder, void* pObj) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT: code = msgToPhysiEventWindowNode(pDecoder, pObj); break; + case QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT: + code = msgToPhysiCountWindowNode(pDecoder, pObj); + break; case QUERY_NODE_PHYSICAL_PLAN_PARTITION: code = msgToPhysiPartitionNode(pDecoder, pObj); break; diff --git a/source/libs/nodes/src/nodesTraverseFuncs.c b/source/libs/nodes/src/nodesTraverseFuncs.c index 8b44e478c0..88bd475fb0 100644 --- a/source/libs/nodes/src/nodesTraverseFuncs.c +++ b/source/libs/nodes/src/nodesTraverseFuncs.c @@ -176,6 +176,11 @@ static EDealRes dispatchExpr(SNode* pNode, ETraversalOrder order, FNodeWalker wa } break; } + case QUERY_NODE_COUNT_WINDOW: { + SCountWindowNode* pEvent = (SCountWindowNode*)pNode; + res = walkExpr(pEvent->pCol, order, walker, pContext); + break; + } default: break; } @@ -367,6 +372,11 @@ static EDealRes rewriteExpr(SNode** pRawNode, ETraversalOrder order, FNodeRewrit } break; } + case QUERY_NODE_COUNT_WINDOW: { + SCountWindowNode* pEvent = (SCountWindowNode*)pNode; + res = rewriteExpr(&pEvent->pCol, order, rewriter, pContext); + break; + } default: break; } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index c9169c12fe..1bdcda3ddf 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -302,6 +302,8 @@ SNode* nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SCaseWhenNode)); case QUERY_NODE_EVENT_WINDOW: return makeNode(type, sizeof(SEventWindowNode)); + case QUERY_NODE_COUNT_WINDOW: + return makeNode(type, sizeof(SCountWindowNode)); case QUERY_NODE_HINT: return makeNode(type, sizeof(SHintNode)); case QUERY_NODE_VIEW: @@ -585,6 +587,10 @@ SNode* nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SEventWinodwPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT: return makeNode(type, sizeof(SStreamEventWinodwPhysiNode)); + case QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT: + return makeNode(type, sizeof(SCountWinodwPhysiNode)); + case QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT: + return makeNode(type, sizeof(SStreamCountWinodwPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_PARTITION: return makeNode(type, sizeof(SPartitionPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION: @@ -850,6 +856,11 @@ void nodesDestroyNode(SNode* pNode) { nodesDestroyNode(pEvent->pEndCond); break; } + case QUERY_NODE_COUNT_WINDOW: { + SCountWindowNode* pEvent = (SCountWindowNode*)pNode; + nodesDestroyNode(pEvent->pCol); + break; + } case QUERY_NODE_HINT: { SHintNode* pHint = (SHintNode*)pNode; destroyHintValue(pHint->option, pHint->value); @@ -1427,6 +1438,12 @@ void nodesDestroyNode(SNode* pNode) { nodesDestroyNode(pPhyNode->pEndCond); break; } + case QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT: + case QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT: { + SCountWinodwPhysiNode* pPhyNode = (SCountWinodwPhysiNode*)pNode; + destroyWinodwPhysiNode((SWindowPhysiNode*)pPhyNode); + break; + } case QUERY_NODE_PHYSICAL_PLAN_PARTITION: { destroyPartitionPhysiNode((SPartitionPhysiNode*)pNode); break; diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 8b45ed6f66..f13f9f1b96 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -131,6 +131,7 @@ SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, SNode* pGap); SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr); SNode* createEventWindowNode(SAstCreateContext* pCxt, SNode* pStartCond, SNode* pEndCond); +SNode* createCountWindowNode(SAstCreateContext* pCxt, const SToken* pCountToken, const SToken* pSlidingToken); SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode* pOffset, SNode* pSliding, SNode* pFill); SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index d2d120fa93..4c59f3abd7 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)); } @@ -1159,6 +1159,10 @@ twindow_clause_opt(A) ::= sliding_opt(D) fill_opt(E). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C), D, E); } twindow_clause_opt(A) ::= EVENT_WINDOW START WITH search_condition(B) END WITH search_condition(C). { A = createEventWindowNode(pCxt, B, C); } +twindow_clause_opt(A) ::= + COUNT_WINDOW NK_LP NK_INTEGER(B) NK_RP. { A = createCountWindowNode(pCxt, &B, &B); } +twindow_clause_opt(A) ::= + COUNT_WINDOW NK_LP NK_INTEGER(B) NK_COMMA NK_INTEGER(C) NK_RP. { A = createCountWindowNode(pCxt, &B, &C); } sliding_opt(A) ::= . { A = NULL; } sliding_opt(A) ::= SLIDING NK_LP interval_sliding_duration_literal(B) NK_RP. { A = releaseRawExprNode(pCxt, B); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 689153010a..f167fa04d7 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -883,6 +883,20 @@ SNode* createEventWindowNode(SAstCreateContext* pCxt, SNode* pStartCond, SNode* return (SNode*)pEvent; } +SNode* createCountWindowNode(SAstCreateContext* pCxt, const SToken* pCountToken, const SToken* pSlidingToken) { + CHECK_PARSER_STATUS(pCxt); + SCountWindowNode* pCount = (SCountWindowNode*)nodesMakeNode(QUERY_NODE_COUNT_WINDOW); + CHECK_OUT_OF_MEM(pCount); + pCount->pCol = createPrimaryKeyCol(pCxt, NULL); + if (NULL == pCount->pCol) { + nodesDestroyNode((SNode*)pCount); + CHECK_OUT_OF_MEM(NULL); + } + pCount->windowCount = taosStr2Int64(pCountToken->z, NULL, 10); + pCount->windowSliding = taosStr2Int64(pSlidingToken->z, NULL, 10); + return (SNode*)pCount; +} + SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode* pOffset, SNode* pSliding, SNode* pFill) { CHECK_PARSER_STATUS(pCxt); diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index a1f682f4cf..8900ef8e7f 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -663,7 +663,7 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate } char* p = (char*)data; - // | version | total length | total rows | total columns | flag seg| block group id | column schema | each column + // | version | total length | total rows | blankFill | total columns | flag seg| block group id | column schema | each column // length | int32_t version = *(int32_t*)data; p += sizeof(int32_t); diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 0777835def..bb60cbdd7e 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -72,6 +72,7 @@ static SKeyword keywordTable[] = { {"CONSUMERS", TK_CONSUMERS}, {"CONTAINS", TK_CONTAINS}, {"COUNT", TK_COUNT}, + {"COUNT_WINDOW", TK_COUNT_WINDOW}, {"CREATE", TK_CREATE}, {"CURRENT_USER", TK_CURRENT_USER}, {"DATABASE", TK_DATABASE}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 960796d345..abe50a27da 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -4002,6 +4002,15 @@ static int32_t translateEventWindow(STranslateContext* pCxt, SSelectStmt* pSelec return TSDB_CODE_SUCCESS; } +static int32_t translateCountWindow(STranslateContext* pCxt, SSelectStmt* pSelect) { + if (QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) && + !isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TIMELINE_QUERY, + "COUNT_WINDOW requires valid time series input"); + } + return TSDB_CODE_SUCCESS; +} + static int32_t translateSpecificWindow(STranslateContext* pCxt, SSelectStmt* pSelect) { switch (nodeType(pSelect->pWindow)) { case QUERY_NODE_STATE_WINDOW: @@ -4012,6 +4021,8 @@ static int32_t translateSpecificWindow(STranslateContext* pCxt, SSelectStmt* pSe return translateIntervalWindow(pCxt, pSelect); case QUERY_NODE_EVENT_WINDOW: return translateEventWindow(pCxt, pSelect); + case QUERY_NODE_COUNT_WINDOW: + return translateCountWindow(pCxt, pSelect); default: break; } @@ -7787,6 +7798,53 @@ static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStm return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "The trigger mode of non window query can only be AT_ONCE"); } + + if (pSelect->pWindow != NULL && pSelect->pWindow->type == QUERY_NODE_COUNT_WINDOW) { + if ( (SRealTableNode*)pSelect->pFromTable && ((SRealTableNode*)pSelect->pFromTable)->pMeta + && TSDB_SUPER_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType + && !hasPartitionByTbname(pSelect->pPartitionByList) ) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, + "Count window for stream on super table must patitioned by table name"); + } + + int64_t watermark = 0; + if (pStmt->pOptions->pWatermark) { + translateValue(pCxt, (SValueNode*)pStmt->pOptions->pWatermark); + watermark =((SValueNode*)pStmt->pOptions->pWatermark)->datum.i; + } + if (watermark <= 0) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, + "Watermark of Count window must exceed 0."); + } + + if (pStmt->pOptions->ignoreExpired != 1) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, + "Ignore expired data of Count window must be 1."); + } + + SCountWindowNode* pCountWin = (SCountWindowNode*)pSelect->pWindow; + if (pCountWin->windowCount <= 1) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, + "Size of Count window must exceed 1."); + } + + if (pCountWin->windowSliding <= 0) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, + "Size of Count window must exceed 0."); + } + + if (pCountWin->windowSliding > pCountWin->windowCount) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, + "sliding value no larger than the count value."); + } + + if (pCountWin->windowCount > INT32_MAX) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, + "Size of Count window must less than 2147483647(INT32_MAX)."); + } + + } + return TSDB_CODE_SUCCESS; } @@ -9399,7 +9457,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..9833c8151b 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,10 +24,7 @@ ** The following is the concatenation of all %include directives from the ** input grammar file: */ -#include -#include /************ Begin %include sections from the grammar ************************/ - #include #include #include @@ -42,11 +41,361 @@ #define YYSTACKDEPTH 0 /**************** 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_COUNT_WINDOW 281 +#define TK_SLIDING 282 +#define TK_FILL 283 +#define TK_VALUE 284 +#define TK_VALUE_F 285 +#define TK_NONE 286 +#define TK_PREV 287 +#define TK_NULL_F 288 +#define TK_LINEAR 289 +#define TK_NEXT 290 +#define TK_HAVING 291 +#define TK_RANGE 292 +#define TK_EVERY 293 +#define TK_ORDER 294 +#define TK_SLIMIT 295 +#define TK_SOFFSET 296 +#define TK_LIMIT 297 +#define TK_OFFSET 298 +#define TK_ASC 299 +#define TK_NULLS 300 +#define TK_ABORT 301 +#define TK_AFTER 302 +#define TK_ATTACH 303 +#define TK_BEFORE 304 +#define TK_BEGIN 305 +#define TK_BITAND 306 +#define TK_BITNOT 307 +#define TK_BITOR 308 +#define TK_BLOCKS 309 +#define TK_CHANGE 310 +#define TK_COMMA 311 +#define TK_CONCAT 312 +#define TK_CONFLICT 313 +#define TK_COPY 314 +#define TK_DEFERRED 315 +#define TK_DELIMITERS 316 +#define TK_DETACH 317 +#define TK_DIVIDE 318 +#define TK_DOT 319 +#define TK_EACH 320 +#define TK_FAIL 321 +#define TK_FILE 322 +#define TK_FOR 323 +#define TK_GLOB 324 +#define TK_ID 325 +#define TK_IMMEDIATE 326 +#define TK_IMPORT 327 +#define TK_INITIALLY 328 +#define TK_INSTEAD 329 +#define TK_ISNULL 330 +#define TK_KEY 331 +#define TK_MODULES 332 +#define TK_NK_BITNOT 333 +#define TK_NK_SEMI 334 +#define TK_NOTNULL 335 +#define TK_OF 336 +#define TK_PLUS 337 +#define TK_PRIVILEGE 338 +#define TK_RAISE 339 +#define TK_RESTRICT 340 +#define TK_ROW 341 +#define TK_SEMI 342 +#define TK_STAR 343 +#define TK_STATEMENT 344 +#define TK_STRICT 345 +#define TK_STRING 346 +#define TK_TIMES 347 +#define TK_VALUES 348 +#define TK_VARIABLE 349 +#define TK_WAL 350 +#endif +/**************** End token definitions ***************************************/ /* The next sections is a series of control #defines. ** various aspects of the generated parser. @@ -104,29 +453,29 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 511 +#define YYNOCODE 512 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EOperatorType yy30; - EJoinType yy246; - int64_t yy277; - ENullOrder yy361; - STokenPair yy483; - SNode* yy490; - SNodeList* yy502; - SAlterOption yy529; - SToken yy561; - EShowKind yy579; - EFillMode yy718; - int32_t yy774; - SDataType yy826; - bool yy845; - EOrder yy876; - SShowTablesOption yy961; - int8_t yy1013; + STokenPair yy57; + int64_t yy221; + EOperatorType yy252; + EShowKind yy321; + bool yy345; + EFillMode yy358; + SNode* yy360; + SNodeList* yy536; + int32_t yy580; + ENullOrder yy585; + EJoinType yy596; + EOrder yy642; + int8_t yy695; + SAlterOption yy797; + SDataType yy912; + SToken yy929; + SShowTablesOption yy1005; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -142,18 +491,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 846 -#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 YYNSTATE 852 +#define YYNRULE 649 +#define YYNRULE_WITH_ACTION 649 +#define YYNTOKEN 351 +#define YY_MAX_SHIFT 851 +#define YY_MIN_SHIFTREDUCE 1256 +#define YY_MAX_SHIFTREDUCE 1904 +#define YY_ERROR_ACTION 1905 +#define YY_ACCEPT_ACTION 1906 +#define YY_NO_ACTION 1907 +#define YY_MIN_REDUCE 1908 +#define YY_MAX_REDUCE 2556 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -220,879 +569,853 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (3083) +#define YY_ACTTAB_COUNT (2941) 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, - /* 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, + /* 0 */ 95, 2332, 567, 2151, 468, 568, 1951, 14, 13, 467, + /* 10 */ 2185, 2315, 48, 46, 1826, 2340, 2532, 387, 723, 2527, + /* 20 */ 419, 699, 1667, 41, 40, 2336, 2093, 47, 45, 44, + /* 30 */ 43, 42, 174, 647, 1920, 1752, 1994, 1665, 2531, 737, + /* 40 */ 2098, 704, 2528, 2530, 2527, 2356, 38, 321, 645, 584, + /* 50 */ 643, 270, 269, 1696, 675, 716, 146, 2527, 719, 137, + /* 60 */ 112, 675, 703, 203, 2527, 1747, 610, 2528, 705, 2338, + /* 70 */ 416, 19, 739, 2236, 2418, 2533, 203, 147, 1673, 747, + /* 80 */ 2528, 705, 2533, 203, 2236, 2090, 2374, 2528, 705, 41, + /* 90 */ 40, 2234, 724, 47, 45, 44, 43, 42, 2322, 412, + /* 100 */ 753, 587, 2233, 724, 848, 585, 2229, 15, 475, 823, + /* 110 */ 822, 821, 820, 431, 1795, 819, 818, 151, 813, 812, + /* 120 */ 811, 810, 809, 808, 807, 150, 801, 800, 799, 430, + /* 130 */ 429, 796, 795, 794, 183, 182, 793, 2074, 1322, 2355, + /* 140 */ 1321, 63, 2393, 1754, 1755, 114, 2357, 757, 2359, 2360, + /* 150 */ 752, 1692, 747, 534, 532, 142, 367, 186, 575, 2446, + /* 160 */ 217, 568, 1951, 415, 2442, 301, 2454, 715, 572, 138, + /* 170 */ 714, 511, 2527, 1323, 569, 510, 184, 2151, 205, 2532, + /* 180 */ 1727, 1737, 2527, 509, 383, 736, 2476, 1753, 1756, 1870, + /* 190 */ 703, 203, 2149, 716, 146, 2528, 705, 1908, 385, 52, + /* 200 */ 2216, 2531, 1668, 63, 1666, 2528, 2529, 792, 196, 1901, + /* 210 */ 1692, 41, 40, 2145, 2146, 47, 45, 44, 43, 42, + /* 220 */ 2138, 136, 135, 134, 133, 132, 131, 130, 129, 128, + /* 230 */ 736, 484, 2212, 528, 1671, 1672, 1724, 1724, 1726, 1729, + /* 240 */ 1730, 1731, 1732, 1733, 1734, 1735, 1736, 749, 745, 1745, + /* 250 */ 1746, 1748, 1749, 1750, 1751, 2, 48, 46, 1325, 1326, + /* 260 */ 1693, 365, 704, 1690, 419, 2527, 1667, 428, 427, 1697, + /* 270 */ 518, 238, 2356, 537, 377, 570, 658, 1959, 536, 1752, + /* 280 */ 219, 1665, 223, 703, 203, 751, 273, 240, 2528, 705, + /* 290 */ 272, 570, 1674, 1959, 498, 228, 538, 466, 1696, 465, + /* 300 */ 698, 366, 500, 202, 2454, 2455, 305, 144, 2459, 1747, + /* 310 */ 1931, 659, 478, 2374, 1900, 19, 1460, 51, 1781, 527, + /* 320 */ 227, 452, 1673, 90, 274, 2322, 89, 753, 2374, 464, + /* 330 */ 1451, 782, 781, 780, 1455, 779, 1457, 1458, 778, 775, + /* 340 */ 583, 1466, 772, 1468, 1469, 769, 766, 763, 848, 386, + /* 350 */ 1693, 15, 790, 161, 160, 787, 786, 785, 158, 98, + /* 360 */ 486, 1997, 372, 2322, 305, 398, 2355, 649, 305, 2393, + /* 370 */ 1566, 1567, 357, 2357, 757, 2359, 2360, 752, 750, 747, + /* 380 */ 738, 2411, 1782, 1586, 1587, 577, 2275, 1754, 1755, 697, + /* 390 */ 2223, 2202, 88, 525, 524, 523, 522, 517, 516, 515, + /* 400 */ 514, 369, 1635, 1636, 1930, 504, 503, 502, 501, 495, + /* 410 */ 494, 493, 2532, 488, 487, 384, 184, 737, 2098, 479, + /* 420 */ 1554, 1555, 716, 146, 1727, 1737, 1573, 1585, 1588, 1695, + /* 430 */ 2461, 1753, 1756, 1695, 629, 628, 627, 137, 716, 146, + /* 440 */ 2217, 619, 143, 623, 615, 1305, 1668, 622, 1666, 456, + /* 450 */ 1696, 1691, 621, 626, 393, 392, 2458, 2322, 620, 1677, + /* 460 */ 194, 616, 37, 417, 1776, 1777, 1778, 1779, 1780, 1784, + /* 470 */ 1785, 1786, 1787, 1495, 1496, 792, 458, 454, 1671, 1672, + /* 480 */ 1724, 744, 1726, 1729, 1730, 1731, 1732, 1733, 1734, 1735, + /* 490 */ 1736, 749, 745, 1745, 1746, 1748, 1749, 1750, 1751, 2, + /* 500 */ 12, 48, 46, 2356, 1322, 2332, 1321, 736, 2531, 419, + /* 510 */ 2075, 1667, 422, 1823, 1697, 256, 754, 1894, 424, 2089, + /* 520 */ 168, 2144, 2146, 2151, 1752, 1929, 1665, 400, 2100, 2336, + /* 530 */ 399, 179, 204, 2454, 2455, 2149, 144, 2459, 2149, 1323, + /* 540 */ 604, 600, 596, 592, 2374, 255, 106, 718, 201, 2454, + /* 550 */ 2455, 1303, 144, 2459, 1747, 12, 2322, 2151, 753, 656, + /* 560 */ 19, 629, 628, 627, 409, 3, 694, 1673, 619, 143, + /* 570 */ 623, 2091, 2149, 2338, 622, 1301, 1302, 54, 2322, 621, + /* 580 */ 626, 393, 392, 747, 1859, 620, 96, 1692, 616, 253, + /* 590 */ 12, 303, 10, 848, 51, 303, 15, 2355, 737, 2098, + /* 600 */ 2393, 2356, 95, 114, 2357, 757, 2359, 2360, 752, 741, + /* 610 */ 747, 2418, 198, 149, 754, 156, 2417, 2446, 492, 41, + /* 620 */ 40, 415, 2442, 47, 45, 44, 43, 42, 2094, 2332, + /* 630 */ 1415, 1696, 1754, 1755, 691, 690, 1857, 1858, 1860, 1861, + /* 640 */ 1862, 1928, 2374, 2341, 1773, 1414, 790, 161, 160, 787, + /* 650 */ 786, 785, 158, 2336, 2322, 243, 753, 1909, 700, 695, + /* 660 */ 688, 684, 490, 2212, 252, 245, 1697, 520, 2212, 1727, + /* 670 */ 1737, 250, 581, 1927, 63, 659, 1753, 1756, 127, 68, + /* 680 */ 2303, 126, 125, 124, 123, 122, 121, 120, 119, 118, + /* 690 */ 242, 1668, 173, 1666, 2322, 2355, 806, 2338, 2393, 2059, + /* 700 */ 2037, 114, 2357, 757, 2359, 2360, 752, 747, 747, 564, + /* 710 */ 1926, 221, 539, 2421, 2316, 2446, 226, 1673, 562, 415, + /* 720 */ 2442, 558, 554, 1671, 1672, 1724, 2322, 1726, 1729, 1730, + /* 730 */ 1731, 1732, 1733, 1734, 1735, 1736, 749, 745, 1745, 1746, + /* 740 */ 1748, 1749, 1750, 1751, 2, 48, 46, 1757, 2356, 661, + /* 750 */ 2275, 737, 2098, 419, 2284, 1667, 654, 312, 313, 305, + /* 760 */ 159, 719, 311, 2322, 675, 1936, 843, 2527, 1752, 127, + /* 770 */ 1665, 208, 126, 125, 124, 123, 122, 121, 120, 119, + /* 780 */ 118, 2356, 63, 1822, 413, 2533, 203, 737, 2098, 2374, + /* 790 */ 2528, 705, 171, 199, 754, 2151, 1961, 326, 1747, 707, + /* 800 */ 2100, 2322, 414, 753, 737, 2098, 675, 56, 275, 2527, + /* 810 */ 2149, 1673, 41, 40, 2151, 422, 47, 45, 44, 43, + /* 820 */ 42, 423, 2374, 171, 472, 606, 605, 2533, 203, 2149, + /* 830 */ 425, 2100, 2528, 705, 2322, 55, 753, 848, 171, 305, + /* 840 */ 49, 9, 2355, 737, 2098, 2393, 2100, 1697, 114, 2357, + /* 850 */ 757, 2359, 2360, 752, 1925, 747, 2356, 1924, 783, 1667, + /* 860 */ 186, 1296, 2446, 473, 171, 1923, 415, 2442, 2461, 754, + /* 870 */ 737, 2098, 2101, 1922, 1665, 2355, 1754, 1755, 2393, 2073, + /* 880 */ 1303, 114, 2357, 757, 2359, 2360, 752, 1919, 747, 2477, + /* 890 */ 505, 636, 1830, 2547, 2457, 2446, 1762, 2374, 1692, 415, + /* 900 */ 2442, 197, 1692, 1298, 1301, 1302, 648, 2322, 210, 2322, + /* 910 */ 2322, 753, 1842, 1727, 1737, 1673, 737, 2098, 2322, 2306, + /* 920 */ 1753, 1756, 271, 41, 40, 1692, 2322, 47, 45, 44, + /* 930 */ 43, 42, 44, 43, 42, 1668, 506, 1666, 639, 1851, + /* 940 */ 2322, 848, 674, 625, 624, 633, 631, 305, 30, 2151, + /* 950 */ 2355, 1403, 268, 2393, 1852, 660, 176, 2357, 757, 2359, + /* 960 */ 2360, 752, 2087, 747, 732, 608, 607, 1671, 1672, 1724, + /* 970 */ 441, 1726, 1729, 1730, 1731, 1732, 1733, 1734, 1735, 1736, + /* 980 */ 749, 745, 1745, 1746, 1748, 1749, 1750, 1751, 2, 48, + /* 990 */ 46, 2083, 1405, 72, 1918, 1850, 71, 419, 1917, 1667, + /* 1000 */ 47, 45, 44, 43, 42, 675, 1916, 1915, 2527, 2085, + /* 1010 */ 706, 2548, 1752, 2151, 1665, 790, 161, 160, 787, 786, + /* 1020 */ 785, 158, 1914, 1871, 1913, 2356, 2533, 203, 2150, 41, + /* 1030 */ 40, 2528, 705, 47, 45, 44, 43, 42, 754, 1668, + /* 1040 */ 2484, 1666, 1747, 1783, 737, 2098, 1692, 2322, 2356, 737, + /* 1050 */ 2098, 2322, 1419, 737, 2098, 1673, 737, 2098, 1728, 2322, + /* 1060 */ 2322, 754, 1728, 2497, 507, 148, 2374, 1418, 2417, 586, + /* 1070 */ 1815, 1671, 1672, 2095, 61, 2322, 276, 2322, 2322, 76, + /* 1080 */ 753, 848, 672, 2356, 49, 1728, 614, 41, 40, 2374, + /* 1090 */ 613, 47, 45, 44, 43, 42, 754, 708, 686, 34, + /* 1100 */ 2169, 2322, 2081, 753, 784, 41, 40, 2142, 1912, 47, + /* 1110 */ 45, 44, 43, 42, 1725, 737, 2098, 803, 1725, 2355, + /* 1120 */ 1754, 1755, 2393, 35, 2374, 114, 2357, 757, 2359, 2360, + /* 1130 */ 752, 87, 747, 1788, 541, 284, 2322, 2547, 753, 2446, + /* 1140 */ 711, 1725, 2355, 415, 2442, 2393, 1981, 99, 114, 2357, + /* 1150 */ 757, 2359, 2360, 752, 2195, 747, 1911, 1727, 1737, 1676, + /* 1160 */ 2547, 2322, 2446, 1675, 1753, 1756, 415, 2442, 630, 737, + /* 1170 */ 2098, 737, 2098, 788, 737, 2098, 2142, 2355, 1614, 1668, + /* 1180 */ 2393, 1666, 805, 114, 2357, 757, 2359, 2360, 752, 322, + /* 1190 */ 747, 722, 720, 36, 316, 2547, 482, 2446, 139, 41, + /* 1200 */ 40, 415, 2442, 47, 45, 44, 43, 42, 2102, 2322, + /* 1210 */ 86, 1671, 1672, 1724, 281, 1726, 1729, 1730, 1731, 1732, + /* 1220 */ 1733, 1734, 1735, 1736, 749, 745, 1745, 1746, 1748, 1749, + /* 1230 */ 1750, 1751, 2, 48, 46, 391, 390, 737, 2098, 2461, + /* 1240 */ 2076, 419, 675, 1667, 159, 2527, 737, 2098, 817, 815, + /* 1250 */ 737, 2098, 789, 2466, 1815, 2142, 1752, 734, 1665, 513, + /* 1260 */ 512, 170, 1725, 2533, 203, 2456, 735, 159, 2528, 705, + /* 1270 */ 426, 335, 261, 152, 2128, 259, 2356, 263, 265, 617, + /* 1280 */ 262, 264, 267, 1979, 1970, 266, 1747, 618, 682, 754, + /* 1290 */ 1968, 2520, 651, 285, 650, 2343, 50, 50, 1921, 1673, + /* 1300 */ 1903, 1904, 748, 1400, 1358, 632, 634, 389, 388, 187, + /* 1310 */ 612, 1398, 637, 14, 13, 2038, 2490, 2374, 172, 1630, + /* 1320 */ 298, 159, 50, 341, 310, 848, 1679, 797, 15, 2322, + /* 1330 */ 1678, 753, 614, 692, 2356, 75, 613, 100, 292, 157, + /* 1340 */ 339, 74, 1633, 159, 73, 1359, 66, 754, 141, 2465, + /* 1350 */ 111, 1377, 50, 2345, 368, 50, 2375, 761, 157, 108, + /* 1360 */ 709, 798, 2035, 1846, 1754, 1755, 236, 549, 547, 544, + /* 1370 */ 2355, 1856, 1855, 2393, 159, 2374, 114, 2357, 757, 2359, + /* 1380 */ 2360, 752, 2034, 747, 290, 1375, 2221, 2322, 2547, 753, + /* 1390 */ 2446, 1962, 1952, 2480, 415, 2442, 721, 1583, 689, 314, + /* 1400 */ 405, 1727, 1737, 140, 157, 712, 696, 63, 1753, 1756, + /* 1410 */ 729, 401, 432, 2222, 318, 1958, 2139, 2481, 1445, 726, + /* 1420 */ 2491, 1789, 668, 1668, 717, 1666, 300, 1738, 2355, 297, + /* 1430 */ 334, 2393, 1473, 1477, 114, 2357, 757, 2359, 2360, 752, + /* 1440 */ 2060, 747, 304, 841, 5, 64, 2547, 435, 2446, 1484, + /* 1450 */ 440, 381, 415, 2442, 448, 1671, 1672, 1724, 449, 1726, + /* 1460 */ 1729, 1730, 1731, 1732, 1733, 1734, 1735, 1736, 749, 745, + /* 1470 */ 1745, 1746, 1748, 1749, 1750, 1751, 2, 1700, 1482, 162, + /* 1480 */ 460, 428, 427, 211, 2356, 459, 212, 462, 214, 329, + /* 1490 */ 1690, 1681, 1607, 476, 84, 83, 471, 754, 1691, 216, + /* 1500 */ 483, 225, 485, 489, 1752, 491, 1674, 2356, 530, 496, + /* 1510 */ 508, 2214, 463, 461, 519, 521, 526, 543, 529, 531, + /* 1520 */ 754, 542, 540, 364, 231, 2374, 450, 230, 545, 447, + /* 1530 */ 443, 439, 436, 464, 1747, 1698, 1906, 2322, 546, 753, + /* 1540 */ 233, 548, 2356, 550, 4, 565, 566, 1673, 2374, 573, + /* 1550 */ 574, 576, 1693, 241, 92, 754, 244, 578, 1699, 1701, + /* 1560 */ 2322, 579, 753, 580, 247, 582, 1702, 249, 588, 93, + /* 1570 */ 94, 609, 305, 743, 2230, 254, 640, 611, 2355, 2088, + /* 1580 */ 116, 2393, 641, 2374, 114, 2357, 757, 2359, 2360, 752, + /* 1590 */ 361, 747, 97, 258, 2084, 2322, 2419, 753, 2446, 260, + /* 1600 */ 164, 2355, 415, 2442, 2393, 165, 653, 114, 2357, 757, + /* 1610 */ 2359, 2360, 752, 2086, 747, 434, 2293, 2082, 166, 740, + /* 1620 */ 433, 2446, 167, 2290, 2289, 415, 2442, 277, 1694, 663, + /* 1630 */ 662, 282, 693, 667, 669, 670, 2355, 679, 727, 2393, + /* 1640 */ 664, 2356, 115, 2357, 757, 2359, 2360, 752, 8, 747, + /* 1650 */ 330, 153, 655, 280, 754, 2496, 2446, 287, 289, 702, + /* 1660 */ 2445, 2442, 2495, 677, 2468, 675, 291, 2276, 2527, 680, + /* 1670 */ 293, 1682, 2356, 1677, 678, 296, 713, 406, 710, 1815, + /* 1680 */ 1695, 2526, 2374, 145, 1820, 754, 2533, 203, 2462, 190, + /* 1690 */ 1818, 2528, 705, 306, 2322, 331, 753, 332, 730, 2356, + /* 1700 */ 154, 725, 294, 1685, 1687, 2244, 2243, 731, 2242, 155, + /* 1710 */ 411, 178, 754, 2374, 333, 105, 62, 745, 1745, 1746, + /* 1720 */ 1748, 1749, 1750, 1751, 295, 2322, 2099, 753, 1, 206, + /* 1730 */ 2427, 107, 759, 299, 336, 2355, 324, 2143, 2393, 1280, + /* 1740 */ 2374, 115, 2357, 757, 2359, 2360, 752, 842, 747, 2550, + /* 1750 */ 845, 847, 2322, 163, 753, 2446, 345, 2356, 360, 742, + /* 1760 */ 2442, 373, 53, 374, 359, 340, 755, 349, 2314, 2393, + /* 1770 */ 754, 338, 115, 2357, 757, 2359, 2360, 752, 2313, 747, + /* 1780 */ 2312, 81, 2307, 437, 438, 1658, 2446, 1659, 209, 442, + /* 1790 */ 376, 2442, 2356, 2355, 2305, 444, 2393, 445, 2374, 175, + /* 1800 */ 2357, 757, 2359, 2360, 752, 754, 747, 446, 1657, 2304, + /* 1810 */ 2322, 382, 753, 2302, 451, 2301, 453, 2300, 455, 2299, + /* 1820 */ 457, 1646, 2356, 213, 2279, 215, 1610, 82, 1609, 2257, + /* 1830 */ 2256, 2255, 469, 2374, 2280, 754, 470, 2254, 2253, 2204, + /* 1840 */ 474, 676, 2487, 2201, 1553, 2322, 2200, 753, 477, 2194, + /* 1850 */ 481, 2355, 2191, 480, 2393, 218, 2190, 115, 2357, 757, + /* 1860 */ 2359, 2360, 752, 2374, 747, 85, 2189, 2188, 403, 2193, + /* 1870 */ 220, 2446, 2192, 2187, 2186, 2322, 2443, 753, 2184, 2183, + /* 1880 */ 2182, 222, 497, 2181, 499, 2179, 2355, 2356, 2178, 2393, + /* 1890 */ 2177, 2176, 175, 2357, 757, 2359, 2360, 752, 91, 747, + /* 1900 */ 754, 2199, 2356, 2175, 2174, 2173, 2197, 2180, 2172, 2171, + /* 1910 */ 2170, 2168, 2167, 2166, 2165, 754, 2355, 2356, 1559, 2393, + /* 1920 */ 2164, 2163, 358, 2357, 757, 2359, 2360, 752, 2374, 747, + /* 1930 */ 754, 224, 2162, 404, 229, 2488, 2161, 2160, 2159, 2198, + /* 1940 */ 2322, 2196, 753, 2374, 2158, 2157, 2156, 2155, 533, 2154, + /* 1950 */ 535, 2153, 2152, 1416, 2000, 2322, 1412, 753, 2374, 232, + /* 1960 */ 1999, 1998, 1420, 1996, 234, 370, 371, 235, 1993, 553, + /* 1970 */ 2322, 1992, 753, 552, 556, 557, 1985, 560, 1972, 551, + /* 1980 */ 555, 2355, 1947, 185, 2393, 559, 1304, 358, 2357, 757, + /* 1990 */ 2359, 2360, 752, 563, 747, 561, 2355, 2356, 1946, 2393, + /* 2000 */ 237, 78, 351, 2357, 757, 2359, 2360, 752, 239, 747, + /* 2010 */ 754, 2355, 79, 2342, 2393, 2356, 195, 176, 2357, 757, + /* 2020 */ 2359, 2360, 752, 571, 747, 2278, 2274, 2264, 751, 246, + /* 2030 */ 2251, 2228, 248, 251, 2077, 1995, 1991, 589, 2374, 2252, + /* 2040 */ 2356, 1351, 1989, 410, 590, 591, 593, 594, 701, 595, + /* 2050 */ 2322, 1987, 753, 754, 597, 598, 2374, 599, 1984, 601, + /* 2060 */ 603, 602, 1967, 1965, 1966, 1964, 1943, 2079, 2322, 1489, + /* 2070 */ 753, 2078, 2549, 65, 1488, 257, 1388, 1402, 1401, 1982, + /* 2080 */ 1399, 2374, 1397, 1396, 1395, 1394, 418, 1393, 814, 816, + /* 2090 */ 1390, 2355, 394, 2322, 2393, 753, 1389, 358, 2357, 757, + /* 2100 */ 2359, 2360, 752, 1980, 747, 1387, 395, 1971, 396, 2355, + /* 2110 */ 2356, 1969, 2393, 635, 657, 357, 2357, 757, 2359, 2360, + /* 2120 */ 752, 397, 747, 754, 2412, 638, 1942, 1941, 1940, 642, + /* 2130 */ 1939, 644, 851, 1938, 2355, 117, 646, 2393, 1640, 1642, + /* 2140 */ 358, 2357, 757, 2359, 2360, 752, 2356, 747, 328, 1639, + /* 2150 */ 2277, 2374, 1644, 279, 2273, 57, 420, 58, 1616, 754, + /* 2160 */ 1618, 2263, 665, 2322, 193, 753, 1620, 666, 29, 2250, + /* 2170 */ 2249, 169, 1595, 839, 835, 831, 827, 2356, 325, 69, + /* 2180 */ 283, 671, 2532, 1594, 20, 31, 673, 2374, 1873, 286, + /* 2190 */ 754, 1847, 681, 402, 17, 6, 683, 7, 685, 2322, + /* 2200 */ 687, 753, 200, 288, 2355, 21, 22, 2393, 1854, 189, + /* 2210 */ 358, 2357, 757, 2359, 2360, 752, 177, 747, 2374, 113, + /* 2220 */ 2343, 33, 319, 188, 32, 67, 1841, 80, 24, 1888, + /* 2230 */ 2322, 1893, 753, 1894, 1887, 407, 1892, 1891, 408, 1812, + /* 2240 */ 652, 60, 1811, 2393, 2248, 302, 353, 2357, 757, 2359, + /* 2250 */ 2360, 752, 2356, 747, 733, 180, 23, 18, 59, 2227, + /* 2260 */ 102, 728, 2226, 103, 101, 754, 25, 26, 108, 317, + /* 2270 */ 309, 2355, 2356, 1849, 2393, 191, 320, 343, 2357, 757, + /* 2280 */ 2359, 2360, 752, 1764, 747, 754, 1763, 315, 2356, 70, + /* 2290 */ 104, 1683, 13, 2374, 11, 1742, 2396, 308, 746, 181, + /* 2300 */ 39, 754, 1740, 1774, 307, 2322, 192, 753, 1717, 323, + /* 2310 */ 1739, 16, 27, 2374, 756, 1709, 28, 760, 1474, 421, + /* 2320 */ 758, 762, 764, 278, 1471, 2322, 765, 753, 1470, 2374, + /* 2330 */ 767, 768, 770, 1467, 1461, 771, 773, 774, 776, 1459, + /* 2340 */ 777, 2322, 1483, 753, 109, 2356, 2355, 110, 77, 2393, + /* 2350 */ 1479, 1465, 342, 2357, 757, 2359, 2360, 752, 754, 747, + /* 2360 */ 1464, 1384, 791, 1463, 1462, 2356, 2355, 1381, 1349, 2393, + /* 2370 */ 1380, 1379, 344, 2357, 757, 2359, 2360, 752, 754, 747, + /* 2380 */ 1378, 1376, 2355, 2356, 1374, 2393, 2374, 1373, 350, 2357, + /* 2390 */ 757, 2359, 2360, 752, 1372, 747, 754, 1410, 2322, 802, + /* 2400 */ 753, 1409, 207, 2356, 804, 1370, 2374, 1369, 1368, 1367, + /* 2410 */ 1366, 1365, 1364, 1406, 1404, 1361, 754, 1360, 2322, 1357, + /* 2420 */ 753, 1355, 1356, 1354, 2374, 1990, 824, 825, 1988, 828, + /* 2430 */ 826, 1986, 829, 830, 832, 834, 2322, 1983, 753, 2355, + /* 2440 */ 836, 2356, 2393, 838, 2374, 354, 2357, 757, 2359, 2360, + /* 2450 */ 752, 833, 747, 837, 754, 1963, 2322, 840, 753, 2355, + /* 2460 */ 1293, 1937, 2393, 1281, 846, 346, 2357, 757, 2359, 2360, + /* 2470 */ 752, 844, 747, 327, 1669, 337, 850, 2355, 2356, 849, + /* 2480 */ 2393, 1907, 2374, 355, 2357, 757, 2359, 2360, 752, 1907, + /* 2490 */ 747, 754, 1907, 1907, 2322, 1907, 753, 2355, 2356, 1907, + /* 2500 */ 2393, 1907, 1907, 347, 2357, 757, 2359, 2360, 752, 1907, + /* 2510 */ 747, 754, 1907, 1907, 2356, 1907, 1907, 1907, 1907, 2374, + /* 2520 */ 1907, 1907, 1907, 1907, 1907, 1907, 1907, 754, 1907, 1907, + /* 2530 */ 1907, 2322, 1907, 753, 1907, 2355, 1907, 1907, 2393, 2374, + /* 2540 */ 1907, 356, 2357, 757, 2359, 2360, 752, 1907, 747, 1907, + /* 2550 */ 1907, 2322, 1907, 753, 1907, 2374, 1907, 1907, 1907, 1907, + /* 2560 */ 1907, 1907, 1907, 1907, 1907, 1907, 1907, 2322, 1907, 753, + /* 2570 */ 1907, 1907, 2355, 1907, 1907, 2393, 1907, 1907, 348, 2357, + /* 2580 */ 757, 2359, 2360, 752, 1907, 747, 1907, 1907, 1907, 1907, + /* 2590 */ 1907, 1907, 2355, 1907, 1907, 2393, 1907, 1907, 362, 2357, + /* 2600 */ 757, 2359, 2360, 752, 1907, 747, 1907, 2356, 2355, 1907, + /* 2610 */ 1907, 2393, 1907, 1907, 363, 2357, 757, 2359, 2360, 752, + /* 2620 */ 754, 747, 1907, 1907, 1907, 1907, 2356, 1907, 1907, 1907, + /* 2630 */ 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, 754, + /* 2640 */ 1907, 1907, 1907, 2356, 1907, 1907, 1907, 1907, 2374, 1907, + /* 2650 */ 1907, 1907, 1907, 1907, 1907, 1907, 754, 1907, 1907, 1907, + /* 2660 */ 2322, 1907, 753, 1907, 1907, 1907, 1907, 2374, 1907, 1907, + /* 2670 */ 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, 2322, + /* 2680 */ 1907, 753, 1907, 1907, 2374, 1907, 1907, 1907, 1907, 1907, + /* 2690 */ 1907, 1907, 1907, 1907, 1907, 1907, 2322, 1907, 753, 1907, + /* 2700 */ 2356, 2355, 1907, 1907, 2393, 1907, 1907, 2368, 2357, 757, + /* 2710 */ 2359, 2360, 752, 754, 747, 1907, 1907, 1907, 1907, 1907, + /* 2720 */ 2355, 2356, 1907, 2393, 1907, 1907, 2367, 2357, 757, 2359, + /* 2730 */ 2360, 752, 1907, 747, 754, 1907, 1907, 2355, 2356, 1907, + /* 2740 */ 2393, 2374, 1907, 2366, 2357, 757, 2359, 2360, 752, 1907, + /* 2750 */ 747, 754, 1907, 2322, 1907, 753, 1907, 1907, 2356, 1907, + /* 2760 */ 1907, 1907, 2374, 1907, 1907, 1907, 1907, 1907, 1907, 1907, + /* 2770 */ 1907, 754, 1907, 1907, 2322, 1907, 753, 1907, 1907, 2374, + /* 2780 */ 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, + /* 2790 */ 1907, 2322, 1907, 753, 2355, 1907, 2356, 2393, 1907, 2374, + /* 2800 */ 378, 2357, 757, 2359, 2360, 752, 1907, 747, 1907, 754, + /* 2810 */ 1907, 2322, 1907, 753, 1907, 2355, 1907, 1907, 2393, 1907, + /* 2820 */ 1907, 379, 2357, 757, 2359, 2360, 752, 1907, 747, 1907, + /* 2830 */ 1907, 1907, 2355, 2356, 1907, 2393, 1907, 2374, 375, 2357, + /* 2840 */ 757, 2359, 2360, 752, 1907, 747, 754, 1907, 1907, 2322, + /* 2850 */ 1907, 753, 2355, 1907, 1907, 2393, 1907, 1907, 380, 2357, + /* 2860 */ 757, 2359, 2360, 752, 1907, 747, 1907, 1907, 1907, 1907, + /* 2870 */ 1907, 1907, 1907, 1907, 2374, 1907, 1907, 1907, 1907, 1907, + /* 2880 */ 1907, 1907, 1907, 1907, 1907, 1907, 2322, 1907, 753, 1907, + /* 2890 */ 755, 1907, 1907, 2393, 1907, 1907, 353, 2357, 757, 2359, + /* 2900 */ 2360, 752, 1907, 747, 1907, 1907, 1907, 1907, 1907, 1907, + /* 2910 */ 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, 1907, + /* 2920 */ 1907, 1907, 1907, 1907, 1907, 1907, 1907, 2355, 1907, 1907, + /* 2930 */ 2393, 1907, 1907, 352, 2357, 757, 2359, 2360, 752, 1907, + /* 2940 */ 747, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 353, 382, 360, 395, 429, 363, 364, 1, 2, 434, - /* 10 */ 0, 429, 12, 13, 14, 396, 479, 2, 386, 482, - /* 20 */ 20, 20, 22, 8, 9, 406, 394, 12, 13, 14, - /* 30 */ 15, 16, 395, 21, 402, 35, 0, 37, 501, 365, - /* 40 */ 366, 479, 505, 506, 482, 353, 468, 469, 36, 365, - /* 50 */ 38, 39, 40, 406, 479, 365, 366, 482, 366, 385, - /* 60 */ 372, 479, 500, 501, 482, 65, 392, 505, 506, 450, - /* 70 */ 451, 71, 352, 408, 354, 500, 501, 389, 78, 460, - /* 80 */ 505, 506, 500, 501, 408, 397, 394, 505, 506, 8, - /* 90 */ 9, 426, 427, 12, 13, 14, 15, 16, 406, 423, - /* 100 */ 408, 70, 426, 427, 104, 421, 422, 107, 365, 73, + /* 0 */ 375, 383, 361, 395, 430, 364, 365, 1, 2, 435, + /* 10 */ 0, 430, 12, 13, 14, 397, 480, 392, 410, 483, + /* 20 */ 20, 20, 22, 8, 9, 407, 401, 12, 13, 14, + /* 30 */ 15, 16, 353, 21, 355, 35, 0, 37, 502, 366, + /* 40 */ 367, 480, 506, 507, 483, 354, 469, 470, 36, 366, + /* 50 */ 38, 39, 40, 20, 480, 366, 367, 483, 367, 386, + /* 60 */ 373, 480, 501, 502, 483, 65, 393, 506, 507, 451, + /* 70 */ 452, 71, 465, 409, 467, 501, 502, 390, 78, 461, + /* 80 */ 506, 507, 501, 502, 409, 398, 395, 506, 507, 8, + /* 90 */ 9, 427, 428, 12, 13, 14, 15, 16, 407, 424, + /* 100 */ 409, 70, 427, 428, 104, 422, 423, 107, 366, 73, /* 110 */ 74, 75, 76, 77, 108, 79, 80, 81, 82, 83, /* 120 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, - /* 130 */ 94, 95, 96, 97, 98, 99, 100, 0, 20, 447, - /* 140 */ 22, 107, 450, 143, 144, 453, 454, 455, 456, 457, - /* 150 */ 458, 20, 460, 410, 411, 37, 413, 465, 360, 467, - /* 160 */ 417, 363, 364, 471, 472, 475, 476, 477, 14, 479, - /* 170 */ 480, 161, 482, 55, 20, 165, 394, 394, 486, 479, - /* 180 */ 180, 181, 482, 173, 401, 20, 494, 187, 188, 108, - /* 190 */ 500, 501, 409, 365, 366, 505, 506, 0, 416, 186, - /* 200 */ 418, 501, 202, 107, 204, 505, 506, 70, 393, 365, - /* 210 */ 366, 8, 9, 365, 366, 12, 13, 14, 15, 16, - /* 220 */ 405, 24, 25, 26, 27, 28, 29, 30, 31, 32, - /* 230 */ 20, 365, 366, 385, 234, 235, 236, 107, 238, 239, + /* 130 */ 94, 95, 96, 97, 98, 99, 100, 0, 20, 448, + /* 140 */ 22, 107, 451, 143, 144, 454, 455, 456, 457, 458, + /* 150 */ 459, 20, 461, 411, 412, 37, 414, 466, 361, 468, + /* 160 */ 418, 364, 365, 472, 473, 476, 477, 478, 14, 480, + /* 170 */ 481, 161, 483, 55, 20, 165, 395, 395, 487, 480, + /* 180 */ 180, 181, 483, 173, 402, 20, 495, 187, 188, 108, + /* 190 */ 501, 502, 410, 366, 367, 506, 507, 0, 417, 107, + /* 200 */ 419, 502, 202, 107, 204, 506, 507, 70, 394, 194, + /* 210 */ 20, 8, 9, 408, 409, 12, 13, 14, 15, 16, + /* 220 */ 406, 24, 25, 26, 27, 28, 29, 30, 31, 32, + /* 230 */ 20, 366, 367, 87, 234, 235, 236, 236, 238, 239, /* 240 */ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, - /* 250 */ 250, 251, 252, 253, 254, 255, 12, 13, 20, 3, - /* 260 */ 20, 18, 479, 20, 20, 482, 22, 365, 366, 175, - /* 270 */ 27, 361, 353, 30, 71, 365, 20, 367, 35, 35, - /* 280 */ 414, 37, 366, 500, 501, 366, 138, 385, 505, 506, - /* 290 */ 142, 278, 279, 280, 51, 69, 53, 201, 20, 203, - /* 300 */ 206, 58, 59, 475, 476, 477, 272, 479, 480, 65, - /* 310 */ 394, 365, 69, 394, 20, 71, 104, 107, 115, 475, - /* 320 */ 476, 477, 78, 479, 480, 406, 4, 408, 33, 233, + /* 250 */ 250, 251, 252, 253, 254, 255, 12, 13, 56, 57, + /* 260 */ 20, 18, 480, 20, 20, 483, 22, 12, 13, 236, + /* 270 */ 27, 362, 354, 30, 71, 366, 20, 368, 35, 35, + /* 280 */ 415, 37, 65, 501, 502, 367, 138, 362, 506, 507, + /* 290 */ 142, 366, 37, 368, 51, 149, 53, 201, 20, 203, + /* 300 */ 367, 58, 59, 476, 477, 478, 272, 480, 481, 65, + /* 310 */ 354, 366, 69, 395, 299, 71, 104, 107, 115, 173, + /* 320 */ 174, 69, 78, 106, 137, 407, 109, 409, 395, 233, /* 330 */ 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - /* 340 */ 45, 129, 130, 131, 132, 133, 134, 135, 104, 106, + /* 340 */ 20, 129, 130, 131, 132, 133, 134, 135, 104, 106, /* 350 */ 20, 107, 136, 137, 138, 139, 140, 141, 142, 211, - /* 360 */ 117, 0, 214, 452, 108, 217, 447, 219, 272, 450, - /* 370 */ 0, 455, 453, 454, 455, 456, 457, 458, 459, 460, - /* 380 */ 461, 462, 179, 143, 144, 439, 440, 143, 144, 478, - /* 390 */ 147, 148, 353, 150, 151, 152, 153, 154, 155, 156, - /* 400 */ 157, 158, 272, 365, 366, 162, 163, 164, 165, 166, - /* 410 */ 167, 168, 42, 170, 171, 172, 13, 365, 366, 176, - /* 420 */ 177, 178, 375, 197, 180, 181, 183, 187, 188, 107, - /* 430 */ 383, 187, 188, 14, 73, 74, 75, 385, 182, 20, - /* 440 */ 20, 80, 81, 82, 392, 406, 202, 86, 204, 394, - /* 450 */ 224, 225, 91, 92, 93, 94, 365, 366, 97, 20, + /* 360 */ 117, 0, 214, 407, 272, 217, 448, 219, 272, 451, + /* 370 */ 180, 181, 454, 455, 456, 457, 458, 459, 460, 461, + /* 380 */ 462, 463, 179, 143, 144, 440, 441, 143, 144, 456, + /* 390 */ 147, 148, 175, 150, 151, 152, 153, 154, 155, 156, + /* 400 */ 157, 158, 215, 216, 354, 162, 163, 164, 165, 166, + /* 410 */ 167, 168, 3, 170, 171, 172, 395, 366, 367, 176, + /* 420 */ 177, 178, 366, 367, 180, 181, 183, 187, 188, 20, + /* 430 */ 453, 187, 188, 20, 73, 74, 75, 386, 366, 367, + /* 440 */ 419, 80, 81, 82, 393, 14, 202, 86, 204, 197, + /* 450 */ 20, 20, 91, 92, 93, 94, 479, 407, 97, 204, /* 460 */ 182, 100, 259, 260, 261, 262, 263, 264, 265, 266, - /* 470 */ 267, 268, 269, 418, 180, 181, 39, 40, 234, 235, - /* 480 */ 236, 78, 238, 239, 240, 241, 242, 243, 244, 245, + /* 470 */ 267, 268, 269, 143, 144, 70, 224, 225, 234, 235, + /* 480 */ 236, 71, 238, 239, 240, 241, 242, 243, 244, 245, /* 490 */ 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, - /* 500 */ 256, 12, 13, 353, 71, 414, 407, 408, 382, 20, - /* 510 */ 180, 22, 474, 475, 476, 477, 366, 479, 480, 361, - /* 520 */ 33, 20, 396, 365, 35, 367, 37, 107, 256, 2, - /* 530 */ 258, 382, 406, 374, 353, 8, 9, 365, 366, 12, - /* 540 */ 13, 14, 15, 16, 394, 396, 107, 366, 111, 112, - /* 550 */ 391, 114, 365, 366, 65, 406, 406, 385, 408, 400, - /* 560 */ 71, 73, 74, 75, 365, 366, 236, 78, 80, 81, - /* 570 */ 82, 20, 385, 136, 86, 394, 450, 140, 3, 91, - /* 580 */ 92, 93, 94, 394, 385, 97, 460, 406, 100, 408, - /* 590 */ 401, 370, 371, 104, 272, 108, 107, 447, 409, 450, - /* 600 */ 450, 353, 70, 453, 454, 455, 456, 457, 458, 460, - /* 610 */ 460, 56, 57, 463, 366, 465, 466, 467, 42, 8, - /* 620 */ 9, 471, 472, 12, 13, 14, 15, 16, 447, 117, - /* 630 */ 350, 450, 143, 144, 453, 454, 455, 456, 457, 458, - /* 640 */ 390, 460, 394, 14, 143, 144, 465, 365, 467, 20, - /* 650 */ 365, 366, 471, 472, 406, 21, 408, 0, 24, 25, - /* 660 */ 26, 27, 28, 29, 30, 31, 32, 234, 404, 180, - /* 670 */ 181, 407, 408, 14, 452, 494, 187, 188, 21, 20, - /* 680 */ 256, 24, 25, 26, 27, 28, 29, 30, 31, 32, - /* 690 */ 50, 202, 272, 204, 444, 447, 365, 366, 450, 414, - /* 700 */ 478, 453, 454, 455, 456, 457, 458, 353, 460, 429, - /* 710 */ 386, 272, 117, 465, 434, 467, 385, 33, 394, 471, - /* 720 */ 472, 439, 440, 234, 235, 236, 402, 238, 239, 240, + /* 500 */ 256, 12, 13, 354, 20, 383, 22, 20, 3, 20, + /* 510 */ 0, 22, 387, 4, 236, 35, 367, 108, 405, 397, + /* 520 */ 395, 408, 409, 395, 35, 354, 37, 402, 403, 407, + /* 530 */ 402, 51, 476, 477, 478, 410, 480, 481, 410, 55, + /* 540 */ 60, 61, 62, 63, 395, 65, 373, 475, 476, 477, + /* 550 */ 478, 23, 480, 481, 65, 256, 407, 395, 409, 117, + /* 560 */ 71, 73, 74, 75, 402, 33, 186, 78, 80, 81, + /* 570 */ 82, 398, 410, 451, 86, 47, 48, 45, 407, 91, + /* 580 */ 92, 93, 94, 461, 234, 97, 106, 20, 100, 109, + /* 590 */ 256, 182, 258, 104, 107, 182, 107, 448, 366, 367, + /* 600 */ 451, 354, 375, 454, 455, 456, 457, 458, 459, 465, + /* 610 */ 461, 467, 182, 464, 367, 466, 467, 468, 386, 8, + /* 620 */ 9, 472, 473, 12, 13, 14, 15, 16, 401, 383, + /* 630 */ 22, 20, 143, 144, 284, 285, 286, 287, 288, 289, + /* 640 */ 290, 354, 395, 397, 234, 37, 136, 137, 138, 139, + /* 650 */ 140, 141, 142, 407, 407, 175, 409, 0, 278, 279, + /* 660 */ 280, 281, 366, 367, 184, 185, 236, 366, 367, 180, + /* 670 */ 181, 191, 192, 354, 107, 366, 187, 188, 21, 4, + /* 680 */ 0, 24, 25, 26, 27, 28, 29, 30, 31, 32, + /* 690 */ 210, 202, 376, 204, 407, 448, 382, 451, 451, 385, + /* 700 */ 384, 454, 455, 456, 457, 458, 459, 461, 461, 51, + /* 710 */ 354, 415, 104, 466, 430, 468, 415, 78, 60, 472, + /* 720 */ 473, 63, 64, 234, 235, 236, 407, 238, 239, 240, /* 730 */ 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, - /* 740 */ 251, 252, 253, 254, 255, 12, 13, 14, 353, 386, - /* 750 */ 12, 13, 4, 20, 22, 22, 22, 394, 386, 479, - /* 760 */ 406, 366, 482, 368, 401, 402, 394, 19, 35, 37, - /* 770 */ 37, 37, 409, 0, 402, 37, 365, 366, 353, 372, - /* 780 */ 500, 501, 374, 35, 179, 505, 506, 236, 20, 394, - /* 790 */ 22, 366, 108, 368, 65, 394, 385, 20, 65, 51, - /* 800 */ 37, 406, 401, 408, 397, 194, 58, 59, 400, 180, - /* 810 */ 409, 78, 78, 65, 12, 13, 14, 15, 16, 394, - /* 820 */ 8, 9, 182, 55, 12, 13, 14, 15, 16, 87, - /* 830 */ 190, 406, 20, 408, 20, 106, 104, 104, 109, 180, - /* 840 */ 107, 78, 447, 365, 366, 450, 353, 271, 453, 454, - /* 850 */ 455, 456, 457, 458, 106, 460, 22, 109, 78, 366, - /* 860 */ 465, 368, 467, 385, 259, 236, 471, 472, 293, 365, - /* 870 */ 366, 37, 447, 234, 269, 450, 143, 144, 453, 454, - /* 880 */ 455, 456, 457, 458, 137, 460, 353, 394, 0, 385, - /* 890 */ 465, 149, 467, 394, 51, 236, 471, 472, 4, 406, - /* 900 */ 401, 408, 387, 60, 175, 390, 63, 64, 409, 298, - /* 910 */ 365, 366, 78, 180, 181, 173, 174, 353, 34, 22, - /* 920 */ 187, 188, 283, 284, 285, 286, 287, 288, 289, 394, - /* 930 */ 385, 23, 159, 160, 37, 202, 401, 204, 104, 406, - /* 940 */ 447, 136, 204, 450, 409, 140, 453, 454, 455, 456, - /* 950 */ 457, 458, 353, 460, 353, 47, 48, 353, 465, 182, - /* 960 */ 467, 395, 215, 216, 471, 472, 395, 234, 235, 236, - /* 970 */ 406, 238, 239, 240, 241, 242, 243, 244, 245, 246, + /* 740 */ 251, 252, 253, 254, 255, 12, 13, 14, 354, 440, + /* 750 */ 441, 366, 367, 20, 391, 22, 430, 137, 138, 272, + /* 760 */ 33, 367, 142, 407, 480, 357, 358, 483, 35, 21, + /* 770 */ 37, 386, 24, 25, 26, 27, 28, 29, 30, 31, + /* 780 */ 32, 354, 107, 274, 387, 501, 502, 366, 367, 395, + /* 790 */ 506, 507, 395, 182, 367, 395, 369, 34, 65, 294, + /* 800 */ 403, 407, 402, 409, 366, 367, 480, 386, 445, 483, + /* 810 */ 410, 78, 8, 9, 395, 387, 12, 13, 14, 15, + /* 820 */ 16, 402, 395, 395, 386, 371, 372, 501, 502, 410, + /* 830 */ 387, 403, 506, 507, 407, 108, 409, 104, 395, 272, + /* 840 */ 107, 42, 448, 366, 367, 451, 403, 236, 454, 455, + /* 850 */ 456, 457, 458, 459, 354, 461, 354, 354, 117, 22, + /* 860 */ 466, 4, 468, 386, 395, 354, 472, 473, 453, 367, + /* 870 */ 366, 367, 403, 354, 37, 448, 143, 144, 451, 0, + /* 880 */ 23, 454, 455, 456, 457, 458, 459, 354, 461, 495, + /* 890 */ 386, 4, 14, 466, 479, 468, 14, 395, 20, 472, + /* 900 */ 473, 436, 20, 46, 47, 48, 19, 407, 228, 407, + /* 910 */ 407, 409, 108, 180, 181, 78, 366, 367, 407, 0, + /* 920 */ 187, 188, 35, 8, 9, 20, 407, 12, 13, 14, + /* 930 */ 15, 16, 14, 15, 16, 202, 386, 204, 51, 22, + /* 940 */ 407, 104, 50, 380, 381, 58, 59, 272, 33, 395, + /* 950 */ 448, 37, 65, 451, 37, 430, 454, 455, 456, 457, + /* 960 */ 458, 459, 396, 461, 410, 371, 372, 234, 235, 236, + /* 970 */ 51, 238, 239, 240, 241, 242, 243, 244, 245, 246, /* 980 */ 247, 248, 249, 250, 251, 252, 253, 254, 255, 12, - /* 990 */ 13, 353, 370, 371, 182, 0, 182, 20, 464, 22, - /* 1000 */ 466, 104, 379, 380, 366, 406, 368, 406, 381, 395, - /* 1010 */ 406, 384, 35, 236, 37, 8, 9, 365, 366, 12, - /* 1020 */ 13, 14, 15, 16, 136, 137, 138, 139, 140, 141, - /* 1030 */ 142, 394, 394, 14, 15, 16, 202, 385, 204, 402, - /* 1040 */ 33, 452, 65, 395, 406, 20, 408, 353, 236, 20, - /* 1050 */ 236, 137, 138, 8, 9, 78, 142, 12, 13, 14, - /* 1060 */ 15, 16, 365, 366, 4, 353, 0, 478, 234, 235, - /* 1070 */ 8, 9, 353, 353, 12, 13, 14, 15, 16, 365, - /* 1080 */ 366, 104, 385, 23, 107, 447, 366, 463, 450, 353, - /* 1090 */ 466, 453, 454, 455, 456, 457, 458, 394, 460, 385, - /* 1100 */ 406, 33, 366, 465, 368, 467, 46, 47, 48, 471, - /* 1110 */ 472, 464, 409, 466, 394, 108, 379, 380, 406, 399, - /* 1120 */ 143, 144, 0, 365, 366, 406, 406, 435, 408, 353, - /* 1130 */ 394, 136, 137, 138, 139, 140, 141, 142, 395, 394, - /* 1140 */ 365, 366, 406, 385, 408, 117, 365, 366, 394, 365, - /* 1150 */ 366, 365, 366, 108, 409, 33, 353, 180, 181, 403, - /* 1160 */ 385, 353, 406, 409, 187, 188, 385, 447, 274, 385, - /* 1170 */ 450, 385, 383, 453, 454, 455, 456, 457, 458, 202, - /* 1180 */ 460, 204, 406, 447, 353, 353, 450, 270, 271, 453, - /* 1190 */ 454, 455, 456, 457, 458, 354, 460, 169, 429, 353, - /* 1200 */ 429, 465, 403, 467, 353, 406, 353, 471, 472, 406, - /* 1210 */ 65, 234, 235, 236, 406, 238, 239, 240, 241, 242, + /* 990 */ 13, 396, 78, 106, 354, 78, 109, 20, 354, 22, + /* 1000 */ 12, 13, 14, 15, 16, 480, 354, 354, 483, 396, + /* 1010 */ 508, 509, 35, 395, 37, 136, 137, 138, 139, 140, + /* 1020 */ 141, 142, 354, 108, 354, 354, 501, 502, 410, 8, + /* 1030 */ 9, 506, 507, 12, 13, 14, 15, 16, 367, 202, + /* 1040 */ 369, 204, 65, 179, 366, 367, 20, 407, 354, 366, + /* 1050 */ 367, 407, 22, 366, 367, 78, 366, 367, 180, 407, + /* 1060 */ 407, 367, 180, 369, 386, 464, 395, 37, 467, 386, + /* 1070 */ 271, 234, 235, 386, 182, 407, 386, 407, 407, 117, + /* 1080 */ 409, 104, 190, 354, 107, 180, 136, 8, 9, 395, + /* 1090 */ 140, 12, 13, 14, 15, 16, 367, 33, 369, 2, + /* 1100 */ 0, 407, 396, 409, 404, 8, 9, 407, 354, 12, + /* 1110 */ 13, 14, 15, 16, 236, 366, 367, 13, 236, 448, + /* 1120 */ 143, 144, 451, 259, 395, 454, 455, 456, 457, 458, + /* 1130 */ 459, 169, 461, 269, 104, 386, 407, 466, 409, 468, + /* 1140 */ 33, 236, 448, 472, 473, 451, 0, 175, 454, 455, + /* 1150 */ 456, 457, 458, 459, 0, 461, 354, 180, 181, 37, + /* 1160 */ 466, 407, 468, 37, 187, 188, 472, 473, 22, 366, + /* 1170 */ 367, 366, 367, 404, 366, 367, 407, 448, 206, 202, + /* 1180 */ 451, 204, 78, 454, 455, 456, 457, 458, 459, 386, + /* 1190 */ 461, 386, 430, 2, 386, 466, 42, 468, 33, 8, + /* 1200 */ 9, 472, 473, 12, 13, 14, 15, 16, 396, 407, + /* 1210 */ 45, 234, 235, 236, 396, 238, 239, 240, 241, 242, /* 1220 */ 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, - /* 1230 */ 253, 254, 255, 12, 13, 33, 403, 406, 406, 406, - /* 1240 */ 0, 20, 13, 22, 182, 356, 357, 45, 479, 0, - /* 1250 */ 479, 482, 406, 482, 109, 353, 35, 406, 37, 406, - /* 1260 */ 13, 236, 22, 35, 110, 236, 37, 113, 366, 500, - /* 1270 */ 501, 500, 501, 0, 505, 506, 505, 506, 110, 51, - /* 1280 */ 110, 113, 110, 113, 37, 113, 65, 0, 60, 61, - /* 1290 */ 62, 63, 0, 65, 228, 22, 394, 8, 9, 78, - /* 1300 */ 51, 12, 13, 14, 15, 16, 419, 33, 406, 22, - /* 1310 */ 408, 218, 33, 220, 22, 33, 33, 49, 18, 33, - /* 1320 */ 143, 144, 37, 23, 33, 104, 1, 2, 107, 33, - /* 1330 */ 33, 33, 353, 509, 106, 498, 37, 109, 37, 429, - /* 1340 */ 40, 41, 33, 33, 44, 366, 33, 368, 13, 447, - /* 1350 */ 13, 369, 450, 33, 54, 453, 454, 455, 456, 457, - /* 1360 */ 458, 107, 460, 295, 143, 144, 66, 67, 68, 69, - /* 1370 */ 116, 491, 37, 394, 37, 107, 382, 429, 394, 78, - /* 1380 */ 382, 419, 108, 33, 364, 406, 419, 408, 497, 479, - /* 1390 */ 108, 108, 482, 497, 108, 497, 428, 495, 496, 108, - /* 1400 */ 497, 180, 181, 175, 108, 108, 108, 107, 187, 188, - /* 1410 */ 500, 501, 184, 185, 366, 505, 506, 108, 108, 191, - /* 1420 */ 192, 108, 369, 202, 419, 204, 447, 479, 108, 450, - /* 1430 */ 482, 0, 453, 454, 455, 456, 457, 458, 210, 460, - /* 1440 */ 33, 33, 405, 33, 465, 145, 467, 33, 500, 501, - /* 1450 */ 471, 472, 33, 505, 506, 234, 235, 236, 108, 238, + /* 1230 */ 253, 254, 255, 12, 13, 39, 40, 366, 367, 453, + /* 1240 */ 0, 20, 480, 22, 33, 483, 366, 367, 380, 381, + /* 1250 */ 366, 367, 404, 270, 271, 407, 35, 386, 37, 159, + /* 1260 */ 160, 182, 236, 501, 502, 479, 386, 33, 506, 507, + /* 1270 */ 386, 388, 110, 33, 391, 113, 354, 110, 110, 13, + /* 1280 */ 113, 113, 110, 0, 0, 113, 65, 13, 33, 367, + /* 1290 */ 0, 369, 218, 65, 220, 49, 33, 33, 355, 78, + /* 1300 */ 143, 144, 396, 37, 37, 22, 22, 111, 112, 33, + /* 1310 */ 114, 37, 22, 1, 2, 384, 420, 395, 18, 108, + /* 1320 */ 510, 33, 33, 23, 33, 104, 204, 13, 107, 407, + /* 1330 */ 204, 409, 136, 499, 354, 33, 140, 109, 492, 33, + /* 1340 */ 40, 41, 108, 33, 44, 78, 33, 367, 370, 369, + /* 1350 */ 107, 37, 33, 107, 54, 33, 395, 33, 33, 116, + /* 1360 */ 296, 13, 383, 108, 143, 144, 66, 67, 68, 69, + /* 1370 */ 448, 108, 108, 451, 33, 395, 454, 455, 456, 457, + /* 1380 */ 458, 459, 383, 461, 108, 37, 420, 407, 466, 409, + /* 1390 */ 468, 0, 365, 420, 472, 473, 108, 108, 498, 108, + /* 1400 */ 498, 180, 181, 33, 33, 298, 498, 107, 187, 188, + /* 1410 */ 108, 429, 370, 420, 108, 367, 406, 420, 108, 498, + /* 1420 */ 420, 108, 437, 202, 482, 204, 503, 108, 448, 474, + /* 1430 */ 108, 451, 108, 108, 454, 455, 456, 457, 458, 459, + /* 1440 */ 385, 461, 485, 52, 275, 145, 466, 431, 468, 108, + /* 1450 */ 51, 450, 472, 473, 42, 234, 235, 236, 449, 238, /* 1460 */ 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, - /* 1470 */ 249, 250, 251, 252, 253, 254, 255, 436, 419, 473, - /* 1480 */ 419, 12, 13, 52, 353, 481, 484, 502, 384, 204, - /* 1490 */ 275, 22, 51, 430, 194, 195, 196, 366, 449, 199, - /* 1500 */ 42, 20, 448, 204, 35, 441, 37, 217, 374, 374, - /* 1510 */ 441, 353, 212, 213, 200, 108, 108, 446, 108, 432, - /* 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, - /* 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, - /* 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, - /* 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, - /* 1900 */ 0, 0, 0, 0, 0, 210, 366, 0, 0, 0, - /* 1910 */ 0, 406, 0, 408, 49, 0, 507, 508, 0, 394, - /* 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, - /* 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, - /* 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, - /* 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, - /* 2460 */ 511, 394, 511, 511, 511, 511, 511, 511, 511, 511, - /* 2470 */ 511, 511, 511, 406, 511, 408, 511, 511, 511, 511, - /* 2480 */ 511, 394, 511, 511, 511, 511, 511, 511, 511, 511, - /* 2490 */ 511, 511, 511, 406, 511, 408, 511, 511, 353, 511, - /* 2500 */ 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, - /* 2510 */ 511, 366, 511, 353, 447, 511, 511, 450, 511, 511, - /* 2520 */ 453, 454, 455, 456, 457, 458, 366, 460, 511, 511, - /* 2530 */ 511, 511, 511, 511, 447, 353, 511, 450, 511, 394, - /* 2540 */ 453, 454, 455, 456, 457, 458, 511, 460, 366, 511, - /* 2550 */ 511, 406, 511, 408, 394, 511, 511, 511, 511, 511, - /* 2560 */ 511, 511, 511, 511, 511, 511, 406, 511, 408, 511, - /* 2570 */ 511, 511, 511, 511, 511, 511, 394, 511, 511, 511, - /* 2580 */ 511, 511, 511, 511, 511, 511, 511, 511, 406, 511, - /* 2590 */ 408, 511, 447, 353, 511, 450, 511, 511, 453, 454, - /* 2600 */ 455, 456, 457, 458, 511, 460, 366, 447, 353, 511, - /* 2610 */ 450, 511, 511, 453, 454, 455, 456, 457, 458, 511, - /* 2620 */ 460, 366, 511, 511, 511, 511, 511, 511, 353, 447, - /* 2630 */ 511, 511, 450, 511, 394, 453, 454, 455, 456, 457, - /* 2640 */ 458, 366, 460, 511, 511, 511, 406, 511, 408, 394, - /* 2650 */ 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, - /* 2660 */ 511, 406, 511, 408, 511, 511, 511, 511, 511, 394, - /* 2670 */ 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, - /* 2680 */ 511, 406, 511, 408, 511, 511, 511, 447, 511, 511, - /* 2690 */ 450, 511, 511, 453, 454, 455, 456, 457, 458, 511, - /* 2700 */ 460, 353, 447, 511, 511, 450, 511, 511, 453, 454, - /* 2710 */ 455, 456, 457, 458, 366, 460, 511, 511, 511, 511, - /* 2720 */ 511, 353, 447, 511, 511, 450, 511, 511, 453, 454, - /* 2730 */ 455, 456, 457, 458, 366, 460, 511, 511, 353, 511, - /* 2740 */ 511, 511, 394, 511, 511, 511, 511, 511, 511, 511, - /* 2750 */ 511, 366, 511, 511, 406, 511, 408, 511, 511, 511, - /* 2760 */ 511, 511, 394, 511, 511, 511, 511, 511, 511, 511, - /* 2770 */ 511, 511, 511, 511, 406, 511, 408, 511, 511, 394, - /* 2780 */ 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, - /* 2790 */ 511, 406, 511, 408, 511, 447, 511, 511, 450, 511, - /* 2800 */ 511, 453, 454, 455, 456, 457, 458, 353, 460, 511, - /* 2810 */ 511, 511, 511, 511, 511, 447, 511, 511, 450, 511, - /* 2820 */ 366, 453, 454, 455, 456, 457, 458, 511, 460, 511, - /* 2830 */ 511, 511, 447, 511, 511, 450, 511, 511, 453, 454, - /* 2840 */ 455, 456, 457, 458, 511, 460, 511, 511, 394, 511, - /* 2850 */ 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, - /* 2860 */ 406, 511, 408, 511, 511, 353, 511, 511, 511, 511, - /* 2870 */ 511, 511, 511, 511, 511, 511, 511, 511, 366, 511, - /* 2880 */ 353, 511, 511, 511, 511, 511, 511, 511, 511, 511, - /* 2890 */ 511, 511, 511, 366, 511, 511, 511, 511, 511, 511, - /* 2900 */ 511, 447, 353, 511, 450, 511, 394, 453, 454, 455, - /* 2910 */ 456, 457, 458, 511, 460, 366, 511, 511, 406, 511, - /* 2920 */ 408, 394, 511, 511, 511, 511, 511, 511, 511, 511, - /* 2930 */ 511, 511, 511, 406, 511, 408, 511, 511, 511, 511, - /* 2940 */ 511, 511, 511, 394, 511, 511, 511, 511, 511, 511, - /* 2950 */ 511, 511, 511, 511, 511, 406, 511, 408, 511, 447, - /* 2960 */ 353, 511, 450, 511, 511, 453, 454, 455, 456, 457, - /* 2970 */ 458, 511, 460, 366, 447, 353, 511, 450, 511, 511, - /* 2980 */ 453, 454, 455, 456, 457, 458, 511, 460, 366, 511, - /* 2990 */ 511, 511, 511, 511, 511, 511, 447, 511, 511, 450, - /* 3000 */ 511, 394, 453, 454, 455, 456, 457, 458, 511, 460, - /* 3010 */ 511, 511, 511, 406, 511, 408, 394, 511, 511, 511, - /* 3020 */ 511, 511, 511, 511, 511, 511, 511, 511, 406, 511, - /* 3030 */ 408, 511, 511, 511, 511, 511, 511, 511, 511, 511, - /* 3040 */ 511, 511, 511, 511, 511, 511, 511, 511, 511, 511, - /* 3050 */ 511, 511, 511, 511, 447, 511, 511, 450, 511, 511, - /* 3060 */ 453, 454, 455, 456, 457, 458, 511, 460, 511, 447, - /* 3070 */ 511, 511, 450, 511, 511, 453, 454, 455, 456, 457, - /* 3080 */ 458, 511, 460, 350, 350, 350, 350, 350, 350, 350, - /* 3090 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3100 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3110 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3120 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3130 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3140 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3150 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3160 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3170 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3180 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3190 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3200 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3210 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3220 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3230 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3240 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3250 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3260 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3270 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3280 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3290 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3300 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3310 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3320 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3330 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3340 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3350 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3360 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3370 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3380 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3390 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3400 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3410 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3420 */ 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, - /* 3430 */ 350, 350, 350, + /* 1470 */ 249, 250, 251, 252, 253, 254, 255, 20, 108, 108, + /* 1480 */ 442, 12, 13, 447, 354, 217, 375, 442, 375, 433, + /* 1490 */ 20, 22, 200, 366, 194, 195, 196, 367, 20, 199, + /* 1500 */ 367, 45, 416, 367, 35, 416, 37, 354, 179, 413, + /* 1510 */ 366, 366, 212, 213, 367, 416, 413, 379, 413, 413, + /* 1520 */ 367, 105, 103, 223, 366, 395, 226, 378, 102, 229, + /* 1530 */ 230, 231, 232, 233, 65, 20, 351, 407, 377, 409, + /* 1540 */ 366, 366, 354, 366, 50, 359, 363, 78, 395, 359, + /* 1550 */ 363, 442, 20, 375, 375, 367, 375, 409, 20, 20, + /* 1560 */ 407, 368, 409, 432, 375, 368, 20, 375, 366, 375, + /* 1570 */ 375, 359, 272, 104, 423, 375, 357, 395, 448, 395, + /* 1580 */ 366, 451, 357, 395, 454, 455, 456, 457, 458, 459, + /* 1590 */ 359, 461, 107, 395, 395, 407, 466, 409, 468, 395, + /* 1600 */ 395, 448, 472, 473, 451, 395, 221, 454, 455, 456, + /* 1610 */ 457, 458, 459, 395, 461, 430, 407, 395, 395, 466, + /* 1620 */ 435, 468, 395, 407, 407, 472, 473, 373, 20, 208, + /* 1630 */ 207, 373, 283, 409, 431, 366, 448, 407, 282, 451, + /* 1640 */ 439, 354, 454, 455, 456, 457, 458, 459, 291, 461, + /* 1650 */ 442, 444, 446, 438, 367, 491, 468, 425, 425, 193, + /* 1660 */ 472, 473, 491, 276, 494, 480, 493, 441, 483, 293, + /* 1670 */ 490, 202, 354, 204, 292, 431, 297, 300, 295, 271, + /* 1680 */ 20, 505, 395, 367, 117, 367, 501, 502, 453, 368, + /* 1690 */ 273, 506, 507, 373, 407, 425, 409, 425, 185, 354, + /* 1700 */ 373, 407, 489, 234, 235, 407, 407, 421, 407, 373, + /* 1710 */ 407, 491, 367, 395, 391, 373, 107, 248, 249, 250, + /* 1720 */ 251, 252, 253, 254, 488, 407, 367, 409, 486, 484, + /* 1730 */ 471, 107, 399, 504, 366, 448, 373, 407, 451, 22, + /* 1740 */ 395, 454, 455, 456, 457, 458, 459, 38, 461, 511, + /* 1750 */ 356, 359, 407, 360, 409, 468, 389, 354, 443, 472, + /* 1760 */ 473, 426, 434, 426, 389, 352, 448, 389, 0, 451, + /* 1770 */ 367, 374, 454, 455, 456, 457, 458, 459, 0, 461, + /* 1780 */ 0, 45, 0, 37, 227, 37, 468, 37, 37, 227, + /* 1790 */ 472, 473, 354, 448, 0, 37, 451, 37, 395, 454, + /* 1800 */ 455, 456, 457, 458, 459, 367, 461, 227, 37, 0, + /* 1810 */ 407, 227, 409, 0, 37, 0, 37, 0, 22, 0, + /* 1820 */ 37, 222, 354, 210, 0, 210, 204, 211, 202, 0, + /* 1830 */ 0, 0, 198, 395, 0, 367, 197, 0, 0, 148, + /* 1840 */ 49, 496, 497, 0, 49, 407, 0, 409, 37, 0, + /* 1850 */ 51, 448, 0, 37, 451, 49, 0, 454, 455, 456, + /* 1860 */ 457, 458, 459, 395, 461, 45, 0, 0, 400, 0, + /* 1870 */ 49, 468, 0, 0, 0, 407, 473, 409, 0, 0, + /* 1880 */ 0, 165, 37, 0, 165, 0, 448, 354, 0, 451, + /* 1890 */ 0, 0, 454, 455, 456, 457, 458, 459, 45, 461, + /* 1900 */ 367, 0, 354, 0, 0, 0, 0, 0, 0, 0, + /* 1910 */ 0, 0, 0, 0, 0, 367, 448, 354, 22, 451, + /* 1920 */ 0, 0, 454, 455, 456, 457, 458, 459, 395, 461, + /* 1930 */ 367, 49, 0, 400, 148, 497, 0, 0, 0, 0, + /* 1940 */ 407, 0, 409, 395, 0, 0, 0, 0, 147, 0, + /* 1950 */ 146, 0, 0, 22, 0, 407, 37, 409, 395, 65, + /* 1960 */ 0, 0, 22, 0, 65, 50, 50, 65, 0, 42, + /* 1970 */ 407, 0, 409, 51, 51, 42, 0, 51, 0, 37, + /* 1980 */ 37, 448, 0, 33, 451, 37, 14, 454, 455, 456, + /* 1990 */ 457, 458, 459, 37, 461, 42, 448, 354, 0, 451, + /* 2000 */ 45, 42, 454, 455, 456, 457, 458, 459, 43, 461, + /* 2010 */ 367, 448, 42, 49, 451, 354, 49, 454, 455, 456, + /* 2020 */ 457, 458, 459, 49, 461, 0, 0, 0, 367, 42, + /* 2030 */ 0, 0, 193, 49, 0, 0, 0, 37, 395, 0, + /* 2040 */ 354, 72, 0, 400, 51, 42, 37, 51, 500, 42, + /* 2050 */ 407, 0, 409, 367, 37, 51, 395, 42, 0, 37, + /* 2060 */ 42, 51, 0, 0, 0, 0, 0, 0, 407, 37, + /* 2070 */ 409, 0, 509, 115, 22, 113, 22, 37, 37, 0, + /* 2080 */ 37, 395, 37, 37, 37, 37, 400, 37, 33, 33, + /* 2090 */ 37, 448, 22, 407, 451, 409, 37, 454, 455, 456, + /* 2100 */ 457, 458, 459, 0, 461, 37, 22, 0, 22, 448, + /* 2110 */ 354, 0, 451, 53, 1, 454, 455, 456, 457, 458, + /* 2120 */ 459, 22, 461, 367, 463, 37, 0, 0, 0, 37, + /* 2130 */ 0, 37, 19, 0, 448, 20, 22, 451, 37, 37, + /* 2140 */ 454, 455, 456, 457, 458, 459, 354, 461, 35, 37, + /* 2150 */ 0, 395, 108, 49, 0, 182, 400, 182, 37, 367, + /* 2160 */ 22, 0, 22, 407, 51, 409, 209, 182, 107, 0, + /* 2170 */ 0, 205, 182, 60, 61, 62, 63, 354, 65, 107, + /* 2180 */ 185, 189, 3, 182, 33, 107, 189, 395, 108, 107, + /* 2190 */ 367, 108, 37, 37, 277, 50, 107, 50, 105, 407, + /* 2200 */ 103, 409, 49, 108, 448, 33, 33, 451, 108, 33, + /* 2210 */ 454, 455, 456, 457, 458, 459, 107, 461, 395, 106, + /* 2220 */ 49, 33, 109, 107, 107, 3, 108, 107, 33, 37, + /* 2230 */ 407, 108, 409, 108, 37, 37, 37, 37, 37, 108, + /* 2240 */ 448, 33, 108, 451, 0, 49, 454, 455, 456, 457, + /* 2250 */ 458, 459, 354, 461, 141, 49, 277, 277, 270, 0, + /* 2260 */ 42, 186, 0, 42, 107, 367, 107, 33, 116, 184, + /* 2270 */ 108, 448, 354, 108, 451, 107, 49, 454, 455, 456, + /* 2280 */ 457, 458, 459, 105, 461, 367, 105, 107, 354, 107, + /* 2290 */ 107, 22, 2, 395, 257, 108, 107, 184, 107, 49, + /* 2300 */ 107, 367, 108, 234, 191, 407, 49, 409, 22, 33, + /* 2310 */ 108, 107, 107, 395, 237, 108, 107, 37, 108, 37, + /* 2320 */ 117, 107, 37, 210, 108, 407, 107, 409, 108, 395, + /* 2330 */ 37, 107, 37, 108, 108, 107, 37, 107, 37, 108, + /* 2340 */ 107, 407, 37, 409, 107, 354, 448, 107, 107, 451, + /* 2350 */ 22, 128, 454, 455, 456, 457, 458, 459, 367, 461, + /* 2360 */ 128, 37, 71, 128, 128, 354, 448, 37, 72, 451, + /* 2370 */ 37, 37, 454, 455, 456, 457, 458, 459, 367, 461, + /* 2380 */ 37, 37, 448, 354, 37, 451, 395, 37, 454, 455, + /* 2390 */ 456, 457, 458, 459, 37, 461, 367, 78, 407, 101, + /* 2400 */ 409, 78, 33, 354, 101, 37, 395, 37, 37, 22, + /* 2410 */ 37, 37, 37, 78, 37, 37, 367, 37, 407, 37, + /* 2420 */ 409, 22, 37, 37, 395, 0, 37, 51, 0, 37, + /* 2430 */ 42, 0, 51, 42, 37, 42, 407, 0, 409, 448, + /* 2440 */ 37, 354, 451, 42, 395, 454, 455, 456, 457, 458, + /* 2450 */ 459, 51, 461, 51, 367, 0, 407, 37, 409, 448, + /* 2460 */ 37, 0, 451, 22, 21, 454, 455, 456, 457, 458, + /* 2470 */ 459, 33, 461, 22, 22, 22, 20, 448, 354, 21, + /* 2480 */ 451, 512, 395, 454, 455, 456, 457, 458, 459, 512, + /* 2490 */ 461, 367, 512, 512, 407, 512, 409, 448, 354, 512, + /* 2500 */ 451, 512, 512, 454, 455, 456, 457, 458, 459, 512, + /* 2510 */ 461, 367, 512, 512, 354, 512, 512, 512, 512, 395, + /* 2520 */ 512, 512, 512, 512, 512, 512, 512, 367, 512, 512, + /* 2530 */ 512, 407, 512, 409, 512, 448, 512, 512, 451, 395, + /* 2540 */ 512, 454, 455, 456, 457, 458, 459, 512, 461, 512, + /* 2550 */ 512, 407, 512, 409, 512, 395, 512, 512, 512, 512, + /* 2560 */ 512, 512, 512, 512, 512, 512, 512, 407, 512, 409, + /* 2570 */ 512, 512, 448, 512, 512, 451, 512, 512, 454, 455, + /* 2580 */ 456, 457, 458, 459, 512, 461, 512, 512, 512, 512, + /* 2590 */ 512, 512, 448, 512, 512, 451, 512, 512, 454, 455, + /* 2600 */ 456, 457, 458, 459, 512, 461, 512, 354, 448, 512, + /* 2610 */ 512, 451, 512, 512, 454, 455, 456, 457, 458, 459, + /* 2620 */ 367, 461, 512, 512, 512, 512, 354, 512, 512, 512, + /* 2630 */ 512, 512, 512, 512, 512, 512, 512, 512, 512, 367, + /* 2640 */ 512, 512, 512, 354, 512, 512, 512, 512, 395, 512, + /* 2650 */ 512, 512, 512, 512, 512, 512, 367, 512, 512, 512, + /* 2660 */ 407, 512, 409, 512, 512, 512, 512, 395, 512, 512, + /* 2670 */ 512, 512, 512, 512, 512, 512, 512, 512, 512, 407, + /* 2680 */ 512, 409, 512, 512, 395, 512, 512, 512, 512, 512, + /* 2690 */ 512, 512, 512, 512, 512, 512, 407, 512, 409, 512, + /* 2700 */ 354, 448, 512, 512, 451, 512, 512, 454, 455, 456, + /* 2710 */ 457, 458, 459, 367, 461, 512, 512, 512, 512, 512, + /* 2720 */ 448, 354, 512, 451, 512, 512, 454, 455, 456, 457, + /* 2730 */ 458, 459, 512, 461, 367, 512, 512, 448, 354, 512, + /* 2740 */ 451, 395, 512, 454, 455, 456, 457, 458, 459, 512, + /* 2750 */ 461, 367, 512, 407, 512, 409, 512, 512, 354, 512, + /* 2760 */ 512, 512, 395, 512, 512, 512, 512, 512, 512, 512, + /* 2770 */ 512, 367, 512, 512, 407, 512, 409, 512, 512, 395, + /* 2780 */ 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, + /* 2790 */ 512, 407, 512, 409, 448, 512, 354, 451, 512, 395, + /* 2800 */ 454, 455, 456, 457, 458, 459, 512, 461, 512, 367, + /* 2810 */ 512, 407, 512, 409, 512, 448, 512, 512, 451, 512, + /* 2820 */ 512, 454, 455, 456, 457, 458, 459, 512, 461, 512, + /* 2830 */ 512, 512, 448, 354, 512, 451, 512, 395, 454, 455, + /* 2840 */ 456, 457, 458, 459, 512, 461, 367, 512, 512, 407, + /* 2850 */ 512, 409, 448, 512, 512, 451, 512, 512, 454, 455, + /* 2860 */ 456, 457, 458, 459, 512, 461, 512, 512, 512, 512, + /* 2870 */ 512, 512, 512, 512, 395, 512, 512, 512, 512, 512, + /* 2880 */ 512, 512, 512, 512, 512, 512, 407, 512, 409, 512, + /* 2890 */ 448, 512, 512, 451, 512, 512, 454, 455, 456, 457, + /* 2900 */ 458, 459, 512, 461, 512, 512, 512, 512, 512, 512, + /* 2910 */ 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, + /* 2920 */ 512, 512, 512, 512, 512, 512, 512, 448, 512, 512, + /* 2930 */ 451, 512, 512, 454, 455, 456, 457, 458, 459, 512, + /* 2940 */ 461, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 2950 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 2960 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 2970 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 2980 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 2990 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3000 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3010 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3020 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3030 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3040 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3050 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3060 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3070 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3080 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3090 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3100 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3110 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3120 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3130 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3140 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3150 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3160 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3170 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3180 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3190 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3200 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3210 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3220 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3230 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3240 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3250 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3260 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3270 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3280 */ 351, 351, 351, 351, 351, 351, 351, 351, 351, 351, + /* 3290 */ 351, 351, }; -#define YY_SHIFT_COUNT (845) +#define YY_SHIFT_COUNT (851) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2412) +#define YY_SHIFT_MAX (2461) 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, /* 20 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, /* 30 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, /* 40 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, - /* 50 */ 977, 420, 439, 96, 210, 34, 130, 34, 34, 210, - /* 60 */ 210, 34, 1469, 34, 243, 1469, 1469, 322, 34, 1, - /* 70 */ 240, 131, 131, 1060, 1060, 240, 294, 501, 154, 154, - /* 80 */ 551, 131, 131, 131, 131, 131, 131, 131, 131, 131, - /* 90 */ 131, 131, 165, 238, 131, 131, 31, 1, 131, 165, - /* 100 */ 131, 1, 131, 131, 1, 131, 131, 1, 131, 1, - /* 110 */ 1, 1, 131, 532, 203, 203, 488, 634, 834, 834, - /* 120 */ 834, 834, 834, 834, 834, 834, 834, 834, 834, 834, - /* 130 */ 834, 834, 834, 834, 834, 834, 834, 437, 256, 294, - /* 140 */ 501, 555, 555, 763, 278, 278, 278, 137, 272, 272, - /* 150 */ 403, 763, 31, 512, 1, 1, 424, 1, 780, 1, - /* 160 */ 780, 780, 595, 884, 212, 212, 212, 212, 212, 212, - /* 170 */ 212, 212, 1695, 361, 657, 812, 611, 639, 118, 13, - /* 180 */ 629, 659, 738, 738, 777, 908, 814, 734, 734, 734, - /* 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, + /* 50 */ 977, 487, 567, 96, 210, 34, 92, 34, 34, 210, + /* 60 */ 210, 34, 1469, 34, 243, 1469, 1469, 675, 34, 131, + /* 70 */ 240, 165, 165, 857, 857, 240, 190, 330, 154, 154, + /* 80 */ 1, 165, 165, 165, 165, 165, 165, 165, 165, 165, + /* 90 */ 165, 165, 256, 320, 165, 165, 31, 131, 165, 256, + /* 100 */ 165, 131, 165, 165, 131, 165, 165, 131, 165, 131, + /* 110 */ 131, 131, 165, 405, 203, 203, 488, 748, 837, 837, + /* 120 */ 837, 837, 837, 837, 837, 837, 837, 837, 837, 837, + /* 130 */ 837, 837, 837, 837, 837, 837, 837, 1196, 409, 190, + /* 140 */ 330, 202, 202, 914, 413, 413, 413, 137, 334, 334, + /* 150 */ 1104, 914, 31, 442, 131, 131, 299, 131, 639, 131, + /* 160 */ 639, 639, 741, 763, 212, 212, 212, 212, 212, 212, + /* 170 */ 212, 212, 2113, 361, 657, 611, 15, 350, 380, 118, + /* 180 */ 878, 882, 255, 255, 278, 528, 430, 917, 917, 917, + /* 190 */ 892, 917, 905, 484, 33, 431, 950, 972, 33, 33, + /* 200 */ 1026, 983, 799, 505, 983, 532, 509, 1104, 1169, 1399, + /* 210 */ 1412, 1457, 1268, 31, 1457, 31, 1292, 1470, 1478, 1456, + /* 220 */ 1478, 1456, 1329, 1470, 1478, 1470, 1456, 1329, 1329, 1329, + /* 230 */ 1416, 1419, 1470, 1426, 1470, 1470, 1470, 1515, 1494, 1515, + /* 240 */ 1494, 1457, 31, 31, 1532, 31, 1538, 1539, 31, 1538, + /* 250 */ 31, 1546, 31, 31, 1470, 31, 1515, 131, 131, 131, + /* 260 */ 131, 131, 131, 131, 131, 131, 131, 131, 1470, 763, + /* 270 */ 763, 1515, 639, 639, 639, 1385, 1485, 1457, 405, 1608, + /* 280 */ 1421, 1423, 1532, 405, 1169, 1470, 639, 1349, 1356, 1349, + /* 290 */ 1356, 1357, 1466, 1349, 1376, 1382, 1387, 1169, 1377, 1379, + /* 300 */ 1383, 1408, 1478, 1660, 1567, 1417, 1538, 405, 405, 1356, + /* 310 */ 639, 639, 639, 639, 1356, 639, 1513, 405, 741, 405, + /* 320 */ 1478, 1609, 1624, 639, 1470, 405, 1717, 1709, 1515, 2941, + /* 330 */ 2941, 2941, 2941, 2941, 2941, 2941, 2941, 2941, 36, 480, + /* 340 */ 197, 887, 915, 81, 804, 510, 1097, 1191, 1079, 879, + /* 350 */ 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 1021, 216, + /* 360 */ 148, 12, 988, 988, 252, 217, 10, 146, 658, 1100, + /* 370 */ 608, 1030, 187, 620, 620, 918, 6, 864, 918, 918, + /* 380 */ 918, 919, 680, 727, 1154, 1165, 962, 1240, 1162, 1167, + /* 390 */ 1168, 1172, 1266, 1274, 1146, 1283, 1284, 1290, 1074, 1211, + /* 400 */ 1234, 1228, 1255, 1263, 1264, 1276, 1157, 1064, 1107, 1288, + /* 410 */ 1289, 1291, 1302, 1306, 1310, 1312, 1313, 410, 1319, 1246, + /* 420 */ 1322, 1324, 1325, 1341, 1370, 1371, 1243, 1122, 1126, 1314, + /* 430 */ 1348, 1267, 1391, 1768, 1778, 1780, 1736, 1782, 1746, 1557, + /* 440 */ 1748, 1750, 1751, 1562, 1794, 1758, 1760, 1580, 1771, 1809, + /* 450 */ 1584, 1813, 1777, 1815, 1779, 1817, 1796, 1819, 1783, 1599, + /* 460 */ 1834, 1613, 1824, 1615, 1616, 1622, 1626, 1829, 1830, 1831, + /* 470 */ 1634, 1639, 1837, 1838, 1691, 1791, 1795, 1843, 1811, 1846, + /* 480 */ 1849, 1816, 1799, 1852, 1806, 1856, 1820, 1866, 1867, 1869, + /* 490 */ 1821, 1872, 1873, 1874, 1878, 1879, 1880, 1716, 1845, 1883, + /* 500 */ 1719, 1885, 1888, 1890, 1891, 1901, 1903, 1904, 1905, 1906, + /* 510 */ 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1920, 1921, + /* 520 */ 1882, 1932, 1853, 1936, 1937, 1938, 1939, 1941, 1944, 1945, + /* 530 */ 1896, 1946, 1786, 1947, 1801, 1949, 1804, 1951, 1952, 1931, + /* 540 */ 1915, 1940, 1916, 1954, 1894, 1919, 1960, 1899, 1961, 1902, + /* 550 */ 1963, 1968, 1942, 1922, 1927, 1971, 1943, 1923, 1933, 1976, + /* 560 */ 1948, 1926, 1953, 1978, 1956, 1982, 1955, 1959, 1950, 1964, + /* 570 */ 1967, 1972, 1974, 1998, 1965, 1970, 2025, 2026, 2027, 2039, + /* 580 */ 1987, 1839, 2030, 1964, 1984, 2031, 2034, 1969, 2035, 2036, + /* 590 */ 2000, 1993, 2003, 2042, 2009, 1996, 2007, 2051, 2017, 2004, + /* 600 */ 2015, 2058, 2022, 2010, 2018, 2062, 2063, 2064, 2065, 2066, + /* 610 */ 2067, 1958, 1962, 2032, 2052, 2071, 2040, 2041, 2043, 2045, + /* 620 */ 2046, 2047, 2048, 2050, 2055, 2056, 2053, 2059, 2054, 2068, + /* 630 */ 2079, 2070, 2103, 2084, 2107, 2086, 2060, 2111, 2099, 2088, + /* 640 */ 2126, 2127, 2128, 2092, 2130, 2094, 2133, 2114, 2115, 2101, + /* 650 */ 2102, 2112, 2044, 2061, 2150, 1973, 2072, 1957, 1964, 2104, + /* 660 */ 2154, 1975, 2121, 2138, 2161, 1966, 2140, 1985, 1995, 2169, + /* 670 */ 2170, 1990, 1992, 2001, 1997, 2179, 2151, 1917, 2078, 2080, + /* 680 */ 2082, 2083, 2155, 2156, 2089, 2145, 2093, 2147, 2097, 2095, + /* 690 */ 2172, 2173, 2100, 2109, 2116, 2117, 2118, 2176, 2153, 2171, + /* 700 */ 2120, 2188, 1979, 2123, 2125, 2222, 2195, 1980, 2192, 2197, + /* 710 */ 2198, 2199, 2200, 2201, 2131, 2134, 2196, 1988, 2208, 2206, + /* 720 */ 2244, 2259, 2157, 2218, 2159, 2162, 2165, 2168, 2180, 2075, + /* 730 */ 2182, 2262, 2221, 2085, 2183, 2152, 1964, 2227, 2234, 2178, + /* 740 */ 2037, 2181, 2290, 2269, 2069, 2189, 2187, 2191, 2194, 2193, + /* 750 */ 2202, 2250, 2204, 2205, 2257, 2207, 2286, 2077, 2209, 2203, + /* 760 */ 2210, 2280, 2282, 2214, 2216, 2285, 2219, 2220, 2293, 2224, + /* 770 */ 2225, 2295, 2228, 2226, 2299, 2230, 2231, 2301, 2233, 2223, + /* 780 */ 2232, 2235, 2236, 2237, 2276, 2240, 2305, 2241, 2276, 2276, + /* 790 */ 2328, 2296, 2291, 2324, 2330, 2333, 2334, 2343, 2344, 2347, + /* 800 */ 2350, 2357, 2319, 2298, 2323, 2303, 2369, 2368, 2370, 2371, + /* 810 */ 2387, 2373, 2374, 2375, 2335, 2055, 2377, 2056, 2378, 2380, + /* 820 */ 2382, 2385, 2399, 2386, 2425, 2389, 2376, 2388, 2428, 2392, + /* 830 */ 2381, 2391, 2431, 2397, 2400, 2393, 2437, 2403, 2402, 2401, + /* 840 */ 2455, 2420, 2423, 2461, 2441, 2438, 2451, 2443, 2452, 2453, + /* 850 */ 2458, 2456, }; -#define YY_REDUCE_COUNT (336) -#define YY_REDUCE_MIN (-463) -#define YY_REDUCE_MAX (2622) +#define YY_REDUCE_COUNT (337) +#define YY_REDUCE_MIN (-464) +#define YY_REDUCE_MAX (2479) static const short yy_reduce_ofst[] = { - /* 0 */ 280, -308, 150, 181, 395, 425, 493, 638, 736, 979, - /* 10 */ 248, 1131, 1158, 1227, 1342, 1374, -81, 902, 1409, 1482, - /* 20 */ 1505, 720, 1525, 1540, 1636, 1672, 1704, 1781, 1797, 1815, - /* 30 */ 1880, 1914, 1937, 1994, 2067, 2087, 2145, 2160, 2182, 2240, - /* 40 */ 2255, 2275, 2348, 2368, 2385, 2454, 2512, 2527, 2549, 2607, - /* 50 */ 2622, -310, -217, -425, 38, -418, 769, 771, 910, -172, - /* 60 */ -156, 948, -381, -438, -257, 126, 149, -463, -300, 363, - /* 70 */ -324, -326, 52, -358, -202, -335, -218, 264, -90, 158, - /* 80 */ -84, -152, -98, 172, 187, -134, 91, 199, 331, 411, - /* 90 */ 478, 285, -54, -316, 504, 545, 159, 189, 652, 282, - /* 100 */ 697, 401, 714, 758, -368, 781, 784, 499, 786, 324, - /* 110 */ 535, 372, 775, -312, -422, -422, 47, -280, -353, 39, - /* 120 */ 354, 533, 564, 599, 601, 604, 694, 712, 719, 776, - /* 130 */ 803, 808, 831, 832, 846, 851, 853, -185, -89, 55, - /* 140 */ 99, 221, 622, 623, -89, 222, 589, 407, 534, 647, - /* 150 */ 627, 737, 408, 250, 703, 745, 624, 637, 756, 754, - /* 160 */ 799, 833, 515, 889, -392, -363, 566, 571, 614, 648, - /* 170 */ 743, 614, 692, 789, 841, 887, 824, 837, 982, 880, - /* 180 */ 984, 984, 994, 998, 962, 1020, 967, 891, 896, 898, - /* 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, + /* 0 */ 1185, -309, 149, 394, 427, 671, 694, 729, 922, 980, + /* 10 */ 247, 1130, 1153, 1188, 1287, 1318, -82, 1345, 502, 1403, + /* 20 */ 1438, 1468, 1533, 1548, 1563, 1643, 1661, 1686, 1756, 1792, + /* 30 */ 1823, 1898, 1918, 1934, 1991, 2011, 2029, 2049, 2087, 2124, + /* 40 */ 2144, 2160, 2253, 2272, 2289, 2346, 2367, 2384, 2404, 2442, + /* 50 */ 2479, -311, -218, -426, 72, -419, 284, 326, 525, -173, + /* 60 */ 56, 762, -382, -439, -258, 122, 246, -464, -301, 125, + /* 70 */ -325, -327, 51, -359, -203, -336, -219, 113, -91, -75, + /* 80 */ -67, 385, 421, 438, 477, -135, 296, 232, 504, 550, + /* 90 */ 678, 301, -55, -317, 683, 687, -375, 128, 690, 309, + /* 100 */ 749, 162, 805, 808, 397, 871, 880, 400, 803, 428, + /* 110 */ 419, 443, 884, -313, -423, -423, 316, -321, -44, 50, + /* 120 */ 171, 287, 319, 356, 500, 503, 511, 519, 533, 640, + /* 130 */ 644, 652, 653, 668, 670, 754, 802, -186, -23, 21, + /* 140 */ -195, 454, 594, 563, -23, 415, 786, 173, -393, 144, + /* 150 */ 314, 868, 227, 363, -392, 554, 601, 469, 700, 618, + /* 160 */ 769, 848, 883, 408, 566, 595, 613, 706, 812, 818, + /* 170 */ 906, 812, 465, 931, 943, 896, 810, 834, 846, 978, + /* 180 */ 961, 961, 979, 999, 966, 1027, 973, 900, 902, 908, + /* 190 */ 982, 921, 961, 1042, 993, 1048, 1010, 985, 997, 1000, + /* 200 */ 961, 942, 942, 923, 942, 955, 957, 1055, 1016, 1001, + /* 210 */ 1009, 1038, 1036, 1111, 1045, 1113, 1056, 1127, 1133, 1086, + /* 220 */ 1136, 1089, 1096, 1144, 1147, 1145, 1099, 1103, 1105, 1106, + /* 230 */ 1138, 1149, 1158, 1161, 1174, 1175, 1177, 1186, 1183, 1190, + /* 240 */ 1187, 1109, 1178, 1179, 1148, 1181, 1193, 1131, 1189, 1197, + /* 250 */ 1192, 1151, 1194, 1195, 1202, 1200, 1212, 1182, 1184, 1198, + /* 260 */ 1199, 1204, 1205, 1210, 1218, 1222, 1223, 1227, 1214, 1219, + /* 270 */ 1225, 1231, 1209, 1216, 1217, 1206, 1207, 1208, 1254, 1226, + /* 280 */ 1201, 1215, 1224, 1258, 1203, 1269, 1230, 1164, 1232, 1171, + /* 290 */ 1233, 1170, 1173, 1220, 1180, 1213, 1236, 1244, 1238, 1176, + /* 300 */ 1229, 942, 1316, 1235, 1242, 1245, 1321, 1320, 1327, 1270, + /* 310 */ 1294, 1298, 1299, 1301, 1272, 1303, 1286, 1336, 1323, 1342, + /* 320 */ 1359, 1259, 1333, 1330, 1368, 1363, 1394, 1393, 1392, 1328, + /* 330 */ 1315, 1335, 1337, 1367, 1375, 1378, 1397, 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 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 10 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 20 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 30 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 40 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 50 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 60 */ 1905, 2245, 1905, 1905, 2208, 1905, 1905, 1905, 1905, 1905, + /* 70 */ 1905, 1905, 1905, 1905, 1905, 1905, 2215, 1905, 1905, 1905, + /* 80 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 90 */ 1905, 1905, 1905, 1905, 1905, 1905, 2004, 1905, 1905, 1905, + /* 100 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 110 */ 1905, 1905, 1905, 2002, 2448, 1905, 1905, 1905, 1905, 1905, + /* 120 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 130 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 2460, 1905, + /* 140 */ 1905, 1976, 1976, 1905, 2460, 2460, 2460, 2002, 2420, 2420, + /* 150 */ 1905, 1905, 2004, 2283, 1905, 1905, 1905, 1905, 1905, 1905, + /* 160 */ 1905, 1905, 2127, 1935, 1905, 1905, 1905, 1905, 2151, 1905, + /* 170 */ 1905, 1905, 2271, 1905, 1905, 2489, 2551, 1905, 2492, 1905, + /* 180 */ 1905, 1905, 1905, 1905, 2220, 1905, 2479, 1905, 1905, 1905, + /* 190 */ 1905, 1905, 1905, 1905, 1905, 1905, 2080, 2265, 1905, 1905, + /* 200 */ 1905, 2452, 2466, 2535, 2453, 2450, 2473, 1905, 2483, 1905, + /* 210 */ 2308, 1905, 2297, 2004, 1905, 2004, 2258, 2203, 1905, 2213, + /* 220 */ 1905, 2213, 2210, 1905, 1905, 1905, 2213, 2210, 2210, 2210, + /* 230 */ 2069, 2065, 1905, 2063, 1905, 1905, 1905, 1905, 1960, 1905, + /* 240 */ 1960, 1905, 2004, 2004, 1905, 2004, 1905, 1905, 2004, 1905, + /* 250 */ 2004, 1905, 2004, 2004, 1905, 2004, 1905, 1905, 1905, 1905, + /* 260 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 270 */ 1905, 1905, 1905, 1905, 1905, 2295, 2281, 1905, 2002, 1905, + /* 280 */ 2269, 2267, 1905, 2002, 2483, 1905, 1905, 2505, 2500, 2505, + /* 290 */ 2500, 2519, 2515, 2505, 2524, 2521, 2485, 2483, 2554, 2541, + /* 300 */ 2537, 2466, 1905, 1905, 2471, 2469, 1905, 2002, 2002, 2500, + /* 310 */ 1905, 1905, 1905, 1905, 2500, 1905, 1905, 2002, 1905, 2002, + /* 320 */ 1905, 1905, 2096, 1905, 1905, 2002, 1905, 1944, 1905, 2260, + /* 330 */ 2286, 2241, 2241, 2130, 2130, 2130, 2005, 1910, 1905, 1905, + /* 340 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 350 */ 2518, 2517, 2373, 1905, 2424, 2423, 2422, 2413, 2372, 2092, + /* 360 */ 1905, 1905, 2371, 2370, 1905, 1905, 1905, 1905, 1905, 1905, + /* 370 */ 1905, 1905, 1905, 2232, 2231, 2364, 1905, 1905, 2365, 2363, + /* 380 */ 2362, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 390 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 400 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 2538, 2542, 1905, + /* 410 */ 1905, 1905, 1905, 1905, 1905, 2449, 1905, 1905, 1905, 2344, + /* 420 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 430 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 440 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 450 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 460 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 470 */ 1905, 1905, 1905, 1905, 2209, 1905, 1905, 1905, 1905, 1905, + /* 480 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 490 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 500 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 510 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 520 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 530 */ 1905, 1905, 1905, 1905, 1905, 1905, 2224, 1905, 1905, 1905, + /* 540 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 550 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 560 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1949, 2351, + /* 570 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 580 */ 1905, 1905, 1905, 2354, 1905, 1905, 1905, 1905, 1905, 1905, + /* 590 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 600 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 610 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 620 */ 1905, 1905, 1905, 1905, 2044, 2043, 1905, 1905, 1905, 1905, + /* 630 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 640 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 650 */ 1905, 1905, 2355, 1905, 1905, 1905, 1905, 1905, 2346, 1905, + /* 660 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 670 */ 1905, 1905, 1905, 1905, 1905, 2534, 2486, 1905, 1905, 1905, + /* 680 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 690 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 2344, + /* 700 */ 1905, 2516, 1905, 1905, 2532, 1905, 2536, 1905, 1905, 1905, + /* 710 */ 1905, 1905, 1905, 1905, 2459, 2455, 1905, 1905, 2451, 1905, + /* 720 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 730 */ 1905, 1905, 1905, 1905, 1905, 1905, 2343, 1905, 2410, 1905, + /* 740 */ 1905, 1905, 2444, 1905, 1905, 2395, 1905, 1905, 1905, 1905, + /* 750 */ 1905, 1905, 1905, 1905, 1905, 2355, 1905, 2358, 1905, 1905, + /* 760 */ 1905, 1905, 1905, 2124, 1905, 1905, 1905, 1905, 1905, 1905, + /* 770 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 2108, + /* 780 */ 2106, 2105, 2104, 1905, 2137, 1905, 1905, 1905, 2133, 2132, + /* 790 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 800 */ 1905, 1905, 1905, 1905, 1905, 1905, 2023, 1905, 1905, 1905, + /* 810 */ 1905, 1905, 1905, 1905, 1905, 2015, 1905, 2014, 1905, 1905, + /* 820 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 830 */ 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, 1905, + /* 840 */ 1905, 1905, 1905, 1905, 1905, 1934, 1905, 1905, 1905, 1905, + /* 850 */ 1905, 1905, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1217,7 +1540,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* BWLIMIT => nothing */ 0, /* START => nothing */ 0, /* TIMESTAMP => nothing */ - 300, /* END => ABORT */ + 301, /* END => ABORT */ 0, /* TABLE => nothing */ 0, /* NK_LP => nothing */ 0, /* NK_RP => nothing */ @@ -1287,7 +1610,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* VNODES => nothing */ 0, /* ALIVE => nothing */ 0, /* VIEWS => nothing */ - 300, /* VIEW => ABORT */ + 301, /* VIEW => ABORT */ 0, /* COMPACTS => nothing */ 0, /* NORMAL => nothing */ 0, /* CHILD => nothing */ @@ -1393,6 +1716,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* SESSION => nothing */ 0, /* STATE_WINDOW => nothing */ 0, /* EVENT_WINDOW => nothing */ + 0, /* COUNT_WINDOW => nothing */ 0, /* SLIDING => nothing */ 0, /* FILL => nothing */ 0, /* VALUE => nothing */ @@ -1413,55 +1737,55 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ABORT => nothing */ - 300, /* AFTER => ABORT */ - 300, /* ATTACH => ABORT */ - 300, /* BEFORE => ABORT */ - 300, /* BEGIN => ABORT */ - 300, /* BITAND => ABORT */ - 300, /* BITNOT => ABORT */ - 300, /* BITOR => ABORT */ - 300, /* BLOCKS => ABORT */ - 300, /* CHANGE => ABORT */ - 300, /* COMMA => ABORT */ - 300, /* CONCAT => ABORT */ - 300, /* CONFLICT => ABORT */ - 300, /* COPY => ABORT */ - 300, /* DEFERRED => ABORT */ - 300, /* DELIMITERS => ABORT */ - 300, /* DETACH => ABORT */ - 300, /* DIVIDE => ABORT */ - 300, /* DOT => ABORT */ - 300, /* EACH => ABORT */ - 300, /* FAIL => ABORT */ - 300, /* FILE => ABORT */ - 300, /* FOR => ABORT */ - 300, /* GLOB => ABORT */ - 300, /* ID => ABORT */ - 300, /* IMMEDIATE => ABORT */ - 300, /* IMPORT => ABORT */ - 300, /* INITIALLY => ABORT */ - 300, /* INSTEAD => ABORT */ - 300, /* ISNULL => ABORT */ - 300, /* KEY => ABORT */ - 300, /* MODULES => ABORT */ - 300, /* NK_BITNOT => ABORT */ - 300, /* NK_SEMI => ABORT */ - 300, /* NOTNULL => ABORT */ - 300, /* OF => ABORT */ - 300, /* PLUS => ABORT */ - 300, /* PRIVILEGE => ABORT */ - 300, /* RAISE => ABORT */ - 300, /* RESTRICT => ABORT */ - 300, /* ROW => ABORT */ - 300, /* SEMI => ABORT */ - 300, /* STAR => ABORT */ - 300, /* STATEMENT => ABORT */ - 300, /* STRICT => ABORT */ - 300, /* STRING => ABORT */ - 300, /* TIMES => ABORT */ - 300, /* VALUES => ABORT */ - 300, /* VARIABLE => ABORT */ - 300, /* WAL => ABORT */ + 301, /* AFTER => ABORT */ + 301, /* ATTACH => ABORT */ + 301, /* BEFORE => ABORT */ + 301, /* BEGIN => ABORT */ + 301, /* BITAND => ABORT */ + 301, /* BITNOT => ABORT */ + 301, /* BITOR => ABORT */ + 301, /* BLOCKS => ABORT */ + 301, /* CHANGE => ABORT */ + 301, /* COMMA => ABORT */ + 301, /* CONCAT => ABORT */ + 301, /* CONFLICT => ABORT */ + 301, /* COPY => ABORT */ + 301, /* DEFERRED => ABORT */ + 301, /* DELIMITERS => ABORT */ + 301, /* DETACH => ABORT */ + 301, /* DIVIDE => ABORT */ + 301, /* DOT => ABORT */ + 301, /* EACH => ABORT */ + 301, /* FAIL => ABORT */ + 301, /* FILE => ABORT */ + 301, /* FOR => ABORT */ + 301, /* GLOB => ABORT */ + 301, /* ID => ABORT */ + 301, /* IMMEDIATE => ABORT */ + 301, /* IMPORT => ABORT */ + 301, /* INITIALLY => ABORT */ + 301, /* INSTEAD => ABORT */ + 301, /* ISNULL => ABORT */ + 301, /* KEY => ABORT */ + 301, /* MODULES => ABORT */ + 301, /* NK_BITNOT => ABORT */ + 301, /* NK_SEMI => ABORT */ + 301, /* NOTNULL => ABORT */ + 301, /* OF => ABORT */ + 301, /* PLUS => ABORT */ + 301, /* PRIVILEGE => ABORT */ + 301, /* RAISE => ABORT */ + 301, /* RESTRICT => ABORT */ + 301, /* ROW => ABORT */ + 301, /* SEMI => ABORT */ + 301, /* STAR => ABORT */ + 301, /* STATEMENT => ABORT */ + 301, /* STRICT => ABORT */ + 301, /* STRING => ABORT */ + 301, /* TIMES => ABORT */ + 301, /* VALUES => ABORT */ + 301, /* VARIABLE => ABORT */ + 301, /* WAL => ABORT */ }; #endif /* YYFALLBACK */ @@ -1513,6 +1837,7 @@ struct yyParser { }; typedef struct yyParser yyParser; +#include #ifndef NDEBUG #include static FILE *yyTraceFILE = 0; @@ -1830,236 +2155,237 @@ static const char *const yyTokenName[] = { /* 278 */ "SESSION", /* 279 */ "STATE_WINDOW", /* 280 */ "EVENT_WINDOW", - /* 281 */ "SLIDING", - /* 282 */ "FILL", - /* 283 */ "VALUE", - /* 284 */ "VALUE_F", - /* 285 */ "NONE", - /* 286 */ "PREV", - /* 287 */ "NULL_F", - /* 288 */ "LINEAR", - /* 289 */ "NEXT", - /* 290 */ "HAVING", - /* 291 */ "RANGE", - /* 292 */ "EVERY", - /* 293 */ "ORDER", - /* 294 */ "SLIMIT", - /* 295 */ "SOFFSET", - /* 296 */ "LIMIT", - /* 297 */ "OFFSET", - /* 298 */ "ASC", - /* 299 */ "NULLS", - /* 300 */ "ABORT", - /* 301 */ "AFTER", - /* 302 */ "ATTACH", - /* 303 */ "BEFORE", - /* 304 */ "BEGIN", - /* 305 */ "BITAND", - /* 306 */ "BITNOT", - /* 307 */ "BITOR", - /* 308 */ "BLOCKS", - /* 309 */ "CHANGE", - /* 310 */ "COMMA", - /* 311 */ "CONCAT", - /* 312 */ "CONFLICT", - /* 313 */ "COPY", - /* 314 */ "DEFERRED", - /* 315 */ "DELIMITERS", - /* 316 */ "DETACH", - /* 317 */ "DIVIDE", - /* 318 */ "DOT", - /* 319 */ "EACH", - /* 320 */ "FAIL", - /* 321 */ "FILE", - /* 322 */ "FOR", - /* 323 */ "GLOB", - /* 324 */ "ID", - /* 325 */ "IMMEDIATE", - /* 326 */ "IMPORT", - /* 327 */ "INITIALLY", - /* 328 */ "INSTEAD", - /* 329 */ "ISNULL", - /* 330 */ "KEY", - /* 331 */ "MODULES", - /* 332 */ "NK_BITNOT", - /* 333 */ "NK_SEMI", - /* 334 */ "NOTNULL", - /* 335 */ "OF", - /* 336 */ "PLUS", - /* 337 */ "PRIVILEGE", - /* 338 */ "RAISE", - /* 339 */ "RESTRICT", - /* 340 */ "ROW", - /* 341 */ "SEMI", - /* 342 */ "STAR", - /* 343 */ "STATEMENT", - /* 344 */ "STRICT", - /* 345 */ "STRING", - /* 346 */ "TIMES", - /* 347 */ "VALUES", - /* 348 */ "VARIABLE", - /* 349 */ "WAL", - /* 350 */ "cmd", - /* 351 */ "account_options", - /* 352 */ "alter_account_options", - /* 353 */ "literal", - /* 354 */ "alter_account_option", - /* 355 */ "ip_range_list", - /* 356 */ "white_list", - /* 357 */ "white_list_opt", - /* 358 */ "user_name", - /* 359 */ "sysinfo_opt", - /* 360 */ "privileges", - /* 361 */ "priv_level", - /* 362 */ "with_opt", - /* 363 */ "priv_type_list", - /* 364 */ "priv_type", - /* 365 */ "db_name", - /* 366 */ "table_name", - /* 367 */ "topic_name", - /* 368 */ "search_condition", - /* 369 */ "dnode_endpoint", - /* 370 */ "force_opt", - /* 371 */ "unsafe_opt", - /* 372 */ "not_exists_opt", - /* 373 */ "db_options", - /* 374 */ "exists_opt", - /* 375 */ "alter_db_options", - /* 376 */ "speed_opt", - /* 377 */ "start_opt", - /* 378 */ "end_opt", - /* 379 */ "integer_list", - /* 380 */ "variable_list", - /* 381 */ "retention_list", - /* 382 */ "signed", - /* 383 */ "alter_db_option", - /* 384 */ "retention", - /* 385 */ "full_table_name", - /* 386 */ "column_def_list", - /* 387 */ "tags_def_opt", - /* 388 */ "table_options", - /* 389 */ "multi_create_clause", - /* 390 */ "tags_def", - /* 391 */ "multi_drop_clause", - /* 392 */ "alter_table_clause", - /* 393 */ "alter_table_options", - /* 394 */ "column_name", - /* 395 */ "type_name", - /* 396 */ "signed_literal", - /* 397 */ "create_subtable_clause", - /* 398 */ "specific_cols_opt", - /* 399 */ "expression_list", - /* 400 */ "drop_table_clause", - /* 401 */ "col_name_list", - /* 402 */ "column_def", - /* 403 */ "duration_list", - /* 404 */ "rollup_func_list", - /* 405 */ "alter_table_option", - /* 406 */ "duration_literal", - /* 407 */ "rollup_func_name", - /* 408 */ "function_name", - /* 409 */ "col_name", - /* 410 */ "db_kind_opt", - /* 411 */ "table_kind_db_name_cond_opt", - /* 412 */ "like_pattern_opt", - /* 413 */ "db_name_cond_opt", - /* 414 */ "table_name_cond", - /* 415 */ "from_db_opt", - /* 416 */ "tag_list_opt", - /* 417 */ "table_kind", - /* 418 */ "tag_item", - /* 419 */ "column_alias", - /* 420 */ "index_options", - /* 421 */ "full_index_name", - /* 422 */ "index_name", - /* 423 */ "func_list", - /* 424 */ "sliding_opt", - /* 425 */ "sma_stream_opt", - /* 426 */ "func", - /* 427 */ "sma_func_name", - /* 428 */ "with_meta", - /* 429 */ "query_or_subquery", - /* 430 */ "where_clause_opt", - /* 431 */ "cgroup_name", - /* 432 */ "analyze_opt", - /* 433 */ "explain_options", - /* 434 */ "insert_query", - /* 435 */ "or_replace_opt", - /* 436 */ "agg_func_opt", - /* 437 */ "bufsize_opt", - /* 438 */ "language_opt", - /* 439 */ "full_view_name", - /* 440 */ "view_name", - /* 441 */ "stream_name", - /* 442 */ "stream_options", - /* 443 */ "col_list_opt", - /* 444 */ "tag_def_or_ref_opt", - /* 445 */ "subtable_opt", - /* 446 */ "ignore_opt", - /* 447 */ "expression", - /* 448 */ "on_vgroup_id", - /* 449 */ "dnode_list", - /* 450 */ "literal_func", - /* 451 */ "literal_list", - /* 452 */ "table_alias", - /* 453 */ "expr_or_subquery", - /* 454 */ "pseudo_column", - /* 455 */ "column_reference", - /* 456 */ "function_expression", - /* 457 */ "case_when_expression", - /* 458 */ "star_func", - /* 459 */ "star_func_para_list", - /* 460 */ "noarg_func", - /* 461 */ "other_para_list", - /* 462 */ "star_func_para", - /* 463 */ "when_then_list", - /* 464 */ "case_when_else_opt", - /* 465 */ "common_expression", - /* 466 */ "when_then_expr", - /* 467 */ "predicate", - /* 468 */ "compare_op", - /* 469 */ "in_op", - /* 470 */ "in_predicate_value", - /* 471 */ "boolean_value_expression", - /* 472 */ "boolean_primary", - /* 473 */ "from_clause_opt", - /* 474 */ "table_reference_list", - /* 475 */ "table_reference", - /* 476 */ "table_primary", - /* 477 */ "joined_table", - /* 478 */ "alias_opt", - /* 479 */ "subquery", - /* 480 */ "parenthesized_joined_table", - /* 481 */ "join_type", - /* 482 */ "query_specification", - /* 483 */ "hint_list", - /* 484 */ "set_quantifier_opt", - /* 485 */ "tag_mode_opt", - /* 486 */ "select_list", - /* 487 */ "partition_by_clause_opt", - /* 488 */ "range_opt", - /* 489 */ "every_opt", - /* 490 */ "fill_opt", - /* 491 */ "twindow_clause_opt", - /* 492 */ "group_by_clause_opt", - /* 493 */ "having_clause_opt", - /* 494 */ "select_item", - /* 495 */ "partition_list", - /* 496 */ "partition_item", - /* 497 */ "interval_sliding_duration_literal", - /* 498 */ "fill_mode", - /* 499 */ "group_by_list", - /* 500 */ "query_expression", - /* 501 */ "query_simple", - /* 502 */ "order_by_clause_opt", - /* 503 */ "slimit_clause_opt", - /* 504 */ "limit_clause_opt", - /* 505 */ "union_query_expression", - /* 506 */ "query_simple_or_subquery", - /* 507 */ "sort_specification_list", - /* 508 */ "sort_specification", - /* 509 */ "ordering_specification_opt", - /* 510 */ "null_ordering_opt", + /* 281 */ "COUNT_WINDOW", + /* 282 */ "SLIDING", + /* 283 */ "FILL", + /* 284 */ "VALUE", + /* 285 */ "VALUE_F", + /* 286 */ "NONE", + /* 287 */ "PREV", + /* 288 */ "NULL_F", + /* 289 */ "LINEAR", + /* 290 */ "NEXT", + /* 291 */ "HAVING", + /* 292 */ "RANGE", + /* 293 */ "EVERY", + /* 294 */ "ORDER", + /* 295 */ "SLIMIT", + /* 296 */ "SOFFSET", + /* 297 */ "LIMIT", + /* 298 */ "OFFSET", + /* 299 */ "ASC", + /* 300 */ "NULLS", + /* 301 */ "ABORT", + /* 302 */ "AFTER", + /* 303 */ "ATTACH", + /* 304 */ "BEFORE", + /* 305 */ "BEGIN", + /* 306 */ "BITAND", + /* 307 */ "BITNOT", + /* 308 */ "BITOR", + /* 309 */ "BLOCKS", + /* 310 */ "CHANGE", + /* 311 */ "COMMA", + /* 312 */ "CONCAT", + /* 313 */ "CONFLICT", + /* 314 */ "COPY", + /* 315 */ "DEFERRED", + /* 316 */ "DELIMITERS", + /* 317 */ "DETACH", + /* 318 */ "DIVIDE", + /* 319 */ "DOT", + /* 320 */ "EACH", + /* 321 */ "FAIL", + /* 322 */ "FILE", + /* 323 */ "FOR", + /* 324 */ "GLOB", + /* 325 */ "ID", + /* 326 */ "IMMEDIATE", + /* 327 */ "IMPORT", + /* 328 */ "INITIALLY", + /* 329 */ "INSTEAD", + /* 330 */ "ISNULL", + /* 331 */ "KEY", + /* 332 */ "MODULES", + /* 333 */ "NK_BITNOT", + /* 334 */ "NK_SEMI", + /* 335 */ "NOTNULL", + /* 336 */ "OF", + /* 337 */ "PLUS", + /* 338 */ "PRIVILEGE", + /* 339 */ "RAISE", + /* 340 */ "RESTRICT", + /* 341 */ "ROW", + /* 342 */ "SEMI", + /* 343 */ "STAR", + /* 344 */ "STATEMENT", + /* 345 */ "STRICT", + /* 346 */ "STRING", + /* 347 */ "TIMES", + /* 348 */ "VALUES", + /* 349 */ "VARIABLE", + /* 350 */ "WAL", + /* 351 */ "cmd", + /* 352 */ "account_options", + /* 353 */ "alter_account_options", + /* 354 */ "literal", + /* 355 */ "alter_account_option", + /* 356 */ "ip_range_list", + /* 357 */ "white_list", + /* 358 */ "white_list_opt", + /* 359 */ "user_name", + /* 360 */ "sysinfo_opt", + /* 361 */ "privileges", + /* 362 */ "priv_level", + /* 363 */ "with_opt", + /* 364 */ "priv_type_list", + /* 365 */ "priv_type", + /* 366 */ "db_name", + /* 367 */ "table_name", + /* 368 */ "topic_name", + /* 369 */ "search_condition", + /* 370 */ "dnode_endpoint", + /* 371 */ "force_opt", + /* 372 */ "unsafe_opt", + /* 373 */ "not_exists_opt", + /* 374 */ "db_options", + /* 375 */ "exists_opt", + /* 376 */ "alter_db_options", + /* 377 */ "speed_opt", + /* 378 */ "start_opt", + /* 379 */ "end_opt", + /* 380 */ "integer_list", + /* 381 */ "variable_list", + /* 382 */ "retention_list", + /* 383 */ "signed", + /* 384 */ "alter_db_option", + /* 385 */ "retention", + /* 386 */ "full_table_name", + /* 387 */ "column_def_list", + /* 388 */ "tags_def_opt", + /* 389 */ "table_options", + /* 390 */ "multi_create_clause", + /* 391 */ "tags_def", + /* 392 */ "multi_drop_clause", + /* 393 */ "alter_table_clause", + /* 394 */ "alter_table_options", + /* 395 */ "column_name", + /* 396 */ "type_name", + /* 397 */ "signed_literal", + /* 398 */ "create_subtable_clause", + /* 399 */ "specific_cols_opt", + /* 400 */ "expression_list", + /* 401 */ "drop_table_clause", + /* 402 */ "col_name_list", + /* 403 */ "column_def", + /* 404 */ "duration_list", + /* 405 */ "rollup_func_list", + /* 406 */ "alter_table_option", + /* 407 */ "duration_literal", + /* 408 */ "rollup_func_name", + /* 409 */ "function_name", + /* 410 */ "col_name", + /* 411 */ "db_kind_opt", + /* 412 */ "table_kind_db_name_cond_opt", + /* 413 */ "like_pattern_opt", + /* 414 */ "db_name_cond_opt", + /* 415 */ "table_name_cond", + /* 416 */ "from_db_opt", + /* 417 */ "tag_list_opt", + /* 418 */ "table_kind", + /* 419 */ "tag_item", + /* 420 */ "column_alias", + /* 421 */ "index_options", + /* 422 */ "full_index_name", + /* 423 */ "index_name", + /* 424 */ "func_list", + /* 425 */ "sliding_opt", + /* 426 */ "sma_stream_opt", + /* 427 */ "func", + /* 428 */ "sma_func_name", + /* 429 */ "with_meta", + /* 430 */ "query_or_subquery", + /* 431 */ "where_clause_opt", + /* 432 */ "cgroup_name", + /* 433 */ "analyze_opt", + /* 434 */ "explain_options", + /* 435 */ "insert_query", + /* 436 */ "or_replace_opt", + /* 437 */ "agg_func_opt", + /* 438 */ "bufsize_opt", + /* 439 */ "language_opt", + /* 440 */ "full_view_name", + /* 441 */ "view_name", + /* 442 */ "stream_name", + /* 443 */ "stream_options", + /* 444 */ "col_list_opt", + /* 445 */ "tag_def_or_ref_opt", + /* 446 */ "subtable_opt", + /* 447 */ "ignore_opt", + /* 448 */ "expression", + /* 449 */ "on_vgroup_id", + /* 450 */ "dnode_list", + /* 451 */ "literal_func", + /* 452 */ "literal_list", + /* 453 */ "table_alias", + /* 454 */ "expr_or_subquery", + /* 455 */ "pseudo_column", + /* 456 */ "column_reference", + /* 457 */ "function_expression", + /* 458 */ "case_when_expression", + /* 459 */ "star_func", + /* 460 */ "star_func_para_list", + /* 461 */ "noarg_func", + /* 462 */ "other_para_list", + /* 463 */ "star_func_para", + /* 464 */ "when_then_list", + /* 465 */ "case_when_else_opt", + /* 466 */ "common_expression", + /* 467 */ "when_then_expr", + /* 468 */ "predicate", + /* 469 */ "compare_op", + /* 470 */ "in_op", + /* 471 */ "in_predicate_value", + /* 472 */ "boolean_value_expression", + /* 473 */ "boolean_primary", + /* 474 */ "from_clause_opt", + /* 475 */ "table_reference_list", + /* 476 */ "table_reference", + /* 477 */ "table_primary", + /* 478 */ "joined_table", + /* 479 */ "alias_opt", + /* 480 */ "subquery", + /* 481 */ "parenthesized_joined_table", + /* 482 */ "join_type", + /* 483 */ "query_specification", + /* 484 */ "hint_list", + /* 485 */ "set_quantifier_opt", + /* 486 */ "tag_mode_opt", + /* 487 */ "select_list", + /* 488 */ "partition_by_clause_opt", + /* 489 */ "range_opt", + /* 490 */ "every_opt", + /* 491 */ "fill_opt", + /* 492 */ "twindow_clause_opt", + /* 493 */ "group_by_clause_opt", + /* 494 */ "having_clause_opt", + /* 495 */ "select_item", + /* 496 */ "partition_list", + /* 497 */ "partition_item", + /* 498 */ "interval_sliding_duration_literal", + /* 499 */ "fill_mode", + /* 500 */ "group_by_list", + /* 501 */ "query_expression", + /* 502 */ "query_simple", + /* 503 */ "order_by_clause_opt", + /* 504 */ "slimit_clause_opt", + /* 505 */ "limit_clause_opt", + /* 506 */ "union_query_expression", + /* 507 */ "query_simple_or_subquery", + /* 508 */ "sort_specification_list", + /* 509 */ "sort_specification", + /* 510 */ "ordering_specification_opt", + /* 511 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -2357,7 +2683,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", @@ -2657,63 +2983,65 @@ static const char *const yyRuleName[] = { /* 587 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", /* 588 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", /* 589 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", - /* 590 */ "sliding_opt ::=", - /* 591 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", - /* 592 */ "interval_sliding_duration_literal ::= NK_VARIABLE", - /* 593 */ "interval_sliding_duration_literal ::= NK_STRING", - /* 594 */ "interval_sliding_duration_literal ::= NK_INTEGER", - /* 595 */ "fill_opt ::=", - /* 596 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 597 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", - /* 598 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", - /* 599 */ "fill_mode ::= NONE", - /* 600 */ "fill_mode ::= PREV", - /* 601 */ "fill_mode ::= NULL", - /* 602 */ "fill_mode ::= NULL_F", - /* 603 */ "fill_mode ::= LINEAR", - /* 604 */ "fill_mode ::= NEXT", - /* 605 */ "group_by_clause_opt ::=", - /* 606 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 607 */ "group_by_list ::= expr_or_subquery", - /* 608 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 609 */ "having_clause_opt ::=", - /* 610 */ "having_clause_opt ::= HAVING search_condition", - /* 611 */ "range_opt ::=", - /* 612 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 613 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", - /* 614 */ "every_opt ::=", - /* 615 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 616 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 617 */ "query_simple ::= query_specification", - /* 618 */ "query_simple ::= union_query_expression", - /* 619 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 620 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 621 */ "query_simple_or_subquery ::= query_simple", - /* 622 */ "query_simple_or_subquery ::= subquery", - /* 623 */ "query_or_subquery ::= query_expression", - /* 624 */ "query_or_subquery ::= subquery", - /* 625 */ "order_by_clause_opt ::=", - /* 626 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 627 */ "slimit_clause_opt ::=", - /* 628 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 629 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 630 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 631 */ "limit_clause_opt ::=", - /* 632 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 633 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 634 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 635 */ "subquery ::= NK_LP query_expression NK_RP", - /* 636 */ "subquery ::= NK_LP subquery NK_RP", - /* 637 */ "search_condition ::= common_expression", - /* 638 */ "sort_specification_list ::= sort_specification", - /* 639 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 640 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 641 */ "ordering_specification_opt ::=", - /* 642 */ "ordering_specification_opt ::= ASC", - /* 643 */ "ordering_specification_opt ::= DESC", - /* 644 */ "null_ordering_opt ::=", - /* 645 */ "null_ordering_opt ::= NULLS FIRST", - /* 646 */ "null_ordering_opt ::= NULLS LAST", + /* 590 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP", + /* 591 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 592 */ "sliding_opt ::=", + /* 593 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", + /* 594 */ "interval_sliding_duration_literal ::= NK_VARIABLE", + /* 595 */ "interval_sliding_duration_literal ::= NK_STRING", + /* 596 */ "interval_sliding_duration_literal ::= NK_INTEGER", + /* 597 */ "fill_opt ::=", + /* 598 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 599 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", + /* 600 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", + /* 601 */ "fill_mode ::= NONE", + /* 602 */ "fill_mode ::= PREV", + /* 603 */ "fill_mode ::= NULL", + /* 604 */ "fill_mode ::= NULL_F", + /* 605 */ "fill_mode ::= LINEAR", + /* 606 */ "fill_mode ::= NEXT", + /* 607 */ "group_by_clause_opt ::=", + /* 608 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 609 */ "group_by_list ::= expr_or_subquery", + /* 610 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 611 */ "having_clause_opt ::=", + /* 612 */ "having_clause_opt ::= HAVING search_condition", + /* 613 */ "range_opt ::=", + /* 614 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 615 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", + /* 616 */ "every_opt ::=", + /* 617 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 618 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 619 */ "query_simple ::= query_specification", + /* 620 */ "query_simple ::= union_query_expression", + /* 621 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 622 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 623 */ "query_simple_or_subquery ::= query_simple", + /* 624 */ "query_simple_or_subquery ::= subquery", + /* 625 */ "query_or_subquery ::= query_expression", + /* 626 */ "query_or_subquery ::= subquery", + /* 627 */ "order_by_clause_opt ::=", + /* 628 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 629 */ "slimit_clause_opt ::=", + /* 630 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 631 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 632 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 633 */ "limit_clause_opt ::=", + /* 634 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 635 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 636 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 637 */ "subquery ::= NK_LP query_expression NK_RP", + /* 638 */ "subquery ::= NK_LP subquery NK_RP", + /* 639 */ "search_condition ::= common_expression", + /* 640 */ "sort_specification_list ::= sort_specification", + /* 641 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 642 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 643 */ "ordering_specification_opt ::=", + /* 644 */ "ordering_specification_opt ::= ASC", + /* 645 */ "ordering_specification_opt ::= DESC", + /* 646 */ "null_ordering_opt ::=", + /* 647 */ "null_ordering_opt ::= NULLS FIRST", + /* 648 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2840,231 +3168,231 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 350: /* cmd */ - case 353: /* literal */ - case 362: /* with_opt */ - case 368: /* search_condition */ - case 373: /* db_options */ - case 375: /* alter_db_options */ - case 377: /* start_opt */ - case 378: /* end_opt */ - case 382: /* signed */ - case 384: /* retention */ - case 385: /* full_table_name */ - case 388: /* table_options */ - case 392: /* alter_table_clause */ - case 393: /* alter_table_options */ - case 396: /* signed_literal */ - case 397: /* create_subtable_clause */ - case 400: /* drop_table_clause */ - case 402: /* column_def */ - case 406: /* duration_literal */ - case 407: /* rollup_func_name */ - case 409: /* col_name */ - case 412: /* like_pattern_opt */ - case 413: /* db_name_cond_opt */ - case 414: /* table_name_cond */ - case 415: /* from_db_opt */ - case 418: /* tag_item */ - case 420: /* index_options */ - case 421: /* full_index_name */ - case 424: /* sliding_opt */ - case 425: /* sma_stream_opt */ - case 426: /* func */ - case 429: /* query_or_subquery */ - case 430: /* where_clause_opt */ - case 433: /* explain_options */ - case 434: /* insert_query */ - case 439: /* full_view_name */ - case 442: /* stream_options */ - case 445: /* subtable_opt */ - case 447: /* expression */ - case 450: /* literal_func */ - case 453: /* expr_or_subquery */ - case 454: /* pseudo_column */ - case 455: /* column_reference */ - case 456: /* function_expression */ - case 457: /* case_when_expression */ - case 462: /* star_func_para */ - case 464: /* case_when_else_opt */ - case 465: /* common_expression */ - case 466: /* when_then_expr */ - case 467: /* predicate */ - case 470: /* in_predicate_value */ - case 471: /* boolean_value_expression */ - case 472: /* boolean_primary */ - case 473: /* from_clause_opt */ - case 474: /* table_reference_list */ - case 475: /* table_reference */ - case 476: /* table_primary */ - case 477: /* joined_table */ - case 479: /* subquery */ - case 480: /* parenthesized_joined_table */ - case 482: /* query_specification */ - case 488: /* range_opt */ - case 489: /* every_opt */ - case 490: /* fill_opt */ - case 491: /* twindow_clause_opt */ - case 493: /* having_clause_opt */ - case 494: /* select_item */ - case 496: /* partition_item */ - case 497: /* interval_sliding_duration_literal */ - case 500: /* query_expression */ - case 501: /* query_simple */ - case 503: /* slimit_clause_opt */ - case 504: /* limit_clause_opt */ - case 505: /* union_query_expression */ - case 506: /* query_simple_or_subquery */ - case 508: /* sort_specification */ + case 351: /* cmd */ + case 354: /* literal */ + case 363: /* with_opt */ + case 369: /* search_condition */ + case 374: /* db_options */ + case 376: /* alter_db_options */ + case 378: /* start_opt */ + case 379: /* end_opt */ + case 383: /* signed */ + case 385: /* retention */ + case 386: /* full_table_name */ + case 389: /* table_options */ + case 393: /* alter_table_clause */ + case 394: /* alter_table_options */ + case 397: /* signed_literal */ + case 398: /* create_subtable_clause */ + case 401: /* drop_table_clause */ + case 403: /* column_def */ + case 407: /* duration_literal */ + case 408: /* rollup_func_name */ + case 410: /* col_name */ + case 413: /* like_pattern_opt */ + case 414: /* db_name_cond_opt */ + case 415: /* table_name_cond */ + case 416: /* from_db_opt */ + case 419: /* tag_item */ + case 421: /* index_options */ + case 422: /* full_index_name */ + case 425: /* sliding_opt */ + case 426: /* sma_stream_opt */ + case 427: /* func */ + case 430: /* query_or_subquery */ + case 431: /* where_clause_opt */ + case 434: /* explain_options */ + case 435: /* insert_query */ + case 440: /* full_view_name */ + case 443: /* stream_options */ + case 446: /* subtable_opt */ + case 448: /* expression */ + case 451: /* literal_func */ + case 454: /* expr_or_subquery */ + case 455: /* pseudo_column */ + case 456: /* column_reference */ + case 457: /* function_expression */ + case 458: /* case_when_expression */ + case 463: /* star_func_para */ + case 465: /* case_when_else_opt */ + case 466: /* common_expression */ + case 467: /* when_then_expr */ + case 468: /* predicate */ + case 471: /* in_predicate_value */ + case 472: /* boolean_value_expression */ + case 473: /* boolean_primary */ + case 474: /* from_clause_opt */ + case 475: /* table_reference_list */ + case 476: /* table_reference */ + case 477: /* table_primary */ + case 478: /* joined_table */ + case 480: /* subquery */ + case 481: /* parenthesized_joined_table */ + case 483: /* query_specification */ + case 489: /* range_opt */ + case 490: /* every_opt */ + case 491: /* fill_opt */ + case 492: /* twindow_clause_opt */ + case 494: /* having_clause_opt */ + case 495: /* select_item */ + case 497: /* partition_item */ + case 498: /* interval_sliding_duration_literal */ + case 501: /* query_expression */ + case 502: /* query_simple */ + case 504: /* slimit_clause_opt */ + case 505: /* limit_clause_opt */ + case 506: /* union_query_expression */ + case 507: /* query_simple_or_subquery */ + case 509: /* sort_specification */ { - nodesDestroyNode((yypminor->yy490)); + nodesDestroyNode((yypminor->yy360)); } break; - case 351: /* account_options */ - case 352: /* alter_account_options */ - case 354: /* alter_account_option */ - case 376: /* speed_opt */ - case 428: /* with_meta */ - case 437: /* bufsize_opt */ + case 352: /* account_options */ + case 353: /* alter_account_options */ + case 355: /* alter_account_option */ + case 377: /* speed_opt */ + case 429: /* with_meta */ + case 438: /* bufsize_opt */ { } break; - case 355: /* ip_range_list */ - case 356: /* white_list */ - case 357: /* white_list_opt */ - case 379: /* integer_list */ - case 380: /* variable_list */ - case 381: /* retention_list */ - case 386: /* column_def_list */ - case 387: /* tags_def_opt */ - case 389: /* multi_create_clause */ - case 390: /* tags_def */ - case 391: /* multi_drop_clause */ - case 398: /* specific_cols_opt */ - case 399: /* expression_list */ - case 401: /* col_name_list */ - case 403: /* duration_list */ - case 404: /* rollup_func_list */ - case 416: /* tag_list_opt */ - case 423: /* func_list */ - case 443: /* col_list_opt */ - case 444: /* tag_def_or_ref_opt */ - case 449: /* dnode_list */ - case 451: /* literal_list */ - case 459: /* star_func_para_list */ - case 461: /* other_para_list */ - case 463: /* when_then_list */ - case 483: /* hint_list */ - case 486: /* select_list */ - case 487: /* partition_by_clause_opt */ - case 492: /* group_by_clause_opt */ - case 495: /* partition_list */ - case 499: /* group_by_list */ - case 502: /* order_by_clause_opt */ - case 507: /* sort_specification_list */ + case 356: /* ip_range_list */ + case 357: /* white_list */ + case 358: /* white_list_opt */ + case 380: /* integer_list */ + case 381: /* variable_list */ + case 382: /* retention_list */ + case 387: /* column_def_list */ + case 388: /* tags_def_opt */ + case 390: /* multi_create_clause */ + case 391: /* tags_def */ + case 392: /* multi_drop_clause */ + case 399: /* specific_cols_opt */ + case 400: /* expression_list */ + case 402: /* col_name_list */ + case 404: /* duration_list */ + case 405: /* rollup_func_list */ + case 417: /* tag_list_opt */ + case 424: /* func_list */ + case 444: /* col_list_opt */ + case 445: /* tag_def_or_ref_opt */ + case 450: /* dnode_list */ + case 452: /* literal_list */ + case 460: /* star_func_para_list */ + case 462: /* other_para_list */ + case 464: /* when_then_list */ + case 484: /* hint_list */ + case 487: /* select_list */ + case 488: /* partition_by_clause_opt */ + case 493: /* group_by_clause_opt */ + case 496: /* partition_list */ + case 500: /* group_by_list */ + case 503: /* order_by_clause_opt */ + case 508: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy502)); + nodesDestroyList((yypminor->yy536)); } break; - case 358: /* user_name */ - case 365: /* db_name */ - case 366: /* table_name */ - case 367: /* topic_name */ - case 369: /* dnode_endpoint */ - case 394: /* column_name */ - case 408: /* function_name */ - case 419: /* column_alias */ - case 422: /* index_name */ - case 427: /* sma_func_name */ - case 431: /* cgroup_name */ - case 438: /* language_opt */ - case 440: /* view_name */ - case 441: /* stream_name */ - case 448: /* on_vgroup_id */ - case 452: /* table_alias */ - case 458: /* star_func */ - case 460: /* noarg_func */ - case 478: /* alias_opt */ + case 359: /* user_name */ + case 366: /* db_name */ + case 367: /* table_name */ + case 368: /* topic_name */ + case 370: /* dnode_endpoint */ + case 395: /* column_name */ + case 409: /* function_name */ + case 420: /* column_alias */ + case 423: /* index_name */ + case 428: /* sma_func_name */ + case 432: /* cgroup_name */ + case 439: /* language_opt */ + case 441: /* view_name */ + case 442: /* stream_name */ + case 449: /* on_vgroup_id */ + case 453: /* table_alias */ + case 459: /* star_func */ + case 461: /* noarg_func */ + case 479: /* alias_opt */ { } break; - case 359: /* sysinfo_opt */ + case 360: /* sysinfo_opt */ { } break; - case 360: /* privileges */ - case 363: /* priv_type_list */ - case 364: /* priv_type */ + case 361: /* privileges */ + case 364: /* priv_type_list */ + case 365: /* priv_type */ { } break; - case 361: /* priv_level */ + case 362: /* priv_level */ { } break; - case 370: /* force_opt */ - case 371: /* unsafe_opt */ - case 372: /* not_exists_opt */ - case 374: /* exists_opt */ - case 432: /* analyze_opt */ - case 435: /* or_replace_opt */ - case 436: /* agg_func_opt */ - case 446: /* ignore_opt */ - case 484: /* set_quantifier_opt */ - case 485: /* tag_mode_opt */ + case 371: /* force_opt */ + case 372: /* unsafe_opt */ + case 373: /* not_exists_opt */ + case 375: /* exists_opt */ + case 433: /* analyze_opt */ + case 436: /* or_replace_opt */ + case 437: /* agg_func_opt */ + case 447: /* ignore_opt */ + case 485: /* set_quantifier_opt */ + case 486: /* tag_mode_opt */ { } break; - case 383: /* alter_db_option */ - case 405: /* alter_table_option */ + case 384: /* alter_db_option */ + case 406: /* alter_table_option */ { } break; - case 395: /* type_name */ + case 396: /* type_name */ { } break; - case 410: /* db_kind_opt */ - case 417: /* table_kind */ + case 411: /* db_kind_opt */ + case 418: /* table_kind */ { } break; - case 411: /* table_kind_db_name_cond_opt */ + case 412: /* table_kind_db_name_cond_opt */ { } break; - case 468: /* compare_op */ - case 469: /* in_op */ + case 469: /* compare_op */ + case 470: /* in_op */ { } break; - case 481: /* join_type */ + case 482: /* join_type */ { } break; - case 498: /* fill_mode */ + case 499: /* fill_mode */ { } break; - case 509: /* ordering_specification_opt */ + case 510: /* ordering_specification_opt */ { } break; - case 510: /* null_ordering_opt */ + case 511: /* null_ordering_opt */ { } @@ -3233,7 +3561,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); @@ -3355,653 +3683,655 @@ static void yy_shift( /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side ** of that rule */ static const YYCODETYPE yyRuleInfoLhs[] = { - 350, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - 350, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - 351, /* (2) account_options ::= */ - 351, /* (3) account_options ::= account_options PPS literal */ - 351, /* (4) account_options ::= account_options TSERIES literal */ - 351, /* (5) account_options ::= account_options STORAGE literal */ - 351, /* (6) account_options ::= account_options STREAMS literal */ - 351, /* (7) account_options ::= account_options QTIME literal */ - 351, /* (8) account_options ::= account_options DBS literal */ - 351, /* (9) account_options ::= account_options USERS literal */ - 351, /* (10) account_options ::= account_options CONNS literal */ - 351, /* (11) account_options ::= account_options STATE literal */ - 352, /* (12) alter_account_options ::= alter_account_option */ - 352, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - 354, /* (14) alter_account_option ::= PASS literal */ - 354, /* (15) alter_account_option ::= PPS literal */ - 354, /* (16) alter_account_option ::= TSERIES literal */ - 354, /* (17) alter_account_option ::= STORAGE literal */ - 354, /* (18) alter_account_option ::= STREAMS literal */ - 354, /* (19) alter_account_option ::= QTIME literal */ - 354, /* (20) alter_account_option ::= DBS literal */ - 354, /* (21) alter_account_option ::= USERS literal */ - 354, /* (22) alter_account_option ::= CONNS literal */ - 354, /* (23) alter_account_option ::= STATE literal */ - 355, /* (24) ip_range_list ::= NK_STRING */ - 355, /* (25) ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ - 356, /* (26) white_list ::= HOST ip_range_list */ - 357, /* (27) white_list_opt ::= */ - 357, /* (28) white_list_opt ::= white_list */ - 350, /* (29) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ - 350, /* (30) cmd ::= ALTER USER user_name PASS NK_STRING */ - 350, /* (31) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - 350, /* (32) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - 350, /* (33) cmd ::= ALTER USER user_name ADD white_list */ - 350, /* (34) cmd ::= ALTER USER user_name DROP white_list */ - 350, /* (35) cmd ::= DROP USER user_name */ - 359, /* (36) sysinfo_opt ::= */ - 359, /* (37) sysinfo_opt ::= SYSINFO NK_INTEGER */ - 350, /* (38) cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ - 350, /* (39) cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ - 360, /* (40) privileges ::= ALL */ - 360, /* (41) privileges ::= priv_type_list */ - 360, /* (42) privileges ::= SUBSCRIBE */ - 363, /* (43) priv_type_list ::= priv_type */ - 363, /* (44) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - 364, /* (45) priv_type ::= READ */ - 364, /* (46) priv_type ::= WRITE */ - 364, /* (47) priv_type ::= ALTER */ - 361, /* (48) priv_level ::= NK_STAR NK_DOT NK_STAR */ - 361, /* (49) priv_level ::= db_name NK_DOT NK_STAR */ - 361, /* (50) priv_level ::= db_name NK_DOT table_name */ - 361, /* (51) priv_level ::= topic_name */ - 362, /* (52) with_opt ::= */ - 362, /* (53) with_opt ::= WITH search_condition */ - 350, /* (54) cmd ::= CREATE DNODE dnode_endpoint */ - 350, /* (55) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - 350, /* (56) cmd ::= DROP DNODE NK_INTEGER force_opt */ - 350, /* (57) cmd ::= DROP DNODE dnode_endpoint force_opt */ - 350, /* (58) cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ - 350, /* (59) cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ - 350, /* (60) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - 350, /* (61) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - 350, /* (62) cmd ::= ALTER ALL DNODES NK_STRING */ - 350, /* (63) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - 350, /* (64) cmd ::= RESTORE DNODE NK_INTEGER */ - 369, /* (65) dnode_endpoint ::= NK_STRING */ - 369, /* (66) dnode_endpoint ::= NK_ID */ - 369, /* (67) dnode_endpoint ::= NK_IPTOKEN */ - 370, /* (68) force_opt ::= */ - 370, /* (69) force_opt ::= FORCE */ - 371, /* (70) unsafe_opt ::= UNSAFE */ - 350, /* (71) cmd ::= ALTER CLUSTER NK_STRING */ - 350, /* (72) cmd ::= ALTER CLUSTER NK_STRING NK_STRING */ - 350, /* (73) cmd ::= ALTER LOCAL NK_STRING */ - 350, /* (74) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - 350, /* (75) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - 350, /* (76) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - 350, /* (77) cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ - 350, /* (78) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - 350, /* (79) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - 350, /* (80) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - 350, /* (81) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - 350, /* (82) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - 350, /* (83) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - 350, /* (84) cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ - 350, /* (85) cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ - 350, /* (86) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - 350, /* (87) cmd ::= DROP DATABASE exists_opt db_name */ - 350, /* (88) cmd ::= USE db_name */ - 350, /* (89) cmd ::= ALTER DATABASE db_name alter_db_options */ - 350, /* (90) cmd ::= FLUSH DATABASE db_name */ - 350, /* (91) cmd ::= TRIM DATABASE db_name speed_opt */ - 350, /* (92) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ - 372, /* (93) not_exists_opt ::= IF NOT EXISTS */ - 372, /* (94) not_exists_opt ::= */ - 374, /* (95) exists_opt ::= IF EXISTS */ - 374, /* (96) exists_opt ::= */ - 373, /* (97) db_options ::= */ - 373, /* (98) db_options ::= db_options BUFFER NK_INTEGER */ - 373, /* (99) db_options ::= db_options CACHEMODEL NK_STRING */ - 373, /* (100) db_options ::= db_options CACHESIZE NK_INTEGER */ - 373, /* (101) db_options ::= db_options COMP NK_INTEGER */ - 373, /* (102) db_options ::= db_options DURATION NK_INTEGER */ - 373, /* (103) db_options ::= db_options DURATION NK_VARIABLE */ - 373, /* (104) db_options ::= db_options MAXROWS NK_INTEGER */ - 373, /* (105) db_options ::= db_options MINROWS NK_INTEGER */ - 373, /* (106) db_options ::= db_options KEEP integer_list */ - 373, /* (107) db_options ::= db_options KEEP variable_list */ - 373, /* (108) db_options ::= db_options PAGES NK_INTEGER */ - 373, /* (109) db_options ::= db_options PAGESIZE NK_INTEGER */ - 373, /* (110) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ - 373, /* (111) db_options ::= db_options PRECISION NK_STRING */ - 373, /* (112) db_options ::= db_options REPLICA NK_INTEGER */ - 373, /* (113) db_options ::= db_options VGROUPS NK_INTEGER */ - 373, /* (114) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - 373, /* (115) db_options ::= db_options RETENTIONS retention_list */ - 373, /* (116) db_options ::= db_options SCHEMALESS NK_INTEGER */ - 373, /* (117) db_options ::= db_options WAL_LEVEL NK_INTEGER */ - 373, /* (118) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ - 373, /* (119) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ - 373, /* (120) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - 373, /* (121) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ - 373, /* (122) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - 373, /* (123) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ - 373, /* (124) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ - 373, /* (125) db_options ::= db_options STT_TRIGGER NK_INTEGER */ - 373, /* (126) db_options ::= db_options TABLE_PREFIX signed */ - 373, /* (127) db_options ::= db_options TABLE_SUFFIX signed */ - 373, /* (128) db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ - 375, /* (129) alter_db_options ::= alter_db_option */ - 375, /* (130) alter_db_options ::= alter_db_options alter_db_option */ - 383, /* (131) alter_db_option ::= BUFFER NK_INTEGER */ - 383, /* (132) alter_db_option ::= CACHEMODEL NK_STRING */ - 383, /* (133) alter_db_option ::= CACHESIZE NK_INTEGER */ - 383, /* (134) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ - 383, /* (135) alter_db_option ::= KEEP integer_list */ - 383, /* (136) alter_db_option ::= KEEP variable_list */ - 383, /* (137) alter_db_option ::= PAGES NK_INTEGER */ - 383, /* (138) alter_db_option ::= REPLICA NK_INTEGER */ - 383, /* (139) alter_db_option ::= WAL_LEVEL NK_INTEGER */ - 383, /* (140) alter_db_option ::= STT_TRIGGER NK_INTEGER */ - 383, /* (141) alter_db_option ::= MINROWS NK_INTEGER */ - 383, /* (142) alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ - 383, /* (143) alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - 383, /* (144) alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ - 383, /* (145) alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - 383, /* (146) alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ - 379, /* (147) integer_list ::= NK_INTEGER */ - 379, /* (148) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - 380, /* (149) variable_list ::= NK_VARIABLE */ - 380, /* (150) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - 381, /* (151) retention_list ::= retention */ - 381, /* (152) retention_list ::= retention_list NK_COMMA retention */ - 384, /* (153) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - 384, /* (154) retention ::= NK_MINUS NK_COLON NK_VARIABLE */ - 376, /* (155) speed_opt ::= */ - 376, /* (156) speed_opt ::= BWLIMIT NK_INTEGER */ - 377, /* (157) start_opt ::= */ - 377, /* (158) start_opt ::= START WITH NK_INTEGER */ - 377, /* (159) start_opt ::= START WITH NK_STRING */ - 377, /* (160) start_opt ::= START WITH TIMESTAMP NK_STRING */ - 378, /* (161) end_opt ::= */ - 378, /* (162) end_opt ::= END WITH NK_INTEGER */ - 378, /* (163) end_opt ::= END WITH NK_STRING */ - 378, /* (164) end_opt ::= END WITH TIMESTAMP NK_STRING */ - 350, /* (165) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - 350, /* (166) cmd ::= CREATE TABLE multi_create_clause */ - 350, /* (167) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - 350, /* (168) cmd ::= DROP TABLE multi_drop_clause */ - 350, /* (169) cmd ::= DROP STABLE exists_opt full_table_name */ - 350, /* (170) cmd ::= ALTER TABLE alter_table_clause */ - 350, /* (171) cmd ::= ALTER STABLE alter_table_clause */ - 392, /* (172) alter_table_clause ::= full_table_name alter_table_options */ - 392, /* (173) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - 392, /* (174) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - 392, /* (175) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - 392, /* (176) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - 392, /* (177) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - 392, /* (178) alter_table_clause ::= full_table_name DROP TAG column_name */ - 392, /* (179) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - 392, /* (180) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - 392, /* (181) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - 389, /* (182) multi_create_clause ::= create_subtable_clause */ - 389, /* (183) multi_create_clause ::= multi_create_clause create_subtable_clause */ - 397, /* (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 */ - 391, /* (185) multi_drop_clause ::= drop_table_clause */ - 391, /* (186) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ - 400, /* (187) drop_table_clause ::= exists_opt full_table_name */ - 398, /* (188) specific_cols_opt ::= */ - 398, /* (189) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - 385, /* (190) full_table_name ::= table_name */ - 385, /* (191) full_table_name ::= db_name NK_DOT table_name */ - 386, /* (192) column_def_list ::= column_def */ - 386, /* (193) column_def_list ::= column_def_list NK_COMMA column_def */ - 402, /* (194) column_def ::= column_name type_name */ - 395, /* (195) type_name ::= BOOL */ - 395, /* (196) type_name ::= TINYINT */ - 395, /* (197) type_name ::= SMALLINT */ - 395, /* (198) type_name ::= INT */ - 395, /* (199) type_name ::= INTEGER */ - 395, /* (200) type_name ::= BIGINT */ - 395, /* (201) type_name ::= FLOAT */ - 395, /* (202) type_name ::= DOUBLE */ - 395, /* (203) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - 395, /* (204) type_name ::= TIMESTAMP */ - 395, /* (205) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - 395, /* (206) type_name ::= TINYINT UNSIGNED */ - 395, /* (207) type_name ::= SMALLINT UNSIGNED */ - 395, /* (208) type_name ::= INT UNSIGNED */ - 395, /* (209) type_name ::= BIGINT UNSIGNED */ - 395, /* (210) type_name ::= JSON */ - 395, /* (211) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - 395, /* (212) type_name ::= MEDIUMBLOB */ - 395, /* (213) type_name ::= BLOB */ - 395, /* (214) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - 395, /* (215) type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ - 395, /* (216) type_name ::= DECIMAL */ - 395, /* (217) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - 395, /* (218) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 387, /* (219) tags_def_opt ::= */ - 387, /* (220) tags_def_opt ::= tags_def */ - 390, /* (221) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - 388, /* (222) table_options ::= */ - 388, /* (223) table_options ::= table_options COMMENT NK_STRING */ - 388, /* (224) table_options ::= table_options MAX_DELAY duration_list */ - 388, /* (225) table_options ::= table_options WATERMARK duration_list */ - 388, /* (226) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - 388, /* (227) table_options ::= table_options TTL NK_INTEGER */ - 388, /* (228) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - 388, /* (229) table_options ::= table_options DELETE_MARK duration_list */ - 393, /* (230) alter_table_options ::= alter_table_option */ - 393, /* (231) alter_table_options ::= alter_table_options alter_table_option */ - 405, /* (232) alter_table_option ::= COMMENT NK_STRING */ - 405, /* (233) alter_table_option ::= TTL NK_INTEGER */ - 403, /* (234) duration_list ::= duration_literal */ - 403, /* (235) duration_list ::= duration_list NK_COMMA duration_literal */ - 404, /* (236) rollup_func_list ::= rollup_func_name */ - 404, /* (237) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - 407, /* (238) rollup_func_name ::= function_name */ - 407, /* (239) rollup_func_name ::= FIRST */ - 407, /* (240) rollup_func_name ::= LAST */ - 401, /* (241) col_name_list ::= col_name */ - 401, /* (242) col_name_list ::= col_name_list NK_COMMA col_name */ - 409, /* (243) col_name ::= column_name */ - 350, /* (244) cmd ::= SHOW DNODES */ - 350, /* (245) cmd ::= SHOW USERS */ - 350, /* (246) cmd ::= SHOW USER PRIVILEGES */ - 350, /* (247) cmd ::= SHOW db_kind_opt DATABASES */ - 350, /* (248) cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ - 350, /* (249) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - 350, /* (250) cmd ::= SHOW db_name_cond_opt VGROUPS */ - 350, /* (251) cmd ::= SHOW MNODES */ - 350, /* (252) cmd ::= SHOW QNODES */ - 350, /* (253) cmd ::= SHOW FUNCTIONS */ - 350, /* (254) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - 350, /* (255) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ - 350, /* (256) cmd ::= SHOW STREAMS */ - 350, /* (257) cmd ::= SHOW ACCOUNTS */ - 350, /* (258) cmd ::= SHOW APPS */ - 350, /* (259) cmd ::= SHOW CONNECTIONS */ - 350, /* (260) cmd ::= SHOW LICENCES */ - 350, /* (261) cmd ::= SHOW GRANTS */ - 350, /* (262) cmd ::= SHOW GRANTS FULL */ - 350, /* (263) cmd ::= SHOW GRANTS LOGS */ - 350, /* (264) cmd ::= SHOW CLUSTER MACHINES */ - 350, /* (265) cmd ::= SHOW CREATE DATABASE db_name */ - 350, /* (266) cmd ::= SHOW CREATE TABLE full_table_name */ - 350, /* (267) cmd ::= SHOW CREATE STABLE full_table_name */ - 350, /* (268) cmd ::= SHOW QUERIES */ - 350, /* (269) cmd ::= SHOW SCORES */ - 350, /* (270) cmd ::= SHOW TOPICS */ - 350, /* (271) cmd ::= SHOW VARIABLES */ - 350, /* (272) cmd ::= SHOW CLUSTER VARIABLES */ - 350, /* (273) cmd ::= SHOW LOCAL VARIABLES */ - 350, /* (274) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ - 350, /* (275) cmd ::= SHOW BNODES */ - 350, /* (276) cmd ::= SHOW SNODES */ - 350, /* (277) cmd ::= SHOW CLUSTER */ - 350, /* (278) cmd ::= SHOW TRANSACTIONS */ - 350, /* (279) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - 350, /* (280) cmd ::= SHOW CONSUMERS */ - 350, /* (281) cmd ::= SHOW SUBSCRIPTIONS */ - 350, /* (282) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - 350, /* (283) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ - 350, /* (284) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ - 350, /* (285) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ - 350, /* (286) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ - 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, /* (291) cmd ::= SHOW CREATE VIEW full_table_name */ - 350, /* (292) cmd ::= SHOW COMPACTS */ - 350, /* (293) cmd ::= SHOW COMPACT NK_INTEGER */ - 411, /* (294) table_kind_db_name_cond_opt ::= */ - 411, /* (295) table_kind_db_name_cond_opt ::= table_kind */ - 411, /* (296) table_kind_db_name_cond_opt ::= db_name NK_DOT */ - 411, /* (297) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ - 417, /* (298) table_kind ::= NORMAL */ - 417, /* (299) table_kind ::= CHILD */ - 413, /* (300) db_name_cond_opt ::= */ - 413, /* (301) db_name_cond_opt ::= db_name NK_DOT */ - 412, /* (302) like_pattern_opt ::= */ - 412, /* (303) like_pattern_opt ::= LIKE NK_STRING */ - 414, /* (304) table_name_cond ::= table_name */ - 415, /* (305) from_db_opt ::= */ - 415, /* (306) from_db_opt ::= FROM db_name */ - 416, /* (307) tag_list_opt ::= */ - 416, /* (308) tag_list_opt ::= tag_item */ - 416, /* (309) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ - 418, /* (310) tag_item ::= TBNAME */ - 418, /* (311) tag_item ::= QTAGS */ - 418, /* (312) tag_item ::= column_name */ - 418, /* (313) tag_item ::= column_name column_alias */ - 418, /* (314) tag_item ::= column_name AS column_alias */ - 410, /* (315) db_kind_opt ::= */ - 410, /* (316) db_kind_opt ::= USER */ - 410, /* (317) db_kind_opt ::= SYSTEM */ - 350, /* (318) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ - 350, /* (319) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ - 350, /* (320) cmd ::= DROP INDEX exists_opt full_index_name */ - 421, /* (321) full_index_name ::= index_name */ - 421, /* (322) full_index_name ::= db_name NK_DOT index_name */ - 420, /* (323) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - 420, /* (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 */ - 423, /* (325) func_list ::= func */ - 423, /* (326) func_list ::= func_list NK_COMMA func */ - 426, /* (327) func ::= sma_func_name NK_LP expression_list NK_RP */ - 427, /* (328) sma_func_name ::= function_name */ - 427, /* (329) sma_func_name ::= COUNT */ - 427, /* (330) sma_func_name ::= FIRST */ - 427, /* (331) sma_func_name ::= LAST */ - 427, /* (332) sma_func_name ::= LAST_ROW */ - 425, /* (333) sma_stream_opt ::= */ - 425, /* (334) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - 425, /* (335) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - 425, /* (336) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - 428, /* (337) with_meta ::= AS */ - 428, /* (338) with_meta ::= WITH META AS */ - 428, /* (339) with_meta ::= ONLY META AS */ - 350, /* (340) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - 350, /* (341) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ - 350, /* (342) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ - 350, /* (343) cmd ::= DROP TOPIC exists_opt topic_name */ - 350, /* (344) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - 350, /* (345) cmd ::= DESC full_table_name */ - 350, /* (346) cmd ::= DESCRIBE full_table_name */ - 350, /* (347) cmd ::= RESET QUERY CACHE */ - 350, /* (348) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - 350, /* (349) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ - 432, /* (350) analyze_opt ::= */ - 432, /* (351) analyze_opt ::= ANALYZE */ - 433, /* (352) explain_options ::= */ - 433, /* (353) explain_options ::= explain_options VERBOSE NK_BOOL */ - 433, /* (354) explain_options ::= explain_options RATIO NK_FLOAT */ - 350, /* (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 */ - 350, /* (356) cmd ::= DROP FUNCTION exists_opt function_name */ - 436, /* (357) agg_func_opt ::= */ - 436, /* (358) agg_func_opt ::= AGGREGATE */ - 437, /* (359) bufsize_opt ::= */ - 437, /* (360) bufsize_opt ::= BUFSIZE NK_INTEGER */ - 438, /* (361) language_opt ::= */ - 438, /* (362) language_opt ::= LANGUAGE NK_STRING */ - 435, /* (363) or_replace_opt ::= */ - 435, /* (364) or_replace_opt ::= OR REPLACE */ - 350, /* (365) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ - 350, /* (366) cmd ::= DROP VIEW exists_opt full_view_name */ - 439, /* (367) full_view_name ::= view_name */ - 439, /* (368) full_view_name ::= db_name NK_DOT view_name */ - 350, /* (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 */ - 350, /* (370) cmd ::= DROP STREAM exists_opt stream_name */ - 350, /* (371) cmd ::= PAUSE STREAM exists_opt stream_name */ - 350, /* (372) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ - 443, /* (373) col_list_opt ::= */ - 443, /* (374) col_list_opt ::= NK_LP col_name_list NK_RP */ - 444, /* (375) tag_def_or_ref_opt ::= */ - 444, /* (376) tag_def_or_ref_opt ::= tags_def */ - 444, /* (377) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ - 442, /* (378) stream_options ::= */ - 442, /* (379) stream_options ::= stream_options TRIGGER AT_ONCE */ - 442, /* (380) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - 442, /* (381) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - 442, /* (382) stream_options ::= stream_options WATERMARK duration_literal */ - 442, /* (383) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - 442, /* (384) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - 442, /* (385) stream_options ::= stream_options DELETE_MARK duration_literal */ - 442, /* (386) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ - 445, /* (387) subtable_opt ::= */ - 445, /* (388) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - 446, /* (389) ignore_opt ::= */ - 446, /* (390) ignore_opt ::= IGNORE UNTREATED */ - 350, /* (391) cmd ::= KILL CONNECTION NK_INTEGER */ - 350, /* (392) cmd ::= KILL QUERY NK_STRING */ - 350, /* (393) cmd ::= KILL TRANSACTION NK_INTEGER */ - 350, /* (394) cmd ::= KILL COMPACT NK_INTEGER */ - 350, /* (395) cmd ::= BALANCE VGROUP */ - 350, /* (396) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ - 350, /* (397) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - 350, /* (398) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - 350, /* (399) cmd ::= SPLIT VGROUP NK_INTEGER */ - 448, /* (400) on_vgroup_id ::= */ - 448, /* (401) on_vgroup_id ::= ON NK_INTEGER */ - 449, /* (402) dnode_list ::= DNODE NK_INTEGER */ - 449, /* (403) dnode_list ::= dnode_list DNODE NK_INTEGER */ - 350, /* (404) cmd ::= DELETE FROM full_table_name where_clause_opt */ - 350, /* (405) cmd ::= query_or_subquery */ - 350, /* (406) cmd ::= insert_query */ - 434, /* (407) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - 434, /* (408) insert_query ::= INSERT INTO full_table_name query_or_subquery */ - 353, /* (409) literal ::= NK_INTEGER */ - 353, /* (410) literal ::= NK_FLOAT */ - 353, /* (411) literal ::= NK_STRING */ - 353, /* (412) literal ::= NK_BOOL */ - 353, /* (413) literal ::= TIMESTAMP NK_STRING */ - 353, /* (414) literal ::= duration_literal */ - 353, /* (415) literal ::= NULL */ - 353, /* (416) literal ::= NK_QUESTION */ - 406, /* (417) duration_literal ::= NK_VARIABLE */ - 382, /* (418) signed ::= NK_INTEGER */ - 382, /* (419) signed ::= NK_PLUS NK_INTEGER */ - 382, /* (420) signed ::= NK_MINUS NK_INTEGER */ - 382, /* (421) signed ::= NK_FLOAT */ - 382, /* (422) signed ::= NK_PLUS NK_FLOAT */ - 382, /* (423) signed ::= NK_MINUS NK_FLOAT */ - 396, /* (424) signed_literal ::= signed */ - 396, /* (425) signed_literal ::= NK_STRING */ - 396, /* (426) signed_literal ::= NK_BOOL */ - 396, /* (427) signed_literal ::= TIMESTAMP NK_STRING */ - 396, /* (428) signed_literal ::= duration_literal */ - 396, /* (429) signed_literal ::= NULL */ - 396, /* (430) signed_literal ::= literal_func */ - 396, /* (431) signed_literal ::= NK_QUESTION */ - 451, /* (432) literal_list ::= signed_literal */ - 451, /* (433) literal_list ::= literal_list NK_COMMA signed_literal */ - 365, /* (434) db_name ::= NK_ID */ - 366, /* (435) table_name ::= NK_ID */ - 394, /* (436) column_name ::= NK_ID */ - 408, /* (437) function_name ::= NK_ID */ - 440, /* (438) view_name ::= NK_ID */ - 452, /* (439) table_alias ::= NK_ID */ - 419, /* (440) column_alias ::= NK_ID */ - 419, /* (441) column_alias ::= NK_ALIAS */ - 358, /* (442) user_name ::= NK_ID */ - 367, /* (443) topic_name ::= NK_ID */ - 441, /* (444) stream_name ::= NK_ID */ - 431, /* (445) cgroup_name ::= NK_ID */ - 422, /* (446) index_name ::= NK_ID */ - 453, /* (447) expr_or_subquery ::= expression */ - 447, /* (448) expression ::= literal */ - 447, /* (449) expression ::= pseudo_column */ - 447, /* (450) expression ::= column_reference */ - 447, /* (451) expression ::= function_expression */ - 447, /* (452) expression ::= case_when_expression */ - 447, /* (453) expression ::= NK_LP expression NK_RP */ - 447, /* (454) expression ::= NK_PLUS expr_or_subquery */ - 447, /* (455) expression ::= NK_MINUS expr_or_subquery */ - 447, /* (456) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - 447, /* (457) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - 447, /* (458) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - 447, /* (459) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - 447, /* (460) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - 447, /* (461) expression ::= column_reference NK_ARROW NK_STRING */ - 447, /* (462) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - 447, /* (463) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - 399, /* (464) expression_list ::= expr_or_subquery */ - 399, /* (465) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - 455, /* (466) column_reference ::= column_name */ - 455, /* (467) column_reference ::= table_name NK_DOT column_name */ - 455, /* (468) column_reference ::= NK_ALIAS */ - 455, /* (469) column_reference ::= table_name NK_DOT NK_ALIAS */ - 454, /* (470) pseudo_column ::= ROWTS */ - 454, /* (471) pseudo_column ::= TBNAME */ - 454, /* (472) pseudo_column ::= table_name NK_DOT TBNAME */ - 454, /* (473) pseudo_column ::= QSTART */ - 454, /* (474) pseudo_column ::= QEND */ - 454, /* (475) pseudo_column ::= QDURATION */ - 454, /* (476) pseudo_column ::= WSTART */ - 454, /* (477) pseudo_column ::= WEND */ - 454, /* (478) pseudo_column ::= WDURATION */ - 454, /* (479) pseudo_column ::= IROWTS */ - 454, /* (480) pseudo_column ::= ISFILLED */ - 454, /* (481) pseudo_column ::= QTAGS */ - 456, /* (482) function_expression ::= function_name NK_LP expression_list NK_RP */ - 456, /* (483) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - 456, /* (484) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - 456, /* (485) function_expression ::= literal_func */ - 450, /* (486) literal_func ::= noarg_func NK_LP NK_RP */ - 450, /* (487) literal_func ::= NOW */ - 460, /* (488) noarg_func ::= NOW */ - 460, /* (489) noarg_func ::= TODAY */ - 460, /* (490) noarg_func ::= TIMEZONE */ - 460, /* (491) noarg_func ::= DATABASE */ - 460, /* (492) noarg_func ::= CLIENT_VERSION */ - 460, /* (493) noarg_func ::= SERVER_VERSION */ - 460, /* (494) noarg_func ::= SERVER_STATUS */ - 460, /* (495) noarg_func ::= CURRENT_USER */ - 460, /* (496) noarg_func ::= USER */ - 458, /* (497) star_func ::= COUNT */ - 458, /* (498) star_func ::= FIRST */ - 458, /* (499) star_func ::= LAST */ - 458, /* (500) star_func ::= LAST_ROW */ - 459, /* (501) star_func_para_list ::= NK_STAR */ - 459, /* (502) star_func_para_list ::= other_para_list */ - 461, /* (503) other_para_list ::= star_func_para */ - 461, /* (504) other_para_list ::= other_para_list NK_COMMA star_func_para */ - 462, /* (505) star_func_para ::= expr_or_subquery */ - 462, /* (506) star_func_para ::= table_name NK_DOT NK_STAR */ - 457, /* (507) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - 457, /* (508) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - 463, /* (509) when_then_list ::= when_then_expr */ - 463, /* (510) when_then_list ::= when_then_list when_then_expr */ - 466, /* (511) when_then_expr ::= WHEN common_expression THEN common_expression */ - 464, /* (512) case_when_else_opt ::= */ - 464, /* (513) case_when_else_opt ::= ELSE common_expression */ - 467, /* (514) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - 467, /* (515) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - 467, /* (516) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - 467, /* (517) predicate ::= expr_or_subquery IS NULL */ - 467, /* (518) predicate ::= expr_or_subquery IS NOT NULL */ - 467, /* (519) predicate ::= expr_or_subquery in_op in_predicate_value */ - 468, /* (520) compare_op ::= NK_LT */ - 468, /* (521) compare_op ::= NK_GT */ - 468, /* (522) compare_op ::= NK_LE */ - 468, /* (523) compare_op ::= NK_GE */ - 468, /* (524) compare_op ::= NK_NE */ - 468, /* (525) compare_op ::= NK_EQ */ - 468, /* (526) compare_op ::= LIKE */ - 468, /* (527) compare_op ::= NOT LIKE */ - 468, /* (528) compare_op ::= MATCH */ - 468, /* (529) compare_op ::= NMATCH */ - 468, /* (530) compare_op ::= CONTAINS */ - 469, /* (531) in_op ::= IN */ - 469, /* (532) in_op ::= NOT IN */ - 470, /* (533) in_predicate_value ::= NK_LP literal_list NK_RP */ - 471, /* (534) boolean_value_expression ::= boolean_primary */ - 471, /* (535) boolean_value_expression ::= NOT boolean_primary */ - 471, /* (536) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - 471, /* (537) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - 472, /* (538) boolean_primary ::= predicate */ - 472, /* (539) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - 465, /* (540) common_expression ::= expr_or_subquery */ - 465, /* (541) common_expression ::= boolean_value_expression */ - 473, /* (542) from_clause_opt ::= */ - 473, /* (543) from_clause_opt ::= FROM table_reference_list */ - 474, /* (544) table_reference_list ::= table_reference */ - 474, /* (545) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - 475, /* (546) table_reference ::= table_primary */ - 475, /* (547) table_reference ::= joined_table */ - 476, /* (548) table_primary ::= table_name alias_opt */ - 476, /* (549) table_primary ::= db_name NK_DOT table_name alias_opt */ - 476, /* (550) table_primary ::= subquery alias_opt */ - 476, /* (551) table_primary ::= parenthesized_joined_table */ - 478, /* (552) alias_opt ::= */ - 478, /* (553) alias_opt ::= table_alias */ - 478, /* (554) alias_opt ::= AS table_alias */ - 480, /* (555) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - 480, /* (556) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - 477, /* (557) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - 481, /* (558) join_type ::= */ - 481, /* (559) join_type ::= INNER */ - 482, /* (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 */ - 483, /* (561) hint_list ::= */ - 483, /* (562) hint_list ::= NK_HINT */ - 485, /* (563) tag_mode_opt ::= */ - 485, /* (564) tag_mode_opt ::= TAGS */ - 484, /* (565) set_quantifier_opt ::= */ - 484, /* (566) set_quantifier_opt ::= DISTINCT */ - 484, /* (567) set_quantifier_opt ::= ALL */ - 486, /* (568) select_list ::= select_item */ - 486, /* (569) select_list ::= select_list NK_COMMA select_item */ - 494, /* (570) select_item ::= NK_STAR */ - 494, /* (571) select_item ::= common_expression */ - 494, /* (572) select_item ::= common_expression column_alias */ - 494, /* (573) select_item ::= common_expression AS column_alias */ - 494, /* (574) select_item ::= table_name NK_DOT NK_STAR */ - 430, /* (575) where_clause_opt ::= */ - 430, /* (576) where_clause_opt ::= WHERE search_condition */ - 487, /* (577) partition_by_clause_opt ::= */ - 487, /* (578) partition_by_clause_opt ::= PARTITION BY partition_list */ - 495, /* (579) partition_list ::= partition_item */ - 495, /* (580) partition_list ::= partition_list NK_COMMA partition_item */ - 496, /* (581) partition_item ::= expr_or_subquery */ - 496, /* (582) partition_item ::= expr_or_subquery column_alias */ - 496, /* (583) partition_item ::= expr_or_subquery AS column_alias */ - 491, /* (584) twindow_clause_opt ::= */ - 491, /* (585) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ - 491, /* (586) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - 491, /* (587) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - 491, /* (588) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - 491, /* (589) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ - 424, /* (590) sliding_opt ::= */ - 424, /* (591) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ - 497, /* (592) interval_sliding_duration_literal ::= NK_VARIABLE */ - 497, /* (593) interval_sliding_duration_literal ::= NK_STRING */ - 497, /* (594) interval_sliding_duration_literal ::= NK_INTEGER */ - 490, /* (595) fill_opt ::= */ - 490, /* (596) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - 490, /* (597) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ - 490, /* (598) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ - 498, /* (599) fill_mode ::= NONE */ - 498, /* (600) fill_mode ::= PREV */ - 498, /* (601) fill_mode ::= NULL */ - 498, /* (602) fill_mode ::= NULL_F */ - 498, /* (603) fill_mode ::= LINEAR */ - 498, /* (604) fill_mode ::= NEXT */ - 492, /* (605) group_by_clause_opt ::= */ - 492, /* (606) group_by_clause_opt ::= GROUP BY group_by_list */ - 499, /* (607) group_by_list ::= expr_or_subquery */ - 499, /* (608) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - 493, /* (609) having_clause_opt ::= */ - 493, /* (610) having_clause_opt ::= HAVING search_condition */ - 488, /* (611) range_opt ::= */ - 488, /* (612) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - 488, /* (613) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ - 489, /* (614) every_opt ::= */ - 489, /* (615) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - 500, /* (616) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - 501, /* (617) query_simple ::= query_specification */ - 501, /* (618) query_simple ::= union_query_expression */ - 505, /* (619) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - 505, /* (620) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - 506, /* (621) query_simple_or_subquery ::= query_simple */ - 506, /* (622) query_simple_or_subquery ::= subquery */ - 429, /* (623) query_or_subquery ::= query_expression */ - 429, /* (624) query_or_subquery ::= subquery */ - 502, /* (625) order_by_clause_opt ::= */ - 502, /* (626) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 503, /* (627) slimit_clause_opt ::= */ - 503, /* (628) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - 503, /* (629) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - 503, /* (630) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 504, /* (631) limit_clause_opt ::= */ - 504, /* (632) limit_clause_opt ::= LIMIT NK_INTEGER */ - 504, /* (633) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - 504, /* (634) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 479, /* (635) subquery ::= NK_LP query_expression NK_RP */ - 479, /* (636) subquery ::= NK_LP subquery NK_RP */ - 368, /* (637) search_condition ::= common_expression */ - 507, /* (638) sort_specification_list ::= sort_specification */ - 507, /* (639) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - 508, /* (640) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - 509, /* (641) ordering_specification_opt ::= */ - 509, /* (642) ordering_specification_opt ::= ASC */ - 509, /* (643) ordering_specification_opt ::= DESC */ - 510, /* (644) null_ordering_opt ::= */ - 510, /* (645) null_ordering_opt ::= NULLS FIRST */ - 510, /* (646) null_ordering_opt ::= NULLS LAST */ + 351, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + 351, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + 352, /* (2) account_options ::= */ + 352, /* (3) account_options ::= account_options PPS literal */ + 352, /* (4) account_options ::= account_options TSERIES literal */ + 352, /* (5) account_options ::= account_options STORAGE literal */ + 352, /* (6) account_options ::= account_options STREAMS literal */ + 352, /* (7) account_options ::= account_options QTIME literal */ + 352, /* (8) account_options ::= account_options DBS literal */ + 352, /* (9) account_options ::= account_options USERS literal */ + 352, /* (10) account_options ::= account_options CONNS literal */ + 352, /* (11) account_options ::= account_options STATE literal */ + 353, /* (12) alter_account_options ::= alter_account_option */ + 353, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + 355, /* (14) alter_account_option ::= PASS literal */ + 355, /* (15) alter_account_option ::= PPS literal */ + 355, /* (16) alter_account_option ::= TSERIES literal */ + 355, /* (17) alter_account_option ::= STORAGE literal */ + 355, /* (18) alter_account_option ::= STREAMS literal */ + 355, /* (19) alter_account_option ::= QTIME literal */ + 355, /* (20) alter_account_option ::= DBS literal */ + 355, /* (21) alter_account_option ::= USERS literal */ + 355, /* (22) alter_account_option ::= CONNS literal */ + 355, /* (23) alter_account_option ::= STATE literal */ + 356, /* (24) ip_range_list ::= NK_STRING */ + 356, /* (25) ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ + 357, /* (26) white_list ::= HOST ip_range_list */ + 358, /* (27) white_list_opt ::= */ + 358, /* (28) white_list_opt ::= white_list */ + 351, /* (29) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ + 351, /* (30) cmd ::= ALTER USER user_name PASS NK_STRING */ + 351, /* (31) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + 351, /* (32) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + 351, /* (33) cmd ::= ALTER USER user_name ADD white_list */ + 351, /* (34) cmd ::= ALTER USER user_name DROP white_list */ + 351, /* (35) cmd ::= DROP USER user_name */ + 360, /* (36) sysinfo_opt ::= */ + 360, /* (37) sysinfo_opt ::= SYSINFO NK_INTEGER */ + 351, /* (38) cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ + 351, /* (39) cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ + 361, /* (40) privileges ::= ALL */ + 361, /* (41) privileges ::= priv_type_list */ + 361, /* (42) privileges ::= SUBSCRIBE */ + 364, /* (43) priv_type_list ::= priv_type */ + 364, /* (44) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + 365, /* (45) priv_type ::= READ */ + 365, /* (46) priv_type ::= WRITE */ + 365, /* (47) priv_type ::= ALTER */ + 362, /* (48) priv_level ::= NK_STAR NK_DOT NK_STAR */ + 362, /* (49) priv_level ::= db_name NK_DOT NK_STAR */ + 362, /* (50) priv_level ::= db_name NK_DOT table_name */ + 362, /* (51) priv_level ::= topic_name */ + 363, /* (52) with_opt ::= */ + 363, /* (53) with_opt ::= WITH search_condition */ + 351, /* (54) cmd ::= CREATE DNODE dnode_endpoint */ + 351, /* (55) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + 351, /* (56) cmd ::= DROP DNODE NK_INTEGER force_opt */ + 351, /* (57) cmd ::= DROP DNODE dnode_endpoint force_opt */ + 351, /* (58) cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ + 351, /* (59) cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ + 351, /* (60) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + 351, /* (61) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + 351, /* (62) cmd ::= ALTER ALL DNODES NK_STRING */ + 351, /* (63) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + 351, /* (64) cmd ::= RESTORE DNODE NK_INTEGER */ + 370, /* (65) dnode_endpoint ::= NK_STRING */ + 370, /* (66) dnode_endpoint ::= NK_ID */ + 370, /* (67) dnode_endpoint ::= NK_IPTOKEN */ + 371, /* (68) force_opt ::= */ + 371, /* (69) force_opt ::= FORCE */ + 372, /* (70) unsafe_opt ::= UNSAFE */ + 351, /* (71) cmd ::= ALTER CLUSTER NK_STRING */ + 351, /* (72) cmd ::= ALTER CLUSTER NK_STRING NK_STRING */ + 351, /* (73) cmd ::= ALTER LOCAL NK_STRING */ + 351, /* (74) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + 351, /* (75) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + 351, /* (76) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + 351, /* (77) cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ + 351, /* (78) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + 351, /* (79) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + 351, /* (80) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + 351, /* (81) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + 351, /* (82) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + 351, /* (83) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + 351, /* (84) cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ + 351, /* (85) cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ + 351, /* (86) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + 351, /* (87) cmd ::= DROP DATABASE exists_opt db_name */ + 351, /* (88) cmd ::= USE db_name */ + 351, /* (89) cmd ::= ALTER DATABASE db_name alter_db_options */ + 351, /* (90) cmd ::= FLUSH DATABASE db_name */ + 351, /* (91) cmd ::= TRIM DATABASE db_name speed_opt */ + 351, /* (92) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ + 373, /* (93) not_exists_opt ::= IF NOT EXISTS */ + 373, /* (94) not_exists_opt ::= */ + 375, /* (95) exists_opt ::= IF EXISTS */ + 375, /* (96) exists_opt ::= */ + 374, /* (97) db_options ::= */ + 374, /* (98) db_options ::= db_options BUFFER NK_INTEGER */ + 374, /* (99) db_options ::= db_options CACHEMODEL NK_STRING */ + 374, /* (100) db_options ::= db_options CACHESIZE NK_INTEGER */ + 374, /* (101) db_options ::= db_options COMP NK_INTEGER */ + 374, /* (102) db_options ::= db_options DURATION NK_INTEGER */ + 374, /* (103) db_options ::= db_options DURATION NK_VARIABLE */ + 374, /* (104) db_options ::= db_options MAXROWS NK_INTEGER */ + 374, /* (105) db_options ::= db_options MINROWS NK_INTEGER */ + 374, /* (106) db_options ::= db_options KEEP integer_list */ + 374, /* (107) db_options ::= db_options KEEP variable_list */ + 374, /* (108) db_options ::= db_options PAGES NK_INTEGER */ + 374, /* (109) db_options ::= db_options PAGESIZE NK_INTEGER */ + 374, /* (110) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ + 374, /* (111) db_options ::= db_options PRECISION NK_STRING */ + 374, /* (112) db_options ::= db_options REPLICA NK_INTEGER */ + 374, /* (113) db_options ::= db_options VGROUPS NK_INTEGER */ + 374, /* (114) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + 374, /* (115) db_options ::= db_options RETENTIONS retention_list */ + 374, /* (116) db_options ::= db_options SCHEMALESS NK_INTEGER */ + 374, /* (117) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + 374, /* (118) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + 374, /* (119) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + 374, /* (120) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + 374, /* (121) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + 374, /* (122) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + 374, /* (123) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + 374, /* (124) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + 374, /* (125) db_options ::= db_options STT_TRIGGER NK_INTEGER */ + 374, /* (126) db_options ::= db_options TABLE_PREFIX signed */ + 374, /* (127) db_options ::= db_options TABLE_SUFFIX signed */ + 374, /* (128) db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ + 376, /* (129) alter_db_options ::= alter_db_option */ + 376, /* (130) alter_db_options ::= alter_db_options alter_db_option */ + 384, /* (131) alter_db_option ::= BUFFER NK_INTEGER */ + 384, /* (132) alter_db_option ::= CACHEMODEL NK_STRING */ + 384, /* (133) alter_db_option ::= CACHESIZE NK_INTEGER */ + 384, /* (134) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + 384, /* (135) alter_db_option ::= KEEP integer_list */ + 384, /* (136) alter_db_option ::= KEEP variable_list */ + 384, /* (137) alter_db_option ::= PAGES NK_INTEGER */ + 384, /* (138) alter_db_option ::= REPLICA NK_INTEGER */ + 384, /* (139) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + 384, /* (140) alter_db_option ::= STT_TRIGGER NK_INTEGER */ + 384, /* (141) alter_db_option ::= MINROWS NK_INTEGER */ + 384, /* (142) alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ + 384, /* (143) alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + 384, /* (144) alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ + 384, /* (145) alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + 384, /* (146) alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ + 380, /* (147) integer_list ::= NK_INTEGER */ + 380, /* (148) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + 381, /* (149) variable_list ::= NK_VARIABLE */ + 381, /* (150) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + 382, /* (151) retention_list ::= retention */ + 382, /* (152) retention_list ::= retention_list NK_COMMA retention */ + 385, /* (153) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + 385, /* (154) retention ::= NK_MINUS NK_COLON NK_VARIABLE */ + 377, /* (155) speed_opt ::= */ + 377, /* (156) speed_opt ::= BWLIMIT NK_INTEGER */ + 378, /* (157) start_opt ::= */ + 378, /* (158) start_opt ::= START WITH NK_INTEGER */ + 378, /* (159) start_opt ::= START WITH NK_STRING */ + 378, /* (160) start_opt ::= START WITH TIMESTAMP NK_STRING */ + 379, /* (161) end_opt ::= */ + 379, /* (162) end_opt ::= END WITH NK_INTEGER */ + 379, /* (163) end_opt ::= END WITH NK_STRING */ + 379, /* (164) end_opt ::= END WITH TIMESTAMP NK_STRING */ + 351, /* (165) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + 351, /* (166) cmd ::= CREATE TABLE multi_create_clause */ + 351, /* (167) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + 351, /* (168) cmd ::= DROP TABLE multi_drop_clause */ + 351, /* (169) cmd ::= DROP STABLE exists_opt full_table_name */ + 351, /* (170) cmd ::= ALTER TABLE alter_table_clause */ + 351, /* (171) cmd ::= ALTER STABLE alter_table_clause */ + 393, /* (172) alter_table_clause ::= full_table_name alter_table_options */ + 393, /* (173) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + 393, /* (174) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + 393, /* (175) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + 393, /* (176) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + 393, /* (177) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + 393, /* (178) alter_table_clause ::= full_table_name DROP TAG column_name */ + 393, /* (179) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + 393, /* (180) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + 393, /* (181) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + 390, /* (182) multi_create_clause ::= create_subtable_clause */ + 390, /* (183) multi_create_clause ::= multi_create_clause create_subtable_clause */ + 398, /* (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 */ + 392, /* (185) multi_drop_clause ::= drop_table_clause */ + 392, /* (186) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ + 401, /* (187) drop_table_clause ::= exists_opt full_table_name */ + 399, /* (188) specific_cols_opt ::= */ + 399, /* (189) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + 386, /* (190) full_table_name ::= table_name */ + 386, /* (191) full_table_name ::= db_name NK_DOT table_name */ + 387, /* (192) column_def_list ::= column_def */ + 387, /* (193) column_def_list ::= column_def_list NK_COMMA column_def */ + 403, /* (194) column_def ::= column_name type_name */ + 396, /* (195) type_name ::= BOOL */ + 396, /* (196) type_name ::= TINYINT */ + 396, /* (197) type_name ::= SMALLINT */ + 396, /* (198) type_name ::= INT */ + 396, /* (199) type_name ::= INTEGER */ + 396, /* (200) type_name ::= BIGINT */ + 396, /* (201) type_name ::= FLOAT */ + 396, /* (202) type_name ::= DOUBLE */ + 396, /* (203) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + 396, /* (204) type_name ::= TIMESTAMP */ + 396, /* (205) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + 396, /* (206) type_name ::= TINYINT UNSIGNED */ + 396, /* (207) type_name ::= SMALLINT UNSIGNED */ + 396, /* (208) type_name ::= INT UNSIGNED */ + 396, /* (209) type_name ::= BIGINT UNSIGNED */ + 396, /* (210) type_name ::= JSON */ + 396, /* (211) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + 396, /* (212) type_name ::= MEDIUMBLOB */ + 396, /* (213) type_name ::= BLOB */ + 396, /* (214) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + 396, /* (215) type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ + 396, /* (216) type_name ::= DECIMAL */ + 396, /* (217) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + 396, /* (218) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 388, /* (219) tags_def_opt ::= */ + 388, /* (220) tags_def_opt ::= tags_def */ + 391, /* (221) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + 389, /* (222) table_options ::= */ + 389, /* (223) table_options ::= table_options COMMENT NK_STRING */ + 389, /* (224) table_options ::= table_options MAX_DELAY duration_list */ + 389, /* (225) table_options ::= table_options WATERMARK duration_list */ + 389, /* (226) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + 389, /* (227) table_options ::= table_options TTL NK_INTEGER */ + 389, /* (228) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + 389, /* (229) table_options ::= table_options DELETE_MARK duration_list */ + 394, /* (230) alter_table_options ::= alter_table_option */ + 394, /* (231) alter_table_options ::= alter_table_options alter_table_option */ + 406, /* (232) alter_table_option ::= COMMENT NK_STRING */ + 406, /* (233) alter_table_option ::= TTL NK_INTEGER */ + 404, /* (234) duration_list ::= duration_literal */ + 404, /* (235) duration_list ::= duration_list NK_COMMA duration_literal */ + 405, /* (236) rollup_func_list ::= rollup_func_name */ + 405, /* (237) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + 408, /* (238) rollup_func_name ::= function_name */ + 408, /* (239) rollup_func_name ::= FIRST */ + 408, /* (240) rollup_func_name ::= LAST */ + 402, /* (241) col_name_list ::= col_name */ + 402, /* (242) col_name_list ::= col_name_list NK_COMMA col_name */ + 410, /* (243) col_name ::= column_name */ + 351, /* (244) cmd ::= SHOW DNODES */ + 351, /* (245) cmd ::= SHOW USERS */ + 351, /* (246) cmd ::= SHOW USER PRIVILEGES */ + 351, /* (247) cmd ::= SHOW db_kind_opt DATABASES */ + 351, /* (248) cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ + 351, /* (249) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + 351, /* (250) cmd ::= SHOW db_name_cond_opt VGROUPS */ + 351, /* (251) cmd ::= SHOW MNODES */ + 351, /* (252) cmd ::= SHOW QNODES */ + 351, /* (253) cmd ::= SHOW FUNCTIONS */ + 351, /* (254) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + 351, /* (255) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ + 351, /* (256) cmd ::= SHOW STREAMS */ + 351, /* (257) cmd ::= SHOW ACCOUNTS */ + 351, /* (258) cmd ::= SHOW APPS */ + 351, /* (259) cmd ::= SHOW CONNECTIONS */ + 351, /* (260) cmd ::= SHOW LICENCES */ + 351, /* (261) cmd ::= SHOW GRANTS */ + 351, /* (262) cmd ::= SHOW GRANTS FULL */ + 351, /* (263) cmd ::= SHOW GRANTS LOGS */ + 351, /* (264) cmd ::= SHOW CLUSTER MACHINES */ + 351, /* (265) cmd ::= SHOW CREATE DATABASE db_name */ + 351, /* (266) cmd ::= SHOW CREATE TABLE full_table_name */ + 351, /* (267) cmd ::= SHOW CREATE STABLE full_table_name */ + 351, /* (268) cmd ::= SHOW QUERIES */ + 351, /* (269) cmd ::= SHOW SCORES */ + 351, /* (270) cmd ::= SHOW TOPICS */ + 351, /* (271) cmd ::= SHOW VARIABLES */ + 351, /* (272) cmd ::= SHOW CLUSTER VARIABLES */ + 351, /* (273) cmd ::= SHOW LOCAL VARIABLES */ + 351, /* (274) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ + 351, /* (275) cmd ::= SHOW BNODES */ + 351, /* (276) cmd ::= SHOW SNODES */ + 351, /* (277) cmd ::= SHOW CLUSTER */ + 351, /* (278) cmd ::= SHOW TRANSACTIONS */ + 351, /* (279) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + 351, /* (280) cmd ::= SHOW CONSUMERS */ + 351, /* (281) cmd ::= SHOW SUBSCRIPTIONS */ + 351, /* (282) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + 351, /* (283) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ + 351, /* (284) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ + 351, /* (285) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ + 351, /* (286) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ + 351, /* (287) cmd ::= SHOW VNODES */ + 351, /* (288) cmd ::= SHOW db_name_cond_opt ALIVE */ + 351, /* (289) cmd ::= SHOW CLUSTER ALIVE */ + 351, /* (290) cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ + 351, /* (291) cmd ::= SHOW CREATE VIEW full_table_name */ + 351, /* (292) cmd ::= SHOW COMPACTS */ + 351, /* (293) cmd ::= SHOW COMPACT NK_INTEGER */ + 412, /* (294) table_kind_db_name_cond_opt ::= */ + 412, /* (295) table_kind_db_name_cond_opt ::= table_kind */ + 412, /* (296) table_kind_db_name_cond_opt ::= db_name NK_DOT */ + 412, /* (297) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ + 418, /* (298) table_kind ::= NORMAL */ + 418, /* (299) table_kind ::= CHILD */ + 414, /* (300) db_name_cond_opt ::= */ + 414, /* (301) db_name_cond_opt ::= db_name NK_DOT */ + 413, /* (302) like_pattern_opt ::= */ + 413, /* (303) like_pattern_opt ::= LIKE NK_STRING */ + 415, /* (304) table_name_cond ::= table_name */ + 416, /* (305) from_db_opt ::= */ + 416, /* (306) from_db_opt ::= FROM db_name */ + 417, /* (307) tag_list_opt ::= */ + 417, /* (308) tag_list_opt ::= tag_item */ + 417, /* (309) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ + 419, /* (310) tag_item ::= TBNAME */ + 419, /* (311) tag_item ::= QTAGS */ + 419, /* (312) tag_item ::= column_name */ + 419, /* (313) tag_item ::= column_name column_alias */ + 419, /* (314) tag_item ::= column_name AS column_alias */ + 411, /* (315) db_kind_opt ::= */ + 411, /* (316) db_kind_opt ::= USER */ + 411, /* (317) db_kind_opt ::= SYSTEM */ + 351, /* (318) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ + 351, /* (319) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ + 351, /* (320) cmd ::= DROP INDEX exists_opt full_index_name */ + 422, /* (321) full_index_name ::= index_name */ + 422, /* (322) full_index_name ::= db_name NK_DOT index_name */ + 421, /* (323) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + 421, /* (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 */ + 424, /* (325) func_list ::= func */ + 424, /* (326) func_list ::= func_list NK_COMMA func */ + 427, /* (327) func ::= sma_func_name NK_LP expression_list NK_RP */ + 428, /* (328) sma_func_name ::= function_name */ + 428, /* (329) sma_func_name ::= COUNT */ + 428, /* (330) sma_func_name ::= FIRST */ + 428, /* (331) sma_func_name ::= LAST */ + 428, /* (332) sma_func_name ::= LAST_ROW */ + 426, /* (333) sma_stream_opt ::= */ + 426, /* (334) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + 426, /* (335) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + 426, /* (336) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + 429, /* (337) with_meta ::= AS */ + 429, /* (338) with_meta ::= WITH META AS */ + 429, /* (339) with_meta ::= ONLY META AS */ + 351, /* (340) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + 351, /* (341) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ + 351, /* (342) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ + 351, /* (343) cmd ::= DROP TOPIC exists_opt topic_name */ + 351, /* (344) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + 351, /* (345) cmd ::= DESC full_table_name */ + 351, /* (346) cmd ::= DESCRIBE full_table_name */ + 351, /* (347) cmd ::= RESET QUERY CACHE */ + 351, /* (348) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + 351, /* (349) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ + 433, /* (350) analyze_opt ::= */ + 433, /* (351) analyze_opt ::= ANALYZE */ + 434, /* (352) explain_options ::= */ + 434, /* (353) explain_options ::= explain_options VERBOSE NK_BOOL */ + 434, /* (354) explain_options ::= explain_options RATIO NK_FLOAT */ + 351, /* (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 */ + 351, /* (356) cmd ::= DROP FUNCTION exists_opt function_name */ + 437, /* (357) agg_func_opt ::= */ + 437, /* (358) agg_func_opt ::= AGGREGATE */ + 438, /* (359) bufsize_opt ::= */ + 438, /* (360) bufsize_opt ::= BUFSIZE NK_INTEGER */ + 439, /* (361) language_opt ::= */ + 439, /* (362) language_opt ::= LANGUAGE NK_STRING */ + 436, /* (363) or_replace_opt ::= */ + 436, /* (364) or_replace_opt ::= OR REPLACE */ + 351, /* (365) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ + 351, /* (366) cmd ::= DROP VIEW exists_opt full_view_name */ + 440, /* (367) full_view_name ::= view_name */ + 440, /* (368) full_view_name ::= db_name NK_DOT view_name */ + 351, /* (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 */ + 351, /* (370) cmd ::= DROP STREAM exists_opt stream_name */ + 351, /* (371) cmd ::= PAUSE STREAM exists_opt stream_name */ + 351, /* (372) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ + 444, /* (373) col_list_opt ::= */ + 444, /* (374) col_list_opt ::= NK_LP col_name_list NK_RP */ + 445, /* (375) tag_def_or_ref_opt ::= */ + 445, /* (376) tag_def_or_ref_opt ::= tags_def */ + 445, /* (377) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ + 443, /* (378) stream_options ::= */ + 443, /* (379) stream_options ::= stream_options TRIGGER AT_ONCE */ + 443, /* (380) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + 443, /* (381) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + 443, /* (382) stream_options ::= stream_options WATERMARK duration_literal */ + 443, /* (383) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + 443, /* (384) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + 443, /* (385) stream_options ::= stream_options DELETE_MARK duration_literal */ + 443, /* (386) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + 446, /* (387) subtable_opt ::= */ + 446, /* (388) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + 447, /* (389) ignore_opt ::= */ + 447, /* (390) ignore_opt ::= IGNORE UNTREATED */ + 351, /* (391) cmd ::= KILL CONNECTION NK_INTEGER */ + 351, /* (392) cmd ::= KILL QUERY NK_STRING */ + 351, /* (393) cmd ::= KILL TRANSACTION NK_INTEGER */ + 351, /* (394) cmd ::= KILL COMPACT NK_INTEGER */ + 351, /* (395) cmd ::= BALANCE VGROUP */ + 351, /* (396) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ + 351, /* (397) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + 351, /* (398) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + 351, /* (399) cmd ::= SPLIT VGROUP NK_INTEGER */ + 449, /* (400) on_vgroup_id ::= */ + 449, /* (401) on_vgroup_id ::= ON NK_INTEGER */ + 450, /* (402) dnode_list ::= DNODE NK_INTEGER */ + 450, /* (403) dnode_list ::= dnode_list DNODE NK_INTEGER */ + 351, /* (404) cmd ::= DELETE FROM full_table_name where_clause_opt */ + 351, /* (405) cmd ::= query_or_subquery */ + 351, /* (406) cmd ::= insert_query */ + 435, /* (407) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + 435, /* (408) insert_query ::= INSERT INTO full_table_name query_or_subquery */ + 354, /* (409) literal ::= NK_INTEGER */ + 354, /* (410) literal ::= NK_FLOAT */ + 354, /* (411) literal ::= NK_STRING */ + 354, /* (412) literal ::= NK_BOOL */ + 354, /* (413) literal ::= TIMESTAMP NK_STRING */ + 354, /* (414) literal ::= duration_literal */ + 354, /* (415) literal ::= NULL */ + 354, /* (416) literal ::= NK_QUESTION */ + 407, /* (417) duration_literal ::= NK_VARIABLE */ + 383, /* (418) signed ::= NK_INTEGER */ + 383, /* (419) signed ::= NK_PLUS NK_INTEGER */ + 383, /* (420) signed ::= NK_MINUS NK_INTEGER */ + 383, /* (421) signed ::= NK_FLOAT */ + 383, /* (422) signed ::= NK_PLUS NK_FLOAT */ + 383, /* (423) signed ::= NK_MINUS NK_FLOAT */ + 397, /* (424) signed_literal ::= signed */ + 397, /* (425) signed_literal ::= NK_STRING */ + 397, /* (426) signed_literal ::= NK_BOOL */ + 397, /* (427) signed_literal ::= TIMESTAMP NK_STRING */ + 397, /* (428) signed_literal ::= duration_literal */ + 397, /* (429) signed_literal ::= NULL */ + 397, /* (430) signed_literal ::= literal_func */ + 397, /* (431) signed_literal ::= NK_QUESTION */ + 452, /* (432) literal_list ::= signed_literal */ + 452, /* (433) literal_list ::= literal_list NK_COMMA signed_literal */ + 366, /* (434) db_name ::= NK_ID */ + 367, /* (435) table_name ::= NK_ID */ + 395, /* (436) column_name ::= NK_ID */ + 409, /* (437) function_name ::= NK_ID */ + 441, /* (438) view_name ::= NK_ID */ + 453, /* (439) table_alias ::= NK_ID */ + 420, /* (440) column_alias ::= NK_ID */ + 420, /* (441) column_alias ::= NK_ALIAS */ + 359, /* (442) user_name ::= NK_ID */ + 368, /* (443) topic_name ::= NK_ID */ + 442, /* (444) stream_name ::= NK_ID */ + 432, /* (445) cgroup_name ::= NK_ID */ + 423, /* (446) index_name ::= NK_ID */ + 454, /* (447) expr_or_subquery ::= expression */ + 448, /* (448) expression ::= literal */ + 448, /* (449) expression ::= pseudo_column */ + 448, /* (450) expression ::= column_reference */ + 448, /* (451) expression ::= function_expression */ + 448, /* (452) expression ::= case_when_expression */ + 448, /* (453) expression ::= NK_LP expression NK_RP */ + 448, /* (454) expression ::= NK_PLUS expr_or_subquery */ + 448, /* (455) expression ::= NK_MINUS expr_or_subquery */ + 448, /* (456) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + 448, /* (457) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + 448, /* (458) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + 448, /* (459) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + 448, /* (460) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + 448, /* (461) expression ::= column_reference NK_ARROW NK_STRING */ + 448, /* (462) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + 448, /* (463) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + 400, /* (464) expression_list ::= expr_or_subquery */ + 400, /* (465) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + 456, /* (466) column_reference ::= column_name */ + 456, /* (467) column_reference ::= table_name NK_DOT column_name */ + 456, /* (468) column_reference ::= NK_ALIAS */ + 456, /* (469) column_reference ::= table_name NK_DOT NK_ALIAS */ + 455, /* (470) pseudo_column ::= ROWTS */ + 455, /* (471) pseudo_column ::= TBNAME */ + 455, /* (472) pseudo_column ::= table_name NK_DOT TBNAME */ + 455, /* (473) pseudo_column ::= QSTART */ + 455, /* (474) pseudo_column ::= QEND */ + 455, /* (475) pseudo_column ::= QDURATION */ + 455, /* (476) pseudo_column ::= WSTART */ + 455, /* (477) pseudo_column ::= WEND */ + 455, /* (478) pseudo_column ::= WDURATION */ + 455, /* (479) pseudo_column ::= IROWTS */ + 455, /* (480) pseudo_column ::= ISFILLED */ + 455, /* (481) pseudo_column ::= QTAGS */ + 457, /* (482) function_expression ::= function_name NK_LP expression_list NK_RP */ + 457, /* (483) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + 457, /* (484) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + 457, /* (485) function_expression ::= literal_func */ + 451, /* (486) literal_func ::= noarg_func NK_LP NK_RP */ + 451, /* (487) literal_func ::= NOW */ + 461, /* (488) noarg_func ::= NOW */ + 461, /* (489) noarg_func ::= TODAY */ + 461, /* (490) noarg_func ::= TIMEZONE */ + 461, /* (491) noarg_func ::= DATABASE */ + 461, /* (492) noarg_func ::= CLIENT_VERSION */ + 461, /* (493) noarg_func ::= SERVER_VERSION */ + 461, /* (494) noarg_func ::= SERVER_STATUS */ + 461, /* (495) noarg_func ::= CURRENT_USER */ + 461, /* (496) noarg_func ::= USER */ + 459, /* (497) star_func ::= COUNT */ + 459, /* (498) star_func ::= FIRST */ + 459, /* (499) star_func ::= LAST */ + 459, /* (500) star_func ::= LAST_ROW */ + 460, /* (501) star_func_para_list ::= NK_STAR */ + 460, /* (502) star_func_para_list ::= other_para_list */ + 462, /* (503) other_para_list ::= star_func_para */ + 462, /* (504) other_para_list ::= other_para_list NK_COMMA star_func_para */ + 463, /* (505) star_func_para ::= expr_or_subquery */ + 463, /* (506) star_func_para ::= table_name NK_DOT NK_STAR */ + 458, /* (507) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + 458, /* (508) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + 464, /* (509) when_then_list ::= when_then_expr */ + 464, /* (510) when_then_list ::= when_then_list when_then_expr */ + 467, /* (511) when_then_expr ::= WHEN common_expression THEN common_expression */ + 465, /* (512) case_when_else_opt ::= */ + 465, /* (513) case_when_else_opt ::= ELSE common_expression */ + 468, /* (514) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + 468, /* (515) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + 468, /* (516) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + 468, /* (517) predicate ::= expr_or_subquery IS NULL */ + 468, /* (518) predicate ::= expr_or_subquery IS NOT NULL */ + 468, /* (519) predicate ::= expr_or_subquery in_op in_predicate_value */ + 469, /* (520) compare_op ::= NK_LT */ + 469, /* (521) compare_op ::= NK_GT */ + 469, /* (522) compare_op ::= NK_LE */ + 469, /* (523) compare_op ::= NK_GE */ + 469, /* (524) compare_op ::= NK_NE */ + 469, /* (525) compare_op ::= NK_EQ */ + 469, /* (526) compare_op ::= LIKE */ + 469, /* (527) compare_op ::= NOT LIKE */ + 469, /* (528) compare_op ::= MATCH */ + 469, /* (529) compare_op ::= NMATCH */ + 469, /* (530) compare_op ::= CONTAINS */ + 470, /* (531) in_op ::= IN */ + 470, /* (532) in_op ::= NOT IN */ + 471, /* (533) in_predicate_value ::= NK_LP literal_list NK_RP */ + 472, /* (534) boolean_value_expression ::= boolean_primary */ + 472, /* (535) boolean_value_expression ::= NOT boolean_primary */ + 472, /* (536) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + 472, /* (537) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + 473, /* (538) boolean_primary ::= predicate */ + 473, /* (539) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + 466, /* (540) common_expression ::= expr_or_subquery */ + 466, /* (541) common_expression ::= boolean_value_expression */ + 474, /* (542) from_clause_opt ::= */ + 474, /* (543) from_clause_opt ::= FROM table_reference_list */ + 475, /* (544) table_reference_list ::= table_reference */ + 475, /* (545) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + 476, /* (546) table_reference ::= table_primary */ + 476, /* (547) table_reference ::= joined_table */ + 477, /* (548) table_primary ::= table_name alias_opt */ + 477, /* (549) table_primary ::= db_name NK_DOT table_name alias_opt */ + 477, /* (550) table_primary ::= subquery alias_opt */ + 477, /* (551) table_primary ::= parenthesized_joined_table */ + 479, /* (552) alias_opt ::= */ + 479, /* (553) alias_opt ::= table_alias */ + 479, /* (554) alias_opt ::= AS table_alias */ + 481, /* (555) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + 481, /* (556) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + 478, /* (557) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + 482, /* (558) join_type ::= */ + 482, /* (559) join_type ::= INNER */ + 483, /* (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 */ + 484, /* (561) hint_list ::= */ + 484, /* (562) hint_list ::= NK_HINT */ + 486, /* (563) tag_mode_opt ::= */ + 486, /* (564) tag_mode_opt ::= TAGS */ + 485, /* (565) set_quantifier_opt ::= */ + 485, /* (566) set_quantifier_opt ::= DISTINCT */ + 485, /* (567) set_quantifier_opt ::= ALL */ + 487, /* (568) select_list ::= select_item */ + 487, /* (569) select_list ::= select_list NK_COMMA select_item */ + 495, /* (570) select_item ::= NK_STAR */ + 495, /* (571) select_item ::= common_expression */ + 495, /* (572) select_item ::= common_expression column_alias */ + 495, /* (573) select_item ::= common_expression AS column_alias */ + 495, /* (574) select_item ::= table_name NK_DOT NK_STAR */ + 431, /* (575) where_clause_opt ::= */ + 431, /* (576) where_clause_opt ::= WHERE search_condition */ + 488, /* (577) partition_by_clause_opt ::= */ + 488, /* (578) partition_by_clause_opt ::= PARTITION BY partition_list */ + 496, /* (579) partition_list ::= partition_item */ + 496, /* (580) partition_list ::= partition_list NK_COMMA partition_item */ + 497, /* (581) partition_item ::= expr_or_subquery */ + 497, /* (582) partition_item ::= expr_or_subquery column_alias */ + 497, /* (583) partition_item ::= expr_or_subquery AS column_alias */ + 492, /* (584) twindow_clause_opt ::= */ + 492, /* (585) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ + 492, /* (586) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + 492, /* (587) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + 492, /* (588) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + 492, /* (589) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ + 492, /* (590) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ + 492, /* (591) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 425, /* (592) sliding_opt ::= */ + 425, /* (593) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ + 498, /* (594) interval_sliding_duration_literal ::= NK_VARIABLE */ + 498, /* (595) interval_sliding_duration_literal ::= NK_STRING */ + 498, /* (596) interval_sliding_duration_literal ::= NK_INTEGER */ + 491, /* (597) fill_opt ::= */ + 491, /* (598) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + 491, /* (599) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ + 491, /* (600) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ + 499, /* (601) fill_mode ::= NONE */ + 499, /* (602) fill_mode ::= PREV */ + 499, /* (603) fill_mode ::= NULL */ + 499, /* (604) fill_mode ::= NULL_F */ + 499, /* (605) fill_mode ::= LINEAR */ + 499, /* (606) fill_mode ::= NEXT */ + 493, /* (607) group_by_clause_opt ::= */ + 493, /* (608) group_by_clause_opt ::= GROUP BY group_by_list */ + 500, /* (609) group_by_list ::= expr_or_subquery */ + 500, /* (610) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + 494, /* (611) having_clause_opt ::= */ + 494, /* (612) having_clause_opt ::= HAVING search_condition */ + 489, /* (613) range_opt ::= */ + 489, /* (614) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + 489, /* (615) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ + 490, /* (616) every_opt ::= */ + 490, /* (617) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + 501, /* (618) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + 502, /* (619) query_simple ::= query_specification */ + 502, /* (620) query_simple ::= union_query_expression */ + 506, /* (621) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + 506, /* (622) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + 507, /* (623) query_simple_or_subquery ::= query_simple */ + 507, /* (624) query_simple_or_subquery ::= subquery */ + 430, /* (625) query_or_subquery ::= query_expression */ + 430, /* (626) query_or_subquery ::= subquery */ + 503, /* (627) order_by_clause_opt ::= */ + 503, /* (628) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 504, /* (629) slimit_clause_opt ::= */ + 504, /* (630) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + 504, /* (631) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + 504, /* (632) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 505, /* (633) limit_clause_opt ::= */ + 505, /* (634) limit_clause_opt ::= LIMIT NK_INTEGER */ + 505, /* (635) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + 505, /* (636) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 480, /* (637) subquery ::= NK_LP query_expression NK_RP */ + 480, /* (638) subquery ::= NK_LP subquery NK_RP */ + 369, /* (639) search_condition ::= common_expression */ + 508, /* (640) sort_specification_list ::= sort_specification */ + 508, /* (641) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + 509, /* (642) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + 510, /* (643) ordering_specification_opt ::= */ + 510, /* (644) ordering_specification_opt ::= ASC */ + 510, /* (645) ordering_specification_opt ::= DESC */ + 511, /* (646) null_ordering_opt ::= */ + 511, /* (647) null_ordering_opt ::= NULLS FIRST */ + 511, /* (648) null_ordering_opt ::= NULLS LAST */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -4297,7 +4627,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 */ @@ -4597,63 +4927,65 @@ static const signed char yyRuleInfoNRhs[] = { -6, /* (587) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -8, /* (588) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -7, /* (589) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ - 0, /* (590) sliding_opt ::= */ - -4, /* (591) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ - -1, /* (592) interval_sliding_duration_literal ::= NK_VARIABLE */ - -1, /* (593) interval_sliding_duration_literal ::= NK_STRING */ - -1, /* (594) interval_sliding_duration_literal ::= NK_INTEGER */ - 0, /* (595) fill_opt ::= */ - -4, /* (596) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - -6, /* (597) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ - -6, /* (598) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ - -1, /* (599) fill_mode ::= NONE */ - -1, /* (600) fill_mode ::= PREV */ - -1, /* (601) fill_mode ::= NULL */ - -1, /* (602) fill_mode ::= NULL_F */ - -1, /* (603) fill_mode ::= LINEAR */ - -1, /* (604) fill_mode ::= NEXT */ - 0, /* (605) group_by_clause_opt ::= */ - -3, /* (606) group_by_clause_opt ::= GROUP BY group_by_list */ - -1, /* (607) group_by_list ::= expr_or_subquery */ - -3, /* (608) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - 0, /* (609) having_clause_opt ::= */ - -2, /* (610) having_clause_opt ::= HAVING search_condition */ - 0, /* (611) range_opt ::= */ - -6, /* (612) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - -4, /* (613) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ - 0, /* (614) every_opt ::= */ - -4, /* (615) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - -4, /* (616) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - -1, /* (617) query_simple ::= query_specification */ - -1, /* (618) query_simple ::= union_query_expression */ - -4, /* (619) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - -3, /* (620) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - -1, /* (621) query_simple_or_subquery ::= query_simple */ - -1, /* (622) query_simple_or_subquery ::= subquery */ - -1, /* (623) query_or_subquery ::= query_expression */ - -1, /* (624) query_or_subquery ::= subquery */ - 0, /* (625) order_by_clause_opt ::= */ - -3, /* (626) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 0, /* (627) slimit_clause_opt ::= */ - -2, /* (628) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - -4, /* (629) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - -4, /* (630) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 0, /* (631) limit_clause_opt ::= */ - -2, /* (632) limit_clause_opt ::= LIMIT NK_INTEGER */ - -4, /* (633) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - -4, /* (634) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - -3, /* (635) subquery ::= NK_LP query_expression NK_RP */ - -3, /* (636) subquery ::= NK_LP subquery NK_RP */ - -1, /* (637) search_condition ::= common_expression */ - -1, /* (638) sort_specification_list ::= sort_specification */ - -3, /* (639) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - -3, /* (640) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - 0, /* (641) ordering_specification_opt ::= */ - -1, /* (642) ordering_specification_opt ::= ASC */ - -1, /* (643) ordering_specification_opt ::= DESC */ - 0, /* (644) null_ordering_opt ::= */ - -2, /* (645) null_ordering_opt ::= NULLS FIRST */ - -2, /* (646) null_ordering_opt ::= NULLS LAST */ + -4, /* (590) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ + -6, /* (591) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 0, /* (592) sliding_opt ::= */ + -4, /* (593) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ + -1, /* (594) interval_sliding_duration_literal ::= NK_VARIABLE */ + -1, /* (595) interval_sliding_duration_literal ::= NK_STRING */ + -1, /* (596) interval_sliding_duration_literal ::= NK_INTEGER */ + 0, /* (597) fill_opt ::= */ + -4, /* (598) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + -6, /* (599) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ + -6, /* (600) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ + -1, /* (601) fill_mode ::= NONE */ + -1, /* (602) fill_mode ::= PREV */ + -1, /* (603) fill_mode ::= NULL */ + -1, /* (604) fill_mode ::= NULL_F */ + -1, /* (605) fill_mode ::= LINEAR */ + -1, /* (606) fill_mode ::= NEXT */ + 0, /* (607) group_by_clause_opt ::= */ + -3, /* (608) group_by_clause_opt ::= GROUP BY group_by_list */ + -1, /* (609) group_by_list ::= expr_or_subquery */ + -3, /* (610) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + 0, /* (611) having_clause_opt ::= */ + -2, /* (612) having_clause_opt ::= HAVING search_condition */ + 0, /* (613) range_opt ::= */ + -6, /* (614) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + -4, /* (615) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ + 0, /* (616) every_opt ::= */ + -4, /* (617) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + -4, /* (618) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + -1, /* (619) query_simple ::= query_specification */ + -1, /* (620) query_simple ::= union_query_expression */ + -4, /* (621) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + -3, /* (622) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + -1, /* (623) query_simple_or_subquery ::= query_simple */ + -1, /* (624) query_simple_or_subquery ::= subquery */ + -1, /* (625) query_or_subquery ::= query_expression */ + -1, /* (626) query_or_subquery ::= subquery */ + 0, /* (627) order_by_clause_opt ::= */ + -3, /* (628) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 0, /* (629) slimit_clause_opt ::= */ + -2, /* (630) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + -4, /* (631) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + -4, /* (632) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 0, /* (633) limit_clause_opt ::= */ + -2, /* (634) limit_clause_opt ::= LIMIT NK_INTEGER */ + -4, /* (635) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + -4, /* (636) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + -3, /* (637) subquery ::= NK_LP query_expression NK_RP */ + -3, /* (638) subquery ::= NK_LP subquery NK_RP */ + -1, /* (639) search_condition ::= common_expression */ + -1, /* (640) sort_specification_list ::= sort_specification */ + -3, /* (641) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + -3, /* (642) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + 0, /* (643) ordering_specification_opt ::= */ + -1, /* (644) ordering_specification_opt ::= ASC */ + -1, /* (645) ordering_specification_opt ::= DESC */ + 0, /* (646) null_ordering_opt ::= */ + -2, /* (647) null_ordering_opt ::= NULLS FIRST */ + -2, /* (648) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -4683,54 +5015,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 @@ -4745,11 +5029,11 @@ static YYACTIONTYPE yy_reduce( YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,351,&yymsp[0].minor); + yy_destructor(yypParser,352,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,352,&yymsp[0].minor); + yy_destructor(yypParser,353,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -4763,20 +5047,20 @@ static YYACTIONTYPE yy_reduce( case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9); case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); -{ yy_destructor(yypParser,351,&yymsp[-2].minor); +{ yy_destructor(yypParser,352,&yymsp[-2].minor); { } - yy_destructor(yypParser,353,&yymsp[0].minor); + yy_destructor(yypParser,354,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,354,&yymsp[0].minor); +{ yy_destructor(yypParser,355,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,352,&yymsp[-1].minor); +{ yy_destructor(yypParser,353,&yymsp[-1].minor); { } - yy_destructor(yypParser,354,&yymsp[0].minor); + yy_destructor(yypParser,355,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -4790,18 +5074,18 @@ static YYACTIONTYPE yy_reduce( case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); { } - yy_destructor(yypParser,353,&yymsp[0].minor); + yy_destructor(yypParser,354,&yymsp[0].minor); break; case 24: /* ip_range_list ::= NK_STRING */ -{ yylhsminor.yy502 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy502 = yylhsminor.yy502; +{ yylhsminor.yy536 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy536 = yylhsminor.yy536; break; case 25: /* ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ -{ yylhsminor.yy502 = addNodeToList(pCxt, yymsp[-2].minor.yy502, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy502 = yylhsminor.yy502; +{ yylhsminor.yy536 = addNodeToList(pCxt, yymsp[-2].minor.yy536, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy536 = yylhsminor.yy536; break; case 26: /* white_list ::= HOST ip_range_list */ -{ yymsp[-1].minor.yy502 = yymsp[0].minor.yy502; } +{ yymsp[-1].minor.yy536 = yymsp[0].minor.yy536; } break; case 27: /* white_list_opt ::= */ case 188: /* specific_cols_opt ::= */ yytestcase(yyruleno==188); @@ -4810,92 +5094,92 @@ static YYACTIONTYPE yy_reduce( case 373: /* col_list_opt ::= */ yytestcase(yyruleno==373); case 375: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==375); 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); -{ yymsp[1].minor.yy502 = NULL; } + case 607: /* group_by_clause_opt ::= */ yytestcase(yyruleno==607); + case 627: /* order_by_clause_opt ::= */ yytestcase(yyruleno==627); +{ yymsp[1].minor.yy536 = NULL; } 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); -{ yylhsminor.yy502 = yymsp[0].minor.yy502; } - yymsp[0].minor.yy502 = yylhsminor.yy502; +{ yylhsminor.yy536 = yymsp[0].minor.yy536; } + yymsp[0].minor.yy536 = yylhsminor.yy536; break; case 29: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ { - 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); + pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-4].minor.yy929, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy695); + pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy536); } break; case 30: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy561, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy929, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 31: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy561, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy929, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } break; case 32: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy561, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy929, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 33: /* cmd ::= ALTER USER user_name ADD white_list */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy561, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy502); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy929, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy536); } break; case 34: /* cmd ::= ALTER USER user_name DROP white_list */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy561, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy502); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy929, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy536); } break; case 35: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy561); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy929); } break; case 36: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy1013 = 1; } +{ yymsp[1].minor.yy695 = 1; } break; case 37: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy1013 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy695 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } break; case 38: /* cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy277, &yymsp[-3].minor.yy483, &yymsp[0].minor.yy561, yymsp[-2].minor.yy490); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy221, &yymsp[-3].minor.yy57, &yymsp[0].minor.yy929, yymsp[-2].minor.yy360); } break; case 39: /* cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy277, &yymsp[-3].minor.yy483, &yymsp[0].minor.yy561, yymsp[-2].minor.yy490); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy221, &yymsp[-3].minor.yy57, &yymsp[0].minor.yy929, yymsp[-2].minor.yy360); } break; case 40: /* privileges ::= ALL */ -{ yymsp[0].minor.yy277 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy221 = PRIVILEGE_TYPE_ALL; } break; case 41: /* privileges ::= priv_type_list */ case 43: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==43); -{ yylhsminor.yy277 = yymsp[0].minor.yy277; } - yymsp[0].minor.yy277 = yylhsminor.yy277; +{ yylhsminor.yy221 = yymsp[0].minor.yy221; } + yymsp[0].minor.yy221 = yylhsminor.yy221; break; case 42: /* privileges ::= SUBSCRIBE */ -{ yymsp[0].minor.yy277 = PRIVILEGE_TYPE_SUBSCRIBE; } +{ yymsp[0].minor.yy221 = PRIVILEGE_TYPE_SUBSCRIBE; } break; case 44: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy277 = yymsp[-2].minor.yy277 | yymsp[0].minor.yy277; } - yymsp[-2].minor.yy277 = yylhsminor.yy277; +{ yylhsminor.yy221 = yymsp[-2].minor.yy221 | yymsp[0].minor.yy221; } + yymsp[-2].minor.yy221 = yylhsminor.yy221; break; case 45: /* priv_type ::= READ */ -{ yymsp[0].minor.yy277 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy221 = PRIVILEGE_TYPE_READ; } break; case 46: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy277 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy221 = PRIVILEGE_TYPE_WRITE; } break; case 47: /* priv_type ::= ALTER */ -{ yymsp[0].minor.yy277 = PRIVILEGE_TYPE_ALTER; } +{ yymsp[0].minor.yy221 = PRIVILEGE_TYPE_ALTER; } break; case 48: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy483.first = yymsp[-2].minor.yy0; yylhsminor.yy483.second = yymsp[0].minor.yy0; } - yymsp[-2].minor.yy483 = yylhsminor.yy483; +{ yylhsminor.yy57.first = yymsp[-2].minor.yy0; yylhsminor.yy57.second = yymsp[0].minor.yy0; } + yymsp[-2].minor.yy57 = yylhsminor.yy57; break; case 49: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy483.first = yymsp[-2].minor.yy561; yylhsminor.yy483.second = yymsp[0].minor.yy0; } - yymsp[-2].minor.yy483 = yylhsminor.yy483; +{ yylhsminor.yy57.first = yymsp[-2].minor.yy929; yylhsminor.yy57.second = yymsp[0].minor.yy0; } + yymsp[-2].minor.yy57 = yylhsminor.yy57; break; case 50: /* priv_level ::= db_name NK_DOT table_name */ -{ yylhsminor.yy483.first = yymsp[-2].minor.yy561; yylhsminor.yy483.second = yymsp[0].minor.yy561; } - yymsp[-2].minor.yy483 = yylhsminor.yy483; +{ yylhsminor.yy57.first = yymsp[-2].minor.yy929; yylhsminor.yy57.second = yymsp[0].minor.yy929; } + yymsp[-2].minor.yy57 = yylhsminor.yy57; break; case 51: /* priv_level ::= topic_name */ -{ yylhsminor.yy483.first = yymsp[0].minor.yy561; yylhsminor.yy483.second = nil_token; } - yymsp[0].minor.yy483 = yylhsminor.yy483; +{ yylhsminor.yy57.first = yymsp[0].minor.yy929; yylhsminor.yy57.second = nil_token; } + yymsp[0].minor.yy57 = yylhsminor.yy57; break; case 52: /* with_opt ::= */ case 157: /* start_opt ::= */ yytestcase(yyruleno==157); @@ -4906,38 +5190,38 @@ static YYACTIONTYPE yy_reduce( case 542: /* from_clause_opt ::= */ yytestcase(yyruleno==542); case 575: /* where_clause_opt ::= */ yytestcase(yyruleno==575); case 584: /* twindow_clause_opt ::= */ yytestcase(yyruleno==584); - case 590: /* sliding_opt ::= */ yytestcase(yyruleno==590); - case 595: /* fill_opt ::= */ yytestcase(yyruleno==595); - case 609: /* having_clause_opt ::= */ yytestcase(yyruleno==609); - case 611: /* range_opt ::= */ yytestcase(yyruleno==611); - case 614: /* every_opt ::= */ yytestcase(yyruleno==614); - case 627: /* slimit_clause_opt ::= */ yytestcase(yyruleno==627); - case 631: /* limit_clause_opt ::= */ yytestcase(yyruleno==631); -{ yymsp[1].minor.yy490 = NULL; } + case 592: /* sliding_opt ::= */ yytestcase(yyruleno==592); + case 597: /* fill_opt ::= */ yytestcase(yyruleno==597); + case 611: /* having_clause_opt ::= */ yytestcase(yyruleno==611); + case 613: /* range_opt ::= */ yytestcase(yyruleno==613); + case 616: /* every_opt ::= */ yytestcase(yyruleno==616); + case 629: /* slimit_clause_opt ::= */ yytestcase(yyruleno==629); + case 633: /* limit_clause_opt ::= */ yytestcase(yyruleno==633); +{ yymsp[1].minor.yy360 = NULL; } 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); -{ yymsp[-1].minor.yy490 = yymsp[0].minor.yy490; } + case 612: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==612); +{ yymsp[-1].minor.yy360 = yymsp[0].minor.yy360; } break; case 54: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy561, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy929, NULL); } break; case 55: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0); } break; case 56: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy845, false); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy345, false); } break; case 57: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy561, yymsp[0].minor.yy845, false); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy929, yymsp[0].minor.yy345, false); } break; case 58: /* cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy845); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy345); } break; case 59: /* cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy561, false, yymsp[0].minor.yy845); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy929, false, yymsp[0].minor.yy345); } break; case 60: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -4987,8 +5271,8 @@ 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); -{ yylhsminor.yy561 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy561 = yylhsminor.yy561; +{ yylhsminor.yy929 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy929 = yylhsminor.yy929; break; case 68: /* force_opt ::= */ case 94: /* not_exists_opt ::= */ yytestcase(yyruleno==94); @@ -4999,7 +5283,7 @@ 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); -{ yymsp[1].minor.yy845 = false; } +{ yymsp[1].minor.yy345 = false; } break; case 69: /* force_opt ::= FORCE */ case 70: /* unsafe_opt ::= UNSAFE */ yytestcase(yyruleno==70); @@ -5007,7 +5291,7 @@ 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); -{ yymsp[0].minor.yy845 = true; } +{ yymsp[0].minor.yy345 = true; } break; case 71: /* cmd ::= ALTER CLUSTER NK_STRING */ { pCxt->pRootNode = createAlterClusterStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -5055,241 +5339,241 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_VNODE_STMT, &yymsp[0].minor.yy0); } break; case 86: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy845, &yymsp[-1].minor.yy561, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy345, &yymsp[-1].minor.yy929, yymsp[0].minor.yy360); } break; case 87: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy561); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy345, &yymsp[0].minor.yy929); } break; case 88: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy561); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy929); } break; case 89: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy561, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy929, yymsp[0].minor.yy360); } break; case 90: /* cmd ::= FLUSH DATABASE db_name */ -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy561); } +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy929); } break; case 91: /* cmd ::= TRIM DATABASE db_name speed_opt */ -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy561, yymsp[0].minor.yy774); } +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy929, yymsp[0].minor.yy580); } break; case 92: /* cmd ::= COMPACT DATABASE db_name start_opt end_opt */ -{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy561, yymsp[-1].minor.yy490, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy929, yymsp[-1].minor.yy360, yymsp[0].minor.yy360); } break; case 93: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy845 = true; } +{ yymsp[-2].minor.yy345 = true; } 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); -{ yymsp[-1].minor.yy845 = true; } +{ yymsp[-1].minor.yy345 = true; } break; case 97: /* db_options ::= */ -{ yymsp[1].minor.yy490 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy360 = createDefaultDatabaseOptions(pCxt); } break; case 98: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 99: /* db_options ::= db_options CACHEMODEL NK_STRING */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 100: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 101: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 102: /* db_options ::= db_options DURATION NK_INTEGER */ case 103: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==103); -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 104: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 105: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 106: /* db_options ::= db_options KEEP integer_list */ case 107: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==107); -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_KEEP, yymsp[0].minor.yy502); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_KEEP, yymsp[0].minor.yy536); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 108: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 109: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 110: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 111: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 112: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 113: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 114: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 115: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_RETENTIONS, yymsp[0].minor.yy502); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_RETENTIONS, yymsp[0].minor.yy536); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 116: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 117: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 118: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 119: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 120: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-3].minor.yy490, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-3].minor.yy360, DB_OPTION_WAL_RETENTION_PERIOD, &t); } - yymsp[-3].minor.yy490 = yylhsminor.yy490; + yymsp[-3].minor.yy360 = yylhsminor.yy360; break; case 121: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 122: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-3].minor.yy490, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-3].minor.yy360, DB_OPTION_WAL_RETENTION_SIZE, &t); } - yymsp[-3].minor.yy490 = yylhsminor.yy490; + yymsp[-3].minor.yy360 = yylhsminor.yy360; break; case 123: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 124: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 125: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 126: /* db_options ::= db_options TABLE_PREFIX signed */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy490); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy360); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 127: /* db_options ::= db_options TABLE_SUFFIX signed */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy490); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy360); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 128: /* db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ -{ yylhsminor.yy490 = setDatabaseOption(pCxt, yymsp[-2].minor.yy490, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setDatabaseOption(pCxt, yymsp[-2].minor.yy360, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 129: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy490 = createAlterDatabaseOptions(pCxt); yylhsminor.yy490 = setAlterDatabaseOption(pCxt, yylhsminor.yy490, &yymsp[0].minor.yy529); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createAlterDatabaseOptions(pCxt); yylhsminor.yy360 = setAlterDatabaseOption(pCxt, yylhsminor.yy360, &yymsp[0].minor.yy797); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 130: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy490 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy490, &yymsp[0].minor.yy529); } - yymsp[-1].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy360, &yymsp[0].minor.yy797); } + yymsp[-1].minor.yy360 = yylhsminor.yy360; break; case 131: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy529.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy797.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } break; case 132: /* alter_db_option ::= CACHEMODEL NK_STRING */ -{ yymsp[-1].minor.yy529.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy797.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } break; case 133: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -{ yymsp[-1].minor.yy529.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy797.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } break; case 134: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy529.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy797.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } break; case 135: /* alter_db_option ::= KEEP integer_list */ case 136: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==136); -{ yymsp[-1].minor.yy529.type = DB_OPTION_KEEP; yymsp[-1].minor.yy529.pList = yymsp[0].minor.yy502; } +{ yymsp[-1].minor.yy797.type = DB_OPTION_KEEP; yymsp[-1].minor.yy797.pList = yymsp[0].minor.yy536; } break; case 137: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy529.type = DB_OPTION_PAGES; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy797.type = DB_OPTION_PAGES; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } break; case 138: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy529.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy797.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } break; case 139: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -{ yymsp[-1].minor.yy529.type = DB_OPTION_WAL; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy797.type = DB_OPTION_WAL; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } break; case 140: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ -{ yymsp[-1].minor.yy529.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy797.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } break; case 141: /* alter_db_option ::= MINROWS NK_INTEGER */ -{ yymsp[-1].minor.yy529.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy797.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } break; case 142: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy529.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy797.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } break; case 143: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yymsp[-2].minor.yy529.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy529.val = t; + yymsp[-2].minor.yy797.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy797.val = t; } break; case 144: /* alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ -{ yymsp[-1].minor.yy529.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy797.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } break; case 145: /* alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yymsp[-2].minor.yy529.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy529.val = t; + yymsp[-2].minor.yy797.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy797.val = t; } break; case 146: /* alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ -{ yymsp[-1].minor.yy529.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy797.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } break; case 147: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy502 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy502 = yylhsminor.yy502; +{ yylhsminor.yy536 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy536 = yylhsminor.yy536; break; case 148: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ case 403: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==403); -{ yylhsminor.yy502 = addNodeToList(pCxt, yymsp[-2].minor.yy502, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy502 = yylhsminor.yy502; +{ yylhsminor.yy536 = addNodeToList(pCxt, yymsp[-2].minor.yy536, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy536 = yylhsminor.yy536; break; case 149: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy502 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy502 = yylhsminor.yy502; +{ yylhsminor.yy536 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy536 = yylhsminor.yy536; break; case 150: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy502 = addNodeToList(pCxt, yymsp[-2].minor.yy502, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy502 = yylhsminor.yy502; +{ yylhsminor.yy536 = addNodeToList(pCxt, yymsp[-2].minor.yy536, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy536 = yylhsminor.yy536; break; case 151: /* retention_list ::= retention */ case 182: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==182); @@ -5304,9 +5588,9 @@ static YYACTIONTYPE yy_reduce( case 509: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==509); 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); -{ yylhsminor.yy502 = createNodeList(pCxt, yymsp[0].minor.yy490); } - yymsp[0].minor.yy502 = yylhsminor.yy502; + case 640: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==640); +{ yylhsminor.yy536 = createNodeList(pCxt, yymsp[0].minor.yy360); } + yymsp[0].minor.yy536 = yylhsminor.yy536; break; case 152: /* retention_list ::= retention_list NK_COMMA retention */ case 186: /* multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ yytestcase(yyruleno==186); @@ -5319,268 +5603,268 @@ static YYACTIONTYPE yy_reduce( case 504: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==504); 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); -{ yylhsminor.yy502 = addNodeToList(pCxt, yymsp[-2].minor.yy502, yymsp[0].minor.yy490); } - yymsp[-2].minor.yy502 = yylhsminor.yy502; + case 641: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==641); +{ yylhsminor.yy536 = addNodeToList(pCxt, yymsp[-2].minor.yy536, yymsp[0].minor.yy360); } + yymsp[-2].minor.yy536 = yylhsminor.yy536; break; case 153: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ case 154: /* retention ::= NK_MINUS NK_COLON NK_VARIABLE */ yytestcase(yyruleno==154); -{ yylhsminor.yy490 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 155: /* speed_opt ::= */ case 359: /* bufsize_opt ::= */ yytestcase(yyruleno==359); -{ yymsp[1].minor.yy774 = 0; } +{ yymsp[1].minor.yy580 = 0; } break; case 156: /* speed_opt ::= BWLIMIT NK_INTEGER */ case 360: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==360); -{ yymsp[-1].minor.yy774 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy580 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; case 158: /* start_opt ::= START WITH NK_INTEGER */ case 162: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==162); -{ yymsp[-2].minor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-2].minor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; case 159: /* start_opt ::= START WITH NK_STRING */ case 163: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==163); -{ yymsp[-2].minor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +{ yymsp[-2].minor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; case 160: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ case 164: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==164); -{ yymsp[-3].minor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +{ yymsp[-3].minor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } 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); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy845, yymsp[-5].minor.yy490, yymsp[-3].minor.yy502, yymsp[-1].minor.yy502, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy345, yymsp[-5].minor.yy360, yymsp[-3].minor.yy536, yymsp[-1].minor.yy536, yymsp[0].minor.yy360); } break; case 166: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy502); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy536); } break; case 168: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy502); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy536); } break; case 169: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy845, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy345, yymsp[0].minor.yy360); } 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); -{ pCxt->pRootNode = yymsp[0].minor.yy490; } +{ pCxt->pRootNode = yymsp[0].minor.yy360; } break; case 171: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy490); } +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy360); } break; case 172: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy490 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy490, yymsp[0].minor.yy490); } - yymsp[-1].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy360, yymsp[0].minor.yy360); } + yymsp[-1].minor.yy360 = yylhsminor.yy360; break; case 173: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy490 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy490, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy561, yymsp[0].minor.yy826); } - yymsp[-4].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy360, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy929, yymsp[0].minor.yy912); } + yymsp[-4].minor.yy360 = yylhsminor.yy360; break; case 174: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy490 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy490, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy561); } - yymsp[-3].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy360, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy929); } + yymsp[-3].minor.yy360 = yylhsminor.yy360; break; case 175: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy490 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy490, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy561, yymsp[0].minor.yy826); } - yymsp[-4].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy360, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy929, yymsp[0].minor.yy912); } + yymsp[-4].minor.yy360 = yylhsminor.yy360; break; case 176: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy490 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy490, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy561, &yymsp[0].minor.yy561); } - yymsp[-4].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy360, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy929, &yymsp[0].minor.yy929); } + yymsp[-4].minor.yy360 = yylhsminor.yy360; break; case 177: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy490 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy490, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy561, yymsp[0].minor.yy826); } - yymsp[-4].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy360, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy929, yymsp[0].minor.yy912); } + yymsp[-4].minor.yy360 = yylhsminor.yy360; break; case 178: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy490 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy490, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy561); } - yymsp[-3].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy360, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy929); } + yymsp[-3].minor.yy360 = yylhsminor.yy360; break; case 179: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy490 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy490, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy561, yymsp[0].minor.yy826); } - yymsp[-4].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy360, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy929, yymsp[0].minor.yy912); } + yymsp[-4].minor.yy360 = yylhsminor.yy360; break; case 180: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy490 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy490, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy561, &yymsp[0].minor.yy561); } - yymsp[-4].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy360, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy929, &yymsp[0].minor.yy929); } + yymsp[-4].minor.yy360 = yylhsminor.yy360; break; case 181: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy490 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy490, &yymsp[-2].minor.yy561, yymsp[0].minor.yy490); } - yymsp[-5].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy360, &yymsp[-2].minor.yy929, yymsp[0].minor.yy360); } + yymsp[-5].minor.yy360 = yylhsminor.yy360; 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); -{ yylhsminor.yy502 = addNodeToList(pCxt, yymsp[-1].minor.yy502, yymsp[0].minor.yy490); } - yymsp[-1].minor.yy502 = yylhsminor.yy502; +{ yylhsminor.yy536 = addNodeToList(pCxt, yymsp[-1].minor.yy536, yymsp[0].minor.yy360); } + yymsp[-1].minor.yy536 = yylhsminor.yy536; 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 */ -{ 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); } - yymsp[-9].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy345, yymsp[-8].minor.yy360, yymsp[-6].minor.yy360, yymsp[-5].minor.yy536, yymsp[-2].minor.yy536, yymsp[0].minor.yy360); } + yymsp[-9].minor.yy360 = yylhsminor.yy360; break; case 187: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy490 = createDropTableClause(pCxt, yymsp[-1].minor.yy845, yymsp[0].minor.yy490); } - yymsp[-1].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createDropTableClause(pCxt, yymsp[-1].minor.yy345, yymsp[0].minor.yy360); } + yymsp[-1].minor.yy360 = yylhsminor.yy360; 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); -{ yymsp[-2].minor.yy502 = yymsp[-1].minor.yy502; } +{ yymsp[-2].minor.yy536 = yymsp[-1].minor.yy536; } break; case 190: /* full_table_name ::= table_name */ -{ yylhsminor.yy490 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy561, NULL); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy929, NULL); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 191: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy490 = createRealTableNode(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy561, NULL); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRealTableNode(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929, NULL); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 194: /* column_def ::= column_name type_name */ -{ yylhsminor.yy490 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy561, yymsp[0].minor.yy826, NULL); } - yymsp[-1].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy929, yymsp[0].minor.yy912, NULL); } + yymsp[-1].minor.yy360 = yylhsminor.yy360; break; case 195: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 196: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 197: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 198: /* type_name ::= INT */ case 199: /* type_name ::= INTEGER */ yytestcase(yyruleno==199); -{ yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_INT); } break; case 200: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 201: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 202: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 203: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy826 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy912 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 204: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 205: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy826 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy912 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 206: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy826 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy912 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 207: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy826 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy912 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 208: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy826 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy912 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 209: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy826 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy912 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 210: /* type_name ::= JSON */ -{ yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 211: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy826 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy912 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 212: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 213: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 214: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy826 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy912 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 215: /* type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy826 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy912 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } break; case 216: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy826 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy912 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 217: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy826 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy912 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 218: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy826 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy912 = createDataType(TSDB_DATA_TYPE_DECIMAL); } 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); -{ yymsp[-3].minor.yy502 = yymsp[-1].minor.yy502; } +{ yymsp[-3].minor.yy536 = yymsp[-1].minor.yy536; } break; case 222: /* table_options ::= */ -{ yymsp[1].minor.yy490 = createDefaultTableOptions(pCxt); } +{ yymsp[1].minor.yy360 = createDefaultTableOptions(pCxt); } break; case 223: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy490 = setTableOption(pCxt, yymsp[-2].minor.yy490, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setTableOption(pCxt, yymsp[-2].minor.yy360, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 224: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy490 = setTableOption(pCxt, yymsp[-2].minor.yy490, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy502); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setTableOption(pCxt, yymsp[-2].minor.yy360, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy536); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 225: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy490 = setTableOption(pCxt, yymsp[-2].minor.yy490, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy502); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setTableOption(pCxt, yymsp[-2].minor.yy360, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy536); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 226: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy490 = setTableOption(pCxt, yymsp[-4].minor.yy490, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy502); } - yymsp[-4].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setTableOption(pCxt, yymsp[-4].minor.yy360, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy536); } + yymsp[-4].minor.yy360 = yylhsminor.yy360; break; case 227: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy490 = setTableOption(pCxt, yymsp[-2].minor.yy490, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setTableOption(pCxt, yymsp[-2].minor.yy360, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 228: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy490 = setTableOption(pCxt, yymsp[-4].minor.yy490, TABLE_OPTION_SMA, yymsp[-1].minor.yy502); } - yymsp[-4].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setTableOption(pCxt, yymsp[-4].minor.yy360, TABLE_OPTION_SMA, yymsp[-1].minor.yy536); } + yymsp[-4].minor.yy360 = yylhsminor.yy360; break; case 229: /* table_options ::= table_options DELETE_MARK duration_list */ -{ yylhsminor.yy490 = setTableOption(pCxt, yymsp[-2].minor.yy490, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy502); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setTableOption(pCxt, yymsp[-2].minor.yy360, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy536); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 230: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy490 = createAlterTableOptions(pCxt); yylhsminor.yy490 = setTableOption(pCxt, yylhsminor.yy490, yymsp[0].minor.yy529.type, &yymsp[0].minor.yy529.val); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createAlterTableOptions(pCxt); yylhsminor.yy360 = setTableOption(pCxt, yylhsminor.yy360, yymsp[0].minor.yy797.type, &yymsp[0].minor.yy797.val); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 231: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy490 = setTableOption(pCxt, yymsp[-1].minor.yy490, yymsp[0].minor.yy529.type, &yymsp[0].minor.yy529.val); } - yymsp[-1].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setTableOption(pCxt, yymsp[-1].minor.yy360, yymsp[0].minor.yy797.type, &yymsp[0].minor.yy797.val); } + yymsp[-1].minor.yy360 = yylhsminor.yy360; break; case 232: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy529.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy797.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } break; case 233: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy529.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy529.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy797.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy797.val = yymsp[0].minor.yy0; } break; case 234: /* duration_list ::= duration_literal */ case 464: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==464); -{ yylhsminor.yy502 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy490)); } - yymsp[0].minor.yy502 = yylhsminor.yy502; +{ yylhsminor.yy536 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy360)); } + yymsp[0].minor.yy536 = yylhsminor.yy536; 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); -{ yylhsminor.yy502 = addNodeToList(pCxt, yymsp[-2].minor.yy502, releaseRawExprNode(pCxt, yymsp[0].minor.yy490)); } - yymsp[-2].minor.yy502 = yylhsminor.yy502; +{ yylhsminor.yy536 = addNodeToList(pCxt, yymsp[-2].minor.yy536, releaseRawExprNode(pCxt, yymsp[0].minor.yy360)); } + yymsp[-2].minor.yy536 = yylhsminor.yy536; break; case 238: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy490 = createFunctionNode(pCxt, &yymsp[0].minor.yy561, NULL); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createFunctionNode(pCxt, &yymsp[0].minor.yy929, NULL); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 239: /* rollup_func_name ::= FIRST */ case 240: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==240); case 311: /* tag_item ::= QTAGS */ yytestcase(yyruleno==311); -{ yylhsminor.yy490 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 243: /* col_name ::= column_name */ case 312: /* tag_item ::= column_name */ yytestcase(yyruleno==312); -{ yylhsminor.yy490 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy561); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy929); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 244: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } @@ -5594,19 +5878,19 @@ static YYACTIONTYPE yy_reduce( case 247: /* cmd ::= SHOW db_kind_opt DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); - setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy579); + setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy321); } break; case 248: /* cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ { - pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy961, yymsp[0].minor.yy490, OP_TYPE_LIKE); + pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy1005, yymsp[0].minor.yy360, OP_TYPE_LIKE); } break; case 249: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy490, yymsp[0].minor.yy490, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy360, yymsp[0].minor.yy360, OP_TYPE_LIKE); } break; case 250: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy490, NULL, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy360, NULL, OP_TYPE_LIKE); } break; case 251: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } @@ -5618,10 +5902,10 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; case 254: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy490, yymsp[-1].minor.yy490, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy360, yymsp[-1].minor.yy360, OP_TYPE_EQUAL); } break; case 255: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy561), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy561), OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy929), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy929), OP_TYPE_EQUAL); } break; case 256: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } @@ -5649,13 +5933,13 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT); } break; case 265: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy561); } +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy929); } break; case 266: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy360); } break; case 267: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy360); } break; case 268: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } @@ -5674,7 +5958,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } break; case 274: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy360); } break; case 275: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } @@ -5689,7 +5973,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; case 279: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy360); } break; case 280: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } @@ -5698,16 +5982,16 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; case 282: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy490, yymsp[-1].minor.yy490, OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy360, yymsp[-1].minor.yy360, OP_TYPE_EQUAL); } break; case 283: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy561), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy561), OP_TYPE_EQUAL); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy929), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy929), OP_TYPE_EQUAL); } break; case 284: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy490, yymsp[0].minor.yy490, yymsp[-3].minor.yy502); } +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy360, yymsp[0].minor.yy360, yymsp[-3].minor.yy536); } break; case 285: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy561), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy561), yymsp[-4].minor.yy502); } +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy929), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy929), yymsp[-4].minor.yy536); } break; case 286: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } @@ -5716,16 +6000,16 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, NULL); } break; case 288: /* cmd ::= SHOW db_name_cond_opt ALIVE */ -{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy490, QUERY_NODE_SHOW_DB_ALIVE_STMT); } +{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy360, QUERY_NODE_SHOW_DB_ALIVE_STMT); } break; case 289: /* cmd ::= SHOW CLUSTER ALIVE */ { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } 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 */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-2].minor.yy360, yymsp[0].minor.yy360, OP_TYPE_LIKE); } break; case 291: /* cmd ::= SHOW CREATE VIEW full_table_name */ -{ pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy360); } break; case 292: /* cmd ::= SHOW COMPACTS */ { pCxt->pRootNode = createShowCompactsStmt(pCxt, QUERY_NODE_SHOW_COMPACTS_STMT); } @@ -5734,232 +6018,232 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createShowCompactDetailsStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; case 294: /* table_kind_db_name_cond_opt ::= */ -{ yymsp[1].minor.yy961.kind = SHOW_KIND_ALL; yymsp[1].minor.yy961.dbName = nil_token; } +{ yymsp[1].minor.yy1005.kind = SHOW_KIND_ALL; yymsp[1].minor.yy1005.dbName = nil_token; } break; case 295: /* table_kind_db_name_cond_opt ::= table_kind */ -{ yylhsminor.yy961.kind = yymsp[0].minor.yy579; yylhsminor.yy961.dbName = nil_token; } - yymsp[0].minor.yy961 = yylhsminor.yy961; +{ yylhsminor.yy1005.kind = yymsp[0].minor.yy321; yylhsminor.yy1005.dbName = nil_token; } + yymsp[0].minor.yy1005 = yylhsminor.yy1005; break; case 296: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy961.kind = SHOW_KIND_ALL; yylhsminor.yy961.dbName = yymsp[-1].minor.yy561; } - yymsp[-1].minor.yy961 = yylhsminor.yy961; +{ yylhsminor.yy1005.kind = SHOW_KIND_ALL; yylhsminor.yy1005.dbName = yymsp[-1].minor.yy929; } + yymsp[-1].minor.yy1005 = yylhsminor.yy1005; break; case 297: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ -{ yylhsminor.yy961.kind = yymsp[-2].minor.yy579; yylhsminor.yy961.dbName = yymsp[-1].minor.yy561; } - yymsp[-2].minor.yy961 = yylhsminor.yy961; +{ yylhsminor.yy1005.kind = yymsp[-2].minor.yy321; yylhsminor.yy1005.dbName = yymsp[-1].minor.yy929; } + yymsp[-2].minor.yy1005 = yylhsminor.yy1005; break; case 298: /* table_kind ::= NORMAL */ -{ yymsp[0].minor.yy579 = SHOW_KIND_TABLES_NORMAL; } +{ yymsp[0].minor.yy321 = SHOW_KIND_TABLES_NORMAL; } break; case 299: /* table_kind ::= CHILD */ -{ yymsp[0].minor.yy579 = SHOW_KIND_TABLES_CHILD; } +{ yymsp[0].minor.yy321 = SHOW_KIND_TABLES_CHILD; } break; case 300: /* db_name_cond_opt ::= */ case 305: /* from_db_opt ::= */ yytestcase(yyruleno==305); -{ yymsp[1].minor.yy490 = createDefaultDatabaseCondValue(pCxt); } +{ yymsp[1].minor.yy360 = createDefaultDatabaseCondValue(pCxt); } break; case 301: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy490 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy561); } - yymsp[-1].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy929); } + yymsp[-1].minor.yy360 = yylhsminor.yy360; break; case 303: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; case 304: /* table_name_cond ::= table_name */ -{ yylhsminor.yy490 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy561); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy929); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 306: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy490 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy561); } +{ yymsp[-1].minor.yy360 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy929); } break; case 310: /* tag_item ::= TBNAME */ -{ yylhsminor.yy490 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 313: /* tag_item ::= column_name column_alias */ -{ yylhsminor.yy490 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy561), &yymsp[0].minor.yy561); } - yymsp[-1].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy929), &yymsp[0].minor.yy929); } + yymsp[-1].minor.yy360 = yylhsminor.yy360; break; case 314: /* tag_item ::= column_name AS column_alias */ -{ yylhsminor.yy490 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy561), &yymsp[0].minor.yy561); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy929), &yymsp[0].minor.yy929); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 315: /* db_kind_opt ::= */ -{ yymsp[1].minor.yy579 = SHOW_KIND_ALL; } +{ yymsp[1].minor.yy321 = SHOW_KIND_ALL; } break; case 316: /* db_kind_opt ::= USER */ -{ yymsp[0].minor.yy579 = SHOW_KIND_DATABASES_USER; } +{ yymsp[0].minor.yy321 = SHOW_KIND_DATABASES_USER; } break; case 317: /* db_kind_opt ::= SYSTEM */ -{ yymsp[0].minor.yy579 = SHOW_KIND_DATABASES_SYSTEM; } +{ yymsp[0].minor.yy321 = SHOW_KIND_DATABASES_SYSTEM; } break; case 318: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy845, yymsp[-3].minor.yy490, yymsp[-1].minor.yy490, NULL, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy345, yymsp[-3].minor.yy360, yymsp[-1].minor.yy360, NULL, yymsp[0].minor.yy360); } break; case 319: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy845, yymsp[-5].minor.yy490, yymsp[-3].minor.yy490, yymsp[-1].minor.yy502, NULL); } +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy345, yymsp[-5].minor.yy360, yymsp[-3].minor.yy360, yymsp[-1].minor.yy536, NULL); } break; case 320: /* cmd ::= DROP INDEX exists_opt full_index_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy845, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy345, yymsp[0].minor.yy360); } break; case 321: /* full_index_name ::= index_name */ -{ yylhsminor.yy490 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy561); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy929); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 322: /* full_index_name ::= db_name NK_DOT index_name */ -{ yylhsminor.yy490 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy561); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 323: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ 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); } +{ yymsp[-9].minor.yy360 = createIndexOption(pCxt, yymsp[-7].minor.yy536, releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), NULL, yymsp[-1].minor.yy360, yymsp[0].minor.yy360); } 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 */ -{ 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); } +{ yymsp[-11].minor.yy360 = createIndexOption(pCxt, yymsp[-9].minor.yy536, releaseRawExprNode(pCxt, yymsp[-5].minor.yy360), releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), yymsp[-1].minor.yy360, yymsp[0].minor.yy360); } break; case 327: /* func ::= sma_func_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy490 = createFunctionNode(pCxt, &yymsp[-3].minor.yy561, yymsp[-1].minor.yy502); } - yymsp[-3].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createFunctionNode(pCxt, &yymsp[-3].minor.yy929, yymsp[-1].minor.yy536); } + yymsp[-3].minor.yy360 = yylhsminor.yy360; break; case 328: /* sma_func_name ::= function_name */ case 553: /* alias_opt ::= table_alias */ yytestcase(yyruleno==553); -{ yylhsminor.yy561 = yymsp[0].minor.yy561; } - yymsp[0].minor.yy561 = yylhsminor.yy561; +{ yylhsminor.yy929 = yymsp[0].minor.yy929; } + yymsp[0].minor.yy929 = yylhsminor.yy929; break; case 333: /* sma_stream_opt ::= */ case 378: /* stream_options ::= */ yytestcase(yyruleno==378); -{ yymsp[1].minor.yy490 = createStreamOptions(pCxt); } +{ yymsp[1].minor.yy360 = createStreamOptions(pCxt); } break; case 334: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy490)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = yymsp[-2].minor.yy490; } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ ((SStreamOptions*)yymsp[-2].minor.yy360)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy360); yylhsminor.yy360 = yymsp[-2].minor.yy360; } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 335: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy490)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = yymsp[-2].minor.yy490; } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ ((SStreamOptions*)yymsp[-2].minor.yy360)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy360); yylhsminor.yy360 = yymsp[-2].minor.yy360; } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 336: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy490)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy490); yylhsminor.yy490 = yymsp[-2].minor.yy490; } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ ((SStreamOptions*)yymsp[-2].minor.yy360)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy360); yylhsminor.yy360 = yymsp[-2].minor.yy360; } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 337: /* with_meta ::= AS */ -{ yymsp[0].minor.yy774 = 0; } +{ yymsp[0].minor.yy580 = 0; } break; case 338: /* with_meta ::= WITH META AS */ -{ yymsp[-2].minor.yy774 = 1; } +{ yymsp[-2].minor.yy580 = 1; } break; case 339: /* with_meta ::= ONLY META AS */ -{ yymsp[-2].minor.yy774 = 2; } +{ yymsp[-2].minor.yy580 = 2; } break; case 340: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy845, &yymsp[-2].minor.yy561, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy345, &yymsp[-2].minor.yy929, yymsp[0].minor.yy360); } break; case 341: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy845, &yymsp[-3].minor.yy561, &yymsp[0].minor.yy561, yymsp[-2].minor.yy774); } +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy345, &yymsp[-3].minor.yy929, &yymsp[0].minor.yy929, yymsp[-2].minor.yy580); } break; case 342: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy845, &yymsp[-4].minor.yy561, yymsp[-1].minor.yy490, yymsp[-3].minor.yy774, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy345, &yymsp[-4].minor.yy929, yymsp[-1].minor.yy360, yymsp[-3].minor.yy580, yymsp[0].minor.yy360); } break; case 343: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy561); } +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy345, &yymsp[0].minor.yy929); } break; case 344: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy845, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy561); } +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy345, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929); } break; case 345: /* cmd ::= DESC full_table_name */ case 346: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==346); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy360); } break; case 347: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } 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); -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy845, yymsp[-1].minor.yy490, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy345, yymsp[-1].minor.yy360, yymsp[0].minor.yy360); } break; case 352: /* explain_options ::= */ -{ yymsp[1].minor.yy490 = createDefaultExplainOptions(pCxt); } +{ yymsp[1].minor.yy360 = createDefaultExplainOptions(pCxt); } break; case 353: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy490 = setExplainVerbose(pCxt, yymsp[-2].minor.yy490, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setExplainVerbose(pCxt, yymsp[-2].minor.yy360, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 354: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy490 = setExplainRatio(pCxt, yymsp[-2].minor.yy490, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setExplainRatio(pCxt, yymsp[-2].minor.yy360, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; 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 */ -{ 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); } +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy345, yymsp[-9].minor.yy345, &yymsp[-6].minor.yy929, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy912, yymsp[-1].minor.yy580, &yymsp[0].minor.yy929, yymsp[-10].minor.yy345); } break; case 356: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy561); } +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy345, &yymsp[0].minor.yy929); } break; case 361: /* language_opt ::= */ case 400: /* on_vgroup_id ::= */ yytestcase(yyruleno==400); -{ yymsp[1].minor.yy561 = nil_token; } +{ yymsp[1].minor.yy929 = nil_token; } break; case 362: /* language_opt ::= LANGUAGE NK_STRING */ case 401: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==401); -{ yymsp[-1].minor.yy561 = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy929 = yymsp[0].minor.yy0; } break; case 365: /* cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy845, yymsp[-2].minor.yy490, &yymsp[-1].minor.yy0, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy345, yymsp[-2].minor.yy360, &yymsp[-1].minor.yy0, yymsp[0].minor.yy360); } break; case 366: /* cmd ::= DROP VIEW exists_opt full_view_name */ -{ pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy845, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy345, yymsp[0].minor.yy360); } break; case 367: /* full_view_name ::= view_name */ -{ yylhsminor.yy490 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy561); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy929); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 368: /* full_view_name ::= db_name NK_DOT view_name */ -{ yylhsminor.yy490 = createViewNode(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy561); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createViewNode(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; 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 */ -{ 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); } +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy345, &yymsp[-8].minor.yy929, yymsp[-5].minor.yy360, yymsp[-7].minor.yy360, yymsp[-3].minor.yy536, yymsp[-2].minor.yy360, yymsp[0].minor.yy360, yymsp[-4].minor.yy536); } break; case 370: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy561); } +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy345, &yymsp[0].minor.yy929); } break; case 371: /* cmd ::= PAUSE STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy561); } +{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy345, &yymsp[0].minor.yy929); } break; case 372: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ -{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy845, yymsp[-1].minor.yy845, &yymsp[0].minor.yy561); } +{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy345, yymsp[-1].minor.yy345, &yymsp[0].minor.yy929); } break; case 379: /* stream_options ::= stream_options TRIGGER AT_ONCE */ case 380: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==380); -{ yylhsminor.yy490 = setStreamOptions(pCxt, yymsp[-2].minor.yy490, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setStreamOptions(pCxt, yymsp[-2].minor.yy360, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 381: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ yylhsminor.yy490 = setStreamOptions(pCxt, yymsp[-3].minor.yy490, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy490)); } - yymsp[-3].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setStreamOptions(pCxt, yymsp[-3].minor.yy360, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy360)); } + yymsp[-3].minor.yy360 = yylhsminor.yy360; break; case 382: /* stream_options ::= stream_options WATERMARK duration_literal */ -{ yylhsminor.yy490 = setStreamOptions(pCxt, yymsp[-2].minor.yy490, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy490)); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setStreamOptions(pCxt, yymsp[-2].minor.yy360, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy360)); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 383: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -{ yylhsminor.yy490 = setStreamOptions(pCxt, yymsp[-3].minor.yy490, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-3].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setStreamOptions(pCxt, yymsp[-3].minor.yy360, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-3].minor.yy360 = yylhsminor.yy360; break; case 384: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ -{ yylhsminor.yy490 = setStreamOptions(pCxt, yymsp[-2].minor.yy490, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setStreamOptions(pCxt, yymsp[-2].minor.yy360, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 385: /* stream_options ::= stream_options DELETE_MARK duration_literal */ -{ yylhsminor.yy490 = setStreamOptions(pCxt, yymsp[-2].minor.yy490, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy490)); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setStreamOptions(pCxt, yymsp[-2].minor.yy360, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy360)); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 386: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ -{ yylhsminor.yy490 = setStreamOptions(pCxt, yymsp[-3].minor.yy490, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-3].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setStreamOptions(pCxt, yymsp[-3].minor.yy360, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-3].minor.yy360 = yylhsminor.yy360; 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); -{ yymsp[-3].minor.yy490 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy490); } + case 593: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==593); + case 617: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==617); +{ yymsp[-3].minor.yy360 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy360); } break; case 391: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } @@ -5977,48 +6261,48 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; case 396: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ -{ pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy561); } +{ pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy929); } break; case 397: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; case 398: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy502); } +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy536); } break; case 399: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; case 402: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy502 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +{ yymsp[-1].minor.yy536 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; case 404: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy490, yymsp[0].minor.yy490); } +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy360, yymsp[0].minor.yy360); } break; case 407: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -{ yymsp[-6].minor.yy490 = createInsertStmt(pCxt, yymsp[-4].minor.yy490, yymsp[-2].minor.yy502, yymsp[0].minor.yy490); } +{ yymsp[-6].minor.yy360 = createInsertStmt(pCxt, yymsp[-4].minor.yy360, yymsp[-2].minor.yy536, yymsp[0].minor.yy360); } break; case 408: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ -{ yymsp[-3].minor.yy490 = createInsertStmt(pCxt, yymsp[-1].minor.yy490, NULL, yymsp[0].minor.yy490); } +{ yymsp[-3].minor.yy360 = createInsertStmt(pCxt, yymsp[-1].minor.yy360, NULL, yymsp[0].minor.yy360); } break; case 409: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 410: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 411: /* literal ::= NK_STRING */ -{ yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 412: /* literal ::= NK_BOOL */ -{ yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 413: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy360 = yylhsminor.yy360; break; case 414: /* literal ::= duration_literal */ case 424: /* signed_literal ::= signed */ yytestcase(yyruleno==424); @@ -6036,190 +6320,190 @@ static YYACTIONTYPE yy_reduce( case 546: /* table_reference ::= table_primary */ yytestcase(yyruleno==546); case 547: /* table_reference ::= joined_table */ yytestcase(yyruleno==547); case 551: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==551); - case 617: /* query_simple ::= query_specification */ yytestcase(yyruleno==617); - 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); -{ yylhsminor.yy490 = yymsp[0].minor.yy490; } - yymsp[0].minor.yy490 = yylhsminor.yy490; + case 619: /* query_simple ::= query_specification */ yytestcase(yyruleno==619); + case 620: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==620); + case 623: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==623); + case 625: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==625); +{ yylhsminor.yy360 = yymsp[0].minor.yy360; } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 415: /* literal ::= NULL */ -{ yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 416: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy360 = yylhsminor.yy360; 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); -{ yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy490 = yylhsminor.yy490; + case 594: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==594); + case 595: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==595); + case 596: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==596); +{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 418: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 419: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } break; case 420: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy490 = yylhsminor.yy490; + yymsp[-1].minor.yy360 = yylhsminor.yy360; break; case 421: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 422: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; case 423: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy490 = yylhsminor.yy490; + yymsp[-1].minor.yy360 = yylhsminor.yy360; break; case 425: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 426: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 427: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +{ yymsp[-1].minor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; case 428: /* signed_literal ::= duration_literal */ case 430: /* signed_literal ::= literal_func */ yytestcase(yyruleno==430); case 505: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==505); case 571: /* select_item ::= common_expression */ yytestcase(yyruleno==571); case 581: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==581); - 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); -{ yylhsminor.yy490 = releaseRawExprNode(pCxt, yymsp[0].minor.yy490); } - yymsp[0].minor.yy490 = yylhsminor.yy490; + case 624: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==624); + case 626: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==626); + case 639: /* search_condition ::= common_expression */ yytestcase(yyruleno==639); +{ yylhsminor.yy360 = releaseRawExprNode(pCxt, yymsp[0].minor.yy360); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 429: /* signed_literal ::= NULL */ -{ yylhsminor.yy490 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 431: /* signed_literal ::= NK_QUESTION */ -{ yylhsminor.yy490 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 449: /* expression ::= pseudo_column */ -{ yylhsminor.yy490 = yymsp[0].minor.yy490; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy490, true); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = yymsp[0].minor.yy360; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy360, true); } + yymsp[0].minor.yy360 = yylhsminor.yy360; 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); -{ yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy490)); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; + case 638: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==638); +{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy360)); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 454: /* expression ::= NK_PLUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy490); - yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy490)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy360)); } - yymsp[-1].minor.yy490 = yylhsminor.yy490; + yymsp[-1].minor.yy360 = yylhsminor.yy360; break; case 455: /* expression ::= NK_MINUS expr_or_subquery */ { - 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)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy360), NULL)); } - yymsp[-1].minor.yy490 = yylhsminor.yy490; + yymsp[-1].minor.yy360 = yylhsminor.yy360; break; case 456: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 457: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 458: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 459: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 460: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 461: /* expression ::= column_reference NK_ARROW NK_STRING */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 462: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 463: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 466: /* column_reference ::= column_name */ -{ yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy561, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy561)); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy929, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy929)); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 467: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy561, createColumnNode(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy561)); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929, createColumnNode(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929)); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 468: /* column_reference ::= NK_ALIAS */ -{ yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 469: /* column_reference ::= table_name NK_DOT NK_ALIAS */ -{ yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 470: /* pseudo_column ::= ROWTS */ case 471: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==471); @@ -6233,342 +6517,348 @@ 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); -{ yylhsminor.yy490 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 472: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ 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)))); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy929)))); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; 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); -{ yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy561, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy561, yymsp[-1].minor.yy502)); } - yymsp[-3].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy929, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy929, yymsp[-1].minor.yy536)); } + yymsp[-3].minor.yy360 = yylhsminor.yy360; break; case 484: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ -{ yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy490), yymsp[-1].minor.yy826)); } - yymsp[-5].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), yymsp[-1].minor.yy912)); } + yymsp[-5].minor.yy360 = yylhsminor.yy360; break; case 486: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy561, NULL)); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy929, NULL)); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 501: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy502 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy502 = yylhsminor.yy502; +{ yylhsminor.yy536 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy536 = yylhsminor.yy536; 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); -{ yylhsminor.yy490 = createColumnNode(pCxt, &yymsp[-2].minor.yy561, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createColumnNode(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 507: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -{ yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy502, yymsp[-1].minor.yy490)); } - yymsp[-3].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy536, yymsp[-1].minor.yy360)); } + yymsp[-3].minor.yy360 = yylhsminor.yy360; break; case 508: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -{ 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)); } - yymsp[-4].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), yymsp[-2].minor.yy536, yymsp[-1].minor.yy360)); } + yymsp[-4].minor.yy360 = yylhsminor.yy360; break; case 511: /* when_then_expr ::= WHEN common_expression THEN common_expression */ -{ yymsp[-3].minor.yy490 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), releaseRawExprNode(pCxt, yymsp[0].minor.yy490)); } +{ yymsp[-3].minor.yy360 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360)); } break; case 513: /* case_when_else_opt ::= ELSE common_expression */ -{ yymsp[-1].minor.yy490 = releaseRawExprNode(pCxt, yymsp[0].minor.yy490); } +{ yymsp[-1].minor.yy360 = releaseRawExprNode(pCxt, yymsp[0].minor.yy360); } 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); { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy252, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 515: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy360); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy360), releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); } - yymsp[-4].minor.yy490 = yylhsminor.yy490; + yymsp[-4].minor.yy360 = yylhsminor.yy360; break; case 516: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy360); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy360), releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); } - yymsp[-5].minor.yy490 = yylhsminor.yy490; + yymsp[-5].minor.yy360 = yylhsminor.yy360; break; case 517: /* predicate ::= expr_or_subquery IS NULL */ { - 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)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), NULL)); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 518: /* predicate ::= expr_or_subquery IS NOT NULL */ { - 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)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), NULL)); } - yymsp[-3].minor.yy490 = yylhsminor.yy490; + yymsp[-3].minor.yy360 = yylhsminor.yy360; break; case 520: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy30 = OP_TYPE_LOWER_THAN; } +{ yymsp[0].minor.yy252 = OP_TYPE_LOWER_THAN; } break; case 521: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy30 = OP_TYPE_GREATER_THAN; } +{ yymsp[0].minor.yy252 = OP_TYPE_GREATER_THAN; } break; case 522: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy30 = OP_TYPE_LOWER_EQUAL; } +{ yymsp[0].minor.yy252 = OP_TYPE_LOWER_EQUAL; } break; case 523: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy30 = OP_TYPE_GREATER_EQUAL; } +{ yymsp[0].minor.yy252 = OP_TYPE_GREATER_EQUAL; } break; case 524: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy30 = OP_TYPE_NOT_EQUAL; } +{ yymsp[0].minor.yy252 = OP_TYPE_NOT_EQUAL; } break; case 525: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy30 = OP_TYPE_EQUAL; } +{ yymsp[0].minor.yy252 = OP_TYPE_EQUAL; } break; case 526: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy30 = OP_TYPE_LIKE; } +{ yymsp[0].minor.yy252 = OP_TYPE_LIKE; } break; case 527: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy30 = OP_TYPE_NOT_LIKE; } +{ yymsp[-1].minor.yy252 = OP_TYPE_NOT_LIKE; } break; case 528: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy30 = OP_TYPE_MATCH; } +{ yymsp[0].minor.yy252 = OP_TYPE_MATCH; } break; case 529: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy30 = OP_TYPE_NMATCH; } +{ yymsp[0].minor.yy252 = OP_TYPE_NMATCH; } break; case 530: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy30 = OP_TYPE_JSON_CONTAINS; } +{ yymsp[0].minor.yy252 = OP_TYPE_JSON_CONTAINS; } break; case 531: /* in_op ::= IN */ -{ yymsp[0].minor.yy30 = OP_TYPE_IN; } +{ yymsp[0].minor.yy252 = OP_TYPE_IN; } break; case 532: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy30 = OP_TYPE_NOT_IN; } +{ yymsp[-1].minor.yy252 = OP_TYPE_NOT_IN; } break; case 533: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -{ yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy502)); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy536)); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 535: /* boolean_value_expression ::= NOT boolean_primary */ { - 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)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy360), NULL)); } - yymsp[-1].minor.yy490 = yylhsminor.yy490; + yymsp[-1].minor.yy360 = yylhsminor.yy360; break; case 536: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 537: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy360); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy360); + yylhsminor.yy360 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 545: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy490 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy490, yymsp[0].minor.yy490, NULL); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy360, yymsp[0].minor.yy360, NULL); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; case 548: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy490 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy561, &yymsp[0].minor.yy561); } - yymsp[-1].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy929, &yymsp[0].minor.yy929); } + yymsp[-1].minor.yy360 = yylhsminor.yy360; break; case 549: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy490 = createRealTableNode(pCxt, &yymsp[-3].minor.yy561, &yymsp[-1].minor.yy561, &yymsp[0].minor.yy561); } - yymsp[-3].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createRealTableNode(pCxt, &yymsp[-3].minor.yy929, &yymsp[-1].minor.yy929, &yymsp[0].minor.yy929); } + yymsp[-3].minor.yy360 = yylhsminor.yy360; break; case 550: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy490 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy490), &yymsp[0].minor.yy561); } - yymsp[-1].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy360), &yymsp[0].minor.yy929); } + yymsp[-1].minor.yy360 = yylhsminor.yy360; break; case 552: /* alias_opt ::= */ -{ yymsp[1].minor.yy561 = nil_token; } +{ yymsp[1].minor.yy929 = nil_token; } break; case 554: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy561 = yymsp[0].minor.yy561; } +{ yymsp[-1].minor.yy929 = yymsp[0].minor.yy929; } 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); -{ yymsp[-2].minor.yy490 = yymsp[-1].minor.yy490; } +{ yymsp[-2].minor.yy360 = yymsp[-1].minor.yy360; } break; case 557: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy490 = createJoinTableNode(pCxt, yymsp[-4].minor.yy246, yymsp[-5].minor.yy490, yymsp[-2].minor.yy490, yymsp[0].minor.yy490); } - yymsp[-5].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createJoinTableNode(pCxt, yymsp[-4].minor.yy596, yymsp[-5].minor.yy360, yymsp[-2].minor.yy360, yymsp[0].minor.yy360); } + yymsp[-5].minor.yy360 = yylhsminor.yy360; break; case 558: /* join_type ::= */ -{ yymsp[1].minor.yy246 = JOIN_TYPE_INNER; } +{ yymsp[1].minor.yy596 = JOIN_TYPE_INNER; } break; case 559: /* join_type ::= INNER */ -{ yymsp[0].minor.yy246 = JOIN_TYPE_INNER; } +{ yymsp[0].minor.yy596 = JOIN_TYPE_INNER; } 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 */ { - 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); - yymsp[-13].minor.yy490 = addWhereClause(pCxt, yymsp[-13].minor.yy490, yymsp[-7].minor.yy490); - yymsp[-13].minor.yy490 = addPartitionByClause(pCxt, yymsp[-13].minor.yy490, yymsp[-6].minor.yy502); - yymsp[-13].minor.yy490 = addWindowClauseClause(pCxt, yymsp[-13].minor.yy490, yymsp[-2].minor.yy490); - yymsp[-13].minor.yy490 = addGroupByClause(pCxt, yymsp[-13].minor.yy490, yymsp[-1].minor.yy502); - yymsp[-13].minor.yy490 = addHavingClause(pCxt, yymsp[-13].minor.yy490, yymsp[0].minor.yy490); - yymsp[-13].minor.yy490 = addRangeClause(pCxt, yymsp[-13].minor.yy490, yymsp[-5].minor.yy490); - 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); + yymsp[-13].minor.yy360 = createSelectStmt(pCxt, yymsp[-11].minor.yy345, yymsp[-9].minor.yy536, yymsp[-8].minor.yy360, yymsp[-12].minor.yy536); + yymsp[-13].minor.yy360 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy360, yymsp[-10].minor.yy345); + yymsp[-13].minor.yy360 = addWhereClause(pCxt, yymsp[-13].minor.yy360, yymsp[-7].minor.yy360); + yymsp[-13].minor.yy360 = addPartitionByClause(pCxt, yymsp[-13].minor.yy360, yymsp[-6].minor.yy536); + yymsp[-13].minor.yy360 = addWindowClauseClause(pCxt, yymsp[-13].minor.yy360, yymsp[-2].minor.yy360); + yymsp[-13].minor.yy360 = addGroupByClause(pCxt, yymsp[-13].minor.yy360, yymsp[-1].minor.yy536); + yymsp[-13].minor.yy360 = addHavingClause(pCxt, yymsp[-13].minor.yy360, yymsp[0].minor.yy360); + yymsp[-13].minor.yy360 = addRangeClause(pCxt, yymsp[-13].minor.yy360, yymsp[-5].minor.yy360); + yymsp[-13].minor.yy360 = addEveryClause(pCxt, yymsp[-13].minor.yy360, yymsp[-4].minor.yy360); + yymsp[-13].minor.yy360 = addFillClause(pCxt, yymsp[-13].minor.yy360, yymsp[-3].minor.yy360); } break; case 561: /* hint_list ::= */ -{ yymsp[1].minor.yy502 = createHintNodeList(pCxt, NULL); } +{ yymsp[1].minor.yy536 = createHintNodeList(pCxt, NULL); } break; case 562: /* hint_list ::= NK_HINT */ -{ yylhsminor.yy502 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy502 = yylhsminor.yy502; +{ yylhsminor.yy536 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy536 = yylhsminor.yy536; break; case 567: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy845 = false; } +{ yymsp[0].minor.yy345 = false; } break; case 570: /* select_item ::= NK_STAR */ -{ yylhsminor.yy490 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy360 = yylhsminor.yy360; break; case 572: /* select_item ::= common_expression column_alias */ case 582: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==582); -{ yylhsminor.yy490 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy490), &yymsp[0].minor.yy561); } - yymsp[-1].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy360), &yymsp[0].minor.yy929); } + yymsp[-1].minor.yy360 = yylhsminor.yy360; break; case 573: /* select_item ::= common_expression AS column_alias */ case 583: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==583); -{ yylhsminor.yy490 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), &yymsp[0].minor.yy561); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; +{ yylhsminor.yy360 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), &yymsp[0].minor.yy929); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; 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); -{ yymsp[-2].minor.yy502 = yymsp[0].minor.yy502; } + case 608: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==608); + case 628: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==628); +{ yymsp[-2].minor.yy536 = yymsp[0].minor.yy536; } break; case 585: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ -{ yymsp[-5].minor.yy490 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy490), releaseRawExprNode(pCxt, yymsp[-1].minor.yy490)); } +{ yymsp[-5].minor.yy360 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), releaseRawExprNode(pCxt, yymsp[-1].minor.yy360)); } break; case 586: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy490 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy490)); } +{ yymsp[-3].minor.yy360 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy360)); } break; case 587: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy490 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy490), NULL, yymsp[-1].minor.yy490, yymsp[0].minor.yy490); } +{ yymsp[-5].minor.yy360 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), NULL, yymsp[-1].minor.yy360, yymsp[0].minor.yy360); } 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 */ -{ 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); } +{ yymsp[-7].minor.yy360 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy360), releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), yymsp[-1].minor.yy360, yymsp[0].minor.yy360); } break; case 589: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ -{ yymsp[-6].minor.yy490 = createEventWindowNode(pCxt, yymsp[-3].minor.yy490, yymsp[0].minor.yy490); } +{ yymsp[-6].minor.yy360 = createEventWindowNode(pCxt, yymsp[-3].minor.yy360, yymsp[0].minor.yy360); } break; - case 596: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy490 = createFillNode(pCxt, yymsp[-1].minor.yy718, NULL); } + case 590: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy360 = createCountWindowNode(pCxt, &yymsp[-1].minor.yy0, &yymsp[-1].minor.yy0); } break; - case 597: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ -{ yymsp[-5].minor.yy490 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy502)); } + case 591: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy360 = createCountWindowNode(pCxt, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0); } break; - case 598: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ -{ yymsp[-5].minor.yy490 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy502)); } + case 598: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy360 = createFillNode(pCxt, yymsp[-1].minor.yy358, NULL); } break; - case 599: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy718 = FILL_MODE_NONE; } + case 599: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ +{ yymsp[-5].minor.yy360 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy536)); } break; - case 600: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy718 = FILL_MODE_PREV; } + case 600: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ +{ yymsp[-5].minor.yy360 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy536)); } break; - case 601: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy718 = FILL_MODE_NULL; } + case 601: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy358 = FILL_MODE_NONE; } break; - case 602: /* fill_mode ::= NULL_F */ -{ yymsp[0].minor.yy718 = FILL_MODE_NULL_F; } + case 602: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy358 = FILL_MODE_PREV; } break; - case 603: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy718 = FILL_MODE_LINEAR; } + case 603: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy358 = FILL_MODE_NULL; } break; - case 604: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy718 = FILL_MODE_NEXT; } + case 604: /* fill_mode ::= NULL_F */ +{ yymsp[0].minor.yy358 = FILL_MODE_NULL_F; } break; - case 607: /* group_by_list ::= expr_or_subquery */ -{ yylhsminor.yy502 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy490))); } - yymsp[0].minor.yy502 = yylhsminor.yy502; + case 605: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy358 = FILL_MODE_LINEAR; } break; - case 608: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -{ yylhsminor.yy502 = addNodeToList(pCxt, yymsp[-2].minor.yy502, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy490))); } - yymsp[-2].minor.yy502 = yylhsminor.yy502; + case 606: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy358 = FILL_MODE_NEXT; } break; - case 612: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -{ yymsp[-5].minor.yy490 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy490), releaseRawExprNode(pCxt, yymsp[-1].minor.yy490)); } + case 609: /* group_by_list ::= expr_or_subquery */ +{ yylhsminor.yy536 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); } + yymsp[0].minor.yy536 = yylhsminor.yy536; break; - case 613: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy490 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy490)); } + case 610: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ +{ yylhsminor.yy536 = addNodeToList(pCxt, yymsp[-2].minor.yy536, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy360))); } + yymsp[-2].minor.yy536 = yylhsminor.yy536; break; - case 616: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 614: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +{ yymsp[-5].minor.yy360 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy360), releaseRawExprNode(pCxt, yymsp[-1].minor.yy360)); } + break; + case 615: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ +{ yymsp[-3].minor.yy360 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy360)); } + break; + case 618: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - 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); + yylhsminor.yy360 = addOrderByClause(pCxt, yymsp[-3].minor.yy360, yymsp[-2].minor.yy536); + yylhsminor.yy360 = addSlimitClause(pCxt, yylhsminor.yy360, yymsp[-1].minor.yy360); + yylhsminor.yy360 = addLimitClause(pCxt, yylhsminor.yy360, yymsp[0].minor.yy360); } - yymsp[-3].minor.yy490 = yylhsminor.yy490; + yymsp[-3].minor.yy360 = yylhsminor.yy360; break; - case 619: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -{ yylhsminor.yy490 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy490, yymsp[0].minor.yy490); } - yymsp[-3].minor.yy490 = yylhsminor.yy490; + case 621: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +{ yylhsminor.yy360 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy360, yymsp[0].minor.yy360); } + yymsp[-3].minor.yy360 = yylhsminor.yy360; break; - case 620: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -{ yylhsminor.yy490 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy490, yymsp[0].minor.yy490); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; + case 622: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +{ yylhsminor.yy360 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy360, yymsp[0].minor.yy360); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; - case 628: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 632: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==632); -{ yymsp[-1].minor.yy490 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 630: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 634: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==634); +{ yymsp[-1].minor.yy360 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } 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); -{ yymsp[-3].minor.yy490 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 631: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 635: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==635); +{ yymsp[-3].minor.yy360 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } 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); -{ yymsp[-3].minor.yy490 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 632: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 636: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==636); +{ yymsp[-3].minor.yy360 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 635: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy490 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy490); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; + case 637: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy360 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy360); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; - case 640: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy490 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy490), yymsp[-1].minor.yy876, yymsp[0].minor.yy361); } - yymsp[-2].minor.yy490 = yylhsminor.yy490; + case 642: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy360 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy360), yymsp[-1].minor.yy642, yymsp[0].minor.yy585); } + yymsp[-2].minor.yy360 = yylhsminor.yy360; break; - case 641: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy876 = ORDER_ASC; } + case 643: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy642 = ORDER_ASC; } break; - case 642: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy876 = ORDER_ASC; } + case 644: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy642 = ORDER_ASC; } break; - case 643: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy876 = ORDER_DESC; } + case 645: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy642 = ORDER_DESC; } break; - case 644: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy361 = NULL_ORDER_DEFAULT; } + case 646: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy585 = NULL_ORDER_DEFAULT; } break; - case 645: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy361 = NULL_ORDER_FIRST; } + case 647: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy585 = NULL_ORDER_FIRST; } break; - case 646: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy361 = NULL_ORDER_LAST; } + case 648: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy585 = NULL_ORDER_LAST; } break; default: break; @@ -6725,12 +7015,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 +7120,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 +7176,7 @@ void Parse( break; #endif } - }while( yypParser->yytos>yypParser->yystack ); + } #ifndef NDEBUG if( yyTraceFILE ){ yyStackEntry *i; diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 12b7360165..0657335e36 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -1008,6 +1008,29 @@ static int32_t createWindowLogicNodeByEvent(SLogicPlanContext* pCxt, SEventWindo return createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode); } +static int32_t createWindowLogicNodeByCount(SLogicPlanContext* pCxt, SCountWindowNode* pCount, SSelectStmt* pSelect, + SLogicNode** pLogicNode) { + SWindowLogicNode* pWindow = (SWindowLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_WINDOW); + if (NULL == pWindow) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + pWindow->winType = WINDOW_TYPE_COUNT; + pWindow->node.groupAction = getGroupAction(pCxt, pSelect); + pWindow->node.requireDataOrder = + pCxt->pPlanCxt->streamQuery ? DATA_ORDER_LEVEL_IN_BLOCK : getRequireDataOrder(true, pSelect); + pWindow->node.resultDataOrder = + pCxt->pPlanCxt->streamQuery ? DATA_ORDER_LEVEL_GLOBAL : pWindow->node.requireDataOrder; + pWindow->windowCount = pCount->windowCount; + pWindow->windowSliding = pCount->windowSliding; + pWindow->pTspk = nodesCloneNode(pCount->pCol); + if (NULL == pWindow->pTspk) { + nodesDestroyNode((SNode*)pWindow); + return TSDB_CODE_OUT_OF_MEMORY; + } + return createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode); +} + static int32_t createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { if (NULL == pSelect->pWindow) { return TSDB_CODE_SUCCESS; @@ -1021,6 +1044,8 @@ static int32_t createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele return createWindowLogicNodeByInterval(pCxt, (SIntervalWindowNode*)pSelect->pWindow, pSelect, pLogicNode); case QUERY_NODE_EVENT_WINDOW: return createWindowLogicNodeByEvent(pCxt, (SEventWindowNode*)pSelect->pWindow, pSelect, pLogicNode); + case QUERY_NODE_COUNT_WINDOW: + return createWindowLogicNodeByCount(pCxt, (SCountWindowNode*)pSelect->pWindow, pSelect, pLogicNode); default: break; } diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index dde3b23b29..8f92da85ba 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1751,6 +1751,27 @@ static int32_t createEventWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pC return code; } +static int32_t createCountWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, + SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) { + SCountWinodwPhysiNode* pCount = (SCountWinodwPhysiNode*)makePhysiNode( + pCxt, (SLogicNode*)pWindowLogicNode, + (pCxt->pPlanCxt->streamQuery ? QUERY_NODE_PHYSICAL_PLAN_STREAM_COUNT : QUERY_NODE_PHYSICAL_PLAN_MERGE_COUNT)); + if (NULL == pCount) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCount->windowCount = pWindowLogicNode->windowCount; + pCount->windowSliding = pWindowLogicNode->windowSliding; + + int32_t code = createWindowPhysiNodeFinalize(pCxt, pChildren, &pCount->window, pWindowLogicNode); + if (TSDB_CODE_SUCCESS == code) { + *pPhyNode = (SPhysiNode*)pCount; + } else { + nodesDestroyNode((SNode*)pCount); + } + + return code; +} + static int32_t createWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SWindowLogicNode* pWindowLogicNode, SPhysiNode** pPhyNode) { switch (pWindowLogicNode->winType) { @@ -1762,6 +1783,8 @@ static int32_t createWindowPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildr return createStateWindowPhysiNode(pCxt, pChildren, pWindowLogicNode, pPhyNode); case WINDOW_TYPE_EVENT: return createEventWindowPhysiNode(pCxt, pChildren, pWindowLogicNode, pPhyNode); + case WINDOW_TYPE_COUNT: + return createCountWindowPhysiNode(pCxt, pChildren, pWindowLogicNode, pPhyNode); default: break; } diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 4099f2be42..d9a7475f59 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -872,6 +872,18 @@ static int32_t stbSplSplitEvent(SSplitContext* pCxt, SStableSplitInfo* pInfo) { } } +static int32_t stbSplSplitCountForStream(SSplitContext* pCxt, SStableSplitInfo* pInfo) { + return TSDB_CODE_PLAN_INTERNAL_ERROR; +} + +static int32_t stbSplSplitCount(SSplitContext* pCxt, SStableSplitInfo* pInfo) { + if (pCxt->pPlanCxt->streamQuery) { + return stbSplSplitCountForStream(pCxt, pInfo); + } else { + return stbSplSplitSessionOrStateForBatch(pCxt, pInfo); + } +} + static int32_t stbSplSplitWindowForCrossTable(SSplitContext* pCxt, SStableSplitInfo* pInfo) { switch (((SWindowLogicNode*)pInfo->pSplitNode)->winType) { case WINDOW_TYPE_INTERVAL: @@ -882,6 +894,8 @@ static int32_t stbSplSplitWindowForCrossTable(SSplitContext* pCxt, SStableSplitI return stbSplSplitState(pCxt, pInfo); case WINDOW_TYPE_EVENT: return stbSplSplitEvent(pCxt, pInfo); + case WINDOW_TYPE_COUNT: + return stbSplSplitCount(pCxt, pInfo); default: break; } diff --git a/source/libs/planner/src/planUtil.c b/source/libs/planner/src/planUtil.c index aeef3f2487..74b325a298 100644 --- a/source/libs/planner/src/planUtil.c +++ b/source/libs/planner/src/planUtil.c @@ -237,6 +237,15 @@ static int32_t adjustEventDataRequirement(SWindowLogicNode* pWindow, EDataOrderL return TSDB_CODE_SUCCESS; } +static int32_t adjustCountDataRequirement(SWindowLogicNode* pWindow, EDataOrderLevel requirement) { + if (requirement <= pWindow->node.resultDataOrder) { + return TSDB_CODE_SUCCESS; + } + pWindow->node.resultDataOrder = requirement; + pWindow->node.requireDataOrder = requirement; + return TSDB_CODE_SUCCESS; +} + static int32_t adjustWindowDataRequirement(SWindowLogicNode* pWindow, EDataOrderLevel requirement) { switch (pWindow->winType) { case WINDOW_TYPE_INTERVAL: @@ -247,6 +256,8 @@ static int32_t adjustWindowDataRequirement(SWindowLogicNode* pWindow, EDataOrder return adjustStateDataRequirement(pWindow, requirement); case WINDOW_TYPE_EVENT: return adjustEventDataRequirement(pWindow, requirement); + case WINDOW_TYPE_COUNT: + return adjustCountDataRequirement(pWindow, requirement); default: break; } 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/src/schUtil.c b/source/libs/scheduler/src/schUtil.c index 39c54ea731..47e6d53b46 100644 --- a/source/libs/scheduler/src/schUtil.c +++ b/source/libs/scheduler/src/schUtil.c @@ -263,6 +263,7 @@ void schCloseJobRef(void) { uint64_t schGenTaskId(void) { return atomic_add_fetch_64(&schMgmt.taskId, 1); } +#ifdef BUILD_NO_CALL uint64_t schGenUUID(void) { static uint64_t hashId = 0; static int32_t requestSerialId = 0; @@ -284,6 +285,7 @@ uint64_t schGenUUID(void) { uint64_t id = ((hashId & 0x0FFF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); return id; } +#endif void schFreeRpcCtxVal(const void *arg) { if (NULL == arg) { diff --git a/source/libs/scheduler/test/CMakeLists.txt b/source/libs/scheduler/test/CMakeLists.txt index 703bd5932b..9605cc7a1c 100644 --- a/source/libs/scheduler/test/CMakeLists.txt +++ b/source/libs/scheduler/test/CMakeLists.txt @@ -25,4 +25,9 @@ IF(NOT TD_DARWIN) PUBLIC "${TD_SOURCE_DIR}/include/libs/scheduler/" PRIVATE "${TD_SOURCE_DIR}/source/libs/scheduler/inc" ) + add_test( + NAME schedulerTest + COMMAND schedulerTest + ) + ENDIF() \ No newline at end of file diff --git a/source/libs/scheduler/test/schedulerTests.cpp b/source/libs/scheduler/test/schedulerTests.cpp index 5605a4b842..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,17 @@ TEST(multiThread, forceFree) { } schtTestStop = true; - taosSsleep(3); + //taosSsleep(3); +} + +TEST(otherTest, otherCase) { + // excpet test + schReleaseJob(0); + schFreeRpcCtx(NULL); + + ASSERT_EQ(schDumpEpSet(NULL), (char*)NULL); + ASSERT_EQ(strcmp(schGetOpStr(SCH_OP_NULL), "NULL"), 0); + ASSERT_EQ(strcmp(schGetOpStr((SCH_OP_TYPE)100), "UNKNOWN"), 0); } int main(int argc, char **argv) { diff --git a/source/libs/stream/inc/streamBackendRocksdb.h b/source/libs/stream/inc/streamBackendRocksdb.h index b89664a6c1..03f70604b7 100644 --- a/source/libs/stream/inc/streamBackendRocksdb.h +++ b/source/libs/stream/inc/streamBackendRocksdb.h @@ -179,7 +179,8 @@ int32_t streamStateSessionDel_rocksdb(SStreamState* pState, const SSessionKey* k SStreamStateCur* streamStateSessionSeekKeyCurrentPrev_rocksdb(SStreamState* pState, const SSessionKey* key); SStreamStateCur* streamStateSessionSeekKeyCurrentNext_rocksdb(SStreamState* pState, SSessionKey* key); SStreamStateCur* streamStateSessionSeekKeyNext_rocksdb(SStreamState* pState, const SSessionKey* key); -SStreamStateCur* streamStateSessionSeekToLast_rocksdb(SStreamState* pState); +SStreamStateCur* streamStateSessionSeekKeyPrev_rocksdb(SStreamState* pState, const SSessionKey* key); +SStreamStateCur* streamStateSessionSeekToLast_rocksdb(SStreamState* pState, int64_t groupId); int32_t streamStateSessionCurPrev_rocksdb(SStreamStateCur* pCur); int32_t streamStateSessionGetKVByCur_rocksdb(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen); diff --git a/source/libs/stream/inc/streamInt.h b/source/libs/stream/inc/streamInt.h index 300b0a7f24..87f63b48ed 100644 --- a/source/libs/stream/inc/streamInt.h +++ b/source/libs/stream/inc/streamInt.h @@ -109,8 +109,6 @@ void destroyStreamDataBlock(SStreamDataBlock* pBlock); int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock* pData); int32_t streamBroadcastToUpTasks(SStreamTask* pTask, const SSDataBlock* pBlock); -int32_t tEncodeStreamRetrieveReq(SEncoder* pEncoder, const SStreamRetrieveReq* pReq); - int32_t streamSaveTaskCheckpointInfo(SStreamTask* p, int64_t checkpointId); int32_t streamSendCheckMsg(SStreamTask* pTask, const SStreamTaskCheckReq* pReq, int32_t nodeId, SEpSet* pEpSet); diff --git a/source/libs/stream/src/streamBackendRocksdb.c b/source/libs/stream/src/streamBackendRocksdb.c index acec9b7da9..f173157da6 100644 --- a/source/libs/stream/src/streamBackendRocksdb.c +++ b/source/libs/stream/src/streamBackendRocksdb.c @@ -2883,13 +2883,13 @@ int32_t streamStateSessionDel_rocksdb(SStreamState* pState, const SSessionKey* k return code; } -SStreamStateCur* streamStateSessionSeekToLast_rocksdb(SStreamState* pState) { +SStreamStateCur* streamStateSessionSeekToLast_rocksdb(SStreamState* pState, int64_t groupId) { stDebug("streamStateSessionSeekToLast_rocksdb"); int32_t code = 0; - SSessionKey maxSessionKey = {.groupId = UINT64_MAX, .win = {.skey = INT64_MAX, .ekey = INT64_MAX}}; - SStateSessionKey maxKey = {.key = maxSessionKey, .opNum = INT64_MAX}; + SSessionKey maxSessionKey = {.groupId = groupId, .win = {.skey = INT64_MAX, .ekey = INT64_MAX}}; + SStateSessionKey maxKey = {.key = maxSessionKey, .opNum = pState->number}; STREAM_STATE_PUT_ROCKSDB(pState, "sess", &maxKey, "", 0); if (code != 0) { @@ -3048,6 +3048,46 @@ SStreamStateCur* streamStateSessionSeekKeyNext_rocksdb(SStreamState* pState, con return pCur; } +SStreamStateCur* streamStateSessionSeekKeyPrev_rocksdb(SStreamState* pState, const SSessionKey* key) { + stDebug("streamStateSessionSeekKeyPrev_rocksdb"); + STaskDbWrapper* wrapper = pState->pTdbState->pOwner->pBackend; + SStreamStateCur* pCur = createStreamStateCursor(); + if (pCur == NULL) { + return NULL; + } + pCur->db = wrapper->db; + pCur->iter = streamStateIterCreate(pState, "sess", (rocksdb_snapshot_t**)&pCur->snapshot, + (rocksdb_readoptions_t**)&pCur->readOpt); + pCur->number = pState->number; + + SStateSessionKey sKey = {.key = *key, .opNum = pState->number}; + + char buf[128] = {0}; + int len = stateSessionKeyEncode(&sKey, buf); + if (!streamStateIterSeekAndValid(pCur->iter, buf, len)) { + streamStateFreeCur(pCur); + return NULL; + } + while (rocksdb_iter_valid(pCur->iter) && iterValueIsStale(pCur->iter)) rocksdb_iter_prev(pCur->iter); + if (!rocksdb_iter_valid(pCur->iter)) { + streamStateFreeCur(pCur); + return NULL; + } + + size_t klen; + const char* iKey = rocksdb_iter_key(pCur->iter, &klen); + SStateSessionKey curKey = {0}; + stateSessionKeyDecode(&curKey, (char*)iKey); + if (stateSessionKeyCmpr(&sKey, sizeof(sKey), &curKey, sizeof(curKey)) > 0) return pCur; + + rocksdb_iter_prev(pCur->iter); + if (!rocksdb_iter_valid(pCur->iter)) { + streamStateFreeCur(pCur); + return NULL; + } + return pCur; +} + int32_t streamStateSessionGetKVByCur_rocksdb(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen) { stDebug("streamStateSessionGetKVByCur_rocksdb"); if (!pCur) { diff --git a/source/libs/stream/src/streamCheckpoint.c b/source/libs/stream/src/streamCheckpoint.c index b1783fb640..607e31bfe6 100644 --- a/source/libs/stream/src/streamCheckpoint.c +++ b/source/libs/stream/src/streamCheckpoint.c @@ -68,18 +68,6 @@ int32_t tEncodeStreamCheckpointSourceRsp(SEncoder* pEncoder, const SStreamCheckp return pEncoder->pos; } -int32_t tDecodeStreamCheckpointSourceRsp(SDecoder* pDecoder, SStreamCheckpointSourceRsp* pRsp) { - if (tStartDecode(pDecoder) < 0) return -1; - if (tDecodeI64(pDecoder, &pRsp->streamId) < 0) return -1; - if (tDecodeI64(pDecoder, &pRsp->checkpointId) < 0) return -1; - if (tDecodeI32(pDecoder, &pRsp->taskId) < 0) return -1; - if (tDecodeI32(pDecoder, &pRsp->nodeId) < 0) return -1; - if (tDecodeI64(pDecoder, &pRsp->expireTime) < 0) return -1; - if (tDecodeI8(pDecoder, &pRsp->success) < 0) return -1; - tEndDecode(pDecoder); - return 0; -} - int32_t tEncodeStreamCheckpointReadyMsg(SEncoder* pEncoder, const SStreamCheckpointReadyMsg* pReq) { if (tStartEncode(pEncoder) < 0) return -1; if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1; @@ -512,7 +500,7 @@ int32_t streamTaskBuildCheckpoint(SStreamTask* pTask) { SStreamTaskId hTaskId = {.streamId = pTask->hTaskInfo.id.streamId, .taskId = pTask->hTaskInfo.id.taskId}; stDebug("s-task:%s fill-history finish checkpoint done, drop related fill-history task:0x%x", id, hTaskId.taskId); - streamBuildAndSendDropTaskMsg(pTask->pMsgCb, pTask->pMeta->vgId, &hTaskId); + streamBuildAndSendDropTaskMsg(pTask->pMsgCb, pTask->pMeta->vgId, &hTaskId, 1); } else { stWarn("s-task:%s related fill-history task:0x%x is erased", id, (int32_t)pTask->hTaskInfo.id.taskId); } diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 98d9a29c87..9383383dc0 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -162,6 +162,8 @@ 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); @@ -174,7 +176,7 @@ void sendRetrieveRsp(SStreamRetrieveReq *pReq, SRpcMsg* pRsp){ tmsgSendRsp(pRsp); } -int32_t broadcastRetrieveMsg(SStreamTask* pTask, SStreamRetrieveReq *req){ +int32_t broadcastRetrieveMsg(SStreamTask* pTask, SStreamRetrieveReq* req) { int32_t code = 0; void* buf = NULL; int32_t sz = taosArrayGetSize(pTask->upstreamInfo.pList); @@ -569,6 +571,7 @@ int32_t streamSearchAndAddBlock(SStreamTask* pTask, SStreamDispatchReq* pReqs, S char ctbName[TSDB_TABLE_FNAME_LEN] = {0}; if (pDataBlock->info.parTbName[0]) { if(pTask->ver >= SSTREAM_TASK_SUBTABLE_CHANGED_VER && + pTask->subtableWithoutMd5 != 1 && !isAutoTableName(pDataBlock->info.parTbName) && !alreadyAddGroupId(pDataBlock->info.parTbName) && groupId != 0){ diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index 840a7678f2..bac6022834 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -328,7 +328,7 @@ int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask) { id, (int32_t) pTask->streamTaskId.taskId); // 1. free it and remove fill-history task from disk meta-store - streamBuildAndSendDropTaskMsg(pTask->pMsgCb, pMeta->vgId, &pTask->id); + streamBuildAndSendDropTaskMsg(pTask->pMsgCb, pMeta->vgId, &pTask->id, 0); // 2. save to disk streamMetaWLock(pMeta); diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index db74ce9897..ab519e2b4b 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -725,9 +725,6 @@ int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t t // it is an fill-history task, remove the related stream task's id that points to it atomic_sub_fetch_32(&pMeta->numOfStreamTasks, 1); - if (pTask->info.fillHistory == 1) { - streamTaskClearHTaskAttr(pTask, false); - } taosHashRemove(pMeta->pTasksMap, &id, sizeof(id)); doRemoveIdFromList(pMeta, (int32_t)taosArrayGetSize(pMeta->pTaskList), &pTask->id); diff --git a/source/libs/stream/src/streamSessionState.c b/source/libs/stream/src/streamSessionState.c index 1f991d309f..bd28d2bca9 100644 --- a/source/libs/stream/src/streamSessionState.c +++ b/source/libs/stream/src/streamSessionState.c @@ -28,6 +28,12 @@ int sessionStateKeyCompare(const SSessionKey* pWin1, const void* pDatas, int pos return sessionWinKeyCmpr(pWin1, pWin2); } +int sessionStateRangeKeyCompare(const SSessionKey* pWin1, const void* pDatas, int pos) { + SRowBuffPos* pPos2 = taosArrayGetP(pDatas, pos); + SSessionKey* pWin2 = (SSessionKey*)pPos2->pKey; + return sessionRangeKeyCmpr(pWin1, pWin2); +} + int32_t binarySearch(void* keyList, int num, const void* key, __session_compare_fn_t cmpFn) { int firstPos = 0, lastPos = num - 1, midPos = -1; int numOfRows = 0; @@ -69,6 +75,12 @@ bool inSessionWindow(SSessionKey* pKey, TSKEY ts, int64_t gap) { return false; } +SStreamStateCur* createSessionStateCursor(SStreamFileState* pFileState) { + SStreamStateCur* pCur = createStreamStateCursor(); + pCur->pStreamFileState = pFileState; + return pCur; +} + static SRowBuffPos* addNewSessionWindow(SStreamFileState* pFileState, SArray* pWinInfos, const SSessionKey* pKey) { SRowBuffPos* pNewPos = getNewRowPosForWrite(pFileState); ASSERT(pNewPos->pRowBuff); @@ -91,7 +103,12 @@ SRowBuffPos* createSessionWinBuff(SStreamFileState* pFileState, SSessionKey* pKe memcpy(pNewPos->pKey, pKey, sizeof(SSessionKey)); pNewPos->needFree = true; pNewPos->beFlushed = true; - memcpy(pNewPos->pRowBuff, p, *pVLen); + if(p) { + memcpy(pNewPos->pRowBuff, p, *pVLen); + } else { + int32_t len = getRowStateRowSize(pFileState); + memset(pNewPos->pRowBuff, 0, len); + } taosMemoryFree(p); return pNewPos; } @@ -364,9 +381,8 @@ static SStreamStateCur* seekKeyCurrentPrev_buff(SStreamFileState* pFileState, co } if (index >= 0) { - pCur = createStreamStateCursor(); + pCur = createSessionStateCursor(pFileState); pCur->buffIndex = index; - pCur->pStreamFileState = pFileState; if (pIndex) { *pIndex = index; } @@ -405,7 +421,7 @@ static void checkAndTransformCursor(SStreamFileState* pFileState, const uint64_t if (taosArrayGetSize(pWinStates) > 0 && (code == TSDB_CODE_FAILED || sessionStateKeyCompare(&key, pWinStates, 0) >= 0)) { if (!(*ppCur)) { - (*ppCur) = createStreamStateCursor(); + (*ppCur) = createSessionStateCursor(pFileState); } transformCursor(pFileState, *ppCur); } else if (*ppCur) { @@ -419,7 +435,7 @@ SStreamStateCur* sessionWinStateSeekKeyCurrentNext(SStreamFileState* pFileState, int32_t index = -1; SStreamStateCur* pCur = seekKeyCurrentPrev_buff(pFileState, pWinKey, &pWinStates, &index); if (pCur) { - if (sessionStateKeyCompare(pWinKey, pWinStates, index) > 0) { + if (sessionStateRangeKeyCompare(pWinKey, pWinStates, index) > 0) { sessionWinStateMoveToNext(pCur); } return pCur; @@ -446,6 +462,66 @@ SStreamStateCur* sessionWinStateSeekKeyNext(SStreamFileState* pFileState, const return pCur; } +SStreamStateCur* countWinStateSeekKeyPrev(SStreamFileState* pFileState, const SSessionKey* pWinKey, COUNT_TYPE count) { + SArray* pWinStates = NULL; + int32_t index = -1; + SStreamStateCur* pBuffCur = seekKeyCurrentPrev_buff(pFileState, pWinKey, &pWinStates, &index); + int32_t resSize = getRowStateRowSize(pFileState); + COUNT_TYPE winCount = 0; + if (pBuffCur) { + while (index >= 0) { + SRowBuffPos* pPos = taosArrayGetP(pWinStates, index); + winCount = *((COUNT_TYPE*) ((char*)pPos->pRowBuff + (resSize - sizeof(COUNT_TYPE)))); + if (sessionStateRangeKeyCompare(pWinKey, pWinStates, index) == 0 || winCount < count) { + index--; + } else if (index >= 0) { + pBuffCur->buffIndex = index + 1; + return pBuffCur; + } + } + pBuffCur->buffIndex = 0; + } else if (taosArrayGetSize(pWinStates) > 0) { + pBuffCur = createSessionStateCursor(pFileState); + pBuffCur->buffIndex = 0; + } + + void* pFileStore = getStateFileStore(pFileState); + SStreamStateCur* pCur = streamStateSessionSeekKeyPrev_rocksdb(pFileStore, pWinKey); + if (pCur) { + SSessionKey key = {0}; + void* pVal = NULL; + int len = 0; + int32_t code = streamStateSessionGetKVByCur_rocksdb(pCur, &key, &pVal, &len); + if (code == TSDB_CODE_FAILED) { + streamStateFreeCur(pCur); + return pBuffCur; + } + winCount = *((COUNT_TYPE*) ((char*)pVal + (resSize - sizeof(COUNT_TYPE)))); + if (sessionRangeKeyCmpr(pWinKey, &key) != 0 && winCount == count) { + streamStateFreeCur(pCur); + return pBuffCur; + } + streamStateCurPrev(pFileStore, pCur); + while (1) { + code = streamStateSessionGetKVByCur_rocksdb(pCur, &key, &pVal, &len); + if (code == TSDB_CODE_FAILED) { + streamStateCurNext(pFileStore, pCur); + streamStateFreeCur(pBuffCur); + return pCur; + } + winCount = *((COUNT_TYPE*) ((char*)pVal + (resSize - sizeof(COUNT_TYPE)))); + if (sessionRangeKeyCmpr(pWinKey, &key) == 0 || winCount < count) { + streamStateCurPrev(pFileStore, pCur); + } else { + streamStateCurNext(pFileStore, pCur); + streamStateFreeCur(pBuffCur); + return pCur; + } + } + } + return pBuffCur; +} + int32_t sessionWinStateGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen) { if (!pCur) { return TSDB_CODE_FAILED; @@ -503,7 +579,7 @@ int32_t sessionWinStateMoveToNext(SStreamStateCur* pCur) { return TSDB_CODE_SUCCESS; } -int32_t sessionWinStateGetKeyByRange(SStreamFileState* pFileState, const SSessionKey* key, SSessionKey* curKey) { +int32_t sessionWinStateGetKeyByRange(SStreamFileState* pFileState, const SSessionKey* key, SSessionKey* curKey, range_cmpr_fn cmpFn) { SStreamStateCur* pCur = sessionWinStateSeekKeyCurrentPrev(pFileState, key); SSessionKey tmpKey = *key; int32_t code = sessionWinStateGetKVByCur(pCur, &tmpKey, NULL, NULL); @@ -520,7 +596,7 @@ int32_t sessionWinStateGetKeyByRange(SStreamFileState* pFileState, const SSessio goto _end; } - if (sessionRangeKeyCmpr(key, &tmpKey) == 0) { + if (cmpFn(key, &tmpKey) == 0) { *curKey = tmpKey; goto _end; } else if (!hasCurrentPrev) { @@ -530,7 +606,7 @@ int32_t sessionWinStateGetKeyByRange(SStreamFileState* pFileState, const SSessio sessionWinStateMoveToNext(pCur); code = sessionWinStateGetKVByCur(pCur, &tmpKey, NULL, NULL); - if (code == TSDB_CODE_SUCCESS && sessionRangeKeyCmpr(key, &tmpKey) == 0) { + if (code == TSDB_CODE_SUCCESS && cmpFn(key, &tmpKey) == 0) { *curKey = tmpKey; } else { code = TSDB_CODE_FAILED; @@ -636,3 +712,143 @@ int32_t getStateWinResultBuff(SStreamFileState* pFileState, SSessionKey* key, ch _end: return code; } + +int32_t getCountWinResultBuff(SStreamFileState* pFileState, SSessionKey* pKey, COUNT_TYPE winCount, void** pVal, int32_t* pVLen) { + SSessionKey* pWinKey = pKey; + const TSKEY gap = 0; + int32_t code = TSDB_CODE_SUCCESS; + SSHashObj* pSessionBuff = getRowStateBuff(pFileState); + SArray* pWinStates = NULL; + void** ppBuff = tSimpleHashGet(pSessionBuff, &pWinKey->groupId, sizeof(uint64_t)); + if (ppBuff) { + pWinStates = (SArray*)(*ppBuff); + } else { + pWinStates = taosArrayInit(16, POINTER_BYTES); + tSimpleHashPut(pSessionBuff, &pWinKey->groupId, sizeof(uint64_t), &pWinStates, POINTER_BYTES); + } + + TSKEY startTs = pWinKey->win.skey; + TSKEY endTs = pWinKey->win.ekey; + + int32_t size = taosArrayGetSize(pWinStates); + if (size == 0) { + void* pFileStore = getStateFileStore(pFileState); + void* pRockVal = NULL; + SStreamStateCur* pCur = streamStateSessionSeekToLast_rocksdb(pFileStore, pKey->groupId); + code = streamStateSessionGetKVByCur_rocksdb(pCur, pWinKey, &pRockVal, pVLen); + if (code == TSDB_CODE_SUCCESS || isFlushedState(pFileState, endTs, 0)) { + qDebug("===stream===0 get state win:%" PRId64 ",%" PRId64 " from disc, res %d", pWinKey->win.skey, pWinKey->win.ekey, code); + if (code == TSDB_CODE_SUCCESS) { + int32_t valSize = *pVLen; + COUNT_TYPE* pWinStateCout = (COUNT_TYPE*)( (char*)(pRockVal) + (valSize - sizeof(COUNT_TYPE)) ); + if (inSessionWindow(pWinKey, startTs, gap) || (*pWinStateCout) < winCount) { + (*pVal) = createSessionWinBuff(pFileState, pWinKey, pRockVal, pVLen); + streamStateFreeCur(pCur); + goto _end; + } + } + pWinKey->win.skey = startTs; + pWinKey->win.ekey = endTs; + (*pVal) = createSessionWinBuff(pFileState, pWinKey, NULL, NULL); + taosMemoryFree(pRockVal); + streamStateFreeCur(pCur); + } else { + (*pVal) = addNewSessionWindow(pFileState, pWinStates, pWinKey); + code = TSDB_CODE_FAILED; + } + goto _end; + } + + // find the first position which is smaller than the pWinKey + int32_t index = binarySearch(pWinStates, size, pWinKey, sessionStateKeyCompare); + SRowBuffPos* pPos = NULL; + int32_t valSize = *pVLen; + + if (index >= 0) { + pPos = taosArrayGetP(pWinStates, index); + COUNT_TYPE* pWinStateCout = (COUNT_TYPE*)( (char*)(pPos->pRowBuff) + (valSize - sizeof(COUNT_TYPE)) ); + if (inSessionWindow(pPos->pKey, startTs, gap) || (index == size - 1 && (*pWinStateCout) < winCount) ) { + (*pVal) = pPos; + SSessionKey* pDestWinKey = (SSessionKey*)pPos->pKey; + pPos->beUsed = true; + *pWinKey = *pDestWinKey; + goto _end; + } + } + + if (index == -1) { + if (!isDeteled(pFileState, endTs)) { + void* p = NULL; + void* pFileStore = getStateFileStore(pFileState); + SStreamStateCur* pCur = streamStateSessionSeekToLast_rocksdb(pFileStore, pKey->groupId); + int32_t code_file = streamStateSessionGetKVByCur_rocksdb(pCur, pWinKey, &p, pVLen); + if (code_file == TSDB_CODE_SUCCESS) { + (*pVal) = createSessionWinBuff(pFileState, pWinKey, p, pVLen); + code = code_file; + qDebug("===stream===1 get state win:%" PRId64 ",%" PRId64 " from disc, res %d", pWinKey->win.skey, pWinKey->win.ekey, code_file); + streamStateFreeCur(pCur); + goto _end; + } + taosMemoryFree(p); + streamStateFreeCur(pCur); + } + } + + if (index + 1 < size) { + pPos = taosArrayGetP(pWinStates, index + 1); + (*pVal) = pPos; + SSessionKey* pDestWinKey = (SSessionKey*)pPos->pKey; + pPos->beUsed = true; + *pWinKey = *pDestWinKey; + goto _end; + } + + (*pVal) = addNewSessionWindow(pFileState, pWinStates, pWinKey); + code = TSDB_CODE_FAILED; + +_end: + return code; +} + +int32_t createCountWinResultBuff(SStreamFileState* pFileState, SSessionKey* pKey, void** pVal, int32_t* pVLen) { + SSessionKey* pWinKey = pKey; + const TSKEY gap = 0; + int32_t code = TSDB_CODE_SUCCESS; + SSHashObj* pSessionBuff = getRowStateBuff(pFileState); + SArray* pWinStates = NULL; + void** ppBuff = tSimpleHashGet(pSessionBuff, &pWinKey->groupId, sizeof(uint64_t)); + if (ppBuff) { + pWinStates = (SArray*)(*ppBuff); + } else { + pWinStates = taosArrayInit(16, POINTER_BYTES); + tSimpleHashPut(pSessionBuff, &pWinKey->groupId, sizeof(uint64_t), &pWinStates, POINTER_BYTES); + } + + TSKEY startTs = pWinKey->win.skey; + TSKEY endTs = pWinKey->win.ekey; + + int32_t size = taosArrayGetSize(pWinStates); + if (size == 0) { + void* pFileStore = getStateFileStore(pFileState); + void* p = NULL; + + SStreamStateCur* pCur = streamStateSessionSeekToLast_rocksdb(pFileStore, pKey->groupId); + int32_t code_file = streamStateSessionGetKVByCur_rocksdb(pCur, pWinKey, &p, pVLen); + if (code_file == TSDB_CODE_SUCCESS || isFlushedState(pFileState, endTs, 0)) { + (*pVal) = createSessionWinBuff(pFileState, pWinKey, p, pVLen); + code = code_file; + qDebug("===stream===0 get state win:%" PRId64 ",%" PRId64 " from disc, res %d", pWinKey->win.skey, pWinKey->win.ekey, code_file); + } else { + (*pVal) = addNewSessionWindow(pFileState, pWinStates, pWinKey); + code = TSDB_CODE_FAILED; + taosMemoryFree(p); + } + streamStateFreeCur(pCur); + goto _end; + } else { + (*pVal) = addNewSessionWindow(pFileState, pWinStates, pWinKey); + } + +_end: + return code; +} diff --git a/source/libs/stream/src/streamStart.c b/source/libs/stream/src/streamStart.c index ee98bc801b..6112a208c6 100644 --- a/source/libs/stream/src/streamStart.c +++ b/source/libs/stream/src/streamStart.c @@ -391,6 +391,16 @@ void doProcessDownstreamReadyRsp(SStreamTask* pTask) { int64_t startTs = pTask->execInfo.start; streamMetaAddTaskLaunchResult(pTask->pMeta, pTask->id.streamId, pTask->id.taskId, initTs, startTs, true); + if (pTask->status.taskStatus == TASK_STATUS__HALT) { + ASSERT(HAS_RELATED_FILLHISTORY_TASK(pTask) && (pTask->info.fillHistory == 0)); + + // halt it self for count window stream task until the related + // fill history task completd. + stDebug("s-task:%s level:%d initial status is %s from mnode, set it to be halt", pTask->id.idStr, + pTask->info.taskLevel, streamTaskGetStatusStr(pTask->status.taskStatus)); + streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_HALT); + } + // start the related fill-history task, when current task is ready // not invoke in success callback due to the deadlock. if (HAS_RELATED_FILLHISTORY_TASK(pTask)) { @@ -539,11 +549,6 @@ int32_t streamSetParamForScanHistory(SStreamTask* pTask) { return qSetStreamOperatorOptionForScanHistory(pTask->exec.pExecutor); } -int32_t streamRestoreParam(SStreamTask* pTask) { - stDebug("s-task:%s restore operator param after scan-history", pTask->id.idStr); - return qRestoreStreamOperatorOption(pTask->exec.pExecutor); -} - // source int32_t streamSetParamForStreamScannerStep1(SStreamTask* pTask, SVersionRange* pVerRange, STimeWindow* pWindow) { return qStreamSourceScanParamForHistoryScanStep1(pTask->exec.pExecutor, pVerRange, pWindow); @@ -804,7 +809,7 @@ int32_t streamLaunchFillHistoryTask(SStreamTask* pTask) { // check stream task status in the first place. SStreamTaskState* pStatus = streamTaskGetStatus(pTask); - if (pStatus->state != TASK_STATUS__READY) { + if (pStatus->state != TASK_STATUS__READY && pStatus->state != TASK_STATUS__HALT) { stDebug("s-task:%s not launch related fill-history task:0x%" PRIx64 "-0x%x, status:%s", idStr, hStreamId, hTaskId, pStatus->name); diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c index e370312338..b53dc9daa6 100644 --- a/source/libs/stream/src/streamState.c +++ b/source/libs/stream/src/streamState.c @@ -42,6 +42,14 @@ int sessionRangeKeyCmpr(const SSessionKey* pWin1, const SSessionKey* pWin2) { return 0; } +int countRangeKeyEqual(const SSessionKey* pWin1, const SSessionKey* pWin2) { + if (pWin1->groupId == pWin2->groupId && pWin1->win.skey <= pWin2->win.skey && pWin2->win.skey <= pWin1->win.ekey) { + return 0; + } + + return 1; +} + int sessionWinKeyCmpr(const SSessionKey* pWin1, const SSessionKey* pWin2) { if (pWin1->groupId > pWin2->groupId) { return 1; @@ -752,6 +760,12 @@ int32_t streamStateSessionDel(SStreamState* pState, const SSessionKey* key) { #endif } +int32_t streamStateSessionReset(SStreamState* pState, void* pVal) { + int32_t len = getRowStateRowSize(pState->pFileState); + memset(pVal, 0, len); + return TSDB_CODE_SUCCESS; +} + SStreamStateCur* streamStateSessionSeekKeyCurrentPrev(SStreamState* pState, const SSessionKey* key) { #ifdef USE_ROCKSDB return sessionWinStateSeekKeyCurrentPrev(pState->pFileState, key); @@ -846,6 +860,13 @@ SStreamStateCur* streamStateSessionSeekKeyNext(SStreamState* pState, const SSess #endif } +SStreamStateCur* streamStateCountSeekKeyPrev(SStreamState* pState, const SSessionKey* key, COUNT_TYPE count) { +#ifdef USE_ROCKSDB + return countWinStateSeekKeyPrev(pState->pFileState, key, count); +#else +#endif +} + int32_t streamStateSessionGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen) { #ifdef USE_ROCKSDB return sessionWinStateGetKVByCur(pCur, pKey, pVal, pVLen); @@ -896,7 +917,7 @@ int32_t streamStateSessionClear(SStreamState* pState) { int32_t streamStateSessionGetKeyByRange(SStreamState* pState, const SSessionKey* key, SSessionKey* curKey) { #ifdef USE_ROCKSDB - return sessionWinStateGetKeyByRange(pState->pFileState, key, curKey); + return sessionWinStateGetKeyByRange(pState->pFileState, key, curKey, sessionRangeKeyCmpr); #else SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur)); if (pCur == NULL) { @@ -946,6 +967,13 @@ int32_t streamStateSessionGetKeyByRange(SStreamState* pState, const SSessionKey* #endif } +int32_t streamStateCountGetKeyByRange(SStreamState* pState, const SSessionKey* key, SSessionKey* curKey) { +#ifdef USE_ROCKSDB + return sessionWinStateGetKeyByRange(pState->pFileState, key, curKey, countRangeKeyEqual); +#else +#endif +} + int32_t streamStateSessionAddIfNotExist(SStreamState* pState, SSessionKey* key, TSKEY gap, void** pVal, int32_t* pVLen) { #ifdef USE_ROCKSDB @@ -1135,90 +1163,11 @@ SStreamStateCur* createStreamStateCursor() { return pCur; } -#if 0 -char* streamStateSessionDump(SStreamState* pState) { - SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur)); - if (pCur == NULL) { - return NULL; - } - pCur->number = pState->number; - if (tdbTbcOpen(pState->pTdbState->pSessionStateDb, &pCur->pCur, NULL) < 0) { - streamStateFreeCur(pCur); - return NULL; - } - tdbTbcMoveToFirst(pCur->pCur); - - SSessionKey key = {0}; - void* buf = NULL; - int32_t bufSize = 0; - int32_t code = streamStateSessionGetKVByCur(pCur, &key, &buf, &bufSize); - if (code != 0) { - streamStateFreeCur(pCur); - return NULL; - } - - int32_t size = 2048; - char* dumpBuf = taosMemoryCalloc(size, 1); - int64_t len = 0; - len += snprintf(dumpBuf + len, size - len, "||s:%15" PRId64 ",", key.win.skey); - len += snprintf(dumpBuf + len, size - len, "e:%15" PRId64 ",", key.win.ekey); - len += snprintf(dumpBuf + len, size - len, "g:%15" PRId64 "||", key.groupId); - while (1) { - tdbTbcMoveToNext(pCur->pCur); - key = (SSessionKey){0}; - code = streamStateSessionGetKVByCur(pCur, &key, NULL, 0); - if (code != 0) { - streamStateFreeCur(pCur); - return dumpBuf; - } - len += snprintf(dumpBuf + len, size - len, "||s:%15" PRId64 ",", key.win.skey); - len += snprintf(dumpBuf + len, size - len, "e:%15" PRId64 ",", key.win.ekey); - len += snprintf(dumpBuf + len, size - len, "g:%15" PRId64 "||", key.groupId); - } - streamStateFreeCur(pCur); - return dumpBuf; +// count window +int32_t streamStateCountWinAddIfNotExist(SStreamState* pState, SSessionKey* pKey, COUNT_TYPE winCount, void** ppVal, int32_t* pVLen) { + return getCountWinResultBuff(pState->pFileState, pKey, winCount, ppVal, pVLen); } -char* streamStateIntervalDump(SStreamState* pState) { - SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur)); - if (pCur == NULL) { - return NULL; - } - pCur->number = pState->number; - if (tdbTbcOpen(pState->pTdbState->pStateDb, &pCur->pCur, NULL) < 0) { - streamStateFreeCur(pCur); - return NULL; - } - tdbTbcMoveToFirst(pCur->pCur); - - SWinKey key = {0}; - void* buf = NULL; - int32_t bufSize = 0; - int32_t code = streamStateGetKVByCur(pCur, &key, (const void **)&buf, &bufSize); - if (code != 0) { - streamStateFreeCur(pCur); - return NULL; - } - - int32_t size = 2048; - char* dumpBuf = taosMemoryCalloc(size, 1); - int64_t len = 0; - len += snprintf(dumpBuf + len, size - len, "||s:%15" PRId64 ",", key.ts); - // len += snprintf(dumpBuf + len, size - len, "e:%15" PRId64 ",", key.win.ekey); - len += snprintf(dumpBuf + len, size - len, "g:%15" PRId64 "||", key.groupId); - while (1) { - tdbTbcMoveToNext(pCur->pCur); - key = (SWinKey){0}; - code = streamStateGetKVByCur(pCur, &key, NULL, 0); - if (code != 0) { - streamStateFreeCur(pCur); - return dumpBuf; - } - len += snprintf(dumpBuf + len, size - len, "||s:%15" PRId64 ",", key.ts); - // len += snprintf(dumpBuf + len, size - len, "e:%15" PRId64 ",", key.win.ekey); - len += snprintf(dumpBuf + len, size - len, "g:%15" PRId64 "||", key.groupId); - } - streamStateFreeCur(pCur); - return dumpBuf; +int32_t streamStateCountWinAdd(SStreamState* pState, SSessionKey* pKey, void** pVal, int32_t* pVLen) { + return createCountWinResultBuff(pState->pFileState, pKey, pVal, pVLen); } -#endif \ No newline at end of file diff --git a/source/libs/stream/src/streamTask.c b/source/libs/stream/src/streamTask.c index 9f08a55b21..281e2ed550 100644 --- a/source/libs/stream/src/streamTask.c +++ b/source/libs/stream/src/streamTask.c @@ -80,7 +80,7 @@ static SStreamChildEpInfo* createStreamTaskEpInfo(const SStreamTask* pTask) { } SStreamTask* tNewStreamTask(int64_t streamId, int8_t taskLevel, SEpSet* pEpset, bool fillHistory, int64_t triggerParam, - SArray* pTaskList, bool hasFillhistory) { + SArray* pTaskList, bool hasFillhistory, int8_t subtableWithoutMd5) { SStreamTask* pTask = (SStreamTask*)taosMemoryCalloc(1, sizeof(SStreamTask)); if (pTask == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -96,6 +96,7 @@ SStreamTask* tNewStreamTask(int64_t streamId, int8_t taskLevel, SEpSet* pEpset, pTask->info.taskLevel = taskLevel; pTask->info.fillHistory = fillHistory; pTask->info.triggerParam = triggerParam; + pTask->subtableWithoutMd5 = subtableWithoutMd5; pTask->status.pSM = streamCreateStateMachine(pTask); if (pTask->status.pSM == NULL) { @@ -108,7 +109,7 @@ SStreamTask* tNewStreamTask(int64_t streamId, int8_t taskLevel, SEpSet* pEpset, pTask->id.idStr = taosStrdup(buf); pTask->status.schedStatus = TASK_SCHED_STATUS__INACTIVE; - pTask->status.taskStatus = (fillHistory || hasFillhistory) ? TASK_STATUS__SCAN_HISTORY : TASK_STATUS__READY; + pTask->status.taskStatus = fillHistory? TASK_STATUS__SCAN_HISTORY : TASK_STATUS__READY; pTask->inputq.status = TASK_INPUT_STATUS__NORMAL; pTask->outputq.status = TASK_OUTPUT_STATUS__NORMAL; @@ -126,7 +127,6 @@ int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo) if (tEncodeI32(pEncoder, pInfo->taskId) < 0) return -1; if (tEncodeI32(pEncoder, pInfo->nodeId) < 0) return -1; if (tEncodeI32(pEncoder, pInfo->childId) < 0) return -1; - /*if (tEncodeI64(pEncoder, pInfo->processedVer) < 0) return -1;*/ if (tEncodeSEpSet(pEncoder, &pInfo->epSet) < 0) return -1; if (tEncodeI64(pEncoder, pInfo->stage) < 0) return -1; return 0; @@ -136,7 +136,6 @@ int32_t tDecodeStreamEpInfo(SDecoder* pDecoder, SStreamChildEpInfo* pInfo) { if (tDecodeI32(pDecoder, &pInfo->taskId) < 0) return -1; if (tDecodeI32(pDecoder, &pInfo->nodeId) < 0) return -1; if (tDecodeI32(pDecoder, &pInfo->childId) < 0) return -1; - /*if (tDecodeI64(pDecoder, &pInfo->processedVer) < 0) return -1;*/ if (tDecodeSEpSet(pDecoder, &pInfo->epSet) < 0) return -1; if (tDecodeI64(pDecoder, &pInfo->stage) < 0) return -1; return 0; @@ -205,6 +204,7 @@ int32_t tEncodeStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) { if (tEncodeCStr(pEncoder, pTask->outputInfo.shuffleDispatcher.stbFullName) < 0) return -1; } if (tEncodeI64(pEncoder, pTask->info.triggerParam) < 0) return -1; + if (tEncodeI8(pEncoder, pTask->subtableWithoutMd5) < 0) return -1; if (tEncodeCStrWithLen(pEncoder, pTask->reserve, sizeof(pTask->reserve) - 1) < 0) return -1; tEndEncode(pEncoder); @@ -287,6 +287,7 @@ int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask) { if (tDecodeCStrTo(pDecoder, pTask->outputInfo.shuffleDispatcher.stbFullName) < 0) return -1; } if (tDecodeI64(pDecoder, &pTask->info.triggerParam) < 0) return -1; + if (tDecodeI8(pDecoder, &pTask->subtableWithoutMd5) < 0) return -1; if (tDecodeCStrTo(pDecoder, pTask->reserve) < 0) return -1; tEndDecode(pDecoder); @@ -294,7 +295,6 @@ int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask) { } int32_t tDecodeStreamTaskChkInfo(SDecoder* pDecoder, SCheckpointInfo* pChkpInfo) { - int64_t ver; int64_t skip64; int8_t skip8; int32_t skip32; @@ -482,7 +482,7 @@ int32_t streamTaskInit(SStreamTask* pTask, SStreamMeta* pMeta, SMsgCb* pMsgCb, i pTask->execInfo.created = taosGetTimestampMs(); SCheckpointInfo* pChkInfo = &pTask->chkInfo; - SDataRange* pRange = &pTask->dataRange; + SDataRange* pRange = &pTask->dataRange; // only set the version info for stream tasks without fill-history task if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) { @@ -648,7 +648,7 @@ int32_t streamTaskStop(SStreamTask* pTask) { streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_STOP); qKillTask(pTask->exec.pExecutor, TSDB_CODE_SUCCESS); - while (/*pTask->status.schedStatus != TASK_SCHED_STATUS__INACTIVE */ !streamTaskIsIdle(pTask)) { + while (!streamTaskIsIdle(pTask)) { stDebug("s-task:%s level:%d wait for task to be idle and then close, check again in 100ms", id, pTask->info.taskLevel); taosMsleep(100); @@ -755,9 +755,9 @@ int8_t streamTaskSetSchedStatusInactive(SStreamTask* pTask) { return status; } -int32_t streamTaskClearHTaskAttr(SStreamTask* pTask, bool metaLock) { - SStreamMeta* pMeta = pTask->pMeta; - STaskId sTaskId = {.streamId = pTask->streamTaskId.streamId, .taskId = pTask->streamTaskId.taskId}; +int32_t streamTaskClearHTaskAttr(SStreamTask* pTask, int32_t resetRelHalt, bool metaLock) { + SStreamMeta* pMeta = pTask->pMeta; + STaskId sTaskId = {.streamId = pTask->streamTaskId.streamId, .taskId = pTask->streamTaskId.taskId}; if (pTask->info.fillHistory == 0) { return 0; } @@ -773,6 +773,12 @@ int32_t streamTaskClearHTaskAttr(SStreamTask* pTask, bool metaLock) { taosThreadMutexLock(&(*ppStreamTask)->lock); CLEAR_RELATED_FILLHISTORY_TASK((*ppStreamTask)); + + if (resetRelHalt) { + (*ppStreamTask)->status.taskStatus = TASK_STATUS__READY; + stDebug("s-task:0x%" PRIx64 " set the status to be ready", sTaskId.taskId); + } + streamMetaSaveTask(pMeta, *ppStreamTask); taosThreadMutexUnlock(&(*ppStreamTask)->lock); } @@ -784,7 +790,7 @@ int32_t streamTaskClearHTaskAttr(SStreamTask* pTask, bool metaLock) { return TSDB_CODE_SUCCESS; } -int32_t streamBuildAndSendDropTaskMsg(SMsgCb* pMsgCb, int32_t vgId, SStreamTaskId* pTaskId) { +int32_t streamBuildAndSendDropTaskMsg(SMsgCb* pMsgCb, int32_t vgId, SStreamTaskId* pTaskId, int64_t resetRelHalt) { SVDropStreamTaskReq* pReq = rpcMallocCont(sizeof(SVDropStreamTaskReq)); if (pReq == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -794,6 +800,7 @@ int32_t streamBuildAndSendDropTaskMsg(SMsgCb* pMsgCb, int32_t vgId, SStreamTaskI pReq->head.vgId = vgId; pReq->taskId = pTaskId->taskId; pReq->streamId = pTaskId->streamId; + pReq->resetRelHalt = resetRelHalt; SRpcMsg msg = {.msgType = TDMT_STREAM_TASK_DROP, .pCont = pReq, .contLen = sizeof(SVDropStreamTaskReq)}; int32_t code = tmsgPutToQueue(pMsgCb, WRITE_QUEUE, &msg); @@ -864,7 +871,7 @@ void streamTaskPause(SStreamMeta* pMeta, SStreamTask* pTask) { void streamTaskResume(SStreamTask* pTask) { SStreamTaskState prevState = *streamTaskGetStatus(pTask); - SStreamMeta* pMeta = pTask->pMeta; + SStreamMeta* pMeta = pTask->pMeta; if (prevState.state == TASK_STATUS__PAUSE || prevState.state == TASK_STATUS__HALT) { streamTaskRestoreStatus(pTask); @@ -881,9 +888,7 @@ void streamTaskResume(SStreamTask* pTask) { } } -bool streamTaskIsSinkTask(const SStreamTask* pTask) { - return pTask->info.taskLevel == TASK_LEVEL__SINK; -} +bool streamTaskIsSinkTask(const SStreamTask* pTask) { return pTask->info.taskLevel == TASK_LEVEL__SINK; } int32_t streamTaskSendCheckpointReq(SStreamTask* pTask) { int32_t code; 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/libs/stream/src/tstreamFileState.c b/source/libs/stream/src/tstreamFileState.c index fb5e02c827..f86ab6b8a3 100644 --- a/source/libs/stream/src/tstreamFileState.c +++ b/source/libs/stream/src/tstreamFileState.c @@ -480,6 +480,15 @@ int32_t deleteRowBuff(SStreamFileState* pFileState, const void* pKey, int32_t ke return TSDB_CODE_FAILED; } +int32_t resetRowBuff(SStreamFileState* pFileState, const void* pKey, int32_t keyLen) { + int32_t code_buff = pFileState->stateBuffRemoveFn(pFileState->rowStateBuff, pKey, keyLen); + int32_t code_file = pFileState->stateFileRemoveFn(pFileState, pKey); + if (code_buff == TSDB_CODE_SUCCESS || code_file == TSDB_CODE_SUCCESS) { + return TSDB_CODE_SUCCESS; + } + return TSDB_CODE_FAILED; +} + static void recoverSessionRowBuff(SStreamFileState* pFileState, SRowBuffPos* pPos) { int32_t len = 0; void* pBuff = NULL; @@ -656,7 +665,7 @@ int32_t recoverSesssion(SStreamFileState* pFileState, int64_t ckId) { deleteExpiredCheckPoint(pFileState, mark); } - SStreamStateCur* pCur = streamStateSessionSeekToLast_rocksdb(pFileState->pFileStore); + SStreamStateCur* pCur = streamStateSessionSeekToLast_rocksdb(pFileState->pFileStore, INT64_MAX); if (pCur == NULL) { return -1; } diff --git a/source/libs/stream/test/CMakeLists.txt b/source/libs/stream/test/CMakeLists.txt index c11d8fe3e6..c90e05bcf6 100644 --- a/source/libs/stream/test/CMakeLists.txt +++ b/source/libs/stream/test/CMakeLists.txt @@ -34,7 +34,7 @@ add_test( COMMAND streamUpdateTest ) -# add_test( -# NAME checkpointTest -# COMMAND checkpointTest -# ) \ No newline at end of file +add_test( + NAME checkpointTest + COMMAND checkpointTest +) \ No newline at end of file diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index 64302a78fc..f658947144 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -140,11 +140,7 @@ void* rpcMallocCont(int64_t contLen) { return start + sizeof(STransMsgHead); } -void rpcFreeCont(void* cont) { - if (cont == NULL) return; - taosMemoryFree((char*)cont - TRANS_MSG_OVERHEAD); - tTrace("rpc free cont:%p", (char*)cont - TRANS_MSG_OVERHEAD); -} +void rpcFreeCont(void* cont) { transFreeMsg(cont); } void* rpcReallocCont(void* ptr, int64_t contLen) { if (ptr == NULL) return rpcMallocCont(contLen); diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index b6942655a9..798a5bf54f 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -218,7 +218,6 @@ static void (*cliAsyncHandle[])(SCliMsg* pMsg, SCliThrd* pThrd) = {cliHandleReq, /// static void (*cliAsyncHandle[])(SCliMsg* pMsg, SCliThrd* pThrd) = {cliHandleReq, cliHandleQuit, cliHandleRelease, /// NULL,cliHandleUpdate}; -static FORCE_INLINE void destroyUserdata(STransMsg* userdata); static FORCE_INLINE void destroyCmsg(void* cmsg); static FORCE_INLINE void destroyCmsgAndAhandle(void* cmsg); static FORCE_INLINE int cliRBChoseIdx(STrans* pTransInst); @@ -1950,14 +1949,6 @@ _err: return NULL; } -static FORCE_INLINE void destroyUserdata(STransMsg* userdata) { - if (userdata->pCont == NULL) { - return; - } - transFreeMsg(userdata->pCont); - userdata->pCont = NULL; -} - static FORCE_INLINE void destroyCmsg(void* arg) { SCliMsg* pMsg = arg; if (pMsg == NULL) { @@ -1965,7 +1956,7 @@ static FORCE_INLINE void destroyCmsg(void* arg) { } transDestroyConnCtx(pMsg->ctx); - destroyUserdata(&pMsg->msg); + transFreeMsg(pMsg->msg.pCont); taosMemoryFree(pMsg); } @@ -1984,7 +1975,7 @@ static FORCE_INLINE void destroyCmsgAndAhandle(void* param) { tDebug("destroy Ahandle C"); transDestroyConnCtx(pMsg->ctx); - destroyUserdata(&pMsg->msg); + transFreeMsg(pMsg->msg.pCont); taosMemoryFree(pMsg); } diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index b1fb9a2450..4619722743 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -87,6 +87,7 @@ void transFreeMsg(void* msg) { if (msg == NULL) { return; } + tTrace("rpc free cont:%p", (char*)msg - TRANS_MSG_OVERHEAD); taosMemoryFree((char*)msg - sizeof(STransMsgHead)); } int transSockInfo2Str(struct sockaddr* sockname, char* dst) { diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index f4e35c5b7f..bab9ba0cea 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -632,6 +632,11 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in return writeLen; } +bool lastErrorIsFileNotExist() { + DWORD dwError = GetLastError(); + return dwError == ERROR_FILE_NOT_FOUND; +} + #else int taosOpenFileNotStream(const char *path, int32_t tdFileOptions) { int access = O_BINARY; @@ -1028,6 +1033,8 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in #endif } +bool lastErrorIsFileNotExist() { return errno == ENOENT; } + #endif // WINDOWS TdFilePtr taosOpenFile(const char *path, int32_t tdFileOptions) { diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index 505ce61eca..eae02125d2 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -350,7 +350,7 @@ void taosResetLog() { static bool taosCheckFileIsOpen(char *logFileName) { TdFilePtr pFile = taosOpenFile(logFileName, TD_FILE_WRITE); if (pFile == NULL) { - if (errno == ENOENT) { + if (lastErrorIsFileNotExist()) { return false; } else { printf("\nfailed to open log file:%s, reason:%s\n", logFileName, strerror(errno)); diff --git a/tests/army/community/cluster/incSnapshot.py b/tests/army/community/cluster/incSnapshot.py index d309bae72c..6bcf547136 100644 --- a/tests/army/community/cluster/incSnapshot.py +++ b/tests/army/community/cluster/incSnapshot.py @@ -18,6 +18,9 @@ from frame.autogen import * class TDTestCase(TBase): + updatecfgDict = { + 'slowLogScope':"query" + } def init(self, conn, logSql, replicaVar=3): super(TDTestCase, self).init(conn, logSql, replicaVar=3, db="snapshot", checkColName="c1") diff --git a/tests/army/community/cluster/snapshot.py b/tests/army/community/cluster/snapshot.py index b4c4d3c4c8..b21cbb1ad8 100644 --- a/tests/army/community/cluster/snapshot.py +++ b/tests/army/community/cluster/snapshot.py @@ -33,7 +33,8 @@ class TDTestCase(TBase): "lossyColumns" : "float,double", "fPrecision" : "0.000000001", "dPrecision" : "0.00000000000000001", - "ifAdtFse" : "1" + "ifAdtFse" : "1", + 'slowLogScope' : "insert" } def insertData(self): @@ -56,7 +57,7 @@ class TDTestCase(TBase): sql = f"select * from {self.db}.{self.stb} where fc!=100" tdSql.query(sql) tdSql.checkRows(0) - sql = f"select count(*) from {self.db}.{self.stb} where dc!=200" + sql = f"select * from {self.db}.{self.stb} where dc!=200" tdSql.query(sql) tdSql.checkRows(0) sql = f"select avg(fc) from {self.db}.{self.stb}" diff --git a/tests/army/community/cluster/splitVgroupByLearner.py b/tests/army/community/cluster/splitVgroupByLearner.py index 5f75db2db5..c2025a331d 100644 --- a/tests/army/community/cluster/splitVgroupByLearner.py +++ b/tests/army/community/cluster/splitVgroupByLearner.py @@ -31,6 +31,9 @@ from frame.srvCtl import * class TDTestCase(TBase): + updatecfgDict = { + 'slowLogScope' : "others" + } def init(self, conn, logSql, replicaVar=1): tdLog.debug(f"start to init {__file__}") diff --git a/tests/army/community/cmdline/fullopt.py b/tests/army/community/cmdline/fullopt.py index c0ce709801..c03ba428a1 100644 --- a/tests/army/community/cmdline/fullopt.py +++ b/tests/army/community/cmdline/fullopt.py @@ -31,10 +31,10 @@ class TDTestCase(TBase): 'queryMaxConcurrentTables': '2K', 'streamMax': '1M', 'totalMemoryKB': '1G', - #'rpcQueueMemoryAllowed': '1T', - #'mndLogRetention': '1P', - 'streamBufferSize':'2G' - } + 'streamMax': '1P', + 'streamBufferSize':'1T', + 'slowLogScope':"query" + } def insertData(self): tdLog.info(f"insert data.") @@ -47,8 +47,40 @@ class TDTestCase(TBase): # taosBenchmark run etool.benchMark(command = f"-d {self.db} -t {self.childtable_count} -n {self.insert_rows} -v 2 -y") + def checkQueryOK(self, rets): + if rets[-2][:9] != "Query OK,": + tdLog.exit(f"check taos -s return unecpect: {rets}") + def doTaos(self): tdLog.info(f"check taos command options...") + + # local command + options = [ + "DebugFlag 143", + "enableCoreFile 1", + "fqdn 127.0.0.1", + "firstEp 127.0.0.1", + "locale ENG", + "metaCacheMaxSize 10000", + "minimalTmpDirGB 5", + "minimalLogDirGB 1", + "secondEp 127.0.0.2", + "smlChildTableName smltbname", + "smlAutoChildTableNameDelimiter autochild", + "smlTagName tagname", + "smlTsDefaultName tsdef", + "serverPort 6030", + "slowLogScope insert", + "timezone tz", + "tempDir /var/tmp" + ] + # exec + for option in options: + rets = etool.runBinFile("taos", f"-s \"alter local '{option}'\";") + self.checkQueryOK(rets) + # error + etool.runBinFile("taos", f"-s \"alter local 'nocmd check'\";") + # help rets = etool.runBinFile("taos", "--help") self.checkListNotEmpty(rets) diff --git a/tests/army/community/query/fill/fill_desc.py b/tests/army/community/query/fill/fill_desc.py index bec29c49fd..02e316a4fb 100644 --- a/tests/army/community/query/fill/fill_desc.py +++ b/tests/army/community/query/fill/fill_desc.py @@ -8,6 +8,9 @@ from frame.caseBase import * from frame import * class TDTestCase(TBase): + updatecfgDict = { + 'slowLogScope':"all" + } def init(self, conn, logSql, replicaVar=1): self.replicaVar = int(replicaVar) diff --git a/tests/army/community/query/query_basic.py b/tests/army/community/query/query_basic.py index bfe88e483e..d2e0201860 100644 --- a/tests/army/community/query/query_basic.py +++ b/tests/army/community/query/query_basic.py @@ -29,9 +29,11 @@ from frame import * class TDTestCase(TBase): updatecfgDict = { - "keepColumnName" : "1", + "keepColumnName" : "1", "ttlChangeOnWrite" : "1", - "querySmaOptimize": "1" + "querySmaOptimize" : "1", + "slowLogScope" : "none", + "queryBufferSize" : 10240 } diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index d43a9a7ee6..9395753510 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -160,6 +160,14 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/td-28068.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/td-28068.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/td-28068.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/agg_group_AlwaysReturnValue.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/agg_group_AlwaysReturnValue.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/agg_group_AlwaysReturnValue.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/agg_group_AlwaysReturnValue.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/agg_group_NotReturnValue.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/agg_group_NotReturnValue.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/agg_group_NotReturnValue.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/agg_group_NotReturnValue.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 3-enterprise/restore/restoreDnode.py -N 5 -M 3 -i False ,,y,system-test,./pytest.sh python3 ./test.py -f 3-enterprise/restore/restoreVnode.py -N 5 -M 3 -i False @@ -575,6 +583,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/ts_3405_3398_3423.py -N 3 -n 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/ts-4348-td-27939.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/backslash_g.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/test_ts4467.py ,,n,system-test,python3 ./test.py -f 2-query/queryQnode.py ,,y,system-test,./pytest.sh python3 ./test.py -f 6-cluster/5dnode1mnode.py @@ -1140,6 +1149,8 @@ ,,y,script,./test.sh -f tsim/query/bug3398.sim ,,y,script,./test.sh -f tsim/query/explain_tsorder.sim ,,y,script,./test.sh -f tsim/query/apercentile.sim +,,y,script,./test.sh -f tsim/query/query_count0.sim +,,y,script,./test.sh -f tsim/query/query_count_sliding0.sim ,,y,script,./test.sh -f tsim/qnode/basic1.sim ,,y,script,./test.sh -f tsim/snode/basic1.sim ,,y,script,./test.sh -f tsim/mnode/basic1.sim @@ -1184,6 +1195,13 @@ ,,y,script,./test.sh -f tsim/stream/checkpointInterval0.sim ,,y,script,./test.sh -f tsim/stream/checkStreamSTable1.sim ,,y,script,./test.sh -f tsim/stream/checkStreamSTable.sim +,,y,script,./test.sh -f tsim/stream/count0.sim +,,y,script,./test.sh -f tsim/stream/count1.sim +,,y,script,./test.sh -f tsim/stream/count2.sim +,,y,script,./test.sh -f tsim/stream/count3.sim +,,y,script,./test.sh -f tsim/stream/countSliding0.sim +,,y,script,./test.sh -f tsim/stream/countSliding1.sim +,,y,script,./test.sh -f tsim/stream/countSliding2.sim ,,y,script,./test.sh -f tsim/stream/deleteInterval.sim ,,y,script,./test.sh -f tsim/stream/deleteSession.sim ,,y,script,./test.sh -f tsim/stream/deleteState.sim 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/query/query_count0.sim b/tests/script/tsim/query/query_count0.sim new file mode 100644 index 0000000000..c3a75d635b --- /dev/null +++ b/tests/script/tsim/query/query_count0.sim @@ -0,0 +1,179 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +print step1 +print =============== create database +sql create database test vgroups 1; +sql use test; + +sql create table t1(ts timestamp, a int, b int , c int, d double); + +sql insert into t1 values(1648791213000,0,1,1,1.0); +sql insert into t1 values(1648791213001,9,2,2,1.1); +sql insert into t1 values(1648791213009,0,3,3,1.0); + + +sql insert into t1 values(1648791223000,0,1,1,1.0); +sql insert into t1 values(1648791223001,9,2,2,1.1); +sql insert into t1 values(1648791223009,0,3,3,1.0); + +$loop_count = 0 +loop2: + +sleep 300 +print 1 sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(3); +sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(3); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 3 then + print ======data01=$data01 + goto loop2 +endi + +if $data02 != 6 then + print ======data02=$data02 + goto loop2 +endi + +if $data03 != 3 then + print ======data03=$data03 + goto loop2 +endi + +# row 1 +if $data11 != 3 then + print ======data11=$data11 + goto loop2 +endi + +if $data12 != 6 then + print ======data12=$data12 + goto loop2 +endi + +if $data13 != 3 then + print ======data13=$data13 + goto loop2 +endi + + + +print step2 +print =============== create database +sql create database test2 vgroups 4; +sql use test2; + +sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(2,2,2); + +sql insert into t1 values(1648791213000,0,1,1,1.0); +sql insert into t1 values(1648791213001,9,2,2,1.1); +sql insert into t1 values(1648791213009,0,3,3,1.0); + +sql insert into t2 values(1648791213000,0,1,1,1.0); +sql insert into t2 values(1648791213001,9,2,2,1.1); +sql insert into t2 values(1648791213009,0,3,3,1.0); + +sql insert into t1 values(1648791223000,0,1,1,1.0); +sql insert into t1 values(1648791223001,9,2,2,1.1); +sql insert into t1 values(1648791223009,0,3,3,1.0); + +sql insert into t2 values(1648791223000,0,1,1,1.0); +sql insert into t2 values(1648791223001,9,2,2,1.1); +sql insert into t2 values(1648791223009,0,3,3,1.0); + +$loop_count = 0 +loop3: + +sleep 300 +print 1 sql select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(3); +sql select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(3); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 3 then + print ======data01=$data01 + goto loop3 +endi + +if $data02 != 6 then + print ======data02=$data02 + goto loop3 +endi + +if $data03 != 3 then + print ======data03=$data03 + goto loop3 +endi + +# row 1 +if $data11 != 3 then + print ======data11=$data11 + goto loop3 +endi + +if $data12 != 6 then + print ======data12=$data12 + goto loop3 +endi + +if $data13 != 3 then + print ======data13=$data13 + goto loop3 +endi + +# row 2 +if $data21 != 3 then + print ======data21=$data21 + goto loop3 +endi + +if $data22 != 6 then + print ======data22=$data22 + goto loop3 +endi + +if $data23 != 3 then + print ======data23=$data23 + goto loop3 +endi + +# row 3 +if $data31 != 3 then + print ======data31=$data31 + goto loop3 +endi + +if $data32 != 6 then + print ======data32=$data32 + goto loop3 +endi + +if $data33 != 3 then + print ======data33=$data33 + goto loop3 +endi + +print query_count0 end +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/query/query_count1.sim b/tests/script/tsim/query/query_count1.sim new file mode 100644 index 0000000000..0694ab062a --- /dev/null +++ b/tests/script/tsim/query/query_count1.sim @@ -0,0 +1,83 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +print step1 +print =============== create database +sql create database test vgroups 4; +sql use test; + +sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(2,2,2); + +sql insert into t1 values(1648791213000,0,1,1,1.0); +sql insert into t1 values(1648791213001,9,1,2,1.1); +sql insert into t1 values(1648791213009,0,1,3,1.0); + +sql insert into t2 values(1648791213000,0,1,4,1.0); +sql insert into t2 values(1648791213001,9,1,5,1.1); +sql insert into t2 values(1648791213009,0,1,6,1.0); + +sql insert into t1 values(1648791223000,0,1,7,1.0); +sql insert into t1 values(1648791223001,9,1,8,1.1); +sql insert into t1 values(1648791223009,0,1,9,1.0); + +sql insert into t2 values(1648791223000,0,1,10,1.0); +sql insert into t2 values(1648791223001,9,1,11,1.1); +sql insert into t2 values(1648791223009,0,1,12,1.0); + +$loop_count = 0 +loop3: + +sleep 300 +print 1 sql select _wstart as s, count(*) c1, sum(b), max(c) from st count_window(4); +sql select _wstart as s, count(*) c1, sum(b), max(c) from st count_window(4); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 4 then + print ======data01=$data01 + goto loop3 +endi + +if $data02 != 4 then + print ======data02=$data02 + goto loop3 +endi + +# row 1 +if $data11 != 4 then + print ======data11=$data11 + goto loop3 +endi + +if $data12 != 4 then + print ======data12=$data12 + goto loop3 +endi + +# row 2 +if $data21 != 4 then + print ======data21=$data21 + goto loop3 +endi + +if $data22 != 4 then + print ======data22=$data22 + goto loop3 +endi + +print query_count0 end +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/query/query_count_sliding0.sim b/tests/script/tsim/query/query_count_sliding0.sim new file mode 100644 index 0000000000..464aec6b97 --- /dev/null +++ b/tests/script/tsim/query/query_count_sliding0.sim @@ -0,0 +1,670 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +print step1 +print =============== create database +sql create database test vgroups 1; +sql use test; + +sql create table t1(ts timestamp, a int, b int , c int, d double); + +sql insert into t1 values(1648791213000,0,1,1,1.0); + +$loop_count = 0 +loop00: + +sleep 300 +print 00 sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); +sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 1 then + print ======rows=$rows + goto loop00 +endi + +# row 0 +if $data01 != 1 then + print ======data01=$data01 + goto loop00 +endi + +sql insert into t1 values(1648791213001,9,2,2,1.1); + +$loop_count = 0 +loop01: + +sleep 300 +print 01 sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); +sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 1 then + print ======rows=$rows + goto loop01 +endi + +# row 0 +if $data01 != 2 then + print ======data01=$data01 + goto loop01 +endi + + +sql insert into t1 values(1648791213002,0,3,3,1.0); + +$loop_count = 0 +loop02: + +sleep 300 +print 02 sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); +sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 2 then + print ======rows=$rows + goto loop02 +endi + +# row 0 +if $data01 != 3 then + print ======data01=$data01 + goto loop02 +endi + +# row 1 +if $data11 != 1 then + print ======data01=$data01 + goto loop02 +endi + +sql insert into t1 values(1648791213009,0,3,3,1.0); + +$loop_count = 0 +loop0: + +sleep 300 +print 1 sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); +sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 2 then + print ======rows=$rows + goto loop0 +endi + +# row 0 +if $data01 != 4 then + print ======data01=$data01 + goto loop0 +endi + +# row 1 +if $data11 != 2 then + print ======data11=$data11 + goto loop0 +endi + +sql insert into t1 values(1648791223000,0,1,1,1.0); +sql insert into t1 values(1648791223001,9,2,2,1.1); +sql insert into t1 values(1648791223002,9,2,2,1.1); +sql insert into t1 values(1648791223009,0,3,3,1.0); + +$loop_count = 0 +loop2: + +sleep 300 +print 1 sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); +sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 4 then + print ======rows=$rows + goto loop2 +endi + +# row 0 +if $data01 != 4 then + print ======data01=$data01 + goto loop2 +endi + +# row 1 +if $data11 != 4 then + print ======data11=$data11 + goto loop2 +endi + +# row 2 +if $data21 != 4 then + print ======data21=$data21 + goto loop2 +endi + +# row 3 +if $data31 != 2 then + print ======data31=$data31 + goto loop2 +endi + +sql insert into t1 values(1648791233000,0,1,1,1.0) (1648791233001,9,2,2,1.1) (1648791233002,9,2,2,1.1) (1648791233009,0,3,3,1.0); + +$loop_count = 0 +loop3: + +sleep 300 +print 1 sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); +sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 6 then + print ======rows=$rows + goto loop3 +endi + + +sql insert into t1 values(1648791243000,0,1,1,1.0) (1648791243001,9,2,2,1.1); + +$loop_count = 0 +loop4: + +sleep 300 +print 1 sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); +sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 7 then + print ======rows=$rows + goto loop4 +endi + +sql insert into t1 values(1648791253000,0,1,1,1.0) (1648791253001,9,2,2,1.1) (1648791253002,9,2,2,1.1); + +$loop_count = 0 +loop5: + +sleep 300 +print 1 sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); +sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 +print $data80 $data81 $data82 $data83 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 9 then + print ======rows=$rows + goto loop5 +endi + +sql insert into t1 values(1648791263000,0,1,1,1.0); + +$loop_count = 0 +loop6: + +sleep 300 +print 1 sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); +sql select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 +print $data80 $data81 $data82 $data83 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 9 then + print ======rows=$rows + goto loop6 +endi + + + +print step2 +print =============== create database +sql create database test2 vgroups 4; +sql use test2; + +sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(2,2,2); + +sql insert into t1 values(1648791213000,0,1,1,1.0); +sql insert into t1 values(1648791213001,9,2,2,1.1); +sql insert into t1 values(1648791213002,0,3,3,1.0); +sql insert into t1 values(1648791213009,0,3,3,1.0); + +$loop_count = 0 +loop7: + +sleep 300 +print 1 sql select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(4, 2); +sql select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(4, 2); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 2 then + print ======rows=$rows + goto loop7 +endi + +# row 0 +if $data01 != 4 then + print ======data01=$data01 + goto loop7 +endi + +# row 1 +if $data11 != 2 then + print ======data11=$data11 + goto loop7 +endi + +sql insert into t1 values(1648791223000,0,1,1,1.0); +sql insert into t1 values(1648791223001,9,2,2,1.1); +sql insert into t1 values(1648791223002,9,2,2,1.1); +sql insert into t1 values(1648791223009,0,3,3,1.0); + +$loop_count = 0 +loop8: + +sleep 300 +print 1 sql select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(4, 2); +sql select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(4, 2); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 4 then + print ======rows=$rows + goto loop8 +endi + +# row 0 +if $data01 != 4 then + print ======data01=$data01 + goto loop8 +endi + +# row 1 +if $data11 != 4 then + print ======data11=$data11 + goto loop8 +endi + +# row 2 +if $data21 != 4 then + print ======data21=$data21 + goto loop8 +endi + +# row 3 +if $data31 != 2 then + print ======data31=$data31 + goto loop8 +endi + +sql insert into t1 values(1648791233000,0,1,1,1.0) (1648791233001,9,2,2,1.1) (1648791233002,9,2,2,1.1) (1648791233009,0,3,3,1.0); + +$loop_count = 0 +loop9: + +sleep 300 +print 1 sql select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(4, 2); +sql select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(4, 2); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 6 then + print ======rows=$rows + goto loop9 +endi + + +sql insert into t1 values(1648791243000,0,1,1,1.0) (1648791243001,9,2,2,1.1); + +$loop_count = 0 +loop10: + +sleep 300 +print 1 sql select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(4, 2); +sql select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(4, 2); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 7 then + print ======rows=$rows + goto loop10 +endi + +sql insert into t1 values(1648791253000,0,1,1,1.0) (1648791253001,9,2,2,1.1) (1648791253002,9,2,2,1.1); + +$loop_count = 0 +loop11: + +sleep 300 +print 1 sql select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(4, 2); +sql select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(4, 2); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 +print $data80 $data81 $data82 $data83 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 9 then + print ======rows=$rows + goto loop11 +endi + +sql insert into t1 values(1648791263000,0,1,1,1.0); + +$loop_count = 0 +loop12: + +sleep 300 +print 1 sql select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(4, 2); +sql select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(4, 2); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 +print $data80 $data81 $data82 $data83 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 9 then + print ======rows=$rows + goto loop12 +endi + + + +print step3 +print =============== create database +sql create database test3 vgroups 4; +sql use test3; + +sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(2,2,2); + +sql insert into t1 values(1648791213000,0,1,1,1.0); +sql insert into t1 values(1648791213001,9,1,2,1.1); +sql insert into t1 values(1648791213009,0,1,3,1.0); + +sql insert into t2 values(1648791213000,0,1,4,1.0); +sql insert into t2 values(1648791213001,9,1,5,1.1); +sql insert into t2 values(1648791213009,0,1,6,1.0); + +sql insert into t1 values(1648791223000,0,1,7,1.0); +sql insert into t1 values(1648791223001,9,1,8,1.1); +sql insert into t1 values(1648791223009,0,1,9,1.0); + +sql insert into t2 values(1648791223000,0,1,10,1.0); +sql insert into t2 values(1648791223001,9,1,11,1.1); +sql insert into t2 values(1648791223009,0,1,12,1.0); + +$loop_count = 0 +loop13: + +sleep 300 +print 1 sql select _wstart as s, count(*) c1, sum(b), max(c) from st count_window(4, 1); +sql select _wstart as s, count(*) c1, sum(b), max(c) from st count_window(4,1); + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 +print $data80 $data81 $data82 $data83 +print $data90 $data91 $data92 $data93 +print $data[10][0] $data[10][1] $data[10][2] $data[10][3] +print $data[11][0] $data[11][1] $data[11][2] $data[11][3] +print $data[12][0] $data[12][1] $data[12][2] $data[12][3] + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# rows +if $rows != 12 then + print ======rows=$rows + goto loop13 +endi + +# row 0 +if $data01 != 4 then + print ======data01=$data01 + goto loop13 +endi + +if $data02 != 4 then + print ======data02=$data02 + goto loop13 +endi + +# row 1 +if $data11 != 4 then + print ======data11=$data11 + goto loop13 +endi + +if $data12 != 4 then + print ======data12=$data12 + goto loop13 +endi + +# row 2 +if $data21 != 4 then + print ======data21=$data21 + goto loop13 +endi + +if $data22 != 4 then + print ======data22=$data22 + goto loop13 +endi + +# row 9 +if $data91 != 3 then + print ======data91=$data91 + goto loop13 +endi + +if $data92 != 3 then + print ======data92=$data92 + goto loop13 +endi + +# row 10 +if $data[10][1] != 2 then + print ======data[10][1]=$data[10][1] + goto loop13 +endi + +if $data[10][2] != 2 then + print ======data[10][2]=$data[10][2] + goto loop13 +endi + +# row 11 +if $data[11][1] != 1 then + print ======data[11][1]=$data[11][1] + goto loop13 +endi + +if $data[11][2] != 1 then + print ======data[11][2]=$data[11][2] + goto loop13 +endi + +print count sliding 0 end +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/count0.sim b/tests/script/tsim/stream/count0.sim new file mode 100644 index 0000000000..5f5ec72275 --- /dev/null +++ b/tests/script/tsim/stream/count0.sim @@ -0,0 +1,249 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +print step1 +print =============== create database +sql create database test vgroups 1; +sql use test; + +sql create table t1(ts timestamp, a int, b int , c int, d double); +sql create stream streams1 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 WATERMARK 100s into streamt as select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(3); +sleep 1000 + +sql insert into t1 values(1648791213000,0,1,1,1.0); +sql insert into t1 values(1648791213001,9,2,2,1.1); +sql insert into t1 values(1648791213009,0,3,3,1.0); + + +sql insert into t1 values(1648791223000,0,1,1,1.0); +sql insert into t1 values(1648791223001,9,2,2,1.1); +sql insert into t1 values(1648791223009,0,3,3,1.0); + +$loop_count = 0 +loop2: + +sleep 300 +print 1 sql select * from streamt; +sql select * from streamt; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 3 then + print ======data01=$data01 + goto loop2 +endi + +if $data02 != 6 then + print ======data02=$data02 + goto loop2 +endi + +if $data03 != 3 then + print ======data03=$data03 + goto loop2 +endi + +# row 1 +if $data11 != 3 then + print ======data11=$data11 + goto loop2 +endi + +if $data12 != 6 then + print ======data12=$data12 + goto loop2 +endi + +if $data13 != 3 then + print ======data13=$data13 + goto loop2 +endi + + + +print step2 +print =============== create database +sql create database test2 vgroups 4; +sql use test2; + +sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(2,2,2); +sql create stream streams2 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 WATERMARK 100s into streamt2 as select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(3) +sleep 1000 + +sql insert into t1 values(1648791213000,0,1,1,1.0); +sql insert into t1 values(1648791213001,9,2,2,1.1); +sql insert into t1 values(1648791213009,0,3,3,1.0); + +sql insert into t2 values(1648791213000,0,1,1,1.0); +sql insert into t2 values(1648791213001,9,2,2,1.1); +sql insert into t2 values(1648791213009,0,3,3,1.0); + +sql insert into t1 values(1648791223000,0,1,1,1.0); +sql insert into t1 values(1648791223001,9,2,2,1.1); +sql insert into t1 values(1648791223009,0,3,3,1.0); + +sql insert into t2 values(1648791223000,0,1,1,1.0); +sql insert into t2 values(1648791223001,9,2,2,1.1); +sql insert into t2 values(1648791223009,0,3,3,1.0); + +$loop_count = 0 +loop3: + +sleep 300 +print 1 sql select * from streamt; +sql select * from streamt2 order by 1,2; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 3 then + print ======data01=$data01 + goto loop3 +endi + +if $data02 != 6 then + print ======data02=$data02 + goto loop3 +endi + +if $data03 != 3 then + print ======data03=$data03 + goto loop3 +endi + +# row 1 +if $data11 != 3 then + print ======data11=$data11 + goto loop3 +endi + +if $data12 != 6 then + print ======data12=$data12 + goto loop3 +endi + +if $data13 != 3 then + print ======data13=$data13 + goto loop3 +endi + +# row 2 +if $data21 != 3 then + print ======data21=$data21 + goto loop3 +endi + +if $data22 != 6 then + print ======data22=$data22 + goto loop3 +endi + +if $data23 != 3 then + print ======data23=$data23 + goto loop3 +endi + +# row 3 +if $data31 != 3 then + print ======data31=$data31 + goto loop3 +endi + +if $data32 != 6 then + print ======data32=$data32 + goto loop3 +endi + +if $data33 != 3 then + print ======data33=$data33 + goto loop3 +endi + +print step3 +print =============== create database +sql create database test3 vgroups 1; +sql use test3; + +sql create table t1(ts timestamp, a int, b int , c int, d double); +sql insert into t1 values(1648791213000,0,1,1,1.0); +sql insert into t1 values(1648791213001,9,2,2,1.1); +sql insert into t1 values(1648791213009,0,3,3,1.0); + +sleep 500 + +sql create stream streams3 trigger at_once FILL_HISTORY 1 IGNORE EXPIRED 1 IGNORE UPDATE 0 WATERMARK 100s into streamt3 as select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(3); +sleep 1000 + +sql insert into t1 values(1648791223000,0,1,1,1.0); +sql insert into t1 values(1648791223001,9,2,2,1.1); +sql insert into t1 values(1648791223009,0,3,3,1.0); + +$loop_count = 0 +loop4: + +sleep 300 +print 1 sql select * from streamt3; +sql select * from streamt3; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 3 then + print ======data01=$data01 + goto loop4 +endi + +if $data02 != 6 then + print ======data02=$data02 + goto loop4 +endi + +if $data03 != 3 then + print ======data03=$data03 + goto loop4 +endi + +# row 1 +if $data11 != 3 then + print ======data11=$data11 + goto loop4 +endi + +if $data12 != 6 then + print ======data12=$data12 + goto loop4 +endi + +if $data13 != 3 then + print ======data13=$data13 + goto loop4 +endi + +print count0 end +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/count1.sim b/tests/script/tsim/stream/count1.sim new file mode 100644 index 0000000000..694f801f77 --- /dev/null +++ b/tests/script/tsim/stream/count1.sim @@ -0,0 +1,36 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +print step1 +print =============== create database +sql create database test vgroups 1; +sql use test; + +sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(2,2,2); + +# stable +sql_error create stream streams1 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 WATERMARK 10s into streamt as select _wstart as s, count(*) c1, sum(b), max(c) from st count_window(3); + +# IGNORE EXPIRED 0 +sql_error create stream streams1 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 WATERMARK 10s into streamt as select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(3); + +# WATERMARK 0 +sql_error create stream streams1 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 into streamt as select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(3); + +# All +sql_error create stream streams1 trigger at_once IGNORE EXPIRED 0 IGNORE UPDATE 0 into streamt as select _wstart as s, count(*) c1, sum(b), max(c) from st count_window(3); + +#2~INT32_MAX +sql_error create stream streams1 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 into streamt as select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(1); +sql_error create stream streams1 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 into streamt as select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(2147483648); + +sql create stream streams2 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 WATERMARK 10s into streamt2 as select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(2); +sql create stream streams3 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 WATERMARK 10s into streamt3 as select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(2147483647); + +print count1 end +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/count2.sim b/tests/script/tsim/stream/count2.sim new file mode 100644 index 0000000000..2558bd1072 --- /dev/null +++ b/tests/script/tsim/stream/count2.sim @@ -0,0 +1,302 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +print step1 +print =============== create database +sql create database test vgroups 1; +sql use test; + +sql create table t1(ts timestamp, a int, b int , c int, d double); +sql create stream streams1 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 WATERMARK 100s into streamt as select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(3); +sleep 1000 + +sql insert into t1 values(1648791213001,9,2,2,1.1); +sql insert into t1 values(1648791213009,0,3,3,1.0); + +$loop_count = 0 +loop0: + +sleep 300 +print 0 sql select * from streamt; +sql select * from streamt; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 2 then + print ======data01=$data01 + goto loop0 +endi + +sql insert into t1 values(1648791213000,0,1,1,1.0); + +$loop_count = 0 +loop1: + +sleep 300 +print 1 sql select * from streamt; +sql select * from streamt; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 + +if $rows != 1 then + print ======rows=$rows + goto loop1 +endi + +if $data01 != 3 then + print ======data01=$data01 + goto loop1 +endi + +sql insert into t1 values(1648791223000,0,1,1,1.0); +sql insert into t1 values(1648791223001,9,2,2,1.1); +sql insert into t1 values(1648791223009,0,3,3,1.0); + +$loop_count = 0 +loop2: + +sleep 300 +print 2 sql select * from streamt order by 1; +sql select * from streamt order by 1; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 2 then + print ======rows=$rows + goto loop2 +endi + +sql insert into t1 values(1648791212000,0,1,1,1.0); + +$loop_count = 0 +loop3: + +sleep 300 +print 3 sql select * from streamt order by 1; +sql select * from streamt order by 1; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 3 then + print ======rows=$rows + goto loop3 +endi + +if $data01 != 3 then + print ======data01=$data01 + goto loop3 +endi + +if $data11 != 3 then + print ======data11=$data11 + goto loop3 +endi + +if $data21 != 1 then + print ======data21=$data21 + goto loop3 +endi + +print step2 +print =============== create database +sql create database test2 vgroups 1; +sql use test2; + +sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(2,2,2); +sql create stream streams2 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 WATERMARK 100s into streamt2 as select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(3) +sleep 1000 + + +sql insert into t1 values(1648791213001,9,2,2,1.1); +sql insert into t1 values(1648791213009,0,3,3,1.0); + +sql insert into t2 values(1648791213001,9,2,2,1.1); +sql insert into t2 values(1648791213009,0,3,3,1.0); + +$loop_count = 0 +loop4: + +sleep 300 +print 0 sql select * from streamt2 order by 1;; +sql select * from streamt2 order by 1;; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $data01 != 2 then + print ======data01=$data01 + goto loop4 +endi + +if $data11 != 2 then + print ======data11=$data11 + goto loop4 +endi + +sql insert into t1 values(1648791213000,0,1,1,1.0); +sql insert into t2 values(1648791213000,0,1,1,1.0); + +$loop_count = 0 +loop5: + +sleep 300 +print 1 sql select * from streamt2 order by 1;; +sql select * from streamt2 order by 1;; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 + +if $rows != 2 then + print ======rows=$rows + goto loop5 +endi + +if $data01 != 3 then + print ======data01=$data01 + goto loop5 +endi + +if $data11 != 3 then + print ======data11=$data11 + goto loop5 +endi + +sql insert into t1 values(1648791223000,0,1,1,1.0); +sql insert into t1 values(1648791223001,9,2,2,1.1); +sql insert into t1 values(1648791223009,0,3,3,1.0); + +sql insert into t2 values(1648791223000,0,1,1,1.0); +sql insert into t2 values(1648791223001,9,2,2,1.1); +sql insert into t2 values(1648791223009,0,3,3,1.0); + +$loop_count = 0 +loop6: + +sleep 300 +print 2 sql select * from streamt2 order by 1; +sql select * from streamt2 order by 1; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 4 then + print ======rows=$rows + goto loop6 +endi + +sql insert into t1 values(1648791212000,0,1,1,1.0); +sql insert into t2 values(1648791212000,0,1,1,1.0); + +$loop_count = 0 +loop7: + +sleep 300 +print 3 sql select * from streamt2 order by 1; +sql select * from streamt2 order by 1; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 6 then + print ======rows=$rows + goto loop7 +endi + +if $data01 != 3 then + print ======data01=$data01 + goto loop7 +endi + +if $data11 != 3 then + print ======data11=$data11 + goto loop7 +endi + +if $data21 != 3 then + print ======data21=$data21 + goto loop7 +endi + +if $data31 != 3 then + print ======data31=$data31 + goto loop7 +endi + +if $data41 != 1 then + print ======data41=$data41 + goto loop7 +endi + +if $data51 != 1 then + print ======data51=$data51 + goto loop7 +endi + +print count2 end +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/count3.sim b/tests/script/tsim/stream/count3.sim new file mode 100644 index 0000000000..f04996cdaa --- /dev/null +++ b/tests/script/tsim/stream/count3.sim @@ -0,0 +1,116 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +print step1 +print =============== create database +sql create database test vgroups 1; +sql use test; + +sql create table t1(ts timestamp, a int, b int , c int, d double); +sql create stream streams1 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 WATERMARK 100s into streamt as select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(3); +sleep 1000 + +sql insert into t1 values(1648791213000,0,1,1,1.0); +sql insert into t1 values(1648791213001,9,2,2,1.1); +sql insert into t1 values(1648791213009,0,3,3,1.0); + +sql insert into t1 values(1648791223000,0,1,1,1.0); +sql insert into t1 values(1648791223001,9,2,2,1.1); +sql insert into t1 values(1648791223009,0,3,3,1.0); + +$loop_count = 0 +loop2: + +sleep 300 +print 2 sql select * from streamt order by 1; +sql select * from streamt order by 1; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 2 then + print ======rows=$rows + goto loop2 +endi + +sql insert into t1 values(1648791213000,4,4,4,4.0); + +$loop_count = 0 +loop3: + +sleep 300 +print 3 sql select * from streamt order by 1; +sql select * from streamt order by 1; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 2 then + print ======rows=$rows + goto loop3 +endi + +if $data01 != 3 then + print ======data01=$data01 + goto loop3 +endi + +if $data11 != 3 then + print ======data11=$data11 + goto loop3 +endi + +sql delete from t1 where ts = 1648791223001; + +$loop_count = 0 +loop4: + +sleep 300 +print 3 sql select * from streamt order by 1; +sql select * from streamt order by 1; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +if $rows != 2 then + print ======rows=$rows + goto loop4 +endi + +if $data01 != 3 then + print ======data01=$data01 + goto loop4 +endi + +if $data11 != 2 then + print ======data11=$data11 + goto loop4 +endi + + +print count3 end +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/countSliding0.sim b/tests/script/tsim/stream/countSliding0.sim new file mode 100644 index 0000000000..82c54649b2 --- /dev/null +++ b/tests/script/tsim/stream/countSliding0.sim @@ -0,0 +1,463 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +print step1 +print =============== create database +sql create database test vgroups 1; +sql use test; + +sql create table t1(ts timestamp, a int, b int , c int, d double); +sql create stream streams1 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 WATERMARK 100s into streamt as select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); +sleep 1000 + +sql insert into t1 values(1648791213000,0,1,1,1.0); +sleep 100 +sql insert into t1 values(1648791213001,9,2,2,1.1); +sleep 100 +sql insert into t1 values(1648791213002,0,3,3,1.0); +sleep 100 +sql insert into t1 values(1648791213009,0,3,3,1.0); + +$loop_count = 0 +loop0: + +sleep 300 +print 1 sql select * from streamt; +sql select * from streamt; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 2 then + print ======rows=$rows + goto loop0 +endi + +# row 0 +if $data01 != 4 then + print ======data01=$data01 + goto loop0 +endi + +# row 1 +if $data11 != 2 then + print ======data11=$data11 + goto loop0 +endi + +sql insert into t1 values(1648791223000,0,1,1,1.0); +sleep 100 +sql insert into t1 values(1648791223001,9,2,2,1.1); +sleep 100 +sql insert into t1 values(1648791223002,9,2,2,1.1); +sleep 100 +sql insert into t1 values(1648791223009,0,3,3,1.0); + +$loop_count = 0 +loop2: + +sleep 300 +print 1 sql select * from streamt; +sql select * from streamt; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 4 then + print ======rows=$rows + goto loop2 +endi + +# row 0 +if $data01 != 4 then + print ======data01=$data01 + goto loop2 +endi + +# row 1 +if $data11 != 4 then + print ======data11=$data11 + goto loop2 +endi + +# row 2 +if $data21 != 4 then + print ======data21=$data21 + goto loop2 +endi + +# row 3 +if $data31 != 2 then + print ======data31=$data31 + goto loop2 +endi + +sql insert into t1 values(1648791233000,0,1,1,1.0) (1648791233001,9,2,2,1.1) (1648791233002,9,2,2,1.1) (1648791233009,0,3,3,1.0); + +$loop_count = 0 +loop3: + +sleep 300 +print 1 sql select * from streamt; +sql select * from streamt; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 6 then + print ======rows=$rows + goto loop3 +endi + + +sql insert into t1 values(1648791243000,0,1,1,1.0) (1648791243001,9,2,2,1.1); + +$loop_count = 0 +loop4: + +sleep 300 +print 1 sql select * from streamt; +sql select * from streamt; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 7 then + print ======rows=$rows + goto loop4 +endi + +sql insert into t1 values(1648791253000,0,1,1,1.0) (1648791253001,9,2,2,1.1) (1648791253002,9,2,2,1.1); + +$loop_count = 0 +loop5: + +sleep 300 +print 1 sql select * from streamt; +sql select * from streamt; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 +print $data80 $data81 $data82 $data83 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 9 then + print ======rows=$rows + goto loop5 +endi + +sql insert into t1 values(1648791263000,0,1,1,1.0); + +$loop_count = 0 +loop6: + +sleep 300 +print 1 sql select * from streamt; +sql select * from streamt; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 +print $data80 $data81 $data82 $data83 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 9 then + print ======rows=$rows + goto loop6 +endi + + + +print step2 +print =============== create database +sql create database test2 vgroups 4; +sql use test2; + +sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); +sql create table t1 using st tags(1,1,1); +sql create table t2 using st tags(2,2,2); +sql create stream streams2 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 WATERMARK 100s into streamt2 as select _wstart as s, count(*) c1, sum(b), max(c) from st partition by tbname count_window(4, 2); +sleep 1000 + +sql insert into t1 values(1648791213000,0,1,1,1.0); +sleep 100 +sql insert into t1 values(1648791213001,9,2,2,1.1); +sleep 100 +sql insert into t1 values(1648791213002,0,3,3,1.0); +sleep 100 +sql insert into t1 values(1648791213009,0,3,3,1.0); + +$loop_count = 0 +loop7: + +sleep 300 +print 1 sql select * from streamt2; +sql select * from streamt2; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 2 then + print ======rows=$rows + goto loop7 +endi + +# row 0 +if $data01 != 4 then + print ======data01=$data01 + goto loop7 +endi + +# row 1 +if $data11 != 2 then + print ======data11=$data11 + goto loop7 +endi + +sql insert into t1 values(1648791223000,0,1,1,1.0); +sleep 100 +sql insert into t1 values(1648791223001,9,2,2,1.1); +sleep 100 +sql insert into t1 values(1648791223002,9,2,2,1.1); +sleep 100 +sql insert into t1 values(1648791223009,0,3,3,1.0); + +$loop_count = 0 +loop8: + +sleep 300 +print 1 sql select * from streamt2; +sql select * from streamt2; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 4 then + print ======rows=$rows + goto loop8 +endi + +# row 0 +if $data01 != 4 then + print ======data01=$data01 + goto loop8 +endi + +# row 1 +if $data11 != 4 then + print ======data11=$data11 + goto loop8 +endi + +# row 2 +if $data21 != 4 then + print ======data21=$data21 + goto loop8 +endi + +# row 3 +if $data31 != 2 then + print ======data31=$data31 + goto loop8 +endi + +sql insert into t1 values(1648791233000,0,1,1,1.0) (1648791233001,9,2,2,1.1) (1648791233002,9,2,2,1.1) (1648791233009,0,3,3,1.0); + +$loop_count = 0 +loop9: + +sleep 300 +print 1 sql select * from streamt2; +sql select * from streamt2; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 6 then + print ======rows=$rows + goto loop9 +endi + + +sql insert into t1 values(1648791243000,0,1,1,1.0) (1648791243001,9,2,2,1.1); + +$loop_count = 0 +loop10: + +sleep 300 +print 1 sql select * from streamt2; +sql select * from streamt2; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 7 then + print ======rows=$rows + goto loop10 +endi + +sql insert into t1 values(1648791253000,0,1,1,1.0) (1648791253001,9,2,2,1.1) (1648791253002,9,2,2,1.1); + +$loop_count = 0 +loop11: + +sleep 300 +print 1 sql select * from streamt2; +sql select * from streamt2; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 +print $data80 $data81 $data82 $data83 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 9 then + print ======rows=$rows + goto loop11 +endi + +sql insert into t1 values(1648791263000,0,1,1,1.0); + +$loop_count = 0 +loop12: + +sleep 300 +print 1 sql select * from streamt2; +sql select * from streamt2; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 +print $data40 $data41 $data42 $data43 +print $data50 $data51 $data52 $data53 +print $data60 $data61 $data62 $data63 +print $data70 $data71 $data72 $data73 +print $data80 $data81 $data82 $data83 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 9 then + print ======rows=$rows + goto loop12 +endi +print count sliding 0 end +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/countSliding1.sim b/tests/script/tsim/stream/countSliding1.sim new file mode 100644 index 0000000000..6759ab7abd --- /dev/null +++ b/tests/script/tsim/stream/countSliding1.sim @@ -0,0 +1,181 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +print step1 +print =============== create database +sql create database test vgroups 1; +sql use test; + +sql create table t1(ts timestamp, a int, b int , c int, d double); +sql create stream streams1 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 WATERMARK 100s into streamt as select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); +sleep 1000 + +sql insert into t1 values(1648791213000,0,1,1,1.0); +sleep 100 +sql insert into t1 values(1648791213001,9,2,2,1.1); +sleep 100 +sql insert into t1 values(1648791213002,0,3,3,1.0); +sleep 100 +sql insert into t1 values(1648791213009,0,3,3,1.0); +sleep 100 +sql insert into t1 values(1648791223000,0,1,1,1.0); +sleep 100 +sql insert into t1 values(1648791223001,9,2,2,1.1); +sleep 100 +sql insert into t1 values(1648791223002,9,2,2,1.1); +sleep 100 +sql insert into t1 values(1648791223009,0,3,3,1.0); + +$loop_count = 0 +loop0: + +sleep 300 +print 1 sql select * from streamt; +sql select * from streamt; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 4 then + print ======rows=$rows + goto loop0 +endi + +# row 0 +if $data01 != 4 then + print ======data01=$data01 + goto loop0 +endi + +# row 1 +if $data11 != 4 then + print ======data11=$data11 + goto loop0 +endi + +# row 2 +if $data21 != 4 then + print ======data21=$data21 + goto loop0 +endi + +# row 3 +if $data31 != 2 then + print ======data31=$data31 + goto loop0 +endi + +sql insert into t1 values(1648791213000,0,1,1,1.0); + + +$loop_count = 0 +loop1: + +sleep 300 +print 1 sql select * from streamt; +sql select * from streamt; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 4 then + print ======rows=$rows + goto loop1 +endi + +# row 0 +if $data01 != 4 then + print ======data01=$data01 + goto loop1 +endi + +# row 1 +if $data11 != 4 then + print ======data11=$data11 + goto loop1 +endi + +# row 2 +if $data21 != 4 then + print ======data21=$data21 + goto loop1 +endi + +# row 3 +if $data31 != 2 then + print ======data31=$data31 + goto loop1 +endi + +sleep 500 +sql insert into t1 values(1648791223002,9,2,2,1.1); + + +$loop_count = 0 +loop2: + +sleep 300 +print 1 sql select * from streamt; +sql select * from streamt; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 4 then + print ======rows=$rows + goto loop2 +endi + +# row 0 +if $data01 != 4 then + print ======data01=$data01 + goto loop2 +endi + +# row 1 +if $data11 != 4 then + print ======data11=$data11 + goto loop2 +endi + +# row 2 +if $data21 != 4 then + print ======data21=$data21 + goto loop2 +endi + +# row 3 +if $data31 != 2 then + print ======data31=$data31 + goto loop2 +endi + +print count sliding 1 end +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/stream/countSliding2.sim b/tests/script/tsim/stream/countSliding2.sim new file mode 100644 index 0000000000..8841283c81 --- /dev/null +++ b/tests/script/tsim/stream/countSliding2.sim @@ -0,0 +1,175 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +print step1 +print =============== create database +sql create database test vgroups 1; +sql use test; + +sql create table t1(ts timestamp, a int, b int , c int, d double); +sql create stream streams1 trigger at_once IGNORE EXPIRED 1 IGNORE UPDATE 0 WATERMARK 100s into streamt as select _wstart as s, count(*) c1, sum(b), max(c) from t1 count_window(4, 2); +sleep 1000 + +sql insert into t1 values(1648791213000,0,1,1,1.0); +sleep 100 +sql insert into t1 values(1648791213001,9,2,2,1.1); +sleep 100 +sql insert into t1 values(1648791213002,0,3,3,1.0); +sleep 100 +sql insert into t1 values(1648791213009,0,3,3,1.0); +sleep 100 +sql insert into t1 values(1648791223000,0,1,1,1.0); +sleep 100 +sql insert into t1 values(1648791223001,9,2,2,1.1); +sleep 100 +sql insert into t1 values(1648791223002,9,2,2,1.1); +sleep 100 +sql insert into t1 values(1648791223009,0,3,3,1.0); + +$loop_count = 0 +loop0: + +sleep 300 +print 1 sql select * from streamt; +sql select * from streamt; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 4 then + print ======rows=$rows + goto loop0 +endi + +# row 0 +if $data01 != 4 then + print ======data01=$data01 + goto loop0 +endi + +# row 1 +if $data11 != 4 then + print ======data11=$data11 + goto loop0 +endi + +# row 2 +if $data21 != 4 then + print ======data21=$data21 + goto loop0 +endi + +# row 3 +if $data31 != 2 then + print ======data31=$data31 + goto loop0 +endi + +sql delete from t1 where ts = 1648791213000; + + +$loop_count = 0 +loop1: + +sleep 300 +print 1 sql select * from streamt; +sql select * from streamt; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 4 then + print ======rows=$rows + goto loop1 +endi + +# row 0 +if $data01 != 4 then + print ======data01=$data01 + goto loop1 +endi + +# row 1 +if $data11 != 4 then + print ======data11=$data11 + goto loop1 +endi + +# row 2 +if $data21 != 3 then + print ======data21=$data21 + goto loop1 +endi + +# row 3 +if $data31 != 1 then + print ======data31=$data31 + goto loop1 +endi + +sleep 500 +sql delete from t1 where ts = 1648791223002; + + +$loop_count = 0 +loop2: + +sleep 300 +print 1 sql select * from streamt; +sql select * from streamt; + +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data30 $data31 $data32 $data33 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +# row 0 +if $rows != 3 then + print ======rows=$rows + goto loop2 +endi + +# row 0 +if $data01 != 4 then + print ======data01=$data01 + goto loop2 +endi + +# row 1 +if $data11 != 4 then + print ======data11=$data11 + goto loop2 +endi + +# row 2 +if $data21 != 2 then + print ======data21=$data21 + goto loop2 +endi + +print count sliding 1 end +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/system-test/2-query/agg_group_AlwaysReturnValue.py b/tests/system-test/2-query/agg_group_AlwaysReturnValue.py new file mode 100755 index 0000000000..9ed0e3fc4a --- /dev/null +++ b/tests/system-test/2-query/agg_group_AlwaysReturnValue.py @@ -0,0 +1,1605 @@ +################################################################### +# 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.cases import tdCases +#from .nestedQueryInterval import * +from .nestedQuery import * +from faker import Faker +import random + +class TDTestCase(TDTestCase): + + def data_check_tbname(self,sql,groupby='Y',partitionby='Y',base_fun='',replace_fun='',base_column='',replace_column=''): + + if groupby=='Y': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(12) + tdSql.checkData(0, 1, 100) + tdSql.checkData(1, 1, 200) + tdSql.checkData(2, 1, 00) + tdSql.checkData(3, 1, 0) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + tdSql.checkData(10, 1, 00) + tdSql.checkData(11, 1, 0) + elif groupby=='UNIONALL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(24) + tdSql.checkData(0, 1, 100) + tdSql.checkData(1, 1, 100) + tdSql.checkData(2, 1, 200) + tdSql.checkData(3, 1, 200) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + tdSql.checkData(10, 1, 00) + tdSql.checkData(11, 1, 0) + elif groupby=='UNIONALLNULL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(24) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 00) + tdSql.checkData(2, 1, 00) + tdSql.checkData(3, 1, 0) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + tdSql.checkData(10, 1, 00) + tdSql.checkData(11, 1, 0) + elif groupby=='NULL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(12) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 0) + tdSql.checkData(2, 1, 00) + tdSql.checkData(3, 1, 0) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + tdSql.checkData(10, 1, 00) + tdSql.checkData(11, 1, 0) + elif groupby=='HAVING=0': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(10) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 0) + tdSql.checkData(2, 1, 00) + tdSql.checkData(3, 1, 0) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + elif groupby=='HAVING>0': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(0, 1, 100) + tdSql.checkData(1, 1, 200) + elif groupby=='HAVING>04': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(4) + tdSql.checkData(0, 1, 100) + tdSql.checkData(1, 1, 100) + tdSql.checkData(2, 1, 200) + tdSql.checkData(3, 1, 200) + elif groupby=='HAVINGCOLUMN=0': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 0) + elif groupby=='NOTSUPPORT': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 0) + elif groupby=='AGG0': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(0) + elif groupby=='AGG2': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(2) + elif groupby=='AGG2_NULL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(0, 1, 'None') + tdSql.checkData(1, 1, 'None') + elif groupby=='AGG4': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(4) + elif groupby=='AGG4_NULL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(4) + tdSql.checkData(0, 1, 'None') + tdSql.checkData(1, 1, 'None') + elif groupby=='AGG10': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(10) + elif groupby=='AGG12': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(12) + elif groupby=='AGG20': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(20) + elif groupby=='AGG24': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(24) + else: + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(12) + + + if partitionby=='Y': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(12) + tdSql.checkData(0, 1, 100) + tdSql.checkData(1, 1, 200) + tdSql.checkData(2, 1, 00) + tdSql.checkData(3, 1, 0) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + tdSql.checkData(10, 1, 00) + tdSql.checkData(11, 1, 0) + elif groupby=='UNIONALL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(24) + tdSql.checkData(0, 1, 100) + tdSql.checkData(1, 1, 100) + tdSql.checkData(2, 1, 200) + tdSql.checkData(3, 1, 200) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + tdSql.checkData(10, 1, 00) + tdSql.checkData(11, 1, 0) + elif groupby=='UNIONALLNULL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(24) + tdSql.checkData(0, 1, 00) + tdSql.checkData(1, 1, 00) + tdSql.checkData(2, 1, 00) + tdSql.checkData(3, 1, 0) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + tdSql.checkData(10, 1, 00) + tdSql.checkData(11, 1, 0) + elif partitionby=='NULL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(12) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 0) + tdSql.checkData(2, 1, 00) + tdSql.checkData(3, 1, 0) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + tdSql.checkData(10, 1, 00) + tdSql.checkData(11, 1, 0) + elif partitionby=='HAVING=0': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(10) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 0) + tdSql.checkData(2, 1, 00) + tdSql.checkData(3, 1, 0) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + elif partitionby=='HAVING>0': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(0, 1, 100) + tdSql.checkData(1, 1, 200) + elif partitionby=='HAVING>04': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(4) + tdSql.checkData(0, 1, 100) + tdSql.checkData(1, 1, 100) + tdSql.checkData(2, 1, 200) + tdSql.checkData(3, 1, 200) + elif partitionby=='HAVINGCOLUMN=0': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 0) + elif partitionby=='NOTSUPPORT': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 0) + elif partitionby=='AGG0': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(0) + elif partitionby=='AGG2': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(2) + elif partitionby=='AGG2_NULL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(0, 1, 'None') + tdSql.checkData(1, 1, 'None') + elif partitionby=='AGG4': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(4) + elif partitionby=='AGG4_NULL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(4) + tdSql.checkData(0, 1, 'None') + tdSql.checkData(1, 1, 'None') + elif partitionby=='AGG10': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(10) + elif partitionby=='AGG12': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(12) + elif partitionby=='AGG20': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(20) + elif partitionby=='AGG24': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(24) + else: + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(12) + + + def tbname_count(self, dbname="nested",base_fun="AGG",replace_fun="COUNT",base_column="COLUMN",replace_column="q_int",execute="Y"): + + # stable count(*) + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + self.data_check_tbname(sql,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #where null \ not null + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is not null group by tbname order by tbname " + self.data_check_tbname(sql,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname order by tbname " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'UNIONALL','UNIONALL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'UNIONALL','UNIONALL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'UNIONALL','UNIONALL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + #having <=0 + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) = 0 order by tbname " + self.data_check_tbname(sql,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) <= 0 order by tbname " + self.data_check_tbname(sql,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname having count(*) <= 0 order by tbname " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #count + having <=0 + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having AGG(COLUMN) = 0 order by tbname " + self.data_check_tbname(sql,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having AGG(COLUMN) <= 0 order by tbname " + self.data_check_tbname(sql,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname having AGG(COLUMN) = 0 order by tbname " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #having >0 + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) != 0 order by tbname " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) > 0 order by tbname " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname having count(*) > 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #count + having >0 + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having AGG(COLUMN) != 0 order by tbname " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having AGG(COLUMN) > 0 order by tbname " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname having AGG(COLUMN) != 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #order by count(*) + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,count(*) " + self.data_check_tbname(sql,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname order by tbname,count(*) " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + def tbname_count_null(self, dbname="nested",base_fun="AGG",replace_fun="COUNT",base_column="COLUMN",replace_column="q_int",execute="Y"): + + # stable count(*) + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #where null \ not null + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is not null group by tbname order by tbname " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname order by tbname " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'UNIONALLNULL','UNIONALLNULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'UNIONALLNULL','UNIONALLNULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'UNIONALLNULL','UNIONALLNULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #having <=0 + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) = 0 order by tbname " + self.data_check_tbname(sql,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) <= 0 order by tbname " + self.data_check_tbname(sql,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname having count(*) <= 0 order by tbname " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #having >0 + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) != 0 order by tbname " + self.data_check_tbname(sql,'HAVINGCOLUMN=0','HAVINGCOLUMN=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVINGCOLUMN=0','HAVINGCOLUMN=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVINGCOLUMN=0','HAVINGCOLUMN=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) > 0 order by tbname " + self.data_check_tbname(sql,'HAVINGCOLUMN=0','HAVINGCOLUMN=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVINGCOLUMN=0','HAVINGCOLUMN=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVINGCOLUMN=0','HAVINGCOLUMN=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname having count(*) != 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #order by count(*) + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,count(*) " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname order by tbname,count(*) " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + def tbname_count_all(self): + #random data + fake = Faker('zh_CN') + random_data_big = fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=10) + random_data_str = fake.pystr() + random_data_float = fake.pyfloat() + + #random cal + calculations = ['+','-','*','/'] + calculation = random.sample(calculations,1) + calculation = str(calculation).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random data column + data_columns = ['q_int','q_bigint','q_smallint','q_tinyint','q_float','q_double'] + data_null_columns = ['q_int_null','q_bigint_null','q_smallint_null','q_tinyint_null','q_float_null','q_double_null'] + + data_column = random.sample(data_columns,1) + data_column = str(data_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + data_null_column = random.sample(data_null_columns,1) + data_null_column = str(data_null_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + data_all_columns = data_columns + data_null_columns + data_all_column = random.sample(data_all_columns,1) + data_all_column = str(data_all_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random data tag + data_tags = ['t_int','t_bigint','t_smallint','t_tinyint','t_float','t_double'] + data_null_tags = ['t_int_null','t_bigint_null','t_smallint_null','t_tinyint_null','t_float_null','t_double_null'] + + data_tag = random.sample(data_tags,1) + data_tag = str(data_tag).replace("[","").replace("]","").replace("'","").replace(", ","") + + data_null_tag = random.sample(data_null_tags,1) + data_null_tag = str(data_null_tag).replace("[","").replace("]","").replace("'","").replace(", ","") + + data_all_tags = data_tags + data_null_tags + data_all_tag = random.sample(data_all_tags,1) + data_all_tag = str(data_all_tag).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random ts column + ts_columns = ['ts','_c0','_C0','_rowts'] + ts_column = random.sample(ts_columns,1) + ts_column = str(ts_column).replace("[","").replace("]","").replace("'","").replace(", ","") + #random other column + other_columns = ['q_bool','q_binary','q_nchar','q_ts','loc','t_bool','t_binary','t_nchar','t_ts'] + other_column = random.sample(other_columns,1) + other_column = str(other_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random other null column and tag + other_null_columns = ['q_bool_null','q_binary_null','q_nchar_null','q_ts_null','t_bool_null','t_binary_null','t_nchar_null','t_ts_null'] + other_null_column = random.sample(other_null_columns,1) + other_null_column = str(other_null_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random all column + all_columns = data_all_columns + data_all_tags + ts_columns + other_columns + other_null_columns + all_column = random.sample(all_columns,1) + all_column = str(all_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + + self.tbname_count_null(replace_fun='count',replace_column=f'{data_null_column}') + self.tbname_count_null(replace_fun='count',replace_column=f'{data_null_tag}') + self.tbname_count_null(replace_fun='count',replace_column=f'{other_null_column}') + + self.tbname_count(replace_fun='count',replace_column='*') + self.tbname_count(replace_fun='count',replace_column=f'{data_column}') + self.tbname_count(replace_fun='count',replace_column=f'{ts_column}') + + self.tbname_count(replace_fun='count',replace_column=f'{other_column}') + self.tbname_count(replace_fun='count',replace_column=f'{data_tag}') + + self.tbname_count(replace_fun='count',replace_column=f'{random_data_big}') + self.tbname_count(replace_fun='count',replace_column=f'{random_data_float}') + self.tbname_count(replace_fun='count',replace_column=f'\'{random_data_str}\'') + self.tbname_count(replace_fun='count',replace_column=f'{random_data_big} {calculation} (abs({data_column})+1)') + self.tbname_count(replace_fun='count',replace_column=f'{random_data_float} {calculation} (abs({data_column})+1)') + + def tbname_agg(self, dbname="nested",base_fun="AGG",replace_fun="",base_column="COLUMN",replace_column="q_int",execute="Y"): + + # stable count(*) + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #where null \ not null + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is not null group by tbname order by tbname " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + #union + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + if execute=="Y": + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) = 0 order by tbname " + self.data_check_tbname(sql,'AGG10','AGG10',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG10','AGG10',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG10','AGG10',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) <= 0 order by tbname " + self.data_check_tbname(sql,'AGG10','AGG10',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG10','AGG10',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG10','AGG10',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) != 0 order by tbname " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) > 0 order by tbname " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,count(*) " + self.data_check_tbname(sql,'AGG12','AGG12',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG12','AGG12',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG12','AGG12',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + # Mixed scene + if execute=="Y": + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) = 0 order by tbname " + self.data_check_tbname(sql,'AGG10','AGG10',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG10','AGG10',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG10','AGG10',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) <= 0 order by tbname " + self.data_check_tbname(sql,'AGG10','AGG10',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG10','AGG10',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG10','AGG10',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) = 0 order by tbname " + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'AGG10','AGG10',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG10','AGG10',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG10','AGG10',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) <= 0 order by tbname " + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'AGG20','AGG20',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG20','AGG20',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG20','AGG20',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) != 0 order by tbname " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) > 0 order by tbname " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) != 0 order by tbname " + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) > 0 order by tbname " + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN) " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN) " + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN) " + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + + sql = f"select tbname,AGG(COLUMN),count(*) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN) " + self.data_check_tbname(sql,'AGG12','AGG12',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG12','AGG12',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG12','AGG12',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select tbname tb,AGG(COLUMN),count(*) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN)" + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'AGG12','AGG12',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG12','AGG12',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG12','AGG12',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select tbname tb ,AGG(COLUMN),count(*) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN)" + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'AGG24','AGG24',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG24','AGG24',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG24','AGG24',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN),count(*) " + self.data_check_tbname(sql,'AGG12','AGG12',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG12','AGG12',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG12','AGG12',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN),count(*)" + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'AGG12','AGG12',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG12','AGG12',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG12','AGG12',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN),count(*)" + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'AGG24','AGG24',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG24','AGG24',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG24','AGG24',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + + def tbname_agg_all(self): + #random data + fake = Faker('zh_CN') + random_data_big = fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=10) + random_data_str = fake.pystr() + random_data_float = fake.pyfloat() + random_data_start = fake.random_int(min=0, max=100, step=1) + random_data_end = fake.random_int(min=0, max=100, step=1) + + #random cal + calculations = ['+','-','*','/'] + calculation = random.sample(calculations,1) + calculation = str(calculation).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random data column + data_columns = ['q_int','q_bigint','q_smallint','q_tinyint','q_float','q_double','t_int','t_bigint','t_smallint','t_tinyint','t_float','t_double'] + data_null_columns = ['q_int_null','q_bigint_null','q_smallint_null','q_tinyint_null','q_float_null','q_double_null','t_int','t_bigint','t_smallint','t_tinyint','t_float','t_double'] + data_columns = data_columns + data_null_columns + data_column = random.sample(data_null_columns,1) + data_column = str(data_column).replace("[","").replace("]","").replace("'","").replace(", ","") + #random ts column + ts_columns = ['ts','_c0','_C0','_rowts'] + ts_column = random.sample(ts_columns,1) + ts_column = str(ts_column).replace("[","").replace("]","").replace("'","").replace(", ","") + #random ts unit column + ts_units = ['1a','1s','1m','1h','1d','1w'] + ts_unit = random.sample(ts_units,1) + ts_unit = str(ts_unit).replace("[","").replace("]","").replace("'","").replace(", ","") + #random str column + str_columns = ['q_int','q_bigint','q_smallint','q_tinyint','q_float','q_double','t_int','t_bigint','t_smallint','t_tinyint','t_float','t_double'] + str_column = random.sample(str_columns,1) + str_column = str(str_column).replace("[","").replace("]","").replace("'","").replace(", ","") + #random other column + other_columns = ['q_bool','q_binary','q_nchar','q_ts','loc','t_bool','t_binary','t_nchar','t_ts'] + other_column = random.sample(other_columns,1) + other_column = str(other_column).replace("[","").replace("]","").replace("'","").replace(", ","") + #random all column + all_columns = data_columns + ts_columns + str_columns + other_columns + all_column = random.sample(all_columns,1) + all_column = str(all_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + self.tbname_agg(replace_fun='sum',replace_column=f'{data_column}') + self.tbname_agg(replace_fun='sum',replace_column=f'{random_data_big}') + self.tbname_agg(replace_fun='sum',replace_column=f'{random_data_float}') + self.tbname_agg(replace_fun='sum',replace_column=f'{random_data_big} {calculation} {data_column}') + self.tbname_agg(replace_fun='sum',replace_column=f'{random_data_float} {calculation} {data_column}') + + self.tbname_agg(replace_fun='avg',replace_column=f'{data_column}') + self.tbname_agg(replace_fun='avg',replace_column=f'{random_data_big}') + self.tbname_agg(replace_fun='avg',replace_column=f'{random_data_float}') + self.tbname_agg(replace_fun='avg',replace_column=f'{random_data_big} {calculation} {data_column}') + self.tbname_agg(replace_fun='avg',replace_column=f'{random_data_float} {calculation} {data_column}') + + self.tbname_agg(replace_fun='spread',replace_column=f'{data_column}') + self.tbname_agg(replace_fun='spread',replace_column=f'{random_data_big}') + self.tbname_agg(replace_fun='spread',replace_column=f'{random_data_float}') + self.tbname_agg(replace_fun='spread',replace_column=f'{random_data_big} {calculation} {data_column}') + self.tbname_agg(replace_fun='spread',replace_column=f'{random_data_float} {calculation} {data_column}') + + self.tbname_agg(replace_fun='stddev',replace_column=f'{data_column}') + self.tbname_agg(replace_fun='stddev',replace_column=f'{random_data_big}') + self.tbname_agg(replace_fun='stddev',replace_column=f'{random_data_float}') + self.tbname_agg(replace_fun='stddev',replace_column=f'{random_data_big} {calculation} {data_column}') + self.tbname_agg(replace_fun='stddev',replace_column=f'{random_data_float} {calculation} {data_column}') + + self.tbname_agg(replace_fun='elapsed',replace_column=f'{ts_column}') + self.tbname_agg(replace_fun='elapsed',replace_column=f'{ts_column},{ts_unit}') + + self.tbname_agg(replace_fun='hyperloglog',replace_column=f'{all_column}') + self.tbname_agg(replace_fun='hyperloglog',replace_column=f'{random_data_big}') + self.tbname_agg(replace_fun='hyperloglog',replace_column=f'{random_data_float}') + self.tbname_agg(replace_fun='hyperloglog',replace_column=f'\'{random_data_str}\'') + self.tbname_agg(replace_fun='hyperloglog',replace_column=f'{random_data_big} {calculation} {data_column}') + self.tbname_agg(replace_fun='hyperloglog',replace_column=f'{random_data_float} {calculation} {data_column}') + + self.tbname_agg(replace_fun='apercentile',replace_column=f'{data_column},{random_data_start}') + self.tbname_agg(replace_fun='apercentile',replace_column=f'{data_column},{random_data_start},"default"') + self.tbname_agg(replace_fun='apercentile',replace_column=f'{data_column},{random_data_start},"t-digest"') + # not support + # self.tbname_agg(replace_fun='percentile',replace_column=f'{data_column},{random_data_start}') + # self.tbname_agg(replace_fun='percentile',replace_column=f'{data_column},{random_data_end}') + # self.tbname_agg(replace_fun='percentile',replace_column=f'{data_column},{random_data_big}') + + self.tbname_agg(replace_fun='leastsquares',replace_column=f'{data_column},{random_data_start},{random_data_end}') + self.tbname_agg(replace_fun='leastsquares',replace_column=f'{data_column},{random_data_start},{random_data_big}') + + self.tbname_agg(replace_fun='histogram',replace_column=f'{data_column},"user_input","[-100000000000,100000000000]",0',execute='N') + self.tbname_agg(replace_fun='histogram',replace_column=f'{data_column},"user_input","[-100000000000,100000000000]",1',execute='N') + histogram_logbin = '{"start":1.0, "factor": 2.0, "count": 1, "infinity": false}' + histogram_linear_bin = '{"start":1.0, "width": 2.0, "count": 1, "infinity": false}' + self.tbname_agg(replace_fun='histogram',replace_column=f'{data_column},"log_bin",\'{histogram_logbin}\',1',execute='N') + self.tbname_agg(replace_fun='histogram',replace_column=f'{data_column},"linear_bin",\'{histogram_linear_bin}\',1',execute='N') + + + + def tag_count(self, dbname="nested",base_fun="AGG",replace_fun="COUNT",base_column="COLUMN",replace_column="q_int",execute="Y"): + + # stable count(*) + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc order by loc " + self.data_check_tbname(sql,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #where null \ not null + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is not null group by loc order by loc " + self.data_check_tbname(sql,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc order by loc " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select loc tb,AGG(COLUMN) from {dbname}.stable_1 group by loc order by loc " + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select loc tb,AGG(COLUMN) from {dbname}.stable_1 group by loc order by loc " + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'UNIONALL','UNIONALL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'UNIONALL','UNIONALL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'UNIONALL','UNIONALL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + #having <=0 + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having count(*) = 0 order by loc " + self.data_check_tbname(sql,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having count(*) <= 0 order by loc " + self.data_check_tbname(sql,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc having count(*) <= 0 order by loc " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #count + having <=0 + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having AGG(COLUMN) = 0 order by loc " + self.data_check_tbname(sql,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having AGG(COLUMN) <= 0 order by loc " + self.data_check_tbname(sql,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc having AGG(COLUMN) = 0 order by loc " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #having >0 + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having count(*) != 0 order by loc " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having count(*) > 0 order by loc " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc having count(*) > 0 order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #count + having >0 + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having AGG(COLUMN) != 0 order by loc " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having AGG(COLUMN) > 0 order by loc " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc having AGG(COLUMN) != 0 order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #order by count(*) + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc order by loc,count(*) " + self.data_check_tbname(sql,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'Y','Y',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc order by loc,count(*) " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + def tag_count_null(self, dbname="nested",base_fun="AGG",replace_fun="COUNT",base_column="COLUMN",replace_column="q_int",execute="Y"): + + # stable count(*) + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc order by loc " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #where null \ not null + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is not null group by loc order by loc " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc order by loc " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select loc tb,AGG(COLUMN) from {dbname}.stable_1 group by loc order by loc " + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select loc tb,AGG(COLUMN) from {dbname}.stable_1 group by loc order by loc " + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'UNIONALLNULL','UNIONALLNULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'UNIONALLNULL','UNIONALLNULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'UNIONALLNULL','UNIONALLNULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #having <=0 + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having count(*) = 0 order by loc " + self.data_check_tbname(sql,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having count(*) <= 0 order by loc " + self.data_check_tbname(sql,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING=0','HAVING=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc having count(*) <= 0 order by loc " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #having >0 + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having count(*) != 0 order by loc " + self.data_check_tbname(sql,'HAVINGCOLUMN=0','HAVINGCOLUMN=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVINGCOLUMN=0','HAVINGCOLUMN=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVINGCOLUMN=0','HAVINGCOLUMN=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having count(*) > 0 order by loc " + self.data_check_tbname(sql,'HAVINGCOLUMN=0','HAVINGCOLUMN=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVINGCOLUMN=0','HAVINGCOLUMN=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVINGCOLUMN=0','HAVINGCOLUMN=0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc having count(*) != 0 order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #order by count(*) + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc order by loc,count(*) " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc order by loc,count(*) " + self.data_check_tbname(sql,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'NULL','NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + def tag_count_all(self): + #random data + fake = Faker('zh_CN') + random_data_big = fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=10) + random_data_str = fake.pystr() + random_data_float = fake.pyfloat() + + #random cal + calculations = ['+','-','*','/'] + calculation = random.sample(calculations,1) + calculation = str(calculation).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random data column + data_columns = ['q_int','q_bigint','q_smallint','q_tinyint','q_float','q_double'] + data_null_columns = ['q_int_null','q_bigint_null','q_smallint_null','q_tinyint_null','q_float_null','q_double_null'] + + data_column = random.sample(data_columns,1) + data_column = str(data_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + data_null_column = random.sample(data_null_columns,1) + data_null_column = str(data_null_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + data_all_columns = data_columns + data_null_columns + data_all_column = random.sample(data_all_columns,1) + data_all_column = str(data_all_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random data tag + data_tags = ['t_int','t_bigint','t_smallint','t_tinyint','t_float','t_double'] + data_null_tags = ['t_int_null','t_bigint_null','t_smallint_null','t_tinyint_null','t_float_null','t_double_null'] + + data_tag = random.sample(data_tags,1) + data_tag = str(data_tag).replace("[","").replace("]","").replace("'","").replace(", ","") + + data_null_tag = random.sample(data_null_tags,1) + data_null_tag = str(data_null_tag).replace("[","").replace("]","").replace("'","").replace(", ","") + + data_all_tags = data_tags + data_null_tags + data_all_tag = random.sample(data_all_tags,1) + data_all_tag = str(data_all_tag).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random ts column + ts_columns = ['ts','_c0','_C0','_rowts'] + ts_column = random.sample(ts_columns,1) + ts_column = str(ts_column).replace("[","").replace("]","").replace("'","").replace(", ","") + #random other column + other_columns = ['q_bool','q_binary','q_nchar','q_ts','loc','t_bool','t_binary','t_nchar','t_ts'] + other_column = random.sample(other_columns,1) + other_column = str(other_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random other null column and tag + other_null_columns = ['q_bool_null','q_binary_null','q_nchar_null','q_ts_null','t_bool_null','t_binary_null','t_nchar_null','t_ts_null'] + other_null_column = random.sample(other_null_columns,1) + other_null_column = str(other_null_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random all column + all_columns = data_all_columns + data_all_tags + ts_columns + other_columns + other_null_columns + all_column = random.sample(all_columns,1) + all_column = str(all_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + + self.tag_count_null(replace_fun='count',replace_column=f'{data_null_column}') + self.tag_count_null(replace_fun='count',replace_column=f'{data_null_tag}') + self.tag_count_null(replace_fun='count',replace_column=f'{other_null_column}') + + self.tag_count(replace_fun='count',replace_column='*') + self.tag_count(replace_fun='count',replace_column=f'{data_column}') + self.tag_count(replace_fun='count',replace_column=f'{ts_column}') + + self.tag_count(replace_fun='count',replace_column=f'{other_column}') + self.tag_count(replace_fun='count',replace_column=f'{data_tag}') + + self.tag_count(replace_fun='count',replace_column=f'{random_data_big}') + self.tag_count(replace_fun='count',replace_column=f'{random_data_float}') + self.tag_count(replace_fun='count',replace_column=f'\'{random_data_str}\'') + self.tag_count(replace_fun='count',replace_column=f'{random_data_big} {calculation} (abs({data_column})+1)') + self.tag_count(replace_fun='count',replace_column=f'{random_data_float} {calculation} (abs({data_column})+1)') + + + + def modify_tables(self): + fake = Faker('zh_CN') + tdSql.execute('delete from stable_1_3;') + tdSql.execute('delete from stable_1_4;') + tdSql.execute('''create table stable_1_5 using stable_1 tags('stable_1_5', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_1_6 using stable_1 tags('stable_1_6', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_1_7 using stable_1 tags('stable_1_7', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_1_8 using stable_1 tags('stable_1_8', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_1_9 using stable_1 tags('stable_1_9', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_1_90 using stable_1 tags('stable_1_90', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_1_91 using stable_1 tags('stable_1_91', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_1_92 using stable_1 tags('stable_1_92', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + + tdSql.execute('alter stable stable_1 add tag t_int_null INT;') + tdSql.execute('alter stable stable_1 add tag t_bigint_null BIGINT;') + tdSql.execute('alter stable stable_1 add tag t_smallint_null SMALLINT;') + tdSql.execute('alter stable stable_1 add tag t_tinyint_null TINYINT;') + tdSql.execute('alter stable stable_1 add tag t_bool_null BOOL;') + tdSql.execute('alter stable stable_1 add tag t_binary_null VARCHAR(100);') + tdSql.execute('alter stable stable_1 add tag t_nchar_null NCHAR(100);') + tdSql.execute('alter stable stable_1 add tag t_float_null FLOAT;') + tdSql.execute('alter stable stable_1 add tag t_double_null DOUBLE;') + tdSql.execute('alter stable stable_1 add tag t_ts_null TIMESTAMP;') + + tdSql.execute('alter stable stable_1 drop column q_nchar8;') + tdSql.execute('alter stable stable_1 drop column q_binary8;') + tdSql.execute('alter stable stable_1 drop column q_nchar7;') + tdSql.execute('alter stable stable_1 drop column q_binary7;') + tdSql.execute('alter stable stable_1 drop column q_nchar6;') + tdSql.execute('alter stable stable_1 drop column q_binary6;') + tdSql.execute('alter stable stable_1 drop column q_nchar5;') + tdSql.execute('alter stable stable_1 drop column q_binary5;') + tdSql.execute('alter stable stable_1 drop column q_nchar4;') + tdSql.execute('alter stable stable_1 drop column q_binary4;') + + def run(self): + tdSql.prepare() + + startTime = time.time() + + # self.create_tables() + # self.insert_data() + + self.dropandcreateDB_random("nested", 1) + self.modify_tables() + + for i in range(1): + self.tbname_count_all() + self.tag_count_all() + self.tbname_agg_all() + + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/agg_group_NotReturnValue.py b/tests/system-test/2-query/agg_group_NotReturnValue.py new file mode 100755 index 0000000000..d25395cbbd --- /dev/null +++ b/tests/system-test/2-query/agg_group_NotReturnValue.py @@ -0,0 +1,1606 @@ +################################################################### +# 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.cases import tdCases +#from .nestedQueryInterval import * +from .nestedQuery import * +from faker import Faker +import random + +class TDTestCase(TDTestCase): + updatecfgDict = {'countAlwaysReturnValue':0} + + def data_check_tbname(self,sql,groupby='Y',partitionby='Y',base_fun='',replace_fun='',base_column='',replace_column=''): + + if groupby=='Y': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(12) + tdSql.checkData(0, 1, 100) + tdSql.checkData(1, 1, 200) + tdSql.checkData(2, 1, 00) + tdSql.checkData(3, 1, 0) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + tdSql.checkData(10, 1, 00) + tdSql.checkData(11, 1, 0) + elif groupby=='UNIONALL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(24) + tdSql.checkData(0, 1, 100) + tdSql.checkData(1, 1, 100) + tdSql.checkData(2, 1, 200) + tdSql.checkData(3, 1, 200) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + tdSql.checkData(10, 1, 00) + tdSql.checkData(11, 1, 0) + elif groupby=='UNIONALLNULL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(24) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 00) + tdSql.checkData(2, 1, 00) + tdSql.checkData(3, 1, 0) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + tdSql.checkData(10, 1, 00) + tdSql.checkData(11, 1, 0) + elif groupby=='NULL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(12) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 0) + tdSql.checkData(2, 1, 00) + tdSql.checkData(3, 1, 0) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + tdSql.checkData(10, 1, 00) + tdSql.checkData(11, 1, 0) + elif groupby=='HAVING=0': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(10) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 0) + tdSql.checkData(2, 1, 00) + tdSql.checkData(3, 1, 0) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + elif groupby=='HAVING>0': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(0, 1, 100) + tdSql.checkData(1, 1, 200) + elif groupby=='HAVING>04': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(4) + tdSql.checkData(0, 1, 100) + tdSql.checkData(1, 1, 100) + tdSql.checkData(2, 1, 200) + tdSql.checkData(3, 1, 200) + elif groupby=='HAVINGCOLUMN=0': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 0) + elif groupby=='NOTSUPPORT': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 0) + elif groupby=='AGG0': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(0) + elif groupby=='AGG2': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(2) + elif groupby=='AGG2_NULL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(0, 1, 'None') + tdSql.checkData(1, 1, 'None') + elif groupby=='AGG4': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(4) + elif groupby=='AGG4_NULL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(4) + tdSql.checkData(0, 1, 'None') + tdSql.checkData(1, 1, 'None') + elif groupby=='AGG10': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(10) + elif groupby=='AGG12': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(12) + elif groupby=='AGG20': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(20) + elif groupby=='AGG24': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(24) + else: + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(12) + + + if partitionby=='Y': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(12) + tdSql.checkData(0, 1, 100) + tdSql.checkData(1, 1, 200) + tdSql.checkData(2, 1, 00) + tdSql.checkData(3, 1, 0) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + tdSql.checkData(10, 1, 00) + tdSql.checkData(11, 1, 0) + elif groupby=='UNIONALL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(24) + tdSql.checkData(0, 1, 100) + tdSql.checkData(1, 1, 100) + tdSql.checkData(2, 1, 200) + tdSql.checkData(3, 1, 200) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + tdSql.checkData(10, 1, 00) + tdSql.checkData(11, 1, 0) + elif groupby=='UNIONALLNULL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(24) + tdSql.checkData(0, 1, 00) + tdSql.checkData(1, 1, 00) + tdSql.checkData(2, 1, 00) + tdSql.checkData(3, 1, 0) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + tdSql.checkData(10, 1, 00) + tdSql.checkData(11, 1, 0) + elif partitionby=='NULL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(12) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 0) + tdSql.checkData(2, 1, 00) + tdSql.checkData(3, 1, 0) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + tdSql.checkData(10, 1, 00) + tdSql.checkData(11, 1, 0) + elif partitionby=='HAVING=0': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(10) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 0) + tdSql.checkData(2, 1, 00) + tdSql.checkData(3, 1, 0) + tdSql.checkData(4, 1, 00) + tdSql.checkData(5, 1, 0) + tdSql.checkData(6, 1, 0) + tdSql.checkData(7, 1, 00) + tdSql.checkData(8, 1, 00) + tdSql.checkData(9, 1, 0) + elif partitionby=='HAVING>0': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(0, 1, 100) + tdSql.checkData(1, 1, 200) + elif partitionby=='HAVING>04': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(4) + tdSql.checkData(0, 1, 100) + tdSql.checkData(1, 1, 100) + tdSql.checkData(2, 1, 200) + tdSql.checkData(3, 1, 200) + elif partitionby=='HAVINGCOLUMN=0': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 0) + elif partitionby=='NOTSUPPORT': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(0, 1, 0) + tdSql.checkData(1, 1, 0) + elif partitionby=='AGG0': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(0) + elif partitionby=='AGG2': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(2) + elif partitionby=='AGG2_NULL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(2) + tdSql.checkData(0, 1, 'None') + tdSql.checkData(1, 1, 'None') + elif partitionby=='AGG4': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(4) + elif partitionby=='AGG4_NULL': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + tdSql.query(sql) + tdSql.checkRows(4) + tdSql.checkData(0, 1, 'None') + tdSql.checkData(1, 1, 'None') + elif partitionby=='AGG10': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(10) + elif partitionby=='AGG12': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(12) + elif partitionby=='AGG20': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(20) + elif partitionby=='AGG24': + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(24) + else: + sql = sql.replace(f'{base_fun}',f'{replace_fun}').replace(f'{base_column}',f'{replace_column}') + sql = sql.replace('group','partition') + tdSql.query(sql) + tdSql.checkRows(12) + + + def tbname_count(self, dbname="nested",base_fun="AGG",replace_fun="COUNT",base_column="COLUMN",replace_column="q_int",execute="Y"): + + # stable count(*) + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #where null \ not null + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is not null group by tbname order by tbname " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'HAVING>04','HAVING>04',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>04','HAVING>04',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'HAVING>04','HAVING>04',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + #having <=0 + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) = 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) <= 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname having count(*) <= 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #count + having <=0 + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having AGG(COLUMN) = 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having AGG(COLUMN) <= 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname having AGG(COLUMN) = 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #having >0 + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) != 0 order by tbname " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) > 0 order by tbname " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname having count(*) > 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #count + having >0 + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having AGG(COLUMN) != 0 order by tbname " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having AGG(COLUMN) > 0 order by tbname " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname having AGG(COLUMN) != 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #order by count(*) + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,count(*) " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname order by tbname,count(*) " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + def tbname_count_null(self, dbname="nested",base_fun="AGG",replace_fun="COUNT",base_column="COLUMN",replace_column="q_int",execute="Y"): + + # stable count(*) + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + self.data_check_tbname(sql,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #where null \ not null + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is not null group by tbname order by tbname " + self.data_check_tbname(sql,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'AGG4_NULL','AGG4_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG4_NULL','AGG4_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG4_NULL','AGG4_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #having <=0 + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) = 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) <= 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname having count(*) <= 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #having >0 + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) != 0 order by tbname " + self.data_check_tbname(sql,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) > 0 order by tbname " + self.data_check_tbname(sql,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname having count(*) != 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #order by count(*) + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,count(*) " + self.data_check_tbname(sql,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname order by tbname,count(*) " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + def tbname_count_all(self): + #random data + fake = Faker('zh_CN') + random_data_big = fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=10) + random_data_str = fake.pystr() + random_data_float = fake.pyfloat() + + #random cal + calculations = ['+','-','*','/'] + calculation = random.sample(calculations,1) + calculation = str(calculation).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random data column + data_columns = ['q_int','q_bigint','q_smallint','q_tinyint','q_float','q_double'] + data_null_columns = ['q_int_null','q_bigint_null','q_smallint_null','q_tinyint_null','q_float_null','q_double_null'] + + data_column = random.sample(data_columns,1) + data_column = str(data_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + data_null_column = random.sample(data_null_columns,1) + data_null_column = str(data_null_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + data_all_columns = data_columns + data_null_columns + data_all_column = random.sample(data_all_columns,1) + data_all_column = str(data_all_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random data tag + data_tags = ['t_int','t_bigint','t_smallint','t_tinyint','t_float','t_double'] + data_null_tags = ['t_int_null','t_bigint_null','t_smallint_null','t_tinyint_null','t_float_null','t_double_null'] + + data_tag = random.sample(data_tags,1) + data_tag = str(data_tag).replace("[","").replace("]","").replace("'","").replace(", ","") + + data_null_tag = random.sample(data_null_tags,1) + data_null_tag = str(data_null_tag).replace("[","").replace("]","").replace("'","").replace(", ","") + + data_all_tags = data_tags + data_null_tags + data_all_tag = random.sample(data_all_tags,1) + data_all_tag = str(data_all_tag).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random ts column + ts_columns = ['ts','_c0','_C0','_rowts'] + ts_column = random.sample(ts_columns,1) + ts_column = str(ts_column).replace("[","").replace("]","").replace("'","").replace(", ","") + #random other column + other_columns = ['q_bool','q_binary','q_nchar','q_ts','loc','t_bool','t_binary','t_nchar','t_ts'] + other_column = random.sample(other_columns,1) + other_column = str(other_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random other null column and tag + other_null_columns = ['q_bool_null','q_binary_null','q_nchar_null','q_ts_null','t_bool_null','t_binary_null','t_nchar_null','t_ts_null'] + other_null_column = random.sample(other_null_columns,1) + other_null_column = str(other_null_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random all column + all_columns = data_all_columns + data_all_tags + ts_columns + other_columns + other_null_columns + all_column = random.sample(all_columns,1) + all_column = str(all_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + + self.tbname_count_null(replace_fun='count',replace_column=f'{data_null_column}') + self.tbname_count_null(replace_fun='count',replace_column=f'{data_null_tag}') + self.tbname_count_null(replace_fun='count',replace_column=f'{other_null_column}') + + self.tbname_count(replace_fun='count',replace_column='*') + self.tbname_count(replace_fun='count',replace_column=f'{data_column}') + self.tbname_count(replace_fun='count',replace_column=f'{ts_column}') + + self.tbname_count(replace_fun='count',replace_column=f'{other_column}') + self.tbname_count(replace_fun='count',replace_column=f'{data_tag}') + + self.tbname_count(replace_fun='count',replace_column=f'{random_data_big}') + self.tbname_count(replace_fun='count',replace_column=f'{random_data_float}') + self.tbname_count(replace_fun='count',replace_column=f'\'{random_data_str}\'') + self.tbname_count(replace_fun='count',replace_column=f'{random_data_big} {calculation} (abs({data_column})+1)') + self.tbname_count(replace_fun='count',replace_column=f'{random_data_float} {calculation} (abs({data_column})+1)') + + def tbname_agg(self, dbname="nested",base_fun="AGG",replace_fun="",base_column="COLUMN",replace_column="q_int",execute="Y"): + + # stable count(*) + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #where null \ not null + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is not null group by tbname order by tbname " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by tbname order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + #union + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname " + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + if execute=="Y": + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) = 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) <= 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) != 0 order by tbname " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) > 0 order by tbname " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,count(*) " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + # Mixed scene + if execute=="Y": + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) = 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) <= 0 order by tbname " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) = 0 order by tbname " + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) <= 0 order by tbname " + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) != 0 order by tbname " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) > 0 order by tbname " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) != 0 order by tbname " + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname having count(*) > 0 order by tbname " + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN) " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN) " + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN) " + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + + sql = f"select tbname,AGG(COLUMN),count(*) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN) " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select tbname tb,AGG(COLUMN),count(*) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN)" + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select tbname tb ,AGG(COLUMN),count(*) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN)" + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + + sql = f"select tbname,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN),count(*) " + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tbname " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN),count(*)" + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG2','AGG2',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select tbname tb,AGG(COLUMN) from {dbname}.stable_1 group by tbname order by tbname,AGG(COLUMN),count(*)" + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG4','AGG4',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + + def tbname_agg_all(self): + #random data + fake = Faker('zh_CN') + random_data_big = fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=10) + random_data_str = fake.pystr() + random_data_float = fake.pyfloat() + random_data_start = fake.random_int(min=0, max=100, step=1) + random_data_end = fake.random_int(min=0, max=100, step=1) + + #random cal + calculations = ['+','-','*','/'] + calculation = random.sample(calculations,1) + calculation = str(calculation).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random data column + data_columns = ['q_int','q_bigint','q_smallint','q_tinyint','q_float','q_double','t_int','t_bigint','t_smallint','t_tinyint','t_float','t_double'] + data_null_columns = ['q_int_null','q_bigint_null','q_smallint_null','q_tinyint_null','q_float_null','q_double_null','t_int','t_bigint','t_smallint','t_tinyint','t_float','t_double'] + data_columns = data_columns + data_null_columns + data_column = random.sample(data_null_columns,1) + data_column = str(data_column).replace("[","").replace("]","").replace("'","").replace(", ","") + #random ts column + ts_columns = ['ts','_c0','_C0','_rowts'] + ts_column = random.sample(ts_columns,1) + ts_column = str(ts_column).replace("[","").replace("]","").replace("'","").replace(", ","") + #random ts unit column + ts_units = ['1a','1s','1m','1h','1d','1w'] + ts_unit = random.sample(ts_units,1) + ts_unit = str(ts_unit).replace("[","").replace("]","").replace("'","").replace(", ","") + #random str column + str_columns = ['q_int','q_bigint','q_smallint','q_tinyint','q_float','q_double','t_int','t_bigint','t_smallint','t_tinyint','t_float','t_double'] + str_column = random.sample(str_columns,1) + str_column = str(str_column).replace("[","").replace("]","").replace("'","").replace(", ","") + #random other column + other_columns = ['q_bool','q_binary','q_nchar','q_ts','loc','t_bool','t_binary','t_nchar','t_ts'] + other_column = random.sample(other_columns,1) + other_column = str(other_column).replace("[","").replace("]","").replace("'","").replace(", ","") + #random all column + all_columns = data_columns + ts_columns + str_columns + other_columns + all_column = random.sample(all_columns,1) + all_column = str(all_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + self.tbname_agg(replace_fun='sum',replace_column=f'{data_column}') + self.tbname_agg(replace_fun='sum',replace_column=f'{random_data_big}') + self.tbname_agg(replace_fun='sum',replace_column=f'{random_data_float}') + self.tbname_agg(replace_fun='sum',replace_column=f'{random_data_big} {calculation} {data_column}') + self.tbname_agg(replace_fun='sum',replace_column=f'{random_data_float} {calculation} {data_column}') + + self.tbname_agg(replace_fun='avg',replace_column=f'{data_column}') + self.tbname_agg(replace_fun='avg',replace_column=f'{random_data_big}') + self.tbname_agg(replace_fun='avg',replace_column=f'{random_data_float}') + self.tbname_agg(replace_fun='avg',replace_column=f'{random_data_big} {calculation} {data_column}') + self.tbname_agg(replace_fun='avg',replace_column=f'{random_data_float} {calculation} {data_column}') + + self.tbname_agg(replace_fun='spread',replace_column=f'{data_column}') + self.tbname_agg(replace_fun='spread',replace_column=f'{random_data_big}') + self.tbname_agg(replace_fun='spread',replace_column=f'{random_data_float}') + self.tbname_agg(replace_fun='spread',replace_column=f'{random_data_big} {calculation} {data_column}') + self.tbname_agg(replace_fun='spread',replace_column=f'{random_data_float} {calculation} {data_column}') + + self.tbname_agg(replace_fun='stddev',replace_column=f'{data_column}') + self.tbname_agg(replace_fun='stddev',replace_column=f'{random_data_big}') + self.tbname_agg(replace_fun='stddev',replace_column=f'{random_data_float}') + self.tbname_agg(replace_fun='stddev',replace_column=f'{random_data_big} {calculation} {data_column}') + self.tbname_agg(replace_fun='stddev',replace_column=f'{random_data_float} {calculation} {data_column}') + + self.tbname_agg(replace_fun='elapsed',replace_column=f'{ts_column}') + self.tbname_agg(replace_fun='elapsed',replace_column=f'{ts_column},{ts_unit}') + + self.tbname_agg(replace_fun='hyperloglog',replace_column=f'{all_column}') + self.tbname_agg(replace_fun='hyperloglog',replace_column=f'{random_data_big}') + self.tbname_agg(replace_fun='hyperloglog',replace_column=f'{random_data_float}') + self.tbname_agg(replace_fun='hyperloglog',replace_column=f'\'{random_data_str}\'') + self.tbname_agg(replace_fun='hyperloglog',replace_column=f'{random_data_big} {calculation} {data_column}') + self.tbname_agg(replace_fun='hyperloglog',replace_column=f'{random_data_float} {calculation} {data_column}') + + self.tbname_agg(replace_fun='apercentile',replace_column=f'{data_column},{random_data_start}') + self.tbname_agg(replace_fun='apercentile',replace_column=f'{data_column},{random_data_start},"default"') + self.tbname_agg(replace_fun='apercentile',replace_column=f'{data_column},{random_data_start},"t-digest"') + # not support + # self.tbname_agg(replace_fun='percentile',replace_column=f'{data_column},{random_data_start}') + # self.tbname_agg(replace_fun='percentile',replace_column=f'{data_column},{random_data_end}') + # self.tbname_agg(replace_fun='percentile',replace_column=f'{data_column},{random_data_big}') + + self.tbname_agg(replace_fun='leastsquares',replace_column=f'{data_column},{random_data_start},{random_data_end}') + self.tbname_agg(replace_fun='leastsquares',replace_column=f'{data_column},{random_data_start},{random_data_big}') + + self.tbname_agg(replace_fun='histogram',replace_column=f'{data_column},"user_input","[-100000000000,100000000000]",0',execute='N') + self.tbname_agg(replace_fun='histogram',replace_column=f'{data_column},"user_input","[-100000000000,100000000000]",1',execute='N') + histogram_logbin = '{"start":1.0, "factor": 2.0, "count": 1, "infinity": false}' + histogram_linear_bin = '{"start":1.0, "width": 2.0, "count": 1, "infinity": false}' + self.tbname_agg(replace_fun='histogram',replace_column=f'{data_column},"log_bin",\'{histogram_logbin}\',1',execute='N') + self.tbname_agg(replace_fun='histogram',replace_column=f'{data_column},"linear_bin",\'{histogram_linear_bin}\',1',execute='N') + + + + def tag_count(self, dbname="nested",base_fun="AGG",replace_fun="COUNT",base_column="COLUMN",replace_column="q_int",execute="Y"): + + # stable count(*) + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc order by loc " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #where null \ not null + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is not null group by loc order by loc " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select loc tb,AGG(COLUMN) from {dbname}.stable_1 group by loc order by loc " + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select loc tb,AGG(COLUMN) from {dbname}.stable_1 group by loc order by loc " + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'HAVING>04','HAVING>04',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>04','HAVING>04',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'HAVING>04','HAVING>04',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + #having <=0 + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having count(*) = 0 order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having count(*) <= 0 order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc having count(*) <= 0 order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #count + having <=0 + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having AGG(COLUMN) = 0 order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having AGG(COLUMN) <= 0 order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc having AGG(COLUMN) = 0 order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #having >0 + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having count(*) != 0 order by loc " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having count(*) > 0 order by loc " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc having count(*) > 0 order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #count + having >0 + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having AGG(COLUMN) != 0 order by loc " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having AGG(COLUMN) > 0 order by loc " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc having AGG(COLUMN) != 0 order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #order by count(*) + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc order by loc,count(*) " + self.data_check_tbname(sql,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'HAVING>0','HAVING>0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc order by loc,count(*) " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + def tag_count_null(self, dbname="nested",base_fun="AGG",replace_fun="COUNT",base_column="COLUMN",replace_column="q_int",execute="Y"): + + # stable count(*) + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc order by loc " + self.data_check_tbname(sql,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #where null \ not null + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is not null group by loc order by loc " + self.data_check_tbname(sql,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union + sql = f"select loc tb,AGG(COLUMN) from {dbname}.stable_1 group by loc order by loc " + sql = f"({sql}) union ({sql}) order by tb" + self.data_check_tbname(sql,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #union all + sql = f"select loc tb,AGG(COLUMN) from {dbname}.stable_1 group by loc order by loc " + sql = f"({sql}) union all ({sql}) order by tb" + self.data_check_tbname(sql,'AGG4_NULL','AGG4_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG4_NULL','AGG4_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by tb " + self.data_check_tbname(sql2,'AGG4_NULL','AGG4_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #having <=0 + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having count(*) = 0 order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having count(*) <= 0 order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc having count(*) <= 0 order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #having >0 + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having count(*) != 0 order by loc " + self.data_check_tbname(sql,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc having count(*) > 0 order by loc " + self.data_check_tbname(sql,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc having count(*) != 0 order by loc " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + #order by count(*) + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 group by loc order by loc,count(*) " + self.data_check_tbname(sql,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG2_NULL','AGG2_NULL',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql = f"select loc,AGG(COLUMN) from {dbname}.stable_1 where ts is null group by loc order by loc,count(*) " + self.data_check_tbname(sql,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql1 = f"select * from ({sql})" + self.data_check_tbname(sql1,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + sql2 = f"select * from ({sql}) order by loc " + self.data_check_tbname(sql2,'AGG0','AGG0',f'{base_fun}',f'{replace_fun}',f'{base_column}',f'{replace_column}') + + def tag_count_all(self): + #random data + fake = Faker('zh_CN') + random_data_big = fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=10) + random_data_str = fake.pystr() + random_data_float = fake.pyfloat() + + #random cal + calculations = ['+','-','*','/'] + calculation = random.sample(calculations,1) + calculation = str(calculation).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random data column + data_columns = ['q_int','q_bigint','q_smallint','q_tinyint','q_float','q_double'] + data_null_columns = ['q_int_null','q_bigint_null','q_smallint_null','q_tinyint_null','q_float_null','q_double_null'] + + data_column = random.sample(data_columns,1) + data_column = str(data_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + data_null_column = random.sample(data_null_columns,1) + data_null_column = str(data_null_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + data_all_columns = data_columns + data_null_columns + data_all_column = random.sample(data_all_columns,1) + data_all_column = str(data_all_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random data tag + data_tags = ['t_int','t_bigint','t_smallint','t_tinyint','t_float','t_double'] + data_null_tags = ['t_int_null','t_bigint_null','t_smallint_null','t_tinyint_null','t_float_null','t_double_null'] + + data_tag = random.sample(data_tags,1) + data_tag = str(data_tag).replace("[","").replace("]","").replace("'","").replace(", ","") + + data_null_tag = random.sample(data_null_tags,1) + data_null_tag = str(data_null_tag).replace("[","").replace("]","").replace("'","").replace(", ","") + + data_all_tags = data_tags + data_null_tags + data_all_tag = random.sample(data_all_tags,1) + data_all_tag = str(data_all_tag).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random ts column + ts_columns = ['ts','_c0','_C0','_rowts'] + ts_column = random.sample(ts_columns,1) + ts_column = str(ts_column).replace("[","").replace("]","").replace("'","").replace(", ","") + #random other column + other_columns = ['q_bool','q_binary','q_nchar','q_ts','loc','t_bool','t_binary','t_nchar','t_ts'] + other_column = random.sample(other_columns,1) + other_column = str(other_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random other null column and tag + other_null_columns = ['q_bool_null','q_binary_null','q_nchar_null','q_ts_null','t_bool_null','t_binary_null','t_nchar_null','t_ts_null'] + other_null_column = random.sample(other_null_columns,1) + other_null_column = str(other_null_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + #random all column + all_columns = data_all_columns + data_all_tags + ts_columns + other_columns + other_null_columns + all_column = random.sample(all_columns,1) + all_column = str(all_column).replace("[","").replace("]","").replace("'","").replace(", ","") + + + self.tag_count_null(replace_fun='count',replace_column=f'{data_null_column}') + self.tag_count_null(replace_fun='count',replace_column=f'{data_null_tag}') + self.tag_count_null(replace_fun='count',replace_column=f'{other_null_column}') + + self.tag_count(replace_fun='count',replace_column='*') + self.tag_count(replace_fun='count',replace_column=f'{data_column}') + self.tag_count(replace_fun='count',replace_column=f'{ts_column}') + + self.tag_count(replace_fun='count',replace_column=f'{other_column}') + self.tag_count(replace_fun='count',replace_column=f'{data_tag}') + + self.tag_count(replace_fun='count',replace_column=f'{random_data_big}') + self.tag_count(replace_fun='count',replace_column=f'{random_data_float}') + self.tag_count(replace_fun='count',replace_column=f'\'{random_data_str}\'') + self.tag_count(replace_fun='count',replace_column=f'{random_data_big} {calculation} (abs({data_column})+1)') + self.tag_count(replace_fun='count',replace_column=f'{random_data_float} {calculation} (abs({data_column})+1)') + + + + def modify_tables(self): + fake = Faker('zh_CN') + tdSql.execute('delete from stable_1_3;') + tdSql.execute('delete from stable_1_4;') + tdSql.execute('''create table stable_1_5 using stable_1 tags('stable_1_5', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_1_6 using stable_1 tags('stable_1_6', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_1_7 using stable_1 tags('stable_1_7', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_1_8 using stable_1 tags('stable_1_8', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_1_9 using stable_1 tags('stable_1_9', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_1_90 using stable_1 tags('stable_1_90', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_1_91 using stable_1 tags('stable_1_91', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + tdSql.execute('''create table stable_1_92 using stable_1 tags('stable_1_92', '%d' , '%d', '%d' , '%d' , 1 , 'binary6.%s' , 'nchar6.%s' , '%f', '%f' ,'%d') ;''' + %(fake.random_int(min=-2147483647, max=2147483647, step=1), fake.random_int(min=-9223372036854775807, max=9223372036854775807, step=1), + fake.random_int(min=-32767, max=32767, step=1) , fake.random_int(min=-127, max=127, step=1) , + fake.pystr() ,fake.pystr() ,fake.pyfloat(),fake.pyfloat(),fake.random_int(min=-2147483647, max=2147483647, step=1))) + + tdSql.execute('alter stable stable_1 add tag t_int_null INT;') + tdSql.execute('alter stable stable_1 add tag t_bigint_null BIGINT;') + tdSql.execute('alter stable stable_1 add tag t_smallint_null SMALLINT;') + tdSql.execute('alter stable stable_1 add tag t_tinyint_null TINYINT;') + tdSql.execute('alter stable stable_1 add tag t_bool_null BOOL;') + tdSql.execute('alter stable stable_1 add tag t_binary_null VARCHAR(100);') + tdSql.execute('alter stable stable_1 add tag t_nchar_null NCHAR(100);') + tdSql.execute('alter stable stable_1 add tag t_float_null FLOAT;') + tdSql.execute('alter stable stable_1 add tag t_double_null DOUBLE;') + tdSql.execute('alter stable stable_1 add tag t_ts_null TIMESTAMP;') + + tdSql.execute('alter stable stable_1 drop column q_nchar8;') + tdSql.execute('alter stable stable_1 drop column q_binary8;') + tdSql.execute('alter stable stable_1 drop column q_nchar7;') + tdSql.execute('alter stable stable_1 drop column q_binary7;') + tdSql.execute('alter stable stable_1 drop column q_nchar6;') + tdSql.execute('alter stable stable_1 drop column q_binary6;') + tdSql.execute('alter stable stable_1 drop column q_nchar5;') + tdSql.execute('alter stable stable_1 drop column q_binary5;') + tdSql.execute('alter stable stable_1 drop column q_nchar4;') + tdSql.execute('alter stable stable_1 drop column q_binary4;') + + def run(self): + tdSql.prepare() + + startTime = time.time() + + # self.create_tables() + # self.insert_data() + + self.dropandcreateDB_random("nested", 1) + self.modify_tables() + + for i in range(2): + self.tag_count_all() + self.tbname_count_all() + self.tbname_agg_all() + + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/explain.py b/tests/system-test/2-query/explain.py index f164d3aedf..92cd28a929 100644 --- a/tests/system-test/2-query/explain.py +++ b/tests/system-test/2-query/explain.py @@ -400,6 +400,9 @@ class TDTestCase: self.explain_check() + # coverage explain.c add + tdSql.query(f"explain verbose true select * from {dbname}.stb1 partition by c1 order by c2") + def __test_error(self, dbname=DBNAME): ratio = random.uniform(0.001,1) diff --git a/tests/system-test/2-query/test_ts4467.py b/tests/system-test/2-query/test_ts4467.py new file mode 100644 index 0000000000..4e09a9fbbe --- /dev/null +++ b/tests/system-test/2-query/test_ts4467.py @@ -0,0 +1,63 @@ +import random +import itertools +from util.log import * +from util.cases import * +from util.sql import * +from util.sqlset import * +from util import constant +from util.common import * + + +class TDTestCase: + """Verify the jira TS-4467 + """ + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + + def prepareData(self): + # db + tdSql.execute("create database if not exists db") + tdSql.execute("use db") + + # table + tdSql.execute("create table t (ts timestamp, c1 varchar(16));") + + # insert data + sql = "insert into t values" + for i in range(6): + sql += f"(now+{str(i+1)}s, '{'name' + str(i+1)}')" + sql += ";" + tdSql.execute(sql) + tdLog.debug("insert data successfully") + + def run(self): + self.prepareData() + + # join query with order by + sql = "select * from t t1, (select * from t order by ts limit 5) t2 where t1.ts = t2.ts;" + tdSql.query(sql) + tdSql.checkRows(5) + + sql = "select * from t t1, (select * from t order by ts desc limit 5) t2 where t1.ts = t2.ts;" + tdSql.query(sql) + tdSql.checkRows(5) + + sql = "select * from t t1, (select * from t order by ts limit 5) t2 where t1.ts = t2.ts order by t1.ts;" + tdSql.query(sql) + res1 = tdSql.queryResult + tdLog.debug("res1: %s" % str(res1)) + + sql = "select * from t t1, (select * from t order by ts limit 5) t2 where t1.ts = t2.ts order by t1.ts desc;" + tdSql.query(sql) + res2 = tdSql.queryResult + tdLog.debug("res2: %s" % str(res2)) + assert(len(res1) == len(res2) and res1[0][0] == res2[4][0]) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/7-tmq/tmq_taosx.py b/tests/system-test/7-tmq/tmq_taosx.py index 5bd70a5d60..ac8a6f377c 100644 --- a/tests/system-test/7-tmq/tmq_taosx.py +++ b/tests/system-test/7-tmq/tmq_taosx.py @@ -311,44 +311,57 @@ class TDTestCase: return - def consumeExcluded(self): - tdSql.execute(f'create topic topic_excluded as database db_taosx') + def consumeTest(self): + tdSql.execute(f'create database if not exists d1 vgroups 1') + tdSql.execute(f'use d1') + tdSql.execute(f'create table st(ts timestamp, i int) tags(t int)') + tdSql.execute(f'insert into t1 using st tags(1) values(now, 1) (now+1s, 2)') + tdSql.execute(f'insert into t2 using st tags(2) values(now, 1) (now+1s, 2)') + tdSql.execute(f'insert into t3 using st tags(3) values(now, 1) (now+1s, 2)') + tdSql.execute(f'insert into t1 using st tags(1) values(now+5s, 11) (now+10s, 12)') + + tdSql.query("select * from st") + tdSql.checkRows(8) + + tdSql.execute(f'create topic topic_excluded with meta as database d1') 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") + index = 0 try: while True: res = consumer.poll(1) if not res: + if index != 1: + tdLog.exit("consume error") break - err = res.error() - if err is not None: - raise err val = res.value() - + if val is None: + continue + cnt = 0; for block in val: - print(block.fetchall()) + cnt += len(block.fetchall()) + if cnt != 8: + tdLog.exit("consume error") + + index += 1 finally: consumer.close() def run(self): + self.consumeTest() + tdSql.prepare() self.checkWal1VgroupOnlyMeta() @@ -362,7 +375,6 @@ class TDTestCase: self.checkSnapshotMultiVgroups() self.checkWalMultiVgroupsWithDropTable() - # self.consumeExcluded() self.checkSnapshotMultiVgroupsWithDropTable()