diff --git a/docs/en/08-client-libraries/50-odbc.mdx b/docs/en/08-client-libraries/50-odbc.mdx index 08b2c031c6..4d9161473a 100644 --- a/docs/en/08-client-libraries/50-odbc.mdx +++ b/docs/en/08-client-libraries/50-odbc.mdx @@ -49,7 +49,7 @@ TDengine ODBC driver supports two kinds of connections to TDengine cluster, nati 4.2 [Connection Type]: required field, we choose "WebSocket" - 4.3 [URL]: required field, the URL for the ODBC data source, for example, `http://localhost:6041` is the URL for a local TDengine cluster, `https://gw.cloud.taosdata.com?token=your_token` is the URL for a TDengine cloud service. + 4.3 [URL]: required field, the URL for the ODBC data source, for example, `http://localhost:6041` is the URL for a local TDengine cluster. 4.4 [Database]: optional field, the default database to access diff --git a/docs/en/10-deployment/02-docker.md b/docs/en/10-deployment/02-docker.md index 2a4511c7b1..2c281ec408 100644 --- a/docs/en/10-deployment/02-docker.md +++ b/docs/en/10-deployment/02-docker.md @@ -128,7 +128,7 @@ If you want to start your application in a container, you need to add the corres FROM ubuntu:20.04 RUN apt-get update && apt-get install -y wget ENV TDENGINE_VERSION=3.0.0.0 -RUN wget -c https://www.taosdata.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ +RUN wget -c https://tdengine.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ && tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ && cd TDengine-client-${TDENGINE_VERSION} \ && ./install_client.sh \ @@ -229,7 +229,7 @@ Here is the full Dockerfile: ```docker FROM golang:1.17.6-buster as builder ENV TDENGINE_VERSION=3.0.0.0 -RUN wget -c https://www.taosdata.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ +RUN wget -c https://tdengine.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ && tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ && cd TDengine-client-${TDENGINE_VERSION} \ && ./install_client.sh \ @@ -245,7 +245,7 @@ RUN go build FROM ubuntu:20.04 RUN apt-get update && apt-get install -y wget ENV TDENGINE_VERSION=3.0.0.0 -RUN wget -c https://www.taosdata.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ +RUN wget -c https://tdengine.com/assets-download/3.0/TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ && tar xvf TDengine-client-${TDENGINE_VERSION}-Linux-x64.tar.gz \ && cd TDengine-client-${TDENGINE_VERSION} \ && ./install_client.sh \ diff --git a/docs/en/10-deployment/03-k8s.md b/docs/en/10-deployment/03-k8s.md index 10c0341598..affb492169 100644 --- a/docs/en/10-deployment/03-k8s.md +++ b/docs/en/10-deployment/03-k8s.md @@ -8,7 +8,7 @@ description: This document describes how to deploy TDengine on Kubernetes. As a time series database for Cloud Native architecture design, TDengine supports Kubernetes deployment. Firstly we introduce how to use YAML files to create a highly available TDengine cluster from scratch step by step for production usage, and highlight the common operations of TDengine in Kubernetes environment. -To meet [high availability ](https://docs.taosdata.com/tdinternal/high-availability/)requirements, clusters need to meet the following requirements: +To meet [high availability](../../tdinternal/high-availability/) requirements, clusters need to meet the following requirements: - 3 or more dnodes: multiple vnodes in the same vgroup of TDengine are not allowed to be distributed in one dnode at the same time, so if you create a database with 3 replicas, the number of dnodes is greater than or equal to 3 - 3 mnodes: mnode is responsible for the management of the entire TDengine cluster. The default number of mnode in TDengine cluster is only one. If the dnode where the mnode located is dropped, the entire cluster is unavailable. diff --git a/docs/en/14-reference/06-taosdump.md b/docs/en/14-reference/06-taosdump.md index 5ec26df1fa..263834dba1 100644 --- a/docs/en/14-reference/06-taosdump.md +++ b/docs/en/14-reference/06-taosdump.md @@ -19,7 +19,7 @@ Users should not use taosdump to back up raw data, environment settings, hardwar There are two ways to install taosdump: -- Install the taosTools official installer. Please find taosTools from [Release History](https://docs.taosdata.com/releases/tools/) page and download and install it. +- Install the taosTools official installer. Please find taosTools from [Release History](../../releases/tools/) page and download and install it. - Compile taos-tools separately and install it. Please refer to the [taos-tools](https://github.com/taosdata/taos-tools) repository for details. diff --git a/docs/en/20-third-party/75-powerbi.md b/docs/en/20-third-party/75-powerbi.md index 4744467f30..03268a5610 100644 --- a/docs/en/20-third-party/75-powerbi.md +++ b/docs/en/20-third-party/75-powerbi.md @@ -19,7 +19,7 @@ With TDengine ODBC driver, PowerBI can access time series data stored in TDengin ## Install Driver -Depending on your TDengine server version, download appropriate version of TDengine client package from TDengine website [Download Link](https://docs.taosdata.com/get-started/package/), or TDengine explorer if you are using a local TDengine cluster. Install the TDengine client package on same Windows machine where PowerBI is running. +Depending on your TDengine server version, download appropriate version of TDengine client package from TDengine website [Download Link](../../get-started/package/), or TDengine explorer if you are using a local TDengine cluster. Install the TDengine client package on same Windows machine where PowerBI is running. ### Configure Data Source @@ -38,7 +38,7 @@ To better use Power BI to analyze the data stored in TDengine, you need to under 1. Dimention: it's normally category (text) data to describe such information as device, collection point, model. In the supertable template of TDengine, we use tag columns to store the dimention information. You can use SQL like `select distinct tbname, tag1, tag2 from supertable` to get dimentions. -2. Metric: quantitive (numeric) fileds that can be calculated, like SUM, AVERAGE, MINIMUM. If the collecting frequency is 1 second, then there are 31,536,000 records in one year, it will be too low efficient to import so big data into Power BI. In TDengine, you can use data partition query, window partition query, in combination with pseudo columns related to window, to import downsampled data into Power BI. For more details, please refer to [TDengine Specialized Queries](https://docs.taosdata.com/taos-sql/distinguished/)。 +2. Metric: quantitive (numeric) fileds that can be calculated, like SUM, AVERAGE, MINIMUM. If the collecting frequency is 1 second, then there are 31,536,000 records in one year, it will be too low efficient to import so big data into Power BI. In TDengine, you can use data partition query, window partition query, in combination with pseudo columns related to window, to import downsampled data into Power BI. For more details, please refer to [TDengine Specialized Queries](../../taos-sql/distinguished/)。 - Window partition query: for example, thermal meters collect one data per second, but you need to query the average temperature every 10 minutes, you can use window subclause to get the downsampling data you need. The corresponding SQL is like `select tbname, _wstart date,avg(temperature) temp from table interval(10m)`, in which _wstart is a pseudo column indicting the start time of a widow, 10m is the duration of the window, `avg(temperature)` indicates the aggregate value inside a window. diff --git a/docs/en/25-application/_03-immigrate.md b/docs/en/25-application/_03-immigrate.md index 4dc7ee711c..af31b31e3c 100644 --- a/docs/en/25-application/_03-immigrate.md +++ b/docs/en/25-application/_03-immigrate.md @@ -184,8 +184,6 @@ TDengine supports the standard JDBC 3.0 interface for manipulating databases, bu To facilitate historical data migration, we provide a plug-in for the data synchronization tool DataX, which can automatically write data into TDengine.The automatic data migration of DataX can only support the data migration process of a single value model. -For the specific usage of DataX and how to use DataX to write data to TDengine, please refer to [DataX-based TDengine Data Migration Tool](https://www.taosdata.com/engineering/16401.html). - After migrating via DataX, we found that we can significantly improve the efficiency of migrating historical data by starting multiple processes and migrating numerous metrics simultaneously. The following are some records of the migration process. We provide these as a reference for application migration. | Number of datax instances (number of concurrent processes) | Migration record speed (pieces/second) | diff --git a/docs/en/28-releases/02-tools.md b/docs/en/28-releases/02-tools.md index f3099b13b4..4def3df638 100644 --- a/docs/en/28-releases/02-tools.md +++ b/docs/en/28-releases/02-tools.md @@ -6,7 +6,7 @@ description: This document provides download links for all released versions of taosTools installation packages can be downloaded at the following links: -For other historical version installers, please visit [here](https://www.taosdata.com/all-downloads). +For other historical version installers, please visit [here](https://tdengine.com/downloads/historical/). import Release from "/components/ReleaseV3"; diff --git a/docs/zh/07-develop/06-stream.md b/docs/zh/07-develop/06-stream.md index 4a5ebb96e8..a6c8b02772 100644 --- a/docs/zh/07-develop/06-stream.md +++ b/docs/zh/07-develop/06-stream.md @@ -8,7 +8,7 @@ title: 流式计算 TDengine 3.0 的流式计算引擎提供了实时处理写入的数据流的能力,使用 SQL 定义实时流变换,当数据被写入流的源表后,数据会被以定义的方式自动处理,并根据定义的触发模式向目的表推送结果。它提供了替代复杂流处理系统的轻量级解决方案,并能够在高吞吐的数据写入的情况下,提供毫秒级的计算结果延迟。 -流式计算可以包含数据过滤,标量函数计算(含UDF),以及窗口聚合(支持滑动窗口、会话窗口与状态窗口),可以以超级表、子表、普通表为源表,写入到目的超级表。在创建流时,目的超级表将被自动创建,随后新插入的数据会被流定义的方式处理并写入其中,通过 partition by 子句,可以以表名或标签划分 partition,不同的 partition 将写入到目的超级表的不同子表。 +流式计算可以包含数据过滤,标量函数计算(含UDF),以及窗口聚合(支持滑动窗口、会话窗口、状态窗口、事件窗口与计数窗口),可以以超级表、子表、普通表为源表,写入到目的超级表。在创建流时,目的超级表将被自动创建,随后新插入的数据会被流定义的方式处理并写入其中,通过 partition by 子句,可以以表名或标签划分 partition,不同的 partition 将写入到目的超级表的不同子表。 TDengine 的流式计算能够支持分布在多个 vnode 中的超级表聚合;还能够处理乱序数据的写入:它提供了 watermark 机制以度量容忍数据乱序的程度,并提供了 ignore expired 配置项以决定乱序数据的处理策略——丢弃或者重新计算。 diff --git a/docs/zh/12-taos-sql/14-stream.md b/docs/zh/12-taos-sql/14-stream.md index 8868b728f8..2ed3c9afae 100644 --- a/docs/zh/12-taos-sql/14-stream.md +++ b/docs/zh/12-taos-sql/14-stream.md @@ -30,7 +30,7 @@ subquery: SELECT select_list [window_clause] ``` -支持会话窗口、状态窗口与滑动窗口,其中,会话窗口与状态窗口搭配超级表时必须与partition by tbname一起使用 +支持会话窗口、状态窗口、滑动窗口、事件窗口和计数窗口,其中,状态窗口、事件窗口和计数窗口搭配超级表时必须与partition by tbname一起使用 stb_name 是保存计算结果的超级表的表名,如果该超级表不存在,会自动创建;如果已存在,则检查列的schema信息。详见 写入已存在的超级表 @@ -60,7 +60,11 @@ COUNT_WINDOW 是计数窗口,按固定的数据行数来划分窗口。 count_va 窗口的定义与时序数据特色查询中的定义完全相同,详见 [TDengine 特色查询](../distinguished) -例如,如下语句创建流式计算,同时自动创建名为 avg_vol 的超级表,此流计算以一分钟为时间窗口、30 秒为前向增量统计这些电表的平均电压,并将来自 meters 表的数据的计算结果写入 avg_vol 表,不同 partition 的数据会分别创建子表并写入不同子表。 +例如,如下语句创建流式计算。第一个流计算,自动创建名为 avg_vol 的超级表,以一分钟为时间窗口、30 秒为前向增量统计这些电表的平均电压,并将来自 meters 表的数据的计算结果写入 avg_vol 表,不同 partition 的数据会分别创建子表并写入不同子表。 + +第二个流计算,自动创建名为 streamt0 的超级表,将数据按时间戳的顺序,以 voltage < 0 作为窗口的开始条件,voltage > 9作为窗口的结束条件,划分窗口做聚合运算,并将来自 meters 表的数据的计算结果写入 streamt0 表,不同 partition 的数据会分别创建子表并写入不同子表。 + +第三个流计算,自动创建名为 streamt1 的超级表,将数据按时间戳的顺序,以10条数据为一组,划分窗口做聚合运算,并将来自 meters 表的数据的计算结果写入 streamt1 表,不同 partition 的数据会分别创建子表并写入不同子表。 ```sql CREATE STREAM avg_vol_s INTO avg_vol AS diff --git a/include/common/systable.h b/include/common/systable.h index f0f8ac8cf6..77fd18da39 100644 --- a/include/common/systable.h +++ b/include/common/systable.h @@ -29,6 +29,7 @@ extern "C" { #define TSDB_INS_TABLE_QNODES "ins_qnodes" #define TSDB_INS_TABLE_BNODES "ins_bnodes" // no longer used #define TSDB_INS_TABLE_SNODES "ins_snodes" +#define TSDB_INS_TABLE_ARBGROUPS "ins_arbgroups" #define TSDB_INS_TABLE_CLUSTER "ins_cluster" #define TSDB_INS_TABLE_DATABASES "ins_databases" #define TSDB_INS_TABLE_FUNCTIONS "ins_functions" diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 93f17fa887..7a7f19c3af 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -76,6 +76,11 @@ extern int32_t tsHeartbeatInterval; extern int32_t tsHeartbeatTimeout; extern int32_t tsSnapReplMaxWaitN; +// arbitrator +extern int32_t tsArbHeartBeatIntervalSec; +extern int32_t tsArbCheckSyncIntervalSec; +extern int32_t tsArbSetAssignedTimeoutSec; + // vnode extern int64_t tsVndCommitMaxIntervalMs; diff --git a/include/common/tgrant.h b/include/common/tgrant.h index ca9e030117..ac0d3155c7 100644 --- a/include/common/tgrant.h +++ b/include/common/tgrant.h @@ -61,9 +61,6 @@ typedef enum { int32_t grantCheck(EGrantType grant); int32_t grantCheckExpire(EGrantType grant); char* tGetMachineId(); -#ifdef TD_UNIQ_GRANT -int32_t grantCheckLE(EGrantType grant); -#endif // #ifndef GRANTS_CFG #ifdef TD_ENTERPRISE @@ -76,7 +73,7 @@ int32_t grantCheckLE(EGrantType grant); {.name = "state", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ {.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ {.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ - {.name = "cpu_cores", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ + {.name = "cpu_cores", .bytes = 13 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ } #else #define GRANTS_SCHEMA \ @@ -88,7 +85,7 @@ int32_t grantCheckLE(EGrantType grant); {.name = "state", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ {.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ {.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ - {.name = "cpu_cores", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ + {.name = "cpu_cores", .bytes = 13 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, \ } #endif // #define GRANT_CFG_ADD diff --git a/include/common/tmsg.h b/include/common/tmsg.h index d4c054af9d..1be5abbf76 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -150,6 +150,7 @@ typedef enum _mgmt_table { TSDB_MGMT_TABLE_GRANTS_FULL, TSDB_MGMT_TABLE_GRANTS_LOGS, TSDB_MGMT_TABLE_MACHINES, + TSDB_MGMT_TABLE_ARBGROUP, TSDB_MGMT_TABLE_MAX, } EShowType; @@ -336,6 +337,7 @@ typedef enum ENodeType { QUERY_NODE_SHOW_QNODES_STMT, QUERY_NODE_SHOW_SNODES_STMT, QUERY_NODE_SHOW_BNODES_STMT, + QUERY_NODE_SHOW_ARBGROUPS_STMT, QUERY_NODE_SHOW_CLUSTER_STMT, QUERY_NODE_SHOW_DATABASES_STMT, QUERY_NODE_SHOW_FUNCTIONS_STMT, @@ -1154,6 +1156,7 @@ typedef struct { int32_t tsdbPageSize; int32_t sqlLen; char* sql; + int8_t withArbitrator; } SCreateDbReq; int32_t tSerializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq); @@ -1182,6 +1185,7 @@ typedef struct { int32_t walRetentionSize; int32_t sqlLen; char* sql; + int8_t withArbitrator; } SAlterDbReq; int32_t tSerializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq); @@ -1304,6 +1308,7 @@ typedef struct { SArray* pRetensions; int8_t schemaless; int16_t sstTrigger; + int8_t withArbitrator; } SDbCfgRsp; typedef SDbCfgRsp SDbCfgInfo; @@ -2147,6 +2152,99 @@ typedef struct { int32_t tSerializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq); int32_t tDeserializeSDCreateMnodeReq(void* buf, int32_t bufLen, SDCreateMnodeReq* pReq); +typedef struct { + int32_t vgId; + int32_t hbSeq; +} SVArbHbReqMember; + +typedef struct { + int32_t dnodeId; + char* arbToken; + int64_t arbTerm; + SArray* hbMembers; // SVArbHbReqMember +} SVArbHeartBeatReq; + +int32_t tSerializeSVArbHeartBeatReq(void* buf, int32_t bufLen, SVArbHeartBeatReq* pReq); +int32_t tDeserializeSVArbHeartBeatReq(void* buf, int32_t bufLen, SVArbHeartBeatReq* pReq); +void tFreeSVArbHeartBeatReq(SVArbHeartBeatReq* pReq); + +typedef struct { + int32_t vgId; + char memberToken[TSDB_ARB_TOKEN_SIZE]; + int32_t hbSeq; +} SVArbHbRspMember; + +typedef struct { + char arbToken[TSDB_ARB_TOKEN_SIZE]; + int32_t dnodeId; + SArray* hbMembers; // SVArbHbRspMember +} SVArbHeartBeatRsp; + +int32_t tSerializeSVArbHeartBeatRsp(void* buf, int32_t bufLen, SVArbHeartBeatRsp* pRsp); +int32_t tDeserializeSVArbHeartBeatRsp(void* buf, int32_t bufLen, SVArbHeartBeatRsp* pRsp); +void tFreeSVArbHeartBeatRsp(SVArbHeartBeatRsp* pRsp); + +typedef struct { + char* arbToken; + int64_t arbTerm; + char* member0Token; + char* member1Token; +} SVArbCheckSyncReq; + +int32_t tSerializeSVArbCheckSyncReq(void* buf, int32_t bufLen, SVArbCheckSyncReq* pReq); +int32_t tDeserializeSVArbCheckSyncReq(void* buf, int32_t bufLen, SVArbCheckSyncReq* pReq); +void tFreeSVArbCheckSyncReq(SVArbCheckSyncReq* pRsp); + +typedef struct { + char* arbToken; + char* member0Token; + char* member1Token; + int32_t vgId; + int32_t errCode; +} SVArbCheckSyncRsp; + +int32_t tSerializeSVArbCheckSyncRsp(void* buf, int32_t bufLen, SVArbCheckSyncRsp* pRsp); +int32_t tDeserializeSVArbCheckSyncRsp(void* buf, int32_t bufLen, SVArbCheckSyncRsp* pRsp); +void tFreeSVArbCheckSyncRsp(SVArbCheckSyncRsp* pRsp); + +typedef struct { + char* arbToken; + int64_t arbTerm; + char* memberToken; +} SVArbSetAssignedLeaderReq; + +int32_t tSerializeSVArbSetAssignedLeaderReq(void* buf, int32_t bufLen, SVArbSetAssignedLeaderReq* pReq); +int32_t tDeserializeSVArbSetAssignedLeaderReq(void* buf, int32_t bufLen, SVArbSetAssignedLeaderReq* pReq); +void tFreeSVArbSetAssignedLeaderReq(SVArbSetAssignedLeaderReq* pReq); + +typedef struct { + char* arbToken; + char* memberToken; + int32_t vgId; +} SVArbSetAssignedLeaderRsp; + +int32_t tSerializeSVArbSetAssignedLeaderRsp(void* buf, int32_t bufLen, SVArbSetAssignedLeaderRsp* pRsp); +int32_t tDeserializeSVArbSetAssignedLeaderRsp(void* buf, int32_t bufLen, SVArbSetAssignedLeaderRsp* pRsp); +void tFreeSVArbSetAssignedLeaderRsp(SVArbSetAssignedLeaderRsp* pRsp); + +typedef struct { + int32_t dnodeId; + char* token; +} SMArbUpdateGroupReqMember; + +typedef struct { + int32_t vgId; + int64_t dbUid; + SMArbUpdateGroupReqMember members[2]; + int8_t isSync; + SMArbUpdateGroupReqMember assignedLeader; + int64_t version; +} SMArbUpdateGroupReq; + +int32_t tSerializeSMArbUpdateGroupReq(void* buf, int32_t bufLen, SMArbUpdateGroupReq* pReq); +int32_t tDeserializeSMArbUpdateGroupReq(void* buf, int32_t bufLen, SMArbUpdateGroupReq* pReq); +void tFreeSMArbUpdateGroupReq(SMArbUpdateGroupReq* pReq); + typedef struct { char queryStrId[TSDB_QUERY_ID_LEN]; } SKillQueryReq; @@ -2824,8 +2922,10 @@ typedef struct { char* tagName; int8_t isNull; int8_t tagType; + int8_t tagFree; uint32_t nTagVal; uint8_t* pTagVal; + SArray* pTagArray; // TSDB_ALTER_TABLE_UPDATE_OPTIONS int8_t updateTTL; int32_t newTTL; @@ -3923,11 +4023,11 @@ int32_t tSerializeSMqAskEpReq(void* buf, int32_t bufLen, SMqAskEpReq* pReq); int32_t tDeserializeSMqAskEpReq(void* buf, int32_t bufLen, SMqAskEpReq* pReq); int32_t tSerializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq); int32_t tDeserializeSMqHbReq(void* buf, int32_t bufLen, SMqHbReq* pReq); -int32_t tDeatroySMqHbReq(SMqHbReq* pReq); +void tDestroySMqHbReq(SMqHbReq* pReq); int32_t tSerializeSMqHbRsp(void* buf, int32_t bufLen, SMqHbRsp* pRsp); int32_t tDeserializeSMqHbRsp(void* buf, int32_t bufLen, SMqHbRsp* pRsp); -int32_t tDeatroySMqHbRsp(SMqHbRsp* pRsp); +void tDestroySMqHbRsp(SMqHbRsp* pRsp); int32_t tSerializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq); int32_t tDeserializeSMqSeekReq(void* buf, int32_t bufLen, SMqSeekReq* pReq); diff --git a/include/common/tmsgcb.h b/include/common/tmsgcb.h index dd1e54318e..03bf8da707 100644 --- a/include/common/tmsgcb.h +++ b/include/common/tmsgcb.h @@ -36,9 +36,11 @@ typedef enum { SYNC_QUEUE, SYNC_RD_QUEUE, STREAM_QUEUE, + ARB_QUEUE, QUEUE_MAX, } EQueueType; +typedef void (*GetDnodeEp)(void* pData, int32_t dnodeId, char* pEp, char* pFqdn, uint16_t* pPort); typedef bool (*UpdateDnodeInfoFp)(void* pData, int32_t* dnodeId, int64_t* clusterId, char* fqdn, uint16_t* port); typedef int32_t (*PutToQueueFp)(void* pMgmt, EQueueType qtype, SRpcMsg* pMsg); typedef int32_t (*GetQueueSizeFp)(void* pMgmt, int32_t vgId, EQueueType qtype); @@ -64,6 +66,7 @@ typedef struct { ReleaseHandleFp releaseHandleFp; ReportStartup reportStartupFp; UpdateDnodeInfoFp updateDnodeInfoFp; + GetDnodeEp getDnodeEpFp; } SMsgCb; void tmsgSetDefault(const SMsgCb* msgcb); diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index 62392a9caa..532a54e9f1 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -272,6 +272,8 @@ TD_DEF_MSG_TYPE(TDMT_VND_DISABLE_WRITE, "vnode-disable-write", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_QUERY_COMPACT_PROGRESS, "vnode-query-compact-progress", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_KILL_COMPACT, "kill-compact", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_VND_ARB_HEARTBEAT, "vnode-arb-hb", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_VND_ARB_CHECK_SYNC, "vnode-arb-check-sync", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_MAX_MSG, "vnd-max", NULL, NULL) TD_CLOSE_MSG_SEG(TDMT_END_VND_MSG) @@ -341,6 +343,7 @@ TD_DEF_MSG_TYPE(TDMT_SYNC_PREP_SNAPSHOT_REPLY, "sync-prep-snapshot-reply", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_UNUSED_CODE, "sync-unused", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_FORCE_FOLLOWER, "sync-force-become-follower", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_SYNC_SET_ASSIGNED_LEADER, "sync-set-assigned-leader", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_MAX_MSG, "sync-max", NULL, NULL) TD_CLOSE_MSG_SEG(TDMT_END_SYNC_MSG) @@ -367,6 +370,13 @@ TD_DEF_MSG_TYPE(TDMT_VND_TMQ_MAX_MSG, "vnd-tmq-max", NULL, NULL) TD_CLOSE_MSG_SEG(TDMT_END_TMQ_MSG) + TD_NEW_MSG_SEG(TDMT_MND_ARB_MSG) //9 << 8 + TD_DEF_MSG_TYPE(TDMT_MND_ARB_HEARTBEAT_TIMER, "mnd-arb-hb-tmr", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_ARB_CHECK_SYNC_TIMER, "mnd-arb-check-sync-tmr", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_ARB_UPDATE_GROUP, "mnd-arb-update-group", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_ARB_MAX_MSG, "mnd-arb-max", NULL, NULL) + TD_CLOSE_MSG_SEG(TDMT_END_ARB_MSG) + TD_NEW_MSG_SEG(TDMT_MAX_MSG) // msg end mark TD_CLOSE_MSG_SEG(TDMT_END_MAX_MSG) diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 404a6fd81b..145afa232b 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -170,212 +170,215 @@ #define TK_STABLES 151 #define TK_MNODES 152 #define TK_QNODES 153 -#define TK_FUNCTIONS 154 -#define TK_INDEXES 155 -#define TK_ACCOUNTS 156 -#define TK_APPS 157 -#define TK_CONNECTIONS 158 -#define TK_LICENCES 159 -#define TK_GRANTS 160 -#define TK_FULL 161 -#define TK_LOGS 162 -#define TK_MACHINES 163 -#define TK_QUERIES 164 -#define TK_SCORES 165 -#define TK_TOPICS 166 -#define TK_VARIABLES 167 -#define TK_BNODES 168 -#define TK_SNODES 169 -#define TK_TRANSACTIONS 170 -#define TK_DISTRIBUTED 171 -#define TK_CONSUMERS 172 -#define TK_SUBSCRIPTIONS 173 -#define TK_VNODES 174 -#define TK_ALIVE 175 -#define TK_VIEWS 176 -#define TK_VIEW 177 -#define TK_COMPACTS 178 -#define TK_NORMAL 179 -#define TK_CHILD 180 -#define TK_LIKE 181 -#define TK_TBNAME 182 -#define TK_QTAGS 183 -#define TK_AS 184 -#define TK_SYSTEM 185 -#define TK_INDEX 186 -#define TK_FUNCTION 187 -#define TK_INTERVAL 188 -#define TK_COUNT 189 -#define TK_LAST_ROW 190 -#define TK_META 191 -#define TK_ONLY 192 -#define TK_TOPIC 193 -#define TK_CONSUMER 194 -#define TK_GROUP 195 -#define TK_DESC 196 -#define TK_DESCRIBE 197 -#define TK_RESET 198 -#define TK_QUERY 199 -#define TK_CACHE 200 -#define TK_EXPLAIN 201 -#define TK_ANALYZE 202 -#define TK_VERBOSE 203 -#define TK_NK_BOOL 204 -#define TK_RATIO 205 -#define TK_NK_FLOAT 206 -#define TK_OUTPUTTYPE 207 -#define TK_AGGREGATE 208 -#define TK_BUFSIZE 209 -#define TK_LANGUAGE 210 -#define TK_REPLACE 211 -#define TK_STREAM 212 -#define TK_INTO 213 -#define TK_PAUSE 214 -#define TK_RESUME 215 -#define TK_TRIGGER 216 -#define TK_AT_ONCE 217 -#define TK_WINDOW_CLOSE 218 -#define TK_IGNORE 219 -#define TK_EXPIRED 220 -#define TK_FILL_HISTORY 221 -#define TK_UPDATE 222 -#define TK_SUBTABLE 223 -#define TK_UNTREATED 224 -#define TK_KILL 225 -#define TK_CONNECTION 226 -#define TK_TRANSACTION 227 -#define TK_BALANCE 228 -#define TK_VGROUP 229 -#define TK_LEADER 230 -#define TK_MERGE 231 -#define TK_REDISTRIBUTE 232 -#define TK_SPLIT 233 -#define TK_DELETE 234 -#define TK_INSERT 235 -#define TK_NULL 236 -#define TK_NK_QUESTION 237 -#define TK_NK_ALIAS 238 -#define TK_NK_ARROW 239 -#define TK_ROWTS 240 -#define TK_QSTART 241 -#define TK_QEND 242 -#define TK_QDURATION 243 -#define TK_WSTART 244 -#define TK_WEND 245 -#define TK_WDURATION 246 -#define TK_IROWTS 247 -#define TK_ISFILLED 248 -#define TK_CAST 249 -#define TK_NOW 250 -#define TK_TODAY 251 -#define TK_TIMEZONE 252 -#define TK_CLIENT_VERSION 253 -#define TK_SERVER_VERSION 254 -#define TK_SERVER_STATUS 255 -#define TK_CURRENT_USER 256 -#define TK_CASE 257 -#define TK_WHEN 258 -#define TK_THEN 259 -#define TK_ELSE 260 -#define TK_BETWEEN 261 -#define TK_IS 262 -#define TK_NK_LT 263 -#define TK_NK_GT 264 -#define TK_NK_LE 265 -#define TK_NK_GE 266 -#define TK_NK_NE 267 -#define TK_MATCH 268 -#define TK_NMATCH 269 -#define TK_CONTAINS 270 -#define TK_IN 271 -#define TK_JOIN 272 -#define TK_INNER 273 -#define TK_SELECT 274 -#define TK_NK_HINT 275 -#define TK_DISTINCT 276 -#define TK_WHERE 277 -#define TK_PARTITION 278 -#define TK_BY 279 -#define TK_SESSION 280 -#define TK_STATE_WINDOW 281 -#define TK_EVENT_WINDOW 282 -#define TK_COUNT_WINDOW 283 -#define TK_SLIDING 284 -#define TK_FILL 285 -#define TK_VALUE 286 -#define TK_VALUE_F 287 -#define TK_NONE 288 -#define TK_PREV 289 -#define TK_NULL_F 290 -#define TK_LINEAR 291 -#define TK_NEXT 292 -#define TK_HAVING 293 -#define TK_RANGE 294 -#define TK_EVERY 295 -#define TK_ORDER 296 -#define TK_SLIMIT 297 -#define TK_SOFFSET 298 -#define TK_LIMIT 299 -#define TK_OFFSET 300 -#define TK_ASC 301 -#define TK_NULLS 302 -#define TK_ABORT 303 -#define TK_AFTER 304 -#define TK_ATTACH 305 -#define TK_BEFORE 306 -#define TK_BEGIN 307 -#define TK_BITAND 308 -#define TK_BITNOT 309 -#define TK_BITOR 310 -#define TK_BLOCKS 311 -#define TK_CHANGE 312 -#define TK_COMMA 313 -#define TK_CONCAT 314 -#define TK_CONFLICT 315 -#define TK_COPY 316 -#define TK_DEFERRED 317 -#define TK_DELIMITERS 318 -#define TK_DETACH 319 -#define TK_DIVIDE 320 -#define TK_DOT 321 -#define TK_EACH 322 -#define TK_FAIL 323 -#define TK_FILE 324 -#define TK_FOR 325 -#define TK_GLOB 326 -#define TK_ID 327 -#define TK_IMMEDIATE 328 -#define TK_IMPORT 329 -#define TK_INITIALLY 330 -#define TK_INSTEAD 331 -#define TK_ISNULL 332 -#define TK_MODULES 333 -#define TK_NK_BITNOT 334 -#define TK_NK_SEMI 335 -#define TK_NOTNULL 336 -#define TK_OF 337 -#define TK_PLUS 338 -#define TK_PRIVILEGE 339 -#define TK_RAISE 340 -#define TK_RESTRICT 341 -#define TK_ROW 342 -#define TK_SEMI 343 -#define TK_STAR 344 -#define TK_STATEMENT 345 -#define TK_STRICT 346 -#define TK_STRING 347 -#define TK_TIMES 348 -#define TK_VALUES 349 -#define TK_VARIABLE 350 -#define TK_WAL 351 +#define TK_ARBGROUPS 154 +#define TK_FUNCTIONS 155 +#define TK_INDEXES 156 +#define TK_ACCOUNTS 157 +#define TK_APPS 158 +#define TK_CONNECTIONS 159 +#define TK_LICENCES 160 +#define TK_GRANTS 161 +#define TK_FULL 162 +#define TK_LOGS 163 +#define TK_MACHINES 164 +#define TK_QUERIES 165 +#define TK_SCORES 166 +#define TK_TOPICS 167 +#define TK_VARIABLES 168 +#define TK_BNODES 169 +#define TK_SNODES 170 +#define TK_TRANSACTIONS 171 +#define TK_DISTRIBUTED 172 +#define TK_CONSUMERS 173 +#define TK_SUBSCRIPTIONS 174 +#define TK_VNODES 175 +#define TK_ALIVE 176 +#define TK_VIEWS 177 +#define TK_VIEW 178 +#define TK_COMPACTS 179 +#define TK_NORMAL 180 +#define TK_CHILD 181 +#define TK_LIKE 182 +#define TK_TBNAME 183 +#define TK_QTAGS 184 +#define TK_AS 185 +#define TK_SYSTEM 186 +#define TK_INDEX 187 +#define TK_FUNCTION 188 +#define TK_INTERVAL 189 +#define TK_COUNT 190 +#define TK_LAST_ROW 191 +#define TK_META 192 +#define TK_ONLY 193 +#define TK_TOPIC 194 +#define TK_CONSUMER 195 +#define TK_GROUP 196 +#define TK_DESC 197 +#define TK_DESCRIBE 198 +#define TK_RESET 199 +#define TK_QUERY 200 +#define TK_CACHE 201 +#define TK_EXPLAIN 202 +#define TK_ANALYZE 203 +#define TK_VERBOSE 204 +#define TK_NK_BOOL 205 +#define TK_RATIO 206 +#define TK_NK_FLOAT 207 +#define TK_OUTPUTTYPE 208 +#define TK_AGGREGATE 209 +#define TK_BUFSIZE 210 +#define TK_LANGUAGE 211 +#define TK_REPLACE 212 +#define TK_STREAM 213 +#define TK_INTO 214 +#define TK_PAUSE 215 +#define TK_RESUME 216 +#define TK_TRIGGER 217 +#define TK_AT_ONCE 218 +#define TK_WINDOW_CLOSE 219 +#define TK_IGNORE 220 +#define TK_EXPIRED 221 +#define TK_FILL_HISTORY 222 +#define TK_UPDATE 223 +#define TK_SUBTABLE 224 +#define TK_UNTREATED 225 +#define TK_KILL 226 +#define TK_CONNECTION 227 +#define TK_TRANSACTION 228 +#define TK_BALANCE 229 +#define TK_VGROUP 230 +#define TK_LEADER 231 +#define TK_MERGE 232 +#define TK_REDISTRIBUTE 233 +#define TK_SPLIT 234 +#define TK_DELETE 235 +#define TK_INSERT 236 +#define TK_NK_BIN 237 +#define TK_NK_HEX 238 +#define TK_NULL 239 +#define TK_NK_QUESTION 240 +#define TK_NK_ALIAS 241 +#define TK_NK_ARROW 242 +#define TK_ROWTS 243 +#define TK_QSTART 244 +#define TK_QEND 245 +#define TK_QDURATION 246 +#define TK_WSTART 247 +#define TK_WEND 248 +#define TK_WDURATION 249 +#define TK_IROWTS 250 +#define TK_ISFILLED 251 +#define TK_CAST 252 +#define TK_NOW 253 +#define TK_TODAY 254 +#define TK_TIMEZONE 255 +#define TK_CLIENT_VERSION 256 +#define TK_SERVER_VERSION 257 +#define TK_SERVER_STATUS 258 +#define TK_CURRENT_USER 259 +#define TK_CASE 260 +#define TK_WHEN 261 +#define TK_THEN 262 +#define TK_ELSE 263 +#define TK_BETWEEN 264 +#define TK_IS 265 +#define TK_NK_LT 266 +#define TK_NK_GT 267 +#define TK_NK_LE 268 +#define TK_NK_GE 269 +#define TK_NK_NE 270 +#define TK_MATCH 271 +#define TK_NMATCH 272 +#define TK_CONTAINS 273 +#define TK_IN 274 +#define TK_JOIN 275 +#define TK_INNER 276 +#define TK_SELECT 277 +#define TK_NK_HINT 278 +#define TK_DISTINCT 279 +#define TK_WHERE 280 +#define TK_PARTITION 281 +#define TK_BY 282 +#define TK_SESSION 283 +#define TK_STATE_WINDOW 284 +#define TK_EVENT_WINDOW 285 +#define TK_COUNT_WINDOW 286 +#define TK_SLIDING 287 +#define TK_FILL 288 +#define TK_VALUE 289 +#define TK_VALUE_F 290 +#define TK_NONE 291 +#define TK_PREV 292 +#define TK_NULL_F 293 +#define TK_LINEAR 294 +#define TK_NEXT 295 +#define TK_HAVING 296 +#define TK_RANGE 297 +#define TK_EVERY 298 +#define TK_ORDER 299 +#define TK_SLIMIT 300 +#define TK_SOFFSET 301 +#define TK_LIMIT 302 +#define TK_OFFSET 303 +#define TK_ASC 304 +#define TK_NULLS 305 +#define TK_ABORT 306 +#define TK_AFTER 307 +#define TK_ATTACH 308 +#define TK_BEFORE 309 +#define TK_BEGIN 310 +#define TK_BITAND 311 +#define TK_BITNOT 312 +#define TK_BITOR 313 +#define TK_BLOCKS 314 +#define TK_CHANGE 315 +#define TK_COMMA 316 +#define TK_CONCAT 317 +#define TK_CONFLICT 318 +#define TK_COPY 319 +#define TK_DEFERRED 320 +#define TK_DELIMITERS 321 +#define TK_DETACH 322 +#define TK_DIVIDE 323 +#define TK_DOT 324 +#define TK_EACH 325 +#define TK_FAIL 326 +#define TK_FILE 327 +#define TK_FOR 328 +#define TK_GLOB 329 +#define TK_ID 330 +#define TK_IMMEDIATE 331 +#define TK_IMPORT 332 +#define TK_INITIALLY 333 +#define TK_INSTEAD 334 +#define TK_ISNULL 335 +#define TK_MODULES 336 +#define TK_NK_BITNOT 337 +#define TK_NK_SEMI 338 +#define TK_NOTNULL 339 +#define TK_OF 340 +#define TK_PLUS 341 +#define TK_PRIVILEGE 342 +#define TK_RAISE 343 +#define TK_RESTRICT 344 +#define TK_ROW 345 +#define TK_SEMI 346 +#define TK_STAR 347 +#define TK_STATEMENT 348 +#define TK_STRICT 349 +#define TK_STRING 350 +#define TK_TIMES 351 +#define TK_VALUES 352 +#define TK_VARIABLE 353 +#define TK_WAL 354 #define TK_NK_SPACE 600 #define TK_NK_COMMENT 601 #define TK_NK_ILLEGAL 602 -#define TK_NK_HEX 603 // hex number 0x123 +// #define TK_NK_HEX 603 // hex number 0x123 #define TK_NK_OCT 604 // oct number -#define TK_NK_BIN 605 // bin format data 0b111 +// #define TK_NK_BIN 605 // bin format data 0b111 #define TK_BATCH_SCAN 606 #define TK_NO_BATCH_SCAN 607 #define TK_SORT_FOR_GROUP 608 diff --git a/include/common/tvariant.h b/include/common/tvariant.h index 66b7302f4e..6f88eba027 100644 --- a/include/common/tvariant.h +++ b/include/common/tvariant.h @@ -44,6 +44,11 @@ int32_t toDoubleEx(const char *z, int32_t n, uint32_t type, double *value); int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value); int32_t toUInteger(const char *z, int32_t n, int32_t base, uint64_t *value); +/** + * non floating point integers +*/ +int32_t toIntegerPure(const char *z, int32_t n, int32_t base, int64_t *value); + void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32_t type); void taosVariantDestroy(SVariant *pV); diff --git a/include/dnode/mnode/mnode.h b/include/dnode/mnode/mnode.h index 6c3c7497b1..108e6f18a6 100644 --- a/include/dnode/mnode/mnode.h +++ b/include/dnode/mnode/mnode.h @@ -75,6 +75,9 @@ void mndStop(SMnode *pMnode); int32_t mndIsCatchUp(SMnode *pMnode); ESyncRole mndGetRole(SMnode *pMnode); +int64_t mndGetTerm(SMnode *pMnode); + +int32_t mndGetArbToken(SMnode *pMnode, char *outToken); /** * @brief Get mnode monitor info. diff --git a/include/libs/executor/storageapi.h b/include/libs/executor/storageapi.h index 3433f98d38..b47a162a1a 100644 --- a/include/libs/executor/storageapi.h +++ b/include/libs/executor/storageapi.h @@ -36,6 +36,7 @@ extern "C" { #define CACHESCAN_RETRIEVE_LAST_ROW 0x4 #define CACHESCAN_RETRIEVE_LAST 0x8 +#define META_READER_LOCK 0x0 #define META_READER_NOLOCK 0x1 #define STREAM_STATE_BUFF_HASH 1 @@ -237,12 +238,12 @@ typedef struct SStoreSnapshotFn { } SStoreSnapshotFn; typedef struct SStoreMeta { - SMTbCursor* (*openTableMetaCursor)(void* pVnode); // metaOpenTbCursor - void (*closeTableMetaCursor)(SMTbCursor* pTbCur); // metaCloseTbCursor - void (*pauseTableMetaCursor)(SMTbCursor* pTbCur); // metaPauseTbCursor - void (*resumeTableMetaCursor)(SMTbCursor* pTbCur, int8_t first); // metaResumeTbCursor - int32_t (*cursorNext)(SMTbCursor* pTbCur, ETableType jumpTableType); // metaTbCursorNext - int32_t (*cursorPrev)(SMTbCursor* pTbCur, ETableType jumpTableType); // metaTbCursorPrev + SMTbCursor* (*openTableMetaCursor)(void* pVnode); // metaOpenTbCursor + void (*closeTableMetaCursor)(SMTbCursor* pTbCur); // metaCloseTbCursor + void (*pauseTableMetaCursor)(SMTbCursor* pTbCur); // metaPauseTbCursor + void (*resumeTableMetaCursor)(SMTbCursor* pTbCur, int8_t first, int8_t move); // metaResumeTbCursor + int32_t (*cursorNext)(SMTbCursor* pTbCur, ETableType jumpTableType); // metaTbCursorNext + int32_t (*cursorPrev)(SMTbCursor* pTbCur, ETableType jumpTableType); // metaTbCursorPrev int32_t (*getTableTags)(void* pVnode, uint64_t suid, SArray* uidList); int32_t (*getTableTagsByUid)(void* pVnode, int64_t suid, SArray* uidList); diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index b7c6a1902c..15522110b5 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -100,6 +100,7 @@ typedef struct SDatabaseOptions { int32_t sstTrigger; int32_t tablePrefix; int32_t tableSuffix; + int8_t withArbitrator; } SDatabaseOptions; typedef struct SCreateDatabaseStmt { diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index cb053d2548..0be03b82f3 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -80,6 +80,7 @@ typedef enum { TAOS_SYNC_STATE_LEADER = 102, TAOS_SYNC_STATE_ERROR = 103, TAOS_SYNC_STATE_LEARNER = 104, + TAOS_SYNC_STATE_ASSIGNED_LEADER = 105, } ESyncState; typedef enum { @@ -184,6 +185,7 @@ typedef struct SSyncFSM { void (*FpBecomeLeaderCb)(const struct SSyncFSM* pFsm); void (*FpBecomeFollowerCb)(const struct SSyncFSM* pFsm); void (*FpBecomeLearnerCb)(const struct SSyncFSM* pFsm); + void (*FpBecomeAssignedLeaderCb)(const struct SSyncFSM* pFsm); int32_t (*FpGetSnapshot)(const struct SSyncFSM* pFsm, SSnapshot* pSnapshot, void* pReaderParam, void** ppReader); int32_t (*FpGetSnapshotInfo)(const struct SSyncFSM* pFsm, SSnapshot* pSnapshot); @@ -273,6 +275,7 @@ int32_t syncPropose(int64_t rid, SRpcMsg* pMsg, bool isWeak, int64_t* seq); int32_t syncCheckMember(int64_t rid); int32_t syncIsCatchUp(int64_t rid); ESyncRole syncGetRole(int64_t rid); +int64_t syncGetTerm(int64_t rid); int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg); int32_t syncReconfig(int64_t rid, SSyncCfg* pCfg); int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex); @@ -284,8 +287,13 @@ bool syncSnapshotSending(int64_t rid); bool syncSnapshotRecving(int64_t rid); int32_t syncSendTimeoutRsp(int64_t rid, int64_t seq); int32_t syncForceBecomeFollower(SSyncNode* ths, const SRpcMsg* pRpcMsg); +int32_t syncBecomeAssignedLeader(SSyncNode* ths, SRpcMsg* pRpcMsg); + +int32_t syncUpdateArbTerm(int64_t rid, SyncTerm arbTerm); SSyncState syncGetState(int64_t rid); +int32_t syncGetArbToken(int64_t rid, char* outToken); +int32_t syncGetAssignedLogSynced(int64_t rid); void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet); const char* syncStr(ESyncState state); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index b2ebd34255..ba66cfb06a 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -323,6 +323,9 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_BNODE_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03A7) #define TSDB_CODE_MND_TOO_FEW_MNODES TAOS_DEF_ERROR_CODE(0, 0x03A8) #define TSDB_CODE_MND_TOO_MANY_MNODES TAOS_DEF_ERROR_CODE(0, 0x03A9) +#define TSDB_CODE_MND_ARBGROUP_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AA) +#define TSDB_CODE_MND_ARBGROUP_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x03AB) +#define TSDB_CODE_MND_ARB_TOKEN_MISMATCH TAOS_DEF_ERROR_CODE(0, 0x03AC) // mnode-dnode-part2 #define TSDB_CODE_MND_TOO_MANY_DNODES TAOS_DEF_ERROR_CODE(0, 0x03B0) @@ -472,6 +475,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_VND_ALREADY_IS_VOTER TAOS_DEF_ERROR_CODE(0, 0x0533) // internal #define TSDB_CODE_VND_DIR_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0534) #define TSDB_CODE_VND_META_DATA_UNSAFE_DELETE TAOS_DEF_ERROR_CODE(0, 0x0535) +#define TSDB_CODE_VND_ARB_NOT_SYNCED TAOS_DEF_ERROR_CODE(0, 0x0536) // internal // tsdb #define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600) diff --git a/include/util/tdef.h b/include/util/tdef.h index e2d1beb5a5..fe24e4e6f6 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -279,6 +279,9 @@ typedef enum ELogicConditionType { #define TSDB_SHOW_SUBQUERY_LEN 1000 #define TSDB_LOG_VAR_LEN 32 +#define TSDB_ARB_GROUP_MEMBER_NUM 2 +#define TSDB_ARB_TOKEN_SIZE 32 + #define TSDB_TRANS_STAGE_LEN 12 #define TSDB_TRANS_TYPE_LEN 16 #define TSDB_TRANS_ERROR_LEN 512 @@ -425,6 +428,10 @@ typedef enum ELogicConditionType { #define TSDB_DB_MIN_WAL_SEGMENT_SIZE 0 #define TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE 0 +#define TSDB_DEFAULT_DB_WITH_ARBITRATOR 0 +#define TSDB_MIN_DB_WITH_ARBITRATOR 0 +#define TSDB_MAX_DB_WITH_ARBITRATOR 1 + #define TSDB_MIN_ROLLUP_MAX_DELAY 1 // unit millisecond #define TSDB_MAX_ROLLUP_MAX_DELAY (15 * 60 * 1000) #define TSDB_MIN_ROLLUP_WATERMARK 0 // unit millisecond @@ -523,12 +530,12 @@ enum { SND_WORKER_TYPE__UNIQUE, }; -#define DEFAULT_HANDLE 0 -#define MNODE_HANDLE 1 -#define QNODE_HANDLE -1 -#define SNODE_HANDLE -2 -#define VNODE_HANDLE -3 -#define CLIENT_HANDLE -5 +#define DEFAULT_HANDLE 0 +#define MNODE_HANDLE 1 +#define QNODE_HANDLE -1 +#define SNODE_HANDLE -2 +#define VNODE_HANDLE -3 +#define CLIENT_HANDLE -5 #define TSDB_CONFIG_OPTION_LEN 32 #define TSDB_CONFIG_VALUE_LEN 64 @@ -548,8 +555,8 @@ enum { // sort page size by default #define DEFAULT_PAGESIZE 4096 -#define VNODE_TIMEOUT_SEC 60 -#define MNODE_TIMEOUT_SEC 60 +#define VNODE_TIMEOUT_SEC 60 +#define MNODE_TIMEOUT_SEC 60 #define MONITOR_TABLENAME_LEN 200 #define MONITOR_TAG_NAME_LEN 100 diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index fb1882e472..c8fc556150 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -779,7 +779,7 @@ int32_t tmqHbCb(void* param, SDataBuf* pMsg, int32_t code) { taosWUnLockLatch(&tmq->lock); taosReleaseRef(tmqMgmt.rsetId, refId); } - tDeatroySMqHbRsp(&rsp); + tDestroySMqHbRsp(&rsp); taosMemoryFree(pMsg->pData); taosMemoryFree(pMsg->pEpSet); } @@ -861,7 +861,7 @@ void tmqSendHbReq(void* param, void* tmrId) { asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); OVER: - tDeatroySMqHbReq(&req); + tDestroySMqHbReq(&req); taosTmrReset(tmqSendHbReq, DEFAULT_HEARTBEAT_INTERVAL, param, tmqMgmt.timer, &tmq->hbLiveTimer); taosReleaseRef(tmqMgmt.rsetId, refId); } diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index c1adc49d48..778b1826b4 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -171,6 +171,7 @@ void createNewTable(TAOS* pConn, int32_t index, int32_t numOfRows, int64_t start printf("failed to insert data, reason:%s\n", taos_errstr(p)); } +// startTs += 20; taos_free_result(p); } } @@ -826,19 +827,19 @@ TEST(clientCase, projection_query_tables) { // } // taos_free_result(pRes); - TAOS_RES* pRes = taos_query(pConn, "use abc1"); + TAOS_RES* pRes = taos_query(pConn, "use test"); taos_free_result(pRes); -// TAOS_RES* pRes = taos_query(pConn, "select tbname, last(ts) from abc1.stable_1 group by tbname"); + pRes = taos_query(pConn, "create table st2 (ts timestamp, k int primary key, j varchar(1000)) tags(a int)"); + taos_free_result(pRes); + +// pRes = taos_query(pConn, "create stream stream_1 trigger at_once fill_history 1 ignore expired 0 into str_res1 as select _wstart as ts, count(*) from stable_1 interval(10s);"); +// if (taos_errno(pRes) != 0) { +// printf("failed to create table tu, reason:%s\n", taos_errstr(pRes)); +// } // taos_free_result(pRes); - pRes = taos_query(pConn, "create stream stream_1 trigger at_once fill_history 1 ignore expired 0 into str_res1 as select _wstart as ts, count(*) from stable_1 interval(10s);"); - if (taos_errno(pRes) != 0) { - printf("failed to create table tu, reason:%s\n", taos_errstr(pRes)); - } - taos_free_result(pRes); - - pRes = taos_query(pConn, "create table tu using st1 tags(1)"); + pRes = taos_query(pConn, "create table tu using st2 tags(2)"); if (taos_errno(pRes) != 0) { printf("failed to create table tu, reason:%s\n", taos_errstr(pRes)); } @@ -853,7 +854,7 @@ TEST(clientCase, projection_query_tables) { "ghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz!@#$%^&&*&^^%$#@!qQWERTYUIOPASDFGHJKL:" "QWERTYUIOP{}"; - for(int32_t i = 0; i < 10000; ++i) { + for(int32_t i = 0; i < 1; ++i) { char str[1024] = {0}; sprintf(str, "create table if not exists tu%d using st2 tags(%d)", i, i); @@ -864,10 +865,10 @@ TEST(clientCase, projection_query_tables) { taos_free_result(px); } - for(int32_t j = 0; j < 5000; ++j) { + for(int32_t j = 0; j < 1; ++j) { start += 20; - for (int32_t i = 0; i < 10000; ++i) { - createNewTable(pConn, i, 20, start, pstr); + for (int32_t i = 0; i < 1; ++i) { + createNewTable(pConn, i, 100, start, pstr); } } diff --git a/source/common/src/systable.c b/source/common/src/systable.c index 25cc5d7c79..e0c0cc89ab 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -68,6 +68,16 @@ static const SSysDbTableSchema snodesSchema[] = { {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true}, }; +static const SSysDbTableSchema arbGroupsSchema[] = { + {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, + {.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, + {.name = "v1_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true}, + {.name = "v2_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true}, + {.name = "is_sync", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true}, + {.name = "assigned_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true}, + {.name = "assigned_token", .bytes = TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, +}; + static const SSysDbTableSchema clusterSchema[] = { {.name = "id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true}, {.name = "name", .bytes = TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, @@ -107,6 +117,7 @@ static const SSysDbTableSchema userDBSchema[] = { {.name = "table_suffix", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true}, {.name = "tsdb_pagesize", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, {.name = "keep_time_offset", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, + {.name = "with_arbitrator", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true}, }; static const SSysDbTableSchema userFuncSchema[] = { @@ -348,21 +359,24 @@ static const SSysDbTableSchema userCompactsDetailSchema[] = { {.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, }; -static const SSysDbTableSchema useGrantsFullSchema[] = { +static const SSysDbTableSchema userGrantsFullSchema[] = { {.name = "grant_name", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, {.name = "display_name", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, {.name = "expire", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, {.name = "limits", .bytes = 512 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, }; -static const SSysDbTableSchema useGrantsLogsSchema[] = { +static const SSysDbTableSchema userGrantsLogsSchema[] = { {.name = "state", .bytes = 1536 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, {.name = "active", .bytes = 512 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, {.name = "machine", .bytes = TSDB_GRANT_LOG_COL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, }; -static const SSysDbTableSchema useMachinesSchema[] = { +static const SSysDbTableSchema userMachinesSchema[] = { {.name = "id", .bytes = TSDB_CLUSTER_ID_LEN + 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, +#ifndef TD_UNIQ_GRANT + {.name = "dnode_num", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, +#endif {.name = "machine", .bytes = 7552 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, }; @@ -395,9 +409,10 @@ static const SSysTableMeta infosMeta[] = { {TSDB_INS_TABLE_VIEWS, userViewsSchema, tListLen(userViewsSchema), false}, {TSDB_INS_TABLE_COMPACTS, userCompactsSchema, tListLen(userCompactsSchema), false}, {TSDB_INS_TABLE_COMPACT_DETAILS, userCompactsDetailSchema, tListLen(userCompactsDetailSchema), false}, - {TSDB_INS_TABLE_GRANTS_FULL, useGrantsFullSchema, tListLen(useGrantsFullSchema), true}, - {TSDB_INS_TABLE_GRANTS_LOGS, useGrantsLogsSchema, tListLen(useGrantsLogsSchema), true}, - {TSDB_INS_TABLE_MACHINES, useMachinesSchema, tListLen(useMachinesSchema), true}, + {TSDB_INS_TABLE_GRANTS_FULL, userGrantsFullSchema, tListLen(userGrantsFullSchema), true}, + {TSDB_INS_TABLE_GRANTS_LOGS, userGrantsLogsSchema, tListLen(userGrantsLogsSchema), true}, + {TSDB_INS_TABLE_MACHINES, userMachinesSchema, tListLen(userMachinesSchema), true}, + {TSDB_INS_TABLE_ARBGROUPS, arbGroupsSchema, tListLen(arbGroupsSchema), true}, }; static const SSysDbTableSchema connectionsSchema[] = { diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index c0a2060907..3381d52050 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -82,6 +82,11 @@ int32_t tsMndGrantMode = 0; bool tsMndSkipGrant = false; bool tsEnableWhiteList = false; // ip white list cfg +// arbitrator +int32_t tsArbHeartBeatIntervalSec = 5; +int32_t tsArbCheckSyncIntervalSec = 10; +int32_t tsArbSetAssignedTimeoutSec = 30; + // dnode int64_t tsDndStart = 0; int64_t tsDndStartOsUptime = 0; @@ -268,7 +273,7 @@ bool tsDisableStream = false; int64_t tsStreamBufferSize = 128 * 1024 * 1024; bool tsFilterScalarMode = false; int tsResolveFQDNRetryTime = 100; // seconds -int tsStreamAggCnt = 1000; +int tsStreamAggCnt = 100000; char tsS3Endpoint[TSDB_FQDN_LEN] = ""; char tsS3AccessKey[TSDB_FQDN_LEN] = ""; @@ -672,6 +677,16 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { (TSDB_SYNC_SNAP_BUFFER_SIZE >> 2), CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1; + if (cfgAddInt32(pCfg, "arbHeartBeatIntervalSec", tsArbHeartBeatIntervalSec, 1, 60 * 24 * 2, CFG_SCOPE_SERVER, + CFG_DYN_NONE) != 0) + return -1; + if (cfgAddInt32(pCfg, "arbCheckSyncIntervalSec", tsArbCheckSyncIntervalSec, 1, 60 * 24 * 2, CFG_SCOPE_SERVER, + CFG_DYN_NONE) != 0) + return -1; + if (cfgAddInt32(pCfg, "arbSetAssignedTimeoutSec", tsArbSetAssignedTimeoutSec, 1, 60 * 24 * 2, CFG_SCOPE_SERVER, + CFG_DYN_NONE) != 0) + return -1; + if (cfgAddInt64(pCfg, "mndSdbWriteDelta", tsMndSdbWriteDelta, 20, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1; if (cfgAddInt64(pCfg, "mndLogRetention", tsMndLogRetention, 500, 10000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) @@ -1187,6 +1202,10 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsHeartbeatTimeout = cfgGetItem(pCfg, "syncHeartbeatTimeout")->i32; tsSnapReplMaxWaitN = cfgGetItem(pCfg, "syncSnapReplMaxWaitN")->i32; + tsArbHeartBeatIntervalSec = cfgGetItem(pCfg, "arbHeartBeatIntervalSec")->i32; + tsArbCheckSyncIntervalSec = cfgGetItem(pCfg, "arbCheckSyncIntervalSec")->i32; + tsArbSetAssignedTimeoutSec = cfgGetItem(pCfg, "arbSetAssignedTimeoutSec")->i32; + tsMndSdbWriteDelta = cfgGetItem(pCfg, "mndSdbWriteDelta")->i64; tsMndLogRetention = cfgGetItem(pCfg, "mndLogRetention")->i64; tsMndSkipGrant = cfgGetItem(pCfg, "skipGrant")->bval; diff --git a/source/common/src/tgrant.c b/source/common/src/tgrant.c index 2b5d91788e..fa1a7d90b7 100644 --- a/source/common/src/tgrant.c +++ b/source/common/src/tgrant.c @@ -21,11 +21,5 @@ int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; } int32_t grantCheckExpire(EGrantType grant) { return TSDB_CODE_SUCCESS; } -#ifdef TD_UNIQ_GRANT -int32_t grantCheckLE(EGrantType grant) { return TSDB_CODE_SUCCESS; } -#endif #else -#ifdef TD_UNIQ_GRANT -int32_t grantCheckExpire(EGrantType grant) { return TSDB_CODE_SUCCESS; } -#endif #endif \ No newline at end of file diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 015cd55f79..f0010d9a1d 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -3024,6 +3024,9 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) { if (tEncodeI32(&encoder, pReq->keepTimeOffset) < 0) return -1; ENCODESQL(); + + if (tEncodeI32(&encoder, pReq->withArbitrator) < 0) return -1; + tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -3093,8 +3096,12 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) DECODESQL(); - tEndDecode(&decoder); + pReq->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR; + if (!tDecodeIsEnd(&decoder)) { + if (tDecodeI8(&decoder, &pReq->withArbitrator) < 0) return -1; + } + tEndDecode(&decoder); tDecoderClear(&decoder); return 0; } @@ -3133,6 +3140,7 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) { if (tEncodeI32(&encoder, pReq->walRetentionSize) < 0) return -1; if (tEncodeI32(&encoder, pReq->keepTimeOffset) < 0) return -1; ENCODESQL(); + if (tEncodeI32(&encoder, pReq->withArbitrator) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -3182,6 +3190,10 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) { } DECODESQL(); + pReq->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR; + if (!tDecodeIsEnd(&decoder)) { + if (tDecodeI8(&decoder, &pReq->withArbitrator) < 0) return -1; + } tEndDecode(&decoder); tDecoderClear(&decoder); @@ -3969,6 +3981,7 @@ int32_t tSerializeSDbCfgRspImpl(SEncoder *encoder, const SDbCfgRsp *pRsp) { if (tEncodeI8(encoder, pRsp->schemaless) < 0) return -1; if (tEncodeI16(encoder, pRsp->sstTrigger) < 0) return -1; if (tEncodeI32(encoder, pRsp->keepTimeOffset) < 0) return -1; + if (tEncodeI8(encoder, pRsp->withArbitrator) < 0) return -1; return 0; } @@ -4041,6 +4054,10 @@ int32_t tDeserializeSDbCfgRspImpl(SDecoder *decoder, SDbCfgRsp *pRsp) { if (!tDecodeIsEnd(decoder)) { if (tDecodeI32(decoder, &pRsp->keepTimeOffset) < 0) return -1; } + pRsp->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR; + if (!tDecodeIsEnd(decoder)) { + if (tDecodeI8(decoder, &pRsp->withArbitrator) < 0) return -1; + } return 0; } @@ -5916,6 +5933,345 @@ int32_t tDeserializeSDCreateMnodeReq(void *buf, int32_t bufLen, SDCreateMnodeReq return 0; } +int32_t tSerializeSVArbHeartBeatReq(void *buf, int32_t bufLen, SVArbHeartBeatReq *pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->arbToken) < 0) return -1; + if (tEncodeI64(&encoder, pReq->arbTerm) < 0) return -1; + + int32_t size = taosArrayGetSize(pReq->hbMembers); + if (tEncodeI32(&encoder, size) < 0) return -1; + for (int32_t i = 0; i < size; i++) { + SVArbHbReqMember *pMember = taosArrayGet(pReq->hbMembers, i); + if (tEncodeI32(&encoder, pMember->vgId) < 0) return -1; + if (tEncodeI32(&encoder, pMember->hbSeq) < 0) return -1; + } + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSVArbHeartBeatReq(void *buf, int32_t bufLen, SVArbHeartBeatReq *pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1; + pReq->arbToken = taosMemoryMalloc(TSDB_ARB_TOKEN_SIZE); + if (tDecodeCStrTo(&decoder, pReq->arbToken) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->arbTerm) < 0) return -1; + + pReq->hbMembers = taosArrayInit(16, sizeof(SVArbHbReqMember)); + int32_t size = 0; + if (tDecodeI32(&decoder, &size) < 0) return -1; + for (int32_t i = 0; i < size; i++) { + SVArbHbReqMember member = {0}; + if (tDecodeI32(&decoder, &member.vgId) < 0) return -1; + if (tDecodeI32(&decoder, &member.hbSeq) < 0) return -1; + taosArrayPush(pReq->hbMembers, &member); + } + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +void tFreeSVArbHeartBeatReq(SVArbHeartBeatReq *pReq) { + if (!pReq) return; + taosMemoryFree(pReq->arbToken); + taosArrayDestroy(pReq->hbMembers); +} + +int32_t tSerializeSVArbHeartBeatRsp(void *buf, int32_t bufLen, SVArbHeartBeatRsp *pRsp) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeCStr(&encoder, pRsp->arbToken) < 0) return -1; + if (tEncodeI32(&encoder, pRsp->dnodeId) < 0) return -1; + int32_t sz = taosArrayGetSize(pRsp->hbMembers); + if (tEncodeI32(&encoder, sz) < 0) return -1; + for (int32_t i = 0; i < sz; i++) { + SVArbHbRspMember *pMember = taosArrayGet(pRsp->hbMembers, i); + if (tEncodeI32(&encoder, pMember->vgId) < 0) return -1; + if (tEncodeI32(&encoder, pMember->hbSeq) < 0) return -1; + if (tEncodeCStr(&encoder, pMember->memberToken) < 0) return -1; + } + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSVArbHeartBeatRsp(void *buf, int32_t bufLen, SVArbHeartBeatRsp *pRsp) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeCStrTo(&decoder, pRsp->arbToken) < 0) return -1; + if (tDecodeI32(&decoder, &pRsp->dnodeId) < 0) return -1; + int32_t sz = 0; + if (tDecodeI32(&decoder, &sz) < 0) return -1; + pRsp->hbMembers = taosArrayInit(sz, sizeof(SVArbHbRspMember)); + for (int32_t i = 0; i < sz; i++) { + SVArbHbRspMember hbMember = {0}; + if (tDecodeI32(&decoder, &hbMember.vgId) < 0) return -1; + if (tDecodeI32(&decoder, &hbMember.hbSeq) < 0) return -1; + if (tDecodeCStrTo(&decoder, hbMember.memberToken) < 0) return -1; + taosArrayPush(pRsp->hbMembers, &hbMember); + } + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +void tFreeSVArbHeartBeatRsp(SVArbHeartBeatRsp *pRsp) { + if (NULL == pRsp) { + return; + } + taosArrayDestroy(pRsp->hbMembers); +} + +int32_t tSerializeSVArbCheckSyncReq(void *buf, int32_t bufLen, SVArbCheckSyncReq *pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->arbToken) < 0) return -1; + if (tEncodeI64(&encoder, pReq->arbTerm) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->member0Token) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->member1Token) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSVArbCheckSyncReq(void *buf, int32_t bufLen, SVArbCheckSyncReq *pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + pReq->arbToken = taosMemoryMalloc(TSDB_ARB_TOKEN_SIZE); + if (tDecodeCStrTo(&decoder, pReq->arbToken) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->arbTerm) < 0) return -1; + pReq->member0Token = taosMemoryMalloc(TSDB_ARB_TOKEN_SIZE); + if (tDecodeCStrTo(&decoder, pReq->member0Token) < 0) return -1; + pReq->member1Token = taosMemoryMalloc(TSDB_ARB_TOKEN_SIZE); + if (tDecodeCStrTo(&decoder, pReq->member1Token) < 0) return -1; + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +void tFreeSVArbCheckSyncReq(SVArbCheckSyncReq *pRsp) { + if (NULL == pRsp) { + return; + } + taosMemoryFreeClear(pRsp->arbToken); + taosMemoryFreeClear(pRsp->member0Token); + taosMemoryFreeClear(pRsp->member1Token); +} + +int32_t tSerializeSVArbCheckSyncRsp(void *buf, int32_t bufLen, SVArbCheckSyncRsp *pRsp) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeCStr(&encoder, pRsp->arbToken) < 0) return -1; + if (tEncodeCStr(&encoder, pRsp->member0Token) < 0) return -1; + if (tEncodeCStr(&encoder, pRsp->member1Token) < 0) return -1; + if (tEncodeI32(&encoder, pRsp->vgId) < 0) return -1; + if (tEncodeI32(&encoder, pRsp->errCode) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSVArbCheckSyncRsp(void *buf, int32_t bufLen, SVArbCheckSyncRsp *pRsp) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + pRsp->arbToken = taosMemoryMalloc(TSDB_ARB_TOKEN_SIZE); + if (tDecodeCStrTo(&decoder, pRsp->arbToken) < 0) return -1; + pRsp->member0Token = taosMemoryMalloc(TSDB_ARB_TOKEN_SIZE); + if (tDecodeCStrTo(&decoder, pRsp->member0Token) < 0) return -1; + pRsp->member1Token = taosMemoryMalloc(TSDB_ARB_TOKEN_SIZE); + if (tDecodeCStrTo(&decoder, pRsp->member1Token) < 0) return -1; + if (tDecodeI32(&decoder, &pRsp->vgId) < 0) return -1; + if (tDecodeI32(&decoder, &pRsp->errCode) < 0) return -1; + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +void tFreeSVArbCheckSyncRsp(SVArbCheckSyncRsp *pRsp) { + if (NULL == pRsp) { + return; + } + taosMemoryFreeClear(pRsp->arbToken); + taosMemoryFreeClear(pRsp->member0Token); + taosMemoryFreeClear(pRsp->member1Token); +} + +int32_t tSerializeSVArbSetAssignedLeaderReq(void *buf, int32_t bufLen, SVArbSetAssignedLeaderReq *pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->arbToken) < 0) return -1; + if (tEncodeI64(&encoder, pReq->arbTerm) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->memberToken) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSVArbSetAssignedLeaderReq(void *buf, int32_t bufLen, SVArbSetAssignedLeaderReq *pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + pReq->arbToken = taosMemoryMalloc(TSDB_ARB_TOKEN_SIZE); + if (tDecodeCStrTo(&decoder, pReq->arbToken) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->arbTerm) < 0) return -1; + pReq->memberToken = taosMemoryMalloc(TSDB_ARB_TOKEN_SIZE); + if (tDecodeCStrTo(&decoder, pReq->memberToken) < 0) return -1; + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +void tFreeSVArbSetAssignedLeaderReq(SVArbSetAssignedLeaderReq *pReq) { + if (NULL == pReq) { + return; + } + taosMemoryFreeClear(pReq->arbToken); + taosMemoryFreeClear(pReq->memberToken); +} + +int32_t tSerializeSVArbSetAssignedLeaderRsp(void *buf, int32_t bufLen, SVArbSetAssignedLeaderRsp *pRsp) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeCStr(&encoder, pRsp->arbToken) < 0) return -1; + if (tEncodeCStr(&encoder, pRsp->memberToken) < 0) return -1; + if (tEncodeI32(&encoder, pRsp->vgId) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSVArbSetAssignedLeaderRsp(void *buf, int32_t bufLen, SVArbSetAssignedLeaderRsp *pRsp) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + pRsp->arbToken = taosMemoryMalloc(TSDB_ARB_TOKEN_SIZE); + if (tDecodeCStrTo(&decoder, pRsp->arbToken) < 0) return -1; + pRsp->memberToken = taosMemoryMalloc(TSDB_ARB_TOKEN_SIZE); + if (tDecodeCStrTo(&decoder, pRsp->memberToken) < 0) return -1; + if (tDecodeI32(&decoder, &pRsp->vgId) < 0) return -1; + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +void tFreeSVArbSetAssignedLeaderRsp(SVArbSetAssignedLeaderRsp *pRsp) { + if (NULL == pRsp) { + return; + } + taosMemoryFreeClear(pRsp->arbToken); + taosMemoryFreeClear(pRsp->memberToken); +} + +int32_t tSerializeSMArbUpdateGroupReq(void *buf, int32_t bufLen, SMArbUpdateGroupReq *pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeI32(&encoder, pReq->vgId) < 0) return -1; + if (tEncodeI64(&encoder, pReq->dbUid) < 0) return -1; + for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) { + if (tEncodeI32(&encoder, pReq->members[i].dnodeId) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->members[i].token) < 0) return -1; + } + if (tEncodeI8(&encoder, pReq->isSync) < 0) return -1; + if (tEncodeI32(&encoder, pReq->assignedLeader.dnodeId) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->assignedLeader.token) < 0) return -1; + if (tEncodeI64(&encoder, pReq->version) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSMArbUpdateGroupReq(void *buf, int32_t bufLen, SMArbUpdateGroupReq *pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->vgId) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->dbUid) < 0) return -1; + for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) { + if (tDecodeI32(&decoder, &pReq->members[i].dnodeId) < 0) return -1; + pReq->members[i].token = taosMemoryMalloc(TSDB_ARB_TOKEN_SIZE); + if (tDecodeCStrTo(&decoder, pReq->members[i].token) < 0) return -1; + } + if (tDecodeI8(&decoder, &pReq->isSync) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->assignedLeader.dnodeId) < 0) return -1; + pReq->assignedLeader.token = taosMemoryMalloc(TSDB_ARB_TOKEN_SIZE); + if (tDecodeCStrTo(&decoder, pReq->assignedLeader.token) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->version) < 0) return -1; + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +void tFreeSMArbUpdateGroupReq(SMArbUpdateGroupReq *pReq) { + if (NULL == pReq) { + return; + } + for (int i = 0; i < 2; i++) { + taosMemoryFreeClear(pReq->members[i].token); + } + taosMemoryFreeClear(pReq->assignedLeader.token); +} + // int32_t tSerializeSAuthReq(void *buf, int32_t bufLen, SAuthReq *pReq) { // SEncoder encoder = {0}; // tEncoderInit(&encoder, buf, bufLen); @@ -6201,9 +6557,8 @@ int32_t tDeserializeSMqAskEpReq(void *buf, int32_t bufLen, SMqAskEpReq *pReq) { return 0; } -int32_t tDeatroySMqHbRsp(SMqHbRsp *pRsp) { +void tDestroySMqHbRsp(SMqHbRsp *pRsp) { taosArrayDestroy(pRsp->topicPrivileges); - return 0; } int32_t tSerializeSMqHbRsp(void *buf, int32_t bufLen, SMqHbRsp *pRsp) { @@ -6250,13 +6605,12 @@ int32_t tDeserializeSMqHbRsp(void *buf, int32_t bufLen, SMqHbRsp *pRsp) { return 0; } -int32_t tDeatroySMqHbReq(SMqHbReq *pReq) { +void tDestroySMqHbReq(SMqHbReq *pReq) { for (int i = 0; i < taosArrayGetSize(pReq->topics); i++) { TopicOffsetRows *vgs = taosArrayGet(pReq->topics, i); if (vgs) taosArrayDestroy(vgs->offsetRows); } taosArrayDestroy(pReq->topics); - return 0; } int32_t tSerializeSMqHbReq(void *buf, int32_t bufLen, SMqHbReq *pReq) { diff --git a/source/common/src/ttypes.c b/source/common/src/ttypes.c index 8827ddc811..57bc875fce 100644 --- a/source/common/src/ttypes.c +++ b/source/common/src/ttypes.c @@ -34,7 +34,7 @@ const int32_t TYPE_BYTES[21] = { INT_BYTES, // TSDB_DATA_TYPE_UINT sizeof(uint64_t), // TSDB_DATA_TYPE_UBIGINT TSDB_MAX_JSON_TAG_LEN, // TSDB_DATA_TYPE_JSON - TSDB_MAX_TAGS_LEN, // TSDB_DATA_TYPE_VARBINARY: placeholder, not implemented + sizeof(VarDataOffsetT), // TSDB_DATA_TYPE_VARBINARY TSDB_MAX_TAGS_LEN, // TSDB_DATA_TYPE_DECIMAL: placeholder, not implemented TSDB_MAX_TAGS_LEN, // TSDB_DATA_TYPE_BLOB: placeholder, not implemented TSDB_MAX_TAGS_LEN, // TSDB_DATA_TYPE_MEDIUMBLOB: placeholder, not implemented diff --git a/source/common/src/tvariant.c b/source/common/src/tvariant.c index dd5e8240b9..ae2c8c0c14 100644 --- a/source/common/src/tvariant.c +++ b/source/common/src/tvariant.c @@ -19,7 +19,7 @@ #include "ttokendef.h" #include "tvariant.h" -int32_t parseBinaryUInteger(const char *z, int32_t n, uint64_t *value) { +static int32_t parseBinaryUInteger(const char *z, int32_t n, uint64_t *value) { // skip head 0b const char *p = z + 2; int32_t l = n - 2; @@ -45,7 +45,7 @@ int32_t parseBinaryUInteger(const char *z, int32_t n, uint64_t *value) { return TSDB_CODE_SUCCESS; } -int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint64_t *value) { +static int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint64_t *value, bool parseFloat) { // parse sign bool has_sign = false; if (z[0] == '-') { @@ -65,8 +65,7 @@ int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint64_t *v } errno = 0; - char *endPtr = NULL; - bool parsed = false; + char *endPtr = NULL; if (z[0] == '0' && n > 2) { if (z[1] == 'b' || z[1] == 'B') { // paring as binary @@ -76,44 +75,87 @@ int32_t parseSignAndUInteger(const char *z, int32_t n, bool *is_neg, uint64_t *v if (z[1] == 'x' || z[1] == 'X') { // parsing as hex *value = taosStr2UInt64(z, &endPtr, 16); - parsed = true; + if (errno == ERANGE || errno == EINVAL || endPtr - z != n) { + return TSDB_CODE_FAILED; + } + return TSDB_CODE_SUCCESS; } } - if (!parsed) { + if (parseFloat) { // parsing as double double val = taosStr2Double(z, &endPtr); + if (errno == ERANGE || errno == EINVAL || endPtr - z != n) { + return TSDB_CODE_FAILED; + } if (val > UINT64_MAX) { + errno = ERANGE; return TSDB_CODE_FAILED; } *value = round(val); - } - - if (errno == ERANGE || errno == EINVAL || endPtr - z != n) { - return TSDB_CODE_FAILED; - } - return TSDB_CODE_SUCCESS; -} - - -int32_t toDoubleEx(const char *z, int32_t n, uint32_t type, double* value) { - if (n == 0) { - *value = 0; return TSDB_CODE_SUCCESS; } + return TSDB_CODE_FAILED; +} + +int32_t toDoubleEx(const char *z, int32_t n, uint32_t type, double *value) { + if (n == 0) { + errno = EINVAL; + return TSDB_CODE_FAILED; + } + errno = 0; - char* endPtr = NULL; - *value = taosStr2Double(z, &endPtr); + char *endPtr = NULL; + *value = taosStr2Double(z, &endPtr); // 0x already converted here + if (errno == ERANGE || errno == EINVAL) return TSDB_CODE_FAILED; + if (endPtr - z == n) return TSDB_CODE_SUCCESS; - if (errno == ERANGE || errno == EINVAL) { - return TSDB_CODE_FAILED; + if (type == TK_NK_BIN || type == TK_NK_STRING) { + bool is_neg = false; + uint64_t uv = 0; + if (TSDB_CODE_SUCCESS == parseSignAndUInteger(z, n, &is_neg, &uv, false)) { + *value = is_neg ? -(double)uv : uv; + return TSDB_CODE_SUCCESS; + } } - if (endPtr - z != n) { - return TSDB_CODE_FAILED; + return TSDB_CODE_FAILED; +} + +int32_t toIntegerPure(const char *z, int32_t n, int32_t base, int64_t *value) { + errno = 0; + + char *endPtr = NULL; + *value = taosStr2Int64(z, &endPtr, base); + if (endPtr - z == n) { + if (errno == ERANGE || errno == EINVAL) { + return TSDB_CODE_FAILED; + } + return TSDB_CODE_SUCCESS; } - return TSDB_CODE_SUCCESS; + + bool is_neg = false; + uint64_t uv = 0; + int32_t code = parseSignAndUInteger(z, n, &is_neg, &uv, false); // support 0b/0x + if (code == TSDB_CODE_SUCCESS) { + if (is_neg) { + if (uv > 1ull + INT64_MAX) { + *value = INT64_MIN; + return TSDB_CODE_FAILED; + } else { + *value = -(int64_t)uv; + } + } else { + if (uv > INT64_MAX) { + *value = INT64_MAX; + return TSDB_CODE_FAILED; + } + *value = uv; + } + } + + return code; } int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) { @@ -144,8 +186,8 @@ int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) { } if (n == 0) { - *value = 0; - return TSDB_CODE_SUCCESS; + errno = EINVAL; + return TSDB_CODE_FAILED; } // 1. try to parse as integer @@ -190,7 +232,7 @@ int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) { // 2. parse as other bool is_neg = false; uint64_t uv = 0; - int32_t code = parseSignAndUInteger(z, n, &is_neg, &uv); + int32_t code = parseSignAndUInteger(z, n, &is_neg, &uv, true); if (code == TSDB_CODE_SUCCESS) { // truncate into int64 if (is_neg) { @@ -198,7 +240,7 @@ int32_t toIntegerEx(const char *z, int32_t n, uint32_t type, int64_t *value) { *value = INT64_MIN; return TSDB_CODE_FAILED; } else { - *value = -uv; + *value = -(int64_t)uv; } } else { if (uv > INT64_MAX) { @@ -216,9 +258,6 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) { errno = 0; char *endPtr = NULL; const char *p = z; - while (*p == ' ') { - p++; - } switch (type) { case TK_NK_INTEGER: { *value = taosStr2UInt64(p, &endPtr, 10); @@ -246,24 +285,22 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) { } if (n == 0) { - *value = 0; - return TSDB_CODE_SUCCESS; + errno = EINVAL; + return TSDB_CODE_FAILED; } // 1. parse as integer *value = taosStr2UInt64(p, &endPtr, 10); - if (*p == '-' && *value) { - return TSDB_CODE_FAILED; - } + if (endPtr - z == n) { - if (errno == ERANGE || errno == EINVAL) { + if (errno == ERANGE || errno == EINVAL || (*p == '-' && *value)) { return TSDB_CODE_FAILED; } return TSDB_CODE_SUCCESS; } else if (errno == 0 && *endPtr == '.') { const char *s = endPtr + 1; const char *end = z + n; - bool pure = true; + bool pure = true; while (s < end) { if (*s < '0' || *s > '9') { pure = false; @@ -275,13 +312,16 @@ int32_t toUIntegerEx(const char *z, int32_t n, uint32_t type, uint64_t *value) { if (endPtr + 1 < end && endPtr[1] > '4' && *value < UINT64_MAX) { (*value)++; } + if (*p == '-' && *value) { + return TSDB_CODE_FAILED; + } return TSDB_CODE_SUCCESS; } } - // 2. parse as other + // 2. parse as other bool is_neg = false; - int32_t code = parseSignAndUInteger(z, n, &is_neg, value); + int32_t code = parseSignAndUInteger(z, n, &is_neg, value, true); if (is_neg) { if (TSDB_CODE_SUCCESS == code && 0 == *value) { return TSDB_CODE_SUCCESS; diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c index aa5e87e8b1..393db84e18 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmHandle.c @@ -90,16 +90,6 @@ static void dmProcessStatusRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) { rpcFreeCont(pRsp->pCont); } -void dmEpSetToStr(char *buf, int32_t len, SEpSet *epSet) { - int32_t n = 0; - n += snprintf(buf + n, len - n, "%s", "{"); - for (int i = 0; i < epSet->numOfEps; i++) { - n += snprintf(buf + n, len - n, "%s:%d%s", epSet->eps[i].fqdn, epSet->eps[i].port, - (i + 1 < epSet->numOfEps ? ", " : "")); - } - n += snprintf(buf + n, len - n, "%s", "}"); -} - void dmSendStatusReq(SDnodeMgmt *pMgmt) { SStatusReq req = {0}; diff --git a/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h b/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h index 24f75e3c8b..bc2977fe31 100644 --- a/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h +++ b/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h @@ -33,6 +33,7 @@ typedef struct SMnodeMgmt { SSingleWorker fetchWorker; SSingleWorker readWorker; SSingleWorker writeWorker; + SSingleWorker arbWorker; SSingleWorker syncWorker; SSingleWorker syncRdWorker; bool stopped; @@ -53,6 +54,7 @@ int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg); int32_t mmStartWorker(SMnodeMgmt *pMgmt); void mmStopWorker(SMnodeMgmt *pMgmt); int32_t mmPutMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); +int32_t mmPutMsgToArbQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t mmPutMsgToSyncRdQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index a3a5f1d971..7e38b994df 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -235,6 +235,9 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_INDEX_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_INDEX_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_DISABLE_WRITE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_ARB_HEARTBEAT_RSP, mmPutMsgToArbQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_ARB_CHECK_SYNC_RSP, mmPutMsgToArbQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_SET_ASSIGNED_LEADER_RSP, mmPutMsgToArbQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT_ELECTION, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c index bbd77c0828..75d5669824 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c @@ -107,6 +107,10 @@ int32_t mmPutMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { return mmPutMsgToWorker(pMgmt, &pMgmt->writeWorker, pMsg); } +int32_t mmPutMsgToArbQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { + return mmPutMsgToWorker(pMgmt, &pMgmt->arbWorker, pMsg); +} + int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { return mmPutMsgToWorker(pMgmt, &pMgmt->syncWorker, pMsg); } @@ -153,6 +157,9 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { case READ_QUEUE: pWorker = &pMgmt->readWorker; break; + case ARB_QUEUE: + pWorker = &pMgmt->arbWorker; + break; case SYNC_QUEUE: pWorker = &pMgmt->syncWorker; break; @@ -252,6 +259,18 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) { return -1; } + SSingleWorkerCfg arbCfg = { + .min = 1, + .max = 1, + .name = "mnode-arb", + .fp = (FItem)mmProcessRpcMsg, + .param = pMgmt, + }; + if (tSingleWorkerInit(&pMgmt->arbWorker, &arbCfg) != 0) { + dError("failed to start mnode mnode-arb worker since %s", terrstr()); + return -1; + } + dDebug("mnode workers are initialized"); return 0; } @@ -263,6 +282,7 @@ void mmStopWorker(SMnodeMgmt *pMgmt) { tSingleWorkerCleanup(&pMgmt->fetchWorker); tSingleWorkerCleanup(&pMgmt->readWorker); tSingleWorkerCleanup(&pMgmt->writeWorker); + tSingleWorkerCleanup(&pMgmt->arbWorker); tSingleWorkerCleanup(&pMgmt->syncWorker); tSingleWorkerCleanup(&pMgmt->syncRdWorker); dDebug("mnode workers are closed"); diff --git a/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h b/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h index d9c368b582..375a34c04f 100644 --- a/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h +++ b/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h @@ -101,6 +101,7 @@ int32_t vmProcessDisableVnodeWriteReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t vmProcessAlterHashRangeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t vmProcessAlterVnodeTypeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t vmProcessCheckLearnCatchupReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); +int32_t vmProcessArbHeartBeatReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); // vmFile.c int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index bfac0bab9d..722eaf1fd3 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -88,7 +88,9 @@ void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) { numOfInsertSuccessReqs += pLoad->numOfInsertSuccessReqs; numOfBatchInsertReqs += pLoad->numOfBatchInsertReqs; numOfBatchInsertSuccessReqs += pLoad->numOfBatchInsertSuccessReqs; - if (pLoad->syncState == TAOS_SYNC_STATE_LEADER) masterNum++; + if (pLoad->syncState == TAOS_SYNC_STATE_LEADER || pLoad->syncState == TAOS_SYNC_STATE_ASSIGNED_LEADER) { + masterNum++; + } totalVnodes++; } @@ -770,6 +772,89 @@ int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return 0; } +int32_t vmProcessArbHeartBeatReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { + SVArbHeartBeatReq arbHbReq = {0}; + SVArbHeartBeatRsp arbHbRsp = {0}; + if (tDeserializeSVArbHeartBeatReq(pMsg->pCont, pMsg->contLen, &arbHbReq) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + if (arbHbReq.dnodeId != pMgmt->pData->dnodeId) { + terrno = TSDB_CODE_INVALID_MSG; + dError("dnodeId:%d not matched with local dnode", arbHbReq.dnodeId); + goto _OVER; + } + + if (strlen(arbHbReq.arbToken) == 0) { + terrno = TSDB_CODE_INVALID_MSG; + dError("dnodeId:%d arbToken is empty", arbHbReq.dnodeId); + goto _OVER; + } + + size_t size = taosArrayGetSize(arbHbReq.hbMembers); + + arbHbRsp.dnodeId = pMgmt->pData->dnodeId; + strncpy(arbHbRsp.arbToken, arbHbReq.arbToken, TSDB_ARB_TOKEN_SIZE); + arbHbRsp.hbMembers = taosArrayInit(size, sizeof(SVArbHbRspMember)); + + for (int32_t i = 0; i < size; i++) { + SVArbHbReqMember *pReqMember = taosArrayGet(arbHbReq.hbMembers, i); + SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pReqMember->vgId); + if (pVnode == NULL) { + dError("dnodeId:%d vgId:%d not found failed to process arb hb req", arbHbReq.dnodeId, pReqMember->vgId); + continue; + } + + SVArbHbRspMember rspMember = {0}; + rspMember.vgId = pReqMember->vgId; + rspMember.hbSeq = pReqMember->hbSeq; + if (vnodeGetArbToken(pVnode->pImpl, rspMember.memberToken) != 0) { + dError("dnodeId:%d vgId:%d failed to get arb token", arbHbReq.dnodeId, pReqMember->vgId); + vmReleaseVnode(pMgmt, pVnode); + continue; + } + + if (vnodeUpdateArbTerm(pVnode->pImpl, arbHbReq.arbTerm) != 0) { + dError("dnodeId:%d vgId:%d failed to update arb term", arbHbReq.dnodeId, pReqMember->vgId); + vmReleaseVnode(pMgmt, pVnode); + continue; + } + + taosArrayPush(arbHbRsp.hbMembers, &rspMember); + + vmReleaseVnode(pMgmt, pVnode); + } + + SRpcMsg rspMsg = {.info = pMsg->info}; + int32_t rspLen = tSerializeSVArbHeartBeatRsp(NULL, 0, &arbHbRsp); + if (rspLen < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + + void *pRsp = rpcMallocCont(rspLen); + if (pRsp == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + + if (tSerializeSVArbHeartBeatRsp(pRsp, rspLen, &arbHbRsp) <= 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + rpcFreeCont(pRsp); + goto _OVER; + } + pMsg->info.rsp = pRsp; + pMsg->info.rspLen = rspLen; + + terrno = TSDB_CODE_SUCCESS; + +_OVER: + tFreeSVArbHeartBeatReq(&arbHbReq); + tFreeSVArbHeartBeatRsp(&arbHbRsp); + return terrno == TSDB_CODE_SUCCESS ? 0 : -1; +} + SArray *vmGetMsgHandles() { int32_t code = -1; SArray *pArray = taosArrayInit(32, sizeof(SMgmtHandle)); @@ -873,6 +958,10 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, vmPutMsgToSyncRdQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_PREP_SNAPSHOT_REPLY, vmPutMsgToSyncRdQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_ARB_HEARTBEAT, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_ARB_CHECK_SYNC, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_SET_ASSIGNED_LEADER, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; + code = 0; _OVER: diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index a6abe5ab4d..e4adfdb6b1 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c @@ -56,6 +56,9 @@ static void vmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { case TDMT_DND_CHECK_VNODE_LEARNER_CATCHUP: code = vmProcessCheckLearnCatchupReq(pMgmt, pMsg); break; + case TDMT_VND_ARB_HEARTBEAT: + code = vmProcessArbHeartBeatReq(pMgmt, pMsg); + break; default: terrno = TSDB_CODE_MSG_NOT_PROCESSED; dGError("msg:%p, not processed in vnode-mgmt queue", pMsg); diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index 77760b16f4..754c42b82e 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -538,6 +538,7 @@ SMsgCb dmGetMsgcb(SDnode *pDnode) { .releaseHandleFp = dmReleaseHandle, .reportStartupFp = dmReportStartup, .updateDnodeInfoFp = dmUpdateDnodeInfo, + .getDnodeEpFp = dmGetDnodeEp, .data = &pDnode->data, }; return msgCb; diff --git a/source/dnode/mgmt/node_util/inc/dmUtil.h b/source/dnode/mgmt/node_util/inc/dmUtil.h index 2175824acd..0dcb77d9df 100644 --- a/source/dnode/mgmt/node_util/inc/dmUtil.h +++ b/source/dnode/mgmt/node_util/inc/dmUtil.h @@ -184,11 +184,13 @@ int32_t dmReadEps(SDnodeData *pData); int32_t dmWriteEps(SDnodeData *pData); void dmUpdateEps(SDnodeData *pData, SArray *pDnodeEps); void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet); +void dmEpSetToStr(char *buf, int32_t len, SEpSet *epSet); void dmRotateMnodeEpSet(SDnodeData *pData); void dmGetMnodeEpSetForRedirect(SDnodeData *pData, SRpcMsg *pMsg, SEpSet *pEpSet); void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet); bool dmUpdateDnodeInfo(void *pData, int32_t *dnodeId, int64_t *clusterId, char *fqdn, uint16_t *port); void dmRemoveDnodePairs(SDnodeData *pData); +void dmGetDnodeEp(void *pData, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/node_util/src/dmEps.c b/source/dnode/mgmt/node_util/src/dmEps.c index 20245c806b..2c341fbd4d 100644 --- a/source/dnode/mgmt/node_util/src/dmEps.c +++ b/source/dnode/mgmt/node_util/src/dmEps.c @@ -31,7 +31,8 @@ static bool dmIsEpChanged(SDnodeData *pData, int32_t dnodeId, const char *ep) static void dmResetEps(SDnodeData *pData, SArray *dnodeEps); static int32_t dmReadDnodePairs(SDnodeData *pData); -static void dmGetDnodeEp(SDnodeData *pData, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort) { +void dmGetDnodeEp(void *data, int32_t dnodeId, char *pEp, char *pFqdn, uint16_t *pPort) { + SDnodeData *pData = data; taosThreadRwlockRdlock(&pData->lock); SDnodeEp *pDnodeEp = taosHashGet(pData->dnodeHash, &dnodeId, sizeof(int32_t)); @@ -335,6 +336,16 @@ void dmGetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet) { taosThreadRwlockUnlock(&pData->lock); } +void dmEpSetToStr(char *buf, int32_t len, SEpSet *epSet) { + int32_t n = 0; + n += snprintf(buf + n, len - n, "%s", "{"); + for (int i = 0; i < epSet->numOfEps; i++) { + n += snprintf(buf + n, len - n, "%s:%d%s", epSet->eps[i].fqdn, epSet->eps[i].port, + (i + 1 < epSet->numOfEps ? ", " : "")); + } + n += snprintf(buf + n, len - n, "%s", "}"); +} + static FORCE_INLINE void dmSwapEps(SEp *epLhs, SEp *epRhs) { SEp epTmp; diff --git a/source/dnode/mnode/impl/inc/mndArbGroup.h b/source/dnode/mnode/impl/inc/mndArbGroup.h new file mode 100644 index 0000000000..ed852cf581 --- /dev/null +++ b/source/dnode/mnode/impl/inc/mndArbGroup.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _TD_MND_ARBGROUP_H_ +#define _TD_MND_ARBGROUP_H_ + +#include "mndInt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int32_t mndInitArbGroup(SMnode *pMnode); +void mndCleanupArbGroup(SMnode *pMnode); +SArbGroup *mndAcquireArbGroup(SMnode *pMnode, int32_t vgId); +void mndReleaseArbGroup(SMnode *pMnode, SArbGroup *pObj); +SSdbRaw *mndArbGroupActionEncode(SArbGroup *pGroup); +SSdbRow *mndArbGroupActionDecode(SSdbRaw *pRaw); + +void mndArbGroupInitFromVgObj(SVgObj *pVgObj, SArbGroup *outGroup); + +int32_t mndSetCreateArbGroupRedoLogs(STrans *pTrans, SArbGroup *pGroup); +int32_t mndSetCreateArbGroupUndoLogs(STrans *pTrans, SArbGroup *pGroup); +int32_t mndSetCreateArbGroupCommitLogs(STrans *pTrans, SArbGroup *pGroup); + +int32_t mndSetDropArbGroupCommitLogs(STrans *pTrans, SArbGroup *pGroup); + +bool mndUpdateArbGroupByHeartBeat(SArbGroup *pGroup, SVArbHbRspMember *pRspMember, int64_t nowMs, int32_t dnodeId, + SArbGroup *pNewGroup); +bool mndUpdateArbGroupByCheckSync(SArbGroup *pGroup, int32_t vgId, char *member0Token, char *member1Token, + bool newIsSync, SArbGroup *pNewGroup); +bool mndUpdateArbGroupBySetAssignedLeader(SArbGroup *pGroup, int32_t vgId, char *memberToken, int32_t errcode, + SArbGroup *pNewGroup); + +int32_t mndGetArbGroupSize(SMnode *pMnode); + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_MND_ARBGROUP_H_*/ diff --git a/source/dnode/mnode/impl/inc/mndConsumer.h b/source/dnode/mnode/impl/inc/mndConsumer.h index 8c89ddc825..5184ad0eca 100644 --- a/source/dnode/mnode/impl/inc/mndConsumer.h +++ b/source/dnode/mnode/impl/inc/mndConsumer.h @@ -24,27 +24,22 @@ extern "C" { enum { MQ_CONSUMER_STATUS_REBALANCE = 1, -// MQ_CONSUMER_STATUS__MODIFY_IN_REB, // this value is not used anymore MQ_CONSUMER_STATUS_READY, MQ_CONSUMER_STATUS_LOST, -// MQ_CONSUMER_STATUS__LOST_IN_REB, // this value is not used anymore -// MQ_CONSUMER_STATUS__LOST_REBD, -};\ +}; int32_t mndInitConsumer(SMnode *pMnode); void mndCleanupConsumer(SMnode *pMnode); -void mndDropConsumerFromSdb(SMnode *pMnode, int64_t consumerId, SRpcHandleInfo* info); +void mndSendConsumerMsg(SMnode *pMnode, int64_t consumerId, uint16_t msgType, SRpcHandleInfo* info); SMqConsumerObj *mndAcquireConsumer(SMnode *pMnode, int64_t consumerId); void mndReleaseConsumer(SMnode *pMnode, SMqConsumerObj *pConsumer); -SMqConsumerObj *mndCreateConsumer(int64_t consumerId, const char *cgroup); - SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer); SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw); -int32_t mndSetConsumerCommitLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *pConsumer); -int32_t mndSetConsumerDropLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *pConsumer); +int32_t mndSetConsumerCommitLogs(STrans *pTrans, SMqConsumerObj *pConsumer); +int32_t mndSetConsumerDropLogs(STrans *pTrans, SMqConsumerObj *pConsumer); const char *mndConsumerStatusName(int status); diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 4a092057ce..a63157445b 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -104,6 +104,7 @@ typedef enum { TRN_CONFLICT_DB_INSIDE = 3, TRN_CONFLICT_TOPIC = 4, TRN_CONFLICT_TOPIC_INSIDE = 5, + TRN_CONFLICT_ARBGROUP = 6, } ETrnConflct; typedef enum { @@ -149,6 +150,7 @@ typedef enum { CONSUMER_REMOVE_REB, // remove after rebalance CONSUMER_UPDATE_REC, // update after recover CONSUMER_UPDATE_SUB, // update after subscribe req + CONSUMER_INSERT_SUB, } ECsmUpdateType; typedef struct { @@ -176,6 +178,7 @@ typedef struct { tmsg_t originRpcType; char dbname[TSDB_TABLE_FNAME_LEN]; char stbname[TSDB_TABLE_FNAME_LEN]; + int32_t arbGroupId; int32_t startFunc; int32_t stopFunc; int32_t paramLen; @@ -214,8 +217,6 @@ typedef struct { uint16_t port; char fqdn[TSDB_FQDN_LEN]; char ep[TSDB_EP_LEN]; - char active[TSDB_ACTIVE_KEY_LEN]; - char connActive[TSDB_CONN_ACTIVE_KEY_LEN]; char machineId[TSDB_MACHINE_ID_LEN + 1]; } SDnodeObj; @@ -247,6 +248,40 @@ typedef struct { SDnodeObj* pDnode; } SSnodeObj; +typedef struct { + int32_t dnodeId; + char token[TSDB_ARB_TOKEN_SIZE]; +} SArbAssignedLeader; + +typedef struct { + int32_t dnodeId; +} SArbMemberInfo; + +typedef struct { + int32_t nextHbSeq; + int32_t responsedHbSeq; + char token[TSDB_ARB_TOKEN_SIZE]; + int64_t lastHbMs; +} SArbMemberState; + +typedef struct { + SArbMemberInfo info; + SArbMemberState state; +} SArbGroupMember; + +typedef struct { + int32_t vgId; + int64_t dbUid; + SArbGroupMember members[TSDB_ARB_GROUP_MEMBER_NUM]; + int8_t isSync; + SArbAssignedLeader assignedLeader; + int64_t version; + + // following fields will not be duplicated + bool mutexInited; + TdThreadMutex mutex; +} SArbGroup; + typedef struct { int32_t maxUsers; int32_t maxDbs; @@ -343,6 +378,7 @@ typedef struct { int32_t walRollPeriod; int64_t walRetentionSize; int64_t walSegmentSize; + int8_t withArbitrator; } SDbCfg; typedef struct { @@ -556,8 +592,9 @@ typedef struct { int32_t resetOffsetCfg; } SMqConsumerObj; -SMqConsumerObj* tNewSMqConsumerObj(int64_t consumerId, char cgroup[TSDB_CGROUP_LEN]); -void tDeleteSMqConsumerObj(SMqConsumerObj* pConsumer, bool isDeleted); +SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType, char *topic, SCMSubscribeReq *subscribe); +void tClearSMqConsumerObj(SMqConsumerObj* pConsumer); +void tDeleteSMqConsumerObj(SMqConsumerObj* pConsumer); int32_t tEncodeSMqConsumerObj(void** buf, const SMqConsumerObj* pConsumer); void* tDecodeSMqConsumerObj(const void* buf, SMqConsumerObj* pConsumer, int8_t sver); diff --git a/source/dnode/mnode/impl/inc/mndDnode.h b/source/dnode/mnode/impl/inc/mndDnode.h index 83c2277612..ab104e316e 100644 --- a/source/dnode/mnode/impl/inc/mndDnode.h +++ b/source/dnode/mnode/impl/inc/mndDnode.h @@ -27,6 +27,7 @@ void mndCleanupDnode(SMnode *pMnode); SDnodeObj *mndAcquireDnode(SMnode *pMnode, int32_t dnodeId); void mndReleaseDnode(SMnode *pMnode, SDnodeObj *pDnode); SEpSet mndGetDnodeEpset(SDnodeObj *pDnode); +SEpSet mndGetDnodeEpsetById(SMnode *pMnode, int32_t dnodeId); int32_t mndGetDnodeSize(SMnode *pMnode); bool mndIsDnodeOnline(SDnodeObj *pDnode, int64_t curMs); void mndGetDnodeData(SMnode *pMnode, SArray *pDnodeInfo); diff --git a/source/dnode/mnode/impl/inc/mndStream.h b/source/dnode/mnode/impl/inc/mndStream.h index 5307ff4b05..5a4caf3348 100644 --- a/source/dnode/mnode/impl/inc/mndStream.h +++ b/source/dnode/mnode/impl/inc/mndStream.h @@ -107,7 +107,7 @@ SArray *mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady); void mndKillTransImpl(SMnode *pMnode, int32_t transId, const char *pDbName); int32_t setTransAction(STrans *pTrans, void *pCont, int32_t contLen, int32_t msgType, const SEpSet *pEpset, int32_t retryCode); -STrans *doCreateTrans(SMnode *pMnode, SStreamObj *pStream, SRpcMsg *pReq, const char *name, const char *pMsg); +STrans *doCreateTrans(SMnode *pMnode, SStreamObj *pStream, SRpcMsg *pReq, ETrnConflct conflict, const char *name, const char *pMsg); int32_t mndPersistTransLog(SStreamObj *pStream, STrans *pTrans, int32_t status); SSdbRaw *mndStreamActionEncode(SStreamObj *pStream); void killAllCheckpointTrans(SMnode *pMnode, SVgroupChangeInfo *pChangeInfo); diff --git a/source/dnode/mnode/impl/inc/mndSubscribe.h b/source/dnode/mnode/impl/inc/mndSubscribe.h index 23b3a7d1fe..eb9902a75c 100644 --- a/source/dnode/mnode/impl/inc/mndSubscribe.h +++ b/source/dnode/mnode/impl/inc/mndSubscribe.h @@ -30,7 +30,7 @@ SMqSubscribeObj *mndAcquireSubscribe(SMnode *pMnode, const char *CGroup, const c SMqSubscribeObj *mndAcquireSubscribeByKey(SMnode *pMnode, const char *key); void mndReleaseSubscribe(SMnode *pMnode, SMqSubscribeObj *pSub); -int32_t mndMakeSubscribeKey(char *key, const char *cgroup, const char *topicName); +void mndMakeSubscribeKey(char *key, const char *cgroup, const char *topicName); int32_t mndDropSubByTopic(SMnode *pMnode, STrans *pTrans, const char *topic); int32_t mndSetDropSubCommitLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeObj *pSub); diff --git a/source/dnode/mnode/impl/inc/mndTrans.h b/source/dnode/mnode/impl/inc/mndTrans.h index 59eaa915bc..8689df98af 100644 --- a/source/dnode/mnode/impl/inc/mndTrans.h +++ b/source/dnode/mnode/impl/inc/mndTrans.h @@ -78,6 +78,7 @@ int32_t mndTransAppendUndoAction(STrans *pTrans, STransAction *pAction); void mndTransSetRpcRsp(STrans *pTrans, void *pCont, int32_t contLen); void mndTransSetCb(STrans *pTrans, ETrnFunc startFunc, ETrnFunc stopFunc, void *param, int32_t paramLen); void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbname); +void mndTransSetArbGroupId(STrans *pTrans, int32_t groupId); void mndTransSetSerial(STrans *pTrans); void mndTransSetParallel(STrans *pTrans); void mndTransSetOper(STrans *pTrans, EOperType oper); diff --git a/source/dnode/mnode/impl/inc/mndVgroup.h b/source/dnode/mnode/impl/inc/mndVgroup.h index b7f6769d12..444c16083c 100644 --- a/source/dnode/mnode/impl/inc/mndVgroup.h +++ b/source/dnode/mnode/impl/inc/mndVgroup.h @@ -29,6 +29,7 @@ void mndReleaseVgroup(SMnode *pMnode, SVgObj *pVgroup); SSdbRaw *mndVgroupActionEncode(SVgObj *pVgroup); SSdbRow *mndVgroupActionDecode(SSdbRaw *pRaw); SEpSet mndGetVgroupEpset(SMnode *pMnode, const SVgObj *pVgroup); +SEpSet mndGetVgroupEpsetById(SMnode *pMnode, int32_t vgId); int32_t mndGetVnodesNum(SMnode *pMnode, int32_t dnodeId); void mndSortVnodeGid(SVgObj *pVgroup); int64_t mndGetVnodesMemory(SMnode *pMnode, int32_t dnodeId); @@ -44,7 +45,7 @@ int32_t mndAddAlterVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pV int32_t mndAddDropVnodeAction(SMnode *, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, SVnodeGid *pVgid, bool isRedo); int32_t mndSetMoveVgroupsInfoToTrans(SMnode *, STrans *pTrans, int32_t dropDnodeId, bool force, bool unsafe); int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb, SDbObj *pNewDb, SVgObj *pVgroup, - SArray *pArray); + SArray *pArray, SVgObj* pNewVgroup); int32_t mndBuildCompactVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, int64_t compactTs, STimeWindow tw); int32_t mndBuildRaftAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb, SDbObj *pNewDb, SVgObj *pVgroup, @@ -54,8 +55,8 @@ void *mndBuildCreateVnodeReq(SMnode *, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *p void *mndBuildDropVnodeReq(SMnode *, SDnodeObj *pDnode, SDbObj *pDb, SVgObj *pVgroup, int32_t *pContLen); bool mndVgroupInDb(SVgObj *pVgroup, int64_t dbUid); bool mndVgroupInDnode(SVgObj *pVgroup, int32_t dnodeId); -int32_t mndBuildRestoreAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *db, SVgObj *pVgroup, - SDnodeObj *pDnode); +int32_t mndBuildRestoreAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *db, SVgObj *pVgroup, + SDnodeObj *pDnode); int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj *pVgroup); diff --git a/source/dnode/mnode/impl/src/mndArbGroup.c b/source/dnode/mnode/impl/src/mndArbGroup.c new file mode 100644 index 0000000000..e056e698f3 --- /dev/null +++ b/source/dnode/mnode/impl/src/mndArbGroup.c @@ -0,0 +1,1096 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _DEFAULT_SOURCE +#include "mndArbGroup.h" +#include "audit.h" +#include "mndDb.h" +#include "mndDnode.h" +#include "mndPrivilege.h" +#include "mndShow.h" +#include "mndTrans.h" +#include "mndUser.h" +#include "mndVgroup.h" + +#define ARBGROUP_VER_NUMBER 1 +#define ARBGROUP_RESERVE_SIZE 64 + +static int32_t mndArbGroupActionInsert(SSdb *pSdb, SArbGroup *pGroup); +static int32_t mndArbGroupActionUpdate(SSdb *pSdb, SArbGroup *pOld, SArbGroup *pNew); +static int32_t mndArbGroupActionDelete(SSdb *pSdb, SArbGroup *pGroup); + +static void mndArbGroupDupObj(SArbGroup *pGroup, SArbGroup *pNew); +static void mndArbGroupSetAssignedLeader(SArbGroup *pGroup, int32_t index); +static void mndArbGroupResetAssignedLeader(SArbGroup *pGroup); + +static int32_t mndArbGroupUpdateTrans(SMnode *pMnode, SArbGroup *pNew); +static int32_t mndPullupArbUpdateGroup(SMnode *pMnode, SArbGroup *pNewGroup); + +static int32_t mndProcessArbHbTimer(SRpcMsg *pReq); +static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq); +static int32_t mndProcessArbUpdateGroupReq(SRpcMsg *pReq); +static int32_t mndProcessArbHbRsp(SRpcMsg *pRsp); +static int32_t mndProcessArbCheckSyncRsp(SRpcMsg *pRsp); +static int32_t mndProcessArbSetAssignedLeaderRsp(SRpcMsg *pRsp); +static int32_t mndRetrieveArbGroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); +static void mndCancelGetNextArbGroup(SMnode *pMnode, void *pIter); + +static int32_t mndArbCheckToken(const char *token1, const char *token2) { + if (token1 == NULL || token2 == NULL) return -1; + if (strlen(token1) == 0 || strlen(token2) == 0) return -1; + return strncmp(token1, token2, TSDB_ARB_TOKEN_SIZE); +} + +int32_t mndInitArbGroup(SMnode *pMnode) { + SSdbTable table = { + .sdbType = SDB_ARBGROUP, + .keyType = SDB_KEY_INT32, + .encodeFp = (SdbEncodeFp)mndArbGroupActionEncode, + .decodeFp = (SdbDecodeFp)mndArbGroupActionDecode, + .insertFp = (SdbInsertFp)mndArbGroupActionInsert, + .updateFp = (SdbUpdateFp)mndArbGroupActionUpdate, + .deleteFp = (SdbDeleteFp)mndArbGroupActionDelete, + }; + + mndSetMsgHandle(pMnode, TDMT_MND_ARB_HEARTBEAT_TIMER, mndProcessArbHbTimer); + mndSetMsgHandle(pMnode, TDMT_MND_ARB_CHECK_SYNC_TIMER, mndProcessArbCheckSyncTimer); + mndSetMsgHandle(pMnode, TDMT_MND_ARB_UPDATE_GROUP, mndProcessArbUpdateGroupReq); + mndSetMsgHandle(pMnode, TDMT_VND_ARB_HEARTBEAT_RSP, mndProcessArbHbRsp); + mndSetMsgHandle(pMnode, TDMT_VND_ARB_CHECK_SYNC_RSP, mndProcessArbCheckSyncRsp); + mndSetMsgHandle(pMnode, TDMT_SYNC_SET_ASSIGNED_LEADER_RSP, mndProcessArbSetAssignedLeaderRsp); + + mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_ARBGROUP, mndRetrieveArbGroups); + mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_ARBGROUP, mndCancelGetNextArbGroup); + + return sdbSetTable(pMnode->pSdb, table); +} + +void mndCleanupArbGroup(SMnode *pMnode) {} + +SArbGroup *mndAcquireArbGroup(SMnode *pMnode, int32_t vgId) { + SArbGroup *pGroup = sdbAcquire(pMnode->pSdb, SDB_ARBGROUP, &vgId); + if (pGroup == NULL && terrno == TSDB_CODE_SDB_OBJ_NOT_THERE) { + terrno = TSDB_CODE_MND_ARBGROUP_NOT_EXIST; + } + return pGroup; +} + +void mndReleaseArbGroup(SMnode *pMnode, SArbGroup *pGroup) { + SSdb *pSdb = pMnode->pSdb; + sdbRelease(pSdb, pGroup); +} + +void mndArbGroupInitFromVgObj(SVgObj *pVgObj, SArbGroup *outGroup) { + ASSERT(pVgObj->replica == 2); + memset(outGroup, 0, sizeof(SArbGroup)); + outGroup->dbUid = pVgObj->dbUid; + outGroup->vgId = pVgObj->vgId; + for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) { + SArbGroupMember *pMember = &outGroup->members[i]; + pMember->info.dnodeId = pVgObj->vnodeGid[i].dnodeId; + } +} + +SSdbRaw *mndArbGroupActionEncode(SArbGroup *pGroup) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + + int32_t size = sizeof(SArbGroup) + ARBGROUP_RESERVE_SIZE; + SSdbRaw *pRaw = sdbAllocRaw(SDB_ARBGROUP, ARBGROUP_VER_NUMBER, size); + if (pRaw == NULL) goto _OVER; + + int32_t dataPos = 0; + SDB_SET_INT32(pRaw, dataPos, pGroup->vgId, _OVER) + SDB_SET_INT64(pRaw, dataPos, pGroup->dbUid, _OVER) + for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) { + SArbGroupMember *pMember = &pGroup->members[i]; + SDB_SET_INT32(pRaw, dataPos, pMember->info.dnodeId, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pMember->state.token, TSDB_ARB_TOKEN_SIZE, _OVER) + } + SDB_SET_INT8(pRaw, dataPos, pGroup->isSync, _OVER) + + SArbAssignedLeader *pLeader = &pGroup->assignedLeader; + SDB_SET_INT32(pRaw, dataPos, pLeader->dnodeId, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pLeader->token, TSDB_ARB_TOKEN_SIZE, _OVER) + SDB_SET_INT64(pRaw, dataPos, pGroup->version, _OVER) + + SDB_SET_RESERVE(pRaw, dataPos, ARBGROUP_RESERVE_SIZE, _OVER) + + terrno = 0; + +_OVER: + if (terrno != 0) { + mError("arbgroup:%d, failed to encode to raw:%p since %s", pGroup->vgId, pRaw, terrstr()); + sdbFreeRaw(pRaw); + return NULL; + } + + mTrace("arbgroup:%d, encode to raw:%p, row:%p", pGroup->vgId, pRaw, pGroup); + return pRaw; +} + +SSdbRow *mndArbGroupActionDecode(SSdbRaw *pRaw) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + SSdbRow *pRow = NULL; + SArbGroup *pGroup = NULL; + + int8_t sver = 0; + if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; + + if (sver != ARBGROUP_VER_NUMBER) { + terrno = TSDB_CODE_SDB_INVALID_DATA_VER; + goto _OVER; + } + + pRow = sdbAllocRow(sizeof(SArbGroup)); + if (pRow == NULL) goto _OVER; + + pGroup = sdbGetRowObj(pRow); + if (pGroup == NULL) goto _OVER; + + int32_t dataPos = 0; + SDB_GET_INT32(pRaw, dataPos, &pGroup->vgId, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pGroup->dbUid, _OVER) + for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) { + SArbGroupMember *pMember = &pGroup->members[i]; + SDB_GET_INT32(pRaw, dataPos, &pMember->info.dnodeId, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pMember->state.token, TSDB_ARB_TOKEN_SIZE, _OVER) + + pMember->state.nextHbSeq = 0; + pMember->state.responsedHbSeq = -1; + pMember->state.lastHbMs = 0; + } + SDB_GET_INT8(pRaw, dataPos, &pGroup->isSync, _OVER) + + SArbAssignedLeader *pLeader = &pGroup->assignedLeader; + SDB_GET_INT32(pRaw, dataPos, &pLeader->dnodeId, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pLeader->token, TSDB_ARB_TOKEN_SIZE, _OVER) + SDB_GET_INT64(pRaw, dataPos, &pGroup->version, _OVER) + + pGroup->mutexInited = false; + + SDB_GET_RESERVE(pRaw, dataPos, ARBGROUP_RESERVE_SIZE, _OVER) + + terrno = 0; + +_OVER: + if (terrno != 0) { + mError("arbgroup:%d, failed to decode from raw:%p since %s", pGroup == NULL ? 0 : pGroup->vgId, pRaw, terrstr()); + taosMemoryFreeClear(pRow); + return NULL; + } + + mTrace("arbgroup:%d, decode from raw:%p, row:%p", pGroup->vgId, pRaw, pGroup); + return pRow; +} + +static int32_t mndArbGroupActionInsert(SSdb *pSdb, SArbGroup *pGroup) { + mTrace("arbgroup:%d, perform insert action, row:%p", pGroup->vgId, pGroup); + if (!pGroup->mutexInited && (taosThreadMutexInit(&pGroup->mutex, NULL) == 0)) { + pGroup->mutexInited = true; + } + + return pGroup->mutexInited ? 0 : -1; +} + +static int32_t mndArbGroupActionDelete(SSdb *pSdb, SArbGroup *pGroup) { + mTrace("arbgroup:%d, perform delete action, row:%p", pGroup->vgId, pGroup); + if (pGroup->mutexInited) { + taosThreadMutexDestroy(&pGroup->mutex); + pGroup->mutexInited = false; + } + return 0; +} + +static int32_t mndArbGroupActionUpdate(SSdb *pSdb, SArbGroup *pOld, SArbGroup *pNew) { + mTrace("arbgroup:%d, perform update action, old row:%p new row:%p", pOld->vgId, pOld, pNew); + taosThreadMutexLock(&pOld->mutex); + + if (pOld->version != pNew->version) { + mInfo("arbgroup:%d, skip to perform update action, old row:%p new row:%p, old version:%" PRId64 + " new version:%" PRId64, + pOld->vgId, pOld, pNew, pOld->version, pNew->version); + taosThreadMutexUnlock(&pOld->mutex); + return 0; + } + + for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) { + memcpy(pOld->members[i].state.token, pNew->members[i].state.token, TSDB_ARB_TOKEN_SIZE); + } + pOld->isSync = pNew->isSync; + pOld->assignedLeader.dnodeId = pNew->assignedLeader.dnodeId; + memcpy(pOld->assignedLeader.token, pNew->assignedLeader.token, TSDB_ARB_TOKEN_SIZE); + pOld->version++; + taosThreadMutexUnlock(&pOld->mutex); + return 0; +} + +int32_t mndSetCreateArbGroupRedoLogs(STrans *pTrans, SArbGroup *pGroup) { + SSdbRaw *pRedoRaw = mndArbGroupActionEncode(pGroup); + if (pRedoRaw == NULL) return -1; + if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) return -1; + if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING) != 0) return -1; + return 0; +} + +int32_t mndSetCreateArbGroupUndoLogs(STrans *pTrans, SArbGroup *pGroup) { + SSdbRaw *pUndoRaw = mndArbGroupActionEncode(pGroup); + if (pUndoRaw == NULL) return -1; + if (mndTransAppendUndolog(pTrans, pUndoRaw) != 0) return -1; + if (sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED) != 0) return -1; + return 0; +} + +int32_t mndSetCreateArbGroupCommitLogs(STrans *pTrans, SArbGroup *pGroup) { + SSdbRaw *pCommitRaw = mndArbGroupActionEncode(pGroup); + if (pCommitRaw == NULL) return -1; + if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1; + if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) return -1; + return 0; +} + +static int32_t mndSetDropArbGroupRedoLogs(STrans *pTrans, SArbGroup *pGroup) { + SSdbRaw *pRedoRaw = mndArbGroupActionEncode(pGroup); + if (pRedoRaw == NULL) return -1; + if (mndTransAppendRedolog(pTrans, pRedoRaw) != 0) return -1; + if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_DROPPING) != 0) return -1; + return 0; +} + +int32_t mndSetDropArbGroupCommitLogs(STrans *pTrans, SArbGroup *pGroup) { + SSdbRaw *pCommitRaw = mndArbGroupActionEncode(pGroup); + if (pCommitRaw == NULL) return -1; + if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1; + if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_DROPPED) != 0) return -1; + return 0; +} + +static void *mndBuildArbHeartBeatReq(int32_t *pContLen, char *arbToken, int32_t dnodeId, int64_t arbTerm, + SArray *hbMembers) { + SVArbHeartBeatReq req = {0}; + req.dnodeId = dnodeId; + req.arbToken = arbToken; + req.arbTerm = arbTerm; + req.hbMembers = hbMembers; + + int32_t contLen = tSerializeSVArbHeartBeatReq(NULL, 0, &req); + if (contLen <= 0) return NULL; + + void *pReq = rpcMallocCont(contLen); + if (pReq == NULL) return NULL; + + if (tSerializeSVArbHeartBeatReq(pReq, contLen, &req) <= 0) { + rpcFreeCont(pReq); + return NULL; + } + *pContLen = contLen; + return pReq; +} + +static int32_t mndSendArbHeartBeatReq(SDnodeObj *pDnode, char *arbToken, int64_t arbTerm, SArray *hbMembers) { + int32_t contLen = 0; + void *pHead = mndBuildArbHeartBeatReq(&contLen, arbToken, pDnode->id, arbTerm, hbMembers); + if (pHead == NULL) { + mError("dnodeId:%d, failed to build arb-hb request", pDnode->id); + return -1; + } + SRpcMsg rpcMsg = {.msgType = TDMT_VND_ARB_HEARTBEAT, .pCont = pHead, .contLen = contLen}; + + SEpSet epSet = mndGetDnodeEpset(pDnode); + if (epSet.numOfEps == 0) { + mError("dnodeId:%d, failed to send arb-hb request to dnode since no epSet found", pDnode->id); + rpcFreeCont(pHead); + return -1; + } + + int32_t code = tmsgSendReq(&epSet, &rpcMsg); + if (code != 0) { + mError("dnodeId:%d, failed to send arb-hb request to dnode since 0x%x", pDnode->id, code); + } else { + mTrace("dnodeId:%d, send arb-hb request to dnode", pDnode->id); + } + return code; +} + +static int32_t mndProcessArbHbTimer(SRpcMsg *pReq) { + SMnode *pMnode = pReq->info.node; + SSdb *pSdb = pMnode->pSdb; + SArbGroup *pArbGroup = NULL; + void *pIter = NULL; + + SHashObj *pDnodeHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + + // collect member of same dnode + while (1) { + pIter = sdbFetch(pSdb, SDB_ARBGROUP, pIter, (void **)&pArbGroup); + if (pIter == NULL) break; + + taosThreadMutexLock(&pArbGroup->mutex); + + for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) { + SArbGroupMember *pMember = &pArbGroup->members[i]; + int32_t dnodeId = pMember->info.dnodeId; + void *pObj = taosHashGet(pDnodeHash, &dnodeId, sizeof(int32_t)); + SArray *hbMembers = NULL; + if (pObj) { + hbMembers = *(SArray **)pObj; + } else { + hbMembers = taosArrayInit(16, sizeof(SVArbHbReqMember)); + taosHashPut(pDnodeHash, &dnodeId, sizeof(int32_t), &hbMembers, POINTER_BYTES); + } + SVArbHbReqMember reqMember = {.vgId = pArbGroup->vgId, .hbSeq = pMember->state.nextHbSeq++}; + taosArrayPush(hbMembers, &reqMember); + } + + taosThreadMutexUnlock(&pArbGroup->mutex); + sdbRelease(pSdb, pArbGroup); + } + + char arbToken[TSDB_ARB_TOKEN_SIZE]; + if (mndGetArbToken(pMnode, arbToken) != 0) { + mError("failed to get arb token for arb-hb timer"); + pIter = taosHashIterate(pDnodeHash, NULL); + while (pIter) { + SArray *hbMembers = *(SArray **)pIter; + taosArrayDestroy(hbMembers); + pIter = taosHashIterate(pDnodeHash, pIter); + } + taosHashCleanup(pDnodeHash); + return -1; + } + + int64_t nowMs = taosGetTimestampMs(); + + pIter = NULL; + while (1) { + pIter = taosHashIterate(pDnodeHash, pIter); + if (pIter == NULL) break; + + int32_t dnodeId = *(int32_t *)taosHashGetKey(pIter, NULL); + SArray *hbMembers = *(SArray **)pIter; + + SDnodeObj *pDnode = mndAcquireDnode(pMnode, dnodeId); + if (pDnode == NULL) { + mError("dnodeId:%d, timer failed to send arb-hb request, failed find dnode", dnodeId); + taosArrayDestroy(hbMembers); + continue; + } + + int64_t mndTerm = mndGetTerm(pMnode); + + if (mndIsDnodeOnline(pDnode, nowMs)) { + (void)mndSendArbHeartBeatReq(pDnode, arbToken, mndTerm, hbMembers); + } + + mndReleaseDnode(pMnode, pDnode); + taosArrayDestroy(hbMembers); + } + taosHashCleanup(pDnodeHash); + + return 0; +} + +static void *mndBuildArbCheckSyncReq(int32_t *pContLen, int32_t vgId, char *arbToken, int64_t arbTerm, + char *member0Token, char *member1Token) { + SVArbCheckSyncReq req = {0}; + req.arbToken = arbToken; + req.arbTerm = arbTerm; + req.member0Token = member0Token; + req.member1Token = member1Token; + + int32_t reqLen = tSerializeSVArbCheckSyncReq(NULL, 0, &req); + int32_t contLen = reqLen + sizeof(SMsgHead); + + if (contLen <= 0) return NULL; + SMsgHead *pHead = rpcMallocCont(contLen); + if (pHead == NULL) return NULL; + + pHead->contLen = htonl(contLen); + pHead->vgId = htonl(vgId); + if (tSerializeSVArbCheckSyncReq((char *)pHead + sizeof(SMsgHead), contLen, &req) <= 0) { + rpcFreeCont(pHead); + return NULL; + } + *pContLen = contLen; + return pHead; +} + +static int32_t mndSendArbCheckSyncReq(SMnode *pMnode, int32_t vgId, char *arbToken, int64_t term, char *member0Token, + char *member1Token) { + int32_t contLen = 0; + void *pHead = mndBuildArbCheckSyncReq(&contLen, vgId, arbToken, term, member0Token, member1Token); + if (!pHead) { + mError("vgId:%d, failed to build check-sync request", vgId); + return -1; + } + SRpcMsg rpcMsg = {.msgType = TDMT_VND_ARB_CHECK_SYNC, .pCont = pHead, .contLen = contLen}; + + SEpSet epSet = mndGetVgroupEpsetById(pMnode, vgId); + if (epSet.numOfEps == 0) { + mError("vgId:%d, failed to send check-sync request since no epSet found", vgId); + rpcFreeCont(pHead); + return -1; + } + + int32_t code = tmsgSendReq(&epSet, &rpcMsg); + if (code != 0) { + mError("vgId:%d, failed to send check-sync request since 0x%x", vgId, code); + } else { + mDebug("vgId:%d, send check-sync request", vgId); + } + return code; +} + +static bool mndCheckArbMemberHbTimeout(SArbGroup *pArbGroup, int32_t index, int64_t nowMs) { + SArbGroupMember *pArbMember = &pArbGroup->members[index]; + return pArbMember->state.lastHbMs < (nowMs - tsArbSetAssignedTimeoutSec * 1000); +} + +static void *mndBuildArbSetAssignedLeaderReq(int32_t *pContLen, int32_t vgId, char *arbToken, int64_t arbTerm, + char *memberToken) { + SVArbSetAssignedLeaderReq req = {0}; + req.arbToken = arbToken; + req.arbTerm = arbTerm; + req.memberToken = memberToken; + + int32_t reqLen = tSerializeSVArbSetAssignedLeaderReq(NULL, 0, &req); + int32_t contLen = reqLen + sizeof(SMsgHead); + + if (contLen <= 0) return NULL; + SMsgHead *pHead = rpcMallocCont(contLen); + if (pHead == NULL) return NULL; + + pHead->contLen = htonl(contLen); + pHead->vgId = htonl(vgId); + if (tSerializeSVArbSetAssignedLeaderReq((char *)pHead + sizeof(SMsgHead), contLen, &req) <= 0) { + rpcFreeCont(pHead); + return NULL; + } + *pContLen = contLen; + return pHead; +} + +static int32_t mndSendArbSetAssignedLeaderReq(SMnode *pMnode, int32_t dnodeId, int32_t vgId, char *arbToken, + int64_t term, char *memberToken) { + int32_t contLen = 0; + void *pHead = mndBuildArbSetAssignedLeaderReq(&contLen, vgId, arbToken, term, memberToken); + if (!pHead) { + mError("vgId:%d, failed to build set-assigned request", vgId); + return -1; + } + SRpcMsg rpcMsg = {.msgType = TDMT_SYNC_SET_ASSIGNED_LEADER, .pCont = pHead, .contLen = contLen}; + + SEpSet epSet = mndGetDnodeEpsetById(pMnode, dnodeId); + if (epSet.numOfEps == 0) { + mError("dnodeId:%d vgId:%d, failed to send arb-set-assigned request to dnode since no epSet found", dnodeId, vgId); + rpcFreeCont(pHead); + return -1; + } + int32_t code = tmsgSendReq(&epSet, &rpcMsg); + if (code != 0) { + mError("dnodeId:%d vgId:%d, failed to send arb-set-assigned request to dnode since 0x%x", dnodeId, vgId, code); + } else { + mInfo("dnodeId:%d vgId:%d, send arb-set-assigned request to dnode", dnodeId, vgId); + } + return code; +} + +static int32_t mndProcessArbCheckSyncTimer(SRpcMsg *pReq) { + SMnode *pMnode = pReq->info.node; + SSdb *pSdb = pMnode->pSdb; + SArbGroup *pArbGroup = NULL; + SArbGroup arbGroupDup = {0}; + void *pIter = NULL; + + char arbToken[TSDB_ARB_TOKEN_SIZE]; + if (mndGetArbToken(pMnode, arbToken) != 0) { + mError("failed to get arb token for arb-check-sync timer"); + return -1; + } + int64_t term = mndGetTerm(pMnode); + if (term < 0) { + mError("arb failed to get term since %s", terrstr()); + return -1; + } + + while (1) { + pIter = sdbFetch(pSdb, SDB_ARBGROUP, pIter, (void **)&pArbGroup); + if (pIter == NULL) break; + + taosThreadMutexLock(&pArbGroup->mutex); + mndArbGroupDupObj(pArbGroup, &arbGroupDup); + taosThreadMutexUnlock(&pArbGroup->mutex); + + int32_t vgId = arbGroupDup.vgId; + int64_t nowMs = taosGetTimestampMs(); + + bool member0IsTimeout = mndCheckArbMemberHbTimeout(&arbGroupDup, 0, nowMs); + bool member1IsTimeout = mndCheckArbMemberHbTimeout(&arbGroupDup, 1, nowMs); + SArbAssignedLeader* pAssignedLeader = &arbGroupDup.assignedLeader; + int32_t currentAssignedDnodeId = pAssignedLeader->dnodeId; + + // 1. has assigned && is sync => send req + if (currentAssignedDnodeId != 0 && arbGroupDup.isSync == true) { + (void)mndSendArbSetAssignedLeaderReq(pMnode, currentAssignedDnodeId, vgId, arbToken, term, + pAssignedLeader->token); + mInfo("vgId:%d, arb send set assigned leader to dnodeId:%d", vgId, currentAssignedDnodeId); + sdbRelease(pSdb, pArbGroup); + continue; + } + + // 2. both of the two members are timeout => skip + if (member0IsTimeout && member1IsTimeout) { + sdbRelease(pSdb, pArbGroup); + continue; + } + + // 3. no member is timeout => check sync + if (member0IsTimeout == false && member1IsTimeout == false) { + // no assigned leader and not sync + if (currentAssignedDnodeId == 0 && !arbGroupDup.isSync) { + (void)mndSendArbCheckSyncReq(pMnode, arbGroupDup.vgId, arbToken, term, arbGroupDup.members[0].state.token, + arbGroupDup.members[1].state.token); + } + sdbRelease(pSdb, pArbGroup); + continue; + } + + // 4. one of the members is timeout => set assigned leader + int32_t candidateIndex = member0IsTimeout ? 1 : 0; + SArbGroupMember *pMember = &arbGroupDup.members[candidateIndex]; + + // has assigned leader and dnodeId not match => skip + if (currentAssignedDnodeId != 0 && currentAssignedDnodeId != pMember->info.dnodeId) { + mInfo("arb skip to set assigned leader to vgId:%d dnodeId:%d, assigned leader has been set to dnodeId:%d", vgId, + pMember->info.dnodeId, currentAssignedDnodeId); + sdbRelease(pSdb, pArbGroup); + continue; + } + + // not sync => skip + if (arbGroupDup.isSync == false) { + if (currentAssignedDnodeId == pMember->info.dnodeId) { + mDebug("arb skip to set assigned leader to vgId:%d dnodeId:%d, arb group is not sync", vgId, + pMember->info.dnodeId); + } else { + mInfo("arb skip to set assigned leader to vgId:%d dnodeId:%d, arb group is not sync", vgId, + pMember->info.dnodeId); + } + sdbRelease(pSdb, pArbGroup); + continue; + } + + // is sync && no assigned leader => write to sdb + SArbGroup newGroup = {0}; + mndArbGroupDupObj(&arbGroupDup, &newGroup); + mndArbGroupSetAssignedLeader(&newGroup, candidateIndex); + if (mndPullupArbUpdateGroup(pMnode, &newGroup) != 0) { + mError("vgId:%d, arb failed to pullup set assigned leader to dnodeId:%d, since %s", vgId, pMember->info.dnodeId, + terrstr()); + sdbRelease(pSdb, pArbGroup); + return -1; + } + + mInfo("vgId:%d, arb pull up set assigned leader to dnodeId:%d", vgId, pMember->info.dnodeId); + + sdbRelease(pSdb, pArbGroup); + } + + return 0; +} + +static void *mndBuildArbUpdateGroupReq(int32_t *pContLen, SArbGroup *pNewGroup) { + SMArbUpdateGroupReq req = {0}; + req.vgId = pNewGroup->vgId; + req.dbUid = pNewGroup->dbUid; + for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) { + req.members[i].dnodeId = pNewGroup->members[i].info.dnodeId; + req.members[i].token = pNewGroup->members[i].state.token; + } + req.isSync = pNewGroup->isSync; + req.assignedLeader.dnodeId = pNewGroup->assignedLeader.dnodeId; + req.assignedLeader.token = pNewGroup->assignedLeader.token; + req.version = pNewGroup->version; + + int32_t contLen = tSerializeSMArbUpdateGroupReq(NULL, 0, &req); + if (contLen <= 0) return NULL; + SMsgHead *pHead = rpcMallocCont(contLen); + if (pHead == NULL) return NULL; + + if (tSerializeSMArbUpdateGroupReq(pHead, contLen, &req) <= 0) { + rpcFreeCont(pHead); + return NULL; + } + *pContLen = contLen; + return pHead; +} + +static int32_t mndPullupArbUpdateGroup(SMnode *pMnode, SArbGroup *pNewGroup) { + int32_t contLen = 0; + void *pHead = mndBuildArbUpdateGroupReq(&contLen, pNewGroup); + if (!pHead) { + mError("vgId:%d, failed to build arb-update-group request", pNewGroup->vgId); + return -1; + } + SRpcMsg rpcMsg = {.msgType = TDMT_MND_ARB_UPDATE_GROUP, .pCont = pHead, .contLen = contLen, .info.noResp = true}; + + return tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); +} + +static int32_t mndProcessArbUpdateGroupReq(SRpcMsg *pReq) { + int ret = 0; + + SMArbUpdateGroupReq req = {0}; + tDeserializeSMArbUpdateGroupReq(pReq->pCont, pReq->contLen, &req); + + SArbGroup newGroup = {0}; + newGroup.vgId = req.vgId; + newGroup.dbUid = req.dbUid; + for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) { + newGroup.members[i].info.dnodeId = req.members[i].dnodeId; + memcpy(newGroup.members[i].state.token, req.members[i].token, TSDB_ARB_TOKEN_SIZE); + } + + newGroup.isSync = req.isSync; + newGroup.assignedLeader.dnodeId = req.assignedLeader.dnodeId; + memcpy(newGroup.assignedLeader.token, req.assignedLeader.token, TSDB_ARB_TOKEN_SIZE); + newGroup.version = req.version; + + SMnode *pMnode = pReq->info.node; + if (mndArbGroupUpdateTrans(pMnode, &newGroup) != 0) { + mError("vgId:%d, arb failed to update arbgroup, since %s", req.vgId, terrstr()); + ret = -1; + } + + tFreeSMArbUpdateGroupReq(&req); + return ret; +} + +static void mndArbGroupDupObj(SArbGroup *pGroup, SArbGroup *pNew) { + memcpy(pNew, pGroup, offsetof(SArbGroup, mutexInited)); +} + +static void mndArbGroupSetAssignedLeader(SArbGroup *pGroup, int32_t index) { + SArbGroupMember *pMember = &pGroup->members[index]; + + pGroup->assignedLeader.dnodeId = pMember->info.dnodeId; + strncpy(pGroup->assignedLeader.token, pMember->state.token, TSDB_ARB_TOKEN_SIZE); +} + +static void mndArbGroupResetAssignedLeader(SArbGroup *pGroup) { + pGroup->assignedLeader.dnodeId = 0; + memset(pGroup->assignedLeader.token, 0, TSDB_ARB_TOKEN_SIZE); +} + +static int32_t mndArbGroupUpdateTrans(SMnode *pMnode, SArbGroup *pNew) { + int32_t ret = -1; + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_ARBGROUP, NULL, "update-arbgroup"); + if (pTrans == NULL) { + mError("failed to update arbgroup in create trans, vgId:%d, since %s", pNew->vgId, terrstr()); + goto _OVER; + } + + mInfo("trans:%d, used to update arbgroup:%d, member0:[%d][%s] member1:[%d][%s] isSync:%d assigned:[%d][%s]", + pTrans->id, pNew->vgId, pNew->members[0].info.dnodeId, pNew->members[0].state.token, + pNew->members[1].info.dnodeId, pNew->members[1].state.token, pNew->isSync, pNew->assignedLeader.dnodeId, + pNew->assignedLeader.token); + + mndTransSetArbGroupId(pTrans, pNew->vgId); + if (mndTransCheckConflict(pMnode, pTrans) != 0) { + ret = -1; + goto _OVER; + } + + if (mndSetCreateArbGroupCommitLogs(pTrans, pNew) != 0) { + mError("failed to update arbgroup in set commit log, vgId:%d, since %s", pNew->vgId, terrstr()); + goto _OVER; + } + + if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; + + ret = 0; + +_OVER: + mndTransDrop(pTrans); + return ret; +} + +bool mndUpdateArbGroupByHeartBeat(SArbGroup *pGroup, SVArbHbRspMember *pRspMember, int64_t nowMs, int32_t dnodeId, + SArbGroup *pNewGroup) { + bool updateToken = false; + SArbGroupMember *pMember = NULL; + + taosThreadMutexLock(&pGroup->mutex); + + int index = 0; + for (; index < TSDB_ARB_GROUP_MEMBER_NUM; index++) { + pMember = &pGroup->members[index]; + if (pMember->info.dnodeId == dnodeId) { + break; + } + pMember = NULL; + } + + if (pMember == NULL) { + mInfo("dnodeId:%d vgId:%d, arb token update check failed, no obj found", dnodeId, pRspMember->vgId); + goto _OVER; + } + + if (pMember->state.responsedHbSeq >= pRspMember->hbSeq) { + // skip + mInfo("dnodeId:%d vgId:%d, skip arb token update, heart beat seq expired, local:%d msg:%d", dnodeId, + pRspMember->vgId, pMember->state.responsedHbSeq, pRspMember->hbSeq); + goto _OVER; + } + + // update hb state + pMember->state.responsedHbSeq = pRspMember->hbSeq; + pMember->state.lastHbMs = nowMs; + if (mndArbCheckToken(pMember->state.token, pRspMember->memberToken) == 0) { + // skip + mDebug("dnodeId:%d vgId:%d, skip arb token update, token matched", dnodeId, pRspMember->vgId); + goto _OVER; + } + + // update token + mndArbGroupDupObj(pGroup, pNewGroup); + memcpy(pNewGroup->members[index].state.token, pRspMember->memberToken, TSDB_ARB_TOKEN_SIZE); + pNewGroup->isSync = false; + + bool resetAssigned = false; + if (pMember->info.dnodeId == pGroup->assignedLeader.dnodeId) { + mndArbGroupResetAssignedLeader(pNewGroup); + resetAssigned = true; + } + + updateToken = true; + mInfo("dnodeId:%d vgId:%d, arb token updating, resetAssigned:%d", dnodeId, pRspMember->vgId, resetAssigned); + +_OVER: + taosThreadMutexUnlock(&pGroup->mutex); + return updateToken; +} + +static int32_t mndUpdateArbHeartBeat(SMnode *pMnode, int32_t dnodeId, SArray *memberArray) { + int ret = 0; + int64_t nowMs = taosGetTimestampMs(); + + size_t size = taosArrayGetSize(memberArray); + for (size_t i = 0; i < size; i++) { + SVArbHbRspMember *pRspMember = taosArrayGet(memberArray, i); + + SArbGroup newGroup = {0}; + SArbGroup *pGroup = sdbAcquire(pMnode->pSdb, SDB_ARBGROUP, &pRspMember->vgId); + if (pGroup == NULL) { + mInfo("failed to update arb token, vgId:%d not found", pRspMember->vgId); + continue; + } + + bool updateToken = mndUpdateArbGroupByHeartBeat(pGroup, pRspMember, nowMs, dnodeId, &newGroup); + if (updateToken) { + ret = mndPullupArbUpdateGroup(pMnode, &newGroup); + if (ret != 0) { + mInfo("failed to pullup update arb token, vgId:%d, since %s", pRspMember->vgId, terrstr()); + } + } + + sdbRelease(pMnode->pSdb, pGroup); + if (ret != 0) break; + } + + return ret; +} + +bool mndUpdateArbGroupByCheckSync(SArbGroup *pGroup, int32_t vgId, char *member0Token, char *member1Token, + bool newIsSync, SArbGroup *pNewGroup) { + bool updateIsSync = false; + + taosThreadMutexLock(&pGroup->mutex); + + if (pGroup->assignedLeader.dnodeId != 0) { + terrno = TSDB_CODE_SUCCESS; + mInfo("skip to update arb sync, vgId:%d has assigned leader:%d", vgId, pGroup->assignedLeader.dnodeId); + goto _OVER; + } + + char *local0Token = pGroup->members[0].state.token; + char *local1Token = pGroup->members[1].state.token; + if (mndArbCheckToken(local0Token, member0Token) != 0 || mndArbCheckToken(local1Token, member1Token) != 0) { + terrno = TSDB_CODE_MND_ARB_TOKEN_MISMATCH; + mInfo("skip to update arb sync, memberToken mismatch local:[%s][%s], msg:[%s][%s]", local0Token, local1Token, + member0Token, member1Token); + goto _OVER; + } + + if (pGroup->isSync != newIsSync) { + mndArbGroupDupObj(pGroup, pNewGroup); + pNewGroup->isSync = newIsSync; + + mInfo("vgId:%d, arb isSync updating, new isSync:%d", vgId, newIsSync); + updateIsSync = true; + } + +_OVER: + taosThreadMutexUnlock(&pGroup->mutex); + return updateIsSync; +} + +static int32_t mndUpdateArbSync(SMnode *pMnode, int32_t vgId, char *member0Token, char *member1Token, bool newIsSync) { + SArbGroup *pGroup = sdbAcquire(pMnode->pSdb, SDB_ARBGROUP, &vgId); + if (pGroup == NULL) { + terrno = TSDB_CODE_NOT_FOUND; + mInfo("failed to update arb sync, vgId:%d not found", vgId); + return -1; + } + + SArbGroup newGroup = {0}; + bool updateIsSync = mndUpdateArbGroupByCheckSync(pGroup, vgId, member0Token, member1Token, newIsSync, &newGroup); + if (updateIsSync) { + if (mndPullupArbUpdateGroup(pMnode, &newGroup) != 0) { + mInfo("failed to pullup update arb sync, vgId:%d, since %s", vgId, terrstr()); + } + } + + sdbRelease(pMnode->pSdb, pGroup); + return 0; +} + +static int32_t mndProcessArbHbRsp(SRpcMsg *pRsp) { + int32_t ret = -1; + + SMnode *pMnode = pRsp->info.node; + SSdb *pSdb = pMnode->pSdb; + + char arbToken[TSDB_ARB_TOKEN_SIZE]; + if (mndGetArbToken(pMnode, arbToken) != 0) { + mError("failed to get arb token for arb-hb response"); + terrno = TSDB_CODE_NOT_FOUND; + return -1; + } + + SVArbHeartBeatRsp arbHbRsp = {0}; + if (tDeserializeSVArbHeartBeatRsp(pRsp->pCont, pRsp->contLen, &arbHbRsp) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + if (mndArbCheckToken(arbToken, arbHbRsp.arbToken) != 0) { + mInfo("arb hearbeat skip update for dnodeId:%d, arb token mismatch, local:[%s] msg:[%s]", arbHbRsp.dnodeId, + arbToken, arbHbRsp.arbToken); + terrno = TSDB_CODE_MND_ARB_TOKEN_MISMATCH; + goto _OVER; + } + + (void)mndUpdateArbHeartBeat(pMnode, arbHbRsp.dnodeId, arbHbRsp.hbMembers); + ret = 0; + +_OVER: + tFreeSVArbHeartBeatRsp(&arbHbRsp); + return ret; +} + +static int32_t mndProcessArbCheckSyncRsp(SRpcMsg *pRsp) { + int32_t ret = -1; + + SMnode *pMnode = pRsp->info.node; + SSdb *pSdb = pMnode->pSdb; + + char arbToken[TSDB_ARB_TOKEN_SIZE]; + if (mndGetArbToken(pMnode, arbToken) != 0) { + mError("failed to get arb token for arb-check-sync response"); + terrno = TSDB_CODE_NOT_FOUND; + return -1; + } + + SVArbCheckSyncRsp syncRsp = {0}; + if (tDeserializeSVArbCheckSyncRsp(pRsp->pCont, pRsp->contLen, &syncRsp) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + mInfo("arb sync check failed, since:%s", tstrerror(pRsp->code)); + return -1; + } + + if (mndArbCheckToken(arbToken, syncRsp.arbToken) != 0) { + mInfo("skip update arb sync for vgId:%d, arb token mismatch, local:[%s] msg:[%s]", syncRsp.vgId, arbToken, + syncRsp.arbToken); + terrno = TSDB_CODE_MND_ARB_TOKEN_MISMATCH; + goto _OVER; + } + + bool newIsSync = (syncRsp.errCode == TSDB_CODE_SUCCESS); + if (mndUpdateArbSync(pMnode, syncRsp.vgId, syncRsp.member0Token, syncRsp.member1Token, newIsSync) != 0) { + mInfo("failed to update arb sync for vgId:%d, since:%s", syncRsp.vgId, terrstr()); + goto _OVER; + } + + ret = 0; + +_OVER: + tFreeSVArbCheckSyncRsp(&syncRsp); + return ret; +} + +bool mndUpdateArbGroupBySetAssignedLeader(SArbGroup *pGroup, int32_t vgId, char *memberToken, int32_t errcode, + SArbGroup *pNewGroup) { + bool updateAssigned = false; + + taosThreadMutexLock(&pGroup->mutex); + if (mndArbCheckToken(pGroup->assignedLeader.token, memberToken) != 0) { + mInfo("skip update arb assigned for vgId:%d, member token mismatch, local:[%s] msg:[%s]", vgId, + pGroup->assignedLeader.token, memberToken); + goto _OVER; + } + + if (errcode != TSDB_CODE_SUCCESS) { + mInfo("skip update arb assigned for vgId:%d, since:%s", vgId, tstrerror(errcode)); + goto _OVER; + } + + if (pGroup->isSync) { + mndArbGroupDupObj(pGroup, pNewGroup); + pNewGroup->isSync = false; + + mInfo("vgId:%d, arb isSync is setting to false", vgId); + updateAssigned = true; + goto _OVER; + } + +_OVER: + taosThreadMutexUnlock(&pGroup->mutex); + return updateAssigned; +} + +static int32_t mndProcessArbSetAssignedLeaderRsp(SRpcMsg *pRsp) { + int32_t ret = -1; + + SMnode *pMnode = pRsp->info.node; + SSdb *pSdb = pMnode->pSdb; + + char arbToken[TSDB_ARB_TOKEN_SIZE]; + if (mndGetArbToken(pMnode, arbToken) != 0) { + mError("failed to get arb token for arb-set-assigned response"); + terrno = TSDB_CODE_NOT_FOUND; + return -1; + } + + SVArbSetAssignedLeaderRsp setAssignedRsp = {0}; + if (tDeserializeSVArbSetAssignedLeaderRsp(pRsp->pCont, pRsp->contLen, &setAssignedRsp) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + mInfo("arb set assigned failed, des failed since:%s", tstrerror(pRsp->code)); + return -1; + } + + if (mndArbCheckToken(arbToken, setAssignedRsp.arbToken) != 0) { + mInfo("skip update arb assigned for vgId:%d, arb token mismatch, local:[%s] msg:[%s]", setAssignedRsp.vgId, + arbToken, setAssignedRsp.arbToken); + terrno = TSDB_CODE_MND_ARB_TOKEN_MISMATCH; + goto _OVER; + } + + SArbGroup *pGroup = mndAcquireArbGroup(pMnode, setAssignedRsp.vgId); + if (!pGroup) { + mError("failed to set arb assigned for vgId:%d, since:%s", setAssignedRsp.vgId, terrstr()); + goto _OVER; + } + + SArbGroup newGroup = {0}; + bool updateAssigned = mndUpdateArbGroupBySetAssignedLeader(pGroup, setAssignedRsp.vgId, setAssignedRsp.memberToken, + pRsp->code, &newGroup); + if (updateAssigned) { + if (mndPullupArbUpdateGroup(pMnode, &newGroup) != 0) { + mInfo("failed to pullup update arb assigned for vgId:%d, since:%s", setAssignedRsp.vgId, terrstr()); + goto _OVER; + } + } + + ret = 0; + +_OVER: + tFreeSVArbSetAssignedLeaderRsp(&setAssignedRsp); + return ret; +} + +static int32_t mndRetrieveArbGroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { + SMnode *pMnode = pReq->info.node; + SSdb *pSdb = pMnode->pSdb; + int32_t numOfRows = 0; + int32_t cols = 0; + SArbGroup *pGroup = NULL; + + while (numOfRows < rows) { + pShow->pIter = sdbFetch(pSdb, SDB_ARBGROUP, pShow->pIter, (void **)&pGroup); + if (pShow->pIter == NULL) break; + + taosThreadMutexLock(&pGroup->mutex); + + cols = 0; + SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + SVgObj *pVgObj = sdbAcquire(pSdb, SDB_VGROUP, &pGroup->vgId); + if (!pVgObj) { + taosThreadMutexUnlock(&pGroup->mutex); + sdbRelease(pSdb, pGroup); + continue; + } + char dbname[TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(dbname, mndGetDbStr(pVgObj->dbName), TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE); + colDataSetVal(pColInfo, numOfRows, (const char *)dbname, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->vgId, false); + + for (int i = 0; i < TSDB_ARB_GROUP_MEMBER_NUM; i++) { + SArbGroupMember *pMember = &pGroup->members[i]; + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)&pMember->info.dnodeId, false); + } + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->isSync, false); + + if (pGroup->assignedLeader.dnodeId != 0) { + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)&pGroup->assignedLeader.dnodeId, false); + + char token[TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE] = {0}; + STR_WITH_MAXSIZE_TO_VARSTR(token, pGroup->assignedLeader.token, TSDB_ARB_TOKEN_SIZE + VARSTR_HEADER_SIZE); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)token, false); + } else { + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetNULL(pColInfo, numOfRows); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetNULL(pColInfo, numOfRows); + } + + taosThreadMutexUnlock(&pGroup->mutex); + + numOfRows++; + sdbRelease(pSdb, pVgObj); + sdbRelease(pSdb, pGroup); + } + + pShow->numOfRows += numOfRows; + + return numOfRows; +} + +static void mndCancelGetNextArbGroup(SMnode *pMnode, void *pIter) { + SSdb *pSdb = pMnode->pSdb; + sdbCancelFetch(pSdb, pIter); +} + +int32_t mndGetArbGroupSize(SMnode *pMnode) { + SSdb *pSdb = pMnode->pSdb; + return sdbGetSize(pSdb, SDB_ARBGROUP); +} diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index f60d8035e3..52671f6b66 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -68,25 +68,27 @@ int32_t mndInitConsumer(SMnode *pMnode) { void mndCleanupConsumer(SMnode *pMnode) {} -void mndDropConsumerFromSdb(SMnode *pMnode, int64_t consumerId, SRpcHandleInfo *info) { - SMqConsumerClearMsg *pClearMsg = rpcMallocCont(sizeof(SMqConsumerClearMsg)); - if (pClearMsg == NULL) { +void mndSendConsumerMsg(SMnode *pMnode, int64_t consumerId, uint16_t msgType, SRpcHandleInfo *info) { + void *msg = rpcMallocCont(sizeof(int64_t)); + if (msg == NULL) { mError("consumer:0x%" PRIx64 " failed to clear consumer due to out of memory. alloc size:%d", consumerId, - (int32_t)sizeof(SMqConsumerClearMsg)); + (int32_t)sizeof(int64_t)); return; } - pClearMsg->consumerId = consumerId; + *(int64_t*)msg = consumerId; SRpcMsg rpcMsg = { - .msgType = TDMT_MND_TMQ_LOST_CONSUMER_CLEAR, - .pCont = pClearMsg, - .contLen = sizeof(SMqConsumerClearMsg), + .msgType = msgType, + .pCont = msg, + .contLen = sizeof(int64_t), .info = *info, }; - mInfo("consumer:0x%" PRIx64 " drop from sdb", consumerId); - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); - return; + mInfo("mndSendConsumerMsg type:%d consumer:0x%" PRIx64, msgType, consumerId); + int32_t code = tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + if (code != 0){ + mError("consumer:%"PRId64" send consumer msg:%d error:%d", consumerId, msgType, code); + } } static int32_t validateTopics(STrans *pTrans, const SArray *pTopicList, SMnode *pMnode, const char *pUser, @@ -148,54 +150,62 @@ FAILED: } static int32_t mndProcessConsumerRecoverMsg(SRpcMsg *pMsg) { + int32_t code = 0; SMnode *pMnode = pMsg->info.node; SMqConsumerRecoverMsg *pRecoverMsg = pMsg->pCont; + SMqConsumerObj *pConsumerNew = NULL; + STrans *pTrans = NULL; SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, pRecoverMsg->consumerId); if (pConsumer == NULL) { mError("cannot find consumer %" PRId64 " when processing consumer recover msg", pRecoverMsg->consumerId); - return -1; + code = -1; + goto END; } mInfo("receive consumer recover msg, consumer:0x%" PRIx64 " status:%d(%s)", pRecoverMsg->consumerId, pConsumer->status, mndConsumerStatusName(pConsumer->status)); if (pConsumer->status != MQ_CONSUMER_STATUS_LOST) { - mndReleaseConsumer(pMnode, pConsumer); terrno = TSDB_CODE_MND_CONSUMER_NOT_READY; - return -1; + code = -1; + goto END; } - SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(pConsumer->consumerId, pConsumer->cgroup); - pConsumerNew->updateType = CONSUMER_UPDATE_REC; + pConsumerNew = tNewSMqConsumerObj(pConsumer->consumerId, pConsumer->cgroup, CONSUMER_UPDATE_REC, NULL, NULL); + if (pConsumerNew == NULL){ + code = -1; + goto END; + } - mndReleaseConsumer(pMnode, pConsumer); - - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_TOPIC, pMsg, "recover-csm"); + pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_TOPIC, pMsg, "recover-csm"); if (pTrans == NULL) { - goto FAIL; + code = -1; + goto END; } - if (validateTopics(pTrans, pConsumer->assignedTopics, pMnode, pMsg->info.conn.user, false) != 0) { - goto FAIL; + code = validateTopics(pTrans, pConsumer->assignedTopics, pMnode, pMsg->info.conn.user, false); + if (code != 0) { + goto END; } - if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) goto FAIL; - if (mndTransPrepare(pMnode, pTrans) != 0) goto FAIL; - - tDeleteSMqConsumerObj(pConsumerNew, true); + code = mndSetConsumerCommitLogs(pTrans, pConsumerNew); + if (code != 0) { + goto END; + } + code = mndTransPrepare(pMnode, pTrans); +END: + mndReleaseConsumer(pMnode, pConsumer); + tDeleteSMqConsumerObj(pConsumerNew); mndTransDrop(pTrans); - return 0; -FAIL: - tDeleteSMqConsumerObj(pConsumerNew, true); - - mndTransDrop(pTrans); - return -1; + return code; } -// todo check the clear process static int32_t mndProcessConsumerClearMsg(SRpcMsg *pMsg) { + int32_t code = 0; SMnode *pMnode = pMsg->info.node; SMqConsumerClearMsg *pClearMsg = pMsg->pCont; + SMqConsumerObj *pConsumerNew = NULL; + STrans *pTrans = NULL; SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, pClearMsg->consumerId); if (pConsumer == NULL) { @@ -206,33 +216,37 @@ static int32_t mndProcessConsumerClearMsg(SRpcMsg *pMsg) { mInfo("consumer:0x%" PRIx64 " needs to be cleared, status %s", pClearMsg->consumerId, mndConsumerStatusName(pConsumer->status)); - SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(pConsumer->consumerId, pConsumer->cgroup); + pConsumerNew = tNewSMqConsumerObj(pConsumer->consumerId, pConsumer->cgroup, -1, NULL, NULL); + if (pConsumerNew == NULL){ + code = -1; + goto END; + } - mndReleaseConsumer(pMnode, pConsumer); + pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pMsg, "clear-csm"); + if (pTrans == NULL) { + code = -1; + goto END; + } - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pMsg, "clear-csm"); - if (pTrans == NULL) goto FAIL; // this is the drop action, not the update action - if (mndSetConsumerDropLogs(pMnode, pTrans, pConsumerNew) != 0) goto FAIL; - if (mndTransPrepare(pMnode, pTrans) != 0) goto FAIL; + code = mndSetConsumerDropLogs(pTrans, pConsumerNew); + if (code != 0) { + goto END; + } - tDeleteSMqConsumerObj(pConsumerNew, true); + code = mndTransPrepare(pMnode, pTrans); +END: + mndReleaseConsumer(pMnode, pConsumer); + tDeleteSMqConsumerObj(pConsumerNew); mndTransDrop(pTrans); - return 0; - -FAIL: - tDeleteSMqConsumerObj(pConsumerNew, true); - - mndTransDrop(pTrans); - return -1; + return code; } static int32_t checkPrivilege(SMnode *pMnode, SMqConsumerObj *pConsumer, SMqHbRsp *rsp, char *user) { rsp->topicPrivileges = taosArrayInit(taosArrayGetSize(pConsumer->currentTopics), sizeof(STopicPrivilege)); if (rsp->topicPrivileges == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return terrno; + return TSDB_CODE_OUT_OF_MEMORY; } for (int32_t i = 0; i < taosArrayGetSize(pConsumer->currentTopics); i++) { char *topic = taosArrayGetP(pConsumer->currentTopics, i); @@ -253,6 +267,47 @@ static int32_t checkPrivilege(SMnode *pMnode, SMqConsumerObj *pConsumer, SMqHbRs return 0; } +static void storeOffsetRows(SMnode *pMnode, SMqHbReq *req, SMqConsumerObj *pConsumer){ + 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) { + continue; + } + taosWLockLatch(&pSub->lock); + SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &pConsumer->consumerId, sizeof(int64_t)); + if (pConsumerEp) { + taosArrayDestroy(pConsumerEp->offsetRows); + pConsumerEp->offsetRows = data->offsetRows; + data->offsetRows = NULL; + } + taosWUnLockLatch(&pSub->lock); + + mndReleaseSubscribe(pMnode, pSub); + } +} + +static int32_t buildMqHbRsp(SRpcMsg *pMsg, SMqHbRsp *rsp){ + int32_t tlen = tSerializeSMqHbRsp(NULL, 0, rsp); + if (tlen <= 0){ + return TSDB_CODE_OUT_OF_MEMORY; + } + void *buf = rpcMallocCont(tlen); + if (buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + if(tSerializeSMqHbRsp(buf, tlen, rsp) != 0){ + rpcFreeCont(buf); + return TSDB_CODE_OUT_OF_MEMORY; + } + pMsg->info.rsp = buf; + pMsg->info.rspLen = tlen; + return 0; +} + static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { int32_t code = 0; SMnode *pMnode = pMsg->info.node; @@ -261,7 +316,6 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { SMqConsumerObj *pConsumer = NULL; if (tDeserializeSMqHbReq(pMsg->pCont, pMsg->contLen, &req) < 0) { - terrno = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY; goto end; } @@ -270,7 +324,6 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { pConsumer = mndAcquireConsumer(pMnode, consumerId); if (pConsumer == NULL) { mError("consumer:0x%" PRIx64 " not exist", consumerId); - terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST; code = TSDB_CODE_MND_CONSUMER_NOT_EXIST; goto end; } @@ -284,88 +337,152 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) { int32_t status = atomic_load_32(&pConsumer->status); if (status == MQ_CONSUMER_STATUS_LOST) { - mInfo("try to recover consumer:0x%" PRIx64 "", consumerId); - SMqConsumerRecoverMsg *pRecoverMsg = rpcMallocCont(sizeof(SMqConsumerRecoverMsg)); - - pRecoverMsg->consumerId = consumerId; - SRpcMsg pRpcMsg = { - .msgType = TDMT_MND_TMQ_CONSUMER_RECOVER, - .pCont = pRecoverMsg, - .contLen = sizeof(SMqConsumerRecoverMsg), - .info = pMsg->info, - }; - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &pRpcMsg); + mInfo("try to recover consumer:0x%" PRIx64, consumerId); + mndSendConsumerMsg(pMnode, pConsumer->consumerId, TDMT_MND_TMQ_CONSUMER_RECOVER, &pMsg->info); } - 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) { -#ifdef TMQ_DEBUG - ASSERT(0); -#endif - continue; - } - taosWLockLatch(&pSub->lock); - SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &consumerId, sizeof(int64_t)); - if (pConsumerEp) { - taosArrayDestroy(pConsumerEp->offsetRows); - pConsumerEp->offsetRows = data->offsetRows; - data->offsetRows = NULL; - } - taosWUnLockLatch(&pSub->lock); - - mndReleaseSubscribe(pMnode, pSub); - } - - // encode rsp - int32_t tlen = tSerializeSMqHbRsp(NULL, 0, &rsp); - void *buf = rpcMallocCont(tlen); - if (buf == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - code = TSDB_CODE_OUT_OF_MEMORY; - goto end; - } - - tSerializeSMqHbRsp(buf, tlen, &rsp); - pMsg->info.rsp = buf; - pMsg->info.rspLen = tlen; + storeOffsetRows(pMnode, &req, pConsumer); + code = buildMqHbRsp(pMsg, &rsp); end: - tDeatroySMqHbRsp(&rsp); + tDestroySMqHbRsp(&rsp); mndReleaseConsumer(pMnode, pConsumer); - tDeatroySMqHbReq(&req); + tDestroySMqHbReq(&req); return code; } +static int32_t addEpSetInfo(SMnode *pMnode, SMqConsumerObj *pConsumer, int32_t epoch, SMqAskEpRsp *rsp){ + taosRLockLatch(&pConsumer->lock); + + int32_t numOfTopics = taosArrayGetSize(pConsumer->currentTopics); + + rsp->topics = taosArrayInit(numOfTopics, sizeof(SMqSubTopicEp)); + if (rsp->topics == NULL) { + taosRUnLockLatch(&pConsumer->lock); + return TSDB_CODE_OUT_OF_MEMORY; + } + + // handle all topics subscribed by this consumer + for (int32_t i = 0; i < numOfTopics; i++) { + char *topic = taosArrayGetP(pConsumer->currentTopics, i); + SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, pConsumer->cgroup, topic); + // txn guarantees pSub is created + if (pSub == NULL) { + continue; + } + taosRLockLatch(&pSub->lock); + + SMqSubTopicEp topicEp = {0}; + strcpy(topicEp.topic, topic); + + // 2.1 fetch topic schema + SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); + if (pTopic == NULL) { + taosRUnLockLatch(&pSub->lock); + mndReleaseSubscribe(pMnode, pSub); + continue; + } + taosRLockLatch(&pTopic->lock); + tstrncpy(topicEp.db, pTopic->db, TSDB_DB_FNAME_LEN); + topicEp.schema.nCols = pTopic->schema.nCols; + if (topicEp.schema.nCols) { + topicEp.schema.pSchema = taosMemoryCalloc(topicEp.schema.nCols, sizeof(SSchema)); + memcpy(topicEp.schema.pSchema, pTopic->schema.pSchema, topicEp.schema.nCols * sizeof(SSchema)); + } + taosRUnLockLatch(&pTopic->lock); + mndReleaseTopic(pMnode, pTopic); + + // 2.2 iterate all vg assigned to the consumer of that topic + SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &pConsumer->consumerId, sizeof(int64_t)); + int32_t vgNum = taosArrayGetSize(pConsumerEp->vgs); + + // this customer assigned vgroups + topicEp.vgs = taosArrayInit(vgNum, sizeof(SMqSubVgEp)); + if (topicEp.vgs == NULL) { + taosRUnLockLatch(&pConsumer->lock); + taosRUnLockLatch(&pSub->lock); + mndReleaseSubscribe(pMnode, pSub); + return TSDB_CODE_OUT_OF_MEMORY; + } + + 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); + + if (epoch == -1) { + SVgObj *pVgroup = mndAcquireVgroup(pMnode, pVgEp->vgId); + if (pVgroup) { + pVgEp->epSet = mndGetVgroupEpset(pMnode, pVgroup); + mndReleaseVgroup(pMnode, pVgroup); + } + } + // 2.2.1 build vg ep + SMqSubVgEp vgEp = { + .epSet = pVgEp->epSet, + .vgId = pVgEp->vgId, + .offset = -1, + }; + + taosArrayPush(topicEp.vgs, &vgEp); + } + taosArrayPush(rsp->topics, &topicEp); + + taosRUnLockLatch(&pSub->lock); + mndReleaseSubscribe(pMnode, pSub); + } + taosRUnLockLatch(&pConsumer->lock); + return 0; +} + +static int32_t buildAskEpRsp(SRpcMsg *pMsg, SMqAskEpRsp *rsp, int32_t serverEpoch, int64_t consumerId){ + // encode rsp + int32_t tlen = sizeof(SMqRspHead) + tEncodeSMqAskEpRsp(NULL, rsp); + void *buf = rpcMallocCont(tlen); + if (buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + SMqRspHead *pHead = buf; + + pHead->mqMsgType = TMQ_MSG_TYPE__EP_RSP; + pHead->epoch = serverEpoch; + pHead->consumerId = consumerId; + pHead->walsver = 0; + pHead->walever = 0; + + void *abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead)); + tEncodeSMqAskEpRsp(&abuf, rsp); + + // send rsp + pMsg->info.rsp = buf; + pMsg->info.rspLen = tlen; + return 0; +} + static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) { SMnode *pMnode = pMsg->info.node; SMqAskEpReq req = {0}; SMqAskEpRsp rsp = {0}; + int32_t code = 0; if (tDeserializeSMqAskEpReq(pMsg->pCont, pMsg->contLen, &req) < 0) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; + return TSDB_CODE_OUT_OF_MEMORY; } int64_t consumerId = req.consumerId; - int32_t epoch = req.epoch; SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, consumerId); if (pConsumer == NULL) { mError("consumer:0x%" PRIx64 " group:%s not exists in sdb", consumerId, req.cgroup); - terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST; - return -1; + return TSDB_CODE_MND_CONSUMER_NOT_EXIST; } - int32_t ret = strncmp(req.cgroup, pConsumer->cgroup, tListLen(pConsumer->cgroup)); - if (ret != 0) { + if (strncmp(req.cgroup, pConsumer->cgroup, tListLen(pConsumer->cgroup)) != 0) { mError("consumer:0x%" PRIx64 " group:%s not consistent with data in sdb, saved cgroup:%s", consumerId, req.cgroup, pConsumer->cgroup); - terrno = TSDB_CODE_MND_CONSUMER_NOT_EXIST; - goto FAIL; + code = TSDB_CODE_MND_CONSUMER_NOT_EXIST; + goto END; } atomic_store_32(&pConsumer->hbStatus, 0); @@ -374,156 +491,37 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) { int32_t status = atomic_load_32(&pConsumer->status); if (status == MQ_CONSUMER_STATUS_LOST) { - mInfo("try to recover consumer:0x%" PRIx64, consumerId); - SMqConsumerRecoverMsg *pRecoverMsg = rpcMallocCont(sizeof(SMqConsumerRecoverMsg)); - - pRecoverMsg->consumerId = consumerId; - SRpcMsg pRpcMsg = { - .msgType = TDMT_MND_TMQ_CONSUMER_RECOVER, - .pCont = pRecoverMsg, - .contLen = sizeof(SMqConsumerRecoverMsg), - .info = pMsg->info, - }; - - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &pRpcMsg); + mndSendConsumerMsg(pMnode, pConsumer->consumerId, TDMT_MND_TMQ_CONSUMER_RECOVER, &pMsg->info); } if (status != MQ_CONSUMER_STATUS_READY) { mInfo("consumer:0x%" PRIx64 " not ready, status: %s", consumerId, mndConsumerStatusName(status)); - terrno = TSDB_CODE_MND_CONSUMER_NOT_READY; - goto FAIL; + code = TSDB_CODE_MND_CONSUMER_NOT_READY; + goto END; } + int32_t epoch = req.epoch; int32_t serverEpoch = atomic_load_32(&pConsumer->epoch); // 2. check epoch, only send ep info when epochs do not match if (epoch != serverEpoch) { - taosRLockLatch(&pConsumer->lock); - mInfo("process ask ep, consumer:0x%" PRIx64 "(epoch %d) update with server epoch %d", consumerId, epoch, - serverEpoch); - int32_t numOfTopics = taosArrayGetSize(pConsumer->currentTopics); - - rsp.topics = taosArrayInit(numOfTopics, sizeof(SMqSubTopicEp)); - if (rsp.topics == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - taosRUnLockLatch(&pConsumer->lock); - goto FAIL; + mInfo("process ask ep, consumer:0x%" PRIx64 "(epoch %d) update with server epoch %d", + consumerId, epoch, serverEpoch); + code = addEpSetInfo(pMnode, pConsumer, epoch, &rsp); + if(code != 0){ + goto END; } - - // handle all topics subscribed by this consumer - for (int32_t i = 0; i < numOfTopics; i++) { - char *topic = taosArrayGetP(pConsumer->currentTopics, i); - SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, pConsumer->cgroup, topic); - // txn guarantees pSub is created - if (pSub == NULL) { -#ifdef TMQ_DEBUG - ASSERT(0); -#endif - continue; - } - taosRLockLatch(&pSub->lock); - - SMqSubTopicEp topicEp = {0}; - strcpy(topicEp.topic, topic); - - // 2.1 fetch topic schema - SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); - if (pTopic == NULL) { -#ifdef TMQ_DEBUG - ASSERT(0); -#endif - taosRUnLockLatch(&pSub->lock); - mndReleaseSubscribe(pMnode, pSub); - continue; - } - taosRLockLatch(&pTopic->lock); - tstrncpy(topicEp.db, pTopic->db, TSDB_DB_FNAME_LEN); - topicEp.schema.nCols = pTopic->schema.nCols; - if (topicEp.schema.nCols) { - topicEp.schema.pSchema = taosMemoryCalloc(topicEp.schema.nCols, sizeof(SSchema)); - memcpy(topicEp.schema.pSchema, pTopic->schema.pSchema, topicEp.schema.nCols * sizeof(SSchema)); - } - taosRUnLockLatch(&pTopic->lock); - mndReleaseTopic(pMnode, pTopic); - - // 2.2 iterate all vg assigned to the consumer of that topic - SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &consumerId, sizeof(int64_t)); - int32_t vgNum = taosArrayGetSize(pConsumerEp->vgs); - - // this customer assigned vgroups - topicEp.vgs = taosArrayInit(vgNum, sizeof(SMqSubVgEp)); - if (topicEp.vgs == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - taosRUnLockLatch(&pConsumer->lock); - taosRUnLockLatch(&pSub->lock); - mndReleaseSubscribe(pMnode, pSub); - goto FAIL; - } - - 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); - - if (epoch == -1) { - SVgObj *pVgroup = mndAcquireVgroup(pMnode, pVgEp->vgId); - if (pVgroup) { - pVgEp->epSet = mndGetVgroupEpset(pMnode, pVgroup); - mndReleaseVgroup(pMnode, pVgroup); - } - } - // 2.2.1 build vg ep - SMqSubVgEp vgEp = { - .epSet = pVgEp->epSet, - .vgId = pVgEp->vgId, - .offset = -1, - }; - - taosArrayPush(topicEp.vgs, &vgEp); - } - taosArrayPush(rsp.topics, &topicEp); - - taosRUnLockLatch(&pSub->lock); - mndReleaseSubscribe(pMnode, pSub); - } - taosRUnLockLatch(&pConsumer->lock); } - // encode rsp - int32_t tlen = sizeof(SMqRspHead) + tEncodeSMqAskEpRsp(NULL, &rsp); - void *buf = rpcMallocCont(tlen); - if (buf == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - goto FAIL; - } + code = buildAskEpRsp(pMsg, &rsp, serverEpoch, consumerId); - SMqRspHead *pHead = buf; - - pHead->mqMsgType = TMQ_MSG_TYPE__EP_RSP; - pHead->epoch = serverEpoch; - pHead->consumerId = pConsumer->consumerId; - pHead->walsver = 0; - pHead->walever = 0; - - void *abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead)); - tEncodeSMqAskEpRsp(&abuf, &rsp); - - // release consumer and free memory +END: tDeleteSMqAskEpRsp(&rsp); mndReleaseConsumer(pMnode, pConsumer); - - // send rsp - pMsg->info.rsp = buf; - pMsg->info.rspLen = tlen; - return 0; - -FAIL: - tDeleteSMqAskEpRsp(&rsp); - mndReleaseConsumer(pMnode, pConsumer); - return -1; + return code; } -int32_t mndSetConsumerDropLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *pConsumer) { +int32_t mndSetConsumerDropLogs(STrans *pTrans, SMqConsumerObj *pConsumer) { SSdbRaw *pCommitRaw = mndConsumerActionEncode(pConsumer); if (pCommitRaw == NULL) return -1; if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1; @@ -531,7 +529,7 @@ int32_t mndSetConsumerDropLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *p return 0; } -int32_t mndSetConsumerCommitLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj *pConsumer) { +int32_t mndSetConsumerCommitLogs(STrans *pTrans, SMqConsumerObj *pConsumer) { SSdbRaw *pCommitRaw = mndConsumerActionEncode(pConsumer); if (pCommitRaw == NULL) return -1; if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1; @@ -539,8 +537,6 @@ int32_t mndSetConsumerCommitLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj return 0; } -static void *topicNameDup(void *p) { return taosStrdup((char *)p); } - static void freeItem(void *param) { void *pItem = *(void **)param; if (pItem != NULL) { @@ -548,21 +544,52 @@ static void freeItem(void *param) { } } -int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { - SMnode *pMnode = pMsg->info.node; - char *msgStr = pMsg->pCont; - int32_t code = -1; +static int32_t getTopicAddDelete(SMqConsumerObj *pExistedConsumer, SMqConsumerObj *pConsumerNew){ + pConsumerNew->rebNewTopics = taosArrayInit(0, sizeof(void *)); + pConsumerNew->rebRemovedTopics = taosArrayInit(0, sizeof(void *)); + if(pConsumerNew->rebNewTopics == NULL || pConsumerNew->rebRemovedTopics == NULL){ + return TSDB_CODE_OUT_OF_MEMORY; + } + int32_t newTopicNum = taosArrayGetSize(pConsumerNew->assignedTopics); + int32_t oldTopicNum = taosArrayGetSize(pExistedConsumer->currentTopics); - SCMSubscribeReq subscribe = {0}; - tDeserializeSCMSubscribeReq(msgStr, &subscribe); + int32_t i = 0, j = 0; + while (i < oldTopicNum || j < newTopicNum) { + if (i >= oldTopicNum) { + char *newTopicCopy = taosStrdup(taosArrayGetP(pConsumerNew->assignedTopics, j)); + taosArrayPush(pConsumerNew->rebNewTopics, &newTopicCopy); + j++; + continue; + } else if (j >= newTopicNum) { + char *oldTopicCopy = taosStrdup(taosArrayGetP(pExistedConsumer->currentTopics, i)); + taosArrayPush(pConsumerNew->rebRemovedTopics, &oldTopicCopy); + i++; + continue; + } else { + char *oldTopic = taosArrayGetP(pExistedConsumer->currentTopics, i); + char *newTopic = taosArrayGetP(pConsumerNew->assignedTopics, j); + int comp = strcmp(oldTopic, newTopic); + if (comp == 0) { + i++; + j++; + continue; + } else if (comp < 0) { + char *oldTopicCopy = taosStrdup(oldTopic); + taosArrayPush(pConsumerNew->rebRemovedTopics, &oldTopicCopy); + i++; + continue; + } else { + char *newTopicCopy = taosStrdup(newTopic); + taosArrayPush(pConsumerNew->rebNewTopics, &newTopicCopy); + j++; + continue; + } + } + } + return 0; +} - int64_t consumerId = subscribe.consumerId; - char *cgroup = subscribe.cgroup; - SMqConsumerObj *pExistedConsumer = NULL; - SMqConsumerObj *pConsumerNew = NULL; - STrans *pTrans = NULL; - - SArray *pTopicList = subscribe.topicNames; +static int32_t checkAndSortTopic(SMnode *pMnode, SArray *pTopicList){ taosArraySort(pTopicList, taosArrayCompareString); taosArrayRemoveDuplicate(pTopicList, taosArrayCompareString, freeItem); @@ -571,125 +598,102 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { 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; + return -1; } } + return TSDB_CODE_SUCCESS; +} - // check topic existence - pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_TOPIC_INSIDE, pMsg, "subscribe"); - if (pTrans == NULL) { - goto _over; - } - - code = validateTopics(pTrans, pTopicList, pMnode, pMsg->info.conn.user, subscribe.enableReplay); - if (code != TSDB_CODE_SUCCESS) { - goto _over; - } - +static SMqConsumerObj* buildSubConsumer(SMnode *pMnode, SCMSubscribeReq *subscribe){ + int64_t consumerId = subscribe->consumerId; + char *cgroup = subscribe->cgroup; + SMqConsumerObj *pConsumerNew = NULL; + SMqConsumerObj *pExistedConsumer = NULL; pExistedConsumer = mndAcquireConsumer(pMnode, consumerId); if (pExistedConsumer == NULL) { - mInfo("receive subscribe request from new consumer:0x%" PRIx64 " cgroup:%s, numOfTopics:%d", consumerId, - subscribe.cgroup, (int32_t)taosArrayGetSize(pTopicList)); + mInfo("receive subscribe request from new consumer:0x%" PRIx64 + ",cgroup:%s, numOfTopics:%d", consumerId, + subscribe->cgroup, (int32_t)taosArrayGetSize(subscribe->topicNames)); - pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup); - tstrncpy(pConsumerNew->clientId, subscribe.clientId, tListLen(pConsumerNew->clientId)); - - pConsumerNew->withTbName = subscribe.withTbName; - pConsumerNew->autoCommit = subscribe.autoCommit; - pConsumerNew->autoCommitInterval = subscribe.autoCommitInterval; - pConsumerNew->resetOffsetCfg = subscribe.resetOffsetCfg; - - // pConsumerNew->updateType = CONSUMER_UPDATE_SUB; // use insert logic - taosArrayDestroy(pConsumerNew->assignedTopics); - pConsumerNew->assignedTopics = taosArrayDup(pTopicList, topicNameDup); - - // all subscribed topics should re-balance. - taosArrayDestroy(pConsumerNew->rebNewTopics); - pConsumerNew->rebNewTopics = pTopicList; - subscribe.topicNames = NULL; - - if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) goto _over; - if (mndTransPrepare(pMnode, pTrans) != 0) goto _over; + pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup, CONSUMER_INSERT_SUB, NULL, subscribe); + if (pConsumerNew == NULL) { + goto _over; + } } else { int32_t status = atomic_load_32(&pExistedConsumer->status); mInfo("receive subscribe request from existed consumer:0x%" PRIx64 - " cgroup:%s, current status:%d(%s), subscribe topic num: %d", - consumerId, subscribe.cgroup, status, mndConsumerStatusName(status), newTopicNum); + ",cgroup:%s, current status:%d(%s), subscribe topic num: %d", + consumerId, subscribe->cgroup, status, mndConsumerStatusName(status), + (int32_t)taosArrayGetSize(subscribe->topicNames)); if (status != MQ_CONSUMER_STATUS_READY) { terrno = TSDB_CODE_MND_CONSUMER_NOT_READY; goto _over; } - - pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup); + pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup, CONSUMER_UPDATE_SUB, NULL, subscribe); if (pConsumerNew == NULL) { goto _over; } - // set the update type - pConsumerNew->updateType = CONSUMER_UPDATE_SUB; - taosArrayDestroy(pConsumerNew->assignedTopics); - pConsumerNew->assignedTopics = taosArrayDup(pTopicList, topicNameDup); - - int32_t oldTopicNum = taosArrayGetSize(pExistedConsumer->currentTopics); - - int32_t i = 0, j = 0; - while (i < oldTopicNum || j < newTopicNum) { - if (i >= oldTopicNum) { - char *newTopicCopy = taosStrdup(taosArrayGetP(pTopicList, j)); - taosArrayPush(pConsumerNew->rebNewTopics, &newTopicCopy); - j++; - continue; - } else if (j >= newTopicNum) { - char *oldTopicCopy = taosStrdup(taosArrayGetP(pExistedConsumer->currentTopics, i)); - taosArrayPush(pConsumerNew->rebRemovedTopics, &oldTopicCopy); - i++; - continue; - } else { - char *oldTopic = taosArrayGetP(pExistedConsumer->currentTopics, i); - char *newTopic = taosArrayGetP(pTopicList, j); - int comp = strcmp(oldTopic, newTopic); - if (comp == 0) { - i++; - j++; - continue; - } else if (comp < 0) { - char *oldTopicCopy = taosStrdup(oldTopic); - taosArrayPush(pConsumerNew->rebRemovedTopics, &oldTopicCopy); - i++; - continue; - } else { - char *newTopicCopy = taosStrdup(newTopic); - taosArrayPush(pConsumerNew->rebNewTopics, &newTopicCopy); - j++; - continue; - } - } - } - - // no topics need to be rebalanced - if (taosArrayGetSize(pConsumerNew->rebNewTopics) == 0 && taosArrayGetSize(pConsumerNew->rebRemovedTopics) == 0) { + int32_t code = getTopicAddDelete(pExistedConsumer, pConsumerNew); + if (code != 0){ + terrno = code; goto _over; } + } + mndReleaseConsumer(pMnode, pExistedConsumer); + return pConsumerNew; - if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) goto _over; - if (mndTransPrepare(pMnode, pTrans) != 0) goto _over; +_over: + mndReleaseConsumer(pMnode, pExistedConsumer); + tDeleteSMqConsumerObj(pConsumerNew); + taosArrayDestroyP(subscribe->topicNames, (FDelete)taosMemoryFree); + return NULL; +} + +int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { + SMnode *pMnode = pMsg->info.node; + char *msgStr = pMsg->pCont; + int32_t code = 0; + + SCMSubscribeReq subscribe = {0}; + tDeserializeSCMSubscribeReq(msgStr, &subscribe); + + SMqConsumerObj *pConsumerNew = NULL; + STrans *pTrans = NULL; + + code = checkAndSortTopic(pMnode, subscribe.topicNames); + if(code != TSDB_CODE_SUCCESS){ + goto _over; } + pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_TOPIC_INSIDE, pMsg, "subscribe"); + if (pTrans == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _over; + } + + code = validateTopics(pTrans, subscribe.topicNames, pMnode, pMsg->info.conn.user, subscribe.enableReplay); + if (code != TSDB_CODE_SUCCESS) { + goto _over; + } + + pConsumerNew = buildSubConsumer(pMnode, &subscribe); + if(pConsumerNew == NULL){ + code = -1; + goto _over; + } + code = mndSetConsumerCommitLogs(pTrans, pConsumerNew); + if (code != 0) goto _over; + + code = mndTransPrepare(pMnode, pTrans); + if (code != 0) goto _over; code = TSDB_CODE_ACTION_IN_PROGRESS; _over: mndTransDrop(pTrans); - - if (pExistedConsumer) { - /*taosRUnLockLatch(&pExistedConsumer->lock);*/ - mndReleaseConsumer(pMnode, pExistedConsumer); - } - - tDeleteSMqConsumerObj(pConsumerNew, true); - + tDeleteSMqConsumerObj(pConsumerNew); taosArrayDestroyP(subscribe.topicNames, (FDelete)taosMemoryFree); return code; } @@ -796,7 +800,7 @@ static int32_t mndConsumerActionInsert(SSdb *pSdb, SMqConsumerObj *pConsumer) { 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)); - tDeleteSMqConsumerObj(pConsumer, false); + tClearSMqConsumerObj(pConsumer); return 0; } @@ -812,48 +816,17 @@ static void updateConsumerStatus(SMqConsumerObj *pConsumer) { } } -// remove from new topic -static void removeFromNewTopicList(SMqConsumerObj *pConsumer, const char *pTopic) { - int32_t size = taosArrayGetSize(pConsumer->rebNewTopics); +// remove from topic list +static void removeFromTopicList(SArray *topicList, const char *pTopic, int64_t consumerId, char *type) { + int32_t size = taosArrayGetSize(topicList); for (int32_t i = 0; i < size; i++) { - char *p = taosArrayGetP(pConsumer->rebNewTopics, i); + char *p = taosArrayGetP(topicList, i); if (strcmp(pTopic, p) == 0) { - taosArrayRemove(pConsumer->rebNewTopics, i); + taosArrayRemove(topicList, i); taosMemoryFree(p); - mInfo("consumer:0x%" PRIx64 " remove new topic:%s in the topic list, remain newTopics:%d", pConsumer->consumerId, - pTopic, (int)taosArrayGetSize(pConsumer->rebNewTopics)); - break; - } - } -} - -// remove from removed topic -static void removeFromRemoveTopicList(SMqConsumerObj *pConsumer, const char *pTopic) { - int32_t size = taosArrayGetSize(pConsumer->rebRemovedTopics); - for (int32_t i = 0; i < size; i++) { - char *p = taosArrayGetP(pConsumer->rebRemovedTopics, i); - if (strcmp(pTopic, p) == 0) { - taosArrayRemove(pConsumer->rebRemovedTopics, i); - taosMemoryFree(p); - - mInfo("consumer:0x%" PRIx64 " remove topic:%s in the removed topic list, remain removedTopics:%d", - pConsumer->consumerId, pTopic, (int)taosArrayGetSize(pConsumer->rebRemovedTopics)); - break; - } - } -} - -static void removeFromCurrentTopicList(SMqConsumerObj *pConsumer, const char *pTopic) { - int32_t sz = taosArrayGetSize(pConsumer->currentTopics); - for (int32_t i = 0; i < sz; i++) { - char *topic = taosArrayGetP(pConsumer->currentTopics, i); - if (strcmp(pTopic, topic) == 0) { - taosArrayRemove(pConsumer->currentTopics, i); - taosMemoryFree(topic); - - mInfo("consumer:0x%" PRIx64 " remove topic:%s in the current topic list, remain currentTopics:%d", - pConsumer->consumerId, pTopic, (int)taosArrayGetSize(pConsumer->currentTopics)); + mInfo("[rebalance] consumer:0x%" PRIx64 " remove topic:%s in the %s topic list, remain newTopics:%d", + consumerId, pTopic, type, (int)taosArrayGetSize(topicList)); break; } } @@ -887,60 +860,38 @@ 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 " subscribe update, modify existed consumer", pOldConsumer->consumerId); } else if (pNewConsumer->updateType == CONSUMER_UPDATE_REC) { int32_t sz = taosArrayGetSize(pOldConsumer->assignedTopics); for (int32_t i = 0; i < sz; i++) { char *topic = taosStrdup(taosArrayGetP(pOldConsumer->assignedTopics, i)); taosArrayPush(pOldConsumer->rebNewTopics, &topic); } - pOldConsumer->status = MQ_CONSUMER_STATUS_REBALANCE; - mInfo("consumer:0x%" PRIx64 " timer update, timer recover", pOldConsumer->consumerId); + mInfo("consumer:0x%" PRIx64 " recover update", pOldConsumer->consumerId); } else if (pNewConsumer->updateType == CONSUMER_UPDATE_REB) { atomic_add_fetch_32(&pOldConsumer->epoch, 1); pOldConsumer->rebalanceTime = taosGetTimestampMs(); - mInfo("consumer:0x%" PRIx64 " reb update, only rebalance time", pOldConsumer->consumerId); + mInfo("[rebalance] consumer:0x%" PRIx64 " rebalance update, only rebalance time", pOldConsumer->consumerId); } else if (pNewConsumer->updateType == CONSUMER_ADD_REB) { char *pNewTopic = taosStrdup(taosArrayGetP(pNewConsumer->rebNewTopics, 0)); - - // check if exist in current topic - removeFromNewTopicList(pOldConsumer, pNewTopic); - - // add to current topic + removeFromTopicList(pOldConsumer->rebNewTopics, pNewTopic, pOldConsumer->consumerId, "new"); bool existing = existInCurrentTopicList(pOldConsumer, pNewTopic); if (existing) { - mError("consumer:0x%" PRIx64 "new topic:%s should not in currentTopics", pOldConsumer->consumerId, pNewTopic); + mError("[rebalance] consumer:0x%" PRIx64 " add new topic:%s should not in currentTopics", pOldConsumer->consumerId, pNewTopic); taosMemoryFree(pNewTopic); - } else { // added into current topic list + } else { taosArrayPush(pOldConsumer->currentTopics, &pNewTopic); taosArraySort(pOldConsumer->currentTopics, taosArrayCompareString); } - // set status int32_t status = pOldConsumer->status; updateConsumerStatus(pOldConsumer); - - // the re-balance is triggered when the new consumer is launched. pOldConsumer->rebalanceTime = taosGetTimestampMs(); - 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 + + mInfo("[rebalance] consumer:0x%" PRIx64 " rebalance 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, @@ -948,22 +899,16 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, (int)taosArrayGetSize(pOldConsumer->rebRemovedTopics)); } else if (pNewConsumer->updateType == CONSUMER_REMOVE_REB) { - char *removedTopic = taosArrayGetP(pNewConsumer->rebRemovedTopics, 0); + char *topic = taosArrayGetP(pNewConsumer->rebRemovedTopics, 0); + removeFromTopicList(pOldConsumer->rebRemovedTopics, topic, pOldConsumer->consumerId, "remove"); + removeFromTopicList(pOldConsumer->currentTopics, topic, pOldConsumer->consumerId, "current"); - // remove from removed topic - removeFromRemoveTopicList(pOldConsumer, removedTopic); - - // remove from current topic - removeFromCurrentTopicList(pOldConsumer, removedTopic); - - // set status int32_t status = pOldConsumer->status; updateConsumerStatus(pOldConsumer); - pOldConsumer->rebalanceTime = taosGetTimestampMs(); 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 + mInfo("[rebalance]consumer:0x%" PRIx64 " rebalance 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, diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 37c2d19bd4..a1f3a24661 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -15,6 +15,8 @@ #define _DEFAULT_SOURCE #include "mndDb.h" +#include "audit.h" +#include "mndArbGroup.h" #include "mndCluster.h" #include "mndDnode.h" #include "mndIndex.h" @@ -30,12 +32,11 @@ #include "mndVgroup.h" #include "mndView.h" #include "systable.h" -#include "tjson.h" #include "thttp.h" -#include "audit.h" +#include "tjson.h" #define DB_VER_NUMBER 1 -#define DB_RESERVE_SIZE 42 +#define DB_RESERVE_SIZE 41 static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw); static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb); @@ -43,14 +44,14 @@ static int32_t mndDbActionDelete(SSdb *pSdb, SDbObj *pDb); static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOld, SDbObj *pNew); static int32_t mndNewDbActionValidate(SMnode *pMnode, STrans *pTrans, SSdbRaw *pRaw); -static int32_t mndProcessCreateDbReq(SRpcMsg *pReq); -static int32_t mndProcessAlterDbReq(SRpcMsg *pReq); -static int32_t mndProcessDropDbReq(SRpcMsg *pReq); -static int32_t mndProcessUseDbReq(SRpcMsg *pReq); -static int32_t mndProcessTrimDbReq(SRpcMsg *pReq); -static int32_t mndRetrieveDbs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rowsCapacity); -static void mndCancelGetNextDb(SMnode *pMnode, void *pIter); -static int32_t mndProcessGetDbCfgReq(SRpcMsg *pReq); +static int32_t mndProcessCreateDbReq(SRpcMsg *pReq); +static int32_t mndProcessAlterDbReq(SRpcMsg *pReq); +static int32_t mndProcessDropDbReq(SRpcMsg *pReq); +static int32_t mndProcessUseDbReq(SRpcMsg *pReq); +static int32_t mndProcessTrimDbReq(SRpcMsg *pReq); +static int32_t mndRetrieveDbs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rowsCapacity); +static void mndCancelGetNextDb(SMnode *pMnode, void *pIter); +static int32_t mndProcessGetDbCfgReq(SRpcMsg *pReq); #ifndef TD_ENTERPRISE int32_t mndProcessCompactDbReq(SRpcMsg *pReq) { return TSDB_CODE_OPS_NOT_SUPPORT; } @@ -139,6 +140,7 @@ SSdbRaw *mndDbActionEncode(SDbObj *pDb) { SDB_SET_INT32(pRaw, dataPos, pDb->cfg.tsdbPageSize, _OVER) SDB_SET_INT64(pRaw, dataPos, pDb->compactStartTime, _OVER) SDB_SET_INT32(pRaw, dataPos, pDb->cfg.keepTimeOffset, _OVER) + SDB_SET_INT8(pRaw, dataPos, pDb->cfg.withArbitrator, _OVER) SDB_SET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER) SDB_SET_DATALEN(pRaw, dataPos, _OVER) @@ -230,6 +232,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.tsdbPageSize, _OVER) SDB_GET_INT64(pRaw, dataPos, &pDb->compactStartTime, _OVER) SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.keepTimeOffset, _OVER) + SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.withArbitrator, _OVER) SDB_GET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER) taosInitRWLatch(&pDb->lock); @@ -319,6 +322,7 @@ static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOld, SDbObj *pNew) { pOld->cfg.minRows = pNew->cfg.minRows; pOld->cfg.maxRows = pNew->cfg.maxRows; pOld->cfg.tsdbPageSize = pNew->cfg.tsdbPageSize; + pOld->cfg.withArbitrator = pNew->cfg.withArbitrator; pOld->compactStartTime = pNew->compactStartTime; taosWUnLockLatch(&pOld->lock); return 0; @@ -393,7 +397,11 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) { if (pCfg->precision < TSDB_MIN_PRECISION && pCfg->precision > TSDB_MAX_PRECISION) return -1; if (pCfg->compression < TSDB_MIN_COMP_LEVEL || pCfg->compression > TSDB_MAX_COMP_LEVEL) return -1; if (pCfg->replications < TSDB_MIN_DB_REPLICA || pCfg->replications > TSDB_MAX_DB_REPLICA) return -1; +#ifdef TD_ENTERPRISE + if ((pCfg->replications == 2) ^ (pCfg->withArbitrator == TSDB_MAX_DB_WITH_ARBITRATOR)) return -1; +#else if (pCfg->replications != 1 && pCfg->replications != 3) return -1; +#endif if (pCfg->strict < TSDB_DB_STRICT_OFF || pCfg->strict > TSDB_DB_STRICT_ON) return -1; if (pCfg->schemaless < TSDB_DB_SCHEMALESS_OFF || pCfg->schemaless > TSDB_DB_SCHEMALESS_ON) return -1; if (pCfg->cacheLast < TSDB_CACHE_MODEL_NONE || pCfg->cacheLast > TSDB_CACHE_MODEL_BOTH) return -1; @@ -418,33 +426,48 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) { return terrno; } -static int32_t mndCheckInChangeDbCfg(SMnode *pMnode, SDbCfg *pCfg) { +static int32_t mndCheckInChangeDbCfg(SMnode *pMnode, SDbCfg *pOldCfg, SDbCfg *pNewCfg) { terrno = TSDB_CODE_MND_INVALID_DB_OPTION; - if (pCfg->buffer < TSDB_MIN_BUFFER_PER_VNODE || pCfg->buffer > TSDB_MAX_BUFFER_PER_VNODE) return -1; - if (pCfg->pages < TSDB_MIN_PAGES_PER_VNODE || pCfg->pages > TSDB_MAX_PAGES_PER_VNODE) return -1; - if (pCfg->pageSize < TSDB_MIN_PAGESIZE_PER_VNODE || pCfg->pageSize > TSDB_MAX_PAGESIZE_PER_VNODE) return -1; - if (pCfg->daysPerFile < TSDB_MIN_DAYS_PER_FILE || pCfg->daysPerFile > TSDB_MAX_DAYS_PER_FILE) return -1; - if (pCfg->daysToKeep0 < TSDB_MIN_KEEP || pCfg->daysToKeep0 > TSDB_MAX_KEEP) return -1; - if (pCfg->daysToKeep1 < TSDB_MIN_KEEP || pCfg->daysToKeep1 > TSDB_MAX_KEEP) return -1; - if (pCfg->daysToKeep2 < TSDB_MIN_KEEP || pCfg->daysToKeep2 > TSDB_MAX_KEEP) return -1; - if (pCfg->daysToKeep0 < pCfg->daysPerFile) return -1; - if (pCfg->daysToKeep0 > pCfg->daysToKeep1) return -1; - if (pCfg->daysToKeep1 > pCfg->daysToKeep2) return -1; - if (pCfg->keepTimeOffset < TSDB_MIN_KEEP_TIME_OFFSET || pCfg->keepTimeOffset > TSDB_MAX_KEEP_TIME_OFFSET) return -1; - if (pCfg->walFsyncPeriod < TSDB_MIN_FSYNC_PERIOD || pCfg->walFsyncPeriod > TSDB_MAX_FSYNC_PERIOD) return -1; - if (pCfg->walLevel < TSDB_MIN_WAL_LEVEL || pCfg->walLevel > TSDB_MAX_WAL_LEVEL) return -1; - if (pCfg->cacheLast < TSDB_CACHE_MODEL_NONE || pCfg->cacheLast > TSDB_CACHE_MODEL_BOTH) return -1; - if (pCfg->cacheLastSize < TSDB_MIN_DB_CACHE_SIZE || pCfg->cacheLastSize > TSDB_MAX_DB_CACHE_SIZE) return -1; - if (pCfg->replications < TSDB_MIN_DB_REPLICA || pCfg->replications > TSDB_MAX_DB_REPLICA) return -1; - if (pCfg->replications != 1 && pCfg->replications != 3) return -1; - if (pCfg->sstTrigger < TSDB_MIN_STT_TRIGGER || pCfg->sstTrigger > TSDB_MAX_STT_TRIGGER) return -1; - if (pCfg->minRows < TSDB_MIN_MINROWS_FBLOCK || pCfg->minRows > TSDB_MAX_MINROWS_FBLOCK) return -1; - if (pCfg->maxRows < TSDB_MIN_MAXROWS_FBLOCK || pCfg->maxRows > TSDB_MAX_MAXROWS_FBLOCK) return -1; - if (pCfg->minRows > pCfg->maxRows) return -1; - if (pCfg->walRetentionPeriod < TSDB_DB_MIN_WAL_RETENTION_PERIOD) return -1; - if (pCfg->walRetentionSize < TSDB_DB_MIN_WAL_RETENTION_SIZE) return -1; - if (pCfg->strict < TSDB_DB_STRICT_OFF || pCfg->strict > TSDB_DB_STRICT_ON) return -1; - if (pCfg->replications > mndGetDnodeSize(pMnode)) { + if (pNewCfg->buffer < TSDB_MIN_BUFFER_PER_VNODE || pNewCfg->buffer > TSDB_MAX_BUFFER_PER_VNODE) return -1; + if (pNewCfg->pages < TSDB_MIN_PAGES_PER_VNODE || pNewCfg->pages > TSDB_MAX_PAGES_PER_VNODE) return -1; + if (pNewCfg->pageSize < TSDB_MIN_PAGESIZE_PER_VNODE || pNewCfg->pageSize > TSDB_MAX_PAGESIZE_PER_VNODE) return -1; + if (pNewCfg->daysPerFile < TSDB_MIN_DAYS_PER_FILE || pNewCfg->daysPerFile > TSDB_MAX_DAYS_PER_FILE) return -1; + if (pNewCfg->daysToKeep0 < TSDB_MIN_KEEP || pNewCfg->daysToKeep0 > TSDB_MAX_KEEP) return -1; + if (pNewCfg->daysToKeep1 < TSDB_MIN_KEEP || pNewCfg->daysToKeep1 > TSDB_MAX_KEEP) return -1; + if (pNewCfg->daysToKeep2 < TSDB_MIN_KEEP || pNewCfg->daysToKeep2 > TSDB_MAX_KEEP) return -1; + if (pNewCfg->daysToKeep0 < pNewCfg->daysPerFile) return -1; + if (pNewCfg->daysToKeep0 > pNewCfg->daysToKeep1) return -1; + if (pNewCfg->daysToKeep1 > pNewCfg->daysToKeep2) return -1; + if (pNewCfg->keepTimeOffset < TSDB_MIN_KEEP_TIME_OFFSET || pNewCfg->keepTimeOffset > TSDB_MAX_KEEP_TIME_OFFSET) + return -1; + if (pNewCfg->walFsyncPeriod < TSDB_MIN_FSYNC_PERIOD || pNewCfg->walFsyncPeriod > TSDB_MAX_FSYNC_PERIOD) return -1; + if (pNewCfg->walLevel < TSDB_MIN_WAL_LEVEL || pNewCfg->walLevel > TSDB_MAX_WAL_LEVEL) return -1; + if (pNewCfg->cacheLast < TSDB_CACHE_MODEL_NONE || pNewCfg->cacheLast > TSDB_CACHE_MODEL_BOTH) return -1; + if (pNewCfg->cacheLastSize < TSDB_MIN_DB_CACHE_SIZE || pNewCfg->cacheLastSize > TSDB_MAX_DB_CACHE_SIZE) return -1; + if (pNewCfg->replications < TSDB_MIN_DB_REPLICA || pNewCfg->replications > TSDB_MAX_DB_REPLICA) return -1; +#ifdef TD_ENTERPRISE + if ((pNewCfg->replications == 2) ^ (pNewCfg->withArbitrator == TSDB_MAX_DB_WITH_ARBITRATOR)) return -1; + if (pNewCfg->replications == 2 && pNewCfg->withArbitrator == TSDB_MAX_DB_WITH_ARBITRATOR) { + if (pOldCfg->replications != 1 && pOldCfg->replications != 2) { + terrno = TSDB_CODE_OPS_NOT_SUPPORT; + return -1; + } + } + if (pNewCfg->replications != 2 && pOldCfg->replications == 2) { + terrno = TSDB_CODE_OPS_NOT_SUPPORT; + return -1; + } +#else + if (pNewCfg->replications != 1 && pNewCfg->replications != 3) return -1; +#endif + if (pNewCfg->sstTrigger < TSDB_MIN_STT_TRIGGER || pNewCfg->sstTrigger > TSDB_MAX_STT_TRIGGER) return -1; + if (pNewCfg->minRows < TSDB_MIN_MINROWS_FBLOCK || pNewCfg->minRows > TSDB_MAX_MINROWS_FBLOCK) return -1; + if (pNewCfg->maxRows < TSDB_MIN_MAXROWS_FBLOCK || pNewCfg->maxRows > TSDB_MAX_MAXROWS_FBLOCK) return -1; + if (pNewCfg->minRows > pNewCfg->maxRows) return -1; + if (pNewCfg->walRetentionPeriod < TSDB_DB_MIN_WAL_RETENTION_PERIOD) return -1; + if (pNewCfg->walRetentionSize < TSDB_DB_MIN_WAL_RETENTION_SIZE) return -1; + if (pNewCfg->strict < TSDB_DB_STRICT_OFF || pNewCfg->strict > TSDB_DB_STRICT_ON) return -1; + if (pNewCfg->replications > mndGetDnodeSize(pMnode)) { terrno = TSDB_CODE_MND_NO_ENOUGH_DNODES; return -1; } @@ -484,6 +507,7 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) { if (pCfg->walSegmentSize < 0) pCfg->walSegmentSize = TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE; if (pCfg->sstTrigger <= 0) pCfg->sstTrigger = TSDB_DEFAULT_SST_TRIGGER; if (pCfg->tsdbPageSize <= 0) pCfg->tsdbPageSize = TSDB_DEFAULT_TSDB_PAGESIZE; + if (pCfg->withArbitrator < 0) pCfg->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR; } static int32_t mndSetCreateDbPrepareAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { @@ -515,6 +539,15 @@ static int32_t mndSetCreateDbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pD if (sdbSetRawStatus(pVgRaw, SDB_STATUS_UPDATE) != 0) return -1; } + if (pDb->cfg.withArbitrator) { + for (int32_t v = 0; v < pDb->cfg.numOfVgroups; ++v) { + SVgObj *pVgObj = pVgroups + v; + SArbGroup arbGroup = {0}; + mndArbGroupInitFromVgObj(pVgObj, &arbGroup); + if (mndSetCreateArbGroupRedoLogs(pTrans, &arbGroup) != 0) return -1; + } + } + return 0; } @@ -531,6 +564,15 @@ static int32_t mndSetCreateDbUndoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pD if (sdbSetRawStatus(pVgRaw, SDB_STATUS_DROPPED) != 0) return -1; } + if (pDb->cfg.withArbitrator) { + for (int32_t v = 0; v < pDb->cfg.numOfVgroups; ++v) { + SVgObj *pVgObj = pVgroups + v; + SArbGroup arbGroup = {0}; + mndArbGroupInitFromVgObj(pVgObj, &arbGroup); + if (mndSetCreateArbGroupUndoLogs(pTrans, &arbGroup) != 0) return -1; + } + } + return 0; } @@ -548,6 +590,15 @@ static int32_t mndSetCreateDbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj * if (sdbSetRawStatus(pVgRaw, SDB_STATUS_READY) != 0) return -1; } + if (pDb->cfg.withArbitrator) { + for (int32_t v = 0; v < pDb->cfg.numOfVgroups; ++v) { + SVgObj *pVgObj = pVgroups + v; + SArbGroup arbGroup = {0}; + mndArbGroupInitFromVgObj(pVgObj, &arbGroup); + if (mndSetCreateArbGroupCommitLogs(pTrans, &arbGroup) != 0) return -1; + } + } + if (pUserDuped) { SSdbRaw *pUserRaw = mndUserActionEncode(pUserDuped); if (pUserRaw == NULL) return -1; @@ -629,6 +680,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate, .hashPrefix = pCreate->hashPrefix, .hashSuffix = pCreate->hashSuffix, .tsdbPageSize = pCreate->tsdbPageSize, + .withArbitrator = pCreate->withArbitrator, }; dbObj.cfg.numOfRetensions = pCreate->numOfRetensions; @@ -698,17 +750,17 @@ _OVER: return code; } -static void mndBuildAuditDetailInt32(char* detail, char* tmp, char* format, int32_t para){ - if(para > 0){ - if(strlen(detail) > 0) strcat(detail, ", "); +static void mndBuildAuditDetailInt32(char *detail, char *tmp, char *format, int32_t para) { + if (para > 0) { + if (strlen(detail) > 0) strcat(detail, ", "); sprintf(tmp, format, para); strcat(detail, tmp); } } -static void mndBuildAuditDetailInt64(char* detail, char* tmp, char* format, int64_t para){ - if(para > 0){ - if(strlen(detail) > 0) strcat(detail, ", "); +static void mndBuildAuditDetailInt64(char *detail, char *tmp, char *format, int64_t para) { + if (para > 0) { + if (strlen(detail) > 0) strcat(detail, ", "); sprintf(tmp, format, para); strcat(detail, tmp); } @@ -893,6 +945,12 @@ static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) { terrno = 0; } + if (pAlter->withArbitrator >= TSDB_MIN_DB_WITH_ARBITRATOR && pAlter->withArbitrator != pDb->cfg.withArbitrator) { + pDb->cfg.withArbitrator = pAlter->withArbitrator; + pDb->vgVersion++; + terrno = 0; + } + return terrno; } @@ -931,12 +989,24 @@ static int32_t mndSetAlterDbRedoActions(SMnode *pMnode, STrans *pTrans, SDbObj * if (pIter == NULL) break; if (mndVgroupInDb(pVgroup, pNewDb->uid)) { - if (mndBuildAlterVgroupAction(pMnode, pTrans, pOldDb, pNewDb, pVgroup, pArray) != 0) { + SVgObj newVgroup = {0}; + if (mndBuildAlterVgroupAction(pMnode, pTrans, pOldDb, pNewDb, pVgroup, pArray, &newVgroup) != 0) { sdbCancelFetch(pSdb, pIter); sdbRelease(pSdb, pVgroup); taosArrayDestroy(pArray); return -1; } + if (pNewDb->cfg.withArbitrator != pOldDb->cfg.withArbitrator) { + if (pNewDb->cfg.withArbitrator) { + SArbGroup arbGroup = {0}; + mndArbGroupInitFromVgObj(&newVgroup, &arbGroup); + if (mndSetCreateArbGroupCommitLogs(pTrans, &arbGroup) != 0) return -1; + } else { + SArbGroup arbGroup = {0}; + mndArbGroupInitFromVgObj(pVgroup, &arbGroup); + if (mndSetDropArbGroupCommitLogs(pTrans, &arbGroup) != 0) return -1; + } + } } sdbRelease(pSdb, pVgroup); @@ -1013,7 +1083,7 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) { goto _OVER; } - code = mndCheckInChangeDbCfg(pMnode, &dbObj.cfg); + code = mndCheckInChangeDbCfg(pMnode, &pDb->cfg, &dbObj.cfg); if (code != 0) goto _OVER; dbObj.cfgVersion++; @@ -1081,6 +1151,7 @@ static void mndDumpDbCfgInfo(SDbCfgRsp *cfgRsp, SDbObj *pDb) { cfgRsp->pRetensions = taosArrayDup(pDb->cfg.pRetensions, NULL); cfgRsp->schemaless = pDb->cfg.schemaless; cfgRsp->sstTrigger = pDb->cfg.sstTrigger; + cfgRsp->withArbitrator = pDb->cfg.withArbitrator; } static int32_t mndProcessGetDbCfgReq(SRpcMsg *pReq) { @@ -1150,6 +1221,22 @@ static int32_t mndSetDropDbCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pD SSdb *pSdb = pMnode->pSdb; void *pIter = NULL; + while (1) { + SArbGroup *pArbGroup = NULL; + pIter = sdbFetch(pSdb, SDB_ARBGROUP, pIter, (void **)&pArbGroup); + if (pIter == NULL) break; + + if (pArbGroup->dbUid == pDb->uid) { + if (mndSetDropArbGroupCommitLogs(pTrans,pArbGroup) != 0) { + sdbCancelFetch(pSdb, pIter); + sdbRelease(pSdb, pArbGroup); + return -1; + } + } + + sdbRelease(pSdb, pArbGroup); + } + while (1) { SVgObj *pVgroup = NULL; pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); @@ -1277,7 +1364,7 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) { if (mndDropStreamByDb(pMnode, pTrans, pDb) != 0) goto _OVER; #ifdef TD_ENTERPRISE if (mndDropViewByDb(pMnode, pTrans, pDb) != 0) goto _OVER; -#endif +#endif if (mndDropSmasByDb(pMnode, pTrans, pDb) != 0) goto _OVER; if (mndDropIdxsByDb(pMnode, pTrans, pDb) != 0) goto _OVER; if (mndSetDropDbRedoActions(pMnode, pTrans, pDb) != 0) goto _OVER; @@ -1390,7 +1477,7 @@ static void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) { pEp->port = pDnode->port; } mndReleaseDnode(pMnode, pDnode); - if (pVgid->syncState == TAOS_SYNC_STATE_LEADER) { + if (pVgid->syncState == TAOS_SYNC_STATE_LEADER || pVgid->syncState == TAOS_SYNC_STATE_ASSIGNED_LEADER) { vgInfo.epSet.inUse = gid; } } @@ -1562,21 +1649,19 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs, int32_t numOfTable = mndGetDBTableNum(pDb, pMnode); - if (pDbCacheInfo->vgVersion >= pDb->vgVersion && - pDbCacheInfo->cfgVersion >= pDb->cfgVersion && - numOfTable == pDbCacheInfo->numOfTable && - pDbCacheInfo->stateTs == pDb->stateTs) { + if (pDbCacheInfo->vgVersion >= pDb->vgVersion && pDbCacheInfo->cfgVersion >= pDb->cfgVersion && + numOfTable == pDbCacheInfo->numOfTable && pDbCacheInfo->stateTs == pDb->stateTs) { mTrace("db:%s, valid dbinfo, vgVersion:%d cfgVersion:%d stateTs:%" PRId64 " numOfTables:%d, not changed vgVersion:%d cfgVersion:%d stateTs:%" PRId64 " numOfTables:%d", - pDbCacheInfo->dbFName, pDbCacheInfo->vgVersion, pDbCacheInfo->cfgVersion, pDbCacheInfo->stateTs, pDbCacheInfo->numOfTable, - pDb->vgVersion, pDb->cfgVersion, pDb->stateTs, numOfTable); + pDbCacheInfo->dbFName, pDbCacheInfo->vgVersion, pDbCacheInfo->cfgVersion, pDbCacheInfo->stateTs, + pDbCacheInfo->numOfTable, pDb->vgVersion, pDb->cfgVersion, pDb->stateTs, numOfTable); mndReleaseDb(pMnode, pDb); continue; } else { mInfo("db:%s, valid dbinfo, vgVersion:%d cfgVersion:%d stateTs:%" PRId64 " numOfTables:%d, changed to vgVersion:%d cfgVersion:%d stateTs:%" PRId64 " numOfTables:%d", - pDbCacheInfo->dbFName, pDbCacheInfo->vgVersion, pDbCacheInfo->cfgVersion, pDbCacheInfo->stateTs, pDbCacheInfo->numOfTable, - pDb->vgVersion, pDb->cfgVersion, pDb->stateTs, numOfTable); + pDbCacheInfo->dbFName, pDbCacheInfo->vgVersion, pDbCacheInfo->cfgVersion, pDbCacheInfo->stateTs, + pDbCacheInfo->numOfTable, pDb->vgVersion, pDb->cfgVersion, pDb->stateTs, numOfTable); } if (pDbCacheInfo->cfgVersion < pDb->cfgVersion) { @@ -1584,8 +1669,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs, mndDumpDbCfgInfo(rsp.cfgRsp, pDb); } - if (pDbCacheInfo->vgVersion < pDb->vgVersion || - numOfTable != pDbCacheInfo->numOfTable || + if (pDbCacheInfo->vgVersion < pDb->vgVersion || numOfTable != pDbCacheInfo->numOfTable || pDbCacheInfo->stateTs != pDb->stateTs) { rsp.useDbRsp = taosMemoryCalloc(1, sizeof(SUseDbRsp)); rsp.useDbRsp->pVgroupInfos = taosArrayInit(pDb->cfg.numOfVgroups, sizeof(SVgroupInfo)); @@ -1801,7 +1885,8 @@ bool mndIsDbReady(SMnode *pMnode, SDbObj *pDb) { if (pVgroup->dbUid == pDb->uid && pVgroup->replica > 1) { bool hasLeader = false; for (int32_t i = 0; i < pVgroup->replica; ++i) { - if (pVgroup->vnodeGid[i].syncState == TAOS_SYNC_STATE_LEADER) { + if (pVgroup->vnodeGid[i].syncState == TAOS_SYNC_STATE_LEADER || + pVgroup->vnodeGid[i].syncState == TAOS_SYNC_STATE_ASSIGNED_LEADER) { hasLeader = true; } } @@ -1991,6 +2076,9 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb, pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.keepTimeOffset, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, rows, (const char *)&pDb->cfg.withArbitrator, false); } taosMemoryFree(buf); diff --git a/source/dnode/mnode/impl/src/mndDef.c b/source/dnode/mnode/impl/src/mndDef.c index 5be641d1c2..3f69c7def3 100644 --- a/source/dnode/mnode/impl/src/mndDef.c +++ b/source/dnode/mnode/impl/src/mndDef.c @@ -249,7 +249,9 @@ void *tDecodeSMqVgEp(const void *buf, SMqVgEp *pVgEp, int8_t sver) { return (void *)buf; } -SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char *cgroup) { +static void *topicNameDup(void *p) { return taosStrdup((char *)p); } + +SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType, char *topic, SCMSubscribeReq *subscribe) { SMqConsumerObj *pConsumer = taosMemoryCalloc(1, sizeof(SMqConsumerObj)); if (pConsumer == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -264,36 +266,64 @@ SMqConsumerObj *tNewSMqConsumerObj(int64_t consumerId, char *cgroup) { pConsumer->hbStatus = 0; taosInitRWLatch(&pConsumer->lock); + pConsumer->createTime = taosGetTimestampMs(); + pConsumer->updateType = updateType; - pConsumer->currentTopics = taosArrayInit(0, sizeof(void *)); - pConsumer->rebNewTopics = taosArrayInit(0, sizeof(void *)); - pConsumer->rebRemovedTopics = taosArrayInit(0, sizeof(void *)); - pConsumer->assignedTopics = taosArrayInit(0, sizeof(void *)); + if (updateType == CONSUMER_ADD_REB){ + pConsumer->rebNewTopics = taosArrayInit(0, sizeof(void *)); + if(pConsumer->rebNewTopics == NULL){ + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto END; + } - if (pConsumer->currentTopics == NULL || pConsumer->rebNewTopics == NULL || pConsumer->rebRemovedTopics == NULL || - pConsumer->assignedTopics == NULL) { - taosArrayDestroy(pConsumer->currentTopics); - taosArrayDestroy(pConsumer->rebNewTopics); - taosArrayDestroy(pConsumer->rebRemovedTopics); - taosArrayDestroy(pConsumer->assignedTopics); - taosMemoryFree(pConsumer); - return NULL; + char* topicTmp = taosStrdup(topic); + taosArrayPush(pConsumer->rebNewTopics, &topicTmp); + }else if (updateType == CONSUMER_REMOVE_REB) { + pConsumer->rebRemovedTopics = taosArrayInit(0, sizeof(void *)); + if(pConsumer->rebRemovedTopics == NULL){ + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto END; + } + char* topicTmp = taosStrdup(topic); + taosArrayPush(pConsumer->rebRemovedTopics, &topicTmp); + }else if (updateType == CONSUMER_INSERT_SUB){ + tstrncpy(pConsumer->clientId, subscribe->clientId, tListLen(pConsumer->clientId)); + pConsumer->withTbName = subscribe->withTbName; + pConsumer->autoCommit = subscribe->autoCommit; + pConsumer->autoCommitInterval = subscribe->autoCommitInterval; + pConsumer->resetOffsetCfg = subscribe->resetOffsetCfg; + + + pConsumer->rebNewTopics = taosArrayDup(subscribe->topicNames, topicNameDup); + if (pConsumer->rebNewTopics == NULL){ + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto END; + } + pConsumer->assignedTopics = subscribe->topicNames; + subscribe->topicNames = NULL; + }else if (updateType == CONSUMER_UPDATE_SUB){ + pConsumer->assignedTopics = subscribe->topicNames; + subscribe->topicNames = NULL; } - pConsumer->createTime = taosGetTimestampMs(); - return pConsumer; + +END: + tDeleteSMqConsumerObj(pConsumer); + return NULL; } -void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer, bool delete) { +void tClearSMqConsumerObj(SMqConsumerObj *pConsumer) { if (pConsumer == NULL) return; taosArrayDestroyP(pConsumer->currentTopics, (FDelete)taosMemoryFree); taosArrayDestroyP(pConsumer->rebNewTopics, (FDelete)taosMemoryFree); taosArrayDestroyP(pConsumer->rebRemovedTopics, (FDelete)taosMemoryFree); taosArrayDestroyP(pConsumer->assignedTopics, (FDelete)taosMemoryFree); - if (delete) { - taosMemoryFree(pConsumer); - } +} + +void tDeleteSMqConsumerObj(SMqConsumerObj *pConsumer) { + tClearSMqConsumerObj(pConsumer); + taosMemoryFree(pConsumer); } int32_t tEncodeSMqConsumerObj(void **buf, const SMqConsumerObj *pConsumer) { @@ -548,6 +578,7 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) { } void tDeleteSubscribeObj(SMqSubscribeObj *pSub) { + if (pSub == NULL) return; void *pIter = NULL; while (1) { pIter = taosHashIterate(pSub->consumerHash, pIter); diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index befb6d3521..57c947eb81 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -33,7 +33,7 @@ #include "taos_monitor.h" #define TSDB_DNODE_VER_NUMBER 2 -#define TSDB_DNODE_RESERVE_SIZE 64 +#define TSDB_DNODE_RESERVE_SIZE 40 static const char *offlineReason[] = { "", @@ -183,11 +183,10 @@ static SSdbRaw *mndDnodeActionEncode(SDnodeObj *pDnode) { SDB_SET_INT64(pRaw, dataPos, pDnode->updateTime, _OVER) SDB_SET_INT16(pRaw, dataPos, pDnode->port, _OVER) SDB_SET_BINARY(pRaw, dataPos, pDnode->fqdn, TSDB_FQDN_LEN, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pDnode->machineId, TSDB_MACHINE_ID_LEN, _OVER) SDB_SET_RESERVE(pRaw, dataPos, TSDB_DNODE_RESERVE_SIZE, _OVER) - SDB_SET_INT16(pRaw, dataPos, TSDB_ACTIVE_KEY_LEN, _OVER) - SDB_SET_BINARY(pRaw, dataPos, pDnode->active, TSDB_ACTIVE_KEY_LEN, _OVER) - SDB_SET_INT16(pRaw, dataPos, TSDB_CONN_ACTIVE_KEY_LEN, _OVER) - SDB_SET_BINARY(pRaw, dataPos, pDnode->connActive, TSDB_CONN_ACTIVE_KEY_LEN, _OVER) + SDB_SET_INT16(pRaw, dataPos, 0, _OVER) // forward/backward compatible + SDB_SET_INT16(pRaw, dataPos, 0, _OVER) // forward/backward compatible SDB_SET_DATALEN(pRaw, dataPos, _OVER); terrno = 0; @@ -227,13 +226,14 @@ static SSdbRow *mndDnodeActionDecode(SSdbRaw *pRaw) { SDB_GET_INT64(pRaw, dataPos, &pDnode->updateTime, _OVER) SDB_GET_INT16(pRaw, dataPos, &pDnode->port, _OVER) SDB_GET_BINARY(pRaw, dataPos, pDnode->fqdn, TSDB_FQDN_LEN, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pDnode->machineId, TSDB_MACHINE_ID_LEN, _OVER) SDB_GET_RESERVE(pRaw, dataPos, TSDB_DNODE_RESERVE_SIZE, _OVER) if (sver > 1) { int16_t keyLen = 0; SDB_GET_INT16(pRaw, dataPos, &keyLen, _OVER) - SDB_GET_BINARY(pRaw, dataPos, pDnode->active, keyLen, _OVER) + SDB_GET_BINARY(pRaw, dataPos, NULL, keyLen, _OVER) SDB_GET_INT16(pRaw, dataPos, &keyLen, _OVER) - SDB_GET_BINARY(pRaw, dataPos, pDnode->connActive, keyLen, _OVER) + SDB_GET_BINARY(pRaw, dataPos, NULL, keyLen, _OVER) } terrno = 0; @@ -271,12 +271,7 @@ static int32_t mndDnodeActionUpdate(SSdb *pSdb, SDnodeObj *pOld, SDnodeObj *pNew mTrace("dnode:%d, perform update action, old row:%p new row:%p", pOld->id, pOld, pNew); pOld->updateTime = pNew->updateTime; #ifdef TD_ENTERPRISE - if (strncmp(pOld->active, pNew->active, TSDB_ACTIVE_KEY_LEN) != 0) { - strncpy(pOld->active, pNew->active, TSDB_ACTIVE_KEY_LEN); - } - if (strncmp(pOld->connActive, pNew->connActive, TSDB_CONN_ACTIVE_KEY_LEN) != 0) { - strncpy(pOld->connActive, pNew->connActive, TSDB_CONN_ACTIVE_KEY_LEN); - } + tstrncpy(pOld->machineId, pNew->machineId, TSDB_MACHINE_ID_LEN + 1); #endif return 0; } @@ -311,6 +306,17 @@ SEpSet mndGetDnodeEpset(SDnodeObj *pDnode) { return epSet; } +SEpSet mndGetDnodeEpsetById(SMnode *pMnode, int32_t dnodeId) { + SEpSet epSet = {0}; + SDnodeObj *pDnode = mndAcquireDnode(pMnode, dnodeId); + if (!pDnode) return epSet; + + epSet = mndGetDnodeEpset(pDnode); + + mndReleaseDnode(pMnode, pDnode); + return epSet; +} + static SDnodeObj *mndAcquireDnodeByEp(SMnode *pMnode, char *pEpStr) { SSdb *pSdb = pMnode->pSdb; @@ -705,6 +711,35 @@ _OVER: */ } +static int32_t mndUpdateDnodeObj(SMnode *pMnode, SDnodeObj *pDnode) { + int32_t code = 0; + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, NULL, "update-dnode-obj"); + if (pTrans == NULL) { + code = terrno; + goto _exit; + } + + pDnode->updateTime = taosGetTimestampMs(); + + SSdbRaw *pCommitRaw = mndDnodeActionEncode(pDnode); + if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) { + mError("trans:%d, failed to append commit log since %s", pTrans->id, terrstr()); + code = terrno; + goto _exit; + } + (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); + + if (mndTransPrepare(pMnode, pTrans) != 0) { + mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); + code = terrno; + goto _exit; + } + +_exit: + mndTransDrop(pTrans); + return code; +} + static int32_t mndProcessStatusReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; SStatusReq statusReq = {0}; @@ -776,7 +811,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { SVgObj *pVgroup = mndAcquireVgroup(pMnode, pVload->vgId); if (pVgroup != NULL) { - if (pVload->syncState == TAOS_SYNC_STATE_LEADER) { + if (pVload->syncState == TAOS_SYNC_STATE_LEADER || pVload->syncState == TAOS_SYNC_STATE_ASSIGNED_LEADER) { pVgroup->cacheUsage = pVload->cacheUsage; pVgroup->numOfCachedTables = pVload->numOfCachedTables; pVgroup->numOfTables = pVload->numOfTables; @@ -874,8 +909,9 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { pDnode->numOfDiskCfg = statusReq.numOfDiskCfg; pDnode->memAvail = statusReq.memAvail; pDnode->memTotal = statusReq.memTotal; - if (pDnode->machineId[0] == 0 && statusReq.machineId[0] != 0) { + if (memcmp(pDnode->machineId, statusReq.machineId, TSDB_MACHINE_ID_LEN) != 0) { tstrncpy(pDnode->machineId, statusReq.machineId, TSDB_MACHINE_ID_LEN + 1); + mndUpdateDnodeObj(pMnode, pDnode); } SStatusRsp statusRsp = {0}; diff --git a/source/dnode/mnode/impl/src/mndIndex.c b/source/dnode/mnode/impl/src/mndIndex.c index 622ed0080f..f2e2c556cf 100644 --- a/source/dnode/mnode/impl/src/mndIndex.c +++ b/source/dnode/mnode/impl/src/mndIndex.c @@ -597,6 +597,7 @@ static int32_t mndSetUpdateIdxStbCommitLogs(SMnode *pMnode, STrans *pTrans, SStb taosRUnLockLatch(&pOld->lock); pNew->pTags = NULL; + pNew->pColumns = NULL; pNew->updateTime = taosGetTimestampMs(); pNew->lock = 0; diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index 69a0bd477d..ee7cd83a8c 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -15,6 +15,7 @@ #define _DEFAULT_SOURCE #include "mndAcct.h" +#include "mndArbGroup.h" #include "mndCluster.h" #include "mndCompact.h" #include "mndCompactDetail.h" @@ -140,6 +141,22 @@ static void mndPullupTrimDb(SMnode *pMnode) { tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); } +static int32_t mndPullupArbHeartbeat(SMnode *pMnode) { + mTrace("pullup arb hb"); + int32_t contLen = 0; + void *pReq = mndBuildTimerMsg(&contLen); + SRpcMsg rpcMsg = {.msgType = TDMT_MND_ARB_HEARTBEAT_TIMER, .pCont = pReq, .contLen = contLen, .info.noResp = 1}; + return tmsgPutToQueue(&pMnode->msgCb, ARB_QUEUE, &rpcMsg); +} + +static int32_t mndPullupArbCheckSync(SMnode *pMnode) { + mTrace("pullup arb sync"); + int32_t contLen = 0; + void *pReq = mndBuildTimerMsg(&contLen); + SRpcMsg rpcMsg = {.msgType = TDMT_MND_ARB_CHECK_SYNC_TIMER, .pCont = pReq, .contLen = contLen, .info.noResp = 1}; + return tmsgPutToQueue(&pMnode->msgCb, ARB_QUEUE, &rpcMsg); +} + static void mndCalMqRebalance(SMnode *pMnode) { int32_t contLen = 0; void *pReq = mndBuildTimerMsg(&contLen); @@ -391,6 +408,18 @@ static void *mndThreadFp(void *param) { continue; } mndDoTimerPullupTask(pMnode, sec); + + if (sec % (tsArbHeartBeatIntervalSec) == 0) { + if (mndPullupArbHeartbeat(pMnode) != 0) { + mError("failed to pullup arb heartbeat, since:%s", terrstr()); + } + } + + if (sec % (tsArbCheckSyncIntervalSec) == 0) { + if (mndPullupArbCheckSync(pMnode) != 0) { + mError("failed to pullup arb check sync, since:%s", terrstr()); + } + } } return NULL; @@ -513,6 +542,7 @@ static int32_t mndInitSteps(SMnode *pMnode) { if (mndAllocStep(pMnode, "mnode-mnode", mndInitMnode, mndCleanupMnode) != 0) return -1; if (mndAllocStep(pMnode, "mnode-qnode", mndInitQnode, mndCleanupQnode) != 0) return -1; if (mndAllocStep(pMnode, "mnode-snode", mndInitSnode, mndCleanupSnode) != 0) return -1; + if (mndAllocStep(pMnode, "mnode-arbgroup", mndInitArbGroup, mndCleanupArbGroup) != 0) return -1; if (mndAllocStep(pMnode, "mnode-dnode", mndInitDnode, mndCleanupDnode) != 0) return -1; if (mndAllocStep(pMnode, "mnode-user", mndInitUser, mndCleanupUser) != 0) return -1; if (mndAllocStep(pMnode, "mnode-grant", mndInitGrant, mndCleanupGrant) != 0) return -1; @@ -694,6 +724,13 @@ ESyncRole mndGetRole(SMnode *pMnode) { return syncGetRole(rid); } +int64_t mndGetTerm(SMnode *pMnode) { + int64_t rid = pMnode->syncMgmt.sync; + return syncGetTerm(rid); +} + +int32_t mndGetArbToken(SMnode *pMnode, char *outToken) { return syncGetArbToken(pMnode->syncMgmt.sync, outToken); } + void mndStop(SMnode *pMnode) { mndSetStop(pMnode); mndSyncStop(pMnode); @@ -768,7 +805,8 @@ _OVER: pMsg->msgType == TDMT_MND_TRIM_DB_TIMER || pMsg->msgType == TDMT_MND_UPTIME_TIMER || pMsg->msgType == TDMT_MND_COMPACT_TIMER || pMsg->msgType == TDMT_MND_NODECHECK_TIMER || pMsg->msgType == TDMT_MND_GRANT_HB_TIMER || pMsg->msgType == TDMT_MND_STREAM_CHECKPOINT_CANDIDITATE || - pMsg->msgType == TDMT_MND_STREAM_CHECKPOINT_TIMER || pMsg->msgType == TDMT_MND_STREAM_REQ_CHKPT) { + pMsg->msgType == TDMT_MND_STREAM_CHECKPOINT_TIMER || pMsg->msgType == TDMT_MND_STREAM_REQ_CHKPT || + pMsg->msgType == TDMT_MND_ARB_HEARTBEAT_TIMER || pMsg->msgType == TDMT_MND_ARB_CHECK_SYNC_TIMER) { mTrace("timer not process since mnode restored:%d stopped:%d, sync restored:%d role:%s ", pMnode->restored, pMnode->stopped, state.restored, syncStr(state.state)); return -1; @@ -951,7 +989,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr pVnDesc->dnode_id = pVgid->dnodeId; tstrncpy(pVnDesc->vnode_role, syncStr(pVgid->syncState), sizeof(pVnDesc->vnode_role)); pVnDesc->syncState = pVgid->syncState; - if (pVgid->syncState == TAOS_SYNC_STATE_LEADER) { + if (pVgid->syncState == TAOS_SYNC_STATE_LEADER || pVgid->syncState == TAOS_SYNC_STATE_ASSIGNED_LEADER) { tstrncpy(desc.status, "ready", sizeof(desc.status)); pClusterInfo->vgroups_alive++; } diff --git a/source/dnode/mnode/impl/src/mndQnode.c b/source/dnode/mnode/impl/src/mndQnode.c index 2f4ad69e2a..b86f14e698 100644 --- a/source/dnode/mnode/impl/src/mndQnode.c +++ b/source/dnode/mnode/impl/src/mndQnode.c @@ -189,7 +189,7 @@ int32_t mndSetCreateQnodeCommitLogs(STrans *pTrans, SQnodeObj *pObj) { return 0; } -bool mndQnodeInDnode(SQnodeObj *pQnode, int32_t dnodeId) { +bool mndQnodeInDnode(SQnodeObj *pQnode, int32_t dnodeId) { return pQnode->pDnode->id == dnodeId; } @@ -434,7 +434,7 @@ _OVER: } mndReleaseQnode(pMnode, pObj); - tFreeSMCreateQnodeReq(&dropReq); + tFreeSDDropQnodeReq(&dropReq); return code; } diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index f887d05d37..b3124fa99f 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -67,6 +67,8 @@ static int32_t convertToRetrieveType(char *name, int32_t len) { type = TSDB_MGMT_TABLE_QNODE; } else if (strncasecmp(name, TSDB_INS_TABLE_SNODES, len) == 0) { type = TSDB_MGMT_TABLE_SNODE; + } else if (strncasecmp(name, TSDB_INS_TABLE_ARBGROUPS, len) == 0) { + type = TSDB_MGMT_TABLE_ARBGROUP; } else if (strncasecmp(name, TSDB_INS_TABLE_CLUSTER, len) == 0) { type = TSDB_MGMT_TABLE_CLUSTER; } else if (strncasecmp(name, TSDB_INS_TABLE_DATABASES, len) == 0) { diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index bf88efdf10..9c86ecdbdd 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -554,6 +554,7 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre createReq.numOfColumns = pStream->outputSchema.nCols; createReq.numOfTags = 1; // group id createReq.pColumns = taosArrayInit_s(sizeof(SField), createReq.numOfColumns); + // build fields for (int32_t i = 0; i < createReq.numOfColumns; i++) { SField *pField = taosArrayGet(createReq.pColumns, i); @@ -627,12 +628,15 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre mndFreeStb(&stbObj); mndReleaseStb(pMnode, pStb); mndReleaseDb(pMnode, pDb); - + mDebug("stream:%s create dst stable:%s, cols:%d", pStream->name, pStream->targetSTbName, pStream->outputSchema.nCols); return 0; + _OVER: tFreeSMCreateStbReq(&createReq); mndReleaseStb(pMnode, pStb); mndReleaseDb(pMnode, pDb); + + mDebug("stream:%s failed to create dst stable:%s, code:%s", pStream->name, pStream->targetSTbName, tstrerror(terrno)); return -1; } @@ -688,7 +692,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { terrno = TSDB_CODE_MND_INVALID_PLATFORM; goto _OVER; #endif - mInfo("stream:%s, start to create, sql:%s", createReq.name, createReq.sql); + mInfo("stream:%s, start to create stream, sql:%s", createReq.name, createReq.sql); if (mndCheckCreateStreamReq(&createReq) != 0) { mError("stream:%s, failed to create since %s", createReq.name, terrstr()); @@ -725,17 +729,20 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { goto _OVER; } - STrans *pTrans = doCreateTrans(pMnode, &streamObj, pReq, MND_STREAM_CREATE_NAME, "create stream tasks on dnodes"); + STrans *pTrans = doCreateTrans(pMnode, &streamObj, pReq, TRN_CONFLICT_DB, MND_STREAM_CREATE_NAME, "create stream tasks on dnodes"); if (pTrans == NULL) { goto _OVER; } // create stb for stream - if (createReq.createStb == STREAM_CREATE_STABLE_TRUE && - mndCreateStbForStream(pMnode, pTrans, &streamObj, pReq->info.conn.user) < 0) { - mError("trans:%d, failed to create stb for stream %s since %s", pTrans->id, createReq.name, terrstr()); - mndTransDrop(pTrans); - goto _OVER; + if (createReq.createStb == STREAM_CREATE_STABLE_TRUE) { + if (mndCreateStbForStream(pMnode, pTrans, &streamObj, pReq->info.conn.user) < 0) { + mError("trans:%d, failed to create stb for stream %s since %s", pTrans->id, createReq.name, terrstr()); + mndTransDrop(pTrans); + goto _OVER; + } + } else { + mDebug("stream:%s no need create stable", createReq.name); } // schedule stream task for stream obj @@ -765,7 +772,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { // add into buffer firstly // to make sure when the hb from vnode arrived, the newly created tasks have been in the task map already. taosThreadMutexLock(&execInfo.lock); - mDebug("stream stream:%s tasks register into node list", createReq.name); + mDebug("stream stream:%s start to register tasks into task_node_list", createReq.name); saveStreamTasksInfo(&streamObj, &execInfo); taosThreadMutexUnlock(&execInfo.lock); @@ -931,7 +938,7 @@ static int32_t mndProcessStreamCheckpointTrans(SMnode *pMnode, SStreamObj *pStre return -1; } - STrans *pTrans = doCreateTrans(pMnode, pStream, NULL, MND_STREAM_CHECKPOINT_NAME, "gen checkpoint for stream"); + STrans *pTrans = doCreateTrans(pMnode, pStream, NULL, TRN_CONFLICT_NOTHING, MND_STREAM_CHECKPOINT_NAME, "gen checkpoint for stream"); if (pTrans == NULL) { mError("failed to checkpoint of stream name%s, checkpointId: %" PRId64 ", reason:%s", pStream->name, checkpointId, tstrerror(TSDB_CODE_MND_TRANS_CONFLICT)); @@ -1184,7 +1191,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, TRN_CONFLICT_NOTHING, MND_STREAM_DROP_NAME, "drop stream"); if (pTrans == NULL) { mError("stream:%s, failed to drop since %s", dropReq.name, terrstr()); sdbRelease(pMnode->pSdb, pStream); @@ -1549,6 +1556,8 @@ static int32_t mndRetrieveStreamTask(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock } } + pBlock->info.rows = numOfRows; + destroyStreamTaskIter(pIter); taosRUnLockLatch(&pStream->lock); @@ -1612,7 +1621,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, TRN_CONFLICT_NOTHING, 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); @@ -1701,7 +1710,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, TRN_CONFLICT_NOTHING, 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); @@ -1833,7 +1842,7 @@ static int32_t mndProcessVgroupChange(SMnode *pMnode, SVgroupChangeInfo *pChange // here create only one trans if (pTrans == NULL) { - pTrans = doCreateTrans(pMnode, pStream, NULL, MND_STREAM_TASK_UPDATE_NAME, "update task epsets"); + pTrans = doCreateTrans(pMnode, pStream, NULL, TRN_CONFLICT_NOTHING, MND_STREAM_TASK_UPDATE_NAME, "update task epsets"); if (pTrans == NULL) { sdbRelease(pSdb, pStream); sdbCancelFetch(pSdb, pIter); diff --git a/source/dnode/mnode/impl/src/mndStreamHb.c b/source/dnode/mnode/impl/src/mndStreamHb.c index 14f3c533e3..c8f943b931 100644 --- a/source/dnode/mnode/impl/src/mndStreamHb.c +++ b/source/dnode/mnode/impl/src/mndStreamHb.c @@ -66,7 +66,7 @@ static void addIntoCheckpointList(SArray* pList, const SFailedCheckpointInfo* pI } int32_t mndCreateStreamResetStatusTrans(SMnode *pMnode, SStreamObj *pStream) { - STrans *pTrans = doCreateTrans(pMnode, pStream, NULL, MND_STREAM_TASK_RESET_NAME, " reset from failed checkpoint"); + STrans *pTrans = doCreateTrans(pMnode, pStream, NULL, TRN_CONFLICT_NOTHING, MND_STREAM_TASK_RESET_NAME, " reset from failed checkpoint"); if (pTrans == NULL) { return terrno; } @@ -156,7 +156,7 @@ static int32_t mndDropOrphanTasks(SMnode* pMnode, SArray* pList) { } SStreamObj dummyObj = {.uid = pTask->streamId, .sourceDb = "", .targetSTbName = ""}; - STrans* pTrans = doCreateTrans(pMnode, &dummyObj, NULL, MND_STREAM_DROP_NAME, "drop stream"); + STrans* pTrans = doCreateTrans(pMnode, &dummyObj, NULL, TRN_CONFLICT_NOTHING, MND_STREAM_DROP_NAME, "drop stream"); if (pTrans == NULL) { mError("failed to create trans to drop orphan tasks since %s", terrstr()); return -1; diff --git a/source/dnode/mnode/impl/src/mndStreamTrans.c b/source/dnode/mnode/impl/src/mndStreamTrans.c index 2241d93465..16b735fbc4 100644 --- a/source/dnode/mnode/impl/src/mndStreamTrans.c +++ b/source/dnode/mnode/impl/src/mndStreamTrans.c @@ -161,8 +161,8 @@ int32_t mndAddtoCheckpointWaitingList(SStreamObj* pStream, int64_t checkpointId) return TSDB_CODE_SUCCESS; } -STrans *doCreateTrans(SMnode *pMnode, SStreamObj *pStream, SRpcMsg *pReq, const char *name, const char *pMsg) { - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, name); +STrans *doCreateTrans(SMnode *pMnode, SStreamObj *pStream, SRpcMsg *pReq, ETrnConflct conflict, const char *name, const char *pMsg) { + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, conflict, pReq, name); if (pTrans == NULL) { mError("failed to build trans:%s, reason: %s", name, tstrerror(TSDB_CODE_OUT_OF_MEMORY)); terrno = TSDB_CODE_OUT_OF_MEMORY; diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index fbdfd81cdf..a6d7a24323 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -41,9 +41,9 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg); static int32_t mndProcessDropCgroupReq(SRpcMsg *pMsg); static int32_t mndRetrieveSubscribe(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextSubscribe(SMnode *pMnode, void *pIter); -static int32_t mndCheckConsumer(SRpcMsg *pMsg, SHashObj* hash); +static void mndCheckConsumer(SRpcMsg *pMsg, SHashObj* hash); -static int32_t mndSetSubCommitLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeObj *pSub) { +static int32_t mndSetSubCommitLogs(STrans *pTrans, SMqSubscribeObj *pSub) { SSdbRaw *pCommitRaw = mndSubActionEncode(pSub); if (pCommitRaw == NULL) return -1; if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) return -1; @@ -223,47 +223,44 @@ static SMqRebInfo *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) { return pRebInfo; } -static void doRemoveLostConsumers(SMqRebOutputObj *pOutput, SHashObj *pHash, const SMqRebInputObj *pInput) { - int32_t numOfRemoved = taosArrayGetSize(pInput->pRebInfo->removedConsumers); - const char *pSubKey = pOutput->pSub->key; +static void pushVgDataToHash(SArray *vgs, SHashObj *pHash, int64_t consumerId, char* key){ + SMqVgEp *pVgEp = *(SMqVgEp **)taosArrayPop(vgs); + SMqRebOutputVg outputVg = {consumerId, -1, pVgEp}; + taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); + mInfo("[rebalance] sub:%s mq rebalance remove vgId:%d from consumer:0x%" PRIx64, + key, pVgEp->vgId, consumerId); +} +static void processRemovedConsumers(SMqRebOutputObj *pOutput, SHashObj *pHash, const SMqRebInputObj *pInput) { + int32_t numOfRemoved = taosArrayGetSize(pInput->pRebInfo->removedConsumers); int32_t actualRemoved = 0; for (int32_t i = 0; i < numOfRemoved; i++) { uint64_t consumerId = *(uint64_t *)taosArrayGet(pInput->pRebInfo->removedConsumers, i); - SMqConsumerEp *pConsumerEp = taosHashGet(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t)); - - // consumer exists till now - if (pConsumerEp) { - actualRemoved++; - - int32_t consumerVgNum = taosArrayGetSize(pConsumerEp->vgs); - for (int32_t j = 0; j < consumerVgNum; j++) { - SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, j); - - SMqRebOutputVg outputVg = {.oldConsumerId = consumerId, .newConsumerId = -1, .pVgEp = pVgEp}; - taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("sub:%s mq re-balance remove vgId:%d from consumer:0x%" PRIx64, pSubKey, pVgEp->vgId, consumerId); - } - - taosArrayDestroy(pConsumerEp->vgs); - taosHashRemove(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t)); - - // put into removed - taosArrayPush(pOutput->removedConsumers, &consumerId); + if (pConsumerEp == NULL) { + continue; } + + int32_t consumerVgNum = taosArrayGetSize(pConsumerEp->vgs); + for (int32_t j = 0; j < consumerVgNum; j++) { + pushVgDataToHash(pConsumerEp->vgs, pHash, consumerId, pOutput->pSub->key); + } + + taosArrayDestroy(pConsumerEp->vgs); + taosHashRemove(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t)); + taosArrayPush(pOutput->removedConsumers, &consumerId); + actualRemoved++; } if (numOfRemoved != actualRemoved) { - mError("sub:%s mq re-balance removedNum:%d not matched with actual:%d", pSubKey, numOfRemoved, actualRemoved); + mError("[rebalance] sub:%s mq rebalance removedNum:%d not matched with actual:%d", pOutput->pSub->key, numOfRemoved, actualRemoved); } else { - mInfo("sub:%s removed %d consumers", pSubKey, numOfRemoved); + mInfo("[rebalance] sub:%s removed %d consumers", pOutput->pSub->key, numOfRemoved); } } -static void doAddNewConsumers(SMqRebOutputObj *pOutput, const SMqRebInputObj *pInput) { +static void processNewConsumers(SMqRebOutputObj *pOutput, const SMqRebInputObj *pInput) { int32_t numOfNewConsumers = taosArrayGetSize(pInput->pRebInfo->newConsumers); - const char *pSubKey = pOutput->pSub->key; for (int32_t i = 0; i < numOfNewConsumers; i++) { int64_t consumerId = *(int64_t *)taosArrayGet(pInput->pRebInfo->newConsumers, i); @@ -274,24 +271,14 @@ static void doAddNewConsumers(SMqRebOutputObj *pOutput, const SMqRebInputObj *pI taosHashPut(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t), &newConsumerEp, sizeof(SMqConsumerEp)); taosArrayPush(pOutput->newConsumers, &consumerId); - mInfo("sub:%s mq rebalance add new consumer:0x%" PRIx64, pSubKey, consumerId); + mInfo("[rebalance] sub:%s mq rebalance add new consumer:0x%" PRIx64, pOutput->pSub->key, consumerId); } } -static void addUnassignedVgroups(SMqRebOutputObj *pOutput, SHashObj *pHash) { - const char *pSubKey = pOutput->pSub->key; +static void processUnassignedVgroups(SMqRebOutputObj *pOutput, SHashObj *pHash) { int32_t numOfVgroups = taosArrayGetSize(pOutput->pSub->unassignedVgs); - for (int32_t i = 0; i < numOfVgroups; i++) { - SMqVgEp *pVgEp = *(SMqVgEp **)taosArrayPop(pOutput->pSub->unassignedVgs); - SMqRebOutputVg rebOutput = { - .oldConsumerId = -1, - .newConsumerId = -1, - .pVgEp = pVgEp, - }; - - taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &rebOutput, sizeof(SMqRebOutputVg)); - mInfo("sub:%s mq re-balance addUnassignedVgroups vgId:%d from unassigned", pSubKey, pVgEp->vgId); + pushVgDataToHash(pOutput->pSub->unassignedVgs, pHash, -1, pOutput->pSub->key); } } @@ -307,11 +294,9 @@ static void addUnassignedVgroups(SMqRebOutputObj *pOutput, SHashObj *pHash) { // } //} -static void transferVgroupsForConsumers(SMqRebOutputObj *pOutput, SHashObj *pHash, int32_t minVgCnt, - int32_t imbConsumerNum) { - const char *pSubKey = pOutput->pSub->key; - - int32_t imbCnt = 0; +static void processModifiedConsumers(SMqRebOutputObj *pOutput, SHashObj *pHash, int32_t minVgCnt, + int32_t remainderVgCnt) { + int32_t cnt = 0; void *pIter = NULL; while (1) { @@ -323,36 +308,16 @@ static void transferVgroupsForConsumers(SMqRebOutputObj *pOutput, SHashObj *pHas SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; int32_t consumerVgNum = taosArrayGetSize(pConsumerEp->vgs); - // all old consumers still existing need to be modified - // TODO optimize: modify only consumer whose vgs changed taosArrayPush(pOutput->modifyConsumers, &pConsumerEp->consumerId); if (consumerVgNum > minVgCnt) { - if (imbCnt < imbConsumerNum) { - // pop until equal minVg + 1 - while (taosArrayGetSize(pConsumerEp->vgs) > minVgCnt + 1) { - SMqVgEp *pVgEp = *(SMqVgEp **)taosArrayPop(pConsumerEp->vgs); - SMqRebOutputVg outputVg = { - .oldConsumerId = pConsumerEp->consumerId, - .newConsumerId = -1, - .pVgEp = pVgEp, - }; - taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("sub:%s mq rebalance remove vgId:%d from consumer:0x%" PRIx64 ",(first scan)", pSubKey, pVgEp->vgId, - pConsumerEp->consumerId); + if (cnt < remainderVgCnt) { + while (taosArrayGetSize(pConsumerEp->vgs) > minVgCnt + 1) { // pop until equal minVg + 1 + pushVgDataToHash(pConsumerEp->vgs, pHash, pConsumerEp->consumerId, pOutput->pSub->key); } - imbCnt++; + cnt++; } else { - // all the remain consumers should only have the number of vgroups, which is equalled to the value of minVg while (taosArrayGetSize(pConsumerEp->vgs) > minVgCnt) { - SMqVgEp *pVgEp = *(SMqVgEp **)taosArrayPop(pConsumerEp->vgs); - SMqRebOutputVg outputVg = { - .oldConsumerId = pConsumerEp->consumerId, - .newConsumerId = -1, - .pVgEp = pVgEp, - }; - taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("sub:%s mq rebalance remove vgId:%d from consumer:0x%" PRIx64 ",(first scan)", pSubKey, pVgEp->vgId, - pConsumerEp->consumerId); + pushVgDataToHash(pConsumerEp->vgs, pHash, pConsumerEp->consumerId, pOutput->pSub->key); } } } @@ -404,7 +369,7 @@ static int32_t processRemoveAddVgs(SMnode *pMnode, SMqRebOutputObj *pOutput){ } } if(!find){ - mInfo("processRemoveAddVgs old vgId:%d", pVgEp->vgId); + mInfo("[rebalance] processRemoveAddVgs old vgId:%d", pVgEp->vgId); tDeleteSMqVgEp(pVgEp); taosArrayRemove(pConsumerEp->vgs, j); continue; @@ -415,7 +380,7 @@ static int32_t processRemoveAddVgs(SMnode *pMnode, SMqRebOutputObj *pOutput){ if(taosArrayGetSize(pOutput->pSub->unassignedVgs) == 0 && taosArrayGetSize(newVgs) != 0){ taosArrayAddAll(pOutput->pSub->unassignedVgs, newVgs); - mInfo("processRemoveAddVgs add new vg num:%d", (int)taosArrayGetSize(newVgs)); + mInfo("[rebalance] processRemoveAddVgs add new vg num:%d", (int)taosArrayGetSize(newVgs)); taosArrayDestroy(newVgs); }else{ taosArrayDestroyP(newVgs, (FDelete)tDeleteSMqVgEp); @@ -423,194 +388,229 @@ static int32_t processRemoveAddVgs(SMnode *pMnode, SMqRebOutputObj *pOutput){ return totalVgNum; } -static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput) { - int32_t totalVgNum = processRemoveAddVgs(pMnode, pOutput); - const char *pSubKey = pOutput->pSub->key; - - int32_t numOfRemoved = taosArrayGetSize(pInput->pRebInfo->removedConsumers); - int32_t numOfAdded = taosArrayGetSize(pInput->pRebInfo->newConsumers); - mInfo("sub:%s mq re-balance %d vgroups, existed consumers:%d, added:%d, removed:%d", pSubKey, totalVgNum, - pInput->oldConsumerNum, numOfAdded, numOfRemoved); - - // 1. build temporary hash(vgId -> SMqRebOutputVg) to store vg that need to be assigned - SHashObj *pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); - - // 2. check and get actual removed consumers, put their vg into pHash - doRemoveLostConsumers(pOutput, pHash, pInput); - - // 3. if previously no consumer, there are vgs not assigned, put these vg into pHash - addUnassignedVgroups(pOutput, pHash); - - // 4. calc vg number of each consumer - int32_t numOfFinal = pInput->oldConsumerNum + numOfAdded - numOfRemoved; - - int32_t minVgCnt = 0; - int32_t imbConsumerNum = 0; - - // calc num - if (numOfFinal) { - minVgCnt = totalVgNum / numOfFinal; - imbConsumerNum = totalVgNum % numOfFinal; - mInfo("sub:%s mq re-balance %d consumers: at least %d vgs each, %d consumers has 1 more vgroups than avg value", - pSubKey, numOfFinal, minVgCnt, imbConsumerNum); - } else { - mInfo("sub:%s no consumer subscribe this topic", pSubKey); - } - - // 5. remove vgroups from consumers who have more vgroups than the threshold value(minVgCnt or minVgCnt + 1), and then another vg into pHash - transferVgroupsForConsumers(pOutput, pHash, minVgCnt, imbConsumerNum); - - // 6. add new consumer into sub - doAddNewConsumers(pOutput, pInput); - - SMqRebOutputVg *pRebVg = NULL; - void *pRemovedIter = NULL; - void *pIter = NULL; - - // 7. extract bgroups from pHash and assign to consumers that do not have enough vgroups - while (1) { - pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); - if (pIter == NULL) { - break; - } - - SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; - - // push until equal minVg - while (taosArrayGetSize(pConsumerEp->vgs) < minVgCnt) { - // iter hash and find one vg - pRemovedIter = taosHashIterate(pHash, pRemovedIter); - if (pRemovedIter == NULL) { - mError("sub:%s removed iter is null, never can reach hear", pSubKey); - break; - } - - pRebVg = (SMqRebOutputVg *)pRemovedIter; - pRebVg->newConsumerId = pConsumerEp->consumerId; - taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp); - mInfo("mq rebalance: add vgId:%d to consumer:0x%" PRIx64 " for average", pRebVg->pVgEp->vgId, pConsumerEp->consumerId); - } - } - - while (1) { - pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); - if (pIter == NULL) { - break; - } - SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; - - if (taosArrayGetSize(pConsumerEp->vgs) == minVgCnt) { - pRemovedIter = taosHashIterate(pHash, pRemovedIter); - if (pRemovedIter == NULL) { - mInfo("sub:%s removed iter is null", pSubKey); - break; - } - - pRebVg = (SMqRebOutputVg *)pRemovedIter; - pRebVg->newConsumerId = pConsumerEp->consumerId; - taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp); - mInfo("mq rebalance: add vgId:%d to consumer:0x%" PRIx64 " for average + 1", pRebVg->pVgEp->vgId, pConsumerEp->consumerId); - } - } - - // All assigned vg should be put into pOutput->rebVgs - if(pRemovedIter != NULL){ - mError("sub:%s error pRemovedIter should be NULL", pSubKey); - } - while (1) { - pRemovedIter = taosHashIterate(pHash, pRemovedIter); - if (pRemovedIter == NULL) { - break; - } - - SMqRebOutputVg* pRebOutput = (SMqRebOutputVg *)pRemovedIter; - taosArrayPush(pOutput->rebVgs, pRebOutput); - if(taosHashGetSize(pOutput->pSub->consumerHash) == 0){ // if all consumer is removed - taosArrayPush(pOutput->pSub->unassignedVgs, &pRebOutput->pVgEp); // put all vg into unassigned - } - } - +static void processSubOffsetRows(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput){ SMqSubscribeObj *pSub = mndAcquireSubscribeByKey(pMnode, pInput->pRebInfo->key); // put all offset rows - if (pSub) { - taosRLockLatch(&pSub->lock); - if (pOutput->pSub->offsetRows == NULL) { - pOutput->pSub->offsetRows = taosArrayInit(4, sizeof(OffsetRows)); - } - pIter = NULL; - while (1) { - pIter = taosHashIterate(pSub->consumerHash, pIter); - if (pIter == NULL) break; - SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; - SMqConsumerEp *pConsumerEpNew = taosHashGet(pOutput->pSub->consumerHash, &pConsumerEp->consumerId, sizeof(int64_t)); + if (pSub == NULL) { + return; + } + taosRLockLatch(&pSub->lock); + if (pOutput->pSub->offsetRows == NULL) { + pOutput->pSub->offsetRows = taosArrayInit(4, sizeof(OffsetRows)); + } + void *pIter = NULL; + while (1) { + pIter = taosHashIterate(pSub->consumerHash, pIter); + if (pIter == NULL) break; + SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; + SMqConsumerEp *pConsumerEpNew = taosHashGet(pOutput->pSub->consumerHash, &pConsumerEp->consumerId, sizeof(int64_t)); - for (int j = 0; j < taosArrayGetSize(pConsumerEp->offsetRows); j++) { - OffsetRows *d1 = taosArrayGet(pConsumerEp->offsetRows, j); - bool jump = false; - for (int i = 0; pConsumerEpNew && i < taosArrayGetSize(pConsumerEpNew->vgs); i++){ - SMqVgEp *pVgEp = taosArrayGetP(pConsumerEpNew->vgs, i); - if(pVgEp->vgId == d1->vgId){ - jump = true; - mInfo("pSub->offsetRows jump, because consumer id:0x%"PRIx64 " and vgId:%d not change", pConsumerEp->consumerId, pVgEp->vgId); - break; - } - } - if(jump) continue; - bool find = false; - for (int i = 0; i < taosArrayGetSize(pOutput->pSub->offsetRows); i++) { - OffsetRows *d2 = taosArrayGet(pOutput->pSub->offsetRows, i); - if (d1->vgId == d2->vgId) { - d2->rows += d1->rows; - d2->offset = d1->offset; - d2->ever = d1->ever; - find = true; - mInfo("pSub->offsetRows add vgId:%d, after:%"PRId64", before:%"PRId64, d2->vgId, d2->rows, d1->rows); - break; - } - } - if(!find){ - taosArrayPush(pOutput->pSub->offsetRows, d1); + for (int j = 0; j < taosArrayGetSize(pConsumerEp->offsetRows); j++) { + OffsetRows *d1 = taosArrayGet(pConsumerEp->offsetRows, j); + bool jump = false; + for (int i = 0; pConsumerEpNew && i < taosArrayGetSize(pConsumerEpNew->vgs); i++){ + SMqVgEp *pVgEp = taosArrayGetP(pConsumerEpNew->vgs, i); + if(pVgEp->vgId == d1->vgId){ + jump = true; + mInfo("pSub->offsetRows jump, because consumer id:0x%"PRIx64 " and vgId:%d not change", pConsumerEp->consumerId, pVgEp->vgId); + break; } } + if(jump) continue; + bool find = false; + for (int i = 0; i < taosArrayGetSize(pOutput->pSub->offsetRows); i++) { + OffsetRows *d2 = taosArrayGet(pOutput->pSub->offsetRows, i); + if (d1->vgId == d2->vgId) { + d2->rows += d1->rows; + d2->offset = d1->offset; + d2->ever = d1->ever; + find = true; + mInfo("pSub->offsetRows add vgId:%d, after:%"PRId64", before:%"PRId64, d2->vgId, d2->rows, d1->rows); + break; + } + } + if(!find){ + taosArrayPush(pOutput->pSub->offsetRows, d1); + } } - taosRUnLockLatch(&pSub->lock); - mndReleaseSubscribe(pMnode, pSub); } + taosRUnLockLatch(&pSub->lock); + mndReleaseSubscribe(pMnode, pSub); +} - // 8. generate logs - mInfo("sub:%s mq re-balance calculation completed, re-balanced vg", pSubKey); +static void printRebalanceLog(SMqRebOutputObj *pOutput){ + mInfo("sub:%s mq re-balance calculation completed, re-balanced vg", pOutput->pSub->key); for (int32_t i = 0; i < taosArrayGetSize(pOutput->rebVgs); i++) { SMqRebOutputVg *pOutputRebVg = taosArrayGet(pOutput->rebVgs, i); - mInfo("sub:%s mq re-balance vgId:%d, moved from consumer:0x%" PRIx64 ", to consumer:0x%" PRIx64, pSubKey, + mInfo("sub:%s mq re-balance vgId:%d, moved from consumer:0x%" PRIx64 ", to consumer:0x%" PRIx64, pOutput->pSub->key, pOutputRebVg->pVgEp->vgId, pOutputRebVg->oldConsumerId, pOutputRebVg->newConsumerId); } - pIter = NULL; + void *pIter = NULL; while (1) { pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); if (pIter == NULL) break; SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; int32_t sz = taosArrayGetSize(pConsumerEp->vgs); - mInfo("sub:%s mq re-balance final cfg: consumer:0x%" PRIx64 " has %d vg", pSubKey, pConsumerEp->consumerId, sz); + mInfo("sub:%s mq re-balance final cfg: consumer:0x%" PRIx64 " has %d vg", pOutput->pSub->key, pConsumerEp->consumerId, sz); for (int32_t i = 0; i < sz; i++) { SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, i); - mInfo("sub:%s mq re-balance final cfg: vg %d to consumer:0x%" PRIx64, pSubKey, pVgEp->vgId, + mInfo("sub:%s mq re-balance final cfg: vg %d to consumer:0x%" PRIx64, pOutput->pSub->key, pVgEp->vgId, pConsumerEp->consumerId); } } +} - // 9. clear +static void calcVgroupsCnt(const SMqRebInputObj *pInput, int32_t totalVgNum, const char *pSubKey, + int32_t *minVgCnt, int32_t *remainderVgCnt){ + int32_t numOfRemoved = taosArrayGetSize(pInput->pRebInfo->removedConsumers); + int32_t numOfAdded = taosArrayGetSize(pInput->pRebInfo->newConsumers); + int32_t numOfFinal = pInput->oldConsumerNum + numOfAdded - numOfRemoved; + + // calc num + if (numOfFinal != 0) { + *minVgCnt = totalVgNum / numOfFinal; + *remainderVgCnt = totalVgNum % numOfFinal; + } else { + mInfo("[rebalance] sub:%s no consumer subscribe this topic", pSubKey); + } + mInfo("[rebalance] sub:%s mq rebalance %d vgroups, existed consumers:%d, added:%d, removed:%d, minVg:%d remainderVg:%d", + pSubKey, totalVgNum, pInput->oldConsumerNum, numOfAdded, numOfRemoved, *minVgCnt, *remainderVgCnt); +} + +static void assignVgroups(SMqRebOutputObj *pOutput, SHashObj *pHash, int32_t minVgCnt){ + SMqRebOutputVg *pRebVg = NULL; + void *pAssignIter = NULL; + void *pIter = NULL; + + while (1) { + pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); + if (pIter == NULL) { + break; + } + SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; + while (taosArrayGetSize(pConsumerEp->vgs) < minVgCnt) { + pAssignIter = taosHashIterate(pHash, pAssignIter); + if (pAssignIter == NULL) { + mError("[rebalance] sub:%s assign iter is NULL, never should reach here", pOutput->pSub->key); + break; + } + + pRebVg = (SMqRebOutputVg *)pAssignIter; + pRebVg->newConsumerId = pConsumerEp->consumerId; + taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp); + mInfo("[rebalance] mq rebalance: add vgId:%d to consumer:0x%" PRIx64 " for average", + pRebVg->pVgEp->vgId, pConsumerEp->consumerId); + } + } + + while (1) { + pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); + if (pIter == NULL) { + break; + } + SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; + if (taosArrayGetSize(pConsumerEp->vgs) == minVgCnt) { + pAssignIter = taosHashIterate(pHash, pAssignIter); + if (pAssignIter == NULL) { + mInfo("[rebalance] sub:%s assign iter is used up", pOutput->pSub->key); + break; + } + + pRebVg = (SMqRebOutputVg *)pAssignIter; + pRebVg->newConsumerId = pConsumerEp->consumerId; + taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp); + mInfo("[rebalance] mq rebalance: add vgId:%d to consumer:0x%" PRIx64 " for average + 1", + pRebVg->pVgEp->vgId, pConsumerEp->consumerId); + } + } + + taosHashCancelIterate(pOutput->pSub->consumerHash, pIter); + if(pAssignIter != NULL){ + mError("[rebalance]sub:%s assign iter is not NULL, never should reach here", pOutput->pSub->key); + } + while (1) { + pAssignIter = taosHashIterate(pHash, pAssignIter); + if (pAssignIter == NULL) { + break; + } + + SMqRebOutputVg* pRebOutput = (SMqRebOutputVg *)pAssignIter; + taosArrayPush(pOutput->rebVgs, pRebOutput); + if(taosHashGetSize(pOutput->pSub->consumerHash) == 0){ // if all consumer is removed + taosArrayPush(pOutput->pSub->unassignedVgs, &pRebOutput->pVgEp); // put all vg into unassigned + } + } +} + +static void mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput) { + int32_t totalVgNum = processRemoveAddVgs(pMnode, pOutput); + const char *pSubKey = pOutput->pSub->key; + int32_t minVgCnt = 0; + int32_t remainderVgCnt = 0; + + SHashObj *pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + + processRemovedConsumers(pOutput, pHash, pInput); + processUnassignedVgroups(pOutput, pHash); + calcVgroupsCnt(pInput, totalVgNum, pSubKey, &minVgCnt, &remainderVgCnt); + processModifiedConsumers(pOutput, pHash, minVgCnt, remainderVgCnt); + processNewConsumers(pOutput, pInput); + assignVgroups(pOutput, pHash, minVgCnt); + processSubOffsetRows(pMnode, pInput, pOutput); + printRebalanceLog(pOutput); taosHashCleanup(pHash); +} - return 0; +static int32_t presistConsumerByType(STrans *pTrans, SArray* consumers, int8_t type, char *cgroup, char *topic){ + int32_t code = 0; + SMqConsumerObj *pConsumerNew = NULL; + int32_t consumerNum = taosArrayGetSize(consumers); + for (int32_t i = 0; i < consumerNum; i++) { + int64_t consumerId = *(int64_t *)taosArrayGet(consumers, i); + pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup, type, topic, NULL); + if (pConsumerNew == NULL){ + code = TSDB_CODE_OUT_OF_MEMORY; + goto END; + } + + code = mndSetConsumerCommitLogs(pTrans, pConsumerNew); + if (code != 0) { + goto END; + } + + tDeleteSMqConsumerObj(pConsumerNew); + } + pConsumerNew = NULL; + +END: + tDeleteSMqConsumerObj(pConsumerNew); + return code; +} + +static int32_t mndPresistConsumer(STrans *pTrans, const SMqRebOutputObj *pOutput, char *cgroup, char *topic){ + int32_t code = presistConsumerByType(pTrans, pOutput->modifyConsumers, CONSUMER_UPDATE_REB, cgroup, NULL); + if (code != 0) { + return code; + } + + code = presistConsumerByType(pTrans, pOutput->newConsumers, CONSUMER_ADD_REB, cgroup, topic); + if (code != 0) { + return code; + } + + return presistConsumerByType(pTrans, pOutput->removedConsumers, CONSUMER_REMOVE_REB, cgroup, topic); } static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOutputObj *pOutput) { - struct SSubplan* pPlan = NULL; + struct SSubplan *pPlan = NULL; + int32_t code = 0; + STrans *pTrans = NULL; + if(strcmp(pOutput->pSub->qmsg, "") != 0){ - int32_t code = qStringToSubplan(pOutput->pSub->qmsg, &pPlan); - if (code != TSDB_CODE_SUCCESS) { + code = qStringToSubplan(pOutput->pSub->qmsg, &pPlan); + if (code != 0) { terrno = code; - return -1; + goto END; } } @@ -618,110 +618,51 @@ static int32_t mndPersistRebResult(SMnode *pMnode, SRpcMsg *pMsg, const SMqRebOu char cgroup[TSDB_CGROUP_LEN] = {0}; mndSplitSubscribeKey(pOutput->pSub->key, topic, cgroup, true); - STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_TOPIC_INSIDE, pMsg, "tmq-reb"); + pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_TOPIC_INSIDE, pMsg, "tmq-reb"); if (pTrans == NULL) { - nodesDestroyNode((SNode*)pPlan); - return -1; + code = TSDB_CODE_OUT_OF_MEMORY; + goto END; } mndTransSetDbName(pTrans, topic, cgroup); - if (mndTransCheckConflict(pMnode, pTrans) != 0) { - mndTransDrop(pTrans); - nodesDestroyNode((SNode*)pPlan); - return -1; + code = mndTransCheckConflict(pMnode, pTrans); + if (code != 0) { + goto END; } - // make txn: // 1. redo action: action to all vg const SArray *rebVgs = pOutput->rebVgs; int32_t vgNum = taosArrayGetSize(rebVgs); for (int32_t i = 0; i < vgNum; i++) { SMqRebOutputVg *pRebVg = taosArrayGet(rebVgs, i); - if (mndPersistSubChangeVgReq(pMnode, pTrans, pOutput->pSub, pRebVg, pPlan) < 0) { - mndTransDrop(pTrans); - nodesDestroyNode((SNode*)pPlan); - return -1; + code = mndPersistSubChangeVgReq(pMnode, pTrans, pOutput->pSub, pRebVg, pPlan); + if (code != 0) { + goto END; } } - nodesDestroyNode((SNode*)pPlan); - // 2. redo log: subscribe and vg assignment - // subscribe - if (mndSetSubCommitLogs(pMnode, pTrans, pOutput->pSub) != 0) { - mndTransDrop(pTrans); - return -1; + // 2. commit log: subscribe and vg assignment + code = mndSetSubCommitLogs(pTrans, pOutput->pSub); + if (code != 0) { + goto END; } // 3. commit log: consumer to update status and epoch - // 3.1 set touched consumer - int32_t consumerNum = taosArrayGetSize(pOutput->modifyConsumers); - for (int32_t i = 0; i < consumerNum; i++) { - int64_t consumerId = *(int64_t *)taosArrayGet(pOutput->modifyConsumers, i); - SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup); - pConsumerNew->updateType = CONSUMER_UPDATE_REB; - if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) { - tDeleteSMqConsumerObj(pConsumerNew, true); - - mndTransDrop(pTrans); - return -1; - } - - tDeleteSMqConsumerObj(pConsumerNew, true); + code = mndPresistConsumer(pTrans, pOutput, cgroup, topic); + if (code != 0) { + goto END; } - // 3.2 set new consumer - consumerNum = taosArrayGetSize(pOutput->newConsumers); - for (int32_t i = 0; i < consumerNum; i++) { - int64_t consumerId = *(int64_t *)taosArrayGet(pOutput->newConsumers, i); - SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup); - pConsumerNew->updateType = CONSUMER_ADD_REB; - - char* topicTmp = taosStrdup(topic); - taosArrayPush(pConsumerNew->rebNewTopics, &topicTmp); - if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) { - tDeleteSMqConsumerObj(pConsumerNew, true); - - mndTransDrop(pTrans); - return -1; - } - - tDeleteSMqConsumerObj(pConsumerNew, true); - } - - // 3.3 set removed consumer - consumerNum = taosArrayGetSize(pOutput->removedConsumers); - for (int32_t i = 0; i < consumerNum; i++) { - int64_t consumerId = *(int64_t *)taosArrayGet(pOutput->removedConsumers, i); - - SMqConsumerObj *pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup); - pConsumerNew->updateType = CONSUMER_REMOVE_REB; - - char* topicTmp = taosStrdup(topic); - taosArrayPush(pConsumerNew->rebRemovedTopics, &topicTmp); - if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) { - tDeleteSMqConsumerObj(pConsumerNew, true); - - mndTransDrop(pTrans); - return -1; - } - - tDeleteSMqConsumerObj(pConsumerNew, true); - } - - // 4. TODO commit log: modification log - - // 5. set cb + // 4. set cb mndTransSetCb(pTrans, TRANS_START_FUNC_MQ_REB, TRANS_STOP_FUNC_MQ_REB, NULL, 0); - // 6. execution - if (mndTransPrepare(pMnode, pTrans) != 0) { - mError("failed to prepare trans rebalance since %s", terrstr()); - mndTransDrop(pTrans); - return -1; - } + // 5. execution + code = mndTransPrepare(pMnode, pTrans); +END: + nodesDestroyNode((SNode*)pPlan); mndTransDrop(pTrans); - return 0; + return code; } static void freeRebalanceItem(void *param) { @@ -730,10 +671,55 @@ static void freeRebalanceItem(void *param) { taosArrayDestroy(pInfo->removedConsumers); } -static int32_t mndCheckConsumer(SRpcMsg *pMsg, SHashObj* rebSubHash) { +// type = 0 remove type = 1 add +static void buildRebInfo(SHashObj* rebSubHash, SArray* topicList, int8_t type, char *group, int64_t consumerId){ + int32_t topicNum = taosArrayGetSize(topicList); + for (int32_t i = 0; i < topicNum; i++) { + char key[TSDB_SUBSCRIBE_KEY_LEN]; + char *removedTopic = taosArrayGetP(topicList, i); + mndMakeSubscribeKey(key, group, removedTopic); + SMqRebInfo *pRebSub = mndGetOrCreateRebSub(rebSubHash, key); + if(type == 0) + taosArrayPush(pRebSub->removedConsumers, &consumerId); + else if(type == 1) + taosArrayPush(pRebSub->newConsumers, &consumerId); + } +} + +static void checkForVgroupSplit(SMnode *pMnode, SMqConsumerObj *pConsumer, SHashObj* rebSubHash){ + int32_t newTopicNum = taosArrayGetSize(pConsumer->currentTopics); + for (int32_t i = 0; i < newTopicNum; i++) { + char * topic = taosArrayGetP(pConsumer->currentTopics, i); + SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, pConsumer->cgroup, topic); + if (pSub == NULL) { + continue; + } + taosRLockLatch(&pSub->lock); + + // iterate all vg assigned to the consumer of that topic + SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &pConsumer->consumerId, sizeof(int64_t)); + int32_t vgNum = taosArrayGetSize(pConsumerEp->vgs); + + for (int32_t j = 0; j < vgNum; j++) { + SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, j); + SVgObj * pVgroup = mndAcquireVgroup(pMnode, pVgEp->vgId); + if (!pVgroup) { + char key[TSDB_SUBSCRIBE_KEY_LEN]; + mndMakeSubscribeKey(key, pConsumer->cgroup, topic); + mndGetOrCreateRebSub(rebSubHash, key); + mInfo("vnode splitted, vgId:%d rebalance will be triggered", pVgEp->vgId); + } + mndReleaseVgroup(pMnode, pVgroup); + } + taosRUnLockLatch(&pSub->lock); + mndReleaseSubscribe(pMnode, pSub); + } +} + +static void mndCheckConsumer(SRpcMsg *pMsg, SHashObj* rebSubHash) { SMnode *pMnode = pMsg->info.node; SSdb *pSdb = pMnode->pSdb; - SMqConsumerObj *pConsumer; + SMqConsumerObj *pConsumer = NULL; void *pIter = NULL; // iterate all consumers, find all modification @@ -746,89 +732,32 @@ static int32_t mndCheckConsumer(SRpcMsg *pMsg, SHashObj* rebSubHash) { int32_t hbStatus = atomic_add_fetch_32(&pConsumer->hbStatus, 1); int32_t status = atomic_load_32(&pConsumer->status); - mDebug("check for consumer:0x%" PRIx64 " status:%d(%s), sub-time:%" PRId64 ", createTime:%" PRId64 ", hbstatus:%d", - pConsumer->consumerId, status, mndConsumerStatusName(status), pConsumer->subscribeTime, pConsumer->createTime, - hbStatus); + mDebug("[rebalance] check for consumer:0x%" PRIx64 " status:%d(%s), sub-time:%" PRId64 ", createTime:%" PRId64 ", hbstatus:%d", + pConsumer->consumerId, status, mndConsumerStatusName(status), pConsumer->subscribeTime, pConsumer->createTime, hbStatus); if (status == MQ_CONSUMER_STATUS_READY) { - if (taosArrayGetSize(pConsumer->assignedTopics) == 0) { // unsubscribe or close - mndDropConsumerFromSdb(pMnode, pConsumer->consumerId, &pMsg->info); + if (taosArrayGetSize(pConsumer->assignedTopics) == 0) {// unsubscribe or close + mndSendConsumerMsg(pMnode, pConsumer->consumerId, TDMT_MND_TMQ_LOST_CONSUMER_CLEAR, &pMsg->info); } else if (hbStatus > MND_CONSUMER_LOST_HB_CNT) { taosRLockLatch(&pConsumer->lock); - int32_t topicNum = taosArrayGetSize(pConsumer->currentTopics); - for (int32_t i = 0; i < topicNum; i++) { - char key[TSDB_SUBSCRIBE_KEY_LEN]; - char *removedTopic = taosArrayGetP(pConsumer->currentTopics, i); - mndMakeSubscribeKey(key, pConsumer->cgroup, removedTopic); - SMqRebInfo *pRebSub = mndGetOrCreateRebSub(rebSubHash, key); - taosArrayPush(pRebSub->removedConsumers, &pConsumer->consumerId); - } + buildRebInfo(rebSubHash, pConsumer->currentTopics, 0, pConsumer->cgroup, pConsumer->consumerId); taosRUnLockLatch(&pConsumer->lock); }else{ - int32_t newTopicNum = taosArrayGetSize(pConsumer->currentTopics); - for (int32_t i = 0; i < newTopicNum; i++) { - char * topic = taosArrayGetP(pConsumer->currentTopics, i); - SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, pConsumer->cgroup, topic); - if (pSub == NULL) { - continue; - } - taosRLockLatch(&pSub->lock); - - // 2.2 iterate all vg assigned to the consumer of that topic - SMqConsumerEp *pConsumerEp = taosHashGet(pSub->consumerHash, &pConsumer->consumerId, sizeof(int64_t)); - int32_t vgNum = taosArrayGetSize(pConsumerEp->vgs); - - for (int32_t j = 0; j < vgNum; j++) { - SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, j); - SVgObj * pVgroup = mndAcquireVgroup(pMnode, pVgEp->vgId); - if (!pVgroup) { - char key[TSDB_SUBSCRIBE_KEY_LEN]; - mndMakeSubscribeKey(key, pConsumer->cgroup, topic); - mndGetOrCreateRebSub(rebSubHash, key); - mInfo("vnode splitted, vgId:%d rebalance will be triggered", pVgEp->vgId); - } - mndReleaseVgroup(pMnode, pVgroup); - } - taosRUnLockLatch(&pSub->lock); - mndReleaseSubscribe(pMnode, pSub); - } + checkForVgroupSplit(pMnode, pConsumer, rebSubHash); } } else if (status == MQ_CONSUMER_STATUS_LOST) { - if (hbStatus > MND_CONSUMER_LOST_CLEAR_THRESHOLD) { // clear consumer if lost a day - mndDropConsumerFromSdb(pMnode, pConsumer->consumerId, &pMsg->info); + if (hbStatus > MND_CONSUMER_LOST_CLEAR_THRESHOLD) { // clear consumer if lost a day + mndSendConsumerMsg(pMnode, pConsumer->consumerId, TDMT_MND_TMQ_LOST_CONSUMER_CLEAR, &pMsg->info); } } else { taosRLockLatch(&pConsumer->lock); - - int32_t newTopicNum = taosArrayGetSize(pConsumer->rebNewTopics); - for (int32_t i = 0; i < newTopicNum; i++) { - char key[TSDB_SUBSCRIBE_KEY_LEN]; - char *newTopic = taosArrayGetP(pConsumer->rebNewTopics, i); - mndMakeSubscribeKey(key, pConsumer->cgroup, newTopic); - SMqRebInfo *pRebSub = mndGetOrCreateRebSub(rebSubHash, key); - taosArrayPush(pRebSub->newConsumers, &pConsumer->consumerId); - } - - int32_t removedTopicNum = taosArrayGetSize(pConsumer->rebRemovedTopics); - for (int32_t i = 0; i < removedTopicNum; i++) { - char key[TSDB_SUBSCRIBE_KEY_LEN]; - char *removedTopic = taosArrayGetP(pConsumer->rebRemovedTopics, i); - mndMakeSubscribeKey(key, pConsumer->cgroup, removedTopic); - SMqRebInfo *pRebSub = mndGetOrCreateRebSub(rebSubHash, key); - taosArrayPush(pRebSub->removedConsumers, &pConsumer->consumerId); - } - - if (newTopicNum == 0 && removedTopicNum == 0 && taosArrayGetSize(pConsumer->assignedTopics) == 0) { // unsubscribe or close - mndDropConsumerFromSdb(pMnode, pConsumer->consumerId, &pMsg->info); - } - + buildRebInfo(rebSubHash, pConsumer->rebNewTopics, 1, pConsumer->cgroup, pConsumer->consumerId); + buildRebInfo(rebSubHash, pConsumer->rebRemovedTopics, 0, pConsumer->cgroup, pConsumer->consumerId); taosRUnLockLatch(&pConsumer->lock); } mndReleaseConsumer(pMnode, pConsumer); } - - return 0; } bool mndRebTryStart() { @@ -847,31 +776,95 @@ void mndRebCntDec() { mInfo("rebalance cnt sub, value:%d", val); } +static void clearRebOutput(SMqRebOutputObj *rebOutput){ + taosArrayDestroy(rebOutput->newConsumers); + taosArrayDestroy(rebOutput->modifyConsumers); + taosArrayDestroy(rebOutput->removedConsumers); + taosArrayDestroy(rebOutput->rebVgs); + tDeleteSubscribeObj(rebOutput->pSub); + taosMemoryFree(rebOutput->pSub); +} + +static int32_t initRebOutput(SMqRebOutputObj *rebOutput) { + rebOutput->newConsumers = taosArrayInit(0, sizeof(int64_t)); + rebOutput->removedConsumers = taosArrayInit(0, sizeof(int64_t)); + rebOutput->modifyConsumers = taosArrayInit(0, sizeof(int64_t)); + rebOutput->rebVgs = taosArrayInit(0, sizeof(SMqRebOutputVg)); + + if (rebOutput->newConsumers == NULL || rebOutput->removedConsumers == NULL || rebOutput->modifyConsumers == NULL || + rebOutput->rebVgs == NULL) { + clearRebOutput(rebOutput); + return TSDB_CODE_OUT_OF_MEMORY; + } + return 0; +} + +static int32_t buildRebOutput(SMnode *pMnode, SMqRebInputObj *rebInput, SMqRebOutputObj *rebOutput){ + const char *key = rebInput->pRebInfo->key; + SMqSubscribeObj *pSub = mndAcquireSubscribeByKey(pMnode, key); + + if (pSub == NULL) { + // split sub key and extract topic + char topic[TSDB_TOPIC_FNAME_LEN]; + char cgroup[TSDB_CGROUP_LEN]; + mndSplitSubscribeKey(key, topic, cgroup, true); + + SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); + if (pTopic == NULL) { + mError("[rebalance] mq rebalance %s ignored since topic %s doesn't exist", key, topic); + return -1; + } + + taosRLockLatch(&pTopic->lock); + + rebInput->oldConsumerNum = 0; + rebOutput->pSub = mndCreateSubscription(pMnode, pTopic, key); + + if (rebOutput->pSub == NULL) { + mError("[rebalance] mq rebalance %s failed create sub since %s, ignore", key, terrstr()); + taosRUnLockLatch(&pTopic->lock); + mndReleaseTopic(pMnode, pTopic); + return -1; + } + + memcpy(rebOutput->pSub->dbName, pTopic->db, TSDB_DB_FNAME_LEN); + taosRUnLockLatch(&pTopic->lock); + mndReleaseTopic(pMnode, pTopic); + + mInfo("[rebalance] sub topic:%s has no consumers sub yet", key); + } else { + taosRLockLatch(&pSub->lock); + rebInput->oldConsumerNum = taosHashGetSize(pSub->consumerHash); + rebOutput->pSub = tCloneSubscribeObj(pSub); + taosRUnLockLatch(&pSub->lock); + + mInfo("[rebalance] sub topic:%s has %d consumers sub till now", key, rebInput->oldConsumerNum); + mndReleaseSubscribe(pMnode, pSub); + } + return 0; +} + static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { - int code = 0; - mInfo("start to process mq timer"); + int code = 0; + void *pIter = NULL; + SMnode *pMnode = pMsg->info.node; + mInfo("[rebalance] start to process mq timer"); if (!mndRebTryStart()) { - mInfo("mq rebalance already in progress, do nothing"); + mInfo("[rebalance] mq rebalance already in progress, do nothing"); return code; } SHashObj *rebSubHash = taosHashInit(64, MurmurHash3_32, true, HASH_NO_LOCK); if (rebSubHash == NULL) { - mError("failed to create rebalance hashmap"); - terrno = TSDB_CODE_OUT_OF_MEMORY; - code = -1; + code = TSDB_CODE_OUT_OF_MEMORY; goto END; } - taosHashSetFreeFp(rebSubHash, freeRebalanceItem); mndCheckConsumer(pMsg, rebSubHash); - mInfo("mq re-balance start, total required re-balanced trans:%d", taosHashGetSize(rebSubHash)); + mInfo("[rebalance] mq re-balance start, total required re-balanced trans:%d", taosHashGetSize(rebSubHash)); - // here we only handle one topic rebalance requirement to ensure the atomic execution of this transaction. - void *pIter = NULL; - SMnode *pMnode = pMsg->info.node; while (1) { pIter = taosHashIterate(rebSubHash, pIter); if (pIter == NULL) { @@ -880,92 +873,30 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { SMqRebInputObj rebInput = {0}; SMqRebOutputObj rebOutput = {0}; - rebOutput.newConsumers = taosArrayInit(0, sizeof(int64_t)); - rebOutput.removedConsumers = taosArrayInit(0, sizeof(int64_t)); - rebOutput.modifyConsumers = taosArrayInit(0, sizeof(int64_t)); - rebOutput.rebVgs = taosArrayInit(0, sizeof(SMqRebOutputVg)); - - if (rebOutput.newConsumers == NULL || rebOutput.removedConsumers == NULL || rebOutput.modifyConsumers == NULL || - rebOutput.rebVgs == NULL) { - taosArrayDestroy(rebOutput.newConsumers); - taosArrayDestroy(rebOutput.removedConsumers); - taosArrayDestroy(rebOutput.modifyConsumers); - taosArrayDestroy(rebOutput.rebVgs); - - taosHashCancelIterate(rebSubHash, pIter); - terrno = TSDB_CODE_OUT_OF_MEMORY; - mError("mq re-balance failed, due to out of memory"); - code = -1; + code = initRebOutput(&rebOutput); + if (code != 0){ goto END; } - SMqRebInfo *pRebInfo = (SMqRebInfo *)pIter; - SMqSubscribeObj *pSub = mndAcquireSubscribeByKey(pMnode, pRebInfo->key); + rebInput.pRebInfo = (SMqRebInfo*)pIter; - rebInput.pRebInfo = pRebInfo; - - if (pSub == NULL) { - // split sub key and extract topic - char topic[TSDB_TOPIC_FNAME_LEN]; - char cgroup[TSDB_CGROUP_LEN]; - mndSplitSubscribeKey(pRebInfo->key, topic, cgroup, true); - - SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); - if (pTopic == NULL) { - mError("mq re-balance %s ignored since topic %s doesn't exist", pRebInfo->key, topic); - continue; - } - - taosRLockLatch(&pTopic->lock); - - rebOutput.pSub = mndCreateSubscription(pMnode, pTopic, pRebInfo->key); - - if (rebOutput.pSub == NULL) { - mError("mq rebalance %s failed create sub since %s, ignore", pRebInfo->key, terrstr()); - taosRUnLockLatch(&pTopic->lock); - mndReleaseTopic(pMnode, pTopic); - continue; - } - - memcpy(rebOutput.pSub->dbName, pTopic->db, TSDB_DB_FNAME_LEN); - taosRUnLockLatch(&pTopic->lock); - mndReleaseTopic(pMnode, pTopic); - - rebInput.oldConsumerNum = 0; - mInfo("sub topic:%s has no consumers sub yet", pRebInfo->key); - } else { - taosRLockLatch(&pSub->lock); - rebInput.oldConsumerNum = taosHashGetSize(pSub->consumerHash); - rebOutput.pSub = tCloneSubscribeObj(pSub); - taosRUnLockLatch(&pSub->lock); - - mInfo("sub topic:%s has %d consumers sub till now", pRebInfo->key, rebInput.oldConsumerNum); - mndReleaseSubscribe(pMnode, pSub); + if (buildRebOutput(pMnode, &rebInput, &rebOutput) != 0){ + continue; } - if (mndDoRebalance(pMnode, &rebInput, &rebOutput) < 0) { - mError("mq re-balance internal error"); - } + mndDoRebalance(pMnode, &rebInput, &rebOutput); - // if add more consumer to balanced subscribe, - // possibly no vg is changed - // when each topic is re-balanced, issue an trans to save the results in sdb. - if (mndPersistRebResult(pMnode, pMsg, &rebOutput) < 0) { + if (mndPersistRebResult(pMnode, pMsg, &rebOutput) != 0) { mError("mq re-balance persist output error, possibly vnode splitted or dropped,msg:%s", terrstr()); } - taosArrayDestroy(rebOutput.newConsumers); - taosArrayDestroy(rebOutput.modifyConsumers); - taosArrayDestroy(rebOutput.removedConsumers); - taosArrayDestroy(rebOutput.rebVgs); - tDeleteSubscribeObj(rebOutput.pSub); - taosMemoryFree(rebOutput.pSub); + clearRebOutput(&rebOutput); } - // reset flag - mInfo("mq re-balance completed successfully"); + mInfo("[rebalance] mq re-balance completed successfully, wait trans finish"); END: + taosHashCancelIterate(rebSubHash, pIter); taosHashCleanup(rebSubHash); mndRebCntDec(); @@ -995,6 +926,28 @@ static int32_t sendDeleteSubToVnode(SMqSubscribeObj *pSub, STrans *pTrans){ return 0; } +static int32_t mndDropConsumerByGroup(SMnode *pMnode, STrans *pTrans, char *cgroup, char *topic){ + void *pIter = NULL; + SMqConsumerObj *pConsumer = NULL; + while (1) { + pIter = sdbFetch(pMnode->pSdb, SDB_CONSUMER, pIter, (void **)&pConsumer); + if (pIter == NULL) { + break; + } + + if (strcmp(cgroup, pConsumer->cgroup) == 0 && taosArrayGetSize(pConsumer->currentTopics) == 0) { + int32_t code = mndSetConsumerDropLogs(pTrans, pConsumer); + if (code != 0) { + sdbRelease(pMnode->pSdb, pConsumer); + sdbCancelFetch(pMnode->pSdb, pIter); + return code; + } + } + sdbRelease(pMnode->pSdb, pConsumer); + } + return 0; +} + static int32_t mndProcessDropCgroupReq(SRpcMsg *pMsg) { SMnode *pMnode = pMsg->info.node; SMDropCgroupReq dropReq = {0}; @@ -1033,41 +986,31 @@ static int32_t mndProcessDropCgroupReq(SRpcMsg *pMsg) { goto end; } + mInfo("trans:%d, used to drop cgroup:%s on topic %s", pTrans->id, dropReq.cgroup, dropReq.topic); mndTransSetDbName(pTrans, dropReq.topic, dropReq.cgroup); code = mndTransCheckConflict(pMnode, pTrans); if (code != 0) { goto end; } - void *pIter = NULL; - SMqConsumerObj *pConsumer; - while (1) { - pIter = sdbFetch(pMnode->pSdb, SDB_CONSUMER, pIter, (void **)&pConsumer); - if (pIter == NULL) { - break; - } - - if (strcmp(dropReq.cgroup, pConsumer->cgroup) == 0) { - mndDropConsumerFromSdb(pMnode, pConsumer->consumerId, &pMsg->info); - } - sdbRelease(pMnode->pSdb, pConsumer); + code = mndDropConsumerByGroup(pMnode, pTrans, dropReq.cgroup, dropReq.topic); + if (code != 0) { + goto end; } - mInfo("trans:%d, used to drop cgroup:%s on topic %s", pTrans->id, dropReq.cgroup, dropReq.topic); - code = sendDeleteSubToVnode(pSub, pTrans); if (code != 0) { goto end; } - if (mndSetDropSubCommitLogs(pMnode, pTrans, pSub) < 0) { + code = mndSetDropSubCommitLogs(pMnode, pTrans, pSub); + if (code != 0) { mError("cgroup %s on topic:%s, failed to drop since %s", dropReq.cgroup, dropReq.topic, terrstr()); - code = -1; goto end; } - if (mndTransPrepare(pMnode, pTrans) < 0) { - code = -1; + code = mndTransPrepare(pMnode, pTrans); + if (code != 0) { goto end; } @@ -1219,12 +1162,11 @@ static int32_t mndSubActionUpdate(SSdb *pSdb, SMqSubscribeObj *pOldSub, SMqSubsc return 0; } -int32_t mndMakeSubscribeKey(char *key, const char *cgroup, const char *topicName) { +void mndMakeSubscribeKey(char *key, const char *cgroup, const char *topicName) { int32_t tlen = strlen(cgroup); memcpy(key, cgroup, tlen); key[tlen] = TMQ_SEPARATOR; strcpy(key + tlen + 1, topicName); - return 0; } SMqSubscribeObj *mndAcquireSubscribe(SMnode *pMnode, const char *cgroup, const char *topicName) { @@ -1294,40 +1236,13 @@ int32_t mndSetDropSubCommitLogs(SMnode *pMnode, STrans *pTrans, SMqSubscribeObj return 0; } -//int32_t mndDropSubByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { -// int32_t code = 0; -// SSdb *pSdb = pMnode->pSdb; -// -// void *pIter = NULL; -// SMqSubscribeObj *pSub = NULL; -// while (1) { -// pIter = sdbFetch(pSdb, SDB_SUBSCRIBE, pIter, (void **)&pSub); -// if (pIter == NULL) break; -// -// if (pSub->dbUid != pDb->uid) { -// sdbRelease(pSdb, pSub); -// continue; -// } -// -// if (mndSetDropSubCommitLogs(pMnode, pTrans, pSub) < 0) { -// sdbRelease(pSdb, pSub); -// sdbCancelFetch(pSdb, pIter); -// code = -1; -// break; -// } -// -// sdbRelease(pSdb, pSub); -// } -// -// return code; -//} - int32_t mndDropSubByTopic(SMnode *pMnode, STrans *pTrans, const char *topicName) { - SSdb *pSdb = pMnode->pSdb; - + SSdb *pSdb = pMnode->pSdb; + int32_t code = 0; void *pIter = NULL; SMqSubscribeObj *pSub = NULL; while (1) { + sdbRelease(pSdb, pSub); pIter = sdbFetch(pSdb, SDB_SUBSCRIBE, pIter, (void **)&pSub); if (pIter == NULL) break; @@ -1335,33 +1250,31 @@ int32_t mndDropSubByTopic(SMnode *pMnode, STrans *pTrans, const char *topicName) char cgroup[TSDB_CGROUP_LEN] = {0}; mndSplitSubscribeKey(pSub->key, topic, cgroup, true); if (strcmp(topic, topicName) != 0) { - sdbRelease(pSdb, pSub); continue; } // iter all vnode to delete handle if (taosHashGetSize(pSub->consumerHash) != 0) { - sdbRelease(pSdb, pSub); - terrno = TSDB_CODE_MND_IN_REBALANCE; - sdbCancelFetch(pSdb, pIter); - return -1; - } - if (sendDeleteSubToVnode(pSub, pTrans) != 0) { - sdbRelease(pSdb, pSub); - sdbCancelFetch(pSdb, pIter); - return -1; + code = TSDB_CODE_MND_IN_REBALANCE; + goto END; } - if (mndSetDropSubCommitLogs(pMnode, pTrans, pSub) < 0) { - sdbRelease(pSdb, pSub); - sdbCancelFetch(pSdb, pIter); - return -1; + code = sendDeleteSubToVnode(pSub, pTrans); + if (code != 0) { + goto END; } - sdbRelease(pSdb, pSub); + code = mndSetDropSubCommitLogs(pMnode, pTrans, pSub); + if (code != 0) { + goto END; + } } - return 0; +END: + sdbRelease(pSdb, pSub); + sdbCancelFetch(pSdb, pIter); + + return code; } static int32_t buildResult(SSDataBlock *pBlock, int32_t* numOfRows, int64_t consumerId, const char* topic, const char* cgroup, SArray* vgs, SArray *offsetRows){ diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index a1490a3813..28c857319f 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -409,6 +409,7 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) { pFsm->FpApplyQueueItems = mndApplyQueueItems; pFsm->FpReConfigCb = NULL; pFsm->FpBecomeLeaderCb = mndBecomeLeader; + pFsm->FpBecomeAssignedLeaderCb = NULL; pFsm->FpBecomeFollowerCb = mndBecomeFollower; pFsm->FpBecomeLearnerCb = mndBecomeLearner; pFsm->FpGetSnapshot = mndSyncGetSnapshot; diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index de543f4256..4a0d58a32e 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -353,6 +353,66 @@ static int32_t extractTopicTbInfo(SNode *pAst, SMqTopicObj *pTopic) { return 0; } +static int32_t sendCheckInfoToVnode(STrans *pTrans, SMnode *pMnode, SMqTopicObj *topicObj){ + STqCheckInfo info; + memcpy(info.topic, topicObj->name, TSDB_TOPIC_FNAME_LEN); + info.ntbUid = topicObj->ntbUid; + info.colIdList = topicObj->ntbColIds; + // broadcast forbid alter info + void *pIter = NULL; + SSdb *pSdb = pMnode->pSdb; + SVgObj *pVgroup = NULL; + int32_t code = 0; + void *buf = NULL; + + while (1) { + // iterate vg + pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); + if (pIter == NULL) break; + if (!mndVgroupInDb(pVgroup, topicObj->dbUid)) { + sdbRelease(pSdb, pVgroup); + continue; + } + + // encoder check alter info + int32_t len; + tEncodeSize(tEncodeSTqCheckInfo, &info, len, code); + if (code != 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto END; + } + buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len); + void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); + SEncoder encoder; + tEncoderInit(&encoder, abuf, len); + code = tEncodeSTqCheckInfo(&encoder, &info); + if (code < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto END; + } + tEncoderClear(&encoder); + ((SMsgHead *)buf)->vgId = htonl(pVgroup->vgId); + // add redo action + STransAction action = {0}; + action.epSet = mndGetVgroupEpset(pMnode, pVgroup); + action.pCont = buf; + action.contLen = sizeof(SMsgHead) + len; + action.msgType = TDMT_VND_TMQ_ADD_CHECKINFO; + code = mndTransAppendRedoAction(pTrans, &action); + if (code != 0) { + goto END; + } + sdbRelease(pSdb, pVgroup); + buf = NULL; + } + +END: + taosMemoryFree(buf); + sdbRelease(pSdb, pVgroup); + sdbCancelFetch(pSdb, pIter); + return code; +} + static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq *pCreate, SDbObj *pDb, const char *userName) { mInfo("start to create topic:%s", pCreate->name); @@ -396,13 +456,6 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq * topicObj.withMeta = pCreate->withMeta; if (pCreate->subType == TOPIC_SUB_TYPE__COLUMN) { - if (pCreate->withMeta) { - terrno = TSDB_CODE_MND_INVALID_TOPIC_OPTION; - mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); - code = terrno; - goto _OUT; - } - topicObj.ast = taosStrdup(pCreate->ast); topicObj.astLen = strlen(pCreate->ast) + 1; @@ -474,59 +527,9 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq * (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); if (topicObj.ntbUid != 0) { - STqCheckInfo info; - memcpy(info.topic, topicObj.name, TSDB_TOPIC_FNAME_LEN); - info.ntbUid = topicObj.ntbUid; - info.colIdList = topicObj.ntbColIds; - // broadcast forbid alter info - void *pIter = NULL; - SSdb *pSdb = pMnode->pSdb; - SVgObj *pVgroup = NULL; - while (1) { - // iterate vg - pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); - if (pIter == NULL) break; - if (!mndVgroupInDb(pVgroup, topicObj.dbUid)) { - sdbRelease(pSdb, pVgroup); - continue; - } - - // encoder check alter info - int32_t len; - tEncodeSize(tEncodeSTqCheckInfo, &info, len, code); - if (code < 0) { - sdbRelease(pSdb, pVgroup); - sdbCancelFetch(pSdb, pIter); - goto _OUT; - } - void *buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len); - void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); - SEncoder encoder; - tEncoderInit(&encoder, abuf, len); - if (tEncodeSTqCheckInfo(&encoder, &info) < 0) { - taosMemoryFree(buf); - sdbRelease(pSdb, pVgroup); - sdbCancelFetch(pSdb, pIter); - code = -1; - goto _OUT; - } - tEncoderClear(&encoder); - ((SMsgHead *)buf)->vgId = htonl(pVgroup->vgId); - // add redo action - STransAction action = {0}; - action.epSet = mndGetVgroupEpset(pMnode, pVgroup); - action.pCont = buf; - action.contLen = sizeof(SMsgHead) + len; - action.msgType = TDMT_VND_TMQ_ADD_CHECKINFO; - if (mndTransAppendRedoAction(pTrans, &action) != 0) { - taosMemoryFree(buf); - sdbRelease(pSdb, pVgroup); - sdbCancelFetch(pSdb, pIter); - code = -1; - goto _OUT; - } - buf = NULL; - sdbRelease(pSdb, pVgroup); + code = sendCheckInfoToVnode(pTrans, pMnode, &topicObj); + if (code != 0){ + goto _OUT; } } @@ -618,7 +621,7 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) { tNameFromString(&topicName, createTopicReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); //reuse this function for topic - auditRecord(pReq, pMnode->clusterId, "createTopic", dbname.dbname, topicName.dbname, + auditRecord(pReq, pMnode->clusterId, "createTopic", dbname.dbname, topicName.dbname, createTopicReq.sql, strlen(createTopicReq.sql)); _OVER: @@ -653,9 +656,104 @@ _OVER: return code; } +static bool checkTopic(SArray *topics, char *topicName){ + int32_t sz = taosArrayGetSize(topics); + for (int32_t i = 0; i < sz; i++) { + char *name = taosArrayGetP(topics, i); + if (strcmp(name, topicName) == 0) { + return true; + } + } + return false; +} + +static int32_t mndDropConsumerByTopic(SMnode *pMnode, STrans *pTrans, char *topicName){ + int32_t code = 0; + SSdb *pSdb = pMnode->pSdb; + void *pIter = NULL; + SMqConsumerObj *pConsumer = NULL; + while (1) { + pIter = sdbFetch(pSdb, SDB_CONSUMER, pIter, (void **)&pConsumer); + if (pIter == NULL) { + break; + } + + bool found = checkTopic(pConsumer->assignedTopics, topicName); + if (found){ + if (pConsumer->status == MQ_CONSUMER_STATUS_LOST) { + code = mndSetConsumerDropLogs(pTrans, pConsumer); + if (code != 0) { + goto end; + } + sdbRelease(pSdb, pConsumer); + continue; + } + mError("topic:%s, failed to drop since subscribed by consumer:0x%" PRIx64 ", in consumer group %s", + topicName, pConsumer->consumerId, pConsumer->cgroup); + code = TSDB_CODE_MND_TOPIC_SUBSCRIBED; + goto end; + } + + if (checkTopic(pConsumer->rebNewTopics, topicName) || checkTopic(pConsumer->rebRemovedTopics, topicName)) { + code = TSDB_CODE_MND_TOPIC_SUBSCRIBED; + mError("topic:%s, failed to drop since subscribed by consumer:%" PRId64 ", in consumer group %s (reb new)", + topicName, pConsumer->consumerId, pConsumer->cgroup); + goto end; + } + sdbRelease(pSdb, pConsumer); + } + +end: + sdbRelease(pSdb, pConsumer); + sdbCancelFetch(pSdb, pIter); + return code; +} + +static int32_t mndDropCheckInfoByTopic(SMnode *pMnode, STrans *pTrans, SMqTopicObj *pTopic){ + // broadcast to all vnode + void *pIter = NULL; + SVgObj *pVgroup = NULL; + int32_t code = 0; + SSdb *pSdb = pMnode->pSdb; + void *buf = NULL; + while (1) { + pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); + if (pIter == NULL) break; + if (!mndVgroupInDb(pVgroup, pTopic->dbUid)) { + sdbRelease(pSdb, pVgroup); + continue; + } + + buf = taosMemoryCalloc(1, sizeof(SMsgHead) + TSDB_TOPIC_FNAME_LEN); + if (buf == NULL){ + code = TSDB_CODE_OUT_OF_MEMORY; + goto end; + } + void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); + ((SMsgHead *)buf)->vgId = htonl(pVgroup->vgId); + memcpy(abuf, pTopic->name, TSDB_TOPIC_FNAME_LEN); + + STransAction action = {0}; + action.epSet = mndGetVgroupEpset(pMnode, pVgroup); + action.pCont = buf; + action.contLen = sizeof(SMsgHead) + TSDB_TOPIC_FNAME_LEN; + action.msgType = TDMT_VND_TMQ_DEL_CHECKINFO; + code = mndTransAppendRedoAction(pTrans, &action); + if (code != 0) { + taosMemoryFree(buf); + goto end; + } + sdbRelease(pSdb, pVgroup); + } + +end: + sdbRelease(pSdb, pVgroup); + sdbCancelFetch(pSdb, pIter); + return code; +} + static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; - SSdb *pSdb = pMnode->pSdb; SMDropTopicReq dropReq = {0}; int32_t code = 0; SMqTopicObj *pTopic = NULL; @@ -705,68 +803,9 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) { goto end; } - void *pIter = NULL; - SMqConsumerObj *pConsumer; - while (1) { - pIter = sdbFetch(pSdb, SDB_CONSUMER, pIter, (void **)&pConsumer); - if (pIter == NULL) { - break; - } - - bool found = false; - int32_t sz = taosArrayGetSize(pConsumer->assignedTopics); - for (int32_t i = 0; i < sz; i++) { - char *name = taosArrayGetP(pConsumer->assignedTopics, i); - if (strcmp(name, pTopic->name) == 0) { - found = true; - break; - } - } - if (found){ - if (pConsumer->status == MQ_CONSUMER_STATUS_LOST) { - mndDropConsumerFromSdb(pMnode, pConsumer->consumerId, &pReq->info); - mndReleaseConsumer(pMnode, pConsumer); - continue; - } - - mndReleaseConsumer(pMnode, pConsumer); - sdbCancelFetch(pSdb, pIter); - terrno = TSDB_CODE_MND_TOPIC_SUBSCRIBED; - mError("topic:%s, failed to drop since subscribed by consumer:0x%" PRIx64 ", in consumer group %s", - dropReq.name, pConsumer->consumerId, pConsumer->cgroup); - code = -1; - goto end; - } - - sz = taosArrayGetSize(pConsumer->rebNewTopics); - for (int32_t i = 0; i < sz; i++) { - char *name = taosArrayGetP(pConsumer->rebNewTopics, i); - if (strcmp(name, pTopic->name) == 0) { - mndReleaseConsumer(pMnode, pConsumer); - sdbCancelFetch(pSdb, pIter); - terrno = TSDB_CODE_MND_TOPIC_SUBSCRIBED; - mError("topic:%s, failed to drop since subscribed by consumer:%" PRId64 ", in consumer group %s (reb new)", - dropReq.name, pConsumer->consumerId, pConsumer->cgroup); - code = -1; - goto end; - } - } - - sz = taosArrayGetSize(pConsumer->rebRemovedTopics); - for (int32_t i = 0; i < sz; i++) { - char *name = taosArrayGetP(pConsumer->rebRemovedTopics, i); - if (strcmp(name, pTopic->name) == 0) { - mndReleaseConsumer(pMnode, pConsumer); - sdbCancelFetch(pSdb, pIter); - terrno = TSDB_CODE_MND_TOPIC_SUBSCRIBED; - mError("topic:%s, failed to drop since subscribed by consumer:%" PRId64 ", in consumer group %s (reb remove)", - dropReq.name, pConsumer->consumerId, pConsumer->cgroup); - code = -1; - goto end; - } - } - - sdbRelease(pSdb, pConsumer); + code = mndDropConsumerByTopic(pMnode, pTrans, dropReq.name); + if (code != 0) { + goto end; } code = mndDropSubByTopic(pMnode, pTrans, dropReq.name); @@ -776,36 +815,9 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) { } if (pTopic->ntbUid != 0) { - // broadcast to all vnode - pIter = NULL; - SVgObj *pVgroup = NULL; - - while (1) { - pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); - if (pIter == NULL) break; - if (!mndVgroupInDb(pVgroup, pTopic->dbUid)) { - sdbRelease(pSdb, pVgroup); - continue; - } - - void *buf = taosMemoryCalloc(1, sizeof(SMsgHead) + TSDB_TOPIC_FNAME_LEN); - void *abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); - ((SMsgHead *)buf)->vgId = htonl(pVgroup->vgId); - memcpy(abuf, pTopic->name, TSDB_TOPIC_FNAME_LEN); - - STransAction action = {0}; - action.epSet = mndGetVgroupEpset(pMnode, pVgroup); - action.pCont = buf; - action.contLen = sizeof(SMsgHead) + TSDB_TOPIC_FNAME_LEN; - action.msgType = TDMT_VND_TMQ_DEL_CHECKINFO; - code = mndTransAppendRedoAction(pTrans, &action); - if (code != 0) { - taosMemoryFree(buf); - sdbRelease(pSdb, pVgroup); - sdbCancelFetch(pSdb, pIter); - goto end; - } - sdbRelease(pSdb, pVgroup); + code = mndDropCheckInfoByTopic(pMnode, pTrans, pTopic); + if (code != 0) { + goto end; } } @@ -822,7 +834,6 @@ end: SName name = {0}; tNameFromString(&name, dropReq.name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); - //reuse this function for topic auditRecord(pReq, pMnode->clusterId, "dropTopic", name.dbname, name.tname, dropReq.sql, dropReq.sqlLen); diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index f7db0d7b15..3af372a432 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -733,6 +733,8 @@ void mndTransSetDbName(STrans *pTrans, const char *dbname, const char *stbname) } } +void mndTransSetArbGroupId(STrans *pTrans, int32_t groupId) { pTrans->arbGroupId = groupId; } + void mndTransSetSerial(STrans *pTrans) { pTrans->exec = TRN_EXEC_SERIAL; } void mndTransSetParallel(STrans *pTrans) { pTrans->exec = TRN_EXEC_PARALLEL; } @@ -814,6 +816,12 @@ static bool mndCheckTransConflict(SMnode *pMnode, STrans *pNew) { conflict = true; } } + if (pNew->conflict == TRN_CONFLICT_ARBGROUP) { + if (pTrans->conflict == TRN_CONFLICT_GLOBAL) conflict = true; + if (pTrans->conflict == TRN_CONFLICT_ARBGROUP) { + if (pNew->arbGroupId == pTrans->arbGroupId) conflict = true; + } + } if (conflict) { mError("trans:%d, db:%s stb:%s type:%d, can't execute since conflict with trans:%d db:%s stb:%s type:%d", @@ -1255,9 +1263,9 @@ static int32_t mndTransExecuteActions(SMnode *pMnode, STrans *pTrans, SArray *pA for (int32_t action = 0; action < numOfActions; ++action) { STransAction *pAction = taosArrayGet(pArray, action); - mDebug("trans:%d, %s:%d Sent:%d, Received:%d, errCode:0x%x, acceptableCode:0x%x, retryCode:0x%x", pTrans->id, - mndTransStr(pAction->stage), pAction->id, pAction->msgSent, pAction->msgReceived, pAction->errCode, - pAction->acceptableCode, pAction->retryCode); + mDebug("trans:%d, %s:%d Sent:%d, Received:%d, errCode:0x%x, acceptableCode:0x%x, retryCode:0x%x", + pTrans->id, mndTransStr(pAction->stage), pAction->id, pAction->msgSent, pAction->msgReceived, + pAction->errCode, pAction->acceptableCode, pAction->retryCode); if (pAction->msgSent) { if (pAction->msgReceived) { if (pAction->errCode != 0 && pAction->errCode != pAction->acceptableCode) { diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index b0290191bc..571f17fab6 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -16,6 +16,7 @@ #define _DEFAULT_SOURCE #include "mndVgroup.h" #include "audit.h" +#include "mndArbGroup.h" #include "mndDb.h" #include "mndDnode.h" #include "mndMnode.h" @@ -351,7 +352,7 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg mInfo( "vgId:%d, build create vnode req, replica:%d selfIndex:%d learnerReplica:%d learnerSelfIndex:%d strict:%d " "changeVersion:%d", - createReq.vgId, createReq.replica, createReq.selfIndex, createReq.learnerReplica, createReq.learnerReplica, + createReq.vgId, createReq.replica, createReq.selfIndex, createReq.learnerReplica, createReq.learnerSelfIndex, createReq.strict, createReq.changeVersion); for (int32_t i = 0; i < createReq.replica; ++i) { mInfo("vgId:%d, replica:%d ep:%s:%u", createReq.vgId, i, createReq.replicas[i].fqdn, createReq.replicas[i].port); @@ -738,10 +739,6 @@ void mndSortVnodeGid(SVgObj *pVgroup) { } static int32_t mndGetAvailableDnode(SMnode *pMnode, SDbObj *pDb, SVgObj *pVgroup, SArray *pArray) { - SSdb *pSdb = pMnode->pSdb; - int32_t allocedVnodes = 0; - void *pIter = NULL; - mDebug("start to sort %d dnodes", (int32_t)taosArrayGetSize(pArray)); taosArraySort(pArray, (__compar_fn_t)mndCompareDnodeVnodes); for (int32_t i = 0; i < (int32_t)taosArrayGetSize(pArray); ++i) { @@ -883,7 +880,7 @@ SEpSet mndGetVgroupEpset(SMnode *pMnode, const SVgObj *pVgroup) { SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId); if (pDnode == NULL) continue; - if (pVgid->syncState == TAOS_SYNC_STATE_LEADER) { + if (pVgid->syncState == TAOS_SYNC_STATE_LEADER || pVgid->syncState == TAOS_SYNC_STATE_ASSIGNED_LEADER) { epset.inUse = epset.numOfEps; } @@ -895,6 +892,29 @@ SEpSet mndGetVgroupEpset(SMnode *pMnode, const SVgObj *pVgroup) { return epset; } +SEpSet mndGetVgroupEpsetById(SMnode *pMnode, int32_t vgId) { + SEpSet epset = {0}; + + SVgObj * pVgroup = mndAcquireVgroup(pMnode, vgId); + if (!pVgroup) return epset; + + for (int32_t v = 0; v < pVgroup->replica; ++v) { + const SVnodeGid *pVgid = &pVgroup->vnodeGid[v]; + SDnodeObj *pDnode = mndAcquireDnode(pMnode, pVgid->dnodeId); + if (pDnode == NULL) continue; + + if (pVgid->syncState == TAOS_SYNC_STATE_LEADER || pVgid->syncState == TAOS_SYNC_STATE_ASSIGNED_LEADER) { + epset.inUse = epset.numOfEps; + } + + addEpIntoEpSet(&epset, pDnode->fqdn, pDnode->port); + mndReleaseDnode(pMnode, pDnode); + } + + mndReleaseVgroup(pMnode, pVgroup); + return epset; +} + static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { SMnode *pMnode = pReq->info.node; SSdb *pSdb = pMnode->pSdb; @@ -958,7 +978,8 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p strcpy(role, "dropping"); } else if (online) { char *star = ""; - if (pVgroup->vnodeGid[i].syncState == TAOS_SYNC_STATE_LEADER) { + if (pVgroup->vnodeGid[i].syncState == TAOS_SYNC_STATE_LEADER || + pVgroup->vnodeGid[i].syncState == TAOS_SYNC_STATE_ASSIGNED_LEADER) { if (!pVgroup->vnodeGid[i].syncRestore && !pVgroup->vnodeGid[i].syncCanRead) { star = "**"; } else if (!pVgroup->vnodeGid[i].syncRestore && pVgroup->vnodeGid[i].syncCanRead) { @@ -2288,7 +2309,7 @@ int32_t mndAddVgroupBalanceToTrans(SMnode *pMnode, SVgObj *pVgroup, STrans *pTra return -1; } - int32_t dnodeId = pVgroup->vnodeGid[0].dnodeId; + int32_t dnodeId = 0; for (int i = 0; i < replica; i++) { if (pVgroup->vnodeGid[i].syncState == TAOS_SYNC_STATE_LEADER) { @@ -2389,81 +2410,102 @@ static int32_t mndCheckDnodeMemory(SMnode *pMnode, SDbObj *pOldDb, SDbObj *pNewD } int32_t mndBuildAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pOldDb, SDbObj *pNewDb, SVgObj *pVgroup, - SArray *pArray) { - SVgObj newVgroup = {0}; - memcpy(&newVgroup, pVgroup, sizeof(SVgObj)); + SArray *pArray, SVgObj *pNewVgroup) { + memcpy(pNewVgroup, pVgroup, sizeof(SVgObj)); if (pVgroup->replica <= 0 || pVgroup->replica == pNewDb->cfg.replications) { if (mndAddAlterVnodeConfigAction(pMnode, pTrans, pNewDb, pVgroup) != 0) return -1; - if (mndCheckDnodeMemory(pMnode, pOldDb, pNewDb, &newVgroup, pVgroup, pArray) != 0) return -1; + if (mndCheckDnodeMemory(pMnode, pOldDb, pNewDb, pNewVgroup, pVgroup, pArray) != 0) return -1; return 0; } mndTransSetSerial(pTrans); - if (newVgroup.replica == 1 && pNewDb->cfg.replications == 3) { + if (pNewVgroup->replica == 1 && pNewDb->cfg.replications == 3) { mInfo("db:%s, vgId:%d, will add 2 vnodes, vn:0 dnode:%d", pVgroup->dbName, pVgroup->vgId, pVgroup->vnodeGid[0].dnodeId); // add second - if (mndAddVnodeToVgroup(pMnode, pTrans, &newVgroup, pArray) != 0) return -1; + if (mndAddVnodeToVgroup(pMnode, pTrans, pNewVgroup, pArray) != 0) return -1; // learner stage - newVgroup.vnodeGid[0].nodeRole = TAOS_SYNC_ROLE_VOTER; - newVgroup.vnodeGid[1].nodeRole = TAOS_SYNC_ROLE_LEARNER; - if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[0].dnodeId) != 0) + pNewVgroup->vnodeGid[0].nodeRole = TAOS_SYNC_ROLE_VOTER; + pNewVgroup->vnodeGid[1].nodeRole = TAOS_SYNC_ROLE_LEARNER; + if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, pNewVgroup, pNewVgroup->vnodeGid[0].dnodeId) != 0) return -1; - if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &newVgroup.vnodeGid[1]) != 0) return -1; + if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, pNewVgroup, &pNewVgroup->vnodeGid[1]) != 0) return -1; // follower stage - newVgroup.vnodeGid[1].nodeRole = TAOS_SYNC_ROLE_VOTER; - if (mndAddAlterVnodeTypeAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[1].dnodeId) != 0) return -1; - if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[0].dnodeId) != 0) + pNewVgroup->vnodeGid[1].nodeRole = TAOS_SYNC_ROLE_VOTER; + if (mndAddAlterVnodeTypeAction(pMnode, pTrans, pNewDb, pNewVgroup, pNewVgroup->vnodeGid[1].dnodeId) != 0) return -1; + if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, pNewVgroup, pNewVgroup->vnodeGid[0].dnodeId) != 0) return -1; - if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1; + if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, pNewVgroup) != 0) return -1; // add third - if (mndAddVnodeToVgroup(pMnode, pTrans, &newVgroup, pArray) != 0) return -1; + if (mndAddVnodeToVgroup(pMnode, pTrans, pNewVgroup, pArray) != 0) return -1; - newVgroup.vnodeGid[0].nodeRole = TAOS_SYNC_ROLE_VOTER; - newVgroup.vnodeGid[1].nodeRole = TAOS_SYNC_ROLE_VOTER; - newVgroup.vnodeGid[2].nodeRole = TAOS_SYNC_ROLE_VOTER; - if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[0].dnodeId) != 0) + pNewVgroup->vnodeGid[0].nodeRole = TAOS_SYNC_ROLE_VOTER; + pNewVgroup->vnodeGid[1].nodeRole = TAOS_SYNC_ROLE_VOTER; + pNewVgroup->vnodeGid[2].nodeRole = TAOS_SYNC_ROLE_VOTER; + if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, pNewVgroup, pNewVgroup->vnodeGid[0].dnodeId) != 0) return -1; - if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[1].dnodeId) != 0) + if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, pNewVgroup, pNewVgroup->vnodeGid[1].dnodeId) != 0) return -1; - if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &newVgroup.vnodeGid[2]) != 0) return -1; + if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, pNewVgroup, &pNewVgroup->vnodeGid[2]) != 0) return -1; - if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1; - } else if (newVgroup.replica == 3 && pNewDb->cfg.replications == 1) { + if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, pNewVgroup) != 0) return -1; + } else if (pNewVgroup->replica == 3 && pNewDb->cfg.replications == 1) { mInfo("db:%s, vgId:%d, will remove 2 vnodes, vn:0 dnode:%d vn:1 dnode:%d vn:2 dnode:%d", pVgroup->dbName, pVgroup->vgId, pVgroup->vnodeGid[0].dnodeId, pVgroup->vnodeGid[1].dnodeId, pVgroup->vnodeGid[2].dnodeId); SVnodeGid del1 = {0}; SVnodeGid del2 = {0}; - if (mndRemoveVnodeFromVgroup(pMnode, pTrans, &newVgroup, pArray, &del1) != 0) return -1; - if (mndAddDropVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &del1, true) != 0) return -1; - if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[0].dnodeId) != 0) + if (mndRemoveVnodeFromVgroup(pMnode, pTrans, pNewVgroup, pArray, &del1) != 0) return -1; + if (mndAddDropVnodeAction(pMnode, pTrans, pNewDb, pNewVgroup, &del1, true) != 0) return -1; + if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, pNewVgroup, pNewVgroup->vnodeGid[0].dnodeId) != 0) return -1; - if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[1].dnodeId) != 0) + if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, pNewVgroup, pNewVgroup->vnodeGid[1].dnodeId) != 0) return -1; - if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1; + if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, pNewVgroup) != 0) return -1; - if (mndRemoveVnodeFromVgroup(pMnode, pTrans, &newVgroup, pArray, &del2) != 0) return -1; - if (mndAddDropVnodeAction(pMnode, pTrans, pNewDb, &newVgroup, &del2, true) != 0) return -1; - if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, &newVgroup, newVgroup.vnodeGid[0].dnodeId) != 0) + if (mndRemoveVnodeFromVgroup(pMnode, pTrans, pNewVgroup, pArray, &del2) != 0) return -1; + if (mndAddDropVnodeAction(pMnode, pTrans, pNewDb, pNewVgroup, &del2, true) != 0) return -1; + if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, pNewVgroup, pNewVgroup->vnodeGid[0].dnodeId) != 0) return -1; - if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, &newVgroup) != 0) return -1; + if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, pNewVgroup) != 0) return -1; + } else if (pNewVgroup->replica == 1 && pNewDb->cfg.replications == 2) { + mInfo("db:%s, vgId:%d, will add 1 vnode, vn:0 dnode:%d", pVgroup->dbName, pVgroup->vgId, + pVgroup->vnodeGid[0].dnodeId); + + // add second + if (mndAddVnodeToVgroup(pMnode, pTrans, pNewVgroup, pArray) != 0) return -1; + + // learner stage + pNewVgroup->vnodeGid[0].nodeRole = TAOS_SYNC_ROLE_VOTER; + pNewVgroup->vnodeGid[1].nodeRole = TAOS_SYNC_ROLE_LEARNER; + if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, pNewVgroup, pNewVgroup->vnodeGid[0].dnodeId) != 0) + return -1; + + if (mndAddCreateVnodeAction(pMnode, pTrans, pNewDb, pNewVgroup, &pNewVgroup->vnodeGid[1]) != 0) return -1; + + // follower stage + pNewVgroup->vnodeGid[1].nodeRole = TAOS_SYNC_ROLE_VOTER; + if (mndAddAlterVnodeTypeAction(pMnode, pTrans, pNewDb, pNewVgroup, pNewVgroup->vnodeGid[1].dnodeId) != 0) return -1; + if (mndAddAlterVnodeReplicaAction(pMnode, pTrans, pNewDb, pNewVgroup, pNewVgroup->vnodeGid[0].dnodeId) != 0) + return -1; + + if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pNewDb, pNewVgroup) != 0) return -1; } else { return -1; } - mndSortVnodeGid(&newVgroup); + mndSortVnodeGid(pNewVgroup); { - SSdbRaw *pVgRaw = mndVgroupActionEncode(&newVgroup); + SSdbRaw *pVgRaw = mndVgroupActionEncode(pNewVgroup); if (pVgRaw == NULL) return -1; if (mndTransAppendCommitlog(pTrans, pVgRaw) != 0) { sdbFreeRaw(pVgRaw); @@ -2622,7 +2664,7 @@ int32_t mndBuildRestoreAlterVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj } } if (mndAddCreateVnodeAction(pMnode, pTrans, db, &newVgroup, &newVgroup.vnodeGid[selected]) != 0) return -1; - } else if (newVgroup.replica == 3) { + } else if (newVgroup.replica == 2 || newVgroup.replica == 3) { for (int i = 0; i < newVgroup.replica; i++) { if (newVgroup.vnodeGid[i].dnodeId == pDnode->id) { newVgroup.vnodeGid[i].nodeRole = TAOS_SYNC_ROLE_LEARNER; @@ -2716,6 +2758,12 @@ int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj *pVgro } #endif + if (pDb->cfg.withArbitrator) { + code = TSDB_CODE_OPS_NOT_SUPPORT; + mError("vgId:%d, db:%s, with arbitrator, split vgroup not allowed", pVgroup->vgId, pVgroup->dbName); + goto _OVER; + } + pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_DB, pReq, "split-vgroup"); if (pTrans == NULL) goto _OVER; mndTransSetSerial(pTrans); @@ -2813,13 +2861,15 @@ int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj *pVgro // adjust vgroup replica if (pDb->cfg.replications != newVg1.replica) { - if (mndBuildAlterVgroupAction(pMnode, pTrans, pDb, pDb, &newVg1, pArray) != 0) goto _OVER; + SVgObj tmpGroup = {0}; + if (mndBuildAlterVgroupAction(pMnode, pTrans, pDb, pDb, &newVg1, pArray, &tmpGroup) != 0) goto _OVER; } else { if (mndAddVgStatusAction(pTrans, &newVg1, SDB_STATUS_READY, TRN_STAGE_COMMIT_ACTION) < 0) goto _OVER; } if (pDb->cfg.replications != newVg2.replica) { - if (mndBuildAlterVgroupAction(pMnode, pTrans, pDb, pDb, &newVg2, pArray) != 0) goto _OVER; + SVgObj tmpGroup = {0}; + if (mndBuildAlterVgroupAction(pMnode, pTrans, pDb, pDb, &newVg2, pArray, &tmpGroup) != 0) goto _OVER; } else { if (mndAddVgStatusAction(pTrans, &newVg2, SDB_STATUS_READY, TRN_STAGE_COMMIT_ACTION) < 0) goto _OVER; } @@ -2907,10 +2957,22 @@ static int32_t mndBalanceVgroupBetweenDnode(SMnode *pMnode, STrans *pTrans, SDno } SDbObj *pDb = mndAcquireDb(pMnode, pVgroup->dbName); + if (pDb == NULL) { + mError("vgId:%d, balance vgroup can't find db obj dbName:%s", pVgroup->vgId, pVgroup->dbName); + goto _OUT; + } + + if (pDb->cfg.withArbitrator) { + mInfo("vgId:%d, db:%s, with arbitrator, balance vgroup not allowed", pVgroup->vgId, pVgroup->dbName); + goto _OUT; + } + code = mndSetBalanceVgroupInfoToTrans(pMnode, pTrans, pDb, pVgroup, pSrc, pDst); if (code == 0) { code = taosHashPut(pBalancedVgroups, &pVgroup->vgId, sizeof(int32_t), &pVgroup->vgId, sizeof(int32_t)); } + + _OUT: mndReleaseDb(pMnode, pDb); sdbRelease(pSdb, pVgroup); sdbCancelFetch(pSdb, pIter); diff --git a/source/dnode/mnode/impl/test/CMakeLists.txt b/source/dnode/mnode/impl/test/CMakeLists.txt index bc5b5125f1..471f0535b8 100644 --- a/source/dnode/mnode/impl/test/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/CMakeLists.txt @@ -1,6 +1,7 @@ enable_testing() add_subdirectory(acct) +add_subdirectory(arbgroup) #add_subdirectory(db) #add_subdirectory(dnode) add_subdirectory(func) diff --git a/source/dnode/mnode/impl/test/arbgroup/CMakeLists.txt b/source/dnode/mnode/impl/test/arbgroup/CMakeLists.txt new file mode 100644 index 0000000000..44ac305498 --- /dev/null +++ b/source/dnode/mnode/impl/test/arbgroup/CMakeLists.txt @@ -0,0 +1,13 @@ +SET(CMAKE_CXX_STANDARD 11) + +aux_source_directory(. MNODE_ARBGROUP_TEST_SRC) +add_executable(arbgroupTest ${MNODE_ARBGROUP_TEST_SRC}) +target_link_libraries( + arbgroupTest + PRIVATE dnode nodes planner gtest qcom +) + +add_test( + NAME arbgroupTest + COMMAND arbgroupTest +) diff --git a/source/dnode/mnode/impl/test/arbgroup/arbgroup.cpp b/source/dnode/mnode/impl/test/arbgroup/arbgroup.cpp new file mode 100644 index 0000000000..fdfc560d54 --- /dev/null +++ b/source/dnode/mnode/impl/test/arbgroup/arbgroup.cpp @@ -0,0 +1,286 @@ +/* + * 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 +#include +#include +// #include "nodes.h" +// #include "planner.h" + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wwrite-strings" +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic ignored "-Wsign-compare" + +// #include +#include "../../inc/mndArbGroup.h" + +namespace { + +void generateArbToken(int32_t nodeId, int32_t vgId, char* buf) { + memset(buf, 0, TSDB_ARB_TOKEN_SIZE); + int32_t randVal = taosSafeRand() % 1000; + int64_t currentMs = taosGetTimestampMs(); + snprintf(buf, TSDB_ARB_TOKEN_SIZE, "d%d#g%d#%" PRId64 "#%d", nodeId, vgId, currentMs, randVal); +} + +} // namespace + +class ArbgroupTest : public testing::Test { + protected: + static void SetUpTestSuite() { + std::cout << "setup env for arbgroupTest suite" << std::endl; + } + + static void TearDownTestSuite() { std::cout << "tearDown env for arbgroupTest suite" << std::endl; } + + virtual void SetUp() override {} + + virtual void TearDown() override {} + +}; + +int main(int argc, char** argv) { + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} + +TEST_F(ArbgroupTest, 01_encode_decode_sdb) { + SArbGroup group = {0}; + group.vgId = 5; + group.dbUid = 1234; + group.members[0].info.dnodeId = 1; + generateArbToken(1, 5, group.members[0].state.token); + group.members[1].info.dnodeId = 2; + generateArbToken(2, 5, group.members[1].state.token); + group.isSync = 1; + group.assignedLeader.dnodeId = 1; + generateArbToken(1, 5, group.assignedLeader.token); + group.version = 2234; + + // -------------------------------------------------------------------------------- + SSdbRaw* pRaw = mndArbGroupActionEncode(&group); + ASSERT_NE(pRaw, nullptr); + + SSdbRow* pRow = mndArbGroupActionDecode(pRaw); + ASSERT_NE(pRow, nullptr); + + SArbGroup* pNewGroup = (SArbGroup*)sdbGetRowObj(pRow); + + EXPECT_EQ(group.vgId, pNewGroup->vgId); + EXPECT_EQ(group.dbUid, pNewGroup->dbUid); + EXPECT_EQ(group.members[0].info.dnodeId, pNewGroup->members[0].info.dnodeId); + EXPECT_EQ(group.members[1].info.dnodeId, pNewGroup->members[1].info.dnodeId); + EXPECT_EQ(group.isSync, pNewGroup->isSync); + EXPECT_EQ(group.assignedLeader.dnodeId, pNewGroup->assignedLeader.dnodeId); + + EXPECT_EQ(std::string(group.members[0].state.token), std::string(pNewGroup->members[0].state.token)); + EXPECT_EQ(std::string(group.members[1].state.token), std::string(pNewGroup->members[1].state.token)); + EXPECT_EQ(std::string(group.assignedLeader.token), std::string(pNewGroup->assignedLeader.token)); + EXPECT_EQ(group.version, pNewGroup->version); + + taosMemoryFree(pRow); + taosMemoryFree(pRaw); +} + +TEST_F(ArbgroupTest, 02_process_heart_beat_rsp) { + const int32_t dnodeId = 1; + const int32_t vgId = 5; + + SArbGroup group = {0}; + group.vgId = vgId; + group.dbUid = 1234; + group.members[0].info.dnodeId = dnodeId; + generateArbToken(dnodeId, vgId, group.members[0].state.token); + group.members[0].state.lastHbMs = 1000; + group.members[0].state.responsedHbSeq = 100; + group.members[0].state.nextHbSeq = 102; + + group.members[1].info.dnodeId = 2; + generateArbToken(2, vgId, group.members[1].state.token); + + group.isSync = 1; + group.assignedLeader.dnodeId = dnodeId; + strncpy(group.assignedLeader.token, group.members[0].state.token, TSDB_ARB_TOKEN_SIZE); + + taosThreadMutexInit(&group.mutex, NULL); + + // -------------------------------------------------------------------------------- + { // expired hb => skip + SVArbHbRspMember rspMember = {0}; + rspMember.vgId = vgId; + rspMember.hbSeq = group.members[0].state.responsedHbSeq - 1; + strncpy(rspMember.memberToken, group.members[0].state.token, TSDB_ARB_TOKEN_SIZE); + int32_t nowMs = group.members[0].state.lastHbMs + 10; + + SArbGroup newGroup = {0}; + bool updateToken = mndUpdateArbGroupByHeartBeat(&group, &rspMember, nowMs, dnodeId, &newGroup); + + EXPECT_FALSE(updateToken); + EXPECT_NE(group.members[0].state.responsedHbSeq, rspMember.hbSeq); + EXPECT_NE(group.members[0].state.lastHbMs, nowMs); + } + + { // old token + SVArbHbRspMember rspMember = {0}; + rspMember.vgId = vgId; + rspMember.hbSeq = group.members[0].state.responsedHbSeq + 1; + strncpy(rspMember.memberToken, group.members[0].state.token, TSDB_ARB_TOKEN_SIZE); + int32_t nowMs = group.members[0].state.lastHbMs + 10; + + SArbGroup newGroup = {0}; + bool updateToken = mndUpdateArbGroupByHeartBeat(&group, &rspMember, nowMs, dnodeId, &newGroup); + + EXPECT_FALSE(updateToken); + EXPECT_EQ(group.members[0].state.responsedHbSeq, rspMember.hbSeq); + EXPECT_EQ(group.members[0].state.lastHbMs, nowMs); + } + + { // new token + SVArbHbRspMember rspMember = {0}; + rspMember.vgId = vgId; + rspMember.hbSeq = group.members[0].state.responsedHbSeq + 1; + generateArbToken(dnodeId, vgId, rspMember.memberToken); + int32_t nowMs = group.members[0].state.lastHbMs + 10; + + SArbGroup newGroup = {0}; + bool updateToken = mndUpdateArbGroupByHeartBeat(&group, &rspMember, nowMs, dnodeId, &newGroup); + + EXPECT_TRUE(updateToken); + EXPECT_EQ(group.members[0].state.responsedHbSeq, rspMember.hbSeq); + EXPECT_EQ(group.members[0].state.lastHbMs, nowMs); + + EXPECT_EQ(std::string(newGroup.members[0].state.token), std::string(rspMember.memberToken)); + EXPECT_FALSE(newGroup.isSync); + EXPECT_EQ(newGroup.assignedLeader.dnodeId, 0); + EXPECT_EQ(std::string(newGroup.assignedLeader.token).size(), 0); + } + + taosThreadMutexDestroy(&group.mutex); +} + +TEST_F(ArbgroupTest, 03_process_check_sync_rsp) { + const int32_t dnodeId = 1; + const int32_t vgId = 5; + + SArbGroup group = {0}; + group.vgId = vgId; + group.dbUid = 1234; + group.members[0].info.dnodeId = dnodeId; + generateArbToken(dnodeId, vgId, group.members[0].state.token); + group.members[0].state.lastHbMs = 1000; + group.members[0].state.responsedHbSeq = 100; + group.members[0].state.nextHbSeq = 102; + + group.members[1].info.dnodeId = 2; + generateArbToken(2, vgId, group.members[1].state.token); + + group.isSync = 0; + + taosThreadMutexInit(&group.mutex, NULL); + + // -------------------------------------------------------------------------------- + { // token mismatch => skip + char member0Token[TSDB_ARB_TOKEN_SIZE] = {0}; + strncpy(member0Token, group.members[0].state.token, TSDB_ARB_TOKEN_SIZE); + char member1Token[TSDB_ARB_TOKEN_SIZE] = {0}; + generateArbToken(2, 5, member1Token); + bool newIsSync = false; + + SArbGroup newGroup = {0}; + bool updateIsSync = mndUpdateArbGroupByCheckSync(&group, vgId, member0Token, member1Token, newIsSync, &newGroup); + + EXPECT_FALSE(updateIsSync); + } + + { // newIsSync + char member0Token[TSDB_ARB_TOKEN_SIZE] = {0}; + strncpy(member0Token, group.members[0].state.token, TSDB_ARB_TOKEN_SIZE); + char member1Token[TSDB_ARB_TOKEN_SIZE] = {0}; + strncpy(member1Token, group.members[1].state.token, TSDB_ARB_TOKEN_SIZE); + bool newIsSync = true; + + SArbGroup newGroup = {0}; + bool updateIsSync = mndUpdateArbGroupByCheckSync(&group, vgId, member0Token, member1Token, newIsSync, &newGroup); + + EXPECT_TRUE(updateIsSync); + EXPECT_TRUE(newGroup.isSync); + } + + taosThreadMutexDestroy(&group.mutex); +} + +TEST_F(ArbgroupTest, 04_process_set_assigned_leader){ + const int32_t dnodeId = 1; + const int32_t vgId = 5; + + SArbGroup group = {0}; + group.vgId = vgId; + group.dbUid = 1234; + group.members[0].info.dnodeId = dnodeId; + generateArbToken(dnodeId, vgId, group.members[0].state.token); + group.members[0].state.lastHbMs = 1000; + group.members[0].state.responsedHbSeq = 100; + group.members[0].state.nextHbSeq = 102; + + group.members[1].info.dnodeId = 2; + generateArbToken(2, vgId, group.members[1].state.token); + + group.isSync = 1; + group.assignedLeader.dnodeId = dnodeId; + strncpy(group.assignedLeader.token, group.members[0].state.token, TSDB_ARB_TOKEN_SIZE); + + taosThreadMutexInit(&group.mutex, NULL); + + // -------------------------------------------------------------------------------- + { // token mismatch => skip + char memberToken[TSDB_ARB_TOKEN_SIZE] = {0}; + generateArbToken(dnodeId, vgId, memberToken); + int32_t errcode = TSDB_CODE_SUCCESS; + + SArbGroup newGroup = {0}; + bool updateAssigned = mndUpdateArbGroupBySetAssignedLeader(&group, vgId, memberToken, errcode, &newGroup); + + EXPECT_FALSE(updateAssigned); + } + + { // errcode != TSDB_CODE_SUCCESS + char memberToken[TSDB_ARB_TOKEN_SIZE] = {0}; + strncpy(memberToken, group.assignedLeader.token, TSDB_ARB_TOKEN_SIZE); + int32_t errcode = TSDB_CODE_MND_ARB_TOKEN_MISMATCH; + + SArbGroup newGroup = {0}; + bool updateAssigned = mndUpdateArbGroupBySetAssignedLeader(&group, vgId, memberToken, errcode, &newGroup); + + EXPECT_FALSE(updateAssigned); + } + + { // errcode == TSDB_CODE_SUCCESS + char memberToken[TSDB_ARB_TOKEN_SIZE] = {0}; + strncpy(memberToken, group.assignedLeader.token, TSDB_ARB_TOKEN_SIZE); + int32_t errcode = TSDB_CODE_SUCCESS; + + SArbGroup newGroup = {0}; + bool updateAssigned = mndUpdateArbGroupBySetAssignedLeader(&group, vgId, memberToken, errcode, &newGroup); + + EXPECT_TRUE(updateAssigned); + EXPECT_FALSE(newGroup.isSync); + } + + taosThreadMutexDestroy(&group.mutex); +} + +#pragma GCC diagnostic pop diff --git a/source/dnode/mnode/sdb/inc/sdb.h b/source/dnode/mnode/sdb/inc/sdb.h index e2d4a1f6fc..12a34b0305 100644 --- a/source/dnode/mnode/sdb/inc/sdb.h +++ b/source/dnode/mnode/sdb/inc/sdb.h @@ -153,7 +153,8 @@ typedef enum { SDB_COMPACT = 24, SDB_COMPACT_DETAIL = 25, SDB_GRANT = 26, // grant log - SDB_MAX = 27 + SDB_ARBGROUP = 27, + SDB_MAX = 28 } ESdbType; typedef struct SSdbRaw { diff --git a/source/dnode/mnode/sdb/src/sdbHash.c b/source/dnode/mnode/sdb/src/sdbHash.c index df228c1fcc..05231f8359 100644 --- a/source/dnode/mnode/sdb/src/sdbHash.c +++ b/source/dnode/mnode/sdb/src/sdbHash.c @@ -70,7 +70,9 @@ const char *sdbTableName(ESdbType type) { return "compact"; case SDB_COMPACT_DETAIL: return "compact_detail"; - default: + case SDB_ARBGROUP: + return "arb_group"; + default: return "undefine"; } } diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 294e75602e..8ae7e9706d 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -76,6 +76,9 @@ int32_t vnodeGetTableList(void *pVnode, int8_t type, SArray *pList); int32_t vnodeGetAllTableList(SVnode *pVnode, uint64_t uid, SArray *list); int32_t vnodeIsCatchUp(SVnode *pVnode); ESyncRole vnodeGetRole(SVnode *pVnode); +int32_t vnodeGetArbToken(SVnode *pVnode, char *outToken); + +int32_t vnodeUpdateArbTerm(SVnode *pVnode, int64_t arbTerm); int32_t vnodeGetCtbIdList(void *pVnode, int64_t suid, SArray *list); int32_t vnodeGetCtbIdListByFilter(SVnode *pVnode, int64_t suid, SArray *list, bool (*filter)(void *arg), void *arg); diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 9fdb4993bd..d564c5a36e 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -136,7 +136,7 @@ typedef SVCreateTSmaReq SSmaCfg; SMTbCursor* metaOpenTbCursor(void* pVnode); void metaCloseTbCursor(SMTbCursor* pTbCur); void metaPauseTbCursor(SMTbCursor* pTbCur); -void metaResumeTbCursor(SMTbCursor* pTbCur, int8_t first); +void metaResumeTbCursor(SMTbCursor* pTbCur, int8_t first, int8_t move); int32_t metaTbCursorNext(SMTbCursor* pTbCur, ETableType jumpTableType); int32_t metaTbCursorPrev(SMTbCursor* pTbCur, ETableType jumpTableType); diff --git a/source/dnode/vnode/src/meta/metaOpen.c b/source/dnode/vnode/src/meta/metaOpen.c index 8055d6e139..4a3dcd0e51 100644 --- a/source/dnode/vnode/src/meta/metaOpen.c +++ b/source/dnode/vnode/src/meta/metaOpen.c @@ -246,32 +246,20 @@ int metaAlterCache(SMeta *pMeta, int32_t nPage) { } int32_t metaRLock(SMeta *pMeta) { - int32_t ret = 0; - metaTrace("meta rlock %p", &pMeta->lock); - - ret = taosThreadRwlockRdlock(&pMeta->lock); - + int32_t ret = taosThreadRwlockRdlock(&pMeta->lock); return ret; } int32_t metaWLock(SMeta *pMeta) { - int32_t ret = 0; - metaTrace("meta wlock %p", &pMeta->lock); - - ret = taosThreadRwlockWrlock(&pMeta->lock); - + int32_t ret = taosThreadRwlockWrlock(&pMeta->lock); return ret; } int32_t metaULock(SMeta *pMeta) { - int32_t ret = 0; - metaTrace("meta ulock %p", &pMeta->lock); - - ret = taosThreadRwlockUnlock(&pMeta->lock); - + int32_t ret = taosThreadRwlockUnlock(&pMeta->lock); return ret; } diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index 2bf73198aa..c52e42d945 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -143,7 +143,7 @@ tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name) { int metaGetTableNameByUid(void *pVnode, uint64_t uid, char *tbName) { int code = 0; SMetaReader mr = {0}; - metaReaderDoInit(&mr, ((SVnode *)pVnode)->pMeta, 0); + metaReaderDoInit(&mr, ((SVnode *)pVnode)->pMeta, META_READER_LOCK); code = metaReaderGetTableEntryByUid(&mr, uid); if (code < 0) { metaReaderClear(&mr); @@ -159,7 +159,7 @@ int metaGetTableNameByUid(void *pVnode, uint64_t uid, char *tbName) { int metaGetTableSzNameByUid(void *meta, uint64_t uid, char *tbName) { int code = 0; SMetaReader mr = {0}; - metaReaderDoInit(&mr, (SMeta *)meta, 0); + metaReaderDoInit(&mr, (SMeta *)meta, META_READER_LOCK); code = metaReaderGetTableEntryByUid(&mr, uid); if (code < 0) { metaReaderClear(&mr); @@ -174,7 +174,7 @@ int metaGetTableSzNameByUid(void *meta, uint64_t uid, char *tbName) { int metaGetTableUidByName(void *pVnode, char *tbName, uint64_t *uid) { int code = 0; SMetaReader mr = {0}; - metaReaderDoInit(&mr, ((SVnode *)pVnode)->pMeta, 0); + metaReaderDoInit(&mr, ((SVnode *)pVnode)->pMeta, META_READER_LOCK); SMetaReader *pReader = &mr; @@ -195,7 +195,7 @@ int metaGetTableUidByName(void *pVnode, char *tbName, uint64_t *uid) { int metaGetTableTypeByName(void *pVnode, char *tbName, ETableType *tbType) { int code = 0; SMetaReader mr = {0}; - metaReaderDoInit(&mr, ((SVnode *)pVnode)->pMeta, 0); + metaReaderDoInit(&mr, ((SVnode *)pVnode)->pMeta, META_READER_LOCK); code = metaGetTableEntryByName(&mr, tbName); if (code == 0) *tbType = mr.me.type; @@ -215,7 +215,7 @@ int metaReadNext(SMetaReader *pReader) { int metaGetTableTtlByUid(void *meta, uint64_t uid, int64_t *ttlDays) { int code = -1; SMetaReader mr = {0}; - metaReaderDoInit(&mr, (SMeta *)meta, 0); + metaReaderDoInit(&mr, (SMeta *)meta, META_READER_LOCK); code = metaReaderGetTableEntryByUid(&mr, uid); if (code < 0) { goto _exit; @@ -248,7 +248,7 @@ SMTbCursor *metaOpenTbCursor(void *pVnode) { // tdbTbcMoveToFirst((TBC *)pTbCur->pDbc); pTbCur->pMeta = pVnodeObj->pMeta; pTbCur->paused = 1; - metaResumeTbCursor(pTbCur, 1); + metaResumeTbCursor(pTbCur, 1, 0); return pTbCur; } @@ -273,18 +273,20 @@ void metaPauseTbCursor(SMTbCursor *pTbCur) { pTbCur->paused = 1; } } -void metaResumeTbCursor(SMTbCursor *pTbCur, int8_t first) { +void metaResumeTbCursor(SMTbCursor *pTbCur, int8_t first, int8_t move) { if (pTbCur->paused) { - metaReaderDoInit(&pTbCur->mr, pTbCur->pMeta, 0); + metaReaderDoInit(&pTbCur->mr, pTbCur->pMeta, META_READER_LOCK); tdbTbcOpen(((SMeta *)pTbCur->pMeta)->pUidIdx, (TBC **)&pTbCur->pDbc, NULL); if (first) { tdbTbcMoveToFirst((TBC *)pTbCur->pDbc); } else { - int c = 0; + int c = 1; tdbTbcMoveTo(pTbCur->pDbc, pTbCur->pKey, pTbCur->kLen, &c); - if (c < 0) { + if (c == 0) { + if (move) tdbTbcMoveToNext(pTbCur->pDbc); + } else if (c < 0) { tdbTbcMoveToPrev(pTbCur->pDbc); } else { tdbTbcMoveToNext(pTbCur->pDbc); @@ -820,7 +822,7 @@ STSmaWrapper *metaGetSmaInfoByTable(SMeta *pMeta, tb_uid_t uid, bool deepCopy) { } SMetaReader mr = {0}; - metaReaderDoInit(&mr, pMeta, 0); + metaReaderDoInit(&mr, pMeta, META_READER_LOCK); int64_t smaId; int smaIdx = 0; STSma *pTSma = NULL; @@ -875,7 +877,7 @@ _err: STSma *metaGetSmaInfoByIndex(SMeta *pMeta, int64_t indexUid) { STSma *pTSma = NULL; SMetaReader mr = {0}; - metaReaderDoInit(&mr, pMeta, 0); + metaReaderDoInit(&mr, pMeta, META_READER_LOCK); if (metaReaderGetTableEntryByUid(&mr, indexUid) < 0) { metaWarn("vgId:%d, failed to get table entry for smaId:%" PRIi64, TD_VID(pMeta->pVnode), indexUid); metaReaderClear(&mr); diff --git a/source/dnode/vnode/src/meta/metaSma.c b/source/dnode/vnode/src/meta/metaSma.c index 91704f5c7a..c61725e834 100644 --- a/source/dnode/vnode/src/meta/metaSma.c +++ b/source/dnode/vnode/src/meta/metaSma.c @@ -37,7 +37,7 @@ int32_t metaCreateTSma(SMeta *pMeta, int64_t version, SSmaCfg *pCfg) { // validate req // save smaIndex - metaReaderDoInit(&mr, pMeta, 0); + metaReaderDoInit(&mr, pMeta, META_READER_LOCK); if (metaReaderGetTableEntryByUidCache(&mr, pCfg->indexUid) == 0) { #if 1 terrno = TSDB_CODE_TSMA_ALREADY_EXIST; diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 4a978c8f41..3c032f193a 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -819,7 +819,7 @@ int metaCreateTable(SMeta *pMeta, int64_t ver, SVCreateTbReq *pReq, STableMetaRs } // validate req - metaReaderDoInit(&mr, pMeta, 0); + metaReaderDoInit(&mr, pMeta, META_READER_LOCK); if (metaGetTableEntryByName(&mr, pReq->name) == 0) { if (pReq->type == TSDB_CHILD_TABLE && pReq->ctb.suid != mr.me.ctbEntry.suid) { terrno = TSDB_CODE_TDB_TABLE_IN_OTHER_STABLE; diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 621651507e..5441d0c4c1 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -1097,7 +1097,7 @@ static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables) { } int64_t nRsmaTables = 0; - metaReaderDoInit(&mr, SMA_META(pSma), 0); + metaReaderDoInit(&mr, SMA_META(pSma), META_READER_LOCK); if (!(uidStore.tbUids = taosArrayInit(1024, sizeof(tb_uid_t)))) { code = TSDB_CODE_OUT_OF_MEMORY; TSDB_CHECK_CODE(code, lino, _exit); diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 47900d540c..ffebd783ac 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -860,6 +860,8 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t nextProcessVer) { 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); + + ASSERT(pChkInfo->checkpointVer <= pChkInfo->nextProcessVer); } return 0; @@ -1203,8 +1205,15 @@ 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); + if (req.mndTrigger) { + 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); + } else { + const char* pPrevStatus = streamTaskGetStatusStr(streamTaskGetPrevStatus(pTask)); + qInfo("s-task:%s (vgId:%d) level:%d receive checkpoint-source msg chkpt:%" PRId64 + ", transId:%d after transfer-state, prev status:%s", + pTask->id.idStr, vgId, pTask->info.taskLevel, req.checkpointId, req.transId, pPrevStatus); + } code = streamAddCheckpointSourceRspMsg(&req, &pMsg->info, pTask, 1); if (code != TSDB_CODE_SUCCESS) { diff --git a/source/dnode/vnode/src/tq/tqMeta.c b/source/dnode/vnode/src/tq/tqMeta.c index 4c403dc18f..e64de9a423 100644 --- a/source/dnode/vnode/src/tq/tqMeta.c +++ b/source/dnode/vnode/src/tq/tqMeta.c @@ -88,10 +88,6 @@ int32_t tqMetaOpen(STQ* pTq) { return -1; } -// if (tqMetaRestoreHandle(pTq) < 0) { -// return -1; -// } - if (tqMetaRestoreCheckInfo(pTq) < 0) { return -1; } @@ -167,32 +163,30 @@ int32_t tqMetaRestoreCheckInfo(STQ* pTq) { void* pVal = NULL; int vLen = 0; SDecoder decoder; + int32_t code = 0; tdbTbcMoveToFirst(pCur); while (tdbTbcNext(pCur, &pKey, &kLen, &pVal, &vLen) == 0) { STqCheckInfo info; tDecoderInit(&decoder, (uint8_t*)pVal, vLen); - if (tDecodeSTqCheckInfo(&decoder, &info) < 0) { + code = tDecodeSTqCheckInfo(&decoder, &info); + if (code != 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; - tdbFree(pKey); - tdbFree(pVal); - tdbTbcClose(pCur); - return -1; + goto END; } tDecoderClear(&decoder); - if (taosHashPut(pTq->pCheckInfo, info.topic, strlen(info.topic), &info, sizeof(STqCheckInfo)) < 0) { + code = taosHashPut(pTq->pCheckInfo, info.topic, strlen(info.topic), &info, sizeof(STqCheckInfo)); + if (code != 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; - tdbFree(pKey); - tdbFree(pVal); - tdbTbcClose(pCur); - return -1; + goto END; } } +END: tdbFree(pKey); tdbFree(pVal); tdbTbcClose(pCur); - return 0; + return code; } int32_t tqMetaSaveHandle(STQ* pTq, const char* key, const STqHandle* pHandle) { diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index a99caa3323..40a24f0bd8 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -115,7 +115,7 @@ bool isValValidForTable(STqHandle* pHandle, SWalCont* pHead) { } SMetaReader mr = {0}; - metaReaderDoInit(&mr, pHandle->execHandle.pTqReader->pVnodeMeta, 0); + metaReaderDoInit(&mr, pHandle->execHandle.pTqReader->pVnodeMeta, META_READER_LOCK); if (metaGetTableEntryByName(&mr, req.tbName) < 0) { metaReaderClear(&mr); @@ -666,20 +666,19 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char* int32_t targetIdx = 0; int32_t sourceIdx = 0; while (targetIdx < colActual) { + SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx); + if (sourceIdx >= numOfCols) { - tqError("tqRetrieveDataBlock sourceIdx:%d >= numOfCols:%d", sourceIdx, numOfCols); - return -1; + tqError("lostdata tqRetrieveDataBlock sourceIdx:%d >= numOfCols:%d", sourceIdx, numOfCols); + colDataSetNNULL(pColData, 0, numOfRows); + targetIdx++; + continue; } SColData* pCol = taosArrayGet(pCols, sourceIdx); - SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, targetIdx); SColVal colVal; - if (pCol->nVal != numOfRows) { - tqError("tqRetrieveDataBlock pCol->nVal:%d != numOfRows:%d", pCol->nVal, numOfRows); - return -1; - } - + tqTrace("lostdata colActual:%d, sourceIdx:%d, targetIdx:%d, numOfCols:%d, source cid:%d, dst cid:%d", colActual, sourceIdx, targetIdx, numOfCols, pCol->cid, pColData->info.colId); if (pCol->cid < pColData->info.colId) { sourceIdx++; } else if (pCol->cid == pColData->info.colId) { @@ -693,7 +692,7 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char* sourceIdx++; targetIdx++; } else { - colDataSetNNULL(pColData, 0, pCol->nVal); + colDataSetNNULL(pColData, 0, numOfRows); targetIdx++; } } @@ -712,9 +711,6 @@ int32_t tqRetrieveDataBlock(STqReader* pReader, SSDataBlock** pRes, const char* SColVal colVal; tRowGet(pRow, pTSchema, sourceIdx, &colVal); if (colVal.cid < pColData->info.colId) { - // tqDebug("colIndex:%d column id:%d in row, ignore, the required colId:%d, total cols in - // schema:%d", - // sourceIdx, colVal.cid, pColData->info.colId, pTSchema->numOfCols); sourceIdx++; continue; } else if (colVal.cid == pColData->info.colId) { diff --git a/source/dnode/vnode/src/tq/tqScan.c b/source/dnode/vnode/src/tq/tqScan.c index 103007eb57..9940164ee2 100644 --- a/source/dnode/vnode/src/tq/tqScan.c +++ b/source/dnode/vnode/src/tq/tqScan.c @@ -47,7 +47,7 @@ static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, STaosxRsp* pRsp static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, STaosxRsp* pRsp, int32_t n) { SMetaReader mr = {0}; - metaReaderDoInit(&mr, pTq->pVnode->pMeta, 0); + metaReaderDoInit(&mr, pTq->pVnode->pMeta, META_READER_LOCK); // TODO add reference to gurantee success if (metaReaderGetTableEntryByUidCache(&mr, uid) < 0) { diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index a7dbdd9a48..ade7958f8a 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -613,7 +613,7 @@ int32_t doWaitForDstTableCreated(SVnode* pVnode, SStreamTask* pTask, STableSinkI // wait for the table to be created SMetaReader mr = {0}; - metaReaderDoInit(&mr, pVnode->pMeta, 0); + metaReaderDoInit(&mr, pVnode->pMeta, META_READER_LOCK); int32_t code = metaGetTableEntryByName(&mr, dstTableName); if (code == 0) { // table already exists, check its type and uid @@ -706,7 +706,7 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat // those mismatched table uids. Only the FIRST table has the correct table uid, and those remain all have // randomly generated, but false table uid in the WAL. SMetaReader mr = {0}; - metaReaderDoInit(&mr, pVnode->pMeta, 0); + metaReaderDoInit(&mr, pVnode->pMeta, META_READER_LOCK); // table not in cache, let's try the extract it from tsdb meta if (metaGetTableEntryByName(&mr, dstTableName) < 0) { diff --git a/source/dnode/vnode/src/tqCommon/tqCommon.c b/source/dnode/vnode/src/tqCommon/tqCommon.c index 9bfdd70477..1b67dce9b0 100644 --- a/source/dnode/vnode/src/tqCommon/tqCommon.c +++ b/source/dnode/vnode/src/tqCommon/tqCommon.c @@ -929,6 +929,7 @@ static int32_t tqProcessTaskResumeImpl(void* handle, SStreamTask* pTask, int64_t } if (level == TASK_LEVEL__SOURCE && pTask->info.fillHistory && status == TASK_STATUS__SCAN_HISTORY) { + pTask->hTaskInfo.operatorOpen = false; streamStartScanHistoryAsync(pTask, igUntreated); } else if (level == TASK_LEVEL__SOURCE && (streamQueueGetNumOfItems(pTask->inputq.queue) == 0)) { tqScanWalAsync((STQ*)handle, false); diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 5c6c6c3e9d..4c88242fee 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -2014,7 +2014,7 @@ static tb_uid_t getTableSuidByUid(tb_uid_t uid, STsdb *pTsdb) { tb_uid_t suid = 0; SMetaReader mr = {0}; - metaReaderDoInit(&mr, pTsdb->pVnode->pMeta, 0); + metaReaderDoInit(&mr, pTsdb->pVnode->pMeta, META_READER_LOCK); if (metaReaderGetTableEntryByUidCache(&mr, uid) < 0) { metaReaderClear(&mr); // table not esist return 0; diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c index 095e427462..61c610538e 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c +++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c @@ -437,7 +437,7 @@ static int32_t doLoadSttFilesBlk(SSttBlockLoadInfo *pBlockLoadInfo, SLDataIter * code = loadTombFn(pReader1, pIter->pReader, pIter->pBlockLoadInfo); double el = (taosGetTimestampUs() - st) / 1000.0; - tsdbDebug("load the stt file info completed, elapsed time:%.2fms, %s", el, idStr); + tsdbDebug("load the stt file blk info completed, elapsed time:%.2fms, %s", el, idStr); return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbRead2.c b/source/dnode/vnode/src/tsdb/tsdbRead2.c index 9a5fa0871f..6e134698b5 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead2.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead2.c @@ -48,9 +48,9 @@ static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter); static int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t endKey, int32_t capacity, STsdbReader* pReader); static TSDBROW* getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pReader); -static int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, STsdbReader* pReader); -static int32_t doMergeRowsInSttBlock(SSttBlockReader* pSttBlockReader, STableBlockScanInfo* pScanInfo, - SRowKey* pRowKey, SRowMerger* pMerger, SVersionRange* pVerRange, const char* id); +static int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, SRowKey* pKey, STsdbReader* pReader); +static int32_t doMergeRowsInSttBlock(SSttBlockReader* pSttBlockReader, STableBlockScanInfo* pScanInfo, SRowKey* pRowKey, + SRowMerger* pMerger, int32_t pkSrcSlot, SVersionRange* pVerRange, const char* id); static int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, SRowKey* pCurKey, SArray* pDelList, STsdbReader* pReader); static int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, SRow* pTSRow, @@ -61,11 +61,11 @@ static void setComposedBlockFlag(STsdbReader* pReader, bool composed); static bool hasBeenDropped(const SArray* pDelList, int32_t* index, int64_t key, int64_t ver, int32_t order, SVersionRange* pVerRange); -static int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, SArray* pDelList, +static int32_t doMergeMemTableMultiRows(TSDBROW* pRow, SRowKey* pKey, uint64_t uid, SIterInfo* pIter, SArray* pDelList, TSDBROW* pResRow, STsdbReader* pReader, bool* freeTSRow); -static int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* pBlockScanInfo, - STsdbReader* pReader, SRow** pTSRow); -static int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBlockScanInfo, int64_t key, +static int32_t doMergeMemIMemRows(TSDBROW* pRow, SRowKey* pRowKey, TSDBROW* piRow, SRowKey* piRowKey, + STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader, SRow** pTSRow); +static int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBlockScanInfo, SRowKey* pKey, STsdbReader* pReader); static int32_t mergeRowsInSttBlocks(SSttBlockReader* pSttBlockReader, STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader); @@ -89,32 +89,26 @@ static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWi static void resetPreFilesetMemTableListIndex(SReaderStatus* pStatus); -static int32_t pkComp(STsdbReader* pReader, TSDBROW* p1, TSDBROW* p2) { - STsdbRowKey k1 = {0}, k2 = {0}; - - if (pReader->pkComparFn == NULL) { - ASSERT(TSDBROW_TS(p1) != TSDBROW_TS(p2)); - return 0; +static int32_t pkCompEx(__compar_fn_t comparFn, SRowKey* p1, SRowKey* p2) { + if (p2 == NULL) { + return 1; } - tsdbRowGetKey(p1, &k1); - tsdbRowGetKey(p2, &k2); - return pReader->pkComparFn(&k1.key.pks[0].val, &k2.key.pks[0].val); -} - -static int32_t pkComp1(STsdbReader* pReader, SRowKey* p1, TSDBROW* p2) { - if (pReader->pkComparFn == NULL) { - ASSERT(p1->ts != TSDBROW_TS(p2)); - return 0; + if (p1 == NULL) { + return -1; } - SRowKey k2 = {0}; - tRowGetKeyEx(p2, &k2); - return pReader->pkComparFn(&p1->pks[0].val, &k2.pks[0].val); -} + if (p1->ts < p2->ts) { + return -1; + } else if (p1->ts > p2->ts) { + return 1; + } -static int32_t pkComp2(__compar_fn_t comparFn, SRowKey* p1, SRowKey* p2) { - return comparFn(&p1->pks[0].val, &p2->pks[0].val); + if (p1->numOfPKs == 0) { + return 0; + } else { + return comparFn(&p1->pks[0].val, &p2->pks[0].val); + } } static void tColRowGetKeyDeepCopy(SBlockData* pBlock, int32_t irow, int32_t slotId, SRowKey* pKey) { @@ -154,6 +148,7 @@ static void tRowGetKeyDeepCopy(SRow* pRow, SRowKey* pKey) { } SPrimaryKeyIndex indices[TD_MAX_PK_COLS]; + ASSERT(pKey->numOfPKs <= TD_MAX_PK_COLS); uint8_t *data = pRow->data; for (int32_t i = 0; i < pRow->numOfPKs; i++) { @@ -203,7 +198,7 @@ static int32_t setColumnIdSlotList(SBlockLoadSuppInfo* pSupInfo, SColumnInfo* pC if (pCols[i].pk) { pSupInfo->pk = pCols[i]; - pSupInfo->pkSrcSlot = i; + pSupInfo->pkSrcSlot = i - 1; pSupInfo->pkDstSlot = pSlotIdList[i]; pSupInfo->numOfPks += 1; } @@ -692,13 +687,14 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN STableBlockScanInfo* pScanInfo = getTableBlockScanInfo(pReader->status.pTableMap, uid, pReader->idStr); // todo: here we should find the first timestamp that is greater than the lastProcKey + // the window is an open interval NOW. if (asc) { - w.skey = pScanInfo->lastProcKey.ts + step; + w.skey = pScanInfo->lastProcKey.ts; } else { - w.ekey = pScanInfo->lastProcKey.ts + step; + w.ekey = pScanInfo->lastProcKey.ts; } - if (isEmptyQueryTimeWindow(&w)) { + if (/*isEmptyQueryTimeWindow(&w)*/ w.ekey - w.skey < 2) { // NOTE: specialized for open interval k += 1; if (k >= numOfTables) { @@ -713,7 +709,11 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN continue; } - // 2. version range check + if (pkCompEx(pReader->pkComparFn, &pRecord->lastKey.key, &pScanInfo->lastProcKey) <= 0) { + continue; + } + + // 2. version range check, version range is an CLOSED interval if (pRecord->minVer > pReader->info.verRange.maxVer || pRecord->maxVer < pReader->info.verRange.minVer) { continue; } @@ -730,6 +730,7 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN if (pScanInfo->filesetWindow.skey > pRecord->firstKey.key.ts) { pScanInfo->filesetWindow.skey = pRecord->firstKey.key.ts; } + if (pScanInfo->filesetWindow.ekey < pRecord->lastKey.key.ts) { pScanInfo->filesetWindow.ekey = pRecord->lastKey.key.ts; } @@ -796,11 +797,12 @@ static int32_t doCopyColVal(SColumnInfoData* pColInfoData, int32_t rowIndex, int colDataSetNULL(pColInfoData, rowIndex); } else { varDataSetLen(pSup->buildBuf[colIndex], pColVal->value.nData); - if (pColVal->value.nData > pColInfoData->info.bytes) { + if ((pColVal->value.nData + VARSTR_HEADER_SIZE) > pColInfoData->info.bytes) { tsdbWarn("column cid:%d actual data len %d is bigger than schema len %d", pColVal->cid, pColVal->value.nData, pColInfoData->info.bytes); return TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER; } + if (pColVal->value.nData > 0) { // pData may be null, if nData is 0 memcpy(varDataVal(pSup->buildBuf[colIndex]), pColVal->value.pData, pColVal->value.nData); } @@ -1504,7 +1506,7 @@ static int32_t buildDataBlockFromBuf(STsdbReader* pReader, STableBlockScanInfo* return code; } -static bool tryCopyDistinctRowFromFileBlock(STsdbReader* pReader, SBlockData* pBlockData, int64_t key, +static bool tryCopyDistinctRowFromFileBlock(STsdbReader* pReader, SBlockData* pBlockData, SRowKey* pKey, SFileBlockDumpInfo* pDumpInfo, bool* copied) { // opt version // 1. it is not a border point @@ -1516,11 +1518,10 @@ static bool tryCopyDistinctRowFromFileBlock(STsdbReader* pReader, SBlockData* pB if ((pDumpInfo->rowIndex < pDumpInfo->totalRows - 1 && asc) || (pDumpInfo->rowIndex > 0 && (!asc))) { int32_t step = ASCENDING_TRAVERSE(pReader->info.order)? 1 : -1; - SRowKey rowKey, nextRowKey; - tColRowGetKey(pBlockData, pDumpInfo->rowIndex, &rowKey); + SRowKey nextRowKey; tColRowGetKey(pBlockData, pDumpInfo->rowIndex + step, &nextRowKey); - if (rowKey.ts != nextRowKey.ts || (pkComp2(pReader->pkComparFn, &rowKey, &nextRowKey) != 0)) { // merge is not needed + if (pkCompEx(pReader->pkComparFn, pKey, &nextRowKey) != 0) { // merge is not needed code = doAppendRowFromFileBlock(pReader->resBlockInfo.pResBlock, pReader, pBlockData, pDumpInfo->rowIndex); if (code) { return code; @@ -1533,7 +1534,7 @@ static bool tryCopyDistinctRowFromFileBlock(STsdbReader* pReader, SBlockData* pB return code; } -static bool nextRowFromSttBlocks(SSttBlockReader* pSttBlockReader, STableBlockScanInfo* pScanInfo, +static bool nextRowFromSttBlocks(SSttBlockReader* pSttBlockReader, STableBlockScanInfo* pScanInfo, int32_t pkSrcSlot, SVersionRange* pVerRange) { int32_t order = pSttBlockReader->order; int32_t step = ASCENDING_TRAVERSE(order) ? 1 : -1; @@ -1554,13 +1555,11 @@ static bool nextRowFromSttBlocks(SSttBlockReader* pSttBlockReader, STableBlockSc if (pSttBlockReader->numOfPks == 0) { pSttBlockReader->currentKey.ts = key; - // todo handle error - pScanInfo->sttKeyInfo.nextProcKey = key; - } else { // todo handle the deep copy problem - tColRowGetKey(pRow->pBlockData, pRow->iRow, &pSttBlockReader->currentKey); - pScanInfo->sttKeyInfo.nextProcKey = key; + } else { + tColRowGetKeyDeepCopy(pRow->pBlockData, pRow->iRow, pkSrcSlot, &pSttBlockReader->currentKey); } + pScanInfo->sttKeyInfo.nextProcKey = key; if (pScanInfo->delSkyline != NULL && TARRAY_SIZE(pScanInfo->delSkyline) > 0) { if (!hasBeenDropped(pScanInfo->delSkyline, &pScanInfo->sttBlockDelIndex, key, ver, order, pVerRange)) { pScanInfo->sttKeyInfo.status = STT_FILE_HAS_DATA; @@ -1577,20 +1576,6 @@ static void doPinSttBlock(SSttBlockReader* pSttBlockReader) { tMergeTreePinSttBl static void doUnpinSttBlock(SSttBlockReader* pSttBlockReader) { tMergeTreeUnpinSttBlock(&pSttBlockReader->mergeTree); } -static int32_t pkCompEx(__compar_fn_t comparFn, SRowKey* p1, SRowKey* p2) { - if (p1->ts < p2->ts) { - return -1; - } else if (p1->ts > p2->ts) { - return 1; - } - - if (p1->numOfPKs == 0) { - return 0; - } else { - return comparFn(&p1->pks[0].val, &p2->pks[0].val); - } -} - static bool tryCopyDistinctRowFromSttBlock(TSDBROW* fRow, SSttBlockReader* pSttBlockReader, STableBlockScanInfo* pScanInfo, SRowKey* pSttKey, STsdbReader* pReader, bool* copied) { @@ -1599,30 +1584,18 @@ static bool tryCopyDistinctRowFromSttBlock(TSDBROW* fRow, SSttBlockReader* pSttB // avoid the fetch next row replace the referenced stt block in buffer doPinSttBlock(pSttBlockReader); - bool hasVal = nextRowFromSttBlocks(pSttBlockReader, pScanInfo, &pReader->info.verRange); + bool hasVal = nextRowFromSttBlocks(pSttBlockReader, pScanInfo, pReader->suppInfo.pkSrcSlot, &pReader->info.verRange); doUnpinSttBlock(pSttBlockReader); if (hasVal) { - SRowKey nextKey; - - TSDBROW* pNextRow = tMergeTreeGetRow(&pSttBlockReader->mergeTree); - tRowGetKeyEx(pNextRow, &nextKey); - - if (pkCompEx(pReader->pkComparFn, pSttKey, &nextKey) != 0) { + SRowKey* pNext = getCurrentKeyInSttBlock(pSttBlockReader); + if (pkCompEx(pReader->pkComparFn, pSttKey, pNext) != 0) { code = doAppendRowFromFileBlock(pReader->resBlockInfo.pResBlock, pReader, fRow->pBlockData, fRow->iRow); - if (code) { - return code; - } - - *copied = true; + *copied = (code == TSDB_CODE_SUCCESS); return code; } } else { code = doAppendRowFromFileBlock(pReader->resBlockInfo.pResBlock, pReader, fRow->pBlockData, fRow->iRow); - if (code) { - return code; - } - - *copied = true; + *copied = (code == TSDB_CODE_SUCCESS); return code; } @@ -1669,10 +1642,13 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* SBlockData* pBlockData = &pReader->status.fileBlockData; SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; __compar_fn_t compFn = pReader->pkComparFn; + int32_t pkSrcSlot = pReader->suppInfo.pkSrcSlot; - SRowKey* pSttKey = NULL; + SRowKey* pSttKey = &(SRowKey){0}; if (hasDataInSttBlock(pBlockScanInfo) && (!pBlockScanInfo->cleanSttBlocks)) { - pSttKey = getCurrentKeyInSttBlock(pSttBlockReader); + tRowKeyAssign(pSttKey, getCurrentKeyInSttBlock(pSttBlockReader)); + } else { + pSttKey = NULL; } SRowKey k; @@ -1708,85 +1684,58 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* if (pReader->info.order == TSDB_ORDER_ASC) { minKey = k; // chosen the minimum value - if (hasDataInFileBlock(pBlockData, pDumpInfo) && (pkCompEx(compFn, pfKey, &minKey) < 0)) { + if (pfKey != NULL && pkCompEx(compFn, pfKey, &minKey) < 0) { minKey = *pfKey; } - if (pSttKey != NULL && (pkCompEx(compFn, pSttKey, &minKey) < 0)) { + if (pSttKey != NULL && pkCompEx(compFn, pSttKey, &minKey) < 0) { minKey = *pSttKey; } } else { minKey = k; - if (hasDataInFileBlock(pBlockData, pDumpInfo) && (pkCompEx(compFn, pfKey, &minKey) > 0)) { + if (pfKey != NULL && pkCompEx(compFn, pfKey, &minKey) > 0) { minKey = *pfKey; } - if (pSttKey != NULL && (pkCompEx(compFn, pSttKey, &minKey) > 0)) { + if (pSttKey != NULL && pkCompEx(compFn, pSttKey, &minKey) > 0) { minKey = *pSttKey; } } - // ASC: file block ---> last block -----> imem -----> mem - // DESC: mem -----> imem -----> last block -----> file block - if (pReader->info.order == TSDB_ORDER_ASC) { - if (pkCompEx(compFn, &minKey, pfKey) == 0) { - int32_t code = tsdbRowMergerAdd(pMerger, &fRow, NULL); - if (code != TSDB_CODE_SUCCESS) { - return code; - } + // copy the last key before the time of stt reader loading the next stt block, in which the underlying data block may + // be changed, resulting in the corresponding changing of the value of sttRowKey + tRowKeyAssign(&pBlockScanInfo->lastProcKey, &minKey); - doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader); + // file block ---> stt block -----> mem + if (pkCompEx(compFn, &minKey, pfKey) == 0) { + int32_t code = tsdbRowMergerAdd(pMerger, &fRow, NULL); + if (code != TSDB_CODE_SUCCESS) { + return code; } - if (pkCompEx(compFn, &minKey, pSttKey) == 0) { - TSDBROW* fRow1 = tMergeTreeGetRow(&pSttBlockReader->mergeTree); - int32_t code = tsdbRowMergerAdd(pMerger, fRow1, NULL); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - doMergeRowsInSttBlock(pSttBlockReader, pBlockScanInfo, pSttKey, pMerger, &pReader->info.verRange, pReader->idStr); + doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pfKey, pReader); + } + + if (pkCompEx(compFn, &minKey, pSttKey) == 0) { + TSDBROW* fRow1 = tMergeTreeGetRow(&pSttBlockReader->mergeTree); + int32_t code = tsdbRowMergerAdd(pMerger, fRow1, NULL); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + doMergeRowsInSttBlock(pSttBlockReader, pBlockScanInfo, pSttKey, pMerger, pkSrcSlot, &pReader->info.verRange, + pReader->idStr); + } + + if (pkCompEx(compFn, &minKey, &k) == 0) { + int32_t code = tsdbRowMergerAdd(pMerger, pRow, pSchema); + if (code != TSDB_CODE_SUCCESS) { + return code; } - if (pkCompEx(compFn, &minKey, &k) == 0) { - int32_t code = tsdbRowMergerAdd(pMerger, pRow, pSchema); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - code = doMergeRowsInBuf(pIter, pBlockScanInfo->uid, &k, pBlockScanInfo->delSkyline, pReader); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - } - } else { - if (pkCompEx(compFn, &minKey, &k) == 0) { - int32_t code = tsdbRowMergerAdd(pMerger, pRow, pSchema); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - code = doMergeRowsInBuf(pIter, pBlockScanInfo->uid, &k, pBlockScanInfo->delSkyline, pReader); - if (code != TSDB_CODE_SUCCESS || pMerger->pTSchema == NULL) { - return code; - } - } - - if (pkCompEx(compFn, &minKey, pSttKey) == 0) { - TSDBROW* fRow1 = tMergeTreeGetRow(&pSttBlockReader->mergeTree); - int32_t code = tsdbRowMergerAdd(pMerger, fRow1, NULL); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - doMergeRowsInSttBlock(pSttBlockReader, pBlockScanInfo, pSttKey, pMerger, &pReader->info.verRange, pReader->idStr); - } - - if (pkCompEx(compFn, &minKey, pfKey) == 0) { - int32_t code = tsdbRowMergerAdd(pMerger, &fRow, NULL); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader); + code = doMergeRowsInBuf(pIter, pBlockScanInfo->uid, &k, pBlockScanInfo->delSkyline, pReader); + if (code != TSDB_CODE_SUCCESS) { + return code; } } @@ -1803,11 +1752,12 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* return code; } -static int32_t mergeFileBlockAndSttBlock(STsdbReader* pReader, SSttBlockReader* pSttBlockReader, int64_t key, +static int32_t mergeFileBlockAndSttBlock(STsdbReader* pReader, SSttBlockReader* pSttBlockReader, SRowKey* pKey, STableBlockScanInfo* pBlockScanInfo, SBlockData* pBlockData) { SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; SRowMerger* pMerger = &pReader->status.merger; int32_t code = TSDB_CODE_SUCCESS; + int32_t pkSrcSlot = pReader->suppInfo.pkSrcSlot; // merge is not initialized yet, due to the fact that the pReader->info.pSchema is not initialized if (pMerger->pArray == NULL) { @@ -1823,88 +1773,57 @@ static int32_t mergeFileBlockAndSttBlock(STsdbReader* pReader, SSttBlockReader* if (dataInDataFile && (!dataInSttFile)) { // no stt file block available, only data block exists - return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, key, pReader); + return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pKey, pReader); } else if ((!dataInDataFile) && dataInSttFile) { // no data in data file exists return mergeRowsInSttBlocks(pSttBlockReader, pBlockScanInfo, pReader); } else if (pBlockScanInfo->cleanSttBlocks && pReader->info.execMode == READER_EXEC_ROWS) { // opt model for count data in stt file, which is not overlap with data blocks in files. - return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, key, pReader); + return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pKey, pReader); } else { // row in both stt file blocks and data file blocks - TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex); + TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex); SRowKey* pSttKey = getCurrentKeyInSttBlock(pSttBlockReader); - if (ASCENDING_TRAVERSE(pReader->info.order)) { - if (key < pSttKey->ts) { // asc - return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, key, pReader); - } else if (key > pSttKey->ts) { - return mergeRowsInSttBlocks(pSttBlockReader, pBlockScanInfo, pReader); - } + int32_t ret = pkCompEx(pSttBlockReader->pkComparFn, pKey, pSttKey); - // key == tsLast. ts is equal and the primary key exists - if (pSttBlockReader->numOfPks > 0) { - int32_t res = pkComp1(pReader, pSttKey, &fRow); - if (res > 0) { - return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, key, pReader); - } else if (res < 0) { - return mergeRowsInSttBlocks(pSttBlockReader, pBlockScanInfo, pReader); - } + if (ASCENDING_TRAVERSE(pReader->info.order)) { + if (ret < 0) { // asc + return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pKey, pReader); + } else if (ret > 0) { + return mergeRowsInSttBlocks(pSttBlockReader, pBlockScanInfo, pReader); } } else { // desc - if (key > pSttKey->ts) { - return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, key, pReader); - } else if (key < pSttKey->ts) { + if (ret > 0) { + return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pKey, pReader); + } else if (ret < 0) { return mergeRowsInSttBlocks(pSttBlockReader, pBlockScanInfo, pReader); } - - // key == tsLast. ts is equal and the primary key exists - if (pReader->suppInfo.numOfPks > 0) { - int32_t res = pkComp1(pReader, pSttKey, &fRow); - if (res < 0) { - return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, key, pReader); - } else if (res > 0) { - return mergeRowsInSttBlocks(pSttBlockReader, pBlockScanInfo, pReader); - } - } } + // pKey == pSttKey + tRowKeyAssign(&pBlockScanInfo->lastProcKey, pKey); + // the following for key == sttKey->key.ts - // ASC: file block ------> stt block - // DESC: stt block ------> file block + // file block ------> stt block SRow* pTSRow = NULL; - if (ASCENDING_TRAVERSE(pReader->info.order)) { - code = tsdbRowMergerAdd(pMerger, &fRow, NULL); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader); - - TSDBROW* pRow1 = tMergeTreeGetRow(&pSttBlockReader->mergeTree); - code = tsdbRowMergerAdd(pMerger, pRow1, NULL); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - doMergeRowsInSttBlock(pSttBlockReader, pBlockScanInfo, pSttKey, pMerger, &pReader->info.verRange, pReader->idStr); - } else { - TSDBROW* pRow1 = tMergeTreeGetRow(&pSttBlockReader->mergeTree); - code = tsdbRowMergerAdd(pMerger, pRow1, NULL); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - doMergeRowsInSttBlock(pSttBlockReader, pBlockScanInfo, pSttKey, pMerger, &pReader->info.verRange, pReader->idStr); - - code = tsdbRowMergerAdd(pMerger, &fRow, NULL); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader); + code = tsdbRowMergerAdd(pMerger, &fRow, NULL); + if (code != TSDB_CODE_SUCCESS) { + return code; } + doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pKey, pReader); + + TSDBROW* pRow1 = tMergeTreeGetRow(&pSttBlockReader->mergeTree); + code = tsdbRowMergerAdd(pMerger, pRow1, NULL); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + // pSttKey will be changed when sttBlockReader iterates to the next row, so use pKey instead. + doMergeRowsInSttBlock(pSttBlockReader, pBlockScanInfo, pKey, pMerger, pkSrcSlot, &pReader->info.verRange, + pReader->idStr); + code = tsdbRowMergerGetRow(pMerger, &pTSRow); if (code != TSDB_CODE_SUCCESS) { return code; @@ -1926,6 +1845,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; SArray* pDelList = pBlockScanInfo->delSkyline; __compar_fn_t compFn = pReader->pkComparFn; + int32_t pkSrcSlot = pReader->suppInfo.pkSrcSlot; TSDBROW* pRow = getValidMemRow(&pBlockScanInfo->iter, pDelList, pReader); TSDBROW* piRow = getValidMemRow(&pBlockScanInfo->iiter, pDelList, pReader); @@ -1973,13 +1893,13 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* SRowKey minKey; if (ASCENDING_TRAVERSE(pReader->info.order)) { - minKey = k; // let's find the minimum + minKey = k; // let's find the minimum - if (pkCompEx(compFn, &ik, &minKey) < 0) {//minKey > ik.key.ts) { + if (pkCompEx(compFn, &ik, &minKey) < 0) { // minKey > ik.key.ts) { minKey = ik; } - if (hasDataInFileBlock(pBlockData, pDumpInfo) && (pkCompEx(compFn, pfKey, &minKey) < 0)) { + if (pfKey != NULL && (pkCompEx(compFn, pfKey, &minKey) < 0)) { minKey = *pfKey; } @@ -1987,12 +1907,12 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* minKey = *pSttKey; } } else { - minKey = k; // let find the maximum ts value + minKey = k; // let find the maximum ts value if (pkCompEx(compFn, &ik, &minKey) > 0) { minKey = ik; } - if (hasDataInFileBlock(pBlockData, pDumpInfo) && (pkCompEx(compFn, pfKey, &minKey) > 0)) { + if (pfKey != NULL && (pkCompEx(compFn, pfKey, &minKey) > 0)) { minKey = *pfKey; } @@ -2001,95 +1921,51 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* } } - // ASC: file block -----> stt block -----> imem -----> mem - // DESC: mem -----> imem -----> stt block -----> file block - if (ASCENDING_TRAVERSE(pReader->info.order)) { - if (pkCompEx(compFn, &minKey, pfKey) == 0) { - TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex); - code = tsdbRowMergerAdd(pMerger, &fRow, NULL); - if (code != TSDB_CODE_SUCCESS) { - return code; - } + tRowKeyAssign(&pBlockScanInfo->lastProcKey, &minKey); - doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader); + // file block -----> stt block -----> imem -----> mem + if (pkCompEx(compFn, &minKey, pfKey) == 0) { + TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex); + code = tsdbRowMergerAdd(pMerger, &fRow, NULL); + if (code != TSDB_CODE_SUCCESS) { + return code; } - if (pkCompEx(compFn, &minKey, pSttKey) == 0) { - TSDBROW* pRow1 = tMergeTreeGetRow(&pSttBlockReader->mergeTree); - code = tsdbRowMergerAdd(pMerger, pRow1, NULL); - if (code != TSDB_CODE_SUCCESS) { - return code; - } + doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pfKey, pReader); + } - doMergeRowsInSttBlock(pSttBlockReader, pBlockScanInfo, pSttKey, pMerger, &pReader->info.verRange, pReader->idStr); + if (pkCompEx(compFn, &minKey, pSttKey) == 0) { + TSDBROW* pRow1 = tMergeTreeGetRow(&pSttBlockReader->mergeTree); + code = tsdbRowMergerAdd(pMerger, pRow1, NULL); + if (code != TSDB_CODE_SUCCESS) { + return code; } - if (pkCompEx(compFn, &minKey, &ik) == 0) { - code = tsdbRowMergerAdd(pMerger, piRow, piSchema); - if (code != TSDB_CODE_SUCCESS) { - return code; - } + doMergeRowsInSttBlock(pSttBlockReader, pBlockScanInfo, pSttKey, pMerger, pkSrcSlot, &pReader->info.verRange, + pReader->idStr); + } - code = doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, &ik, pBlockScanInfo->delSkyline, pReader); - if (code != TSDB_CODE_SUCCESS) { - return code; - } + if (pkCompEx(compFn, &minKey, &ik) == 0) { + code = tsdbRowMergerAdd(pMerger, piRow, piSchema); + if (code != TSDB_CODE_SUCCESS) { + return code; } - if (pkCompEx(compFn, &minKey, &k) == 0) { - code = tsdbRowMergerAdd(pMerger, pRow, pSchema); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, &k, pBlockScanInfo->delSkyline, pReader); - if (code != TSDB_CODE_SUCCESS) { - return code; - } + code = doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, &ik, pBlockScanInfo->delSkyline, pReader); + if (code != TSDB_CODE_SUCCESS) { + return code; } - } else { - if (pkCompEx(compFn, &minKey, &k) == 0) { - code = tsdbRowMergerAdd(pMerger, pRow, pSchema); - if (code != TSDB_CODE_SUCCESS) { - return code; - } + } - code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, &k, pBlockScanInfo->delSkyline, pReader); - if (code != TSDB_CODE_SUCCESS) { - return code; - } + if (pkCompEx(compFn, &minKey, &k) == 0) { + code = tsdbRowMergerAdd(pMerger, pRow, pSchema); + if (code != TSDB_CODE_SUCCESS) { + return code; } - if (pkCompEx(compFn, &minKey, &ik) == 0) { - code = tsdbRowMergerAdd(pMerger, piRow, piSchema); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - code = doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, &ik, pBlockScanInfo->delSkyline, pReader); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - } - - if (pkCompEx(compFn, &minKey, pSttKey) == 0) { - TSDBROW* pRow1 = tMergeTreeGetRow(&pSttBlockReader->mergeTree); - code = tsdbRowMergerAdd(pMerger, pRow1, NULL); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - doMergeRowsInSttBlock(pSttBlockReader, pBlockScanInfo, pSttKey, pMerger, &pReader->info.verRange, pReader->idStr); - } - - if (pkCompEx(compFn, &minKey, pfKey) == 0) { - TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex); - code = tsdbRowMergerAdd(pMerger, &fRow, NULL); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader); + code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, &k, pBlockScanInfo->delSkyline, pReader); + if (code != TSDB_CODE_SUCCESS) { + return code; } } @@ -2147,13 +2023,13 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea startKey = (STsdbRowKey){.version = pReader->info.verRange.minVer, .key = { .ts = pBlockScanInfo->lastProcKey.ts + 1, - .numOfPKs = 0, // TODO: change here if multi-key is supported + .numOfPKs = pReader->suppInfo.numOfPks, }}; } else { startKey = (STsdbRowKey){.version = pReader->info.verRange.maxVer, .key = { .ts = pBlockScanInfo->lastProcKey.ts - 1, - .numOfPKs = 0, // TODO: change here if multi-key is supported + .numOfPKs = pReader->suppInfo.numOfPks, }}; } @@ -2202,9 +2078,9 @@ static bool isValidFileBlockRow(SBlockData* pBlockData, int32_t rowIndex, STable } if (ts == pBlockScanInfo->lastProcKey.ts) { // todo opt perf - SRowKey nextRowKey; + SRowKey nextRowKey; // lazy eval tColRowGetKey(pBlockData, rowIndex, &nextRowKey); - if (pkComp2(pReader->pkComparFn, &pBlockScanInfo->lastProcKey, &nextRowKey) == 0) { + if (pkCompEx(pReader->pkComparFn, &pBlockScanInfo->lastProcKey, &nextRowKey) == 0) { return false; } } @@ -2303,16 +2179,16 @@ static bool initSttBlockReader(SSttBlockReader* pSttBlockReader, STableBlockScan pScanInfo->sttKeyInfo.nextProcKey = ASCENDING_TRAVERSE(pReader->info.order) ? pScanInfo->sttWindow.skey : pScanInfo->sttWindow.ekey; hasData = (pScanInfo->sttKeyInfo.status == STT_FILE_HAS_DATA); - } else { // not clean stt blocks - INIT_TIMEWINDOW(&pScanInfo->sttWindow); // reset the time window + } else { // not clean stt blocks + INIT_TIMEWINDOW(&pScanInfo->sttWindow); //reset the time window pScanInfo->sttBlockReturned = false; - hasData = nextRowFromSttBlocks(pSttBlockReader, pScanInfo, &pReader->info.verRange); + hasData = nextRowFromSttBlocks(pSttBlockReader, pScanInfo, pReader->suppInfo.pkSrcSlot, &pReader->info.verRange); } } else { pScanInfo->cleanSttBlocks = false; INIT_TIMEWINDOW(&pScanInfo->sttWindow); // reset the time window pScanInfo->sttBlockReturned = false; - hasData = nextRowFromSttBlocks(pSttBlockReader, pScanInfo, &pReader->info.verRange); + hasData = nextRowFromSttBlocks(pSttBlockReader, pScanInfo, pReader->suppInfo.pkSrcSlot, &pReader->info.verRange); } taosArrayDestroy(info.pTimeWindowList); @@ -2333,13 +2209,13 @@ bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* return pBlockData->nRow > 0 && (!pDumpInfo->allDumped); } -int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBlockScanInfo, int64_t key, +int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBlockScanInfo, SRowKey* pKey, STsdbReader* pReader) { SRowMerger* pMerger = &pReader->status.merger; SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; bool copied = false; - int32_t code = tryCopyDistinctRowFromFileBlock(pReader, pBlockData, key, pDumpInfo, &copied); + int32_t code = tryCopyDistinctRowFromFileBlock(pReader, pBlockData, pKey, pDumpInfo, &copied); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -2353,13 +2229,9 @@ int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBloc } } + tRowKeyAssign(&pBlockScanInfo->lastProcKey, pKey); + if (copied) { -// if (pReader->suppInfo.numOfPks == 0) { -// pBlockScanInfo->lastProcKey.ts = key; -// } else { // todo use deep copy instead of shallow copy -// int32_t step = ASCENDING_TRAVERSE(pReader->info.order)? 1 : -1; -// tColRowGetKey(pBlockData, pDumpInfo->rowIndex - step, &pBlockScanInfo->lastProcKey); -// } return TSDB_CODE_SUCCESS; } else { TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex); @@ -2370,7 +2242,7 @@ int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBloc return code; } - doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader); + doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pKey, pReader); code = tsdbRowMergerGetRow(pMerger, &pTSRow); if (code != TSDB_CODE_SUCCESS) { return code; @@ -2386,9 +2258,10 @@ int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBloc int32_t mergeRowsInSttBlocks(SSttBlockReader* pSttBlockReader, STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader) { - bool copied = false; - SRow* pTSRow = NULL; - SRowKey sttKey = {0}; + bool copied = false; + SRow* pTSRow = NULL; + SRowKey sttKey = {0}; + int32_t pkSrcSlot = pReader->suppInfo.pkSrcSlot; tRowKeyAssign(&sttKey, getCurrentKeyInSttBlock(pSttBlockReader)); @@ -2404,8 +2277,9 @@ int32_t mergeRowsInSttBlocks(SSttBlockReader* pSttBlockReader, STableBlockScanIn return code; } + tRowKeyAssign(&pBlockScanInfo->lastProcKey, &sttKey); + if (copied) { -// tRowKeyAssign(&pBlockScanInfo->lastProcKey, &sttKey); return TSDB_CODE_SUCCESS; } else { code = tsdbRowMergerAdd(pMerger, &fRow, NULL); @@ -2415,7 +2289,7 @@ int32_t mergeRowsInSttBlocks(SSttBlockReader* pSttBlockReader, STableBlockScanIn TSDBROW* pRow1 = tMergeTreeGetRow(&pSttBlockReader->mergeTree); tsdbRowMergerAdd(pMerger, pRow1, NULL); - doMergeRowsInSttBlock(pSttBlockReader, pBlockScanInfo, &sttKey, pMerger, &pReader->info.verRange, pReader->idStr); + doMergeRowsInSttBlock(pSttBlockReader, pBlockScanInfo, &sttKey, pMerger, pkSrcSlot, &pReader->info.verRange, pReader->idStr); code = tsdbRowMergerGetRow(pMerger, &pTSRow); if (code != TSDB_CODE_SUCCESS) { @@ -2435,9 +2309,14 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; TSDBROW *pRow = NULL, *piRow = NULL; - int64_t key = (pBlockData->nRow > 0 && (!pDumpInfo->allDumped)) - ? pBlockData->aTSKEY[pDumpInfo->rowIndex] - : (ASCENDING_TRAVERSE(pReader->info.order) ? INT64_MAX : INT64_MIN); + + SRowKey* pKey = &(SRowKey){0}; + if (hasDataInFileBlock(pBlockData, pDumpInfo)) { + tColRowGetKey(pBlockData, pDumpInfo->rowIndex, pKey); + } else { + pKey = NULL; + } + if (pBlockScanInfo->iter.hasVal) { pRow = getValidMemRow(&pBlockScanInfo->iter, pBlockScanInfo->delSkyline, pReader); } @@ -2462,7 +2341,7 @@ static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanI } // files data blocks + stt block - return mergeFileBlockAndSttBlock(pReader, pSttBlockReader, key, pBlockScanInfo, pBlockData); + return mergeFileBlockAndSttBlock(pReader, pSttBlockReader, pKey, pBlockScanInfo, pBlockData); } static int32_t loadNeighborIfOverlap(SFileDataBlockInfo* pBlockInfo, STableBlockScanInfo* pBlockScanInfo, @@ -2862,10 +2741,19 @@ static void buildCleanBlockFromSttFiles(STsdbReader* pReader, STableBlockScanInf pScanInfo->sttKeyInfo.nextProcKey = asc ? pScanInfo->sttWindow.ekey + 1 : pScanInfo->sttWindow.skey - 1; pScanInfo->sttKeyInfo.status = STT_FILE_NO_DATA; - ASSERT(0); pScanInfo->lastProcKey.ts = asc ? pScanInfo->sttWindow.ekey : pScanInfo->sttWindow.skey; - pScanInfo->sttBlockReturned = true; + if (pScanInfo->lastProcKey.numOfPKs > 0) { + ASSERT(0); +// if (IS_NUMERIC_TYPE(pKey->pks[0].type)) { +// pKey->pks[0].val = asc ? pBlockInfo->lastPk.val : pBlockInfo->firstPk.val; +// } else { +// uint8_t* p = asc ? pBlockInfo->lastPk.pData : pBlockInfo->firstPk.pData; +// pKey->pks[0].nData = asc ? pBlockInfo->lastPKLen : pBlockInfo->firstPKLen; +// memcpy(pKey->pks[0].pData, p, pKey->pks[0].nData); +// } + } + pScanInfo->sttBlockReturned = true; pSttBlockReader->mergeTree.pIter = NULL; tsdbDebug("%p uid:%" PRId64 " return clean stt block as one, brange:%" PRId64 "-%" PRId64 " rows:%" PRId64 " %s", @@ -2886,7 +2774,7 @@ static void buildCleanBlockFromDataFiles(STsdbReader* pReader, STableBlockScanIn pInfo->version = pReader->info.verRange.maxVer; pInfo->window = (STimeWindow){.skey = pBlockInfo->firstKey, .ekey = pBlockInfo->lastKey}; - if (pReader->suppInfo.pk.pk) { + if (pReader->suppInfo.numOfPks > 0) { if (IS_NUMERIC_TYPE(pReader->suppInfo.pk.type)) { pInfo->pks[0].val = pBlockInfo->firstPk.val; pInfo->pks[1].val = pBlockInfo->lastPk.val; @@ -3224,6 +3112,7 @@ static void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter) SFileBlockDumpInfo* pDumpInfo = &pStatus->fBlockDumpInfo; if (pBlockInfo) { + // todo handle // STableBlockScanInfo* pScanInfo = tSimpleHashGet(pBlockIter->pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid)); // if (pScanInfo) { // tsdbRowKeyAssign(&pDumpInfo->lastKey, &pScanInfo->lastProcKey); @@ -3627,7 +3516,9 @@ int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, SRowKey *pCurKey, SArra break; } - if (pkComp1(pReader, pCurKey, pRow) != 0) { + SRowKey nextKey = {0}; + tRowGetKeyEx(pRow, &nextKey); + if (pkCompEx(pReader->pkComparFn, pCurKey, &nextKey) != 0) { break; } @@ -3645,9 +3536,15 @@ int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, SRowKey *pCurKey, SArra return TSDB_CODE_SUCCESS; } -static int32_t doMergeRowsInFileBlockImpl(SBlockData* pBlockData, int32_t rowIndex, int64_t key, SRowMerger* pMerger, - SVersionRange* pVerRange, int32_t step) { - while (rowIndex < pBlockData->nRow && rowIndex >= 0 && pBlockData->aTSKEY[rowIndex] == key) { +static int32_t doMergeRowsInFileBlockImpl(SBlockData* pBlockData, int32_t rowIndex, SRowKey* pKey, SRowMerger* pMerger, + SVersionRange* pVerRange, int32_t step, __compar_fn_t comparFn) { + while (rowIndex < pBlockData->nRow && rowIndex >= 0) { + SRowKey cur; + tColRowGetKey(pBlockData, rowIndex, &cur); + if (pkCompEx(comparFn, &cur, pKey) != 0) { + break; + } + if (pBlockData->aVersion[rowIndex] > pVerRange->maxVer || pBlockData->aVersion[rowIndex] < pVerRange->minVer) { rowIndex += step; continue; @@ -3667,21 +3564,20 @@ typedef enum { } CHECK_FILEBLOCK_STATE; static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanInfo* pScanInfo, - SFileDataBlockInfo* pFBlock, SRowMerger* pMerger, int64_t key, + SFileDataBlockInfo* pFBlock, SRowMerger* pMerger, SRowKey* pKey, CHECK_FILEBLOCK_STATE* state) { SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; SBlockData* pBlockData = &pReader->status.fileBlockData; bool asc = ASCENDING_TRAVERSE(pReader->info.order); + SVersionRange* pVerRange = &pReader->info.verRange; + bool loadNeighbor = true; + int32_t step = ASCENDING_TRAVERSE(pReader->info.order) ? 1 : -1; - *state = CHECK_FILEBLOCK_QUIT; - int32_t step = ASCENDING_TRAVERSE(pReader->info.order) ? 1 : -1; - - bool loadNeighbor = true; int32_t code = loadNeighborIfOverlap(pFBlock, pScanInfo, pReader, &loadNeighbor); + *state = CHECK_FILEBLOCK_QUIT; if (loadNeighbor && (code == TSDB_CODE_SUCCESS)) { - pDumpInfo->rowIndex = - doMergeRowsInFileBlockImpl(pBlockData, pDumpInfo->rowIndex, key, pMerger, &pReader->info.verRange, step); + pDumpInfo->rowIndex = doMergeRowsInFileBlockImpl(pBlockData, pDumpInfo->rowIndex, pKey, pMerger, pVerRange, step, pReader->pkComparFn); if ((pDumpInfo->rowIndex >= pDumpInfo->totalRows && asc) || (pDumpInfo->rowIndex < 0 && !asc)) { *state = CHECK_FILEBLOCK_CONT; } @@ -3690,18 +3586,17 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn return code; } -int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, STsdbReader* pReader) { +int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, SRowKey* pKey, STsdbReader* pReader) { SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; - - SRowMerger* pMerger = &pReader->status.merger; - bool asc = ASCENDING_TRAVERSE(pReader->info.order); - int64_t key = pBlockData->aTSKEY[pDumpInfo->rowIndex]; - int32_t step = asc ? 1 : -1; + SRowMerger* pMerger = &pReader->status.merger; + bool asc = ASCENDING_TRAVERSE(pReader->info.order); + int32_t step = asc ? 1 : -1; + SVersionRange* pRange = &pReader->info.verRange; pDumpInfo->rowIndex += step; if ((pDumpInfo->rowIndex <= pBlockData->nRow - 1 && asc) || (pDumpInfo->rowIndex >= 0 && !asc)) { pDumpInfo->rowIndex = - doMergeRowsInFileBlockImpl(pBlockData, pDumpInfo->rowIndex, key, pMerger, &pReader->info.verRange, step); + doMergeRowsInFileBlockImpl(pBlockData, pDumpInfo->rowIndex, pKey, pMerger, pRange, step, pReader->pkComparFn); } // all rows are consumed, let's try next file block @@ -3715,7 +3610,7 @@ int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pSc break; } - checkForNeighborFileBlock(pReader, pScanInfo, pFileBlockInfo, pMerger, key, &st); + checkForNeighborFileBlock(pReader, pScanInfo, pFileBlockInfo, pMerger, pKey, &st); if (st == CHECK_FILEBLOCK_QUIT) { break; } @@ -3725,19 +3620,16 @@ int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pSc return TSDB_CODE_SUCCESS; } - - int32_t doMergeRowsInSttBlock(SSttBlockReader* pSttBlockReader, STableBlockScanInfo* pScanInfo, SRowKey* pRowKey, - SRowMerger* pMerger, SVersionRange* pVerRange, const char* idStr) { - while (nextRowFromSttBlocks(pSttBlockReader, pScanInfo, pVerRange)) { - SRowKey* next1 = getCurrentKeyInSttBlock(pSttBlockReader); + SRowMerger* pMerger, int32_t pkSrcSlot, SVersionRange* pVerRange, const char* idStr) { + while (nextRowFromSttBlocks(pSttBlockReader, pScanInfo, pkSrcSlot, pVerRange)) { + SRowKey* pNextKey = getCurrentKeyInSttBlock(pSttBlockReader); - int32_t ret = pkCompEx(pSttBlockReader->pkComparFn, pRowKey, next1); + int32_t ret = pkCompEx(pSttBlockReader->pkComparFn, pRowKey, pNextKey); if (ret == 0) { TSDBROW* pRow1 = tMergeTreeGetRow(&pSttBlockReader->mergeTree); tsdbRowMergerAdd(pMerger, pRow1, NULL); } else { - ASSERT(ret < 0); tsdbTrace("uid:%" PRIu64 " last del index:%d, del range:%d, lastKeyInStt:%" PRId64 ", %s", pScanInfo->uid, pScanInfo->sttBlockDelIndex, (int32_t)taosArrayGetSize(pScanInfo->delSkyline), pScanInfo->sttKeyInfo.nextProcKey, idStr); @@ -3748,13 +3640,11 @@ int32_t doMergeRowsInSttBlock(SSttBlockReader* pSttBlockReader, STableBlockScanI return TSDB_CODE_SUCCESS; } -int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, SArray* pDelList, TSDBROW* pResRow, - STsdbReader* pReader, bool* freeTSRow) { - TSDBROW* pNextRow = NULL; - TSDBROW current = *pRow; - - SRowKey curKey = {0}; - tRowGetKeyEx(¤t, &curKey); +int32_t doMergeMemTableMultiRows(TSDBROW* pRow, SRowKey* pKey, uint64_t uid, SIterInfo* pIter, SArray* pDelList, + TSDBROW* pResRow, STsdbReader* pReader, bool* freeTSRow) { + SRowMerger* pMerger = &pReader->status.merger; + TSDBROW* pNextRow = NULL; + TSDBROW current = *pRow; { // if the timestamp of the next valid row has a different ts, return current row directly pIter->hasVal = tsdbTbDataIterNext(pIter->iter); @@ -3771,7 +3661,15 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, return TSDB_CODE_SUCCESS; } - if (TSDBROW_TS(¤t) != TSDBROW_TS(pNextRow) || (pkComp1(pReader, &curKey, pNextRow) != 0)) { + if (TSDBROW_TS(¤t) != TSDBROW_TS(pNextRow)) { + *pResRow = current; + *freeTSRow = false; + return TSDB_CODE_SUCCESS; + } + + SRowKey nextRowKey = {0}; + tRowGetKeyEx(pNextRow, &nextRowKey); + if (pKey->numOfPKs > 0 && pkCompEx(pReader->pkComparFn, pKey, &nextRowKey) != 0) { *pResRow = current; *freeTSRow = false; return TSDB_CODE_SUCCESS; @@ -3791,7 +3689,7 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, } } - code = tsdbRowMergerAdd(&pReader->status.merger, ¤t, pTSchema); + code = tsdbRowMergerAdd(pMerger, ¤t, pTSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -3804,35 +3702,32 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, } } - code = tsdbRowMergerAdd(&pReader->status.merger, pNextRow, pTSchema1); + code = tsdbRowMergerAdd(pMerger, pNextRow, pTSchema1); if (code != TSDB_CODE_SUCCESS) { return code; } - code = doMergeRowsInBuf(pIter, uid, &curKey, pDelList, pReader); + code = doMergeRowsInBuf(pIter, uid, pKey, pDelList, pReader); if (code != TSDB_CODE_SUCCESS) { return code; } - code = tsdbRowMergerGetRow(&pReader->status.merger, &pResRow->pTSRow); + code = tsdbRowMergerGetRow(pMerger, &pResRow->pTSRow); if (code != TSDB_CODE_SUCCESS) { return code; } pResRow->type = TSDBROW_ROW_FMT; - tsdbRowMergerClear(&pReader->status.merger); + tsdbRowMergerClear(pMerger); *freeTSRow = true; return TSDB_CODE_SUCCESS; } -int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader, - SRow** pTSRow) { +int32_t doMergeMemIMemRows(TSDBROW* pRow, SRowKey* pRowKey, TSDBROW* piRow, SRowKey* piRowKey, + STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader, SRow** pTSRow) { SRowMerger* pMerger = &pReader->status.merger; - - SRowKey k, ik; - tRowGetKeyEx(pRow, &k); - tRowGetKeyEx(piRow, &ik); + int32_t code = TSDB_CODE_SUCCESS; STSchema* pSchema = NULL; if (pRow->type == TSDBROW_ROW_FMT) { @@ -3851,83 +3746,97 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p } if (ASCENDING_TRAVERSE(pReader->info.order)) { // ascending order imem --> mem - int32_t code = tsdbRowMergerAdd(&pReader->status.merger, piRow, piSchema); + code = tsdbRowMergerAdd(pMerger, piRow, piSchema); if (code != TSDB_CODE_SUCCESS) { return code; } - code = doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, &ik, pBlockScanInfo->delSkyline, pReader); + code = doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, piRowKey, pBlockScanInfo->delSkyline, pReader); if (code != TSDB_CODE_SUCCESS) { return code; } - tsdbRowMergerAdd(&pReader->status.merger, pRow, pSchema); - code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, &k, pBlockScanInfo->delSkyline, pReader); + code = tsdbRowMergerAdd(pMerger, pRow, pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } + code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, pRowKey, pBlockScanInfo->delSkyline, pReader); + if (code != TSDB_CODE_SUCCESS) { + return code; + } } else { - int32_t code = tsdbRowMergerAdd(&pReader->status.merger, pRow, pSchema); - if (code != TSDB_CODE_SUCCESS || pMerger->pTSchema == NULL) { - return code; - } - - code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, &k, pBlockScanInfo->delSkyline, pReader); + code = tsdbRowMergerAdd(pMerger, pRow, pSchema); if (code != TSDB_CODE_SUCCESS) { return code; } - tsdbRowMergerAdd(&pReader->status.merger, piRow, piSchema); - code = doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, &ik, pBlockScanInfo->delSkyline, pReader); + code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, pRowKey, pBlockScanInfo->delSkyline, pReader); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + code = tsdbRowMergerAdd(pMerger, piRow, piSchema); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + code = doMergeRowsInBuf(&pBlockScanInfo->iiter, pBlockScanInfo->uid, piRowKey, pBlockScanInfo->delSkyline, pReader); if (code != TSDB_CODE_SUCCESS) { return code; } } - int32_t code = tsdbRowMergerGetRow(pMerger, pTSRow); + tRowKeyAssign(&pBlockScanInfo->lastProcKey, pRowKey); + + code = tsdbRowMergerGetRow(pMerger, pTSRow); tsdbRowMergerClear(pMerger); return code; } static int32_t tsdbGetNextRowInMem(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader, TSDBROW* pResRow, int64_t endKey, bool* freeTSRow) { - TSDBROW* pRow = getValidMemRow(&pBlockScanInfo->iter, pBlockScanInfo->delSkyline, pReader); - TSDBROW* piRow = getValidMemRow(&pBlockScanInfo->iiter, pBlockScanInfo->delSkyline, pReader); - SArray* pDelList = pBlockScanInfo->delSkyline; - uint64_t uid = pBlockScanInfo->uid; + TSDBROW* pRow = getValidMemRow(&pBlockScanInfo->iter, pBlockScanInfo->delSkyline, pReader); + TSDBROW* piRow = getValidMemRow(&pBlockScanInfo->iiter, pBlockScanInfo->delSkyline, pReader); + + SArray* pDelList = pBlockScanInfo->delSkyline; + uint64_t uid = pBlockScanInfo->uid; + SIterInfo* piter = &pBlockScanInfo->iter; + SIterInfo* piiter = &pBlockScanInfo->iiter; + SRowKey rowKey = {0}, irowKey = {0}; // todo refactor bool asc = ASCENDING_TRAVERSE(pReader->info.order); - if (pBlockScanInfo->iter.hasVal) { + if (piter->hasVal) { TSDBKEY k = TSDBROW_KEY(pRow); if ((k.ts >= endKey && asc) || (k.ts <= endKey && !asc)) { pRow = NULL; } } - if (pBlockScanInfo->iiter.hasVal) { + if (piiter->hasVal) { TSDBKEY k = TSDBROW_KEY(piRow); if ((k.ts >= endKey && asc) || (k.ts <= endKey && !asc)) { piRow = NULL; } } - if (pBlockScanInfo->iter.hasVal && pBlockScanInfo->iiter.hasVal && pRow != NULL && piRow != NULL) { - TSDBKEY k = TSDBROW_KEY(pRow); - TSDBKEY ik = TSDBROW_KEY(piRow); + if (piter->hasVal && piiter->hasVal && pRow != NULL && piRow != NULL) { + tRowGetKeyEx(pRow, &rowKey); + tRowGetKeyEx(piRow, &irowKey); int32_t code = TSDB_CODE_SUCCESS; - if (ik.ts != k.ts || (pkComp(pReader, pRow, piRow) != 0)) { - if (((ik.ts < k.ts) && asc) || ((ik.ts > k.ts) && (!asc))) { // ik.ts < k.ts - code = doMergeMemTableMultiRows(piRow, uid, &pBlockScanInfo->iiter, pDelList, pResRow, pReader, freeTSRow); - } else if (((k.ts < ik.ts) && asc) || ((k.ts > ik.ts) && (!asc))) { - code = doMergeMemTableMultiRows(pRow, uid, &pBlockScanInfo->iter, pDelList, pResRow, pReader, freeTSRow); + int32_t ret = pkCompEx(pReader->pkComparFn, &rowKey, &irowKey); + if (ret != 0) { + if ((ret > 0 && asc) || (ret < 0 && (!asc))) { // ik.ts < k.ts + code = doMergeMemTableMultiRows(piRow, &irowKey, uid, piiter, pDelList, pResRow, pReader, freeTSRow); + } else if ((ret < 0 && asc) || (ret > 0 && (!asc))) { + code = doMergeMemTableMultiRows(pRow, &rowKey, uid, piter, pDelList, pResRow, pReader, freeTSRow); } } else { // ik.ts == k.ts *freeTSRow = true; pResRow->type = TSDBROW_ROW_FMT; - code = doMergeMemIMemRows(pRow, piRow, pBlockScanInfo, pReader, &pResRow->pTSRow); + code = doMergeMemIMemRows(pRow, &rowKey, piRow, &irowKey, pBlockScanInfo, pReader, &pResRow->pTSRow); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -3936,12 +3845,14 @@ static int32_t tsdbGetNextRowInMem(STableBlockScanInfo* pBlockScanInfo, STsdbRea return code; } - if (pBlockScanInfo->iter.hasVal && pRow != NULL) { - return doMergeMemTableMultiRows(pRow, uid, &pBlockScanInfo->iter, pDelList, pResRow, pReader, freeTSRow); + if (piter->hasVal && pRow != NULL) { + tRowGetKeyEx(pRow, &rowKey); + return doMergeMemTableMultiRows(pRow, &rowKey, uid, piter, pDelList, pResRow, pReader, freeTSRow); } - if (pBlockScanInfo->iiter.hasVal && piRow != NULL) { - return doMergeMemTableMultiRows(piRow, uid, &pBlockScanInfo->iiter, pDelList, pResRow, pReader, freeTSRow); + if (piiter->hasVal && piRow != NULL) { + tRowGetKeyEx(piRow, &irowKey); + return doMergeMemTableMultiRows(piRow, &irowKey, uid, piiter, pDelList, pResRow, pReader, freeTSRow); } return TSDB_CODE_SUCCESS; @@ -4065,6 +3976,9 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e if (row.type == TSDBROW_ROW_FMT) { code = doAppendRowFromTSRow(pBlock, pReader, row.pTSRow, pBlockScanInfo); + if (code == TSDB_CODE_SUCCESS) { + tRowGetKeyDeepCopy(row.pTSRow, &pBlockScanInfo->lastProcKey); + } if (freeTSRow) { taosMemoryFree(row.pTSRow); @@ -4073,8 +3987,6 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e if (code) { return code; } - - tRowGetKeyDeepCopy(row.pTSRow, &pBlockScanInfo->lastProcKey); } else { code = doAppendRowFromFileBlock(pBlock, pReader, row.pBlockData, row.iRow); if (code) { @@ -4128,25 +4040,10 @@ int32_t tsdbSetTableList2(STsdbReader* pReader, const void* pTableList, int32_t STableKeyInfo* pList = (STableKeyInfo*)pTableList; for (int32_t i = 0; i < num; ++i) { - STableBlockScanInfo* pInfo = getPosInBlockInfoBuf(&pReader->blockInfoBuf, i); - pInfo->uid = pList[i].uid; pUidList->tableUidList[i] = pList[i].uid; - // todo extract method - if (ASCENDING_TRAVERSE(pReader->info.order)) { - int64_t skey = pReader->info.window.skey; - ASSERT(0); -// pInfo->lastProcKey = (skey > INT64_MIN) ? (skey - 1) : skey; - pInfo->sttKeyInfo.nextProcKey = skey; - } else { - int64_t ekey = pReader->info.window.ekey; - ASSERT(0); -// pInfo->lastProcKey = (ekey < INT64_MAX) ? (ekey + 1) : ekey; - pInfo->sttKeyInfo.nextProcKey = ekey; - } - - pInfo->sttKeyInfo.status = STT_FILE_READER_UNINIT; - tSimpleHashPut(pReader->status.pTableMap, &pInfo->uid, sizeof(uint64_t), &pInfo, POINTER_BYTES); + STableBlockScanInfo* pInfo = getPosInBlockInfoBuf(&pReader->blockInfoBuf, i); + initTableBlockScanInfo(pInfo, pList[i].uid, pReader->status.pTableMap, pReader); } return TDB_CODE_SUCCESS; @@ -4183,8 +4080,6 @@ static int32_t doOpenReaderImpl(STsdbReader* pReader) { int32_t code = TSDB_CODE_SUCCESS; if (pStatus->fileIter.numOfFiles == 0) { pStatus->loadFromFile = false; - // } else if (READER_EXEC_DATA == pReader->info.readMode) { - // DO NOTHING } else { code = initForFirstBlockInFile(pReader, pBlockIter); } @@ -4457,7 +4352,7 @@ static int32_t doSuspendCurrentReader(STsdbReader* pCurrentReader) { while ((p = tSimpleHashIterate(pStatus->pTableMap, p, &iter)) != NULL) { STableBlockScanInfo* pInfo = *(STableBlockScanInfo**)p; clearBlockScanInfo(pInfo); - ASSERT(0); +// pInfo->sttKeyInfo.nextProcKey = pInfo->lastProcKey.ts + step; // pInfo->sttKeyInfo.nextProcKey = pInfo->lastProcKey + step; } @@ -4782,10 +4677,10 @@ int32_t tsdbNextDataBlock2(STsdbReader* pReader, bool* hasNext) { qTrace("tsdb/read: %p, unlock read mutex", pReader); tsdbReleaseReader(pReader); } - return code; } + if (pReader->step == EXTERNAL_ROWS_MAIN && pReader->innerReader[1] != NULL) { // prepare for the next row scan int32_t step = -1; @@ -5007,6 +4902,8 @@ SSDataBlock* tsdbRetrieveDataBlock2(STsdbReader* pReader, SArray* pIdList) { qTrace("tsdb/read-retrieve: %p, unlock read mutex", pReader); tsdbReleaseReader(pReader); +// tsdbReaderSuspend2(pReader); +// tsdbReaderResume2(pReader); return ret; } @@ -5282,7 +5179,7 @@ int64_t tsdbGetNumOfRowsInMemTable2(STsdbReader* pReader) { int32_t tsdbGetTableSchema(SMeta* pMeta, int64_t uid, STSchema** pSchema, int64_t* suid) { SMetaReader mr = {0}; - metaReaderDoInit(&mr, pMeta, 0); + metaReaderDoInit(&mr, pMeta, META_READER_LOCK); int32_t code = metaReaderGetTableEntryByUidCache(&mr, uid); if (code != TSDB_CODE_SUCCESS) { terrno = TSDB_CODE_TDB_INVALID_TABLE_ID; diff --git a/source/dnode/vnode/src/tsdb/tsdbReadUtil.c b/source/dnode/vnode/src/tsdb/tsdbReadUtil.c index fb43e5b713..93bc5ca573 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReadUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbReadUtil.c @@ -130,6 +130,46 @@ STableBlockScanInfo* getTableBlockScanInfo(SSHashObj* pTableMap, uint64_t uid, c return *p; } +static void initLastProcKey(STableBlockScanInfo *pScanInfo, STsdbReader* pReader) { + SRowKey* pRowKey = &pScanInfo->lastProcKey; + if (ASCENDING_TRAVERSE(pReader->info.order)) { + int64_t skey = pReader->info.window.skey; + pRowKey->ts = (skey > INT64_MIN) ? (skey - 1) : skey; + pScanInfo->sttKeyInfo.nextProcKey = skey; + } else { + int64_t ekey = pReader->info.window.ekey; + pRowKey->ts = (ekey < INT64_MAX) ? (ekey + 1) : ekey; + pScanInfo->sttKeyInfo.nextProcKey = ekey; + } + + // only handle the first primary key. + pRowKey->numOfPKs = pReader->suppInfo.numOfPks; + if (pReader->suppInfo.numOfPks > 0) { + if (IS_VAR_DATA_TYPE(pReader->suppInfo.pk.type)) { + pRowKey->pks[0].pData = taosMemoryCalloc(1, pReader->suppInfo.pk.bytes); + } + pRowKey->pks[0].type = pReader->suppInfo.pk.type; + } +} + +int32_t initTableBlockScanInfo(STableBlockScanInfo* pScanInfo, uint64_t uid, SSHashObj* pTableMap, + STsdbReader* pReader) { + pScanInfo->uid = uid; + INIT_TIMEWINDOW(&pScanInfo->sttWindow); + INIT_TIMEWINDOW(&pScanInfo->filesetWindow); + + pScanInfo->cleanSttBlocks = false; + pScanInfo->sttBlockReturned = false; + + initLastProcKey(pScanInfo, pReader); + + pScanInfo->sttKeyInfo.status = STT_FILE_READER_UNINIT; + tSimpleHashPut(pTableMap, &pScanInfo->uid, sizeof(uint64_t), &pScanInfo, POINTER_BYTES); + tsdbTrace("%p check table uid:%" PRId64 " from lastKey:%" PRId64 " %s", pReader, pScanInfo->uid, + pScanInfo->lastProcKey.ts, pReader->idStr); + return TSDB_CODE_SUCCESS; +} + // NOTE: speedup the whole processing by preparing the buffer for STableBlockScanInfo in batch model SSHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf* pBuf, const STableKeyInfo* idList, STableUidList* pUidList, int32_t numOfTables) { @@ -152,36 +192,10 @@ SSHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf* pBuf pUidList->currentIndex = 0; for (int32_t j = 0; j < numOfTables; ++j) { - STableBlockScanInfo* pScanInfo = getPosInBlockInfoBuf(pBuf, j); - - pScanInfo->uid = idList[j].uid; - INIT_TIMEWINDOW(&pScanInfo->sttWindow); - INIT_TIMEWINDOW(&pScanInfo->filesetWindow); - - pScanInfo->cleanSttBlocks = false; - pScanInfo->sttBlockReturned = false; - pUidList->tableUidList[j] = idList[j].uid; - if (ASCENDING_TRAVERSE(pTsdbReader->info.order)) { - int64_t skey = pTsdbReader->info.window.skey; - pScanInfo->lastProcKey.ts = (skey > INT64_MIN) ? (skey - 1) : skey; - pScanInfo->sttKeyInfo.nextProcKey = skey; - } else { - int64_t ekey = pTsdbReader->info.window.ekey; - pScanInfo->lastProcKey.ts = (ekey < INT64_MAX) ? (ekey + 1) : ekey; - pScanInfo->sttKeyInfo.nextProcKey = ekey; - } - - pScanInfo->lastProcKey.numOfPKs = pTsdbReader->suppInfo.numOfPks; - if (pTsdbReader->suppInfo.numOfPks > 0 && IS_VAR_DATA_TYPE(pTsdbReader->suppInfo.pk.type)) { - pScanInfo->lastProcKey.pks[0].pData = taosMemoryCalloc(1, pTsdbReader->suppInfo.pk.bytes); - } - - pScanInfo->sttKeyInfo.status = STT_FILE_READER_UNINIT; - tSimpleHashPut(pTableMap, &pScanInfo->uid, sizeof(uint64_t), &pScanInfo, POINTER_BYTES); - tsdbTrace("%p check table uid:%" PRId64 " from lastKey:%" PRId64 " %s", pTsdbReader, pScanInfo->uid, - pScanInfo->lastProcKey.ts, pTsdbReader->idStr); + STableBlockScanInfo* pScanInfo = getPosInBlockInfoBuf(pBuf, j); + initTableBlockScanInfo(pScanInfo, idList[j].uid, pTableMap, pTsdbReader); } taosSort(pUidList->tableUidList, numOfTables, sizeof(uint64_t), uidComparFunc); @@ -215,8 +229,7 @@ void resetAllDataBlockScanInfo(SSHashObj* pTableMap, int64_t ts, int32_t step) { pInfo->delSkyline = taosArrayDestroy(pInfo->delSkyline); pInfo->lastProcKey.ts = ts; - ASSERT(0); - + // todo check the nextProcKey info pInfo->sttKeyInfo.nextProcKey = ts + step; } } diff --git a/source/dnode/vnode/src/tsdb/tsdbReadUtil.h b/source/dnode/vnode/src/tsdb/tsdbReadUtil.h index 56e6ca9ba7..4131bb1b86 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReadUtil.h +++ b/source/dnode/vnode/src/tsdb/tsdbReadUtil.h @@ -298,8 +298,10 @@ int32_t uidComparFunc(const void* p1, const void* p2); STableBlockScanInfo* getTableBlockScanInfo(SSHashObj* pTableMap, uint64_t uid, const char* id); -SSHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf* pBuf, const STableKeyInfo* idList, +SSHashObj* createDataBlockScanInfo(STsdbReader* pReader, SBlockInfoBuf* pBuf, const STableKeyInfo* idList, STableUidList* pUidList, int32_t numOfTables); +int32_t initTableBlockScanInfo(STableBlockScanInfo* pScanInfo, uint64_t uid, SSHashObj* pTableMap, + STsdbReader* pReader); void clearBlockScanInfo(STableBlockScanInfo* p); void destroyAllBlockScanInfo(SSHashObj* pTableMap); void resetAllDataBlockScanInfo(SSHashObj* pTableMap, int64_t ts, int32_t step); diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index dece1c7b98..d7bc60e1a1 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -584,13 +584,30 @@ struct STsdbSnapWriter { // APIs static int32_t tsdbSnapWriteTimeSeriesRow(STsdbSnapWriter* writer, SRowInfo* row) { - int32_t code = 0; - int32_t lino = 0; + int32_t code = 0; + int32_t lino = 0; + TABLEID tbid = {0}; + SMetaInfo info; while (writer->ctx->hasData) { - SRowInfo* row1 = tsdbIterMergerGetData(writer->ctx->dataIterMerger); - if (row1 == NULL) { - writer->ctx->hasData = false; + SRowInfo* row1; + for (;;) { + row1 = tsdbIterMergerGetData(writer->ctx->dataIterMerger); + if (row1 == NULL) { + writer->ctx->hasData = false; + } else if (row1->uid != tbid.uid) { + tbid.suid = row1->suid; + tbid.uid = row1->uid; + if (metaGetInfo(writer->tsdb->pVnode->pMeta, tbid.uid, &info, NULL) != 0) { + code = tsdbIterMergerSkipTableData(writer->ctx->dataIterMerger, &tbid); + TSDB_CHECK_CODE(code, lino, _exit); + continue; + } + } + break; + } + + if (writer->ctx->hasData == false) { break; } diff --git a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c index c8b2cf3adf..69ec30fe40 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c +++ b/source/dnode/vnode/src/tsdb/tsdbSttFileRW.c @@ -556,7 +556,7 @@ static int32_t tsdbSttFileDoWriteStatisBlock(SSttFileWriter *writer) { SValueColumnCompressInfo compressInfo = {.cmprAlg = statisBlk.cmprAlg}; tBufferClear(buffer0); - tBufferClear(buffer0); + tBufferClear(buffer1); for (int32_t i = 0; i < statisBlk.numOfPKs; i++) { code = tValueColumnCompress(&statisBlock->firstKeyPKs[i], &compressInfo, buffer1, assist); diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c index 550bedf173..fe7a3457bd 100644 --- a/source/dnode/vnode/src/tsdb/tsdbUtil.c +++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c @@ -629,18 +629,20 @@ void tColRowGetKey(SBlockData* pBlock, int32_t irow, SRowKey* key) { } int32_t tRowKeyAssign(SRowKey *pDst, SRowKey* pSrc) { - if (pSrc->numOfPKs == 0) { - pDst->ts = pSrc->ts; - pDst->numOfPKs = 0; - } else { - *pDst = *pSrc; + pDst->ts = pSrc->ts; + pDst->numOfPKs = pSrc->numOfPKs; + if (pSrc->numOfPKs > 0) { for (int32_t i = 0; i < pDst->numOfPKs; ++i) { SValue *pVal = &pDst->pks[i]; + pVal->type = pSrc->pks[i].type; + if (IS_NUMERIC_TYPE(pVal->type)) { - continue; + pVal->val = pSrc->pks[i].val; + } else { + memcpy(pVal->pData, pVal->pData, pVal->nData); + pVal->nData = pSrc->pks[i].nData; } - memcpy(pVal->pData, pVal->pData, pVal->nData); } } diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c index 63ca7251f5..daee8966f9 100644 --- a/source/dnode/vnode/src/vnd/vnodeOpen.c +++ b/source/dnode/vnode/src/vnd/vnodeOpen.c @@ -493,7 +493,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC VNODE_METRIC_TAG_NAME_DNODE_ID, VNODE_METRIC_TAG_NAME_DNODE_EP, VNODE_METRIC_TAG_NAME_VGROUP_ID, VNODE_METRIC_TAG_NAME_USERNAME, VNODE_METRIC_TAG_NAME_RESULT}; - counter = taos_counter_new(VNODE_METRIC_SQL_COUNT, "counter for insert sql", + counter = taos_counter_new(VNODE_METRIC_SQL_COUNT, "counter for insert sql", label_count, sample_labels); vInfo("vgId:%d, new metric:%p",TD_VID(pVnode), counter); if(taos_collector_registry_register_metric(counter) == 1){ @@ -503,7 +503,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC } } pVnode->monitor.insertCounter = counter; - vInfo("vgId:%d, succeed to set metric:%p",TD_VID(pVnode), counter); + vInfo("vgId:%d, succeed to set metric:%p",TD_VID(pVnode), counter); } return pVnode; @@ -560,6 +560,9 @@ int32_t vnodeIsCatchUp(SVnode *pVnode) { return syncIsCatchUp(pVnode->sync); } ESyncRole vnodeGetRole(SVnode *pVnode) { return syncGetRole(pVnode->sync); } +int32_t vnodeUpdateArbTerm(SVnode *pVnode, int64_t arbTerm) { return syncUpdateArbTerm(pVnode->sync, arbTerm); } +int32_t vnodeGetArbToken(SVnode *pVnode, char *outToken) { return syncGetArbToken(pVnode->sync, outToken); } + void vnodeStop(SVnode *pVnode) {} int64_t vnodeGetSyncHandle(SVnode *pVnode) { return pVnode->sync; } diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index d1c811858a..a85192546f 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -63,7 +63,7 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) { } // query meta - metaReaderDoInit(&mer1, pVnode->pMeta, 0); + metaReaderDoInit(&mer1, pVnode->pMeta, META_READER_LOCK); if (metaGetTableEntryByName(&mer1, infoReq.tbName) < 0) { code = terrno; @@ -179,7 +179,7 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) { } // query meta - metaReaderDoInit(&mer1, pVnode->pMeta, 0); + metaReaderDoInit(&mer1, pVnode->pMeta, META_READER_LOCK); if (metaGetTableEntryByName(&mer1, cfgReq.tbName) < 0) { code = terrno; @@ -192,7 +192,7 @@ int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) { code = TSDB_CODE_VND_HASH_MISMATCH; goto _exit; } else if (mer1.me.type == TSDB_CHILD_TABLE) { - metaReaderDoInit(&mer2, pVnode->pMeta, 0); + metaReaderDoInit(&mer2, pVnode->pMeta, META_READER_LOCK); if (metaReaderGetTableEntryByUid(&mer2, mer1.me.ctbEntry.suid) < 0) goto _exit; strcpy(cfgRsp.stbName, mer2.me.name); @@ -406,7 +406,7 @@ int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { int32_t vnodeGetLoadLite(SVnode *pVnode, SVnodeLoadLite *pLoad) { SSyncState syncState = syncGetState(pVnode->sync); - if (syncState.state == TAOS_SYNC_STATE_LEADER) { + if (syncState.state == TAOS_SYNC_STATE_LEADER || syncState.state == TAOS_SYNC_STATE_ASSIGNED_LEADER) { pLoad->vgId = TD_VID(pVnode); pLoad->nTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta, 1); return 0; diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index e32d4b70e0..a03adb164b 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -31,20 +31,24 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, static int32_t vnodeProcessAlterTbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp, SRpcMsg *pOriginRpc); -static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp, +static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp, SRpcMsg *pOriginalMsg); static int32_t vnodeProcessCreateTSmaReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); static int32_t vnodeProcessAlterConfirmReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); static int32_t vnodeProcessDropTtlTbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); static int32_t vnodeProcessTrimReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); -static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp, +static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp, SRpcMsg *pOriginalMsg); static int32_t vnodeProcessBatchDeleteReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); static int32_t vnodeProcessCreateIndexReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); static int32_t vnodeProcessDropIndexReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); static int32_t vnodeProcessCompactVnodeReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); static int32_t vnodeProcessConfigChangeReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); +static int32_t vnodeProcessArbCheckSyncReq(SVnode *pVnode, void *pReq, int32_t len, SRpcMsg *pRsp); + +static int32_t vnodePreCheckAssignedLogSyncd(SVnode *pVnode, char *member0Token, char *member1Token); +static int32_t vnodeCheckAssignedLogSyncd(SVnode *pVnode, char *member0Token, char *member1Token); extern int32_t vnodeProcessKillCompactReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); extern int32_t vnodeQueryCompactProgress(SVnode *pVnode, SRpcMsg *pMsg); @@ -451,6 +455,21 @@ static int32_t vnodePreProcessBatchDeleteMsg(SVnode *pVnode, SRpcMsg *pMsg) { return code; } +static int32_t vnodePreProcessArbCheckSyncMsg(SVnode *pVnode, SRpcMsg *pMsg) { + SVArbCheckSyncReq syncReq = {0}; + + if (tDeserializeSVArbCheckSyncReq((char *)pMsg->pCont + sizeof(SMsgHead), pMsg->contLen - sizeof(SMsgHead), + &syncReq) != 0) { + return TSDB_CODE_INVALID_MSG; + } + + (void)vnodePreCheckAssignedLogSyncd(pVnode, syncReq.member0Token, syncReq.member1Token); + int32_t code = terrno; + tFreeSVArbCheckSyncReq(&syncReq); + + return code; +} + int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) { int32_t code = 0; @@ -473,6 +492,9 @@ int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) { case TDMT_VND_BATCH_DEL: { code = vnodePreProcessBatchDeleteMsg(pVnode, pMsg); } break; + case TDMT_VND_ARB_CHECK_SYNC: { + code = vnodePreProcessArbCheckSyncMsg(pVnode, pMsg); + } break; default: break; } @@ -643,6 +665,10 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg vnodeProcessKillCompactReq(pVnode, ver, pReq, len, pRsp); break; #endif + /* ARB */ + case TDMT_VND_ARB_CHECK_SYNC: + vnodeProcessArbCheckSyncReq(pVnode, pReq, len, pRsp); + break; default: vError("vgId:%d, unprocessed msg, %d", TD_VID(pVnode), pMsg->msgType); return -1; @@ -1489,7 +1515,7 @@ static int32_t vnodeRebuildSubmitReqMsg(SSubmitReq2 *pSubmitReq, void **ppMsg) { return code; } -static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp, +static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp, SRpcMsg *pOriginalMsg) { int32_t code = 0; terrno = 0; @@ -1710,8 +1736,8 @@ _exit: atomic_add_fetch_64(&pVnode->statis.nBatchInsert, 1); if(tsEnableMonitor && pSubmitRsp->affectedRows > 0 && strlen(pOriginalMsg->info.conn.user) > 0){ - const char *sample_labels[] = {VNODE_METRIC_TAG_VALUE_INSERT_AFFECTED_ROWS, pVnode->monitor.strClusterId, - pVnode->monitor.strDnodeId, tsLocalEp, pVnode->monitor.strVgId, + const char *sample_labels[] = {VNODE_METRIC_TAG_VALUE_INSERT_AFFECTED_ROWS, pVnode->monitor.strClusterId, + pVnode->monitor.strDnodeId, tsLocalEp, pVnode->monitor.strVgId, pOriginalMsg->info.conn.user, "Success"}; taos_counter_add(pVnode->monitor.insertCounter, pSubmitRsp->affectedRows, sample_labels); } @@ -1725,14 +1751,14 @@ _exit: atomic_add_fetch_64(&pVnode->statis.nBatchInsertSuccess, 1); code = tdProcessRSmaSubmit(pVnode->pSma, ver, pSubmitReq, pReq, len); - const char *batch_sample_labels[] = {VNODE_METRIC_TAG_VALUE_INSERT, pVnode->monitor.strClusterId, - pVnode->monitor.strDnodeId, tsLocalEp, pVnode->monitor.strVgId, + const char *batch_sample_labels[] = {VNODE_METRIC_TAG_VALUE_INSERT, pVnode->monitor.strClusterId, + pVnode->monitor.strDnodeId, tsLocalEp, pVnode->monitor.strVgId, pOriginalMsg->info.conn.user, "Success"}; taos_counter_inc(pVnode->monitor.insertCounter, batch_sample_labels); } else{ - const char *batch_sample_labels[] = {VNODE_METRIC_TAG_VALUE_INSERT, pVnode->monitor.strClusterId, - pVnode->monitor.strDnodeId, tsLocalEp, pVnode->monitor.strVgId, + const char *batch_sample_labels[] = {VNODE_METRIC_TAG_VALUE_INSERT, pVnode->monitor.strClusterId, + pVnode->monitor.strDnodeId, tsLocalEp, pVnode->monitor.strVgId, pOriginalMsg->info.conn.user, "Failed"}; taos_counter_inc(pVnode->monitor.insertCounter, batch_sample_labels); } @@ -1992,7 +2018,7 @@ static int32_t vnodeProcessBatchDeleteReq(SVnode *pVnode, int64_t ver, void *pRe return 0; } -static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp, +static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp, SRpcMsg *pOriginalMsg) { int32_t code = 0; SDecoder *pCoder = &(SDecoder){0}; @@ -2038,14 +2064,14 @@ static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t ver, void *pReq, in _err: /* if(code == TSDB_CODE_SUCCESS){ - const char *batch_sample_labels[] = {VNODE_METRIC_TAG_VALUE_DELETE, pVnode->monitor.strClusterId, - pVnode->monitor.strDnodeId, tsLocalEp, pVnode->monitor.strVgId, + const char *batch_sample_labels[] = {VNODE_METRIC_TAG_VALUE_DELETE, pVnode->monitor.strClusterId, + pVnode->monitor.strDnodeId, tsLocalEp, pVnode->monitor.strVgId, pOriginalMsg->info.conn.user, "Success"}; taos_counter_inc(pVnode->monitor.insertCounter, batch_sample_labels); } else{ - const char *batch_sample_labels[] = {VNODE_METRIC_TAG_VALUE_DELETE, pVnode->monitor.strClusterId, - pVnode->monitor.strDnodeId, tsLocalEp, pVnode->monitor.strVgId, + const char *batch_sample_labels[] = {VNODE_METRIC_TAG_VALUE_DELETE, pVnode->monitor.strClusterId, + pVnode->monitor.strDnodeId, tsLocalEp, pVnode->monitor.strVgId, pOriginalMsg->info.conn.user, "Failed"}; taos_counter_inc(pVnode->monitor.insertCounter, batch_sample_labels); } @@ -2119,6 +2145,98 @@ static int32_t vnodeProcessConfigChangeReq(SVnode *pVnode, int64_t ver, void *pR return 0; } +static int32_t vnodePreCheckAssignedLogSyncd(SVnode *pVnode, char *member0Token, char *member1Token) { + SSyncState syncState = syncGetState(pVnode->sync); + if (syncState.state != TAOS_SYNC_STATE_LEADER) { + terrno = TSDB_CODE_SYN_NOT_LEADER; + return -1; + } + + char token[TSDB_ARB_TOKEN_SIZE] = {0}; + if (vnodeGetArbToken(pVnode, token) != 0) { + terrno = TSDB_CODE_NOT_FOUND; + return -1; + } + + if (strncmp(token, member0Token, TSDB_ARB_TOKEN_SIZE) != 0 && + strncmp(token, member1Token, TSDB_ARB_TOKEN_SIZE) != 0) { + terrno = TSDB_CODE_MND_ARB_TOKEN_MISMATCH; + return -1; + } + + terrno = TSDB_CODE_SUCCESS; + return 0; +} + +static int32_t vnodeCheckAssignedLogSyncd(SVnode *pVnode, char *member0Token, char *member1Token) { + int32_t code = vnodePreCheckAssignedLogSyncd(pVnode, member0Token, member1Token); + if (code != 0) { + return code; + } + + return syncGetAssignedLogSynced(pVnode->sync); +} + +static int32_t vnodeProcessArbCheckSyncReq(SVnode *pVnode, void *pReq, int32_t len, SRpcMsg *pRsp) { + int32_t code = 0; + + SVArbCheckSyncReq syncReq = {0}; + + if (tDeserializeSVArbCheckSyncReq(pReq, len, &syncReq) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + pRsp->msgType = TDMT_VND_ARB_CHECK_SYNC_RSP; + pRsp->code = TSDB_CODE_SUCCESS; + pRsp->pCont = NULL; + pRsp->contLen = 0; + + SVArbCheckSyncRsp syncRsp = {0}; + syncRsp.arbToken = syncReq.arbToken; + syncRsp.member0Token = syncReq.member0Token; + syncRsp.member1Token = syncReq.member1Token; + syncRsp.vgId = TD_VID(pVnode); + + (void)vnodeCheckAssignedLogSyncd(pVnode, syncReq.member0Token, syncReq.member1Token); + syncRsp.errCode = terrno; + + if (vnodeUpdateArbTerm(pVnode, syncReq.arbTerm) != 0) { + vError("vgId:%d, failed to update arb term", TD_VID(pVnode)); + code = -1; + goto _OVER; + } + + int32_t contLen = tSerializeSVArbCheckSyncRsp(NULL, 0, &syncRsp); + if (contLen <= 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + code = -1; + goto _OVER; + } + void *pHead = rpcMallocCont(contLen); + if (!pHead) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + code = -1; + goto _OVER; + } + + if (tSerializeSVArbCheckSyncRsp(pHead, contLen, &syncRsp) <= 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + rpcFreeCont(pHead); + code = -1; + goto _OVER; + } + + pRsp->pCont = pHead; + pRsp->contLen = contLen; + + terrno = TSDB_CODE_SUCCESS; + +_OVER: + tFreeSVArbCheckSyncReq(&syncReq); + return code; +} + #ifndef TD_ENTERPRISE int32_t vnodeProcessCompactVnodeReqImpl(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp) { return 0; diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index f9f2ae6b21..63494a17b9 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -638,6 +638,14 @@ static void vnodeBecomeLeader(const SSyncFSM *pFsm) { } } +static void vnodeBecomeAssignedLeader(const SSyncFSM* pFsm) { + SVnode *pVnode = pFsm->data; + vDebug("vgId:%d, become assigned leader", pVnode->config.vgId); + if (pVnode->pTq) { + tqUpdateNodeStage(pVnode->pTq, true); + } +} + static bool vnodeApplyQueueEmpty(const SSyncFSM *pFsm) { SVnode *pVnode = pFsm->data; @@ -674,6 +682,7 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) { pFsm->FpApplyQueueEmptyCb = vnodeApplyQueueEmpty; pFsm->FpApplyQueueItems = vnodeApplyQueueItems; pFsm->FpBecomeLeaderCb = vnodeBecomeLeader; + pFsm->FpBecomeAssignedLeaderCb = vnodeBecomeAssignedLeader; pFsm->FpBecomeFollowerCb = vnodeBecomeFollower; pFsm->FpBecomeLearnerCb = vnodeBecomeLearner; pFsm->FpReConfigCb = NULL; diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index 2136ef7d6d..dc8fa49e27 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -501,8 +501,12 @@ void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) { } else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) { sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)); } - char* pk = (pSchema->flags & COL_IS_KEY) ? "PRIMARY KEY" : ""; - *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s %s", ((i > 0) ? ", " : ""), pSchema->name, type, pk); + if (!(pSchema->flags & COL_IS_KEY)) { + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s", ((i > 0) ? ", " : ""), pSchema->name, type); + } else { + char* pk = "PRIMARY KEY"; + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s %s", ((i > 0) ? ", " : ""), pSchema->name, type, pk); + } } } diff --git a/source/libs/executor/CMakeLists.txt b/source/libs/executor/CMakeLists.txt index d2c39aba74..838233346e 100644 --- a/source/libs/executor/CMakeLists.txt +++ b/source/libs/executor/CMakeLists.txt @@ -3,7 +3,7 @@ aux_source_directory(src EXECUTOR_SRC) add_library(executor STATIC ${EXECUTOR_SRC}) target_link_libraries(executor - PRIVATE os util common function parser planner qcom scalar nodes index wal tdb + PRIVATE os util common function parser planner qcom scalar nodes index wal tdb geometry ) target_include_directories( diff --git a/source/libs/executor/inc/executorInt.h b/source/libs/executor/inc/executorInt.h index 5e3469b8db..c896869a24 100644 --- a/source/libs/executor/inc/executorInt.h +++ b/source/libs/executor/inc/executorInt.h @@ -302,11 +302,13 @@ typedef struct STmsSubTableInput { int32_t rowIdx; int64_t* aTs; + SSDataBlock* pInputBlock; } STmsSubTableInput; typedef struct SBlockOrderInfo SBlockOrderInfo; typedef struct STmsSubTablesMergeInfo { - SBlockOrderInfo* pOrderInfo; + SBlockOrderInfo* pTsOrderInfo; + SBlockOrderInfo* pPkOrderInfo; int32_t numSubTables; STmsSubTableInput* aInputs; @@ -602,6 +604,8 @@ typedef struct SStreamIntervalOperatorInfo { bool recvPullover; SSDataBlock* pMidPulloverRes; bool clearState; + SArray* pMidPullDatas; + int32_t midDelIndex; SSHashObj* pDeletedMap; bool destHasPrimaryKey; } SStreamIntervalOperatorInfo; diff --git a/source/libs/executor/inc/tsort.h b/source/libs/executor/inc/tsort.h index ca799673ea..b9118cf00d 100644 --- a/source/libs/executor/inc/tsort.h +++ b/source/libs/executor/inc/tsort.h @@ -56,10 +56,11 @@ typedef struct SMsortComparParam { bool cmpGroupId; int32_t sortType; - // the following field to speed up when sortType == SORT_BLOCK_TS_MERGE + // the following fields to speed up sorting when sortType == SORT_BLOCK_TS_MERGE int32_t tsSlotId; - int32_t order; - __compar_fn_t cmpFn; + int32_t tsOrder; + __compar_fn_t cmpTsFn; + void* pPkOrder; // SBlockOrderInfo* } SMsortComparParam; typedef struct SSortHandle SSortHandle; @@ -211,6 +212,9 @@ int32_t tsortCompAndBuildKeys(const SArray* pSortCols, char* keyBuf, int32_t* ke * @brief set the merge limit reached callback. it calls mergeLimitReached param with tableUid and param */ void tsortSetMergeLimitReachedFp(SSortHandle* pHandle, void (*mergeLimitReached)(uint64_t tableUid, void* param), void* param); + +int tsortComparBlockCell(SSDataBlock* pLeftBlock, SSDataBlock* pRightBlock, + int32_t leftRowIndex, int32_t rightRowIndex, void* pOrder); #ifdef __cplusplus } #endif diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index beaa0684ad..97b9b00efb 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -308,7 +308,7 @@ int32_t isQualifiedTable(STableKeyInfo* info, SNode* pTagCond, void* metaHandle, int32_t code = TSDB_CODE_SUCCESS; SMetaReader mr = {0}; - pAPI->metaReaderFn.initReader(&mr, metaHandle, 0, &pAPI->metaFn); + pAPI->metaReaderFn.initReader(&mr, metaHandle, META_READER_LOCK, &pAPI->metaFn); code = pAPI->metaReaderFn.getEntryGetUidCache(&mr, info->uid); if (TSDB_CODE_SUCCESS != code) { pAPI->metaReaderFn.clearReader(&mr); @@ -1226,7 +1226,7 @@ int32_t getGroupIdFromTagsVal(void* pVnode, uint64_t uid, SNodeList* pGroupNode, SStorageAPI* pAPI) { SMetaReader mr = {0}; - pAPI->metaReaderFn.initReader(&mr, pVnode, 0, &pAPI->metaFn); + pAPI->metaReaderFn.initReader(&mr, pVnode, META_READER_LOCK, &pAPI->metaFn); if (pAPI->metaReaderFn.getEntryGetUidCache(&mr, uid) != 0) { // table not exist pAPI->metaReaderFn.clearReader(&mr); return TSDB_CODE_PAR_TABLE_NOT_EXIST; @@ -1341,6 +1341,7 @@ int32_t extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod c.srcSlotId = pColNode->slotId; c.dstSlotId = pNode->slotId; c.isPk = pColNode->isPk; + c.dataType = pColNode->node.resType; taosArrayPush(pList, &c); } } diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 831fd4e883..26a80cc6b5 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -351,7 +351,7 @@ static SArray* filterUnqualifiedTables(const SStreamScanInfo* pScanInfo, const S // let's discard the tables those are not created according to the queried super table. SMetaReader mr = {0}; - pAPI->metaReaderFn.initReader(&mr, pScanInfo->readHandle.vnode, 0, &pAPI->metaFn); + pAPI->metaReaderFn.initReader(&mr, pScanInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn); for (int32_t i = 0; i < numOfUids; ++i) { uint64_t* id = (uint64_t*)taosArrayGet(tableIdList, i); diff --git a/source/libs/executor/src/querytask.c b/source/libs/executor/src/querytask.c index 9eb1c8d653..0fff5fa649 100644 --- a/source/libs/executor/src/querytask.c +++ b/source/libs/executor/src/querytask.c @@ -127,7 +127,7 @@ int32_t initQueriedTableSchemaInfo(SReadHandle* pHandle, SScanPhysiNode* pScanNo SStorageAPI* pAPI = &pTaskInfo->storageAPI; - pAPI->metaReaderFn.initReader(&mr, pHandle->vnode, 0, &pAPI->metaFn); + pAPI->metaReaderFn.initReader(&mr, pHandle->vnode, META_READER_LOCK, &pAPI->metaFn); int32_t code = pAPI->metaReaderFn.getEntryGetUidCache(&mr, pScanNode->uid); if (code != TSDB_CODE_SUCCESS) { qError("failed to get the table meta, uid:0x%" PRIx64 ", suid:0x%" PRIx64 ", %s", pScanNode->uid, pScanNode->suid, diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index dbb0761046..1e5fa065de 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -505,7 +505,7 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int // 1. check if it is existed in meta cache if (pCache == NULL) { - pHandle->api.metaReaderFn.initReader(&mr, pHandle->vnode, 0, &pHandle->api.metaFn); + pHandle->api.metaReaderFn.initReader(&mr, pHandle->vnode, META_READER_LOCK, &pHandle->api.metaFn); code = pHandle->api.metaReaderFn.getEntryGetUidCache(&mr, pBlock->info.id.uid); if (code != TSDB_CODE_SUCCESS) { // when encounter the TSDB_CODE_PAR_TABLE_NOT_EXIST error, we proceed. @@ -534,7 +534,7 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int h = taosLRUCacheLookup(pCache->pTableMetaEntryCache, &pBlock->info.id.uid, sizeof(pBlock->info.id.uid)); if (h == NULL) { - pHandle->api.metaReaderFn.initReader(&mr, pHandle->vnode, 0, &pHandle->api.metaFn); + pHandle->api.metaReaderFn.initReader(&mr, pHandle->vnode, META_READER_LOCK, &pHandle->api.metaFn); code = pHandle->api.metaReaderFn.getEntryGetUidCache(&mr, pBlock->info.id.uid); if (code != TSDB_CODE_SUCCESS) { if (terrno == TSDB_CODE_PAR_TABLE_NOT_EXIST) { @@ -1198,16 +1198,17 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, pInfo->pResBlock = createDataBlockFromDescNode(pDescNode); { // todo :refactor: + SDataBlockInfo* pBlockInfo = &pInfo->pResBlock->info; for(int32_t i = 0; i < taosArrayGetSize(pInfo->base.matchInfo.pList); ++i) { SColMatchItem* pItem = taosArrayGet(pInfo->base.matchInfo.pList, i); if (pItem->isPk) { SColumnInfoData* pInfoData = taosArrayGet(pInfo->pResBlock->pDataBlock, pItem->dstSlotId); - pInfo->pResBlock->info.pks[0].type = pInfoData->info.type; - pInfo->pResBlock->info.pks[1].type = pInfoData->info.type; + pBlockInfo->pks[0].type = pInfoData->info.type; + pBlockInfo->pks[1].type = pInfoData->info.type; if (IS_VAR_DATA_TYPE(pItem->dataType.type)) { - pInfo->pResBlock->info.pks[0].pData = taosMemoryCalloc(1, pInfoData->info.bytes); - pInfo->pResBlock->info.pks[1].pData = taosMemoryCalloc(1, pInfoData->info.bytes); + pBlockInfo->pks[0].pData = taosMemoryCalloc(1, pInfoData->info.bytes); + pBlockInfo->pks[1].pData = taosMemoryCalloc(1, pInfoData->info.bytes); } } } @@ -2099,6 +2100,8 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { blockDataCleanup(pInfo->pRes); STimeWindow defaultWindow = {.skey = INT64_MIN, .ekey = INT64_MAX}; setBlockIntoRes(pInfo, pRes, &defaultWindow, true); + qDebug("doQueueScan after filter get data from log %" PRId64 " rows, version:%" PRId64, pInfo->pRes->info.rows, + pTaskInfo->streamInfo.currentOffset.version); if (pInfo->pRes->info.rows > 0) { return pInfo->pRes; } @@ -3333,7 +3336,7 @@ static SSDataBlock* doTagScanFromMetaEntry(SOperatorInfo* pOperator) { char str[512] = {0}; int32_t count = 0; SMetaReader mr = {0}; - pAPI->metaReaderFn.initReader(&mr, pInfo->readHandle.vnode, 0, &pAPI->metaFn); + pAPI->metaReaderFn.initReader(&mr, pInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn); while (pInfo->curPos < size && count < pOperator->resultInfo.capacity) { doTagScanOneTable(pOperator, pRes, count, &mr, &pTaskInfo->storageAPI); @@ -3439,9 +3442,7 @@ _error: // table merge scan operator -// table merge scan operator - -static int32_t subTblRowCompareFn(const void* pLeft, const void* pRight, void* param) { +static int32_t subTblRowCompareTsFn(const void* pLeft, const void* pRight, void* param) { int32_t left = *(int32_t*)pLeft; int32_t right = *(int32_t*)pRight; STmsSubTablesMergeInfo* pInfo = (STmsSubTablesMergeInfo*)param; @@ -3458,12 +3459,39 @@ static int32_t subTblRowCompareFn(const void* pLeft, const void* pRight, void* p int64_t leftTs = pInfo->aInputs[left].aTs[leftIdx]; int64_t rightTs = pInfo->aInputs[right].aTs[rightIdx]; int32_t ret = leftTs>rightTs ? 1 : ((leftTs < rightTs) ? -1 : 0); - if (pInfo->pOrderInfo->order == TSDB_ORDER_DESC) { + if (pInfo->pTsOrderInfo->order == TSDB_ORDER_DESC) { ret = -1 * ret; } return ret; } +static int32_t subTblRowCompareTsPkFn(const void* pLeft, const void* pRight, void* param) { + int32_t left = *(int32_t*)pLeft; + int32_t right = *(int32_t*)pRight; + STmsSubTablesMergeInfo* pInfo = (STmsSubTablesMergeInfo*)param; + + int32_t leftIdx = pInfo->aInputs[left].rowIdx; + int32_t rightIdx = pInfo->aInputs[right].rowIdx; + + if (leftIdx == -1) { + return 1; + } else if (rightIdx == -1) { + return -1; + } + + int64_t leftTs = pInfo->aInputs[left].aTs[leftIdx]; + int64_t rightTs = pInfo->aInputs[right].aTs[rightIdx]; + int32_t ret = leftTs>rightTs ? 1 : ((leftTs < rightTs) ? -1 : 0); + if (pInfo->pTsOrderInfo->order == TSDB_ORDER_DESC) { + ret = -1 * ret; + } + if (ret == 0 && pInfo->pPkOrderInfo) { + ret = tsortComparBlockCell(pInfo->aInputs[left].pInputBlock, pInfo->aInputs[right].pInputBlock, + leftIdx, rightIdx, pInfo->pPkOrderInfo); + } + return ret; +} + int32_t dumpQueryTableCond(const SQueryTableDataCond* src, SQueryTableDataCond* dst) { memcpy((void*)dst, (void*)src, sizeof(SQueryTableDataCond)); dst->colList = taosMemoryCalloc(src->numOfCols, sizeof(SColumnInfo)); @@ -3572,11 +3600,12 @@ static int32_t openSubTablesMergeSort(STmsSubTablesMergeInfo* pSubTblsInfo) { pInput->rowIdx = 0; pInput->pageIdx = -1; } - SSDataBlock* pInputBlock = (pInput->type == SUB_TABLE_MEM_BLOCK) ? pInput->pReaderBlock : pInput->pPageBlock; - SColumnInfoData* col = taosArrayGet(pInputBlock->pDataBlock, pSubTblsInfo->pOrderInfo->slotId); + pInput->pInputBlock = (pInput->type == SUB_TABLE_MEM_BLOCK) ? pInput->pReaderBlock : pInput->pPageBlock; + SColumnInfoData* col = taosArrayGet(pInput->pInputBlock->pDataBlock, pSubTblsInfo->pTsOrderInfo->slotId); pInput->aTs = (int64_t*)col->pData; } - tMergeTreeCreate(&pSubTblsInfo->pTree, pSubTblsInfo->numSubTables, pSubTblsInfo, subTblRowCompareFn); + __merge_compare_fn_t mergeCompareFn = (!pSubTblsInfo->pPkOrderInfo) ? subTblRowCompareTsFn : subTblRowCompareTsPkFn; + tMergeTreeCreate(&pSubTblsInfo->pTree, pSubTblsInfo->numSubTables, pSubTblsInfo, mergeCompareFn); return TSDB_CODE_SUCCESS; } @@ -3586,7 +3615,12 @@ static int32_t initSubTablesMergeInfo(STableMergeScanInfo* pInfo) { if (pSubTblsInfo == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } - pSubTblsInfo->pOrderInfo = taosArrayGet(pInfo->pSortInfo, 0); + pSubTblsInfo->pTsOrderInfo = taosArrayGet(pInfo->pSortInfo, 0); + if (taosArrayGetSize(pInfo->pSortInfo) == 2) { + pSubTblsInfo->pPkOrderInfo = taosArrayGet(pInfo->pSortInfo, 1); + } else { + pSubTblsInfo->pPkOrderInfo = NULL; + } pSubTblsInfo->numSubTables = pInfo->tableEndIndex - pInfo->tableStartIndex + 1; pSubTblsInfo->aInputs = taosMemoryCalloc(pSubTblsInfo->numSubTables, sizeof(STmsSubTableInput)); if (pSubTblsInfo->aInputs == NULL) { @@ -3678,7 +3712,8 @@ static int32_t adjustSubTableForNextRow(SOperatorInfo* pOperatorInfo, STmsSubTab adjustSubTableFromMemBlock(pOperatorInfo, pSubTblsInfo); } if (pInput->rowIdx != -1) { - SColumnInfoData* col = taosArrayGet(pInputBlock->pDataBlock, pSubTblsInfo->pOrderInfo->slotId); + SColumnInfoData* col = taosArrayGet(pInputBlock->pDataBlock, pSubTblsInfo->pTsOrderInfo->slotId); + pInput->pInputBlock = pInputBlock; pInput->aTs = (int64_t*)col->pData; } } @@ -3984,34 +4019,37 @@ static SSDataBlock* getBlockForTableMergeScan(void* param) { SArray* generateSortByTsPkInfo(SArray* colMatchInfo, int32_t order) { + SArray* pSortInfo = taosArrayInit(1, sizeof(SBlockOrderInfo)); + SBlockOrderInfo biTs = {0}; + SBlockOrderInfo biPk = {0}; + int32_t tsTargetSlotId = 0; int32_t pkTargetSlotId = -1; for (int32_t i = 0; i < taosArrayGetSize(colMatchInfo); ++i) { SColMatchItem* colInfo = taosArrayGet(colMatchInfo, i); if (colInfo->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { tsTargetSlotId = colInfo->dstSlotId; + biTs.order = order; + biTs.slotId = tsTargetSlotId; + biTs.nullFirst = (order == TSDB_ORDER_ASC); + biTs.compFn = getKeyComparFunc(TSDB_DATA_TYPE_TIMESTAMP, order); } + //TODO: order by just ts if (colInfo->isPk) { pkTargetSlotId = colInfo->dstSlotId; + biPk.order = order; + biPk.slotId = pkTargetSlotId; + biPk.nullFirst = (order == TSDB_ORDER_ASC); + biPk.compFn = getKeyComparFunc(colInfo->dataType.type, order); } } - SArray* pList = taosArrayInit(1, sizeof(SBlockOrderInfo)); - SBlockOrderInfo biTs = {0}; - biTs.order = order; - biTs.slotId = tsTargetSlotId; - biTs.nullFirst = NULL_ORDER_FIRST; - taosArrayPush(pList, &biTs); - + taosArrayPush(pSortInfo, &biTs); if (pkTargetSlotId != -1) { - SBlockOrderInfo biPk = {0}; - biPk.order = order; - biPk.slotId = pkTargetSlotId; - biPk.nullFirst = NULL_ORDER_FIRST; - taosArrayPush(pList, &biPk); + taosArrayPush(pSortInfo, &biPk); } - return pList; + return pSortInfo; } void tableMergeScanTsdbNotifyCb(ETsdReaderNotifyType type, STsdReaderNotifyInfo* info, void* param) { diff --git a/source/libs/executor/src/streameventwindowoperator.c b/source/libs/executor/src/streameventwindowoperator.c index 1f5cb6be18..6db5a60ed4 100644 --- a/source/libs/executor/src/streameventwindowoperator.c +++ b/source/libs/executor/src/streameventwindowoperator.c @@ -104,6 +104,10 @@ int32_t getEndCondIndex(bool* pEnd, int32_t start, int32_t rows) { static bool isWindowIncomplete(SEventWindowInfo* pWinInfo) { return !(pWinInfo->pWinFlag->startFlag && pWinInfo->pWinFlag->endFlag); } +int32_t reuseOutputBuf(void* pState, SRowBuffPos* pPos, SStateStore* pAPI) { + pAPI->streamStateReleaseBuf(pState, pPos, true); + return TSDB_CODE_SUCCESS; +} void setEventOutputBuf(SStreamAggSupporter* pAggSup, TSKEY* pTs, uint64_t groupId, bool* pStart, bool* pEnd, int32_t index, int32_t rows, SEventWindowInfo* pCurWin, SSessionKey* pNextWinKey) { @@ -150,6 +154,7 @@ void setEventOutputBuf(SStreamAggSupporter* pAggSup, TSKEY* pTs, uint64_t groupI pCurWin->winInfo.isOutput = false; _end: + reuseOutputBuf(pAggSup->pState, pCurWin->winInfo.pStatePos, &pAggSup->stateStore); pAggSup->stateStore.streamStateCurNext(pAggSup->pState, pCur); pNextWinKey->groupId = groupId; code = pAggSup->stateStore.streamStateSessionGetKVByCur(pCur, pNextWinKey, NULL, 0); @@ -347,6 +352,7 @@ static void doStreamEventAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl } if (isWindowIncomplete(&curWin)) { + releaseOutputBuf(pAggSup->pState, curWin.winInfo.pStatePos, &pAggSup->stateStore); continue; } diff --git a/source/libs/executor/src/streamtimewindowoperator.c b/source/libs/executor/src/streamtimewindowoperator.c index 07e81ed334..075a58e932 100644 --- a/source/libs/executor/src/streamtimewindowoperator.c +++ b/source/libs/executor/src/streamtimewindowoperator.c @@ -227,7 +227,7 @@ static bool doDeleteWindow(SOperatorInfo* pOperator, TSKEY ts, uint64_t groupId) static int32_t getChildIndex(SSDataBlock* pBlock) { return pBlock->info.childId; } static void doDeleteWindows(SOperatorInfo* pOperator, SInterval* pInterval, SSDataBlock* pBlock, SArray* pUpWins, - SSHashObj* pUpdatedMap) { + SSHashObj* pUpdatedMap, SHashObj* pInvalidWins) { SStreamIntervalOperatorInfo* pInfo = pOperator->info; SColumnInfoData* pStartTsCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX); TSKEY* startTsCols = (TSKEY*)pStartTsCol->pData; @@ -261,10 +261,15 @@ static void doDeleteWindows(SOperatorInfo* pOperator, SInterval* pInterval, SSDa void* chIds = taosHashGet(pInfo->pPullDataMap, &winRes, sizeof(SWinKey)); if (chIds) { int32_t childId = getChildIndex(pBlock); + if (pInvalidWins) { + qDebug("===stream===save mid delete window:%" PRId64 ",groupId:%" PRId64 ",chId:%d", winRes.ts, winRes.groupId, childId); + taosHashPut(pInvalidWins, &winRes, sizeof(SWinKey), NULL, 0); + } + SArray* chArray = *(void**)chIds; int32_t index = taosArraySearchIdx(chArray, &childId, compareInt32Val, TD_EQ); if (index != -1) { - qDebug("===stream===try push delete window%" PRId64 "chId:%d ,continue", win.skey, childId); + qDebug("===stream===try push delete window:%" PRId64 ",groupId:%" PRId64 ",chId:%d ,continue", win.skey, winGpId, childId); getNextTimeWindow(pInterval, &win, TSDB_ORDER_ASC); continue; } @@ -419,6 +424,7 @@ void destroyStreamFinalIntervalOperatorInfo(void* param) { blockDataDestroy(pInfo->pMidRetriveRes); blockDataDestroy(pInfo->pMidPulloverRes); pInfo->stateStore.streamFileStateDestroy(pInfo->pState->pFileState); + taosArrayDestroy(pInfo->pMidPullDatas); if (pInfo->pState->dump == 1) { taosMemoryFreeClear(pInfo->pState->pTdbState->pOwner); @@ -648,7 +654,11 @@ static bool processPullOver(SSDataBlock* pBlock, SHashObj* pMap, SHashObj* pFina .calWin.skey = nextWin.skey, .calWin.ekey = nextWin.skey}; // add pull data request - if (savePullWindow(&pull, pPullWins) == TSDB_CODE_SUCCESS) { + qDebug("===stream===prepare final retrive for delete window:%" PRId64 ",groupId%" PRId64 ", size:%d", winRes.ts, winRes.groupId, numOfCh); + if (IS_MID_INTERVAL_OP(pOperator)) { + SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperator->info; + taosArrayPush(pInfo->pMidPullDatas, &winRes); + } else if (savePullWindow(&pull, pPullWins) == TSDB_CODE_SUCCESS) { addPullWindow(pMap, &winRes, numOfCh); if (pInfo->destHasPrimaryKey) { tSimpleHashPut(pInfo->pDeletedMap,&winRes, sizeof(SWinKey), NULL, 0); @@ -1221,11 +1231,6 @@ static SSDataBlock* buildIntervalResult(SOperatorInfo* pOperator) { return pInfo->binfo.pRes; } - if (pInfo->recvPullover) { - pInfo->recvPullover = false; - printDataBlock(pInfo->pMidPulloverRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); - return pInfo->pMidPulloverRes; - } return NULL; } @@ -1303,14 +1308,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { while (1) { if (isTaskKilled(pTaskInfo)) { - if (pInfo->pUpdated != NULL) { - pInfo->pUpdated = taosArrayDestroy(pInfo->pUpdated); - } - - if (pInfo->pUpdatedMap != NULL) { - tSimpleHashCleanup(pInfo->pUpdatedMap); - pInfo->pUpdatedMap = NULL; - } qInfo("===stream=== %s task is killed, code %s", GET_TASKID(pTaskInfo), tstrerror(pTaskInfo->code)); return NULL; } @@ -1331,7 +1328,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT || pBlock->info.type == STREAM_CLEAR) { SArray* delWins = taosArrayInit(8, sizeof(SWinKey)); - doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap); + doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap, NULL); if (IS_FINAL_INTERVAL_OP(pOperator)) { int32_t chId = getChildIndex(pBlock); addRetriveWindow(delWins, pInfo, chId); @@ -1367,7 +1364,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { pInfo->recvRetrive = true; copyDataBlock(pInfo->pMidRetriveRes, pBlock); pInfo->pMidRetriveRes->info.type = STREAM_MID_RETRIEVE; - doDeleteWindows(pOperator, &pInfo->interval, pBlock, NULL, pInfo->pUpdatedMap); + doDeleteWindows(pOperator, &pInfo->interval, pBlock, NULL, pInfo->pUpdatedMap, NULL); break; } continue; @@ -1598,8 +1595,10 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, pInfo->pCheckpointRes = createSpecialDataBlock(STREAM_CHECKPOINT); pInfo->recvRetrive = false; pInfo->pMidRetriveRes = createSpecialDataBlock(STREAM_MID_RETRIEVE); + pInfo->recvPullover = false; pInfo->pMidPulloverRes = createSpecialDataBlock(STREAM_MID_RETRIEVE); pInfo->clearState = false; + pInfo->pMidPullDatas = taosArrayInit(4, sizeof(SWinKey)); pInfo->pDeletedMap = tSimpleHashInit(4096, hashFn); pInfo->destHasPrimaryKey = pIntervalPhyNode->window.destHasPrimayKey; @@ -1881,11 +1880,6 @@ int32_t releaseOutputBuf(void* pState, SRowBuffPos* pPos, SStateStore* pAPI) { return TSDB_CODE_SUCCESS; } -int32_t reuseOutputBuf(void* pState, SRowBuffPos* pPos, SStateStore* pAPI) { - pAPI->streamStateReleaseBuf(pState, pPos, true); - return TSDB_CODE_SUCCESS; -} - void removeSessionResult(SStreamAggSupporter* pAggSup, SSHashObj* pHashMap, SSHashObj* pResMap, SSessionKey* pKey) { SSessionKey key = {0}; getSessionHashKey(pKey, &key); @@ -2534,7 +2528,7 @@ void getMaxTsWins(const SArray* pAllWins, SArray* pMaxWins) { return; } SResultWindowInfo* pWinInfo = taosArrayGet(pAllWins, size - 1); - SSessionKey* pSeKey = pWinInfo->pStatePos->pKey; + SSessionKey* pSeKey = &pWinInfo->sessionWin; taosArrayPush(pMaxWins, pSeKey); if (pSeKey->groupId == 0) { return; @@ -2542,7 +2536,7 @@ void getMaxTsWins(const SArray* pAllWins, SArray* pMaxWins) { uint64_t preGpId = pSeKey->groupId; for (int32_t i = size - 2; i >= 0; i--) { pWinInfo = taosArrayGet(pAllWins, i); - pSeKey = pWinInfo->pStatePos->pKey; + pSeKey = &pWinInfo->sessionWin; if (preGpId != pSeKey->groupId) { taosArrayPush(pMaxWins, pSeKey); preGpId = pSeKey->groupId; @@ -4054,7 +4048,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT || pBlock->info.type == STREAM_CLEAR) { - doDeleteWindows(pOperator, &pInfo->interval, pBlock, pInfo->pDelWins, pInfo->pUpdatedMap); + doDeleteWindows(pOperator, &pInfo->interval, pBlock, pInfo->pDelWins, pInfo->pUpdatedMap, NULL); continue; } else if (pBlock->info.type == STREAM_GET_ALL) { pInfo->recvGetAll = true; @@ -4355,6 +4349,34 @@ static void addMidRetriveWindow(SArray* wins, SHashObj* pMidPullMap, int32_t num } } +static SSDataBlock* buildMidIntervalResult(SOperatorInfo* pOperator) { + SStreamIntervalOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + uint16_t opType = pOperator->operatorType; + + if (pInfo->recvPullover) { + pInfo->recvPullover = false; + printDataBlock(pInfo->pMidPulloverRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pInfo->pMidPulloverRes; + } + + qDebug("===stream=== build mid interval result"); + doBuildDeleteResult(pInfo, pInfo->pMidPullDatas, &pInfo->midDelIndex, pInfo->pDelRes); + if (pInfo->pDelRes->info.rows != 0) { + // process the rest of the data + printDataBlock(pInfo->pDelRes, getStreamOpName(opType), GET_TASKID(pTaskInfo)); + return pInfo->pDelRes; + } + + if (pInfo->recvRetrive) { + pInfo->recvRetrive = false; + printDataBlock(pInfo->pMidRetriveRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); + return pInfo->pMidRetriveRes; + } + + return NULL; +} + static SSDataBlock* doStreamMidIntervalAgg(SOperatorInfo* pOperator) { SStreamIntervalOperatorInfo* pInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; @@ -4383,10 +4405,9 @@ static SSDataBlock* doStreamMidIntervalAgg(SOperatorInfo* pOperator) { return resBlock; } - if (pInfo->recvRetrive) { - pInfo->recvRetrive = false; - printDataBlock(pInfo->pMidRetriveRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); - return pInfo->pMidRetriveRes; + resBlock = buildMidIntervalResult(pOperator); + if (resBlock != NULL) { + return resBlock; } if (pInfo->clearState) { @@ -4406,15 +4427,6 @@ static SSDataBlock* doStreamMidIntervalAgg(SOperatorInfo* pOperator) { while (1) { if (isTaskKilled(pTaskInfo)) { - if (pInfo->pUpdated != NULL) { - pInfo->pUpdated = taosArrayDestroy(pInfo->pUpdated); - } - - if (pInfo->pUpdatedMap != NULL) { - tSimpleHashCleanup(pInfo->pUpdatedMap); - pInfo->pUpdatedMap = NULL; - } - qInfo("===stream=== %s task is killed, code %s", GET_TASKID(pTaskInfo), tstrerror(pTaskInfo->code)); return NULL; } @@ -4435,7 +4447,7 @@ static SSDataBlock* doStreamMidIntervalAgg(SOperatorInfo* pOperator) { } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT || pBlock->info.type == STREAM_CLEAR) { SArray* delWins = taosArrayInit(8, sizeof(SWinKey)); - doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap); + doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap, pInfo->pFinalPullDataMap); removeResults(delWins, pInfo->pUpdatedMap); taosArrayAddAll(pInfo->pDelWins, delWins); taosArrayDestroy(delWins); @@ -4471,7 +4483,7 @@ static SSDataBlock* doStreamMidIntervalAgg(SOperatorInfo* pOperator) { continue; } else if (pBlock->info.type == STREAM_MID_RETRIEVE) { SArray* delWins = taosArrayInit(8, sizeof(SWinKey)); - doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap); + doDeleteWindows(pOperator, &pInfo->interval, pBlock, delWins, pInfo->pUpdatedMap, NULL); addMidRetriveWindow(delWins, pInfo->pPullDataMap, pInfo->numOfChild); taosArrayDestroy(delWins); pInfo->recvRetrive = true; @@ -4516,10 +4528,9 @@ static SSDataBlock* doStreamMidIntervalAgg(SOperatorInfo* pOperator) { return resBlock; } - if (pInfo->recvRetrive) { - pInfo->recvRetrive = false; - printDataBlock(pInfo->pMidRetriveRes, getStreamOpName(pOperator->operatorType), GET_TASKID(pTaskInfo)); - return pInfo->pMidRetriveRes; + resBlock = buildMidIntervalResult(pOperator); + if (resBlock != NULL) { + return resBlock; } if (pInfo->clearState) { diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index 1f41a0c7b3..69a90f03ed 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -14,6 +14,7 @@ */ #include "executorInt.h" +#include "geosWrapper.h" #include "filter.h" #include "functionMgt.h" #include "querynodes.h" @@ -432,95 +433,113 @@ static bool sysTableIsCondOnOneTable(SNode* pCond, char* condTable) { return false; } -static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) { - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - SStorageAPI* pAPI = &pTaskInfo->storageAPI; - +static SSDataBlock* doOptimizeTableNameFilter(SOperatorInfo* pOperator, SSDataBlock* dataBlock, char* dbname) { + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SStorageAPI* pAPI = &pTaskInfo->storageAPI; SSysTableScanInfo* pInfo = pOperator->info; - if (pOperator->status == OP_EXEC_DONE) { + int32_t numOfRows = 0; + + char tableName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_TO_VARSTR(tableName, pInfo->req.filterTb); + + SMetaReader smrTable = {0}; + pAPI->metaReaderFn.initReader(&smrTable, pInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn); + int32_t code = pAPI->metaReaderFn.getTableEntryByName(&smrTable, pInfo->req.filterTb); + if (code != TSDB_CODE_SUCCESS) { + // terrno has been set by pAPI->metaReaderFn.getTableEntryByName, therefore, return directly + pAPI->metaReaderFn.clearReader(&smrTable); + pInfo->loadInfo.totalRows = 0; return NULL; } - blockDataCleanup(pInfo->pRes); - int32_t numOfRows = 0; + if (smrTable.me.type == TSDB_SUPER_TABLE) { + pAPI->metaReaderFn.clearReader(&smrTable); + pInfo->loadInfo.totalRows = 0; + return NULL; + } - SSDataBlock* dataBlock = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_COLS); - blockDataEnsureCapacity(dataBlock, pOperator->resultInfo.capacity); + if (smrTable.me.type == TSDB_CHILD_TABLE) { + int64_t suid = smrTable.me.ctbEntry.suid; + pAPI->metaReaderFn.clearReader(&smrTable); + pAPI->metaReaderFn.initReader(&smrTable, pInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn); + code = pAPI->metaReaderFn.getTableEntryByUid(&smrTable, suid); + if (code != TSDB_CODE_SUCCESS) { + // terrno has been set by pAPI->metaReaderFn.getTableEntryByName, therefore, return directly + pAPI->metaReaderFn.clearReader(&smrTable); + pInfo->loadInfo.totalRows = 0; + return NULL; + } + } + char typeName[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; + SSchemaWrapper* schemaRow = NULL; + if (smrTable.me.type == TSDB_SUPER_TABLE) { + schemaRow = &smrTable.me.stbEntry.schemaRow; + STR_TO_VARSTR(typeName, "CHILD_TABLE"); + } else if (smrTable.me.type == TSDB_NORMAL_TABLE) { + schemaRow = &smrTable.me.ntbEntry.schemaRow; + STR_TO_VARSTR(typeName, "NORMAL_TABLE"); + } + + sysTableUserColsFillOneTableCols(pInfo, dbname, &numOfRows, dataBlock, tableName, schemaRow, typeName); + pAPI->metaReaderFn.clearReader(&smrTable); + + if (numOfRows > 0) { + relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock, pOperator->exprSupp.pFilterInfo); + numOfRows = 0; + } + + pInfo->loadInfo.totalRows += pInfo->pRes->info.rows; + setOperatorCompleted(pOperator); + + qDebug("get cols success, total rows:%" PRIu64 ", current:%" PRId64 " %s", pInfo->loadInfo.totalRows, + pInfo->pRes->info.rows, GET_TASKID(pTaskInfo)); + return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes; +} + +int32_t doExtractDbName(char* dbname, SSysTableScanInfo* pInfo, SStorageAPI* pAPI) { + SName sn = {0}; const char* db = NULL; int32_t vgId = 0; pAPI->metaFn.getBasicInfo(pInfo->readHandle.vnode, &db, &vgId, NULL, NULL); - - SName sn = {0}; - char dbname[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; tNameFromString(&sn, db, T_NAME_ACCT | T_NAME_DB); tNameGetDbName(&sn, varDataVal(dbname)); varDataSetLen(dbname, strlen(varDataVal(dbname))); - // optimize when sql like where table_name='tablename' and xxx. - if (pInfo->req.filterTb[0]) { - char tableName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; - STR_TO_VARSTR(tableName, pInfo->req.filterTb); + return TSDB_CODE_SUCCESS; +} - SMetaReader smrTable = {0}; - pAPI->metaReaderFn.initReader(&smrTable, pInfo->readHandle.vnode, 0, &pAPI->metaFn); - int32_t code = pAPI->metaReaderFn.getTableEntryByName(&smrTable, pInfo->req.filterTb); - if (code != TSDB_CODE_SUCCESS) { - // terrno has been set by pAPI->metaReaderFn.getTableEntryByName, therefore, return directly - pAPI->metaReaderFn.clearReader(&smrTable); - blockDataDestroy(dataBlock); - pInfo->loadInfo.totalRows = 0; - return NULL; - } +static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) { + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SStorageAPI* pAPI = &pTaskInfo->storageAPI; + SSysTableScanInfo* pInfo = pOperator->info; + int32_t numOfRows = 0; + int32_t ret = 0; + char dbname[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; + SSDataBlock* pDataBlock = NULL; - if (smrTable.me.type == TSDB_SUPER_TABLE) { - pAPI->metaReaderFn.clearReader(&smrTable); - blockDataDestroy(dataBlock); - pInfo->loadInfo.totalRows = 0; - return NULL; - } - - if (smrTable.me.type == TSDB_CHILD_TABLE) { - int64_t suid = smrTable.me.ctbEntry.suid; - pAPI->metaReaderFn.clearReader(&smrTable); - pAPI->metaReaderFn.initReader(&smrTable, pInfo->readHandle.vnode, 0, &pAPI->metaFn); - code = pAPI->metaReaderFn.getTableEntryByUid(&smrTable, suid); - if (code != TSDB_CODE_SUCCESS) { - // terrno has been set by pAPI->metaReaderFn.getTableEntryByName, therefore, return directly - pAPI->metaReaderFn.clearReader(&smrTable); - blockDataDestroy(dataBlock); - pInfo->loadInfo.totalRows = 0; - return NULL; - } - } - - char typeName[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; - SSchemaWrapper* schemaRow = NULL; - if (smrTable.me.type == TSDB_SUPER_TABLE) { - schemaRow = &smrTable.me.stbEntry.schemaRow; - STR_TO_VARSTR(typeName, "CHILD_TABLE"); - } else if (smrTable.me.type == TSDB_NORMAL_TABLE) { - schemaRow = &smrTable.me.ntbEntry.schemaRow; - STR_TO_VARSTR(typeName, "NORMAL_TABLE"); - } - - sysTableUserColsFillOneTableCols(pInfo, dbname, &numOfRows, dataBlock, tableName, schemaRow, typeName); - pAPI->metaReaderFn.clearReader(&smrTable); - - if (numOfRows > 0) { - relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock, pOperator->exprSupp.pFilterInfo); - numOfRows = 0; - } - blockDataDestroy(dataBlock); - pInfo->loadInfo.totalRows += pInfo->pRes->info.rows; - setOperatorCompleted(pOperator); - return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes; + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } + + blockDataCleanup(pInfo->pRes); + + pDataBlock = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_COLS); + blockDataEnsureCapacity(pDataBlock, pOperator->resultInfo.capacity); + doExtractDbName(dbname, pInfo, pAPI); + + // optimize when sql like where table_name='tablename' and xxx. + if (pInfo->req.filterTb[0]) { + SSDataBlock* p = doOptimizeTableNameFilter(pOperator, pDataBlock, dbname); + blockDataDestroy(pDataBlock); + return p; } - int32_t ret = 0; if (pInfo->pCur == NULL) { pInfo->pCur = pAPI->metaFn.openTableMetaCursor(pInfo->readHandle.vnode); + } else { + pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0); } if (pInfo->pSchema == NULL) { @@ -531,26 +550,20 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) { if (!pInfo->pCur || !pInfo->pSchema) { terrno = TSDB_CODE_OUT_OF_MEMORY; qError("sysTableScanUserCols failed since %s", terrstr(terrno)); - blockDataDestroy(dataBlock); + blockDataDestroy(pDataBlock); pInfo->loadInfo.totalRows = 0; return NULL; } - int32_t restore = pInfo->restore; - pInfo->restore = false; - - while (restore || ((ret = pAPI->metaFn.cursorNext(pInfo->pCur, TSDB_TABLE_MAX)) == 0)) { - if (restore) { - restore = false; - } + while (((ret = pAPI->metaFn.cursorNext(pInfo->pCur, TSDB_TABLE_MAX)) == 0)) { char typeName[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; char tableName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; SSchemaWrapper* schemaRow = NULL; if (pInfo->pCur->mr.me.type == TSDB_SUPER_TABLE) { - qDebug("sysTableScanUserCols cursor get super table"); + qDebug("sysTableScanUserCols cursor get super table, %s", GET_TASKID(pTaskInfo)); void* schema = taosHashGet(pInfo->pSchema, &pInfo->pCur->mr.me.uid, sizeof(int64_t)); if (schema == NULL) { SSchemaWrapper* schemaWrapper = tCloneSSchemaWrapper(&pInfo->pCur->mr.me.stbEntry.schemaRow); @@ -558,7 +571,8 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) { } continue; } else if (pInfo->pCur->mr.me.type == TSDB_CHILD_TABLE) { - qDebug("sysTableScanUserCols cursor get child table"); + qDebug("sysTableScanUserCols cursor get child table, %s", GET_TASKID(pTaskInfo)); + STR_TO_VARSTR(typeName, "CHILD_TABLE"); STR_TO_VARSTR(tableName, pInfo->pCur->mr.me.name); int64_t suid = pInfo->pCur->mr.me.ctbEntry.suid; @@ -567,13 +581,14 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) { schemaRow = *(SSchemaWrapper**)schema; } else { SMetaReader smrSuperTable = {0}; - pAPI->metaReaderFn.initReader(&smrSuperTable, pInfo->readHandle.vnode, 0, &pAPI->metaFn); + pAPI->metaReaderFn.initReader(&smrSuperTable, pInfo->readHandle.vnode, META_READER_NOLOCK, &pAPI->metaFn); int code = pAPI->metaReaderFn.getTableEntryByUid(&smrSuperTable, suid); if (code != TSDB_CODE_SUCCESS) { // terrno has been set by pAPI->metaReaderFn.getTableEntryByName, therefore, return directly - qError("sysTableScanUserCols get meta by suid:%" PRId64 " error, code:%d", suid, code); + qError("sysTableScanUserCols get meta by suid:%" PRId64 " error, code:%d, %s", suid, code, GET_TASKID(pTaskInfo)); + pAPI->metaReaderFn.clearReader(&smrSuperTable); - blockDataDestroy(dataBlock); + blockDataDestroy(pDataBlock); pInfo->loadInfo.totalRows = 0; return NULL; } @@ -583,34 +598,35 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) { pAPI->metaReaderFn.clearReader(&smrSuperTable); } } else if (pInfo->pCur->mr.me.type == TSDB_NORMAL_TABLE) { - qDebug("sysTableScanUserCols cursor get normal table"); + qDebug("sysTableScanUserCols cursor get normal table, %s", GET_TASKID(pTaskInfo)); schemaRow = &pInfo->pCur->mr.me.ntbEntry.schemaRow; STR_TO_VARSTR(typeName, "NORMAL_TABLE"); STR_TO_VARSTR(tableName, pInfo->pCur->mr.me.name); } else { - qDebug("sysTableScanUserCols cursor get invalid table"); + qDebug("sysTableScanUserCols cursor get invalid table, %s", GET_TASKID(pTaskInfo)); continue; } if ((numOfRows + schemaRow->nCols) > pOperator->resultInfo.capacity) { - relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock, pOperator->exprSupp.pFilterInfo); + relocateAndFilterSysTagsScanResult(pInfo, numOfRows, pDataBlock, pOperator->exprSupp.pFilterInfo); numOfRows = 0; - pInfo->restore = true; if (pInfo->pRes->info.rows > 0) { + pAPI->metaFn.pauseTableMetaCursor(pInfo->pCur); break; } } else { - sysTableUserColsFillOneTableCols(pInfo, dbname, &numOfRows, dataBlock, tableName, schemaRow, typeName); + sysTableUserColsFillOneTableCols(pInfo, dbname, &numOfRows, pDataBlock, tableName, schemaRow, typeName); } } if (numOfRows > 0) { - relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock, pOperator->exprSupp.pFilterInfo); + pAPI->metaFn.pauseTableMetaCursor(pInfo->pCur); + relocateAndFilterSysTagsScanResult(pInfo, numOfRows, pDataBlock, pOperator->exprSupp.pFilterInfo); numOfRows = 0; } - blockDataDestroy(dataBlock); + blockDataDestroy(pDataBlock); if (ret != 0) { pAPI->metaFn.closeTableMetaCursor(pInfo->pCur); pInfo->pCur = NULL; @@ -618,8 +634,7 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) { } pInfo->loadInfo.totalRows += pInfo->pRes->info.rows; - qDebug("sysTableScanUserCols get cols success, rows:%" PRIu64, pInfo->loadInfo.totalRows); - + qDebug("get cols success, rows:%" PRIu64 " %s", pInfo->loadInfo.totalRows, GET_TASKID(pTaskInfo)); return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes; } @@ -656,7 +671,7 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { STR_TO_VARSTR(tableName, condTableName); SMetaReader smrChildTable = {0}; - pAPI->metaReaderFn.initReader(&smrChildTable, pInfo->readHandle.vnode, 0, &pAPI->metaFn); + pAPI->metaReaderFn.initReader(&smrChildTable, pInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn); int32_t code = pAPI->metaReaderFn.getTableEntryByName(&smrChildTable, condTableName); if (code != TSDB_CODE_SUCCESS) { // terrno has been set by pAPI->metaReaderFn.getTableEntryByName, therefore, return directly @@ -701,6 +716,8 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { int32_t ret = 0; if (pInfo->pCur == NULL) { pInfo->pCur = pAPI->metaFn.openTableMetaCursor(pInfo->readHandle.vnode); + } else { + pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 0); } bool blockFull = false; @@ -713,7 +730,7 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { STR_TO_VARSTR(tableName, pInfo->pCur->mr.me.name); SMetaReader smrSuperTable = {0}; - pAPI->metaReaderFn.initReader(&smrSuperTable, pInfo->readHandle.vnode, 0, &pAPI->metaFn); + pAPI->metaReaderFn.initReader(&smrSuperTable, pInfo->readHandle.vnode, META_READER_NOLOCK, &pAPI->metaFn); uint64_t suid = pInfo->pCur->mr.me.ctbEntry.suid; int32_t code = pAPI->metaReaderFn.getTableEntryByUid(&smrSuperTable, suid); if (code != TSDB_CODE_SUCCESS) { @@ -726,7 +743,6 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { } if ((smrSuperTable.me.stbEntry.schemaTag.nCols + numOfRows) > pOperator->resultInfo.capacity) { - pAPI->metaFn.cursorPrev(pInfo->pCur, TSDB_TABLE_MAX); blockFull = true; } else { sysTableUserTagsFillOneTableTags(pInfo, &smrSuperTable, &pInfo->pCur->mr, dbname, tableName, &numOfRows, @@ -740,6 +756,7 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { numOfRows = 0; if (pInfo->pRes->info.rows > 0) { + pAPI->metaFn.pauseTableMetaCursor(pInfo->pCur); break; } @@ -748,6 +765,7 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { } if (numOfRows > 0) { + pAPI->metaFn.pauseTableMetaCursor(pInfo->pCur); relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock, pOperator->exprSupp.pFilterInfo); numOfRows = 0; } @@ -811,6 +829,8 @@ int32_t convertTagDataToStr(char* str, int type, void* buf, int32_t bufSize, int break; case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_VARBINARY: + case TSDB_DATA_TYPE_GEOMETRY: if (bufSize < 0) { return TSDB_CODE_TSC_INVALID_VALUE; } @@ -854,6 +874,30 @@ int32_t convertTagDataToStr(char* str, int type, void* buf, int32_t bufSize, int return TSDB_CODE_SUCCESS; } +static int32_t sysTableGetGeomText(char* iGeom, int32_t nGeom, char** output, int32_t* nOutput) { + int32_t code = 0; + char* outputWKT = NULL; + + if (nGeom == 0) { + if (!(*output = strdup(""))) code = TSDB_CODE_OUT_OF_MEMORY; + *nOutput = 0; + return code; + } + + if (TSDB_CODE_SUCCESS != (code = initCtxAsText()) || + TSDB_CODE_SUCCESS != (code = doAsText(iGeom, nGeom, &outputWKT))) { + qError("geo text for systable failed:%s", getThreadLocalGeosCtx()->errMsg); + *output = NULL; + *nOutput = 0; + return code; + } + + *output = outputWKT; + *nOutput = strlen(outputWKT); + + return code; +} + static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo, SMetaReader* smrSuperTable, SMetaReader* smrChildTable, const char* dbname, const char* tableName, int32_t* pNumOfRows, const SSDataBlock* dataBlock) { @@ -889,13 +933,13 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo, pColInfoData = taosArrayGet(dataBlock->pDataBlock, 4); char tagTypeStr[VARSTR_HEADER_SIZE + 32]; int tagTypeLen = sprintf(varDataVal(tagTypeStr), "%s", tDataTypes[tagType].name); - if (tagType == TSDB_DATA_TYPE_VARCHAR) { - tagTypeLen += sprintf(varDataVal(tagTypeStr) + tagTypeLen, "(%d)", - (int32_t)((*smrSuperTable).me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE)); - } else if (tagType == TSDB_DATA_TYPE_NCHAR) { + if (tagType == TSDB_DATA_TYPE_NCHAR) { tagTypeLen += sprintf( varDataVal(tagTypeStr) + tagTypeLen, "(%d)", (int32_t)(((*smrSuperTable).me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)); + } else if (IS_VAR_DATA_TYPE(tagType)) { + tagTypeLen += sprintf(varDataVal(tagTypeStr) + tagTypeLen, "(%d)", + (int32_t)((*smrSuperTable).me.stbEntry.schemaTag.pSchema[i].bytes - VARSTR_HEADER_SIZE)); } varDataSetLen(tagTypeStr, tagTypeLen); colDataSetVal(pColInfoData, numOfRows, (char*)tagTypeStr, false); @@ -910,7 +954,13 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo, } else { bool exist = tTagGet((STag*)smrChildTable->me.ctbEntry.pTags, &tagVal); if (exist) { - if (IS_VAR_DATA_TYPE(tagType)) { + if (tagType == TSDB_DATA_TYPE_GEOMETRY) { + sysTableGetGeomText(tagVal.pData, tagVal.nData, &tagData, &tagLen); + } else if (tagType == TSDB_DATA_TYPE_VARBINARY) { + if (taosAscii2Hex(tagVal.pData, tagVal.nData, (void**)&tagData, &tagLen) < 0) { + qError("varbinary for systable failed since %s", tstrerror(TSDB_CODE_OUT_OF_MEMORY)); + } + } else if (IS_VAR_DATA_TYPE(tagType)) { tagData = (char*)tagVal.pData; tagLen = tagVal.nData; } else { @@ -940,6 +990,7 @@ static int32_t sysTableUserTagsFillOneTableTags(const SSysTableScanInfo* pInfo, pColInfoData = taosArrayGet(dataBlock->pDataBlock, 5); colDataSetVal(pColInfoData, numOfRows, tagVarChar, (tagData == NULL) || (tagType == TSDB_DATA_TYPE_JSON && tTagIsJsonNull(tagData))); + if (tagType == TSDB_DATA_TYPE_GEOMETRY || tagType == TSDB_DATA_TYPE_VARBINARY) taosMemoryFreeClear(tagData); taosMemoryFree(tagVarChar); ++numOfRows; } @@ -1129,7 +1180,7 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) { tb_uid_t* uid = taosArrayGet(pIdx->uids, i); SMetaReader mr = {0}; - pAPI->metaReaderFn.initReader(&mr, pInfo->readHandle.vnode, 0, &pAPI->metaFn); + pAPI->metaReaderFn.initReader(&mr, pInfo->readHandle.vnode, META_READER_LOCK, &pAPI->metaFn); ret = pAPI->metaReaderFn.getTableEntryByUid(&mr, *uid); if (ret < 0) { pAPI->metaReaderFn.clearReader(&mr); @@ -1295,7 +1346,7 @@ static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) { firstMetaCursor = 1; } if (!firstMetaCursor) { - pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0); + pAPI->metaFn.resumeTableMetaCursor(pInfo->pCur, 0, 1); } blockDataCleanup(pInfo->pRes); @@ -2170,7 +2221,7 @@ static int32_t doGetTableRowSize(SReadHandle* pHandle, uint64_t uid, int32_t* ro *rowLen = 0; SMetaReader mr = {0}; - pHandle->api.metaReaderFn.initReader(&mr, pHandle->vnode, 0, &pHandle->api.metaFn); + pHandle->api.metaReaderFn.initReader(&mr, pHandle->vnode, META_READER_LOCK, &pHandle->api.metaFn); int32_t code = pHandle->api.metaReaderFn.getTableEntryByUid(&mr, uid); if (code != TSDB_CODE_SUCCESS) { qError("failed to get table meta, uid:0x%" PRIx64 ", code:%s, %s", uid, tstrerror(terrno), idstr); diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 82881dcd14..271d3e05a5 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -108,8 +108,8 @@ struct SSortHandle { int32_t extRowsPageSize; int32_t extRowsMemSize; int32_t srcTsSlotId; - SBlockOrderInfo extRowsOrderInfo; - + SArray* aExtRowsOrders; + bool bSortPk; void (*mergeLimitReachedFn)(uint64_t tableUid, void* param); void* mergeLimitReachedParam; }; @@ -261,10 +261,17 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t page pSortHandle->cmpParam.cmpGroupId = false; pSortHandle->cmpParam.sortType = type; if (type == SORT_BLOCK_TS_MERGE) { - SBlockOrderInfo* pOrder = TARRAY_GET_ELEM(pSortInfo, 0); - pSortHandle->cmpParam.tsSlotId = pOrder->slotId; - pSortHandle->cmpParam.order = pOrder->order; - pSortHandle->cmpParam.cmpFn = (pOrder->order == TSDB_ORDER_ASC) ? compareInt64Val : compareInt64ValDesc; + SBlockOrderInfo* pTsOrder = TARRAY_GET_ELEM(pSortInfo, 0); + pSortHandle->cmpParam.tsSlotId = pTsOrder->slotId; + pSortHandle->cmpParam.tsOrder = pTsOrder->order; + pSortHandle->cmpParam.cmpTsFn = pTsOrder->compFn; + if (taosArrayGetSize(pSortHandle->pSortInfo) == 2) { + pSortHandle->cmpParam.pPkOrder = taosArrayGet(pSortHandle->pSortInfo, 1); + pSortHandle->bSortPk = true; + } else { + pSortHandle->cmpParam.pPkOrder = NULL; + pSortHandle->bSortPk = false; + } } tsortSetComparFp(pSortHandle, msortComparFn); @@ -347,6 +354,8 @@ void tsortDestroySortHandle(SSortHandle* pSortHandle) { destroySortMemFile(pSortHandle); } taosArrayDestroy(pSortHandle->pSortInfo); + taosArrayDestroy(pSortHandle->aExtRowsOrders); + pSortHandle->aExtRowsOrders = NULL; taosMemoryFreeClear(pSortHandle); } @@ -624,6 +633,57 @@ static SSDataBlock* getSortedBlockDataInner(SSortHandle* pHandle, SMsortComparPa return (pHandle->pDataBlock->info.rows > 0) ? pHandle->pDataBlock : NULL; } +// TODO: improve this function performance + +int tsortComparBlockCell(SSDataBlock* pLeftBlock, SSDataBlock* pRightBlock, + int32_t leftRowIndex, int32_t rightRowIndex, void* pCompareOrder) { + SBlockOrderInfo* pOrder = pCompareOrder; + SColumnInfoData* pLeftColInfoData = TARRAY_GET_ELEM(pLeftBlock->pDataBlock, pOrder->slotId); + SColumnInfoData* pRightColInfoData = TARRAY_GET_ELEM(pRightBlock->pDataBlock, pOrder->slotId); + + bool isVarType = IS_VAR_DATA_TYPE(pLeftColInfoData->info.type); + if (pLeftColInfoData->hasNull || pRightColInfoData->hasNull) { + bool leftNull = false; + if (pLeftColInfoData->hasNull) { + if (pLeftBlock->pBlockAgg == NULL) { + leftNull = colDataIsNull_t(pLeftColInfoData, leftRowIndex, isVarType); + } else { + leftNull = + colDataIsNull(pLeftColInfoData, pLeftBlock->info.rows, leftRowIndex, pLeftBlock->pBlockAgg[pOrder->slotId]); + } + } + + bool rightNull = false; + if (pRightColInfoData->hasNull) { + if (pRightBlock->pBlockAgg == NULL) { + rightNull = colDataIsNull_t(pRightColInfoData, rightRowIndex, isVarType); + } else { + rightNull = colDataIsNull(pRightColInfoData, pRightBlock->info.rows, rightRowIndex, + pRightBlock->pBlockAgg[pOrder->slotId]); + } + } + + if (leftNull && rightNull) { + return 0; + } + + if (rightNull) { + return pOrder->nullFirst ? 1 : -1; + } + + if (leftNull) { + return pOrder->nullFirst ? -1 : 1; + } + } + + void *left1, *right1; + left1 = colDataGetData(pLeftColInfoData, leftRowIndex); + right1 = colDataGetData(pRightColInfoData, rightRowIndex); + __compar_fn_t fn = pOrder->compFn; + int ret = fn(left1, right1); + return ret; +} + int32_t msortComparFn(const void* pLeft, const void* pRight, void* param) { int32_t pLeftIdx = *(int32_t*)pLeft; int32_t pRightIdx = *(int32_t*)pRight; @@ -654,12 +714,16 @@ int32_t msortComparFn(const void* pLeft, const void* pRight, void* param) { } if (pParam->sortType == SORT_BLOCK_TS_MERGE) { - SColumnInfoData* pLeftColInfoData = TARRAY_GET_ELEM(pLeftBlock->pDataBlock, pParam->tsSlotId); - SColumnInfoData* pRightColInfoData = TARRAY_GET_ELEM(pRightBlock->pDataBlock, pParam->tsSlotId); - int64_t* left1 = (int64_t*)(pLeftColInfoData->pData) + pLeftSource->src.rowIndex; - int64_t* right1 = (int64_t*)(pRightColInfoData->pData) + pRightSource->src.rowIndex; + SColumnInfoData* pLeftTsCol = TARRAY_GET_ELEM(pLeftBlock->pDataBlock, pParam->tsSlotId); + SColumnInfoData* pRightTsCol = TARRAY_GET_ELEM(pRightBlock->pDataBlock, pParam->tsSlotId); + int64_t* leftTs = (int64_t*)(pLeftTsCol->pData) + pLeftSource->src.rowIndex; + int64_t* rightTs = (int64_t*)(pRightTsCol->pData) + pRightSource->src.rowIndex; - int ret = pParam->cmpFn(left1, right1); + int ret = pParam->cmpTsFn(leftTs, rightTs); + if (ret == 0 && pParam->pPkOrder) { + ret = tsortComparBlockCell(pLeftBlock, pRightBlock, + pLeftSource->src.rowIndex, pRightSource->src.rowIndex, (SBlockOrderInfo*)pParam->pPkOrder); + } return ret; } else { bool isVarType; @@ -1208,7 +1272,8 @@ static void appendToRowIndexDataBlock(SSortHandle* pHandle, SSDataBlock* pSource saveBlockRowToExtRowsMemFile(pHandle, pSource, *rowIndex, &pageId, &offset, &length); SSDataBlock* pBlock = pHandle->pDataBlock; - SColumnInfoData* pSrcTsCol = taosArrayGet(pSource->pDataBlock, pHandle->extRowsOrderInfo.slotId); + SBlockOrderInfo* extRowsTsOrder = taosArrayGet(pHandle->aExtRowsOrders, 0); + SColumnInfoData* pSrcTsCol = taosArrayGet(pSource->pDataBlock, extRowsTsOrder->slotId); SColumnInfoData* pTsCol = taosArrayGet(pBlock->pDataBlock, 0); char* pData = colDataGetData(pSrcTsCol, *rowIndex); colDataSetVal(pTsCol, pBlock->info.rows, pData, false); @@ -1222,11 +1287,25 @@ static void appendToRowIndexDataBlock(SSortHandle* pHandle, SSDataBlock* pSource SColumnInfoData* pLengthCol = taosArrayGet(pBlock->pDataBlock, 3); colDataSetInt32(pLengthCol, pBlock->info.rows, &length); + if (pHandle->bSortPk) { + SBlockOrderInfo* extRowsPkOrder = taosArrayGet(pHandle->aExtRowsOrders, 1); + SColumnInfoData* pSrcPkCol = taosArrayGet(pSource->pDataBlock, extRowsPkOrder->slotId); + SColumnInfoData* pPkCol = taosArrayGet(pBlock->pDataBlock, 4); + if (colDataIsNull_s(pSrcPkCol, *rowIndex)) { + colDataSetNULL(pPkCol, pBlock->info.rows); + } else { + char* pPkData = colDataGetData(pSrcPkCol, *rowIndex); + colDataSetVal(pPkCol, pBlock->info.rows, pPkData, false); + } + } + pBlock->info.rows += 1; *rowIndex += 1; } static void initRowIdSort(SSortHandle* pHandle) { + SBlockOrderInfo* pkOrder = (pHandle->bSortPk) ? taosArrayGet(pHandle->aExtRowsOrders, 1) : NULL; + SColumnInfoData* extPkCol = (pHandle->bSortPk) ? taosArrayGet(pHandle->pDataBlock->pDataBlock, pkOrder->slotId) : NULL; SSDataBlock* pSortInput = createDataBlock(); SColumnInfoData tsCol = createColumnInfoData(TSDB_DATA_TYPE_TIMESTAMP, 8, 1); @@ -1237,7 +1316,10 @@ static void initRowIdSort(SSortHandle* pHandle) { blockDataAppendColInfo(pSortInput, &offsetCol); SColumnInfoData lengthCol = createColumnInfoData(TSDB_DATA_TYPE_INT, 4, 4); blockDataAppendColInfo(pSortInput, &lengthCol); - + if (pHandle->bSortPk) { + SColumnInfoData pkCol = createColumnInfoData(extPkCol->info.type, extPkCol->info.bytes, 5); + blockDataAppendColInfo(pSortInput, &pkCol); + } blockDataDestroy(pHandle->pDataBlock); pHandle->pDataBlock = pSortInput; @@ -1246,15 +1328,24 @@ static void initRowIdSort(SSortHandle* pHandle) { pHandle->pageSize = 256 * 1024; // 256k pHandle->numOfPages = 256; - SBlockOrderInfo* pOrder = taosArrayGet(pHandle->pSortInfo, 0); - SBlockOrderInfo bi = {0}; - bi.order = pOrder->order; - bi.slotId = 0; - bi.nullFirst = NULL_ORDER_FIRST; - SArray* aOrder = taosArrayInit(1, sizeof(SBlockOrderInfo)); - taosArrayPush(aOrder, &bi); + SBlockOrderInfo* pTsOrder = taosArrayGet(pHandle->pSortInfo, 0); + SBlockOrderInfo biTs = {0}; + biTs.order = pTsOrder->order; + biTs.slotId = 0; + biTs.nullFirst = (biTs.order == TSDB_ORDER_ASC); + biTs.compFn = getKeyComparFunc(TSDB_DATA_TYPE_TIMESTAMP, biTs.order); + taosArrayPush(aOrder, &biTs); + + if (pHandle->bSortPk) { + SBlockOrderInfo biPk = {0}; + biPk.order = pkOrder->order; + biPk.slotId = 4; + biPk.nullFirst = (biPk.order == TSDB_ORDER_ASC); + biPk.compFn = getKeyComparFunc(extPkCol->info.type, biPk.order); + taosArrayPush(aOrder, &biPk); + } taosArrayDestroy(pHandle->pSortInfo); pHandle->pSortInfo = aOrder; return; @@ -1263,8 +1354,7 @@ static void initRowIdSort(SSortHandle* pHandle) { int32_t tsortSetSortByRowId(SSortHandle* pHandle, int32_t extRowsMemSize) { pHandle->extRowBytes = blockDataGetRowSize(pHandle->pDataBlock) + taosArrayGetSize(pHandle->pDataBlock->pDataBlock) + sizeof(int32_t); pHandle->extRowsMemSize = extRowsMemSize; - SBlockOrderInfo* pOrder = taosArrayGet(pHandle->pSortInfo, 0); - pHandle->extRowsOrderInfo = *pOrder; + pHandle->aExtRowsOrders = taosArrayDup(pHandle->pSortInfo, NULL); initRowIdSort(pHandle); if (!osTempSpaceAvailable()) { terrno = TSDB_CODE_NO_DISKSPACE; @@ -1279,7 +1369,10 @@ int32_t tsortSetSortByRowId(SSortHandle* pHandle, int32_t extRowsMemSize) { typedef struct SBlkMergeSupport { int64_t** aTs; int32_t* aRowIdx; - int32_t order; + int32_t tsOrder; + + SBlockOrderInfo* pPkOrder; + SSDataBlock** aBlks; } SBlkMergeSupport; static int32_t blockCompareTsFn(const void* pLeft, const void* pRight, void* param) { @@ -1297,12 +1390,36 @@ static int32_t blockCompareTsFn(const void* pLeft, const void* pRight, void* par int64_t rightTs = pSup->aTs[right][pSup->aRowIdx[right]]; int32_t ret = leftTs>rightTs ? 1 : ((leftTs < rightTs) ? -1 : 0); - if (pSup->order == TSDB_ORDER_DESC) { + if (pSup->tsOrder == TSDB_ORDER_DESC) { ret = -1 * ret; } return ret; } +static int32_t blockCompareTsPkFn(const void* pLeft, const void* pRight, void* param) { + int32_t left = *(int32_t*)pLeft; + int32_t right = *(int32_t*)pRight; + + SBlkMergeSupport* pSup = (SBlkMergeSupport*)param; + if (pSup->aRowIdx[left] == -1) { + return 1; + } else if (pSup->aRowIdx[right] == -1) { + return -1; + } + + int64_t leftTs = pSup->aTs[left][pSup->aRowIdx[left]]; + int64_t rightTs = pSup->aTs[right][pSup->aRowIdx[right]]; + + int32_t ret = leftTs>rightTs ? 1 : ((leftTs < rightTs) ? -1 : 0); + if (pSup->tsOrder == TSDB_ORDER_DESC) { + ret = -1 * ret; + } + if (ret == 0 && pSup->pPkOrder) { + ret = tsortComparBlockCell(pSup->aBlks[left], pSup->aBlks[right], pSup->aRowIdx[left], pSup->aRowIdx[right], pSup->pPkOrder); + } + return ret; +} + static int32_t appendDataBlockToPageBuf(SSortHandle* pHandle, SSDataBlock* blk, SArray* aPgId) { int32_t pageId = -1; void* pPage = getNewBufPage(pHandle->pBuf, &pageId); @@ -1358,18 +1475,27 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray* blockDataCleanup(pHandle->pDataBlock); int32_t numBlks = taosArrayGetSize(aBlk); - SBlockOrderInfo* pOrigBlockOrder = (!pHandle->bSortByRowId) ? taosArrayGet(pHandle->pSortInfo, 0) : &pHandle->extRowsOrderInfo; - SBlockOrderInfo* pHandleBlockOrder = taosArrayGet(pHandle->pSortInfo, 0); - SBlkMergeSupport sup; + SBlockOrderInfo* pOrigBlockTsOrder = (!pHandle->bSortByRowId) ? + taosArrayGet(pHandle->pSortInfo, 0) : taosArrayGet(pHandle->aExtRowsOrders, 0); + SBlockOrderInfo* pHandleBlockTsOrder = taosArrayGet(pHandle->pSortInfo, 0); + SBlkMergeSupport sup = {0}; sup.aRowIdx = taosMemoryCalloc(numBlks, sizeof(int32_t)); sup.aTs = taosMemoryCalloc(numBlks, sizeof(int64_t*)); - sup.order = pOrigBlockOrder->order; + sup.tsOrder = pOrigBlockTsOrder->order; + sup.aBlks = taosMemoryCalloc(numBlks, sizeof(SSDataBlock*)); for (int i = 0; i < numBlks; ++i) { SSDataBlock* blk = taosArrayGetP(aBlk, i); - SColumnInfoData* col = taosArrayGet(blk->pDataBlock, pOrigBlockOrder->slotId); + SColumnInfoData* col = taosArrayGet(blk->pDataBlock, pOrigBlockTsOrder->slotId); sup.aTs[i] = (int64_t*)col->pData; sup.aRowIdx[i] = 0; + sup.aBlks[i] = blk; } + SBlockOrderInfo* pOrigBlockPkOrder = NULL; + if (pHandle->bSortPk) { + pOrigBlockPkOrder = (!pHandle->bSortByRowId) ? + taosArrayGet(pHandle->pSortInfo, 1) : taosArrayGet(pHandle->aExtRowsOrders, 1); + } + sup.pPkOrder = pOrigBlockPkOrder; int32_t totalRows = 0; for (int i = 0; i < numBlks; ++i) { @@ -1377,11 +1503,13 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray* totalRows += blk->info.rows; } - SMultiwayMergeTreeInfo* pTree = NULL; - code = tMergeTreeCreate(&pTree, taosArrayGetSize(aBlk), &sup, blockCompareTsFn); + SMultiwayMergeTreeInfo* pTree = NULL; + __merge_compare_fn_t mergeCompareFn = (!pHandle->bSortPk) ? blockCompareTsFn : blockCompareTsPkFn; + code = tMergeTreeCreate(&pTree, taosArrayGetSize(aBlk), &sup, mergeCompareFn); if (TSDB_CODE_SUCCESS != code) { taosMemoryFree(sup.aRowIdx); taosMemoryFree(sup.aTs); + taosMemoryFree(sup.aBlks); return code; } @@ -1390,8 +1518,8 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray* int32_t nMergedRows = 0; bool mergeLimitReached = false; size_t blkPgSz = pgHeaderSz; - int64_t lastPageBufTs = (pHandleBlockOrder->order == TSDB_ORDER_ASC) ? INT64_MAX : INT64_MIN; - int64_t currTs = (pHandleBlockOrder->order == TSDB_ORDER_ASC) ? INT64_MAX : INT64_MIN; + int64_t lastPageBufTs = (pHandleBlockTsOrder->order == TSDB_ORDER_ASC) ? INT64_MAX : INT64_MIN; + int64_t currTs = (pHandleBlockTsOrder->order == TSDB_ORDER_ASC) ? INT64_MAX : INT64_MIN; while (nRows < totalRows) { int32_t minIdx = tMergeTreeGetChosenIndex(pTree); SSDataBlock* minBlk = taosArrayGetP(aBlk, minIdx); @@ -1400,7 +1528,7 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray* int32_t bufInc = getPageBufIncForRow(incBlock, minRow, pHandle->pDataBlock->info.rows); if (blkPgSz <= pHandle->pageSize && blkPgSz + bufInc > pHandle->pageSize) { - SColumnInfoData* tsCol = taosArrayGet(pHandle->pDataBlock->pDataBlock, pHandleBlockOrder->slotId); + SColumnInfoData* tsCol = taosArrayGet(pHandle->pDataBlock->pDataBlock, pHandleBlockTsOrder->slotId); lastPageBufTs = ((int64_t*)tsCol->pData)[pHandle->pDataBlock->info.rows - 1]; code = appendDataBlockToPageBuf(pHandle, pHandle->pDataBlock, aPgId); if (code != TSDB_CODE_SUCCESS) { @@ -1408,6 +1536,7 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray* taosArrayDestroy(aPgId); taosMemoryFree(sup.aRowIdx); taosMemoryFree(sup.aTs); + taosMemoryFree(sup.aBlks); return code; } nMergedRows += pHandle->pDataBlock->info.rows; @@ -1418,8 +1547,8 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray* if ((pHandle->mergeLimit != -1) && (nMergedRows >= pHandle->mergeLimit)) { mergeLimitReached = true; - if ((lastPageBufTs < pHandle->currMergeLimitTs && pHandleBlockOrder->order == TSDB_ORDER_ASC) || - (lastPageBufTs > pHandle->currMergeLimitTs && pHandleBlockOrder->order == TSDB_ORDER_DESC)) { + if ((lastPageBufTs < pHandle->currMergeLimitTs && pHandleBlockTsOrder->order == TSDB_ORDER_ASC) || + (lastPageBufTs > pHandle->currMergeLimitTs && pHandleBlockTsOrder->order == TSDB_ORDER_DESC)) { pHandle->currMergeLimitTs = lastPageBufTs; } break; @@ -1444,7 +1573,7 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray* } if (pHandle->pDataBlock->info.rows > 0) { if (!mergeLimitReached) { - SColumnInfoData* tsCol = taosArrayGet(pHandle->pDataBlock->pDataBlock, pHandleBlockOrder->slotId); + SColumnInfoData* tsCol = taosArrayGet(pHandle->pDataBlock->pDataBlock, pHandleBlockTsOrder->slotId); lastPageBufTs = ((int64_t*)tsCol->pData)[pHandle->pDataBlock->info.rows - 1]; code = appendDataBlockToPageBuf(pHandle, pHandle->pDataBlock, aPgId); if (code != TSDB_CODE_SUCCESS) { @@ -1452,13 +1581,14 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray* taosMemoryFree(pTree); taosMemoryFree(sup.aRowIdx); taosMemoryFree(sup.aTs); + taosMemoryFree(sup.aBlks); return code; } nMergedRows += pHandle->pDataBlock->info.rows; if ((pHandle->mergeLimit != -1) && (nMergedRows >= pHandle->mergeLimit)) { mergeLimitReached = true; - if ((lastPageBufTs < pHandle->currMergeLimitTs && pHandleBlockOrder->order == TSDB_ORDER_ASC) || - (lastPageBufTs > pHandle->currMergeLimitTs && pHandleBlockOrder->order == TSDB_ORDER_DESC)) { + if ((lastPageBufTs < pHandle->currMergeLimitTs && pHandleBlockTsOrder->order == TSDB_ORDER_ASC) || + (lastPageBufTs > pHandle->currMergeLimitTs && pHandleBlockTsOrder->order == TSDB_ORDER_DESC)) { pHandle->currMergeLimitTs = lastPageBufTs; } } @@ -1471,6 +1601,7 @@ static int32_t sortBlocksToExtSource(SSortHandle* pHandle, SArray* aBlk, SArray* taosMemoryFree(sup.aRowIdx); taosMemoryFree(sup.aTs); + taosMemoryFree(sup.aBlks); tMergeTreeDestroy(&pTree); @@ -1531,8 +1662,9 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) { SSortSource* pSrc = taosArrayGetP(pHandle->pOrderedSource, 0); int32_t szSort = 0; - SBlockOrderInfo* pOrigOrder = (!pHandle->bSortByRowId) ? taosArrayGet(pHandle->pSortInfo, 0) : &pHandle->extRowsOrderInfo; - if (pOrigOrder->order == TSDB_ORDER_ASC) { + SBlockOrderInfo* pOrigTsOrder = (!pHandle->bSortByRowId) ? + taosArrayGet(pHandle->pSortInfo, 0) : taosArrayGet(pHandle->aExtRowsOrders, 0); + if (pOrigTsOrder->order == TSDB_ORDER_ASC) { pHandle->currMergeLimitTs = INT64_MAX; } else { pHandle->currMergeLimitTs = INT64_MIN; @@ -1554,10 +1686,10 @@ static int32_t createBlocksMergeSortInitialSources(SSortHandle* pHandle) { } if (pBlk != NULL) { - SColumnInfoData* tsCol = taosArrayGet(pBlk->pDataBlock, pOrigOrder->slotId); + SColumnInfoData* tsCol = taosArrayGet(pBlk->pDataBlock, pOrigTsOrder->slotId); int64_t firstRowTs = *(int64_t*)tsCol->pData; - if ((pOrigOrder->order == TSDB_ORDER_ASC && firstRowTs > pHandle->currMergeLimitTs) || - (pOrigOrder->order == TSDB_ORDER_DESC && firstRowTs < pHandle->currMergeLimitTs)) { + if ((pOrigTsOrder->order == TSDB_ORDER_ASC && firstRowTs > pHandle->currMergeLimitTs) || + (pOrigTsOrder->order == TSDB_ORDER_DESC && firstRowTs < pHandle->currMergeLimitTs)) { if (bExtractedBlock) { blockDataDestroy(pBlk); } diff --git a/source/libs/geometry/src/geosWrapper.c b/source/libs/geometry/src/geosWrapper.c index 993178e2b0..ad2d477a13 100644 --- a/source/libs/geometry/src/geosWrapper.c +++ b/source/libs/geometry/src/geosWrapper.c @@ -199,6 +199,7 @@ int32_t doAsText(const unsigned char *inputGeom, size_t size, char **outputWKT) wkt = GEOSWKTWriter_write_r(geosCtx->handle, geosCtx->WKTWriter, geom); if (wkt == NULL) { + code = TSDB_CODE_MSG_DECODE_ERROR; goto _exit; } *outputWKT = wkt; diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 2d2d2ad102..36bcfdc43b 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -209,6 +209,8 @@ const char* nodesNodeName(ENodeType type) { return "ShowSnodesStmt"; case QUERY_NODE_SHOW_BNODES_STMT: return "ShowBnodesStmt"; + case QUERY_NODE_SHOW_ARBGROUPS_STMT: + return "ShowArbGroupsStmt"; case QUERY_NODE_SHOW_CLUSTER_STMT: return "ShowClusterStmt"; case QUERY_NODE_SHOW_DATABASES_STMT: @@ -266,7 +268,7 @@ const char* nodesNodeName(ENodeType type) { case QUERY_NODE_SHOW_COMPACTS_STMT: return "ShowCompactsStmt"; case QUERY_NODE_SHOW_COMPACT_DETAILS_STMT: - return "ShowCompactDetailsStmt"; + return "ShowCompactDetailsStmt"; case QUERY_NODE_SHOW_GRANTS_FULL_STMT: return "ShowGrantsFullStmt"; case QUERY_NODE_SHOW_GRANTS_LOGS_STMT: @@ -3185,16 +3187,16 @@ static int32_t physiGroupCacheNodeToJson(const void* pObj, SJson* pJson) { int32_t code = physicPlanNodeToJson(pObj, pJson); if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkGroupCachePhysiPlanGrpColsMayBeNull, pNode->grpColsMayBeNull); - } + } if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkGroupCachePhysiPlanGroupByUid, pNode->grpByUid); - } + } if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkGroupCachePhysiPlanGlobalGroup, pNode->globalGrp); - } + } if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkGroupCachePhysiPlanBatchFetch, pNode->batchFetch); - } + } if (TSDB_CODE_SUCCESS == code) { code = nodeListToJson(pJson, jkGroupCachePhysiPlanGroupCols, pNode->pGroupCols); } @@ -6691,6 +6693,10 @@ static int32_t showQnodesStmtToJson(const void* pObj, SJson* pJson) { return sho static int32_t jsonToShowQnodesStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); } +static int32_t showArbGroupsStmtToJson(const void* pObj, SJson* pJson) { return showStmtToJson(pObj, pJson); } + +static int32_t jsonToShowArbGroupsStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); } + static int32_t showClusterStmtToJson(const void* pObj, SJson* pJson) { return showStmtToJson(pObj, pJson); } static int32_t jsonToShowClusterStmt(const SJson* pJson, void* pObj) { return jsonToShowStmt(pJson, pObj); } @@ -7216,6 +7222,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { return showMnodesStmtToJson(pObj, pJson); case QUERY_NODE_SHOW_QNODES_STMT: return showQnodesStmtToJson(pObj, pJson); + case QUERY_NODE_SHOW_ARBGROUPS_STMT: + return showArbGroupsStmtToJson(pObj, pJson); case QUERY_NODE_SHOW_CLUSTER_STMT: return showClusterStmtToJson(pObj, pJson); case QUERY_NODE_SHOW_DATABASES_STMT: @@ -7553,6 +7561,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { return jsonToShowMnodesStmt(pJson, pObj); case QUERY_NODE_SHOW_QNODES_STMT: return jsonToShowQnodesStmt(pJson, pObj); + case QUERY_NODE_SHOW_ARBGROUPS_STMT: + return jsonToShowArbGroupsStmt(pJson, pObj); case QUERY_NODE_SHOW_CLUSTER_STMT: return jsonToShowClusterStmt(pJson, pObj); case QUERY_NODE_SHOW_DATABASES_STMT: @@ -7617,7 +7627,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { return jsonToRestoreQnodeStmt(pJson, pObj); case QUERY_NODE_RESTORE_MNODE_STMT: return jsonToRestoreMnodeStmt(pJson, pObj); - case QUERY_NODE_RESTORE_VNODE_STMT: + case QUERY_NODE_RESTORE_VNODE_STMT: return jsonToRestoreVnodeStmt(pJson, pObj); case QUERY_NODE_LOGIC_PLAN_SCAN: return jsonToLogicScanNode(pJson, pObj); diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 1bdcda3ddf..7251db21b6 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -419,6 +419,7 @@ SNode* nodesMakeNode(ENodeType type) { case QUERY_NODE_SHOW_QNODES_STMT: case QUERY_NODE_SHOW_SNODES_STMT: case QUERY_NODE_SHOW_BNODES_STMT: + case QUERY_NODE_SHOW_ARBGROUPS_STMT: case QUERY_NODE_SHOW_CLUSTER_STMT: case QUERY_NODE_SHOW_DATABASES_STMT: case QUERY_NODE_SHOW_FUNCTIONS_STMT: @@ -1072,6 +1073,7 @@ void nodesDestroyNode(SNode* pNode) { case QUERY_NODE_SHOW_QNODES_STMT: case QUERY_NODE_SHOW_SNODES_STMT: case QUERY_NODE_SHOW_BNODES_STMT: + case QUERY_NODE_SHOW_ARBGROUPS_STMT: case QUERY_NODE_SHOW_CLUSTER_STMT: case QUERY_NODE_SHOW_DATABASES_STMT: case QUERY_NODE_SHOW_FUNCTIONS_STMT: @@ -1363,7 +1365,7 @@ void nodesDestroyNode(SNode* pNode) { nodesDestroyList(pPhyNode->pOnRight); nodesDestroyNode(pPhyNode->pFilterConditions); nodesDestroyList(pPhyNode->pTargets); - + nodesDestroyNode(pPhyNode->pPrimKeyCond); nodesDestroyNode(pPhyNode->pColEqCond); nodesDestroyNode(pPhyNode->pTagEqCond); @@ -1703,9 +1705,9 @@ void nodesListInsertListAfterPos(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc->pTail->pNext = pPos->pNext; pPos->pNext = pSrc->pHead; - + pTarget->length += pSrc->length; - nodesFree(pSrc); + nodesFree(pSrc); } SNode* nodesListGetNode(SNodeList* pList, int32_t index) { diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index ff1f95f754..6ad563ab62 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -108,6 +108,8 @@ SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pColumnName); SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral); +SNode* createRawValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral, SNode *pNode); +SNode* createRawValueNodeExt(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral, SNode *pLeft, SNode *pRight); SNodeList* createHintNodeList(SAstCreateContext* pCxt, const SToken* pLiteral); SNode* createIdentifierValueNode(SAstCreateContext* pCxt, SToken* pLiteral); SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral); @@ -194,7 +196,7 @@ SNode* setShowKind(SAstCreateContext* pCxt, SNode* pStmt, EShowKind showKind); SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type); SNode* createShowStmtWithCond(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbName, EOperatorType tableCondType); -SNode* createShowTablesStmt(SAstCreateContext* pCxt, SShowTablesOption option, SNode* pTbName, EOperatorType tableCondType); +SNode* createShowTablesStmt(SAstCreateContext* pCxt, SShowTablesOption option, SNode* pTbName, EOperatorType tableCondType); SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName); SNode* createShowAliveStmt(SAstCreateContext* pCxt, SNode* pDbName, ENodeType type); SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable); diff --git a/source/libs/parser/inc/parToken.h b/source/libs/parser/inc/parToken.h index 86bcc18fd5..87e9a82d2b 100644 --- a/source/libs/parser/inc/parToken.h +++ b/source/libs/parser/inc/parToken.h @@ -24,6 +24,15 @@ extern "C" { #include "ttokendef.h" +#define IS_TRUE_STR(s, n) \ + (n == 4 && (*(s) == 't' || *(s) == 'T') && (*((s) + 1) == 'r' || *((s) + 1) == 'R') && \ + (*((s) + 2) == 'u' || *((s) + 2) == 'U') && (*((s) + 3) == 'e' || *((s) + 3) == 'E')) + +#define IS_FALSE_STR(s, n) \ + (n == 5 && (*(s) == 'f' || *(s) == 'F') && (*((s) + 1) == 'a' || *((s) + 1) == 'A') && \ + (*((s) + 2) == 'l' || *((s) + 2) == 'L') && (*((s) + 3) == 's' || *((s) + 3) == 'S') && \ + (*((s) + 4) == 'e' || *((s) + 4) == 'E')) + // used to denote the minimum unite in sql parsing typedef struct SToken { uint32_t n; diff --git a/source/libs/parser/inc/parUtil.h b/source/libs/parser/inc/parUtil.h index 11a3a40a1e..b6170aaca6 100644 --- a/source/libs/parser/inc/parUtil.h +++ b/source/libs/parser/inc/parUtil.h @@ -23,6 +23,7 @@ extern "C" { #include "catalog.h" #include "os.h" #include "parser.h" +#include "parToken.h" #include "query.h" #define parserFatal(param, ...) qFatal("PARSER: " param, ##__VA_ARGS__) @@ -35,6 +36,45 @@ extern "C" { #define ROWTS_PSEUDO_COLUMN_NAME "_rowts" #define C0_PSEUDO_COLUMN_NAME "_c0" +#define IS_NOW_STR(s, n) \ + ((*(s) == 'n' || *(s) == 'N') && (*((s) + 1) == 'o' || *((s) + 1) == 'O') && \ + (*((s) + 2) == 'w' || *((s) + 2) == 'W') && (n == 3 || (n == 5 && *((s) + 3) == '(' && *((s) + 4) == ')'))) + +#define IS_TODAY_STR(s, n) \ + ((*(s) == 't' || *(s) == 'T') && (*((s) + 1) == 'o' || *((s) + 1) == 'O') && \ + (*((s) + 2) == 'd' || *((s) + 2) == 'D') && (*((s) + 3) == 'a' || *((s) + 3) == 'A') && \ + (*((s) + 4) == 'y' || *((s) + 4) == 'Y') && (n == 5 || (n == 7 && *((s) + 5) == '(' && *((s) + 6) == ')'))) + +#define IS_NULL_STR(s, n) \ + (n == 4 && (*(s) == 'N' || *(s) == 'n') && (*((s) + 1) == 'U' || *((s) + 1) == 'u') && \ + (*((s) + 2) == 'L' || *((s) + 2) == 'l') && (*((s) + 3) == 'L' || *((s) + 3) == 'l')) + +#define NEXT_TOKEN_WITH_PREV(pSql, token) \ + do { \ + int32_t index = 0; \ + token = tStrGetToken(pSql, &index, true, NULL); \ + pSql += index; \ + } while (0) + +#define NEXT_TOKEN_WITH_PREV_EXT(pSql, token, pIgnoreComma) \ + do { \ + int32_t index = 0; \ + token = tStrGetToken(pSql, &index, true, pIgnoreComma); \ + pSql += index; \ + } while (0) + +#define NEXT_TOKEN_KEEP_SQL(pSql, token, index) \ + do { \ + token = tStrGetToken(pSql, &index, false, NULL); \ + } while (0) + +#define NEXT_VALID_TOKEN(pSql, token) \ + do { \ + (token).n = tGetToken(pSql, &(token).type); \ + (token).z = (char*)pSql; \ + pSql += (token).n; \ + } while (TK_NK_SPACE == (token).type) + typedef struct SMsgBuf { int32_t len; char* buf; @@ -89,6 +129,9 @@ int32_t getTableTypeFromTableNode(SNode *pTable); int32_t trimString(const char* src, int32_t len, char* dst, int32_t dlen); int32_t getVnodeSysTableTargetName(int32_t acctId, SNode* pWhere, SName* pName); +int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, SMsgBuf* pMsgBuf, int8_t type); +int32_t parseTagValue(SMsgBuf* pMsgBuf, const char** pSql, uint8_t precision, SSchema* pTagSchema, SToken* pToken, + SArray* pTagName, SArray* pTagVals, STag** pTag); int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalogReq); int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMetaData, SParseMetaCache* pMetaCache); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 6f53a3d252..7a69866f0e 100755 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -354,7 +354,7 @@ alter_table_clause(A) ::= alter_table_clause(A) ::= full_table_name(B) RENAME TAG column_name(C) column_name(D). { A = createAlterTableRenameCol(pCxt, B, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &C, &D); } alter_table_clause(A) ::= - full_table_name(B) SET TAG column_name(C) NK_EQ signed_literal(D). { A = createAlterTableSetTag(pCxt, B, &C, D); } + full_table_name(B) SET TAG column_name(C) NK_EQ tags_literal(D). { A = createAlterTableSetTag(pCxt, B, &C, D); } %type multi_create_clause { SNodeList* } %destructor multi_create_clause { nodesDestroyList($$); } @@ -363,7 +363,7 @@ multi_create_clause(A) ::= multi_create_clause(B) create_subtable_clause(C). create_subtable_clause(A) ::= not_exists_opt(B) full_table_name(C) USING full_table_name(D) - specific_cols_opt(E) TAGS NK_LP expression_list(F) NK_RP table_options(G). { A = createCreateSubTableClause(pCxt, B, C, D, E, F, G); } + specific_cols_opt(E) TAGS NK_LP tags_literal_list(F) NK_RP table_options(G). { A = createCreateSubTableClause(pCxt, B, C, D, E, F, G); } %type multi_drop_clause { SNodeList* } %destructor multi_drop_clause { nodesDestroyList($$); } @@ -479,6 +479,7 @@ cmd ::= SHOW db_name_cond_opt(A) VGROUPS. cmd ::= SHOW MNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } //cmd ::= SHOW MODULES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT); } cmd ::= SHOW QNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } +cmd ::= SHOW ARBGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ARBGROUPS_STMT); } cmd ::= SHOW FUNCTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } cmd ::= SHOW INDEXES FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, B, A, OP_TYPE_EQUAL); } cmd ::= SHOW INDEXES FROM db_name(B) NK_DOT table_name(A). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &B), createIdentifierValueNode(pCxt, &A), OP_TYPE_EQUAL); } @@ -530,7 +531,7 @@ table_kind_db_name_cond_opt(A) ::= db_name(C) NK_DOT. table_kind_db_name_cond_opt(A) ::= table_kind(B) db_name(C) NK_DOT. { A.kind = B; A.dbName = C; } %type table_kind { EShowKind } -%destructor table_kind { } +%destructor table_kind { } table_kind(A) ::= NORMAL. { A = SHOW_KIND_TABLES_NORMAL; } table_kind(A) ::= CHILD. { A = SHOW_KIND_TABLES_CHILD; } @@ -755,6 +756,76 @@ insert_query(A) ::= INSERT INTO full_table_name(D) NK_LP col_name_list(B) NK_RP query_or_subquery(C). { A = createInsertStmt(pCxt, D, B, C); } insert_query(A) ::= INSERT INTO full_table_name(C) query_or_subquery(B). { A = createInsertStmt(pCxt, C, NULL, B); } +/************************************************ tags_literal *************************************************************/ +tags_literal(A) ::= NK_INTEGER(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B, NULL); } +tags_literal(A) ::= NK_PLUS(B) NK_INTEGER(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); + } +tags_literal(A) ::= NK_MINUS(B) NK_INTEGER(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); + } +tags_literal(A) ::= NK_FLOAT(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &B, NULL); } +tags_literal(A) ::= NK_PLUS(B) NK_FLOAT(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t, NULL); + } +tags_literal(A) ::= NK_MINUS(B) NK_FLOAT(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t, NULL); + } + +tags_literal(A) ::= NK_BIN(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B, NULL); } +tags_literal(A) ::= NK_PLUS(B) NK_BIN(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); + } +tags_literal(A) ::= NK_MINUS(B) NK_BIN(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); + } +tags_literal(A) ::= NK_HEX(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B, NULL); } +tags_literal(A) ::= NK_PLUS(B) NK_HEX(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); + } +tags_literal(A) ::= NK_MINUS(B) NK_HEX(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); + } + +tags_literal(A) ::= NK_STRING(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B, NULL); } +tags_literal(A) ::= NK_BOOL(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &B, NULL); } +tags_literal(A) ::= NULL(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_NULL, &B, NULL); } + +tags_literal(A) ::= literal_func(B). { A = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, NULL, B); } +tags_literal(A) ::= literal_func(B) NK_PLUS duration_literal(C). { + SToken l = getTokenFromRawExprNode(pCxt, B); + SToken r = getTokenFromRawExprNode(pCxt, C); + l.n = (r.z + r.n) - l.z; + A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, B, C); + } +tags_literal(A) ::= literal_func(B) NK_MINUS duration_literal(C). { + SToken l = getTokenFromRawExprNode(pCxt, B); + SToken r = getTokenFromRawExprNode(pCxt, C); + l.n = (r.z + r.n) - l.z; + A = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, B, C); + } + +%type tags_literal_list { SNodeList* } +%destructor tags_literal_list { nodesDestroyList($$); } +tags_literal_list(A) ::= tags_literal(B). { A = createNodeList(pCxt, B); } +tags_literal_list(A) ::= tags_literal_list(B) NK_COMMA tags_literal(C). { A = addNodeToList(pCxt, B, C); } + /************************************************ literal *************************************************************/ literal(A) ::= NK_INTEGER(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &B)); } literal(A) ::= NK_FLOAT(B). { A = createRawExprNode(pCxt, &B, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &B)); } @@ -935,6 +1006,7 @@ function_expression(A) ::= literal_func(B). literal_func(A) ::= noarg_func(B) NK_LP NK_RP(C). { A = createRawExprNodeExt(pCxt, &B, &C, createFunctionNode(pCxt, &B, NULL)); } literal_func(A) ::= NOW(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } +literal_func(A) ::= TODAY(B). { A = createRawExprNode(pCxt, &B, createFunctionNode(pCxt, &B, NULL)); } %type noarg_func { SToken } %destructor noarg_func { } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index b232fbd107..eee0eba78b 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -288,7 +288,7 @@ SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) { } else if (pRawExpr->isPseudoColumn) { // all pseudo column are translate to function with same name strcpy(pExpr->userAlias, ((SFunctionNode*)pExpr)->functionName); - strcpy(pExpr->aliasName, ((SFunctionNode*)pExpr)->functionName); + strcpy(pExpr->aliasName, ((SFunctionNode*)pExpr)->functionName); } else { int32_t len = TMIN(sizeof(pExpr->aliasName) - 1, pRawExpr->n); @@ -371,6 +371,80 @@ SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* return (SNode*)val; } +SNode* createRawValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral, SNode* pNode) { + CHECK_PARSER_STATUS(pCxt); + SValueNode* val = NULL; + + if (!(val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE))) { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY, "Out of memory"); + goto _exit; + } + if (pLiteral) { + val->literal = strndup(pLiteral->z, pLiteral->n); + } else if (pNode) { + SRawExprNode* pRawExpr = (SRawExprNode*)pNode; + if (!nodesIsExprNode(pRawExpr->pNode)) { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, pRawExpr->p); + goto _exit; + } + val->literal = strndup(pRawExpr->p, pRawExpr->n); + } else { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTERNAL_ERROR, "Invalid parameters"); + goto _exit; + } + if (!val->literal) { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY, "Out of memory"); + goto _exit; + } + + val->node.resType.type = dataType; + val->node.resType.bytes = IS_VAR_DATA_TYPE(dataType) ? strlen(val->literal) : tDataTypes[dataType].bytes; + if (TSDB_DATA_TYPE_TIMESTAMP == dataType) { + val->node.resType.precision = TSDB_TIME_PRECISION_MILLI; + } +_exit: + nodesDestroyNode(pNode); + if (pCxt->errCode != 0) { + nodesDestroyNode((SNode*)val); + return NULL; + } + return (SNode*)val; +} + +SNode* createRawValueNodeExt(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral, SNode* pLeft, + SNode* pRight) { + CHECK_PARSER_STATUS(pCxt); + SValueNode* val = NULL; + + if (!(val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE))) { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY, "Out of memory"); + goto _exit; + } + if (pLiteral) { + if (!(val->literal = strndup(pLiteral->z, pLiteral->n))) { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY, "Out of memory"); + goto _exit; + } + } else { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTERNAL_ERROR, "Invalid parameters"); + goto _exit; + } + + val->node.resType.type = dataType; + val->node.resType.bytes = IS_VAR_DATA_TYPE(dataType) ? strlen(val->literal) : tDataTypes[dataType].bytes; + if (TSDB_DATA_TYPE_TIMESTAMP == dataType) { + val->node.resType.precision = TSDB_TIME_PRECISION_MILLI; + } +_exit: + nodesDestroyNode(pLeft); + nodesDestroyNode(pRight); + if (pCxt->errCode != 0) { + nodesDestroyNode((SNode*)val); + return NULL; + } + return (SNode*)val; +} + static bool hasHint(SNodeList* pHintList, EHintOption hint) { if (!pHintList) return false; SNode* pNode; @@ -1115,11 +1189,11 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr return select; } -SNode* setSelectStmtTagMode(SAstCreateContext* pCxt, SNode* pStmt, bool bSelectTags) { +SNode* setSelectStmtTagMode(SAstCreateContext* pCxt, SNode* pStmt, bool bSelectTags) { if (pStmt && QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { if (pCxt->pQueryCxt->biMode) { ((SSelectStmt*)pStmt)->tagScan = true; - } else { + } else { ((SSelectStmt*)pStmt)->tagScan = bSelectTags; } } @@ -1189,6 +1263,7 @@ SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { pOptions->sstTrigger = TSDB_DEFAULT_SST_TRIGGER; pOptions->tablePrefix = TSDB_DEFAULT_HASH_PREFIX; pOptions->tableSuffix = TSDB_DEFAULT_HASH_SUFFIX; + pOptions->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR; return (SNode*)pOptions; } @@ -1224,6 +1299,7 @@ SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) { pOptions->sstTrigger = -1; pOptions->tablePrefix = -1; pOptions->tableSuffix = -1; + pOptions->withArbitrator = -1; return (SNode*)pOptions; } @@ -1279,6 +1355,7 @@ static SNode* setDatabaseOptionImpl(SAstCreateContext* pCxt, SNode* pOptions, ED break; case DB_OPTION_REPLICA: pDbOptions->replica = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); + pDbOptions->withArbitrator = (pDbOptions->replica == 2); if (!alter) { updateWalOptionsDefault(pDbOptions); } @@ -1709,7 +1786,7 @@ SNode* createShowCompactsStmt(SAstCreateContext* pCxt, ENodeType type) { SNode* setShowKind(SAstCreateContext* pCxt, SNode* pStmt, EShowKind showKind) { if (pStmt == NULL) { return NULL; - } + } SShowStmt* pShow = (SShowStmt*)pStmt; pShow->showKind = showKind; return pStmt; diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index 9b34672418..f746304730 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -72,9 +72,7 @@ int32_t parse(SParseContext* pParseCxt, SQuery** pQuery) { cxt.errCode = TSDB_CODE_PAR_SYNTAX_ERROR; goto abort_parse; } - case TK_NK_HEX: - case TK_NK_OCT: - case TK_NK_BIN: { + case TK_NK_OCT: { snprintf(cxt.pQueryCxt->pMsg, cxt.pQueryCxt->msgLen, "unsupported token: \"%s\"", t0.z); cxt.errCode = TSDB_CODE_PAR_SYNTAX_ERROR; goto abort_parse; @@ -172,7 +170,7 @@ static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, const c code = reserveUserAuthInCache(pCxt->pParseCxt->acctId, pCxt->pParseCxt->pEffectiveUser, pDb, pTable, authType, pCxt->pMetaCache); } -#endif +#endif if (TSDB_CODE_SUCCESS == code) { code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pDb, pCxt->pMetaCache); } @@ -461,6 +459,14 @@ static int32_t collectMetaKeyFromShowBnodes(SCollectMetaKeyCxt* pCxt, SShowStmt* return TSDB_CODE_SUCCESS; } +static int32_t collectMetaKeyFromShowArbGroups(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { + if (pCxt->pParseCxt->enableSysInfo) { + return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_ARBGROUPS, + pCxt->pMetaCache); + } + return TSDB_CODE_SUCCESS; +} + static int32_t collectMetaKeyFromShowCluster(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { if (pCxt->pParseCxt->enableSysInfo) { return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_CLUSTER, @@ -670,7 +676,7 @@ static int32_t collectMetaKeyFromShowCreateView(SCollectMetaKeyCxt* pCxt, SShowC if (TSDB_CODE_SUCCESS == code) { code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, pCxt->pMetaCache); } - + return code; } @@ -808,6 +814,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { return collectMetaKeyFromShowSnodes(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_BNODES_STMT: return collectMetaKeyFromShowBnodes(pCxt, (SShowStmt*)pStmt); + case QUERY_NODE_SHOW_ARBGROUPS_STMT: + return collectMetaKeyFromShowArbGroups(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_CLUSTER_STMT: return collectMetaKeyFromShowCluster(pCxt, (SShowStmt*)pStmt); case QUERY_NODE_SHOW_DATABASES_STMT: diff --git a/source/libs/parser/src/parAuthenticator.c b/source/libs/parser/src/parAuthenticator.c index 4f523bf4f2..dd04a5c36c 100644 --- a/source/libs/parser/src/parAuthenticator.c +++ b/source/libs/parser/src/parAuthenticator.c @@ -41,7 +41,7 @@ static void setUserAuthInfo(SParseContext* pCxt, const char* pDbName, const char } else { snprintf(pAuth->user, sizeof(pAuth->user), "%s", pCxt->pUser); } - + if (NULL == pTabName) { tNameSetDbName(&pAuth->tbName, pCxt->acctId, pDbName, strlen(pDbName)); } else { @@ -173,7 +173,7 @@ static EDealRes authSelectImpl(SNode* pNode, void* pContext) { isView = true; } taosMemoryFree(pTableMeta); -#endif +#endif if (!isView) { pAuthCxt->errCode = checkAuth(pAuthCxt, pTable->dbName, pTable->tableName, AUTH_TYPE_READ, &pTagCond); if (TSDB_CODE_SUCCESS != pAuthCxt->errCode && NULL != pAuthCxt->pParseCxt->pEffectiveUser) { @@ -355,6 +355,7 @@ static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) { case QUERY_NODE_SHOW_GRANTS_FULL_STMT: case QUERY_NODE_SHOW_GRANTS_LOGS_STMT: case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT: + case QUERY_NODE_SHOW_ARBGROUPS_STMT: return !pCxt->pParseCxt->enableSysInfo ? TSDB_CODE_PAR_PERMISSION_DENIED : TSDB_CODE_SUCCESS; case QUERY_NODE_SHOW_TABLES_STMT: case QUERY_NODE_SHOW_STABLES_STMT: diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index 4d62f71b72..77c63c38d8 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -20,32 +20,6 @@ #include "ttime.h" #include "geosWrapper.h" -#define NEXT_TOKEN_WITH_PREV(pSql, token) \ - do { \ - int32_t index = 0; \ - token = tStrGetToken(pSql, &index, true, NULL); \ - pSql += index; \ - } while (0) - -#define NEXT_TOKEN_WITH_PREV_EXT(pSql, token, pIgnoreComma) \ - do { \ - int32_t index = 0; \ - token = tStrGetToken(pSql, &index, true, pIgnoreComma); \ - pSql += index; \ - } while (0) - -#define NEXT_TOKEN_KEEP_SQL(pSql, token, index) \ - do { \ - token = tStrGetToken(pSql, &index, false, NULL); \ - } while (0) - -#define NEXT_VALID_TOKEN(pSql, token) \ - do { \ - (token).n = tGetToken(pSql, &(token).type); \ - (token).z = (char*)pSql; \ - pSql += (token).n; \ - } while (TK_NK_SPACE == (token).type) - typedef struct SInsertParseContext { SParseContext* pComCxt; SMsgBuf msg; @@ -63,13 +37,9 @@ typedef int32_t (*_row_append_fn_t)(SMsgBuf* pMsgBuf, const void* value, int32_t static uint8_t TRUE_VALUE = (uint8_t)TSDB_TRUE; static uint8_t FALSE_VALUE = (uint8_t)TSDB_FALSE; -static bool isNullStr(SToken* pToken) { - return ((pToken->type == TK_NK_STRING) && (strlen(TSDB_DATA_NULL_STR_L) == pToken->n) && - (strncasecmp(TSDB_DATA_NULL_STR_L, pToken->z, pToken->n) == 0)); -} - -static bool isNullValue(int8_t dataType, SToken* pToken) { - return TK_NULL == pToken->type || (!IS_STR_DATA_TYPE(dataType) && isNullStr(pToken)); +static FORCE_INLINE bool isNullValue(int8_t dataType, SToken* pToken) { + return TK_NULL == pToken->type || + (TK_NK_STRING == pToken->type && !IS_STR_DATA_TYPE(dataType) && IS_NULL_STR(pToken->z, pToken->n)); } static FORCE_INLINE int32_t toDouble(SToken* pToken, double* value, char** endPtr) { @@ -268,7 +238,8 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, const char** pSql, E return code; } -static int parseTimestampOrInterval(const char** end, SToken* pToken, int16_t timePrec, int64_t* ts, int64_t* interval, SMsgBuf* pMsgBuf, bool* isTs) { +static int parseTimestampOrInterval(const char** end, SToken* pToken, int16_t timePrec, int64_t* ts, int64_t* interval, + SMsgBuf* pMsgBuf, bool* isTs) { if (pToken->type == TK_NOW) { *isTs = true; *ts = taosGetTimestamp(timePrec); @@ -289,7 +260,21 @@ static int parseTimestampOrInterval(const char** end, SToken* pToken, int16_t ti } else { // parse the RFC-3339/ISO-8601 timestamp format string *isTs = true; if (taosParseTime(pToken->z, ts, pToken->n, timePrec, tsDaylight) != TSDB_CODE_SUCCESS) { - return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z); + if ((pToken->n == 0) || + (pToken->type != TK_NK_STRING && pToken->type != TK_NK_HEX && pToken->type != TK_NK_BIN)) { + return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z); + } + if (IS_NOW_STR(pToken->z, pToken->n)) { + *isTs = true; + *ts = taosGetTimestamp(timePrec); + } else if (IS_TODAY_STR(pToken->z, pToken->n)) { + *isTs = true; + *ts = taosGetTimestampToday(timePrec); + } else if (TSDB_CODE_SUCCESS == toIntegerPure(pToken->z, pToken->n, 10, ts)) { + *isTs = true; + } else { + return buildSyntaxErrMsg(pMsgBuf, "invalid timestamp format", pToken->z); + } } } @@ -313,10 +298,22 @@ static int parseTime(const char** end, SToken* pToken, int16_t timePrec, int64_t for (int k = pToken->n; pToken->z[k] != '\0'; k++) { if (pToken->z[k] == ' ' || pToken->z[k] == '\t') continue; - if (pToken->z[k] == '(' && pToken->z[k + 1] == ')') { // for insert NOW()/TODAY() - *end = pTokenEnd = &pToken->z[k + 2]; - k++; - continue; + if (pToken->z[k] == '(') { // for insert NOW()/TODAY() + if (pToken->z[k + 1] == ')') { + *end = pTokenEnd = &pToken->z[k + 2]; + ++k; + continue; + } else { + char nc = pToken->z[k + 1]; + while (nc == ' ' || nc == '\t' || nc == '\n' || nc == '\r' || nc == '\f') { + nc = pToken->z[(++k) + 1]; + } + if (nc == ')') { + *end = pTokenEnd = &pToken->z[k + 2]; + ++k; + continue; + } + } } if (pToken->z[k] == ',') { *end = pTokenEnd; @@ -491,10 +488,12 @@ static int32_t parseTagToken(const char** end, SToken* pToken, SSchema* pSchema, switch (pSchema->type) { case TSDB_DATA_TYPE_BOOL: { if ((pToken->type == TK_NK_BOOL || pToken->type == TK_NK_STRING) && (pToken->n != 0)) { - if (strncmp(pToken->z, "true", pToken->n) == 0) { + if (IS_TRUE_STR(pToken->z, pToken->n)) { *(int8_t*)(&val->i64) = TRUE_VALUE; - } else if (strncmp(pToken->z, "false", pToken->n) == 0) { + } else if (IS_FALSE_STR(pToken->z, pToken->n)) { *(int8_t*)(&val->i64) = FALSE_VALUE; + } else if (TSDB_CODE_SUCCESS == toDoubleEx(pToken->z, pToken->n, pToken->type, (double*)&iv)) { + *(int8_t*)(&val->i64) = (*(double*)&iv == 0 ? FALSE_VALUE : TRUE_VALUE); } else { return buildSyntaxErrMsg(pMsgBuf, "invalid bool data", pToken->z); } @@ -502,6 +501,9 @@ static int32_t parseTagToken(const char** end, SToken* pToken, SSchema* pSchema, *(int8_t*)(&val->i64) = ((taosStr2Int64(pToken->z, NULL, 10) == 0) ? FALSE_VALUE : TRUE_VALUE); } else if (pToken->type == TK_NK_FLOAT) { *(int8_t*)(&val->i64) = ((taosStr2Double(pToken->z, NULL) == 0) ? FALSE_VALUE : TRUE_VALUE); + } else if ((pToken->type == TK_NK_HEX || pToken->type == TK_NK_BIN) && + (TSDB_CODE_SUCCESS == toDoubleEx(pToken->z, pToken->n, pToken->type, (double*)&iv))) { + *(int8_t*)(&val->i64) = (*(double*)&iv == 0 ? FALSE_VALUE : TRUE_VALUE); } else { return buildSyntaxErrMsg(pMsgBuf, "invalid bool data", pToken->z); } @@ -709,30 +711,29 @@ static int32_t parseBoundTagsClause(SInsertParseContext* pCxt, SVnodeModifyOpStm return parseBoundColumns(pCxt, &pStmt->pSql, BOUND_TAGS, pStmt->pTableMeta, &pCxt->tags); } -static int32_t parseTagValue(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt, const char** ppSql, SSchema* pTagSchema, SToken* pToken, - SArray* pTagName, SArray* pTagVals, STag** pTag) { +int32_t parseTagValue(SMsgBuf* pMsgBuf, const char** pSql, uint8_t precision, SSchema* pTagSchema, SToken* pToken, + SArray* pTagName, SArray* pTagVals, STag** pTag) { bool isNull = isNullValue(pTagSchema->type, pToken); - if (!isNull) { + if (!isNull && pTagName) { taosArrayPush(pTagName, pTagSchema->name); } if (pTagSchema->type == TSDB_DATA_TYPE_JSON) { if (pToken->n > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { - return buildSyntaxErrMsg(&pCxt->msg, "json string too long than 4095", pToken->z); + return buildSyntaxErrMsg(pMsgBuf, "json string too long than 4095", pToken->z); } if (isNull) { return tTagNew(pTagVals, 1, true, pTag); } else { - return parseJsontoTagData(pToken->z, pTagVals, pTag, &pCxt->msg); + return parseJsontoTagData(pToken->z, pTagVals, pTag, pMsgBuf); } } if (isNull) return 0; STagVal val = {0}; - int32_t code = - parseTagToken(ppSql, pToken, pTagSchema, pStmt->pTableMeta->tableInfo.precision, &val, &pCxt->msg); + int32_t code = parseTagToken(pSql, pToken, pTagSchema, precision, &val, pMsgBuf); if (TSDB_CODE_SUCCESS == code) { taosArrayPush(pTagVals, &val); } @@ -755,7 +756,7 @@ static int32_t buildCreateTbReq(SVnodeModifyOpStmt* pStmt, STag* pTag, SArray* p return TSDB_CODE_SUCCESS; } -static int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, SMsgBuf* pMsgBuf, int8_t type) { +int32_t checkAndTrimValue(SToken* pToken, char* tmpTokenBuf, SMsgBuf* pMsgBuf, int8_t type) { if ((pToken->type != TK_NOW && pToken->type != TK_TODAY && pToken->type != TK_NK_INTEGER && pToken->type != TK_NK_STRING && pToken->type != TK_NK_FLOAT && pToken->type != TK_NK_BOOL && pToken->type != TK_NULL && pToken->type != TK_NK_HEX && pToken->type != TK_NK_OCT && @@ -911,12 +912,20 @@ static int32_t checkSubtablePrivilege(SArray* pTagVals, SArray* pTagName, SNode* static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStmt) { int32_t code = TSDB_CODE_SUCCESS; SSchema* pSchema = getTableTagSchema(pStmt->pTableMeta); - SArray* pTagVals = taosArrayInit(pCxt->tags.numOfBound, sizeof(STagVal)); - SArray* pTagName = taosArrayInit(8, TSDB_COL_NAME_LEN); + SArray* pTagVals = NULL; + SArray* pTagName = NULL; + uint8_t precision = pStmt->pTableMeta->tableInfo.precision; SToken token; bool isParseBindParam = false; bool isJson = false; STag* pTag = NULL; + + if (!(pTagVals = taosArrayInit(pCxt->tags.numOfBound, sizeof(STagVal))) || + !(pTagName = taosArrayInit(pCxt->tags.numOfBound, TSDB_COL_NAME_LEN))) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + for (int i = 0; TSDB_CODE_SUCCESS == code && i < pCxt->tags.numOfBound; ++i) { NEXT_TOKEN_WITH_PREV(pStmt->pSql, token); @@ -938,11 +947,11 @@ static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt SSchema* pTagSchema = &pSchema[pCxt->tags.pColIndex[i]]; isJson = pTagSchema->type == TSDB_DATA_TYPE_JSON; code = checkAndTrimValue(&token, pCxt->tmpTokenBuf, &pCxt->msg, pTagSchema->type); - if (TK_NK_VARIABLE == token.type) { + if (TSDB_CODE_SUCCESS == code && TK_NK_VARIABLE == token.type) { code = buildSyntaxErrMsg(&pCxt->msg, "not expected tags values ", token.z); } if (TSDB_CODE_SUCCESS == code) { - code = parseTagValue(pCxt, pStmt, &pStmt->pSql, pTagSchema, &token, pTagName, pTagVals, &pTag); + code = parseTagValue(&pCxt->msg, &pStmt->pSql, precision, pTagSchema, &token, pTagName, pTagVals, &pTag); } } @@ -959,8 +968,9 @@ static int32_t parseTagsClauseImpl(SInsertParseContext* pCxt, SVnodeModifyOpStmt pTag = NULL; } - for (int i = 0; i < taosArrayGetSize(pTagVals); ++i) { - STagVal* p = (STagVal*)taosArrayGet(pTagVals, i); +_exit: + for (int32_t i = 0; i < taosArrayGetSize(pTagVals); ++i) { + STagVal* p = (STagVal*)TARRAY_GET_ELEM(pTagVals, i); if (IS_VAR_DATA_TYPE(p->type)) { taosMemoryFreeClear(p->pData); } @@ -1425,10 +1435,12 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql, switch (pSchema->type) { case TSDB_DATA_TYPE_BOOL: { if ((pToken->type == TK_NK_BOOL || pToken->type == TK_NK_STRING) && (pToken->n != 0)) { - if (strncmp(pToken->z, "true", pToken->n) == 0) { + if (IS_TRUE_STR(pToken->z, pToken->n)) { pVal->value.val = TRUE_VALUE; - } else if (strncmp(pToken->z, "false", pToken->n) == 0) { + } else if (IS_FALSE_STR(pToken->z, pToken->n)) { pVal->value.val = FALSE_VALUE; + } else if (TSDB_CODE_SUCCESS == toDoubleEx(pToken->z, pToken->n, pToken->type, (double*)&pVal->value.val)) { + *(int8_t*)(&pVal->value.val) = (*(double*)&pVal->value.val == 0 ? FALSE_VALUE : TRUE_VALUE); } else { return buildSyntaxErrMsg(&pCxt->msg, "invalid bool data", pToken->z); } @@ -1436,6 +1448,9 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql, pVal->value.val = ((taosStr2Int64(pToken->z, NULL, 10) == 0) ? FALSE_VALUE : TRUE_VALUE); } else if (pToken->type == TK_NK_FLOAT) { pVal->value.val = ((taosStr2Double(pToken->z, NULL) == 0) ? FALSE_VALUE : TRUE_VALUE); + } else if ((pToken->type == TK_NK_HEX || pToken->type == TK_NK_BIN) && + (TSDB_CODE_SUCCESS == toDoubleEx(pToken->z, pToken->n, pToken->type, (double*)&pVal->value.val))) { + *(int8_t*)(&pVal->value.val) = (*(double*)&pVal->value.val == 0 ? FALSE_VALUE : TRUE_VALUE); } else { return buildSyntaxErrMsg(&pCxt->msg, "invalid bool data", pToken->z); } @@ -1510,7 +1525,7 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql, break; } case TSDB_DATA_TYPE_FLOAT: { - double dv; + double dv; int32_t code = toDoubleEx(pToken->z, pToken->n, pToken->type, &dv); if (TSDB_CODE_SUCCESS != code) { return buildSyntaxErrMsg(&pCxt->msg, "illegal float data", pToken->z); @@ -1523,7 +1538,7 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql, break; } case TSDB_DATA_TYPE_DOUBLE: { - double dv; + double dv; int32_t code = toDoubleEx(pToken->z, pToken->n, pToken->type, &dv); if (TSDB_CODE_SUCCESS != code) { return buildSyntaxErrMsg(&pCxt->msg, "illegal float data", pToken->z); @@ -1549,7 +1564,7 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql, } case TSDB_DATA_TYPE_VARBINARY: { int32_t code = parseVarbinary(pToken, &pVal->value.pData, &pVal->value.nData, pSchema->bytes); - if(code != TSDB_CODE_SUCCESS){ + if (code != TSDB_CODE_SUCCESS) { return generateSyntaxErrMsg(&pCxt->msg, code, pSchema->name); } break; @@ -1587,9 +1602,9 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql, break; } case TSDB_DATA_TYPE_GEOMETRY: { - int32_t code = TSDB_CODE_FAILED; - unsigned char *output = NULL; - size_t size = 0; + int32_t code = TSDB_CODE_FAILED; + unsigned char* output = NULL; + size_t size = 0; code = parseGeometry(pToken, &output, &size); if (code != TSDB_CODE_SUCCESS) { @@ -1598,13 +1613,11 @@ static int32_t parseValueTokenImpl(SInsertParseContext* pCxt, const char** pSql, // Too long values will raise the invalid sql error message else if (size + VARSTR_HEADER_SIZE > pSchema->bytes) { code = generateSyntaxErrMsg(&pCxt->msg, TSDB_CODE_PAR_VALUE_TOO_LONG, pSchema->name); - } - else { + } else { pVal->value.pData = taosMemoryMalloc(size); if (NULL == pVal->value.pData) { code = TSDB_CODE_OUT_OF_MEMORY; - } - else { + } else { memcpy(pVal->value.pData, output, size); pVal->value.nData = size; } @@ -1639,18 +1652,14 @@ static int32_t parseValueToken(SInsertParseContext* pCxt, const char** pSql, STo return buildSyntaxErrMsg(&pCxt->msg, "primary timestamp should not be null", pToken->z); } - if (TK_NK_VARIABLE == pToken->type && pSchema->type != TSDB_DATA_TYPE_TIMESTAMP) { - return buildSyntaxErrMsg(&pCxt->msg, "invalid values", pToken->z); - } pVal->flag = CV_FLAG_NULL; return TSDB_CODE_SUCCESS; } - if (TSDB_CODE_SUCCESS == code && IS_NUMERIC_TYPE(pSchema->type) && pToken->n == 0) { - return buildSyntaxErrMsg(&pCxt->msg, "invalid numeric data", pToken->z); - } - if (TSDB_CODE_SUCCESS == code) { + if (pToken->n == 0 && IS_NUMERIC_TYPE(pSchema->type)) { + return buildSyntaxErrMsg(&pCxt->msg, "invalid numeric data", pToken->z); + } code = parseValueTokenImpl(pCxt, pSql, pToken, pSchema, timePrec, pVal); } @@ -1728,18 +1737,19 @@ static int32_t processCtbTagsAfterCtbName(SInsertParseContext* pCxt, SVnodeModif const SToken* tagTokens, SSchema* const* tagSchemas, int numOfTagTokens) { int32_t code = TSDB_CODE_SUCCESS; + uint8_t precision = pStmt->pTableMeta->tableInfo.precision; if (code == TSDB_CODE_SUCCESS && ctbFirst) { for (int32_t i = 0; code == TSDB_CODE_SUCCESS && i < numOfTagTokens; ++i) { SToken* pTagToken = (SToken*)(tagTokens + i); SSchema* pTagSchema = tagSchemas[i]; code = checkAndTrimValue(pTagToken, pCxt->tmpTokenBuf, &pCxt->msg, pTagSchema->type); - if (TK_NK_VARIABLE == pTagToken->type) { + if (code == TSDB_CODE_SUCCESS && TK_NK_VARIABLE == pTagToken->type) { code = buildInvalidOperationMsg(&pCxt->msg, "not expected tag"); } if (code == TSDB_CODE_SUCCESS) { - code = parseTagValue(pCxt, pStmt, NULL, pTagSchema, pTagToken, pStbRowsCxt->aTagNames, pStbRowsCxt->aTagVals, + code = parseTagValue(&pCxt->msg, NULL, precision, pTagSchema, pTagToken, pStbRowsCxt->aTagNames, pStbRowsCxt->aTagVals, &pStbRowsCxt->pTag); } } @@ -1759,11 +1769,12 @@ static int32_t doGetStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt* const SBoundColInfo* pCols, const SSchema* pSchemas, SToken* tagTokens, SSchema** tagSchemas, int* pNumOfTagTokens, bool* bFoundTbName) { int32_t code = TSDB_CODE_SUCCESS; - SArray* pTagNames = pStbRowsCxt->aTagNames; - SArray* pTagVals = pStbRowsCxt->aTagVals; - bool canParseTagsAfter = !pStbRowsCxt->pTagCond && !pStbRowsCxt->hasTimestampTag; + SArray* pTagNames = pStbRowsCxt->aTagNames; + SArray* pTagVals = pStbRowsCxt->aTagVals; + bool canParseTagsAfter = !pStbRowsCxt->pTagCond && !pStbRowsCxt->hasTimestampTag; int32_t numOfCols = getNumOfColumns(pStbRowsCxt->pStbMeta); int32_t tbnameIdx = getTbnameSchemaIndex(pStbRowsCxt->pStbMeta); + uint8_t precision = getTableInfo(pStbRowsCxt->pStbMeta).precision; for (int i = 0; i < pCols->numOfBound && (code) == TSDB_CODE_SUCCESS; ++i) { const char* pTmpSql = *ppSql; bool ignoreComma = false; @@ -1781,7 +1792,7 @@ static int32_t doGetStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt* if (pCols->pColIndex[i] < numOfCols) { const SSchema* pSchema = &pSchemas[pCols->pColIndex[i]]; SColVal* pVal = taosArrayGet(pStbRowsCxt->aColVals, pCols->pColIndex[i]); - code = parseValueToken(pCxt, ppSql, pToken, (SSchema*)pSchema, getTableInfo(pStbRowsCxt->pStbMeta).precision, pVal); + code = parseValueToken(pCxt, ppSql, pToken, (SSchema*)pSchema, precision, pVal); if (TK_NK_VARIABLE == pToken->type) { code = buildInvalidOperationMsg(&pCxt->msg, "not expected row value"); } @@ -1793,11 +1804,11 @@ static int32_t doGetStbRowValues(SInsertParseContext* pCxt, SVnodeModifyOpStmt* ++(*pNumOfTagTokens); } else { code = checkAndTrimValue(pToken, pCxt->tmpTokenBuf, &pCxt->msg, pTagSchema->type); - if (TK_NK_VARIABLE == pToken->type) { + if (code == TSDB_CODE_SUCCESS && TK_NK_VARIABLE == pToken->type) { code = buildInvalidOperationMsg(&pCxt->msg, "not expected row value"); } if (code == TSDB_CODE_SUCCESS) { - code = parseTagValue(pCxt, pStmt, ppSql, (SSchema*)pTagSchema, pToken, pTagNames, pTagVals, &pStbRowsCxt->pTag); + code = parseTagValue(&pCxt->msg, ppSql, precision, (SSchema*)pTagSchema, pToken, pTagNames, pTagVals, &pStbRowsCxt->pTag); } } } diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 69a0f66c16..3a2d200d31 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -306,6 +306,7 @@ static SKeyword keywordTable[] = { {"ALIVE", TK_ALIVE}, {"VARBINARY", TK_VARBINARY}, {"KEEP_TIME_OFFSET", TK_KEEP_TIME_OFFSET}, + {"ARBGROUPS", TK_ARBGROUPS}, }; // clang-format on @@ -659,7 +660,7 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) { *tokenId = TK_NK_ALIAS; // must be alias return i; } - if ((i == 4 && strncasecmp(z, "true", 4) == 0) || (i == 5 && strncasecmp(z, "false", 5) == 0)) { + if (IS_TRUE_STR(z, i) || IS_FALSE_STR(z, i)) { *tokenId = TK_NK_BOOL; return i; } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index f2285d57fd..14a12b8893 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -100,6 +100,13 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = { .numOfShowCols = 1, .pShowCols = {"*"} }, + { + .showType = QUERY_NODE_SHOW_ARBGROUPS_STMT, + .pDbName = TSDB_INFORMATION_SCHEMA_DB, + .pTableName = TSDB_INS_TABLE_ARBGROUPS, + .numOfShowCols = 1, + .pShowCols = {"*"} + }, { .showType = QUERY_NODE_SHOW_CLUSTER_STMT, .pDbName = TSDB_INFORMATION_SCHEMA_DB, @@ -263,7 +270,7 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = { .pTableName = TSDB_INS_TABLE_COMPACTS, .numOfShowCols = 1, .pShowCols = {"*"} - }, + }, { .showType = QUERY_NODE_SHOW_COMPACT_DETAILS_STMT, .pDbName = TSDB_INFORMATION_SCHEMA_DB, .pTableName = TSDB_INS_TABLE_COMPACT_DETAILS, @@ -380,7 +387,7 @@ static int32_t getViewMetaImpl(SParseContext* pParCxt, SParseMetaCache* pMetaCac #endif int32_t code = TSDB_CODE_SUCCESS; - + if (pParCxt->async) { code = getViewMetaFromCache(pMetaCache, pName, pMeta); } else { @@ -390,7 +397,7 @@ static int32_t getViewMetaImpl(SParseContext* pParCxt, SParseMetaCache* pMetaCac .mgmtEps = pParCxt->mgmtEpSet}; code = catalogGetViewMeta(pParCxt->pCatalog, &conn, pName, pMeta); } - + if (TSDB_CODE_SUCCESS != code && TSDB_CODE_PAR_TABLE_NOT_EXIST != code) { parserError("0x%" PRIx64 " catalogGetViewMeta error, code:%s, dbName:%s, viewName:%s", pParCxt->requestId, tstrerror(code), pName->dbname, pName->tname); @@ -401,7 +408,7 @@ static int32_t getViewMetaImpl(SParseContext* pParCxt, SParseMetaCache* pMetaCac int32_t getTargetMetaImpl(SParseContext* pParCxt, SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta, bool couldBeView) { int32_t code = TSDB_CODE_SUCCESS; - + if (pParCxt->async) { code = getTableMetaFromCache(pMetaCache, pName, pMeta); #ifdef TD_ENTERPRISE @@ -420,7 +427,7 @@ int32_t getTargetMetaImpl(SParseContext* pParCxt, SParseMetaCache* pMetaCache, c .mgmtEps = pParCxt->mgmtEpSet}; code = catalogGetTableMeta(pParCxt->pCatalog, &conn, pName, pMeta); } - + if (TSDB_CODE_SUCCESS != code && TSDB_CODE_PAR_TABLE_NOT_EXIST != code) { parserError("0x%" PRIx64 " catalogGetTableMeta error, code:%s, dbName:%s, tbName:%s", pParCxt->requestId, tstrerror(code), pName->dbname, pName->tname); @@ -960,7 +967,7 @@ static void setColumnInfoByExpr(STempTableNode* pTable, SExprNode* pExpr, SColum assNode.pPlace = (SNode**)pColRef; assNode.pAssociationNode = (SNode*)*pColRef; taosArrayPush(pExpr->pAssociation, &assNode); - + strcpy(pCol->tableAlias, pTable->table.tableAlias); pCol->colId = isPrimaryKey(pTable, (SNode*)pExpr) ? PRIMARYKEY_TIMESTAMP_COL_ID : 0; strcpy(pCol->colName, pExpr->aliasName); @@ -1177,8 +1184,8 @@ static SNode* biMakeTbnameProjectAstNode(char* funcName, char* tableAlias) { if (valNode != NULL) { nodesListMakeAppend(&tbNameFunc->pParameterList, (SNode*)valNode); } - snprintf(tbNameFunc->node.userAlias, sizeof(tbNameFunc->node.userAlias), - (tableAlias)? "%s.tbname" : "%stbname", + snprintf(tbNameFunc->node.userAlias, sizeof(tbNameFunc->node.userAlias), + (tableAlias)? "%s.tbname" : "%stbname", (tableAlias)? tableAlias : ""); strncpy(tbNameFunc->node.aliasName, tbNameFunc->functionName, TSDB_COL_NAME_LEN); @@ -1190,13 +1197,13 @@ static SNode* biMakeTbnameProjectAstNode(char* funcName, char* tableAlias) { nodesListMakeAppend(&multiResFunc->pParameterList, (SNode*)tbNameFunc); if (tsKeepColumnName) { - snprintf(multiResFunc->node.userAlias, sizeof(tbNameFunc->node.userAlias), - (tableAlias)? "%s.tbname" : "%stbname", + snprintf(multiResFunc->node.userAlias, sizeof(tbNameFunc->node.userAlias), + (tableAlias)? "%s.tbname" : "%stbname", (tableAlias)? tableAlias : ""); strcpy(multiResFunc->node.aliasName, tbNameFunc->functionName); } else { - snprintf(multiResFunc->node.userAlias, sizeof(multiResFunc->node.userAlias), - tableAlias? "%s(%s.tbname)" : "%s(%stbname)", funcName, + snprintf(multiResFunc->node.userAlias, sizeof(multiResFunc->node.userAlias), + tableAlias? "%s(%s.tbname)" : "%s(%stbname)", funcName, tableAlias? tableAlias: ""); biMakeAliasNameInMD5(multiResFunc->node.userAlias, strlen(multiResFunc->node.userAlias), multiResFunc->node.aliasName); } @@ -1209,7 +1216,7 @@ static int32_t biRewriteSelectFuncParamStar(STranslateContext* pCxt, SSelectStmt SNodeList* pTbnameNodeList = nodesMakeList(); SFunctionNode* pFunc = (SFunctionNode*)pNode; - if (strcasecmp(pFunc->functionName, "last") == 0 || + if (strcasecmp(pFunc->functionName, "last") == 0 || strcasecmp(pFunc->functionName, "last_row") == 0 || strcasecmp(pFunc->functionName, "first") == 0) { SNodeList* pParams = pFunc->pParameterList; @@ -1259,8 +1266,8 @@ int32_t biRewriteSelectStar(STranslateContext* pCxt, SSelectStmt* pSelect) { size_t n = taosArrayGetSize(pTables); for (int32_t i = 0; i < n; ++i) { STableNode* pTable = taosArrayGetP(pTables, i); - if (nodeType(pTable) == QUERY_NODE_REAL_TABLE && - ((SRealTableNode*)pTable)->pMeta != NULL && + if (nodeType(pTable) == QUERY_NODE_REAL_TABLE && + ((SRealTableNode*)pTable)->pMeta != NULL && ((SRealTableNode*)pTable)->pMeta->tableType == TSDB_SUPER_TABLE) { SNode* pTbnameNode = biMakeTbnameProjectAstNode(NULL, NULL); nodesListAppend(pTbnameNodeList, pTbnameNode); @@ -1273,9 +1280,9 @@ int32_t biRewriteSelectStar(STranslateContext* pCxt, SSelectStmt* pSelect) { char* pTableAlias = ((SColumnNode*)pNode)->tableAlias; STableNode* pTable = NULL; int32_t code = findTable(pCxt, pTableAlias, &pTable); - if (TSDB_CODE_SUCCESS == code && + if (TSDB_CODE_SUCCESS == code && nodeType(pTable) == QUERY_NODE_REAL_TABLE && - ((SRealTableNode*)pTable)->pMeta != NULL && + ((SRealTableNode*)pTable)->pMeta != NULL && ((SRealTableNode*)pTable)->pMeta->tableType == TSDB_SUPER_TABLE) { SNode* pTbnameNode = biMakeTbnameProjectAstNode(NULL, pTableAlias); nodesListAppend(pTbnameNodeList, pTbnameNode); @@ -1527,12 +1534,13 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal, void* data = NULL; uint32_t size = 0; - bool isHexChar = isHex(pVal->literal, strlen(pVal->literal)); + uint32_t vlen = strlen(pVal->literal); + bool isHexChar = isHex(pVal->literal, vlen); if (isHexChar) { - if (!isValidateHex(pVal->literal, strlen(pVal->literal))) { + if (!isValidateHex(pVal->literal, vlen)) { return TSDB_CODE_PAR_INVALID_VARBINARY; } - if (taosHex2Ascii(pVal->literal, strlen(pVal->literal), &data, &size) < 0) { + if (taosHex2Ascii(pVal->literal, vlen, &data, &size) < 0) { return TSDB_CODE_OUT_OF_MEMORY; } } else { @@ -1556,14 +1564,15 @@ static EDealRes translateNormalValue(STranslateContext* pCxt, SValueNode* pVal, } case TSDB_DATA_TYPE_VARCHAR: case TSDB_DATA_TYPE_GEOMETRY: { - if (strict && (pVal->node.resType.bytes > targetDt.bytes - VARSTR_HEADER_SIZE)) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal); + int32_t vlen = IS_VAR_DATA_TYPE(pVal->node.resType.type) ? pVal->node.resType.bytes : strlen(pVal->literal); + if (strict && (vlen > targetDt.bytes - VARSTR_HEADER_SIZE)) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_VALUE_TOO_LONG, pVal->literal); } - pVal->datum.p = taosMemoryCalloc(1, targetDt.bytes + 1); + int32_t len = TMIN(targetDt.bytes - VARSTR_HEADER_SIZE, vlen); + pVal->datum.p = taosMemoryCalloc(1, len + VARSTR_HEADER_SIZE + 1); if (NULL == pVal->datum.p) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_OUT_OF_MEMORY); } - int32_t len = TMIN(targetDt.bytes - VARSTR_HEADER_SIZE, pVal->node.resType.bytes); varDataSetLen(pVal->datum.p, len); strncpy(varDataVal(pVal->datum.p), pVal->literal, len); break; @@ -1965,7 +1974,7 @@ static int32_t translateInterpPseudoColumnFunc(STranslateContext* pCxt, SNode** return code; } translateColumn(pCxt, (SColumnNode**)ppNode); - return pCxt->errCode; + return pCxt->errCode; } return TSDB_CODE_SUCCESS; } @@ -2270,7 +2279,7 @@ static int32_t replacePsedudoColumnFuncWithColumn(STranslateContext* pCxt, SNode nodesDestroyNode(*ppNode); *ppNode = (SNode*)pCol; - return TSDB_CODE_SUCCESS; + return TSDB_CODE_SUCCESS; } } pCol->node.resType = pOldExpr->resType; @@ -2294,14 +2303,14 @@ static int32_t rewriteToColumnAndRetranslate(STranslateContext* pCxt, SNode** pp return generateSyntaxErrMsg(&pCxt->msgBuf, errCode); } else { return TSDB_CODE_SUCCESS; - } + } } static int32_t translateWindowPseudoColumnFunc(STranslateContext* pCxt, SNode** ppNode, bool* pRewriteToColumn) { SFunctionNode* pFunc = (SFunctionNode*)(*ppNode); if (!fmIsWindowPseudoColumnFunc(pFunc->funcId)) { return TSDB_CODE_SUCCESS; - } + } if (!isSelectStmt(pCxt->pCurrStmt)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_WINDOW_PC); } @@ -2335,7 +2344,7 @@ static int32_t translateScanPseudoColumnFunc(STranslateContext* pCxt, SNode** pp pCxt->errCode = findTable(pCxt, pVal->literal, &pTable); if (TSDB_CODE_SUCCESS != pCxt->errCode || (NULL == pTable)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TBNAME); - } + } if (nodeType(pTable) != QUERY_NODE_REAL_TABLE) { *pRewriteToColumn = true; return rewriteToColumnAndRetranslate(pCxt, ppNode, TSDB_CODE_PAR_INVALID_TBNAME); @@ -2830,7 +2839,7 @@ static int32_t checkAggColCoexist(STranslateContext* pCxt, SSelectStmt* pSelect) if (!pSelect->isDistinct) { nodesRewriteExprs(pSelect->pOrderByList, doCheckAggColCoexist, &cxt); } - if (((!cxt.existCol && 0 < pSelect->selectFuncNum) || (cxt.existCol && 1 == pSelect->selectFuncNum) ) + if (((!cxt.existCol && 0 < pSelect->selectFuncNum) || (cxt.existCol && 1 == pSelect->selectFuncNum) ) && !pSelect->hasOtherVectorFunc) { return rewriteColsToSelectValFunc(pCxt, pSelect); } @@ -4375,7 +4384,7 @@ static bool findEqCondTbNameInOperatorNode(STranslateContext* pCxt, SNode* pWher } else { code = findTable(pCxt, pTableAlias, &pTable); } - if (code == TSDB_CODE_SUCCESS && nodeType(pTable) == QUERY_NODE_REAL_TABLE && + if (code == TSDB_CODE_SUCCESS && nodeType(pTable) == QUERY_NODE_REAL_TABLE && ((SRealTableNode*)pTable)->pMeta && ((SRealTableNode*)pTable)->pMeta->tableType == TSDB_SUPER_TABLE) { pInfo->pRealTable = (SRealTableNode*)pTable; return true; @@ -4411,7 +4420,7 @@ static void findEqualCondTbnameInLogicCondAnd(STranslateContext* pCxt, SNode* pW } } } - //TODO: logic cond + //TODO: logic cond } } @@ -4531,7 +4540,7 @@ static int32_t setEqualTbnameTableVgroups(STranslateContext* pCxt, SSelectStmt* pInfo->pRealTable->pVgroupList = vgsInfo; } else { taosMemoryFree(vgsInfo); - } + } } return TSDB_CODE_SUCCESS; } @@ -5109,7 +5118,7 @@ static int32_t translateInsertTable(STranslateContext* pCxt, SNode** pTable) { if (TSDB_CODE_SUCCESS == code && TSDB_CHILD_TABLE != ((SRealTableNode*)*pTable)->pMeta->tableType && TSDB_NORMAL_TABLE != ((SRealTableNode*)*pTable)->pMeta->tableType) { code = buildInvalidOperationMsg(&pCxt->msgBuf, "insert data into super table is not supported"); - + } return code; } @@ -5206,6 +5215,7 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS pReq->tsdbPageSize = pStmt->pOptions->tsdbPageSize; pReq->keepTimeOffset = pStmt->pOptions->keepTimeOffset; pReq->ignoreExist = pStmt->ignoreExists; + pReq->withArbitrator = pStmt->pOptions->withArbitrator; return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq); } @@ -5443,7 +5453,7 @@ static int32_t checkDbRetentionsOption(STranslateContext* pCxt, SNodeList* pRete "Invalid option retentions(freq/keep): %s should larger than %s", pKeep->literal, pFreq->literal); } - + if (NULL != pPrevFreq && pPrevFreq->datum.i >= pFreq->datum.i) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION, "Invalid option retentions(freq): %s should larger than %s", pFreq->literal, @@ -5507,6 +5517,12 @@ static int32_t checkOptionsDependency(STranslateContext* pCxt, const char* pDbNa return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION, "Invalid duration value, should be keep2 >= keep1 >= keep0 >= 3 * duration"); } + + if ((pOptions->replica == 2) ^ (pOptions->withArbitrator == TSDB_MAX_DB_WITH_ARBITRATOR)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DB_OPTION, + "Invalid database option, with_arbitrator should be used with replica 2"); + } + return TSDB_CODE_SUCCESS; } @@ -5559,7 +5575,7 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName TSDB_MAX_TSDB_PAGESIZE); } if (TSDB_CODE_SUCCESS == code) { - code = checkDbEnumOption(pCxt, "replications", pOptions->replica, TSDB_MIN_DB_REPLICA, TSDB_MAX_DB_REPLICA); + code = checkDbRangeOption(pCxt, "replications", pOptions->replica, TSDB_MIN_DB_REPLICA, TSDB_MAX_DB_REPLICA); } if (TSDB_CODE_SUCCESS == code) { code = checkDbStrictOption(pCxt, pOptions); @@ -5598,6 +5614,10 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName if (TSDB_CODE_SUCCESS == code) { code = checkDbRangeOption(pCxt, "sstTrigger", pOptions->sstTrigger, TSDB_MIN_STT_TRIGGER, TSDB_MAX_STT_TRIGGER); } + if (TSDB_CODE_SUCCESS == code) { + code = checkDbEnumOption(pCxt, "withArbitrator", pOptions->withArbitrator, TSDB_MIN_DB_WITH_ARBITRATOR, + TSDB_MAX_DB_WITH_ARBITRATOR); + } if (TSDB_CODE_SUCCESS == code) { code = checkDbTbPrefixSuffixOptions(pCxt, pOptions->tablePrefix, pOptions->tableSuffix); } @@ -5810,6 +5830,7 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt, pReq->minRows = pStmt->pOptions->minRowsPerBlock; pReq->walRetentionPeriod = pStmt->pOptions->walRetentionPeriod; pReq->walRetentionSize = pStmt->pOptions->walRetentionSize; + pReq->withArbitrator = pStmt->pOptions->withArbitrator; return; } @@ -7568,7 +7589,7 @@ static int32_t translateDescribe(STranslateContext* pCxt, SDescribeStmt* pStmt) taosMemoryFree(res.schemaRes.pSchema); } } -#endif +#endif return code; } @@ -7669,8 +7690,8 @@ static int32_t checkCreateStream(STranslateContext* pCxt, SCreateStreamStmt* pSt if (TSDB_VIEW_TABLE == tableType) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Unsupported stream query"); } -#endif - +#endif + return TSDB_CODE_SUCCESS; } @@ -8760,7 +8781,7 @@ static int32_t translateCreateView(STranslateContext* pCxt, SCreateViewStmt* pSt tNameGetFullDbName(&name, dbFName); int32_t code = validateCreateView(pCxt, pStmt); - if (TSDB_CODE_SUCCESS == code) { + if (TSDB_CODE_SUCCESS == code) { code = (*pCxt->pParseCxt->parseSqlFp)(pCxt->pParseCxt->parseSqlParam, pStmt->dbName, pStmt->pQuerySql, false, NULL, &res); } if (TSDB_CODE_SUCCESS == code) { @@ -8783,7 +8804,7 @@ static int32_t translateCreateView(STranslateContext* pCxt, SCreateViewStmt* pSt if (TSDB_CODE_SUCCESS == code) { code = buildCmdMsg(pCxt, TDMT_MND_CREATE_VIEW, (FSerializeFunc)tSerializeSCMCreateViewReq, &pStmt->createReq); } - + tFreeSCMCreateViewReq(&pStmt->createReq); return code; } @@ -8811,7 +8832,7 @@ static int32_t translateDropView(STranslateContext* pCxt, SDropViewStmt* pStmt) if (TSDB_CODE_SUCCESS != code) { return code; } - + return buildCmdMsg(pCxt, TDMT_MND_DROP_VIEW, (FSerializeFunc)tSerializeSCMDropViewReq, &dropReq); } @@ -9004,7 +9025,7 @@ static int32_t translateRevoke(STranslateContext* pCxt, SRevokeStmt* pStmt) { taosMemoryFree(pTableMeta); } #endif - + strcpy(req.user, pStmt->userName); sprintf(req.objname, "%d.%s", pCxt->pParseCxt->acctId, pStmt->objName); sprintf(req.tabName, "%s", pStmt->tabName); @@ -9113,7 +9134,7 @@ static int32_t translateShowCreateTable(STranslateContext* pCxt, SShowCreateTabl static int32_t translateShowCreateView(STranslateContext* pCxt, SShowCreateViewStmt* pStmt) { #ifndef TD_ENTERPRISE return TSDB_CODE_OPS_NOT_SUPPORT; -#else +#else SName name; toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->viewName, &name); return getViewMetaFromMetaCache(pCxt, &name, (SViewMeta**)&pStmt->pViewMeta); @@ -9528,7 +9549,7 @@ int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pS case QUERY_NODE_SHOW_VARIABLES_STMT: return extractShowVariablesResultSchema(numOfCols, pSchema); case QUERY_NODE_COMPACT_DATABASE_STMT: - return extractCompactDbResultSchema(numOfCols, pSchema); + return extractCompactDbResultSchema(numOfCols, pSchema); default: break; } @@ -10205,75 +10226,6 @@ static int32_t createCastFuncForTag(STranslateContext* pCxt, SNode* pNode, SData return code; } -static int32_t createTagValFromExpr(STranslateContext* pCxt, SDataType targetDt, SNode* pNode, SValueNode** pVal) { - SNode* pCast = NULL; - int32_t code = createCastFuncForTag(pCxt, pNode, targetDt, &pCast); - SNode* pNew = NULL; - if (TSDB_CODE_SUCCESS == code) { - code = scalarCalculateConstants(pCast, &pNew); - } - if (TSDB_CODE_SUCCESS == code) { - pCast = pNew; - if (QUERY_NODE_VALUE != nodeType(pCast)) { - code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)pNode)->aliasName); - } - } - - if (TSDB_CODE_SUCCESS == code) { - *pVal = (SValueNode*)pCast; - } else { - nodesDestroyNode(pCast); - } - return code; -} - -static int32_t createTagValFromVal(STranslateContext* pCxt, SDataType targetDt, SNode* pNode, SValueNode** pVal) { - SValueNode* pTempVal = (SValueNode*)nodesCloneNode(pNode); - if (NULL == pTempVal) { - return TSDB_CODE_OUT_OF_MEMORY; - } - if (DEAL_RES_ERROR == translateValueImpl(pCxt, pTempVal, targetDt, true)) { - nodesDestroyNode((SNode*)pTempVal); - return pCxt->errCode; - } - *pVal = pTempVal; - return TSDB_CODE_SUCCESS; -} - -static int32_t createTagVal(STranslateContext* pCxt, uint8_t precision, SSchema* pSchema, SNode* pNode, - SValueNode** pVal) { - if (QUERY_NODE_VALUE == nodeType(pNode)) { - return createTagValFromVal(pCxt, schemaToDataType(precision, pSchema), pNode, pVal); - } else { - return createTagValFromExpr(pCxt, schemaToDataType(precision, pSchema), pNode, pVal); - } -} - -static int32_t buildJsonTagVal(STranslateContext* pCxt, SSchema* pTagSchema, SValueNode* pVal, SArray* pTagArray, - STag** ppTag) { - if (pVal->literal && strlen(pVal->literal) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { - return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pVal->literal); - } - - return parseJsontoTagData(pVal->literal, pTagArray, ppTag, &pCxt->msgBuf); -} - -static int32_t buildNormalTagVal(STranslateContext* pCxt, SSchema* pTagSchema, SValueNode* pVal, SArray* pTagArray) { - if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) { - void* nodeVal = nodesGetValueFromNode(pVal); - STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; - // strcpy(val.colName, pTagSchema->name); - if (IS_VAR_DATA_TYPE(pTagSchema->type)) { - val.pData = varDataVal(nodeVal); - val.nData = varDataLen(nodeVal); - } else { - memcpy(&val.i64, nodeVal, pTagSchema->bytes); - } - taosArrayPush(pTagArray, &val); - } - return TSDB_CODE_SUCCESS; -} - static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableClause* pStmt, STableMeta* pSuperTableMeta, STag** ppTag, SArray* tagName) { int32_t numOfTags = getNumOfTags(pSuperTableMeta); @@ -10289,42 +10241,56 @@ static int32_t buildKVRowForBindTags(STranslateContext* pCxt, SCreateSubTableCla int32_t code = TSDB_CODE_SUCCESS; - bool isJson = false; - SNodeList* pVals = NULL; - SNode * pTag = NULL, *pNode = NULL; - FORBOTH(pTag, pStmt->pSpecificTags, pNode, pStmt->pValsOfTags) { - SColumnNode* pCol = (SColumnNode*)pTag; - SSchema* pSchema = getTagSchema(pSuperTableMeta, pCol->colName); - if (NULL == pSchema) { - code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAG_NAME, pCol->colName); - } - SValueNode* pVal = NULL; + bool isJson = false; + SNode * pTagNode = NULL, *pNode = NULL; + uint8_t precision = pSuperTableMeta->tableInfo.precision; + SToken token; + char tokenBuf[TSDB_MAX_TAGS_LEN]; + const char* tagStr = NULL; + FORBOTH(pTagNode, pStmt->pSpecificTags, pNode, pStmt->pValsOfTags) { + tagStr = ((SValueNode*)pNode)->literal; + NEXT_TOKEN_WITH_PREV(tagStr, token); + + SSchema* pSchema = NULL; if (TSDB_CODE_SUCCESS == code) { - code = createTagVal(pCxt, pSuperTableMeta->tableInfo.precision, pSchema, pNode, &pVal); + if ((pSchema = getTagSchema(pSuperTableMeta, ((SColumnNode*)pTagNode)->colName))) { + code = checkAndTrimValue(&token, tokenBuf, &pCxt->msgBuf, pSchema->type); + if (TSDB_CODE_SUCCESS == code && TK_NK_VARIABLE == token.type) { + code = TSDB_CODE_TSC_SQL_SYNTAX_ERROR; + } + } else { + code = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TAG_NAME, ((SColumnNode*)pTagNode)->colName); + } } + if (TSDB_CODE_SUCCESS == code) { if (pSchema->type == TSDB_DATA_TYPE_JSON) { isJson = true; - code = buildJsonTagVal(pCxt, pSchema, pVal, pTagArray, ppTag); - taosArrayPush(tagName, pCol->colName); - } else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL) { - code = buildNormalTagVal(pCxt, pSchema, pVal, pTagArray); - taosArrayPush(tagName, pCol->colName); + } + code = parseTagValue(&pCxt->msgBuf, &tagStr, precision, pSchema, &token, tagName, pTagArray, ppTag); + } + + if (TSDB_CODE_SUCCESS == code) { + NEXT_VALID_TOKEN(tagStr, token); + if (token.n != 0) { + code = buildSyntaxErrMsg(&pCxt->msgBuf, "not expected tags values", token.z); } } - if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeAppend(&pVals, (SNode*)pVal); - } + if (TSDB_CODE_SUCCESS != code) { break; } } - if (TSDB_CODE_SUCCESS == code && !isJson) { code = tTagNew(pTagArray, 1, false, ppTag); } - nodesDestroyList(pVals); + for (int i = 0; i < taosArrayGetSize(pTagArray); ++i) { + STagVal* p = (STagVal*)taosArrayGet(pTagArray, i); + if (IS_VAR_DATA_TYPE(p->type)) { + taosMemoryFreeClear(p->pData); + } + } taosArrayDestroy(pTagArray); return code; } @@ -10342,51 +10308,52 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau int32_t code = TSDB_CODE_SUCCESS; - bool isJson = false; - int32_t index = 0; - SSchema* pTagSchemas = getTableTagSchema(pSuperTableMeta); - SNodeList* pVals = NULL; - SNode* pNode; + bool isJson = false; + SNode* pNode; + uint8_t precision = pSuperTableMeta->tableInfo.precision; + SSchema* pTagSchema = getTableTagSchema(pSuperTableMeta); + SToken token; + char tokenBuf[TSDB_MAX_TAGS_LEN]; + const char* tagStr = NULL; FOREACH(pNode, pStmt->pValsOfTags) { - SValueNode* pVal = NULL; - SSchema* pTagSchema = pTagSchemas + index; - code = createTagVal(pCxt, pSuperTableMeta->tableInfo.precision, pTagSchema, pNode, &pVal); + tagStr = ((SValueNode*)pNode)->literal; + NEXT_TOKEN_WITH_PREV(tagStr, token); + + code = checkAndTrimValue(&token, tokenBuf, &pCxt->msgBuf, pTagSchema->type); + if (TSDB_CODE_SUCCESS == code && TK_NK_VARIABLE == token.type) { + code = buildSyntaxErrMsg(&pCxt->msgBuf, "not expected tags values", token.z); + } + if (TSDB_CODE_SUCCESS == code) { if (pTagSchema->type == TSDB_DATA_TYPE_JSON) { isJson = true; - code = buildJsonTagVal(pCxt, pTagSchema, pVal, pTagArray, ppTag); - if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode((SNode*)pVal); - } - taosArrayPush(tagName, pTagSchema->name); - } else if (pVal->node.resType.type != TSDB_DATA_TYPE_NULL && !pVal->isNull) { - char* tmpVal = nodesGetValueFromNode(pVal); - STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type}; - // strcpy(val.colName, pTagSchema->name); - if (IS_VAR_DATA_TYPE(pTagSchema->type)) { - val.pData = varDataVal(tmpVal); - val.nData = varDataLen(tmpVal); - } else { - memcpy(&val.i64, tmpVal, pTagSchema->bytes); - } - taosArrayPush(pTagArray, &val); - taosArrayPush(tagName, pTagSchema->name); + } + code = parseTagValue(&pCxt->msgBuf, &tagStr, precision, pTagSchema, &token, tagName, pTagArray, ppTag); + } + + if (TSDB_CODE_SUCCESS == code) { + NEXT_VALID_TOKEN(tagStr, token); + if (token.n != 0) { + code = buildSyntaxErrMsg(&pCxt->msgBuf, "not expected tags values", token.z); } } - if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeAppend(&pVals, (SNode*)pVal); - } + if (TSDB_CODE_SUCCESS != code) { break; } - ++index; + ++pTagSchema; } if (TSDB_CODE_SUCCESS == code && !isJson) { code = tTagNew(pTagArray, 1, false, ppTag); } - nodesDestroyList(pVals); + for (int32_t i = 0; i < TARRAY_SIZE(pTagArray); ++i) { + STagVal* p = (STagVal*)TARRAY_GET_ELEM(pTagArray, i); + if (IS_VAR_DATA_TYPE(p->type)) { + taosMemoryFreeClear(p->pData); + } + } taosArrayDestroy(pTagArray); return code; } @@ -10647,58 +10614,68 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE, "Invalid tag name: %s", pStmt->colName); } - pReq->tagName = taosStrdup(pStmt->colName); if (NULL == pReq->tagName) { return TSDB_CODE_OUT_OF_MEMORY; } + pReq->pTagArray = taosArrayInit(1, sizeof(STagVal)); + if (NULL == pReq->pTagArray) { + return TSDB_CODE_OUT_OF_MEMORY; + } pReq->colId = pSchema->colId; + pReq->tagType = pSchema->type; - SDataType targetDt = schemaToDataType(pTableMeta->tableInfo.precision, pSchema); + int32_t code = 0; - if (QUERY_NODE_VALUE != pStmt->pVal->node.type) { - SValueNode* pVal = NULL; - pCxt->errCode = createTagValFromExpr(pCxt, targetDt, (SNode*)pStmt->pVal, &pVal); - if (pCxt->errCode) { - return pCxt->errCode; - } - - nodesDestroyNode((SNode*)pStmt->pVal); - pStmt->pVal = pVal; - } else if (DEAL_RES_ERROR == translateValueImpl(pCxt, pStmt->pVal, targetDt, true)) { - return pCxt->errCode; - } - - pReq->tagType = targetDt.type; - if (targetDt.type == TSDB_DATA_TYPE_JSON) { - if (pStmt->pVal->literal && - strlen(pStmt->pVal->literal) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { - return buildSyntaxErrMsg(&pCxt->msgBuf, "json string too long than 4095", pStmt->pVal->literal); - } - SArray* pTagVals = taosArrayInit(1, sizeof(STagVal)); - int32_t code = TSDB_CODE_SUCCESS; - STag* pTag = NULL; - code = parseJsontoTagData(pStmt->pVal->literal, pTagVals, &pTag, &pCxt->msgBuf); - taosArrayDestroy(pTagVals); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - pReq->nTagVal = pTag->len; - pReq->pTagVal = (uint8_t*)pTag; - pStmt->pVal->datum.p = (char*)pTag; // for free - } else { - pReq->isNull = pStmt->pVal->isNull; - pReq->nTagVal = pStmt->pVal->node.resType.bytes; - pReq->pTagVal = nodesGetValueFromNode(pStmt->pVal); - - // data and length are seperated for new tag format STagVal - if (IS_VAR_DATA_TYPE(pStmt->pVal->node.resType.type)) { - pReq->nTagVal = varDataLen(pReq->pTagVal); - pReq->pTagVal = varDataVal(pReq->pTagVal); + STag* pTag = NULL; + SToken token; + char tokenBuf[TSDB_MAX_TAGS_LEN]; + const char* tagStr = pStmt->pVal->literal; + NEXT_TOKEN_WITH_PREV(tagStr, token); + if (TSDB_CODE_SUCCESS == code) { + code = checkAndTrimValue(&token, tokenBuf, &pCxt->msgBuf, pSchema->type); + if (TSDB_CODE_SUCCESS == code && TK_NK_VARIABLE == token.type) { + code = buildSyntaxErrMsg(&pCxt->msgBuf, "not expected tags values", token.z); } } - return TSDB_CODE_SUCCESS; + if (TSDB_CODE_SUCCESS == code) { + code = parseTagValue(&pCxt->msgBuf, &tagStr, pTableMeta->tableInfo.precision, pSchema, &token, NULL, + pReq->pTagArray, &pTag); + if (pSchema->type == TSDB_DATA_TYPE_JSON && token.type == TK_NULL && code == TSDB_CODE_SUCCESS) { + pReq->tagFree = true; + } + } + if (TSDB_CODE_SUCCESS == code && tagStr) { + NEXT_VALID_TOKEN(tagStr, token); + if (token.n != 0) { + code = buildSyntaxErrMsg(&pCxt->msgBuf, "not expected tags values", token.z); + } + } + + if (TSDB_CODE_SUCCESS == code) { + if (pSchema->type == TSDB_DATA_TYPE_JSON) { + pReq->nTagVal = pTag->len; + pReq->pTagVal = (uint8_t*)pTag; + pStmt->pVal->datum.p = (char*)pTag; // for free + } else { + STagVal* pTagVal = taosArrayGet(pReq->pTagArray, 0); + if (pTagVal) { + pReq->isNull = false; + if (IS_VAR_DATA_TYPE(pSchema->type)) { + pReq->nTagVal = pTagVal->nData; + pReq->pTagVal = pTagVal->pData; + } else { + pReq->nTagVal = pSchema->bytes; + pReq->pTagVal = (uint8_t*)&pTagVal->i64; + } + } else { + pReq->isNull = true; + } + } + } + + return code; } static int32_t buildAddColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta, @@ -10922,6 +10899,14 @@ static void destoryAlterTbReq(SVAlterTbReq* pReq) { taosMemoryFree(pReq->colNewName); taosMemoryFree(pReq->tagName); taosMemoryFree(pReq->newComment); + for (int i = 0; i < taosArrayGetSize(pReq->pTagArray); ++i) { + STagVal* p = (STagVal*)taosArrayGet(pReq->pTagArray, i); + if (IS_VAR_DATA_TYPE(p->type)) { + taosMemoryFreeClear(p->pData); + } + } + taosArrayDestroy(pReq->pTagArray); + if(pReq->tagFree) tTagFree((STag*)pReq->pTagVal); } static int32_t rewriteAlterTableImpl(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta, @@ -11051,7 +11036,7 @@ static int32_t rewriteShowCompactDetailsStmt(STranslateContext* pCxt, SQuery* pQ nodesDestroyNode(pQuery->pRoot); pQuery->pRoot = (SNode*)pStmt; } - return code; + return code; } static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) { @@ -11085,6 +11070,7 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) { case QUERY_NODE_SHOW_GRANTS_FULL_STMT: case QUERY_NODE_SHOW_GRANTS_LOGS_STMT: case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT: + case QUERY_NODE_SHOW_ARBGROUPS_STMT: code = rewriteShow(pCxt, pQuery); break; case QUERY_NODE_SHOW_VGROUPS_STMT: diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 1581f3ff07..39f50da9fd 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -361,7 +361,7 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi SHashObj* keyHash = NULL; int32_t size = 0; // set json NULL data - if (!json || strtrim((char*)json) == 0 || strcasecmp(json, TSDB_DATA_NULL_STR_L) == 0) { + if (!json || strcasecmp(json, TSDB_DATA_NULL_STR_L) == 0 || strtrim((char*)json) == 0) { retCode = TSDB_CODE_SUCCESS; goto end; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index cb961f039b..3dae58c907 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -197,204 +197,207 @@ #define TK_STABLES 151 #define TK_MNODES 152 #define TK_QNODES 153 -#define TK_FUNCTIONS 154 -#define TK_INDEXES 155 -#define TK_ACCOUNTS 156 -#define TK_APPS 157 -#define TK_CONNECTIONS 158 -#define TK_LICENCES 159 -#define TK_GRANTS 160 -#define TK_FULL 161 -#define TK_LOGS 162 -#define TK_MACHINES 163 -#define TK_QUERIES 164 -#define TK_SCORES 165 -#define TK_TOPICS 166 -#define TK_VARIABLES 167 -#define TK_BNODES 168 -#define TK_SNODES 169 -#define TK_TRANSACTIONS 170 -#define TK_DISTRIBUTED 171 -#define TK_CONSUMERS 172 -#define TK_SUBSCRIPTIONS 173 -#define TK_VNODES 174 -#define TK_ALIVE 175 -#define TK_VIEWS 176 -#define TK_VIEW 177 -#define TK_COMPACTS 178 -#define TK_NORMAL 179 -#define TK_CHILD 180 -#define TK_LIKE 181 -#define TK_TBNAME 182 -#define TK_QTAGS 183 -#define TK_AS 184 -#define TK_SYSTEM 185 -#define TK_INDEX 186 -#define TK_FUNCTION 187 -#define TK_INTERVAL 188 -#define TK_COUNT 189 -#define TK_LAST_ROW 190 -#define TK_META 191 -#define TK_ONLY 192 -#define TK_TOPIC 193 -#define TK_CONSUMER 194 -#define TK_GROUP 195 -#define TK_DESC 196 -#define TK_DESCRIBE 197 -#define TK_RESET 198 -#define TK_QUERY 199 -#define TK_CACHE 200 -#define TK_EXPLAIN 201 -#define TK_ANALYZE 202 -#define TK_VERBOSE 203 -#define TK_NK_BOOL 204 -#define TK_RATIO 205 -#define TK_NK_FLOAT 206 -#define TK_OUTPUTTYPE 207 -#define TK_AGGREGATE 208 -#define TK_BUFSIZE 209 -#define TK_LANGUAGE 210 -#define TK_REPLACE 211 -#define TK_STREAM 212 -#define TK_INTO 213 -#define TK_PAUSE 214 -#define TK_RESUME 215 -#define TK_TRIGGER 216 -#define TK_AT_ONCE 217 -#define TK_WINDOW_CLOSE 218 -#define TK_IGNORE 219 -#define TK_EXPIRED 220 -#define TK_FILL_HISTORY 221 -#define TK_UPDATE 222 -#define TK_SUBTABLE 223 -#define TK_UNTREATED 224 -#define TK_KILL 225 -#define TK_CONNECTION 226 -#define TK_TRANSACTION 227 -#define TK_BALANCE 228 -#define TK_VGROUP 229 -#define TK_LEADER 230 -#define TK_MERGE 231 -#define TK_REDISTRIBUTE 232 -#define TK_SPLIT 233 -#define TK_DELETE 234 -#define TK_INSERT 235 -#define TK_NULL 236 -#define TK_NK_QUESTION 237 -#define TK_NK_ALIAS 238 -#define TK_NK_ARROW 239 -#define TK_ROWTS 240 -#define TK_QSTART 241 -#define TK_QEND 242 -#define TK_QDURATION 243 -#define TK_WSTART 244 -#define TK_WEND 245 -#define TK_WDURATION 246 -#define TK_IROWTS 247 -#define TK_ISFILLED 248 -#define TK_CAST 249 -#define TK_NOW 250 -#define TK_TODAY 251 -#define TK_TIMEZONE 252 -#define TK_CLIENT_VERSION 253 -#define TK_SERVER_VERSION 254 -#define TK_SERVER_STATUS 255 -#define TK_CURRENT_USER 256 -#define TK_CASE 257 -#define TK_WHEN 258 -#define TK_THEN 259 -#define TK_ELSE 260 -#define TK_BETWEEN 261 -#define TK_IS 262 -#define TK_NK_LT 263 -#define TK_NK_GT 264 -#define TK_NK_LE 265 -#define TK_NK_GE 266 -#define TK_NK_NE 267 -#define TK_MATCH 268 -#define TK_NMATCH 269 -#define TK_CONTAINS 270 -#define TK_IN 271 -#define TK_JOIN 272 -#define TK_INNER 273 -#define TK_SELECT 274 -#define TK_NK_HINT 275 -#define TK_DISTINCT 276 -#define TK_WHERE 277 -#define TK_PARTITION 278 -#define TK_BY 279 -#define TK_SESSION 280 -#define TK_STATE_WINDOW 281 -#define TK_EVENT_WINDOW 282 -#define TK_COUNT_WINDOW 283 -#define TK_SLIDING 284 -#define TK_FILL 285 -#define TK_VALUE 286 -#define TK_VALUE_F 287 -#define TK_NONE 288 -#define TK_PREV 289 -#define TK_NULL_F 290 -#define TK_LINEAR 291 -#define TK_NEXT 292 -#define TK_HAVING 293 -#define TK_RANGE 294 -#define TK_EVERY 295 -#define TK_ORDER 296 -#define TK_SLIMIT 297 -#define TK_SOFFSET 298 -#define TK_LIMIT 299 -#define TK_OFFSET 300 -#define TK_ASC 301 -#define TK_NULLS 302 -#define TK_ABORT 303 -#define TK_AFTER 304 -#define TK_ATTACH 305 -#define TK_BEFORE 306 -#define TK_BEGIN 307 -#define TK_BITAND 308 -#define TK_BITNOT 309 -#define TK_BITOR 310 -#define TK_BLOCKS 311 -#define TK_CHANGE 312 -#define TK_COMMA 313 -#define TK_CONCAT 314 -#define TK_CONFLICT 315 -#define TK_COPY 316 -#define TK_DEFERRED 317 -#define TK_DELIMITERS 318 -#define TK_DETACH 319 -#define TK_DIVIDE 320 -#define TK_DOT 321 -#define TK_EACH 322 -#define TK_FAIL 323 -#define TK_FILE 324 -#define TK_FOR 325 -#define TK_GLOB 326 -#define TK_ID 327 -#define TK_IMMEDIATE 328 -#define TK_IMPORT 329 -#define TK_INITIALLY 330 -#define TK_INSTEAD 331 -#define TK_ISNULL 332 -#define TK_MODULES 333 -#define TK_NK_BITNOT 334 -#define TK_NK_SEMI 335 -#define TK_NOTNULL 336 -#define TK_OF 337 -#define TK_PLUS 338 -#define TK_PRIVILEGE 339 -#define TK_RAISE 340 -#define TK_RESTRICT 341 -#define TK_ROW 342 -#define TK_SEMI 343 -#define TK_STAR 344 -#define TK_STATEMENT 345 -#define TK_STRICT 346 -#define TK_STRING 347 -#define TK_TIMES 348 -#define TK_VALUES 349 -#define TK_VARIABLE 350 -#define TK_WAL 351 +#define TK_ARBGROUPS 154 +#define TK_FUNCTIONS 155 +#define TK_INDEXES 156 +#define TK_ACCOUNTS 157 +#define TK_APPS 158 +#define TK_CONNECTIONS 159 +#define TK_LICENCES 160 +#define TK_GRANTS 161 +#define TK_FULL 162 +#define TK_LOGS 163 +#define TK_MACHINES 164 +#define TK_QUERIES 165 +#define TK_SCORES 166 +#define TK_TOPICS 167 +#define TK_VARIABLES 168 +#define TK_BNODES 169 +#define TK_SNODES 170 +#define TK_TRANSACTIONS 171 +#define TK_DISTRIBUTED 172 +#define TK_CONSUMERS 173 +#define TK_SUBSCRIPTIONS 174 +#define TK_VNODES 175 +#define TK_ALIVE 176 +#define TK_VIEWS 177 +#define TK_VIEW 178 +#define TK_COMPACTS 179 +#define TK_NORMAL 180 +#define TK_CHILD 181 +#define TK_LIKE 182 +#define TK_TBNAME 183 +#define TK_QTAGS 184 +#define TK_AS 185 +#define TK_SYSTEM 186 +#define TK_INDEX 187 +#define TK_FUNCTION 188 +#define TK_INTERVAL 189 +#define TK_COUNT 190 +#define TK_LAST_ROW 191 +#define TK_META 192 +#define TK_ONLY 193 +#define TK_TOPIC 194 +#define TK_CONSUMER 195 +#define TK_GROUP 196 +#define TK_DESC 197 +#define TK_DESCRIBE 198 +#define TK_RESET 199 +#define TK_QUERY 200 +#define TK_CACHE 201 +#define TK_EXPLAIN 202 +#define TK_ANALYZE 203 +#define TK_VERBOSE 204 +#define TK_NK_BOOL 205 +#define TK_RATIO 206 +#define TK_NK_FLOAT 207 +#define TK_OUTPUTTYPE 208 +#define TK_AGGREGATE 209 +#define TK_BUFSIZE 210 +#define TK_LANGUAGE 211 +#define TK_REPLACE 212 +#define TK_STREAM 213 +#define TK_INTO 214 +#define TK_PAUSE 215 +#define TK_RESUME 216 +#define TK_TRIGGER 217 +#define TK_AT_ONCE 218 +#define TK_WINDOW_CLOSE 219 +#define TK_IGNORE 220 +#define TK_EXPIRED 221 +#define TK_FILL_HISTORY 222 +#define TK_UPDATE 223 +#define TK_SUBTABLE 224 +#define TK_UNTREATED 225 +#define TK_KILL 226 +#define TK_CONNECTION 227 +#define TK_TRANSACTION 228 +#define TK_BALANCE 229 +#define TK_VGROUP 230 +#define TK_LEADER 231 +#define TK_MERGE 232 +#define TK_REDISTRIBUTE 233 +#define TK_SPLIT 234 +#define TK_DELETE 235 +#define TK_INSERT 236 +#define TK_NK_BIN 237 +#define TK_NK_HEX 238 +#define TK_NULL 239 +#define TK_NK_QUESTION 240 +#define TK_NK_ALIAS 241 +#define TK_NK_ARROW 242 +#define TK_ROWTS 243 +#define TK_QSTART 244 +#define TK_QEND 245 +#define TK_QDURATION 246 +#define TK_WSTART 247 +#define TK_WEND 248 +#define TK_WDURATION 249 +#define TK_IROWTS 250 +#define TK_ISFILLED 251 +#define TK_CAST 252 +#define TK_NOW 253 +#define TK_TODAY 254 +#define TK_TIMEZONE 255 +#define TK_CLIENT_VERSION 256 +#define TK_SERVER_VERSION 257 +#define TK_SERVER_STATUS 258 +#define TK_CURRENT_USER 259 +#define TK_CASE 260 +#define TK_WHEN 261 +#define TK_THEN 262 +#define TK_ELSE 263 +#define TK_BETWEEN 264 +#define TK_IS 265 +#define TK_NK_LT 266 +#define TK_NK_GT 267 +#define TK_NK_LE 268 +#define TK_NK_GE 269 +#define TK_NK_NE 270 +#define TK_MATCH 271 +#define TK_NMATCH 272 +#define TK_CONTAINS 273 +#define TK_IN 274 +#define TK_JOIN 275 +#define TK_INNER 276 +#define TK_SELECT 277 +#define TK_NK_HINT 278 +#define TK_DISTINCT 279 +#define TK_WHERE 280 +#define TK_PARTITION 281 +#define TK_BY 282 +#define TK_SESSION 283 +#define TK_STATE_WINDOW 284 +#define TK_EVENT_WINDOW 285 +#define TK_COUNT_WINDOW 286 +#define TK_SLIDING 287 +#define TK_FILL 288 +#define TK_VALUE 289 +#define TK_VALUE_F 290 +#define TK_NONE 291 +#define TK_PREV 292 +#define TK_NULL_F 293 +#define TK_LINEAR 294 +#define TK_NEXT 295 +#define TK_HAVING 296 +#define TK_RANGE 297 +#define TK_EVERY 298 +#define TK_ORDER 299 +#define TK_SLIMIT 300 +#define TK_SOFFSET 301 +#define TK_LIMIT 302 +#define TK_OFFSET 303 +#define TK_ASC 304 +#define TK_NULLS 305 +#define TK_ABORT 306 +#define TK_AFTER 307 +#define TK_ATTACH 308 +#define TK_BEFORE 309 +#define TK_BEGIN 310 +#define TK_BITAND 311 +#define TK_BITNOT 312 +#define TK_BITOR 313 +#define TK_BLOCKS 314 +#define TK_CHANGE 315 +#define TK_COMMA 316 +#define TK_CONCAT 317 +#define TK_CONFLICT 318 +#define TK_COPY 319 +#define TK_DEFERRED 320 +#define TK_DELIMITERS 321 +#define TK_DETACH 322 +#define TK_DIVIDE 323 +#define TK_DOT 324 +#define TK_EACH 325 +#define TK_FAIL 326 +#define TK_FILE 327 +#define TK_FOR 328 +#define TK_GLOB 329 +#define TK_ID 330 +#define TK_IMMEDIATE 331 +#define TK_IMPORT 332 +#define TK_INITIALLY 333 +#define TK_INSTEAD 334 +#define TK_ISNULL 335 +#define TK_MODULES 336 +#define TK_NK_BITNOT 337 +#define TK_NK_SEMI 338 +#define TK_NOTNULL 339 +#define TK_OF 340 +#define TK_PLUS 341 +#define TK_PRIVILEGE 342 +#define TK_RAISE 343 +#define TK_RESTRICT 344 +#define TK_ROW 345 +#define TK_SEMI 346 +#define TK_STAR 347 +#define TK_STATEMENT 348 +#define TK_STRICT 349 +#define TK_STRING 350 +#define TK_TIMES 351 +#define TK_VALUES 352 +#define TK_VARIABLE 353 +#define TK_WAL 354 #endif /**************** End token definitions ***************************************/ @@ -454,29 +457,29 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 515 +#define YYNOCODE 520 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - int32_t yy10; - int64_t yy89; - SShowTablesOption yy147; - EOrder yy248; - SNodeList* yy264; - EFillMode yy284; - EShowKind yy319; - STokenPair yy357; - bool yy547; - SDataType yy624; - SNode* yy752; - EJoinType yy792; - SToken yy879; - SAlterOption yy935; - ENullOrder yy937; - EOperatorType yy980; - int8_t yy983; + int32_t yy20; + SNodeList* yy184; + ENullOrder yy217; + EOperatorType yy220; + SToken yy369; + EFillMode yy374; + bool yy377; + SNode* yy392; + SShowTablesOption yy397; + EOrder yy578; + int8_t yy743; + SAlterOption yy845; + EShowKind yy849; + SDataType yy864; + int64_t yy909; + EJoinType yy932; + STokenPair yy937; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -492,18 +495,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 857 -#define YYNRULE 654 -#define YYNRULE_WITH_ACTION 654 -#define YYNTOKEN 352 -#define YY_MAX_SHIFT 856 -#define YY_MIN_SHIFTREDUCE 1264 -#define YY_MAX_SHIFTREDUCE 1917 -#define YY_ERROR_ACTION 1918 -#define YY_ACCEPT_ACTION 1919 -#define YY_NO_ACTION 1920 -#define YY_MIN_REDUCE 1921 -#define YY_MAX_REDUCE 2574 +#define YYNSTATE 865 +#define YYNRULE 676 +#define YYNRULE_WITH_ACTION 676 +#define YYNTOKEN 355 +#define YY_MAX_SHIFT 864 +#define YY_MIN_SHIFTREDUCE 1290 +#define YY_MAX_SHIFTREDUCE 1965 +#define YY_ERROR_ACTION 1966 +#define YY_ACCEPT_ACTION 1967 +#define YY_NO_ACTION 1968 +#define YY_MIN_REDUCE 1969 +#define YY_MAX_REDUCE 2644 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -570,905 +573,889 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (3202) +#define YY_ACTTAB_COUNT (3107) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 568, 2165, 423, 569, 1964, 576, 38, 322, 569, 1964, - /* 10 */ 165, 239, 48, 46, 1839, 571, 726, 1972, 2113, 2350, - /* 20 */ 420, 1922, 1680, 41, 40, 719, 146, 47, 45, 44, - /* 30 */ 43, 42, 175, 2102, 1933, 1765, 2007, 1678, 2250, 1705, - /* 40 */ 719, 146, 127, 2354, 618, 126, 125, 124, 123, 122, - /* 50 */ 121, 120, 119, 118, 41, 40, 2248, 727, 47, 45, - /* 60 */ 44, 43, 42, 401, 2297, 1760, 1709, 1330, 1408, 1329, - /* 70 */ 425, 19, 739, 2158, 2160, 41, 40, 1706, 1686, 47, - /* 80 */ 45, 44, 43, 42, 142, 740, 2111, 127, 588, 2356, - /* 90 */ 126, 125, 124, 123, 122, 121, 120, 119, 118, 750, - /* 100 */ 30, 742, 1331, 2436, 853, 209, 739, 15, 573, 828, - /* 110 */ 827, 826, 825, 432, 570, 824, 823, 151, 818, 817, - /* 120 */ 816, 815, 814, 813, 812, 150, 806, 805, 804, 431, - /* 130 */ 430, 801, 800, 799, 184, 183, 798, 302, 2472, 718, - /* 140 */ 174, 138, 717, 2165, 2545, 1767, 1768, 185, 2050, 106, - /* 150 */ 173, 721, 202, 2472, 2473, 342, 144, 2477, 735, 51, - /* 160 */ 740, 2111, 706, 204, 2550, 453, 224, 2546, 708, 386, - /* 170 */ 661, 2230, 340, 74, 2104, 1884, 73, 2165, 648, 1411, - /* 180 */ 137, 1708, 1740, 1750, 384, 811, 369, 611, 2072, 1766, - /* 190 */ 1769, 63, 2163, 646, 63, 644, 271, 270, 237, 550, - /* 200 */ 548, 545, 1504, 1505, 1681, 739, 1679, 90, 41, 40, - /* 210 */ 89, 1914, 47, 45, 44, 43, 42, 584, 41, 40, - /* 220 */ 1413, 1919, 47, 45, 44, 43, 42, 41, 40, 52, - /* 230 */ 200, 47, 45, 44, 43, 42, 1684, 1685, 1737, 63, - /* 240 */ 1739, 1742, 1743, 1744, 1745, 1746, 1747, 1748, 1749, 752, - /* 250 */ 748, 1758, 1759, 1761, 1762, 1763, 1764, 2, 48, 46, - /* 260 */ 797, 476, 1705, 366, 707, 1703, 420, 2545, 1680, 1907, - /* 270 */ 1705, 378, 519, 740, 2111, 538, 697, 185, 88, 64, - /* 280 */ 537, 1765, 197, 1678, 1710, 706, 204, 467, 111, 466, - /* 290 */ 2546, 708, 51, 56, 2152, 457, 499, 108, 539, 707, - /* 300 */ 435, 2231, 2545, 367, 501, 434, 535, 533, 1708, 368, - /* 310 */ 2199, 1760, 1921, 218, 479, 1794, 1913, 19, 1883, 465, - /* 320 */ 706, 204, 459, 455, 1686, 2546, 708, 1855, 84, 83, - /* 330 */ 472, 429, 428, 217, 1944, 2374, 136, 135, 134, 133, - /* 340 */ 132, 131, 130, 129, 128, 304, 464, 462, 722, 63, - /* 350 */ 853, 387, 678, 15, 657, 2545, 1687, 365, 306, 1686, - /* 360 */ 451, 306, 487, 448, 444, 440, 437, 465, 703, 698, - /* 370 */ 691, 687, 702, 2551, 204, 12, 2392, 10, 2546, 708, - /* 380 */ 2088, 1795, 47, 45, 44, 43, 42, 2340, 2340, 657, - /* 390 */ 756, 1767, 1768, 2086, 2237, 2216, 306, 526, 525, 524, - /* 400 */ 523, 518, 517, 516, 515, 370, 306, 400, 2297, 505, - /* 410 */ 504, 503, 502, 496, 495, 494, 241, 489, 488, 385, - /* 420 */ 571, 2479, 1972, 480, 1563, 1564, 740, 2111, 1740, 1750, - /* 430 */ 1582, 2373, 1575, 1576, 2411, 1766, 1769, 114, 2375, 760, - /* 440 */ 2377, 2378, 755, 2298, 750, 565, 137, 2476, 2479, 187, - /* 450 */ 1681, 2464, 1679, 616, 563, 416, 2460, 559, 555, 306, - /* 460 */ 2302, 37, 418, 1789, 1790, 1791, 1792, 1793, 1797, 1798, - /* 470 */ 1799, 1800, 304, 512, 2475, 392, 391, 511, 2495, 2159, - /* 480 */ 2160, 701, 1684, 1685, 1737, 510, 1739, 1742, 1743, 1744, - /* 490 */ 1745, 1746, 1747, 1748, 1749, 752, 748, 1758, 1759, 1761, - /* 500 */ 1762, 1763, 1764, 2, 12, 48, 46, 485, 2226, 2392, - /* 510 */ 44, 43, 42, 420, 276, 1680, 306, 3, 795, 162, - /* 520 */ 161, 792, 791, 790, 159, 1690, 2250, 257, 1765, 54, - /* 530 */ 1678, 795, 162, 161, 792, 791, 790, 159, 2374, 2550, - /* 540 */ 1304, 413, 2545, 180, 2247, 727, 68, 390, 389, 12, - /* 550 */ 613, 722, 605, 601, 597, 593, 220, 256, 1760, 1311, - /* 560 */ 1709, 2549, 313, 314, 19, 2546, 2548, 312, 630, 629, - /* 570 */ 628, 1686, 700, 327, 615, 620, 143, 624, 614, 2392, - /* 580 */ 2479, 623, 1306, 1309, 1310, 2350, 622, 627, 394, 393, - /* 590 */ 1737, 2340, 621, 756, 1469, 617, 1843, 853, 96, 2358, - /* 600 */ 15, 254, 1705, 808, 491, 2226, 2474, 2374, 658, 2354, - /* 610 */ 1460, 785, 784, 783, 1464, 782, 1466, 1467, 781, 778, - /* 620 */ 757, 1475, 775, 1477, 1478, 772, 769, 766, 659, 1330, - /* 630 */ 1775, 1329, 1706, 662, 2373, 2087, 1705, 2411, 1767, 1768, - /* 640 */ 114, 2375, 760, 2377, 2378, 755, 95, 750, 2392, 63, - /* 650 */ 788, 662, 187, 222, 2464, 2356, 417, 160, 416, 2460, - /* 660 */ 2340, 585, 756, 388, 1331, 750, 521, 2226, 810, 244, - /* 670 */ 740, 2111, 2106, 206, 2550, 1740, 1750, 2545, 253, 246, - /* 680 */ 1796, 2494, 1766, 1769, 1709, 251, 582, 41, 40, 787, - /* 690 */ 473, 47, 45, 44, 43, 42, 2549, 1681, 2100, 1679, - /* 700 */ 2546, 2547, 1943, 2373, 243, 797, 2411, 578, 2289, 114, - /* 710 */ 2375, 760, 2377, 2378, 755, 227, 750, 586, 2243, 149, - /* 720 */ 1942, 157, 2435, 2464, 195, 664, 2289, 416, 2460, 1684, - /* 730 */ 1685, 1737, 55, 1739, 1742, 1743, 1744, 1745, 1746, 1747, - /* 740 */ 1748, 1749, 752, 748, 1758, 1759, 1761, 1762, 1763, 1764, - /* 750 */ 2, 48, 46, 1770, 2374, 2340, 1680, 1595, 1596, 420, - /* 760 */ 35, 1680, 740, 2111, 1741, 719, 146, 757, 274, 1974, - /* 770 */ 1801, 1678, 273, 2340, 1765, 1941, 1678, 198, 1710, 34, - /* 780 */ 1872, 2165, 474, 112, 2374, 41, 40, 1940, 410, 47, - /* 790 */ 45, 44, 43, 42, 9, 2392, 2163, 757, 1741, 2502, - /* 800 */ 147, 1594, 1597, 2165, 1760, 414, 1705, 2340, 2103, 756, - /* 810 */ 415, 2374, 1686, 172, 1423, 615, 306, 1686, 2163, 614, - /* 820 */ 1738, 2113, 740, 2111, 757, 2392, 2515, 2209, 2340, 1422, - /* 830 */ 694, 693, 1870, 1871, 1873, 1874, 1875, 2340, 853, 756, - /* 840 */ 2340, 98, 493, 853, 373, 529, 49, 399, 199, 650, - /* 850 */ 2373, 2096, 2392, 2411, 1738, 1709, 114, 2375, 760, 2377, - /* 860 */ 2378, 755, 2549, 750, 2340, 744, 756, 2436, 2565, 483, - /* 870 */ 2464, 2098, 740, 2111, 416, 2460, 1705, 203, 2472, 2473, - /* 880 */ 2373, 144, 2477, 2411, 1767, 1768, 114, 2375, 760, 2377, - /* 890 */ 2378, 755, 506, 750, 275, 423, 540, 2165, 2565, 1311, - /* 900 */ 2464, 2094, 1710, 172, 416, 2460, 282, 2373, 2183, 229, - /* 910 */ 2411, 2113, 2164, 114, 2375, 760, 2377, 2378, 755, 751, - /* 920 */ 750, 1740, 1750, 1309, 1310, 2565, 2051, 2464, 1766, 1769, - /* 930 */ 1469, 416, 2460, 528, 228, 1934, 740, 2111, 1681, 148, - /* 940 */ 1679, 677, 2435, 1681, 711, 1679, 1460, 785, 784, 783, - /* 950 */ 1464, 782, 1466, 1467, 781, 778, 507, 1475, 775, 1477, - /* 960 */ 1478, 772, 769, 766, 14, 13, 1333, 1334, 1741, 1689, - /* 970 */ 1684, 1685, 1648, 1649, 95, 1684, 1685, 1737, 1836, 1739, - /* 980 */ 1742, 1743, 1744, 1745, 1746, 1747, 1748, 1749, 752, 748, - /* 990 */ 1758, 1759, 1761, 1762, 1763, 1764, 2, 48, 46, 2374, - /* 1000 */ 2107, 740, 2111, 336, 2165, 420, 2142, 1680, 740, 2111, - /* 1010 */ 426, 424, 757, 2324, 689, 2508, 1864, 1427, 172, 2163, - /* 1020 */ 1765, 587, 1678, 36, 1738, 1828, 2113, 637, 508, 41, - /* 1030 */ 40, 1865, 1426, 47, 45, 44, 43, 42, 2374, 2321, - /* 1040 */ 2392, 2350, 649, 795, 162, 161, 792, 791, 790, 159, - /* 1050 */ 1760, 757, 2340, 2538, 756, 2359, 740, 2111, 272, 1939, - /* 1060 */ 740, 2111, 299, 1686, 442, 2354, 619, 740, 2111, 514, - /* 1070 */ 513, 1808, 1863, 1710, 640, 61, 2108, 740, 2111, 2392, - /* 1080 */ 277, 634, 632, 675, 719, 146, 1938, 285, 269, 853, - /* 1090 */ 1406, 2340, 49, 756, 1738, 2373, 1937, 725, 2411, 542, - /* 1100 */ 1936, 114, 2375, 760, 2377, 2378, 755, 789, 750, 2374, - /* 1110 */ 2156, 2356, 2340, 2565, 714, 2464, 740, 2111, 1935, 416, - /* 1120 */ 2460, 750, 754, 607, 606, 172, 740, 2111, 695, 72, - /* 1130 */ 1767, 1768, 71, 2114, 2373, 1932, 317, 2411, 1692, 2340, - /* 1140 */ 114, 2375, 760, 2377, 2378, 755, 737, 750, 99, 2340, - /* 1150 */ 2392, 1931, 2565, 2340, 2464, 710, 740, 2111, 416, 2460, - /* 1160 */ 740, 2111, 2340, 293, 756, 626, 625, 1740, 1750, 609, - /* 1170 */ 608, 2340, 740, 2111, 1766, 1769, 738, 41, 40, 1623, - /* 1180 */ 323, 47, 45, 44, 43, 42, 2484, 1828, 2340, 1681, - /* 1190 */ 2010, 1679, 427, 1930, 1929, 1928, 205, 2472, 2473, 1927, - /* 1200 */ 144, 2477, 1926, 1925, 2340, 2373, 1924, 793, 2411, 712, - /* 1210 */ 2156, 358, 2375, 760, 2377, 2378, 755, 753, 750, 741, - /* 1220 */ 2429, 1684, 1685, 1737, 76, 1739, 1742, 1743, 1744, 1745, - /* 1230 */ 1746, 1747, 1748, 1749, 752, 748, 1758, 1759, 1761, 1762, - /* 1240 */ 1763, 1764, 2, 48, 46, 2374, 2340, 2340, 2340, 469, - /* 1250 */ 1835, 420, 2340, 1680, 468, 2340, 2340, 747, 757, 2340, - /* 1260 */ 2483, 822, 820, 630, 629, 628, 1765, 1313, 1678, 211, - /* 1270 */ 620, 143, 624, 1704, 794, 2089, 623, 2156, 87, 1949, - /* 1280 */ 848, 622, 627, 394, 393, 139, 2392, 621, 262, 264, - /* 1290 */ 617, 260, 263, 1994, 153, 286, 1760, 86, 2340, 266, - /* 1300 */ 756, 678, 265, 268, 2545, 2361, 267, 1992, 152, 1686, - /* 1310 */ 1983, 1981, 652, 153, 651, 631, 2333, 141, 2334, 1916, - /* 1320 */ 1917, 1688, 2551, 204, 685, 50, 2393, 2546, 708, 633, - /* 1330 */ 14, 13, 635, 638, 50, 853, 188, 1366, 15, 100, - /* 1340 */ 2048, 2373, 160, 2047, 2411, 2235, 1965, 114, 2375, 760, - /* 1350 */ 2377, 2378, 755, 171, 750, 1975, 50, 429, 428, 2565, - /* 1360 */ 655, 2464, 802, 2363, 2498, 416, 2460, 1694, 678, 1639, - /* 1370 */ 678, 2545, 692, 2545, 803, 311, 1767, 1768, 1367, 406, - /* 1380 */ 1765, 715, 1687, 75, 699, 158, 1385, 160, 1646, 2551, - /* 1390 */ 204, 2551, 204, 729, 2546, 708, 2546, 708, 1383, 1859, - /* 1400 */ 1869, 433, 402, 2236, 1971, 2153, 2374, 846, 671, 1868, - /* 1410 */ 1760, 291, 678, 1740, 1750, 2545, 66, 724, 2499, 757, - /* 1420 */ 1766, 1769, 1786, 1686, 50, 50, 764, 2509, 158, 720, - /* 1430 */ 298, 1592, 301, 2551, 204, 1681, 305, 1679, 2546, 708, - /* 1440 */ 2073, 5, 436, 382, 449, 441, 1713, 2392, 450, 746, - /* 1450 */ 315, 2374, 461, 160, 140, 158, 212, 460, 732, 2340, - /* 1460 */ 319, 756, 1453, 213, 757, 463, 663, 1684, 1685, 1737, - /* 1470 */ 215, 1739, 1742, 1743, 1744, 1745, 1746, 1747, 1748, 1749, - /* 1480 */ 752, 748, 1758, 1759, 1761, 1762, 1763, 1764, 2, 1616, - /* 1490 */ 1691, 1802, 2392, 330, 1703, 477, 1704, 484, 226, 1751, - /* 1500 */ 335, 1482, 2373, 1486, 2340, 2411, 756, 486, 114, 2375, - /* 1510 */ 760, 2377, 2378, 755, 490, 750, 492, 531, 678, 497, - /* 1520 */ 2439, 2545, 2464, 2374, 509, 2228, 416, 2460, 1493, 1491, - /* 1530 */ 163, 520, 522, 723, 527, 530, 757, 532, 543, 2551, - /* 1540 */ 204, 544, 541, 232, 2546, 708, 231, 2373, 546, 1695, - /* 1550 */ 2411, 1690, 234, 114, 2375, 760, 2377, 2378, 755, 547, - /* 1560 */ 750, 549, 551, 1711, 2392, 2437, 566, 2464, 4, 567, - /* 1570 */ 574, 416, 2460, 575, 577, 242, 2340, 92, 756, 1706, - /* 1580 */ 579, 1698, 1700, 245, 1712, 678, 580, 1714, 2545, 581, - /* 1590 */ 248, 583, 2374, 1715, 250, 748, 1758, 1759, 1761, 1762, - /* 1600 */ 1763, 1764, 93, 94, 2244, 757, 2551, 204, 589, 255, - /* 1610 */ 610, 2546, 708, 116, 362, 612, 2101, 259, 641, 2373, - /* 1620 */ 2097, 261, 2411, 642, 166, 114, 2375, 760, 2377, 2378, - /* 1630 */ 755, 167, 750, 2392, 656, 2099, 2095, 743, 168, 2464, - /* 1640 */ 169, 654, 2311, 416, 2460, 2340, 97, 756, 154, 1707, - /* 1650 */ 278, 2308, 2374, 2307, 331, 2290, 667, 666, 665, 670, - /* 1660 */ 283, 672, 281, 673, 696, 757, 682, 2514, 730, 2513, - /* 1670 */ 8, 179, 705, 288, 290, 683, 294, 680, 407, 2486, - /* 1680 */ 292, 681, 1828, 295, 716, 2568, 713, 296, 2373, 297, - /* 1690 */ 145, 2411, 1708, 2392, 115, 2375, 760, 2377, 2378, 755, - /* 1700 */ 2544, 750, 1833, 1831, 300, 2340, 191, 756, 2464, 307, - /* 1710 */ 728, 2480, 2463, 2460, 155, 332, 2258, 733, 156, 207, - /* 1720 */ 2257, 2374, 2256, 412, 333, 1, 734, 105, 2112, 62, - /* 1730 */ 334, 107, 762, 2445, 757, 2157, 337, 325, 1288, 850, - /* 1740 */ 847, 53, 164, 361, 374, 375, 852, 346, 2373, 360, - /* 1750 */ 339, 2411, 350, 341, 115, 2375, 760, 2377, 2378, 755, - /* 1760 */ 2332, 750, 2392, 2331, 2330, 81, 2374, 2325, 2464, 438, - /* 1770 */ 439, 1671, 745, 2460, 2340, 1672, 756, 210, 443, 757, - /* 1780 */ 2323, 445, 446, 447, 1670, 2322, 383, 2320, 452, 2319, - /* 1790 */ 454, 2374, 2318, 456, 2317, 458, 1659, 2294, 214, 2293, - /* 1800 */ 216, 1619, 82, 1618, 757, 2271, 2270, 2392, 2269, 470, - /* 1810 */ 471, 2268, 2267, 2218, 475, 1562, 2215, 758, 478, 2340, - /* 1820 */ 2411, 756, 2214, 115, 2375, 760, 2377, 2378, 755, 2208, - /* 1830 */ 750, 2205, 2392, 481, 482, 219, 2374, 2464, 2204, 2203, - /* 1840 */ 85, 377, 2460, 2202, 2340, 2207, 756, 221, 2206, 757, - /* 1850 */ 2201, 2200, 2198, 2197, 2196, 223, 498, 2195, 500, 2193, - /* 1860 */ 2192, 2191, 2373, 2190, 2213, 2411, 2374, 2189, 176, 2375, - /* 1870 */ 760, 2377, 2378, 755, 2188, 750, 2187, 2392, 2211, 757, - /* 1880 */ 2194, 2186, 2185, 2184, 2182, 2181, 2180, 2373, 2179, 2340, - /* 1890 */ 2411, 756, 2178, 177, 2375, 760, 2377, 2378, 755, 2177, - /* 1900 */ 750, 2176, 2175, 2374, 225, 2174, 2173, 2392, 2212, 2210, - /* 1910 */ 679, 2505, 2172, 91, 2171, 1568, 757, 2170, 230, 2340, - /* 1920 */ 2169, 756, 534, 2168, 536, 2167, 2166, 371, 2013, 1424, - /* 1930 */ 233, 1420, 2373, 2012, 235, 2411, 2011, 2374, 115, 2375, - /* 1940 */ 760, 2377, 2378, 755, 2392, 750, 1428, 709, 2566, 404, - /* 1950 */ 757, 2009, 2464, 372, 236, 2006, 2340, 2461, 756, 552, - /* 1960 */ 554, 553, 2373, 2005, 556, 2411, 557, 1998, 176, 2375, - /* 1970 */ 760, 2377, 2378, 755, 558, 750, 560, 562, 2392, 1985, - /* 1980 */ 561, 564, 2374, 405, 78, 238, 186, 2360, 1312, 1959, - /* 1990 */ 2340, 1960, 756, 2292, 196, 757, 572, 240, 79, 2373, - /* 2000 */ 2288, 2278, 2411, 2266, 247, 359, 2375, 760, 2377, 2378, - /* 2010 */ 755, 2506, 750, 249, 2265, 252, 2242, 2090, 1359, 2008, - /* 2020 */ 2004, 591, 590, 2392, 592, 2002, 595, 594, 596, 2000, - /* 2030 */ 600, 598, 599, 2373, 1997, 2340, 2411, 756, 603, 359, - /* 2040 */ 2375, 760, 2377, 2378, 755, 602, 750, 604, 1980, 2374, - /* 2050 */ 1978, 1979, 1977, 1956, 2092, 1498, 65, 1497, 2091, 1410, - /* 2060 */ 1409, 258, 757, 1407, 2374, 1405, 1396, 1404, 1403, 1402, - /* 2070 */ 1401, 819, 821, 1398, 1397, 1995, 1993, 757, 2373, 1395, - /* 2080 */ 1984, 2411, 395, 396, 352, 2375, 760, 2377, 2378, 755, - /* 2090 */ 2392, 750, 397, 636, 1982, 398, 639, 1955, 1954, 1953, - /* 2100 */ 643, 1952, 2340, 645, 756, 2392, 647, 117, 1653, 1655, - /* 2110 */ 411, 1951, 1657, 29, 1652, 2291, 658, 2340, 57, 756, - /* 2120 */ 69, 1643, 2287, 280, 2374, 1625, 1627, 1629, 2277, 668, - /* 2130 */ 704, 2264, 2263, 58, 674, 20, 669, 754, 170, 6, - /* 2140 */ 2550, 17, 1604, 1603, 284, 2373, 684, 403, 2411, 1886, - /* 2150 */ 31, 177, 2375, 760, 2377, 2378, 755, 1860, 750, 676, - /* 2160 */ 2373, 688, 287, 2411, 686, 2392, 359, 2375, 760, 2377, - /* 2170 */ 2378, 755, 690, 750, 7, 289, 21, 2340, 22, 756, - /* 2180 */ 190, 33, 201, 2361, 67, 24, 1867, 1854, 178, 189, - /* 2190 */ 32, 1901, 23, 80, 1900, 408, 1905, 2374, 1906, 1907, - /* 2200 */ 18, 1904, 409, 1825, 1824, 303, 2567, 60, 2262, 59, - /* 2210 */ 757, 181, 2241, 102, 2240, 101, 108, 103, 321, 25, - /* 2220 */ 2373, 2374, 310, 2411, 1862, 192, 358, 2375, 760, 2377, - /* 2230 */ 2378, 755, 316, 750, 757, 2430, 70, 104, 2392, 26, - /* 2240 */ 1777, 1776, 11, 419, 13, 1696, 1787, 2414, 318, 1755, - /* 2250 */ 2340, 749, 756, 731, 1753, 1730, 39, 763, 1752, 182, - /* 2260 */ 16, 422, 2392, 1722, 193, 767, 2374, 421, 27, 770, - /* 2270 */ 28, 773, 1474, 776, 2340, 1483, 756, 761, 1480, 757, - /* 2280 */ 765, 779, 324, 768, 759, 1479, 771, 1492, 1476, 774, - /* 2290 */ 786, 1470, 777, 2373, 1468, 660, 2411, 780, 1473, 359, - /* 2300 */ 2375, 760, 2377, 2378, 755, 2374, 750, 2392, 1472, 109, - /* 2310 */ 1459, 110, 77, 856, 1471, 1488, 796, 2373, 757, 2340, - /* 2320 */ 2411, 756, 1392, 359, 2375, 760, 2377, 2378, 755, 329, - /* 2330 */ 750, 1357, 1389, 1388, 1387, 1386, 1384, 1382, 1381, 2374, - /* 2340 */ 1380, 1418, 807, 1417, 809, 194, 2392, 208, 1378, 1377, - /* 2350 */ 1376, 1375, 757, 1374, 844, 840, 836, 832, 2340, 326, - /* 2360 */ 756, 1373, 653, 1372, 2374, 2411, 1414, 1412, 354, 2375, - /* 2370 */ 760, 2377, 2378, 755, 1369, 750, 1368, 757, 1365, 1364, - /* 2380 */ 2392, 1363, 1362, 2003, 829, 830, 831, 2001, 833, 834, - /* 2390 */ 835, 1999, 2340, 837, 756, 839, 1996, 841, 1976, 843, - /* 2400 */ 113, 2373, 1950, 320, 2411, 2392, 838, 344, 2375, 760, - /* 2410 */ 2377, 2378, 755, 842, 750, 845, 1301, 2340, 849, 756, - /* 2420 */ 1920, 1289, 328, 1682, 851, 855, 338, 854, 1920, 1920, - /* 2430 */ 1920, 1920, 1920, 1920, 1920, 2373, 1920, 736, 2411, 1920, - /* 2440 */ 2374, 343, 2375, 760, 2377, 2378, 755, 1920, 750, 1920, - /* 2450 */ 1920, 1920, 1920, 757, 1920, 1920, 1920, 1920, 1920, 1920, - /* 2460 */ 2373, 2374, 1920, 2411, 1920, 1920, 345, 2375, 760, 2377, - /* 2470 */ 2378, 755, 1920, 750, 757, 1920, 1920, 1920, 1920, 1920, - /* 2480 */ 309, 2392, 1920, 1920, 1920, 1920, 1920, 308, 1920, 1920, - /* 2490 */ 1920, 1920, 1920, 2340, 1920, 756, 1920, 1920, 1920, 1920, - /* 2500 */ 1920, 1920, 2392, 1920, 1920, 1920, 279, 1920, 1920, 1920, - /* 2510 */ 1920, 1920, 1920, 1920, 2340, 1920, 756, 1920, 1920, 1920, - /* 2520 */ 1920, 2374, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, - /* 2530 */ 1920, 1920, 1920, 1920, 757, 1920, 2373, 1920, 1920, 2411, - /* 2540 */ 1920, 1920, 351, 2375, 760, 2377, 2378, 755, 1920, 750, - /* 2550 */ 1920, 1920, 1920, 1920, 1920, 1920, 1920, 2373, 1920, 1920, - /* 2560 */ 2411, 1920, 2392, 355, 2375, 760, 2377, 2378, 755, 1920, - /* 2570 */ 750, 1920, 1920, 1920, 2340, 1920, 756, 1920, 1920, 1920, - /* 2580 */ 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, - /* 2590 */ 2374, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, - /* 2600 */ 1920, 1920, 1920, 757, 1920, 1920, 2374, 1920, 1920, 1920, - /* 2610 */ 1920, 1920, 1920, 1920, 1920, 1920, 1920, 2373, 1920, 757, - /* 2620 */ 2411, 1920, 2374, 347, 2375, 760, 2377, 2378, 755, 1920, - /* 2630 */ 750, 2392, 1920, 1920, 1920, 757, 1920, 1920, 1920, 1920, - /* 2640 */ 1920, 1920, 1920, 2340, 1920, 756, 1920, 2392, 1920, 1920, - /* 2650 */ 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 2340, - /* 2660 */ 1920, 756, 1920, 2392, 1920, 1920, 1920, 1920, 1920, 1920, - /* 2670 */ 1920, 1920, 1920, 1920, 1920, 2340, 1920, 756, 1920, 1920, - /* 2680 */ 1920, 1920, 1920, 1920, 1920, 1920, 2373, 1920, 1920, 2411, - /* 2690 */ 1920, 1920, 356, 2375, 760, 2377, 2378, 755, 1920, 750, - /* 2700 */ 1920, 2374, 2373, 1920, 1920, 2411, 1920, 1920, 348, 2375, - /* 2710 */ 760, 2377, 2378, 755, 757, 750, 1920, 1920, 2373, 1920, - /* 2720 */ 2374, 2411, 1920, 1920, 357, 2375, 760, 2377, 2378, 755, - /* 2730 */ 1920, 750, 1920, 757, 1920, 1920, 2374, 1920, 1920, 1920, - /* 2740 */ 1920, 1920, 2392, 1920, 1920, 1920, 1920, 1920, 1920, 757, - /* 2750 */ 1920, 1920, 1920, 1920, 2340, 1920, 756, 1920, 1920, 1920, - /* 2760 */ 1920, 2392, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, - /* 2770 */ 1920, 1920, 1920, 2340, 1920, 756, 1920, 2392, 1920, 1920, - /* 2780 */ 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 2340, - /* 2790 */ 1920, 756, 1920, 1920, 1920, 1920, 2374, 2373, 1920, 1920, - /* 2800 */ 2411, 1920, 1920, 349, 2375, 760, 2377, 2378, 755, 757, - /* 2810 */ 750, 1920, 1920, 1920, 1920, 1920, 2373, 2374, 1920, 2411, - /* 2820 */ 1920, 1920, 363, 2375, 760, 2377, 2378, 755, 1920, 750, - /* 2830 */ 757, 1920, 2373, 1920, 1920, 2411, 1920, 2392, 364, 2375, - /* 2840 */ 760, 2377, 2378, 755, 1920, 750, 1920, 1920, 1920, 2340, - /* 2850 */ 1920, 756, 1920, 1920, 1920, 1920, 1920, 1920, 2392, 1920, - /* 2860 */ 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, - /* 2870 */ 2340, 1920, 756, 1920, 1920, 1920, 1920, 2374, 1920, 1920, - /* 2880 */ 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, - /* 2890 */ 757, 1920, 2373, 1920, 1920, 2411, 1920, 1920, 2386, 2375, - /* 2900 */ 760, 2377, 2378, 755, 1920, 750, 1920, 1920, 1920, 1920, - /* 2910 */ 1920, 1920, 1920, 2373, 1920, 1920, 2411, 1920, 2392, 2385, - /* 2920 */ 2375, 760, 2377, 2378, 755, 1920, 750, 1920, 1920, 1920, - /* 2930 */ 2340, 1920, 756, 1920, 1920, 1920, 1920, 1920, 1920, 1920, - /* 2940 */ 1920, 1920, 1920, 1920, 1920, 1920, 2374, 1920, 1920, 1920, - /* 2950 */ 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 757, - /* 2960 */ 1920, 1920, 2374, 1920, 1920, 1920, 1920, 1920, 1920, 1920, - /* 2970 */ 1920, 1920, 1920, 2373, 1920, 757, 2411, 1920, 2374, 2384, - /* 2980 */ 2375, 760, 2377, 2378, 755, 1920, 750, 2392, 1920, 1920, - /* 2990 */ 1920, 757, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 2340, - /* 3000 */ 1920, 756, 1920, 2392, 1920, 1920, 1920, 1920, 1920, 1920, - /* 3010 */ 1920, 1920, 1920, 1920, 1920, 2340, 1920, 756, 1920, 2392, - /* 3020 */ 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, - /* 3030 */ 1920, 2340, 1920, 756, 1920, 1920, 1920, 1920, 1920, 1920, - /* 3040 */ 1920, 1920, 2373, 1920, 1920, 2411, 1920, 1920, 379, 2375, - /* 3050 */ 760, 2377, 2378, 755, 1920, 750, 1920, 2374, 2373, 1920, - /* 3060 */ 1920, 2411, 1920, 1920, 380, 2375, 760, 2377, 2378, 755, - /* 3070 */ 757, 750, 1920, 1920, 2373, 1920, 2374, 2411, 1920, 1920, - /* 3080 */ 376, 2375, 760, 2377, 2378, 755, 1920, 750, 1920, 757, - /* 3090 */ 1920, 1920, 2374, 1920, 1920, 1920, 1920, 1920, 2392, 1920, - /* 3100 */ 1920, 1920, 1920, 1920, 1920, 757, 1920, 1920, 1920, 1920, - /* 3110 */ 2340, 1920, 756, 1920, 1920, 1920, 1920, 2392, 1920, 1920, - /* 3120 */ 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 1920, 2340, - /* 3130 */ 1920, 756, 1920, 2392, 1920, 1920, 1920, 1920, 1920, 1920, - /* 3140 */ 1920, 1920, 1920, 1920, 1920, 2340, 1920, 756, 1920, 1920, - /* 3150 */ 1920, 1920, 1920, 2373, 1920, 1920, 2411, 1920, 1920, 381, - /* 3160 */ 2375, 760, 2377, 2378, 755, 1920, 750, 1920, 1920, 1920, - /* 3170 */ 1920, 1920, 758, 1920, 1920, 2411, 1920, 1920, 354, 2375, - /* 3180 */ 760, 2377, 2378, 755, 1920, 750, 1920, 1920, 2373, 1920, - /* 3190 */ 1920, 2411, 1920, 1920, 353, 2375, 760, 2377, 2378, 755, - /* 3200 */ 1920, 750, + /* 0 */ 795, 475, 37, 311, 714, 575, 474, 2615, 576, 2012, + /* 10 */ 2299, 429, 47, 45, 1887, 2402, 2148, 186, 427, 166, + /* 20 */ 420, 1970, 1727, 726, 147, 713, 205, 2161, 2297, 751, + /* 30 */ 2616, 715, 2248, 2150, 1752, 1813, 2055, 1725, 580, 391, + /* 40 */ 2299, 2279, 128, 2443, 577, 127, 126, 125, 124, 123, + /* 50 */ 122, 121, 120, 119, 685, 423, 729, 2615, 2296, 751, + /* 60 */ 1753, 1337, 40, 39, 709, 1808, 46, 44, 43, 42, + /* 70 */ 41, 19, 426, 406, 2346, 2621, 205, 708, 1733, 763, + /* 80 */ 2616, 715, 2213, 768, 2461, 1335, 1336, 40, 39, 389, + /* 90 */ 426, 46, 44, 43, 42, 41, 2409, 2211, 746, 583, + /* 100 */ 664, 768, 576, 2012, 861, 2461, 175, 15, 763, 836, + /* 110 */ 835, 834, 833, 438, 2098, 832, 831, 152, 826, 825, + /* 120 */ 824, 823, 822, 821, 820, 151, 814, 813, 812, 437, + /* 130 */ 436, 809, 808, 807, 185, 184, 806, 303, 2542, 725, + /* 140 */ 2442, 139, 724, 2480, 2615, 1815, 1816, 115, 2444, 750, + /* 150 */ 2446, 2447, 745, 174, 768, 2347, 424, 2403, 345, 188, + /* 160 */ 161, 2534, 713, 205, 173, 416, 2530, 2616, 715, 572, + /* 170 */ 707, 714, 2161, 62, 2615, 343, 75, 668, 570, 74, + /* 180 */ 207, 566, 562, 1787, 1797, 1530, 1531, 1931, 2564, 372, + /* 190 */ 1814, 1817, 713, 205, 1330, 50, 518, 2616, 715, 459, + /* 200 */ 517, 238, 557, 555, 552, 1728, 431, 1726, 516, 2206, + /* 210 */ 2208, 40, 39, 1337, 426, 46, 44, 43, 42, 41, + /* 220 */ 176, 669, 1981, 128, 2619, 768, 127, 126, 125, 124, + /* 230 */ 123, 122, 121, 120, 119, 54, 1332, 1335, 1336, 1731, + /* 240 */ 1732, 1784, 62, 1786, 1789, 1790, 1791, 1792, 1793, 1794, + /* 250 */ 1795, 1796, 742, 766, 765, 1807, 1809, 1810, 1811, 1812, + /* 260 */ 2, 47, 45, 1969, 819, 763, 369, 2120, 1750, 420, + /* 270 */ 473, 1727, 472, 240, 381, 525, 482, 578, 545, 2020, + /* 280 */ 764, 2159, 63, 544, 1813, 1784, 1725, 137, 136, 135, + /* 290 */ 134, 133, 132, 131, 130, 129, 585, 2338, 33, 505, + /* 300 */ 210, 546, 471, 591, 40, 39, 370, 507, 46, 44, + /* 310 */ 43, 42, 41, 2620, 1808, 1752, 2615, 485, 1842, 242, + /* 320 */ 19, 542, 540, 578, 371, 2020, 1755, 1733, 219, 2213, + /* 330 */ 463, 2370, 85, 84, 478, 2619, 415, 218, 113, 2616, + /* 340 */ 2618, 40, 39, 307, 2211, 46, 44, 43, 42, 41, + /* 350 */ 470, 468, 50, 861, 392, 150, 15, 465, 461, 1495, + /* 360 */ 1891, 368, 198, 2151, 457, 493, 1752, 454, 450, 446, + /* 370 */ 443, 471, 186, 665, 2200, 1486, 793, 792, 791, 1490, + /* 380 */ 790, 1492, 1493, 789, 786, 1843, 1501, 783, 1503, 1504, + /* 390 */ 780, 777, 774, 1339, 1815, 1816, 2280, 2286, 2265, 1751, + /* 400 */ 533, 532, 531, 530, 529, 524, 523, 522, 521, 375, + /* 410 */ 435, 434, 307, 511, 510, 509, 508, 502, 501, 500, + /* 420 */ 595, 495, 494, 390, 66, 726, 147, 486, 1590, 1591, + /* 430 */ 1920, 96, 1787, 1797, 1609, 1734, 2373, 40, 39, 1814, + /* 440 */ 1817, 46, 44, 43, 42, 41, 315, 316, 393, 1756, + /* 450 */ 1752, 314, 35, 666, 1728, 1753, 1726, 2154, 40, 39, + /* 460 */ 726, 147, 46, 44, 43, 42, 41, 36, 418, 1837, + /* 470 */ 1838, 1839, 1840, 1841, 1845, 1846, 1847, 1848, 1602, 1603, + /* 480 */ 701, 700, 1918, 1919, 1921, 1922, 1923, 448, 1731, 1732, + /* 490 */ 1784, 305, 1786, 1789, 1790, 1791, 1792, 1793, 1794, 1795, + /* 500 */ 1796, 742, 766, 765, 1807, 1809, 1810, 1811, 1812, 2, + /* 510 */ 12, 47, 45, 2443, 275, 1356, 2213, 1355, 274, 420, + /* 520 */ 717, 1727, 307, 425, 62, 2620, 747, 62, 2615, 1788, + /* 530 */ 1962, 2211, 143, 258, 1813, 816, 1725, 62, 644, 204, + /* 540 */ 2542, 2543, 2443, 145, 2547, 764, 2159, 2619, 12, 181, + /* 550 */ 1357, 2616, 2617, 656, 2461, 729, 14, 13, 612, 608, + /* 560 */ 604, 600, 212, 257, 1808, 55, 2409, 1912, 746, 273, + /* 570 */ 19, 51, 704, 728, 203, 2542, 2543, 1733, 145, 2547, + /* 580 */ 1622, 1623, 1913, 2461, 287, 647, 669, 1785, 99, 764, + /* 590 */ 2159, 378, 641, 639, 404, 2409, 657, 746, 2620, 270, + /* 600 */ 818, 1992, 1823, 861, 97, 1737, 15, 255, 1752, 138, + /* 610 */ 2442, 1707, 2549, 2480, 201, 1755, 618, 115, 2444, 750, + /* 620 */ 2446, 2447, 745, 1911, 768, 1621, 1624, 149, 101, 157, + /* 630 */ 2505, 2534, 764, 2159, 154, 416, 2530, 1961, 2546, 2442, + /* 640 */ 71, 2351, 2480, 70, 1815, 1816, 115, 2444, 750, 2446, + /* 650 */ 2447, 745, 138, 768, 2409, 764, 2159, 1706, 188, 623, + /* 660 */ 2534, 671, 2338, 1856, 416, 2530, 710, 705, 698, 694, + /* 670 */ 1757, 764, 2159, 40, 39, 479, 245, 46, 44, 43, + /* 680 */ 42, 41, 1787, 1797, 1991, 254, 247, 2565, 1884, 1814, + /* 690 */ 1817, 480, 252, 589, 307, 655, 277, 307, 29, 1356, + /* 700 */ 1495, 1355, 2135, 1955, 1728, 536, 1726, 307, 592, 1666, + /* 710 */ 653, 244, 651, 272, 271, 805, 1486, 793, 792, 791, + /* 720 */ 1490, 790, 1492, 1493, 789, 786, 1990, 1501, 783, 1503, + /* 730 */ 1504, 780, 777, 774, 1357, 726, 147, 2409, 1731, 1732, + /* 740 */ 1784, 307, 1786, 1789, 1790, 1791, 1792, 1793, 1794, 1795, + /* 750 */ 1796, 742, 766, 765, 1807, 1809, 1810, 1811, 1812, 2, + /* 760 */ 47, 45, 1818, 2443, 593, 2292, 491, 2275, 420, 230, + /* 770 */ 1727, 1788, 805, 1932, 497, 2275, 747, 1989, 2022, 2409, + /* 780 */ 305, 1710, 276, 1813, 2213, 1725, 46, 44, 43, 42, + /* 790 */ 41, 430, 2443, 148, 535, 229, 2505, 764, 2159, 2211, + /* 800 */ 1733, 637, 636, 635, 2461, 747, 2136, 2572, 627, 144, + /* 810 */ 631, 1713, 1716, 1808, 630, 221, 2409, 499, 746, 629, + /* 820 */ 634, 399, 398, 223, 1967, 628, 1733, 1709, 624, 1785, + /* 830 */ 2409, 1727, 2023, 2461, 40, 39, 764, 2159, 46, 44, + /* 840 */ 43, 42, 41, 1844, 622, 2409, 1725, 746, 621, 206, + /* 850 */ 2542, 2543, 861, 145, 2547, 48, 512, 1712, 1715, 1988, + /* 860 */ 2442, 1675, 1676, 2480, 2443, 1987, 1437, 115, 2444, 750, + /* 870 */ 2446, 2447, 745, 2232, 768, 764, 2159, 744, 12, 2635, + /* 880 */ 10, 2534, 764, 2159, 854, 416, 2530, 1733, 664, 2442, + /* 890 */ 2207, 2208, 2480, 1815, 1816, 513, 115, 2444, 750, 2446, + /* 900 */ 2447, 745, 514, 768, 441, 2461, 2382, 1439, 2635, 440, + /* 910 */ 2534, 796, 2409, 861, 416, 2530, 1752, 2409, 2409, 746, + /* 920 */ 764, 2159, 40, 39, 330, 34, 46, 44, 43, 42, + /* 930 */ 41, 1787, 1797, 684, 1903, 1849, 764, 2159, 1814, 1817, + /* 940 */ 594, 2144, 405, 2346, 803, 163, 162, 800, 799, 798, + /* 950 */ 160, 1359, 1360, 1728, 2146, 1726, 2156, 685, 2419, 685, + /* 960 */ 2615, 2442, 2615, 1883, 2480, 43, 42, 41, 361, 2444, + /* 970 */ 750, 2446, 2447, 745, 743, 768, 734, 2499, 2621, 205, + /* 980 */ 2621, 205, 2423, 2616, 715, 2616, 715, 1731, 1732, 1784, + /* 990 */ 107, 1786, 1789, 1790, 1791, 1792, 1793, 1794, 1795, 1796, + /* 1000 */ 742, 766, 765, 1807, 1809, 1810, 1811, 1812, 2, 47, + /* 1010 */ 45, 225, 2443, 2383, 1728, 2152, 1726, 420, 2419, 1727, + /* 1020 */ 1986, 527, 2275, 764, 2159, 747, 2142, 2585, 662, 2425, + /* 1030 */ 2427, 417, 1813, 2134, 1725, 520, 519, 764, 2159, 173, + /* 1040 */ 768, 2443, 2423, 278, 1985, 614, 613, 2162, 1731, 1732, + /* 1050 */ 616, 615, 91, 2461, 747, 90, 696, 286, 764, 2159, + /* 1060 */ 764, 2159, 1808, 764, 2159, 2409, 685, 746, 60, 2615, + /* 1070 */ 228, 764, 2159, 2409, 797, 1733, 682, 2204, 732, 1788, + /* 1080 */ 319, 685, 2461, 761, 2615, 764, 2159, 2621, 205, 2425, + /* 1090 */ 2428, 762, 2616, 715, 2409, 9, 746, 2409, 429, 172, + /* 1100 */ 768, 861, 2621, 205, 48, 326, 173, 2616, 715, 2442, + /* 1110 */ 2549, 1756, 2480, 2443, 2161, 1756, 115, 2444, 750, 2446, + /* 1120 */ 2447, 745, 199, 768, 89, 1449, 747, 1756, 2635, 2213, + /* 1130 */ 2534, 764, 2159, 1984, 416, 2530, 2545, 1785, 2442, 2549, + /* 1140 */ 1448, 2480, 1815, 1816, 733, 115, 2444, 750, 2446, 2447, + /* 1150 */ 745, 433, 768, 670, 2461, 730, 1752, 2635, 735, 2534, + /* 1160 */ 2506, 1983, 432, 416, 2530, 2544, 2409, 737, 746, 2506, + /* 1170 */ 173, 803, 163, 162, 800, 799, 798, 160, 2161, 96, + /* 1180 */ 1787, 1797, 633, 632, 2213, 1453, 2409, 1814, 1817, 397, + /* 1190 */ 396, 3, 803, 163, 162, 800, 799, 798, 160, 759, + /* 1200 */ 1452, 625, 1728, 53, 1726, 2155, 685, 547, 685, 2615, + /* 1210 */ 2442, 2615, 1980, 2480, 2409, 718, 1979, 178, 2444, 750, + /* 1220 */ 2446, 2447, 745, 1736, 768, 1434, 1978, 2621, 205, 2621, + /* 1230 */ 205, 283, 2616, 715, 2616, 715, 1731, 1732, 1784, 100, + /* 1240 */ 1786, 1789, 1790, 1791, 1792, 1793, 1794, 1795, 1796, 742, + /* 1250 */ 766, 765, 1807, 1809, 1810, 1811, 1812, 2, 47, 45, + /* 1260 */ 2443, 395, 394, 1977, 620, 2409, 420, 549, 1727, 2409, + /* 1270 */ 1650, 716, 2636, 747, 1976, 2608, 196, 1975, 2258, 2409, + /* 1280 */ 200, 1813, 1974, 1725, 1973, 1972, 801, 2213, 622, 2204, + /* 1290 */ 2443, 77, 621, 830, 828, 802, 339, 154, 2204, 2190, + /* 1300 */ 140, 2461, 2212, 747, 626, 2553, 1997, 856, 2137, 2554, + /* 1310 */ 1876, 1808, 87, 2409, 263, 746, 2409, 261, 265, 267, + /* 1320 */ 489, 264, 266, 269, 1733, 2042, 268, 2409, 1432, 1876, + /* 1330 */ 2409, 2461, 1757, 2040, 2031, 2409, 1757, 2409, 2409, 2029, + /* 1340 */ 659, 153, 658, 2409, 692, 746, 88, 638, 1757, 49, + /* 1350 */ 861, 49, 189, 15, 741, 640, 642, 2442, 2430, 721, + /* 1360 */ 2480, 645, 1964, 1965, 115, 2444, 750, 2446, 2447, 745, + /* 1370 */ 2099, 768, 1673, 161, 14, 13, 2635, 1785, 2534, 435, + /* 1380 */ 434, 740, 416, 2530, 64, 49, 49, 2442, 1982, 1741, + /* 1390 */ 2480, 1815, 1816, 1739, 115, 2444, 750, 2446, 2447, 745, + /* 1400 */ 1735, 768, 1813, 313, 1734, 76, 2635, 159, 2534, 161, + /* 1410 */ 325, 324, 416, 2530, 112, 2443, 2432, 1392, 2578, 1907, + /* 1420 */ 810, 300, 811, 109, 1917, 702, 1916, 292, 747, 1787, + /* 1430 */ 1797, 294, 1808, 142, 2462, 73, 1814, 1817, 772, 159, + /* 1440 */ 2284, 161, 2096, 141, 1411, 1733, 1409, 2095, 731, 2013, + /* 1450 */ 159, 1728, 2568, 1726, 2058, 699, 2461, 407, 1393, 1850, + /* 1460 */ 1798, 1619, 411, 706, 753, 2285, 439, 2019, 2409, 678, + /* 1470 */ 746, 739, 2201, 2569, 2579, 727, 302, 299, 317, 306, + /* 1480 */ 756, 5, 321, 719, 1479, 1731, 1732, 1784, 2121, 1786, + /* 1490 */ 1789, 1790, 1791, 1792, 1793, 1794, 1795, 1796, 742, 766, + /* 1500 */ 765, 1807, 1809, 1810, 1811, 1812, 2, 374, 373, 442, + /* 1510 */ 338, 447, 2442, 1508, 1512, 2480, 1519, 1717, 1517, 115, + /* 1520 */ 2444, 750, 2446, 2447, 745, 164, 768, 637, 636, 635, + /* 1530 */ 1813, 2509, 1705, 2534, 627, 144, 631, 416, 2530, 2443, + /* 1540 */ 630, 387, 455, 456, 1760, 629, 634, 399, 398, 1834, + /* 1550 */ 466, 628, 747, 467, 624, 214, 213, 469, 216, 1643, + /* 1560 */ 1808, 333, 1750, 2443, 483, 1751, 490, 227, 492, 496, + /* 1570 */ 1738, 498, 1742, 538, 1737, 528, 747, 503, 526, 534, + /* 1580 */ 2461, 515, 2277, 537, 539, 550, 551, 548, 232, 233, + /* 1590 */ 553, 554, 2409, 235, 746, 556, 558, 1758, 573, 2443, + /* 1600 */ 4, 574, 581, 582, 2461, 1753, 1745, 1747, 584, 243, + /* 1610 */ 93, 246, 747, 586, 1759, 587, 2409, 1761, 746, 249, + /* 1620 */ 766, 765, 1807, 1809, 1810, 1811, 1812, 588, 590, 722, + /* 1630 */ 251, 1762, 94, 95, 256, 596, 2442, 617, 117, 2480, + /* 1640 */ 2461, 2293, 661, 115, 2444, 750, 2446, 2447, 745, 619, + /* 1650 */ 768, 2149, 2409, 648, 746, 2507, 260, 2534, 2145, 262, + /* 1660 */ 2442, 416, 2530, 2480, 649, 167, 663, 115, 2444, 750, + /* 1670 */ 2446, 2447, 745, 2360, 768, 168, 2147, 365, 2143, 736, + /* 1680 */ 169, 2534, 170, 2357, 2356, 416, 2530, 98, 1754, 279, + /* 1690 */ 2339, 155, 334, 673, 284, 672, 2442, 677, 680, 2480, + /* 1700 */ 1718, 282, 1708, 116, 2444, 750, 2446, 2447, 745, 689, + /* 1710 */ 768, 679, 703, 674, 754, 2584, 2443, 2534, 289, 2583, + /* 1720 */ 2556, 2533, 2530, 291, 8, 712, 688, 180, 293, 747, + /* 1730 */ 690, 295, 1711, 1714, 1719, 296, 687, 298, 412, 723, + /* 1740 */ 2638, 720, 2614, 297, 1876, 1755, 2443, 2550, 766, 765, + /* 1750 */ 1807, 1809, 1810, 1811, 1812, 146, 1881, 2461, 192, 747, + /* 1760 */ 301, 1879, 308, 208, 1, 61, 156, 2515, 752, 2409, + /* 1770 */ 335, 746, 2307, 2306, 336, 2305, 422, 757, 158, 758, + /* 1780 */ 106, 108, 337, 2160, 770, 340, 2401, 2461, 2400, 2443, + /* 1790 */ 2205, 328, 855, 1314, 858, 364, 344, 352, 860, 2409, + /* 1800 */ 165, 746, 747, 342, 363, 52, 353, 2381, 385, 2380, + /* 1810 */ 2379, 82, 386, 2442, 2374, 444, 2480, 445, 1698, 1699, + /* 1820 */ 116, 2444, 750, 2446, 2447, 745, 211, 768, 449, 2372, + /* 1830 */ 2461, 451, 452, 453, 2534, 1697, 2371, 388, 738, 2530, + /* 1840 */ 2369, 458, 2409, 748, 746, 2368, 2480, 2367, 460, 2443, + /* 1850 */ 116, 2444, 750, 2446, 2447, 745, 462, 768, 2366, 464, + /* 1860 */ 1686, 2343, 747, 215, 2534, 2342, 217, 1646, 380, 2530, + /* 1870 */ 83, 2443, 1645, 2320, 2319, 2318, 476, 477, 2317, 2316, + /* 1880 */ 2267, 481, 1589, 2264, 747, 484, 2442, 2263, 2257, 2480, + /* 1890 */ 2461, 487, 488, 177, 2444, 750, 2446, 2447, 745, 2254, + /* 1900 */ 768, 220, 2409, 2253, 746, 86, 2252, 2251, 2256, 2255, + /* 1910 */ 2250, 222, 2461, 224, 504, 2244, 506, 2242, 2241, 2240, + /* 1920 */ 2239, 2262, 2238, 2237, 2409, 2249, 746, 2247, 2246, 2245, + /* 1930 */ 2236, 2260, 2243, 2235, 2234, 686, 2575, 2233, 2231, 2230, + /* 1940 */ 2229, 2228, 2227, 2226, 226, 2225, 2442, 92, 2224, 2480, + /* 1950 */ 2223, 2443, 2222, 116, 2444, 750, 2446, 2447, 745, 2221, + /* 1960 */ 768, 2261, 2259, 2220, 747, 2219, 1595, 2534, 2442, 2218, + /* 1970 */ 231, 2480, 2531, 541, 2216, 177, 2444, 750, 2446, 2447, + /* 1980 */ 745, 2443, 768, 2217, 2215, 543, 2214, 2061, 1450, 1454, + /* 1990 */ 1446, 234, 2461, 559, 747, 2060, 376, 2059, 2057, 2443, + /* 2000 */ 236, 377, 2054, 2053, 2409, 560, 746, 563, 564, 2046, + /* 2010 */ 561, 568, 747, 565, 237, 567, 2033, 569, 2576, 571, + /* 2020 */ 2008, 239, 2461, 79, 187, 1338, 409, 2007, 2429, 2443, + /* 2030 */ 2341, 2337, 2327, 241, 2409, 2315, 746, 197, 579, 250, + /* 2040 */ 2461, 80, 747, 248, 2314, 253, 2291, 2138, 2442, 1385, + /* 2050 */ 2056, 2480, 2409, 2052, 746, 362, 2444, 750, 2446, 2447, + /* 2060 */ 745, 597, 768, 598, 599, 2050, 601, 603, 602, 2048, + /* 2070 */ 2461, 605, 606, 2045, 410, 607, 609, 610, 2442, 611, + /* 2080 */ 2028, 2480, 2409, 2026, 746, 355, 2444, 750, 2446, 2447, + /* 2090 */ 745, 2027, 768, 2025, 2004, 2140, 2442, 1524, 1523, 2480, + /* 2100 */ 72, 2139, 643, 362, 2444, 750, 2446, 2447, 745, 2443, + /* 2110 */ 768, 1436, 2043, 259, 1435, 1433, 1431, 2041, 1430, 1429, + /* 2120 */ 827, 1428, 744, 1427, 2032, 829, 2442, 1424, 2443, 2480, + /* 2130 */ 1422, 711, 400, 178, 2444, 750, 2446, 2447, 745, 1423, + /* 2140 */ 768, 747, 401, 1421, 402, 2030, 2443, 403, 646, 2003, + /* 2150 */ 2461, 2002, 2001, 650, 2000, 652, 1999, 654, 118, 747, + /* 2160 */ 1684, 28, 2409, 1680, 746, 1682, 1679, 2340, 67, 2461, + /* 2170 */ 1670, 2336, 1654, 665, 1652, 2326, 1656, 56, 2313, 281, + /* 2180 */ 171, 2409, 675, 746, 2312, 2620, 681, 2461, 2637, 57, + /* 2190 */ 676, 20, 1631, 1630, 285, 30, 17, 1934, 691, 2409, + /* 2200 */ 408, 746, 683, 419, 288, 693, 2442, 1908, 667, 2480, + /* 2210 */ 697, 290, 6, 361, 2444, 750, 2446, 2447, 745, 695, + /* 2220 */ 768, 421, 2500, 7, 21, 2442, 864, 22, 2480, 1915, + /* 2230 */ 191, 65, 362, 2444, 750, 2446, 2447, 745, 179, 768, + /* 2240 */ 190, 31, 332, 2442, 1902, 202, 2480, 2430, 2443, 81, + /* 2250 */ 362, 2444, 750, 2446, 2447, 745, 32, 768, 195, 24, + /* 2260 */ 304, 747, 23, 1954, 1949, 1955, 1948, 852, 848, 844, + /* 2270 */ 840, 2443, 329, 413, 1873, 1953, 1952, 414, 1872, 59, + /* 2280 */ 182, 2311, 2290, 102, 747, 103, 25, 13, 1825, 2461, + /* 2290 */ 58, 1824, 1743, 1800, 38, 18, 1835, 1799, 11, 183, + /* 2300 */ 16, 2409, 26, 746, 193, 2443, 1777, 1769, 749, 27, + /* 2310 */ 2289, 312, 2461, 114, 1910, 194, 322, 318, 747, 69, + /* 2320 */ 104, 755, 105, 323, 2409, 109, 746, 320, 2485, 771, + /* 2330 */ 769, 2443, 2484, 428, 775, 778, 781, 784, 1802, 767, + /* 2340 */ 68, 787, 1509, 1506, 747, 660, 2461, 1500, 2480, 773, + /* 2350 */ 760, 2443, 357, 2444, 750, 2446, 2447, 745, 2409, 768, + /* 2360 */ 746, 776, 794, 779, 747, 1505, 1502, 782, 2442, 1496, + /* 2370 */ 785, 2480, 2461, 1494, 788, 347, 2444, 750, 2446, 2447, + /* 2380 */ 745, 1499, 768, 1485, 2409, 327, 746, 110, 1514, 1498, + /* 2390 */ 111, 1518, 2461, 78, 310, 1383, 1497, 804, 1418, 1415, + /* 2400 */ 1414, 309, 2442, 815, 2409, 2480, 746, 1413, 1412, 346, + /* 2410 */ 2444, 750, 2446, 2447, 745, 1410, 768, 1408, 1407, 1406, + /* 2420 */ 280, 1444, 1443, 817, 209, 1404, 1403, 1402, 2442, 1401, + /* 2430 */ 1400, 2480, 1399, 2443, 1398, 348, 2444, 750, 2446, 2447, + /* 2440 */ 745, 1438, 768, 1440, 1389, 1395, 747, 1394, 2442, 1391, + /* 2450 */ 1390, 2480, 1388, 2051, 837, 354, 2444, 750, 2446, 2447, + /* 2460 */ 745, 839, 768, 2443, 2049, 838, 841, 842, 843, 2047, + /* 2470 */ 845, 846, 847, 2044, 2461, 849, 747, 851, 850, 2024, + /* 2480 */ 853, 2443, 1327, 1998, 1315, 857, 2409, 331, 746, 859, + /* 2490 */ 1968, 1968, 1729, 341, 747, 862, 863, 1968, 1968, 1968, + /* 2500 */ 1968, 1968, 1968, 1968, 2461, 1968, 1968, 1968, 1968, 1968, + /* 2510 */ 1968, 1968, 1968, 1968, 1968, 1968, 2409, 1968, 746, 1968, + /* 2520 */ 1968, 1968, 2461, 1968, 1968, 1968, 1968, 1968, 1968, 1968, + /* 2530 */ 2442, 1968, 1968, 2480, 2409, 1968, 746, 358, 2444, 750, + /* 2540 */ 2446, 2447, 745, 1968, 768, 1968, 1968, 1968, 1968, 1968, + /* 2550 */ 1968, 1968, 1968, 1968, 1968, 1968, 1968, 1968, 1968, 1968, + /* 2560 */ 2442, 1968, 2443, 2480, 1968, 1968, 1968, 349, 2444, 750, + /* 2570 */ 2446, 2447, 745, 1968, 768, 747, 1968, 1968, 2442, 1968, + /* 2580 */ 2443, 2480, 1968, 1968, 1968, 359, 2444, 750, 2446, 2447, + /* 2590 */ 745, 1968, 768, 747, 1968, 2443, 1968, 1968, 1968, 1968, + /* 2600 */ 1968, 1968, 1968, 2461, 1968, 1968, 1968, 1968, 747, 1968, + /* 2610 */ 2443, 1968, 1968, 1968, 1968, 2409, 1968, 746, 1968, 1968, + /* 2620 */ 1968, 2461, 1968, 747, 1968, 1968, 1968, 1968, 1968, 1968, + /* 2630 */ 1968, 1968, 1968, 2409, 1968, 746, 2461, 1968, 1968, 1968, + /* 2640 */ 1968, 1968, 1968, 1968, 1968, 1968, 1968, 1968, 2409, 1968, + /* 2650 */ 746, 2461, 1968, 1968, 1968, 1968, 1968, 1968, 1968, 2442, + /* 2660 */ 1968, 1968, 2480, 2409, 1968, 746, 350, 2444, 750, 2446, + /* 2670 */ 2447, 745, 1968, 768, 1968, 1968, 1968, 2442, 1968, 1968, + /* 2680 */ 2480, 1968, 1968, 2443, 360, 2444, 750, 2446, 2447, 745, + /* 2690 */ 1968, 768, 2442, 1968, 1968, 2480, 747, 1968, 1968, 351, + /* 2700 */ 2444, 750, 2446, 2447, 745, 1968, 768, 2442, 1968, 2443, + /* 2710 */ 2480, 1968, 1968, 1968, 366, 2444, 750, 2446, 2447, 745, + /* 2720 */ 1968, 768, 747, 1968, 2461, 1968, 1968, 1968, 1968, 1968, + /* 2730 */ 1968, 2443, 1968, 1968, 1968, 1968, 2409, 1968, 746, 1968, + /* 2740 */ 1968, 1968, 1968, 1968, 747, 1968, 1968, 1968, 1968, 1968, + /* 2750 */ 2461, 1968, 1968, 1968, 1968, 1968, 1968, 1968, 1968, 1968, + /* 2760 */ 1968, 1968, 2409, 1968, 746, 1968, 1968, 1968, 1968, 2443, + /* 2770 */ 1968, 1968, 2461, 1968, 1968, 1968, 1968, 1968, 1968, 1968, + /* 2780 */ 2442, 1968, 747, 2480, 2409, 1968, 746, 367, 2444, 750, + /* 2790 */ 2446, 2447, 745, 1968, 768, 1968, 1968, 1968, 1968, 1968, + /* 2800 */ 1968, 1968, 1968, 1968, 1968, 1968, 2442, 1968, 1968, 2480, + /* 2810 */ 2461, 1968, 1968, 2455, 2444, 750, 2446, 2447, 745, 1968, + /* 2820 */ 768, 1968, 2409, 1968, 746, 1968, 1968, 1968, 2442, 1968, + /* 2830 */ 1968, 2480, 1968, 1968, 1968, 2454, 2444, 750, 2446, 2447, + /* 2840 */ 745, 1968, 768, 1968, 1968, 2443, 1968, 1968, 1968, 1968, + /* 2850 */ 1968, 1968, 1968, 1968, 1968, 1968, 1968, 1968, 747, 1968, + /* 2860 */ 1968, 1968, 1968, 1968, 1968, 1968, 2442, 1968, 1968, 2480, + /* 2870 */ 1968, 1968, 1968, 2453, 2444, 750, 2446, 2447, 745, 1968, + /* 2880 */ 768, 2443, 1968, 1968, 1968, 1968, 2461, 1968, 1968, 1968, + /* 2890 */ 1968, 1968, 1968, 1968, 747, 1968, 1968, 1968, 2409, 1968, + /* 2900 */ 746, 1968, 1968, 1968, 1968, 1968, 1968, 1968, 1968, 1968, + /* 2910 */ 1968, 1968, 1968, 1968, 1968, 1968, 1968, 1968, 1968, 2443, + /* 2920 */ 1968, 1968, 2461, 1968, 1968, 1968, 1968, 1968, 1968, 1968, + /* 2930 */ 1968, 1968, 747, 1968, 2409, 1968, 746, 1968, 1968, 1968, + /* 2940 */ 1968, 1968, 2442, 1968, 1968, 2480, 1968, 1968, 1968, 382, + /* 2950 */ 2444, 750, 2446, 2447, 745, 1968, 768, 1968, 1968, 1968, + /* 2960 */ 2461, 1968, 2443, 1968, 1968, 1968, 1968, 1968, 1968, 1968, + /* 2970 */ 1968, 1968, 2409, 1968, 746, 747, 1968, 1968, 2442, 1968, + /* 2980 */ 2443, 2480, 1968, 1968, 1968, 383, 2444, 750, 2446, 2447, + /* 2990 */ 745, 1968, 768, 747, 1968, 2443, 1968, 1968, 1968, 1968, + /* 3000 */ 1968, 1968, 1968, 2461, 1968, 1968, 1968, 1968, 747, 1968, + /* 3010 */ 1968, 1968, 1968, 1968, 1968, 2409, 2442, 746, 1968, 2480, + /* 3020 */ 1968, 2461, 1968, 379, 2444, 750, 2446, 2447, 745, 1968, + /* 3030 */ 768, 1968, 1968, 2409, 1968, 746, 2461, 1968, 1968, 1968, + /* 3040 */ 1968, 1968, 1968, 1968, 1968, 1968, 1968, 1968, 2409, 1968, + /* 3050 */ 746, 1968, 1968, 1968, 1968, 1968, 1968, 1968, 1968, 2442, + /* 3060 */ 1968, 1968, 2480, 1968, 1968, 1968, 384, 2444, 750, 2446, + /* 3070 */ 2447, 745, 1968, 768, 1968, 1968, 1968, 748, 1968, 1968, + /* 3080 */ 2480, 1968, 1968, 1968, 357, 2444, 750, 2446, 2447, 745, + /* 3090 */ 1968, 768, 2442, 1968, 1968, 2480, 1968, 1968, 1968, 356, + /* 3100 */ 2444, 750, 2446, 2447, 745, 1968, 768, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 362, 396, 388, 365, 366, 362, 472, 473, 365, 366, - /* 10 */ 396, 363, 12, 13, 14, 367, 411, 369, 404, 384, - /* 20 */ 20, 0, 22, 8, 9, 367, 368, 12, 13, 14, - /* 30 */ 15, 16, 354, 398, 356, 35, 0, 37, 410, 20, - /* 40 */ 367, 368, 21, 408, 13, 24, 25, 26, 27, 28, - /* 50 */ 29, 30, 31, 32, 8, 9, 428, 429, 12, 13, - /* 60 */ 14, 15, 16, 449, 450, 65, 20, 20, 37, 22, - /* 70 */ 406, 71, 20, 409, 410, 8, 9, 20, 78, 12, - /* 80 */ 13, 14, 15, 16, 37, 367, 368, 21, 70, 454, - /* 90 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 464, - /* 100 */ 33, 468, 55, 470, 104, 387, 20, 107, 14, 73, - /* 110 */ 74, 75, 76, 77, 20, 79, 80, 81, 82, 83, + /* 0 */ 400, 435, 477, 478, 488, 365, 440, 491, 368, 369, + /* 10 */ 413, 391, 12, 13, 14, 401, 400, 399, 404, 399, + /* 20 */ 20, 0, 22, 370, 371, 509, 510, 407, 431, 432, + /* 30 */ 514, 515, 0, 401, 20, 35, 0, 37, 14, 421, + /* 40 */ 413, 423, 21, 358, 20, 24, 25, 26, 27, 28, + /* 50 */ 29, 30, 31, 32, 488, 428, 371, 491, 431, 432, + /* 60 */ 20, 23, 8, 9, 20, 65, 12, 13, 14, 15, + /* 70 */ 16, 71, 458, 453, 454, 509, 510, 371, 78, 20, + /* 80 */ 514, 515, 399, 469, 399, 47, 48, 8, 9, 406, + /* 90 */ 458, 12, 13, 14, 15, 16, 411, 414, 413, 365, + /* 100 */ 399, 469, 368, 369, 104, 399, 380, 107, 20, 73, + /* 110 */ 74, 75, 76, 77, 388, 79, 80, 81, 82, 83, /* 120 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, - /* 130 */ 94, 95, 96, 97, 98, 99, 100, 479, 480, 481, - /* 140 */ 377, 483, 484, 396, 486, 145, 146, 396, 385, 374, - /* 150 */ 18, 478, 479, 480, 481, 23, 483, 484, 411, 107, - /* 160 */ 367, 368, 504, 505, 3, 69, 65, 509, 510, 418, - /* 170 */ 20, 420, 40, 41, 399, 108, 44, 396, 21, 37, - /* 180 */ 387, 20, 182, 183, 403, 383, 54, 394, 386, 189, - /* 190 */ 190, 107, 411, 36, 107, 38, 39, 40, 66, 67, - /* 200 */ 68, 69, 145, 146, 204, 20, 206, 106, 8, 9, - /* 210 */ 109, 196, 12, 13, 14, 15, 16, 20, 8, 9, - /* 220 */ 78, 352, 12, 13, 14, 15, 16, 8, 9, 107, - /* 230 */ 184, 12, 13, 14, 15, 16, 236, 237, 238, 107, - /* 240 */ 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, - /* 250 */ 250, 251, 252, 253, 254, 255, 256, 257, 12, 13, - /* 260 */ 70, 367, 20, 18, 483, 20, 20, 486, 22, 108, - /* 270 */ 20, 71, 27, 367, 368, 30, 188, 396, 177, 147, - /* 280 */ 35, 35, 395, 37, 238, 504, 505, 203, 107, 205, - /* 290 */ 509, 510, 107, 387, 407, 199, 51, 116, 53, 483, - /* 300 */ 431, 420, 486, 58, 59, 436, 412, 413, 20, 415, - /* 310 */ 0, 65, 0, 419, 69, 115, 301, 71, 108, 235, - /* 320 */ 504, 505, 226, 227, 78, 509, 510, 108, 196, 197, - /* 330 */ 198, 12, 13, 201, 355, 355, 24, 25, 26, 27, - /* 340 */ 28, 29, 30, 31, 32, 184, 214, 215, 368, 107, - /* 350 */ 104, 106, 483, 107, 396, 486, 37, 225, 274, 78, - /* 360 */ 228, 274, 117, 231, 232, 233, 234, 235, 280, 281, - /* 370 */ 282, 283, 20, 504, 505, 258, 396, 260, 509, 510, - /* 380 */ 0, 181, 12, 13, 14, 15, 16, 408, 408, 396, - /* 390 */ 410, 145, 146, 0, 149, 150, 274, 152, 153, 154, - /* 400 */ 155, 156, 157, 158, 159, 160, 274, 449, 450, 164, - /* 410 */ 165, 166, 167, 168, 169, 170, 363, 172, 173, 174, - /* 420 */ 367, 456, 369, 178, 179, 180, 367, 368, 182, 183, - /* 430 */ 185, 451, 182, 183, 454, 189, 190, 457, 458, 459, - /* 440 */ 460, 461, 462, 450, 464, 51, 387, 482, 456, 469, - /* 450 */ 204, 471, 206, 394, 60, 475, 476, 63, 64, 274, - /* 460 */ 392, 261, 262, 263, 264, 265, 266, 267, 268, 269, - /* 470 */ 270, 271, 184, 163, 482, 39, 40, 167, 498, 409, - /* 480 */ 410, 368, 236, 237, 238, 175, 240, 241, 242, 243, - /* 490 */ 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, - /* 500 */ 254, 255, 256, 257, 258, 12, 13, 367, 368, 396, - /* 510 */ 14, 15, 16, 20, 446, 22, 274, 33, 138, 139, - /* 520 */ 140, 141, 142, 143, 144, 206, 410, 35, 35, 45, - /* 530 */ 37, 138, 139, 140, 141, 142, 143, 144, 355, 483, - /* 540 */ 4, 425, 486, 51, 428, 429, 4, 111, 112, 258, - /* 550 */ 114, 368, 60, 61, 62, 63, 416, 65, 65, 23, - /* 560 */ 20, 505, 139, 140, 71, 509, 510, 144, 73, 74, - /* 570 */ 75, 78, 459, 34, 138, 80, 81, 82, 142, 396, - /* 580 */ 456, 86, 46, 47, 48, 384, 91, 92, 93, 94, - /* 590 */ 238, 408, 97, 410, 104, 100, 14, 104, 106, 398, - /* 600 */ 107, 109, 20, 13, 367, 368, 482, 355, 118, 408, - /* 610 */ 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, - /* 620 */ 368, 131, 132, 133, 134, 135, 136, 137, 117, 20, - /* 630 */ 14, 22, 20, 367, 451, 0, 20, 454, 145, 146, - /* 640 */ 457, 458, 459, 460, 461, 462, 376, 464, 396, 107, - /* 650 */ 117, 367, 469, 416, 471, 454, 455, 33, 475, 476, - /* 660 */ 408, 367, 410, 393, 55, 464, 367, 368, 78, 177, - /* 670 */ 367, 368, 402, 490, 483, 182, 183, 486, 186, 187, - /* 680 */ 181, 498, 189, 190, 20, 193, 194, 8, 9, 397, - /* 690 */ 387, 12, 13, 14, 15, 16, 505, 204, 397, 206, - /* 700 */ 509, 510, 355, 451, 212, 70, 454, 441, 442, 457, - /* 710 */ 458, 459, 460, 461, 462, 416, 464, 423, 424, 467, - /* 720 */ 355, 469, 470, 471, 184, 441, 442, 475, 476, 236, - /* 730 */ 237, 238, 108, 240, 241, 242, 243, 244, 245, 246, - /* 740 */ 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, - /* 750 */ 257, 12, 13, 14, 355, 408, 22, 145, 146, 20, - /* 760 */ 261, 22, 367, 368, 182, 367, 368, 368, 140, 370, - /* 770 */ 271, 37, 144, 408, 35, 355, 37, 437, 238, 2, - /* 780 */ 236, 396, 387, 374, 355, 8, 9, 355, 403, 12, - /* 790 */ 13, 14, 15, 16, 42, 396, 411, 368, 182, 370, - /* 800 */ 391, 189, 190, 396, 65, 388, 20, 408, 399, 410, - /* 810 */ 403, 355, 78, 396, 22, 138, 274, 78, 411, 142, - /* 820 */ 238, 404, 367, 368, 368, 396, 370, 0, 408, 37, - /* 830 */ 286, 287, 288, 289, 290, 291, 292, 408, 104, 410, - /* 840 */ 408, 213, 387, 104, 216, 87, 107, 219, 184, 221, - /* 850 */ 451, 397, 396, 454, 238, 20, 457, 458, 459, 460, - /* 860 */ 461, 462, 3, 464, 408, 468, 410, 470, 469, 42, - /* 870 */ 471, 397, 367, 368, 475, 476, 20, 479, 480, 481, - /* 880 */ 451, 483, 484, 454, 145, 146, 457, 458, 459, 460, - /* 890 */ 461, 462, 387, 464, 139, 388, 104, 396, 469, 23, - /* 900 */ 471, 397, 238, 396, 475, 476, 397, 451, 0, 151, - /* 910 */ 454, 404, 411, 457, 458, 459, 460, 461, 462, 397, - /* 920 */ 464, 182, 183, 47, 48, 469, 385, 471, 189, 190, - /* 930 */ 104, 475, 476, 175, 176, 356, 367, 368, 204, 467, - /* 940 */ 206, 50, 470, 204, 33, 206, 120, 121, 122, 123, - /* 950 */ 124, 125, 126, 127, 128, 129, 387, 131, 132, 133, - /* 960 */ 134, 135, 136, 137, 1, 2, 56, 57, 182, 37, - /* 970 */ 236, 237, 217, 218, 376, 236, 237, 238, 4, 240, - /* 980 */ 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, - /* 990 */ 251, 252, 253, 254, 255, 256, 257, 12, 13, 355, - /* 1000 */ 402, 367, 368, 389, 396, 20, 392, 22, 367, 368, - /* 1010 */ 388, 403, 368, 0, 370, 421, 22, 22, 396, 411, - /* 1020 */ 35, 387, 37, 2, 238, 273, 404, 4, 387, 8, - /* 1030 */ 9, 37, 37, 12, 13, 14, 15, 16, 355, 0, - /* 1040 */ 396, 384, 19, 138, 139, 140, 141, 142, 143, 144, - /* 1050 */ 65, 368, 408, 370, 410, 398, 367, 368, 35, 355, - /* 1060 */ 367, 368, 513, 78, 51, 408, 13, 367, 368, 161, - /* 1070 */ 162, 108, 78, 238, 51, 184, 387, 367, 368, 396, - /* 1080 */ 387, 58, 59, 192, 367, 368, 355, 387, 65, 104, - /* 1090 */ 37, 408, 107, 410, 238, 451, 355, 387, 454, 104, - /* 1100 */ 355, 457, 458, 459, 460, 461, 462, 405, 464, 355, - /* 1110 */ 408, 454, 408, 469, 33, 471, 367, 368, 355, 475, - /* 1120 */ 476, 464, 368, 372, 373, 396, 367, 368, 502, 106, - /* 1130 */ 145, 146, 109, 404, 451, 355, 387, 454, 206, 408, - /* 1140 */ 457, 458, 459, 460, 461, 462, 387, 464, 177, 408, - /* 1150 */ 396, 355, 469, 408, 471, 296, 367, 368, 475, 476, - /* 1160 */ 367, 368, 408, 495, 410, 381, 382, 182, 183, 372, - /* 1170 */ 373, 408, 367, 368, 189, 190, 387, 8, 9, 208, - /* 1180 */ 387, 12, 13, 14, 15, 16, 272, 273, 408, 204, - /* 1190 */ 0, 206, 387, 355, 355, 355, 479, 480, 481, 355, - /* 1200 */ 483, 484, 355, 355, 408, 451, 355, 405, 454, 298, - /* 1210 */ 408, 457, 458, 459, 460, 461, 462, 463, 464, 465, - /* 1220 */ 466, 236, 237, 238, 117, 240, 241, 242, 243, 244, - /* 1230 */ 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, - /* 1240 */ 255, 256, 257, 12, 13, 355, 408, 408, 408, 431, - /* 1250 */ 276, 20, 408, 22, 436, 408, 408, 71, 368, 408, - /* 1260 */ 370, 381, 382, 73, 74, 75, 35, 14, 37, 230, - /* 1270 */ 80, 81, 82, 20, 405, 0, 86, 408, 171, 358, - /* 1280 */ 359, 91, 92, 93, 94, 33, 396, 97, 110, 110, - /* 1290 */ 100, 113, 113, 0, 33, 65, 65, 45, 408, 110, - /* 1300 */ 410, 483, 113, 110, 486, 49, 113, 0, 33, 78, - /* 1310 */ 0, 0, 220, 33, 222, 22, 431, 371, 431, 145, - /* 1320 */ 146, 37, 504, 505, 33, 33, 396, 509, 510, 22, - /* 1330 */ 1, 2, 22, 22, 33, 104, 33, 37, 107, 109, - /* 1340 */ 384, 451, 33, 384, 454, 421, 366, 457, 458, 459, - /* 1350 */ 460, 461, 462, 184, 464, 0, 33, 12, 13, 469, - /* 1360 */ 431, 471, 13, 107, 421, 475, 476, 22, 483, 108, - /* 1370 */ 483, 486, 501, 486, 13, 33, 145, 146, 78, 501, - /* 1380 */ 35, 300, 37, 33, 501, 33, 37, 33, 108, 504, - /* 1390 */ 505, 504, 505, 501, 509, 510, 509, 510, 37, 108, - /* 1400 */ 108, 371, 430, 421, 368, 407, 355, 52, 438, 108, - /* 1410 */ 65, 108, 483, 182, 183, 486, 33, 108, 421, 368, - /* 1420 */ 189, 190, 236, 78, 33, 33, 33, 421, 33, 485, - /* 1430 */ 477, 108, 506, 504, 505, 204, 488, 206, 509, 510, - /* 1440 */ 386, 277, 432, 453, 42, 51, 20, 396, 452, 104, - /* 1450 */ 108, 355, 443, 33, 33, 33, 448, 219, 108, 408, - /* 1460 */ 108, 410, 108, 376, 368, 443, 431, 236, 237, 238, - /* 1470 */ 376, 240, 241, 242, 243, 244, 245, 246, 247, 248, - /* 1480 */ 249, 250, 251, 252, 253, 254, 255, 256, 257, 202, - /* 1490 */ 206, 108, 396, 434, 20, 367, 20, 368, 45, 108, - /* 1500 */ 108, 108, 451, 108, 408, 454, 410, 417, 457, 458, - /* 1510 */ 459, 460, 461, 462, 368, 464, 417, 181, 483, 414, - /* 1520 */ 469, 486, 471, 355, 367, 367, 475, 476, 108, 108, - /* 1530 */ 108, 368, 417, 431, 414, 414, 368, 414, 105, 504, - /* 1540 */ 505, 380, 103, 367, 509, 510, 379, 451, 102, 204, - /* 1550 */ 454, 206, 367, 457, 458, 459, 460, 461, 462, 378, - /* 1560 */ 464, 367, 367, 20, 396, 469, 360, 471, 50, 364, - /* 1570 */ 360, 475, 476, 364, 443, 376, 408, 376, 410, 20, - /* 1580 */ 410, 236, 237, 376, 20, 483, 369, 20, 486, 433, - /* 1590 */ 376, 369, 355, 20, 376, 250, 251, 252, 253, 254, - /* 1600 */ 255, 256, 376, 376, 424, 368, 504, 505, 367, 376, - /* 1610 */ 360, 509, 510, 367, 360, 396, 396, 396, 358, 451, - /* 1620 */ 396, 396, 454, 358, 396, 457, 458, 459, 460, 461, - /* 1630 */ 462, 396, 464, 396, 447, 396, 396, 469, 396, 471, - /* 1640 */ 396, 223, 408, 475, 476, 408, 107, 410, 445, 20, - /* 1650 */ 374, 408, 355, 408, 443, 442, 440, 210, 209, 410, - /* 1660 */ 374, 432, 439, 367, 285, 368, 408, 494, 284, 494, - /* 1670 */ 293, 494, 195, 426, 426, 295, 493, 278, 302, 497, - /* 1680 */ 496, 294, 273, 492, 299, 514, 297, 491, 451, 432, - /* 1690 */ 368, 454, 20, 396, 457, 458, 459, 460, 461, 462, - /* 1700 */ 508, 464, 117, 275, 507, 408, 369, 410, 471, 374, - /* 1710 */ 408, 456, 475, 476, 374, 426, 408, 187, 374, 487, - /* 1720 */ 408, 355, 408, 408, 426, 489, 422, 374, 368, 107, - /* 1730 */ 392, 107, 400, 474, 368, 408, 367, 374, 22, 357, - /* 1740 */ 38, 435, 361, 444, 427, 427, 360, 390, 451, 390, - /* 1750 */ 375, 454, 390, 353, 457, 458, 459, 460, 461, 462, - /* 1760 */ 0, 464, 396, 0, 0, 45, 355, 0, 471, 37, - /* 1770 */ 229, 37, 475, 476, 408, 37, 410, 37, 229, 368, - /* 1780 */ 0, 37, 37, 229, 37, 0, 229, 0, 37, 0, - /* 1790 */ 37, 355, 0, 22, 0, 37, 224, 0, 212, 0, - /* 1800 */ 212, 206, 213, 204, 368, 0, 0, 396, 0, 200, - /* 1810 */ 199, 0, 0, 150, 49, 49, 0, 451, 37, 408, - /* 1820 */ 454, 410, 0, 457, 458, 459, 460, 461, 462, 0, - /* 1830 */ 464, 0, 396, 37, 51, 49, 355, 471, 0, 0, - /* 1840 */ 45, 475, 476, 0, 408, 0, 410, 49, 0, 368, - /* 1850 */ 0, 0, 0, 0, 0, 167, 37, 0, 167, 0, - /* 1860 */ 0, 0, 451, 0, 0, 454, 355, 0, 457, 458, - /* 1870 */ 459, 460, 461, 462, 0, 464, 0, 396, 0, 368, - /* 1880 */ 0, 0, 0, 0, 0, 0, 0, 451, 0, 408, - /* 1890 */ 454, 410, 0, 457, 458, 459, 460, 461, 462, 0, - /* 1900 */ 464, 0, 0, 355, 49, 0, 0, 396, 0, 0, - /* 1910 */ 499, 500, 0, 45, 0, 22, 368, 0, 150, 408, - /* 1920 */ 0, 410, 149, 0, 148, 0, 0, 50, 0, 22, - /* 1930 */ 65, 37, 451, 0, 65, 454, 0, 355, 457, 458, - /* 1940 */ 459, 460, 461, 462, 396, 464, 22, 511, 512, 401, - /* 1950 */ 368, 0, 471, 50, 65, 0, 408, 476, 410, 37, - /* 1960 */ 42, 51, 451, 0, 37, 454, 51, 0, 457, 458, - /* 1970 */ 459, 460, 461, 462, 42, 464, 37, 42, 396, 0, - /* 1980 */ 51, 37, 355, 401, 42, 45, 33, 49, 14, 0, - /* 1990 */ 408, 0, 410, 0, 49, 368, 49, 43, 42, 451, - /* 2000 */ 0, 0, 454, 0, 42, 457, 458, 459, 460, 461, - /* 2010 */ 462, 500, 464, 195, 0, 49, 0, 0, 72, 0, - /* 2020 */ 0, 51, 37, 396, 42, 0, 51, 37, 42, 0, - /* 2030 */ 42, 37, 51, 451, 0, 408, 454, 410, 51, 457, - /* 2040 */ 458, 459, 460, 461, 462, 37, 464, 42, 0, 355, - /* 2050 */ 0, 0, 0, 0, 0, 37, 115, 22, 0, 37, - /* 2060 */ 37, 113, 368, 37, 355, 37, 22, 37, 37, 37, - /* 2070 */ 37, 33, 33, 37, 37, 0, 0, 368, 451, 37, - /* 2080 */ 0, 454, 22, 22, 457, 458, 459, 460, 461, 462, - /* 2090 */ 396, 464, 22, 53, 0, 22, 37, 0, 0, 0, - /* 2100 */ 37, 0, 408, 37, 410, 396, 22, 20, 37, 37, - /* 2110 */ 401, 0, 108, 107, 37, 0, 118, 408, 184, 410, - /* 2120 */ 107, 119, 0, 49, 355, 37, 22, 211, 0, 22, - /* 2130 */ 503, 0, 0, 184, 191, 33, 184, 368, 207, 50, - /* 2140 */ 3, 279, 184, 184, 187, 451, 37, 37, 454, 108, - /* 2150 */ 107, 457, 458, 459, 460, 461, 462, 108, 464, 191, - /* 2160 */ 451, 105, 107, 454, 107, 396, 457, 458, 459, 460, - /* 2170 */ 461, 462, 103, 464, 50, 108, 33, 408, 33, 410, - /* 2180 */ 33, 33, 49, 49, 3, 33, 108, 108, 107, 107, - /* 2190 */ 107, 37, 279, 107, 37, 37, 37, 355, 108, 108, - /* 2200 */ 279, 37, 37, 108, 108, 49, 512, 33, 0, 272, - /* 2210 */ 368, 49, 0, 42, 0, 107, 116, 42, 49, 107, - /* 2220 */ 451, 355, 108, 454, 108, 107, 457, 458, 459, 460, - /* 2230 */ 461, 462, 107, 464, 368, 466, 107, 107, 396, 33, - /* 2240 */ 105, 105, 259, 401, 2, 22, 236, 107, 186, 108, - /* 2250 */ 408, 107, 410, 188, 108, 22, 107, 37, 108, 49, - /* 2260 */ 107, 37, 396, 108, 49, 37, 355, 401, 107, 37, - /* 2270 */ 107, 37, 130, 37, 408, 108, 410, 117, 108, 368, - /* 2280 */ 107, 37, 33, 107, 239, 108, 107, 37, 108, 107, - /* 2290 */ 118, 108, 107, 451, 108, 1, 454, 107, 130, 457, - /* 2300 */ 458, 459, 460, 461, 462, 355, 464, 396, 130, 107, - /* 2310 */ 119, 107, 107, 19, 130, 22, 71, 451, 368, 408, - /* 2320 */ 454, 410, 37, 457, 458, 459, 460, 461, 462, 35, - /* 2330 */ 464, 72, 37, 37, 37, 37, 37, 37, 37, 355, - /* 2340 */ 37, 78, 101, 78, 101, 51, 396, 33, 37, 37, - /* 2350 */ 37, 22, 368, 37, 60, 61, 62, 63, 408, 65, - /* 2360 */ 410, 37, 451, 37, 355, 454, 78, 37, 457, 458, - /* 2370 */ 459, 460, 461, 462, 37, 464, 37, 368, 37, 37, - /* 2380 */ 396, 22, 37, 0, 37, 51, 42, 0, 37, 51, - /* 2390 */ 42, 0, 408, 37, 410, 42, 0, 37, 0, 42, - /* 2400 */ 106, 451, 0, 109, 454, 396, 51, 457, 458, 459, - /* 2410 */ 460, 461, 462, 51, 464, 37, 37, 408, 33, 410, - /* 2420 */ 515, 22, 22, 22, 21, 20, 22, 21, 515, 515, - /* 2430 */ 515, 515, 515, 515, 515, 451, 515, 143, 454, 515, - /* 2440 */ 355, 457, 458, 459, 460, 461, 462, 515, 464, 515, - /* 2450 */ 515, 515, 515, 368, 515, 515, 515, 515, 515, 515, - /* 2460 */ 451, 355, 515, 454, 515, 515, 457, 458, 459, 460, - /* 2470 */ 461, 462, 515, 464, 368, 515, 515, 515, 515, 515, - /* 2480 */ 186, 396, 515, 515, 515, 515, 515, 193, 515, 515, - /* 2490 */ 515, 515, 515, 408, 515, 410, 515, 515, 515, 515, - /* 2500 */ 515, 515, 396, 515, 515, 515, 212, 515, 515, 515, - /* 2510 */ 515, 515, 515, 515, 408, 515, 410, 515, 515, 515, - /* 2520 */ 515, 355, 515, 515, 515, 515, 515, 515, 515, 515, - /* 2530 */ 515, 515, 515, 515, 368, 515, 451, 515, 515, 454, - /* 2540 */ 515, 515, 457, 458, 459, 460, 461, 462, 515, 464, - /* 2550 */ 515, 515, 515, 515, 515, 515, 515, 451, 515, 515, - /* 2560 */ 454, 515, 396, 457, 458, 459, 460, 461, 462, 515, - /* 2570 */ 464, 515, 515, 515, 408, 515, 410, 515, 515, 515, - /* 2580 */ 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, - /* 2590 */ 355, 515, 515, 515, 515, 515, 515, 515, 515, 515, - /* 2600 */ 515, 515, 515, 368, 515, 515, 355, 515, 515, 515, - /* 2610 */ 515, 515, 515, 515, 515, 515, 515, 451, 515, 368, - /* 2620 */ 454, 515, 355, 457, 458, 459, 460, 461, 462, 515, - /* 2630 */ 464, 396, 515, 515, 515, 368, 515, 515, 515, 515, - /* 2640 */ 515, 515, 515, 408, 515, 410, 515, 396, 515, 515, - /* 2650 */ 515, 515, 515, 515, 515, 515, 515, 515, 515, 408, - /* 2660 */ 515, 410, 515, 396, 515, 515, 515, 515, 515, 515, - /* 2670 */ 515, 515, 515, 515, 515, 408, 515, 410, 515, 515, - /* 2680 */ 515, 515, 515, 515, 515, 515, 451, 515, 515, 454, - /* 2690 */ 515, 515, 457, 458, 459, 460, 461, 462, 515, 464, - /* 2700 */ 515, 355, 451, 515, 515, 454, 515, 515, 457, 458, - /* 2710 */ 459, 460, 461, 462, 368, 464, 515, 515, 451, 515, - /* 2720 */ 355, 454, 515, 515, 457, 458, 459, 460, 461, 462, - /* 2730 */ 515, 464, 515, 368, 515, 515, 355, 515, 515, 515, - /* 2740 */ 515, 515, 396, 515, 515, 515, 515, 515, 515, 368, - /* 2750 */ 515, 515, 515, 515, 408, 515, 410, 515, 515, 515, - /* 2760 */ 515, 396, 515, 515, 515, 515, 515, 515, 515, 515, - /* 2770 */ 515, 515, 515, 408, 515, 410, 515, 396, 515, 515, - /* 2780 */ 515, 515, 515, 515, 515, 515, 515, 515, 515, 408, - /* 2790 */ 515, 410, 515, 515, 515, 515, 355, 451, 515, 515, - /* 2800 */ 454, 515, 515, 457, 458, 459, 460, 461, 462, 368, - /* 2810 */ 464, 515, 515, 515, 515, 515, 451, 355, 515, 454, - /* 2820 */ 515, 515, 457, 458, 459, 460, 461, 462, 515, 464, - /* 2830 */ 368, 515, 451, 515, 515, 454, 515, 396, 457, 458, - /* 2840 */ 459, 460, 461, 462, 515, 464, 515, 515, 515, 408, - /* 2850 */ 515, 410, 515, 515, 515, 515, 515, 515, 396, 515, - /* 2860 */ 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, - /* 2870 */ 408, 515, 410, 515, 515, 515, 515, 355, 515, 515, - /* 2880 */ 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, - /* 2890 */ 368, 515, 451, 515, 515, 454, 515, 515, 457, 458, - /* 2900 */ 459, 460, 461, 462, 515, 464, 515, 515, 515, 515, - /* 2910 */ 515, 515, 515, 451, 515, 515, 454, 515, 396, 457, - /* 2920 */ 458, 459, 460, 461, 462, 515, 464, 515, 515, 515, - /* 2930 */ 408, 515, 410, 515, 515, 515, 515, 515, 515, 515, - /* 2940 */ 515, 515, 515, 515, 515, 515, 355, 515, 515, 515, - /* 2950 */ 515, 515, 515, 515, 515, 515, 515, 515, 515, 368, - /* 2960 */ 515, 515, 355, 515, 515, 515, 515, 515, 515, 515, - /* 2970 */ 515, 515, 515, 451, 515, 368, 454, 515, 355, 457, - /* 2980 */ 458, 459, 460, 461, 462, 515, 464, 396, 515, 515, - /* 2990 */ 515, 368, 515, 515, 515, 515, 515, 515, 515, 408, - /* 3000 */ 515, 410, 515, 396, 515, 515, 515, 515, 515, 515, - /* 3010 */ 515, 515, 515, 515, 515, 408, 515, 410, 515, 396, - /* 3020 */ 515, 515, 515, 515, 515, 515, 515, 515, 515, 515, - /* 3030 */ 515, 408, 515, 410, 515, 515, 515, 515, 515, 515, - /* 3040 */ 515, 515, 451, 515, 515, 454, 515, 515, 457, 458, - /* 3050 */ 459, 460, 461, 462, 515, 464, 515, 355, 451, 515, - /* 3060 */ 515, 454, 515, 515, 457, 458, 459, 460, 461, 462, - /* 3070 */ 368, 464, 515, 515, 451, 515, 355, 454, 515, 515, - /* 3080 */ 457, 458, 459, 460, 461, 462, 515, 464, 515, 368, - /* 3090 */ 515, 515, 355, 515, 515, 515, 515, 515, 396, 515, - /* 3100 */ 515, 515, 515, 515, 515, 368, 515, 515, 515, 515, - /* 3110 */ 408, 515, 410, 515, 515, 515, 515, 396, 515, 515, - /* 3120 */ 515, 515, 515, 515, 515, 515, 515, 515, 515, 408, - /* 3130 */ 515, 410, 515, 396, 515, 515, 515, 515, 515, 515, - /* 3140 */ 515, 515, 515, 515, 515, 408, 515, 410, 515, 515, - /* 3150 */ 515, 515, 515, 451, 515, 515, 454, 515, 515, 457, - /* 3160 */ 458, 459, 460, 461, 462, 515, 464, 515, 515, 515, - /* 3170 */ 515, 515, 451, 515, 515, 454, 515, 515, 457, 458, - /* 3180 */ 459, 460, 461, 462, 515, 464, 515, 515, 451, 515, - /* 3190 */ 515, 454, 515, 515, 457, 458, 459, 460, 461, 462, - /* 3200 */ 515, 464, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3210 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3220 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3230 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3240 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3250 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3260 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3270 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3280 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3290 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3300 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3310 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3320 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3330 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3340 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3350 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3360 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3370 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3380 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3390 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3400 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3410 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3420 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3430 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3440 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3450 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3460 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3470 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3480 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3490 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3500 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3510 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3520 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3530 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3540 */ 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, - /* 3550 */ 352, 352, 352, 352, + /* 130 */ 94, 95, 96, 97, 98, 99, 100, 484, 485, 486, + /* 140 */ 455, 488, 489, 458, 491, 145, 146, 462, 463, 464, + /* 150 */ 465, 466, 467, 18, 469, 454, 391, 401, 23, 474, + /* 160 */ 33, 476, 509, 510, 399, 480, 481, 514, 515, 51, + /* 170 */ 464, 488, 407, 107, 491, 40, 41, 20, 60, 44, + /* 180 */ 495, 63, 64, 183, 184, 145, 146, 108, 503, 54, + /* 190 */ 190, 191, 509, 510, 4, 107, 164, 514, 515, 69, + /* 200 */ 168, 66, 67, 68, 69, 205, 409, 207, 176, 412, + /* 210 */ 413, 8, 9, 23, 458, 12, 13, 14, 15, 16, + /* 220 */ 357, 370, 359, 21, 3, 469, 24, 25, 26, 27, + /* 230 */ 28, 29, 30, 31, 32, 108, 46, 47, 48, 239, + /* 240 */ 240, 241, 107, 243, 244, 245, 246, 247, 248, 249, + /* 250 */ 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, + /* 260 */ 260, 12, 13, 0, 386, 20, 18, 389, 20, 20, + /* 270 */ 204, 22, 206, 366, 71, 27, 370, 370, 30, 372, + /* 280 */ 370, 371, 147, 35, 35, 241, 37, 24, 25, 26, + /* 290 */ 27, 28, 29, 30, 31, 32, 445, 446, 2, 51, + /* 300 */ 390, 53, 236, 20, 8, 9, 58, 59, 12, 13, + /* 310 */ 14, 15, 16, 488, 65, 20, 491, 69, 115, 366, + /* 320 */ 71, 415, 416, 370, 418, 372, 20, 78, 422, 399, + /* 330 */ 200, 0, 197, 198, 199, 510, 406, 202, 377, 514, + /* 340 */ 515, 8, 9, 277, 414, 12, 13, 14, 15, 16, + /* 350 */ 215, 216, 107, 104, 106, 394, 107, 227, 228, 104, + /* 360 */ 14, 226, 398, 402, 229, 117, 20, 232, 233, 234, + /* 370 */ 235, 236, 399, 118, 410, 120, 121, 122, 123, 124, + /* 380 */ 125, 126, 127, 128, 129, 182, 131, 132, 133, 134, + /* 390 */ 135, 136, 137, 14, 145, 146, 423, 149, 150, 20, + /* 400 */ 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, + /* 410 */ 12, 13, 277, 165, 166, 167, 168, 169, 170, 171, + /* 420 */ 70, 173, 174, 175, 4, 370, 371, 179, 180, 181, + /* 430 */ 239, 379, 183, 184, 186, 37, 0, 8, 9, 190, + /* 440 */ 191, 12, 13, 14, 15, 16, 139, 140, 396, 20, + /* 450 */ 20, 144, 2, 117, 205, 20, 207, 405, 8, 9, + /* 460 */ 370, 371, 12, 13, 14, 15, 16, 264, 265, 266, + /* 470 */ 267, 268, 269, 270, 271, 272, 273, 274, 183, 184, + /* 480 */ 289, 290, 291, 292, 293, 294, 295, 51, 239, 240, + /* 490 */ 241, 185, 243, 244, 245, 246, 247, 248, 249, 250, + /* 500 */ 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, + /* 510 */ 261, 12, 13, 358, 140, 20, 399, 22, 144, 20, + /* 520 */ 299, 22, 277, 406, 107, 488, 371, 107, 491, 183, + /* 530 */ 197, 414, 37, 35, 35, 13, 37, 107, 4, 484, + /* 540 */ 485, 486, 358, 488, 489, 370, 371, 510, 261, 51, + /* 550 */ 55, 514, 515, 19, 399, 371, 1, 2, 60, 61, + /* 560 */ 62, 63, 231, 65, 65, 390, 411, 22, 413, 35, + /* 570 */ 71, 107, 189, 483, 484, 485, 486, 78, 488, 489, + /* 580 */ 145, 146, 37, 399, 65, 51, 370, 241, 214, 370, + /* 590 */ 371, 217, 58, 59, 220, 411, 222, 413, 3, 65, + /* 600 */ 78, 358, 14, 104, 106, 207, 107, 109, 20, 390, + /* 610 */ 455, 37, 461, 458, 185, 20, 397, 462, 463, 464, + /* 620 */ 465, 466, 467, 78, 469, 190, 191, 472, 109, 474, + /* 630 */ 475, 476, 370, 371, 33, 480, 481, 304, 487, 455, + /* 640 */ 106, 395, 458, 109, 145, 146, 462, 463, 464, 465, + /* 650 */ 466, 467, 390, 469, 411, 370, 371, 37, 474, 397, + /* 660 */ 476, 445, 446, 108, 480, 481, 283, 284, 285, 286, + /* 670 */ 241, 370, 371, 8, 9, 390, 178, 12, 13, 14, + /* 680 */ 15, 16, 183, 184, 358, 187, 188, 503, 4, 190, + /* 690 */ 191, 390, 194, 195, 277, 21, 450, 277, 33, 20, + /* 700 */ 104, 22, 0, 108, 205, 87, 207, 277, 370, 108, + /* 710 */ 36, 213, 38, 39, 40, 70, 120, 121, 122, 123, + /* 720 */ 124, 125, 126, 127, 128, 129, 358, 131, 132, 133, + /* 730 */ 134, 135, 136, 137, 55, 370, 371, 411, 239, 240, + /* 740 */ 241, 277, 243, 244, 245, 246, 247, 248, 249, 250, + /* 750 */ 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, + /* 760 */ 12, 13, 14, 358, 426, 427, 370, 371, 20, 151, + /* 770 */ 22, 183, 70, 108, 370, 371, 371, 358, 373, 411, + /* 780 */ 185, 207, 139, 35, 399, 37, 12, 13, 14, 15, + /* 790 */ 16, 406, 358, 472, 176, 177, 475, 370, 371, 414, + /* 800 */ 78, 73, 74, 75, 399, 371, 0, 373, 80, 81, + /* 810 */ 82, 237, 238, 65, 86, 419, 411, 390, 413, 91, + /* 820 */ 92, 93, 94, 419, 355, 97, 78, 207, 100, 241, + /* 830 */ 411, 22, 0, 399, 8, 9, 370, 371, 12, 13, + /* 840 */ 14, 15, 16, 182, 138, 411, 37, 413, 142, 484, + /* 850 */ 485, 486, 104, 488, 489, 107, 390, 237, 238, 358, + /* 860 */ 455, 218, 219, 458, 358, 358, 37, 462, 463, 464, + /* 870 */ 465, 466, 467, 0, 469, 370, 371, 371, 261, 474, + /* 880 */ 263, 476, 370, 371, 52, 480, 481, 78, 399, 455, + /* 890 */ 412, 413, 458, 145, 146, 390, 462, 463, 464, 465, + /* 900 */ 466, 467, 390, 469, 435, 399, 435, 78, 474, 440, + /* 910 */ 476, 117, 411, 104, 480, 481, 20, 411, 411, 413, + /* 920 */ 370, 371, 8, 9, 34, 264, 12, 13, 14, 15, + /* 930 */ 16, 183, 184, 50, 108, 274, 370, 371, 190, 191, + /* 940 */ 390, 400, 453, 454, 138, 139, 140, 141, 142, 143, + /* 950 */ 144, 56, 57, 205, 400, 207, 390, 488, 387, 488, + /* 960 */ 491, 455, 491, 279, 458, 14, 15, 16, 462, 463, + /* 970 */ 464, 465, 466, 467, 468, 469, 470, 471, 509, 510, + /* 980 */ 509, 510, 411, 514, 515, 514, 515, 239, 240, 241, + /* 990 */ 377, 243, 244, 245, 246, 247, 248, 249, 250, 251, + /* 1000 */ 252, 253, 254, 255, 256, 257, 258, 259, 260, 12, + /* 1010 */ 13, 65, 358, 435, 205, 402, 207, 20, 387, 22, + /* 1020 */ 358, 370, 371, 370, 371, 371, 400, 373, 435, 458, + /* 1030 */ 459, 460, 35, 0, 37, 162, 163, 370, 371, 399, + /* 1040 */ 469, 358, 411, 390, 358, 375, 376, 407, 239, 240, + /* 1050 */ 375, 376, 106, 399, 371, 109, 373, 390, 370, 371, + /* 1060 */ 370, 371, 65, 370, 371, 411, 488, 413, 185, 491, + /* 1070 */ 419, 370, 371, 411, 408, 78, 193, 411, 390, 183, + /* 1080 */ 390, 488, 399, 390, 491, 370, 371, 509, 510, 458, + /* 1090 */ 459, 390, 514, 515, 411, 42, 413, 411, 391, 185, + /* 1100 */ 469, 104, 509, 510, 107, 390, 399, 514, 515, 455, + /* 1110 */ 461, 20, 458, 358, 407, 20, 462, 463, 464, 465, + /* 1120 */ 466, 467, 441, 469, 178, 22, 371, 20, 474, 399, + /* 1130 */ 476, 370, 371, 358, 480, 481, 487, 241, 455, 461, + /* 1140 */ 37, 458, 145, 146, 414, 462, 463, 464, 465, 466, + /* 1150 */ 467, 390, 469, 435, 399, 435, 20, 474, 473, 476, + /* 1160 */ 475, 358, 391, 480, 481, 487, 411, 473, 413, 475, + /* 1170 */ 399, 138, 139, 140, 141, 142, 143, 144, 407, 379, + /* 1180 */ 183, 184, 384, 385, 399, 22, 411, 190, 191, 39, + /* 1190 */ 40, 33, 138, 139, 140, 141, 142, 143, 144, 414, + /* 1200 */ 37, 13, 205, 45, 207, 405, 488, 104, 488, 491, + /* 1210 */ 455, 491, 358, 458, 411, 33, 358, 462, 463, 464, + /* 1220 */ 465, 466, 467, 37, 469, 37, 358, 509, 510, 509, + /* 1230 */ 510, 400, 514, 515, 514, 515, 239, 240, 241, 178, + /* 1240 */ 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, + /* 1250 */ 253, 254, 255, 256, 257, 258, 259, 260, 12, 13, + /* 1260 */ 358, 111, 112, 358, 114, 411, 20, 104, 22, 411, + /* 1270 */ 209, 516, 517, 371, 358, 373, 185, 358, 0, 411, + /* 1280 */ 185, 35, 358, 37, 358, 358, 408, 399, 138, 411, + /* 1290 */ 358, 117, 142, 384, 385, 408, 392, 33, 411, 395, + /* 1300 */ 33, 399, 414, 371, 13, 373, 361, 362, 0, 275, + /* 1310 */ 276, 65, 45, 411, 110, 413, 411, 113, 110, 110, + /* 1320 */ 42, 113, 113, 110, 78, 0, 113, 411, 37, 276, + /* 1330 */ 411, 399, 241, 0, 0, 411, 241, 411, 411, 0, + /* 1340 */ 221, 33, 223, 411, 33, 413, 172, 22, 241, 33, + /* 1350 */ 104, 33, 33, 107, 400, 22, 22, 455, 49, 33, + /* 1360 */ 458, 22, 145, 146, 462, 463, 464, 465, 466, 467, + /* 1370 */ 388, 469, 108, 33, 1, 2, 474, 241, 476, 12, + /* 1380 */ 13, 71, 480, 481, 33, 33, 33, 455, 359, 22, + /* 1390 */ 458, 145, 146, 207, 462, 463, 464, 465, 466, 467, + /* 1400 */ 37, 469, 35, 33, 37, 33, 474, 33, 476, 33, + /* 1410 */ 12, 13, 480, 481, 107, 358, 107, 37, 424, 108, + /* 1420 */ 13, 518, 13, 116, 108, 507, 108, 108, 371, 183, + /* 1430 */ 184, 500, 65, 374, 399, 33, 190, 191, 33, 33, + /* 1440 */ 424, 33, 387, 33, 37, 78, 37, 387, 108, 369, + /* 1450 */ 33, 205, 424, 207, 0, 506, 399, 434, 78, 108, + /* 1460 */ 108, 108, 506, 506, 506, 424, 374, 371, 411, 442, + /* 1470 */ 413, 104, 410, 424, 424, 490, 511, 482, 108, 493, + /* 1480 */ 108, 280, 108, 301, 108, 239, 240, 241, 389, 243, + /* 1490 */ 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, + /* 1500 */ 254, 255, 256, 257, 258, 259, 260, 12, 13, 436, + /* 1510 */ 108, 51, 455, 108, 108, 458, 108, 22, 108, 462, + /* 1520 */ 463, 464, 465, 466, 467, 108, 469, 73, 74, 75, + /* 1530 */ 35, 474, 37, 476, 80, 81, 82, 480, 481, 358, + /* 1540 */ 86, 457, 42, 456, 20, 91, 92, 93, 94, 239, + /* 1550 */ 220, 97, 371, 447, 100, 379, 452, 447, 379, 203, + /* 1560 */ 65, 438, 20, 358, 370, 20, 371, 45, 420, 371, + /* 1570 */ 207, 420, 205, 182, 207, 420, 371, 417, 371, 417, + /* 1580 */ 399, 370, 370, 417, 417, 105, 383, 103, 382, 370, + /* 1590 */ 102, 381, 411, 370, 413, 370, 370, 20, 363, 358, + /* 1600 */ 50, 367, 363, 367, 399, 20, 239, 240, 447, 379, + /* 1610 */ 379, 379, 371, 413, 20, 372, 411, 20, 413, 379, + /* 1620 */ 253, 254, 255, 256, 257, 258, 259, 437, 372, 303, + /* 1630 */ 379, 20, 379, 379, 379, 370, 455, 363, 370, 458, + /* 1640 */ 399, 427, 224, 462, 463, 464, 465, 466, 467, 399, + /* 1650 */ 469, 399, 411, 361, 413, 474, 399, 476, 399, 399, + /* 1660 */ 455, 480, 481, 458, 361, 399, 451, 462, 463, 464, + /* 1670 */ 465, 466, 467, 411, 469, 399, 399, 363, 399, 474, + /* 1680 */ 399, 476, 399, 411, 411, 480, 481, 107, 20, 377, + /* 1690 */ 446, 449, 447, 211, 377, 210, 455, 413, 370, 458, + /* 1700 */ 205, 443, 207, 462, 463, 464, 465, 466, 467, 411, + /* 1710 */ 469, 436, 288, 444, 287, 499, 358, 476, 429, 499, + /* 1720 */ 502, 480, 481, 429, 296, 196, 297, 499, 501, 371, + /* 1730 */ 298, 498, 237, 238, 239, 497, 281, 436, 305, 302, + /* 1740 */ 519, 300, 513, 496, 276, 20, 358, 461, 253, 254, + /* 1750 */ 255, 256, 257, 258, 259, 371, 117, 399, 372, 371, + /* 1760 */ 512, 278, 377, 492, 494, 107, 377, 479, 411, 411, + /* 1770 */ 429, 413, 411, 411, 429, 411, 411, 188, 377, 425, + /* 1780 */ 377, 107, 395, 371, 403, 370, 411, 399, 411, 358, + /* 1790 */ 411, 377, 38, 22, 360, 448, 356, 393, 363, 411, + /* 1800 */ 364, 413, 371, 378, 393, 439, 393, 0, 430, 0, + /* 1810 */ 0, 45, 430, 455, 0, 37, 458, 230, 37, 37, + /* 1820 */ 462, 463, 464, 465, 466, 467, 37, 469, 230, 0, + /* 1830 */ 399, 37, 37, 230, 476, 37, 0, 230, 480, 481, + /* 1840 */ 0, 37, 411, 455, 413, 0, 458, 0, 37, 358, + /* 1850 */ 462, 463, 464, 465, 466, 467, 22, 469, 0, 37, + /* 1860 */ 225, 0, 371, 213, 476, 0, 213, 207, 480, 481, + /* 1870 */ 214, 358, 205, 0, 0, 0, 201, 200, 0, 0, + /* 1880 */ 150, 49, 49, 0, 371, 37, 455, 0, 0, 458, + /* 1890 */ 399, 37, 51, 462, 463, 464, 465, 466, 467, 0, + /* 1900 */ 469, 49, 411, 0, 413, 45, 0, 0, 0, 0, + /* 1910 */ 0, 49, 399, 168, 37, 0, 168, 0, 0, 0, + /* 1920 */ 0, 0, 0, 0, 411, 0, 413, 0, 0, 0, + /* 1930 */ 0, 0, 0, 0, 0, 504, 505, 0, 0, 0, + /* 1940 */ 0, 0, 0, 0, 49, 0, 455, 45, 0, 458, + /* 1950 */ 0, 358, 0, 462, 463, 464, 465, 466, 467, 0, + /* 1960 */ 469, 0, 0, 0, 371, 0, 22, 476, 455, 0, + /* 1970 */ 150, 458, 481, 149, 0, 462, 463, 464, 465, 466, + /* 1980 */ 467, 358, 469, 0, 0, 148, 0, 0, 22, 22, + /* 1990 */ 37, 65, 399, 37, 371, 0, 50, 0, 0, 358, + /* 2000 */ 65, 50, 0, 0, 411, 51, 413, 37, 51, 0, + /* 2010 */ 42, 51, 371, 42, 65, 37, 0, 42, 505, 37, + /* 2020 */ 0, 45, 399, 42, 33, 14, 433, 0, 49, 358, + /* 2030 */ 0, 0, 0, 43, 411, 0, 413, 49, 49, 196, + /* 2040 */ 399, 42, 371, 42, 0, 49, 0, 0, 455, 72, + /* 2050 */ 0, 458, 411, 0, 413, 462, 463, 464, 465, 466, + /* 2060 */ 467, 37, 469, 51, 42, 0, 37, 42, 51, 0, + /* 2070 */ 399, 37, 51, 0, 433, 42, 37, 51, 455, 42, + /* 2080 */ 0, 458, 411, 0, 413, 462, 463, 464, 465, 466, + /* 2090 */ 467, 0, 469, 0, 0, 0, 455, 37, 22, 458, + /* 2100 */ 115, 0, 53, 462, 463, 464, 465, 466, 467, 358, + /* 2110 */ 469, 37, 0, 113, 37, 37, 37, 0, 37, 37, + /* 2120 */ 33, 37, 371, 37, 0, 33, 455, 37, 358, 458, + /* 2130 */ 22, 508, 22, 462, 463, 464, 465, 466, 467, 37, + /* 2140 */ 469, 371, 22, 37, 22, 0, 358, 22, 37, 0, + /* 2150 */ 399, 0, 0, 37, 0, 37, 0, 22, 20, 371, + /* 2160 */ 108, 107, 411, 37, 413, 37, 37, 0, 107, 399, + /* 2170 */ 119, 0, 22, 118, 37, 0, 212, 185, 0, 49, + /* 2180 */ 208, 411, 22, 413, 0, 3, 192, 399, 517, 185, + /* 2190 */ 185, 33, 185, 185, 188, 107, 282, 108, 37, 411, + /* 2200 */ 37, 413, 192, 433, 107, 107, 455, 108, 1, 458, + /* 2210 */ 103, 108, 50, 462, 463, 464, 465, 466, 467, 105, + /* 2220 */ 469, 433, 471, 50, 33, 455, 19, 33, 458, 108, + /* 2230 */ 33, 3, 462, 463, 464, 465, 466, 467, 107, 469, + /* 2240 */ 107, 107, 35, 455, 108, 49, 458, 49, 358, 107, + /* 2250 */ 462, 463, 464, 465, 466, 467, 33, 469, 51, 33, + /* 2260 */ 49, 371, 282, 108, 37, 108, 37, 60, 61, 62, + /* 2270 */ 63, 358, 65, 37, 108, 37, 37, 37, 108, 33, + /* 2280 */ 49, 0, 0, 107, 371, 42, 33, 2, 105, 399, + /* 2290 */ 275, 105, 22, 108, 107, 282, 239, 108, 262, 49, + /* 2300 */ 107, 411, 107, 413, 49, 358, 22, 108, 242, 107, + /* 2310 */ 0, 108, 399, 106, 108, 107, 109, 107, 371, 107, + /* 2320 */ 42, 189, 107, 49, 411, 116, 413, 187, 107, 37, + /* 2330 */ 117, 358, 107, 37, 37, 37, 37, 37, 108, 107, + /* 2340 */ 107, 37, 108, 108, 371, 455, 399, 130, 458, 107, + /* 2350 */ 143, 358, 462, 463, 464, 465, 466, 467, 411, 469, + /* 2360 */ 413, 107, 118, 107, 371, 108, 108, 107, 455, 108, + /* 2370 */ 107, 458, 399, 108, 107, 462, 463, 464, 465, 466, + /* 2380 */ 467, 130, 469, 119, 411, 33, 413, 107, 22, 130, + /* 2390 */ 107, 37, 399, 107, 187, 72, 130, 71, 37, 37, + /* 2400 */ 37, 194, 455, 101, 411, 458, 413, 37, 37, 462, + /* 2410 */ 463, 464, 465, 466, 467, 37, 469, 37, 37, 37, + /* 2420 */ 213, 78, 78, 101, 33, 37, 37, 37, 455, 22, + /* 2430 */ 37, 458, 37, 358, 37, 462, 463, 464, 465, 466, + /* 2440 */ 467, 37, 469, 78, 22, 37, 371, 37, 455, 37, + /* 2450 */ 37, 458, 37, 0, 37, 462, 463, 464, 465, 466, + /* 2460 */ 467, 42, 469, 358, 0, 51, 37, 51, 42, 0, + /* 2470 */ 37, 51, 42, 0, 399, 37, 371, 42, 51, 0, + /* 2480 */ 37, 358, 37, 0, 22, 33, 411, 22, 413, 21, + /* 2490 */ 520, 520, 22, 22, 371, 21, 20, 520, 520, 520, + /* 2500 */ 520, 520, 520, 520, 399, 520, 520, 520, 520, 520, + /* 2510 */ 520, 520, 520, 520, 520, 520, 411, 520, 413, 520, + /* 2520 */ 520, 520, 399, 520, 520, 520, 520, 520, 520, 520, + /* 2530 */ 455, 520, 520, 458, 411, 520, 413, 462, 463, 464, + /* 2540 */ 465, 466, 467, 520, 469, 520, 520, 520, 520, 520, + /* 2550 */ 520, 520, 520, 520, 520, 520, 520, 520, 520, 520, + /* 2560 */ 455, 520, 358, 458, 520, 520, 520, 462, 463, 464, + /* 2570 */ 465, 466, 467, 520, 469, 371, 520, 520, 455, 520, + /* 2580 */ 358, 458, 520, 520, 520, 462, 463, 464, 465, 466, + /* 2590 */ 467, 520, 469, 371, 520, 358, 520, 520, 520, 520, + /* 2600 */ 520, 520, 520, 399, 520, 520, 520, 520, 371, 520, + /* 2610 */ 358, 520, 520, 520, 520, 411, 520, 413, 520, 520, + /* 2620 */ 520, 399, 520, 371, 520, 520, 520, 520, 520, 520, + /* 2630 */ 520, 520, 520, 411, 520, 413, 399, 520, 520, 520, + /* 2640 */ 520, 520, 520, 520, 520, 520, 520, 520, 411, 520, + /* 2650 */ 413, 399, 520, 520, 520, 520, 520, 520, 520, 455, + /* 2660 */ 520, 520, 458, 411, 520, 413, 462, 463, 464, 465, + /* 2670 */ 466, 467, 520, 469, 520, 520, 520, 455, 520, 520, + /* 2680 */ 458, 520, 520, 358, 462, 463, 464, 465, 466, 467, + /* 2690 */ 520, 469, 455, 520, 520, 458, 371, 520, 520, 462, + /* 2700 */ 463, 464, 465, 466, 467, 520, 469, 455, 520, 358, + /* 2710 */ 458, 520, 520, 520, 462, 463, 464, 465, 466, 467, + /* 2720 */ 520, 469, 371, 520, 399, 520, 520, 520, 520, 520, + /* 2730 */ 520, 358, 520, 520, 520, 520, 411, 520, 413, 520, + /* 2740 */ 520, 520, 520, 520, 371, 520, 520, 520, 520, 520, + /* 2750 */ 399, 520, 520, 520, 520, 520, 520, 520, 520, 520, + /* 2760 */ 520, 520, 411, 520, 413, 520, 520, 520, 520, 358, + /* 2770 */ 520, 520, 399, 520, 520, 520, 520, 520, 520, 520, + /* 2780 */ 455, 520, 371, 458, 411, 520, 413, 462, 463, 464, + /* 2790 */ 465, 466, 467, 520, 469, 520, 520, 520, 520, 520, + /* 2800 */ 520, 520, 520, 520, 520, 520, 455, 520, 520, 458, + /* 2810 */ 399, 520, 520, 462, 463, 464, 465, 466, 467, 520, + /* 2820 */ 469, 520, 411, 520, 413, 520, 520, 520, 455, 520, + /* 2830 */ 520, 458, 520, 520, 520, 462, 463, 464, 465, 466, + /* 2840 */ 467, 520, 469, 520, 520, 358, 520, 520, 520, 520, + /* 2850 */ 520, 520, 520, 520, 520, 520, 520, 520, 371, 520, + /* 2860 */ 520, 520, 520, 520, 520, 520, 455, 520, 520, 458, + /* 2870 */ 520, 520, 520, 462, 463, 464, 465, 466, 467, 520, + /* 2880 */ 469, 358, 520, 520, 520, 520, 399, 520, 520, 520, + /* 2890 */ 520, 520, 520, 520, 371, 520, 520, 520, 411, 520, + /* 2900 */ 413, 520, 520, 520, 520, 520, 520, 520, 520, 520, + /* 2910 */ 520, 520, 520, 520, 520, 520, 520, 520, 520, 358, + /* 2920 */ 520, 520, 399, 520, 520, 520, 520, 520, 520, 520, + /* 2930 */ 520, 520, 371, 520, 411, 520, 413, 520, 520, 520, + /* 2940 */ 520, 520, 455, 520, 520, 458, 520, 520, 520, 462, + /* 2950 */ 463, 464, 465, 466, 467, 520, 469, 520, 520, 520, + /* 2960 */ 399, 520, 358, 520, 520, 520, 520, 520, 520, 520, + /* 2970 */ 520, 520, 411, 520, 413, 371, 520, 520, 455, 520, + /* 2980 */ 358, 458, 520, 520, 520, 462, 463, 464, 465, 466, + /* 2990 */ 467, 520, 469, 371, 520, 358, 520, 520, 520, 520, + /* 3000 */ 520, 520, 520, 399, 520, 520, 520, 520, 371, 520, + /* 3010 */ 520, 520, 520, 520, 520, 411, 455, 413, 520, 458, + /* 3020 */ 520, 399, 520, 462, 463, 464, 465, 466, 467, 520, + /* 3030 */ 469, 520, 520, 411, 520, 413, 399, 520, 520, 520, + /* 3040 */ 520, 520, 520, 520, 520, 520, 520, 520, 411, 520, + /* 3050 */ 413, 520, 520, 520, 520, 520, 520, 520, 520, 455, + /* 3060 */ 520, 520, 458, 520, 520, 520, 462, 463, 464, 465, + /* 3070 */ 466, 467, 520, 469, 520, 520, 520, 455, 520, 520, + /* 3080 */ 458, 520, 520, 520, 462, 463, 464, 465, 466, 467, + /* 3090 */ 520, 469, 455, 520, 520, 458, 520, 520, 520, 462, + /* 3100 */ 463, 464, 465, 466, 467, 520, 469, 355, 355, 355, + /* 3110 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3120 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3130 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3140 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3150 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3160 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3170 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3180 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3190 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3200 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3210 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3220 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3230 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3240 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3250 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3260 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3270 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3280 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3290 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3300 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3310 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3320 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3330 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3340 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3350 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3360 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3370 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3380 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3390 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3400 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3410 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3420 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3430 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3440 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3450 */ 355, 355, 355, 355, 355, 355, 355, 355, 355, 355, + /* 3460 */ 355, 355, }; -#define YY_SHIFT_COUNT (856) +#define YY_SHIFT_COUNT (864) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2406) +#define YY_SHIFT_MAX (2483) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 132, 0, 246, 0, 493, 493, 493, 493, 493, 493, - /* 10 */ 493, 493, 493, 493, 493, 493, 739, 985, 985, 1231, - /* 20 */ 985, 985, 985, 985, 985, 985, 985, 985, 985, 985, - /* 30 */ 985, 985, 985, 985, 985, 985, 985, 985, 985, 985, - /* 40 */ 985, 985, 985, 985, 985, 985, 985, 985, 985, 985, - /* 50 */ 985, 185, 242, 84, 52, 87, 122, 87, 87, 52, - /* 60 */ 52, 87, 1345, 87, 245, 1345, 1345, 542, 87, 19, - /* 70 */ 612, 86, 86, 536, 536, 612, 250, 57, 94, 94, - /* 80 */ 352, 86, 86, 86, 86, 86, 86, 86, 86, 86, - /* 90 */ 86, 86, 150, 197, 86, 86, 18, 19, 86, 150, - /* 100 */ 86, 19, 86, 86, 19, 86, 86, 19, 86, 19, - /* 110 */ 19, 19, 86, 190, 200, 200, 495, 66, 734, 734, - /* 120 */ 734, 734, 734, 734, 734, 734, 734, 734, 734, 734, - /* 130 */ 734, 734, 734, 734, 734, 734, 734, 436, 161, 250, - /* 140 */ 57, 910, 910, 142, 288, 288, 288, 635, 117, 117, - /* 150 */ 590, 142, 18, 19, 511, 19, 19, 291, 19, 281, - /* 160 */ 19, 281, 281, 533, 539, 490, 826, 826, 826, 826, - /* 170 */ 826, 826, 826, 2294, 1190, 21, 46, 15, 544, 88, - /* 180 */ 47, 582, 616, 319, 319, 540, 876, 664, 994, 994, - /* 190 */ 994, 891, 994, 786, 609, 835, 1253, 677, 971, 835, - /* 200 */ 835, 856, 914, 752, 859, 914, 484, 974, 590, 1164, - /* 210 */ 1394, 1402, 1426, 1238, 18, 1426, 18, 1287, 1474, 1476, - /* 220 */ 1453, 1476, 1453, 1336, 1474, 1476, 1474, 1453, 1336, 1336, - /* 230 */ 1336, 1433, 1439, 1474, 1446, 1474, 1474, 1474, 1543, 1518, - /* 240 */ 1543, 1518, 1426, 18, 18, 1559, 18, 1564, 1567, 18, - /* 250 */ 1564, 18, 1573, 18, 18, 1474, 18, 1543, 19, 19, - /* 260 */ 19, 19, 19, 19, 19, 19, 19, 19, 19, 1474, - /* 270 */ 539, 539, 1543, 281, 281, 281, 1418, 1539, 1426, 190, - /* 280 */ 1629, 1447, 1449, 1559, 190, 1164, 1474, 281, 1379, 1384, - /* 290 */ 1379, 1384, 1377, 1477, 1379, 1380, 1387, 1399, 1164, 1376, - /* 300 */ 1385, 1389, 1409, 1476, 1672, 1585, 1428, 1564, 190, 190, - /* 310 */ 1384, 281, 281, 281, 281, 1384, 281, 1530, 190, 533, - /* 320 */ 190, 1476, 1622, 1624, 281, 1474, 190, 1716, 1702, 1543, - /* 330 */ 3202, 3202, 3202, 3202, 3202, 3202, 3202, 3202, 3202, 36, - /* 340 */ 492, 312, 1023, 67, 210, 219, 380, 777, 1021, 1169, - /* 350 */ 393, 679, 679, 679, 679, 679, 679, 679, 679, 679, - /* 360 */ 905, 628, 157, 370, 370, 96, 101, 310, 758, 394, - /* 370 */ 908, 792, 995, 755, 423, 423, 496, 963, 499, 496, - /* 380 */ 496, 496, 1013, 1039, 624, 827, 1252, 1107, 1275, 1178, - /* 390 */ 1179, 1189, 1193, 31, 1053, 1293, 1307, 1310, 1311, 1092, - /* 400 */ 1261, 1280, 1230, 1291, 1292, 1301, 1303, 1174, 911, 1081, - /* 410 */ 1309, 1323, 1342, 1350, 1352, 1354, 1329, 1383, 1186, 1391, - /* 420 */ 1256, 1392, 1393, 1395, 1420, 1421, 1422, 181, 932, 1284, - /* 430 */ 1349, 1361, 1300, 1355, 1760, 1763, 1764, 1720, 1767, 1732, - /* 440 */ 1541, 1734, 1738, 1740, 1549, 1780, 1744, 1745, 1554, 1747, - /* 450 */ 1785, 1557, 1787, 1751, 1789, 1753, 1792, 1771, 1794, 1758, - /* 460 */ 1572, 1797, 1586, 1799, 1588, 1589, 1595, 1599, 1805, 1806, - /* 470 */ 1808, 1609, 1611, 1811, 1812, 1663, 1765, 1766, 1816, 1781, - /* 480 */ 1822, 1829, 1796, 1783, 1831, 1786, 1838, 1795, 1839, 1843, - /* 490 */ 1845, 1798, 1848, 1850, 1851, 1852, 1853, 1854, 1688, 1819, - /* 500 */ 1857, 1691, 1859, 1860, 1861, 1863, 1864, 1867, 1874, 1876, - /* 510 */ 1878, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1888, 1892, - /* 520 */ 1899, 1855, 1901, 1868, 1902, 1905, 1906, 1908, 1909, 1912, - /* 530 */ 1914, 1893, 1917, 1768, 1920, 1773, 1923, 1776, 1925, 1926, - /* 540 */ 1907, 1877, 1924, 1903, 1928, 1865, 1894, 1933, 1869, 1936, - /* 550 */ 1889, 1951, 1955, 1922, 1910, 1918, 1963, 1927, 1915, 1932, - /* 560 */ 1967, 1939, 1929, 1935, 1979, 1944, 1991, 1940, 1942, 1953, - /* 570 */ 1938, 1945, 1974, 1947, 1989, 1954, 1956, 1993, 2000, 2001, - /* 580 */ 2003, 1962, 1818, 2014, 1938, 1966, 2016, 2017, 1946, 2019, - /* 590 */ 2020, 1985, 1970, 1982, 2025, 1990, 1975, 1986, 2029, 1994, - /* 600 */ 1981, 1988, 2034, 2008, 1987, 2005, 2048, 2050, 2051, 2052, - /* 610 */ 2053, 2054, 1941, 1948, 2018, 2035, 2058, 2022, 2023, 2026, - /* 620 */ 2028, 2030, 2031, 2032, 2033, 2038, 2039, 2036, 2037, 2044, - /* 630 */ 2042, 2075, 2060, 2076, 2061, 2080, 2070, 2040, 2094, 2073, - /* 640 */ 2059, 2097, 2098, 2099, 2063, 2101, 2066, 2111, 2084, 2087, - /* 650 */ 2071, 2072, 2077, 2004, 2006, 2115, 1934, 1998, 2002, 2013, - /* 660 */ 1916, 1938, 2074, 2122, 1949, 2088, 2104, 2128, 1931, 2107, - /* 670 */ 1952, 1957, 2131, 2132, 1958, 1943, 1959, 1968, 2137, 2102, - /* 680 */ 1862, 2043, 2041, 2055, 2049, 2109, 2110, 2057, 2089, 2056, - /* 690 */ 2124, 2069, 2067, 2143, 2145, 2078, 2081, 2082, 2083, 2079, - /* 700 */ 2147, 2133, 2134, 2086, 2148, 1913, 2090, 2091, 2181, 2152, - /* 710 */ 1921, 2154, 2157, 2158, 2159, 2164, 2165, 2095, 2096, 2156, - /* 720 */ 1937, 2174, 2162, 2208, 2212, 2108, 2171, 2112, 2114, 2116, - /* 730 */ 2118, 2125, 2065, 2129, 2214, 2175, 2062, 2130, 2100, 1938, - /* 740 */ 2169, 2206, 2135, 1983, 2136, 2242, 2223, 2010, 2140, 2141, - /* 750 */ 2144, 2146, 2149, 2150, 2210, 2153, 2161, 2215, 2155, 2233, - /* 760 */ 2045, 2163, 2160, 2167, 2220, 2224, 2173, 2170, 2228, 2176, - /* 770 */ 2177, 2232, 2179, 2180, 2234, 2182, 2183, 2236, 2185, 2186, - /* 780 */ 2244, 2190, 2142, 2168, 2178, 2184, 2191, 2172, 2202, 2249, - /* 790 */ 2204, 2250, 2205, 2249, 2249, 2293, 2259, 2245, 2285, 2295, - /* 800 */ 2296, 2297, 2298, 2299, 2300, 2301, 2303, 2263, 2241, 2265, - /* 810 */ 2243, 2314, 2311, 2312, 2313, 2329, 2316, 2324, 2326, 2288, - /* 820 */ 2038, 2330, 2039, 2337, 2339, 2341, 2342, 2359, 2345, 2383, - /* 830 */ 2347, 2334, 2344, 2387, 2351, 2338, 2348, 2391, 2356, 2355, - /* 840 */ 2353, 2396, 2360, 2362, 2357, 2398, 2378, 2379, 2402, 2399, - /* 850 */ 2385, 2400, 2403, 2401, 2404, 2406, 2405, + /* 0 */ 135, 0, 249, 0, 499, 499, 499, 499, 499, 499, + /* 10 */ 499, 499, 499, 499, 499, 499, 748, 997, 997, 1246, + /* 20 */ 997, 997, 997, 997, 997, 997, 997, 997, 997, 997, + /* 30 */ 997, 997, 997, 997, 997, 997, 997, 997, 997, 997, + /* 40 */ 997, 997, 997, 997, 997, 997, 997, 997, 997, 997, + /* 50 */ 245, 430, 66, 88, 417, 464, 417, 417, 88, 88, + /* 60 */ 417, 1367, 417, 248, 1367, 420, 417, 14, 1495, 435, + /* 70 */ 59, 59, 1495, 1495, 190, 190, 435, 295, 40, 24, + /* 80 */ 24, 44, 59, 59, 59, 59, 59, 59, 59, 59, + /* 90 */ 59, 59, 59, 157, 283, 59, 59, 350, 14, 59, + /* 100 */ 157, 59, 14, 59, 59, 14, 59, 59, 14, 59, + /* 110 */ 14, 14, 14, 59, 645, 203, 203, 728, 202, 809, + /* 120 */ 809, 809, 809, 809, 809, 809, 809, 809, 809, 809, + /* 130 */ 809, 809, 809, 809, 809, 809, 809, 809, 1150, 595, + /* 140 */ 295, 40, 895, 895, 829, 306, 306, 306, 617, 617, + /* 150 */ 702, 522, 829, 350, 14, 336, 14, 287, 14, 14, + /* 160 */ 722, 14, 722, 722, 794, 890, 255, 596, 596, 596, + /* 170 */ 596, 596, 596, 596, 2207, 1454, 21, 429, 333, 191, + /* 180 */ 383, 495, 346, 588, 398, 398, 1091, 38, 1095, 545, + /* 190 */ 545, 545, 883, 896, 545, 679, 1107, 379, 706, 1061, + /* 200 */ 1107, 1107, 1136, 1034, 1053, 221, 1034, 1158, 684, 522, + /* 210 */ 1201, 1460, 1500, 1524, 1330, 350, 1524, 350, 1356, 1542, + /* 220 */ 1545, 1522, 1545, 1522, 1391, 1542, 1545, 1542, 1522, 1391, + /* 230 */ 1391, 1391, 1480, 1484, 1542, 1488, 1542, 1542, 1542, 1577, + /* 240 */ 1550, 1577, 1550, 1524, 350, 350, 1585, 350, 1594, 1597, + /* 250 */ 350, 1594, 350, 1611, 350, 350, 1542, 350, 1577, 14, + /* 260 */ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, + /* 270 */ 1542, 890, 890, 1577, 722, 722, 722, 1418, 1580, 1524, + /* 280 */ 645, 1668, 1482, 1485, 1585, 645, 1201, 1542, 722, 1424, + /* 290 */ 1427, 1424, 1427, 1428, 1529, 1424, 1432, 1429, 1455, 1201, + /* 300 */ 1433, 1437, 1441, 1468, 1545, 1725, 1639, 1483, 1594, 645, + /* 310 */ 645, 1658, 1427, 722, 722, 722, 722, 1427, 722, 1589, + /* 320 */ 645, 794, 645, 1545, 722, 722, 1674, 722, 1542, 645, + /* 330 */ 1771, 1754, 1577, 3107, 3107, 3107, 3107, 3107, 3107, 3107, + /* 340 */ 3107, 3107, 36, 498, 263, 534, 665, 79, 826, 296, + /* 350 */ 450, 914, 806, 1033, 54, 54, 54, 54, 54, 54, + /* 360 */ 54, 54, 54, 1054, 374, 674, 774, 774, 130, 946, + /* 370 */ 32, 618, 118, 574, 620, 873, 1103, 1163, 643, 951, + /* 380 */ 555, 661, 951, 951, 951, 307, 307, 436, 331, 127, + /* 390 */ 1278, 1267, 1174, 1308, 1204, 1208, 1209, 1213, 1188, 1291, + /* 400 */ 1325, 1333, 1334, 1339, 1119, 601, 1264, 519, 1311, 1316, + /* 410 */ 1318, 1319, 1217, 1182, 1326, 1340, 1373, 1351, 1310, 1352, + /* 420 */ 1309, 1353, 1370, 1372, 1374, 1376, 1398, 1402, 1405, 1406, + /* 430 */ 1408, 1410, 1417, 1307, 1186, 1363, 1407, 1409, 1380, 832, + /* 440 */ 1807, 1809, 1810, 1766, 1814, 1778, 1587, 1781, 1782, 1789, + /* 450 */ 1598, 1829, 1794, 1795, 1603, 1798, 1836, 1607, 1840, 1804, + /* 460 */ 1845, 1811, 1847, 1834, 1858, 1822, 1635, 1861, 1650, 1865, + /* 470 */ 1653, 1656, 1660, 1667, 1873, 1874, 1875, 1675, 1677, 1878, + /* 480 */ 1879, 1730, 1832, 1833, 1883, 1848, 1887, 1888, 1854, 1841, + /* 490 */ 1899, 1852, 1903, 1860, 1906, 1907, 1908, 1862, 1909, 1910, + /* 500 */ 1925, 1927, 1928, 1929, 1745, 1877, 1915, 1748, 1917, 1918, + /* 510 */ 1919, 1920, 1921, 1922, 1923, 1930, 1931, 1932, 1933, 1934, + /* 520 */ 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1895, 1945, 1902, + /* 530 */ 1948, 1950, 1952, 1959, 1961, 1962, 1963, 1965, 1944, 1969, + /* 540 */ 1820, 1983, 1824, 1974, 1837, 1984, 1986, 1966, 1946, 1967, + /* 550 */ 1951, 1987, 1926, 1953, 1995, 1935, 1997, 1949, 1998, 2002, + /* 560 */ 1956, 1954, 1968, 2003, 1970, 1957, 1971, 2009, 1978, 1960, + /* 570 */ 1975, 2016, 1982, 2020, 1976, 1981, 1991, 1979, 1988, 2011, + /* 580 */ 1989, 2027, 1990, 1999, 2030, 2031, 2032, 2035, 2001, 1843, + /* 590 */ 2044, 1979, 1996, 2046, 2047, 1977, 2050, 2053, 2024, 2012, + /* 600 */ 2022, 2065, 2029, 2017, 2025, 2069, 2034, 2021, 2033, 2073, + /* 610 */ 2039, 2026, 2037, 2080, 2083, 2091, 2093, 2094, 2095, 1985, + /* 620 */ 2000, 2060, 2076, 2101, 2074, 2077, 2078, 2079, 2081, 2082, + /* 630 */ 2084, 2086, 2087, 2092, 2090, 2102, 2108, 2106, 2112, 2110, + /* 640 */ 2117, 2120, 2124, 2122, 2049, 2145, 2125, 2111, 2149, 2151, + /* 650 */ 2152, 2116, 2154, 2118, 2156, 2135, 2138, 2126, 2128, 2129, + /* 660 */ 2052, 2054, 2167, 1992, 2055, 2051, 2061, 1964, 1979, 2130, + /* 670 */ 2171, 2004, 2137, 2150, 2175, 1972, 2160, 2005, 2006, 2178, + /* 680 */ 2184, 2007, 1994, 2008, 2010, 2182, 2158, 1914, 2088, 2089, + /* 690 */ 2097, 2099, 2161, 2163, 2098, 2162, 2114, 2173, 2107, 2103, + /* 700 */ 2191, 2194, 2121, 2131, 2133, 2134, 2136, 2197, 2196, 2198, + /* 710 */ 2142, 2223, 1980, 2155, 2157, 2228, 2226, 2013, 2227, 2229, + /* 720 */ 2236, 2238, 2239, 2240, 2166, 2170, 2211, 2015, 2246, 2231, + /* 730 */ 2281, 2282, 2176, 2243, 2253, 2183, 2036, 2186, 2285, 2270, + /* 740 */ 2057, 2185, 2187, 2189, 2250, 2193, 2195, 2255, 2199, 2284, + /* 750 */ 2066, 2202, 2203, 2206, 2208, 2210, 2132, 2212, 2310, 2278, + /* 760 */ 2140, 2215, 2209, 1979, 2274, 2221, 2225, 2230, 2232, 2233, + /* 770 */ 2213, 2234, 2292, 2296, 2242, 2235, 2297, 2254, 2257, 2298, + /* 780 */ 2256, 2258, 2299, 2260, 2261, 2300, 2263, 2265, 2304, 2267, + /* 790 */ 2217, 2251, 2259, 2266, 2264, 2244, 2280, 2352, 2283, 2354, + /* 800 */ 2286, 2352, 2352, 2366, 2323, 2326, 2361, 2362, 2363, 2370, + /* 810 */ 2371, 2378, 2380, 2381, 2382, 2343, 2302, 2344, 2322, 2391, + /* 820 */ 2388, 2389, 2390, 2407, 2393, 2395, 2397, 2365, 2087, 2404, + /* 830 */ 2092, 2408, 2410, 2412, 2413, 2422, 2415, 2453, 2417, 2414, + /* 840 */ 2419, 2464, 2429, 2416, 2426, 2469, 2433, 2420, 2430, 2473, + /* 850 */ 2438, 2427, 2435, 2479, 2443, 2445, 2483, 2462, 2452, 2465, + /* 860 */ 2468, 2470, 2471, 2474, 2476, }; -#define YY_REDUCE_COUNT (338) -#define YY_REDUCE_MIN (-466) -#define YY_REDUCE_MAX (2737) +#define YY_REDUCE_COUNT (341) +#define YY_REDUCE_MIN (-484) +#define YY_REDUCE_MAX (2637) static const short yy_reduce_ofst[] = { - /* 0 */ -131, 183, 252, -20, 399, 429, 456, 644, 683, 890, - /* 10 */ 1051, 1096, 1168, 1237, 1297, 1366, 754, 1411, 1436, 1481, - /* 20 */ 1511, 1548, 1582, 1627, 1694, 1709, 1769, 1842, 1866, 1911, - /* 30 */ 1950, 1984, 2009, 2085, 2106, 2166, 2235, 2251, 2267, 2346, - /* 40 */ 2365, 2381, 2441, 2462, 2522, 2591, 2607, 2623, 2702, 2721, - /* 50 */ 2737, -342, -219, 818, -327, 885, 887, 929, 1035, 398, - /* 60 */ 717, 1102, 201, -184, -106, -365, 657, 56, 191, -386, - /* 70 */ 116, -207, 59, -362, -357, -372, -249, -336, -352, 53, - /* 80 */ 113, -282, -94, 303, 395, 140, 237, 455, 505, 569, - /* 90 */ 641, 299, 266, 294, 634, 689, 270, -42, 693, 284, - /* 100 */ 700, 385, 710, 749, 417, 759, 789, 407, 793, 507, - /* 110 */ 608, 622, 805, 409, -466, -466, -237, -322, -21, 347, - /* 120 */ 365, 420, 432, 704, 731, 741, 745, 763, 780, 796, - /* 130 */ 838, 839, 840, 844, 847, 848, 851, -113, -35, -119, - /* 140 */ 70, 751, 797, 784, -35, -8, 124, -225, -367, 397, - /* 150 */ -198, 880, 598, -7, 68, -395, -253, 472, 729, 702, - /* 160 */ 501, 802, 869, 614, 921, 292, 301, 454, 474, 504, - /* 170 */ 509, 522, 292, 340, 541, 579, 594, 549, 626, 668, - /* 180 */ 946, 930, 930, 956, 959, 924, 980, 943, 871, 878, - /* 190 */ 883, 972, 892, 930, 1030, 982, 1036, 998, 970, 997, - /* 200 */ 1006, 930, 944, 944, 926, 944, 953, 948, 1054, 1010, - /* 210 */ 990, 996, 1009, 1008, 1087, 1022, 1094, 1059, 1128, 1129, - /* 220 */ 1090, 1146, 1099, 1105, 1157, 1163, 1158, 1115, 1120, 1121, - /* 230 */ 1123, 1161, 1167, 1176, 1181, 1185, 1194, 1195, 1206, 1205, - /* 240 */ 1210, 1209, 1131, 1199, 1201, 1170, 1207, 1217, 1156, 1214, - /* 250 */ 1222, 1218, 1180, 1226, 1227, 1241, 1233, 1250, 1219, 1220, - /* 260 */ 1221, 1224, 1225, 1228, 1235, 1239, 1240, 1242, 1244, 1246, - /* 270 */ 1260, 1265, 1254, 1234, 1243, 1245, 1187, 1203, 1211, 1276, - /* 280 */ 1213, 1216, 1223, 1249, 1286, 1229, 1296, 1258, 1173, 1247, - /* 290 */ 1175, 1248, 1182, 1184, 1177, 1183, 1191, 1196, 1257, 1171, - /* 300 */ 1192, 1197, 944, 1322, 1255, 1236, 1232, 1337, 1335, 1340, - /* 310 */ 1289, 1302, 1308, 1312, 1314, 1298, 1315, 1304, 1344, 1338, - /* 320 */ 1353, 1360, 1259, 1332, 1327, 1369, 1363, 1382, 1381, 1386, - /* 330 */ 1306, 1299, 1317, 1318, 1357, 1359, 1362, 1375, 1400, + /* 0 */ 469, -315, 155, 184, 405, 434, 654, 683, 902, 932, + /* 10 */ 1057, 1181, 1205, 1241, 1358, 1388, 506, 1431, 755, 1491, + /* 20 */ 1513, 1593, 1641, 1623, 1671, 1751, 1770, 1788, 1890, 1913, + /* 30 */ 1947, 1973, 1993, 2075, 2105, 2123, 2204, 2222, 2237, 2252, + /* 40 */ 2325, 2351, 2373, 2411, 2487, 2523, 2561, 2604, 2622, 2637, + /* 50 */ -347, -317, -434, 90, 471, 578, 593, 718, 55, 365, + /* 60 */ 720, 571, -484, -94, 631, -175, 37, -380, -386, -373, + /* 70 */ 219, 262, -368, -244, -360, -266, -403, -382, -203, -93, + /* 80 */ -47, -294, -90, 175, 285, 301, 396, 404, 427, 466, + /* 90 */ 505, 512, 651, -149, 338, 550, 566, 52, 489, 653, + /* 100 */ 216, 667, -70, 688, 690, -235, 693, 701, 117, 715, + /* 110 */ 707, 385, 771, 761, -39, -475, -475, -274, -137, 243, + /* 120 */ 326, 368, 419, 501, 507, 662, 686, 775, 803, 854, + /* 130 */ 858, 868, 905, 916, 919, 924, 926, 927, -36, 151, + /* 140 */ -27, 478, 670, 675, 798, 151, 649, 678, 685, 694, + /* 150 */ 613, -122, 909, 800, -299, 246, 730, 321, 785, 640, + /* 160 */ 666, 888, 878, 887, 904, 945, -400, -384, 541, 554, + /* 170 */ 626, 831, 954, -400, 681, 982, 1029, 994, 903, 918, + /* 180 */ 931, 1059, 1035, 1035, 1055, 1060, 1016, 1080, 1028, 949, + /* 190 */ 956, 957, 1023, 1035, 958, 1092, 1041, 1096, 1062, 1027, + /* 200 */ 1049, 1050, 1035, 985, 985, 965, 985, 995, 986, 1099, + /* 210 */ 1073, 1084, 1087, 1106, 1104, 1176, 1110, 1179, 1123, 1194, + /* 220 */ 1195, 1148, 1198, 1151, 1160, 1211, 1207, 1212, 1155, 1162, + /* 230 */ 1166, 1167, 1203, 1206, 1219, 1210, 1223, 1225, 1226, 1235, + /* 240 */ 1234, 1239, 1236, 1161, 1230, 1231, 1200, 1232, 1243, 1190, + /* 250 */ 1240, 1256, 1251, 1214, 1253, 1254, 1265, 1255, 1274, 1250, + /* 260 */ 1252, 1257, 1259, 1260, 1266, 1276, 1277, 1279, 1281, 1283, + /* 270 */ 1268, 1292, 1303, 1314, 1262, 1272, 1273, 1215, 1242, 1245, + /* 280 */ 1312, 1244, 1269, 1258, 1284, 1317, 1275, 1328, 1298, 1216, + /* 290 */ 1289, 1220, 1294, 1218, 1227, 1228, 1233, 1238, 1247, 1301, + /* 300 */ 1221, 1229, 1248, 985, 1384, 1286, 1270, 1271, 1386, 1385, + /* 310 */ 1389, 1288, 1341, 1357, 1361, 1362, 1364, 1345, 1365, 1354, + /* 320 */ 1401, 1387, 1403, 1412, 1375, 1377, 1381, 1379, 1415, 1414, + /* 330 */ 1434, 1436, 1435, 1366, 1347, 1378, 1382, 1404, 1411, 1413, + /* 340 */ 1425, 1440, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 10 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 20 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 30 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 40 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 50 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 60 */ 1918, 2259, 1918, 1918, 2222, 1918, 1918, 1918, 1918, 1918, - /* 70 */ 1918, 1918, 1918, 1918, 1918, 1918, 2229, 1918, 1918, 1918, - /* 80 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 90 */ 1918, 1918, 1918, 1918, 1918, 1918, 2017, 1918, 1918, 1918, - /* 100 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 110 */ 1918, 1918, 1918, 2015, 2466, 1918, 1918, 1918, 1918, 1918, - /* 120 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 130 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 2478, 1918, - /* 140 */ 1918, 1989, 1989, 1918, 2478, 2478, 2478, 2015, 2438, 2438, - /* 150 */ 1918, 1918, 2017, 1918, 2301, 1918, 1918, 1918, 1918, 1918, - /* 160 */ 1918, 1918, 1918, 2141, 1948, 2299, 1918, 1918, 1918, 1918, - /* 170 */ 1918, 1918, 1918, 2285, 1918, 1918, 2507, 2569, 1918, 2510, - /* 180 */ 1918, 1918, 1918, 1918, 1918, 2234, 1918, 2497, 1918, 1918, - /* 190 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 2093, 2279, 1918, - /* 200 */ 1918, 1918, 2470, 2484, 2553, 2471, 2468, 2491, 1918, 2501, - /* 210 */ 1918, 2326, 1918, 2315, 2017, 1918, 2017, 2272, 2217, 1918, - /* 220 */ 2227, 1918, 2227, 2224, 1918, 1918, 1918, 2227, 2224, 2224, - /* 230 */ 2224, 2082, 2078, 1918, 2076, 1918, 1918, 1918, 1918, 1973, - /* 240 */ 1918, 1973, 1918, 2017, 2017, 1918, 2017, 1918, 1918, 2017, - /* 250 */ 1918, 2017, 1918, 2017, 2017, 1918, 2017, 1918, 1918, 1918, - /* 260 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 270 */ 1918, 1918, 1918, 1918, 1918, 1918, 2313, 2295, 1918, 2015, - /* 280 */ 1918, 2283, 2281, 1918, 2015, 2501, 1918, 1918, 2523, 2518, - /* 290 */ 2523, 2518, 2537, 2533, 2523, 2542, 2539, 2503, 2501, 2572, - /* 300 */ 2559, 2555, 2484, 1918, 1918, 2489, 2487, 1918, 2015, 2015, - /* 310 */ 2518, 1918, 1918, 1918, 1918, 2518, 1918, 1918, 2015, 1918, - /* 320 */ 2015, 1918, 1918, 2109, 1918, 1918, 2015, 1918, 1957, 1918, - /* 330 */ 2274, 2304, 2255, 2255, 2144, 2144, 2144, 2018, 1923, 1918, - /* 340 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 350 */ 1918, 2536, 2535, 2391, 1918, 2442, 2441, 2440, 2431, 2390, - /* 360 */ 2105, 1918, 1918, 2389, 2388, 1918, 1918, 1918, 1918, 1918, - /* 370 */ 1918, 1918, 1918, 1918, 2246, 2245, 2382, 1918, 1918, 2383, - /* 380 */ 2381, 2380, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 390 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 400 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 2556, 2560, - /* 410 */ 1918, 1918, 1918, 1918, 1918, 1918, 2467, 1918, 1918, 1918, - /* 420 */ 2362, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 430 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 440 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 450 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 460 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 470 */ 1918, 1918, 1918, 1918, 1918, 2223, 1918, 1918, 1918, 1918, - /* 480 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 490 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 500 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 510 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 520 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 530 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 2238, 1918, 1918, - /* 540 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 550 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 560 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1962, - /* 570 */ 2369, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 580 */ 1918, 1918, 1918, 1918, 2372, 1918, 1918, 1918, 1918, 1918, - /* 590 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 600 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 610 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 620 */ 1918, 1918, 1918, 1918, 1918, 2057, 2056, 1918, 1918, 1918, - /* 630 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 640 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 650 */ 1918, 1918, 1918, 2373, 1918, 1918, 1918, 2299, 1918, 1918, - /* 660 */ 1918, 2364, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 670 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 2552, 2504, - /* 680 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 690 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 700 */ 1918, 1918, 2362, 1918, 2534, 1918, 1918, 2550, 1918, 2554, - /* 710 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 2477, 2473, 1918, - /* 720 */ 1918, 2469, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 730 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 2361, - /* 740 */ 1918, 2428, 1918, 1918, 1918, 2462, 1918, 1918, 2413, 1918, - /* 750 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 2373, 1918, - /* 760 */ 2376, 1918, 1918, 1918, 1918, 1918, 2138, 1918, 1918, 1918, - /* 770 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 780 */ 1918, 1918, 2122, 2120, 2119, 2118, 1918, 2115, 1918, 2151, - /* 790 */ 1918, 1918, 1918, 2147, 2146, 1918, 1918, 1918, 1918, 1918, - /* 800 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 810 */ 1918, 2036, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 820 */ 2028, 1918, 2027, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 830 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 840 */ 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, 1918, - /* 850 */ 1947, 1918, 1918, 1918, 1918, 1918, 1918, + /* 0 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 10 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 20 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 30 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 40 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 50 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 60 */ 2308, 1966, 1966, 2271, 1966, 1966, 1966, 1966, 1966, 1966, + /* 70 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 2278, 1966, 1966, + /* 80 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 90 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 2065, 1966, 1966, + /* 100 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 110 */ 1966, 1966, 1966, 1966, 2063, 2536, 1966, 1966, 1966, 1966, + /* 120 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 130 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 2548, + /* 140 */ 1966, 1966, 2037, 2037, 1966, 2548, 2548, 2548, 2508, 2508, + /* 150 */ 2063, 1966, 1966, 2065, 1966, 2350, 1966, 1966, 1966, 1966, + /* 160 */ 1966, 1966, 1966, 1966, 2189, 1996, 2348, 1966, 1966, 1966, + /* 170 */ 1966, 1966, 1966, 1966, 2334, 1966, 1966, 2577, 2639, 1966, + /* 180 */ 2580, 1966, 1966, 1966, 1966, 1966, 2283, 1966, 2567, 1966, + /* 190 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 2141, 2328, + /* 200 */ 1966, 1966, 1966, 2540, 2554, 2623, 2541, 2538, 2561, 1966, + /* 210 */ 2571, 1966, 2375, 1966, 2364, 2065, 1966, 2065, 2321, 2266, + /* 220 */ 1966, 2276, 1966, 2276, 2273, 1966, 1966, 1966, 2276, 2273, + /* 230 */ 2273, 2273, 2130, 2126, 1966, 2124, 1966, 1966, 1966, 1966, + /* 240 */ 2021, 1966, 2021, 1966, 2065, 2065, 1966, 2065, 1966, 1966, + /* 250 */ 2065, 1966, 2065, 1966, 2065, 2065, 1966, 2065, 1966, 1966, + /* 260 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 270 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 2362, 2344, 1966, + /* 280 */ 2063, 1966, 2332, 2330, 1966, 2063, 2571, 1966, 1966, 2593, + /* 290 */ 2588, 2593, 2588, 2607, 2603, 2593, 2612, 2609, 2573, 2571, + /* 300 */ 2642, 2629, 2625, 2554, 1966, 1966, 2559, 2557, 1966, 2063, + /* 310 */ 2063, 1966, 2588, 1966, 1966, 1966, 1966, 2588, 1966, 1966, + /* 320 */ 2063, 1966, 2063, 1966, 1966, 1966, 2157, 1966, 1966, 2063, + /* 330 */ 1966, 2005, 1966, 2323, 2353, 2304, 2304, 2192, 2192, 2192, + /* 340 */ 2066, 1971, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 350 */ 1966, 1966, 1966, 1966, 2606, 2605, 2460, 1966, 2512, 2511, + /* 360 */ 2510, 2501, 2459, 2153, 1966, 1966, 2458, 2457, 1966, 1966, + /* 370 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 2451, + /* 380 */ 1966, 1966, 2452, 2450, 2449, 2295, 2294, 1966, 1966, 1966, + /* 390 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 400 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 410 */ 1966, 1966, 1966, 2626, 2630, 1966, 2537, 1966, 1966, 1966, + /* 420 */ 2431, 1966, 1966, 1966, 1966, 1966, 2399, 1966, 1966, 1966, + /* 430 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 440 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 450 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 460 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 470 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 480 */ 1966, 2272, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 490 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 500 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 510 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 520 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 530 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 540 */ 1966, 1966, 1966, 1966, 2287, 1966, 1966, 1966, 1966, 1966, + /* 550 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 560 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 570 */ 1966, 1966, 1966, 1966, 1966, 1966, 2010, 2438, 1966, 1966, + /* 580 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 590 */ 1966, 2441, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 600 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 610 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 620 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 630 */ 1966, 1966, 2105, 2104, 1966, 1966, 1966, 1966, 1966, 1966, + /* 640 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 650 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 660 */ 2442, 1966, 1966, 1966, 2348, 1966, 1966, 1966, 2433, 1966, + /* 670 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 680 */ 1966, 1966, 1966, 1966, 1966, 2622, 2574, 1966, 1966, 1966, + /* 690 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 700 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 2431, + /* 710 */ 1966, 2604, 1966, 1966, 2620, 1966, 2624, 1966, 1966, 1966, + /* 720 */ 1966, 1966, 1966, 1966, 2547, 2543, 1966, 1966, 2539, 1966, + /* 730 */ 1966, 1966, 1966, 1966, 2498, 1966, 1966, 1966, 2532, 1966, + /* 740 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 2442, 1966, + /* 750 */ 2445, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 760 */ 1966, 1966, 1966, 2430, 1966, 2483, 2482, 1966, 1966, 1966, + /* 770 */ 1966, 1966, 1966, 1966, 2186, 1966, 1966, 1966, 1966, 1966, + /* 780 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 790 */ 2170, 2168, 2167, 2166, 1966, 2163, 1966, 2199, 1966, 1966, + /* 800 */ 1966, 2195, 2194, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 810 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 2084, + /* 820 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 2076, 1966, + /* 830 */ 2075, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 840 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, + /* 850 */ 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1966, 1995, 1966, + /* 860 */ 1966, 1966, 1966, 1966, 1966, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1593,7 +1580,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* BWLIMIT => nothing */ 0, /* START => nothing */ 0, /* TIMESTAMP => nothing */ - 303, /* END => ABORT */ + 306, /* END => ABORT */ 0, /* TABLE => nothing */ 0, /* NK_LP => nothing */ 0, /* NK_RP => nothing */ @@ -1607,7 +1594,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* USING => nothing */ 0, /* TAGS => nothing */ 0, /* PRIMARY => nothing */ - 303, /* KEY => ABORT */ + 306, /* KEY => ABORT */ 0, /* BOOL => nothing */ 0, /* TINYINT => nothing */ 0, /* SMALLINT => nothing */ @@ -1642,6 +1629,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* STABLES => nothing */ 0, /* MNODES => nothing */ 0, /* QNODES => nothing */ + 0, /* ARBGROUPS => nothing */ 0, /* FUNCTIONS => nothing */ 0, /* INDEXES => nothing */ 0, /* ACCOUNTS => nothing */ @@ -1665,7 +1653,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* VNODES => nothing */ 0, /* ALIVE => nothing */ 0, /* VIEWS => nothing */ - 303, /* VIEW => ABORT */ + 306, /* VIEW => ABORT */ 0, /* COMPACTS => nothing */ 0, /* NORMAL => nothing */ 0, /* CHILD => nothing */ @@ -1724,6 +1712,8 @@ static const YYCODETYPE yyFallback[] = { 0, /* SPLIT => nothing */ 0, /* DELETE => nothing */ 0, /* INSERT => nothing */ + 0, /* NK_BIN => nothing */ + 0, /* NK_HEX => nothing */ 0, /* NULL => nothing */ 0, /* NK_QUESTION => nothing */ 0, /* NK_ALIAS => nothing */ @@ -1792,54 +1782,54 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ABORT => nothing */ - 303, /* AFTER => ABORT */ - 303, /* ATTACH => ABORT */ - 303, /* BEFORE => ABORT */ - 303, /* BEGIN => ABORT */ - 303, /* BITAND => ABORT */ - 303, /* BITNOT => ABORT */ - 303, /* BITOR => ABORT */ - 303, /* BLOCKS => ABORT */ - 303, /* CHANGE => ABORT */ - 303, /* COMMA => ABORT */ - 303, /* CONCAT => ABORT */ - 303, /* CONFLICT => ABORT */ - 303, /* COPY => ABORT */ - 303, /* DEFERRED => ABORT */ - 303, /* DELIMITERS => ABORT */ - 303, /* DETACH => ABORT */ - 303, /* DIVIDE => ABORT */ - 303, /* DOT => ABORT */ - 303, /* EACH => ABORT */ - 303, /* FAIL => ABORT */ - 303, /* FILE => ABORT */ - 303, /* FOR => ABORT */ - 303, /* GLOB => ABORT */ - 303, /* ID => ABORT */ - 303, /* IMMEDIATE => ABORT */ - 303, /* IMPORT => ABORT */ - 303, /* INITIALLY => ABORT */ - 303, /* INSTEAD => ABORT */ - 303, /* ISNULL => ABORT */ - 303, /* MODULES => ABORT */ - 303, /* NK_BITNOT => ABORT */ - 303, /* NK_SEMI => ABORT */ - 303, /* NOTNULL => ABORT */ - 303, /* OF => ABORT */ - 303, /* PLUS => ABORT */ - 303, /* PRIVILEGE => ABORT */ - 303, /* RAISE => ABORT */ - 303, /* RESTRICT => ABORT */ - 303, /* ROW => ABORT */ - 303, /* SEMI => ABORT */ - 303, /* STAR => ABORT */ - 303, /* STATEMENT => ABORT */ - 303, /* STRICT => ABORT */ - 303, /* STRING => ABORT */ - 303, /* TIMES => ABORT */ - 303, /* VALUES => ABORT */ - 303, /* VARIABLE => ABORT */ - 303, /* WAL => ABORT */ + 306, /* AFTER => ABORT */ + 306, /* ATTACH => ABORT */ + 306, /* BEFORE => ABORT */ + 306, /* BEGIN => ABORT */ + 306, /* BITAND => ABORT */ + 306, /* BITNOT => ABORT */ + 306, /* BITOR => ABORT */ + 306, /* BLOCKS => ABORT */ + 306, /* CHANGE => ABORT */ + 306, /* COMMA => ABORT */ + 306, /* CONCAT => ABORT */ + 306, /* CONFLICT => ABORT */ + 306, /* COPY => ABORT */ + 306, /* DEFERRED => ABORT */ + 306, /* DELIMITERS => ABORT */ + 306, /* DETACH => ABORT */ + 306, /* DIVIDE => ABORT */ + 306, /* DOT => ABORT */ + 306, /* EACH => ABORT */ + 306, /* FAIL => ABORT */ + 306, /* FILE => ABORT */ + 306, /* FOR => ABORT */ + 306, /* GLOB => ABORT */ + 306, /* ID => ABORT */ + 306, /* IMMEDIATE => ABORT */ + 306, /* IMPORT => ABORT */ + 306, /* INITIALLY => ABORT */ + 306, /* INSTEAD => ABORT */ + 306, /* ISNULL => ABORT */ + 306, /* MODULES => ABORT */ + 306, /* NK_BITNOT => ABORT */ + 306, /* NK_SEMI => ABORT */ + 306, /* NOTNULL => ABORT */ + 306, /* OF => ABORT */ + 306, /* PLUS => ABORT */ + 306, /* PRIVILEGE => ABORT */ + 306, /* RAISE => ABORT */ + 306, /* RESTRICT => ABORT */ + 306, /* ROW => ABORT */ + 306, /* SEMI => ABORT */ + 306, /* STAR => ABORT */ + 306, /* STATEMENT => ABORT */ + 306, /* STRICT => ABORT */ + 306, /* STRING => ABORT */ + 306, /* TIMES => ABORT */ + 306, /* VALUES => ABORT */ + 306, /* VARIABLE => ABORT */ + 306, /* WAL => ABORT */ }; #endif /* YYFALLBACK */ @@ -2082,367 +2072,372 @@ static const char *const yyTokenName[] = { /* 151 */ "STABLES", /* 152 */ "MNODES", /* 153 */ "QNODES", - /* 154 */ "FUNCTIONS", - /* 155 */ "INDEXES", - /* 156 */ "ACCOUNTS", - /* 157 */ "APPS", - /* 158 */ "CONNECTIONS", - /* 159 */ "LICENCES", - /* 160 */ "GRANTS", - /* 161 */ "FULL", - /* 162 */ "LOGS", - /* 163 */ "MACHINES", - /* 164 */ "QUERIES", - /* 165 */ "SCORES", - /* 166 */ "TOPICS", - /* 167 */ "VARIABLES", - /* 168 */ "BNODES", - /* 169 */ "SNODES", - /* 170 */ "TRANSACTIONS", - /* 171 */ "DISTRIBUTED", - /* 172 */ "CONSUMERS", - /* 173 */ "SUBSCRIPTIONS", - /* 174 */ "VNODES", - /* 175 */ "ALIVE", - /* 176 */ "VIEWS", - /* 177 */ "VIEW", - /* 178 */ "COMPACTS", - /* 179 */ "NORMAL", - /* 180 */ "CHILD", - /* 181 */ "LIKE", - /* 182 */ "TBNAME", - /* 183 */ "QTAGS", - /* 184 */ "AS", - /* 185 */ "SYSTEM", - /* 186 */ "INDEX", - /* 187 */ "FUNCTION", - /* 188 */ "INTERVAL", - /* 189 */ "COUNT", - /* 190 */ "LAST_ROW", - /* 191 */ "META", - /* 192 */ "ONLY", - /* 193 */ "TOPIC", - /* 194 */ "CONSUMER", - /* 195 */ "GROUP", - /* 196 */ "DESC", - /* 197 */ "DESCRIBE", - /* 198 */ "RESET", - /* 199 */ "QUERY", - /* 200 */ "CACHE", - /* 201 */ "EXPLAIN", - /* 202 */ "ANALYZE", - /* 203 */ "VERBOSE", - /* 204 */ "NK_BOOL", - /* 205 */ "RATIO", - /* 206 */ "NK_FLOAT", - /* 207 */ "OUTPUTTYPE", - /* 208 */ "AGGREGATE", - /* 209 */ "BUFSIZE", - /* 210 */ "LANGUAGE", - /* 211 */ "REPLACE", - /* 212 */ "STREAM", - /* 213 */ "INTO", - /* 214 */ "PAUSE", - /* 215 */ "RESUME", - /* 216 */ "TRIGGER", - /* 217 */ "AT_ONCE", - /* 218 */ "WINDOW_CLOSE", - /* 219 */ "IGNORE", - /* 220 */ "EXPIRED", - /* 221 */ "FILL_HISTORY", - /* 222 */ "UPDATE", - /* 223 */ "SUBTABLE", - /* 224 */ "UNTREATED", - /* 225 */ "KILL", - /* 226 */ "CONNECTION", - /* 227 */ "TRANSACTION", - /* 228 */ "BALANCE", - /* 229 */ "VGROUP", - /* 230 */ "LEADER", - /* 231 */ "MERGE", - /* 232 */ "REDISTRIBUTE", - /* 233 */ "SPLIT", - /* 234 */ "DELETE", - /* 235 */ "INSERT", - /* 236 */ "NULL", - /* 237 */ "NK_QUESTION", - /* 238 */ "NK_ALIAS", - /* 239 */ "NK_ARROW", - /* 240 */ "ROWTS", - /* 241 */ "QSTART", - /* 242 */ "QEND", - /* 243 */ "QDURATION", - /* 244 */ "WSTART", - /* 245 */ "WEND", - /* 246 */ "WDURATION", - /* 247 */ "IROWTS", - /* 248 */ "ISFILLED", - /* 249 */ "CAST", - /* 250 */ "NOW", - /* 251 */ "TODAY", - /* 252 */ "TIMEZONE", - /* 253 */ "CLIENT_VERSION", - /* 254 */ "SERVER_VERSION", - /* 255 */ "SERVER_STATUS", - /* 256 */ "CURRENT_USER", - /* 257 */ "CASE", - /* 258 */ "WHEN", - /* 259 */ "THEN", - /* 260 */ "ELSE", - /* 261 */ "BETWEEN", - /* 262 */ "IS", - /* 263 */ "NK_LT", - /* 264 */ "NK_GT", - /* 265 */ "NK_LE", - /* 266 */ "NK_GE", - /* 267 */ "NK_NE", - /* 268 */ "MATCH", - /* 269 */ "NMATCH", - /* 270 */ "CONTAINS", - /* 271 */ "IN", - /* 272 */ "JOIN", - /* 273 */ "INNER", - /* 274 */ "SELECT", - /* 275 */ "NK_HINT", - /* 276 */ "DISTINCT", - /* 277 */ "WHERE", - /* 278 */ "PARTITION", - /* 279 */ "BY", - /* 280 */ "SESSION", - /* 281 */ "STATE_WINDOW", - /* 282 */ "EVENT_WINDOW", - /* 283 */ "COUNT_WINDOW", - /* 284 */ "SLIDING", - /* 285 */ "FILL", - /* 286 */ "VALUE", - /* 287 */ "VALUE_F", - /* 288 */ "NONE", - /* 289 */ "PREV", - /* 290 */ "NULL_F", - /* 291 */ "LINEAR", - /* 292 */ "NEXT", - /* 293 */ "HAVING", - /* 294 */ "RANGE", - /* 295 */ "EVERY", - /* 296 */ "ORDER", - /* 297 */ "SLIMIT", - /* 298 */ "SOFFSET", - /* 299 */ "LIMIT", - /* 300 */ "OFFSET", - /* 301 */ "ASC", - /* 302 */ "NULLS", - /* 303 */ "ABORT", - /* 304 */ "AFTER", - /* 305 */ "ATTACH", - /* 306 */ "BEFORE", - /* 307 */ "BEGIN", - /* 308 */ "BITAND", - /* 309 */ "BITNOT", - /* 310 */ "BITOR", - /* 311 */ "BLOCKS", - /* 312 */ "CHANGE", - /* 313 */ "COMMA", - /* 314 */ "CONCAT", - /* 315 */ "CONFLICT", - /* 316 */ "COPY", - /* 317 */ "DEFERRED", - /* 318 */ "DELIMITERS", - /* 319 */ "DETACH", - /* 320 */ "DIVIDE", - /* 321 */ "DOT", - /* 322 */ "EACH", - /* 323 */ "FAIL", - /* 324 */ "FILE", - /* 325 */ "FOR", - /* 326 */ "GLOB", - /* 327 */ "ID", - /* 328 */ "IMMEDIATE", - /* 329 */ "IMPORT", - /* 330 */ "INITIALLY", - /* 331 */ "INSTEAD", - /* 332 */ "ISNULL", - /* 333 */ "MODULES", - /* 334 */ "NK_BITNOT", - /* 335 */ "NK_SEMI", - /* 336 */ "NOTNULL", - /* 337 */ "OF", - /* 338 */ "PLUS", - /* 339 */ "PRIVILEGE", - /* 340 */ "RAISE", - /* 341 */ "RESTRICT", - /* 342 */ "ROW", - /* 343 */ "SEMI", - /* 344 */ "STAR", - /* 345 */ "STATEMENT", - /* 346 */ "STRICT", - /* 347 */ "STRING", - /* 348 */ "TIMES", - /* 349 */ "VALUES", - /* 350 */ "VARIABLE", - /* 351 */ "WAL", - /* 352 */ "cmd", - /* 353 */ "account_options", - /* 354 */ "alter_account_options", - /* 355 */ "literal", - /* 356 */ "alter_account_option", - /* 357 */ "ip_range_list", - /* 358 */ "white_list", - /* 359 */ "white_list_opt", - /* 360 */ "user_name", - /* 361 */ "sysinfo_opt", - /* 362 */ "privileges", - /* 363 */ "priv_level", - /* 364 */ "with_opt", - /* 365 */ "priv_type_list", - /* 366 */ "priv_type", - /* 367 */ "db_name", - /* 368 */ "table_name", - /* 369 */ "topic_name", - /* 370 */ "search_condition", - /* 371 */ "dnode_endpoint", - /* 372 */ "force_opt", - /* 373 */ "unsafe_opt", - /* 374 */ "not_exists_opt", - /* 375 */ "db_options", - /* 376 */ "exists_opt", - /* 377 */ "alter_db_options", - /* 378 */ "speed_opt", - /* 379 */ "start_opt", - /* 380 */ "end_opt", - /* 381 */ "integer_list", - /* 382 */ "variable_list", - /* 383 */ "retention_list", - /* 384 */ "signed", - /* 385 */ "alter_db_option", - /* 386 */ "retention", - /* 387 */ "full_table_name", - /* 388 */ "column_def_list", - /* 389 */ "tags_def_opt", - /* 390 */ "table_options", - /* 391 */ "multi_create_clause", - /* 392 */ "tags_def", - /* 393 */ "multi_drop_clause", - /* 394 */ "alter_table_clause", - /* 395 */ "alter_table_options", - /* 396 */ "column_name", - /* 397 */ "type_name", - /* 398 */ "signed_literal", - /* 399 */ "create_subtable_clause", - /* 400 */ "specific_cols_opt", - /* 401 */ "expression_list", - /* 402 */ "drop_table_clause", - /* 403 */ "col_name_list", - /* 404 */ "column_def", - /* 405 */ "duration_list", - /* 406 */ "rollup_func_list", - /* 407 */ "alter_table_option", - /* 408 */ "duration_literal", - /* 409 */ "rollup_func_name", - /* 410 */ "function_name", - /* 411 */ "col_name", - /* 412 */ "db_kind_opt", - /* 413 */ "table_kind_db_name_cond_opt", - /* 414 */ "like_pattern_opt", - /* 415 */ "db_name_cond_opt", - /* 416 */ "table_name_cond", - /* 417 */ "from_db_opt", - /* 418 */ "tag_list_opt", - /* 419 */ "table_kind", - /* 420 */ "tag_item", - /* 421 */ "column_alias", - /* 422 */ "index_options", - /* 423 */ "full_index_name", - /* 424 */ "index_name", - /* 425 */ "func_list", - /* 426 */ "sliding_opt", - /* 427 */ "sma_stream_opt", - /* 428 */ "func", - /* 429 */ "sma_func_name", - /* 430 */ "with_meta", - /* 431 */ "query_or_subquery", - /* 432 */ "where_clause_opt", - /* 433 */ "cgroup_name", - /* 434 */ "analyze_opt", - /* 435 */ "explain_options", - /* 436 */ "insert_query", - /* 437 */ "or_replace_opt", - /* 438 */ "agg_func_opt", - /* 439 */ "bufsize_opt", - /* 440 */ "language_opt", - /* 441 */ "full_view_name", - /* 442 */ "view_name", - /* 443 */ "stream_name", - /* 444 */ "stream_options", - /* 445 */ "col_list_opt", - /* 446 */ "tag_def_or_ref_opt", - /* 447 */ "subtable_opt", - /* 448 */ "ignore_opt", - /* 449 */ "column_stream_def_list", - /* 450 */ "column_stream_def", - /* 451 */ "expression", - /* 452 */ "on_vgroup_id", - /* 453 */ "dnode_list", - /* 454 */ "literal_func", - /* 455 */ "literal_list", - /* 456 */ "table_alias", - /* 457 */ "expr_or_subquery", - /* 458 */ "pseudo_column", - /* 459 */ "column_reference", - /* 460 */ "function_expression", - /* 461 */ "case_when_expression", - /* 462 */ "star_func", - /* 463 */ "star_func_para_list", - /* 464 */ "noarg_func", - /* 465 */ "other_para_list", - /* 466 */ "star_func_para", - /* 467 */ "when_then_list", - /* 468 */ "case_when_else_opt", - /* 469 */ "common_expression", - /* 470 */ "when_then_expr", - /* 471 */ "predicate", - /* 472 */ "compare_op", - /* 473 */ "in_op", - /* 474 */ "in_predicate_value", - /* 475 */ "boolean_value_expression", - /* 476 */ "boolean_primary", - /* 477 */ "from_clause_opt", - /* 478 */ "table_reference_list", - /* 479 */ "table_reference", - /* 480 */ "table_primary", - /* 481 */ "joined_table", - /* 482 */ "alias_opt", - /* 483 */ "subquery", - /* 484 */ "parenthesized_joined_table", - /* 485 */ "join_type", - /* 486 */ "query_specification", - /* 487 */ "hint_list", - /* 488 */ "set_quantifier_opt", - /* 489 */ "tag_mode_opt", - /* 490 */ "select_list", - /* 491 */ "partition_by_clause_opt", - /* 492 */ "range_opt", - /* 493 */ "every_opt", - /* 494 */ "fill_opt", - /* 495 */ "twindow_clause_opt", - /* 496 */ "group_by_clause_opt", - /* 497 */ "having_clause_opt", - /* 498 */ "select_item", - /* 499 */ "partition_list", - /* 500 */ "partition_item", - /* 501 */ "interval_sliding_duration_literal", - /* 502 */ "fill_mode", - /* 503 */ "group_by_list", - /* 504 */ "query_expression", - /* 505 */ "query_simple", - /* 506 */ "order_by_clause_opt", - /* 507 */ "slimit_clause_opt", - /* 508 */ "limit_clause_opt", - /* 509 */ "union_query_expression", - /* 510 */ "query_simple_or_subquery", - /* 511 */ "sort_specification_list", - /* 512 */ "sort_specification", - /* 513 */ "ordering_specification_opt", - /* 514 */ "null_ordering_opt", + /* 154 */ "ARBGROUPS", + /* 155 */ "FUNCTIONS", + /* 156 */ "INDEXES", + /* 157 */ "ACCOUNTS", + /* 158 */ "APPS", + /* 159 */ "CONNECTIONS", + /* 160 */ "LICENCES", + /* 161 */ "GRANTS", + /* 162 */ "FULL", + /* 163 */ "LOGS", + /* 164 */ "MACHINES", + /* 165 */ "QUERIES", + /* 166 */ "SCORES", + /* 167 */ "TOPICS", + /* 168 */ "VARIABLES", + /* 169 */ "BNODES", + /* 170 */ "SNODES", + /* 171 */ "TRANSACTIONS", + /* 172 */ "DISTRIBUTED", + /* 173 */ "CONSUMERS", + /* 174 */ "SUBSCRIPTIONS", + /* 175 */ "VNODES", + /* 176 */ "ALIVE", + /* 177 */ "VIEWS", + /* 178 */ "VIEW", + /* 179 */ "COMPACTS", + /* 180 */ "NORMAL", + /* 181 */ "CHILD", + /* 182 */ "LIKE", + /* 183 */ "TBNAME", + /* 184 */ "QTAGS", + /* 185 */ "AS", + /* 186 */ "SYSTEM", + /* 187 */ "INDEX", + /* 188 */ "FUNCTION", + /* 189 */ "INTERVAL", + /* 190 */ "COUNT", + /* 191 */ "LAST_ROW", + /* 192 */ "META", + /* 193 */ "ONLY", + /* 194 */ "TOPIC", + /* 195 */ "CONSUMER", + /* 196 */ "GROUP", + /* 197 */ "DESC", + /* 198 */ "DESCRIBE", + /* 199 */ "RESET", + /* 200 */ "QUERY", + /* 201 */ "CACHE", + /* 202 */ "EXPLAIN", + /* 203 */ "ANALYZE", + /* 204 */ "VERBOSE", + /* 205 */ "NK_BOOL", + /* 206 */ "RATIO", + /* 207 */ "NK_FLOAT", + /* 208 */ "OUTPUTTYPE", + /* 209 */ "AGGREGATE", + /* 210 */ "BUFSIZE", + /* 211 */ "LANGUAGE", + /* 212 */ "REPLACE", + /* 213 */ "STREAM", + /* 214 */ "INTO", + /* 215 */ "PAUSE", + /* 216 */ "RESUME", + /* 217 */ "TRIGGER", + /* 218 */ "AT_ONCE", + /* 219 */ "WINDOW_CLOSE", + /* 220 */ "IGNORE", + /* 221 */ "EXPIRED", + /* 222 */ "FILL_HISTORY", + /* 223 */ "UPDATE", + /* 224 */ "SUBTABLE", + /* 225 */ "UNTREATED", + /* 226 */ "KILL", + /* 227 */ "CONNECTION", + /* 228 */ "TRANSACTION", + /* 229 */ "BALANCE", + /* 230 */ "VGROUP", + /* 231 */ "LEADER", + /* 232 */ "MERGE", + /* 233 */ "REDISTRIBUTE", + /* 234 */ "SPLIT", + /* 235 */ "DELETE", + /* 236 */ "INSERT", + /* 237 */ "NK_BIN", + /* 238 */ "NK_HEX", + /* 239 */ "NULL", + /* 240 */ "NK_QUESTION", + /* 241 */ "NK_ALIAS", + /* 242 */ "NK_ARROW", + /* 243 */ "ROWTS", + /* 244 */ "QSTART", + /* 245 */ "QEND", + /* 246 */ "QDURATION", + /* 247 */ "WSTART", + /* 248 */ "WEND", + /* 249 */ "WDURATION", + /* 250 */ "IROWTS", + /* 251 */ "ISFILLED", + /* 252 */ "CAST", + /* 253 */ "NOW", + /* 254 */ "TODAY", + /* 255 */ "TIMEZONE", + /* 256 */ "CLIENT_VERSION", + /* 257 */ "SERVER_VERSION", + /* 258 */ "SERVER_STATUS", + /* 259 */ "CURRENT_USER", + /* 260 */ "CASE", + /* 261 */ "WHEN", + /* 262 */ "THEN", + /* 263 */ "ELSE", + /* 264 */ "BETWEEN", + /* 265 */ "IS", + /* 266 */ "NK_LT", + /* 267 */ "NK_GT", + /* 268 */ "NK_LE", + /* 269 */ "NK_GE", + /* 270 */ "NK_NE", + /* 271 */ "MATCH", + /* 272 */ "NMATCH", + /* 273 */ "CONTAINS", + /* 274 */ "IN", + /* 275 */ "JOIN", + /* 276 */ "INNER", + /* 277 */ "SELECT", + /* 278 */ "NK_HINT", + /* 279 */ "DISTINCT", + /* 280 */ "WHERE", + /* 281 */ "PARTITION", + /* 282 */ "BY", + /* 283 */ "SESSION", + /* 284 */ "STATE_WINDOW", + /* 285 */ "EVENT_WINDOW", + /* 286 */ "COUNT_WINDOW", + /* 287 */ "SLIDING", + /* 288 */ "FILL", + /* 289 */ "VALUE", + /* 290 */ "VALUE_F", + /* 291 */ "NONE", + /* 292 */ "PREV", + /* 293 */ "NULL_F", + /* 294 */ "LINEAR", + /* 295 */ "NEXT", + /* 296 */ "HAVING", + /* 297 */ "RANGE", + /* 298 */ "EVERY", + /* 299 */ "ORDER", + /* 300 */ "SLIMIT", + /* 301 */ "SOFFSET", + /* 302 */ "LIMIT", + /* 303 */ "OFFSET", + /* 304 */ "ASC", + /* 305 */ "NULLS", + /* 306 */ "ABORT", + /* 307 */ "AFTER", + /* 308 */ "ATTACH", + /* 309 */ "BEFORE", + /* 310 */ "BEGIN", + /* 311 */ "BITAND", + /* 312 */ "BITNOT", + /* 313 */ "BITOR", + /* 314 */ "BLOCKS", + /* 315 */ "CHANGE", + /* 316 */ "COMMA", + /* 317 */ "CONCAT", + /* 318 */ "CONFLICT", + /* 319 */ "COPY", + /* 320 */ "DEFERRED", + /* 321 */ "DELIMITERS", + /* 322 */ "DETACH", + /* 323 */ "DIVIDE", + /* 324 */ "DOT", + /* 325 */ "EACH", + /* 326 */ "FAIL", + /* 327 */ "FILE", + /* 328 */ "FOR", + /* 329 */ "GLOB", + /* 330 */ "ID", + /* 331 */ "IMMEDIATE", + /* 332 */ "IMPORT", + /* 333 */ "INITIALLY", + /* 334 */ "INSTEAD", + /* 335 */ "ISNULL", + /* 336 */ "MODULES", + /* 337 */ "NK_BITNOT", + /* 338 */ "NK_SEMI", + /* 339 */ "NOTNULL", + /* 340 */ "OF", + /* 341 */ "PLUS", + /* 342 */ "PRIVILEGE", + /* 343 */ "RAISE", + /* 344 */ "RESTRICT", + /* 345 */ "ROW", + /* 346 */ "SEMI", + /* 347 */ "STAR", + /* 348 */ "STATEMENT", + /* 349 */ "STRICT", + /* 350 */ "STRING", + /* 351 */ "TIMES", + /* 352 */ "VALUES", + /* 353 */ "VARIABLE", + /* 354 */ "WAL", + /* 355 */ "cmd", + /* 356 */ "account_options", + /* 357 */ "alter_account_options", + /* 358 */ "literal", + /* 359 */ "alter_account_option", + /* 360 */ "ip_range_list", + /* 361 */ "white_list", + /* 362 */ "white_list_opt", + /* 363 */ "user_name", + /* 364 */ "sysinfo_opt", + /* 365 */ "privileges", + /* 366 */ "priv_level", + /* 367 */ "with_opt", + /* 368 */ "priv_type_list", + /* 369 */ "priv_type", + /* 370 */ "db_name", + /* 371 */ "table_name", + /* 372 */ "topic_name", + /* 373 */ "search_condition", + /* 374 */ "dnode_endpoint", + /* 375 */ "force_opt", + /* 376 */ "unsafe_opt", + /* 377 */ "not_exists_opt", + /* 378 */ "db_options", + /* 379 */ "exists_opt", + /* 380 */ "alter_db_options", + /* 381 */ "speed_opt", + /* 382 */ "start_opt", + /* 383 */ "end_opt", + /* 384 */ "integer_list", + /* 385 */ "variable_list", + /* 386 */ "retention_list", + /* 387 */ "signed", + /* 388 */ "alter_db_option", + /* 389 */ "retention", + /* 390 */ "full_table_name", + /* 391 */ "column_def_list", + /* 392 */ "tags_def_opt", + /* 393 */ "table_options", + /* 394 */ "multi_create_clause", + /* 395 */ "tags_def", + /* 396 */ "multi_drop_clause", + /* 397 */ "alter_table_clause", + /* 398 */ "alter_table_options", + /* 399 */ "column_name", + /* 400 */ "type_name", + /* 401 */ "tags_literal", + /* 402 */ "create_subtable_clause", + /* 403 */ "specific_cols_opt", + /* 404 */ "tags_literal_list", + /* 405 */ "drop_table_clause", + /* 406 */ "col_name_list", + /* 407 */ "column_def", + /* 408 */ "duration_list", + /* 409 */ "rollup_func_list", + /* 410 */ "alter_table_option", + /* 411 */ "duration_literal", + /* 412 */ "rollup_func_name", + /* 413 */ "function_name", + /* 414 */ "col_name", + /* 415 */ "db_kind_opt", + /* 416 */ "table_kind_db_name_cond_opt", + /* 417 */ "like_pattern_opt", + /* 418 */ "db_name_cond_opt", + /* 419 */ "table_name_cond", + /* 420 */ "from_db_opt", + /* 421 */ "tag_list_opt", + /* 422 */ "table_kind", + /* 423 */ "tag_item", + /* 424 */ "column_alias", + /* 425 */ "index_options", + /* 426 */ "full_index_name", + /* 427 */ "index_name", + /* 428 */ "func_list", + /* 429 */ "sliding_opt", + /* 430 */ "sma_stream_opt", + /* 431 */ "func", + /* 432 */ "sma_func_name", + /* 433 */ "expression_list", + /* 434 */ "with_meta", + /* 435 */ "query_or_subquery", + /* 436 */ "where_clause_opt", + /* 437 */ "cgroup_name", + /* 438 */ "analyze_opt", + /* 439 */ "explain_options", + /* 440 */ "insert_query", + /* 441 */ "or_replace_opt", + /* 442 */ "agg_func_opt", + /* 443 */ "bufsize_opt", + /* 444 */ "language_opt", + /* 445 */ "full_view_name", + /* 446 */ "view_name", + /* 447 */ "stream_name", + /* 448 */ "stream_options", + /* 449 */ "col_list_opt", + /* 450 */ "tag_def_or_ref_opt", + /* 451 */ "subtable_opt", + /* 452 */ "ignore_opt", + /* 453 */ "column_stream_def_list", + /* 454 */ "column_stream_def", + /* 455 */ "expression", + /* 456 */ "on_vgroup_id", + /* 457 */ "dnode_list", + /* 458 */ "literal_func", + /* 459 */ "signed_literal", + /* 460 */ "literal_list", + /* 461 */ "table_alias", + /* 462 */ "expr_or_subquery", + /* 463 */ "pseudo_column", + /* 464 */ "column_reference", + /* 465 */ "function_expression", + /* 466 */ "case_when_expression", + /* 467 */ "star_func", + /* 468 */ "star_func_para_list", + /* 469 */ "noarg_func", + /* 470 */ "other_para_list", + /* 471 */ "star_func_para", + /* 472 */ "when_then_list", + /* 473 */ "case_when_else_opt", + /* 474 */ "common_expression", + /* 475 */ "when_then_expr", + /* 476 */ "predicate", + /* 477 */ "compare_op", + /* 478 */ "in_op", + /* 479 */ "in_predicate_value", + /* 480 */ "boolean_value_expression", + /* 481 */ "boolean_primary", + /* 482 */ "from_clause_opt", + /* 483 */ "table_reference_list", + /* 484 */ "table_reference", + /* 485 */ "table_primary", + /* 486 */ "joined_table", + /* 487 */ "alias_opt", + /* 488 */ "subquery", + /* 489 */ "parenthesized_joined_table", + /* 490 */ "join_type", + /* 491 */ "query_specification", + /* 492 */ "hint_list", + /* 493 */ "set_quantifier_opt", + /* 494 */ "tag_mode_opt", + /* 495 */ "select_list", + /* 496 */ "partition_by_clause_opt", + /* 497 */ "range_opt", + /* 498 */ "every_opt", + /* 499 */ "fill_opt", + /* 500 */ "twindow_clause_opt", + /* 501 */ "group_by_clause_opt", + /* 502 */ "having_clause_opt", + /* 503 */ "select_item", + /* 504 */ "partition_list", + /* 505 */ "partition_item", + /* 506 */ "interval_sliding_duration_literal", + /* 507 */ "fill_mode", + /* 508 */ "group_by_list", + /* 509 */ "query_expression", + /* 510 */ "query_simple", + /* 511 */ "order_by_clause_opt", + /* 512 */ "slimit_clause_opt", + /* 513 */ "limit_clause_opt", + /* 514 */ "union_query_expression", + /* 515 */ "query_simple_or_subquery", + /* 516 */ "sort_specification_list", + /* 517 */ "sort_specification", + /* 518 */ "ordering_specification_opt", + /* 519 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -2631,10 +2626,10 @@ static const char *const yyRuleName[] = { /* 178 */ "alter_table_clause ::= full_table_name DROP TAG column_name", /* 179 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", /* 180 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 181 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", + /* 181 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal", /* 182 */ "multi_create_clause ::= create_subtable_clause", /* 183 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 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", + /* 184 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP tags_literal_list NK_RP table_options", /* 185 */ "multi_drop_clause ::= drop_table_clause", /* 186 */ "multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause", /* 187 */ "drop_table_clause ::= exists_opt full_table_name", @@ -2704,406 +2699,428 @@ static const char *const yyRuleName[] = { /* 251 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", /* 252 */ "cmd ::= SHOW MNODES", /* 253 */ "cmd ::= SHOW QNODES", - /* 254 */ "cmd ::= SHOW FUNCTIONS", - /* 255 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 256 */ "cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name", - /* 257 */ "cmd ::= SHOW STREAMS", - /* 258 */ "cmd ::= SHOW ACCOUNTS", - /* 259 */ "cmd ::= SHOW APPS", - /* 260 */ "cmd ::= SHOW CONNECTIONS", - /* 261 */ "cmd ::= SHOW LICENCES", - /* 262 */ "cmd ::= SHOW GRANTS", - /* 263 */ "cmd ::= SHOW GRANTS FULL", - /* 264 */ "cmd ::= SHOW GRANTS LOGS", - /* 265 */ "cmd ::= SHOW CLUSTER MACHINES", - /* 266 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 267 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 268 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 269 */ "cmd ::= SHOW QUERIES", - /* 270 */ "cmd ::= SHOW SCORES", - /* 271 */ "cmd ::= SHOW TOPICS", - /* 272 */ "cmd ::= SHOW VARIABLES", - /* 273 */ "cmd ::= SHOW CLUSTER VARIABLES", - /* 274 */ "cmd ::= SHOW LOCAL VARIABLES", - /* 275 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt", - /* 276 */ "cmd ::= SHOW BNODES", - /* 277 */ "cmd ::= SHOW SNODES", - /* 278 */ "cmd ::= SHOW CLUSTER", - /* 279 */ "cmd ::= SHOW TRANSACTIONS", - /* 280 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", - /* 281 */ "cmd ::= SHOW CONSUMERS", - /* 282 */ "cmd ::= SHOW SUBSCRIPTIONS", - /* 283 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", - /* 284 */ "cmd ::= SHOW TAGS FROM db_name NK_DOT table_name", - /* 285 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", - /* 286 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name", - /* 287 */ "cmd ::= SHOW VNODES ON DNODE NK_INTEGER", - /* 288 */ "cmd ::= SHOW VNODES", - /* 289 */ "cmd ::= SHOW db_name_cond_opt ALIVE", - /* 290 */ "cmd ::= SHOW CLUSTER ALIVE", - /* 291 */ "cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt", - /* 292 */ "cmd ::= SHOW CREATE VIEW full_table_name", - /* 293 */ "cmd ::= SHOW COMPACTS", - /* 294 */ "cmd ::= SHOW COMPACT NK_INTEGER", - /* 295 */ "table_kind_db_name_cond_opt ::=", - /* 296 */ "table_kind_db_name_cond_opt ::= table_kind", - /* 297 */ "table_kind_db_name_cond_opt ::= db_name NK_DOT", - /* 298 */ "table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT", - /* 299 */ "table_kind ::= NORMAL", - /* 300 */ "table_kind ::= CHILD", - /* 301 */ "db_name_cond_opt ::=", - /* 302 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 303 */ "like_pattern_opt ::=", - /* 304 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 305 */ "table_name_cond ::= table_name", - /* 306 */ "from_db_opt ::=", - /* 307 */ "from_db_opt ::= FROM db_name", - /* 308 */ "tag_list_opt ::=", - /* 309 */ "tag_list_opt ::= tag_item", - /* 310 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", - /* 311 */ "tag_item ::= TBNAME", - /* 312 */ "tag_item ::= QTAGS", - /* 313 */ "tag_item ::= column_name", - /* 314 */ "tag_item ::= column_name column_alias", - /* 315 */ "tag_item ::= column_name AS column_alias", - /* 316 */ "db_kind_opt ::=", - /* 317 */ "db_kind_opt ::= USER", - /* 318 */ "db_kind_opt ::= SYSTEM", - /* 319 */ "cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options", - /* 320 */ "cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP", - /* 321 */ "cmd ::= DROP INDEX exists_opt full_index_name", - /* 322 */ "full_index_name ::= index_name", - /* 323 */ "full_index_name ::= db_name NK_DOT index_name", - /* 324 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 325 */ "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", - /* 326 */ "func_list ::= func", - /* 327 */ "func_list ::= func_list NK_COMMA func", - /* 328 */ "func ::= sma_func_name NK_LP expression_list NK_RP", - /* 329 */ "sma_func_name ::= function_name", - /* 330 */ "sma_func_name ::= COUNT", - /* 331 */ "sma_func_name ::= FIRST", - /* 332 */ "sma_func_name ::= LAST", - /* 333 */ "sma_func_name ::= LAST_ROW", - /* 334 */ "sma_stream_opt ::=", - /* 335 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", - /* 336 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", - /* 337 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", - /* 338 */ "with_meta ::= AS", - /* 339 */ "with_meta ::= WITH META AS", - /* 340 */ "with_meta ::= ONLY META AS", - /* 341 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", - /* 342 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name", - /* 343 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt", - /* 344 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 345 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 346 */ "cmd ::= DESC full_table_name", - /* 347 */ "cmd ::= DESCRIBE full_table_name", - /* 348 */ "cmd ::= RESET QUERY CACHE", - /* 349 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", - /* 350 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", - /* 351 */ "analyze_opt ::=", - /* 352 */ "analyze_opt ::= ANALYZE", - /* 353 */ "explain_options ::=", - /* 354 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 355 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 356 */ "cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt", - /* 357 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 358 */ "agg_func_opt ::=", - /* 359 */ "agg_func_opt ::= AGGREGATE", - /* 360 */ "bufsize_opt ::=", - /* 361 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 362 */ "language_opt ::=", - /* 363 */ "language_opt ::= LANGUAGE NK_STRING", - /* 364 */ "or_replace_opt ::=", - /* 365 */ "or_replace_opt ::= OR REPLACE", - /* 366 */ "cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery", - /* 367 */ "cmd ::= DROP VIEW exists_opt full_view_name", - /* 368 */ "full_view_name ::= view_name", - /* 369 */ "full_view_name ::= db_name NK_DOT view_name", - /* 370 */ "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", - /* 371 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 372 */ "cmd ::= PAUSE STREAM exists_opt stream_name", - /* 373 */ "cmd ::= RESUME STREAM exists_opt ignore_opt stream_name", - /* 374 */ "col_list_opt ::=", - /* 375 */ "col_list_opt ::= NK_LP column_stream_def_list NK_RP", - /* 376 */ "column_stream_def_list ::= column_stream_def", - /* 377 */ "column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def", - /* 378 */ "column_stream_def ::= column_name", - /* 379 */ "column_stream_def ::= column_name PRIMARY KEY", - /* 380 */ "tag_def_or_ref_opt ::=", - /* 381 */ "tag_def_or_ref_opt ::= tags_def", - /* 382 */ "tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP", - /* 383 */ "stream_options ::=", - /* 384 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 385 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 386 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 387 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 388 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 389 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", - /* 390 */ "stream_options ::= stream_options DELETE_MARK duration_literal", - /* 391 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", - /* 392 */ "subtable_opt ::=", - /* 393 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 394 */ "ignore_opt ::=", - /* 395 */ "ignore_opt ::= IGNORE UNTREATED", - /* 396 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 397 */ "cmd ::= KILL QUERY NK_STRING", - /* 398 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 399 */ "cmd ::= KILL COMPACT NK_INTEGER", - /* 400 */ "cmd ::= BALANCE VGROUP", - /* 401 */ "cmd ::= BALANCE VGROUP LEADER on_vgroup_id", - /* 402 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 403 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 404 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 405 */ "on_vgroup_id ::=", - /* 406 */ "on_vgroup_id ::= ON NK_INTEGER", - /* 407 */ "dnode_list ::= DNODE NK_INTEGER", - /* 408 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 409 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 410 */ "cmd ::= query_or_subquery", - /* 411 */ "cmd ::= insert_query", - /* 412 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 413 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", - /* 414 */ "literal ::= NK_INTEGER", - /* 415 */ "literal ::= NK_FLOAT", - /* 416 */ "literal ::= NK_STRING", - /* 417 */ "literal ::= NK_BOOL", - /* 418 */ "literal ::= TIMESTAMP NK_STRING", - /* 419 */ "literal ::= duration_literal", - /* 420 */ "literal ::= NULL", - /* 421 */ "literal ::= NK_QUESTION", - /* 422 */ "duration_literal ::= NK_VARIABLE", - /* 423 */ "signed ::= NK_INTEGER", - /* 424 */ "signed ::= NK_PLUS NK_INTEGER", - /* 425 */ "signed ::= NK_MINUS NK_INTEGER", - /* 426 */ "signed ::= NK_FLOAT", - /* 427 */ "signed ::= NK_PLUS NK_FLOAT", - /* 428 */ "signed ::= NK_MINUS NK_FLOAT", - /* 429 */ "signed_literal ::= signed", - /* 430 */ "signed_literal ::= NK_STRING", - /* 431 */ "signed_literal ::= NK_BOOL", - /* 432 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 433 */ "signed_literal ::= duration_literal", - /* 434 */ "signed_literal ::= NULL", - /* 435 */ "signed_literal ::= literal_func", - /* 436 */ "signed_literal ::= NK_QUESTION", - /* 437 */ "literal_list ::= signed_literal", - /* 438 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 439 */ "db_name ::= NK_ID", - /* 440 */ "table_name ::= NK_ID", - /* 441 */ "column_name ::= NK_ID", - /* 442 */ "function_name ::= NK_ID", - /* 443 */ "view_name ::= NK_ID", - /* 444 */ "table_alias ::= NK_ID", - /* 445 */ "column_alias ::= NK_ID", - /* 446 */ "column_alias ::= NK_ALIAS", - /* 447 */ "user_name ::= NK_ID", - /* 448 */ "topic_name ::= NK_ID", - /* 449 */ "stream_name ::= NK_ID", - /* 450 */ "cgroup_name ::= NK_ID", - /* 451 */ "index_name ::= NK_ID", - /* 452 */ "expr_or_subquery ::= expression", - /* 453 */ "expression ::= literal", - /* 454 */ "expression ::= pseudo_column", - /* 455 */ "expression ::= column_reference", - /* 456 */ "expression ::= function_expression", - /* 457 */ "expression ::= case_when_expression", - /* 458 */ "expression ::= NK_LP expression NK_RP", - /* 459 */ "expression ::= NK_PLUS expr_or_subquery", - /* 460 */ "expression ::= NK_MINUS expr_or_subquery", - /* 461 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 462 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 463 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 464 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 465 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 466 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 467 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 468 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 469 */ "expression_list ::= expr_or_subquery", - /* 470 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 471 */ "column_reference ::= column_name", - /* 472 */ "column_reference ::= table_name NK_DOT column_name", - /* 473 */ "column_reference ::= NK_ALIAS", - /* 474 */ "column_reference ::= table_name NK_DOT NK_ALIAS", - /* 475 */ "pseudo_column ::= ROWTS", - /* 476 */ "pseudo_column ::= TBNAME", - /* 477 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 478 */ "pseudo_column ::= QSTART", - /* 479 */ "pseudo_column ::= QEND", - /* 480 */ "pseudo_column ::= QDURATION", - /* 481 */ "pseudo_column ::= WSTART", - /* 482 */ "pseudo_column ::= WEND", - /* 483 */ "pseudo_column ::= WDURATION", - /* 484 */ "pseudo_column ::= IROWTS", - /* 485 */ "pseudo_column ::= ISFILLED", - /* 486 */ "pseudo_column ::= QTAGS", - /* 487 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 488 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 489 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 490 */ "function_expression ::= literal_func", - /* 491 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 492 */ "literal_func ::= NOW", - /* 493 */ "noarg_func ::= NOW", - /* 494 */ "noarg_func ::= TODAY", - /* 495 */ "noarg_func ::= TIMEZONE", - /* 496 */ "noarg_func ::= DATABASE", - /* 497 */ "noarg_func ::= CLIENT_VERSION", - /* 498 */ "noarg_func ::= SERVER_VERSION", - /* 499 */ "noarg_func ::= SERVER_STATUS", - /* 500 */ "noarg_func ::= CURRENT_USER", - /* 501 */ "noarg_func ::= USER", - /* 502 */ "star_func ::= COUNT", - /* 503 */ "star_func ::= FIRST", - /* 504 */ "star_func ::= LAST", - /* 505 */ "star_func ::= LAST_ROW", - /* 506 */ "star_func_para_list ::= NK_STAR", - /* 507 */ "star_func_para_list ::= other_para_list", - /* 508 */ "other_para_list ::= star_func_para", - /* 509 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 510 */ "star_func_para ::= expr_or_subquery", - /* 511 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 512 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 513 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 514 */ "when_then_list ::= when_then_expr", - /* 515 */ "when_then_list ::= when_then_list when_then_expr", - /* 516 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 517 */ "case_when_else_opt ::=", - /* 518 */ "case_when_else_opt ::= ELSE common_expression", - /* 519 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 520 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 521 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 522 */ "predicate ::= expr_or_subquery IS NULL", - /* 523 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 524 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 525 */ "compare_op ::= NK_LT", - /* 526 */ "compare_op ::= NK_GT", - /* 527 */ "compare_op ::= NK_LE", - /* 528 */ "compare_op ::= NK_GE", - /* 529 */ "compare_op ::= NK_NE", - /* 530 */ "compare_op ::= NK_EQ", - /* 531 */ "compare_op ::= LIKE", - /* 532 */ "compare_op ::= NOT LIKE", - /* 533 */ "compare_op ::= MATCH", - /* 534 */ "compare_op ::= NMATCH", - /* 535 */ "compare_op ::= CONTAINS", - /* 536 */ "in_op ::= IN", - /* 537 */ "in_op ::= NOT IN", - /* 538 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 539 */ "boolean_value_expression ::= boolean_primary", - /* 540 */ "boolean_value_expression ::= NOT boolean_primary", - /* 541 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 542 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 543 */ "boolean_primary ::= predicate", - /* 544 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 545 */ "common_expression ::= expr_or_subquery", - /* 546 */ "common_expression ::= boolean_value_expression", - /* 547 */ "from_clause_opt ::=", - /* 548 */ "from_clause_opt ::= FROM table_reference_list", - /* 549 */ "table_reference_list ::= table_reference", - /* 550 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 551 */ "table_reference ::= table_primary", - /* 552 */ "table_reference ::= joined_table", - /* 553 */ "table_primary ::= table_name alias_opt", - /* 554 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 555 */ "table_primary ::= subquery alias_opt", - /* 556 */ "table_primary ::= parenthesized_joined_table", - /* 557 */ "alias_opt ::=", - /* 558 */ "alias_opt ::= table_alias", - /* 559 */ "alias_opt ::= AS table_alias", - /* 560 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 561 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 562 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 563 */ "join_type ::=", - /* 564 */ "join_type ::= INNER", - /* 565 */ "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", - /* 566 */ "hint_list ::=", - /* 567 */ "hint_list ::= NK_HINT", - /* 568 */ "tag_mode_opt ::=", - /* 569 */ "tag_mode_opt ::= TAGS", - /* 570 */ "set_quantifier_opt ::=", - /* 571 */ "set_quantifier_opt ::= DISTINCT", - /* 572 */ "set_quantifier_opt ::= ALL", - /* 573 */ "select_list ::= select_item", - /* 574 */ "select_list ::= select_list NK_COMMA select_item", - /* 575 */ "select_item ::= NK_STAR", - /* 576 */ "select_item ::= common_expression", - /* 577 */ "select_item ::= common_expression column_alias", - /* 578 */ "select_item ::= common_expression AS column_alias", - /* 579 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 580 */ "where_clause_opt ::=", - /* 581 */ "where_clause_opt ::= WHERE search_condition", - /* 582 */ "partition_by_clause_opt ::=", - /* 583 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 584 */ "partition_list ::= partition_item", - /* 585 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 586 */ "partition_item ::= expr_or_subquery", - /* 587 */ "partition_item ::= expr_or_subquery column_alias", - /* 588 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 589 */ "twindow_clause_opt ::=", - /* 590 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", - /* 591 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 592 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 593 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 594 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", - /* 595 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP", - /* 596 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 597 */ "sliding_opt ::=", - /* 598 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", - /* 599 */ "interval_sliding_duration_literal ::= NK_VARIABLE", - /* 600 */ "interval_sliding_duration_literal ::= NK_STRING", - /* 601 */ "interval_sliding_duration_literal ::= NK_INTEGER", - /* 602 */ "fill_opt ::=", - /* 603 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 604 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", - /* 605 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", - /* 606 */ "fill_mode ::= NONE", - /* 607 */ "fill_mode ::= PREV", - /* 608 */ "fill_mode ::= NULL", - /* 609 */ "fill_mode ::= NULL_F", - /* 610 */ "fill_mode ::= LINEAR", - /* 611 */ "fill_mode ::= NEXT", - /* 612 */ "group_by_clause_opt ::=", - /* 613 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 614 */ "group_by_list ::= expr_or_subquery", - /* 615 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 616 */ "having_clause_opt ::=", - /* 617 */ "having_clause_opt ::= HAVING search_condition", - /* 618 */ "range_opt ::=", - /* 619 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 620 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", - /* 621 */ "every_opt ::=", - /* 622 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 623 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 624 */ "query_simple ::= query_specification", - /* 625 */ "query_simple ::= union_query_expression", - /* 626 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 627 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 628 */ "query_simple_or_subquery ::= query_simple", - /* 629 */ "query_simple_or_subquery ::= subquery", - /* 630 */ "query_or_subquery ::= query_expression", - /* 631 */ "query_or_subquery ::= subquery", - /* 632 */ "order_by_clause_opt ::=", - /* 633 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 634 */ "slimit_clause_opt ::=", - /* 635 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 636 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 637 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 638 */ "limit_clause_opt ::=", - /* 639 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 640 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 641 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 642 */ "subquery ::= NK_LP query_expression NK_RP", - /* 643 */ "subquery ::= NK_LP subquery NK_RP", - /* 644 */ "search_condition ::= common_expression", - /* 645 */ "sort_specification_list ::= sort_specification", - /* 646 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 647 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 648 */ "ordering_specification_opt ::=", - /* 649 */ "ordering_specification_opt ::= ASC", - /* 650 */ "ordering_specification_opt ::= DESC", - /* 651 */ "null_ordering_opt ::=", - /* 652 */ "null_ordering_opt ::= NULLS FIRST", - /* 653 */ "null_ordering_opt ::= NULLS LAST", + /* 254 */ "cmd ::= SHOW ARBGROUPS", + /* 255 */ "cmd ::= SHOW FUNCTIONS", + /* 256 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 257 */ "cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name", + /* 258 */ "cmd ::= SHOW STREAMS", + /* 259 */ "cmd ::= SHOW ACCOUNTS", + /* 260 */ "cmd ::= SHOW APPS", + /* 261 */ "cmd ::= SHOW CONNECTIONS", + /* 262 */ "cmd ::= SHOW LICENCES", + /* 263 */ "cmd ::= SHOW GRANTS", + /* 264 */ "cmd ::= SHOW GRANTS FULL", + /* 265 */ "cmd ::= SHOW GRANTS LOGS", + /* 266 */ "cmd ::= SHOW CLUSTER MACHINES", + /* 267 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 268 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 269 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 270 */ "cmd ::= SHOW QUERIES", + /* 271 */ "cmd ::= SHOW SCORES", + /* 272 */ "cmd ::= SHOW TOPICS", + /* 273 */ "cmd ::= SHOW VARIABLES", + /* 274 */ "cmd ::= SHOW CLUSTER VARIABLES", + /* 275 */ "cmd ::= SHOW LOCAL VARIABLES", + /* 276 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt", + /* 277 */ "cmd ::= SHOW BNODES", + /* 278 */ "cmd ::= SHOW SNODES", + /* 279 */ "cmd ::= SHOW CLUSTER", + /* 280 */ "cmd ::= SHOW TRANSACTIONS", + /* 281 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", + /* 282 */ "cmd ::= SHOW CONSUMERS", + /* 283 */ "cmd ::= SHOW SUBSCRIPTIONS", + /* 284 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", + /* 285 */ "cmd ::= SHOW TAGS FROM db_name NK_DOT table_name", + /* 286 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", + /* 287 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name", + /* 288 */ "cmd ::= SHOW VNODES ON DNODE NK_INTEGER", + /* 289 */ "cmd ::= SHOW VNODES", + /* 290 */ "cmd ::= SHOW db_name_cond_opt ALIVE", + /* 291 */ "cmd ::= SHOW CLUSTER ALIVE", + /* 292 */ "cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt", + /* 293 */ "cmd ::= SHOW CREATE VIEW full_table_name", + /* 294 */ "cmd ::= SHOW COMPACTS", + /* 295 */ "cmd ::= SHOW COMPACT NK_INTEGER", + /* 296 */ "table_kind_db_name_cond_opt ::=", + /* 297 */ "table_kind_db_name_cond_opt ::= table_kind", + /* 298 */ "table_kind_db_name_cond_opt ::= db_name NK_DOT", + /* 299 */ "table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT", + /* 300 */ "table_kind ::= NORMAL", + /* 301 */ "table_kind ::= CHILD", + /* 302 */ "db_name_cond_opt ::=", + /* 303 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 304 */ "like_pattern_opt ::=", + /* 305 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 306 */ "table_name_cond ::= table_name", + /* 307 */ "from_db_opt ::=", + /* 308 */ "from_db_opt ::= FROM db_name", + /* 309 */ "tag_list_opt ::=", + /* 310 */ "tag_list_opt ::= tag_item", + /* 311 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", + /* 312 */ "tag_item ::= TBNAME", + /* 313 */ "tag_item ::= QTAGS", + /* 314 */ "tag_item ::= column_name", + /* 315 */ "tag_item ::= column_name column_alias", + /* 316 */ "tag_item ::= column_name AS column_alias", + /* 317 */ "db_kind_opt ::=", + /* 318 */ "db_kind_opt ::= USER", + /* 319 */ "db_kind_opt ::= SYSTEM", + /* 320 */ "cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options", + /* 321 */ "cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP", + /* 322 */ "cmd ::= DROP INDEX exists_opt full_index_name", + /* 323 */ "full_index_name ::= index_name", + /* 324 */ "full_index_name ::= db_name NK_DOT index_name", + /* 325 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 326 */ "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", + /* 327 */ "func_list ::= func", + /* 328 */ "func_list ::= func_list NK_COMMA func", + /* 329 */ "func ::= sma_func_name NK_LP expression_list NK_RP", + /* 330 */ "sma_func_name ::= function_name", + /* 331 */ "sma_func_name ::= COUNT", + /* 332 */ "sma_func_name ::= FIRST", + /* 333 */ "sma_func_name ::= LAST", + /* 334 */ "sma_func_name ::= LAST_ROW", + /* 335 */ "sma_stream_opt ::=", + /* 336 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", + /* 337 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", + /* 338 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", + /* 339 */ "with_meta ::= AS", + /* 340 */ "with_meta ::= WITH META AS", + /* 341 */ "with_meta ::= ONLY META AS", + /* 342 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", + /* 343 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name", + /* 344 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt", + /* 345 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 346 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 347 */ "cmd ::= DESC full_table_name", + /* 348 */ "cmd ::= DESCRIBE full_table_name", + /* 349 */ "cmd ::= RESET QUERY CACHE", + /* 350 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", + /* 351 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", + /* 352 */ "analyze_opt ::=", + /* 353 */ "analyze_opt ::= ANALYZE", + /* 354 */ "explain_options ::=", + /* 355 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 356 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 357 */ "cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt", + /* 358 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 359 */ "agg_func_opt ::=", + /* 360 */ "agg_func_opt ::= AGGREGATE", + /* 361 */ "bufsize_opt ::=", + /* 362 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 363 */ "language_opt ::=", + /* 364 */ "language_opt ::= LANGUAGE NK_STRING", + /* 365 */ "or_replace_opt ::=", + /* 366 */ "or_replace_opt ::= OR REPLACE", + /* 367 */ "cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery", + /* 368 */ "cmd ::= DROP VIEW exists_opt full_view_name", + /* 369 */ "full_view_name ::= view_name", + /* 370 */ "full_view_name ::= db_name NK_DOT view_name", + /* 371 */ "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", + /* 372 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 373 */ "cmd ::= PAUSE STREAM exists_opt stream_name", + /* 374 */ "cmd ::= RESUME STREAM exists_opt ignore_opt stream_name", + /* 375 */ "col_list_opt ::=", + /* 376 */ "col_list_opt ::= NK_LP column_stream_def_list NK_RP", + /* 377 */ "column_stream_def_list ::= column_stream_def", + /* 378 */ "column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def", + /* 379 */ "column_stream_def ::= column_name", + /* 380 */ "column_stream_def ::= column_name PRIMARY KEY", + /* 381 */ "tag_def_or_ref_opt ::=", + /* 382 */ "tag_def_or_ref_opt ::= tags_def", + /* 383 */ "tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP", + /* 384 */ "stream_options ::=", + /* 385 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 386 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 387 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 388 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 389 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", + /* 390 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", + /* 391 */ "stream_options ::= stream_options DELETE_MARK duration_literal", + /* 392 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", + /* 393 */ "subtable_opt ::=", + /* 394 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 395 */ "ignore_opt ::=", + /* 396 */ "ignore_opt ::= IGNORE UNTREATED", + /* 397 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 398 */ "cmd ::= KILL QUERY NK_STRING", + /* 399 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 400 */ "cmd ::= KILL COMPACT NK_INTEGER", + /* 401 */ "cmd ::= BALANCE VGROUP", + /* 402 */ "cmd ::= BALANCE VGROUP LEADER on_vgroup_id", + /* 403 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 404 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 405 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 406 */ "on_vgroup_id ::=", + /* 407 */ "on_vgroup_id ::= ON NK_INTEGER", + /* 408 */ "dnode_list ::= DNODE NK_INTEGER", + /* 409 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 410 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 411 */ "cmd ::= query_or_subquery", + /* 412 */ "cmd ::= insert_query", + /* 413 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 414 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", + /* 415 */ "tags_literal ::= NK_INTEGER", + /* 416 */ "tags_literal ::= NK_PLUS NK_INTEGER", + /* 417 */ "tags_literal ::= NK_MINUS NK_INTEGER", + /* 418 */ "tags_literal ::= NK_FLOAT", + /* 419 */ "tags_literal ::= NK_PLUS NK_FLOAT", + /* 420 */ "tags_literal ::= NK_MINUS NK_FLOAT", + /* 421 */ "tags_literal ::= NK_BIN", + /* 422 */ "tags_literal ::= NK_PLUS NK_BIN", + /* 423 */ "tags_literal ::= NK_MINUS NK_BIN", + /* 424 */ "tags_literal ::= NK_HEX", + /* 425 */ "tags_literal ::= NK_PLUS NK_HEX", + /* 426 */ "tags_literal ::= NK_MINUS NK_HEX", + /* 427 */ "tags_literal ::= NK_STRING", + /* 428 */ "tags_literal ::= NK_BOOL", + /* 429 */ "tags_literal ::= NULL", + /* 430 */ "tags_literal ::= literal_func", + /* 431 */ "tags_literal ::= literal_func NK_PLUS duration_literal", + /* 432 */ "tags_literal ::= literal_func NK_MINUS duration_literal", + /* 433 */ "tags_literal_list ::= tags_literal", + /* 434 */ "tags_literal_list ::= tags_literal_list NK_COMMA tags_literal", + /* 435 */ "literal ::= NK_INTEGER", + /* 436 */ "literal ::= NK_FLOAT", + /* 437 */ "literal ::= NK_STRING", + /* 438 */ "literal ::= NK_BOOL", + /* 439 */ "literal ::= TIMESTAMP NK_STRING", + /* 440 */ "literal ::= duration_literal", + /* 441 */ "literal ::= NULL", + /* 442 */ "literal ::= NK_QUESTION", + /* 443 */ "duration_literal ::= NK_VARIABLE", + /* 444 */ "signed ::= NK_INTEGER", + /* 445 */ "signed ::= NK_PLUS NK_INTEGER", + /* 446 */ "signed ::= NK_MINUS NK_INTEGER", + /* 447 */ "signed ::= NK_FLOAT", + /* 448 */ "signed ::= NK_PLUS NK_FLOAT", + /* 449 */ "signed ::= NK_MINUS NK_FLOAT", + /* 450 */ "signed_literal ::= signed", + /* 451 */ "signed_literal ::= NK_STRING", + /* 452 */ "signed_literal ::= NK_BOOL", + /* 453 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 454 */ "signed_literal ::= duration_literal", + /* 455 */ "signed_literal ::= NULL", + /* 456 */ "signed_literal ::= literal_func", + /* 457 */ "signed_literal ::= NK_QUESTION", + /* 458 */ "literal_list ::= signed_literal", + /* 459 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 460 */ "db_name ::= NK_ID", + /* 461 */ "table_name ::= NK_ID", + /* 462 */ "column_name ::= NK_ID", + /* 463 */ "function_name ::= NK_ID", + /* 464 */ "view_name ::= NK_ID", + /* 465 */ "table_alias ::= NK_ID", + /* 466 */ "column_alias ::= NK_ID", + /* 467 */ "column_alias ::= NK_ALIAS", + /* 468 */ "user_name ::= NK_ID", + /* 469 */ "topic_name ::= NK_ID", + /* 470 */ "stream_name ::= NK_ID", + /* 471 */ "cgroup_name ::= NK_ID", + /* 472 */ "index_name ::= NK_ID", + /* 473 */ "expr_or_subquery ::= expression", + /* 474 */ "expression ::= literal", + /* 475 */ "expression ::= pseudo_column", + /* 476 */ "expression ::= column_reference", + /* 477 */ "expression ::= function_expression", + /* 478 */ "expression ::= case_when_expression", + /* 479 */ "expression ::= NK_LP expression NK_RP", + /* 480 */ "expression ::= NK_PLUS expr_or_subquery", + /* 481 */ "expression ::= NK_MINUS expr_or_subquery", + /* 482 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 483 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 484 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 485 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 486 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 487 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 488 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 489 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 490 */ "expression_list ::= expr_or_subquery", + /* 491 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 492 */ "column_reference ::= column_name", + /* 493 */ "column_reference ::= table_name NK_DOT column_name", + /* 494 */ "column_reference ::= NK_ALIAS", + /* 495 */ "column_reference ::= table_name NK_DOT NK_ALIAS", + /* 496 */ "pseudo_column ::= ROWTS", + /* 497 */ "pseudo_column ::= TBNAME", + /* 498 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 499 */ "pseudo_column ::= QSTART", + /* 500 */ "pseudo_column ::= QEND", + /* 501 */ "pseudo_column ::= QDURATION", + /* 502 */ "pseudo_column ::= WSTART", + /* 503 */ "pseudo_column ::= WEND", + /* 504 */ "pseudo_column ::= WDURATION", + /* 505 */ "pseudo_column ::= IROWTS", + /* 506 */ "pseudo_column ::= ISFILLED", + /* 507 */ "pseudo_column ::= QTAGS", + /* 508 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 509 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 510 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 511 */ "function_expression ::= literal_func", + /* 512 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 513 */ "literal_func ::= NOW", + /* 514 */ "literal_func ::= TODAY", + /* 515 */ "noarg_func ::= NOW", + /* 516 */ "noarg_func ::= TODAY", + /* 517 */ "noarg_func ::= TIMEZONE", + /* 518 */ "noarg_func ::= DATABASE", + /* 519 */ "noarg_func ::= CLIENT_VERSION", + /* 520 */ "noarg_func ::= SERVER_VERSION", + /* 521 */ "noarg_func ::= SERVER_STATUS", + /* 522 */ "noarg_func ::= CURRENT_USER", + /* 523 */ "noarg_func ::= USER", + /* 524 */ "star_func ::= COUNT", + /* 525 */ "star_func ::= FIRST", + /* 526 */ "star_func ::= LAST", + /* 527 */ "star_func ::= LAST_ROW", + /* 528 */ "star_func_para_list ::= NK_STAR", + /* 529 */ "star_func_para_list ::= other_para_list", + /* 530 */ "other_para_list ::= star_func_para", + /* 531 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 532 */ "star_func_para ::= expr_or_subquery", + /* 533 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 534 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 535 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 536 */ "when_then_list ::= when_then_expr", + /* 537 */ "when_then_list ::= when_then_list when_then_expr", + /* 538 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 539 */ "case_when_else_opt ::=", + /* 540 */ "case_when_else_opt ::= ELSE common_expression", + /* 541 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 542 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 543 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 544 */ "predicate ::= expr_or_subquery IS NULL", + /* 545 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 546 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 547 */ "compare_op ::= NK_LT", + /* 548 */ "compare_op ::= NK_GT", + /* 549 */ "compare_op ::= NK_LE", + /* 550 */ "compare_op ::= NK_GE", + /* 551 */ "compare_op ::= NK_NE", + /* 552 */ "compare_op ::= NK_EQ", + /* 553 */ "compare_op ::= LIKE", + /* 554 */ "compare_op ::= NOT LIKE", + /* 555 */ "compare_op ::= MATCH", + /* 556 */ "compare_op ::= NMATCH", + /* 557 */ "compare_op ::= CONTAINS", + /* 558 */ "in_op ::= IN", + /* 559 */ "in_op ::= NOT IN", + /* 560 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 561 */ "boolean_value_expression ::= boolean_primary", + /* 562 */ "boolean_value_expression ::= NOT boolean_primary", + /* 563 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 564 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 565 */ "boolean_primary ::= predicate", + /* 566 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 567 */ "common_expression ::= expr_or_subquery", + /* 568 */ "common_expression ::= boolean_value_expression", + /* 569 */ "from_clause_opt ::=", + /* 570 */ "from_clause_opt ::= FROM table_reference_list", + /* 571 */ "table_reference_list ::= table_reference", + /* 572 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 573 */ "table_reference ::= table_primary", + /* 574 */ "table_reference ::= joined_table", + /* 575 */ "table_primary ::= table_name alias_opt", + /* 576 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 577 */ "table_primary ::= subquery alias_opt", + /* 578 */ "table_primary ::= parenthesized_joined_table", + /* 579 */ "alias_opt ::=", + /* 580 */ "alias_opt ::= table_alias", + /* 581 */ "alias_opt ::= AS table_alias", + /* 582 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 583 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 584 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 585 */ "join_type ::=", + /* 586 */ "join_type ::= INNER", + /* 587 */ "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", + /* 588 */ "hint_list ::=", + /* 589 */ "hint_list ::= NK_HINT", + /* 590 */ "tag_mode_opt ::=", + /* 591 */ "tag_mode_opt ::= TAGS", + /* 592 */ "set_quantifier_opt ::=", + /* 593 */ "set_quantifier_opt ::= DISTINCT", + /* 594 */ "set_quantifier_opt ::= ALL", + /* 595 */ "select_list ::= select_item", + /* 596 */ "select_list ::= select_list NK_COMMA select_item", + /* 597 */ "select_item ::= NK_STAR", + /* 598 */ "select_item ::= common_expression", + /* 599 */ "select_item ::= common_expression column_alias", + /* 600 */ "select_item ::= common_expression AS column_alias", + /* 601 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 602 */ "where_clause_opt ::=", + /* 603 */ "where_clause_opt ::= WHERE search_condition", + /* 604 */ "partition_by_clause_opt ::=", + /* 605 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 606 */ "partition_list ::= partition_item", + /* 607 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 608 */ "partition_item ::= expr_or_subquery", + /* 609 */ "partition_item ::= expr_or_subquery column_alias", + /* 610 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 611 */ "twindow_clause_opt ::=", + /* 612 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", + /* 613 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 614 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", + /* 615 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", + /* 616 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", + /* 617 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP", + /* 618 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 619 */ "sliding_opt ::=", + /* 620 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", + /* 621 */ "interval_sliding_duration_literal ::= NK_VARIABLE", + /* 622 */ "interval_sliding_duration_literal ::= NK_STRING", + /* 623 */ "interval_sliding_duration_literal ::= NK_INTEGER", + /* 624 */ "fill_opt ::=", + /* 625 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 626 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", + /* 627 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", + /* 628 */ "fill_mode ::= NONE", + /* 629 */ "fill_mode ::= PREV", + /* 630 */ "fill_mode ::= NULL", + /* 631 */ "fill_mode ::= NULL_F", + /* 632 */ "fill_mode ::= LINEAR", + /* 633 */ "fill_mode ::= NEXT", + /* 634 */ "group_by_clause_opt ::=", + /* 635 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 636 */ "group_by_list ::= expr_or_subquery", + /* 637 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 638 */ "having_clause_opt ::=", + /* 639 */ "having_clause_opt ::= HAVING search_condition", + /* 640 */ "range_opt ::=", + /* 641 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 642 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", + /* 643 */ "every_opt ::=", + /* 644 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 645 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 646 */ "query_simple ::= query_specification", + /* 647 */ "query_simple ::= union_query_expression", + /* 648 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 649 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 650 */ "query_simple_or_subquery ::= query_simple", + /* 651 */ "query_simple_or_subquery ::= subquery", + /* 652 */ "query_or_subquery ::= query_expression", + /* 653 */ "query_or_subquery ::= subquery", + /* 654 */ "order_by_clause_opt ::=", + /* 655 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 656 */ "slimit_clause_opt ::=", + /* 657 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 658 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 659 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 660 */ "limit_clause_opt ::=", + /* 661 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 662 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 663 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 664 */ "subquery ::= NK_LP query_expression NK_RP", + /* 665 */ "subquery ::= NK_LP subquery NK_RP", + /* 666 */ "search_condition ::= common_expression", + /* 667 */ "sort_specification_list ::= sort_specification", + /* 668 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 669 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 670 */ "ordering_specification_opt ::=", + /* 671 */ "ordering_specification_opt ::= ASC", + /* 672 */ "ordering_specification_opt ::= DESC", + /* 673 */ "null_ordering_opt ::=", + /* 674 */ "null_ordering_opt ::= NULLS FIRST", + /* 675 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -3230,233 +3247,235 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 352: /* cmd */ - case 355: /* literal */ - case 364: /* with_opt */ - case 370: /* search_condition */ - case 375: /* db_options */ - case 377: /* alter_db_options */ - case 379: /* start_opt */ - case 380: /* end_opt */ - case 384: /* signed */ - case 386: /* retention */ - case 387: /* full_table_name */ - case 390: /* table_options */ - case 394: /* alter_table_clause */ - case 395: /* alter_table_options */ - case 398: /* signed_literal */ - case 399: /* create_subtable_clause */ - case 402: /* drop_table_clause */ - case 404: /* column_def */ - case 408: /* duration_literal */ - case 409: /* rollup_func_name */ - case 411: /* col_name */ - case 414: /* like_pattern_opt */ - case 415: /* db_name_cond_opt */ - case 416: /* table_name_cond */ - case 417: /* from_db_opt */ - case 420: /* tag_item */ - case 422: /* index_options */ - case 423: /* full_index_name */ - case 426: /* sliding_opt */ - case 427: /* sma_stream_opt */ - case 428: /* func */ - case 431: /* query_or_subquery */ - case 432: /* where_clause_opt */ - case 435: /* explain_options */ - case 436: /* insert_query */ - case 441: /* full_view_name */ - case 444: /* stream_options */ - case 447: /* subtable_opt */ - case 450: /* column_stream_def */ - case 451: /* expression */ - case 454: /* literal_func */ - case 457: /* expr_or_subquery */ - case 458: /* pseudo_column */ - case 459: /* column_reference */ - case 460: /* function_expression */ - case 461: /* case_when_expression */ - case 466: /* star_func_para */ - case 468: /* case_when_else_opt */ - case 469: /* common_expression */ - case 470: /* when_then_expr */ - case 471: /* predicate */ - case 474: /* in_predicate_value */ - case 475: /* boolean_value_expression */ - case 476: /* boolean_primary */ - case 477: /* from_clause_opt */ - case 478: /* table_reference_list */ - case 479: /* table_reference */ - case 480: /* table_primary */ - case 481: /* joined_table */ - case 483: /* subquery */ - case 484: /* parenthesized_joined_table */ - case 486: /* query_specification */ - case 492: /* range_opt */ - case 493: /* every_opt */ - case 494: /* fill_opt */ - case 495: /* twindow_clause_opt */ - case 497: /* having_clause_opt */ - case 498: /* select_item */ - case 500: /* partition_item */ - case 501: /* interval_sliding_duration_literal */ - case 504: /* query_expression */ - case 505: /* query_simple */ - case 507: /* slimit_clause_opt */ - case 508: /* limit_clause_opt */ - case 509: /* union_query_expression */ - case 510: /* query_simple_or_subquery */ - case 512: /* sort_specification */ + case 355: /* cmd */ + case 358: /* literal */ + case 367: /* with_opt */ + case 373: /* search_condition */ + case 378: /* db_options */ + case 380: /* alter_db_options */ + case 382: /* start_opt */ + case 383: /* end_opt */ + case 387: /* signed */ + case 389: /* retention */ + case 390: /* full_table_name */ + case 393: /* table_options */ + case 397: /* alter_table_clause */ + case 398: /* alter_table_options */ + case 401: /* tags_literal */ + case 402: /* create_subtable_clause */ + case 405: /* drop_table_clause */ + case 407: /* column_def */ + case 411: /* duration_literal */ + case 412: /* rollup_func_name */ + case 414: /* col_name */ + case 417: /* like_pattern_opt */ + case 418: /* db_name_cond_opt */ + case 419: /* table_name_cond */ + case 420: /* from_db_opt */ + case 423: /* tag_item */ + case 425: /* index_options */ + case 426: /* full_index_name */ + case 429: /* sliding_opt */ + case 430: /* sma_stream_opt */ + case 431: /* func */ + case 435: /* query_or_subquery */ + case 436: /* where_clause_opt */ + case 439: /* explain_options */ + case 440: /* insert_query */ + case 445: /* full_view_name */ + case 448: /* stream_options */ + case 451: /* subtable_opt */ + case 454: /* column_stream_def */ + case 455: /* expression */ + case 458: /* literal_func */ + case 459: /* signed_literal */ + case 462: /* expr_or_subquery */ + case 463: /* pseudo_column */ + case 464: /* column_reference */ + case 465: /* function_expression */ + case 466: /* case_when_expression */ + case 471: /* star_func_para */ + case 473: /* case_when_else_opt */ + case 474: /* common_expression */ + case 475: /* when_then_expr */ + case 476: /* predicate */ + case 479: /* in_predicate_value */ + case 480: /* boolean_value_expression */ + case 481: /* boolean_primary */ + case 482: /* from_clause_opt */ + case 483: /* table_reference_list */ + case 484: /* table_reference */ + case 485: /* table_primary */ + case 486: /* joined_table */ + case 488: /* subquery */ + case 489: /* parenthesized_joined_table */ + case 491: /* query_specification */ + case 497: /* range_opt */ + case 498: /* every_opt */ + case 499: /* fill_opt */ + case 500: /* twindow_clause_opt */ + case 502: /* having_clause_opt */ + case 503: /* select_item */ + case 505: /* partition_item */ + case 506: /* interval_sliding_duration_literal */ + case 509: /* query_expression */ + case 510: /* query_simple */ + case 512: /* slimit_clause_opt */ + case 513: /* limit_clause_opt */ + case 514: /* union_query_expression */ + case 515: /* query_simple_or_subquery */ + case 517: /* sort_specification */ { - nodesDestroyNode((yypminor->yy752)); + nodesDestroyNode((yypminor->yy392)); } break; - case 353: /* account_options */ - case 354: /* alter_account_options */ - case 356: /* alter_account_option */ - case 378: /* speed_opt */ - case 430: /* with_meta */ - case 439: /* bufsize_opt */ + case 356: /* account_options */ + case 357: /* alter_account_options */ + case 359: /* alter_account_option */ + case 381: /* speed_opt */ + case 434: /* with_meta */ + case 443: /* bufsize_opt */ { } break; - case 357: /* ip_range_list */ - case 358: /* white_list */ - case 359: /* white_list_opt */ - case 381: /* integer_list */ - case 382: /* variable_list */ - case 383: /* retention_list */ - case 388: /* column_def_list */ - case 389: /* tags_def_opt */ - case 391: /* multi_create_clause */ - case 392: /* tags_def */ - case 393: /* multi_drop_clause */ - case 400: /* specific_cols_opt */ - case 401: /* expression_list */ - case 403: /* col_name_list */ - case 405: /* duration_list */ - case 406: /* rollup_func_list */ - case 418: /* tag_list_opt */ - case 425: /* func_list */ - case 445: /* col_list_opt */ - case 446: /* tag_def_or_ref_opt */ - case 449: /* column_stream_def_list */ - case 453: /* dnode_list */ - case 455: /* literal_list */ - case 463: /* star_func_para_list */ - case 465: /* other_para_list */ - case 467: /* when_then_list */ - case 487: /* hint_list */ - case 490: /* select_list */ - case 491: /* partition_by_clause_opt */ - case 496: /* group_by_clause_opt */ - case 499: /* partition_list */ - case 503: /* group_by_list */ - case 506: /* order_by_clause_opt */ - case 511: /* sort_specification_list */ + case 360: /* ip_range_list */ + case 361: /* white_list */ + case 362: /* white_list_opt */ + case 384: /* integer_list */ + case 385: /* variable_list */ + case 386: /* retention_list */ + case 391: /* column_def_list */ + case 392: /* tags_def_opt */ + case 394: /* multi_create_clause */ + case 395: /* tags_def */ + case 396: /* multi_drop_clause */ + case 403: /* specific_cols_opt */ + case 404: /* tags_literal_list */ + case 406: /* col_name_list */ + case 408: /* duration_list */ + case 409: /* rollup_func_list */ + case 421: /* tag_list_opt */ + case 428: /* func_list */ + case 433: /* expression_list */ + case 449: /* col_list_opt */ + case 450: /* tag_def_or_ref_opt */ + case 453: /* column_stream_def_list */ + case 457: /* dnode_list */ + case 460: /* literal_list */ + case 468: /* star_func_para_list */ + case 470: /* other_para_list */ + case 472: /* when_then_list */ + case 492: /* hint_list */ + case 495: /* select_list */ + case 496: /* partition_by_clause_opt */ + case 501: /* group_by_clause_opt */ + case 504: /* partition_list */ + case 508: /* group_by_list */ + case 511: /* order_by_clause_opt */ + case 516: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy264)); + nodesDestroyList((yypminor->yy184)); } break; - case 360: /* user_name */ - case 367: /* db_name */ - case 368: /* table_name */ - case 369: /* topic_name */ - case 371: /* dnode_endpoint */ - case 396: /* column_name */ - case 410: /* function_name */ - case 421: /* column_alias */ - case 424: /* index_name */ - case 429: /* sma_func_name */ - case 433: /* cgroup_name */ - case 440: /* language_opt */ - case 442: /* view_name */ - case 443: /* stream_name */ - case 452: /* on_vgroup_id */ - case 456: /* table_alias */ - case 462: /* star_func */ - case 464: /* noarg_func */ - case 482: /* alias_opt */ + case 363: /* user_name */ + case 370: /* db_name */ + case 371: /* table_name */ + case 372: /* topic_name */ + case 374: /* dnode_endpoint */ + case 399: /* column_name */ + case 413: /* function_name */ + case 424: /* column_alias */ + case 427: /* index_name */ + case 432: /* sma_func_name */ + case 437: /* cgroup_name */ + case 444: /* language_opt */ + case 446: /* view_name */ + case 447: /* stream_name */ + case 456: /* on_vgroup_id */ + case 461: /* table_alias */ + case 467: /* star_func */ + case 469: /* noarg_func */ + case 487: /* alias_opt */ { } break; - case 361: /* sysinfo_opt */ + case 364: /* sysinfo_opt */ { } break; - case 362: /* privileges */ - case 365: /* priv_type_list */ - case 366: /* priv_type */ + case 365: /* privileges */ + case 368: /* priv_type_list */ + case 369: /* priv_type */ { } break; - case 363: /* priv_level */ + case 366: /* priv_level */ { } break; - case 372: /* force_opt */ - case 373: /* unsafe_opt */ - case 374: /* not_exists_opt */ - case 376: /* exists_opt */ - case 434: /* analyze_opt */ - case 437: /* or_replace_opt */ - case 438: /* agg_func_opt */ - case 448: /* ignore_opt */ - case 488: /* set_quantifier_opt */ - case 489: /* tag_mode_opt */ + case 375: /* force_opt */ + case 376: /* unsafe_opt */ + case 377: /* not_exists_opt */ + case 379: /* exists_opt */ + case 438: /* analyze_opt */ + case 441: /* or_replace_opt */ + case 442: /* agg_func_opt */ + case 452: /* ignore_opt */ + case 493: /* set_quantifier_opt */ + case 494: /* tag_mode_opt */ { } break; - case 385: /* alter_db_option */ - case 407: /* alter_table_option */ + case 388: /* alter_db_option */ + case 410: /* alter_table_option */ { } break; - case 397: /* type_name */ + case 400: /* type_name */ { } break; - case 412: /* db_kind_opt */ - case 419: /* table_kind */ + case 415: /* db_kind_opt */ + case 422: /* table_kind */ { } break; - case 413: /* table_kind_db_name_cond_opt */ + case 416: /* table_kind_db_name_cond_opt */ { } break; - case 472: /* compare_op */ - case 473: /* in_op */ + case 477: /* compare_op */ + case 478: /* in_op */ { } break; - case 485: /* join_type */ + case 490: /* join_type */ { } break; - case 502: /* fill_mode */ + case 507: /* fill_mode */ { } break; - case 513: /* ordering_specification_opt */ + case 518: /* ordering_specification_opt */ { } break; - case 514: /* null_ordering_opt */ + case 519: /* null_ordering_opt */ { } @@ -3747,660 +3766,682 @@ static void yy_shift( /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side ** of that rule */ static const YYCODETYPE yyRuleInfoLhs[] = { - 352, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - 352, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - 353, /* (2) account_options ::= */ - 353, /* (3) account_options ::= account_options PPS literal */ - 353, /* (4) account_options ::= account_options TSERIES literal */ - 353, /* (5) account_options ::= account_options STORAGE literal */ - 353, /* (6) account_options ::= account_options STREAMS literal */ - 353, /* (7) account_options ::= account_options QTIME literal */ - 353, /* (8) account_options ::= account_options DBS literal */ - 353, /* (9) account_options ::= account_options USERS literal */ - 353, /* (10) account_options ::= account_options CONNS literal */ - 353, /* (11) account_options ::= account_options STATE literal */ - 354, /* (12) alter_account_options ::= alter_account_option */ - 354, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - 356, /* (14) alter_account_option ::= PASS literal */ - 356, /* (15) alter_account_option ::= PPS literal */ - 356, /* (16) alter_account_option ::= TSERIES literal */ - 356, /* (17) alter_account_option ::= STORAGE literal */ - 356, /* (18) alter_account_option ::= STREAMS literal */ - 356, /* (19) alter_account_option ::= QTIME literal */ - 356, /* (20) alter_account_option ::= DBS literal */ - 356, /* (21) alter_account_option ::= USERS literal */ - 356, /* (22) alter_account_option ::= CONNS literal */ - 356, /* (23) alter_account_option ::= STATE literal */ - 357, /* (24) ip_range_list ::= NK_STRING */ - 357, /* (25) ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ - 358, /* (26) white_list ::= HOST ip_range_list */ - 359, /* (27) white_list_opt ::= */ - 359, /* (28) white_list_opt ::= white_list */ - 352, /* (29) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ - 352, /* (30) cmd ::= ALTER USER user_name PASS NK_STRING */ - 352, /* (31) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - 352, /* (32) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - 352, /* (33) cmd ::= ALTER USER user_name ADD white_list */ - 352, /* (34) cmd ::= ALTER USER user_name DROP white_list */ - 352, /* (35) cmd ::= DROP USER user_name */ - 361, /* (36) sysinfo_opt ::= */ - 361, /* (37) sysinfo_opt ::= SYSINFO NK_INTEGER */ - 352, /* (38) cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ - 352, /* (39) cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ - 362, /* (40) privileges ::= ALL */ - 362, /* (41) privileges ::= priv_type_list */ - 362, /* (42) privileges ::= SUBSCRIBE */ - 365, /* (43) priv_type_list ::= priv_type */ - 365, /* (44) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - 366, /* (45) priv_type ::= READ */ - 366, /* (46) priv_type ::= WRITE */ - 366, /* (47) priv_type ::= ALTER */ - 363, /* (48) priv_level ::= NK_STAR NK_DOT NK_STAR */ - 363, /* (49) priv_level ::= db_name NK_DOT NK_STAR */ - 363, /* (50) priv_level ::= db_name NK_DOT table_name */ - 363, /* (51) priv_level ::= topic_name */ - 364, /* (52) with_opt ::= */ - 364, /* (53) with_opt ::= WITH search_condition */ - 352, /* (54) cmd ::= CREATE DNODE dnode_endpoint */ - 352, /* (55) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - 352, /* (56) cmd ::= DROP DNODE NK_INTEGER force_opt */ - 352, /* (57) cmd ::= DROP DNODE dnode_endpoint force_opt */ - 352, /* (58) cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ - 352, /* (59) cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ - 352, /* (60) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - 352, /* (61) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - 352, /* (62) cmd ::= ALTER ALL DNODES NK_STRING */ - 352, /* (63) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - 352, /* (64) cmd ::= RESTORE DNODE NK_INTEGER */ - 371, /* (65) dnode_endpoint ::= NK_STRING */ - 371, /* (66) dnode_endpoint ::= NK_ID */ - 371, /* (67) dnode_endpoint ::= NK_IPTOKEN */ - 372, /* (68) force_opt ::= */ - 372, /* (69) force_opt ::= FORCE */ - 373, /* (70) unsafe_opt ::= UNSAFE */ - 352, /* (71) cmd ::= ALTER CLUSTER NK_STRING */ - 352, /* (72) cmd ::= ALTER CLUSTER NK_STRING NK_STRING */ - 352, /* (73) cmd ::= ALTER LOCAL NK_STRING */ - 352, /* (74) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - 352, /* (75) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - 352, /* (76) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - 352, /* (77) cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ - 352, /* (78) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - 352, /* (79) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - 352, /* (80) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - 352, /* (81) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - 352, /* (82) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - 352, /* (83) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - 352, /* (84) cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ - 352, /* (85) cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ - 352, /* (86) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - 352, /* (87) cmd ::= DROP DATABASE exists_opt db_name */ - 352, /* (88) cmd ::= USE db_name */ - 352, /* (89) cmd ::= ALTER DATABASE db_name alter_db_options */ - 352, /* (90) cmd ::= FLUSH DATABASE db_name */ - 352, /* (91) cmd ::= TRIM DATABASE db_name speed_opt */ - 352, /* (92) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ - 374, /* (93) not_exists_opt ::= IF NOT EXISTS */ - 374, /* (94) not_exists_opt ::= */ - 376, /* (95) exists_opt ::= IF EXISTS */ - 376, /* (96) exists_opt ::= */ - 375, /* (97) db_options ::= */ - 375, /* (98) db_options ::= db_options BUFFER NK_INTEGER */ - 375, /* (99) db_options ::= db_options CACHEMODEL NK_STRING */ - 375, /* (100) db_options ::= db_options CACHESIZE NK_INTEGER */ - 375, /* (101) db_options ::= db_options COMP NK_INTEGER */ - 375, /* (102) db_options ::= db_options DURATION NK_INTEGER */ - 375, /* (103) db_options ::= db_options DURATION NK_VARIABLE */ - 375, /* (104) db_options ::= db_options MAXROWS NK_INTEGER */ - 375, /* (105) db_options ::= db_options MINROWS NK_INTEGER */ - 375, /* (106) db_options ::= db_options KEEP integer_list */ - 375, /* (107) db_options ::= db_options KEEP variable_list */ - 375, /* (108) db_options ::= db_options PAGES NK_INTEGER */ - 375, /* (109) db_options ::= db_options PAGESIZE NK_INTEGER */ - 375, /* (110) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ - 375, /* (111) db_options ::= db_options PRECISION NK_STRING */ - 375, /* (112) db_options ::= db_options REPLICA NK_INTEGER */ - 375, /* (113) db_options ::= db_options VGROUPS NK_INTEGER */ - 375, /* (114) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - 375, /* (115) db_options ::= db_options RETENTIONS retention_list */ - 375, /* (116) db_options ::= db_options SCHEMALESS NK_INTEGER */ - 375, /* (117) db_options ::= db_options WAL_LEVEL NK_INTEGER */ - 375, /* (118) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ - 375, /* (119) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ - 375, /* (120) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - 375, /* (121) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ - 375, /* (122) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - 375, /* (123) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ - 375, /* (124) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ - 375, /* (125) db_options ::= db_options STT_TRIGGER NK_INTEGER */ - 375, /* (126) db_options ::= db_options TABLE_PREFIX signed */ - 375, /* (127) db_options ::= db_options TABLE_SUFFIX signed */ - 375, /* (128) db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ - 377, /* (129) alter_db_options ::= alter_db_option */ - 377, /* (130) alter_db_options ::= alter_db_options alter_db_option */ - 385, /* (131) alter_db_option ::= BUFFER NK_INTEGER */ - 385, /* (132) alter_db_option ::= CACHEMODEL NK_STRING */ - 385, /* (133) alter_db_option ::= CACHESIZE NK_INTEGER */ - 385, /* (134) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ - 385, /* (135) alter_db_option ::= KEEP integer_list */ - 385, /* (136) alter_db_option ::= KEEP variable_list */ - 385, /* (137) alter_db_option ::= PAGES NK_INTEGER */ - 385, /* (138) alter_db_option ::= REPLICA NK_INTEGER */ - 385, /* (139) alter_db_option ::= WAL_LEVEL NK_INTEGER */ - 385, /* (140) alter_db_option ::= STT_TRIGGER NK_INTEGER */ - 385, /* (141) alter_db_option ::= MINROWS NK_INTEGER */ - 385, /* (142) alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ - 385, /* (143) alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - 385, /* (144) alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ - 385, /* (145) alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - 385, /* (146) alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ - 381, /* (147) integer_list ::= NK_INTEGER */ - 381, /* (148) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - 382, /* (149) variable_list ::= NK_VARIABLE */ - 382, /* (150) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - 383, /* (151) retention_list ::= retention */ - 383, /* (152) retention_list ::= retention_list NK_COMMA retention */ - 386, /* (153) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - 386, /* (154) retention ::= NK_MINUS NK_COLON NK_VARIABLE */ - 378, /* (155) speed_opt ::= */ - 378, /* (156) speed_opt ::= BWLIMIT NK_INTEGER */ - 379, /* (157) start_opt ::= */ - 379, /* (158) start_opt ::= START WITH NK_INTEGER */ - 379, /* (159) start_opt ::= START WITH NK_STRING */ - 379, /* (160) start_opt ::= START WITH TIMESTAMP NK_STRING */ - 380, /* (161) end_opt ::= */ - 380, /* (162) end_opt ::= END WITH NK_INTEGER */ - 380, /* (163) end_opt ::= END WITH NK_STRING */ - 380, /* (164) end_opt ::= END WITH TIMESTAMP NK_STRING */ - 352, /* (165) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - 352, /* (166) cmd ::= CREATE TABLE multi_create_clause */ - 352, /* (167) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - 352, /* (168) cmd ::= DROP TABLE multi_drop_clause */ - 352, /* (169) cmd ::= DROP STABLE exists_opt full_table_name */ - 352, /* (170) cmd ::= ALTER TABLE alter_table_clause */ - 352, /* (171) cmd ::= ALTER STABLE alter_table_clause */ - 394, /* (172) alter_table_clause ::= full_table_name alter_table_options */ - 394, /* (173) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - 394, /* (174) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - 394, /* (175) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - 394, /* (176) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - 394, /* (177) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - 394, /* (178) alter_table_clause ::= full_table_name DROP TAG column_name */ - 394, /* (179) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - 394, /* (180) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - 394, /* (181) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - 391, /* (182) multi_create_clause ::= create_subtable_clause */ - 391, /* (183) multi_create_clause ::= multi_create_clause create_subtable_clause */ - 399, /* (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 */ - 393, /* (185) multi_drop_clause ::= drop_table_clause */ - 393, /* (186) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ - 402, /* (187) drop_table_clause ::= exists_opt full_table_name */ - 400, /* (188) specific_cols_opt ::= */ - 400, /* (189) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - 387, /* (190) full_table_name ::= table_name */ - 387, /* (191) full_table_name ::= db_name NK_DOT table_name */ - 388, /* (192) column_def_list ::= column_def */ - 388, /* (193) column_def_list ::= column_def_list NK_COMMA column_def */ - 404, /* (194) column_def ::= column_name type_name */ - 404, /* (195) column_def ::= column_name type_name PRIMARY KEY */ - 397, /* (196) type_name ::= BOOL */ - 397, /* (197) type_name ::= TINYINT */ - 397, /* (198) type_name ::= SMALLINT */ - 397, /* (199) type_name ::= INT */ - 397, /* (200) type_name ::= INTEGER */ - 397, /* (201) type_name ::= BIGINT */ - 397, /* (202) type_name ::= FLOAT */ - 397, /* (203) type_name ::= DOUBLE */ - 397, /* (204) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - 397, /* (205) type_name ::= TIMESTAMP */ - 397, /* (206) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - 397, /* (207) type_name ::= TINYINT UNSIGNED */ - 397, /* (208) type_name ::= SMALLINT UNSIGNED */ - 397, /* (209) type_name ::= INT UNSIGNED */ - 397, /* (210) type_name ::= BIGINT UNSIGNED */ - 397, /* (211) type_name ::= JSON */ - 397, /* (212) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - 397, /* (213) type_name ::= MEDIUMBLOB */ - 397, /* (214) type_name ::= BLOB */ - 397, /* (215) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - 397, /* (216) type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ - 397, /* (217) type_name ::= DECIMAL */ - 397, /* (218) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - 397, /* (219) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 389, /* (220) tags_def_opt ::= */ - 389, /* (221) tags_def_opt ::= tags_def */ - 392, /* (222) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - 390, /* (223) table_options ::= */ - 390, /* (224) table_options ::= table_options COMMENT NK_STRING */ - 390, /* (225) table_options ::= table_options MAX_DELAY duration_list */ - 390, /* (226) table_options ::= table_options WATERMARK duration_list */ - 390, /* (227) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - 390, /* (228) table_options ::= table_options TTL NK_INTEGER */ - 390, /* (229) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - 390, /* (230) table_options ::= table_options DELETE_MARK duration_list */ - 395, /* (231) alter_table_options ::= alter_table_option */ - 395, /* (232) alter_table_options ::= alter_table_options alter_table_option */ - 407, /* (233) alter_table_option ::= COMMENT NK_STRING */ - 407, /* (234) alter_table_option ::= TTL NK_INTEGER */ - 405, /* (235) duration_list ::= duration_literal */ - 405, /* (236) duration_list ::= duration_list NK_COMMA duration_literal */ - 406, /* (237) rollup_func_list ::= rollup_func_name */ - 406, /* (238) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - 409, /* (239) rollup_func_name ::= function_name */ - 409, /* (240) rollup_func_name ::= FIRST */ - 409, /* (241) rollup_func_name ::= LAST */ - 403, /* (242) col_name_list ::= col_name */ - 403, /* (243) col_name_list ::= col_name_list NK_COMMA col_name */ - 411, /* (244) col_name ::= column_name */ - 352, /* (245) cmd ::= SHOW DNODES */ - 352, /* (246) cmd ::= SHOW USERS */ - 352, /* (247) cmd ::= SHOW USER PRIVILEGES */ - 352, /* (248) cmd ::= SHOW db_kind_opt DATABASES */ - 352, /* (249) cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ - 352, /* (250) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - 352, /* (251) cmd ::= SHOW db_name_cond_opt VGROUPS */ - 352, /* (252) cmd ::= SHOW MNODES */ - 352, /* (253) cmd ::= SHOW QNODES */ - 352, /* (254) cmd ::= SHOW FUNCTIONS */ - 352, /* (255) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - 352, /* (256) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ - 352, /* (257) cmd ::= SHOW STREAMS */ - 352, /* (258) cmd ::= SHOW ACCOUNTS */ - 352, /* (259) cmd ::= SHOW APPS */ - 352, /* (260) cmd ::= SHOW CONNECTIONS */ - 352, /* (261) cmd ::= SHOW LICENCES */ - 352, /* (262) cmd ::= SHOW GRANTS */ - 352, /* (263) cmd ::= SHOW GRANTS FULL */ - 352, /* (264) cmd ::= SHOW GRANTS LOGS */ - 352, /* (265) cmd ::= SHOW CLUSTER MACHINES */ - 352, /* (266) cmd ::= SHOW CREATE DATABASE db_name */ - 352, /* (267) cmd ::= SHOW CREATE TABLE full_table_name */ - 352, /* (268) cmd ::= SHOW CREATE STABLE full_table_name */ - 352, /* (269) cmd ::= SHOW QUERIES */ - 352, /* (270) cmd ::= SHOW SCORES */ - 352, /* (271) cmd ::= SHOW TOPICS */ - 352, /* (272) cmd ::= SHOW VARIABLES */ - 352, /* (273) cmd ::= SHOW CLUSTER VARIABLES */ - 352, /* (274) cmd ::= SHOW LOCAL VARIABLES */ - 352, /* (275) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ - 352, /* (276) cmd ::= SHOW BNODES */ - 352, /* (277) cmd ::= SHOW SNODES */ - 352, /* (278) cmd ::= SHOW CLUSTER */ - 352, /* (279) cmd ::= SHOW TRANSACTIONS */ - 352, /* (280) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - 352, /* (281) cmd ::= SHOW CONSUMERS */ - 352, /* (282) cmd ::= SHOW SUBSCRIPTIONS */ - 352, /* (283) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - 352, /* (284) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ - 352, /* (285) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ - 352, /* (286) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ - 352, /* (287) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ - 352, /* (288) cmd ::= SHOW VNODES */ - 352, /* (289) cmd ::= SHOW db_name_cond_opt ALIVE */ - 352, /* (290) cmd ::= SHOW CLUSTER ALIVE */ - 352, /* (291) cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ - 352, /* (292) cmd ::= SHOW CREATE VIEW full_table_name */ - 352, /* (293) cmd ::= SHOW COMPACTS */ - 352, /* (294) cmd ::= SHOW COMPACT NK_INTEGER */ - 413, /* (295) table_kind_db_name_cond_opt ::= */ - 413, /* (296) table_kind_db_name_cond_opt ::= table_kind */ - 413, /* (297) table_kind_db_name_cond_opt ::= db_name NK_DOT */ - 413, /* (298) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ - 419, /* (299) table_kind ::= NORMAL */ - 419, /* (300) table_kind ::= CHILD */ - 415, /* (301) db_name_cond_opt ::= */ - 415, /* (302) db_name_cond_opt ::= db_name NK_DOT */ - 414, /* (303) like_pattern_opt ::= */ - 414, /* (304) like_pattern_opt ::= LIKE NK_STRING */ - 416, /* (305) table_name_cond ::= table_name */ - 417, /* (306) from_db_opt ::= */ - 417, /* (307) from_db_opt ::= FROM db_name */ - 418, /* (308) tag_list_opt ::= */ - 418, /* (309) tag_list_opt ::= tag_item */ - 418, /* (310) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ - 420, /* (311) tag_item ::= TBNAME */ - 420, /* (312) tag_item ::= QTAGS */ - 420, /* (313) tag_item ::= column_name */ - 420, /* (314) tag_item ::= column_name column_alias */ - 420, /* (315) tag_item ::= column_name AS column_alias */ - 412, /* (316) db_kind_opt ::= */ - 412, /* (317) db_kind_opt ::= USER */ - 412, /* (318) db_kind_opt ::= SYSTEM */ - 352, /* (319) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ - 352, /* (320) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ - 352, /* (321) cmd ::= DROP INDEX exists_opt full_index_name */ - 423, /* (322) full_index_name ::= index_name */ - 423, /* (323) full_index_name ::= db_name NK_DOT index_name */ - 422, /* (324) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - 422, /* (325) 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 */ - 425, /* (326) func_list ::= func */ - 425, /* (327) func_list ::= func_list NK_COMMA func */ - 428, /* (328) func ::= sma_func_name NK_LP expression_list NK_RP */ - 429, /* (329) sma_func_name ::= function_name */ - 429, /* (330) sma_func_name ::= COUNT */ - 429, /* (331) sma_func_name ::= FIRST */ - 429, /* (332) sma_func_name ::= LAST */ - 429, /* (333) sma_func_name ::= LAST_ROW */ - 427, /* (334) sma_stream_opt ::= */ - 427, /* (335) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - 427, /* (336) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - 427, /* (337) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - 430, /* (338) with_meta ::= AS */ - 430, /* (339) with_meta ::= WITH META AS */ - 430, /* (340) with_meta ::= ONLY META AS */ - 352, /* (341) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - 352, /* (342) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ - 352, /* (343) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ - 352, /* (344) cmd ::= DROP TOPIC exists_opt topic_name */ - 352, /* (345) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - 352, /* (346) cmd ::= DESC full_table_name */ - 352, /* (347) cmd ::= DESCRIBE full_table_name */ - 352, /* (348) cmd ::= RESET QUERY CACHE */ - 352, /* (349) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - 352, /* (350) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ - 434, /* (351) analyze_opt ::= */ - 434, /* (352) analyze_opt ::= ANALYZE */ - 435, /* (353) explain_options ::= */ - 435, /* (354) explain_options ::= explain_options VERBOSE NK_BOOL */ - 435, /* (355) explain_options ::= explain_options RATIO NK_FLOAT */ - 352, /* (356) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ - 352, /* (357) cmd ::= DROP FUNCTION exists_opt function_name */ - 438, /* (358) agg_func_opt ::= */ - 438, /* (359) agg_func_opt ::= AGGREGATE */ - 439, /* (360) bufsize_opt ::= */ - 439, /* (361) bufsize_opt ::= BUFSIZE NK_INTEGER */ - 440, /* (362) language_opt ::= */ - 440, /* (363) language_opt ::= LANGUAGE NK_STRING */ - 437, /* (364) or_replace_opt ::= */ - 437, /* (365) or_replace_opt ::= OR REPLACE */ - 352, /* (366) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ - 352, /* (367) cmd ::= DROP VIEW exists_opt full_view_name */ - 441, /* (368) full_view_name ::= view_name */ - 441, /* (369) full_view_name ::= db_name NK_DOT view_name */ - 352, /* (370) 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 */ - 352, /* (371) cmd ::= DROP STREAM exists_opt stream_name */ - 352, /* (372) cmd ::= PAUSE STREAM exists_opt stream_name */ - 352, /* (373) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ - 445, /* (374) col_list_opt ::= */ - 445, /* (375) col_list_opt ::= NK_LP column_stream_def_list NK_RP */ - 449, /* (376) column_stream_def_list ::= column_stream_def */ - 449, /* (377) column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ - 450, /* (378) column_stream_def ::= column_name */ - 450, /* (379) column_stream_def ::= column_name PRIMARY KEY */ - 446, /* (380) tag_def_or_ref_opt ::= */ - 446, /* (381) tag_def_or_ref_opt ::= tags_def */ - 446, /* (382) tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ - 444, /* (383) stream_options ::= */ - 444, /* (384) stream_options ::= stream_options TRIGGER AT_ONCE */ - 444, /* (385) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - 444, /* (386) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - 444, /* (387) stream_options ::= stream_options WATERMARK duration_literal */ - 444, /* (388) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - 444, /* (389) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - 444, /* (390) stream_options ::= stream_options DELETE_MARK duration_literal */ - 444, /* (391) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ - 447, /* (392) subtable_opt ::= */ - 447, /* (393) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - 448, /* (394) ignore_opt ::= */ - 448, /* (395) ignore_opt ::= IGNORE UNTREATED */ - 352, /* (396) cmd ::= KILL CONNECTION NK_INTEGER */ - 352, /* (397) cmd ::= KILL QUERY NK_STRING */ - 352, /* (398) cmd ::= KILL TRANSACTION NK_INTEGER */ - 352, /* (399) cmd ::= KILL COMPACT NK_INTEGER */ - 352, /* (400) cmd ::= BALANCE VGROUP */ - 352, /* (401) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ - 352, /* (402) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - 352, /* (403) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - 352, /* (404) cmd ::= SPLIT VGROUP NK_INTEGER */ - 452, /* (405) on_vgroup_id ::= */ - 452, /* (406) on_vgroup_id ::= ON NK_INTEGER */ - 453, /* (407) dnode_list ::= DNODE NK_INTEGER */ - 453, /* (408) dnode_list ::= dnode_list DNODE NK_INTEGER */ - 352, /* (409) cmd ::= DELETE FROM full_table_name where_clause_opt */ - 352, /* (410) cmd ::= query_or_subquery */ - 352, /* (411) cmd ::= insert_query */ - 436, /* (412) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - 436, /* (413) insert_query ::= INSERT INTO full_table_name query_or_subquery */ - 355, /* (414) literal ::= NK_INTEGER */ - 355, /* (415) literal ::= NK_FLOAT */ - 355, /* (416) literal ::= NK_STRING */ - 355, /* (417) literal ::= NK_BOOL */ - 355, /* (418) literal ::= TIMESTAMP NK_STRING */ - 355, /* (419) literal ::= duration_literal */ - 355, /* (420) literal ::= NULL */ - 355, /* (421) literal ::= NK_QUESTION */ - 408, /* (422) duration_literal ::= NK_VARIABLE */ - 384, /* (423) signed ::= NK_INTEGER */ - 384, /* (424) signed ::= NK_PLUS NK_INTEGER */ - 384, /* (425) signed ::= NK_MINUS NK_INTEGER */ - 384, /* (426) signed ::= NK_FLOAT */ - 384, /* (427) signed ::= NK_PLUS NK_FLOAT */ - 384, /* (428) signed ::= NK_MINUS NK_FLOAT */ - 398, /* (429) signed_literal ::= signed */ - 398, /* (430) signed_literal ::= NK_STRING */ - 398, /* (431) signed_literal ::= NK_BOOL */ - 398, /* (432) signed_literal ::= TIMESTAMP NK_STRING */ - 398, /* (433) signed_literal ::= duration_literal */ - 398, /* (434) signed_literal ::= NULL */ - 398, /* (435) signed_literal ::= literal_func */ - 398, /* (436) signed_literal ::= NK_QUESTION */ - 455, /* (437) literal_list ::= signed_literal */ - 455, /* (438) literal_list ::= literal_list NK_COMMA signed_literal */ - 367, /* (439) db_name ::= NK_ID */ - 368, /* (440) table_name ::= NK_ID */ - 396, /* (441) column_name ::= NK_ID */ - 410, /* (442) function_name ::= NK_ID */ - 442, /* (443) view_name ::= NK_ID */ - 456, /* (444) table_alias ::= NK_ID */ - 421, /* (445) column_alias ::= NK_ID */ - 421, /* (446) column_alias ::= NK_ALIAS */ - 360, /* (447) user_name ::= NK_ID */ - 369, /* (448) topic_name ::= NK_ID */ - 443, /* (449) stream_name ::= NK_ID */ - 433, /* (450) cgroup_name ::= NK_ID */ - 424, /* (451) index_name ::= NK_ID */ - 457, /* (452) expr_or_subquery ::= expression */ - 451, /* (453) expression ::= literal */ - 451, /* (454) expression ::= pseudo_column */ - 451, /* (455) expression ::= column_reference */ - 451, /* (456) expression ::= function_expression */ - 451, /* (457) expression ::= case_when_expression */ - 451, /* (458) expression ::= NK_LP expression NK_RP */ - 451, /* (459) expression ::= NK_PLUS expr_or_subquery */ - 451, /* (460) expression ::= NK_MINUS expr_or_subquery */ - 451, /* (461) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - 451, /* (462) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - 451, /* (463) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - 451, /* (464) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - 451, /* (465) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - 451, /* (466) expression ::= column_reference NK_ARROW NK_STRING */ - 451, /* (467) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - 451, /* (468) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - 401, /* (469) expression_list ::= expr_or_subquery */ - 401, /* (470) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - 459, /* (471) column_reference ::= column_name */ - 459, /* (472) column_reference ::= table_name NK_DOT column_name */ - 459, /* (473) column_reference ::= NK_ALIAS */ - 459, /* (474) column_reference ::= table_name NK_DOT NK_ALIAS */ - 458, /* (475) pseudo_column ::= ROWTS */ - 458, /* (476) pseudo_column ::= TBNAME */ - 458, /* (477) pseudo_column ::= table_name NK_DOT TBNAME */ - 458, /* (478) pseudo_column ::= QSTART */ - 458, /* (479) pseudo_column ::= QEND */ - 458, /* (480) pseudo_column ::= QDURATION */ - 458, /* (481) pseudo_column ::= WSTART */ - 458, /* (482) pseudo_column ::= WEND */ - 458, /* (483) pseudo_column ::= WDURATION */ - 458, /* (484) pseudo_column ::= IROWTS */ - 458, /* (485) pseudo_column ::= ISFILLED */ - 458, /* (486) pseudo_column ::= QTAGS */ - 460, /* (487) function_expression ::= function_name NK_LP expression_list NK_RP */ - 460, /* (488) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - 460, /* (489) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - 460, /* (490) function_expression ::= literal_func */ - 454, /* (491) literal_func ::= noarg_func NK_LP NK_RP */ - 454, /* (492) literal_func ::= NOW */ - 464, /* (493) noarg_func ::= NOW */ - 464, /* (494) noarg_func ::= TODAY */ - 464, /* (495) noarg_func ::= TIMEZONE */ - 464, /* (496) noarg_func ::= DATABASE */ - 464, /* (497) noarg_func ::= CLIENT_VERSION */ - 464, /* (498) noarg_func ::= SERVER_VERSION */ - 464, /* (499) noarg_func ::= SERVER_STATUS */ - 464, /* (500) noarg_func ::= CURRENT_USER */ - 464, /* (501) noarg_func ::= USER */ - 462, /* (502) star_func ::= COUNT */ - 462, /* (503) star_func ::= FIRST */ - 462, /* (504) star_func ::= LAST */ - 462, /* (505) star_func ::= LAST_ROW */ - 463, /* (506) star_func_para_list ::= NK_STAR */ - 463, /* (507) star_func_para_list ::= other_para_list */ - 465, /* (508) other_para_list ::= star_func_para */ - 465, /* (509) other_para_list ::= other_para_list NK_COMMA star_func_para */ - 466, /* (510) star_func_para ::= expr_or_subquery */ - 466, /* (511) star_func_para ::= table_name NK_DOT NK_STAR */ - 461, /* (512) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - 461, /* (513) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - 467, /* (514) when_then_list ::= when_then_expr */ - 467, /* (515) when_then_list ::= when_then_list when_then_expr */ - 470, /* (516) when_then_expr ::= WHEN common_expression THEN common_expression */ - 468, /* (517) case_when_else_opt ::= */ - 468, /* (518) case_when_else_opt ::= ELSE common_expression */ - 471, /* (519) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - 471, /* (520) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - 471, /* (521) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - 471, /* (522) predicate ::= expr_or_subquery IS NULL */ - 471, /* (523) predicate ::= expr_or_subquery IS NOT NULL */ - 471, /* (524) predicate ::= expr_or_subquery in_op in_predicate_value */ - 472, /* (525) compare_op ::= NK_LT */ - 472, /* (526) compare_op ::= NK_GT */ - 472, /* (527) compare_op ::= NK_LE */ - 472, /* (528) compare_op ::= NK_GE */ - 472, /* (529) compare_op ::= NK_NE */ - 472, /* (530) compare_op ::= NK_EQ */ - 472, /* (531) compare_op ::= LIKE */ - 472, /* (532) compare_op ::= NOT LIKE */ - 472, /* (533) compare_op ::= MATCH */ - 472, /* (534) compare_op ::= NMATCH */ - 472, /* (535) compare_op ::= CONTAINS */ - 473, /* (536) in_op ::= IN */ - 473, /* (537) in_op ::= NOT IN */ - 474, /* (538) in_predicate_value ::= NK_LP literal_list NK_RP */ - 475, /* (539) boolean_value_expression ::= boolean_primary */ - 475, /* (540) boolean_value_expression ::= NOT boolean_primary */ - 475, /* (541) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - 475, /* (542) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - 476, /* (543) boolean_primary ::= predicate */ - 476, /* (544) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - 469, /* (545) common_expression ::= expr_or_subquery */ - 469, /* (546) common_expression ::= boolean_value_expression */ - 477, /* (547) from_clause_opt ::= */ - 477, /* (548) from_clause_opt ::= FROM table_reference_list */ - 478, /* (549) table_reference_list ::= table_reference */ - 478, /* (550) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - 479, /* (551) table_reference ::= table_primary */ - 479, /* (552) table_reference ::= joined_table */ - 480, /* (553) table_primary ::= table_name alias_opt */ - 480, /* (554) table_primary ::= db_name NK_DOT table_name alias_opt */ - 480, /* (555) table_primary ::= subquery alias_opt */ - 480, /* (556) table_primary ::= parenthesized_joined_table */ - 482, /* (557) alias_opt ::= */ - 482, /* (558) alias_opt ::= table_alias */ - 482, /* (559) alias_opt ::= AS table_alias */ - 484, /* (560) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - 484, /* (561) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - 481, /* (562) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - 485, /* (563) join_type ::= */ - 485, /* (564) join_type ::= INNER */ - 486, /* (565) 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 */ - 487, /* (566) hint_list ::= */ - 487, /* (567) hint_list ::= NK_HINT */ - 489, /* (568) tag_mode_opt ::= */ - 489, /* (569) tag_mode_opt ::= TAGS */ - 488, /* (570) set_quantifier_opt ::= */ - 488, /* (571) set_quantifier_opt ::= DISTINCT */ - 488, /* (572) set_quantifier_opt ::= ALL */ - 490, /* (573) select_list ::= select_item */ - 490, /* (574) select_list ::= select_list NK_COMMA select_item */ - 498, /* (575) select_item ::= NK_STAR */ - 498, /* (576) select_item ::= common_expression */ - 498, /* (577) select_item ::= common_expression column_alias */ - 498, /* (578) select_item ::= common_expression AS column_alias */ - 498, /* (579) select_item ::= table_name NK_DOT NK_STAR */ - 432, /* (580) where_clause_opt ::= */ - 432, /* (581) where_clause_opt ::= WHERE search_condition */ - 491, /* (582) partition_by_clause_opt ::= */ - 491, /* (583) partition_by_clause_opt ::= PARTITION BY partition_list */ - 499, /* (584) partition_list ::= partition_item */ - 499, /* (585) partition_list ::= partition_list NK_COMMA partition_item */ - 500, /* (586) partition_item ::= expr_or_subquery */ - 500, /* (587) partition_item ::= expr_or_subquery column_alias */ - 500, /* (588) partition_item ::= expr_or_subquery AS column_alias */ - 495, /* (589) twindow_clause_opt ::= */ - 495, /* (590) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ - 495, /* (591) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - 495, /* (592) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - 495, /* (593) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - 495, /* (594) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ - 495, /* (595) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ - 495, /* (596) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 426, /* (597) sliding_opt ::= */ - 426, /* (598) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ - 501, /* (599) interval_sliding_duration_literal ::= NK_VARIABLE */ - 501, /* (600) interval_sliding_duration_literal ::= NK_STRING */ - 501, /* (601) interval_sliding_duration_literal ::= NK_INTEGER */ - 494, /* (602) fill_opt ::= */ - 494, /* (603) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - 494, /* (604) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ - 494, /* (605) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ - 502, /* (606) fill_mode ::= NONE */ - 502, /* (607) fill_mode ::= PREV */ - 502, /* (608) fill_mode ::= NULL */ - 502, /* (609) fill_mode ::= NULL_F */ - 502, /* (610) fill_mode ::= LINEAR */ - 502, /* (611) fill_mode ::= NEXT */ - 496, /* (612) group_by_clause_opt ::= */ - 496, /* (613) group_by_clause_opt ::= GROUP BY group_by_list */ - 503, /* (614) group_by_list ::= expr_or_subquery */ - 503, /* (615) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - 497, /* (616) having_clause_opt ::= */ - 497, /* (617) having_clause_opt ::= HAVING search_condition */ - 492, /* (618) range_opt ::= */ - 492, /* (619) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - 492, /* (620) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ - 493, /* (621) every_opt ::= */ - 493, /* (622) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - 504, /* (623) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - 505, /* (624) query_simple ::= query_specification */ - 505, /* (625) query_simple ::= union_query_expression */ - 509, /* (626) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - 509, /* (627) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - 510, /* (628) query_simple_or_subquery ::= query_simple */ - 510, /* (629) query_simple_or_subquery ::= subquery */ - 431, /* (630) query_or_subquery ::= query_expression */ - 431, /* (631) query_or_subquery ::= subquery */ - 506, /* (632) order_by_clause_opt ::= */ - 506, /* (633) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 507, /* (634) slimit_clause_opt ::= */ - 507, /* (635) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - 507, /* (636) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - 507, /* (637) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 508, /* (638) limit_clause_opt ::= */ - 508, /* (639) limit_clause_opt ::= LIMIT NK_INTEGER */ - 508, /* (640) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - 508, /* (641) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 483, /* (642) subquery ::= NK_LP query_expression NK_RP */ - 483, /* (643) subquery ::= NK_LP subquery NK_RP */ - 370, /* (644) search_condition ::= common_expression */ - 511, /* (645) sort_specification_list ::= sort_specification */ - 511, /* (646) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - 512, /* (647) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - 513, /* (648) ordering_specification_opt ::= */ - 513, /* (649) ordering_specification_opt ::= ASC */ - 513, /* (650) ordering_specification_opt ::= DESC */ - 514, /* (651) null_ordering_opt ::= */ - 514, /* (652) null_ordering_opt ::= NULLS FIRST */ - 514, /* (653) null_ordering_opt ::= NULLS LAST */ + 355, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + 355, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + 356, /* (2) account_options ::= */ + 356, /* (3) account_options ::= account_options PPS literal */ + 356, /* (4) account_options ::= account_options TSERIES literal */ + 356, /* (5) account_options ::= account_options STORAGE literal */ + 356, /* (6) account_options ::= account_options STREAMS literal */ + 356, /* (7) account_options ::= account_options QTIME literal */ + 356, /* (8) account_options ::= account_options DBS literal */ + 356, /* (9) account_options ::= account_options USERS literal */ + 356, /* (10) account_options ::= account_options CONNS literal */ + 356, /* (11) account_options ::= account_options STATE literal */ + 357, /* (12) alter_account_options ::= alter_account_option */ + 357, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + 359, /* (14) alter_account_option ::= PASS literal */ + 359, /* (15) alter_account_option ::= PPS literal */ + 359, /* (16) alter_account_option ::= TSERIES literal */ + 359, /* (17) alter_account_option ::= STORAGE literal */ + 359, /* (18) alter_account_option ::= STREAMS literal */ + 359, /* (19) alter_account_option ::= QTIME literal */ + 359, /* (20) alter_account_option ::= DBS literal */ + 359, /* (21) alter_account_option ::= USERS literal */ + 359, /* (22) alter_account_option ::= CONNS literal */ + 359, /* (23) alter_account_option ::= STATE literal */ + 360, /* (24) ip_range_list ::= NK_STRING */ + 360, /* (25) ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ + 361, /* (26) white_list ::= HOST ip_range_list */ + 362, /* (27) white_list_opt ::= */ + 362, /* (28) white_list_opt ::= white_list */ + 355, /* (29) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ + 355, /* (30) cmd ::= ALTER USER user_name PASS NK_STRING */ + 355, /* (31) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + 355, /* (32) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + 355, /* (33) cmd ::= ALTER USER user_name ADD white_list */ + 355, /* (34) cmd ::= ALTER USER user_name DROP white_list */ + 355, /* (35) cmd ::= DROP USER user_name */ + 364, /* (36) sysinfo_opt ::= */ + 364, /* (37) sysinfo_opt ::= SYSINFO NK_INTEGER */ + 355, /* (38) cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ + 355, /* (39) cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ + 365, /* (40) privileges ::= ALL */ + 365, /* (41) privileges ::= priv_type_list */ + 365, /* (42) privileges ::= SUBSCRIBE */ + 368, /* (43) priv_type_list ::= priv_type */ + 368, /* (44) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + 369, /* (45) priv_type ::= READ */ + 369, /* (46) priv_type ::= WRITE */ + 369, /* (47) priv_type ::= ALTER */ + 366, /* (48) priv_level ::= NK_STAR NK_DOT NK_STAR */ + 366, /* (49) priv_level ::= db_name NK_DOT NK_STAR */ + 366, /* (50) priv_level ::= db_name NK_DOT table_name */ + 366, /* (51) priv_level ::= topic_name */ + 367, /* (52) with_opt ::= */ + 367, /* (53) with_opt ::= WITH search_condition */ + 355, /* (54) cmd ::= CREATE DNODE dnode_endpoint */ + 355, /* (55) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + 355, /* (56) cmd ::= DROP DNODE NK_INTEGER force_opt */ + 355, /* (57) cmd ::= DROP DNODE dnode_endpoint force_opt */ + 355, /* (58) cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ + 355, /* (59) cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ + 355, /* (60) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + 355, /* (61) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + 355, /* (62) cmd ::= ALTER ALL DNODES NK_STRING */ + 355, /* (63) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + 355, /* (64) cmd ::= RESTORE DNODE NK_INTEGER */ + 374, /* (65) dnode_endpoint ::= NK_STRING */ + 374, /* (66) dnode_endpoint ::= NK_ID */ + 374, /* (67) dnode_endpoint ::= NK_IPTOKEN */ + 375, /* (68) force_opt ::= */ + 375, /* (69) force_opt ::= FORCE */ + 376, /* (70) unsafe_opt ::= UNSAFE */ + 355, /* (71) cmd ::= ALTER CLUSTER NK_STRING */ + 355, /* (72) cmd ::= ALTER CLUSTER NK_STRING NK_STRING */ + 355, /* (73) cmd ::= ALTER LOCAL NK_STRING */ + 355, /* (74) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + 355, /* (75) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + 355, /* (76) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + 355, /* (77) cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ + 355, /* (78) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + 355, /* (79) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + 355, /* (80) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + 355, /* (81) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + 355, /* (82) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + 355, /* (83) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + 355, /* (84) cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ + 355, /* (85) cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ + 355, /* (86) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + 355, /* (87) cmd ::= DROP DATABASE exists_opt db_name */ + 355, /* (88) cmd ::= USE db_name */ + 355, /* (89) cmd ::= ALTER DATABASE db_name alter_db_options */ + 355, /* (90) cmd ::= FLUSH DATABASE db_name */ + 355, /* (91) cmd ::= TRIM DATABASE db_name speed_opt */ + 355, /* (92) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ + 377, /* (93) not_exists_opt ::= IF NOT EXISTS */ + 377, /* (94) not_exists_opt ::= */ + 379, /* (95) exists_opt ::= IF EXISTS */ + 379, /* (96) exists_opt ::= */ + 378, /* (97) db_options ::= */ + 378, /* (98) db_options ::= db_options BUFFER NK_INTEGER */ + 378, /* (99) db_options ::= db_options CACHEMODEL NK_STRING */ + 378, /* (100) db_options ::= db_options CACHESIZE NK_INTEGER */ + 378, /* (101) db_options ::= db_options COMP NK_INTEGER */ + 378, /* (102) db_options ::= db_options DURATION NK_INTEGER */ + 378, /* (103) db_options ::= db_options DURATION NK_VARIABLE */ + 378, /* (104) db_options ::= db_options MAXROWS NK_INTEGER */ + 378, /* (105) db_options ::= db_options MINROWS NK_INTEGER */ + 378, /* (106) db_options ::= db_options KEEP integer_list */ + 378, /* (107) db_options ::= db_options KEEP variable_list */ + 378, /* (108) db_options ::= db_options PAGES NK_INTEGER */ + 378, /* (109) db_options ::= db_options PAGESIZE NK_INTEGER */ + 378, /* (110) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ + 378, /* (111) db_options ::= db_options PRECISION NK_STRING */ + 378, /* (112) db_options ::= db_options REPLICA NK_INTEGER */ + 378, /* (113) db_options ::= db_options VGROUPS NK_INTEGER */ + 378, /* (114) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + 378, /* (115) db_options ::= db_options RETENTIONS retention_list */ + 378, /* (116) db_options ::= db_options SCHEMALESS NK_INTEGER */ + 378, /* (117) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + 378, /* (118) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + 378, /* (119) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + 378, /* (120) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + 378, /* (121) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + 378, /* (122) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + 378, /* (123) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + 378, /* (124) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + 378, /* (125) db_options ::= db_options STT_TRIGGER NK_INTEGER */ + 378, /* (126) db_options ::= db_options TABLE_PREFIX signed */ + 378, /* (127) db_options ::= db_options TABLE_SUFFIX signed */ + 378, /* (128) db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ + 380, /* (129) alter_db_options ::= alter_db_option */ + 380, /* (130) alter_db_options ::= alter_db_options alter_db_option */ + 388, /* (131) alter_db_option ::= BUFFER NK_INTEGER */ + 388, /* (132) alter_db_option ::= CACHEMODEL NK_STRING */ + 388, /* (133) alter_db_option ::= CACHESIZE NK_INTEGER */ + 388, /* (134) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + 388, /* (135) alter_db_option ::= KEEP integer_list */ + 388, /* (136) alter_db_option ::= KEEP variable_list */ + 388, /* (137) alter_db_option ::= PAGES NK_INTEGER */ + 388, /* (138) alter_db_option ::= REPLICA NK_INTEGER */ + 388, /* (139) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + 388, /* (140) alter_db_option ::= STT_TRIGGER NK_INTEGER */ + 388, /* (141) alter_db_option ::= MINROWS NK_INTEGER */ + 388, /* (142) alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ + 388, /* (143) alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + 388, /* (144) alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ + 388, /* (145) alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + 388, /* (146) alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ + 384, /* (147) integer_list ::= NK_INTEGER */ + 384, /* (148) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + 385, /* (149) variable_list ::= NK_VARIABLE */ + 385, /* (150) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + 386, /* (151) retention_list ::= retention */ + 386, /* (152) retention_list ::= retention_list NK_COMMA retention */ + 389, /* (153) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + 389, /* (154) retention ::= NK_MINUS NK_COLON NK_VARIABLE */ + 381, /* (155) speed_opt ::= */ + 381, /* (156) speed_opt ::= BWLIMIT NK_INTEGER */ + 382, /* (157) start_opt ::= */ + 382, /* (158) start_opt ::= START WITH NK_INTEGER */ + 382, /* (159) start_opt ::= START WITH NK_STRING */ + 382, /* (160) start_opt ::= START WITH TIMESTAMP NK_STRING */ + 383, /* (161) end_opt ::= */ + 383, /* (162) end_opt ::= END WITH NK_INTEGER */ + 383, /* (163) end_opt ::= END WITH NK_STRING */ + 383, /* (164) end_opt ::= END WITH TIMESTAMP NK_STRING */ + 355, /* (165) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + 355, /* (166) cmd ::= CREATE TABLE multi_create_clause */ + 355, /* (167) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + 355, /* (168) cmd ::= DROP TABLE multi_drop_clause */ + 355, /* (169) cmd ::= DROP STABLE exists_opt full_table_name */ + 355, /* (170) cmd ::= ALTER TABLE alter_table_clause */ + 355, /* (171) cmd ::= ALTER STABLE alter_table_clause */ + 397, /* (172) alter_table_clause ::= full_table_name alter_table_options */ + 397, /* (173) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + 397, /* (174) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + 397, /* (175) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + 397, /* (176) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + 397, /* (177) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + 397, /* (178) alter_table_clause ::= full_table_name DROP TAG column_name */ + 397, /* (179) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + 397, /* (180) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + 397, /* (181) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal */ + 394, /* (182) multi_create_clause ::= create_subtable_clause */ + 394, /* (183) multi_create_clause ::= multi_create_clause create_subtable_clause */ + 402, /* (184) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP tags_literal_list NK_RP table_options */ + 396, /* (185) multi_drop_clause ::= drop_table_clause */ + 396, /* (186) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ + 405, /* (187) drop_table_clause ::= exists_opt full_table_name */ + 403, /* (188) specific_cols_opt ::= */ + 403, /* (189) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + 390, /* (190) full_table_name ::= table_name */ + 390, /* (191) full_table_name ::= db_name NK_DOT table_name */ + 391, /* (192) column_def_list ::= column_def */ + 391, /* (193) column_def_list ::= column_def_list NK_COMMA column_def */ + 407, /* (194) column_def ::= column_name type_name */ + 407, /* (195) column_def ::= column_name type_name PRIMARY KEY */ + 400, /* (196) type_name ::= BOOL */ + 400, /* (197) type_name ::= TINYINT */ + 400, /* (198) type_name ::= SMALLINT */ + 400, /* (199) type_name ::= INT */ + 400, /* (200) type_name ::= INTEGER */ + 400, /* (201) type_name ::= BIGINT */ + 400, /* (202) type_name ::= FLOAT */ + 400, /* (203) type_name ::= DOUBLE */ + 400, /* (204) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + 400, /* (205) type_name ::= TIMESTAMP */ + 400, /* (206) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + 400, /* (207) type_name ::= TINYINT UNSIGNED */ + 400, /* (208) type_name ::= SMALLINT UNSIGNED */ + 400, /* (209) type_name ::= INT UNSIGNED */ + 400, /* (210) type_name ::= BIGINT UNSIGNED */ + 400, /* (211) type_name ::= JSON */ + 400, /* (212) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + 400, /* (213) type_name ::= MEDIUMBLOB */ + 400, /* (214) type_name ::= BLOB */ + 400, /* (215) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + 400, /* (216) type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ + 400, /* (217) type_name ::= DECIMAL */ + 400, /* (218) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + 400, /* (219) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 392, /* (220) tags_def_opt ::= */ + 392, /* (221) tags_def_opt ::= tags_def */ + 395, /* (222) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + 393, /* (223) table_options ::= */ + 393, /* (224) table_options ::= table_options COMMENT NK_STRING */ + 393, /* (225) table_options ::= table_options MAX_DELAY duration_list */ + 393, /* (226) table_options ::= table_options WATERMARK duration_list */ + 393, /* (227) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + 393, /* (228) table_options ::= table_options TTL NK_INTEGER */ + 393, /* (229) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + 393, /* (230) table_options ::= table_options DELETE_MARK duration_list */ + 398, /* (231) alter_table_options ::= alter_table_option */ + 398, /* (232) alter_table_options ::= alter_table_options alter_table_option */ + 410, /* (233) alter_table_option ::= COMMENT NK_STRING */ + 410, /* (234) alter_table_option ::= TTL NK_INTEGER */ + 408, /* (235) duration_list ::= duration_literal */ + 408, /* (236) duration_list ::= duration_list NK_COMMA duration_literal */ + 409, /* (237) rollup_func_list ::= rollup_func_name */ + 409, /* (238) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + 412, /* (239) rollup_func_name ::= function_name */ + 412, /* (240) rollup_func_name ::= FIRST */ + 412, /* (241) rollup_func_name ::= LAST */ + 406, /* (242) col_name_list ::= col_name */ + 406, /* (243) col_name_list ::= col_name_list NK_COMMA col_name */ + 414, /* (244) col_name ::= column_name */ + 355, /* (245) cmd ::= SHOW DNODES */ + 355, /* (246) cmd ::= SHOW USERS */ + 355, /* (247) cmd ::= SHOW USER PRIVILEGES */ + 355, /* (248) cmd ::= SHOW db_kind_opt DATABASES */ + 355, /* (249) cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ + 355, /* (250) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + 355, /* (251) cmd ::= SHOW db_name_cond_opt VGROUPS */ + 355, /* (252) cmd ::= SHOW MNODES */ + 355, /* (253) cmd ::= SHOW QNODES */ + 355, /* (254) cmd ::= SHOW ARBGROUPS */ + 355, /* (255) cmd ::= SHOW FUNCTIONS */ + 355, /* (256) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + 355, /* (257) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ + 355, /* (258) cmd ::= SHOW STREAMS */ + 355, /* (259) cmd ::= SHOW ACCOUNTS */ + 355, /* (260) cmd ::= SHOW APPS */ + 355, /* (261) cmd ::= SHOW CONNECTIONS */ + 355, /* (262) cmd ::= SHOW LICENCES */ + 355, /* (263) cmd ::= SHOW GRANTS */ + 355, /* (264) cmd ::= SHOW GRANTS FULL */ + 355, /* (265) cmd ::= SHOW GRANTS LOGS */ + 355, /* (266) cmd ::= SHOW CLUSTER MACHINES */ + 355, /* (267) cmd ::= SHOW CREATE DATABASE db_name */ + 355, /* (268) cmd ::= SHOW CREATE TABLE full_table_name */ + 355, /* (269) cmd ::= SHOW CREATE STABLE full_table_name */ + 355, /* (270) cmd ::= SHOW QUERIES */ + 355, /* (271) cmd ::= SHOW SCORES */ + 355, /* (272) cmd ::= SHOW TOPICS */ + 355, /* (273) cmd ::= SHOW VARIABLES */ + 355, /* (274) cmd ::= SHOW CLUSTER VARIABLES */ + 355, /* (275) cmd ::= SHOW LOCAL VARIABLES */ + 355, /* (276) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ + 355, /* (277) cmd ::= SHOW BNODES */ + 355, /* (278) cmd ::= SHOW SNODES */ + 355, /* (279) cmd ::= SHOW CLUSTER */ + 355, /* (280) cmd ::= SHOW TRANSACTIONS */ + 355, /* (281) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + 355, /* (282) cmd ::= SHOW CONSUMERS */ + 355, /* (283) cmd ::= SHOW SUBSCRIPTIONS */ + 355, /* (284) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + 355, /* (285) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ + 355, /* (286) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ + 355, /* (287) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ + 355, /* (288) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ + 355, /* (289) cmd ::= SHOW VNODES */ + 355, /* (290) cmd ::= SHOW db_name_cond_opt ALIVE */ + 355, /* (291) cmd ::= SHOW CLUSTER ALIVE */ + 355, /* (292) cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ + 355, /* (293) cmd ::= SHOW CREATE VIEW full_table_name */ + 355, /* (294) cmd ::= SHOW COMPACTS */ + 355, /* (295) cmd ::= SHOW COMPACT NK_INTEGER */ + 416, /* (296) table_kind_db_name_cond_opt ::= */ + 416, /* (297) table_kind_db_name_cond_opt ::= table_kind */ + 416, /* (298) table_kind_db_name_cond_opt ::= db_name NK_DOT */ + 416, /* (299) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ + 422, /* (300) table_kind ::= NORMAL */ + 422, /* (301) table_kind ::= CHILD */ + 418, /* (302) db_name_cond_opt ::= */ + 418, /* (303) db_name_cond_opt ::= db_name NK_DOT */ + 417, /* (304) like_pattern_opt ::= */ + 417, /* (305) like_pattern_opt ::= LIKE NK_STRING */ + 419, /* (306) table_name_cond ::= table_name */ + 420, /* (307) from_db_opt ::= */ + 420, /* (308) from_db_opt ::= FROM db_name */ + 421, /* (309) tag_list_opt ::= */ + 421, /* (310) tag_list_opt ::= tag_item */ + 421, /* (311) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ + 423, /* (312) tag_item ::= TBNAME */ + 423, /* (313) tag_item ::= QTAGS */ + 423, /* (314) tag_item ::= column_name */ + 423, /* (315) tag_item ::= column_name column_alias */ + 423, /* (316) tag_item ::= column_name AS column_alias */ + 415, /* (317) db_kind_opt ::= */ + 415, /* (318) db_kind_opt ::= USER */ + 415, /* (319) db_kind_opt ::= SYSTEM */ + 355, /* (320) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ + 355, /* (321) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ + 355, /* (322) cmd ::= DROP INDEX exists_opt full_index_name */ + 426, /* (323) full_index_name ::= index_name */ + 426, /* (324) full_index_name ::= db_name NK_DOT index_name */ + 425, /* (325) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + 425, /* (326) 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 */ + 428, /* (327) func_list ::= func */ + 428, /* (328) func_list ::= func_list NK_COMMA func */ + 431, /* (329) func ::= sma_func_name NK_LP expression_list NK_RP */ + 432, /* (330) sma_func_name ::= function_name */ + 432, /* (331) sma_func_name ::= COUNT */ + 432, /* (332) sma_func_name ::= FIRST */ + 432, /* (333) sma_func_name ::= LAST */ + 432, /* (334) sma_func_name ::= LAST_ROW */ + 430, /* (335) sma_stream_opt ::= */ + 430, /* (336) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + 430, /* (337) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + 430, /* (338) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + 434, /* (339) with_meta ::= AS */ + 434, /* (340) with_meta ::= WITH META AS */ + 434, /* (341) with_meta ::= ONLY META AS */ + 355, /* (342) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + 355, /* (343) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ + 355, /* (344) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ + 355, /* (345) cmd ::= DROP TOPIC exists_opt topic_name */ + 355, /* (346) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + 355, /* (347) cmd ::= DESC full_table_name */ + 355, /* (348) cmd ::= DESCRIBE full_table_name */ + 355, /* (349) cmd ::= RESET QUERY CACHE */ + 355, /* (350) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + 355, /* (351) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ + 438, /* (352) analyze_opt ::= */ + 438, /* (353) analyze_opt ::= ANALYZE */ + 439, /* (354) explain_options ::= */ + 439, /* (355) explain_options ::= explain_options VERBOSE NK_BOOL */ + 439, /* (356) explain_options ::= explain_options RATIO NK_FLOAT */ + 355, /* (357) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ + 355, /* (358) cmd ::= DROP FUNCTION exists_opt function_name */ + 442, /* (359) agg_func_opt ::= */ + 442, /* (360) agg_func_opt ::= AGGREGATE */ + 443, /* (361) bufsize_opt ::= */ + 443, /* (362) bufsize_opt ::= BUFSIZE NK_INTEGER */ + 444, /* (363) language_opt ::= */ + 444, /* (364) language_opt ::= LANGUAGE NK_STRING */ + 441, /* (365) or_replace_opt ::= */ + 441, /* (366) or_replace_opt ::= OR REPLACE */ + 355, /* (367) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ + 355, /* (368) cmd ::= DROP VIEW exists_opt full_view_name */ + 445, /* (369) full_view_name ::= view_name */ + 445, /* (370) full_view_name ::= db_name NK_DOT view_name */ + 355, /* (371) 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 */ + 355, /* (372) cmd ::= DROP STREAM exists_opt stream_name */ + 355, /* (373) cmd ::= PAUSE STREAM exists_opt stream_name */ + 355, /* (374) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ + 449, /* (375) col_list_opt ::= */ + 449, /* (376) col_list_opt ::= NK_LP column_stream_def_list NK_RP */ + 453, /* (377) column_stream_def_list ::= column_stream_def */ + 453, /* (378) column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ + 454, /* (379) column_stream_def ::= column_name */ + 454, /* (380) column_stream_def ::= column_name PRIMARY KEY */ + 450, /* (381) tag_def_or_ref_opt ::= */ + 450, /* (382) tag_def_or_ref_opt ::= tags_def */ + 450, /* (383) tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ + 448, /* (384) stream_options ::= */ + 448, /* (385) stream_options ::= stream_options TRIGGER AT_ONCE */ + 448, /* (386) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + 448, /* (387) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + 448, /* (388) stream_options ::= stream_options WATERMARK duration_literal */ + 448, /* (389) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + 448, /* (390) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + 448, /* (391) stream_options ::= stream_options DELETE_MARK duration_literal */ + 448, /* (392) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + 451, /* (393) subtable_opt ::= */ + 451, /* (394) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + 452, /* (395) ignore_opt ::= */ + 452, /* (396) ignore_opt ::= IGNORE UNTREATED */ + 355, /* (397) cmd ::= KILL CONNECTION NK_INTEGER */ + 355, /* (398) cmd ::= KILL QUERY NK_STRING */ + 355, /* (399) cmd ::= KILL TRANSACTION NK_INTEGER */ + 355, /* (400) cmd ::= KILL COMPACT NK_INTEGER */ + 355, /* (401) cmd ::= BALANCE VGROUP */ + 355, /* (402) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ + 355, /* (403) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + 355, /* (404) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + 355, /* (405) cmd ::= SPLIT VGROUP NK_INTEGER */ + 456, /* (406) on_vgroup_id ::= */ + 456, /* (407) on_vgroup_id ::= ON NK_INTEGER */ + 457, /* (408) dnode_list ::= DNODE NK_INTEGER */ + 457, /* (409) dnode_list ::= dnode_list DNODE NK_INTEGER */ + 355, /* (410) cmd ::= DELETE FROM full_table_name where_clause_opt */ + 355, /* (411) cmd ::= query_or_subquery */ + 355, /* (412) cmd ::= insert_query */ + 440, /* (413) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + 440, /* (414) insert_query ::= INSERT INTO full_table_name query_or_subquery */ + 401, /* (415) tags_literal ::= NK_INTEGER */ + 401, /* (416) tags_literal ::= NK_PLUS NK_INTEGER */ + 401, /* (417) tags_literal ::= NK_MINUS NK_INTEGER */ + 401, /* (418) tags_literal ::= NK_FLOAT */ + 401, /* (419) tags_literal ::= NK_PLUS NK_FLOAT */ + 401, /* (420) tags_literal ::= NK_MINUS NK_FLOAT */ + 401, /* (421) tags_literal ::= NK_BIN */ + 401, /* (422) tags_literal ::= NK_PLUS NK_BIN */ + 401, /* (423) tags_literal ::= NK_MINUS NK_BIN */ + 401, /* (424) tags_literal ::= NK_HEX */ + 401, /* (425) tags_literal ::= NK_PLUS NK_HEX */ + 401, /* (426) tags_literal ::= NK_MINUS NK_HEX */ + 401, /* (427) tags_literal ::= NK_STRING */ + 401, /* (428) tags_literal ::= NK_BOOL */ + 401, /* (429) tags_literal ::= NULL */ + 401, /* (430) tags_literal ::= literal_func */ + 401, /* (431) tags_literal ::= literal_func NK_PLUS duration_literal */ + 401, /* (432) tags_literal ::= literal_func NK_MINUS duration_literal */ + 404, /* (433) tags_literal_list ::= tags_literal */ + 404, /* (434) tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ + 358, /* (435) literal ::= NK_INTEGER */ + 358, /* (436) literal ::= NK_FLOAT */ + 358, /* (437) literal ::= NK_STRING */ + 358, /* (438) literal ::= NK_BOOL */ + 358, /* (439) literal ::= TIMESTAMP NK_STRING */ + 358, /* (440) literal ::= duration_literal */ + 358, /* (441) literal ::= NULL */ + 358, /* (442) literal ::= NK_QUESTION */ + 411, /* (443) duration_literal ::= NK_VARIABLE */ + 387, /* (444) signed ::= NK_INTEGER */ + 387, /* (445) signed ::= NK_PLUS NK_INTEGER */ + 387, /* (446) signed ::= NK_MINUS NK_INTEGER */ + 387, /* (447) signed ::= NK_FLOAT */ + 387, /* (448) signed ::= NK_PLUS NK_FLOAT */ + 387, /* (449) signed ::= NK_MINUS NK_FLOAT */ + 459, /* (450) signed_literal ::= signed */ + 459, /* (451) signed_literal ::= NK_STRING */ + 459, /* (452) signed_literal ::= NK_BOOL */ + 459, /* (453) signed_literal ::= TIMESTAMP NK_STRING */ + 459, /* (454) signed_literal ::= duration_literal */ + 459, /* (455) signed_literal ::= NULL */ + 459, /* (456) signed_literal ::= literal_func */ + 459, /* (457) signed_literal ::= NK_QUESTION */ + 460, /* (458) literal_list ::= signed_literal */ + 460, /* (459) literal_list ::= literal_list NK_COMMA signed_literal */ + 370, /* (460) db_name ::= NK_ID */ + 371, /* (461) table_name ::= NK_ID */ + 399, /* (462) column_name ::= NK_ID */ + 413, /* (463) function_name ::= NK_ID */ + 446, /* (464) view_name ::= NK_ID */ + 461, /* (465) table_alias ::= NK_ID */ + 424, /* (466) column_alias ::= NK_ID */ + 424, /* (467) column_alias ::= NK_ALIAS */ + 363, /* (468) user_name ::= NK_ID */ + 372, /* (469) topic_name ::= NK_ID */ + 447, /* (470) stream_name ::= NK_ID */ + 437, /* (471) cgroup_name ::= NK_ID */ + 427, /* (472) index_name ::= NK_ID */ + 462, /* (473) expr_or_subquery ::= expression */ + 455, /* (474) expression ::= literal */ + 455, /* (475) expression ::= pseudo_column */ + 455, /* (476) expression ::= column_reference */ + 455, /* (477) expression ::= function_expression */ + 455, /* (478) expression ::= case_when_expression */ + 455, /* (479) expression ::= NK_LP expression NK_RP */ + 455, /* (480) expression ::= NK_PLUS expr_or_subquery */ + 455, /* (481) expression ::= NK_MINUS expr_or_subquery */ + 455, /* (482) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + 455, /* (483) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + 455, /* (484) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + 455, /* (485) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + 455, /* (486) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + 455, /* (487) expression ::= column_reference NK_ARROW NK_STRING */ + 455, /* (488) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + 455, /* (489) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + 433, /* (490) expression_list ::= expr_or_subquery */ + 433, /* (491) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + 464, /* (492) column_reference ::= column_name */ + 464, /* (493) column_reference ::= table_name NK_DOT column_name */ + 464, /* (494) column_reference ::= NK_ALIAS */ + 464, /* (495) column_reference ::= table_name NK_DOT NK_ALIAS */ + 463, /* (496) pseudo_column ::= ROWTS */ + 463, /* (497) pseudo_column ::= TBNAME */ + 463, /* (498) pseudo_column ::= table_name NK_DOT TBNAME */ + 463, /* (499) pseudo_column ::= QSTART */ + 463, /* (500) pseudo_column ::= QEND */ + 463, /* (501) pseudo_column ::= QDURATION */ + 463, /* (502) pseudo_column ::= WSTART */ + 463, /* (503) pseudo_column ::= WEND */ + 463, /* (504) pseudo_column ::= WDURATION */ + 463, /* (505) pseudo_column ::= IROWTS */ + 463, /* (506) pseudo_column ::= ISFILLED */ + 463, /* (507) pseudo_column ::= QTAGS */ + 465, /* (508) function_expression ::= function_name NK_LP expression_list NK_RP */ + 465, /* (509) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + 465, /* (510) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + 465, /* (511) function_expression ::= literal_func */ + 458, /* (512) literal_func ::= noarg_func NK_LP NK_RP */ + 458, /* (513) literal_func ::= NOW */ + 458, /* (514) literal_func ::= TODAY */ + 469, /* (515) noarg_func ::= NOW */ + 469, /* (516) noarg_func ::= TODAY */ + 469, /* (517) noarg_func ::= TIMEZONE */ + 469, /* (518) noarg_func ::= DATABASE */ + 469, /* (519) noarg_func ::= CLIENT_VERSION */ + 469, /* (520) noarg_func ::= SERVER_VERSION */ + 469, /* (521) noarg_func ::= SERVER_STATUS */ + 469, /* (522) noarg_func ::= CURRENT_USER */ + 469, /* (523) noarg_func ::= USER */ + 467, /* (524) star_func ::= COUNT */ + 467, /* (525) star_func ::= FIRST */ + 467, /* (526) star_func ::= LAST */ + 467, /* (527) star_func ::= LAST_ROW */ + 468, /* (528) star_func_para_list ::= NK_STAR */ + 468, /* (529) star_func_para_list ::= other_para_list */ + 470, /* (530) other_para_list ::= star_func_para */ + 470, /* (531) other_para_list ::= other_para_list NK_COMMA star_func_para */ + 471, /* (532) star_func_para ::= expr_or_subquery */ + 471, /* (533) star_func_para ::= table_name NK_DOT NK_STAR */ + 466, /* (534) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + 466, /* (535) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + 472, /* (536) when_then_list ::= when_then_expr */ + 472, /* (537) when_then_list ::= when_then_list when_then_expr */ + 475, /* (538) when_then_expr ::= WHEN common_expression THEN common_expression */ + 473, /* (539) case_when_else_opt ::= */ + 473, /* (540) case_when_else_opt ::= ELSE common_expression */ + 476, /* (541) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + 476, /* (542) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + 476, /* (543) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + 476, /* (544) predicate ::= expr_or_subquery IS NULL */ + 476, /* (545) predicate ::= expr_or_subquery IS NOT NULL */ + 476, /* (546) predicate ::= expr_or_subquery in_op in_predicate_value */ + 477, /* (547) compare_op ::= NK_LT */ + 477, /* (548) compare_op ::= NK_GT */ + 477, /* (549) compare_op ::= NK_LE */ + 477, /* (550) compare_op ::= NK_GE */ + 477, /* (551) compare_op ::= NK_NE */ + 477, /* (552) compare_op ::= NK_EQ */ + 477, /* (553) compare_op ::= LIKE */ + 477, /* (554) compare_op ::= NOT LIKE */ + 477, /* (555) compare_op ::= MATCH */ + 477, /* (556) compare_op ::= NMATCH */ + 477, /* (557) compare_op ::= CONTAINS */ + 478, /* (558) in_op ::= IN */ + 478, /* (559) in_op ::= NOT IN */ + 479, /* (560) in_predicate_value ::= NK_LP literal_list NK_RP */ + 480, /* (561) boolean_value_expression ::= boolean_primary */ + 480, /* (562) boolean_value_expression ::= NOT boolean_primary */ + 480, /* (563) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + 480, /* (564) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + 481, /* (565) boolean_primary ::= predicate */ + 481, /* (566) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + 474, /* (567) common_expression ::= expr_or_subquery */ + 474, /* (568) common_expression ::= boolean_value_expression */ + 482, /* (569) from_clause_opt ::= */ + 482, /* (570) from_clause_opt ::= FROM table_reference_list */ + 483, /* (571) table_reference_list ::= table_reference */ + 483, /* (572) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + 484, /* (573) table_reference ::= table_primary */ + 484, /* (574) table_reference ::= joined_table */ + 485, /* (575) table_primary ::= table_name alias_opt */ + 485, /* (576) table_primary ::= db_name NK_DOT table_name alias_opt */ + 485, /* (577) table_primary ::= subquery alias_opt */ + 485, /* (578) table_primary ::= parenthesized_joined_table */ + 487, /* (579) alias_opt ::= */ + 487, /* (580) alias_opt ::= table_alias */ + 487, /* (581) alias_opt ::= AS table_alias */ + 489, /* (582) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + 489, /* (583) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + 486, /* (584) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + 490, /* (585) join_type ::= */ + 490, /* (586) join_type ::= INNER */ + 491, /* (587) 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 */ + 492, /* (588) hint_list ::= */ + 492, /* (589) hint_list ::= NK_HINT */ + 494, /* (590) tag_mode_opt ::= */ + 494, /* (591) tag_mode_opt ::= TAGS */ + 493, /* (592) set_quantifier_opt ::= */ + 493, /* (593) set_quantifier_opt ::= DISTINCT */ + 493, /* (594) set_quantifier_opt ::= ALL */ + 495, /* (595) select_list ::= select_item */ + 495, /* (596) select_list ::= select_list NK_COMMA select_item */ + 503, /* (597) select_item ::= NK_STAR */ + 503, /* (598) select_item ::= common_expression */ + 503, /* (599) select_item ::= common_expression column_alias */ + 503, /* (600) select_item ::= common_expression AS column_alias */ + 503, /* (601) select_item ::= table_name NK_DOT NK_STAR */ + 436, /* (602) where_clause_opt ::= */ + 436, /* (603) where_clause_opt ::= WHERE search_condition */ + 496, /* (604) partition_by_clause_opt ::= */ + 496, /* (605) partition_by_clause_opt ::= PARTITION BY partition_list */ + 504, /* (606) partition_list ::= partition_item */ + 504, /* (607) partition_list ::= partition_list NK_COMMA partition_item */ + 505, /* (608) partition_item ::= expr_or_subquery */ + 505, /* (609) partition_item ::= expr_or_subquery column_alias */ + 505, /* (610) partition_item ::= expr_or_subquery AS column_alias */ + 500, /* (611) twindow_clause_opt ::= */ + 500, /* (612) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ + 500, /* (613) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + 500, /* (614) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + 500, /* (615) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + 500, /* (616) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ + 500, /* (617) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ + 500, /* (618) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 429, /* (619) sliding_opt ::= */ + 429, /* (620) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ + 506, /* (621) interval_sliding_duration_literal ::= NK_VARIABLE */ + 506, /* (622) interval_sliding_duration_literal ::= NK_STRING */ + 506, /* (623) interval_sliding_duration_literal ::= NK_INTEGER */ + 499, /* (624) fill_opt ::= */ + 499, /* (625) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + 499, /* (626) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ + 499, /* (627) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ + 507, /* (628) fill_mode ::= NONE */ + 507, /* (629) fill_mode ::= PREV */ + 507, /* (630) fill_mode ::= NULL */ + 507, /* (631) fill_mode ::= NULL_F */ + 507, /* (632) fill_mode ::= LINEAR */ + 507, /* (633) fill_mode ::= NEXT */ + 501, /* (634) group_by_clause_opt ::= */ + 501, /* (635) group_by_clause_opt ::= GROUP BY group_by_list */ + 508, /* (636) group_by_list ::= expr_or_subquery */ + 508, /* (637) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + 502, /* (638) having_clause_opt ::= */ + 502, /* (639) having_clause_opt ::= HAVING search_condition */ + 497, /* (640) range_opt ::= */ + 497, /* (641) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + 497, /* (642) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ + 498, /* (643) every_opt ::= */ + 498, /* (644) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + 509, /* (645) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + 510, /* (646) query_simple ::= query_specification */ + 510, /* (647) query_simple ::= union_query_expression */ + 514, /* (648) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + 514, /* (649) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + 515, /* (650) query_simple_or_subquery ::= query_simple */ + 515, /* (651) query_simple_or_subquery ::= subquery */ + 435, /* (652) query_or_subquery ::= query_expression */ + 435, /* (653) query_or_subquery ::= subquery */ + 511, /* (654) order_by_clause_opt ::= */ + 511, /* (655) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 512, /* (656) slimit_clause_opt ::= */ + 512, /* (657) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + 512, /* (658) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + 512, /* (659) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 513, /* (660) limit_clause_opt ::= */ + 513, /* (661) limit_clause_opt ::= LIMIT NK_INTEGER */ + 513, /* (662) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + 513, /* (663) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 488, /* (664) subquery ::= NK_LP query_expression NK_RP */ + 488, /* (665) subquery ::= NK_LP subquery NK_RP */ + 373, /* (666) search_condition ::= common_expression */ + 516, /* (667) sort_specification_list ::= sort_specification */ + 516, /* (668) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + 517, /* (669) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + 518, /* (670) ordering_specification_opt ::= */ + 518, /* (671) ordering_specification_opt ::= ASC */ + 518, /* (672) ordering_specification_opt ::= DESC */ + 519, /* (673) null_ordering_opt ::= */ + 519, /* (674) null_ordering_opt ::= NULLS FIRST */ + 519, /* (675) null_ordering_opt ::= NULLS LAST */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -4587,10 +4628,10 @@ static const signed char yyRuleInfoNRhs[] = { -4, /* (178) alter_table_clause ::= full_table_name DROP TAG column_name */ -5, /* (179) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -5, /* (180) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - -6, /* (181) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + -6, /* (181) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal */ -1, /* (182) multi_create_clause ::= create_subtable_clause */ -2, /* (183) multi_create_clause ::= multi_create_clause create_subtable_clause */ - -10, /* (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 */ + -10, /* (184) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP tags_literal_list NK_RP table_options */ -1, /* (185) multi_drop_clause ::= drop_table_clause */ -3, /* (186) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ -2, /* (187) drop_table_clause ::= exists_opt full_table_name */ @@ -4660,406 +4701,428 @@ static const signed char yyRuleInfoNRhs[] = { -3, /* (251) cmd ::= SHOW db_name_cond_opt VGROUPS */ -2, /* (252) cmd ::= SHOW MNODES */ -2, /* (253) cmd ::= SHOW QNODES */ - -2, /* (254) cmd ::= SHOW FUNCTIONS */ - -5, /* (255) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - -6, /* (256) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ - -2, /* (257) cmd ::= SHOW STREAMS */ - -2, /* (258) cmd ::= SHOW ACCOUNTS */ - -2, /* (259) cmd ::= SHOW APPS */ - -2, /* (260) cmd ::= SHOW CONNECTIONS */ - -2, /* (261) cmd ::= SHOW LICENCES */ - -2, /* (262) cmd ::= SHOW GRANTS */ - -3, /* (263) cmd ::= SHOW GRANTS FULL */ - -3, /* (264) cmd ::= SHOW GRANTS LOGS */ - -3, /* (265) cmd ::= SHOW CLUSTER MACHINES */ - -4, /* (266) cmd ::= SHOW CREATE DATABASE db_name */ - -4, /* (267) cmd ::= SHOW CREATE TABLE full_table_name */ - -4, /* (268) cmd ::= SHOW CREATE STABLE full_table_name */ - -2, /* (269) cmd ::= SHOW QUERIES */ - -2, /* (270) cmd ::= SHOW SCORES */ - -2, /* (271) cmd ::= SHOW TOPICS */ - -2, /* (272) cmd ::= SHOW VARIABLES */ - -3, /* (273) cmd ::= SHOW CLUSTER VARIABLES */ - -3, /* (274) cmd ::= SHOW LOCAL VARIABLES */ - -5, /* (275) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ - -2, /* (276) cmd ::= SHOW BNODES */ - -2, /* (277) cmd ::= SHOW SNODES */ - -2, /* (278) cmd ::= SHOW CLUSTER */ - -2, /* (279) cmd ::= SHOW TRANSACTIONS */ - -4, /* (280) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - -2, /* (281) cmd ::= SHOW CONSUMERS */ - -2, /* (282) cmd ::= SHOW SUBSCRIPTIONS */ - -5, /* (283) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - -6, /* (284) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ - -7, /* (285) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ - -8, /* (286) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ - -5, /* (287) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ - -2, /* (288) cmd ::= SHOW VNODES */ - -3, /* (289) cmd ::= SHOW db_name_cond_opt ALIVE */ - -3, /* (290) cmd ::= SHOW CLUSTER ALIVE */ - -4, /* (291) cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ - -4, /* (292) cmd ::= SHOW CREATE VIEW full_table_name */ - -2, /* (293) cmd ::= SHOW COMPACTS */ - -3, /* (294) cmd ::= SHOW COMPACT NK_INTEGER */ - 0, /* (295) table_kind_db_name_cond_opt ::= */ - -1, /* (296) table_kind_db_name_cond_opt ::= table_kind */ - -2, /* (297) table_kind_db_name_cond_opt ::= db_name NK_DOT */ - -3, /* (298) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ - -1, /* (299) table_kind ::= NORMAL */ - -1, /* (300) table_kind ::= CHILD */ - 0, /* (301) db_name_cond_opt ::= */ - -2, /* (302) db_name_cond_opt ::= db_name NK_DOT */ - 0, /* (303) like_pattern_opt ::= */ - -2, /* (304) like_pattern_opt ::= LIKE NK_STRING */ - -1, /* (305) table_name_cond ::= table_name */ - 0, /* (306) from_db_opt ::= */ - -2, /* (307) from_db_opt ::= FROM db_name */ - 0, /* (308) tag_list_opt ::= */ - -1, /* (309) tag_list_opt ::= tag_item */ - -3, /* (310) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ - -1, /* (311) tag_item ::= TBNAME */ - -1, /* (312) tag_item ::= QTAGS */ - -1, /* (313) tag_item ::= column_name */ - -2, /* (314) tag_item ::= column_name column_alias */ - -3, /* (315) tag_item ::= column_name AS column_alias */ - 0, /* (316) db_kind_opt ::= */ - -1, /* (317) db_kind_opt ::= USER */ - -1, /* (318) db_kind_opt ::= SYSTEM */ - -8, /* (319) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ - -9, /* (320) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ - -4, /* (321) cmd ::= DROP INDEX exists_opt full_index_name */ - -1, /* (322) full_index_name ::= index_name */ - -3, /* (323) full_index_name ::= db_name NK_DOT index_name */ - -10, /* (324) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - -12, /* (325) 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 */ - -1, /* (326) func_list ::= func */ - -3, /* (327) func_list ::= func_list NK_COMMA func */ - -4, /* (328) func ::= sma_func_name NK_LP expression_list NK_RP */ - -1, /* (329) sma_func_name ::= function_name */ - -1, /* (330) sma_func_name ::= COUNT */ - -1, /* (331) sma_func_name ::= FIRST */ - -1, /* (332) sma_func_name ::= LAST */ - -1, /* (333) sma_func_name ::= LAST_ROW */ - 0, /* (334) sma_stream_opt ::= */ - -3, /* (335) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - -3, /* (336) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - -3, /* (337) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - -1, /* (338) with_meta ::= AS */ - -3, /* (339) with_meta ::= WITH META AS */ - -3, /* (340) with_meta ::= ONLY META AS */ - -6, /* (341) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - -7, /* (342) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ - -8, /* (343) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ - -4, /* (344) cmd ::= DROP TOPIC exists_opt topic_name */ - -7, /* (345) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - -2, /* (346) cmd ::= DESC full_table_name */ - -2, /* (347) cmd ::= DESCRIBE full_table_name */ - -3, /* (348) cmd ::= RESET QUERY CACHE */ - -4, /* (349) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - -4, /* (350) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ - 0, /* (351) analyze_opt ::= */ - -1, /* (352) analyze_opt ::= ANALYZE */ - 0, /* (353) explain_options ::= */ - -3, /* (354) explain_options ::= explain_options VERBOSE NK_BOOL */ - -3, /* (355) explain_options ::= explain_options RATIO NK_FLOAT */ - -12, /* (356) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ - -4, /* (357) cmd ::= DROP FUNCTION exists_opt function_name */ - 0, /* (358) agg_func_opt ::= */ - -1, /* (359) agg_func_opt ::= AGGREGATE */ - 0, /* (360) bufsize_opt ::= */ - -2, /* (361) bufsize_opt ::= BUFSIZE NK_INTEGER */ - 0, /* (362) language_opt ::= */ - -2, /* (363) language_opt ::= LANGUAGE NK_STRING */ - 0, /* (364) or_replace_opt ::= */ - -2, /* (365) or_replace_opt ::= OR REPLACE */ - -6, /* (366) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ - -4, /* (367) cmd ::= DROP VIEW exists_opt full_view_name */ - -1, /* (368) full_view_name ::= view_name */ - -3, /* (369) full_view_name ::= db_name NK_DOT view_name */ - -12, /* (370) 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 */ - -4, /* (371) cmd ::= DROP STREAM exists_opt stream_name */ - -4, /* (372) cmd ::= PAUSE STREAM exists_opt stream_name */ - -5, /* (373) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ - 0, /* (374) col_list_opt ::= */ - -3, /* (375) col_list_opt ::= NK_LP column_stream_def_list NK_RP */ - -1, /* (376) column_stream_def_list ::= column_stream_def */ - -3, /* (377) column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ - -1, /* (378) column_stream_def ::= column_name */ - -3, /* (379) column_stream_def ::= column_name PRIMARY KEY */ - 0, /* (380) tag_def_or_ref_opt ::= */ - -1, /* (381) tag_def_or_ref_opt ::= tags_def */ - -4, /* (382) tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ - 0, /* (383) stream_options ::= */ - -3, /* (384) stream_options ::= stream_options TRIGGER AT_ONCE */ - -3, /* (385) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - -4, /* (386) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - -3, /* (387) stream_options ::= stream_options WATERMARK duration_literal */ - -4, /* (388) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - -3, /* (389) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - -3, /* (390) stream_options ::= stream_options DELETE_MARK duration_literal */ - -4, /* (391) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ - 0, /* (392) subtable_opt ::= */ - -4, /* (393) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - 0, /* (394) ignore_opt ::= */ - -2, /* (395) ignore_opt ::= IGNORE UNTREATED */ - -3, /* (396) cmd ::= KILL CONNECTION NK_INTEGER */ - -3, /* (397) cmd ::= KILL QUERY NK_STRING */ - -3, /* (398) cmd ::= KILL TRANSACTION NK_INTEGER */ - -3, /* (399) cmd ::= KILL COMPACT NK_INTEGER */ - -2, /* (400) cmd ::= BALANCE VGROUP */ - -4, /* (401) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ - -4, /* (402) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - -4, /* (403) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - -3, /* (404) cmd ::= SPLIT VGROUP NK_INTEGER */ - 0, /* (405) on_vgroup_id ::= */ - -2, /* (406) on_vgroup_id ::= ON NK_INTEGER */ - -2, /* (407) dnode_list ::= DNODE NK_INTEGER */ - -3, /* (408) dnode_list ::= dnode_list DNODE NK_INTEGER */ - -4, /* (409) cmd ::= DELETE FROM full_table_name where_clause_opt */ - -1, /* (410) cmd ::= query_or_subquery */ - -1, /* (411) cmd ::= insert_query */ - -7, /* (412) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - -4, /* (413) insert_query ::= INSERT INTO full_table_name query_or_subquery */ - -1, /* (414) literal ::= NK_INTEGER */ - -1, /* (415) literal ::= NK_FLOAT */ - -1, /* (416) literal ::= NK_STRING */ - -1, /* (417) literal ::= NK_BOOL */ - -2, /* (418) literal ::= TIMESTAMP NK_STRING */ - -1, /* (419) literal ::= duration_literal */ - -1, /* (420) literal ::= NULL */ - -1, /* (421) literal ::= NK_QUESTION */ - -1, /* (422) duration_literal ::= NK_VARIABLE */ - -1, /* (423) signed ::= NK_INTEGER */ - -2, /* (424) signed ::= NK_PLUS NK_INTEGER */ - -2, /* (425) signed ::= NK_MINUS NK_INTEGER */ - -1, /* (426) signed ::= NK_FLOAT */ - -2, /* (427) signed ::= NK_PLUS NK_FLOAT */ - -2, /* (428) signed ::= NK_MINUS NK_FLOAT */ - -1, /* (429) signed_literal ::= signed */ - -1, /* (430) signed_literal ::= NK_STRING */ - -1, /* (431) signed_literal ::= NK_BOOL */ - -2, /* (432) signed_literal ::= TIMESTAMP NK_STRING */ - -1, /* (433) signed_literal ::= duration_literal */ - -1, /* (434) signed_literal ::= NULL */ - -1, /* (435) signed_literal ::= literal_func */ - -1, /* (436) signed_literal ::= NK_QUESTION */ - -1, /* (437) literal_list ::= signed_literal */ - -3, /* (438) literal_list ::= literal_list NK_COMMA signed_literal */ - -1, /* (439) db_name ::= NK_ID */ - -1, /* (440) table_name ::= NK_ID */ - -1, /* (441) column_name ::= NK_ID */ - -1, /* (442) function_name ::= NK_ID */ - -1, /* (443) view_name ::= NK_ID */ - -1, /* (444) table_alias ::= NK_ID */ - -1, /* (445) column_alias ::= NK_ID */ - -1, /* (446) column_alias ::= NK_ALIAS */ - -1, /* (447) user_name ::= NK_ID */ - -1, /* (448) topic_name ::= NK_ID */ - -1, /* (449) stream_name ::= NK_ID */ - -1, /* (450) cgroup_name ::= NK_ID */ - -1, /* (451) index_name ::= NK_ID */ - -1, /* (452) expr_or_subquery ::= expression */ - -1, /* (453) expression ::= literal */ - -1, /* (454) expression ::= pseudo_column */ - -1, /* (455) expression ::= column_reference */ - -1, /* (456) expression ::= function_expression */ - -1, /* (457) expression ::= case_when_expression */ - -3, /* (458) expression ::= NK_LP expression NK_RP */ - -2, /* (459) expression ::= NK_PLUS expr_or_subquery */ - -2, /* (460) expression ::= NK_MINUS expr_or_subquery */ - -3, /* (461) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - -3, /* (462) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - -3, /* (463) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - -3, /* (464) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - -3, /* (465) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - -3, /* (466) expression ::= column_reference NK_ARROW NK_STRING */ - -3, /* (467) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - -3, /* (468) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - -1, /* (469) expression_list ::= expr_or_subquery */ - -3, /* (470) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - -1, /* (471) column_reference ::= column_name */ - -3, /* (472) column_reference ::= table_name NK_DOT column_name */ - -1, /* (473) column_reference ::= NK_ALIAS */ - -3, /* (474) column_reference ::= table_name NK_DOT NK_ALIAS */ - -1, /* (475) pseudo_column ::= ROWTS */ - -1, /* (476) pseudo_column ::= TBNAME */ - -3, /* (477) pseudo_column ::= table_name NK_DOT TBNAME */ - -1, /* (478) pseudo_column ::= QSTART */ - -1, /* (479) pseudo_column ::= QEND */ - -1, /* (480) pseudo_column ::= QDURATION */ - -1, /* (481) pseudo_column ::= WSTART */ - -1, /* (482) pseudo_column ::= WEND */ - -1, /* (483) pseudo_column ::= WDURATION */ - -1, /* (484) pseudo_column ::= IROWTS */ - -1, /* (485) pseudo_column ::= ISFILLED */ - -1, /* (486) pseudo_column ::= QTAGS */ - -4, /* (487) function_expression ::= function_name NK_LP expression_list NK_RP */ - -4, /* (488) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - -6, /* (489) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - -1, /* (490) function_expression ::= literal_func */ - -3, /* (491) literal_func ::= noarg_func NK_LP NK_RP */ - -1, /* (492) literal_func ::= NOW */ - -1, /* (493) noarg_func ::= NOW */ - -1, /* (494) noarg_func ::= TODAY */ - -1, /* (495) noarg_func ::= TIMEZONE */ - -1, /* (496) noarg_func ::= DATABASE */ - -1, /* (497) noarg_func ::= CLIENT_VERSION */ - -1, /* (498) noarg_func ::= SERVER_VERSION */ - -1, /* (499) noarg_func ::= SERVER_STATUS */ - -1, /* (500) noarg_func ::= CURRENT_USER */ - -1, /* (501) noarg_func ::= USER */ - -1, /* (502) star_func ::= COUNT */ - -1, /* (503) star_func ::= FIRST */ - -1, /* (504) star_func ::= LAST */ - -1, /* (505) star_func ::= LAST_ROW */ - -1, /* (506) star_func_para_list ::= NK_STAR */ - -1, /* (507) star_func_para_list ::= other_para_list */ - -1, /* (508) other_para_list ::= star_func_para */ - -3, /* (509) other_para_list ::= other_para_list NK_COMMA star_func_para */ - -1, /* (510) star_func_para ::= expr_or_subquery */ - -3, /* (511) star_func_para ::= table_name NK_DOT NK_STAR */ - -4, /* (512) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - -5, /* (513) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - -1, /* (514) when_then_list ::= when_then_expr */ - -2, /* (515) when_then_list ::= when_then_list when_then_expr */ - -4, /* (516) when_then_expr ::= WHEN common_expression THEN common_expression */ - 0, /* (517) case_when_else_opt ::= */ - -2, /* (518) case_when_else_opt ::= ELSE common_expression */ - -3, /* (519) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - -5, /* (520) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - -6, /* (521) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - -3, /* (522) predicate ::= expr_or_subquery IS NULL */ - -4, /* (523) predicate ::= expr_or_subquery IS NOT NULL */ - -3, /* (524) predicate ::= expr_or_subquery in_op in_predicate_value */ - -1, /* (525) compare_op ::= NK_LT */ - -1, /* (526) compare_op ::= NK_GT */ - -1, /* (527) compare_op ::= NK_LE */ - -1, /* (528) compare_op ::= NK_GE */ - -1, /* (529) compare_op ::= NK_NE */ - -1, /* (530) compare_op ::= NK_EQ */ - -1, /* (531) compare_op ::= LIKE */ - -2, /* (532) compare_op ::= NOT LIKE */ - -1, /* (533) compare_op ::= MATCH */ - -1, /* (534) compare_op ::= NMATCH */ - -1, /* (535) compare_op ::= CONTAINS */ - -1, /* (536) in_op ::= IN */ - -2, /* (537) in_op ::= NOT IN */ - -3, /* (538) in_predicate_value ::= NK_LP literal_list NK_RP */ - -1, /* (539) boolean_value_expression ::= boolean_primary */ - -2, /* (540) boolean_value_expression ::= NOT boolean_primary */ - -3, /* (541) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - -3, /* (542) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - -1, /* (543) boolean_primary ::= predicate */ - -3, /* (544) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - -1, /* (545) common_expression ::= expr_or_subquery */ - -1, /* (546) common_expression ::= boolean_value_expression */ - 0, /* (547) from_clause_opt ::= */ - -2, /* (548) from_clause_opt ::= FROM table_reference_list */ - -1, /* (549) table_reference_list ::= table_reference */ - -3, /* (550) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - -1, /* (551) table_reference ::= table_primary */ - -1, /* (552) table_reference ::= joined_table */ - -2, /* (553) table_primary ::= table_name alias_opt */ - -4, /* (554) table_primary ::= db_name NK_DOT table_name alias_opt */ - -2, /* (555) table_primary ::= subquery alias_opt */ - -1, /* (556) table_primary ::= parenthesized_joined_table */ - 0, /* (557) alias_opt ::= */ - -1, /* (558) alias_opt ::= table_alias */ - -2, /* (559) alias_opt ::= AS table_alias */ - -3, /* (560) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - -3, /* (561) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - -6, /* (562) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - 0, /* (563) join_type ::= */ - -1, /* (564) join_type ::= INNER */ - -14, /* (565) 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 */ - 0, /* (566) hint_list ::= */ - -1, /* (567) hint_list ::= NK_HINT */ - 0, /* (568) tag_mode_opt ::= */ - -1, /* (569) tag_mode_opt ::= TAGS */ - 0, /* (570) set_quantifier_opt ::= */ - -1, /* (571) set_quantifier_opt ::= DISTINCT */ - -1, /* (572) set_quantifier_opt ::= ALL */ - -1, /* (573) select_list ::= select_item */ - -3, /* (574) select_list ::= select_list NK_COMMA select_item */ - -1, /* (575) select_item ::= NK_STAR */ - -1, /* (576) select_item ::= common_expression */ - -2, /* (577) select_item ::= common_expression column_alias */ - -3, /* (578) select_item ::= common_expression AS column_alias */ - -3, /* (579) select_item ::= table_name NK_DOT NK_STAR */ - 0, /* (580) where_clause_opt ::= */ - -2, /* (581) where_clause_opt ::= WHERE search_condition */ - 0, /* (582) partition_by_clause_opt ::= */ - -3, /* (583) partition_by_clause_opt ::= PARTITION BY partition_list */ - -1, /* (584) partition_list ::= partition_item */ - -3, /* (585) partition_list ::= partition_list NK_COMMA partition_item */ - -1, /* (586) partition_item ::= expr_or_subquery */ - -2, /* (587) partition_item ::= expr_or_subquery column_alias */ - -3, /* (588) partition_item ::= expr_or_subquery AS column_alias */ - 0, /* (589) twindow_clause_opt ::= */ - -6, /* (590) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ - -4, /* (591) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - -6, /* (592) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - -8, /* (593) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - -7, /* (594) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ - -4, /* (595) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ - -6, /* (596) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 0, /* (597) sliding_opt ::= */ - -4, /* (598) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ - -1, /* (599) interval_sliding_duration_literal ::= NK_VARIABLE */ - -1, /* (600) interval_sliding_duration_literal ::= NK_STRING */ - -1, /* (601) interval_sliding_duration_literal ::= NK_INTEGER */ - 0, /* (602) fill_opt ::= */ - -4, /* (603) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - -6, /* (604) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ - -6, /* (605) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ - -1, /* (606) fill_mode ::= NONE */ - -1, /* (607) fill_mode ::= PREV */ - -1, /* (608) fill_mode ::= NULL */ - -1, /* (609) fill_mode ::= NULL_F */ - -1, /* (610) fill_mode ::= LINEAR */ - -1, /* (611) fill_mode ::= NEXT */ - 0, /* (612) group_by_clause_opt ::= */ - -3, /* (613) group_by_clause_opt ::= GROUP BY group_by_list */ - -1, /* (614) group_by_list ::= expr_or_subquery */ - -3, /* (615) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - 0, /* (616) having_clause_opt ::= */ - -2, /* (617) having_clause_opt ::= HAVING search_condition */ - 0, /* (618) range_opt ::= */ - -6, /* (619) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - -4, /* (620) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ - 0, /* (621) every_opt ::= */ - -4, /* (622) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - -4, /* (623) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - -1, /* (624) query_simple ::= query_specification */ - -1, /* (625) query_simple ::= union_query_expression */ - -4, /* (626) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - -3, /* (627) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - -1, /* (628) query_simple_or_subquery ::= query_simple */ - -1, /* (629) query_simple_or_subquery ::= subquery */ - -1, /* (630) query_or_subquery ::= query_expression */ - -1, /* (631) query_or_subquery ::= subquery */ - 0, /* (632) order_by_clause_opt ::= */ - -3, /* (633) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 0, /* (634) slimit_clause_opt ::= */ - -2, /* (635) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - -4, /* (636) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - -4, /* (637) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 0, /* (638) limit_clause_opt ::= */ - -2, /* (639) limit_clause_opt ::= LIMIT NK_INTEGER */ - -4, /* (640) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - -4, /* (641) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - -3, /* (642) subquery ::= NK_LP query_expression NK_RP */ - -3, /* (643) subquery ::= NK_LP subquery NK_RP */ - -1, /* (644) search_condition ::= common_expression */ - -1, /* (645) sort_specification_list ::= sort_specification */ - -3, /* (646) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - -3, /* (647) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - 0, /* (648) ordering_specification_opt ::= */ - -1, /* (649) ordering_specification_opt ::= ASC */ - -1, /* (650) ordering_specification_opt ::= DESC */ - 0, /* (651) null_ordering_opt ::= */ - -2, /* (652) null_ordering_opt ::= NULLS FIRST */ - -2, /* (653) null_ordering_opt ::= NULLS LAST */ + -2, /* (254) cmd ::= SHOW ARBGROUPS */ + -2, /* (255) cmd ::= SHOW FUNCTIONS */ + -5, /* (256) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + -6, /* (257) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ + -2, /* (258) cmd ::= SHOW STREAMS */ + -2, /* (259) cmd ::= SHOW ACCOUNTS */ + -2, /* (260) cmd ::= SHOW APPS */ + -2, /* (261) cmd ::= SHOW CONNECTIONS */ + -2, /* (262) cmd ::= SHOW LICENCES */ + -2, /* (263) cmd ::= SHOW GRANTS */ + -3, /* (264) cmd ::= SHOW GRANTS FULL */ + -3, /* (265) cmd ::= SHOW GRANTS LOGS */ + -3, /* (266) cmd ::= SHOW CLUSTER MACHINES */ + -4, /* (267) cmd ::= SHOW CREATE DATABASE db_name */ + -4, /* (268) cmd ::= SHOW CREATE TABLE full_table_name */ + -4, /* (269) cmd ::= SHOW CREATE STABLE full_table_name */ + -2, /* (270) cmd ::= SHOW QUERIES */ + -2, /* (271) cmd ::= SHOW SCORES */ + -2, /* (272) cmd ::= SHOW TOPICS */ + -2, /* (273) cmd ::= SHOW VARIABLES */ + -3, /* (274) cmd ::= SHOW CLUSTER VARIABLES */ + -3, /* (275) cmd ::= SHOW LOCAL VARIABLES */ + -5, /* (276) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ + -2, /* (277) cmd ::= SHOW BNODES */ + -2, /* (278) cmd ::= SHOW SNODES */ + -2, /* (279) cmd ::= SHOW CLUSTER */ + -2, /* (280) cmd ::= SHOW TRANSACTIONS */ + -4, /* (281) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + -2, /* (282) cmd ::= SHOW CONSUMERS */ + -2, /* (283) cmd ::= SHOW SUBSCRIPTIONS */ + -5, /* (284) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + -6, /* (285) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ + -7, /* (286) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ + -8, /* (287) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ + -5, /* (288) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ + -2, /* (289) cmd ::= SHOW VNODES */ + -3, /* (290) cmd ::= SHOW db_name_cond_opt ALIVE */ + -3, /* (291) cmd ::= SHOW CLUSTER ALIVE */ + -4, /* (292) cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ + -4, /* (293) cmd ::= SHOW CREATE VIEW full_table_name */ + -2, /* (294) cmd ::= SHOW COMPACTS */ + -3, /* (295) cmd ::= SHOW COMPACT NK_INTEGER */ + 0, /* (296) table_kind_db_name_cond_opt ::= */ + -1, /* (297) table_kind_db_name_cond_opt ::= table_kind */ + -2, /* (298) table_kind_db_name_cond_opt ::= db_name NK_DOT */ + -3, /* (299) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ + -1, /* (300) table_kind ::= NORMAL */ + -1, /* (301) table_kind ::= CHILD */ + 0, /* (302) db_name_cond_opt ::= */ + -2, /* (303) db_name_cond_opt ::= db_name NK_DOT */ + 0, /* (304) like_pattern_opt ::= */ + -2, /* (305) like_pattern_opt ::= LIKE NK_STRING */ + -1, /* (306) table_name_cond ::= table_name */ + 0, /* (307) from_db_opt ::= */ + -2, /* (308) from_db_opt ::= FROM db_name */ + 0, /* (309) tag_list_opt ::= */ + -1, /* (310) tag_list_opt ::= tag_item */ + -3, /* (311) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ + -1, /* (312) tag_item ::= TBNAME */ + -1, /* (313) tag_item ::= QTAGS */ + -1, /* (314) tag_item ::= column_name */ + -2, /* (315) tag_item ::= column_name column_alias */ + -3, /* (316) tag_item ::= column_name AS column_alias */ + 0, /* (317) db_kind_opt ::= */ + -1, /* (318) db_kind_opt ::= USER */ + -1, /* (319) db_kind_opt ::= SYSTEM */ + -8, /* (320) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ + -9, /* (321) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ + -4, /* (322) cmd ::= DROP INDEX exists_opt full_index_name */ + -1, /* (323) full_index_name ::= index_name */ + -3, /* (324) full_index_name ::= db_name NK_DOT index_name */ + -10, /* (325) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + -12, /* (326) 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 */ + -1, /* (327) func_list ::= func */ + -3, /* (328) func_list ::= func_list NK_COMMA func */ + -4, /* (329) func ::= sma_func_name NK_LP expression_list NK_RP */ + -1, /* (330) sma_func_name ::= function_name */ + -1, /* (331) sma_func_name ::= COUNT */ + -1, /* (332) sma_func_name ::= FIRST */ + -1, /* (333) sma_func_name ::= LAST */ + -1, /* (334) sma_func_name ::= LAST_ROW */ + 0, /* (335) sma_stream_opt ::= */ + -3, /* (336) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + -3, /* (337) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + -3, /* (338) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + -1, /* (339) with_meta ::= AS */ + -3, /* (340) with_meta ::= WITH META AS */ + -3, /* (341) with_meta ::= ONLY META AS */ + -6, /* (342) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + -7, /* (343) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ + -8, /* (344) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ + -4, /* (345) cmd ::= DROP TOPIC exists_opt topic_name */ + -7, /* (346) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + -2, /* (347) cmd ::= DESC full_table_name */ + -2, /* (348) cmd ::= DESCRIBE full_table_name */ + -3, /* (349) cmd ::= RESET QUERY CACHE */ + -4, /* (350) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + -4, /* (351) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ + 0, /* (352) analyze_opt ::= */ + -1, /* (353) analyze_opt ::= ANALYZE */ + 0, /* (354) explain_options ::= */ + -3, /* (355) explain_options ::= explain_options VERBOSE NK_BOOL */ + -3, /* (356) explain_options ::= explain_options RATIO NK_FLOAT */ + -12, /* (357) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ + -4, /* (358) cmd ::= DROP FUNCTION exists_opt function_name */ + 0, /* (359) agg_func_opt ::= */ + -1, /* (360) agg_func_opt ::= AGGREGATE */ + 0, /* (361) bufsize_opt ::= */ + -2, /* (362) bufsize_opt ::= BUFSIZE NK_INTEGER */ + 0, /* (363) language_opt ::= */ + -2, /* (364) language_opt ::= LANGUAGE NK_STRING */ + 0, /* (365) or_replace_opt ::= */ + -2, /* (366) or_replace_opt ::= OR REPLACE */ + -6, /* (367) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ + -4, /* (368) cmd ::= DROP VIEW exists_opt full_view_name */ + -1, /* (369) full_view_name ::= view_name */ + -3, /* (370) full_view_name ::= db_name NK_DOT view_name */ + -12, /* (371) 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 */ + -4, /* (372) cmd ::= DROP STREAM exists_opt stream_name */ + -4, /* (373) cmd ::= PAUSE STREAM exists_opt stream_name */ + -5, /* (374) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ + 0, /* (375) col_list_opt ::= */ + -3, /* (376) col_list_opt ::= NK_LP column_stream_def_list NK_RP */ + -1, /* (377) column_stream_def_list ::= column_stream_def */ + -3, /* (378) column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ + -1, /* (379) column_stream_def ::= column_name */ + -3, /* (380) column_stream_def ::= column_name PRIMARY KEY */ + 0, /* (381) tag_def_or_ref_opt ::= */ + -1, /* (382) tag_def_or_ref_opt ::= tags_def */ + -4, /* (383) tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ + 0, /* (384) stream_options ::= */ + -3, /* (385) stream_options ::= stream_options TRIGGER AT_ONCE */ + -3, /* (386) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + -4, /* (387) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + -3, /* (388) stream_options ::= stream_options WATERMARK duration_literal */ + -4, /* (389) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + -3, /* (390) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + -3, /* (391) stream_options ::= stream_options DELETE_MARK duration_literal */ + -4, /* (392) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + 0, /* (393) subtable_opt ::= */ + -4, /* (394) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + 0, /* (395) ignore_opt ::= */ + -2, /* (396) ignore_opt ::= IGNORE UNTREATED */ + -3, /* (397) cmd ::= KILL CONNECTION NK_INTEGER */ + -3, /* (398) cmd ::= KILL QUERY NK_STRING */ + -3, /* (399) cmd ::= KILL TRANSACTION NK_INTEGER */ + -3, /* (400) cmd ::= KILL COMPACT NK_INTEGER */ + -2, /* (401) cmd ::= BALANCE VGROUP */ + -4, /* (402) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ + -4, /* (403) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + -4, /* (404) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + -3, /* (405) cmd ::= SPLIT VGROUP NK_INTEGER */ + 0, /* (406) on_vgroup_id ::= */ + -2, /* (407) on_vgroup_id ::= ON NK_INTEGER */ + -2, /* (408) dnode_list ::= DNODE NK_INTEGER */ + -3, /* (409) dnode_list ::= dnode_list DNODE NK_INTEGER */ + -4, /* (410) cmd ::= DELETE FROM full_table_name where_clause_opt */ + -1, /* (411) cmd ::= query_or_subquery */ + -1, /* (412) cmd ::= insert_query */ + -7, /* (413) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + -4, /* (414) insert_query ::= INSERT INTO full_table_name query_or_subquery */ + -1, /* (415) tags_literal ::= NK_INTEGER */ + -2, /* (416) tags_literal ::= NK_PLUS NK_INTEGER */ + -2, /* (417) tags_literal ::= NK_MINUS NK_INTEGER */ + -1, /* (418) tags_literal ::= NK_FLOAT */ + -2, /* (419) tags_literal ::= NK_PLUS NK_FLOAT */ + -2, /* (420) tags_literal ::= NK_MINUS NK_FLOAT */ + -1, /* (421) tags_literal ::= NK_BIN */ + -2, /* (422) tags_literal ::= NK_PLUS NK_BIN */ + -2, /* (423) tags_literal ::= NK_MINUS NK_BIN */ + -1, /* (424) tags_literal ::= NK_HEX */ + -2, /* (425) tags_literal ::= NK_PLUS NK_HEX */ + -2, /* (426) tags_literal ::= NK_MINUS NK_HEX */ + -1, /* (427) tags_literal ::= NK_STRING */ + -1, /* (428) tags_literal ::= NK_BOOL */ + -1, /* (429) tags_literal ::= NULL */ + -1, /* (430) tags_literal ::= literal_func */ + -3, /* (431) tags_literal ::= literal_func NK_PLUS duration_literal */ + -3, /* (432) tags_literal ::= literal_func NK_MINUS duration_literal */ + -1, /* (433) tags_literal_list ::= tags_literal */ + -3, /* (434) tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ + -1, /* (435) literal ::= NK_INTEGER */ + -1, /* (436) literal ::= NK_FLOAT */ + -1, /* (437) literal ::= NK_STRING */ + -1, /* (438) literal ::= NK_BOOL */ + -2, /* (439) literal ::= TIMESTAMP NK_STRING */ + -1, /* (440) literal ::= duration_literal */ + -1, /* (441) literal ::= NULL */ + -1, /* (442) literal ::= NK_QUESTION */ + -1, /* (443) duration_literal ::= NK_VARIABLE */ + -1, /* (444) signed ::= NK_INTEGER */ + -2, /* (445) signed ::= NK_PLUS NK_INTEGER */ + -2, /* (446) signed ::= NK_MINUS NK_INTEGER */ + -1, /* (447) signed ::= NK_FLOAT */ + -2, /* (448) signed ::= NK_PLUS NK_FLOAT */ + -2, /* (449) signed ::= NK_MINUS NK_FLOAT */ + -1, /* (450) signed_literal ::= signed */ + -1, /* (451) signed_literal ::= NK_STRING */ + -1, /* (452) signed_literal ::= NK_BOOL */ + -2, /* (453) signed_literal ::= TIMESTAMP NK_STRING */ + -1, /* (454) signed_literal ::= duration_literal */ + -1, /* (455) signed_literal ::= NULL */ + -1, /* (456) signed_literal ::= literal_func */ + -1, /* (457) signed_literal ::= NK_QUESTION */ + -1, /* (458) literal_list ::= signed_literal */ + -3, /* (459) literal_list ::= literal_list NK_COMMA signed_literal */ + -1, /* (460) db_name ::= NK_ID */ + -1, /* (461) table_name ::= NK_ID */ + -1, /* (462) column_name ::= NK_ID */ + -1, /* (463) function_name ::= NK_ID */ + -1, /* (464) view_name ::= NK_ID */ + -1, /* (465) table_alias ::= NK_ID */ + -1, /* (466) column_alias ::= NK_ID */ + -1, /* (467) column_alias ::= NK_ALIAS */ + -1, /* (468) user_name ::= NK_ID */ + -1, /* (469) topic_name ::= NK_ID */ + -1, /* (470) stream_name ::= NK_ID */ + -1, /* (471) cgroup_name ::= NK_ID */ + -1, /* (472) index_name ::= NK_ID */ + -1, /* (473) expr_or_subquery ::= expression */ + -1, /* (474) expression ::= literal */ + -1, /* (475) expression ::= pseudo_column */ + -1, /* (476) expression ::= column_reference */ + -1, /* (477) expression ::= function_expression */ + -1, /* (478) expression ::= case_when_expression */ + -3, /* (479) expression ::= NK_LP expression NK_RP */ + -2, /* (480) expression ::= NK_PLUS expr_or_subquery */ + -2, /* (481) expression ::= NK_MINUS expr_or_subquery */ + -3, /* (482) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + -3, /* (483) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + -3, /* (484) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + -3, /* (485) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + -3, /* (486) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + -3, /* (487) expression ::= column_reference NK_ARROW NK_STRING */ + -3, /* (488) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + -3, /* (489) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + -1, /* (490) expression_list ::= expr_or_subquery */ + -3, /* (491) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + -1, /* (492) column_reference ::= column_name */ + -3, /* (493) column_reference ::= table_name NK_DOT column_name */ + -1, /* (494) column_reference ::= NK_ALIAS */ + -3, /* (495) column_reference ::= table_name NK_DOT NK_ALIAS */ + -1, /* (496) pseudo_column ::= ROWTS */ + -1, /* (497) pseudo_column ::= TBNAME */ + -3, /* (498) pseudo_column ::= table_name NK_DOT TBNAME */ + -1, /* (499) pseudo_column ::= QSTART */ + -1, /* (500) pseudo_column ::= QEND */ + -1, /* (501) pseudo_column ::= QDURATION */ + -1, /* (502) pseudo_column ::= WSTART */ + -1, /* (503) pseudo_column ::= WEND */ + -1, /* (504) pseudo_column ::= WDURATION */ + -1, /* (505) pseudo_column ::= IROWTS */ + -1, /* (506) pseudo_column ::= ISFILLED */ + -1, /* (507) pseudo_column ::= QTAGS */ + -4, /* (508) function_expression ::= function_name NK_LP expression_list NK_RP */ + -4, /* (509) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + -6, /* (510) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + -1, /* (511) function_expression ::= literal_func */ + -3, /* (512) literal_func ::= noarg_func NK_LP NK_RP */ + -1, /* (513) literal_func ::= NOW */ + -1, /* (514) literal_func ::= TODAY */ + -1, /* (515) noarg_func ::= NOW */ + -1, /* (516) noarg_func ::= TODAY */ + -1, /* (517) noarg_func ::= TIMEZONE */ + -1, /* (518) noarg_func ::= DATABASE */ + -1, /* (519) noarg_func ::= CLIENT_VERSION */ + -1, /* (520) noarg_func ::= SERVER_VERSION */ + -1, /* (521) noarg_func ::= SERVER_STATUS */ + -1, /* (522) noarg_func ::= CURRENT_USER */ + -1, /* (523) noarg_func ::= USER */ + -1, /* (524) star_func ::= COUNT */ + -1, /* (525) star_func ::= FIRST */ + -1, /* (526) star_func ::= LAST */ + -1, /* (527) star_func ::= LAST_ROW */ + -1, /* (528) star_func_para_list ::= NK_STAR */ + -1, /* (529) star_func_para_list ::= other_para_list */ + -1, /* (530) other_para_list ::= star_func_para */ + -3, /* (531) other_para_list ::= other_para_list NK_COMMA star_func_para */ + -1, /* (532) star_func_para ::= expr_or_subquery */ + -3, /* (533) star_func_para ::= table_name NK_DOT NK_STAR */ + -4, /* (534) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + -5, /* (535) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + -1, /* (536) when_then_list ::= when_then_expr */ + -2, /* (537) when_then_list ::= when_then_list when_then_expr */ + -4, /* (538) when_then_expr ::= WHEN common_expression THEN common_expression */ + 0, /* (539) case_when_else_opt ::= */ + -2, /* (540) case_when_else_opt ::= ELSE common_expression */ + -3, /* (541) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + -5, /* (542) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + -6, /* (543) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + -3, /* (544) predicate ::= expr_or_subquery IS NULL */ + -4, /* (545) predicate ::= expr_or_subquery IS NOT NULL */ + -3, /* (546) predicate ::= expr_or_subquery in_op in_predicate_value */ + -1, /* (547) compare_op ::= NK_LT */ + -1, /* (548) compare_op ::= NK_GT */ + -1, /* (549) compare_op ::= NK_LE */ + -1, /* (550) compare_op ::= NK_GE */ + -1, /* (551) compare_op ::= NK_NE */ + -1, /* (552) compare_op ::= NK_EQ */ + -1, /* (553) compare_op ::= LIKE */ + -2, /* (554) compare_op ::= NOT LIKE */ + -1, /* (555) compare_op ::= MATCH */ + -1, /* (556) compare_op ::= NMATCH */ + -1, /* (557) compare_op ::= CONTAINS */ + -1, /* (558) in_op ::= IN */ + -2, /* (559) in_op ::= NOT IN */ + -3, /* (560) in_predicate_value ::= NK_LP literal_list NK_RP */ + -1, /* (561) boolean_value_expression ::= boolean_primary */ + -2, /* (562) boolean_value_expression ::= NOT boolean_primary */ + -3, /* (563) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + -3, /* (564) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + -1, /* (565) boolean_primary ::= predicate */ + -3, /* (566) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + -1, /* (567) common_expression ::= expr_or_subquery */ + -1, /* (568) common_expression ::= boolean_value_expression */ + 0, /* (569) from_clause_opt ::= */ + -2, /* (570) from_clause_opt ::= FROM table_reference_list */ + -1, /* (571) table_reference_list ::= table_reference */ + -3, /* (572) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + -1, /* (573) table_reference ::= table_primary */ + -1, /* (574) table_reference ::= joined_table */ + -2, /* (575) table_primary ::= table_name alias_opt */ + -4, /* (576) table_primary ::= db_name NK_DOT table_name alias_opt */ + -2, /* (577) table_primary ::= subquery alias_opt */ + -1, /* (578) table_primary ::= parenthesized_joined_table */ + 0, /* (579) alias_opt ::= */ + -1, /* (580) alias_opt ::= table_alias */ + -2, /* (581) alias_opt ::= AS table_alias */ + -3, /* (582) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + -3, /* (583) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + -6, /* (584) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + 0, /* (585) join_type ::= */ + -1, /* (586) join_type ::= INNER */ + -14, /* (587) 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 */ + 0, /* (588) hint_list ::= */ + -1, /* (589) hint_list ::= NK_HINT */ + 0, /* (590) tag_mode_opt ::= */ + -1, /* (591) tag_mode_opt ::= TAGS */ + 0, /* (592) set_quantifier_opt ::= */ + -1, /* (593) set_quantifier_opt ::= DISTINCT */ + -1, /* (594) set_quantifier_opt ::= ALL */ + -1, /* (595) select_list ::= select_item */ + -3, /* (596) select_list ::= select_list NK_COMMA select_item */ + -1, /* (597) select_item ::= NK_STAR */ + -1, /* (598) select_item ::= common_expression */ + -2, /* (599) select_item ::= common_expression column_alias */ + -3, /* (600) select_item ::= common_expression AS column_alias */ + -3, /* (601) select_item ::= table_name NK_DOT NK_STAR */ + 0, /* (602) where_clause_opt ::= */ + -2, /* (603) where_clause_opt ::= WHERE search_condition */ + 0, /* (604) partition_by_clause_opt ::= */ + -3, /* (605) partition_by_clause_opt ::= PARTITION BY partition_list */ + -1, /* (606) partition_list ::= partition_item */ + -3, /* (607) partition_list ::= partition_list NK_COMMA partition_item */ + -1, /* (608) partition_item ::= expr_or_subquery */ + -2, /* (609) partition_item ::= expr_or_subquery column_alias */ + -3, /* (610) partition_item ::= expr_or_subquery AS column_alias */ + 0, /* (611) twindow_clause_opt ::= */ + -6, /* (612) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ + -4, /* (613) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + -6, /* (614) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + -8, /* (615) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + -7, /* (616) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ + -4, /* (617) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ + -6, /* (618) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 0, /* (619) sliding_opt ::= */ + -4, /* (620) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ + -1, /* (621) interval_sliding_duration_literal ::= NK_VARIABLE */ + -1, /* (622) interval_sliding_duration_literal ::= NK_STRING */ + -1, /* (623) interval_sliding_duration_literal ::= NK_INTEGER */ + 0, /* (624) fill_opt ::= */ + -4, /* (625) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + -6, /* (626) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ + -6, /* (627) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ + -1, /* (628) fill_mode ::= NONE */ + -1, /* (629) fill_mode ::= PREV */ + -1, /* (630) fill_mode ::= NULL */ + -1, /* (631) fill_mode ::= NULL_F */ + -1, /* (632) fill_mode ::= LINEAR */ + -1, /* (633) fill_mode ::= NEXT */ + 0, /* (634) group_by_clause_opt ::= */ + -3, /* (635) group_by_clause_opt ::= GROUP BY group_by_list */ + -1, /* (636) group_by_list ::= expr_or_subquery */ + -3, /* (637) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + 0, /* (638) having_clause_opt ::= */ + -2, /* (639) having_clause_opt ::= HAVING search_condition */ + 0, /* (640) range_opt ::= */ + -6, /* (641) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + -4, /* (642) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ + 0, /* (643) every_opt ::= */ + -4, /* (644) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + -4, /* (645) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + -1, /* (646) query_simple ::= query_specification */ + -1, /* (647) query_simple ::= union_query_expression */ + -4, /* (648) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + -3, /* (649) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + -1, /* (650) query_simple_or_subquery ::= query_simple */ + -1, /* (651) query_simple_or_subquery ::= subquery */ + -1, /* (652) query_or_subquery ::= query_expression */ + -1, /* (653) query_or_subquery ::= subquery */ + 0, /* (654) order_by_clause_opt ::= */ + -3, /* (655) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 0, /* (656) slimit_clause_opt ::= */ + -2, /* (657) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + -4, /* (658) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + -4, /* (659) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 0, /* (660) limit_clause_opt ::= */ + -2, /* (661) limit_clause_opt ::= LIMIT NK_INTEGER */ + -4, /* (662) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + -4, /* (663) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + -3, /* (664) subquery ::= NK_LP query_expression NK_RP */ + -3, /* (665) subquery ::= NK_LP subquery NK_RP */ + -1, /* (666) search_condition ::= common_expression */ + -1, /* (667) sort_specification_list ::= sort_specification */ + -3, /* (668) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + -3, /* (669) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + 0, /* (670) ordering_specification_opt ::= */ + -1, /* (671) ordering_specification_opt ::= ASC */ + -1, /* (672) ordering_specification_opt ::= DESC */ + 0, /* (673) null_ordering_opt ::= */ + -2, /* (674) null_ordering_opt ::= NULLS FIRST */ + -2, /* (675) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -5103,11 +5166,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,353,&yymsp[0].minor); + yy_destructor(yypParser,356,&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,354,&yymsp[0].minor); + yy_destructor(yypParser,357,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -5121,20 +5184,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,353,&yymsp[-2].minor); +{ yy_destructor(yypParser,356,&yymsp[-2].minor); { } - yy_destructor(yypParser,355,&yymsp[0].minor); + yy_destructor(yypParser,358,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,356,&yymsp[0].minor); +{ yy_destructor(yypParser,359,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,354,&yymsp[-1].minor); +{ yy_destructor(yypParser,357,&yymsp[-1].minor); { } - yy_destructor(yypParser,356,&yymsp[0].minor); + yy_destructor(yypParser,359,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -5148,154 +5211,154 @@ 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,355,&yymsp[0].minor); + yy_destructor(yypParser,358,&yymsp[0].minor); break; case 24: /* ip_range_list ::= NK_STRING */ -{ yylhsminor.yy264 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy264 = yylhsminor.yy264; +{ yylhsminor.yy184 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy184 = yylhsminor.yy184; break; case 25: /* ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ -{ yylhsminor.yy264 = addNodeToList(pCxt, yymsp[-2].minor.yy264, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy264 = yylhsminor.yy264; +{ yylhsminor.yy184 = addNodeToList(pCxt, yymsp[-2].minor.yy184, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy184 = yylhsminor.yy184; break; case 26: /* white_list ::= HOST ip_range_list */ -{ yymsp[-1].minor.yy264 = yymsp[0].minor.yy264; } +{ yymsp[-1].minor.yy184 = yymsp[0].minor.yy184; } break; case 27: /* white_list_opt ::= */ case 188: /* specific_cols_opt ::= */ yytestcase(yyruleno==188); case 220: /* tags_def_opt ::= */ yytestcase(yyruleno==220); - case 308: /* tag_list_opt ::= */ yytestcase(yyruleno==308); - case 374: /* col_list_opt ::= */ yytestcase(yyruleno==374); - case 380: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==380); - case 582: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==582); - case 612: /* group_by_clause_opt ::= */ yytestcase(yyruleno==612); - case 632: /* order_by_clause_opt ::= */ yytestcase(yyruleno==632); -{ yymsp[1].minor.yy264 = NULL; } + case 309: /* tag_list_opt ::= */ yytestcase(yyruleno==309); + case 375: /* col_list_opt ::= */ yytestcase(yyruleno==375); + case 381: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==381); + case 604: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==604); + case 634: /* group_by_clause_opt ::= */ yytestcase(yyruleno==634); + case 654: /* order_by_clause_opt ::= */ yytestcase(yyruleno==654); +{ yymsp[1].minor.yy184 = NULL; } break; case 28: /* white_list_opt ::= white_list */ case 221: /* tags_def_opt ::= tags_def */ yytestcase(yyruleno==221); - case 381: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==381); - case 507: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==507); -{ yylhsminor.yy264 = yymsp[0].minor.yy264; } - yymsp[0].minor.yy264 = yylhsminor.yy264; + case 382: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==382); + case 529: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==529); +{ yylhsminor.yy184 = yymsp[0].minor.yy184; } + yymsp[0].minor.yy184 = yylhsminor.yy184; break; case 29: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ { - pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-4].minor.yy879, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy983); - pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy264); + pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-4].minor.yy369, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy743); + pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy184); } break; case 30: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy879, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy369, 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.yy879, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy369, 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.yy879, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy369, 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.yy879, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy264); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy369, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy184); } break; case 34: /* cmd ::= ALTER USER user_name DROP white_list */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy879, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy264); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy369, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy184); } break; case 35: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy879); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy369); } break; case 36: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy983 = 1; } +{ yymsp[1].minor.yy743 = 1; } break; case 37: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy983 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy743 = 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.yy89, &yymsp[-3].minor.yy357, &yymsp[0].minor.yy879, yymsp[-2].minor.yy752); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy909, &yymsp[-3].minor.yy937, &yymsp[0].minor.yy369, yymsp[-2].minor.yy392); } break; case 39: /* cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy89, &yymsp[-3].minor.yy357, &yymsp[0].minor.yy879, yymsp[-2].minor.yy752); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy909, &yymsp[-3].minor.yy937, &yymsp[0].minor.yy369, yymsp[-2].minor.yy392); } break; case 40: /* privileges ::= ALL */ -{ yymsp[0].minor.yy89 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy909 = PRIVILEGE_TYPE_ALL; } break; case 41: /* privileges ::= priv_type_list */ case 43: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==43); -{ yylhsminor.yy89 = yymsp[0].minor.yy89; } - yymsp[0].minor.yy89 = yylhsminor.yy89; +{ yylhsminor.yy909 = yymsp[0].minor.yy909; } + yymsp[0].minor.yy909 = yylhsminor.yy909; break; case 42: /* privileges ::= SUBSCRIBE */ -{ yymsp[0].minor.yy89 = PRIVILEGE_TYPE_SUBSCRIBE; } +{ yymsp[0].minor.yy909 = PRIVILEGE_TYPE_SUBSCRIBE; } break; case 44: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy89 = yymsp[-2].minor.yy89 | yymsp[0].minor.yy89; } - yymsp[-2].minor.yy89 = yylhsminor.yy89; +{ yylhsminor.yy909 = yymsp[-2].minor.yy909 | yymsp[0].minor.yy909; } + yymsp[-2].minor.yy909 = yylhsminor.yy909; break; case 45: /* priv_type ::= READ */ -{ yymsp[0].minor.yy89 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy909 = PRIVILEGE_TYPE_READ; } break; case 46: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy89 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy909 = PRIVILEGE_TYPE_WRITE; } break; case 47: /* priv_type ::= ALTER */ -{ yymsp[0].minor.yy89 = PRIVILEGE_TYPE_ALTER; } +{ yymsp[0].minor.yy909 = PRIVILEGE_TYPE_ALTER; } break; case 48: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy357.first = yymsp[-2].minor.yy0; yylhsminor.yy357.second = yymsp[0].minor.yy0; } - yymsp[-2].minor.yy357 = yylhsminor.yy357; +{ yylhsminor.yy937.first = yymsp[-2].minor.yy0; yylhsminor.yy937.second = yymsp[0].minor.yy0; } + yymsp[-2].minor.yy937 = yylhsminor.yy937; break; case 49: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy357.first = yymsp[-2].minor.yy879; yylhsminor.yy357.second = yymsp[0].minor.yy0; } - yymsp[-2].minor.yy357 = yylhsminor.yy357; +{ yylhsminor.yy937.first = yymsp[-2].minor.yy369; yylhsminor.yy937.second = yymsp[0].minor.yy0; } + yymsp[-2].minor.yy937 = yylhsminor.yy937; break; case 50: /* priv_level ::= db_name NK_DOT table_name */ -{ yylhsminor.yy357.first = yymsp[-2].minor.yy879; yylhsminor.yy357.second = yymsp[0].minor.yy879; } - yymsp[-2].minor.yy357 = yylhsminor.yy357; +{ yylhsminor.yy937.first = yymsp[-2].minor.yy369; yylhsminor.yy937.second = yymsp[0].minor.yy369; } + yymsp[-2].minor.yy937 = yylhsminor.yy937; break; case 51: /* priv_level ::= topic_name */ -{ yylhsminor.yy357.first = yymsp[0].minor.yy879; yylhsminor.yy357.second = nil_token; } - yymsp[0].minor.yy357 = yylhsminor.yy357; +{ yylhsminor.yy937.first = yymsp[0].minor.yy369; yylhsminor.yy937.second = nil_token; } + yymsp[0].minor.yy937 = yylhsminor.yy937; break; case 52: /* with_opt ::= */ case 157: /* start_opt ::= */ yytestcase(yyruleno==157); case 161: /* end_opt ::= */ yytestcase(yyruleno==161); - case 303: /* like_pattern_opt ::= */ yytestcase(yyruleno==303); - case 392: /* subtable_opt ::= */ yytestcase(yyruleno==392); - case 517: /* case_when_else_opt ::= */ yytestcase(yyruleno==517); - case 547: /* from_clause_opt ::= */ yytestcase(yyruleno==547); - case 580: /* where_clause_opt ::= */ yytestcase(yyruleno==580); - case 589: /* twindow_clause_opt ::= */ yytestcase(yyruleno==589); - case 597: /* sliding_opt ::= */ yytestcase(yyruleno==597); - case 602: /* fill_opt ::= */ yytestcase(yyruleno==602); - case 616: /* having_clause_opt ::= */ yytestcase(yyruleno==616); - case 618: /* range_opt ::= */ yytestcase(yyruleno==618); - case 621: /* every_opt ::= */ yytestcase(yyruleno==621); - case 634: /* slimit_clause_opt ::= */ yytestcase(yyruleno==634); - case 638: /* limit_clause_opt ::= */ yytestcase(yyruleno==638); -{ yymsp[1].minor.yy752 = NULL; } + case 304: /* like_pattern_opt ::= */ yytestcase(yyruleno==304); + case 393: /* subtable_opt ::= */ yytestcase(yyruleno==393); + case 539: /* case_when_else_opt ::= */ yytestcase(yyruleno==539); + case 569: /* from_clause_opt ::= */ yytestcase(yyruleno==569); + case 602: /* where_clause_opt ::= */ yytestcase(yyruleno==602); + case 611: /* twindow_clause_opt ::= */ yytestcase(yyruleno==611); + case 619: /* sliding_opt ::= */ yytestcase(yyruleno==619); + case 624: /* fill_opt ::= */ yytestcase(yyruleno==624); + case 638: /* having_clause_opt ::= */ yytestcase(yyruleno==638); + case 640: /* range_opt ::= */ yytestcase(yyruleno==640); + case 643: /* every_opt ::= */ yytestcase(yyruleno==643); + case 656: /* slimit_clause_opt ::= */ yytestcase(yyruleno==656); + case 660: /* limit_clause_opt ::= */ yytestcase(yyruleno==660); +{ yymsp[1].minor.yy392 = NULL; } break; case 53: /* with_opt ::= WITH search_condition */ - case 548: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==548); - case 581: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==581); - case 617: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==617); -{ yymsp[-1].minor.yy752 = yymsp[0].minor.yy752; } + case 570: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==570); + case 603: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==603); + case 639: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==639); +{ yymsp[-1].minor.yy392 = yymsp[0].minor.yy392; } break; case 54: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy879, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy369, NULL); } break; case 55: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy879, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy369, &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.yy547, false); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy377, false); } break; case 57: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy879, yymsp[0].minor.yy547, false); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy369, yymsp[0].minor.yy377, false); } break; case 58: /* cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy547); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy377); } break; case 59: /* cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy879, false, yymsp[0].minor.yy547); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy369, false, yymsp[0].minor.yy377); } break; case 60: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -5315,57 +5378,57 @@ static YYACTIONTYPE yy_reduce( case 65: /* dnode_endpoint ::= NK_STRING */ case 66: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==66); case 67: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==67); - case 330: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==330); - case 331: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==331); - case 332: /* sma_func_name ::= LAST */ yytestcase(yyruleno==332); - case 333: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==333); - case 439: /* db_name ::= NK_ID */ yytestcase(yyruleno==439); - case 440: /* table_name ::= NK_ID */ yytestcase(yyruleno==440); - case 441: /* column_name ::= NK_ID */ yytestcase(yyruleno==441); - case 442: /* function_name ::= NK_ID */ yytestcase(yyruleno==442); - case 443: /* view_name ::= NK_ID */ yytestcase(yyruleno==443); - case 444: /* table_alias ::= NK_ID */ yytestcase(yyruleno==444); - case 445: /* column_alias ::= NK_ID */ yytestcase(yyruleno==445); - case 446: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==446); - case 447: /* user_name ::= NK_ID */ yytestcase(yyruleno==447); - case 448: /* topic_name ::= NK_ID */ yytestcase(yyruleno==448); - case 449: /* stream_name ::= NK_ID */ yytestcase(yyruleno==449); - case 450: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==450); - case 451: /* index_name ::= NK_ID */ yytestcase(yyruleno==451); - case 493: /* noarg_func ::= NOW */ yytestcase(yyruleno==493); - case 494: /* noarg_func ::= TODAY */ yytestcase(yyruleno==494); - case 495: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==495); - case 496: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==496); - case 497: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==497); - case 498: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==498); - case 499: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==499); - case 500: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==500); - case 501: /* noarg_func ::= USER */ yytestcase(yyruleno==501); - case 502: /* star_func ::= COUNT */ yytestcase(yyruleno==502); - case 503: /* star_func ::= FIRST */ yytestcase(yyruleno==503); - case 504: /* star_func ::= LAST */ yytestcase(yyruleno==504); - case 505: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==505); -{ yylhsminor.yy879 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy879 = yylhsminor.yy879; + case 331: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==331); + case 332: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==332); + case 333: /* sma_func_name ::= LAST */ yytestcase(yyruleno==333); + case 334: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==334); + case 460: /* db_name ::= NK_ID */ yytestcase(yyruleno==460); + case 461: /* table_name ::= NK_ID */ yytestcase(yyruleno==461); + case 462: /* column_name ::= NK_ID */ yytestcase(yyruleno==462); + case 463: /* function_name ::= NK_ID */ yytestcase(yyruleno==463); + case 464: /* view_name ::= NK_ID */ yytestcase(yyruleno==464); + case 465: /* table_alias ::= NK_ID */ yytestcase(yyruleno==465); + case 466: /* column_alias ::= NK_ID */ yytestcase(yyruleno==466); + case 467: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==467); + case 468: /* user_name ::= NK_ID */ yytestcase(yyruleno==468); + case 469: /* topic_name ::= NK_ID */ yytestcase(yyruleno==469); + case 470: /* stream_name ::= NK_ID */ yytestcase(yyruleno==470); + case 471: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==471); + case 472: /* index_name ::= NK_ID */ yytestcase(yyruleno==472); + case 515: /* noarg_func ::= NOW */ yytestcase(yyruleno==515); + case 516: /* noarg_func ::= TODAY */ yytestcase(yyruleno==516); + case 517: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==517); + case 518: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==518); + case 519: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==519); + case 520: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==520); + case 521: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==521); + case 522: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==522); + case 523: /* noarg_func ::= USER */ yytestcase(yyruleno==523); + case 524: /* star_func ::= COUNT */ yytestcase(yyruleno==524); + case 525: /* star_func ::= FIRST */ yytestcase(yyruleno==525); + case 526: /* star_func ::= LAST */ yytestcase(yyruleno==526); + case 527: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==527); +{ yylhsminor.yy369 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy369 = yylhsminor.yy369; break; case 68: /* force_opt ::= */ case 94: /* not_exists_opt ::= */ yytestcase(yyruleno==94); case 96: /* exists_opt ::= */ yytestcase(yyruleno==96); - case 351: /* analyze_opt ::= */ yytestcase(yyruleno==351); - case 358: /* agg_func_opt ::= */ yytestcase(yyruleno==358); - case 364: /* or_replace_opt ::= */ yytestcase(yyruleno==364); - case 394: /* ignore_opt ::= */ yytestcase(yyruleno==394); - case 568: /* tag_mode_opt ::= */ yytestcase(yyruleno==568); - case 570: /* set_quantifier_opt ::= */ yytestcase(yyruleno==570); -{ yymsp[1].minor.yy547 = false; } + case 352: /* analyze_opt ::= */ yytestcase(yyruleno==352); + case 359: /* agg_func_opt ::= */ yytestcase(yyruleno==359); + case 365: /* or_replace_opt ::= */ yytestcase(yyruleno==365); + case 395: /* ignore_opt ::= */ yytestcase(yyruleno==395); + case 590: /* tag_mode_opt ::= */ yytestcase(yyruleno==590); + case 592: /* set_quantifier_opt ::= */ yytestcase(yyruleno==592); +{ yymsp[1].minor.yy377 = false; } break; case 69: /* force_opt ::= FORCE */ case 70: /* unsafe_opt ::= UNSAFE */ yytestcase(yyruleno==70); - case 352: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==352); - case 359: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==359); - case 569: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==569); - case 571: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==571); -{ yymsp[0].minor.yy547 = true; } + case 353: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==353); + case 360: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==360); + case 591: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==591); + case 593: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==593); +{ yymsp[0].minor.yy377 = true; } break; case 71: /* cmd ::= ALTER CLUSTER NK_STRING */ { pCxt->pRootNode = createAlterClusterStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -5413,241 +5476,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.yy547, &yymsp[-1].minor.yy879, yymsp[0].minor.yy752); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy377, &yymsp[-1].minor.yy369, yymsp[0].minor.yy392); } break; case 87: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy547, &yymsp[0].minor.yy879); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy377, &yymsp[0].minor.yy369); } break; case 88: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy879); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy369); } break; case 89: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy879, yymsp[0].minor.yy752); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy369, yymsp[0].minor.yy392); } break; case 90: /* cmd ::= FLUSH DATABASE db_name */ -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy879); } +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy369); } break; case 91: /* cmd ::= TRIM DATABASE db_name speed_opt */ -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy879, yymsp[0].minor.yy10); } +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy369, yymsp[0].minor.yy20); } break; case 92: /* cmd ::= COMPACT DATABASE db_name start_opt end_opt */ -{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy879, yymsp[-1].minor.yy752, yymsp[0].minor.yy752); } +{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy369, yymsp[-1].minor.yy392, yymsp[0].minor.yy392); } break; case 93: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy547 = true; } +{ yymsp[-2].minor.yy377 = true; } break; case 95: /* exists_opt ::= IF EXISTS */ - case 365: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==365); - case 395: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==395); -{ yymsp[-1].minor.yy547 = true; } + case 366: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==366); + case 396: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==396); +{ yymsp[-1].minor.yy377 = true; } break; case 97: /* db_options ::= */ -{ yymsp[1].minor.yy752 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy392 = createDefaultDatabaseOptions(pCxt); } break; case 98: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 99: /* db_options ::= db_options CACHEMODEL NK_STRING */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 100: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 101: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 102: /* db_options ::= db_options DURATION NK_INTEGER */ case 103: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==103); -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 104: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 105: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 106: /* db_options ::= db_options KEEP integer_list */ case 107: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==107); -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_KEEP, yymsp[0].minor.yy264); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_KEEP, yymsp[0].minor.yy184); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 108: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 109: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 110: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 111: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 112: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 113: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 114: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 115: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_RETENTIONS, yymsp[0].minor.yy264); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_RETENTIONS, yymsp[0].minor.yy184); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 116: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 117: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 118: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 119: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; 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.yy752 = setDatabaseOption(pCxt, yymsp[-3].minor.yy752, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-3].minor.yy392, DB_OPTION_WAL_RETENTION_PERIOD, &t); } - yymsp[-3].minor.yy752 = yylhsminor.yy752; + yymsp[-3].minor.yy392 = yylhsminor.yy392; break; case 121: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; 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.yy752 = setDatabaseOption(pCxt, yymsp[-3].minor.yy752, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-3].minor.yy392, DB_OPTION_WAL_RETENTION_SIZE, &t); } - yymsp[-3].minor.yy752 = yylhsminor.yy752; + yymsp[-3].minor.yy392 = yylhsminor.yy392; break; case 123: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 124: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 125: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 126: /* db_options ::= db_options TABLE_PREFIX signed */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy752); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy392); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 127: /* db_options ::= db_options TABLE_SUFFIX signed */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy752); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy392); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 128: /* db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ -{ yylhsminor.yy752 = setDatabaseOption(pCxt, yymsp[-2].minor.yy752, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 129: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy752 = createAlterDatabaseOptions(pCxt); yylhsminor.yy752 = setAlterDatabaseOption(pCxt, yylhsminor.yy752, &yymsp[0].minor.yy935); } - yymsp[0].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createAlterDatabaseOptions(pCxt); yylhsminor.yy392 = setAlterDatabaseOption(pCxt, yylhsminor.yy392, &yymsp[0].minor.yy845); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; case 130: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy752 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy752, &yymsp[0].minor.yy935); } - yymsp[-1].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy392, &yymsp[0].minor.yy845); } + yymsp[-1].minor.yy392 = yylhsminor.yy392; break; case 131: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy935.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy935.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 132: /* alter_db_option ::= CACHEMODEL NK_STRING */ -{ yymsp[-1].minor.yy935.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy935.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 133: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -{ yymsp[-1].minor.yy935.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy935.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 134: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy935.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy935.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy845.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.yy935.type = DB_OPTION_KEEP; yymsp[-1].minor.yy935.pList = yymsp[0].minor.yy264; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_KEEP; yymsp[-1].minor.yy845.pList = yymsp[0].minor.yy184; } break; case 137: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy935.type = DB_OPTION_PAGES; yymsp[-1].minor.yy935.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_PAGES; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 138: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy935.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy935.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 139: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -{ yymsp[-1].minor.yy935.type = DB_OPTION_WAL; yymsp[-1].minor.yy935.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_WAL; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 140: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ -{ yymsp[-1].minor.yy935.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy935.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 141: /* alter_db_option ::= MINROWS NK_INTEGER */ -{ yymsp[-1].minor.yy935.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy935.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 142: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy935.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy935.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy845.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.yy935.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy935.val = t; + yymsp[-2].minor.yy845.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy845.val = t; } break; case 144: /* alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ -{ yymsp[-1].minor.yy935.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy935.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy845.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.yy935.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy935.val = t; + yymsp[-2].minor.yy845.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy845.val = t; } break; case 146: /* alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ -{ yymsp[-1].minor.yy935.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy935.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 147: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy264 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy264 = yylhsminor.yy264; +{ yylhsminor.yy184 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy184 = yylhsminor.yy184; break; case 148: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 408: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==408); -{ yylhsminor.yy264 = addNodeToList(pCxt, yymsp[-2].minor.yy264, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy264 = yylhsminor.yy264; + case 409: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==409); +{ yylhsminor.yy184 = addNodeToList(pCxt, yymsp[-2].minor.yy184, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy184 = yylhsminor.yy184; break; case 149: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy264 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy264 = yylhsminor.yy264; +{ yylhsminor.yy184 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy184 = yylhsminor.yy184; break; case 150: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy264 = addNodeToList(pCxt, yymsp[-2].minor.yy264, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy264 = yylhsminor.yy264; +{ yylhsminor.yy184 = addNodeToList(pCxt, yymsp[-2].minor.yy184, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy184 = yylhsminor.yy184; break; case 151: /* retention_list ::= retention */ case 182: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==182); @@ -5655,296 +5718,298 @@ static YYACTIONTYPE yy_reduce( case 192: /* column_def_list ::= column_def */ yytestcase(yyruleno==192); case 237: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==237); case 242: /* col_name_list ::= col_name */ yytestcase(yyruleno==242); - case 309: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==309); - case 326: /* func_list ::= func */ yytestcase(yyruleno==326); - case 376: /* column_stream_def_list ::= column_stream_def */ yytestcase(yyruleno==376); - case 437: /* literal_list ::= signed_literal */ yytestcase(yyruleno==437); - case 508: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==508); - case 514: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==514); - case 573: /* select_list ::= select_item */ yytestcase(yyruleno==573); - case 584: /* partition_list ::= partition_item */ yytestcase(yyruleno==584); - case 645: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==645); -{ yylhsminor.yy264 = createNodeList(pCxt, yymsp[0].minor.yy752); } - yymsp[0].minor.yy264 = yylhsminor.yy264; + case 310: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==310); + case 327: /* func_list ::= func */ yytestcase(yyruleno==327); + case 377: /* column_stream_def_list ::= column_stream_def */ yytestcase(yyruleno==377); + case 433: /* tags_literal_list ::= tags_literal */ yytestcase(yyruleno==433); + case 458: /* literal_list ::= signed_literal */ yytestcase(yyruleno==458); + case 530: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==530); + case 536: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==536); + case 595: /* select_list ::= select_item */ yytestcase(yyruleno==595); + case 606: /* partition_list ::= partition_item */ yytestcase(yyruleno==606); + case 667: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==667); +{ yylhsminor.yy184 = createNodeList(pCxt, yymsp[0].minor.yy392); } + yymsp[0].minor.yy184 = yylhsminor.yy184; 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); case 193: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==193); case 238: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==238); case 243: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==243); - case 310: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==310); - case 327: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==327); - case 377: /* column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ yytestcase(yyruleno==377); - case 438: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==438); - case 509: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==509); - case 574: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==574); - case 585: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==585); - case 646: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==646); -{ yylhsminor.yy264 = addNodeToList(pCxt, yymsp[-2].minor.yy264, yymsp[0].minor.yy752); } - yymsp[-2].minor.yy264 = yylhsminor.yy264; + case 311: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==311); + case 328: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==328); + case 378: /* column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ yytestcase(yyruleno==378); + case 434: /* tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ yytestcase(yyruleno==434); + case 459: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==459); + case 531: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==531); + case 596: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==596); + case 607: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==607); + case 668: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==668); +{ yylhsminor.yy184 = addNodeToList(pCxt, yymsp[-2].minor.yy184, yymsp[0].minor.yy392); } + yymsp[-2].minor.yy184 = yylhsminor.yy184; break; case 153: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ case 154: /* retention ::= NK_MINUS NK_COLON NK_VARIABLE */ yytestcase(yyruleno==154); -{ yylhsminor.yy752 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 155: /* speed_opt ::= */ - case 360: /* bufsize_opt ::= */ yytestcase(yyruleno==360); -{ yymsp[1].minor.yy10 = 0; } + case 361: /* bufsize_opt ::= */ yytestcase(yyruleno==361); +{ yymsp[1].minor.yy20 = 0; } break; case 156: /* speed_opt ::= BWLIMIT NK_INTEGER */ - case 361: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==361); -{ yymsp[-1].minor.yy10 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + case 362: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==362); +{ yymsp[-1].minor.yy20 = 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.yy752 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +{ yymsp[-2].minor.yy392 = 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.yy752 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +{ yymsp[-2].minor.yy392 = 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.yy752 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +{ yymsp[-3].minor.yy392 = 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.yy547, yymsp[-5].minor.yy752, yymsp[-3].minor.yy264, yymsp[-1].minor.yy264, yymsp[0].minor.yy752); } +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy377, yymsp[-5].minor.yy392, yymsp[-3].minor.yy184, yymsp[-1].minor.yy184, yymsp[0].minor.yy392); } break; case 166: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy264); } +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy184); } break; case 168: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy264); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy184); } break; case 169: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy547, yymsp[0].minor.yy752); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy377, yymsp[0].minor.yy392); } break; case 170: /* cmd ::= ALTER TABLE alter_table_clause */ - case 410: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==410); - case 411: /* cmd ::= insert_query */ yytestcase(yyruleno==411); -{ pCxt->pRootNode = yymsp[0].minor.yy752; } + case 411: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==411); + case 412: /* cmd ::= insert_query */ yytestcase(yyruleno==412); +{ pCxt->pRootNode = yymsp[0].minor.yy392; } break; case 171: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy752); } +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy392); } break; case 172: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy752 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy752, yymsp[0].minor.yy752); } - yymsp[-1].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy392, yymsp[0].minor.yy392); } + yymsp[-1].minor.yy392 = yylhsminor.yy392; break; case 173: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy752 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy752, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy879, yymsp[0].minor.yy624); } - yymsp[-4].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy392, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy369, yymsp[0].minor.yy864); } + yymsp[-4].minor.yy392 = yylhsminor.yy392; break; case 174: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy752 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy752, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy879); } - yymsp[-3].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy392, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy369); } + yymsp[-3].minor.yy392 = yylhsminor.yy392; break; case 175: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy752 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy752, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy879, yymsp[0].minor.yy624); } - yymsp[-4].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy392, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy369, yymsp[0].minor.yy864); } + yymsp[-4].minor.yy392 = yylhsminor.yy392; break; case 176: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy752 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy752, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy879, &yymsp[0].minor.yy879); } - yymsp[-4].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy392, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy369, &yymsp[0].minor.yy369); } + yymsp[-4].minor.yy392 = yylhsminor.yy392; break; case 177: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy752 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy752, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy879, yymsp[0].minor.yy624); } - yymsp[-4].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy392, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy369, yymsp[0].minor.yy864); } + yymsp[-4].minor.yy392 = yylhsminor.yy392; break; case 178: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy752 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy752, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy879); } - yymsp[-3].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy392, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy369); } + yymsp[-3].minor.yy392 = yylhsminor.yy392; break; case 179: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy752 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy752, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy879, yymsp[0].minor.yy624); } - yymsp[-4].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy392, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy369, yymsp[0].minor.yy864); } + yymsp[-4].minor.yy392 = yylhsminor.yy392; break; case 180: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy752 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy752, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy879, &yymsp[0].minor.yy879); } - yymsp[-4].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy392, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy369, &yymsp[0].minor.yy369); } + yymsp[-4].minor.yy392 = yylhsminor.yy392; break; - case 181: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy752 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy752, &yymsp[-2].minor.yy879, yymsp[0].minor.yy752); } - yymsp[-5].minor.yy752 = yylhsminor.yy752; + case 181: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal */ +{ yylhsminor.yy392 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy392, &yymsp[-2].minor.yy369, yymsp[0].minor.yy392); } + yymsp[-5].minor.yy392 = yylhsminor.yy392; break; case 183: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 515: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==515); -{ yylhsminor.yy264 = addNodeToList(pCxt, yymsp[-1].minor.yy264, yymsp[0].minor.yy752); } - yymsp[-1].minor.yy264 = yylhsminor.yy264; + case 537: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==537); +{ yylhsminor.yy184 = addNodeToList(pCxt, yymsp[-1].minor.yy184, yymsp[0].minor.yy392); } + yymsp[-1].minor.yy184 = yylhsminor.yy184; 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.yy752 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy547, yymsp[-8].minor.yy752, yymsp[-6].minor.yy752, yymsp[-5].minor.yy264, yymsp[-2].minor.yy264, yymsp[0].minor.yy752); } - yymsp[-9].minor.yy752 = yylhsminor.yy752; + case 184: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP tags_literal_list NK_RP table_options */ +{ yylhsminor.yy392 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy377, yymsp[-8].minor.yy392, yymsp[-6].minor.yy392, yymsp[-5].minor.yy184, yymsp[-2].minor.yy184, yymsp[0].minor.yy392); } + yymsp[-9].minor.yy392 = yylhsminor.yy392; break; case 187: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy752 = createDropTableClause(pCxt, yymsp[-1].minor.yy547, yymsp[0].minor.yy752); } - yymsp[-1].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createDropTableClause(pCxt, yymsp[-1].minor.yy377, yymsp[0].minor.yy392); } + yymsp[-1].minor.yy392 = yylhsminor.yy392; break; case 189: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ - case 375: /* col_list_opt ::= NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==375); -{ yymsp[-2].minor.yy264 = yymsp[-1].minor.yy264; } + case 376: /* col_list_opt ::= NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==376); +{ yymsp[-2].minor.yy184 = yymsp[-1].minor.yy184; } break; case 190: /* full_table_name ::= table_name */ -{ yylhsminor.yy752 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy879, NULL); } - yymsp[0].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy369, NULL); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; case 191: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy752 = createRealTableNode(pCxt, &yymsp[-2].minor.yy879, &yymsp[0].minor.yy879, NULL); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createRealTableNode(pCxt, &yymsp[-2].minor.yy369, &yymsp[0].minor.yy369, NULL); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 194: /* column_def ::= column_name type_name */ -{ yylhsminor.yy752 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy879, yymsp[0].minor.yy624, NULL, false); } - yymsp[-1].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy369, yymsp[0].minor.yy864, NULL, false); } + yymsp[-1].minor.yy392 = yylhsminor.yy392; break; case 195: /* column_def ::= column_name type_name PRIMARY KEY */ -{ yylhsminor.yy752 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy879, yymsp[-2].minor.yy624, NULL, true); } - yymsp[-3].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy369, yymsp[-2].minor.yy864, NULL, true); } + yymsp[-3].minor.yy392 = yylhsminor.yy392; break; case 196: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy624 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy864 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 197: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy624 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy864 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 198: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy624 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy864 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 199: /* type_name ::= INT */ case 200: /* type_name ::= INTEGER */ yytestcase(yyruleno==200); -{ yymsp[0].minor.yy624 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy864 = createDataType(TSDB_DATA_TYPE_INT); } break; case 201: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy624 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy864 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 202: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy624 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy864 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 203: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy624 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy864 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 204: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy624 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy864 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 205: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy624 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy864 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 206: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy624 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy864 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 207: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy624 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy864 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 208: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy624 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy864 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 209: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy624 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy864 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 210: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy624 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy864 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 211: /* type_name ::= JSON */ -{ yymsp[0].minor.yy624 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy864 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 212: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy624 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy864 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 213: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy624 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy864 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 214: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy624 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy864 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 215: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy624 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy864 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 216: /* type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy624 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy864 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } break; case 217: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy624 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy864 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 218: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy624 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy864 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 219: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy624 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy864 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 222: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ - case 382: /* tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==382); -{ yymsp[-3].minor.yy264 = yymsp[-1].minor.yy264; } + case 383: /* tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==383); +{ yymsp[-3].minor.yy184 = yymsp[-1].minor.yy184; } break; case 223: /* table_options ::= */ -{ yymsp[1].minor.yy752 = createDefaultTableOptions(pCxt); } +{ yymsp[1].minor.yy392 = createDefaultTableOptions(pCxt); } break; case 224: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy752 = setTableOption(pCxt, yymsp[-2].minor.yy752, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setTableOption(pCxt, yymsp[-2].minor.yy392, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 225: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy752 = setTableOption(pCxt, yymsp[-2].minor.yy752, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy264); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setTableOption(pCxt, yymsp[-2].minor.yy392, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy184); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 226: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy752 = setTableOption(pCxt, yymsp[-2].minor.yy752, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy264); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setTableOption(pCxt, yymsp[-2].minor.yy392, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy184); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 227: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy752 = setTableOption(pCxt, yymsp[-4].minor.yy752, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy264); } - yymsp[-4].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setTableOption(pCxt, yymsp[-4].minor.yy392, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy184); } + yymsp[-4].minor.yy392 = yylhsminor.yy392; break; case 228: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy752 = setTableOption(pCxt, yymsp[-2].minor.yy752, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setTableOption(pCxt, yymsp[-2].minor.yy392, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 229: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy752 = setTableOption(pCxt, yymsp[-4].minor.yy752, TABLE_OPTION_SMA, yymsp[-1].minor.yy264); } - yymsp[-4].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setTableOption(pCxt, yymsp[-4].minor.yy392, TABLE_OPTION_SMA, yymsp[-1].minor.yy184); } + yymsp[-4].minor.yy392 = yylhsminor.yy392; break; case 230: /* table_options ::= table_options DELETE_MARK duration_list */ -{ yylhsminor.yy752 = setTableOption(pCxt, yymsp[-2].minor.yy752, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy264); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setTableOption(pCxt, yymsp[-2].minor.yy392, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy184); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; case 231: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy752 = createAlterTableOptions(pCxt); yylhsminor.yy752 = setTableOption(pCxt, yylhsminor.yy752, yymsp[0].minor.yy935.type, &yymsp[0].minor.yy935.val); } - yymsp[0].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createAlterTableOptions(pCxt); yylhsminor.yy392 = setTableOption(pCxt, yylhsminor.yy392, yymsp[0].minor.yy845.type, &yymsp[0].minor.yy845.val); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; case 232: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy752 = setTableOption(pCxt, yymsp[-1].minor.yy752, yymsp[0].minor.yy935.type, &yymsp[0].minor.yy935.val); } - yymsp[-1].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = setTableOption(pCxt, yymsp[-1].minor.yy392, yymsp[0].minor.yy845.type, &yymsp[0].minor.yy845.val); } + yymsp[-1].minor.yy392 = yylhsminor.yy392; break; case 233: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy935.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy935.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 234: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy935.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy935.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy845.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } break; case 235: /* duration_list ::= duration_literal */ - case 469: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==469); -{ yylhsminor.yy264 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy752)); } - yymsp[0].minor.yy264 = yylhsminor.yy264; + case 490: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==490); +{ yylhsminor.yy184 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy392)); } + yymsp[0].minor.yy184 = yylhsminor.yy184; break; case 236: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 470: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==470); -{ yylhsminor.yy264 = addNodeToList(pCxt, yymsp[-2].minor.yy264, releaseRawExprNode(pCxt, yymsp[0].minor.yy752)); } - yymsp[-2].minor.yy264 = yylhsminor.yy264; + case 491: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==491); +{ yylhsminor.yy184 = addNodeToList(pCxt, yymsp[-2].minor.yy184, releaseRawExprNode(pCxt, yymsp[0].minor.yy392)); } + yymsp[-2].minor.yy184 = yylhsminor.yy184; break; case 239: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy752 = createFunctionNode(pCxt, &yymsp[0].minor.yy879, NULL); } - yymsp[0].minor.yy752 = yylhsminor.yy752; +{ yylhsminor.yy392 = createFunctionNode(pCxt, &yymsp[0].minor.yy369, NULL); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; case 240: /* rollup_func_name ::= FIRST */ case 241: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==241); - case 312: /* tag_item ::= QTAGS */ yytestcase(yyruleno==312); -{ yylhsminor.yy752 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy752 = yylhsminor.yy752; + case 313: /* tag_item ::= QTAGS */ yytestcase(yyruleno==313); +{ yylhsminor.yy392 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; case 244: /* col_name ::= column_name */ - case 313: /* tag_item ::= column_name */ yytestcase(yyruleno==313); -{ yylhsminor.yy752 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy879); } - yymsp[0].minor.yy752 = yylhsminor.yy752; + case 314: /* tag_item ::= column_name */ yytestcase(yyruleno==314); +{ yylhsminor.yy392 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy369); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; case 245: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } @@ -5958,19 +6023,19 @@ static YYACTIONTYPE yy_reduce( case 248: /* cmd ::= SHOW db_kind_opt DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); - setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy319); + setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy849); } break; case 249: /* cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ { - pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy147, yymsp[0].minor.yy752, OP_TYPE_LIKE); + pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy397, yymsp[0].minor.yy392, OP_TYPE_LIKE); } break; case 250: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy752, yymsp[0].minor.yy752, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy392, yymsp[0].minor.yy392, OP_TYPE_LIKE); } break; case 251: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy752, NULL, OP_TYPE_LIKE); } +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy392, NULL, OP_TYPE_LIKE); } break; case 252: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } @@ -5978,975 +6043,1037 @@ static YYACTIONTYPE yy_reduce( case 253: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } break; - case 254: /* cmd ::= SHOW FUNCTIONS */ + case 254: /* cmd ::= SHOW ARBGROUPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ARBGROUPS_STMT); } + break; + case 255: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; - case 255: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy752, yymsp[-1].minor.yy752, OP_TYPE_EQUAL); } + case 256: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy392, yymsp[-1].minor.yy392, OP_TYPE_EQUAL); } break; - case 256: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy879), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy879), OP_TYPE_EQUAL); } + case 257: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy369), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy369), OP_TYPE_EQUAL); } break; - case 257: /* cmd ::= SHOW STREAMS */ + case 258: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } break; - case 258: /* cmd ::= SHOW ACCOUNTS */ + case 259: /* cmd ::= SHOW ACCOUNTS */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } break; - case 259: /* cmd ::= SHOW APPS */ + case 260: /* cmd ::= SHOW APPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } break; - case 260: /* cmd ::= SHOW CONNECTIONS */ + case 261: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } break; - case 261: /* cmd ::= SHOW LICENCES */ - case 262: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==262); + case 262: /* cmd ::= SHOW LICENCES */ + case 263: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==263); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } break; - case 263: /* cmd ::= SHOW GRANTS FULL */ + case 264: /* cmd ::= SHOW GRANTS FULL */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_FULL_STMT); } break; - case 264: /* cmd ::= SHOW GRANTS LOGS */ + case 265: /* cmd ::= SHOW GRANTS LOGS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_LOGS_STMT); } break; - case 265: /* cmd ::= SHOW CLUSTER MACHINES */ + case 266: /* cmd ::= SHOW CLUSTER MACHINES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT); } break; - case 266: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy879); } + case 267: /* cmd ::= SHOW CREATE DATABASE db_name */ +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy369); } break; - case 267: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy752); } + case 268: /* cmd ::= SHOW CREATE TABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy392); } break; - case 268: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy752); } + case 269: /* cmd ::= SHOW CREATE STABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy392); } break; - case 269: /* cmd ::= SHOW QUERIES */ + case 270: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } break; - case 270: /* cmd ::= SHOW SCORES */ + case 271: /* cmd ::= SHOW SCORES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } break; - case 271: /* cmd ::= SHOW TOPICS */ + case 272: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } break; - case 272: /* cmd ::= SHOW VARIABLES */ - case 273: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==273); + case 273: /* cmd ::= SHOW VARIABLES */ + case 274: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==274); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } break; - case 274: /* cmd ::= SHOW LOCAL VARIABLES */ + case 275: /* cmd ::= SHOW LOCAL VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } break; - case 275: /* 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.yy752); } + case 276: /* 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.yy392); } break; - case 276: /* cmd ::= SHOW BNODES */ + case 277: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } break; - case 277: /* cmd ::= SHOW SNODES */ + case 278: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } break; - case 278: /* cmd ::= SHOW CLUSTER */ + case 279: /* cmd ::= SHOW CLUSTER */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } break; - case 279: /* cmd ::= SHOW TRANSACTIONS */ + case 280: /* cmd ::= SHOW TRANSACTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; - case 280: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy752); } + case 281: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy392); } break; - case 281: /* cmd ::= SHOW CONSUMERS */ + case 282: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } break; - case 282: /* cmd ::= SHOW SUBSCRIPTIONS */ + case 283: /* cmd ::= SHOW SUBSCRIPTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; - case 283: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy752, yymsp[-1].minor.yy752, OP_TYPE_EQUAL); } + case 284: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy392, yymsp[-1].minor.yy392, OP_TYPE_EQUAL); } break; - case 284: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy879), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy879), OP_TYPE_EQUAL); } + case 285: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy369), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy369), OP_TYPE_EQUAL); } break; - case 285: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy752, yymsp[0].minor.yy752, yymsp[-3].minor.yy264); } + case 286: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy392, yymsp[0].minor.yy392, yymsp[-3].minor.yy184); } break; - case 286: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy879), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy879), yymsp[-4].minor.yy264); } + case 287: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy369), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy369), yymsp[-4].minor.yy184); } break; - case 287: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ + case 288: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } break; - case 288: /* cmd ::= SHOW VNODES */ + case 289: /* cmd ::= SHOW VNODES */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, NULL); } break; - case 289: /* cmd ::= SHOW db_name_cond_opt ALIVE */ -{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy752, QUERY_NODE_SHOW_DB_ALIVE_STMT); } + case 290: /* cmd ::= SHOW db_name_cond_opt ALIVE */ +{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy392, QUERY_NODE_SHOW_DB_ALIVE_STMT); } break; - case 290: /* cmd ::= SHOW CLUSTER ALIVE */ + case 291: /* cmd ::= SHOW CLUSTER ALIVE */ { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } break; - case 291: /* cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-2].minor.yy752, yymsp[0].minor.yy752, OP_TYPE_LIKE); } + case 292: /* cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-2].minor.yy392, yymsp[0].minor.yy392, OP_TYPE_LIKE); } break; - case 292: /* cmd ::= SHOW CREATE VIEW full_table_name */ -{ pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy752); } + case 293: /* cmd ::= SHOW CREATE VIEW full_table_name */ +{ pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy392); } break; - case 293: /* cmd ::= SHOW COMPACTS */ + case 294: /* cmd ::= SHOW COMPACTS */ { pCxt->pRootNode = createShowCompactsStmt(pCxt, QUERY_NODE_SHOW_COMPACTS_STMT); } break; - case 294: /* cmd ::= SHOW COMPACT NK_INTEGER */ + case 295: /* cmd ::= SHOW COMPACT NK_INTEGER */ { pCxt->pRootNode = createShowCompactDetailsStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 295: /* table_kind_db_name_cond_opt ::= */ -{ yymsp[1].minor.yy147.kind = SHOW_KIND_ALL; yymsp[1].minor.yy147.dbName = nil_token; } + case 296: /* table_kind_db_name_cond_opt ::= */ +{ yymsp[1].minor.yy397.kind = SHOW_KIND_ALL; yymsp[1].minor.yy397.dbName = nil_token; } break; - case 296: /* table_kind_db_name_cond_opt ::= table_kind */ -{ yylhsminor.yy147.kind = yymsp[0].minor.yy319; yylhsminor.yy147.dbName = nil_token; } - yymsp[0].minor.yy147 = yylhsminor.yy147; + case 297: /* table_kind_db_name_cond_opt ::= table_kind */ +{ yylhsminor.yy397.kind = yymsp[0].minor.yy849; yylhsminor.yy397.dbName = nil_token; } + yymsp[0].minor.yy397 = yylhsminor.yy397; break; - case 297: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy147.kind = SHOW_KIND_ALL; yylhsminor.yy147.dbName = yymsp[-1].minor.yy879; } - yymsp[-1].minor.yy147 = yylhsminor.yy147; + case 298: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy397.kind = SHOW_KIND_ALL; yylhsminor.yy397.dbName = yymsp[-1].minor.yy369; } + yymsp[-1].minor.yy397 = yylhsminor.yy397; break; - case 298: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ -{ yylhsminor.yy147.kind = yymsp[-2].minor.yy319; yylhsminor.yy147.dbName = yymsp[-1].minor.yy879; } - yymsp[-2].minor.yy147 = yylhsminor.yy147; + case 299: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ +{ yylhsminor.yy397.kind = yymsp[-2].minor.yy849; yylhsminor.yy397.dbName = yymsp[-1].minor.yy369; } + yymsp[-2].minor.yy397 = yylhsminor.yy397; break; - case 299: /* table_kind ::= NORMAL */ -{ yymsp[0].minor.yy319 = SHOW_KIND_TABLES_NORMAL; } + case 300: /* table_kind ::= NORMAL */ +{ yymsp[0].minor.yy849 = SHOW_KIND_TABLES_NORMAL; } break; - case 300: /* table_kind ::= CHILD */ -{ yymsp[0].minor.yy319 = SHOW_KIND_TABLES_CHILD; } + case 301: /* table_kind ::= CHILD */ +{ yymsp[0].minor.yy849 = SHOW_KIND_TABLES_CHILD; } break; - case 301: /* db_name_cond_opt ::= */ - case 306: /* from_db_opt ::= */ yytestcase(yyruleno==306); -{ yymsp[1].minor.yy752 = createDefaultDatabaseCondValue(pCxt); } + case 302: /* db_name_cond_opt ::= */ + case 307: /* from_db_opt ::= */ yytestcase(yyruleno==307); +{ yymsp[1].minor.yy392 = createDefaultDatabaseCondValue(pCxt); } break; - case 302: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy752 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy879); } - yymsp[-1].minor.yy752 = yylhsminor.yy752; + case 303: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy392 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy369); } + yymsp[-1].minor.yy392 = yylhsminor.yy392; break; - case 304: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy752 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 305: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 305: /* table_name_cond ::= table_name */ -{ yylhsminor.yy752 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy879); } - yymsp[0].minor.yy752 = yylhsminor.yy752; + case 306: /* table_name_cond ::= table_name */ +{ yylhsminor.yy392 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy369); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; - case 307: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy752 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy879); } + case 308: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy392 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy369); } break; - case 311: /* tag_item ::= TBNAME */ -{ yylhsminor.yy752 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } - yymsp[0].minor.yy752 = yylhsminor.yy752; + case 312: /* tag_item ::= TBNAME */ +{ yylhsminor.yy392 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; - case 314: /* tag_item ::= column_name column_alias */ -{ yylhsminor.yy752 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy879), &yymsp[0].minor.yy879); } - yymsp[-1].minor.yy752 = yylhsminor.yy752; + case 315: /* tag_item ::= column_name column_alias */ +{ yylhsminor.yy392 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy369), &yymsp[0].minor.yy369); } + yymsp[-1].minor.yy392 = yylhsminor.yy392; break; - case 315: /* tag_item ::= column_name AS column_alias */ -{ yylhsminor.yy752 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy879), &yymsp[0].minor.yy879); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 316: /* tag_item ::= column_name AS column_alias */ +{ yylhsminor.yy392 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy369), &yymsp[0].minor.yy369); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 316: /* db_kind_opt ::= */ -{ yymsp[1].minor.yy319 = SHOW_KIND_ALL; } + case 317: /* db_kind_opt ::= */ +{ yymsp[1].minor.yy849 = SHOW_KIND_ALL; } break; - case 317: /* db_kind_opt ::= USER */ -{ yymsp[0].minor.yy319 = SHOW_KIND_DATABASES_USER; } + case 318: /* db_kind_opt ::= USER */ +{ yymsp[0].minor.yy849 = SHOW_KIND_DATABASES_USER; } break; - case 318: /* db_kind_opt ::= SYSTEM */ -{ yymsp[0].minor.yy319 = SHOW_KIND_DATABASES_SYSTEM; } + case 319: /* db_kind_opt ::= SYSTEM */ +{ yymsp[0].minor.yy849 = SHOW_KIND_DATABASES_SYSTEM; } break; - case 319: /* 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.yy547, yymsp[-3].minor.yy752, yymsp[-1].minor.yy752, NULL, yymsp[0].minor.yy752); } + case 320: /* 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.yy377, yymsp[-3].minor.yy392, yymsp[-1].minor.yy392, NULL, yymsp[0].minor.yy392); } break; - case 320: /* 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.yy547, yymsp[-5].minor.yy752, yymsp[-3].minor.yy752, yymsp[-1].minor.yy264, NULL); } + case 321: /* 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.yy377, yymsp[-5].minor.yy392, yymsp[-3].minor.yy392, yymsp[-1].minor.yy184, NULL); } break; - case 321: /* cmd ::= DROP INDEX exists_opt full_index_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy547, yymsp[0].minor.yy752); } + case 322: /* cmd ::= DROP INDEX exists_opt full_index_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy377, yymsp[0].minor.yy392); } break; - case 322: /* full_index_name ::= index_name */ -{ yylhsminor.yy752 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy879); } - yymsp[0].minor.yy752 = yylhsminor.yy752; + case 323: /* full_index_name ::= index_name */ +{ yylhsminor.yy392 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy369); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; - case 323: /* full_index_name ::= db_name NK_DOT index_name */ -{ yylhsminor.yy752 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy879, &yymsp[0].minor.yy879); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 324: /* full_index_name ::= db_name NK_DOT index_name */ +{ yylhsminor.yy392 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy369, &yymsp[0].minor.yy369); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 324: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy752 = createIndexOption(pCxt, yymsp[-7].minor.yy264, releaseRawExprNode(pCxt, yymsp[-3].minor.yy752), NULL, yymsp[-1].minor.yy752, yymsp[0].minor.yy752); } + case 325: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-9].minor.yy392 = createIndexOption(pCxt, yymsp[-7].minor.yy184, releaseRawExprNode(pCxt, yymsp[-3].minor.yy392), NULL, yymsp[-1].minor.yy392, yymsp[0].minor.yy392); } break; - case 325: /* 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.yy752 = createIndexOption(pCxt, yymsp[-9].minor.yy264, releaseRawExprNode(pCxt, yymsp[-5].minor.yy752), releaseRawExprNode(pCxt, yymsp[-3].minor.yy752), yymsp[-1].minor.yy752, yymsp[0].minor.yy752); } + case 326: /* 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.yy392 = createIndexOption(pCxt, yymsp[-9].minor.yy184, releaseRawExprNode(pCxt, yymsp[-5].minor.yy392), releaseRawExprNode(pCxt, yymsp[-3].minor.yy392), yymsp[-1].minor.yy392, yymsp[0].minor.yy392); } break; - case 328: /* func ::= sma_func_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy752 = createFunctionNode(pCxt, &yymsp[-3].minor.yy879, yymsp[-1].minor.yy264); } - yymsp[-3].minor.yy752 = yylhsminor.yy752; + case 329: /* func ::= sma_func_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy392 = createFunctionNode(pCxt, &yymsp[-3].minor.yy369, yymsp[-1].minor.yy184); } + yymsp[-3].minor.yy392 = yylhsminor.yy392; break; - case 329: /* sma_func_name ::= function_name */ - case 558: /* alias_opt ::= table_alias */ yytestcase(yyruleno==558); -{ yylhsminor.yy879 = yymsp[0].minor.yy879; } - yymsp[0].minor.yy879 = yylhsminor.yy879; + case 330: /* sma_func_name ::= function_name */ + case 580: /* alias_opt ::= table_alias */ yytestcase(yyruleno==580); +{ yylhsminor.yy369 = yymsp[0].minor.yy369; } + yymsp[0].minor.yy369 = yylhsminor.yy369; break; - case 334: /* sma_stream_opt ::= */ - case 383: /* stream_options ::= */ yytestcase(yyruleno==383); -{ yymsp[1].minor.yy752 = createStreamOptions(pCxt); } + case 335: /* sma_stream_opt ::= */ + case 384: /* stream_options ::= */ yytestcase(yyruleno==384); +{ yymsp[1].minor.yy392 = createStreamOptions(pCxt); } break; - case 335: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy752)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy752); yylhsminor.yy752 = yymsp[-2].minor.yy752; } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 336: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy392)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy392); yylhsminor.yy392 = yymsp[-2].minor.yy392; } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 336: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy752)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy752); yylhsminor.yy752 = yymsp[-2].minor.yy752; } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 337: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy392)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy392); yylhsminor.yy392 = yymsp[-2].minor.yy392; } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 337: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy752)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy752); yylhsminor.yy752 = yymsp[-2].minor.yy752; } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 338: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy392)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy392); yylhsminor.yy392 = yymsp[-2].minor.yy392; } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 338: /* with_meta ::= AS */ -{ yymsp[0].minor.yy10 = 0; } + case 339: /* with_meta ::= AS */ +{ yymsp[0].minor.yy20 = 0; } break; - case 339: /* with_meta ::= WITH META AS */ -{ yymsp[-2].minor.yy10 = 1; } + case 340: /* with_meta ::= WITH META AS */ +{ yymsp[-2].minor.yy20 = 1; } break; - case 340: /* with_meta ::= ONLY META AS */ -{ yymsp[-2].minor.yy10 = 2; } + case 341: /* with_meta ::= ONLY META AS */ +{ yymsp[-2].minor.yy20 = 2; } break; - case 341: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy547, &yymsp[-2].minor.yy879, yymsp[0].minor.yy752); } + case 342: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy377, &yymsp[-2].minor.yy369, yymsp[0].minor.yy392); } break; - case 342: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy547, &yymsp[-3].minor.yy879, &yymsp[0].minor.yy879, yymsp[-2].minor.yy10); } + case 343: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy377, &yymsp[-3].minor.yy369, &yymsp[0].minor.yy369, yymsp[-2].minor.yy20); } break; - case 343: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy547, &yymsp[-4].minor.yy879, yymsp[-1].minor.yy752, yymsp[-3].minor.yy10, yymsp[0].minor.yy752); } + case 344: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy377, &yymsp[-4].minor.yy369, yymsp[-1].minor.yy392, yymsp[-3].minor.yy20, yymsp[0].minor.yy392); } break; - case 344: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy547, &yymsp[0].minor.yy879); } + case 345: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy377, &yymsp[0].minor.yy369); } break; - case 345: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy547, &yymsp[-2].minor.yy879, &yymsp[0].minor.yy879); } + case 346: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy377, &yymsp[-2].minor.yy369, &yymsp[0].minor.yy369); } break; - case 346: /* cmd ::= DESC full_table_name */ - case 347: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==347); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy752); } + case 347: /* cmd ::= DESC full_table_name */ + case 348: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==348); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy392); } break; - case 348: /* cmd ::= RESET QUERY CACHE */ + case 349: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 349: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - case 350: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==350); -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy547, yymsp[-1].minor.yy752, yymsp[0].minor.yy752); } + case 350: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + case 351: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==351); +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy377, yymsp[-1].minor.yy392, yymsp[0].minor.yy392); } break; - case 353: /* explain_options ::= */ -{ yymsp[1].minor.yy752 = createDefaultExplainOptions(pCxt); } + case 354: /* explain_options ::= */ +{ yymsp[1].minor.yy392 = createDefaultExplainOptions(pCxt); } break; - case 354: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy752 = setExplainVerbose(pCxt, yymsp[-2].minor.yy752, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 355: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy392 = setExplainVerbose(pCxt, yymsp[-2].minor.yy392, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 355: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy752 = setExplainRatio(pCxt, yymsp[-2].minor.yy752, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 356: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy392 = setExplainRatio(pCxt, yymsp[-2].minor.yy392, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 356: /* 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.yy547, yymsp[-9].minor.yy547, &yymsp[-6].minor.yy879, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy624, yymsp[-1].minor.yy10, &yymsp[0].minor.yy879, yymsp[-10].minor.yy547); } + case 357: /* 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.yy377, yymsp[-9].minor.yy377, &yymsp[-6].minor.yy369, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy864, yymsp[-1].minor.yy20, &yymsp[0].minor.yy369, yymsp[-10].minor.yy377); } break; - case 357: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy547, &yymsp[0].minor.yy879); } + case 358: /* cmd ::= DROP FUNCTION exists_opt function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy377, &yymsp[0].minor.yy369); } break; - case 362: /* language_opt ::= */ - case 405: /* on_vgroup_id ::= */ yytestcase(yyruleno==405); -{ yymsp[1].minor.yy879 = nil_token; } + case 363: /* language_opt ::= */ + case 406: /* on_vgroup_id ::= */ yytestcase(yyruleno==406); +{ yymsp[1].minor.yy369 = nil_token; } break; - case 363: /* language_opt ::= LANGUAGE NK_STRING */ - case 406: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==406); -{ yymsp[-1].minor.yy879 = yymsp[0].minor.yy0; } + case 364: /* language_opt ::= LANGUAGE NK_STRING */ + case 407: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==407); +{ yymsp[-1].minor.yy369 = yymsp[0].minor.yy0; } break; - case 366: /* cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy547, yymsp[-2].minor.yy752, &yymsp[-1].minor.yy0, yymsp[0].minor.yy752); } + case 367: /* cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ +{ pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy377, yymsp[-2].minor.yy392, &yymsp[-1].minor.yy0, yymsp[0].minor.yy392); } break; - case 367: /* cmd ::= DROP VIEW exists_opt full_view_name */ -{ pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy547, yymsp[0].minor.yy752); } + case 368: /* cmd ::= DROP VIEW exists_opt full_view_name */ +{ pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy377, yymsp[0].minor.yy392); } break; - case 368: /* full_view_name ::= view_name */ -{ yylhsminor.yy752 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy879); } - yymsp[0].minor.yy752 = yylhsminor.yy752; + case 369: /* full_view_name ::= view_name */ +{ yylhsminor.yy392 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy369); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; - case 369: /* full_view_name ::= db_name NK_DOT view_name */ -{ yylhsminor.yy752 = createViewNode(pCxt, &yymsp[-2].minor.yy879, &yymsp[0].minor.yy879); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 370: /* full_view_name ::= db_name NK_DOT view_name */ +{ yylhsminor.yy392 = createViewNode(pCxt, &yymsp[-2].minor.yy369, &yymsp[0].minor.yy369); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 370: /* 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.yy547, &yymsp[-8].minor.yy879, yymsp[-5].minor.yy752, yymsp[-7].minor.yy752, yymsp[-3].minor.yy264, yymsp[-2].minor.yy752, yymsp[0].minor.yy752, yymsp[-4].minor.yy264); } + case 371: /* 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.yy377, &yymsp[-8].minor.yy369, yymsp[-5].minor.yy392, yymsp[-7].minor.yy392, yymsp[-3].minor.yy184, yymsp[-2].minor.yy392, yymsp[0].minor.yy392, yymsp[-4].minor.yy184); } break; - case 371: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy547, &yymsp[0].minor.yy879); } + case 372: /* cmd ::= DROP STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy377, &yymsp[0].minor.yy369); } break; - case 372: /* cmd ::= PAUSE STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy547, &yymsp[0].minor.yy879); } + case 373: /* cmd ::= PAUSE STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy377, &yymsp[0].minor.yy369); } break; - case 373: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ -{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy547, yymsp[-1].minor.yy547, &yymsp[0].minor.yy879); } + case 374: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ +{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy377, yymsp[-1].minor.yy377, &yymsp[0].minor.yy369); } break; - case 378: /* column_stream_def ::= column_name */ -{ yylhsminor.yy752 = createColumnDefNode(pCxt, &yymsp[0].minor.yy879, createDataType(TSDB_DATA_TYPE_NULL), NULL, false); } - yymsp[0].minor.yy752 = yylhsminor.yy752; + case 379: /* column_stream_def ::= column_name */ +{ yylhsminor.yy392 = createColumnDefNode(pCxt, &yymsp[0].minor.yy369, createDataType(TSDB_DATA_TYPE_NULL), NULL, false); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; - case 379: /* column_stream_def ::= column_name PRIMARY KEY */ -{ yylhsminor.yy752 = createColumnDefNode(pCxt, &yymsp[-2].minor.yy879, createDataType(TSDB_DATA_TYPE_NULL), NULL, true); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 380: /* column_stream_def ::= column_name PRIMARY KEY */ +{ yylhsminor.yy392 = createColumnDefNode(pCxt, &yymsp[-2].minor.yy369, createDataType(TSDB_DATA_TYPE_NULL), NULL, true); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 384: /* stream_options ::= stream_options TRIGGER AT_ONCE */ - case 385: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==385); -{ yylhsminor.yy752 = setStreamOptions(pCxt, yymsp[-2].minor.yy752, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 385: /* stream_options ::= stream_options TRIGGER AT_ONCE */ + case 386: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==386); +{ yylhsminor.yy392 = setStreamOptions(pCxt, yymsp[-2].minor.yy392, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 386: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ yylhsminor.yy752 = setStreamOptions(pCxt, yymsp[-3].minor.yy752, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy752)); } - yymsp[-3].minor.yy752 = yylhsminor.yy752; + case 387: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +{ yylhsminor.yy392 = setStreamOptions(pCxt, yymsp[-3].minor.yy392, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy392)); } + yymsp[-3].minor.yy392 = yylhsminor.yy392; break; - case 387: /* stream_options ::= stream_options WATERMARK duration_literal */ -{ yylhsminor.yy752 = setStreamOptions(pCxt, yymsp[-2].minor.yy752, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy752)); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 388: /* stream_options ::= stream_options WATERMARK duration_literal */ +{ yylhsminor.yy392 = setStreamOptions(pCxt, yymsp[-2].minor.yy392, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy392)); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 388: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -{ yylhsminor.yy752 = setStreamOptions(pCxt, yymsp[-3].minor.yy752, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-3].minor.yy752 = yylhsminor.yy752; + case 389: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ +{ yylhsminor.yy392 = setStreamOptions(pCxt, yymsp[-3].minor.yy392, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-3].minor.yy392 = yylhsminor.yy392; break; - case 389: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ -{ yylhsminor.yy752 = setStreamOptions(pCxt, yymsp[-2].minor.yy752, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 390: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ +{ yylhsminor.yy392 = setStreamOptions(pCxt, yymsp[-2].minor.yy392, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 390: /* stream_options ::= stream_options DELETE_MARK duration_literal */ -{ yylhsminor.yy752 = setStreamOptions(pCxt, yymsp[-2].minor.yy752, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy752)); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 391: /* stream_options ::= stream_options DELETE_MARK duration_literal */ +{ yylhsminor.yy392 = setStreamOptions(pCxt, yymsp[-2].minor.yy392, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy392)); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 391: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ -{ yylhsminor.yy752 = setStreamOptions(pCxt, yymsp[-3].minor.yy752, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-3].minor.yy752 = yylhsminor.yy752; + case 392: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ +{ yylhsminor.yy392 = setStreamOptions(pCxt, yymsp[-3].minor.yy392, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-3].minor.yy392 = yylhsminor.yy392; break; - case 393: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 598: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==598); - case 622: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==622); -{ yymsp[-3].minor.yy752 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy752); } + case 394: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 620: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==620); + case 644: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==644); +{ yymsp[-3].minor.yy392 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy392); } break; - case 396: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 397: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 397: /* cmd ::= KILL QUERY NK_STRING */ + case 398: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 398: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 399: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 399: /* cmd ::= KILL COMPACT NK_INTEGER */ + case 400: /* cmd ::= KILL COMPACT NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_COMPACT_STMT, &yymsp[0].minor.yy0); } break; - case 400: /* cmd ::= BALANCE VGROUP */ + case 401: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 401: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ -{ pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy879); } + case 402: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ +{ pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy369); } break; - case 402: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 403: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 403: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy264); } + case 404: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy184); } break; - case 404: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 405: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 407: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy264 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 408: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy184 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 409: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy752, yymsp[0].minor.yy752); } + case 410: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy392, yymsp[0].minor.yy392); } break; - case 412: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -{ yymsp[-6].minor.yy752 = createInsertStmt(pCxt, yymsp[-4].minor.yy752, yymsp[-2].minor.yy264, yymsp[0].minor.yy752); } + case 413: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ +{ yymsp[-6].minor.yy392 = createInsertStmt(pCxt, yymsp[-4].minor.yy392, yymsp[-2].minor.yy184, yymsp[0].minor.yy392); } break; - case 413: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ -{ yymsp[-3].minor.yy752 = createInsertStmt(pCxt, yymsp[-1].minor.yy752, NULL, yymsp[0].minor.yy752); } + case 414: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ +{ yymsp[-3].minor.yy392 = createInsertStmt(pCxt, yymsp[-1].minor.yy392, NULL, yymsp[0].minor.yy392); } break; - case 414: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy752 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy752 = yylhsminor.yy752; + case 415: /* tags_literal ::= NK_INTEGER */ + case 421: /* tags_literal ::= NK_BIN */ yytestcase(yyruleno==421); + case 424: /* tags_literal ::= NK_HEX */ yytestcase(yyruleno==424); +{ yylhsminor.yy392 = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; - case 415: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy752 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy752 = yylhsminor.yy752; - break; - case 416: /* literal ::= NK_STRING */ -{ yylhsminor.yy752 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy752 = yylhsminor.yy752; - break; - case 417: /* literal ::= NK_BOOL */ -{ yylhsminor.yy752 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy752 = yylhsminor.yy752; - break; - case 418: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy752 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy752 = yylhsminor.yy752; - break; - case 419: /* literal ::= duration_literal */ - case 429: /* signed_literal ::= signed */ yytestcase(yyruleno==429); - case 452: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==452); - case 453: /* expression ::= literal */ yytestcase(yyruleno==453); - case 455: /* expression ::= column_reference */ yytestcase(yyruleno==455); - case 456: /* expression ::= function_expression */ yytestcase(yyruleno==456); - case 457: /* expression ::= case_when_expression */ yytestcase(yyruleno==457); - case 490: /* function_expression ::= literal_func */ yytestcase(yyruleno==490); - case 539: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==539); - case 543: /* boolean_primary ::= predicate */ yytestcase(yyruleno==543); - case 545: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==545); - case 546: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==546); - case 549: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==549); - case 551: /* table_reference ::= table_primary */ yytestcase(yyruleno==551); - case 552: /* table_reference ::= joined_table */ yytestcase(yyruleno==552); - case 556: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==556); - case 624: /* query_simple ::= query_specification */ yytestcase(yyruleno==624); - case 625: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==625); - case 628: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==628); - case 630: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==630); -{ yylhsminor.yy752 = yymsp[0].minor.yy752; } - yymsp[0].minor.yy752 = yylhsminor.yy752; - break; - case 420: /* literal ::= NULL */ -{ yylhsminor.yy752 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy752 = yylhsminor.yy752; - break; - case 421: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy752 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy752 = yylhsminor.yy752; - break; - case 422: /* duration_literal ::= NK_VARIABLE */ - case 599: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==599); - case 600: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==600); - case 601: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==601); -{ yylhsminor.yy752 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy752 = yylhsminor.yy752; - break; - case 423: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy752 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy752 = yylhsminor.yy752; - break; - case 424: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy752 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - break; - case 425: /* signed ::= NK_MINUS NK_INTEGER */ + case 416: /* tags_literal ::= NK_PLUS NK_INTEGER */ + case 417: /* tags_literal ::= NK_MINUS NK_INTEGER */ yytestcase(yyruleno==417); + case 422: /* tags_literal ::= NK_PLUS NK_BIN */ yytestcase(yyruleno==422); + case 423: /* tags_literal ::= NK_MINUS NK_BIN */ yytestcase(yyruleno==423); + case 425: /* tags_literal ::= NK_PLUS NK_HEX */ yytestcase(yyruleno==425); + case 426: /* tags_literal ::= NK_MINUS NK_HEX */ yytestcase(yyruleno==426); { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy752 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy392 = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); } - yymsp[-1].minor.yy752 = yylhsminor.yy752; + yymsp[-1].minor.yy392 = yylhsminor.yy392; break; - case 426: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy752 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy752 = yylhsminor.yy752; + case 418: /* tags_literal ::= NK_FLOAT */ +{ yylhsminor.yy392 = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; - case 427: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy752 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - break; - case 428: /* signed ::= NK_MINUS NK_FLOAT */ + case 419: /* tags_literal ::= NK_PLUS NK_FLOAT */ + case 420: /* tags_literal ::= NK_MINUS NK_FLOAT */ yytestcase(yyruleno==420); { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy752 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy392 = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t, NULL); } - yymsp[-1].minor.yy752 = yylhsminor.yy752; + yymsp[-1].minor.yy392 = yylhsminor.yy392; break; - case 430: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy752 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy752 = yylhsminor.yy752; + case 427: /* tags_literal ::= NK_STRING */ +{ yylhsminor.yy392 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; - case 431: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy752 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy752 = yylhsminor.yy752; + case 428: /* tags_literal ::= NK_BOOL */ +{ yylhsminor.yy392 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; - case 432: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy752 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 429: /* tags_literal ::= NULL */ +{ yylhsminor.yy392 = createRawValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; - case 433: /* signed_literal ::= duration_literal */ - case 435: /* signed_literal ::= literal_func */ yytestcase(yyruleno==435); - case 510: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==510); - case 576: /* select_item ::= common_expression */ yytestcase(yyruleno==576); - case 586: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==586); - case 629: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==629); - case 631: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==631); - case 644: /* search_condition ::= common_expression */ yytestcase(yyruleno==644); -{ yylhsminor.yy752 = releaseRawExprNode(pCxt, yymsp[0].minor.yy752); } - yymsp[0].minor.yy752 = yylhsminor.yy752; + case 430: /* tags_literal ::= literal_func */ +{ yylhsminor.yy392 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, NULL, yymsp[0].minor.yy392); } + yymsp[0].minor.yy392 = yylhsminor.yy392; break; - case 434: /* signed_literal ::= NULL */ -{ yylhsminor.yy752 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy752 = yylhsminor.yy752; - break; - case 436: /* signed_literal ::= NK_QUESTION */ -{ yylhsminor.yy752 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy752 = yylhsminor.yy752; - break; - case 454: /* expression ::= pseudo_column */ -{ yylhsminor.yy752 = yymsp[0].minor.yy752; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy752, true); } - yymsp[0].minor.yy752 = yylhsminor.yy752; - break; - case 458: /* expression ::= NK_LP expression NK_RP */ - case 544: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==544); - case 643: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==643); -{ yylhsminor.yy752 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy752)); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; - break; - case 459: /* expression ::= NK_PLUS expr_or_subquery */ + case 431: /* tags_literal ::= literal_func NK_PLUS duration_literal */ + case 432: /* tags_literal ::= literal_func NK_MINUS duration_literal */ yytestcase(yyruleno==432); { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy752)); + SToken l = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy392); + SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); + l.n = (r.z + r.n) - l.z; + yylhsminor.yy392 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, yymsp[-2].minor.yy392, yymsp[0].minor.yy392); } - yymsp[-1].minor.yy752 = yylhsminor.yy752; + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 460: /* expression ::= NK_MINUS expr_or_subquery */ + case 435: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy392 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 436: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy392 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 437: /* literal ::= NK_STRING */ +{ yylhsminor.yy392 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 438: /* literal ::= NK_BOOL */ +{ yylhsminor.yy392 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 439: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy392 = yylhsminor.yy392; + break; + case 440: /* literal ::= duration_literal */ + case 450: /* signed_literal ::= signed */ yytestcase(yyruleno==450); + case 473: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==473); + case 474: /* expression ::= literal */ yytestcase(yyruleno==474); + case 476: /* expression ::= column_reference */ yytestcase(yyruleno==476); + case 477: /* expression ::= function_expression */ yytestcase(yyruleno==477); + case 478: /* expression ::= case_when_expression */ yytestcase(yyruleno==478); + case 511: /* function_expression ::= literal_func */ yytestcase(yyruleno==511); + case 561: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==561); + case 565: /* boolean_primary ::= predicate */ yytestcase(yyruleno==565); + case 567: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==567); + case 568: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==568); + case 571: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==571); + case 573: /* table_reference ::= table_primary */ yytestcase(yyruleno==573); + case 574: /* table_reference ::= joined_table */ yytestcase(yyruleno==574); + case 578: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==578); + case 646: /* query_simple ::= query_specification */ yytestcase(yyruleno==646); + case 647: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==647); + case 650: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==650); + case 652: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==652); +{ yylhsminor.yy392 = yymsp[0].minor.yy392; } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 441: /* literal ::= NULL */ +{ yylhsminor.yy392 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 442: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy392 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 443: /* duration_literal ::= NK_VARIABLE */ + case 621: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==621); + case 622: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==622); + case 623: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==623); +{ yylhsminor.yy392 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 444: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 445: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + break; + case 446: /* signed ::= NK_MINUS NK_INTEGER */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy752), NULL)); + SToken t = yymsp[-1].minor.yy0; + t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; + yylhsminor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy752 = yylhsminor.yy752; + yymsp[-1].minor.yy392 = yylhsminor.yy392; break; - case 461: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + case 447: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 448: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + break; + case 449: /* signed ::= NK_MINUS NK_FLOAT */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy752); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), releaseRawExprNode(pCxt, yymsp[0].minor.yy752))); + SToken t = yymsp[-1].minor.yy0; + t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; + yylhsminor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + yymsp[-1].minor.yy392 = yylhsminor.yy392; break; - case 462: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + case 451: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 452: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 453: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + break; + case 454: /* signed_literal ::= duration_literal */ + case 456: /* signed_literal ::= literal_func */ yytestcase(yyruleno==456); + case 532: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==532); + case 598: /* select_item ::= common_expression */ yytestcase(yyruleno==598); + case 608: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==608); + case 651: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==651); + case 653: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==653); + case 666: /* search_condition ::= common_expression */ yytestcase(yyruleno==666); +{ yylhsminor.yy392 = releaseRawExprNode(pCxt, yymsp[0].minor.yy392); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 455: /* signed_literal ::= NULL */ +{ yylhsminor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 457: /* signed_literal ::= NK_QUESTION */ +{ yylhsminor.yy392 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 475: /* expression ::= pseudo_column */ +{ yylhsminor.yy392 = yymsp[0].minor.yy392; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy392, true); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 479: /* expression ::= NK_LP expression NK_RP */ + case 566: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==566); + case 665: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==665); +{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy392)); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; + break; + case 480: /* expression ::= NK_PLUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy752); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), releaseRawExprNode(pCxt, yymsp[0].minor.yy752))); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy392)); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + yymsp[-1].minor.yy392 = yylhsminor.yy392; break; - case 463: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + case 481: /* expression ::= NK_MINUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy752); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), releaseRawExprNode(pCxt, yymsp[0].minor.yy752))); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy392), NULL)); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + yymsp[-1].minor.yy392 = yylhsminor.yy392; break; - case 464: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + case 482: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy752); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), releaseRawExprNode(pCxt, yymsp[0].minor.yy752))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy392); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 465: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ + case 483: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy752); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), releaseRawExprNode(pCxt, yymsp[0].minor.yy752))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy392); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 466: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 484: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy392); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 467: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + case 485: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy752); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), releaseRawExprNode(pCxt, yymsp[0].minor.yy752))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy392); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 468: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + case 486: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy752); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), releaseRawExprNode(pCxt, yymsp[0].minor.yy752))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy392); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 471: /* column_reference ::= column_name */ -{ yylhsminor.yy752 = createRawExprNode(pCxt, &yymsp[0].minor.yy879, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy879)); } - yymsp[0].minor.yy752 = yylhsminor.yy752; - break; - case 472: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy752 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy879, &yymsp[0].minor.yy879, createColumnNode(pCxt, &yymsp[-2].minor.yy879, &yymsp[0].minor.yy879)); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; - break; - case 473: /* column_reference ::= NK_ALIAS */ -{ yylhsminor.yy752 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy752 = yylhsminor.yy752; - break; - case 474: /* column_reference ::= table_name NK_DOT NK_ALIAS */ -{ yylhsminor.yy752 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy879, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy879, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; - break; - case 475: /* pseudo_column ::= ROWTS */ - case 476: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==476); - case 478: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==478); - case 479: /* pseudo_column ::= QEND */ yytestcase(yyruleno==479); - case 480: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==480); - case 481: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==481); - case 482: /* pseudo_column ::= WEND */ yytestcase(yyruleno==482); - case 483: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==483); - case 484: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==484); - case 485: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==485); - case 486: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==486); - case 492: /* literal_func ::= NOW */ yytestcase(yyruleno==492); -{ yylhsminor.yy752 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy752 = yylhsminor.yy752; - break; - case 477: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy752 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy879, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy879)))); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; - break; - case 487: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 488: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==488); -{ yylhsminor.yy752 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy879, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy879, yymsp[-1].minor.yy264)); } - yymsp[-3].minor.yy752 = yylhsminor.yy752; - break; - case 489: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ -{ yylhsminor.yy752 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy752), yymsp[-1].minor.yy624)); } - yymsp[-5].minor.yy752 = yylhsminor.yy752; - break; - case 491: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy752 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy879, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy879, NULL)); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; - break; - case 506: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy264 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy264 = yylhsminor.yy264; - break; - case 511: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 579: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==579); -{ yylhsminor.yy752 = createColumnNode(pCxt, &yymsp[-2].minor.yy879, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; - break; - case 512: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -{ yylhsminor.yy752 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy264, yymsp[-1].minor.yy752)); } - yymsp[-3].minor.yy752 = yylhsminor.yy752; - break; - case 513: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -{ yylhsminor.yy752 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy752), yymsp[-2].minor.yy264, yymsp[-1].minor.yy752)); } - yymsp[-4].minor.yy752 = yylhsminor.yy752; - break; - case 516: /* when_then_expr ::= WHEN common_expression THEN common_expression */ -{ yymsp[-3].minor.yy752 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), releaseRawExprNode(pCxt, yymsp[0].minor.yy752)); } - break; - case 518: /* case_when_else_opt ::= ELSE common_expression */ -{ yymsp[-1].minor.yy752 = releaseRawExprNode(pCxt, yymsp[0].minor.yy752); } - break; - case 519: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 524: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==524); + case 487: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy752); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy980, releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), releaseRawExprNode(pCxt, yymsp[0].minor.yy752))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 520: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + case 488: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy752); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy752), releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), releaseRawExprNode(pCxt, yymsp[0].minor.yy752))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy392); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } - yymsp[-4].minor.yy752 = yylhsminor.yy752; + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 521: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + case 489: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy752); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy752), releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), releaseRawExprNode(pCxt, yymsp[0].minor.yy752))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy392); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } - yymsp[-5].minor.yy752 = yylhsminor.yy752; + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 522: /* predicate ::= expr_or_subquery IS NULL */ + case 492: /* column_reference ::= column_name */ +{ yylhsminor.yy392 = createRawExprNode(pCxt, &yymsp[0].minor.yy369, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy369)); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 493: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy369, &yymsp[0].minor.yy369, createColumnNode(pCxt, &yymsp[-2].minor.yy369, &yymsp[0].minor.yy369)); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; + break; + case 494: /* column_reference ::= NK_ALIAS */ +{ yylhsminor.yy392 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 495: /* column_reference ::= table_name NK_DOT NK_ALIAS */ +{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy369, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy369, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; + break; + case 496: /* pseudo_column ::= ROWTS */ + case 497: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==497); + case 499: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==499); + case 500: /* pseudo_column ::= QEND */ yytestcase(yyruleno==500); + case 501: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==501); + case 502: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==502); + case 503: /* pseudo_column ::= WEND */ yytestcase(yyruleno==503); + case 504: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==504); + case 505: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==505); + case 506: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==506); + case 507: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==507); + case 513: /* literal_func ::= NOW */ yytestcase(yyruleno==513); + case 514: /* literal_func ::= TODAY */ yytestcase(yyruleno==514); +{ yylhsminor.yy392 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 498: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy369, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy369)))); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; + break; + case 508: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 509: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==509); +{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy369, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy369, yymsp[-1].minor.yy184)); } + yymsp[-3].minor.yy392 = yylhsminor.yy392; + break; + case 510: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ +{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy392), yymsp[-1].minor.yy864)); } + yymsp[-5].minor.yy392 = yylhsminor.yy392; + break; + case 512: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy369, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy369, NULL)); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; + break; + case 528: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy184 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy184 = yylhsminor.yy184; + break; + case 533: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 601: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==601); +{ yylhsminor.yy392 = createColumnNode(pCxt, &yymsp[-2].minor.yy369, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; + break; + case 534: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ +{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy184, yymsp[-1].minor.yy392)); } + yymsp[-3].minor.yy392 = yylhsminor.yy392; + break; + case 535: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ +{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy392), yymsp[-2].minor.yy184, yymsp[-1].minor.yy392)); } + yymsp[-4].minor.yy392 = yylhsminor.yy392; + break; + case 538: /* when_then_expr ::= WHEN common_expression THEN common_expression */ +{ yymsp[-3].minor.yy392 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), releaseRawExprNode(pCxt, yymsp[0].minor.yy392)); } + break; + case 540: /* case_when_else_opt ::= ELSE common_expression */ +{ yymsp[-1].minor.yy392 = releaseRawExprNode(pCxt, yymsp[0].minor.yy392); } + break; + case 541: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 546: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==546); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy392); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy220, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 523: /* predicate ::= expr_or_subquery IS NOT NULL */ + case 542: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy752), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy392); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy392), releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } - yymsp[-3].minor.yy752 = yylhsminor.yy752; + yymsp[-4].minor.yy392 = yylhsminor.yy392; break; - case 525: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy980 = OP_TYPE_LOWER_THAN; } - break; - case 526: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy980 = OP_TYPE_GREATER_THAN; } - break; - case 527: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy980 = OP_TYPE_LOWER_EQUAL; } - break; - case 528: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy980 = OP_TYPE_GREATER_EQUAL; } - break; - case 529: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy980 = OP_TYPE_NOT_EQUAL; } - break; - case 530: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy980 = OP_TYPE_EQUAL; } - break; - case 531: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy980 = OP_TYPE_LIKE; } - break; - case 532: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy980 = OP_TYPE_NOT_LIKE; } - break; - case 533: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy980 = OP_TYPE_MATCH; } - break; - case 534: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy980 = OP_TYPE_NMATCH; } - break; - case 535: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy980 = OP_TYPE_JSON_CONTAINS; } - break; - case 536: /* in_op ::= IN */ -{ yymsp[0].minor.yy980 = OP_TYPE_IN; } - break; - case 537: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy980 = OP_TYPE_NOT_IN; } - break; - case 538: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -{ yylhsminor.yy752 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy264)); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; - break; - case 540: /* boolean_value_expression ::= NOT boolean_primary */ + case 543: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy752), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy392); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy392), releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } - yymsp[-1].minor.yy752 = yylhsminor.yy752; + yymsp[-5].minor.yy392 = yylhsminor.yy392; break; - case 541: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 544: /* predicate ::= expr_or_subquery IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy752); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), releaseRawExprNode(pCxt, yymsp[0].minor.yy752))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), NULL)); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 542: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 545: /* predicate ::= expr_or_subquery IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy752); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy752); - yylhsminor.yy752 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), releaseRawExprNode(pCxt, yymsp[0].minor.yy752))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy392), NULL)); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + yymsp[-3].minor.yy392 = yylhsminor.yy392; break; - case 550: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy752 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy752, yymsp[0].minor.yy752, NULL); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 547: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy220 = OP_TYPE_LOWER_THAN; } break; - case 553: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy752 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy879, &yymsp[0].minor.yy879); } - yymsp[-1].minor.yy752 = yylhsminor.yy752; + case 548: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy220 = OP_TYPE_GREATER_THAN; } break; - case 554: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy752 = createRealTableNode(pCxt, &yymsp[-3].minor.yy879, &yymsp[-1].minor.yy879, &yymsp[0].minor.yy879); } - yymsp[-3].minor.yy752 = yylhsminor.yy752; + case 549: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy220 = OP_TYPE_LOWER_EQUAL; } break; - case 555: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy752 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy752), &yymsp[0].minor.yy879); } - yymsp[-1].minor.yy752 = yylhsminor.yy752; + case 550: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy220 = OP_TYPE_GREATER_EQUAL; } break; - case 557: /* alias_opt ::= */ -{ yymsp[1].minor.yy879 = nil_token; } + case 551: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy220 = OP_TYPE_NOT_EQUAL; } break; - case 559: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy879 = yymsp[0].minor.yy879; } + case 552: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy220 = OP_TYPE_EQUAL; } break; - case 560: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 561: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==561); -{ yymsp[-2].minor.yy752 = yymsp[-1].minor.yy752; } + case 553: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy220 = OP_TYPE_LIKE; } break; - case 562: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy752 = createJoinTableNode(pCxt, yymsp[-4].minor.yy792, yymsp[-5].minor.yy752, yymsp[-2].minor.yy752, yymsp[0].minor.yy752); } - yymsp[-5].minor.yy752 = yylhsminor.yy752; + case 554: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy220 = OP_TYPE_NOT_LIKE; } break; - case 563: /* join_type ::= */ -{ yymsp[1].minor.yy792 = JOIN_TYPE_INNER; } + case 555: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy220 = OP_TYPE_MATCH; } break; - case 564: /* join_type ::= INNER */ -{ yymsp[0].minor.yy792 = JOIN_TYPE_INNER; } + case 556: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy220 = OP_TYPE_NMATCH; } break; - case 565: /* 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 */ + case 557: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy220 = OP_TYPE_JSON_CONTAINS; } + break; + case 558: /* in_op ::= IN */ +{ yymsp[0].minor.yy220 = OP_TYPE_IN; } + break; + case 559: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy220 = OP_TYPE_NOT_IN; } + break; + case 560: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy184)); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; + break; + case 562: /* boolean_value_expression ::= NOT boolean_primary */ { - yymsp[-13].minor.yy752 = createSelectStmt(pCxt, yymsp[-11].minor.yy547, yymsp[-9].minor.yy264, yymsp[-8].minor.yy752, yymsp[-12].minor.yy264); - yymsp[-13].minor.yy752 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy752, yymsp[-10].minor.yy547); - yymsp[-13].minor.yy752 = addWhereClause(pCxt, yymsp[-13].minor.yy752, yymsp[-7].minor.yy752); - yymsp[-13].minor.yy752 = addPartitionByClause(pCxt, yymsp[-13].minor.yy752, yymsp[-6].minor.yy264); - yymsp[-13].minor.yy752 = addWindowClauseClause(pCxt, yymsp[-13].minor.yy752, yymsp[-2].minor.yy752); - yymsp[-13].minor.yy752 = addGroupByClause(pCxt, yymsp[-13].minor.yy752, yymsp[-1].minor.yy264); - yymsp[-13].minor.yy752 = addHavingClause(pCxt, yymsp[-13].minor.yy752, yymsp[0].minor.yy752); - yymsp[-13].minor.yy752 = addRangeClause(pCxt, yymsp[-13].minor.yy752, yymsp[-5].minor.yy752); - yymsp[-13].minor.yy752 = addEveryClause(pCxt, yymsp[-13].minor.yy752, yymsp[-4].minor.yy752); - yymsp[-13].minor.yy752 = addFillClause(pCxt, yymsp[-13].minor.yy752, yymsp[-3].minor.yy752); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy392), NULL)); } + yymsp[-1].minor.yy392 = yylhsminor.yy392; break; - case 566: /* hint_list ::= */ -{ yymsp[1].minor.yy264 = createHintNodeList(pCxt, NULL); } - break; - case 567: /* hint_list ::= NK_HINT */ -{ yylhsminor.yy264 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy264 = yylhsminor.yy264; - break; - case 572: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy547 = false; } - break; - case 575: /* select_item ::= NK_STAR */ -{ yylhsminor.yy752 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy752 = yylhsminor.yy752; - break; - case 577: /* select_item ::= common_expression column_alias */ - case 587: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==587); -{ yylhsminor.yy752 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy752), &yymsp[0].minor.yy879); } - yymsp[-1].minor.yy752 = yylhsminor.yy752; - break; - case 578: /* select_item ::= common_expression AS column_alias */ - case 588: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==588); -{ yylhsminor.yy752 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), &yymsp[0].minor.yy879); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; - break; - case 583: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 613: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==613); - case 633: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==633); -{ yymsp[-2].minor.yy264 = yymsp[0].minor.yy264; } - break; - case 590: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ -{ yymsp[-5].minor.yy752 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy752), releaseRawExprNode(pCxt, yymsp[-1].minor.yy752)); } - break; - case 591: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy752 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy752)); } - break; - case 592: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy752 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy752), NULL, yymsp[-1].minor.yy752, yymsp[0].minor.yy752); } - break; - case 593: /* 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.yy752 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy752), releaseRawExprNode(pCxt, yymsp[-3].minor.yy752), yymsp[-1].minor.yy752, yymsp[0].minor.yy752); } - break; - case 594: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ -{ yymsp[-6].minor.yy752 = createEventWindowNode(pCxt, yymsp[-3].minor.yy752, yymsp[0].minor.yy752); } - break; - case 595: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy752 = createCountWindowNode(pCxt, &yymsp[-1].minor.yy0, &yymsp[-1].minor.yy0); } - break; - case 596: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy752 = createCountWindowNode(pCxt, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0); } - break; - case 603: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy752 = createFillNode(pCxt, yymsp[-1].minor.yy284, NULL); } - break; - case 604: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ -{ yymsp[-5].minor.yy752 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy264)); } - break; - case 605: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ -{ yymsp[-5].minor.yy752 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy264)); } - break; - case 606: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy284 = FILL_MODE_NONE; } - break; - case 607: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy284 = FILL_MODE_PREV; } - break; - case 608: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy284 = FILL_MODE_NULL; } - break; - case 609: /* fill_mode ::= NULL_F */ -{ yymsp[0].minor.yy284 = FILL_MODE_NULL_F; } - break; - case 610: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy284 = FILL_MODE_LINEAR; } - break; - case 611: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy284 = FILL_MODE_NEXT; } - break; - case 614: /* group_by_list ::= expr_or_subquery */ -{ yylhsminor.yy264 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy752))); } - yymsp[0].minor.yy264 = yylhsminor.yy264; - break; - case 615: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -{ yylhsminor.yy264 = addNodeToList(pCxt, yymsp[-2].minor.yy264, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy752))); } - yymsp[-2].minor.yy264 = yylhsminor.yy264; - break; - case 619: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -{ yymsp[-5].minor.yy752 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy752), releaseRawExprNode(pCxt, yymsp[-1].minor.yy752)); } - break; - case 620: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy752 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy752)); } - break; - case 623: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 563: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - yylhsminor.yy752 = addOrderByClause(pCxt, yymsp[-3].minor.yy752, yymsp[-2].minor.yy264); - yylhsminor.yy752 = addSlimitClause(pCxt, yylhsminor.yy752, yymsp[-1].minor.yy752); - yylhsminor.yy752 = addLimitClause(pCxt, yylhsminor.yy752, yymsp[0].minor.yy752); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy392); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } - yymsp[-3].minor.yy752 = yylhsminor.yy752; + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 626: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -{ yylhsminor.yy752 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy752, yymsp[0].minor.yy752); } - yymsp[-3].minor.yy752 = yylhsminor.yy752; + case 564: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy392); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); + yylhsminor.yy392 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); + } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 627: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -{ yylhsminor.yy752 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy752, yymsp[0].minor.yy752); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 572: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy392 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy392, yymsp[0].minor.yy392, NULL); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 635: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 639: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==639); -{ yymsp[-1].minor.yy752 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 575: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy392 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy369, &yymsp[0].minor.yy369); } + yymsp[-1].minor.yy392 = yylhsminor.yy392; break; - case 636: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 640: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==640); -{ yymsp[-3].minor.yy752 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 576: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy392 = createRealTableNode(pCxt, &yymsp[-3].minor.yy369, &yymsp[-1].minor.yy369, &yymsp[0].minor.yy369); } + yymsp[-3].minor.yy392 = yylhsminor.yy392; break; - case 637: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 641: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==641); -{ yymsp[-3].minor.yy752 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 577: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy392 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy392), &yymsp[0].minor.yy369); } + yymsp[-1].minor.yy392 = yylhsminor.yy392; break; - case 642: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy752 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy752); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 579: /* alias_opt ::= */ +{ yymsp[1].minor.yy369 = nil_token; } break; - case 647: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy752 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy752), yymsp[-1].minor.yy248, yymsp[0].minor.yy937); } - yymsp[-2].minor.yy752 = yylhsminor.yy752; + case 581: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy369 = yymsp[0].minor.yy369; } break; - case 648: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy248 = ORDER_ASC; } + case 582: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 583: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==583); +{ yymsp[-2].minor.yy392 = yymsp[-1].minor.yy392; } break; - case 649: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy248 = ORDER_ASC; } + case 584: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy392 = createJoinTableNode(pCxt, yymsp[-4].minor.yy932, yymsp[-5].minor.yy392, yymsp[-2].minor.yy392, yymsp[0].minor.yy392); } + yymsp[-5].minor.yy392 = yylhsminor.yy392; break; - case 650: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy248 = ORDER_DESC; } + case 585: /* join_type ::= */ +{ yymsp[1].minor.yy932 = JOIN_TYPE_INNER; } break; - case 651: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy937 = NULL_ORDER_DEFAULT; } + case 586: /* join_type ::= INNER */ +{ yymsp[0].minor.yy932 = JOIN_TYPE_INNER; } break; - case 652: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy937 = NULL_ORDER_FIRST; } + case 587: /* 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.yy392 = createSelectStmt(pCxt, yymsp[-11].minor.yy377, yymsp[-9].minor.yy184, yymsp[-8].minor.yy392, yymsp[-12].minor.yy184); + yymsp[-13].minor.yy392 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy392, yymsp[-10].minor.yy377); + yymsp[-13].minor.yy392 = addWhereClause(pCxt, yymsp[-13].minor.yy392, yymsp[-7].minor.yy392); + yymsp[-13].minor.yy392 = addPartitionByClause(pCxt, yymsp[-13].minor.yy392, yymsp[-6].minor.yy184); + yymsp[-13].minor.yy392 = addWindowClauseClause(pCxt, yymsp[-13].minor.yy392, yymsp[-2].minor.yy392); + yymsp[-13].minor.yy392 = addGroupByClause(pCxt, yymsp[-13].minor.yy392, yymsp[-1].minor.yy184); + yymsp[-13].minor.yy392 = addHavingClause(pCxt, yymsp[-13].minor.yy392, yymsp[0].minor.yy392); + yymsp[-13].minor.yy392 = addRangeClause(pCxt, yymsp[-13].minor.yy392, yymsp[-5].minor.yy392); + yymsp[-13].minor.yy392 = addEveryClause(pCxt, yymsp[-13].minor.yy392, yymsp[-4].minor.yy392); + yymsp[-13].minor.yy392 = addFillClause(pCxt, yymsp[-13].minor.yy392, yymsp[-3].minor.yy392); + } break; - case 653: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy937 = NULL_ORDER_LAST; } + case 588: /* hint_list ::= */ +{ yymsp[1].minor.yy184 = createHintNodeList(pCxt, NULL); } + break; + case 589: /* hint_list ::= NK_HINT */ +{ yylhsminor.yy184 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy184 = yylhsminor.yy184; + break; + case 594: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy377 = false; } + break; + case 597: /* select_item ::= NK_STAR */ +{ yylhsminor.yy392 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy392 = yylhsminor.yy392; + break; + case 599: /* select_item ::= common_expression column_alias */ + case 609: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==609); +{ yylhsminor.yy392 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy392), &yymsp[0].minor.yy369); } + yymsp[-1].minor.yy392 = yylhsminor.yy392; + break; + case 600: /* select_item ::= common_expression AS column_alias */ + case 610: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==610); +{ yylhsminor.yy392 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), &yymsp[0].minor.yy369); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; + break; + case 605: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 635: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==635); + case 655: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==655); +{ yymsp[-2].minor.yy184 = yymsp[0].minor.yy184; } + break; + case 612: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ +{ yymsp[-5].minor.yy392 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy392), releaseRawExprNode(pCxt, yymsp[-1].minor.yy392)); } + break; + case 613: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ +{ yymsp[-3].minor.yy392 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy392)); } + break; + case 614: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy392 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy392), NULL, yymsp[-1].minor.yy392, yymsp[0].minor.yy392); } + break; + case 615: /* 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.yy392 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy392), releaseRawExprNode(pCxt, yymsp[-3].minor.yy392), yymsp[-1].minor.yy392, yymsp[0].minor.yy392); } + break; + case 616: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ +{ yymsp[-6].minor.yy392 = createEventWindowNode(pCxt, yymsp[-3].minor.yy392, yymsp[0].minor.yy392); } + break; + case 617: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy392 = createCountWindowNode(pCxt, &yymsp[-1].minor.yy0, &yymsp[-1].minor.yy0); } + break; + case 618: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy392 = createCountWindowNode(pCxt, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0); } + break; + case 625: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy392 = createFillNode(pCxt, yymsp[-1].minor.yy374, NULL); } + break; + case 626: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ +{ yymsp[-5].minor.yy392 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy184)); } + break; + case 627: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ +{ yymsp[-5].minor.yy392 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy184)); } + break; + case 628: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy374 = FILL_MODE_NONE; } + break; + case 629: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy374 = FILL_MODE_PREV; } + break; + case 630: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy374 = FILL_MODE_NULL; } + break; + case 631: /* fill_mode ::= NULL_F */ +{ yymsp[0].minor.yy374 = FILL_MODE_NULL_F; } + break; + case 632: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy374 = FILL_MODE_LINEAR; } + break; + case 633: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy374 = FILL_MODE_NEXT; } + break; + case 636: /* group_by_list ::= expr_or_subquery */ +{ yylhsminor.yy184 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } + yymsp[0].minor.yy184 = yylhsminor.yy184; + break; + case 637: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ +{ yylhsminor.yy184 = addNodeToList(pCxt, yymsp[-2].minor.yy184, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } + yymsp[-2].minor.yy184 = yylhsminor.yy184; + break; + case 641: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +{ yymsp[-5].minor.yy392 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy392), releaseRawExprNode(pCxt, yymsp[-1].minor.yy392)); } + break; + case 642: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ +{ yymsp[-3].minor.yy392 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy392)); } + break; + case 645: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ +{ + yylhsminor.yy392 = addOrderByClause(pCxt, yymsp[-3].minor.yy392, yymsp[-2].minor.yy184); + yylhsminor.yy392 = addSlimitClause(pCxt, yylhsminor.yy392, yymsp[-1].minor.yy392); + yylhsminor.yy392 = addLimitClause(pCxt, yylhsminor.yy392, yymsp[0].minor.yy392); + } + yymsp[-3].minor.yy392 = yylhsminor.yy392; + break; + case 648: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +{ yylhsminor.yy392 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy392, yymsp[0].minor.yy392); } + yymsp[-3].minor.yy392 = yylhsminor.yy392; + break; + case 649: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +{ yylhsminor.yy392 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy392, yymsp[0].minor.yy392); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; + break; + case 657: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 661: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==661); +{ yymsp[-1].minor.yy392 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + break; + case 658: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 662: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==662); +{ yymsp[-3].minor.yy392 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + break; + case 659: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 663: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==663); +{ yymsp[-3].minor.yy392 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + break; + case 664: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy392); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; + break; + case 669: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy392 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), yymsp[-1].minor.yy578, yymsp[0].minor.yy217); } + yymsp[-2].minor.yy392 = yylhsminor.yy392; + break; + case 670: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy578 = ORDER_ASC; } + break; + case 671: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy578 = ORDER_ASC; } + break; + case 672: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy578 = ORDER_DESC; } + break; + case 673: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy217 = NULL_ORDER_DEFAULT; } + break; + case 674: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy217 = NULL_ORDER_FIRST; } + break; + case 675: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy217 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parAlterToBalanceTest.cpp b/source/libs/parser/test/parAlterToBalanceTest.cpp index 1cf132a632..84be1e92d0 100644 --- a/source/libs/parser/test/parAlterToBalanceTest.cpp +++ b/source/libs/parser/test/parAlterToBalanceTest.cpp @@ -337,7 +337,7 @@ TEST_F(ParserInitialATest, alterDatabaseSemanticCheck) { run("ALTER DATABASE test PAGES 63", TSDB_CODE_PAR_INVALID_DB_OPTION); run("ALTER DATABASE test WAL_LEVEL 0", TSDB_CODE_PAR_INVALID_DB_OPTION); run("ALTER DATABASE test WAL_LEVEL 3", TSDB_CODE_PAR_INVALID_DB_OPTION); - run("ALTER DATABASE test REPLICA 2", TSDB_CODE_PAR_INVALID_DB_OPTION); + //run("ALTER DATABASE test REPLICA 2", TSDB_CODE_PAR_INVALID_DB_OPTION); run("ALTER DATABASE test STT_TRIGGER 0", TSDB_CODE_PAR_INVALID_DB_OPTION); run("ALTER DATABASE test STT_TRIGGER 17", TSDB_CODE_PAR_INVALID_DB_OPTION); // Regardless of the specific sentence @@ -784,7 +784,7 @@ TEST_F(ParserInitialATest, alterTableSemanticCheck) { run("ALTER TABLE st1s1 DROP TAG tag1", TSDB_CODE_PAR_INVALID_ALTER_TABLE); run("ALTER TABLE st1s1 MODIFY TAG tag2 VARCHAR(30)", TSDB_CODE_PAR_INVALID_ALTER_TABLE); run("ALTER TABLE st1s1 RENAME TAG tag1 tag11", TSDB_CODE_PAR_INVALID_ALTER_TABLE); - run("ALTER TABLE st1s1 SET TAG tag2 = '123456789012345678901'", TSDB_CODE_PAR_WRONG_VALUE_TYPE); + run("ALTER TABLE st1s1 SET TAG tag2 = '123456789012345678901'", TSDB_CODE_PAR_VALUE_TOO_LONG); } /* diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index c1793bfb90..c79fbd01f0 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -341,10 +341,11 @@ static int32_t addDefaultScanCol(const STableMeta* pMeta, SNodeList** pCols) { if (TSDB_SYSTEM_TABLE == pMeta->tableType) { return addSystableFirstCol(pMeta->uid, pMeta->schema, pCols, pMeta); } - if (hasPkInTable(pMeta)) { - addPkCol(pMeta->uid, pMeta->schema + 1, pCols, pMeta); + int32_t code = addPrimaryKeyCol(pMeta->uid, pMeta->schema, pCols, pMeta); + if (code == TSDB_CODE_SUCCESS && hasPkInTable(pMeta)) { + code = addPkCol(pMeta->uid, pMeta->schema + 1, pCols, pMeta); } - return addPrimaryKeyCol(pMeta->uid, pMeta->schema, pCols, pMeta); + return code; } static int32_t makeScanLogicNode(SLogicPlanContext* pCxt, SRealTableNode* pRealTable, bool hasRepeatScanFuncs, diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 793f8914dc..1e2f3c53af 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -2096,6 +2096,13 @@ static bool eliminateProjOptMayBeOptimized(SLogicNode* pNode) { TSDB_SUPER_TABLE == ((SScanLogicNode*)nodesListGetNode(pNode->pChildren, 0))->tableType)) { return false; } + + if (QUERY_NODE_LOGIC_PLAN_DYN_QUERY_CTRL == nodeType(nodesListGetNode(pNode->pChildren, 0))) { + SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pNode->pChildren, 0); + if(LIST_LENGTH(pChild->pTargets) != LIST_LENGTH(pNode->pTargets)) { + return false; + } + } SProjectLogicNode* pProjectNode = (SProjectLogicNode*)pNode; if (NULL != pProjectNode->node.pLimit || NULL != pProjectNode->node.pSlimit || diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index b1cd10eac9..5f43ae9f3c 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -808,7 +808,11 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o complete = false; continue; } - char *p = colDataGetData(params[m].columnData, i); + + // 1=1 and tag_column = 1 + int32_t ind = (i >= params[m].numOfRows)? (params[m].numOfRows - 1):i; + char* p = colDataGetData(params[m].columnData, ind); + GET_TYPED_DATA(value, bool, params[m].columnData->info.type, p); if (LOGIC_COND_TYPE_AND == node->condType && (false == value)) { diff --git a/source/libs/stream/inc/streamInt.h b/source/libs/stream/inc/streamInt.h index d0055d5400..ff56ae76b0 100644 --- a/source/libs/stream/inc/streamInt.h +++ b/source/libs/stream/inc/streamInt.h @@ -131,7 +131,7 @@ int32_t streamQueueItemGetSize(const SStreamQueueItem* pItem); void streamQueueItemIncSize(const SStreamQueueItem* pItem, int32_t size); const char* streamQueueItemGetTypeStr(int32_t type); SStreamQueueItem* streamQueueMergeQueueItem(SStreamQueueItem* dst, SStreamQueueItem* pElem); -int32_t streamTransferStateToStreamTask(SStreamTask* pTask); +int32_t streamTransferStatePrepare(SStreamTask* pTask); SStreamQueue* streamQueueOpen(int64_t cap); void streamQueueClose(SStreamQueue* pQueue, int32_t taskId); diff --git a/source/libs/stream/src/streamCheckpoint.c b/source/libs/stream/src/streamCheckpoint.c index 607e31bfe6..f58c72eded 100644 --- a/source/libs/stream/src/streamCheckpoint.c +++ b/source/libs/stream/src/streamCheckpoint.c @@ -300,6 +300,8 @@ int32_t streamSaveTaskCheckpointInfo(SStreamTask* p, int64_t checkpointId) { taosThreadMutexLock(&p->lock); SStreamTaskState* pStatus = streamTaskGetStatus(p); + ETaskStatus prevStatus = pStatus->state; + if (pStatus->state == TASK_STATUS__CK) { ASSERT(pCKInfo->checkpointId <= pCKInfo->checkpointingId && pCKInfo->checkpointingId == checkpointId && pCKInfo->checkpointVer <= pCKInfo->processedVer); @@ -325,8 +327,9 @@ int32_t streamSaveTaskCheckpointInfo(SStreamTask* p, int64_t checkpointId) { } stDebug("vgId:%d s-task:%s level:%d open upstream inputQ, save status after checkpoint, checkpointId:%" PRId64 - ", Ver(saved):%" PRId64 " currentVer:%" PRId64 ", status: normal, prev:%s", - vgId, id, p->info.taskLevel, checkpointId, pCKInfo->checkpointVer, pCKInfo->nextProcessVer, pStatus->name); + ", Ver(saved):%" PRId64 " currentVer:%" PRId64 ", status: ready, prev:%s", + vgId, id, p->info.taskLevel, checkpointId, pCKInfo->checkpointVer, pCKInfo->nextProcessVer, + streamTaskGetStatusStr(prevStatus)); // save the task if not sink task if (p->info.taskLevel <= TASK_LEVEL__SINK) { @@ -437,9 +440,11 @@ int32_t streamTaskUploadChkp(SStreamTask* pTask, int64_t chkpId, char* taskId) { if (type == UPLOAD_DISABLE) { return 0; } + if (pTask == NULL || pTask->pBackend == NULL) { return 0; } + SAsyncUploadArg* arg = taosMemoryCalloc(1, sizeof(SAsyncUploadArg)); arg->type = type; arg->taskId = taosStrdup(taskId); @@ -448,16 +453,19 @@ int32_t streamTaskUploadChkp(SStreamTask* pTask, int64_t chkpId, char* taskId) { return streamMetaAsyncExec(pTask->pMeta, doUploadChkp, arg, NULL); } -int32_t streamTaskBuildCheckpoint(SStreamTask* pTask) { - int32_t code = TSDB_CODE_SUCCESS; - int64_t startTs = pTask->chkInfo.startTs; - int64_t ckId = pTask->chkInfo.checkpointingId; - const char* id = pTask->id.idStr; - bool dropRelHTask = (streamTaskGetPrevStatus(pTask) == TASK_STATUS__HALT); - // sink task do not need to save the status, and generated the checkpoint +int32_t streamTaskBuildCheckpoint(SStreamTask* pTask) { + int32_t code = TSDB_CODE_SUCCESS; + int64_t startTs = pTask->chkInfo.startTs; + int64_t ckId = pTask->chkInfo.checkpointingId; + const char* id = pTask->id.idStr; + bool dropRelHTask = (streamTaskGetPrevStatus(pTask) == TASK_STATUS__HALT); + SStreamMeta* pMeta = pTask->pMeta; + + // sink task does not need to save the status, and generated the checkpoint if (pTask->info.taskLevel != TASK_LEVEL__SINK) { stDebug("s-task:%s level:%d start gen checkpoint, checkpointId:%" PRId64, id, pTask->info.taskLevel, ckId); + code = streamBackendDoCheckpoint(pTask->pBackend, ckId); if (code != TSDB_CODE_SUCCESS) { stError("s-task:%s gen checkpoint:%" PRId64 " failed, code:%s", id, ckId, tstrerror(terrno)); @@ -500,10 +508,11 @@ 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, 1); + streamBuildAndSendDropTaskMsg(pTask->pMsgCb, pMeta->vgId, &hTaskId, 1); } else { stWarn("s-task:%s related fill-history task:0x%x is erased", id, (int32_t)pTask->hTaskInfo.id.taskId); } + taosThreadMutexUnlock(&pTask->lock); } diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index dc790b5b2d..0af664f1e1 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -1094,10 +1094,10 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, i // trans-state msg has been sent to downstream successfully. let's transfer the fill-history task state if (pTask->msgInfo.dispatchMsgType == STREAM_INPUT__TRANS_STATE) { - stDebug("s-task:%s dispatch transtate msgId:%d to downstream successfully, start to transfer state", id, msgId); + stDebug("s-task:%s dispatch transtate msgId:%d to downstream successfully, start to prepare transfer state", id, msgId); ASSERT(pTask->info.fillHistory == 1); - code = streamTransferStateToStreamTask(pTask); + code = streamTransferStatePrepare(pTask); if (code != TSDB_CODE_SUCCESS) { // todo: do nothing if error happens } diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index cb51d90fba..24d1bf7603 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -21,7 +21,7 @@ #define STREAM_RESULT_DUMP_SIZE_THRESHOLD (1048576 * 1) // 1MiB result data #define STREAM_SCAN_HISTORY_TIMESLICE 1000 // 1000 ms -static int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask); +static int32_t streamTransferStateDoPrepare(SStreamTask* pTask); bool streamTaskShouldStop(const SStreamTask* pTask) { SStreamTaskState* pState = streamTaskGetStatus(pTask); @@ -316,7 +316,7 @@ static void waitForTaskIdle(SStreamTask* pTask, SStreamTask* pStreamTask) { } } -int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask) { +int32_t streamTransferStateDoPrepare(SStreamTask* pTask) { SStreamMeta* pMeta = pTask->pMeta; const char* id = pTask->id.idStr; @@ -340,9 +340,9 @@ int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask) { } else { double el = (taosGetTimestampMs() - pTask->execInfo.step2Start) / 1000.; stDebug( - "s-task:%s fill-history task end, scan wal elapsed time:%.2fSec,update related stream task:%s info, transfer " - "exec state", - id, el, pStreamTask->id.idStr); + "s-task:%s fill-history task end, status:%s, scan wal elapsed time:%.2fSec, update related stream task:%s " + "info, prepare transfer exec state", + id, streamTaskGetStatus(pTask)->name, el, pStreamTask->id.idStr); } ETaskStatus status = streamTaskGetStatus(pStreamTask)->state; @@ -366,9 +366,6 @@ int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask) { } } - // wait for the stream task to handle all in the inputQ, and to be idle - waitForTaskIdle(pTask, pStreamTask); - // In case of sink tasks, no need to halt them. // In case of source tasks and agg tasks, we should HALT them, and wait for them to be idle. And then, it's safe to // start the task state transfer procedure. @@ -394,17 +391,14 @@ int32_t streamDoTransferStateToStreamTask(SStreamTask* pTask) { stDebug("s-task:%s no need to update/reset filter time window for non-source tasks", pStreamTask->id.idStr); } - // 2. transfer the ownership of executor state - streamTaskReleaseState(pTask); - streamTaskReloadState(pStreamTask); - - // 3. send msg to mnode to launch a checkpoint to keep the state for current stream + // NOTE: transfer the ownership of executor state before handle the checkpoint block during stream exec + // 2. send msg to mnode to launch a checkpoint to keep the state for current stream streamTaskSendCheckpointReq(pStreamTask); - // 4. assign the status to the value that will be kept in disk + // 3. assign the status to the value that will be kept in disk pStreamTask->status.taskStatus = streamTaskGetStatus(pStreamTask)->state; - // 5. open the inputQ for all upstream tasks + // 4. open the inputQ for all upstream tasks streamTaskOpenAllUpstreamInput(pStreamTask); streamMetaReleaseTask(pMeta, pStreamTask); @@ -417,7 +411,7 @@ static int32_t haltCallback(SStreamTask* pTask, void* param) { return TSDB_CODE_SUCCESS; } -int32_t streamTransferStateToStreamTask(SStreamTask* pTask) { +int32_t streamTransferStatePrepare(SStreamTask* pTask) { int32_t code = TSDB_CODE_SUCCESS; SStreamMeta* pMeta = pTask->pMeta; @@ -425,7 +419,7 @@ int32_t streamTransferStateToStreamTask(SStreamTask* pTask) { int32_t level = pTask->info.taskLevel; if (level == TASK_LEVEL__AGG || level == TASK_LEVEL__SOURCE) { // do transfer task operator states. - code = streamDoTransferStateToStreamTask(pTask); + code = streamTransferStateDoPrepare(pTask); } else { // no state transfer for sink tasks, and drop fill-history task, followed by opening inputQ of sink task. SStreamTask* pStreamTask = streamMetaAcquireTask(pMeta, pTask->streamTaskId.streamId, pTask->streamTaskId.taskId); @@ -541,7 +535,7 @@ int32_t streamProcessTransstateBlock(SStreamTask* pTask, SStreamDataBlock* pBloc stDebug("s-task:%s non-dispatch task, level:%d start to transfer state directly", id, level); ASSERT(pTask->info.fillHistory == 1); - code = streamTransferStateToStreamTask(pTask); + code = streamTransferStatePrepare(pTask); if (code != TSDB_CODE_SUCCESS) { /*int8_t status = */ streamTaskSetSchedStatusInactive(pTask); } @@ -622,10 +616,31 @@ int32_t doStreamExecTask(SStreamTask* pTask) { } } - int64_t st = taosGetTimestampMs(); + if (type == STREAM_INPUT__CHECKPOINT) { + // transfer the state from fill-history to related stream task before generating the checkpoint. + bool dropRelHTask = (streamTaskGetPrevStatus(pTask) == TASK_STATUS__HALT); + if (dropRelHTask) { + ASSERT(HAS_RELATED_FILLHISTORY_TASK(pTask)); - const SStreamQueueItem* pItem = pInput; - stDebug("s-task:%s start to process batch of blocks, num:%d, type:%d", id, numOfBlocks, pItem->type); + STaskId* pHTaskId = &pTask->hTaskInfo.id; + SStreamTask* pHTask = streamMetaAcquireTask(pTask->pMeta, pHTaskId->streamId, pHTaskId->taskId); + if (pHTask != NULL) { + // 2. transfer the ownership of executor state + streamTaskReleaseState(pHTask); + streamTaskReloadState(pTask); + stDebug("s-task:%s transfer state from fill-history task:%s, status:%s completed", id, pHTask->id.idStr, + streamTaskGetStatus(pHTask)->name); + + streamMetaReleaseTask(pTask->pMeta, pHTask); + } else { + stError("s-task:%s related fill-history task:0x%x failed to acquire, transfer state failed", id, + (int32_t)pHTaskId->taskId); + } + } + } + + int64_t st = taosGetTimestampMs(); + stDebug("s-task:%s start to process batch of blocks, num:%d, type:%s", id, numOfBlocks, streamQueueItemGetTypeStr(type)); int64_t ver = pTask->chkInfo.processedVer; doSetStreamInputBlock(pTask, pInput, &ver, id); diff --git a/source/libs/stream/src/streamMeta.c b/source/libs/stream/src/streamMeta.c index a072ee1f6f..5f6440c06d 100644 --- a/source/libs/stream/src/streamMeta.c +++ b/source/libs/stream/src/streamMeta.c @@ -1128,7 +1128,11 @@ static int32_t metaHeartbeatToMnodeImpl(SStreamMeta* pMeta) { } if ((*pTask)->exec.pWalReader != NULL) { - entry.processedVer = (*pTask)->chkInfo.nextProcessVer - 1; + entry.processedVer = walReaderGetCurrentVer((*pTask)->exec.pWalReader) - 1; + if (entry.processedVer < 0) { + entry.processedVer = (*pTask)->chkInfo.processedVer; + } + walReaderValidVersionRange((*pTask)->exec.pWalReader, &entry.verStart, &entry.verEnd); } diff --git a/source/libs/stream/src/streamSessionState.c b/source/libs/stream/src/streamSessionState.c index 723f04c499..295132a4f5 100644 --- a/source/libs/stream/src/streamSessionState.c +++ b/source/libs/stream/src/streamSessionState.c @@ -310,7 +310,7 @@ int32_t allocSessioncWinBuffByNextPosition(SStreamFileState* pFileState, SStream int32_t size = taosArrayGetSize(pWinStates); if (pCur->buffIndex >= 0) { if (pCur->buffIndex >= size) { - pNewPos = insertNewSessionWindow(pFileState, pWinStates, pWinKey, size); + pNewPos = addNewSessionWindow(pFileState, pWinStates, pWinKey); goto _end; } pNewPos = insertNewSessionWindow(pFileState, pWinStates, pWinKey, pCur->buffIndex); @@ -327,12 +327,12 @@ int32_t allocSessioncWinBuffByNextPosition(SStreamFileState* pFileState, SStream } } pNewPos = getNewRowPosForWrite(pFileState); + memcpy(pNewPos->pKey, pWinKey, sizeof(SSessionKey)); pNewPos->needFree = true; pNewPos->beFlushed = true; } _end: - memcpy(pNewPos->pKey, pWinKey, sizeof(SSessionKey)); (*ppVal) = pNewPos; return TSDB_CODE_SUCCESS; } diff --git a/source/libs/stream/src/streamTask.c b/source/libs/stream/src/streamTask.c index 45a9a68d3d..4ca784a32f 100644 --- a/source/libs/stream/src/streamTask.c +++ b/source/libs/stream/src/streamTask.c @@ -456,12 +456,49 @@ void tFreeStreamTask(SStreamTask* pTask) { stDebug("s-task:0x%x free task completed", taskId); } +static void setInitialVersionInfo(SStreamTask* pTask, int64_t ver) { + SCheckpointInfo* pChkInfo = &pTask->chkInfo; + SDataRange* pRange = &pTask->dataRange; + + // only set the version info for stream tasks without fill-history task + if ((pTask->info.fillHistory == 0) && (!HAS_RELATED_FILLHISTORY_TASK(pTask))) { + pChkInfo->checkpointVer = ver - 1; // only update when generating checkpoint + pChkInfo->processedVer = ver - 1; // already processed version + pChkInfo->nextProcessVer = ver; // next processed version + + pRange->range.maxVer = ver; + pRange->range.minVer = ver; + } else { + // the initial value of processedVer/nextProcessVer/checkpointVer for stream task with related fill-history task + // is set at the mnode. + if (pTask->info.fillHistory == 1) { + pChkInfo->checkpointVer = pRange->range.maxVer; + pChkInfo->processedVer = pRange->range.maxVer; + pChkInfo->nextProcessVer = pRange->range.maxVer + 1; + } else { + pChkInfo->checkpointVer = pRange->range.minVer - 1; + pChkInfo->processedVer = pRange->range.minVer - 1; + pChkInfo->nextProcessVer = pRange->range.minVer; + + { // for compatible purpose, remove it later + if (pRange->range.minVer == 0) { + pChkInfo->checkpointVer = 0; + pChkInfo->processedVer = 0; + pChkInfo->nextProcessVer = 1; + stDebug("s-task:%s update the processedVer to 0 from -1 due to compatible purpose", pTask->id.idStr); + } + } + } + } +} + int32_t streamTaskInit(SStreamTask* pTask, SStreamMeta* pMeta, SMsgCb* pMsgCb, int64_t ver) { pTask->id.idStr = createStreamTaskIdStr(pTask->id.streamId, pTask->id.taskId); pTask->refCnt = 1; pTask->inputq.status = TASK_INPUT_STATUS__NORMAL; pTask->outputq.status = TASK_OUTPUT_STATUS__NORMAL; + pTask->inputq.queue = streamQueueOpen(512 << 10); pTask->outputq.queue = streamQueueOpen(512 << 10); if (pTask->inputq.queue == NULL || pTask->outputq.queue == NULL) { @@ -479,41 +516,7 @@ int32_t streamTaskInit(SStreamTask* pTask, SStreamMeta* pMeta, SMsgCb* pMsgCb, i } pTask->execInfo.created = taosGetTimestampMs(); - SCheckpointInfo* pChkInfo = &pTask->chkInfo; - SDataRange* pRange = &pTask->dataRange; - - // only set the version info for stream tasks without fill-history task - if (pTask->info.taskLevel == TASK_LEVEL__SOURCE) { - if ((pTask->info.fillHistory == 0) && (!HAS_RELATED_FILLHISTORY_TASK(pTask))) { - pChkInfo->checkpointVer = ver - 1; // only update when generating checkpoint - pChkInfo->processedVer = ver - 1; // already processed version - pChkInfo->nextProcessVer = ver; // next processed version - - pRange->range.maxVer = ver; - pRange->range.minVer = ver; - } else { - // the initial value of processedVer/nextProcessVer/checkpointVer for stream task with related fill-history task - // is set at the mnode. - if (pTask->info.fillHistory == 1) { - pChkInfo->checkpointVer = pRange->range.maxVer; - pChkInfo->processedVer = pRange->range.maxVer; - pChkInfo->nextProcessVer = pRange->range.maxVer + 1; - } else { - pChkInfo->checkpointVer = pRange->range.minVer - 1; - pChkInfo->processedVer = pRange->range.minVer - 1; - pChkInfo->nextProcessVer = pRange->range.minVer; - - { // for compatible purpose, remove it later - if (pRange->range.minVer == 0) { - pChkInfo->checkpointVer = 0; - pChkInfo->processedVer = 0; - pChkInfo->nextProcessVer = 1; - stDebug("s-task:%s update the processedVer to 0 from -1 due to compatible purpose", pTask->id.idStr); - } - } - } - } - } + setInitialVersionInfo(pTask, ver); pTask->pMeta = pMeta; pTask->pMsgCb = pMsgCb; @@ -779,8 +782,10 @@ int32_t streamTaskClearHTaskAttr(SStreamTask* pTask, int32_t resetRelHalt) { CLEAR_RELATED_FILLHISTORY_TASK((*ppStreamTask)); if (resetRelHalt) { + stDebug("s-task:0x%" PRIx64 " set the persistent status attr to be ready, prev:%s, status in sm:%s", + sTaskId.taskId, streamTaskGetStatusStr((*ppStreamTask)->status.taskStatus), + streamTaskGetStatus(*ppStreamTask)->name); (*ppStreamTask)->status.taskStatus = TASK_STATUS__READY; - stDebug("s-task:0x%" PRIx64 " set the status to be ready", sTaskId.taskId); } streamMetaSaveTask(pMeta, *ppStreamTask); diff --git a/source/libs/sync/inc/syncCommit.h b/source/libs/sync/inc/syncCommit.h index 07b4702b1b..e6b54ea86b 100644 --- a/source/libs/sync/inc/syncCommit.h +++ b/source/libs/sync/inc/syncCommit.h @@ -53,6 +53,8 @@ bool syncNodeAgreedUpon(SSyncNode* pNode, SyncIndex index); int64_t syncNodeUpdateCommitIndex(SSyncNode* ths, SyncIndex commitIndex); int64_t syncNodeCheckCommitIndex(SSyncNode* ths, SyncIndex indexLikely); +int64_t syncNodeUpdateAssignedCommitIndex(SSyncNode* ths, SyncIndex assignedCommitIndex); + #ifdef __cplusplus } #endif diff --git a/source/libs/sync/inc/syncInt.h b/source/libs/sync/inc/syncInt.h index 637c18e97d..3d8588a55a 100644 --- a/source/libs/sync/inc/syncInt.h +++ b/source/libs/sync/inc/syncInt.h @@ -160,6 +160,13 @@ typedef struct SSyncNode { SSyncLogStore* pLogStore; SyncIndex commitIndex; + // assigned leader log vars + SyncIndex assignedCommitIndex; + + SyncTerm arbTerm; + TdThreadMutex arbTokenMutex; + char arbToken[TSDB_ARB_TOKEN_SIZE]; + // timer ms init int32_t pingBaseLine; int32_t electBaseLine; @@ -219,6 +226,7 @@ typedef struct SSyncNode { int32_t electNum; int32_t becomeLeaderNum; + int32_t becomeAssignedLeaderNum; int32_t configChangeNum; int32_t hbSlowNum; int32_t hbrSlowNum; @@ -282,10 +290,12 @@ void syncNodeStepDown(SSyncNode* pSyncNode, SyncTerm newTerm); void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr); void syncNodeBecomeLearner(SSyncNode* pSyncNode, const char* debugStr); void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr); +void syncNodeBecomeAssignedLeader(SSyncNode* pSyncNode); void syncNodeCandidate2Leader(SSyncNode* pSyncNode); void syncNodeFollower2Candidate(SSyncNode* pSyncNode); void syncNodeLeader2Follower(SSyncNode* pSyncNode); void syncNodeCandidate2Follower(SSyncNode* pSyncNode); +int32_t syncNodeAssignedLeader2Leader(SSyncNode* pSyncNode); // raft vote -------------- void syncNodeVoteForTerm(SSyncNode* pSyncNode, SyncTerm term, SRaftId* pRaftId); diff --git a/source/libs/sync/inc/syncUtil.h b/source/libs/sync/inc/syncUtil.h index 39c679a2ad..a550ae8fbb 100644 --- a/source/libs/sync/inc/syncUtil.h +++ b/source/libs/sync/inc/syncUtil.h @@ -78,6 +78,8 @@ void syncUtilMsgHtoN(void* msg); bool syncUtilUserPreCommit(tmsg_t msgType); bool syncUtilUserRollback(tmsg_t msgType); +void syncUtilGenerateArbToken(int32_t nodeId, int32_t groupId, char* buf); + void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNode* pNode, const char* format, ...); void syncPrintSnapshotSenderLog(const char* flags, ELogLevel level, int32_t dflag, SSyncSnapshotSender* pSender, const char* format, ...); diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index 7c343c0e5d..ede4dc07e1 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -55,7 +55,7 @@ int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) { return 0; } - if (ths->state == TAOS_SYNC_STATE_LEADER) { + if (ths->state == TAOS_SYNC_STATE_LEADER || ths->state == TAOS_SYNC_STATE_ASSIGNED_LEADER) { if (pMsg->term > raftStoreGetTerm(ths)) { syncLogRecvAppendEntriesReply(ths, pMsg, "error term"); syncNodeStepDown(ths, pMsg->term); @@ -76,7 +76,27 @@ int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, const SRpcMsg* pRpcMsg) { // commit if needed SyncIndex indexLikely = TMIN(pMsg->matchIndex, ths->pLogBuf->matchIndex); SyncIndex commitIndex = syncNodeCheckCommitIndex(ths, indexLikely); - (void)syncLogBufferCommit(ths->pLogBuf, ths, commitIndex); + if (ths->state == TAOS_SYNC_STATE_ASSIGNED_LEADER) { + if (commitIndex >= ths->assignedCommitIndex) { + terrno = TSDB_CODE_SUCCESS; + raftStoreNextTerm(ths); + if (terrno != TSDB_CODE_SUCCESS) { + sError("vgId:%d, failed to update term, reason:%s", ths->vgId, tstrerror(terrno)); + return -1; + } + if (syncNodeAssignedLeader2Leader(ths) != 0) { + sError("vgId:%d, failed to change state from assigned leader to leader", ths->vgId); + return -1; + } + + taosThreadMutexLock(&ths->arbTokenMutex); + syncUtilGenerateArbToken(ths->myNodeInfo.nodeId, ths->vgId, ths->arbToken); + sInfo("vgId:%d, assigned leader to leader, arbToken:%s", ths->vgId, ths->arbToken); + taosThreadMutexUnlock(&ths->arbTokenMutex); + } + } else { + (void)syncLogBufferCommit(ths->pLogBuf, ths, commitIndex); + } } // replicate log diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index 47e4049c73..3c401a978b 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -88,3 +88,11 @@ int64_t syncNodeCheckCommitIndex(SSyncNode* ths, SyncIndex indexLikely) { } return ths->commitIndex; } + +int64_t syncNodeUpdateAssignedCommitIndex(SSyncNode* ths, SyncIndex assignedCommitIndex) { + SyncIndex lastVer = ths->pLogStore->syncLogLastIndex(ths->pLogStore); + assignedCommitIndex = TMAX(assignedCommitIndex, ths->assignedCommitIndex); + ths->assignedCommitIndex = TMIN(assignedCommitIndex, lastVer); + ths->pLogStore->syncLogUpdateCommitIndex(ths->pLogStore, ths->assignedCommitIndex); + return ths->commitIndex; +} diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 7ff6116137..da18bbdea2 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -173,7 +173,7 @@ int32_t syncReconfig(int64_t rid, SSyncCfg* pNewCfg) { syncNodeUpdateNewConfigIndex(pSyncNode, pNewCfg); syncNodeDoConfigChange(pSyncNode, pNewCfg, pNewCfg->lastIndex); - if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { + if (pSyncNode->state == TAOS_SYNC_STATE_LEADER || pSyncNode->state == TAOS_SYNC_STATE_ASSIGNED_LEADER) { syncNodeStopHeartbeatTimer(pSyncNode); for (int32_t i = 0; i < TSDB_MAX_REPLICA + TSDB_MAX_LEARNER_REPLICA; ++i) { @@ -235,6 +235,9 @@ int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg) { case TDMT_SYNC_FORCE_FOLLOWER: code = syncForceBecomeFollower(pSyncNode, pMsg); break; + case TDMT_SYNC_SET_ASSIGNED_LEADER: + code = syncBecomeAssignedLeader(pSyncNode, pMsg); + break; default: terrno = TSDB_CODE_MSG_NOT_PROCESSED; code = -1; @@ -271,6 +274,86 @@ int32_t syncForceBecomeFollower(SSyncNode* ths, const SRpcMsg* pRpcMsg) { return 0; } +int32_t syncBecomeAssignedLeader(SSyncNode* ths, SRpcMsg* pRpcMsg) { + int32_t ret = -1; + + SVArbSetAssignedLeaderReq req = {0}; + if (tDeserializeSVArbSetAssignedLeaderReq((char*)pRpcMsg->pCont + sizeof(SMsgHead), pRpcMsg->contLen, &req) != 0) { + sError("vgId:%d, failed to deserialize SVArbSetAssignedLeaderReq", ths->vgId); + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + int32_t errcode = TSDB_CODE_MND_ARB_TOKEN_MISMATCH; + + if (ths->arbTerm > req.arbTerm) { + sInfo("vgId:%d, skip to set assigned leader, msg with lower term, local:%" PRId64 "msg:%" PRId64, ths->vgId, + ths->arbTerm, req.arbTerm); + goto _OVER; + } + + ths->arbTerm = TMAX(req.arbTerm, ths->arbTerm); + + if (strncmp(req.memberToken, ths->arbToken, TSDB_ARB_TOKEN_SIZE) == 0) { + if (ths->state != TAOS_SYNC_STATE_ASSIGNED_LEADER) { + raftStoreNextTerm(ths); + if (terrno != TSDB_CODE_SUCCESS) { + sError("vgId:%d, failed to set next term since:%s", ths->vgId, terrstr()); + goto _OVER; + } + syncNodeBecomeAssignedLeader(ths); + + if (syncNodeAppendNoop(ths) < 0) { + sError("vgId:%d, assigned leader failed to append noop entry since %s", ths->vgId, terrstr()); + } + } + errcode = TSDB_CODE_SUCCESS; + } else { + sInfo("vgId:%d, skip to set assigned leader, token mismatch, local:%s, msg:%s", ths->vgId, ths->arbToken, + req.memberToken); + goto _OVER; + } + + SVArbSetAssignedLeaderRsp rsp = {0}; + rsp.arbToken = req.arbToken; + rsp.memberToken = req.memberToken; + rsp.vgId = ths->vgId; + + int32_t contLen = tSerializeSVArbSetAssignedLeaderRsp(NULL, 0, &rsp); + if (contLen <= 0) { + sError("vgId:%d, failed to serialize SVArbSetAssignedLeaderRsp", ths->vgId); + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + void* pHead = rpcMallocCont(contLen); + if (!pHead) { + sError("vgId:%d, failed to malloc memory for SVArbSetAssignedLeaderRsp", ths->vgId); + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + if (tSerializeSVArbSetAssignedLeaderRsp(pHead, contLen, &rsp) <= 0) { + sError("vgId:%d, failed to serialize SVArbSetAssignedLeaderRsp", ths->vgId); + terrno = TSDB_CODE_OUT_OF_MEMORY; + rpcFreeCont(pHead); + goto _OVER; + } + + SRpcMsg rspMsg = { + .code = errcode, + .pCont = pHead, + .contLen = contLen, + .info = pRpcMsg->info, + }; + + tmsgSendRsp(&rspMsg); + + ret = 0; + +_OVER: + tFreeSVArbSetAssignedLeaderReq(&req); + return ret; +} + int32_t syncSendTimeoutRsp(int64_t rid, int64_t seq) { SSyncNode* pNode = syncNodeAcquire(rid); if (pNode == NULL) return -1; @@ -342,7 +425,7 @@ int32_t syncBeginSnapshot(int64_t rid, int64_t lastApplyIndex) { if (pSyncNode->totalReplicaNum > 1) { if (pSyncNode->state != TAOS_SYNC_STATE_LEADER && pSyncNode->state != TAOS_SYNC_STATE_FOLLOWER && - pSyncNode->state != TAOS_SYNC_STATE_LEARNER) { + pSyncNode->state != TAOS_SYNC_STATE_LEARNER && pSyncNode->state != TAOS_SYNC_STATE_ASSIGNED_LEADER) { sNTrace(pSyncNode, "new-snapshot-index:%" PRId64 " candidate or unknown state, do not delete wal", lastApplyIndex); syncNodeRelease(pSyncNode); @@ -434,7 +517,7 @@ bool syncNodeIsReadyForRead(SSyncNode* pSyncNode) { return false; } - if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { + if (pSyncNode->state != TAOS_SYNC_STATE_LEADER && pSyncNode->state != TAOS_SYNC_STATE_ASSIGNED_LEADER) { terrno = TSDB_CODE_SYN_NOT_LEADER; return false; } @@ -562,6 +645,55 @@ SSyncState syncGetState(int64_t rid) { return state; } +int32_t syncGetArbToken(int64_t rid, char* outToken) { + SSyncNode* pSyncNode = syncNodeAcquire(rid); + if (pSyncNode == NULL) { + terrno = TSDB_CODE_NOT_FOUND; + return -1; + } + + memset(outToken, 0, TSDB_ARB_TOKEN_SIZE); + taosThreadMutexLock(&pSyncNode->arbTokenMutex); + strncpy(outToken, pSyncNode->arbToken, TSDB_ARB_TOKEN_SIZE); + taosThreadMutexUnlock(&pSyncNode->arbTokenMutex); + + terrno = TSDB_CODE_SUCCESS; + syncNodeRelease(pSyncNode); + return 0; +} + +int32_t syncGetAssignedLogSynced(int64_t rid) { + SSyncNode* pSyncNode = syncNodeAcquire(rid); + if (pSyncNode == NULL) { + terrno = TSDB_CODE_NOT_FOUND; + return -1; + } + + if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { + terrno = TSDB_CODE_VND_ARB_NOT_SYNCED; + syncNodeRelease(pSyncNode); + return 0; + } + + bool isSync = pSyncNode->commitIndex >= pSyncNode->assignedCommitIndex; + terrno = (isSync ? TSDB_CODE_SUCCESS : TSDB_CODE_VND_ARB_NOT_SYNCED); + + syncNodeRelease(pSyncNode); + return 0; +} + +int32_t syncUpdateArbTerm(int64_t rid, SyncTerm arbTerm) { + SSyncNode* pSyncNode = syncNodeAcquire(rid); + if (pSyncNode == NULL) { + terrno = TSDB_CODE_NOT_FOUND; + return -1; + } + + pSyncNode->arbTerm = TMAX(arbTerm, pSyncNode->arbTerm); + syncNodeRelease(pSyncNode); + return 0; +} + SyncIndex syncNodeGetSnapshotConfigIndex(SSyncNode* pSyncNode, SyncIndex snapshotLastApplyIndex) { ASSERT(pSyncNode->raftCfg.configIndexCount >= 1); SyncIndex lastIndex = (pSyncNode->raftCfg.configIndexArr)[0]; @@ -668,8 +800,21 @@ ESyncRole syncGetRole(int64_t rid) { return role; } +int64_t syncGetTerm(int64_t rid) { + SSyncNode* pSyncNode = syncNodeAcquire(rid); + if (pSyncNode == NULL) { + sError("sync Node Acquire error since %d", errno); + return -1; + } + + int64_t term = raftStoreGetTerm(pSyncNode); + + syncNodeRelease(pSyncNode); + return term; +} + int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak, int64_t* seq) { - if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { + if (pSyncNode->state != TAOS_SYNC_STATE_LEADER && pSyncNode->state != TAOS_SYNC_STATE_ASSIGNED_LEADER) { terrno = TSDB_CODE_SYN_NOT_LEADER; sNWarn(pSyncNode, "sync propose not leader, type:%s", TMSG_INFO(pMsg->msgType)); return -1; @@ -683,7 +828,7 @@ int32_t syncNodePropose(SSyncNode* pSyncNode, SRpcMsg* pMsg, bool isWeak, int64_ } // heartbeat timeout - if (syncNodeHeartbeatReplyTimeout(pSyncNode)) { + if (pSyncNode->state != TAOS_SYNC_STATE_ASSIGNED_LEADER && syncNodeHeartbeatReplyTimeout(pSyncNode)) { terrno = TSDB_CODE_SYN_PROPOSE_NOT_READY; sNError(pSyncNode, "failed to sync propose since heartbeat timeout, type:%s, last:%" PRId64 ", cmt:%" PRId64, TMSG_INFO(pMsg->msgType), syncNodeGetLastIndex(pSyncNode), pSyncNode->commitIndex); @@ -916,6 +1061,11 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo, int32_t vnodeVersion) { goto _error; } + pSyncNode->arbTerm = -1; + taosThreadMutexInit(&pSyncNode->arbTokenMutex, NULL); + syncUtilGenerateArbToken(pSyncNode->myNodeInfo.nodeId, pSyncInfo->vgId, pSyncNode->arbToken); + sInfo("vgId:%d, arb token:%s", pSyncNode->vgId, pSyncNode->arbToken); + // init peersNum, peers, peersId pSyncNode->peersNum = pSyncNode->raftCfg.cfg.totalReplicaNum - 1; int32_t j = 0; @@ -1064,9 +1214,9 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo, int32_t vnodeVersion) { pSyncNode->heartbeatTimerMS = pSyncNode->hbBaseLine; atomic_store_64(&pSyncNode->heartbeatTimerLogicClock, 0); atomic_store_64(&pSyncNode->heartbeatTimerLogicClockUser, 0); -#ifdef BUILD_NO_CALL +#ifdef BUILD_NO_CALL pSyncNode->FpHeartbeatTimerCB = syncNodeEqHeartbeatTimer; -#endif +#endif pSyncNode->heartbeatTimerCounter = 0; // init peer heartbeat timer @@ -1138,6 +1288,7 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo, int32_t vnodeVersion) { pSyncNode->isStart = true; pSyncNode->electNum = 0; pSyncNode->becomeLeaderNum = 0; + pSyncNode->becomeAssignedLeaderNum = 0; pSyncNode->configChangeNum = 0; pSyncNode->hbSlowNum = 0; pSyncNode->hbrSlowNum = 0; @@ -1305,6 +1456,8 @@ void syncNodeClose(SSyncNode* pSyncNode) { syncLogBufferDestroy(pSyncNode->pLogBuf); pSyncNode->pLogBuf = NULL; + taosThreadMutexDestroy(&pSyncNode->arbTokenMutex); + for (int32_t i = 0; i < TSDB_MAX_REPLICA + TSDB_MAX_LEARNER_REPLICA; ++i) { if (pSyncNode->senders[i] != NULL) { sDebug("vgId:%d, snapshot sender destroy while close, data:%p", pSyncNode->vgId, pSyncNode->senders[i]); @@ -1906,6 +2059,66 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode, const char* debugStr) { sNInfo(pSyncNode, "become leader %s", debugStr); } +void syncNodeBecomeAssignedLeader(SSyncNode* pSyncNode) { + pSyncNode->becomeAssignedLeaderNum++; + pSyncNode->hbrSlowNum = 0; + + // reset restoreFinish + //pSyncNode->restoreFinish = false; + + // state change + pSyncNode->state = TAOS_SYNC_STATE_ASSIGNED_LEADER; + pSyncNode->roleTimeMs = taosGetTimestampMs(); + + // set leader cache + pSyncNode->leaderCache = pSyncNode->myRaftId; + + for (int32_t i = 0; i < pSyncNode->pNextIndex->replicaNum; ++i) { + SyncIndex lastIndex; + SyncTerm lastTerm; + int32_t code = syncNodeGetLastIndexTerm(pSyncNode, &lastIndex, &lastTerm); + ASSERT(code == 0); + pSyncNode->pNextIndex->index[i] = lastIndex + 1; + } + + for (int32_t i = 0; i < pSyncNode->pMatchIndex->replicaNum; ++i) { + // maybe overwrite myself, no harm + // just do it! + pSyncNode->pMatchIndex->index[i] = SYNC_INDEX_INVALID; + } + + // init peer mgr + syncNodePeerStateInit(pSyncNode); + + // close receiver + if (snapshotReceiverIsStart(pSyncNode->pNewNodeReceiver)) { + snapshotReceiverStop(pSyncNode->pNewNodeReceiver); + } + + // stop elect timer + syncNodeStopElectTimer(pSyncNode); + + // start heartbeat timer + syncNodeStartHeartbeatTimer(pSyncNode); + + // send heartbeat right now + syncNodeHeartbeatPeers(pSyncNode); + + // call back + if (pSyncNode->pFsm != NULL && pSyncNode->pFsm->FpBecomeAssignedLeaderCb != NULL) { + pSyncNode->pFsm->FpBecomeAssignedLeaderCb(pSyncNode->pFsm); + } + + // min match index + pSyncNode->minMatchIndex = SYNC_INDEX_INVALID; + + // reset log buffer + syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); + + // trace log + sNInfo(pSyncNode, "become assigned leader"); +} + void syncNodeCandidate2Leader(SSyncNode* pSyncNode) { ASSERT(pSyncNode->state == TAOS_SYNC_STATE_CANDIDATE); bool granted = voteGrantedMajority(pSyncNode->pVotesGranted); @@ -1972,6 +2185,24 @@ void syncNodeCandidate2Follower(SSyncNode* pSyncNode) { } #endif +int32_t syncNodeAssignedLeader2Leader(SSyncNode* pSyncNode) { + ASSERT(pSyncNode->state == TAOS_SYNC_STATE_ASSIGNED_LEADER); + syncNodeBecomeLeader(pSyncNode, "assigned leader to leader"); + + sNTrace(pSyncNode, "assigned leader to leader"); + + int32_t ret = syncNodeAppendNoop(pSyncNode); + if (ret < 0) { + sError("vgId:%d, failed to append noop entry since %s", pSyncNode->vgId, terrstr()); + } + + SyncIndex lastIndex = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore); + sInfo("vgId:%d, become leader from assigned leader. term:%" PRId64 ", commit index:%" PRId64 + "assigned commit index:%" PRId64 ", last index:%" PRId64, + pSyncNode->vgId, raftStoreGetTerm(pSyncNode), pSyncNode->commitIndex, pSyncNode->assignedCommitIndex, lastIndex); + return 0; +} + // just called by syncNodeVoteForSelf // need assert void syncNodeVoteForTerm(SSyncNode* pSyncNode, SyncTerm term, SRaftId* pRaftId) { @@ -2291,7 +2522,7 @@ static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId) { return; } - if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { + if (pSyncNode->state != TAOS_SYNC_STATE_LEADER && pSyncNode->state != TAOS_SYNC_STATE_ASSIGNED_LEADER) { syncNodeRelease(pSyncNode); syncHbTimerDataRelease(pData); sError("vgId:%d, hb timer sync node not leader", pSyncNode->vgId); @@ -2426,7 +2657,8 @@ int32_t syncNodeCheckChangeConfig(SSyncNode* ths, SSyncRaftEntry* pEntry) { SSyncCfg cfg = {0}; syncBuildConfigFromReq(&req, &cfg); - if (cfg.totalReplicaNum >= 1 && ths->state == TAOS_SYNC_STATE_LEADER) { + if (cfg.totalReplicaNum >= 1 && + (ths->state == TAOS_SYNC_STATE_LEADER || ths->state == TAOS_SYNC_STATE_ASSIGNED_LEADER)) { bool incfg = false; for (int32_t j = 0; j < cfg.totalReplicaNum; ++j) { if (strcmp(ths->myNodeInfo.nodeFqdn, cfg.nodeInfo[j].nodeFqdn) == 0 && @@ -2934,6 +3166,16 @@ _out:; ths->vgId, pEntry->index, pEntry->term, ths->pLogBuf->startIndex, ths->pLogBuf->commitIndex, ths->pLogBuf->matchIndex, ths->pLogBuf->endIndex); + if (code == 0 && ths->state == TAOS_SYNC_STATE_ASSIGNED_LEADER) { + (void)syncNodeUpdateAssignedCommitIndex(ths, matchIndex); + + if (ths->fsmState != SYNC_FSM_STATE_INCOMPLETE && + syncLogBufferCommit(ths->pLogBuf, ths, ths->assignedCommitIndex) < 0) { + sError("vgId:%d, failed to commit until commitIndex:%" PRId64 "", ths->vgId, ths->commitIndex); + code = -1; + } + } + // multi replica if (ths->replicaNum > 1) { return code; @@ -3080,7 +3322,8 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { currentTerm = pMsg->term; } - if (pMsg->term == currentTerm && ths->state != TAOS_SYNC_STATE_LEADER) { + if (pMsg->term == currentTerm && + (ths->state != TAOS_SYNC_STATE_LEADER && ths->state != TAOS_SYNC_STATE_ASSIGNED_LEADER)) { syncIndexMgrSetRecvTime(ths->pNextIndex, &(pMsg->srcId), tsMs); resetElect = true; @@ -3109,7 +3352,8 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { } } - if (pMsg->term >= currentTerm && ths->state == TAOS_SYNC_STATE_LEADER) { + if (pMsg->term >= currentTerm && + (ths->state == TAOS_SYNC_STATE_LEADER || ths->state == TAOS_SYNC_STATE_ASSIGNED_LEADER)) { SRpcMsg rpcMsgLocalCmd = {0}; (void)syncBuildLocalCmd(&rpcMsgLocalCmd, ths->vgId); @@ -3239,7 +3483,7 @@ int32_t syncNodeOnClientRequest(SSyncNode* ths, SRpcMsg* pMsg, SyncIndex* pRetIn return -1; } - if (ths->state == TAOS_SYNC_STATE_LEADER) { + if (ths->state == TAOS_SYNC_STATE_LEADER || ths->state == TAOS_SYNC_STATE_ASSIGNED_LEADER) { if (pRetIndex) { (*pRetIndex) = index; } @@ -3288,6 +3532,8 @@ const char* syncStr(ESyncState state) { return "offline"; case TAOS_SYNC_STATE_LEARNER: return "learner"; + case TAOS_SYNC_STATE_ASSIGNED_LEADER: + return "assigned leader"; default: return "unknown"; } diff --git a/source/libs/sync/src/syncPipeline.c b/source/libs/sync/src/syncPipeline.c index 70bdd4a837..d40fff447f 100644 --- a/source/libs/sync/src/syncPipeline.c +++ b/source/libs/sync/src/syncPipeline.c @@ -484,7 +484,7 @@ int64_t syncLogBufferProceed(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncTerm* p taosMsleep(1); goto _out; } - + if(pEntry->originalRpcType == TDMT_SYNC_CONFIG_CHANGE){ if(pNode->pLogBuf->commitIndex == pEntry->index -1){ sInfo("vgId:%d, to change config at %s. " @@ -492,7 +492,7 @@ int64_t syncLogBufferProceed(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncTerm* p "node, restore:%d, commitIndex:%" PRId64 ", " "cond: (pre entry index:%" PRId64 "== buf commit index:%" PRId64 ")", pNode->vgId, str, - pEntry->index, pEntry->term, + pEntry->index, pEntry->term, pNode->restoreFinish, pNode->commitIndex, pEntry->index - 1, pNode->pLogBuf->commitIndex); if(syncNodeChangeConfig(pNode, pEntry, str) != 0){ @@ -507,9 +507,9 @@ int64_t syncLogBufferProceed(SSyncLogBuffer* pBuf, SSyncNode* pNode, SyncTerm* p "node, commitIndex:%" PRId64 ", pBuf: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 "), " "cond:( pre entry index:%" PRId64" != buf commit index:%" PRId64 ")", pNode->vgId, str, - pEntry->index, pEntry->term, + pEntry->index, pEntry->term, pNode->commitIndex, pNode->pLogBuf->startIndex, pNode->pLogBuf->commitIndex, - pNode->pLogBuf->matchIndex, pNode->pLogBuf->endIndex, + pNode->pLogBuf->matchIndex, pNode->pLogBuf->endIndex, pEntry->index - 1, pNode->pLogBuf->commitIndex); } } @@ -653,8 +653,8 @@ int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t comm "current entry, index:%" PRId64 ", term:%" PRId64", " "node, role:%d, current term:%" PRId64 ", restore:%d, " "cond, next entry index:%" PRId64 ", msgType:%s", - vgId, - pEntry->index, pEntry->term, + vgId, + pEntry->index, pEntry->term, role, currentTerm, pNode->restoreFinish, pNextEntry->index, TMSG_INFO(pNextEntry->originalRpcType)); @@ -685,12 +685,12 @@ int32_t syncLogBufferCommit(SSyncLogBuffer* pBuf, SSyncNode* pNode, int64_t comm syncEntryDestroy(pNextEntry); pNextEntry = NULL; } - } - + } + if (!inBuf) { syncEntryDestroy(pEntry); pEntry = NULL; - } + } } // recycle diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index 2c7fc70ae9..9312719be7 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -64,7 +64,8 @@ int32_t syncNodeReplicate(SSyncNode* pNode) { } int32_t syncNodeReplicateWithoutLock(SSyncNode* pNode) { - if (pNode->state != TAOS_SYNC_STATE_LEADER || pNode->raftCfg.cfg.totalReplicaNum == 1) { + if ((pNode->state != TAOS_SYNC_STATE_LEADER && pNode->state != TAOS_SYNC_STATE_ASSIGNED_LEADER) || + pNode->raftCfg.cfg.totalReplicaNum == 1) { return -1; } for (int32_t i = 0; i < pNode->totalReplicaNum; i++) { diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index d9c8bb21ac..5c1f8739bd 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -1242,7 +1242,7 @@ int32_t syncNodeOnSnapshotRsp(SSyncNode *pSyncNode, SRpcMsg *pRpcMsg) { goto _ERROR; } - if (pSyncNode->state != TAOS_SYNC_STATE_LEADER) { + if (pSyncNode->state != TAOS_SYNC_STATE_LEADER && pSyncNode->state != TAOS_SYNC_STATE_ASSIGNED_LEADER) { sSError(pSender, "snapshot sender not leader"); terrno = TSDB_CODE_SYN_NOT_LEADER; goto _ERROR; diff --git a/source/libs/sync/src/syncTimeout.c b/source/libs/sync/src/syncTimeout.c index a57dfbee53..dbbd914041 100644 --- a/source/libs/sync/src/syncTimeout.c +++ b/source/libs/sync/src/syncTimeout.c @@ -77,7 +77,8 @@ static int32_t syncNodeTimerRoutine(SSyncNode* ths) { for (int i = 0; i < ths->peersNum; ++i) { SSyncSnapshotSender* pSender = syncNodeGetSnapshotSender(ths, &(ths->peersId[i])); if (pSender != NULL) { - if (ths->isStart && ths->state == TAOS_SYNC_STATE_LEADER && pSender->start) { + if (ths->isStart && (ths->state == TAOS_SYNC_STATE_LEADER || ths->state == TAOS_SYNC_STATE_ASSIGNED_LEADER) && + pSender->start) { int64_t elapsedMs = timeNow - pSender->lastSendTime; if (elapsedMs < SYNC_SNAP_RESEND_MS) { continue; diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index 2ce56af946..93a06ddf30 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -44,7 +44,7 @@ void syncUtilNodeInfo2EpSet(const SNodeInfo* pInfo, SEpSet* pEpSet) { bool syncUtilNodeInfo2RaftId(const SNodeInfo* pInfo, SyncGroupId vgId, SRaftId* raftId) { uint32_t ipv4 = 0xFFFFFFFF; sDebug("vgId:%d, start to resolve sync addr fqdn in %d seconds, " - "dnode:%d cluster:%" PRId64 " fqdn:%s port:%u ", + "dnode:%d cluster:%" PRId64 " fqdn:%s port:%u ", vgId, tsResolveFQDNRetryTime, pInfo->nodeId, pInfo->clusterId, pInfo->nodeFqdn, pInfo->nodePort); for(int i = 0; i < tsResolveFQDNRetryTime; i++){ @@ -57,7 +57,7 @@ bool syncUtilNodeInfo2RaftId(const SNodeInfo* pInfo, SyncGroupId vgId, SRaftId* break; } } - + if (ipv4 == 0xFFFFFFFF || ipv4 == 1) { sError("failed to resolve ipv4 addr, fqdn:%s", pInfo->nodeFqdn); terrno = TSDB_CODE_TSC_INVALID_FQDN; @@ -103,6 +103,13 @@ bool syncUtilUserPreCommit(tmsg_t msgType) { return msgType != TDMT_SYNC_NOOP && bool syncUtilUserRollback(tmsg_t msgType) { return msgType != TDMT_SYNC_NOOP && msgType != TDMT_SYNC_LEADER_TRANSFER; } +void syncUtilGenerateArbToken(int32_t nodeId, int32_t groupId, char* buf) { + memset(buf, 0, TSDB_ARB_TOKEN_SIZE); + int32_t randVal = taosSafeRand() % 1000; + int64_t currentMs = taosGetTimestampMs(); + snprintf(buf, TSDB_ARB_TOKEN_SIZE, "d%d#g%d#%" PRId64 "#%d", nodeId, groupId, currentMs, randVal); +} + // for leader static void syncHearbeatReplyTime2Str(SSyncNode* pSyncNode, char* buf, int32_t bufLen) { int32_t len = 0; @@ -221,19 +228,22 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, SSyncNo SyncIndex appliedIndex = pNode->pFsm->FpAppliedIndexCb(pNode->pFsm); if (pNode != NULL) { - taosPrintLog(flags, level, dflag, - "vgId:%d, %s, sync:%s, term:%" PRIu64 ", commit-index:%" PRId64 ", applied-index:%" PRId64 - ", first-ver:%" PRId64 ", last-ver:%" PRId64 ", min:%" PRId64 ", snap:%" PRId64 ", snap-term:%" PRIu64 - ", elect-times:%d, as-leader-times:%d, cfg-ch-times:%d, hb-slow:%d, hbr-slow:%d, " - "aq-items:%d, snaping:%" PRId64 ", replicas:%d, last-cfg:%" PRId64 - ", chging:%d, restore:%d, quorum:%d, elect-lc-timer:%" PRId64 ", hb:%" PRId64 - ", buffer:%s, repl-mgrs:%s, members:%s, hb:%s, hb-reply:%s", - pNode->vgId, eventLog, syncStr(pNode->state), currentTerm, pNode->commitIndex, appliedIndex, - logBeginIndex, logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, snapshot.lastApplyTerm, - pNode->electNum, pNode->becomeLeaderNum, pNode->configChangeNum, pNode->hbSlowNum, pNode->hbrSlowNum, - aqItems, pNode->snapshottingIndex, pNode->replicaNum, pNode->raftCfg.lastConfigIndex, pNode->changing, - pNode->restoreFinish, syncNodeDynamicQuorum(pNode), pNode->electTimerLogicClock, - pNode->heartbeatTimerLogicClockUser, bufferStatesStr, replMgrStatesStr, cfgStr, hbTimeStr, hbrTimeStr); + taosPrintLog( + flags, level, dflag, + "vgId:%d, %s, sync:%s, term:%" PRIu64 ", commit-index:%" PRId64 ", assigned-index:%" PRId64 + ", applied-index:%" PRId64 ", first-ver:%" PRId64 ", last-ver:%" PRId64 ", min:%" PRId64 ", snap:%" PRId64 + ", snap-term:%" PRIu64 + ", elect-times:%d, as-leader-times:%d, as-assigned-leader-times:%d, cfg-ch-times:%d, hb-slow:%d, hbr-slow:%d, " + "aq-items:%d, snaping:%" PRId64 ", replicas:%d, last-cfg:%" PRId64 + ", chging:%d, restore:%d, quorum:%d, elect-lc-timer:%" PRId64 ", hb:%" PRId64 + ", buffer:%s, repl-mgrs:%s, members:%s, hb:%s, hb-reply:%s", + pNode->vgId, eventLog, syncStr(pNode->state), currentTerm, pNode->commitIndex, pNode->assignedCommitIndex, + appliedIndex, logBeginIndex, logLastIndex, pNode->minMatchIndex, snapshot.lastApplyIndex, + snapshot.lastApplyTerm, pNode->electNum, pNode->becomeLeaderNum, pNode->becomeAssignedLeaderNum, + pNode->configChangeNum, pNode->hbSlowNum, pNode->hbrSlowNum, aqItems, pNode->snapshottingIndex, + pNode->replicaNum, pNode->raftCfg.lastConfigIndex, pNode->changing, pNode->restoreFinish, + syncNodeDynamicQuorum(pNode), pNode->electTimerLogicClock, pNode->heartbeatTimerLogicClockUser, bufferStatesStr, + replMgrStatesStr, cfgStr, hbTimeStr, hbrTimeStr); } } diff --git a/source/os/src/osString.c b/source/os/src/osString.c index 9119c1d470..8c6c0e0d7c 100644 --- a/source/os/src/osString.c +++ b/source/os/src/osString.c @@ -485,7 +485,7 @@ bool isHex(const char* z, uint32_t n){ } bool isValidateHex(const char* z, uint32_t n){ - if(n % 2 != 0) return false; + if((n & 1) != 0) return false; for(size_t i = HEX_PREFIX_LEN; i < n; i++){ if(isxdigit(z[i]) == 0){ return false; @@ -494,13 +494,16 @@ bool isValidateHex(const char* z, uint32_t n){ return true; } -int32_t taosHex2Ascii(const char *z, uint32_t n, void** data, uint32_t* size){ - n -= HEX_PREFIX_LEN; // remove 0x +int32_t taosHex2Ascii(const char *z, uint32_t n, void **data, uint32_t *size) { + n -= HEX_PREFIX_LEN; // remove 0x z += HEX_PREFIX_LEN; *size = n / HEX_PREFIX_LEN; - if(*size == 0) return 0; - uint8_t* tmp = (uint8_t*)taosMemoryCalloc(*size, 1); - if(tmp == NULL) return -1; + if (*size == 0) { + if (!(*data = taosStrdup(""))) return -1; + return 0; + } + uint8_t *tmp = (uint8_t *)taosMemoryCalloc(*size, 1); + if (tmp == NULL) return -1; int8_t num = 0; uint8_t *byte = tmp + *size - 1; diff --git a/source/util/src/terror.c b/source/util/src/terror.c index ffc6f8a42f..6df9bf0e16 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -254,6 +254,9 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_SNODE_ALREADY_EXIST, "Snode can only be cre TAOS_DEFINE_ERROR(TSDB_CODE_MND_SNODE_NOT_EXIST, "Snode not there") TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_FEW_MNODES, "The replica of mnode cannot less than 1") TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_MNODES, "The replica of mnode cannot exceed 3") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_ARBGROUP_ALREADY_EXIST, "Arbitrator group already exists") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_ARBGROUP_NOT_EXIST, "Arbitrator group not there") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_ARB_TOKEN_MISMATCH, "Arbitrator token mismatch") // mnode-dnode-part2 TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_DNODES, "Too many dnodes") @@ -368,6 +371,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_VND_NOT_CATCH_UP, "Vnode didn't catch up TAOS_DEFINE_ERROR(TSDB_CODE_VND_ALREADY_IS_VOTER, "Vnode already is a voter") TAOS_DEFINE_ERROR(TSDB_CODE_VND_DIR_ALREADY_EXIST, "Vnode directory already exist") TAOS_DEFINE_ERROR(TSDB_CODE_VND_META_DATA_UNSAFE_DELETE, "Single replica vnode data will lost permanently after this operation, if you make sure this, please use drop dnode unsafe to execute") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_ARB_NOT_SYNCED, "Vgroup peer is not synced") // tsdb TAOS_DEFINE_ERROR(TSDB_CODE_TDB_INVALID_TABLE_ID, "Invalid table ID") @@ -613,7 +617,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_GET_META_ERROR, "Fail to get table i TAOS_DEFINE_ERROR(TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS, "Not unique table/alias") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_SYSTABLE_NOT_ALLOWED_FUNC, "System table not allowed") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_SYSTABLE_NOT_ALLOWED, "System table not allowed") -TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_VARBINARY, "Invalidate varbinary value") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_VARBINARY, "Invalid varbinary value") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_IP_RANGE, "Invalid IPV4 address ranges") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Invalid stream query") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_VIEW_QUERY, "Invalid view query type") @@ -709,7 +713,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TMQ_REPLAY_NOT_SUPPORT, "Replay is disabled TAOS_DEFINE_ERROR(TSDB_CODE_STREAM_TASK_NOT_EXIST, "Stream task not exist") TAOS_DEFINE_ERROR(TSDB_CODE_STREAM_EXEC_CANCELLED, "Stream task exec cancelled") TAOS_DEFINE_ERROR(TSDB_CODE_STREAM_INVALID_STATETRANS, "Invalid task state to handle event") -TAOS_DEFINE_ERROR(TSDB_CODE_STREAM_TASK_IVLD_STATUS,"Invalid task status to proceed") +TAOS_DEFINE_ERROR(TSDB_CODE_STREAM_TASK_IVLD_STATUS, "Invalid task status to proceed") // TDLite TAOS_DEFINE_ERROR(TSDB_CODE_TDLITE_IVLD_OPEN_FLAGS, "Invalid TDLite open flags") diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index eae02125d2..16ca1b64c3 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -41,6 +41,12 @@ #define LOG_BUF_SIZE(x) ((x)->buffSize) #define LOG_BUF_MUTEX(x) ((x)->buffMutex) +#ifdef TD_ENTERPRISE +#define LOG_EDITION_FLG ("E") +#else +#define LOG_EDITION_FLG ("C") +#endif + typedef struct { char *buffer; int32_t buffStart; @@ -490,8 +496,9 @@ static inline int32_t taosBuildLogHead(char *buffer, const char *flags) { time_t curTime = timeSecs.tv_sec; ptm = taosLocalTime(&curTime, &Tm, NULL); - return sprintf(buffer, "%02d/%02d %02d:%02d:%02d.%06d %08" PRId64 " %s", ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, - ptm->tm_min, ptm->tm_sec, (int32_t)timeSecs.tv_usec, taosGetSelfPthreadId(), flags); + return sprintf(buffer, "%02d/%02d %02d:%02d:%02d.%06d %08" PRId64 " %s %s", ptm->tm_mon + 1, ptm->tm_mday, + ptm->tm_hour, ptm->tm_min, ptm->tm_sec, (int32_t)timeSecs.tv_usec, taosGetSelfPthreadId(), + LOG_EDITION_FLG, flags); } static inline void taosPrintLogImp(ELogLevel level, int32_t dflag, const char *buffer, int32_t len) { diff --git a/tests/develop-test/2-query/table_count_scan.py b/tests/develop-test/2-query/table_count_scan.py index 09b34a97d0..60899bc1c8 100644 --- a/tests/develop-test/2-query/table_count_scan.py +++ b/tests/develop-test/2-query/table_count_scan.py @@ -1,4 +1,4 @@ -import sys +import sys from util.log import * from util.cases import * from util.sql import * @@ -9,14 +9,14 @@ class TDTestCase: def caseDescription(self): ''' case1: [TD-21890] table count scan test case - ''' + ''' return - + def init(self, conn, logSql, replicaVer=1): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), True) self._conn = conn - + def restartTaosd(self, index=1, dbname="db"): tdDnodes.stop(index) tdDnodes.startWithoutSleep(index) @@ -65,7 +65,7 @@ class TDTestCase: tdSql.query('select count(*),db_name, stable_name from information_schema.ins_tables group by db_name, stable_name;') tdSql.checkRows(3) - tdSql.checkData(0, 0, 29) + tdSql.checkData(0, 0, 30) tdSql.checkData(0, 1, 'information_schema') tdSql.checkData(0, 2, None) tdSql.checkData(1, 0, 3) @@ -77,7 +77,7 @@ class TDTestCase: tdSql.query('select count(1) v,db_name, stable_name from information_schema.ins_tables group by db_name, stable_name order by v desc;') tdSql.checkRows(3) - tdSql.checkData(0, 0, 29) + tdSql.checkData(0, 0, 30) tdSql.checkData(0, 1, 'information_schema') tdSql.checkData(0, 2, None) tdSql.checkData(1, 0, 5) @@ -93,7 +93,7 @@ class TDTestCase: tdSql.checkData(1, 1, 'performance_schema') tdSql.checkData(0, 0, 3) tdSql.checkData(0, 1, 'tbl_count') - tdSql.checkData(2, 0, 29) + tdSql.checkData(2, 0, 30) tdSql.checkData(2, 1, 'information_schema') tdSql.query("select count(*) from information_schema.ins_tables where db_name='tbl_count'") @@ -106,7 +106,7 @@ class TDTestCase: tdSql.query('select count(*) from information_schema.ins_tables') tdSql.checkRows(1) - tdSql.checkData(0, 0, 37) + tdSql.checkData(0, 0, 38) tdSql.execute('create table stba (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) TAGS(t1 int, t2 binary(10), t3 double);') @@ -189,7 +189,7 @@ class TDTestCase: tdSql.checkData(2, 0, 5) tdSql.checkData(2, 1, 'performance_schema') tdSql.checkData(2, 2, None) - tdSql.checkData(3, 0, 29) + tdSql.checkData(3, 0, 30) tdSql.checkData(3, 1, 'information_schema') tdSql.checkData(3, 2, None) @@ -204,7 +204,7 @@ class TDTestCase: tdSql.checkData(2, 0, 5) tdSql.checkData(2, 1, 'performance_schema') tdSql.checkData(2, 2, None) - tdSql.checkData(3, 0, 29) + tdSql.checkData(3, 0, 30) tdSql.checkData(3, 1, 'information_schema') tdSql.checkData(3, 2, None) @@ -215,7 +215,7 @@ class TDTestCase: tdSql.checkData(0, 1, 'tbl_count') tdSql.checkData(1, 0, 5) tdSql.checkData(1, 1, 'performance_schema') - tdSql.checkData(2, 0, 29) + tdSql.checkData(2, 0, 30) tdSql.checkData(2, 1, 'information_schema') tdSql.query("select count(*) from information_schema.ins_tables where db_name='tbl_count'") @@ -228,7 +228,7 @@ class TDTestCase: tdSql.query('select count(*) from information_schema.ins_tables') tdSql.checkRows(1) - tdSql.checkData(0, 0, 38) + tdSql.checkData(0, 0, 39) tdSql.execute('drop database tbl_count') diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index a2348bdedd..2402f6a94a 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -229,6 +229,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dataFromTsdbNWal.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dataFromTsdbNWal-multiCtb.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_taosx.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_ts4563.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_replay.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqSeekAndCommit.py ,,n,system-test,python3 ./test.py -f 7-tmq/tmq_offset.py @@ -327,6 +328,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/db_tb_name_check.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/InsertFuturets.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/insert_wide_column.py +,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/insert_column_value.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k_benchmark.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/rowlength64k.py -R @@ -589,6 +591,7 @@ ,,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 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/geometry.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 @@ -1056,6 +1059,13 @@ ,,y,script,./test.sh -f tsim/parser/columnValue_smallint.sim ,,y,script,./test.sh -f tsim/parser/columnValue_tinyint.sim ,,y,script,./test.sh -f tsim/parser/columnValue_unsign.sim +,,y,script,./test.sh -f tsim/parser/columnValue_uint.sim +,,y,script,./test.sh -f tsim/parser/columnValue_timestamp.sim +,,y,script,./test.sh -f tsim/parser/columnValue_varchar.sim +,,y,script,./test.sh -f tsim/parser/columnValue_nchar.sim +,,y,script,./test.sh -f tsim/parser/columnValue_varbinary.sim +,,y,script,./test.sh -f tsim/parser/columnValue_json.sim +,,y,script,./test.sh -f tsim/parser/columnValue_geometry.sim ,,y,script,./test.sh -f tsim/parser/condition.sim ,,y,script,./test.sh -f tsim/parser/condition_scl.sim ,,y,script,./test.sh -f tsim/parser/constCol.sim diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index 92074161b6..d1ffaaca92 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -115,13 +115,17 @@ class TDSql: else: tdLog.info("sql:%s, check passed, no ErrInfo occurred" % (sql)) - def error(self, sql, expectedErrno = None, expectErrInfo = None, fullMatched = True): + def error(self, sql, expectedErrno = None, expectErrInfo = None, fullMatched = True, show = False): caller = inspect.getframeinfo(inspect.stack()[1][0]) expectErrNotOccured = True + if show: + tdLog.info("sql:%s" % (sql)) + try: self.cursor.execute(sql) except BaseException as e: + tdLog.info("err:%s" % (e)) expectErrNotOccured = False self.errno = e.errno error_info = repr(e) @@ -161,7 +165,10 @@ class TDSql: return self.error_info - def query(self, sql, row_tag=None, queryTimes=10, count_expected_res=None): + def query(self, sql, row_tag=None, queryTimes=10, count_expected_res=None, show = False): + if show: + tdLog.info("sql:%s" % (sql)) + self.sql = sql i=1 while i <= queryTimes: diff --git a/tests/script/tsim/db/create_all_options.sim b/tests/script/tsim/db/create_all_options.sim index abba824e82..71aa763662 100644 --- a/tests/script/tsim/db/create_all_options.sim +++ b/tests/script/tsim/db/create_all_options.sim @@ -362,7 +362,7 @@ if $data4_db != 1 then return -1 endi sql drop database db -sql_error create database db REPLICA 2 +#sql_error create database db REPLICA 2 sql_error create database db REPLICA 0 sql_error create database db REPLICA -1 sql_error create database db REPLICA 4 diff --git a/tests/script/tsim/parser/columnValue_bigint.sim b/tests/script/tsim/parser/columnValue_bigint.sim index 056855eea2..e4d1a6b6e3 100644 --- a/tests/script/tsim/parser/columnValue_bigint.sim +++ b/tests/script/tsim/parser/columnValue_bigint.sim @@ -28,10 +28,26 @@ if $data05 != NULL then return -1 endi -sql_error create table st_bigint_2 using mt_bigint tags ('NULL') -sql_error create table st_bigint_3 using mt_bigint tags ('NULL') -sql_error create table st_bigint_4 using mt_bigint tags ("NULL") -sql_error create table st_bigint_5 using mt_bigint tags ("NULL") +sql create table st_bigint_2 using mt_bigint tags ('NULL') +sql show tags from st_bigint_2 +if $data05 != NULL then + return -1 +endi +sql create table st_bigint_3 using mt_bigint tags ('NULL') +sql show tags from st_bigint_3 +if $data05 != NULL then + return -1 +endi +sql create table st_bigint_4 using mt_bigint tags ("NULL") +sql show tags from st_bigint_4 +if $data05 != NULL then + return -1 +endi +sql create table st_bigint_5 using mt_bigint tags ("NULL") +sql show tags from st_bigint_5 +if $data05 != NULL then + return -1 +endi sql create table st_bigint_6 using mt_bigint tags (-9223372036854775807) sql show tags from st_bigint_6 @@ -97,6 +113,39 @@ if $data01 != NULL then return -1 endi +sql insert into st_bigint_2 values (now, NULL) +sql select * from st_bigint_2 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_3 values (now, NULL) +sql select * from st_bigint_3 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_4 values (now, NULL) +sql select * from st_bigint_4 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_bigint_5 values (now, NULL) +sql select * from st_bigint_5 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + sql insert into st_bigint_6 values (now, 9223372036854775807) sql select * from st_bigint_6 if $rows != 1 then @@ -348,7 +397,7 @@ sql_error create table st_bigint_e0 using mt_bigint tags ("123abc") sql_error create table st_bigint_e0 using mt_bigint tags (abc) sql_error create table st_bigint_e0 using mt_bigint tags ("abc") sql_error create table st_bigint_e0 using mt_bigint tags (" ") -sql create table st_bigint_e0_error using mt_bigint tags ('') +sql_error create table st_bigint_e0_error using mt_bigint tags ('') sql create table st_bigint_e0 using mt_bigint tags (123) sql create table st_bigint_e1 using mt_bigint tags (123) @@ -401,7 +450,7 @@ sql_error insert into st_bigint_e20 using mt_bigint tags ("123abc") values (now, sql_error insert into st_bigint_e22 using mt_bigint tags (abc) values (now, -033) sql_error insert into st_bigint_e23 using mt_bigint tags ("abc") values (now, -033) sql_error insert into st_bigint_e24 using mt_bigint tags (" ") values (now, -033) -sql insert into st_bigint_e25 using mt_bigint tags ('') values (now, -033) +sql_error insert into st_bigint_e25 using mt_bigint tags ('') values (now, -033) sql insert into st_bigint_e13 using mt_bigint tags (033) values (now, 00062) sql insert into st_bigint_e14 using mt_bigint tags (033) values (now, 00062) @@ -417,15 +466,17 @@ sql insert into st_bigint_e23 using mt_bigint tags (033) values (now, 00062) sql insert into st_bigint_e24 using mt_bigint tags (033) values (now, 00062) sql insert into st_bigint_e25 using mt_bigint tags (033) values (now, 00062) -#sql alter table st_bigint_e13 set tag tagname=9223372036854775808 -#sql_error alter table st_bigint_e14 set tag tagname=-9223372036854775808 -#sql alter table st_bigint_e15 set tag tagname=92233720368547758080 -#sql_error alter table st_bigint_e16 set tag tagname=-92233720368547758080 -#sql_error alter table st_bigint_e19 set tag tagname=123abc -#sql_error alter table st_bigint_e20 set tag tagname="123abc" -#sql_error alter table st_bigint_e22 set tag tagname=abc -#sql_error alter table st_bigint_e23 set tag tagname="abc" -#sql_error alter table st_bigint_e24 set tag tagname=" " -#sql_error alter table st_bigint_e25 set tag tagname='' +sql_error alter table st_bigint_e13 set tag tagname=9223372036854775808 +sql alter table st_bigint_e13 set tag tagname=9223372036854775807 +sql_error alter table st_bigint_e14 set tag tagname=-9223372036854775809 +sql alter table st_bigint_e14 set tag tagname=-9223372036854775808 +sql_error alter table st_bigint_e15 set tag tagname=92233720368547758080 +sql_error alter table st_bigint_e16 set tag tagname=-92233720368547758080 +sql_error alter table st_bigint_e19 set tag tagname=123abc +sql_error alter table st_bigint_e20 set tag tagname="123abc" +sql_error alter table st_bigint_e22 set tag tagname=abc +sql_error alter table st_bigint_e23 set tag tagname="abc" +sql_error alter table st_bigint_e24 set tag tagname=" " +sql_error alter table st_bigint_e25 set tag tagname='' system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_bool.sim b/tests/script/tsim/parser/columnValue_bool.sim index 2553e6805a..db89db4256 100644 --- a/tests/script/tsim/parser/columnValue_bool.sim +++ b/tests/script/tsim/parser/columnValue_bool.sim @@ -31,26 +31,26 @@ if $data05 != NULL then endi sql create table st_bool_2 using mt_bool tags ('NULL') sql show tags from st_bool_2 -if $data05 != false then - print ==3== expect: false, actually: $data05 +if $data05 != NULL then + print ==3== expect: NULL, actually: $data05 return -1 endi sql create table st_bool_3 using mt_bool tags ('NULL') sql show tags from st_bool_3 -if $data05 != false then - print ==4== expect: false, actually: $data05 +if $data05 != NULL then + print ==4== expect: NULL, actually: $data05 return -1 endi sql create table st_bool_4 using mt_bool tags ("NULL") sql show tags from st_bool_4 -if $data05 != false then - print ==5== expect: false, actually: $data05 +if $data05 != NULL then + print ==5== expect: NULL, actually: $data05 return -1 endi sql create table st_bool_5 using mt_bool tags ("NULL") sql show tags from st_bool_5 -if $data05 != false then - print ==6== expect: false, actually: $data05 +if $data05 != NULL then + print ==6== expect: NULL, actually: $data05 return -1 endi sql create table st_bool_6 using mt_bool tags ("true") @@ -113,16 +113,94 @@ if $data05 != true then print ==16== expect: 1, actually: $data00 return -1 endi -sql create table st_bool_15_0 using mt_bool tags (+300) -sql show tags from st_bool_15_0 +sql create table st_bool_16 using mt_bool tags (+300) +sql show tags from st_bool_16 if $data05 != true then - print ==16== expect: 1, actually: $data00 return -1 endi -sql create table st_bool_15_1 using mt_bool tags (-8.03) -sql show tags from st_bool_15_1 +sql create table st_bool_17 using mt_bool tags (-8.03) +sql show tags from st_bool_17 if $data05 != true then - print ==16== expect: 1, actually: $data00 + return -1 +endi +sql create table st_bool_18 using mt_bool tags ("-8.03") +sql show tags from st_bool_18 +if $data05 != true then + return -1 +endi +sql create table st_bool_19 using mt_bool tags ("+300") +sql show tags from st_bool_19 +if $data05 != true then + return -1 +endi +sql create table st_bool_20 using mt_bool tags ("-8e+2") +sql show tags from st_bool_20 +if $data05 != true then + return -1 +endi +sql create table st_bool_21 using mt_bool tags ("0x01") +sql show tags from st_bool_21 +if $data05 != true then + return -1 +endi +sql create table st_bool_22 using mt_bool tags ("0b01") +sql show tags from st_bool_22 +if $data05 != true then + return -1 +endi +sql create table st_bool_23 using mt_bool tags ("+0x01") +sql show tags from st_bool_23 +if $data05 != true then + return -1 +endi +sql create table st_bool_24 using mt_bool tags ("-0b00") +sql show tags from st_bool_24 +if $data05 != false then + return -1 +endi +sql create table st_bool_26 using mt_bool tags ("-0.11e-30") +sql show tags from st_bool_26 +if $data05 != true then + return -1 +endi +sql create table st_bool_27 using mt_bool tags ("-1.0e-307") +sql show tags from st_bool_27 +if $data05 != true then + return -1 +endi +sql create table st_bool_28 using mt_bool tags ( -1e-1 ) +sql show tags from st_bool_28 +if $data05 != true then + return -1 +endi +sql create table st_bool_29 using mt_bool tags (-0.11e-30) +sql show tags from st_bool_29 +if $data05 != true then + return -1 +endi +sql create table st_bool_30 using mt_bool tags (-1.1e-307) +sql show tags from st_bool_30 +if $data05 != true then + return -1 +endi +sql create table st_bool_31 using mt_bool tags ( 0x01) +sql show tags from st_bool_31 +if $data05 != true then + return -1 +endi +sql create table st_bool_32 using mt_bool tags (0b01 ) +sql show tags from st_bool_32 +if $data05 != true then + return -1 +endi +sql create table st_bool_33 using mt_bool tags (+0x01) +sql show tags from st_bool_33 +if $data05 != true then + return -1 +endi +sql create table st_bool_34 using mt_bool tags ( -0b00 ) +sql show tags from st_bool_34 +if $data05 != false then return -1 endi @@ -271,8 +349,8 @@ if $data01 != 1 then print ==32== expect: true, actually: $data01 return -1 endi -sql insert into st_bool_15_0 values (now, +300) -sql select * from st_bool_15_0 +sql insert into st_bool_16 values (now, +300) +sql select * from st_bool_16 if $rows != 1 then return -1 endi @@ -280,8 +358,8 @@ if $data01 != 1 then print ==32== expect: true, actually: $data01 return -1 endi -sql insert into st_bool_15_1 values (now, -3.15) -sql select * from st_bool_15_1 +sql insert into st_bool_17 values (now, -3.15) +sql select * from st_bool_17 if $rows != 1 then return -1 endi @@ -289,304 +367,529 @@ if $data01 != 1 then print ==32== expect: true, actually: $data01 return -1 endi +sql insert into st_bool_18 values(now,"-8.03") +sql select * from st_bool_18 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_19 values(now,"+300") +sql select * from st_bool_19 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_20 values(now,"-8e+2") +sql select * from st_bool_20 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_21 values(now,"0x01") +sql select * from st_bool_21 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_22 values(now,"0b01") +sql select * from st_bool_22 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_23 values(now,"+0x01") +sql select * from st_bool_23 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_24 values(now,"-0b00") +sql select * from st_bool_24 +if $data01 != 0 then + return -1 +endi +sql insert into st_bool_26 values(now,"-0.11e-30") +sql select * from st_bool_26 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_27 values(now,"-1.0e-307") +sql select * from st_bool_27 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_28 values(now, -1e-1 ) +sql select * from st_bool_28 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_29 values(now,-0.11e-30) +sql select * from st_bool_29 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_30 values(now,-1.1e-307) +sql select * from st_bool_30 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_31 values(now, 0x01) +sql select * from st_bool_31 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_32 values(now,0b01 ) +sql select * from st_bool_32 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_33 values(now,+0x01) +sql select * from st_bool_33 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_34 values(now, -0b00 ) +sql select * from st_bool_34 +if $data01 != 0 then + return -1 +endi ## case 02: dynamic create table for test tag values -sql insert into st_bool_16 using mt_bool tags (NULL) values (now, NULL) -sql show create table st_bool_16 -sql show tags from st_bool_16 +sql insert into st_bool_116 using mt_bool tags (NULL) values (now, NULL) +sql show create table st_bool_116 +sql show tags from st_bool_116 if $data05 != NULL then print ==33== expect: NULL, actually: $data00 return -1 endi -sql select * from st_bool_16 +sql select * from st_bool_116 if $data01 != NULL then print ==34== expect: NULL, actually: $data01 return -1 endi -sql insert into st_bool_17 using mt_bool tags (NULL) values (now, NULL) -sql show tags from st_bool_17 +sql insert into st_bool_117 using mt_bool tags (NULL) values (now, NULL) +sql show tags from st_bool_117 if $data05 != NULL then print ==35== expect: NULL, actually: $data00 return -1 endi -sql select * from st_bool_17 +sql select * from st_bool_117 if $data01 != NULL then print ==36== expect: NULL, actually: $data01 return -1 endi -sql insert into st_bool_18 using mt_bool tags ('NULL') values (now, 'NULL') -sql show tags from st_bool_18 +sql insert into st_bool_118 using mt_bool tags ('NULL') values (now, 'NULL') +sql show tags from st_bool_118 if $data05 != NULL then print ==37== expect: NULL, actually: $data00 return -1 endi -sql select * from st_bool_18 +sql select * from st_bool_118 if $data01 != NULL then print ==38== expect: NULL, actually: $data01 return -1 endi -sql insert into st_bool_19 using mt_bool tags ('NULL') values (now, 'NULL') -sql show tags from st_bool_19 +sql insert into st_bool_119 using mt_bool tags ('NULL') values (now, 'NULL') +sql show tags from st_bool_119 if $data05 != NULL then print ==39== expect: NULL, actually: $data00 return -1 endi -sql select * from st_bool_19 +sql select * from st_bool_119 if $data01 != NULL then print ==40== expect: NULL, actually: $data01 return -1 endi -sql insert into st_bool_20 using mt_bool tags ("NULL") values (now, "NULL") -sql show tags from st_bool_20 +sql insert into st_bool_120 using mt_bool tags ("NULL") values (now, "NULL") +sql show tags from st_bool_120 if $data05 != NULL then print ==41== expect: NULL, actually: $data00 return -1 endi -sql select * from st_bool_20 +sql select * from st_bool_120 if $data01 != NULL then print ==42== expect: NULL, actually: $data01 return -1 endi -sql insert into st_bool_21 using mt_bool tags ("NULL") values (now, "NULL") -sql show tags from st_bool_21 +sql insert into st_bool_121 using mt_bool tags ("NULL") values (now, "NULL") +sql show tags from st_bool_121 if $data05 != NULL then print ==43== expect: NULL, actually: $data00 return -1 endi -sql select * from st_bool_21 +sql select * from st_bool_121 if $data01 != NULL then print ==44== expect: NULL, actually: $data01 return -1 endi -sql insert into st_bool_22 using mt_bool tags ("true") values (now, "true") -sql show tags from st_bool_22 +sql insert into st_bool_122 using mt_bool tags ("true") values (now, "true") +sql show tags from st_bool_122 if $data05 != true then print ==45== expect: 1, actually: $data00 return -1 endi -sql select * from st_bool_22 +sql select * from st_bool_122 if $data01 != 1 then print ==46== expect: 1, actually: $data01 return -1 endi -sql insert into st_bool_23 using mt_bool tags ('true') values (now, 'true') -sql show tags from st_bool_23 +sql insert into st_bool_123 using mt_bool tags ('true') values (now, 'true') +sql show tags from st_bool_123 if $data05 != true then print ==47== expect: 1, actually: $data00 return -1 endi -sql select * from st_bool_23 +sql select * from st_bool_123 if $data01 != 1 then print ==48== expect: 1, actually: $data01 return -1 endi -sql insert into st_bool_24 using mt_bool tags (true) values (now, true) -sql show tags from st_bool_24 +sql insert into st_bool_124 using mt_bool tags (true) values (now, true) +sql show tags from st_bool_124 if $data05 != true then print ==49== expect: 1, actually: $data00 return -1 endi -sql select * from st_bool_24 +sql select * from st_bool_124 if $data01 != 1 then print ==50== expect: 1, actually: $data01 return -1 endi -sql insert into st_bool_25 using mt_bool tags ("false") values (now, "false") -sql show tags from st_bool_25 +sql insert into st_bool_125 using mt_bool tags ("false") values (now, "false") +sql show tags from st_bool_125 if $data05 != false then print ==51== expect: 0, actually: $data00 return -1 endi -sql select * from st_bool_25 +sql select * from st_bool_125 if $data01 != 0 then print ==52== expect: 0, actually: $data01 return -1 endi -sql insert into st_bool_26 using mt_bool tags ('false') values (now, 'false') -sql show tags from st_bool_26 +sql insert into st_bool_126 using mt_bool tags ('false') values (now, 'false') +sql show tags from st_bool_126 if $data05 != false then print ==53== expect: 0, actually: $data00 return -1 endi -sql select * from st_bool_26 +sql select * from st_bool_126 if $data01 != 0 then print ==54== expect: 0, actually: $data01 return -1 endi -sql insert into st_bool_27 using mt_bool tags (false) values (now, false) -sql show tags from st_bool_27 +sql insert into st_bool_127 using mt_bool tags (false) values (now, false) +sql show tags from st_bool_127 if $data05 != false then print ==55== expect: 0, actually: $data00 return -1 endi -sql select * from st_bool_27 +sql select * from st_bool_127 if $data01 != 0 then print ==56== expect: 0, actually: $data01 return -1 endi -sql insert into st_bool_28 using mt_bool tags (0) values (now, 0) -sql show tags from st_bool_28 +sql insert into st_bool_128 using mt_bool tags (0) values (now, 0) +sql show tags from st_bool_128 if $data05 != false then print ==57== expect: 0, actually: $data00 return -1 endi -sql select * from st_bool_28 +sql select * from st_bool_128 if $data01 != 0 then print ==58== expect: 0, actually: $data01 return -1 endi -sql insert into st_bool_29 using mt_bool tags (1) values (now, 1) -sql show tags from st_bool_29 +sql insert into st_bool_129 using mt_bool tags (1) values (now, 1) +sql show tags from st_bool_129 if $data05 != true then print ==59== expect: 1, actually: $data00 return -1 endi -sql select * from st_bool_29 +sql select * from st_bool_129 if $data01 != 1 then print ==60== expect: 1, actually: $data01 return -1 endi -sql insert into st_bool_30 using mt_bool tags (6.9) values (now, 6.9) -sql show tags from st_bool_30 +sql insert into st_bool_130 using mt_bool tags (6.9) values (now, 6.9) +sql show tags from st_bool_130 if $data05 != true then print ==61== expect: 1, actually: $data00 return -1 endi -sql select * from st_bool_30 +sql select * from st_bool_130 if $data01 != 1 then print ==62== expect: 1, actually: $data01 return -1 endi -sql insert into st_bool_31 using mt_bool tags (-3) values (now, -3) -sql show tags from st_bool_31 +sql insert into st_bool_131 using mt_bool tags (-3) values (now, -3) +sql show tags from st_bool_131 if $data05 != true then print ==63== expect: 1, actually: $data00 return -1 endi -sql select * from st_bool_31 +sql select * from st_bool_131 if $data01 != 1 then print ==64== expect: 1, actually: $data01 return -1 endi -sql insert into st_bool_32 using mt_bool tags (+300) values (now, +300) -sql show tags from st_bool_32 +sql insert into st_bool_132 using mt_bool tags (+300) values (now, +300) +sql show tags from st_bool_132 if $data05 != true then print ==63== expect: 1, actually: $data00 return -1 endi -sql select * from st_bool_32 +sql select * from st_bool_132 if $data01 != 1 then print ==64== expect: 1, actually: $data01 return -1 endi -sql insert into st_bool_33 using mt_bool tags (+30.890) values (now, +30.890) -sql show tags from st_bool_33 +sql insert into st_bool_133 using mt_bool tags (+30.890) values (now, +30.890) +sql show tags from st_bool_133 if $data05 != true then print ==63== expect: 1, actually: $data00 return -1 endi -sql select * from st_bool_33 +sql select * from st_bool_133 if $data01 != 1 then print ==64== expect: 1, actually: $data01 return -1 endi - - - - - +sql insert into st_bool_218 using mt_bool tags ("-8.03") values (now,"-8.03") +sql show tags from st_bool_218 +if $data05 != true then + return -1 +endi +sql select * from st_bool_218 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_219 using mt_bool tags ("+300") values (now,"+300") +sql show tags from st_bool_219 +if $data05 != true then + return -1 +endi +sql select * from st_bool_219 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_220 using mt_bool tags ("-8e+2") values (now,"-8e+2") +sql show tags from st_bool_220 +if $data05 != true then + return -1 +endi +sql select * from st_bool_220 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_221 using mt_bool tags ("0x01") values (now,"0x01") +sql show tags from st_bool_221 +if $data05 != true then + return -1 +endi +sql select * from st_bool_221 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_222 using mt_bool tags ("0b01") values (now,"0b01") +sql show tags from st_bool_222 +if $data05 != true then + return -1 +endi +sql select * from st_bool_222 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_223 using mt_bool tags ("+0x01") values (now,"+0x01") +sql show tags from st_bool_223 +if $data05 != true then + return -1 +endi +sql select * from st_bool_223 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_224 using mt_bool tags ("-0b00") values (now,"-0b00") +sql show tags from st_bool_224 +if $data05 != false then + return -1 +endi +sql select * from st_bool_224 +if $data01 != 0 then + return -1 +endi +sql insert into st_bool_226 using mt_bool tags ("-0.11e-30") values (now,"-0.11e-30") +sql show tags from st_bool_226 +if $data05 != true then + return -1 +endi +sql select * from st_bool_226 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_227 using mt_bool tags ("-1.0e-307") values (now,"-1.0e-307") +sql show tags from st_bool_227 +if $data05 != true then + return -1 +endi +sql select * from st_bool_227 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_228 using mt_bool tags ( -1e-1 ) values (now, -1e-1 ) +sql show tags from st_bool_228 +if $data05 != true then + return -1 +endi +sql select * from st_bool_228 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_229 using mt_bool tags (-0.11e-30) values (now,-0.11e-30) +sql show tags from st_bool_229 +if $data05 != true then + return -1 +endi +sql select * from st_bool_229 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_230 using mt_bool tags (-1.1e-307) values (now,-1.1e-307) +sql show tags from st_bool_230 +if $data05 != true then + return -1 +endi +sql select * from st_bool_230 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_231 using mt_bool tags ( 0x01) values (now, 0x01) +sql show tags from st_bool_231 +if $data05 != true then + return -1 +endi +sql select * from st_bool_231 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_232 using mt_bool tags (0b01 ) values (now, 0b01) +sql show tags from st_bool_232 +if $data05 != true then + return -1 +endi +sql select * from st_bool_232 +if $data01 != 1 then + return -1 +endi +sql insert into st_bool_233 using mt_bool tags (+0x01) values (now,+0x01) +sql show tags from st_bool_233 +if $data05 != true then + return -1 +endi +sql insert into st_bool_234 using mt_bool tags ( -0b00 ) values (now, -0b00) +sql show tags from st_bool_234 +if $data05 != false then + return -1 +endi +sql select * from st_bool_234 +if $data01 != 0 then + return -1 +endi ## case 03: alter tag values -#sql alter table st_bool_0 set tag tagname=true -#sql show tags from st_bool_0 -#if $data00 != true then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname=NULL -#sql show tags from st_bool_0 -#if $data00 != NULL then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname=false -#sql show tags from st_bool_0 -#if $data00 != false then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname=NULL -#sql show tags from st_bool_0 -#if $data00 != NULL then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname='true' -#sql show tags from st_bool_0 -#if $data00 != true then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname='NULL' -#sql show tags from st_bool_0 -#if $data00 != NULL then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname='false' -#sql show tags from st_bool_0 -#if $data00 != false then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname='NULL' -#sql show tags from st_bool_0 -#if $data00 != NULL then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname="true" -#sql show tags from st_bool_0 -#if $data00 != true then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname="NULL" -#sql show tags from st_bool_0 -#if $data00 != NULL then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname="false" -#sql show tags from st_bool_0 -#if $data00 != false then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname="NULL" -#sql show tags from st_bool_0 -#if $data00 != NULL then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname=1 -#sql show tags from st_bool_0 -#if $data00 != true then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname=0 -#sql show tags from st_bool_0 -#if $data00 != false then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname=6.9 -#sql show tags from st_bool_0 -#if $data00 != true then -# return -1 -#endi -#sql alter table st_bool_0 set tag tagname=-3 -#sql show tags from st_bool_0 -#if $data00 != true then -# return -1 -#endi +sql alter table st_bool_16 set tag tagname=+300 +sql show tags from st_bool_16 +if $data05 != true then + return -1 +endi +sql alter table st_bool_17 set tag tagname=-8.03 +sql show tags from st_bool_17 +if $data05 != true then + return -1 +endi +sql alter table st_bool_18 set tag tagname="-8.03" +sql show tags from st_bool_18 +if $data05 != true then + return -1 +endi +sql alter table st_bool_19 set tag tagname="+300" +sql show tags from st_bool_19 +if $data05 != true then + return -1 +endi +sql alter table st_bool_20 set tag tagname="-8e+2" +sql show tags from st_bool_20 +if $data05 != true then + return -1 +endi +sql alter table st_bool_21 set tag tagname="0x01" +sql show tags from st_bool_21 +if $data05 != true then + return -1 +endi +sql alter table st_bool_22 set tag tagname="0b01" +sql show tags from st_bool_22 +if $data05 != true then + return -1 +endi +sql alter table st_bool_23 set tag tagname="+0x01" +sql show tags from st_bool_23 +if $data05 != true then + return -1 +endi +sql alter table st_bool_24 set tag tagname="-0b00" +sql show tags from st_bool_24 +if $data05 != false then + return -1 +endi +sql alter table st_bool_26 set tag tagname="-0.11e-30" +sql show tags from st_bool_26 +if $data05 != true then + return -1 +endi +sql alter table st_bool_27 set tag tagname="-1.0e-307" +sql show tags from st_bool_27 +if $data05 != true then + return -1 +endi +sql alter table st_bool_28 set tag tagname= -1e-1 +sql show tags from st_bool_28 +if $data05 != true then + return -1 +endi +sql alter table st_bool_29 set tag tagname=-0.11e-30 +sql show tags from st_bool_29 +if $data05 != true then + return -1 +endi +sql alter table st_bool_30 set tag tagname=-1.1e-307 +sql show tags from st_bool_30 +if $data05 != true then + return -1 +endi +sql alter table st_bool_31 set tag tagname= 0x01 +sql show tags from st_bool_31 +if $data05 != true then + return -1 +endi +sql alter table st_bool_32 set tag tagname=0b01 +sql show tags from st_bool_32 +if $data05 != true then + return -1 +endi +sql alter table st_bool_33 set tag tagname=+0x01 +sql show tags from st_bool_33 +if $data05 != true then + return -1 +endi +sql alter table st_bool_34 set tag tagname= -0b00 +sql show tags from st_bool_34 +if $data05 != false then + return -1 +endi # case 04: illegal input sql_error create table st_bool_e0 using mt_bool tags (123abc) -sql create table st_bool_e1 using mt_bool tags ("123abc") +sql_error create table st_bool_e1 using mt_bool tags ("123abc") sql create table st_bool_e2 using mt_bool tags ("123") sql_error create table st_bool_e3 using mt_bool tags (abc) -sql create table st_bool_e4 using mt_bool tags ("abc") -sql create table st_bool_e5 using mt_bool tags (" ") -sql create table st_bool_e6 using mt_bool tags ('') +sql_error create table st_bool_e4 using mt_bool tags ("abc") +sql_error create table st_bool_e5 using mt_bool tags (" ") +sql_error create table st_bool_e6 using mt_bool tags ('') sql create table st_bool_f0 using mt_bool tags (true) sql create table st_bool_f1 using mt_bool tags (true) @@ -598,7 +901,7 @@ sql create table st_bool_f6 using mt_bool tags (true) sql_error insert into st_bool_g0 values (now, 123abc) sql_error insert into st_bool_g1 values (now, "123abc") -sql_error insert into st_bool_g2 values (now, "123") +sql insert into st_bool_f2 values (now, "123") sql_error insert into st_bool_g3 values (now, abc) sql_error insert into st_bool_g4 values (now, "abc") sql_error insert into st_bool_g5 values (now, " ") @@ -606,7 +909,7 @@ sql_error insert into st_bool_g6 values (now, '') sql_error insert into st_bool_h0 using mt_bool tags (123abc) values (now, 1) sql_error insert into st_bool_h1 using mt_bool tags ("123abc") values (now, 1) -sql_error insert into st_bool_h2 using mt_bool tags ("123") values (now, 1) +sql insert into st_bool_h2 using mt_bool tags ("123") values (now, 1) sql_error insert into st_bool_h3 using mt_bool tags (abc) values (now, 1) sql_error insert into st_bool_h4 using mt_bool tags ("abc") values (now, 1) sql_error insert into st_bool_h5 using mt_bool tags (" ") values (now, 1) @@ -614,7 +917,7 @@ sql_error insert into st_bool_h6 using mt_bool tags ('') values (now, 1) sql_error insert into st_bool_h0 using mt_bool tags (1) values (now, 123abc) sql_error insert into st_bool_h1 using mt_bool tags (1) values (now, "123abc") -sql_error insert into st_bool_h2 using mt_bool tags (1) values (now, "123") +sql insert into st_bool_h2 using mt_bool tags (1) values (now, "123") sql_error insert into st_bool_h3 using mt_bool tags (1) values (now, abc) sql_error insert into st_bool_h4 using mt_bool tags (1) values (now, "abc") sql_error insert into st_bool_h5 using mt_bool tags (1) values (now, " ") @@ -629,11 +932,11 @@ sql insert into st_bool_i5 using mt_bool tags (1) values (now, 1) sql insert into st_bool_i6 using mt_bool tags (1) values (now, 1) sql_error alter table st_bool_i0 set tag tagname=123abc -sql alter table st_bool_i1 set tag tagname="123abc" -sql alter table st_bool_i2 set tag tagname="123" +sql_error alter table st_bool_i1 set tag tagname="123abc" +sql alter table st_bool_i2 set tag tagname="123" sql_error alter table st_bool_i3 set tag tagname=abc -sql alter table st_bool_i4 set tag tagname="abc" -sql alter table st_bool_i5 set tag tagname=" " -sql alter table st_bool_i6 set tag tagname='' +sql_error alter table st_bool_i4 set tag tagname="abc" +sql_error alter table st_bool_i5 set tag tagname=" " +sql_error alter table st_bool_i6 set tag tagname='' system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_double.sim b/tests/script/tsim/parser/columnValue_double.sim index bfcf338fac..2b1178106f 100644 --- a/tests/script/tsim/parser/columnValue_double.sim +++ b/tests/script/tsim/parser/columnValue_double.sim @@ -28,22 +28,22 @@ if $data05 != NULL then endi sql create table st_double_2 using mt_double tags ('NULL') sql show tags from st_double_2 -if $data05 != 0.000000000 then +if $data05 != NULL then return -1 endi sql create table st_double_3 using mt_double tags ('NULL') sql show tags from st_double_3 -if $data05 != 0.000000000 then +if $data05 != NULL then return -1 endi sql create table st_double_4 using mt_double tags ("NULL") sql show tags from st_double_4 -if $data05 != 0.000000000 then +if $data05 != NULL then return -1 endi sql create table st_double_5 using mt_double tags ("NULL") sql show tags from st_double_5 -if $data05 != 0.000000000 then +if $data05 != NULL then return -1 endi sql create table st_double_6 using mt_double tags (-123.321) @@ -148,6 +148,46 @@ sql show tags from st_double_16_0 #if $data05 != 0.001500000 then # return -1 #endi +sql create table st_double_100 using mt_double tags ("0x01") +sql show tags from st_double_100 +if $data05 != 1.000000000 then + return -1 +endi +sql create table st_double_101 using mt_double tags ("0b01") +sql show tags from st_double_101 +if $data05 != 1.000000000 then + return -1 +endi +sql create table st_double_102 using mt_double tags ("+0x01") +sql show tags from st_double_102 +if $data05 != 1.000000000 then + return -1 +endi +sql create table st_double_103 using mt_double tags ("-0b01") +sql show tags from st_double_103 +if $data05 != -1.000000000 then + return -1 +endi +sql create table st_double_200 using mt_double tags ( 0x01) +sql show tags from st_double_200 +if $data05 != 1.000000000 then + return -1 +endi +sql create table st_double_201 using mt_double tags (0b01 ) +sql show tags from st_double_201 +if $data05 != 1.000000000 then + return -1 +endi +sql create table st_double_202 using mt_double tags (+0x01) +sql show tags from st_double_202 +if $data05 != 1.000000000 then + return -1 +endi +sql create table st_double_203 using mt_double tags ( -0b01 ) +sql show tags from st_double_203 +if $data05 != -1.000000000 then + return -1 +endi ## case 01: insert values for test column values sql insert into st_double_0 values (now, NULL ) @@ -274,6 +314,70 @@ endi #if $data01 != -56 then # return -1 #endi +sql insert into st_double_100 values(now, "0x01") +sql select * from st_double_100 +if $rows != 1 then + return -1 +endi +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_101 values(now, "0b01") +sql select * from st_double_101 +if $rows != 1 then + return -1 +endi +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_102 values(now, "+0x01") +sql select * from st_double_102 +if $rows != 1 then + return -1 +endi +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_103 values(now, "-0b01") +sql select * from st_double_103 +if $rows != 1 then + return -1 +endi +if $data01 != -1.000000000 then + return -1 +endi +sql insert into st_double_200 values(now, 0x01) +sql select * from st_double_200 +if $rows != 1 then + return -1 +endi +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_201 values(now, 0b01 ) +sql select * from st_double_201 +if $rows != 1 then + return -1 +endi +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_202 values(now, +0x01) +sql select * from st_double_202 +if $rows != 1 then + return -1 +endi +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_203 values(now, -0b01 ) +sql select * from st_double_203 +if $rows != 1 then + return -1 +endi +if $data01 != -1.000000000 then + return -1 +endi ## case 02: dynamic create table for test tag values sql insert into st_double_16 using mt_double tags (NULL ) values (now, NULL ) @@ -394,6 +498,78 @@ sql select * from st_double_28 #if $data01 != -56 then # return -1 #endi +sql insert into st_double_100 using mt_double tags ("0x01") values (now, "0x01") +sql show tags from st_double_100 +if $data05 != 1.000000000 then + return -1 +endi +sql select * from st_double_100 +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_101 using mt_double tags ("0b01") values (now, "0b01") +sql show tags from st_double_101 +if $data05 != 1.000000000 then + return -1 +endi +sql select * from st_double_101 +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_102 using mt_double tags ("+0x01") values (now, "+0x01") +sql show tags from st_double_102 +if $data05 != 1.000000000 then + return -1 +endi +sql select * from st_double_102 +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_103 using mt_double tags ("-0b01") values (now, "-0b01") +sql show tags from st_double_103 +if $data05 != -1.000000000 then + return -1 +endi +sql select * from st_double_103 +if $data01 != -1.000000000 then + return -1 +endi +sql insert into st_double_200 using mt_double tags ( 0x01) values (now, 0x01) +sql show tags from st_double_200 +if $data05 != 1.000000000 then + return -1 +endi +sql select * from st_double_200 +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_201 using mt_double tags (0b01 ) values (now, 0b01) +sql show tags from st_double_201 +if $data05 != 1.000000000 then + return -1 +endi +sql select * from st_double_201 +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_202 using mt_double tags (+0x01) values (now, +0x01) +sql show tags from st_double_202 +if $data05 != 1.000000000 then + return -1 +endi +sql select * from st_double_202 +if $data01 != 1.000000000 then + return -1 +endi +sql insert into st_double_203 using mt_double tags ( -0b01 ) values (now, -0b01) +sql show tags from st_double_203 +if $data05 != -1.000000000 then + return -1 +endi +sql select * from st_double_203 +if $data01 != -1.000000000 then + return -1 +endi ### case 03: alter tag values #sql alter table st_double_0 set tag tagname=1.7976931348623157e+308 @@ -436,6 +612,46 @@ sql select * from st_double_28 ##if $data05 != -63 then ## return -1 ##endi +sql alter table st_double_100 set tag tagname="0x01" +sql show tags from st_double_100 +if $data05 != 1.000000000 then + return -1 +endi +sql alter table st_double_101 set tag tagname="0b01" +sql show tags from st_double_101 +if $data05 != 1.000000000 then + return -1 +endi +sql alter table st_double_102 set tag tagname="+0x01" +sql show tags from st_double_102 +if $data05 != 1.000000000 then + return -1 +endi +sql alter table st_double_103 set tag tagname="-0b01" +sql show tags from st_double_103 +if $data05 != -1.000000000 then + return -1 +endi +sql alter table st_double_200 set tag tagname= 0x01 +sql show tags from st_double_200 +if $data05 != 1.000000000 then + return -1 +endi +sql alter table st_double_201 set tag tagname=0b01 +sql show tags from st_double_201 +if $data05 != 1.000000000 then + return -1 +endi +sql alter table st_double_202 set tag tagname=+0x01 +sql show tags from st_double_202 +if $data05 != 1.000000000 then + return -1 +endi +sql alter table st_double_203 set tag tagname= -0b01 +sql show tags from st_double_203 +if $data05 != -1.000000000 then + return -1 +endi ## case 04: illegal input sql_error create table st_double_e0 using mt_double tags (1.8976931348623157e+308) @@ -445,11 +661,11 @@ sql_error create table st_double_e0 using mt_double tags (-31.7976931348623157e+ #sql_error create table st_double_e0 using mt_double tags (12.80) truncate integer part #sql_error create table st_double_e0 using mt_double tags (-11.80) sql_error create table st_double_e0 using mt_double tags (123abc) -sql create table st_double_e0_1 using mt_double tags ("123abc") +sql_error create table st_double_e0_1 using mt_double tags ("123abc") sql_error create table st_double_e0 using mt_double tags (abc) -sql create table st_double_e0_2 using mt_double tags ("abc") -sql create table st_double_e0_3 using mt_double tags (" ") -sql create table st_double_e0_4 using mt_double tags ('') +sql_error create table st_double_e0_2 using mt_double tags ("abc") +sql_error create table st_double_e0_3 using mt_double tags (" ") +sql_error create table st_double_e0_4 using mt_double tags ('') sql create table st_double_e0 using mt_double tags (123) sql create table st_double_e1 using mt_double tags (123) @@ -502,7 +718,8 @@ sql_error insert into st_double_e20 using mt_double tags ("123abc") values (now, sql_error insert into st_double_e22 using mt_double tags (abc) values (now, -033) sql_error insert into st_double_e23 using mt_double tags ("abc") values (now, -033) sql_error insert into st_double_e24 using mt_double tags (" ") values (now, -033) -sql insert into st_double_e25 using mt_double tags ('') values (now, -033) +sql_error insert into st_double_e25 using mt_double tags ('') values (now, -033) +sql insert into st_double_e20 using mt_double tags ("123") values (now, -033) sql insert into st_double_e13 using mt_double tags (033) values (now, 00062) sql insert into st_double_e14 using mt_double tags (033) values (now, 00062) @@ -523,10 +740,11 @@ sql_error alter table st_double_e14 set tag tagname=-1.8976931348623157e+308 sql_error alter table st_double_e15 set tag tagname=131.7976931348623157e+308 sql_error alter table st_double_e16 set tag tagname=-131.7976931348623157e+308 sql_error alter table st_double_e19 set tag tagname=123abc -sql alter table st_double_e20 set tag tagname="123abc" +sql_error alter table st_double_e20 set tag tagname="123abc" sql_error alter table st_double_e22 set tag tagname=abc -sql alter table st_double_e23 set tag tagname="abc" -sql alter table st_double_e24 set tag tagname=" " -sql alter table st_double_e25 set tag tagname='' +sql_error alter table st_double_e23 set tag tagname="abc" +sql_error alter table st_double_e24 set tag tagname=" " +sql_error alter table st_double_e25 set tag tagname='' +sql alter table st_double_e25 set tag tagname='123' system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_float.sim b/tests/script/tsim/parser/columnValue_float.sim index 4dcda33224..facb2f1b79 100644 --- a/tests/script/tsim/parser/columnValue_float.sim +++ b/tests/script/tsim/parser/columnValue_float.sim @@ -29,22 +29,22 @@ if $data05 != NULL then endi sql create table st_float_2 using mt_float tags ('NULL') sql show tags from st_float_2 -if $data05 != 0.00000 then +if $data05 != NULL then return -1 endi sql create table st_float_3 using mt_float tags ('NULL') sql show tags from st_float_3 -if $data05 != 0.00000 then +if $data05 != NULL then return -1 endi sql create table st_float_4 using mt_float tags ("NULL") sql show tags from st_float_4 -if $data05 != 0.00000 then +if $data05 != NULL then return -1 endi sql create table st_float_5 using mt_float tags ("NULL") sql show tags from st_float_5 -if $data05 != 0.00000 then +if $data05 != NULL then return -1 endi sql create table st_float_6 using mt_float tags (-123.321) @@ -156,16 +156,62 @@ if $data05 != 0.00150 then print expect 0.00150, actual: $data05 return -1 endi -#sql create table st_float_15_0 using mt_float tags (3.40282347e+38) -#sql show tags from st_float_15_0 -#if $data05 != 0.001500 then -# return -1 -#endi -#sql create table st_float_16_0 using mt_float tags (-3.40282347e+38) -#sql show tags from st_float_16_0 -#if $data05 != 0.001500 then -# return -1 -#endi +sql create table st_float_15_0 using mt_float tags (3.40282346638528859811704183484516925e+38) +sql show tags from st_float_15_0 +if $data05 < 340282346638528859811704183484516925000 then + return -1 +endi +if $data05 > 340282346638528859811704183484516925900 then + return -1 +endi +sql create table st_float_16_0 using mt_float tags (-3.40282346638528859811704183484516925e+38) +sql show tags from st_float_16_0 +if $data05 < -340282346638528859811704183484516925900 then + return -1 +endi +if $data05 > -340282346638528859811704183484516925000 then + return -1 +endi +sql create table st_float_100 using mt_float tags ("0x01") +sql show tags from st_float_100 +if $data05 != 1.00000 then + return -1 +endi +sql create table st_float_101 using mt_float tags ("0b01") +sql show tags from st_float_101 +if $data05 != 1.00000 then + return -1 +endi +sql create table st_float_102 using mt_float tags ("+0x01") +sql show tags from st_float_102 +if $data05 != 1.00000 then + return -1 +endi +sql create table st_float_103 using mt_float tags ("-0b01") +sql show tags from st_float_103 +if $data05 != -1.00000 then + return -1 +endi +sql create table st_float_200 using mt_float tags ( 0x01) +sql show tags from st_float_200 +if $data05 != 1.00000 then + return -1 +endi +sql create table st_float_201 using mt_float tags (0b01 ) +sql show tags from st_float_201 +if $data05 != 1.00000 then + return -1 +endi +sql create table st_float_202 using mt_float tags (+0x01) +sql show tags from st_float_202 +if $data05 != 1.00000 then + return -1 +endi +sql create table st_float_203 using mt_float tags ( -0b01 ) +sql show tags from st_float_203 +if $data05 != -1.00000 then + return -1 +endi ## case 01: insert values for test column values sql insert into st_float_0 values (now, NULL) @@ -216,6 +262,70 @@ endi if $data01 != NULL then return -1 endi +sql insert into st_float_100 values(now, "0x01") +sql select * from st_float_100 +if $rows != 1 then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_101 values(now, "0b01") +sql select * from st_float_101 +if $rows != 1 then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_102 values(now, "+0x01") +sql select * from st_float_102 +if $rows != 1 then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_103 values(now, "-0b01") +sql select * from st_float_103 +if $rows != 1 then + return -1 +endi +if $data01 != -1.00000 then + return -1 +endi +sql insert into st_float_200 values(now, 0x01) +sql select * from st_float_200 +if $rows != 1 then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_201 values(now, 0b01 ) +sql select * from st_float_201 +if $rows != 1 then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_202 values(now, +0x01) +sql select * from st_float_202 +if $rows != 1 then + return -1 +endi +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_203 values(now, -0b01 ) +sql select * from st_float_203 +if $rows != 1 then + return -1 +endi +if $data01 != -1.00000 then + return -1 +endi sql_error insert into st_float_6 values (now, 3.40282347e+38) sql_error insert into st_float_6 values (now, -3.40282347e+38) @@ -425,6 +535,78 @@ sql select * from st_float_28 if $data01 != -5.60000 then return -1 endi +sql insert into st_float_100 using mt_float tags ("0x01") values (now, "0x01") +sql show tags from st_float_100 +if $data05 != 1.00000 then + return -1 +endi +sql select * from st_float_100 +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_101 using mt_float tags ("0b01") values (now, "0b01") +sql show tags from st_float_101 +if $data05 != 1.00000 then + return -1 +endi +sql select * from st_float_101 +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_102 using mt_float tags ("+0x01") values (now, "+0x01") +sql show tags from st_float_102 +if $data05 != 1.00000 then + return -1 +endi +sql select * from st_float_102 +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_103 using mt_float tags ("-0b01") values (now, "-0b01") +sql show tags from st_float_103 +if $data05 != -1.00000 then + return -1 +endi +sql select * from st_float_103 +if $data01 != -1.00000 then + return -1 +endi +sql insert into st_float_200 using mt_float tags ( 0x01) values (now, 0x01) +sql show tags from st_float_200 +if $data05 != 1.00000 then + return -1 +endi +sql select * from st_float_200 +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_201 using mt_float tags (0b01 ) values (now, 0b01) +sql show tags from st_float_201 +if $data05 != 1.00000 then + return -1 +endi +sql select * from st_float_201 +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_202 using mt_float tags (+0x01) values (now, +0x01) +sql show tags from st_float_202 +if $data05 != 1.00000 then + return -1 +endi +sql select * from st_float_202 +if $data01 != 1.00000 then + return -1 +endi +sql insert into st_float_203 using mt_float tags ( -0b01 ) values (now, -0b01) +sql show tags from st_float_203 +if $data05 != -1.00000 then + return -1 +endi +sql select * from st_float_203 +if $data01 != -1.00000 then + return -1 +endi ### case 03: alter tag values sql alter table st_float_0 set tag tagname=340282346638528859811704183484516925440.00000 @@ -468,6 +650,46 @@ sql show tags from st_float_0 if $data05 != -63.58200 then return -1 endi +sql alter table st_float_100 set tag tagname="0x01" +sql show tags from st_float_100 +if $data05 != 1.00000 then + return -1 +endi +sql alter table st_float_101 set tag tagname="0b01" +sql show tags from st_float_101 +if $data05 != 1.00000 then + return -1 +endi +sql alter table st_float_102 set tag tagname="+0x01" +sql show tags from st_float_102 +if $data05 != 1.00000 then + return -1 +endi +sql alter table st_float_103 set tag tagname="-0b01" +sql show tags from st_float_103 +if $data05 != -1.00000 then + return -1 +endi +sql alter table st_float_200 set tag tagname= 0x01 +sql show tags from st_float_200 +if $data05 != 1.00000 then + return -1 +endi +sql alter table st_float_201 set tag tagname=0b01 +sql show tags from st_float_201 +if $data05 != 1.00000 then + return -1 +endi +sql alter table st_float_202 set tag tagname=+0x01 +sql show tags from st_float_202 +if $data05 != 1.00000 then + return -1 +endi +sql alter table st_float_203 set tag tagname= -0b01 +sql show tags from st_float_203 +if $data05 != -1.00000 then + return -1 +endi ## case 04: illegal input sql_error create table st_float_e0 using mt_float tags (3.50282347e+38) @@ -477,11 +699,11 @@ sql_error create table st_float_e0 using mt_float tags (-333.40282347e+38) #sql_error create table st_float_e0 using mt_float tags (12.80) truncate integer part #sql_error create table st_float_e0 using mt_float tags (-11.80) sql_error create table st_float_e0 using mt_float tags (123abc) -sql create table st_float_e0_1 using mt_float tags ("123abc") +sql_error create table st_float_e0_1 using mt_float tags ("123abc") sql_error create table st_float_e0 using mt_float tags (abc) -sql create table st_float_e0_2 using mt_float tags ("abc") -sql create table st_float_e0_3 using mt_float tags (" ") -sql create table st_float_e0_4 using mt_float tags ('') +sql_error create table st_float_e0_2 using mt_float tags ("abc") +sql_error create table st_float_e0_3 using mt_float tags (" ") +sql_error create table st_float_e0_4 using mt_float tags ('') sql create table st_float_e0 using mt_float tags (123) sql create table st_float_e1 using mt_float tags (123) @@ -534,7 +756,7 @@ sql_error insert into st_float_e20 using mt_float tags ("123abc") values (now, - sql_error insert into st_float_e22 using mt_float tags (abc) values (now, -033) sql_error insert into st_float_e23 using mt_float tags ("abc") values (now, -033) sql_error insert into st_float_e24 using mt_float tags (" ") values (now, -033) -sql insert into st_float_e25_3 using mt_float tags ('') values (now, -033) +sql_error insert into st_float_e25_3 using mt_float tags ('') values (now, -033) sql insert into st_float_e13 using mt_float tags (033) values (now, 00062) sql insert into st_float_e14 using mt_float tags (033) values (now, 00062) @@ -555,10 +777,10 @@ sql_error alter table st_float_e14 set tag tagname=-3.50282347e+38 sql_error alter table st_float_e15 set tag tagname=13.40282347e+38 sql_error alter table st_float_e16 set tag tagname=-13.40282347e+38 sql_error alter table st_float_e19 set tag tagname=123abc -sql alter table st_float_e20 set tag tagname="123abc" +sql_error alter table st_float_e20 set tag tagname="123abc" sql_error alter table st_float_e22 set tag tagname=abc -sql alter table st_float_e23 set tag tagname="abc" -sql alter table st_float_e24 set tag tagname=" " -sql alter table st_float_e25 set tag tagname='' +sql_error alter table st_float_e23 set tag tagname="abc" +sql_error alter table st_float_e24 set tag tagname=" " +sql_error alter table st_float_e25 set tag tagname='' system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_geometry.sim b/tests/script/tsim/parser/columnValue_geometry.sim new file mode 100644 index 0000000000..6b3c3a4390 --- /dev/null +++ b/tests/script/tsim/parser/columnValue_geometry.sim @@ -0,0 +1,277 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: geometry +print ========== geometry +sql create table mt_geometry (ts timestamp, c geometry(128)) tags(tagname geometry(128)) + +## case 00: static create table for test tag values +sql create table st_geometry_0 using mt_geometry tags(NULL) +sql show tags from st_geometry_0 +if $data05 != NULL then + return -1 +endi +sql create table st_geometry_1 using mt_geometry tags(NULL) +sql show tags from st_geometry_1 +if $data05 != NULL then + return -1 +endi +sql create table st_geometry_2 using mt_geometry tags('NULL') +sql show tags from st_geometry_2 +if $data05 != NULL then + return -1 +endi +sql create table st_geometry_3 using mt_geometry tags('NULL') +sql show tags from st_geometry_3 +if $data05 != NULL then + return -1 +endi +sql create table st_geometry_4 using mt_geometry tags("NULL") +sql show tags from st_geometry_4 +if $data05 != NULL then + return -1 +endi +sql create table st_geometry_5 using mt_geometry tags("NULL") +sql show tags from st_geometry_5 +if $data05 != NULL then + return -1 +endi +sql create table st_geometry_6 using mt_geometry tags("POINT(1.0 1.0)") +sql show tags from st_geometry_6 +if $data05 != @POINT (1.000000 1.000000)@ then + print $data05 + return -1 +endi +sql create table st_geometry_7 using mt_geometry tags(" LINESTRING(1.0 1.0, 2.0 2.0)") +sql show tags from st_geometry_7 +if $data05 != @LINESTRING (1.000000 1.000000, 2.000000 2.000000)@ then + print $data05 + return -1 +endi +sql create table st_geometry_8 using mt_geometry tags("POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))") +sql show tags from st_geometry_8 +if $data05 != @POLYGON ((1.000000 1.000000, -2.000000 2.000000, 1.000000 1.000000))@ then + print $data05 + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_geometry_0 values(now, NULL) +sql select *from st_geometry_0 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_1 values(now, NULL) +sql select *from st_geometry_1 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_2 values(now, 'NULL') +sql select *from st_geometry_2 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_3 values(now, 'NULL') +sql select *from st_geometry_3 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_4 values(now, "NULL") +sql select *from st_geometry_4 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_5 values(now, "NULL") +sql select *from st_geometry_5 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_6 values(now, "POINT(1.0 1.0)") +sql select *from st_geometry_6 +if $data01 != @POINT (1.000000 1.000000)@ then +# return -1 +endi +sql insert into st_geometry_7 values(now, " LINESTRING(1.0 1.0, 2.0 2.0)") +sql select *from st_geometry_7 +if $data01 != @LINESTRING (1.000000 1.000000, 2.000000 2.000000)@ then +# return -1 +endi +sql insert into st_geometry_8 values(now, "POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))") +sql select *from st_geometry_8 +if $data01 != @POLYGON ((1.000000 1.000000, -2.000000 2.000000, 1.000000 1.000000))@ then +# return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_geometry_100 using mt_geometry tags(NULL) values(now, NULL) +sql show tags from st_geometry_100 +if $data05 != NULL then + return -1 +endi +sql select *from st_geometry_100 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_101 using mt_geometry tags(NULL) values(now, NULL) +sql show tags from st_geometry_101 +if $data05 != NULL then + return -1 +endi +sql select *from st_geometry_100 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_102 using mt_geometry tags('NULL') values(now, 'NULL') +sql show tags from st_geometry_102 +if $data05 != NULL then + return -1 +endi +sql select *from st_geometry_100 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_103 using mt_geometry tags('NULL') values(now, 'NULL') +sql show tags from st_geometry_103 +if $data05 != NULL then + return -1 +endi +sql select *from st_geometry_100 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_104 using mt_geometry tags("NULL") values(now, "NULL") +sql show tags from st_geometry_104 +if $data05 != NULL then + return -1 +endi +sql select *from st_geometry_100 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_105 using mt_geometry tags("NULL") values(now, "NULL") +sql show tags from st_geometry_105 +if $data05 != NULL then + return -1 +endi +sql select *from st_geometry_100 +if $data01 != NULL then + return -1 +endi +sql insert into st_geometry_106 using mt_geometry tags("POINT(1.0 1.0)") values(now, "POINT(1.0 1.0)") +sql show tags from st_geometry_106 +if $data05 != @POINT (1.000000 1.000000)@ then + return -1 +endi +sql select *from st_geometry_106 +if $data01 != @POINT (1.000000 1.000000)@ then +# return -1 +endi +sql insert into st_geometry_107 using mt_geometry tags(" LINESTRING(1.0 1.0, 2.0 2.0)") values(now, "LINESTRING(1.0 1.0, 2.0 2.0)") +sql show tags from st_geometry_107 +if $data05 != @LINESTRING (1.000000 1.000000, 2.000000 2.000000)@ then + return -1 +endi +sql select *from st_geometry_107 +if $data01 != @LINESTRING (1.000000 1.000000, 2.000000 2.000000)@ then +# return -1 +endi +sql insert into st_geometry_108 using mt_geometry tags("POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))") values(now, "POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))") +sql show tags from st_geometry_108 +if $data05 != @POLYGON ((1.000000 1.000000, -2.000000 2.000000, 1.000000 1.000000))@ then + return -1 +endi +sql select *from st_geometry_108 +if $data01 != @POLYGON ((1.000000 1.000000, -2.000000 2.000000, 1.000000 1.000000))@ then +# return -1 +endi + +## case 03: alter tag values +sql alter table st_geometry_0 set tag tagname=NULL +sql show tags from st_geometry_0 +if $data05 != NULL then + return -1 +endi +sql alter table st_geometry_1 set tag tagname=NULL +sql show tags from st_geometry_1 +if $data05 != NULL then + return -1 +endi +sql alter table st_geometry_2 set tag tagname='NULL' +sql show tags from st_geometry_2 +if $data05 != NULL then + return -1 +endi +sql alter table st_geometry_3 set tag tagname='NULL' +sql show tags from st_geometry_3 +if $data05 != NULL then + return -1 +endi +sql alter table st_geometry_4 set tag tagname="NULL" +sql show tags from st_geometry_4 +if $data05 != NULL then + return -1 +endi +sql alter table st_geometry_5 set tag tagname="NULL" +sql show tags from st_geometry_5 +if $data05 != NULL then + return -1 +endi +sql alter table st_geometry_6 set tag tagname="POINT(1.0 1.0)" +sql show tags from st_geometry_6 +if $data05 != @POINT (1.000000 1.000000)@ then + return -1 +endi +sql alter table st_geometry_7 set tag tagname=" LINESTRING(1.0 1.0, 2.0 2.0)" +sql show tags from st_geometry_7 +if $data05 != @LINESTRING (1.000000 1.000000, 2.000000 2.000000)@ then + return -1 +endi +sql alter table st_geometry_8 set tag tagname="POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))" +sql show tags from st_geometry_8 +if $data05 != @POLYGON ((1.000000 1.000000, -2.000000 2.000000, 1.000000 1.000000))@ then + return -1 +endi + +# case 04: illegal input +sql_error create table st_geometry_206 using mt_geometry tags(+0123) +sql_error create table st_geometry_207 using mt_geometry tags(-01.23) +sql_error create table st_geometry_208 using mt_geometry tags(+0x01) +sql_error create table st_geometry_209 using mt_geometry tags(-0b01) +sql_error create table st_geometry_2010 using mt_geometry tags(-0.1e-10) +sql_error create table st_geometry_2011 using mt_geometry tags(+0.1E+2) +sql_error create table st_geometry_2012 using mt_geometry tags(tRue) +sql_error create table st_geometry_2013 using mt_geometry tags(FalsE) +sql_error create table st_geometry_2014 using mt_geometry tags(noW) +sql_error create table st_geometry_2015 using mt_geometry tags(toDay) +sql_error insert into st_geometry_206 using mt_geometry tags(+0123) values(now, NULL); +sql_error insert into st_geometry_207 using mt_geometry tags(-01.23) values(now, NULL); +sql_error insert into st_geometry_208 using mt_geometry tags(+0x01) values(now, NULL); +sql_error insert into st_geometry_209 using mt_geometry tags(-0b01) values(now, NULL); +sql_error insert into st_geometry_2010 using mt_geometry tags(-0.1e-10) values(now, NULL); +sql_error insert into st_geometry_2011 using mt_geometry tags(+0.1E+2) values(now, NULL); +sql_error insert into st_geometry_2012 using mt_geometry tags(tRue) values(now, NULL); +sql_error insert into st_geometry_2013 using mt_geometry tags(FalsE) values(now, NULL); +sql_error insert into st_geometry_2014 using mt_geometry tags(noW) values(now, NULL); +sql_error insert into st_geometry_2015 using mt_geometry tags(toDay) values(now, NULL); +sql_error insert into st_geometry_106 using mt_varbinary tags(NULL) values(now(), +0123) +sql_error insert into st_geometry_107 using mt_varbinary tags(NULL) values(now(), -01.23) +sql_error insert into st_geometry_108 using mt_varbinary tags(NULL) values(now(), +0x01) +sql_error insert into st_geometry_109 using mt_varbinary tags(NULL) values(now(), -0b01) +sql_error insert into st_geometry_1010 using mt_varbinary tags(NULL) values(now(), -0.1e-10) +sql_error insert into st_geometry_1011 using mt_varbinary tags(NULL) values(now(), +0.1E+2) +sql_error insert into st_geometry_1012 using mt_varbinary tags(NULL) values(now(), tRue) +sql_error insert into st_geometry_1013 using mt_varbinary tags(NULL) values(now(), FalsE) +sql_error insert into st_geometry_1014 using mt_varbinary tags(NULL) values(now(), noW) +sql_error insert into st_geometry_1015 using mt_varbinary tags(NULL) values(now(), toDay) + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_int.sim b/tests/script/tsim/parser/columnValue_int.sim index e68ae6f13f..f03a576ae3 100644 --- a/tests/script/tsim/parser/columnValue_int.sim +++ b/tests/script/tsim/parser/columnValue_int.sim @@ -28,10 +28,26 @@ if $data05 != NULL then return -1 endi -sql_error create table st_int_2 using mt_int tags ('NULL') -sql_error create table st_int_3 using mt_int tags ('NULL') -sql_error create table st_int_4 using mt_int tags ("NULL") -sql_error create table st_int_5 using mt_int tags ("NULL") +sql create table st_int_2 using mt_int tags ('NULL') +sql show tags from st_int_2 +if $data05 != NULL then + return -1 +endi +sql create table st_int_3 using mt_int tags ('NULL') +sql show tags from st_int_3 +if $data05 != NULL then + return -1 +endi +sql create table st_int_4 using mt_int tags ("NULL") +sql show tags from st_int_4 +if $data05 != NULL then + return -1 +endi +sql create table st_int_5 using mt_int tags ("NULL") +sql show tags from st_int_5 +if $data05 != NULL then + return -1 +endi sql create table st_int_6 using mt_int tags (-2147483647) sql show tags from st_int_6 @@ -78,6 +94,103 @@ sql show tags from st_int_14 if $data05 != -78 then return -1 endi +sql create table st_int_100 using mt_int tags ("0x01") +sql show tags from st_int_100 +if $data05 != 1 then + return -1 +endi +sql create table st_int_101 using mt_int tags ("0b01") +sql show tags from st_int_101 +if $data05 != 1 then + return -1 +endi +sql create table st_int_102 using mt_int tags ("+0x01") +sql show tags from st_int_102 +if $data05 != 1 then + return -1 +endi +sql create table st_int_103 using mt_int tags ("-0b01") +sql show tags from st_int_103 +if $data05 != -1 then + return -1 +endi +sql create table st_int_104 using mt_int tags ("-123.1") +sql show tags from st_int_104 +if $data05 != -123 then + return -1 +endi +sql create table st_int_105 using mt_int tags ("+123.5") +sql show tags from st_int_105 +if $data05 != 124 then + return -1 +endi +sql create table st_int_106 using mt_int tags ("-1e-1") +sql show tags from st_int_106 +if $data05 != 0 then + return -1 +endi +sql create table st_int_107 using mt_int tags ("+0.1235e3") +sql show tags from st_int_107 +if $data05 != 124 then + print $data05 != 124 + return -1 +endi +sql create table st_int_108 using mt_int tags ("-0.11e-30") +sql show tags from st_int_108 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql create table st_int_109 using mt_int tags ("-1.1e-307") +sql show tags from st_int_109 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql create table st_int_110 using mt_int tags ( -1e-1 ) +sql show tags from st_int_110 +if $data05 != 0 then + return -1 +endi +sql create table st_int_111 using mt_int tags ( +0.1235e3 ) +sql show tags from st_int_111 +if $data05 != 124 then + print $data05 != 124 + return -1 +endi +sql create table st_int_112 using mt_int tags (-0.11e-30) +sql show tags from st_int_112 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql create table st_int_113 using mt_int tags (-1.1e-307) +sql show tags from st_int_113 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql create table st_int_200 using mt_int tags ( 0x01) +sql show tags from st_int_200 +if $data05 != 1 then + return -1 +endi +sql create table st_int_201 using mt_int tags (0b01 ) +sql show tags from st_int_201 +if $data05 != 1 then + return -1 +endi +sql create table st_int_202 using mt_int tags (+0x01) +sql show tags from st_int_202 +if $data05 != 1 then + return -1 +endi + +sql create table st_int_203 using mt_int tags ( -0b01 ) +sql show tags from st_int_203 +if $data05 != -1 then + return -1 +endi ## case 01: insert values for test column values sql insert into st_int_0 values (now, NULL) @@ -171,6 +284,122 @@ if $data01 != -56 then return -1 endi +sql insert into st_int_100 values (now, "0x01") +sql select * from st_int_100 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_int_101 values (now, "0b01") +sql select * from st_int_101 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_int_102 values (now, "+0x01") +sql select * from st_int_102 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_int_103 values (now, "-0b01") +sql select * from st_int_103 +if $data01 != -1 then + return -1 +endi +sql insert into st_int_104 values (now, "-123.1") +sql select * from st_int_104 +if $data01 != -123 then + return -1 +endi +sql insert into st_int_105 values (now, "+123.5") +sql select * from st_int_105 +if $data01 != 124 then + return -1 +endi +sql insert into st_int_106 values (now, "-1e-1") +sql select * from st_int_106 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_107 values (now, "+0.1235e3") +sql select * from st_int_107 +if $data01 != 124 then + print $data05 != 124 + return -1 +endi +sql insert into st_int_108 values (now, "-0.11e-30") +sql select * from st_int_108 +if $data01 != 0 then + print $data05 != 0 + return -1 +endi +sql insert into st_int_109 values (now, "-1.1e-307") +sql select * from st_int_109 +if $data01 != 0 then + print $data05 != 0 + return -1 +endi +sql insert into st_int_110 values (now, -1e-1 ) +sql select * from st_int_110 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_111 values (now, +0.1235e3 ) +sql select * from st_int_111 +if $data01 != 124 then + print $data05 != 124 + return -1 +endi +sql insert into st_int_112 values (now, -0.11e-30) +sql select * from st_int_112 +if $data01 != 0 then + print $data05 != 0 + return -1 +endi +sql insert into st_int_113 values (now, -1.1e-307) +sql select * from st_int_113 +if $data01 != 0 then + print $data05 != 0 + return -1 +endi +sql insert into st_int_200 values (now, 0x01) +sql select * from st_int_200 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_int_201 values (now, 0b01 ) +sql select * from st_int_201 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_int_202 values (now, +0x01) +sql select * from st_int_202 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql insert into st_int_203 values (now, -0b01 ) +sql select * from st_int_203 +if $data01 != -1 then + return -1 +endi + ## case 02: dynamic create table for test tag values sql insert into st_int_16 using mt_int tags (NULL) values (now, NULL) sql show create table st_int_16 @@ -291,52 +520,308 @@ sql select * from st_int_28 if $data01 != -56 then return -1 endi +sql insert into st_int_1100 using mt_int tags ("0x01") values(now, "0x01"); +sql show tags from st_int_1100 +if $data05 != 1 then + return -1 +endi +sql select * from st_int_1100 +if $data01 != 1 then + return -1 +endi +sql insert into st_int_1101 using mt_int tags ("0b01") values(now, "0b01"); +sql show tags from st_int_1101 +if $data05 != 1 then + return -1 +endi +sql select * from st_int_1101 +if $data01 != 1 then + return -1 +endi +sql insert into st_int_1102 using mt_int tags ("+0x01") values(now, "+0x01"); +sql show tags from st_int_1102 +if $data05 != 1 then + return -1 +endi +sql select * from st_int_1102 +if $data01 != 1 then + return -1 +endi +sql insert into st_int_1103 using mt_int tags ("-0b01") values(now, "-0b01"); +sql show tags from st_int_1103 +if $data05 != -1 then + return -1 +endi +sql select * from st_int_1103 +if $data01 != -1 then + return -1 +endi +sql insert into st_int_1104 using mt_int tags ("-123.1") values(now, "-123.1"); +sql show tags from st_int_1104 +if $data05 != -123 then + return -1 +endi +sql select * from st_int_1104 +if $data01 != -123 then + return -1 +endi +sql insert into st_int_1105 using mt_int tags ("+123.5") values(now, "+123.5"); +sql show tags from st_int_1105 +if $data05 != 124 then + return -1 +endi +sql select * from st_int_1105 +if $data01 != 124 then + return -1 +endi +sql insert into st_int_1106 using mt_int tags ("-1e-1") values(now, "-1e-1"); +sql show tags from st_int_1106 +if $data05 != 0 then + return -1 +endi +sql select * from st_int_1106 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_1107 using mt_int tags ("+0.1235e3") values(now, "+0.1235e3"); +sql show tags from st_int_1107 +if $data05 != 124 then + return -1 +endi +sql insert into st_int_1108 using mt_int tags ("-0.11e-30") values(now, "-0.11e-30"); +sql show tags from st_int_1108 +if $data05 != 0 then + return -1 +endi +sql select * from st_int_1108 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_1109 using mt_int tags ("-1.1e-307") values(now, "-1.1e-307"); +sql show tags from st_int_1109 +if $data05 != 0 then + return -1 +endi +sql select * from st_int_1109 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_1110 using mt_int tags ( -1e-1 ) values(now, -1e-1); +sql show tags from st_int_1110 +if $data05 != 0 then + return -1 +endi +sql select * from st_int_1110 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_1111 using mt_int tags ( +0.1235e3 ) values(now, +0.1235e3); +sql show tags from st_int_1111 +if $data05 != 124 then + return -1 +endi +sql select * from st_int_1111 +if $data01 != 124 then + return -1 +endi +sql insert into st_int_1112 using mt_int tags (-0.11e-30) values(now, -0.11e-30); +sql show tags from st_int_1112 +if $data05 != 0 then + return -1 +endi +sql select * from st_int_1112 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_1113 using mt_int tags (-1.1e-307) values(now, -1.1e-307); +sql show tags from st_int_1113 +if $data05 != 0 then + return -1 +endi +sql select * from st_int_1113 +if $data01 != 0 then + return -1 +endi +sql insert into st_int_1200 using mt_int tags ( 0x01) values(now, 0x01); +sql show tags from st_int_1200 +if $data05 != 1 then + return -1 +endi +sql select * from st_int_1200 +if $data01 != 1 then + return -1 +endi +sql insert into st_int_1201 using mt_int tags (0b01 ) values(now, 0b01); +sql show tags from st_int_1201 +if $data05 != 1 then + return -1 +endi +sql select * from st_int_1201 +if $data01 != 1 then + return -1 +endi +sql insert into st_int_1202 using mt_int tags (+0x01) values(now, +0x01); +sql show tags from st_int_1202 +if $data05 != 1 then + return -1 +endi +sql select * from st_int_1202 +if $data01 != 1 then + return -1 +endi + +sql insert into st_int_1203 using mt_int tags ( -0b01 ) values(now, -0b01); +sql show tags from st_int_1203 +if $data05 != -1 then + return -1 +endi +sql select * from st_int_1203 +if $data01 != -1 then + return -1 +endi ### case 03: alter tag values -#sql alter table st_int_0 set tag tagname=2147483647 -#sql show tags from st_int_0 -#if $data05 != 2147483647 then -# return -1 -#endi -#sql alter table st_int_0 set tag tagname=-2147483647 -#sql show tags from st_int_0 -#if $data05 != -2147483647 then -# return -1 -#endi -#sql alter table st_int_0 set tag tagname=+100 -#sql show tags from st_int_0 -#if $data05 != 100 then -# return -1 -#endi -#sql alter table st_int_0 set tag tagname=-33 -#sql show tags from st_int_0 -#if $data05 != -33 then -# return -1 -#endi -#sql alter table st_int_0 set tag tagname='+98' -#sql show tags from st_int_0 -#if $data05 != 98 then -# return -1 -#endi -#sql alter table st_int_0 set tag tagname='-076' -#sql show tags from st_int_0 -#if $data05 != -76 then -# return -1 -#endi -#sql alter table st_int_0 set tag tagname=+0012 -#sql show tags from st_int_0 -#if $data05 != 12 then -# return -1 -#endi -#sql alter table st_int_0 set tag tagname=-00063 -#sql show tags from st_int_0 -#if $data05 != -63 then -# return -1 -#endi +sql alter table st_int_0 set tag tagname=2147483647 +sql show tags from st_int_0 +if $data05 != 2147483647 then + return -1 +endi +sql alter table st_int_0 set tag tagname=-2147483647 +sql show tags from st_int_0 +if $data05 != -2147483647 then + return -1 +endi +sql alter table st_int_0 set tag tagname=+100 +sql show tags from st_int_0 +if $data05 != 100 then + return -1 +endi +sql alter table st_int_0 set tag tagname=-33 +sql show tags from st_int_0 +if $data05 != -33 then + return -1 +endi +sql alter table st_int_0 set tag tagname='+98' +sql show tags from st_int_0 +if $data05 != 98 then + return -1 +endi +sql alter table st_int_0 set tag tagname='-076' +sql show tags from st_int_0 +if $data05 != -76 then + return -1 +endi +sql alter table st_int_0 set tag tagname=+0012 +sql show tags from st_int_0 +if $data05 != 12 then + return -1 +endi +sql alter table st_int_0 set tag tagname=-00063 +sql show tags from st_int_0 +if $data05 != -63 then + return -1 +endi +sql alter table st_int_100 set tag tagname="0x01" +sql show tags from st_int_100 +if $data05 != 1 then + return -1 +endi +sql alter table st_int_101 set tag tagname="0b01" +sql show tags from st_int_101 +if $data05 != 1 then + return -1 +endi +sql alter table st_int_102 set tag tagname="+0x01" +sql show tags from st_int_102 +if $data05 != 1 then + return -1 +endi +sql alter table st_int_103 set tag tagname="-0b01" +sql show tags from st_int_103 +if $data05 != -1 then + return -1 +endi +sql alter table st_int_104 set tag tagname="-123.1" +sql show tags from st_int_104 +if $data05 != -123 then + return -1 +endi +sql alter table st_int_105 set tag tagname="+123.5" +sql show tags from st_int_105 +if $data05 != 124 then + return -1 +endi +sql alter table st_int_106 set tag tagname="-1e-1" +sql show tags from st_int_106 +if $data05 != 0 then + return -1 +endi +sql alter table st_int_107 set tag tagname="+0.1235e3" +sql show tags from st_int_107 +if $data05 != 124 then + print $data05 != 124 + return -1 +endi +sql alter table st_int_108 set tag tagname="-0.11e-30" +sql show tags from st_int_108 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql alter table st_int_109 set tag tagname="-1.1e-307" +sql show tags from st_int_109 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql alter table st_int_110 set tag tagname= -1e-1 +sql show tags from st_int_110 +if $data05 != 0 then + return -1 +endi +sql alter table st_int_111 set tag tagname= +0.1235e3 +sql show tags from st_int_111 +if $data05 != 124 then + print $data05 != 124 + return -1 +endi +sql alter table st_int_112 set tag tagname=-0.11e-30 +sql show tags from st_int_112 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql alter table st_int_113 set tag tagname=-1.1e-307 +sql show tags from st_int_113 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql alter table st_int_200 set tag tagname= 0x01 +sql show tags from st_int_200 +if $data05 != 1 then + return -1 +endi +sql alter table st_int_201 set tag tagname=0b01 +sql show tags from st_int_201 +if $data05 != 1 then + return -1 +endi +sql alter table st_int_202 set tag tagname=+0x01 +sql show tags from st_int_202 +if $data05 != 1 then + return -1 +endi +sql alter table st_int_203 set tag tagname= -0b01 +sql show tags from st_int_203 +if $data05 != -1 then + return -1 +endi ## case 04: illegal input sql_error create table st_int_e0 using mt_int tags (2147483648) sql create table st_int_e0_err1 using mt_int tags (-2147483648) +sql_error create table st_int_e0_err2 using mt_int tags (-2147483649) sql_error create table st_int_e0 using mt_int tags (214748364800) sql_error create table st_int_e0 using mt_int tags (-214748364800) #sql_error create table st_int_e0 using mt_int tags (12.80) truncate integer part @@ -346,7 +831,7 @@ sql_error create table st_int_e0 using mt_int tags ("123abc") sql_error create table st_int_e0 using mt_int tags (abc) sql_error create table st_int_e0 using mt_int tags ("abc") sql_error create table st_int_e0 using mt_int tags (" ") -sql create table st_int_e0_err2 using mt_int tags ('') +sql_error create table st_int_e0_err2 using mt_int tags ('') sql create table st_int_e0 using mt_int tags (123) sql create table st_int_e1 using mt_int tags (123) @@ -399,7 +884,10 @@ sql_error insert into st_int_e20 using mt_int tags ("123abc") values (now, -033) sql_error insert into st_int_e22 using mt_int tags (abc) values (now, -033) sql_error insert into st_int_e23 using mt_int tags ("abc") values (now, -033) sql_error insert into st_int_e24 using mt_int tags (" ") values (now, -033) -sql insert into st_int_e25_1 using mt_int tags ('') values (now, -033) +sql_error insert into st_int_e25_1 using mt_int tags ('') values (now, -033) +sql insert into st_int_e26_1 using mt_int tags ('123') values (now, -033) +sql insert into st_int_e27_1 using mt_int tags ('12.80') values (now, -033) +sql insert into st_int_e28_1 using mt_int tags ('-11.80') values (now, -033) sql insert into st_int_e13 using mt_int tags (033) values (now, 00062) sql insert into st_int_e14 using mt_int tags (033) values (now, 00062) @@ -415,8 +903,10 @@ sql insert into st_int_e23 using mt_int tags (033) values (now, 00062) sql insert into st_int_e24 using mt_int tags (033) values (now, 00062) sql insert into st_int_e25 using mt_int tags (033) values (now, 00062) +sql alter table st_int_e13 set tag tagname=2147483647 sql_error alter table st_int_e13 set tag tagname=2147483648 sql alter table st_int_e14 set tag tagname=-2147483648 +sql_error alter table st_int_e14 set tag tagname=2147483649 sql_error alter table st_int_e15 set tag tagname=12147483648 sql_error alter table st_int_e16 set tag tagname=-3147483648 sql_error alter table st_int_e19 set tag tagname=123abc @@ -424,6 +914,9 @@ sql_error alter table st_int_e20 set tag tagname="123abc" sql_error alter table st_int_e22 set tag tagname=abc sql_error alter table st_int_e23 set tag tagname="abc" sql_error alter table st_int_e24 set tag tagname=" " -sql alter table st_int_e25 set tag tagname='' +sql_error alter table st_int_e25 set tag tagname='' +sql alter table st_int_e26_1 set tag tagname='123' +sql alter table st_int_e27_1 set tag tagname='12.80' +sql alter table st_int_e28_1 set tag tagname='-11.80' system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_json.sim b/tests/script/tsim/parser/columnValue_json.sim new file mode 100644 index 0000000000..002f71b290 --- /dev/null +++ b/tests/script/tsim/parser/columnValue_json.sim @@ -0,0 +1,220 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: json +print ========== json +sql create table mt_json (ts timestamp, c varchar(50)) tags(tagname json) + +## case 00: static create table for test tag values +sql create table st_json_0 using mt_json tags(NULL) +sql show tags from st_json_0 +if $data05 != NULL then + return -1 +endi +sql create table st_json_1 using mt_json tags(NULL) +sql show tags from st_json_1 +if $data05 != NULL then + return -1 +endi +sql create table st_json_2 using mt_json tags('NULL') +sql show tags from st_json_2 +if $data05 != NULL then + return -1 +endi +sql create table st_json_3 using mt_json tags('NULL') +sql show tags from st_json_3 +if $data05 != NULL then + return -1 +endi +sql create table st_json_4 using mt_json tags("NULL") +sql show tags from st_json_4 +if $data05 != NULL then + return -1 +endi +sql create table st_json_5 using mt_json tags("NULL") +sql show tags from st_json_5 +if $data05 != NULL then + return -1 +endi +sql create table st_json_6 using mt_json tags("") +sql show tags from st_json_6 +if $data05 != NULL then + return -1 +endi +sql create table st_json_7 using mt_json tags(" ") +sql show tags from st_json_7 +if $data05 != NULL then + return -1 +endi +sql create table st_json_8 using mt_json tags("{\"k1\":\"v1\",\"k2\":\"v2\"}") +sql show tags from st_json_8 +if $data05 != {"k1":"v1","k2":"v2"} then + return -1 +endi + +## case 01: insert values for test column values + +## case 02: dynamic create table for test tag values +sql insert into st_json_100 using mt_json tags(NULL) values(now,NULL) +sql show tags from st_json_100 +if $data05 != NULL then + return -1 +endi +sql select * from st_json_100 +if $data01 != NULL then + return -1 +endi +sql insert into st_json_101 using mt_json tags(NULL) values(now,NULL) +sql show tags from st_json_101 +if $data05 != NULL then + return -1 +endi +sql select * from st_json_101 +if $data01 != NULL then + return -1 +endi +sql insert into st_json_102 using mt_json tags('NULL') values(now,'NULL') +sql show tags from st_json_102 +if $data05 != NULL then + return -1 +endi +sql select * from st_json_102 +if $data01 != NULL then + return -1 +endi +sql insert into st_json_103 using mt_json tags('NULL') values(now,'NULL') +sql show tags from st_json_103 +if $data05 != NULL then + return -1 +endi +sql select * from st_json_103 +if $data01 != NULL then + return -1 +endi +sql insert into st_json_104 using mt_json tags("NULL") values(now,"NULL") +sql show tags from st_json_104 +if $data05 != NULL then + return -1 +endi +sql select * from st_json_104 +if $data01 != NULL then + return -1 +endi +sql insert into st_json_105 using mt_json tags("NULL") values(now,"NULL") +sql show tags from st_json_105 +if $data05 != NULL then + return -1 +endi +sql select * from st_json_105 +if $data01 != NULL then + return -1 +endi +sql insert into st_json_106 using mt_json tags("") values(now,"vc") +sql show tags from st_json_106 +if $data05 != NULL then + return -1 +endi +sql select * from st_json_106 +if $data01 != vc then + return -1 +endi +sql insert into st_json_107 using mt_json tags(" ") values(now,"vc") +sql show tags from st_json_107 +if $data05 != NULL then + return -1 +endi +sql select * from st_json_107 +if $data01 != vc then + return -1 +endi +sql insert into st_json_108 using mt_json tags("{\"k1\":\"v1\",\"k2\":\"v2\"} ") values(now,"vc") +sql show tags from st_json_108 +if $data05 != {"k1":"v1","k2":"v2"} then + return -1 +endi +sql select * from st_json_108 +if $data01 != vc then + return -1 +endi + +## case 03: alter tag values +sql alter table st_json_100 set tag tagname=NULL +sql show tags from st_json_100 +if $data05 != NULL then + return -1 +endi +sql alter table st_json_101 set tag tagname=NULL +sql show tags from st_json_101 +if $data05 != NULL then + return -1 +endi +sql alter table st_json_102 set tag tagname='NULL' +sql show tags from st_json_102 +if $data05 != NULL then + return -1 +endi +sql alter table st_json_103 set tag tagname='NULL' +sql show tags from st_json_103 +if $data05 != NULL then + return -1 +endi +sql alter table st_json_104 set tag tagname="NULL" +sql show tags from st_json_104 +if $data05 != NULL then + return -1 +endi +sql alter table st_json_105 set tag tagname="NULL" +sql show tags from st_json_105 +if $data05 != NULL then + return -1 +endi +sql alter table st_json_106 set tag tagname="" +sql show tags from st_json_106 +if $data05 != NULL then + return -1 +endi +sql alter table st_json_107 set tag tagname=" " +sql show tags from st_json_107 +if $data05 != NULL then + return -1 +endi +sql alter table st_json_108 set tag tagname="{\"k1\":\"v1\",\"k2\":\"v2\"}" +sql show tags from st_json_108 +if $data05 != {"k1":"v1","k2":"v2"} then + return -1 +endi + + +# case 04: illegal input +sql_error create table st_json_206 using mt_json tags(+0123) +sql_error create table st_json_207 using mt_json tags(-01.23) +sql_error create table st_json_208 using mt_json tags(+0x01) +sql_error create table st_json_209 using mt_json tags(-0b01) +sql_error create table st_json_2010 using mt_json tags(-0.1e-10) +sql_error create table st_json_2011 using mt_json tags(+0.1E+2) +sql_error create table st_json_2012 using mt_json tags(tRue) +sql_error create table st_json_2013 using mt_json tags(FalsE) +sql_error create table st_json_2014 using mt_json tags(noW) +sql_error create table st_json_2015 using mt_json tags(toDay) +sql_error insert into st_json_206 using mt_json tags(+0123) values(now, NULL); +sql_error insert into st_json_207 using mt_json tags(-01.23) values(now, NULL); +sql_error insert into st_json_208 using mt_json tags(+0x01) values(now, NULL); +sql_error insert into st_json_209 using mt_json tags(-0b01) values(now, NULL); +sql_error insert into st_json_2010 using mt_json tags(-0.1e-10) values(now, NULL); +sql_error insert into st_json_2011 using mt_json tags(+0.1E+2) values(now, NULL); +sql_error insert into st_json_2012 using mt_json tags(tRue) values(now, NULL); +sql_error insert into st_json_2013 using mt_json tags(FalsE) values(now, NULL); +sql_error insert into st_json_2014 using mt_json tags(noW) values(now, NULL); +sql_error insert into st_json_2015 using mt_json tags(toDay) values(now, NULL); + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_nchar.sim b/tests/script/tsim/parser/columnValue_nchar.sim new file mode 100644 index 0000000000..0b5de82d57 --- /dev/null +++ b/tests/script/tsim/parser/columnValue_nchar.sim @@ -0,0 +1,415 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: nchar +print ========== nchar +sql create table mt_nchar (ts timestamp, c nchar(50)) tags (tagname nchar(50)) + +## case 00: static create table for test tag values +sql create table st_nchar_0 using mt_nchar tags (NULL) +sql show create table st_nchar_0 +sql show tags from st_nchar_0 +if $data05 != NULL then + return -1 +endi +sql create table st_nchar_1 using mt_nchar tags (NULL) +sql show tags from st_nchar_1 +if $data05 != NULL then + return -1 +endi +sql create table st_nchar_2 using mt_nchar tags ('NULL') +sql show tags from st_nchar_2 +if $data05 != NULL then + return -1 +endi +sql create table st_nchar_3 using mt_nchar tags ('NULL') +sql show tags from st_nchar_3 +if $data05 != NULL then + return -1 +endi +sql create table st_nchar_4 using mt_nchar tags ("NULL") +sql show tags from st_nchar_4 +if $data05 != NULL then + return -1 +endi +sql create table st_nchar_5 using mt_nchar tags ("NULL") +sql show tags from st_nchar_5 +if $data05 != NULL then + return -1 +endi +sql create table st_nchar_6 using mt_nchar tags (+0123) +sql show tags from st_nchar_6 +if $data05 != +0123 then + return -1 +endi +sql create table st_nchar_7 using mt_nchar tags (-01.23) +sql show tags from st_nchar_7 +if $data05 != -01.23 then + return -1 +endi +sql create table st_nchar_8 using mt_nchar tags (+0x01) +sql show tags from st_nchar_8 +if $data05 != +0x01 then + return -1 +endi +sql create table st_nchar_9 using mt_nchar tags (-0b01) +sql show tags from st_nchar_9 +if $data05 != -0b01 then + return -1 +endi +sql create table st_nchar_10 using mt_nchar tags (-0.1e-10) +sql show tags from st_nchar_10 +if $data05 != -0.1e-10 then + return -1 +endi +sql create table st_nchar_11 using mt_nchar tags (+0.1E+2) +sql show tags from st_nchar_11 +if $data05 != +0.1e+2 then + return -1 +endi +sql create table st_nchar_12 using mt_nchar tags (tRue) +sql show tags from st_nchar_12 +if $data05 != true then + return -1 +endi +sql create table st_nchar_13 using mt_nchar tags (FalsE) +sql show tags from st_nchar_13 +if $data05 != false then + return -1 +endi +sql create table st_nchar_14 using mt_nchar tags (noW) +sql show tags from st_nchar_14 +if $data05 != now then + return -1 +endi +sql create table st_nchar_15 using mt_nchar tags (toDay) +sql show tags from st_nchar_15 +if $data05 != today then + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_nchar_0 values(now, NULL) +sql select * from st_nchar_0 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_1 values(now, NULL) +sql select * from st_nchar_1 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_2 values(now, 'NULL') +sql select * from st_nchar_2 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_3 values(now, 'NULL') +sql select * from st_nchar_3 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_4 values(now, "NULL") +sql select * from st_nchar_4 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_5 values(now, "NULL") +sql select * from st_nchar_5 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_6 values(now, +0123) +sql select * from st_nchar_6 +if $data01 != +0123 then + return -1 +endi +sql insert into st_nchar_7 values(now, -01.23) +sql select * from st_nchar_7 +if $data01 != -01.23 then + return -1 +endi +sql insert into st_nchar_8 values(now, +0x01) +sql select * from st_nchar_8 +if $data01 != +0x01 then + return -1 +endi +sql insert into st_nchar_9 values(now, -0b01) +sql select * from st_nchar_9 +if $data01 != -0b01 then + return -1 +endi +sql insert into st_nchar_10 values(now, -0.1e-10) +sql select * from st_nchar_10 +if $data01 != -0.1e-10 then + return -1 +endi +sql insert into st_nchar_11 values(now, +0.1E+2) +sql select * from st_nchar_11 +if $data01 != +0.1e+2 then + return -1 +endi +sql insert into st_nchar_12 values(now, tRue) +sql select * from st_nchar_12 +if $data01 != true then + return -1 +endi +sql insert into st_nchar_13 values(now, FalsE) +sql select * from st_nchar_13 +if $data01 != false then + return -1 +endi +sql insert into st_nchar_14 values(now, noW) +sql select * from st_nchar_14 +if $data01 != now then + return -1 +endi +sql insert into st_nchar_15 values(now, toDay) +sql select * from st_nchar_15 +if $data01 != today then + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_nchar_0 using mt_nchar tags (NULL) values(now, NULL) +sql show tags from st_nchar_0 +if $data05 != NULL then + return -1 +endi +sql select * from st_nchar_0 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_1 using mt_nchar tags (NULL) values(now, NULL) +sql show tags from st_nchar_1 +if $data05 != NULL then + return -1 +endi +sql select * from st_nchar_1 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_2 using mt_nchar tags ('NULL') values(now, 'NULL') +sql show tags from st_nchar_2 +if $data05 != NULL then + return -1 +endi +sql select * from st_nchar_2 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_3 using mt_nchar tags ('NULL') values(now, 'NULL') +sql show tags from st_nchar_3 +if $data05 != NULL then + return -1 +endi +sql select * from st_nchar_3 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_4 using mt_nchar tags ("NULL") values(now, "NULL") +sql show tags from st_nchar_4 +if $data05 != NULL then + return -1 +endi +sql select * from st_nchar_4 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_5 using mt_nchar tags ("NULL") values(now, "NULL") +sql show tags from st_nchar_5 +if $data05 != NULL then + return -1 +endi +sql select * from st_nchar_5 +if $data01 != NULL then + return -1 +endi +sql insert into st_nchar_6 using mt_nchar tags (+0123) values(now, +0123) +sql show tags from st_nchar_6 +if $data05 != +0123 then + return -1 +endi +sql select * from st_nchar_6 +if $data01 != +0123 then + return -1 +endi +sql insert into st_nchar_7 using mt_nchar tags (-01.23) values(now, -01.23) +sql show tags from st_nchar_7 +if $data05 != -01.23 then + return -1 +endi +sql select * from st_nchar_7 +if $data01 != -01.23 then + return -1 +endi +sql insert into st_nchar_8 using mt_nchar tags (+0x01) values(now, +0x01) +sql show tags from st_nchar_8 +if $data05 != +0x01 then + return -1 +endi +sql select * from st_nchar_8 +if $data01 != +0x01 then + return -1 +endi +sql insert into st_nchar_9 using mt_nchar tags (-0b01) values(now, -0b01) +sql show tags from st_nchar_9 +if $data05 != -0b01 then + return -1 +endi +sql select * from st_nchar_9 +if $data01 != -0b01 then + return -1 +endi +sql insert into st_nchar_10 using mt_nchar tags (-0.1e-10) values(now, -0.1e-10) +sql show tags from st_nchar_10 +if $data05 != -0.1e-10 then + return -1 +endi +sql select * from st_nchar_10 +if $data01 != -0.1e-10 then + return -1 +endi +sql insert into st_nchar_11 using mt_nchar tags (+0.1E+2) values(now, +0.1E+2) +sql show tags from st_nchar_11 +if $data05 != +0.1e+2 then + return -1 +endi +sql select * from st_nchar_11 +if $data01 != +0.1e+2 then + return -1 +endi +sql insert into st_nchar_12 using mt_nchar tags (tRue) values(now, tRue) +sql show tags from st_nchar_12 +if $data05 != true then + return -1 +endi +sql select * from st_nchar_12 +if $data01 != true then + return -1 +endi +sql insert into st_nchar_13 using mt_nchar tags (FalsE) values(now, FalsE) +sql show tags from st_nchar_13 +if $data05 != false then + return -1 +endi +sql select * from st_nchar_13 +if $data01 != false then + return -1 +endi +sql insert into st_nchar_14 using mt_nchar tags (noW) values(now, noW) +sql show tags from st_nchar_14 +if $data05 != now then + return -1 +endi +sql select * from st_nchar_14 +if $data01 != now then + return -1 +endi +sql insert into st_nchar_15 using mt_nchar tags (toDay) values(now, toDay) +sql show tags from st_nchar_15 +if $data05 != today then + return -1 +endi +sql select * from st_nchar_15 +if $data01 != today then + return -1 +endi + +## case 03: alter tag values +sql alter table st_nchar_0 set tag tagname=NULL +sql show tags from st_nchar_0 +if $data05 != NULL then + return -1 +endi +sql alter table st_nchar_1 set tag tagname=NULL +sql show tags from st_nchar_1 +if $data05 != NULL then + return -1 +endi +sql alter table st_nchar_2 set tag tagname='NULL' +sql show tags from st_nchar_2 +if $data05 != NULL then + return -1 +endi +sql alter table st_nchar_3 set tag tagname='NULL' +sql show tags from st_nchar_3 +if $data05 != NULL then + return -1 +endi +sql alter table st_nchar_4 set tag tagname="NULL" +sql show tags from st_nchar_4 +if $data05 != NULL then + return -1 +endi +sql alter table st_nchar_5 set tag tagname="NULL" +sql show tags from st_nchar_5 +if $data05 != NULL then + return -1 +endi +sql alter table st_nchar_6 set tag tagname=+0123 +sql show tags from st_nchar_6 +if $data05 != +0123 then + return -1 +endi +sql alter table st_nchar_7 set tag tagname=-01.23 +sql show tags from st_nchar_7 +if $data05 != -01.23 then + return -1 +endi +sql alter table st_nchar_8 set tag tagname=+0x01 +sql show tags from st_nchar_8 +if $data05 != +0x01 then + return -1 +endi +sql alter table st_nchar_9 set tag tagname=-0b01 +sql show tags from st_nchar_9 +if $data05 != -0b01 then + return -1 +endi +sql alter table st_nchar_10 set tag tagname=-0.1e-10 +sql show tags from st_nchar_10 +if $data05 != -0.1e-10 then + return -1 +endi +sql alter table st_nchar_11 set tag tagname=+0.1E+2 +sql show tags from st_nchar_11 +if $data05 != +0.1e+2 then + return -1 +endi +sql alter table st_nchar_12 set tag tagname=tRue +sql show tags from st_nchar_12 +if $data05 != true then + return -1 +endi +sql alter table st_nchar_13 set tag tagname=FalsE +sql show tags from st_nchar_13 +if $data05 != false then + return -1 +endi +sql alter table st_nchar_14 set tag tagname=noW +sql show tags from st_nchar_14 +if $data05 != now then + return -1 +endi +sql alter table st_nchar_15 set tag tagname=toDay +sql show tags from st_nchar_15 +if $data05 != today then + return -1 +endi + + +# case 04: illegal input + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_smallint.sim b/tests/script/tsim/parser/columnValue_smallint.sim index f9be6ebd52..8b9be73ca0 100644 --- a/tests/script/tsim/parser/columnValue_smallint.sim +++ b/tests/script/tsim/parser/columnValue_smallint.sim @@ -31,10 +31,27 @@ if $data05 != NULL then return -1 endi -sql_error create table st_smallint_2 using mt_smallint tags ('NULL') -sql_error create table st_smallint_3 using mt_smallint tags ('NULL') -sql_error create table st_smallint_4 using mt_smallint tags ("NULL") -sql_error create table st_smallint_5 using mt_smallint tags ("NULL") + +sql create table st_smallint_2 using mt_smallint tags ('NULL') +sql show tags from st_smallint_2 +if $data05 != NULL then + return -1 +endi +sql create table st_smallint_3 using mt_smallint tags ('NULL') +sql show tags from st_smallint_3 +if $data05 != NULL then + return -1 +endi +sql create table st_smallint_4 using mt_smallint tags ("NULL") +sql show tags from st_smallint_4 +if $data05 != NULL then + return -1 +endi +sql create table st_smallint_5 using mt_smallint tags ("NULL") +sql show tags from st_smallint_5 +if $data05 != NULL then + return -1 +endi sql create table st_smallint_6 using mt_smallint tags (-32767) sql show tags from st_smallint_6 @@ -349,7 +366,8 @@ sql_error create table st_smallint_e0 using mt_smallint tags ("123abc") sql_error create table st_smallint_e0 using mt_smallint tags (abc) sql_error create table st_smallint_e0 using mt_smallint tags ("abc") sql_error create table st_smallint_e0 using mt_smallint tags (" ") -sql create table st_smallint_e0_1 using mt_smallint tags ('') +sql_error create table st_smallint_e0_1 using mt_smallint tags ('') +sql create table st_smallint_e0_2 using mt_smallint tags ('123') sql create table st_smallint_e0 using mt_smallint tags (123) sql create table st_smallint_e1 using mt_smallint tags (123) @@ -402,7 +420,8 @@ sql_error insert into st_smallint_e20 using mt_smallint tags ("123abc") values ( sql_error insert into st_smallint_e22 using mt_smallint tags (abc) values (now, -033) sql_error insert into st_smallint_e23 using mt_smallint tags ("abc") values (now, -033) sql_error insert into st_smallint_e24 using mt_smallint tags (" ") values (now, -033) -sql insert into st_smallint_e25 using mt_smallint tags ('') values (now, -033) +sql_error insert into st_smallint_e25 using mt_smallint tags ('') values (now, -033) +sql insert into st_smallint_e26 using mt_smallint tags ('123') values (now, -033) sql insert into st_smallint_e13 using mt_smallint tags (033) values (now, 00062) sql insert into st_smallint_e14 using mt_smallint tags (033) values (now, 00062) @@ -427,6 +446,7 @@ sql_error alter table st_smallint_e20 set tag tagname="123abc" sql_error alter table st_smallint_e22 set tag tagname=abc sql_error alter table st_smallint_e23 set tag tagname="abc" sql_error alter table st_smallint_e24 set tag tagname=" " -sql alter table st_smallint_e25 set tag tagname='' +sql_error alter table st_smallint_e25 set tag tagname='' +sql alter table st_smallint_e26 set tag tagname='123' system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_timestamp.sim b/tests/script/tsim/parser/columnValue_timestamp.sim new file mode 100644 index 0000000000..1f457dbd7c --- /dev/null +++ b/tests/script/tsim/parser/columnValue_timestamp.sim @@ -0,0 +1,594 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: timestamp +print ========== timestamp +sql create table mt_timestamp (ts timestamp, c timestamp) tags (tagname timestamp) + +## case 00: static create table for test tag values +sql create table st_timestamp_0 using mt_timestamp tags (NULL) +sql show create table st_timestamp_0 +sql show tags from st_timestamp_0 +if $data05 != NULL then + return -1 +endi +sql create table st_timestamp_1 using mt_timestamp tags (NULL) +sql show tags from st_timestamp_1 +if $data05 != NULL then + return -1 +endi +sql create table st_timestamp_2 using mt_timestamp tags ('NULL') +sql show tags from st_timestamp_2 +if $data05 != NULL then + return -1 +endi +sql create table st_timestamp_3 using mt_timestamp tags ('NULL') +sql show tags from st_timestamp_3 +if $data05 != NULL then + return -1 +endi +sql create table st_timestamp_4 using mt_timestamp tags ("NULL") +sql show tags from st_timestamp_4 +if $data05 != NULL then + return -1 +endi +sql create table st_timestamp_5 using mt_timestamp tags ("NULL") +sql show tags from st_timestamp_5 +if $data05 != NULL then + return -1 +endi +sql create table st_timestamp_6 using mt_timestamp tags (-2147483647) +sql show tags from st_timestamp_6 +if $data05 != -2147483647 then + return -1 +endi +sql create table st_timestamp_7 using mt_timestamp tags (2147483647) +sql show tags from st_timestamp_7 +if $data05 != 2147483647 then + return -1 +endi +sql create table st_timestamp_8 using mt_timestamp tags (37) +sql show tags from st_timestamp_8 +if $data05 != 37 then + return -1 +endi +sql create table st_timestamp_9 using mt_timestamp tags (-100) +sql show tags from st_timestamp_9 +if $data05 != -100 then + return -1 +endi +sql create table st_timestamp_10 using mt_timestamp tags (+113) +sql show tags from st_timestamp_10 +if $data05 != 113 then + return -1 +endi +sql create table st_timestamp_11 using mt_timestamp tags ('-100') +sql show tags from st_timestamp_11 +if $data05 != -100 then + return -1 +endi +sql create table st_timestamp_12 using mt_timestamp tags ("-0") +sql show tags from st_timestamp_12 +if $data05 != 0 then + return -1 +endi +sql create table st_timestamp_13 using mt_timestamp tags (+0078) +sql show tags from st_timestamp_13 +if $data05 != 78 then + return -1 +endi +sql create table st_timestamp_14 using mt_timestamp tags (-00078) +sql show tags from st_timestamp_14 +if $data05 != -78 then + return -1 +endi +sql create table st_timestamp_15 using mt_timestamp tags ("0x01") +sql show tags from st_timestamp_15 +if $data05 != 1 then + return -1 +endi +sql create table st_timestamp_16 using mt_timestamp tags ("0b01") +sql show tags from st_timestamp_16 +if $data05 != 1 then + return -1 +endi +sql create table st_timestamp_17 using mt_timestamp tags ("+0x01") +sql show tags from st_timestamp_17 +if $data05 != 1 then + return -1 +endi +sql create table st_timestamp_18 using mt_timestamp tags ("-0b01") +sql show tags from st_timestamp_18 +if $data05 != -1 then + return -1 +endi +sql create table st_timestamp_19 using mt_timestamp tags ( 0x01) +sql show tags from st_timestamp_19 +if $data05 != 1 then + return -1 +endi +sql create table st_timestamp_20 using mt_timestamp tags (0b01 ) +sql show tags from st_timestamp_20 +if $data05 != 1 then + return -1 +endi +sql create table st_timestamp_21 using mt_timestamp tags (+0x01) +sql show tags from st_timestamp_21 +if $data05 != 1 then + return -1 +endi +sql create table st_timestamp_22 using mt_timestamp tags ( -0b01 ) +sql show tags from st_timestamp_22 +if $data05 != -1 then + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_timestamp_0 values(now,NULL) +sql select * from st_timestamp_0 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_1 values(now,NULL) +sql select * from st_timestamp_1 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_2 values(now,'NULL') +sql select * from st_timestamp_2 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_3 values(now,'NULL') +sql select * from st_timestamp_3 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_4 values(now,"NULL") +sql select * from st_timestamp_4 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_5 values(now,"NULL") +sql select * from st_timestamp_5 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_6 values(now,-2147483647) +sql select ts, cast(c as bigint) from st_timestamp_6 +if $data01 != -2147483647 then + return -1 +endi +sql insert into st_timestamp_7 values(now,2147483647) +sql select ts, cast(c as bigint) from st_timestamp_7 +if $data01 != 2147483647 then + return -1 +endi +sql insert into st_timestamp_8 values(now,37) +sql select ts, cast(c as bigint) from st_timestamp_8 +if $data01 != 37 then + return -1 +endi +sql insert into st_timestamp_9 values(now,-100) +sql select ts, cast(c as bigint) from st_timestamp_9 +if $data01 != -100 then + return -1 +endi +sql insert into st_timestamp_10 values(now,+113) +sql select ts, cast(c as bigint) from st_timestamp_10 +if $data01 != 113 then + return -1 +endi +sql insert into st_timestamp_11 values(now,'-100') +sql select ts, cast(c as bigint) from st_timestamp_11 +if $data01 != -100 then + return -1 +endi +sql insert into st_timestamp_12 values(now,"-0") +sql select ts, cast(c as bigint) from st_timestamp_12 +if $data01 != 0 then + return -1 +endi +sql insert into st_timestamp_13 values(now,+0078) +sql select ts, cast(c as bigint) from st_timestamp_13 +if $data01 != 78 then + return -1 +endi +sql insert into st_timestamp_14 values(now,-00078) +sql select ts, cast(c as bigint) from st_timestamp_14 +if $data01 != -78 then + return -1 +endi +sql insert into st_timestamp_15 values(now,"0x01") +sql select ts, cast(c as bigint) from st_timestamp_15 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_16 values(now,"0b01") +sql select ts, cast(c as bigint) from st_timestamp_16 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_17 values(now,"+0x01") +sql select ts, cast(c as bigint) from st_timestamp_17 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_18 values(now,"-0b01") +sql select ts, cast(c as bigint) from st_timestamp_18 +if $data01 != -1 then + return -1 +endi +sql insert into st_timestamp_19 values(now, 0x01) +sql select ts, cast(c as bigint) from st_timestamp_19 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_20 values(now,0b01 ) +sql select ts, cast(c as bigint) from st_timestamp_20 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_21 values(now,+0x01) +sql select ts, cast(c as bigint) from st_timestamp_21 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_22 values(now, -0b01 ) +sql select ts, cast(c as bigint) from st_timestamp_22 +if $data01 != -1 then + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_timestamp_100 using mt_timestamp tags(NULL) values(now, NULL) +sql show tags from st_timestamp_100 +if $data05 != NULL then + return -1 +endi +sql select * from st_timestamp_100 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_101 using mt_timestamp tags(NULL) values(now, NULL) +sql show tags from st_timestamp_101 +if $data05 != NULL then + return -1 +endi +sql select * from st_timestamp_101 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_102 using mt_timestamp tags('NULL') values(now, 'NULL') +sql show tags from st_timestamp_102 +if $data05 != NULL then + return -1 +endi +sql select * from st_timestamp_102 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_103 using mt_timestamp tags('NULL') values(now, 'NULL') +sql show tags from st_timestamp_103 +if $data05 != NULL then + return -1 +endi +sql select * from st_timestamp_103 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_104 using mt_timestamp tags("NULL") values(now, "NULL") +sql show tags from st_timestamp_104 +if $data05 != NULL then + return -1 +endi +sql select * from st_timestamp_104 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_105 using mt_timestamp tags("NULL") values(now, "NULL") +sql show tags from st_timestamp_105 +if $data05 != NULL then + return -1 +endi +sql select * from st_timestamp_105 +if $data01 != NULL then + return -1 +endi +sql insert into st_timestamp_106 using mt_timestamp tags(-2147483647) values(now, -2147483647) +sql show tags from st_timestamp_106 +if $data05 != -2147483647 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_106 +if $data01 != -2147483647 then + return -1 +endi +sql insert into st_timestamp_107 using mt_timestamp tags(2147483647) values(now, 2147483647) +sql show tags from st_timestamp_107 +if $data05 != 2147483647 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_107 +if $data01 != 2147483647 then + return -1 +endi +sql insert into st_timestamp_108 using mt_timestamp tags(37) values(now, 37) +sql show tags from st_timestamp_108 +if $data05 != 37 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_108 +if $data01 != 37 then + return -1 +endi +sql insert into st_timestamp_109 using mt_timestamp tags(-100) values(now, -100) +sql show tags from st_timestamp_109 +if $data05 != -100 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_109 +if $data01 != -100 then + return -1 +endi +sql insert into st_timestamp_1010 using mt_timestamp tags(+113) values(now, +113) +sql show tags from st_timestamp_1010 +if $data05 != 113 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1010 +if $data01 != 113 then + return -1 +endi +sql insert into st_timestamp_1011 using mt_timestamp tags('-100') values(now, '-100') +sql show tags from st_timestamp_1011 +if $data05 != -100 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1011 +if $data01 != -100 then + return -1 +endi +sql insert into st_timestamp_1012 using mt_timestamp tags("-0") values(now, "-0") +sql show tags from st_timestamp_1012 +if $data05 != 0 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1012 +if $data01 != 0 then + return -1 +endi +sql insert into st_timestamp_1013 using mt_timestamp tags(+0078) values(now, +0078) +sql show tags from st_timestamp_1013 +if $data05 != 78 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1013 +if $data01 != 78 then + return -1 +endi +sql insert into st_timestamp_1014 using mt_timestamp tags(-00078) values(now, -00078) +sql show tags from st_timestamp_1014 +if $data05 != -78 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1014 +if $data01 != -78 then + return -1 +endi +sql insert into st_timestamp_1015 using mt_timestamp tags("0x01") values(now, "0x01") +sql show tags from st_timestamp_1015 +if $data05 != 1 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1015 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_1016 using mt_timestamp tags("0b01") values(now, "0b01") +sql show tags from st_timestamp_1016 +if $data05 != 1 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1016 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_1017 using mt_timestamp tags("+0x01") values(now, "+0x01") +sql show tags from st_timestamp_1017 +if $data05 != 1 then + return -1 +endi +sql insert into st_timestamp_1018 using mt_timestamp tags("-0b01") values(now, "-0b01") +sql show tags from st_timestamp_1018 +if $data05 != -1 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1018 +if $data01 != -1 then + return -1 +endi +sql insert into st_timestamp_1019 using mt_timestamp tags( 0x01) values(now, 0x01) +sql show tags from st_timestamp_1019 +if $data05 != 1 then + return -1 +endi +sql insert into st_timestamp_1020 using mt_timestamp tags(0b01 ) values(now, 0b01 ) +sql show tags from st_timestamp_1020 +if $data05 != 1 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1020 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_1021 using mt_timestamp tags(+0x01) values(now, +0x01) +sql show tags from st_timestamp_1021 +if $data05 != 1 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1021 +if $data01 != 1 then + return -1 +endi +sql insert into st_timestamp_1022 using mt_timestamp tags( -0b01 ) values(now, -0b01) +sql show tags from st_timestamp_1022 +if $data05 != -1 then + return -1 +endi +sql select ts, cast(c as bigint) from st_timestamp_1022 +if $data01 != -1 then + return -1 +endi + +### case 03: alter tag values +sql alter table st_timestamp_0 set tag tagname=NULL +sql show tags from st_timestamp_0 +if $data05 != NULL then + return -1 +endi +sql alter table st_timestamp_1 set tag tagname=NULL +sql show tags from st_timestamp_1 +if $data05 != NULL then + return -1 +endi +sql alter table st_timestamp_2 set tag tagname='NULL' +sql show tags from st_timestamp_2 +if $data05 != NULL then + return -1 +endi +sql alter table st_timestamp_3 set tag tagname='NULL' +sql show tags from st_timestamp_3 +if $data05 != NULL then + return -1 +endi +sql alter table st_timestamp_4 set tag tagname="NULL" +sql show tags from st_timestamp_4 +if $data05 != NULL then + return -1 +endi +sql alter table st_timestamp_5 set tag tagname="NULL" +sql show tags from st_timestamp_5 +if $data05 != NULL then + return -1 +endi +sql alter table st_timestamp_6 set tag tagname=-2147483647 +sql show tags from st_timestamp_6 +if $data05 != -2147483647 then + return -1 +endi +sql alter table st_timestamp_7 set tag tagname=2147483647 +sql show tags from st_timestamp_7 +if $data05 != 2147483647 then + return -1 +endi +sql alter table st_timestamp_8 set tag tagname=37 +sql show tags from st_timestamp_8 +if $data05 != 37 then + return -1 +endi +sql alter table st_timestamp_9 set tag tagname=-100 +sql show tags from st_timestamp_9 +if $data05 != -100 then + return -1 +endi +sql alter table st_timestamp_10 set tag tagname=+113 +sql show tags from st_timestamp_10 +if $data05 != 113 then + return -1 +endi +sql alter table st_timestamp_11 set tag tagname='-100' +sql show tags from st_timestamp_11 +if $data05 != -100 then + return -1 +endi +sql alter table st_timestamp_12 set tag tagname="-0" +sql show tags from st_timestamp_12 +if $data05 != 0 then + return -1 +endi +sql alter table st_timestamp_13 set tag tagname=+0078 +sql show tags from st_timestamp_13 +if $data05 != 78 then + return -1 +endi +sql alter table st_timestamp_14 set tag tagname=-00078 +sql show tags from st_timestamp_14 +if $data05 != -78 then + return -1 +endi +sql alter table st_timestamp_15 set tag tagname="0x01" +sql show tags from st_timestamp_15 +if $data05 != 1 then + return -1 +endi +sql alter table st_timestamp_16 set tag tagname="0b01" +sql show tags from st_timestamp_16 +if $data05 != 1 then + return -1 +endi +sql alter table st_timestamp_17 set tag tagname="+0x01" +sql show tags from st_timestamp_17 +if $data05 != 1 then + return -1 +endi +sql alter table st_timestamp_18 set tag tagname="-0b01" +sql show tags from st_timestamp_18 +if $data05 != -1 then + return -1 +endi +sql alter table st_timestamp_19 set tag tagname= 0x01 +sql show tags from st_timestamp_19 +if $data05 != 1 then + return -1 +endi +sql alter table st_timestamp_20 set tag tagname=0b01 +sql show tags from st_timestamp_20 +if $data05 != 1 then + return -1 +endi +sql alter table st_timestamp_21 set tag tagname=+0x01 +sql show tags from st_timestamp_21 +if $data05 != 1 then + return -1 +endi +sql alter table st_timestamp_22 set tag tagname= -0b01 +sql show tags from st_timestamp_22 +if $data05 != -1 then + return -1 +endi + +## case 04: illegal input +sql_error create table st_timestamp_e0 using mt_timestamp tags (123abc) +sql_error create table st_timestamp_e0 using mt_timestamp tags ("123abc") +sql_error create table st_timestamp_e0 using mt_timestamp tags (abc) +sql_error create table st_timestamp_e0 using mt_timestamp tags ("abc") +sql_error create table st_timestamp_e0 using mt_timestamp tags (" ") +sql_error create table st_timestamp_e0 using mt_timestamp tags ('') +sql_error create table st_timestamp_104 using mt_timestamp tags ("-123.1") +sql_error create table st_timestamp_105 using mt_timestamp tags ("+123.5") +sql_error create table st_timestamp_106 using mt_timestamp tags ("-1e-1") +sql_error create table st_timestamp_107 using mt_timestamp tags ("+0.1235e3") +sql_error create table st_timestamp_108 using mt_timestamp tags ("-0.11e-30") +sql_error create table st_timestamp_109 using mt_timestamp tags ("-1.1e-307") +sql_error create table st_timestamp_110 using mt_timestamp tags ( -1e-1 ) +sql_error create table st_timestamp_111 using mt_timestamp tags ( +0.1235e3 ) +sql_error create table st_timestamp_112 using mt_timestamp tags (-0.11e-30) +sql_error create table st_timestamp_113 using mt_timestamp tags (-1.1e-307) +sql create table st_timestamp_114 using mt_timestamp tags (9223372036854775807) +sql_error create table st_timestamp_115 using mt_timestamp tags (9223372036854775808) +sql create table st_timestamp_116 using mt_timestamp tags (-9223372036854775808) +sql_error create table st_timestamp_117 using mt_timestamp tags (-9223372036854775809) +sql_error insert into st_timestamp_118 using mt_timestamp tags(9223372036854775807) values(9223372036854775807, 9223372036854775807) + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_tinyint.sim b/tests/script/tsim/parser/columnValue_tinyint.sim index 7d0f10a30d..5076280872 100644 --- a/tests/script/tsim/parser/columnValue_tinyint.sim +++ b/tests/script/tsim/parser/columnValue_tinyint.sim @@ -29,10 +29,26 @@ if $data05 != NULL then return -1 endi -sql_error create table st_tinyint_2 using mt_tinyint tags ('NULL') -sql_error create table st_tinyint_3 using mt_tinyint tags ('NULL') -sql_error create table st_tinyint_4 using mt_tinyint tags ("NULL") -sql_error create table st_tinyint_5 using mt_tinyint tags ("NULL") +sql create table st_tinyint_2 using mt_tinyint tags ('NULL') +sql show tags from st_tinyint_2 +if $data05 != NULL then + return -1 +endi +sql create table st_tinyint_3 using mt_tinyint tags ('NULL') +sql show tags from st_tinyint_3 +if $data05 != NULL then + return -1 +endi +sql create table st_tinyint_4 using mt_tinyint tags ("NULL") +sql show tags from st_tinyint_4 +if $data05 != NULL then + return -1 +endi +sql create table st_tinyint_5 using mt_tinyint tags ("NULL") +sql show tags from st_tinyint_5 +if $data05 != NULL then + return -1 +endi sql create table st_tinyint_6 using mt_tinyint tags (-127) sql show tags from st_tinyint_6 @@ -97,6 +113,40 @@ endi if $data01 != NULL then return -1 endi + +sql insert into st_tinyint_2 values (now, NULL) +sql select * from st_tinyint_2 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_3 values (now, NULL) +sql select * from st_tinyint_3 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_4 values (now, NULL) +sql select * from st_tinyint_4 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_tinyint_5 values (now, NULL) +sql select * from st_tinyint_5 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi + sql insert into st_tinyint_6 values (now, 127) sql select * from st_tinyint_6 if $rows != 1 then @@ -347,7 +397,7 @@ sql_error create table st_tinyint_e0 using mt_tinyint tags ("123abc") sql_error create table st_tinyint_e0 using mt_tinyint tags (abc) sql_error create table st_tinyint_e0 using mt_tinyint tags ("abc") sql_error create table st_tinyint_e0 using mt_tinyint tags (" ") -sql create table st_tinyint_e0_2 using mt_tinyint tags ('') +sql_error create table st_tinyint_e0_2 using mt_tinyint tags ('') sql create table st_tinyint_e0 using mt_tinyint tags (123) sql create table st_tinyint_e1 using mt_tinyint tags (123) @@ -400,7 +450,7 @@ sql_error insert into st_tinyint_e20 using mt_tinyint tags ("123abc") values (no sql_error insert into st_tinyint_e22 using mt_tinyint tags (abc) values (now, -033) sql_error insert into st_tinyint_e23 using mt_tinyint tags ("abc") values (now, -033) sql_error insert into st_tinyint_e24 using mt_tinyint tags (" ") values (now, -033) -sql insert into st_tinyint_e25 using mt_tinyint tags ('') values (now, -033) +sql_error insert into st_tinyint_e25 using mt_tinyint tags ('') values (now, -033) sql insert into st_tinyint_e13 using mt_tinyint tags (033) values (now, 00062) sql insert into st_tinyint_e14 using mt_tinyint tags (033) values (now, 00062) @@ -425,6 +475,6 @@ sql_error alter table st_tinyint_e20 set tag tagname="123abc" sql_error alter table st_tinyint_e22 set tag tagname=abc sql_error alter table st_tinyint_e23 set tag tagname="abc" sql_error alter table st_tinyint_e24 set tag tagname=" " -sql alter table st_tinyint_e25 set tag tagname='' +sql_error alter table st_tinyint_e25 set tag tagname='' system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_uint.sim b/tests/script/tsim/parser/columnValue_uint.sim new file mode 100644 index 0000000000..a2707bbf17 --- /dev/null +++ b/tests/script/tsim/parser/columnValue_uint.sim @@ -0,0 +1,904 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: uint +print ========== uint +sql create table mt_uint (ts timestamp, c int unsigned) tags (tagname int unsigned) + +## case 00: static create table for test tag values +sql create table st_uint_0 using mt_uint tags (NULL) +sql show create table st_uint_0 +sql show tags from st_uint_0 +if $data05 != NULL then + return -1 +endi +sql create table st_uint_1 using mt_uint tags (NULL) +sql show tags from st_uint_1 +if $data05 != NULL then + return -1 +endi + +sql create table st_uint_2 using mt_uint tags ('NULL') +sql show tags from st_uint_2 +if $data05 != NULL then + return -1 +endi +sql create table st_uint_3 using mt_uint tags ('NULL') +sql show tags from st_uint_3 +if $data05 != NULL then + return -1 +endi +sql create table st_uint_4 using mt_uint tags ("NULL") +sql show tags from st_uint_4 +if $data05 != NULL then + return -1 +endi +sql create table st_uint_5 using mt_uint tags ("-0") +sql show tags from st_uint_5 +if $data05 != 0 then + return -1 +endi +sql create table st_uint_6 using mt_uint tags (-0 ) +sql show tags from st_uint_6 +if $data05 != 0 then + return -1 +endi +sql create table st_uint_7 using mt_uint tags (2147483647) +sql show tags from st_uint_7 +if $data05 != 2147483647 then + return -1 +endi +sql create table st_uint_8 using mt_uint tags (37) +sql show tags from st_uint_8 +if $data05 != 37 then + return -1 +endi +sql create table st_uint_9 using mt_uint tags (098) +sql show tags from st_uint_9 +if $data05 != 98 then + return -1 +endi +sql create table st_uint_10 using mt_uint tags (+113) +sql show tags from st_uint_10 +if $data05 != 113 then + return -1 +endi +sql create table st_uint_11 using mt_uint tags (+000.000) +sql show tags from st_uint_11 +if $data05 != 0 then + return -1 +endi +sql create table st_uint_12 using mt_uint tags ("+78") +sql show tags from st_uint_12 +if $data05 != 78 then + return -1 +endi +sql create table st_uint_13 using mt_uint tags (+0078) +sql show tags from st_uint_13 +if $data05 != 78 then + return -1 +endi +sql create table st_uint_14 using mt_uint tags (00078) +sql show tags from st_uint_14 +if $data05 != 78 then + return -1 +endi +sql create table st_uint_100 using mt_uint tags ("0x01") +sql show tags from st_uint_100 +if $data05 != 1 then + return -1 +endi +sql create table st_uint_101 using mt_uint tags ("0b01") +sql show tags from st_uint_101 +if $data05 != 1 then + return -1 +endi +sql create table st_uint_102 using mt_uint tags ("+0x01") +sql show tags from st_uint_102 +if $data05 != 1 then + return -1 +endi +sql create table st_uint_103 using mt_uint tags ("-0b00") +sql show tags from st_uint_103 +if $data05 != 0 then + return -1 +endi +sql create table st_uint_104 using mt_uint tags ("123.1") +sql show tags from st_uint_104 +if $data05 != 123 then + return -1 +endi +sql create table st_uint_105 using mt_uint tags ("+123.5") +sql show tags from st_uint_105 +if $data05 != 124 then + return -1 +endi +sql create table st_uint_106 using mt_uint tags ("-1e-1") +sql show tags from st_uint_106 +if $data05 != 0 then + return -1 +endi +sql create table st_uint_107 using mt_uint tags ("+0.1235e3") +sql show tags from st_uint_107 +if $data05 != 124 then + print $data05 != 124 + return -1 +endi +sql create table st_uint_108 using mt_uint tags ("-0.11e-30") +sql show tags from st_uint_108 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql create table st_uint_109 using mt_uint tags ("-1.1e-307") +sql show tags from st_uint_109 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql create table st_uint_110 using mt_uint tags ( -1e-1 ) +sql show tags from st_uint_110 +if $data05 != 0 then + return -1 +endi +sql create table st_uint_111 using mt_uint tags ( +0.1235e3 ) +sql show tags from st_uint_111 +if $data05 != 124 then + print $data05 != 124 + return -1 +endi +sql create table st_uint_112 using mt_uint tags (-0.11e-30) +sql show tags from st_uint_112 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql create table st_uint_113 using mt_uint tags (-1.1e-307) +sql show tags from st_uint_113 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql create table st_uint_200 using mt_uint tags ( 0x01) +sql show tags from st_uint_200 +if $data05 != 1 then + return -1 +endi +sql create table st_uint_201 using mt_uint tags (0b01 ) +sql show tags from st_uint_201 +if $data05 != 1 then + return -1 +endi +sql create table st_uint_202 using mt_uint tags (+0x01) +sql show tags from st_uint_202 +if $data05 != 1 then + return -1 +endi +sql create table st_uint_203 using mt_uint tags ( -0b00 ) +sql show tags from st_uint_203 +if $data05 != 0 then + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_uint_0 values (now, NULL) +sql select * from st_uint_0 +if $rows != 1 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +sql insert into st_uint_1 values (now, "-0") +sql select * from st_uint_1 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_6 values (now, 2147483647) +sql select * from st_uint_6 +if $rows != 1 then + return -1 +endi +if $data01 != 2147483647 then + return -1 +endi +sql insert into st_uint_7 values (now, -0) +sql select * from st_uint_7 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_8 values (now, +100) +sql select * from st_uint_8 +if $rows != 1 then + return -1 +endi +if $data01 != 100 then + return -1 +endi +sql insert into st_uint_9 values (now, "098") +sql select * from st_uint_9 +if $rows != 1 then + return -1 +endi +if $data01 != 98 then + return -1 +endi +sql insert into st_uint_10 values (now, '0') +sql select * from st_uint_10 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_11 values (now, +000.000) +sql select * from st_uint_11 +if $rows != 1 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_12 values (now, "+056") +sql select * from st_uint_12 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_uint_13 values (now, +056) +sql select * from st_uint_13 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_uint_14 values (now, 056) +sql select * from st_uint_14 +if $rows != 1 then + return -1 +endi +if $data01 != 56 then + return -1 +endi + +sql insert into st_uint_100 values (now, "0x01") +sql select * from st_uint_100 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_101 values (now, "0b01") +sql select * from st_uint_101 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_102 values (now, "+0x01") +sql select * from st_uint_102 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_103 values (now, "-0b00") +sql select * from st_uint_103 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_104 values (now, "123.1") +sql select * from st_uint_104 +if $data01 != 123 then + return -1 +endi +sql insert into st_uint_105 values (now, "+123.5") +sql select * from st_uint_105 +if $data01 != 124 then + return -1 +endi +sql insert into st_uint_106 values (now, "-1e-1") +sql select * from st_uint_106 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_107 values (now, "+0.1235e3") +sql select * from st_uint_107 +if $data01 != 124 then + print $data05 != 124 + return -1 +endi +sql insert into st_uint_108 values (now, "-0.11e-30") +sql select * from st_uint_108 +if $data01 != 0 then + print $data05 != 0 + return -1 +endi +sql insert into st_uint_109 values (now, "-1.1e-307") +sql select * from st_uint_109 +if $data01 != 0 then + print $data05 != 0 + return -1 +endi +sql insert into st_uint_110 values (now, -1e-1 ) +sql select * from st_uint_110 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_111 values (now, +0.1235e3 ) +sql select * from st_uint_111 +if $data01 != 124 then + print $data05 != 124 + return -1 +endi +sql insert into st_uint_112 values (now, -0.11e-30) +sql select * from st_uint_112 +if $data01 != 0 then + print $data05 != 0 + return -1 +endi +sql insert into st_uint_113 values (now, -1.1e-307) +sql select * from st_uint_113 +if $data01 != 0 then + print $data05 != 0 + return -1 +endi +sql insert into st_uint_200 values (now, 0x01) +sql select * from st_uint_200 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_201 values (now, 0b01 ) +sql select * from st_uint_201 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_202 values (now, +0x01) +sql select * from st_uint_202 +if $rows != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi + +sql insert into st_uint_203 values (now, -0b00 ) +sql select * from st_uint_203 +if $data01 != 0 then + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_uint_16 using mt_uint tags (NULL) values (now, NULL) +sql show create table st_uint_16 +sql show tags from st_uint_16 +if $data05 != NULL then + return -1 +endi +sql select * from st_uint_16 +if $data01 != NULL then + return -1 +endi + +sql insert into st_uint_17 using mt_uint tags (NULL) values (now, NULL) +sql show tags from st_uint_17 +if $data05 != NULL then + return -1 +endi +sql select * from st_uint_17 +if $data01 != NULL then + return -1 +endi +sql insert into st_uint_18 using mt_uint tags ('NULL') values (now, 'NULL') +sql show tags from st_uint_18 +if $data05 != NULL then + return -1 +endi +sql select * from st_uint_18 +if $data01 != NULL then + return -1 +endi +sql insert into st_uint_19 using mt_uint tags ('NULL') values (now, 'NULL') +sql show tags from st_uint_19 +if $data05 != NULL then + return -1 +endi +sql select * from st_uint_19 +if $data01 != NULL then + return -1 +endi +sql insert into st_uint_20 using mt_uint tags ("NULL") values (now, "NULL") +sql show tags from st_uint_20 +if $data05 != NULL then + return -1 +endi +sql select * from st_uint_20 +if $data01 != NULL then + return -1 +endi +sql insert into st_uint_21 using mt_uint tags ("-0") values (now, "-0") +sql show tags from st_uint_21 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_21 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_22 using mt_uint tags (2147483647) values (now, 2147483647) +sql show tags from st_uint_22 +if $data05 != 2147483647 then + return -1 +endi +sql select * from st_uint_22 +if $data01 != 2147483647 then + return -1 +endi +sql insert into st_uint_23 using mt_uint tags (-0) values (now, -0) +sql show tags from st_uint_23 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_23 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_24 using mt_uint tags (10) values (now, 10) +sql show tags from st_uint_24 +if $data05 != 10 then + return -1 +endi +sql select * from st_uint_24 +if $data01 != 10 then + return -1 +endi +sql insert into st_uint_25 using mt_uint tags ("-0") values (now, "-0") +sql show tags from st_uint_25 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_25 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_26 using mt_uint tags ('123') values (now, '123') +sql show tags from st_uint_26 +if $data05 != 123 then + return -1 +endi +sql select * from st_uint_26 +if $data01 != 123 then + return -1 +endi +sql insert into st_uint_27 using mt_uint tags (+056) values (now, +00056) +sql show tags from st_uint_27 +if $data05 != 56 then + return -1 +endi +sql select * from st_uint_27 +if $data01 != 56 then + return -1 +endi +sql insert into st_uint_28 using mt_uint tags (056) values (now, 0056) +sql show tags from st_uint_28 +if $data05 != 56 then + return -1 +endi +sql select * from st_uint_28 +if $data01 != 56 then + return -1 +endi +sql insert into st_uint_1100 using mt_uint tags ("0x01") values(now, "0x01"); +sql show tags from st_uint_1100 +if $data05 != 1 then + return -1 +endi +sql select * from st_uint_1100 +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_1101 using mt_uint tags ("0b01") values(now, "0b01"); +sql show tags from st_uint_1101 +if $data05 != 1 then + return -1 +endi +sql select * from st_uint_1101 +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_1102 using mt_uint tags ("+0x01") values(now, "+0x01"); +sql show tags from st_uint_1102 +if $data05 != 1 then + return -1 +endi +sql select * from st_uint_1102 +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_1103 using mt_uint tags ("-0b00") values(now, "-0b000"); +sql show tags from st_uint_1103 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_1103 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_1104 using mt_uint tags ("123.1") values(now, "123.1"); +sql show tags from st_uint_1104 +if $data05 != 123 then + return -1 +endi +sql select * from st_uint_1104 +if $data01 != 123 then + return -1 +endi +sql insert into st_uint_1105 using mt_uint tags ("+123.5") values(now, "+123.5"); +sql show tags from st_uint_1105 +if $data05 != 124 then + return -1 +endi +sql select * from st_uint_1105 +if $data01 != 124 then + return -1 +endi +sql insert into st_uint_1106 using mt_uint tags ("-1e-1") values(now, "-1e-1"); +sql show tags from st_uint_1106 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_1106 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_1107 using mt_uint tags ("+0.1235e3") values(now, "+0.1235e3"); +sql show tags from st_uint_1107 +if $data05 != 124 then + return -1 +endi +sql insert into st_uint_1108 using mt_uint tags ("-0.11e-30") values(now, "-0.11e-30"); +sql show tags from st_uint_1108 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_1108 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_1109 using mt_uint tags ("-1.1e-307") values(now, "-1.1e-307"); +sql show tags from st_uint_1109 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_1109 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_1110 using mt_uint tags ( -1e-1 ) values(now, -1e-1); +sql show tags from st_uint_1110 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_1110 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_1111 using mt_uint tags ( +0.1235e3 ) values(now, +0.1235e3); +sql show tags from st_uint_1111 +if $data05 != 124 then + return -1 +endi +sql select * from st_uint_1111 +if $data01 != 124 then + return -1 +endi +sql insert into st_uint_1112 using mt_uint tags (-0.11e-30) values(now, -0.11e-30); +sql show tags from st_uint_1112 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_1112 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_1113 using mt_uint tags (-1.1e-307) values(now, -1.1e-307); +sql show tags from st_uint_1113 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_1113 +if $data01 != 0 then + return -1 +endi +sql insert into st_uint_1200 using mt_uint tags ( 0x01) values(now, 0x01); +sql show tags from st_uint_1200 +if $data05 != 1 then + return -1 +endi +sql select * from st_uint_1200 +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_1201 using mt_uint tags (0b01 ) values(now, 0b01); +sql show tags from st_uint_1201 +if $data05 != 1 then + return -1 +endi +sql select * from st_uint_1201 +if $data01 != 1 then + return -1 +endi +sql insert into st_uint_1202 using mt_uint tags (+0x01) values(now, +0x01); +sql show tags from st_uint_1202 +if $data05 != 1 then + return -1 +endi +sql select * from st_uint_1202 +if $data01 != 1 then + return -1 +endi + +sql insert into st_uint_1203 using mt_uint tags ( 0b000000 ) values(now, -0b0000); +sql show tags from st_uint_1203 +if $data05 != 0 then + return -1 +endi +sql select * from st_uint_1203 +if $data01 != 0 then + return -1 +endi + +### case 03: alter tag values +sql alter table st_uint_0 set tag tagname=2147483647 +sql show tags from st_uint_0 +if $data05 != 2147483647 then + return -1 +endi +sql alter table st_uint_0 set tag tagname=-0 +sql show tags from st_uint_0 +if $data05 != 0 then + return -1 +endi +sql alter table st_uint_0 set tag tagname=+100 +sql show tags from st_uint_0 +if $data05 != 100 then + return -1 +endi +sql alter table st_uint_0 set tag tagname=+33.333 +sql show tags from st_uint_0 +if $data05 != 33 then + return -1 +endi +sql alter table st_uint_0 set tag tagname='+98' +sql show tags from st_uint_0 +if $data05 != 98 then + return -1 +endi +sql alter table st_uint_0 set tag tagname='076' +sql show tags from st_uint_0 +if $data05 != 76 then + return -1 +endi +sql alter table st_uint_0 set tag tagname=+0012 +sql show tags from st_uint_0 +if $data05 != 12 then + return -1 +endi +sql alter table st_uint_0 set tag tagname=00063 +sql show tags from st_uint_0 +if $data05 != 63 then + return -1 +endi +sql alter table st_uint_100 set tag tagname="0x01" +sql show tags from st_uint_100 +if $data05 != 1 then + return -1 +endi +sql alter table st_uint_101 set tag tagname="0b01" +sql show tags from st_uint_101 +if $data05 != 1 then + return -1 +endi +sql alter table st_uint_102 set tag tagname="+0x01" +sql show tags from st_uint_102 +if $data05 != 1 then + return -1 +endi +sql alter table st_uint_103 set tag tagname="-0b00" +sql show tags from st_uint_103 +if $data05 != 0 then + return -1 +endi +sql alter table st_uint_104 set tag tagname="123.1" +sql show tags from st_uint_104 +if $data05 != 123 then + return -1 +endi +sql alter table st_uint_105 set tag tagname="+123.5" +sql show tags from st_uint_105 +if $data05 != 124 then + return -1 +endi +sql alter table st_uint_106 set tag tagname="-1e-1" +sql show tags from st_uint_106 +if $data05 != 0 then + return -1 +endi +sql alter table st_uint_107 set tag tagname="+0.1235e3" +sql show tags from st_uint_107 +if $data05 != 124 then + print $data05 != 124 + return -1 +endi +sql alter table st_uint_108 set tag tagname="-0.11e-30" +sql show tags from st_uint_108 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql alter table st_uint_109 set tag tagname="-1.1e-307" +sql show tags from st_uint_109 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql alter table st_uint_110 set tag tagname= -1e-1 +sql show tags from st_uint_110 +if $data05 != 0 then + return -1 +endi +sql alter table st_uint_111 set tag tagname= +0.1235e3 +sql show tags from st_uint_111 +if $data05 != 124 then + print $data05 != 124 + return -1 +endi +sql alter table st_uint_112 set tag tagname=-0.11e-30 +sql show tags from st_uint_112 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql alter table st_uint_113 set tag tagname=-1.1e-307 +sql show tags from st_uint_113 +if $data05 != 0 then + print $data05 != 0 + return -1 +endi +sql alter table st_uint_200 set tag tagname= 0x01 +sql show tags from st_uint_200 +if $data05 != 1 then + return -1 +endi +sql alter table st_uint_201 set tag tagname=0b00 +sql show tags from st_uint_201 +if $data05 != 0 then + return -1 +endi +sql alter table st_uint_202 set tag tagname=+0x01 +sql show tags from st_uint_202 +if $data05 != 1 then + return -1 +endi +sql alter table st_uint_203 set tag tagname= -0b0 +sql show tags from st_uint_203 +if $data05 != 0 then + return -1 +endi + +## case 04: illegal input +sql_error create table st_uint_e0_err0 using mt_uint tags (4294967296) +sql_error create table st_uint_e0_err1 using mt_uint tags (-4294967297) +sql_error create table st_uint_e0_err2 using mt_uint tags (-214748364800) +sql_error create table st_uint_e0_err3 using mt_uint tags (123abc) +sql_error create table st_uint_e0_err4 using mt_uint tags ("123abc") +sql_error create table st_uint_e0_err5 using mt_uint tags (abc) +sql_error create table st_uint_e0_err6 using mt_uint tags ("abc") +sql_error create table st_uint_e0_err7 using mt_uint tags (" ") +sql_error create table st_uint_e0_err8 using mt_uint tags ('') + +sql create table st_uint_e0 using mt_uint tags (123) +sql create table st_uint_e1 using mt_uint tags (123) +sql create table st_uint_e2 using mt_uint tags (123) +sql create table st_uint_e3 using mt_uint tags (123) +sql create table st_uint_e4 using mt_uint tags (123) +sql create table st_uint_e5 using mt_uint tags (123) +sql create table st_uint_e6 using mt_uint tags (123) +sql create table st_uint_e7 using mt_uint tags (123) +sql create table st_uint_e8 using mt_uint tags (123) +sql create table st_uint_e9 using mt_uint tags (123) +sql create table st_uint_e10 using mt_uint tags (123) +sql create table st_uint_e11 using mt_uint tags (123) +sql create table st_uint_e12 using mt_uint tags (123) + +sql_error insert into st_uint_e0 values (now, 4294967296) +sql_error insert into st_uint_e1 values (now, -4294967297) +sql_error insert into st_uint_e3 values (now, -21474836481) +sql_error insert into st_uint_e6 values (now, 123abc) +sql_error insert into st_uint_e7 values (now, "123abc") +sql_error insert into st_uint_e9 values (now, abc) +sql_error insert into st_uint_e10 values (now, "abc") +sql_error insert into st_uint_e11 values (now, " ") +sql_error insert into st_uint_e12 values (now, '') + +sql_error insert into st_uint_e13 using mt_uint tags (033) values (now, 4294967296) +sql_error insert into st_uint_e14 using mt_uint tags (033) values (now, -4294967297) +sql_error insert into st_uint_e16 using mt_uint tags (033) values (now, -21474836481) +sql_error insert into st_uint_e19 using mt_uint tags (033) values (now, 123abc) +sql_error insert into st_uint_e20 using mt_uint tags (033) values (now, "123abc") +sql_error insert into st_uint_e22 using mt_uint tags (033) values (now, abc) +sql_error insert into st_uint_e23 using mt_uint tags (033) values (now, "abc") +sql_error insert into st_uint_e24 using mt_uint tags (033) values (now, " ") +sql_error insert into st_uint_e25 using mt_uint tags (033) values (now, '') + +sql_error insert into st_uint_e13 using mt_uint tags (21474294967296483648) values (now, -033) +sql_error insert into st_uint_e14_1 using mt_uint tags (-2147483648) values (now, -033) +sql_error insert into st_uint_e16 using mt_uint tags (-2147483649) values (now, -033) +sql_error insert into st_uint_e19 using mt_uint tags (123abc) values (now, -033) +sql_error insert into st_uint_e20 using mt_uint tags ("123abc") values (now, -033) +sql_error insert into st_uint_e22 using mt_uint tags (abc) values (now, -033) +sql_error insert into st_uint_e23 using mt_uint tags ("abc") values (now, -033) +sql_error insert into st_uint_e24 using mt_uint tags (" ") values (now, -033) +sql_error insert into st_uint_e25_1 using mt_uint tags ('') values (now, -033) +sql insert into st_uint_e26_1 using mt_uint tags ('123') values (now, 033) +sql insert into st_uint_e27_1 using mt_uint tags ('12.80') values (now, 033) +sql_error insert into st_uint_e28_1 using mt_uint tags ('-11.80') values (now, 033) + +sql insert into st_uint_e13 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e14 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e15 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e16 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e17 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e18 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e19 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e20 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e21 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e22 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e23 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e24 using mt_uint tags (033) values (now, 00062) +sql insert into st_uint_e25 using mt_uint tags (033) values (now, 00062) + +sql_error alter table st_uint_e13 set tag tagname=4294967296 +sql_error alter table st_uint_e14 set tag tagname=-4294967297 +sql_error alter table st_uint_e16 set tag tagname=-3147483648 +sql_error alter table st_uint_e19 set tag tagname=123abc +sql_error alter table st_uint_e20 set tag tagname="123abc" +sql_error alter table st_uint_e22 set tag tagname=abc +sql_error alter table st_uint_e23 set tag tagname="abc" +sql_error alter table st_uint_e24 set tag tagname=" " +sql_error alter table st_uint_e25 set tag tagname='' +sql alter table st_uint_e26_1 set tag tagname='123' +sql alter table st_uint_e27_1 set tag tagname='12.80' +sql_error alter table st_uint_e28_1 set tag tagname='-11.80' + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_varbinary.sim b/tests/script/tsim/parser/columnValue_varbinary.sim new file mode 100644 index 0000000000..1db1054646 --- /dev/null +++ b/tests/script/tsim/parser/columnValue_varbinary.sim @@ -0,0 +1,323 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: varbinary +print ========== varbinary +sql create table mt_varbinary (ts timestamp, c varbinary(50)) tags(tagname varbinary(50)) + +## case 00: static create table for test tag values +sql create table st_varbinary_0 using mt_varbinary tags(NULL) +sql show tags from st_varbinary_0 +if $data05 != NULL then + return -1 +endi +sql create table st_varbinary_1 using mt_varbinary tags(NULL) +sql show tags from st_varbinary_1 +if $data05 != NULL then + return -1 +endi +sql create table st_varbinary_2 using mt_varbinary tags('NULL') +sql show tags from st_varbinary_2 +if $data05 != \x4E554C4C then + return -1 +endi +sql create table st_varbinary_3 using mt_varbinary tags('NULL') +sql show tags from st_varbinary_3 +if $data05 != \x4E554C4C then + return -1 +endi +sql create table st_varbinary_4 using mt_varbinary tags("NULL") +sql show tags from st_varbinary_4 +if $data05 != \x4E554C4C then + return -1 +endi +sql create table st_varbinary_5 using mt_varbinary tags("NULL") +sql show tags from st_varbinary_5 +if $data05 != \x4E554C4C then + return -1 +endi +sql create table st_varbinary_6 using mt_varbinary tags("") +sql show tags from st_varbinary_6 +if $data05 != \x then + return -1 +endi +sql create table st_varbinary_7 using mt_varbinary tags(" ") +sql show tags from st_varbinary_7 +if $data05 != \x20 then + return -1 +endi +sql create table st_varbinary_8 using mt_varbinary tags("\x") +sql show tags from st_varbinary_8 +if $data05 != \x then + return -1 +endi +sql create table st_varbinary_9 using mt_varbinary tags("\xaB") +sql show tags from st_varbinary_9 +if $data05 != \xAB then + return -1 +endi +sql create table st_varbinary_10 using mt_varbinary tags("aB") +sql show tags from st_varbinary_10 +if $data05 != \x6142 then + return -1 +endi + + +## case 01: insert values for test column values +sql insert into st_varbinary_0 values(now, NULL) +sql select * from st_varbinary_0 +if $data01 != NULL then + return -1 +endi +sql insert into st_varbinary_1 values(now, NULL) +sql select * from st_varbinary_1 +if $data01 != NULL then + return -1 +endi +sql insert into st_varbinary_2 values(now, 'NULL') +sql select * from st_varbinary_2 +if $data01 != \x4E554C4C then +# return -1 +endi +sql insert into st_varbinary_3 values(now, 'NULL') +sql select * from st_varbinary_3 +if $data01 != \x4E554C4C then +# return -1 +endi +sql insert into st_varbinary_4 values(now, "NULL") +sql select * from st_varbinary_4 +if $data01 != \x4E554C4C then +# return -1 +endi +sql insert into st_varbinary_5 values(now, "NULL") +sql select * from st_varbinary_5 +if $data01 != \x4E554C4C then +# return -1 +endi +sql insert into st_varbinary_6 values(now, "") +sql select * from st_varbinary_6 +if $data01 != \x then +# return -1 +endi +sql insert into st_varbinary_7 values(now, " ") +sql select * from st_varbinary_7 +if $data01 != \x20 then +# return -1 +endi +sql insert into st_varbinary_8 values(now, "\x") +sql select * from st_varbinary_8 +if $data01 != \x then +# return -1 +endi +sql insert into st_varbinary_9 values(now, "\xaB") +sql select * from st_varbinary_9 +if $data01 != \xAB then +# return -1 +endi +sql insert into st_varbinary_10 values(now, "aB") +sql select * from st_varbinary_10 +if $data01 != \x6142 then +# return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_varbinary_100 using mt_varbinary tags(NULL) values(now,NULL) +sql show tags from st_varbinary_100 +if $data05 != NULL then + return -1 +endi +sql select * from st_varbinary_100 +if $data01 != NULL then +# return -1 +endi +sql insert into st_varbinary_101 using mt_varbinary tags(NULL) values(now,NULL) +sql show tags from st_varbinary_101 +if $data05 != NULL then + return -1 +endi +sql select * from st_varbinary_101 +if $data01 != NULL then +# return -1 +endi +sql insert into st_varbinary_102 using mt_varbinary tags('NULL') values(now,'NULL') +sql show tags from st_varbinary_102 +if $data05 != \x4E554C4C then + return -1 +endi +sql select * from st_varbinary_102 +if $data01 != \x4E554C4C then +# return -1 +endi +sql insert into st_varbinary_103 using mt_varbinary tags('NULL') values(now,'NULL') +sql show tags from st_varbinary_103 +if $data05 != \x4E554C4C then + return -1 +endi +sql select * from st_varbinary_103 +if $data01 != \x4E554C4C then +# return -1 +endi +sql insert into st_varbinary_104 using mt_varbinary tags("NULL") values(now,"NULL") +sql show tags from st_varbinary_104 +if $data05 != \x4E554C4C then + return -1 +endi +sql select * from st_varbinary_104 +if $data01 != \x4E554C4C then +# return -1 +endi +sql insert into st_varbinary_105 using mt_varbinary tags("NULL") values(now,"NULL") +sql show tags from st_varbinary_105 +if $data05 != \x4E554C4C then + return -1 +endi +sql select * from st_varbinary_105 +if $data01 != \x4E554C4C then +# return -1 +endi +sql insert into st_varbinary_106 using mt_varbinary tags("") values(now,"") +sql show tags from st_varbinary_106 +if $data05 != \x then + return -1 +endi +sql select * from st_varbinary_106 +if $data01 != \x then +# return -1 +endi +sql insert into st_varbinary_107 using mt_varbinary tags(" ") values(now," ") +sql show tags from st_varbinary_107 +if $data05 != \x20 then + return -1 +endi +sql select * from st_varbinary_107 +if $data01 != \x20 then +# return -1 +endi +sql insert into st_varbinary_108 using mt_varbinary tags("\x") values(now,"\x") +sql show tags from st_varbinary_108 +if $data05 != \x then + return -1 +endi +sql select * from st_varbinary_108 +if $data01 != \x then +# return -1 +endi +sql insert into st_varbinary_109 using mt_varbinary tags("\xaB") values(now,"\xaB") +sql show tags from st_varbinary_109 +if $data05 != \xAB then + return -1 +endi +sql select * from st_varbinary_109 +if $data01 != \xAB then +# return -1 +endi +sql insert into st_varbinary_1010 using mt_varbinary tags("aB") values(now,"aB") +sql show tags from st_varbinary_1010 +if $data05 != \x6142 then + return -1 +endi +sql select * from st_varbinary_1010 +if $data01 != \x6142 then +# return -1 +endi + +## case 03: alter tag values +sql alter table st_varbinary_100 set tag tagname=NULL +sql show tags from st_varbinary_100 +if $data05 != NULL then + return -1 +endi +sql alter table st_varbinary_101 set tag tagname=NULL +sql show tags from st_varbinary_101 +if $data05 != NULL then + return -1 +endi +sql alter table st_varbinary_102 set tag tagname='NULL' +sql show tags from st_varbinary_102 +if $data05 != \x4E554C4C then + return -1 +endi +sql alter table st_varbinary_103 set tag tagname='NULL' +sql show tags from st_varbinary_103 +if $data05 != \x4E554C4C then + return -1 +endi +sql alter table st_varbinary_104 set tag tagname="NULL" +sql show tags from st_varbinary_104 +if $data05 != \x4E554C4C then + return -1 +endi +sql alter table st_varbinary_105 set tag tagname="NULL" +sql show tags from st_varbinary_105 +if $data05 != \x4E554C4C then + return -1 +endi +sql alter table st_varbinary_106 set tag tagname="" +sql show tags from st_varbinary_106 +if $data05 != \x then + return -1 +endi +sql alter table st_varbinary_107 set tag tagname=" " +sql show tags from st_varbinary_107 +if $data05 != \x20 then + return -1 +endi +sql alter table st_varbinary_108 set tag tagname="\x" +sql show tags from st_varbinary_108 +if $data05 != \x then + return -1 +endi +sql alter table st_varbinary_109 set tag tagname="\xaB" +sql show tags from st_varbinary_109 +if $data05 != \xAB then + return -1 +endi +sql alter table st_varbinary_1010 set tag tagname="aB" +sql show tags from st_varbinary_1010 +if $data05 != \x6142 then + return -1 +endi + +# case 04: illegal input +sql_error create table st_varbinary_106 using mt_varbinary tags(+0123) +sql_error create table st_varbinary_107 using mt_varbinary tags(-01.23) +sql_error create table st_varbinary_108 using mt_varbinary tags(+0x01) +sql_error create table st_varbinary_109 using mt_varbinary tags(-0b01) +sql_error create table st_varbinary_1010 using mt_varbinary tags(-0.1e-10) +sql_error create table st_varbinary_1011 using mt_varbinary tags(+0.1E+2) +sql_error create table st_varbinary_1012 using mt_varbinary tags(tRue) +sql_error create table st_varbinary_1013 using mt_varbinary tags(FalsE) +sql_error create table st_varbinary_1014 using mt_varbinary tags(noW) +sql_error create table st_varbinary_1015 using mt_varbinary tags(toDay) +sql_error insert into st_varbinary_106 using mt_varbinary tags(+0123) values(now, NULL); +sql_error insert into st_varbinary_107 using mt_varbinary tags(-01.23) values(now, NULL); +sql_error insert into st_varbinary_108 using mt_varbinary tags(+0x01) values(now, NULL); +sql_error insert into st_varbinary_109 using mt_varbinary tags(-0b01) values(now, NULL); +sql_error insert into st_varbinary_1010 using mt_varbinary tags(-0.1e-10) values(now, NULL); +sql_error insert into st_varbinary_1011 using mt_varbinary tags(+0.1E+2) values(now, NULL); +sql_error insert into st_varbinary_1012 using mt_varbinary tags(tRue) values(now, NULL); +sql_error insert into st_varbinary_1013 using mt_varbinary tags(FalsE) values(now, NULL); +sql_error insert into st_varbinary_1014 using mt_varbinary tags(noW) values(now, NULL); +sql_error insert into st_varbinary_1015 using mt_varbinary tags(toDay) values(now, NULL); +sql_error insert into st_varbinary_106 using mt_varbinary tags(NULL) values(now(), +0123) +sql_error insert into st_varbinary_107 using mt_varbinary tags(NULL) values(now(), -01.23) +sql_error insert into st_varbinary_108 using mt_varbinary tags(NULL) values(now(), +0x01) +sql_error insert into st_varbinary_109 using mt_varbinary tags(NULL) values(now(), -0b01) +sql_error insert into st_varbinary_1010 using mt_varbinary tags(NULL) values(now(), -0.1e-10) +sql_error insert into st_varbinary_1011 using mt_varbinary tags(NULL) values(now(), +0.1E+2) +sql_error insert into st_varbinary_1012 using mt_varbinary tags(NULL) values(now(), tRue) +sql_error insert into st_varbinary_1013 using mt_varbinary tags(NULL) values(now(), FalsE) +sql_error insert into st_varbinary_1014 using mt_varbinary tags(NULL) values(now(), noW) +sql_error insert into st_varbinary_1015 using mt_varbinary tags(NULL) values(now(), toDay) + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/columnValue_varchar.sim b/tests/script/tsim/parser/columnValue_varchar.sim new file mode 100644 index 0000000000..5edfe5ed24 --- /dev/null +++ b/tests/script/tsim/parser/columnValue_varchar.sim @@ -0,0 +1,415 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ========== columnValues.sim + +sql drop database if exists db +sql create database db +sql use db + +#### test the value of all data types in four cases: static create table, insert column value, synamic create table, alter tag value + +######## case 0: varchar +print ========== varchar +sql create table mt_varchar (ts timestamp, c varchar(50)) tags (tagname varchar(50)) + +## case 00: static create table for test tag values +sql create table st_varchar_0 using mt_varchar tags (NULL) +sql show create table st_varchar_0 +sql show tags from st_varchar_0 +if $data05 != NULL then + return -1 +endi +sql create table st_varchar_1 using mt_varchar tags (NULL) +sql show tags from st_varchar_1 +if $data05 != NULL then + return -1 +endi +sql create table st_varchar_2 using mt_varchar tags ('NULL') +sql show tags from st_varchar_2 +if $data05 != NULL then + return -1 +endi +sql create table st_varchar_3 using mt_varchar tags ('NULL') +sql show tags from st_varchar_3 +if $data05 != NULL then + return -1 +endi +sql create table st_varchar_4 using mt_varchar tags ("NULL") +sql show tags from st_varchar_4 +if $data05 != NULL then + return -1 +endi +sql create table st_varchar_5 using mt_varchar tags ("NULL") +sql show tags from st_varchar_5 +if $data05 != NULL then + return -1 +endi +sql create table st_varchar_6 using mt_varchar tags (+0123) +sql show tags from st_varchar_6 +if $data05 != +0123 then + return -1 +endi +sql create table st_varchar_7 using mt_varchar tags (-01.23) +sql show tags from st_varchar_7 +if $data05 != -01.23 then + return -1 +endi +sql create table st_varchar_8 using mt_varchar tags (+0x01) +sql show tags from st_varchar_8 +if $data05 != +0x01 then + return -1 +endi +sql create table st_varchar_9 using mt_varchar tags (-0b01) +sql show tags from st_varchar_9 +if $data05 != -0b01 then + return -1 +endi +sql create table st_varchar_10 using mt_varchar tags (-0.1e-10) +sql show tags from st_varchar_10 +if $data05 != -0.1e-10 then + return -1 +endi +sql create table st_varchar_11 using mt_varchar tags (+0.1E+2) +sql show tags from st_varchar_11 +if $data05 != +0.1e+2 then + return -1 +endi +sql create table st_varchar_12 using mt_varchar tags (tRue) +sql show tags from st_varchar_12 +if $data05 != true then + return -1 +endi +sql create table st_varchar_13 using mt_varchar tags (FalsE) +sql show tags from st_varchar_13 +if $data05 != false then + return -1 +endi +sql create table st_varchar_14 using mt_varchar tags (noW) +sql show tags from st_varchar_14 +if $data05 != now then + return -1 +endi +sql create table st_varchar_15 using mt_varchar tags (toDay) +sql show tags from st_varchar_15 +if $data05 != today then + return -1 +endi + +## case 01: insert values for test column values +sql insert into st_varchar_0 values(now, NULL) +sql select * from st_varchar_0 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_1 values(now, NULL) +sql select * from st_varchar_1 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_2 values(now, 'NULL') +sql select * from st_varchar_2 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_3 values(now, 'NULL') +sql select * from st_varchar_3 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_4 values(now, "NULL") +sql select * from st_varchar_4 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_5 values(now, "NULL") +sql select * from st_varchar_5 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_6 values(now, +0123) +sql select * from st_varchar_6 +if $data01 != +0123 then + return -1 +endi +sql insert into st_varchar_7 values(now, -01.23) +sql select * from st_varchar_7 +if $data01 != -01.23 then + return -1 +endi +sql insert into st_varchar_8 values(now, +0x01) +sql select * from st_varchar_8 +if $data01 != +0x01 then + return -1 +endi +sql insert into st_varchar_9 values(now, -0b01) +sql select * from st_varchar_9 +if $data01 != -0b01 then + return -1 +endi +sql insert into st_varchar_10 values(now, -0.1e-10) +sql select * from st_varchar_10 +if $data01 != -0.1e-10 then + return -1 +endi +sql insert into st_varchar_11 values(now, +0.1E+2) +sql select * from st_varchar_11 +if $data01 != +0.1e+2 then + return -1 +endi +sql insert into st_varchar_12 values(now, tRue) +sql select * from st_varchar_12 +if $data01 != true then + return -1 +endi +sql insert into st_varchar_13 values(now, FalsE) +sql select * from st_varchar_13 +if $data01 != false then + return -1 +endi +sql insert into st_varchar_14 values(now, noW) +sql select * from st_varchar_14 +if $data01 != now then + return -1 +endi +sql insert into st_varchar_15 values(now, toDay) +sql select * from st_varchar_15 +if $data01 != today then + return -1 +endi + +## case 02: dynamic create table for test tag values +sql insert into st_varchar_0 using mt_varchar tags (NULL) values(now, NULL) +sql show tags from st_varchar_0 +if $data05 != NULL then + return -1 +endi +sql select * from st_varchar_0 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_1 using mt_varchar tags (NULL) values(now, NULL) +sql show tags from st_varchar_1 +if $data05 != NULL then + return -1 +endi +sql select * from st_varchar_1 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_2 using mt_varchar tags ('NULL') values(now, 'NULL') +sql show tags from st_varchar_2 +if $data05 != NULL then + return -1 +endi +sql select * from st_varchar_2 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_3 using mt_varchar tags ('NULL') values(now, 'NULL') +sql show tags from st_varchar_3 +if $data05 != NULL then + return -1 +endi +sql select * from st_varchar_3 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_4 using mt_varchar tags ("NULL") values(now, "NULL") +sql show tags from st_varchar_4 +if $data05 != NULL then + return -1 +endi +sql select * from st_varchar_4 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_5 using mt_varchar tags ("NULL") values(now, "NULL") +sql show tags from st_varchar_5 +if $data05 != NULL then + return -1 +endi +sql select * from st_varchar_5 +if $data01 != NULL then + return -1 +endi +sql insert into st_varchar_6 using mt_varchar tags (+0123) values(now, +0123) +sql show tags from st_varchar_6 +if $data05 != +0123 then + return -1 +endi +sql select * from st_varchar_6 +if $data01 != +0123 then + return -1 +endi +sql insert into st_varchar_7 using mt_varchar tags (-01.23) values(now, -01.23) +sql show tags from st_varchar_7 +if $data05 != -01.23 then + return -1 +endi +sql select * from st_varchar_7 +if $data01 != -01.23 then + return -1 +endi +sql insert into st_varchar_8 using mt_varchar tags (+0x01) values(now, +0x01) +sql show tags from st_varchar_8 +if $data05 != +0x01 then + return -1 +endi +sql select * from st_varchar_8 +if $data01 != +0x01 then + return -1 +endi +sql insert into st_varchar_9 using mt_varchar tags (-0b01) values(now, -0b01) +sql show tags from st_varchar_9 +if $data05 != -0b01 then + return -1 +endi +sql select * from st_varchar_9 +if $data01 != -0b01 then + return -1 +endi +sql insert into st_varchar_10 using mt_varchar tags (-0.1e-10) values(now, -0.1e-10) +sql show tags from st_varchar_10 +if $data05 != -0.1e-10 then + return -1 +endi +sql select * from st_varchar_10 +if $data01 != -0.1e-10 then + return -1 +endi +sql insert into st_varchar_11 using mt_varchar tags (+0.1E+2) values(now, +0.1E+2) +sql show tags from st_varchar_11 +if $data05 != +0.1e+2 then + return -1 +endi +sql select * from st_varchar_11 +if $data01 != +0.1e+2 then + return -1 +endi +sql insert into st_varchar_12 using mt_varchar tags (tRue) values(now, tRue) +sql show tags from st_varchar_12 +if $data05 != true then + return -1 +endi +sql select * from st_varchar_12 +if $data01 != true then + return -1 +endi +sql insert into st_varchar_13 using mt_varchar tags (FalsE) values(now, FalsE) +sql show tags from st_varchar_13 +if $data05 != false then + return -1 +endi +sql select * from st_varchar_13 +if $data01 != false then + return -1 +endi +sql insert into st_varchar_14 using mt_varchar tags (noW) values(now, noW) +sql show tags from st_varchar_14 +if $data05 != now then + return -1 +endi +sql select * from st_varchar_14 +if $data01 != now then + return -1 +endi +sql insert into st_varchar_15 using mt_varchar tags (toDay) values(now, toDay) +sql show tags from st_varchar_15 +if $data05 != today then + return -1 +endi +sql select * from st_varchar_15 +if $data01 != today then + return -1 +endi + +## case 03: alter tag values +sql alter table st_varchar_0 set tag tagname=NULL +sql show tags from st_varchar_0 +if $data05 != NULL then + return -1 +endi +sql alter table st_varchar_1 set tag tagname=NULL +sql show tags from st_varchar_1 +if $data05 != NULL then + return -1 +endi +sql alter table st_varchar_2 set tag tagname='NULL' +sql show tags from st_varchar_2 +if $data05 != NULL then + return -1 +endi +sql alter table st_varchar_3 set tag tagname='NULL' +sql show tags from st_varchar_3 +if $data05 != NULL then + return -1 +endi +sql alter table st_varchar_4 set tag tagname="NULL" +sql show tags from st_varchar_4 +if $data05 != NULL then + return -1 +endi +sql alter table st_varchar_5 set tag tagname="NULL" +sql show tags from st_varchar_5 +if $data05 != NULL then + return -1 +endi +sql alter table st_varchar_6 set tag tagname=+0123 +sql show tags from st_varchar_6 +if $data05 != +0123 then + return -1 +endi +sql alter table st_varchar_7 set tag tagname=-01.23 +sql show tags from st_varchar_7 +if $data05 != -01.23 then + return -1 +endi +sql alter table st_varchar_8 set tag tagname=+0x01 +sql show tags from st_varchar_8 +if $data05 != +0x01 then + return -1 +endi +sql alter table st_varchar_9 set tag tagname=-0b01 +sql show tags from st_varchar_9 +if $data05 != -0b01 then + return -1 +endi +sql alter table st_varchar_10 set tag tagname=-0.1e-10 +sql show tags from st_varchar_10 +if $data05 != -0.1e-10 then + return -1 +endi +sql alter table st_varchar_11 set tag tagname=+0.1E+2 +sql show tags from st_varchar_11 +if $data05 != +0.1e+2 then + return -1 +endi +sql alter table st_varchar_12 set tag tagname=tRue +sql show tags from st_varchar_12 +if $data05 != true then + return -1 +endi +sql alter table st_varchar_13 set tag tagname=FalsE +sql show tags from st_varchar_13 +if $data05 != false then + return -1 +endi +sql alter table st_varchar_14 set tag tagname=noW +sql show tags from st_varchar_14 +if $data05 != now then + return -1 +endi +sql alter table st_varchar_15 set tag tagname=toDay +sql show tags from st_varchar_15 +if $data05 != today then + return -1 +endi + + +# case 04: illegal input + + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/create_mt.sim b/tests/script/tsim/parser/create_mt.sim index dd2a7834c4..57647b3c7e 100644 --- a/tests/script/tsim/parser/create_mt.sim +++ b/tests/script/tsim/parser/create_mt.sim @@ -187,7 +187,7 @@ sql_error create table $tb using $mt tags (abc) sql_error create table $tb using $mt tags ('abc') sql drop table if exists $tb sql reset query cache -sql_error create table $tb using $mt tags (1e1) +sql create table $tb using $mt tags (1e1) sql_error create table $tb using $mt tags ('1e1') sql_error create table $tb using $mt tags (2147483649) diff --git a/tests/script/tsim/parser/null_char.sim b/tests/script/tsim/parser/null_char.sim index 9d476b5227..3bac92334b 100644 --- a/tests/script/tsim/parser/null_char.sim +++ b/tests/script/tsim/parser/null_char.sim @@ -140,7 +140,7 @@ endi ### bool: sql create table stx using mt2 tags ('NULL', '123aBc', 104, '123') -sql create table sty using mt2 tags ('NULL', '123aBc', 104, 'xtz') +sql_error create table sty using mt2 tags ('NULL', '123aBc', 104, 'xtz') sql create table st4 using mt2 tags ('NULL', '123aBc', 104, 'NULL') sql insert into st4 (ts, col1) values(now, 1) sql select tag1,tag2,tag3,tag5 from st4 @@ -156,7 +156,7 @@ endi if $data02 != 104 then return -1 endi -if $data03 != 0 then +if $data03 != NULL then print ==6== expect: NULL, actually: $data03 return -1 endi @@ -182,7 +182,7 @@ endi #### case 2: dynamic create table using super table when insert into sql create table mt3 (ts timestamp, col1 int, col3 float, col5 binary(8), col6 bool, col9 nchar(8)) tags (tag1 binary(8), tag2 nchar(8), tag3 int, tag5 bool) -sql_error insert into st31 using mt3 tags (NULL, 'NULL', 102, 'true') values (now+1s, 31, 31, 'bin_31', '123', 'nchar_31') +sql insert into st31 using mt3 tags (NULL, 'NULL', 102, 'true') values (now+1s, 31, 31, 'bin_31', '123', 'nchar_31') sql_error insert into st32 using mt3 tags (NULL, 'ABC', 103, 'FALSE') values (now+2s, 32, 32.12345, 'bin_32', 'abc', 'nchar_32') sql_error insert into st33 using mt3 tags ('NULL', '123aBc', 104, 'NULL') values (now+3s, 33, 33, 'bin_33', 'false123', 'nchar_33') sql_error insert into st34 using mt3 tags ('NULL', '123aBc', 105, NULL) values (now+4s, 34, 34.12345, 'bin_34', 'true123', 'nchar_34') @@ -306,8 +306,8 @@ if $data02 != NULL then print ==10== expect: NULL, actually: $data02 return -1 endi -sql_error alter table st41 set tag tag_int = 'NULL' -sql alter table st41 set tag tag_int = '' +sql alter table st41 set tag tag_int = 'NULL' +sql_error alter table st41 set tag tag_int = '' sql_error alter table st41 set tag tag_int = abc379 ################### bool @@ -333,8 +333,8 @@ if $data03 != 1 then endi sql alter table st41 set tag tag_bool = 'NULL' sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 -if $data03 != 0 then - print ==14== expect: 0, actually: $data03 +if $data03 != NULL then + print ==14== expect: NULL, actually: $data03 return -1 endi sql alter table st41 set tag tag_bool = NULL @@ -344,7 +344,7 @@ if $data03 != NULL then endi sql alter table st41 set tag tag_bool = '123' -sql alter table st41 set tag tag_bool = '' +sql_error alter table st41 set tag tag_bool = '' sql_error alter table st41 set tag tag_bool = abc379 ################### float @@ -380,8 +380,8 @@ if $data04 != NULL then endi sql alter table st41 set tag tag_float = 'NULL' sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 -if $data04 != 0.00000 then - print ==17== expect: 0.00000, actually : $data04 +if $data04 != NULL then + print ==17== expect: NULL, actually : $data04 return -1 endi sql alter table st41 set tag tag_float = '54.123456' @@ -396,10 +396,10 @@ if $data04 != -54.12346 then print ==19== expect: -54.12346, actually : $data04 return -1 endi -sql alter table st41 set tag tag_float = '' +sql_error alter table st41 set tag tag_float = '' -sql alter table st41 set tag tag_float = 'abc' -sql alter table st41 set tag tag_float = '123abc' +sql_error alter table st41 set tag tag_float = 'abc' +sql_error alter table st41 set tag tag_float = '123abc' sql_error alter table st41 set tag tag_float = abc ################### double @@ -428,14 +428,15 @@ if $data05 != NULL then endi sql alter table st41 set tag tag_double = 'NULL' sql select tag_binary, tag_nchar, tag_int, tag_bool, tag_float, tag_double from st41 -if $data05 != 0.000000000 then - print ==20== expect: 0.000000000, actually : $data05 +if $data05 != NULL then + print ==20== expect: NULL, actually : $data05 return -1 endi -sql alter table st41 set tag tag_double = '' -sql alter table st41 set tag tag_double = 'abc' -sql alter table st41 set tag tag_double = '123abc' +sql_error alter table st41 set tag tag_double = '' +sql alter table st41 set tag tag_double = '123' +sql_error alter table st41 set tag tag_double = 'abc' +sql_error alter table st41 set tag tag_double = '123abc' sql_error alter table st41 set tag tag_double = abc ################### bigint smallint tinyint @@ -459,8 +460,8 @@ if $data00 != -9223372036854775807 then endi sql alter table st51 set tag tag_bigint = -9223372036854775808 -sql_error alter table st51 set tag tag_bigint = 'NULL' -sql alter table st51 set tag tag_bigint = '' +sql alter table st51 set tag tag_bigint = 'NULL' +sql_error alter table st51 set tag tag_bigint = '' sql_error alter table st51 set tag tag_bigint = abc379 #### @@ -480,8 +481,8 @@ if $data01 != -32767 then endi sql alter table st51 set tag tag_smallint = -32768 -sql_error alter table st51 set tag tag_smallint = 'NULL' -sql alter table st51 set tag tag_smallint = '' +sql alter table st51 set tag tag_smallint = 'NULL' +sql_error alter table st51 set tag tag_smallint = '' sql_error alter table st51 set tag tag_smallint = abc379 #### @@ -499,8 +500,8 @@ if $data02 != -127 then endi sql alter table st51 set tag tag_tinyint = '-128' sql_error alter table st51 set tag tag_tinyint = 128 -sql_error alter table st51 set tag tag_tinyint = 'NULL' -sql alter table st51 set tag tag_tinyint = '' +sql alter table st51 set tag tag_tinyint = 'NULL' +sql_error alter table st51 set tag tag_tinyint = '' sql_error alter table st51 set tag tag_tinyint = abc379 # test end diff --git a/tests/script/tsim/query/cache_last.sim b/tests/script/tsim/query/cache_last.sim index 65eb46de69..50199117b0 100644 --- a/tests/script/tsim/query/cache_last.sim +++ b/tests/script/tsim/query/cache_last.sim @@ -89,7 +89,7 @@ if $data10 != @ -> Merge (columns=3 width=24 input_order=unknown output_order= return -1 endi sql explain select count(*), last_row(f1), min(f1) from sta interval(1s); -if $data10 != @ -> Merge (columns=4 width=66 input_order=asc output_order=asc mode=sort)@ then +if $data10 != @ -> Merge (columns=4 width=82 input_order=asc output_order=asc mode=sort)@ then return -1 endi sql explain select distinct count(*), last_row(f1), min(f1) from tba1; diff --git a/tests/script/tsim/query/sys_tbname.sim b/tests/script/tsim/query/sys_tbname.sim index 9069ad949c..65f96ebc66 100644 --- a/tests/script/tsim/query/sys_tbname.sim +++ b/tests/script/tsim/query/sys_tbname.sim @@ -52,13 +52,13 @@ if $data00 != @ins_stables@ then endi sql select * from information_schema.ins_tables where table_name=''; -if $rows != 0 then +if $rows != 0 then return -1 endi sql select tbname from information_schema.ins_tables; print $rows $data00 -if $rows != 38 then +if $rows != 39 then return -1 endi if $data00 != @ins_tables@ then diff --git a/tests/script/tsim/query/tableCount.sim b/tests/script/tsim/query/tableCount.sim index 573e134133..b8ffc3a41d 100644 --- a/tests/script/tsim/query/tableCount.sim +++ b/tests/script/tsim/query/tableCount.sim @@ -36,7 +36,7 @@ sql create table tba2 using sta tags(2, 2, 2); sql create table tbb1 using stb tags(4, 4, 4); sql create table tbb2 using stb tags(5, 5, 5); sql create table tbb3 using stb tags(6, 6, 6); - + sql select count(table_name) from information_schema.ins_tables group by stable_name; if $rows != 3 then return -1 @@ -53,7 +53,7 @@ sql select stable_name,count(table_name) from information_schema.ins_tables grou if $rows != 3 then return -1 endi -if $data01 != 35 then +if $data01 != 36 then return -1 endi if $data11 != 10 then @@ -72,7 +72,7 @@ endi if $data11 != 5 then return -1 endi -if $data21 != 29 then +if $data21 != 30 then return -1 endi if $data31 != 5 then @@ -97,7 +97,7 @@ endi if $data42 != 3 then return -1 endi -if $data52 != 29 then +if $data52 != 30 then return -1 endi if $data62 != 5 then diff --git a/tests/script/tsim/stream/pauseAndResume.sim b/tests/script/tsim/stream/pauseAndResume.sim index be89d8e235..9a05e645c2 100644 --- a/tests/script/tsim/stream/pauseAndResume.sim +++ b/tests/script/tsim/stream/pauseAndResume.sim @@ -274,7 +274,7 @@ sql insert into ts4 values(1648791213001,1,12,3,1.0); $loop_count = 0 -loop3: +loop4: $loop_count = $loop_count + 1 if $loop_count == 20 then @@ -291,7 +291,7 @@ if $rows != 1 then print $data00 $data01 $data02 print $data10 $data11 $data12 print $data20 $data21 $data22 - goto loop3 + goto loop4 endi print 2 select * from streamt5; @@ -302,7 +302,7 @@ if $rows != 1 then print $data00 $data01 $data02 print $data10 $data11 $data12 print $data20 $data21 $data22 - goto loop3 + goto loop4 endi print 3 select * from streamt3; diff --git a/tests/script/tsim/tag/add.sim b/tests/script/tsim/tag/add.sim index 2b528c0255..0e0755111d 100644 --- a/tests/script/tsim/tag/add.sim +++ b/tests/script/tsim/tag/add.sim @@ -409,7 +409,7 @@ endi if $data03 != 5 then return -1 endi -if $data04 != 0 then +if $data04 != 1 then return -1 endi diff --git a/tests/script/win-test-file b/tests/script/win-test-file index b9f250927f..d51de0a61b 100644 --- a/tests/script/win-test-file +++ b/tests/script/win-test-file @@ -113,6 +113,13 @@ ./test.sh -f tsim/parser/columnValue_smallint.sim ./test.sh -f tsim/parser/columnValue_tinyint.sim ./test.sh -f tsim/parser/columnValue_unsign.sim +./test.sh -f tsim/parser/columnValue_uint.sim +./test.sh -f tsim/parser/columnValue_timestamp.sim +./test.sh -f tsim/parser/columnValue_varchar.sim +./test.sh -f tsim/parser/columnValue_nchar.sim +./test.sh -f tsim/parser/columnValue_varbinary.sim +./test.sh -f tsim/parser/columnValue_json.sim +./test.sh -f tsim/parser/columnValue_geometry.sim ./test.sh -f tsim/parser/condition.sim ./test.sh -f tsim/parser/condition_scl.sim ./test.sh -f tsim/parser/constCol.sim diff --git a/tests/system-test/0-others/information_schema.py b/tests/system-test/0-others/information_schema.py index a7995762d8..63718417b4 100644 --- a/tests/system-test/0-others/information_schema.py +++ b/tests/system-test/0-others/information_schema.py @@ -19,6 +19,8 @@ from util.common import * from util.sqlset import * class TDTestCase: + updatecfgDict = {'qDebugFlag':135 , 'mDebugFlag':135} + def init(self, conn, logSql, replicaVar=1): self.replicaVar = int(replicaVar) tdLog.debug("start to execute %s" % __file__) @@ -58,7 +60,7 @@ class TDTestCase: self.ins_list = ['ins_dnodes','ins_mnodes','ins_qnodes','ins_snodes','ins_cluster','ins_databases','ins_functions',\ 'ins_indexes','ins_stables','ins_tables','ins_tags','ins_columns','ins_users','ins_grants','ins_vgroups','ins_configs','ins_dnode_variables',\ 'ins_topics','ins_subscriptions','ins_streams','ins_stream_tasks','ins_vnodes','ins_user_privileges','ins_views', - 'ins_compacts', 'ins_compact_details', 'ins_grants_full','ins_grants_logs', 'ins_machines'] + 'ins_compacts', 'ins_compact_details', 'ins_grants_full','ins_grants_logs', 'ins_machines', 'ins_arbgroups'] self.perf_list = ['perf_connections','perf_queries','perf_consumers','perf_trans','perf_apps'] def insert_data(self,column_dict,tbname,row_num): insert_sql = self.setsql.set_insertsql(column_dict,tbname,self.binary_str,self.nchar_str) diff --git a/tests/system-test/1-insert/insert_column_value.py b/tests/system-test/1-insert/insert_column_value.py new file mode 100644 index 0000000000..fcb83e2f97 --- /dev/null +++ b/tests/system-test/1-insert/insert_column_value.py @@ -0,0 +1,529 @@ +import datetime, time +from enum import Enum +import binascii +from util.log import * +from util.sql import * +from util.cases import * +from util.common import * +from util.dnodes import * +from util.sqlset import * + + +DBNAME = "db" + +class TDDataType(Enum): + NULL = 0 + BOOL = 1 + TINYINT = 2 + SMALLINT = 3 + INT = 4 + BIGINT = 5 + FLOAT = 6 + DOUBLE = 7 + VARCHAR = 8 + TIMESTAMP = 9 + NCHAR = 10 + UTINYINT = 11 + USMALLINT = 12 + UINT = 13 + UBIGINT = 14 + JSON = 15 + VARBINARY = 16 + DECIMAL = 17 + BLOB = 18 + MEDIUMBLOB = 19 + BINARY = 8 + GEOMETRY = 20 + MAX = 21 + + +class TDTestCase: + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + self.TIMESTAMP_MIN = -1000 + self.TIMESTAMP_BASE = 1706716800 + tdSql.init(conn.cursor()) + tdSql.execute(f'drop database if exists db') + tdSql.execute(f'create database if not exists db vgroups 1') + tdLog.printNoPrefix("create table") + self.__create_tb() + + def __create_tb(self, dbname="db"): + CREATE_STB_LIST = [ f"create table {dbname}.stb_vc (ts timestamp, c0 varchar(50), c1 varchar(50)) tags(t0 varchar(50), t1 varchar(50));", + f"create table {dbname}.stb_nc (ts timestamp, c0 nchar(50), c1 nchar(50)) tags(t0 nchar(50), t1 nchar(50));", + f"create table {dbname}.stb_bi (ts timestamp, c0 binary(50), c1 binary(50)) tags(t0 binary(50), t1 binary(50));", + f"create table {dbname}.stb_ts (ts timestamp, c0 timestamp, c1 timestamp) tags(t0 timestamp, t1 timestamp);", + f"create table {dbname}.stb_bo (ts timestamp, c0 bool, c1 bool) tags(t0 bool, t1 bool);", + f"create table {dbname}.stb_vb (ts timestamp, c0 varbinary(50), c1 varbinary(50)) tags(t0 varbinary(50), t1 varbinary(50));", + f"create table {dbname}.stb_in (ts timestamp, c0 int, c1 int) tags(t0 int, t1 int);", + f"create table {dbname}.stb_ui (ts timestamp, c0 int unsigned, c1 int unsigned) tags(t0 int unsigned, t1 int unsigned);", + f"create table {dbname}.stb_bin (ts timestamp, c0 bigint, c1 bigint) tags(t0 bigint, t1 bigint);", + f"create table {dbname}.stb_bui (ts timestamp, c0 bigint unsigned, c1 bigint unsigned) tags(t0 bigint unsigned, t1 bigint unsigned);", + f"create table {dbname}.stb_sin (ts timestamp, c0 smallint, c1 smallint) tags(t0 smallint, t1 smallint);", + f"create table {dbname}.stb_sui (ts timestamp, c0 smallint unsigned, c1 smallint unsigned) tags(t0 smallint unsigned, t1 smallint unsigned);", + f"create table {dbname}.stb_tin (ts timestamp, c0 tinyint, c1 tinyint) tags(t0 tinyint, t1 tinyint);", + f"create table {dbname}.stb_tui (ts timestamp, c0 tinyint unsigned, c1 tinyint unsigned) tags(t0 tinyint unsigned, t1 tinyint unsigned);", + f"create table {dbname}.stb_fl (ts timestamp, c0 float, c1 float) tags(t0 float, t1 float);", + f"create table {dbname}.stb_db (ts timestamp, c0 double, c1 double) tags(t0 double, t1 double);", + f"create table {dbname}.stb_ge (ts timestamp, c0 geometry(512), c1 geometry(512)) tags(t0 geometry(512), t1 geometry(512));", + f"create table {dbname}.stb_js (ts timestamp, c0 int) tags(t0 json);"] + + CREATE_NTB_LIST = [ f"create table {dbname}.ntb_vc (ts timestamp, c0 binary(50), c1 varchar(50));", + f"create table {dbname}.ntb_nc (ts timestamp, c0 nchar(50), c1 nchar(50));", + f"create table {dbname}.ntb_bi (ts timestamp, c0 binary(50), c1 binary(50));", + f"create table {dbname}.ntb_ts (ts timestamp, c0 timestamp, c1 timestamp);", + f"create table {dbname}.ntb_bo (ts timestamp, c0 bool, c1 bool);", + f"create table {dbname}.ntb_vb (ts timestamp, c0 varbinary(50), c1 varbinary(50));", + f"create table {dbname}.ntb_in (ts timestamp, c0 int, c1 int);", + f"create table {dbname}.ntb_ui (ts timestamp, c0 int unsigned, c1 int unsigned);", + f"create table {dbname}.ntb_bin (ts timestamp, c0 bigint, c1 bigint);", + f"create table {dbname}.ntb_bui (ts timestamp, c0 bigint unsigned, c1 bigint unsigned);", + f"create table {dbname}.ntb_sin (ts timestamp, c0 smallint, c1 smallint);", + f"create table {dbname}.ntb_sui (ts timestamp, c0 smallint unsigned, c1 smallint unsigned);", + f"create table {dbname}.ntb_tin (ts timestamp, c0 tinyint, c1 tinyint);", + f"create table {dbname}.ntb_tui (ts timestamp, c0 tinyint unsigned, c1 tinyint unsigned);", + f"create table {dbname}.ntb_fl (ts timestamp, c0 float, c1 float);", + f"create table {dbname}.ntb_db (ts timestamp, c0 double, c1 double);", + f"create table {dbname}.ntb_ge (ts timestamp, c0 geometry(512), c1 geometry(512));"] + for _stb in CREATE_STB_LIST: + tdSql.execute(_stb) + tdSql.query(f'show {dbname}.stables') + tdSql.checkRows(len(CREATE_STB_LIST)) + + for _stb in CREATE_NTB_LIST: + tdSql.execute(_stb) + tdSql.query(f'show {dbname}.tables') + tdSql.checkRows(len(CREATE_NTB_LIST)) + + def _query_check_varchar(self, result, okv, nv, row = 0, col = 0): + for i in range(row): + for j in range(1, col): + check_result = False + check_item = result[i][j] + if result[i][j] == None: + check_item = 'null' + if check_item == okv or check_item == nv: + check_result = True + if check_result == False and (okv[0:1] == '\'' or okv[0:1] == '\"'): + if check_item == okv[1:-1]: + check_result = True + if check_result == False and (nv[0:1] == '\'' or nv[0:1] == '\"'): + if check_item == nv[1:-1]: + check_result = True + if check_result == False: + if check_item == nv.strip().lower(): + check_result = True + tdSql.checkEqual(check_result, True) + + def _query_check_int(self, result, okv, nv, row = 0, col = 0): + for i in range(row): + for j in range(1, col): + check_result = False + check_item = result[i][j] + if result[i][j] == None: + check_item = 'null' + if check_item == okv or check_item == nv: + check_result = True + if check_item == nv.strip().lower(): + check_result = True + if check_result == False and (okv.find('1') != -1 or okv.find('2') != -1): + if check_item != 0: + check_result = True + if check_result == False and (nv.find('1') != -1 or nv.find('2') != -1): + if check_item != 0: + check_result = True + if check_item == 0: + check_result = True + tdSql.checkEqual(check_result, True) + + def _query_check_bool(self, result, okv, nv, row = 0, col = 0): + for i in range(row): + for j in range(1, col): + check_result = False + check_item = result[i][j] + if result[i][j] == None: + check_item = 'null' + elif result[i][j] == True: + check_item = "true" + else: + check_item = "false" + if check_item == okv.strip().lower() or check_item == nv.strip().lower(): + check_result = True + if check_result == False and (nv[0:1] == '\'' or nv[0:1] == '\"'): + if check_item == nv[1:-1].strip().lower(): + check_result = True + if check_result == False and (nv.find('1') != -1 or nv.find('2') != -1): # char 1 or 2 exist for non-zero values + if check_item == "true": + check_result = True + else: + if check_item == "false": + check_result = True + tdSql.checkEqual(check_result, True) + + def _query_check_timestamp(self, result, okv, nv, row = 0, col = 0): + for i in range(row): + for j in range(1, col): + check_result = False + check_item = result[i][j] + if result[i][j] == None: + check_item = 'null' + if nv.lower().find(check_item) != -1: + check_result = True + else: + check_item = int(result[i][j].timestamp()) + if check_result == False and nv.lower().find("now") != -1 or nv.lower().find("today") != -1 or nv.lower().find("now") != -1 or nv.lower().find("today") != -1: + if check_item > self.TIMESTAMP_BASE: + check_result = True + if check_result == False and check_item > self.TIMESTAMP_MIN: + check_result = True + tdSql.checkEqual(check_result, True) + + def _query_check_varbinary(self, result, okv, nv, row = 0, col = 0): + tdLog.info(f'[okv={okv}, nv={nv}') + for i in range(row): + for j in range(1, col): + check_result = False + if result[i][j]: + check_item = result[i][j].decode('utf-8') + else: + check_item = '' + # new_nv = None + + if nv[0:1] == '\'' or nv[0:1] == '\"': + nv = nv[1:-1] + if okv[0:1] == '\'' or okv[0:1] == '\"': + okv = okv[1:-1] + + # if nv[0:2] == '\\x' or nv[0:2] == '\\X': + # nv = nv[1:] + # elif nv == '' or nv =="": + # new_nv = nv + # elif nv.isspace(): + # new_nv = nv + # else: + # hex_text = binascii.hexlify(nv.encode()) + # new_nv = '/x' + hex_text.decode().upper() + # tdLog.info(f"okv={okv}, nv={nv}, check_item={check_item}") + if check_item == None: + check_item = 'null' + if check_item in okv or check_item in nv: + check_result = True + tdSql.checkEqual(check_result, True) + + def _query_check(self, dbname="db", stbname="", ctbname="", ntbname="",nRows = 0, okv = None, nv = None, dtype = TDDataType.NULL): + result = None + if stbname: + if dtype != TDDataType.GEOMETRY: # geometry query by py connector need to be supported + tdSql.query(f'select * from {dbname}.{stbname}') + tdSql.checkRows(nRows) + result = tdSql.queryResult + else: + tdSql.query(f'select * from {dbname}.{ntbname}') + tdSql.checkRows(nRows) + result = tdSql.queryResult + + + if dtype == TDDataType.VARCHAR or dtype == TDDataType.NCHAR or dtype == TDDataType.BINARY: + self._query_check_varchar(result, okv, nv, nRows, 4) + elif dtype == TDDataType.TIMESTAMP: + self._query_check_timestamp(result, okv, nv, nRows, 4) + elif dtype == TDDataType.BOOL: + self._query_check_bool(result, okv, nv, nRows, 4) + elif dtype == TDDataType.VARBINARY: + self._query_check_varbinary(result, okv, nv, nRows, 4) + elif dtype == TDDataType.INT or dtype == TDDataType.BIGINT or dtype == TDDataType.SMALLINT or dtype == TDDataType.TINYINT: + self._query_check_int(result, okv, nv, nRows, 4) + elif dtype == TDDataType.UINT or dtype == TDDataType.UBIGINT or dtype == TDDataType.USMALLINT or dtype == TDDataType.UTINYINT: + self._query_check_int(result, okv, nv, nRows, 4) + elif dtype == TDDataType.FLOAT or dtype == TDDataType.DOUBLE: + self._query_check_int(result, okv, nv, nRows, 4) + elif dtype == TDDataType.GEOMETRY: + pass + else: + tdLog.info(f"unknown data type %s" % (dtype)) + + if ctbname != "": + tdSql.execute(f'drop table {dbname}.{ctbname}') + + def __insert_query_common(self, dbname="db", stbname="", ctbname="", ntbname="", oklist=[], kolist=[], okv=None, dtype = TDDataType.NULL): + tdLog.info(f'[Begin]{dbname}.{stbname} {ctbname}, oklist:%d, kolist:%d, TDDataType:%s'%(len(oklist), len(kolist), dtype)) + # tdSql.checkEqual(34, len(oklist) + len(kolist)) + + for _l in kolist: + for _e in _l: + # tdLog.info(f'[ko:verify value "{_e}"]') + # create sub-table manually, check tag + tdLog.info('[ko:create sub-table manually, check tag]') + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv})' %(_e), show=True) + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, %s)' %(_e), show=True) + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, %s)' %(_e, _e), show=True) + + # create sub-table automatically, check tag + tdLog.info('[ko:create sub-table automatically, check tag]') + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, %s) values(now, {okv}, {okv})' %(_e), show=True) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s, {okv}) values(now, {okv}, {okv})' %(_e), show=True) + + # create sub-table automatically, check value + tdLog.info('[ko:create sub-table automatically, check value]') + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, %s, {okv})' %(_e), show=True) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, {okv}, %s)' %(_e), show=True) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, %s, %s)' %(_e, _e), show=True) + + # check alter table tag + tdLog.info('[ko:check alter table tag]') + tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}, {okv}) values(now, {okv}, {okv})', show=True) + # self._query_check(dbname,stbname, "", None, 1, okv, _e, dtype) + # tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = {okv}', show=True) + tdSql.error(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e), show=True) + tdSql.error(f'alter table {dbname}.{ctbname} set tag t1 = %s' %(_e), show=True) + tdSql.execute(f'drop table {dbname}.{ctbname}') + + # insert into value by supper-table, check tag & value + tdLog.info('[ko:insert into value by supper-table, check tag & value]') + tdSql.error(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_1", %s, {okv}, now, {okv}, {okv})' %(_e), show=True) + tdSql.error(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_2", {okv},{okv}, now + 1s, {okv}, %s)' %(_e), show=True) + tdSql.error(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_3", %s, %s, now + 2s, %s, %s)' %(_e, _e, _e, _e), show=True) + + # insert into normal table, check value + tdLog.info('[ko:insert into normal table, check value]') + tdSql.error(f'insert into {dbname}.{ntbname} values(now, %s, {okv})' %(_e), show=True) + tdSql.error(f'insert into {dbname}.{ntbname} values(now, {okv}, %s)' %(_e), show=True) + tdSql.error(f'insert into {dbname}.{ntbname} values(now, %s, %s)' %(_e, _e), show=True) + + for _l in oklist: + for _e in _l: + tdLog.info(f'[ok:verify value "{_e}"]') + # 1. create sub-table manually, check tag + tdLog.info('[ok:create sub-table manually, check tag]') + tdSql.execute(f'create table {dbname}.{ctbname}_1 using {dbname}.{stbname} tags({_e}, {okv})', show=True) + tdSql.execute(f'create table {dbname}.{ctbname}_2 using {dbname}.{stbname} tags({okv}, %s)' %(_e), show=True) + tdSql.execute(f'create table {dbname}.{ctbname}_3 using {dbname}.{stbname} tags(%s, %s)' %(_e, _e), show=True) + + + # 1.1 insert into sub-table, check value + tdLog.info('[ok:insert into sub-table, check value]') + tdSql.execute(f'insert into {dbname}.{ctbname}_1 values(now + 0s, %s, {okv})' %(_e), show=True) + tdSql.execute(f'insert into {dbname}.{ctbname}_2 values(now + 1s, {okv}, %s)' %(_e), show=True) + tdSql.execute(f'insert into {dbname}.{ctbname}_3 values(now + 2s, %s, %s)' %(_e, _e), show=True) + + # 1.2 check alter table tag + tdLog.info('[ok:check alter table tag]') + tdSql.execute(f'alter table {dbname}.{ctbname}_1 set tag t1 = %s' %(_e), show=True) + tdSql.execute(f'alter table {dbname}.{ctbname}_2 set tag t0 = %s' %(_e), show=True) + + # 1.3 check table data + tdLog.info('[ok:check table data]') + self._query_check(dbname, stbname, f'{ctbname}_1', None, 3, okv, _e, dtype) + self._query_check(dbname, stbname, f'{ctbname}_2', None, 2, okv, _e, dtype) + self._query_check(dbname, stbname, f'{ctbname}_3', None, 1, okv, _e, dtype) + + # 2. insert into value by creating sub-table automatically, check tag & value + tdLog.info('[ok:insert into value by creating sub-table automatically, check tag & value]') + tdSql.execute(f'insert into {dbname}.{ctbname}_1 using {dbname}.{stbname} tags(%s, {okv}) values(now, %s, {okv})' %(_e, _e), show=True) + tdSql.execute(f'insert into {dbname}.{ctbname}_2 using {dbname}.{stbname} tags({okv}, %s) values(now + 1s, {okv}, %s)' %(_e, _e), show=True) + tdSql.execute(f'insert into {dbname}.{ctbname}_3 using {dbname}.{stbname} tags(%s, %s) values(now + 2s, %s, %s)' %(_e, _e, _e, _e), show=True) + + self._query_check(dbname, stbname, f'{ctbname}_1', None, 3, okv, _e, dtype) + self._query_check(dbname, stbname, f'{ctbname}_2', None, 2, okv, _e, dtype) + self._query_check(dbname, stbname, f'{ctbname}_3', None, 1, okv, _e, dtype) + + # 3. insert into value by supper-table, check tag & value + tdLog.info('[ok:insert into value by supper-table, check tag & value]') + tdSql.execute(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_1", %s, {okv}, now, %s, {okv})' %(_e, _e), show=True) + tdSql.execute(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_2", {okv}, %s, now + 1s, {okv}, %s)' %(_e, _e), show=True) + tdSql.execute(f'insert into {dbname}.{stbname}(tbname, t0, t1, ts, c0, c1) values("{ctbname}_3", %s, %s, now + 2s, %s, %s)' %(_e, _e, _e, _e), show=True) + + self._query_check(dbname, stbname, f'{ctbname}_1', None, 3, okv, _e, dtype) + self._query_check(dbname, stbname, f'{ctbname}_2', None, 2, okv, _e, dtype) + self._query_check(dbname, stbname, f'{ctbname}_3', None, 1, okv, _e, dtype) + + # 4. insert value into normal table + tdLog.info('[ok:insert value into normal table]') + tdSql.execute(f'insert into {dbname}.{ntbname} values(now, %s, {okv})' %(_e), show=True) + tdSql.execute(f'insert into {dbname}.{ntbname} values(now + 1s, {okv}, %s)' %(_e), show=True) + tdSql.execute(f'insert into {dbname}.{ntbname} values(now + 2s, %s, %s)' %(_e, _e), show=True) + + if dtype != TDDataType.GEOMETRY: + # self._query_check(dbname, None, None, ntbname, 3, okv, _e, dtype) + tdSql.query(f'select * from {dbname}.{ntbname}') + tdSql.checkRows(3) + tdSql.query(f'delete from {dbname}.{ntbname}') + + def __insert_query_json(self, dbname="db", stbname="", ctbname="", oklist=[], kolist=[], okv=None): + tdLog.info(f'{dbname}.{stbname} {ctbname}, oklist:%d, kolist:%d'%(len(oklist), len(kolist))) + # tdSql.checkEqual(34, len(oklist) + len(kolist)) + + for _l in kolist: + for _e in _l: + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s)' %(_e), show=True) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags(%s) values(now, 1)' %(_e), show=True) + tdSql.execute(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} tags({okv}) values(now, 1)', show=True) + tdSql.query(f'select * from {dbname}.{stbname}', show=True) + tdSql.checkRows(1) + tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = {okv}', show=True) + tdSql.error(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e), show=True) + tdSql.execute(f'drop table {dbname}.{ctbname}', show=True) + for _l in oklist: + for _e in _l: + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} tags(%s)' %(_e), show=True) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now, 1)', show=True) + tdSql.execute(f'alter table {dbname}.{ctbname} set tag t0 = %s' %(_e), show=True) + tdSql.query(f'select * from {dbname}.{stbname}', show=True) + tdSql.checkRows(1) + tdSql.execute(f'drop table {dbname}.{ctbname}', show=True) + + def __insert_query_exec(self): + STR_EMPTY = ['\'\'', "\"\"", '\' \'', "\" \""] + STR_CHINESE = ['\'年年岁岁,花相似\''] + STR_CHINESE_ILLEGAL = ['\'洛阳城东桃李花,飞来飞去落谁家。幽闺女儿爱颜色,坐见落花长叹息。今岁花开君不待。明年花开复谁在。故人不共洛阳东,今来空对落花风。年年岁岁花相似,岁岁年年人不同\''] + STR_INTEGER_P = ["\"42\"", '\'+42\'', '\'+0\'', '\'1\'','\'-0\'', '\'0x2A\'', '\'-0X0\'', '\'+0x0\'', '\'0B00101010\'', '\'-0b00\''] + STR_INTEGER_M = ['\'-128\'', '\'-0X1\'', '\"-0x34\"', '\'-0b01\'', '\'-0B00101010\''] + STR_FLOAT_P = ['\'42.1\'', "\"+0.003\"", "\'-0.0\'"] + STR_FLOAT_M = ["\"-32.001\""] + STR_FLOAT_E_P = ['\'1e1\'', "\"3e-2\"", "\"-3e-5\""] + STR_FLOAT_E_M = ["\"-0.3E+1\""] + STR_MISC = ["\"123ab\"", '\'123d\'', '\'-12s\'', '\'\x012\'', '\'x12\'', '\'x\'', '\'NULL \'', '\' NULL\'', '\'True \'', '\' False\'', + '\'0B0101 \'', '\' 0B0101\'', '\' -0x01 \'', '\'-0x02 \''] + STR_OPTR = ['\'1*10\'', '\'1+2\'', '\'-2-0\'','\'1%2\'', '\'2/0\'', '\'1&31\''] + STR_TSK = ['\'now\'', '\'today\''] + STR_TSK_MISC = ['\'now+1s\'', '\' now\'', '\'today \'', '\'today+1m\'', '\'today-1w\''] + STR_TSKP = ['\'now()\'', '\'today()\''] + STR_TSKP_MISC = ['\'now()+1s\'', '\' now()\'', '\'now( )\'', '\'today() \'', '\'today())\'', '\'today()+1m\'', '\'today()-1w\''] + STR_BOOL = ['\'true\'', '\'false\'', '\'TRUE\'', '\'FALSE\'', '\'tRuE\'', '\'falsE\''] + STR_TS = ["\"2024-02-01 00:00:01.001-08:00\"", "\'2024-02-01T00:00:01.001+09:00\'", "\"2024-02-01\"", "\'2024-02-02 00:00:01\'", "\'2024-02-02 00:00:01.009\'"] + STR_TS_ILLEGAL = ["\"2023-2024-02-01 00:00:01.001-08:00\"", "\'2024-02-01T99:00:01.001+09:00\'", "\"2024-02-31\"", "\'2024-02-02 00:88:01\'", "\'2024-02-02 00:00:77.009\'"] + STR_VARBIN = ["\'\x12\'", "\'\x13\'", "\' \x14 \'", "\'\x12ab\'"] + STR_JSON_O = ['\'{\"k1\":\"v1\"}\'', '\' {} \''] + STR_JSON_A = ['\'[]\'', '\"{\'k1\': \'v1\',\'k2\'}\"', '\"{\'k1\': \'v1\'}}\"'] + STR_GEO = ["\' POINT(1.0 1.0)\'", "\'LINESTRING(1.00 +2.0, 2.1 -3.2, 5.00 5.01) \'", "\'POLYGON((1.0 1.0, -2.0 +2.0, 1.0 1.0))\'" ] + STR_GEO_ILLEGAL = ['\' POINT(1.0)\'', '\'LINESTRING(1.00 +2.0, -3.2, 5.00 5.01) \'', '\'POLYGON((-2.0 +2.0, 1.0 1.0))\'' ] + STR_NULL = ['\'NuLl\'', '\'null\'', '\'NULL\''] + STR_NONE = ['\'NoNe\'', '\'none\'', '\'NONE\''] + STR_BINARY = ["\'\x7f8290\'", "\'\X7f8290\'", "\'x7f8290\'", "\'\\x\'"] # bug TD-29193 + STR_BINARY_ILLEGAL = ["\'\\x7f829\'"] + + RAW_INTEGER_P = [' 42 ', '+042 ', ' +0', '0 ', '-0', '0', ' 0X2A', ' -0x0 ', '+0x0 ', ' 0B00101010', ' -0b00'] + RAW_INTEGER_M = [' -42 ', ' -0128',' -0x1', ' -0X2A', '-0b01 ', ' -0B00101010 '] + RAW_INTEGER_INT_BOUNDARY_ILLEGAL =['2147483648', '-2147483649'] + RAW_INTEGER_UINT_BOUNDARY_ILLEGAL =['4294967296', '-1'] + RAW_INTEGER_BINT_BOUNDARY_ILLEGAL =['9223372036854775808', '-9223372036854775809'] + RAW_INTEGER_UBINT_BOUNDARY_ILLEGAL =['18446744073709551616', '-1'] + RAW_INTEGER_SINT_BOUNDARY_ILLEGAL =['32768', '-32769'] + RAW_INTEGER_USINT_BOUNDARY_ILLEGAL =['65536', '-1'] + RAW_INTEGER_TINT_BOUNDARY_ILLEGAL =['128', '-129'] + RAW_INTEGER_UTINT_BOUNDARY_ILLEGAL =['256', '-1'] + RAW_FLOAT_P = [' 123.012', ' 0.0', ' +0.0', ' -0.0 '] + RAW_FLOAT_M = ['-128.001 '] + RAW_FLOAT_E_P = [' 1e-100', ' +0.1E+2', ' -0.1E-10'] + RAW_FLOAT_E_M = [" -1E2 "] + RAW_FLOAT_E_M_SPE = ["-1e-100"] + RAW_MISC = ['123abc', "123c", '-123d', '+', '-', ' *', ' /', '% ', '&', "|", "^", "&&", "||", "!", " =", ' None ', 'NONE', 'now+1 s', 'now-1','now-1y','now+2 d', + 'today+1 s', 'today-1','today-1y','today+2 d', 'now()+1 s', 'now()-1','now()-1y','now()+2 d', 'today()+1 s', 'today()-1','today()-1y','today()+2 d'] + RAW_OPTR = ['1*10', '1+2', '-2-0','1%2', '2/0', '1&31'] + RAW_TSK = [' now ', 'today '] + RAW_TSK_OPTR = [' now +1s', 'today + 2d'] + RAW_TSKP = ['now( ) ', ' toDay() '] + RAW_TSKP_OPTR = [' noW ( ) + 1s', 'nOw( ) + 2D', 'NOW () + 000s', ' today()+1M', 'today( ) - 1w ', 'TodaY ( ) - 1U '] + RAW_BOOL = ['true', 'false', ' TRUE ', 'FALSE ', ' tRuE', ' falsE '] + RAW_NULL = ['NuLl', 'null ', ' NULL', ' NULL '] + RAW_NONE = ['None', 'none ', ' NoNe', ' NONE '] + RAW_BINARY_ILLEGAL = ['\\x7f8290', '\\X7f8290', 'x7f8290', '\\x', '\\x7f829'] + + OK_VC = [STR_EMPTY, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, + STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, STR_NULL, RAW_INTEGER_P, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M, + RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_TSK, RAW_BOOL, RAW_NULL, STR_CHINESE, STR_NONE] + KO_VC = [RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_CHINESE_ILLEGAL, RAW_NONE] + OK_NC = OK_VC + KO_NC = KO_VC + OK_BI = OK_VC + KO_BI = KO_VC + OK_TS = [STR_TSK, STR_INTEGER_P, STR_INTEGER_M, STR_TSKP, STR_TS, STR_NULL, RAW_INTEGER_P, RAW_INTEGER_M, RAW_TSK, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, RAW_NULL] + KO_TS = [STR_EMPTY, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_MISC, STR_OPTR, STR_TSK_MISC, STR_TSKP_MISC, STR_BOOL, STR_VARBIN, + STR_JSON_O, STR_JSON_A, STR_GEO, RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_MISC, RAW_OPTR, RAW_BOOL, STR_CHINESE, STR_NONE, STR_TS_ILLEGAL, + STR_BINARY, RAW_NONE] + OK_BO = [STR_BOOL, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M,RAW_BOOL, STR_NULL, RAW_INTEGER_P, RAW_INTEGER_M, + RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_NULL] + KO_BO = [STR_EMPTY, STR_TSK, STR_TSKP, STR_TS, STR_MISC, STR_OPTR, STR_TSK_MISC, STR_TSKP_MISC, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK, + RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, RAW_MISC, RAW_OPTR, STR_CHINESE, STR_NONE, STR_BINARY, RAW_NONE] + OK_VB = [STR_EMPTY, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, + STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, STR_NULL, RAW_NULL, STR_CHINESE, STR_NONE, STR_BINARY] + KO_VB = [RAW_INTEGER_P, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_TSK, RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, + STR_BINARY_ILLEGAL, STR_BINARY_ILLEGAL, RAW_BINARY_ILLEGAL, RAW_NONE] + OK_IN = [STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_NULL, RAW_INTEGER_P, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M, + RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_NULL] + BASE_KO_IN = [STR_EMPTY, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK, + RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_CHINESE, STR_NONE, STR_BINARY, RAW_NONE] + KO_IN = BASE_KO_IN + [RAW_INTEGER_INT_BOUNDARY_ILLEGAL] + OK_BIN = OK_IN + KO_BIN = BASE_KO_IN + [RAW_INTEGER_BINT_BOUNDARY_ILLEGAL] + OK_SIN = OK_IN + KO_SIN = BASE_KO_IN + [RAW_INTEGER_SINT_BOUNDARY_ILLEGAL] + OK_TIN = OK_IN + KO_TIN = BASE_KO_IN + [RAW_INTEGER_TINT_BOUNDARY_ILLEGAL] + OK_UI = [STR_INTEGER_P, STR_FLOAT_P, STR_FLOAT_E_P, STR_NULL, RAW_INTEGER_P, RAW_FLOAT_P, RAW_FLOAT_E_P, RAW_NULL, RAW_FLOAT_E_M_SPE] + BASE_KO_UI = [STR_EMPTY, STR_MISC, STR_INTEGER_M, STR_FLOAT_M, STR_FLOAT_E_M, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, + STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK, RAW_BOOL, RAW_INTEGER_M, RAW_FLOAT_M, RAW_FLOAT_E_M, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, + STR_CHINESE, STR_NONE, RAW_NONE] + KO_UI = BASE_KO_UI + [RAW_INTEGER_UINT_BOUNDARY_ILLEGAL] + OK_UBINT = OK_UI + KO_UBINT = BASE_KO_UI + [RAW_INTEGER_UBINT_BOUNDARY_ILLEGAL] + OK_USINT = OK_UI + KO_USINT = BASE_KO_UI + [RAW_INTEGER_USINT_BOUNDARY_ILLEGAL] + OK_UTINT = OK_UI + KO_UTINT = BASE_KO_UI + [RAW_INTEGER_UTINT_BOUNDARY_ILLEGAL] + OK_FL = [RAW_INTEGER_P, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, STR_NULL, RAW_INTEGER_M, RAW_FLOAT_P, RAW_FLOAT_M, + RAW_FLOAT_E_P, RAW_FLOAT_E_M, RAW_NULL] + KO_FL = [STR_EMPTY, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_VARBIN, STR_JSON_O, STR_JSON_A, STR_GEO, RAW_TSK, + RAW_BOOL, RAW_MISC, RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_CHINESE, STR_NONE, STR_BINARY, RAW_NONE] + OK_DB = OK_FL + KO_DB = KO_FL + OK_GE = [STR_GEO, STR_NULL, RAW_NULL] + KO_GE = [STR_EMPTY, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_JSON_O, STR_JSON_A, STR_VARBIN, RAW_TSK, RAW_BOOL, RAW_MISC, + RAW_OPTR, RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, RAW_INTEGER_P, RAW_INTEGER_M, + RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, STR_CHINESE, STR_NONE, STR_BINARY, STR_GEO_ILLEGAL, RAW_NONE] + OK_JS = [STR_EMPTY, STR_JSON_O, STR_NULL, RAW_NULL] + KO_JS = [STR_JSON_A, STR_MISC, STR_OPTR, STR_TSK, STR_TSK_MISC, STR_TSKP, STR_TSKP_MISC, STR_BOOL, STR_TS, STR_GEO, STR_VARBIN, RAW_TSK, RAW_BOOL, RAW_MISC, RAW_OPTR, + RAW_TSK_OPTR, RAW_TSKP, RAW_TSKP_OPTR, STR_INTEGER_P, STR_INTEGER_M, STR_FLOAT_P, STR_FLOAT_M, STR_FLOAT_E_P, STR_FLOAT_E_M, RAW_INTEGER_P, RAW_INTEGER_M, + RAW_FLOAT_P, RAW_FLOAT_M, RAW_FLOAT_E_P, RAW_FLOAT_E_M, STR_CHINESE, STR_NONE, STR_BINARY, RAW_NONE] + + TEST = [["' POINT(1.0 1.0)'"]] + PARAM_LIST = [ + ["db", "stb_vc", "ctb_vc", "ntb_vc", OK_VC, KO_VC, "\'vc\'", TDDataType.VARCHAR], + ["db", "stb_nc", "ctb_nc", "ntb_nc", OK_NC, KO_NC, "\'nc\'", TDDataType.NCHAR], + ["db", "stb_bi", "ctb_bi", "ntb_bi", OK_BI, KO_BI, "\'bi\'", TDDataType.BINARY], + ["db", "stb_ts", "ctb_ts", "ntb_ts", OK_TS, KO_TS, "now", TDDataType.TIMESTAMP], + ["db", "stb_bo", "ctb_bo", "ntb_bo", OK_BO, KO_BO, "true", TDDataType.BOOL], + ["db", "stb_vb", "ctb_vb", "ntb_vb", OK_VB, KO_VB, "'hello'", TDDataType.VARBINARY], + + ["db", "stb_in", "ctb_in", "ntb_in", OK_IN, KO_IN, "-1", TDDataType.INT], + ["db", "stb_ui", "ctb_ui", "ntb_ui", OK_UI, KO_UI, "1", TDDataType.UINT], + ["db", "stb_bin", "ctb_bin", "ntb_bin", OK_BIN, KO_BIN, "-1", TDDataType.BIGINT], + ["db", "stb_bui", "ctb_bui", "ntb_bui", OK_UBINT, KO_UBINT, "1", TDDataType.UBIGINT], + ["db", "stb_sin", "ctb_sin", "ntb_sin", OK_SIN, KO_SIN, "-1", TDDataType.SMALLINT], + ["db", "stb_sui", "ctb_sui", "ntb_sui", OK_USINT, KO_USINT, "1", TDDataType.USMALLINT], + ["db", "stb_tin", "ctb_tin", "ntb_tin", OK_TIN, KO_TIN, "-1", TDDataType.TINYINT], + ["db", "stb_tui", "ctb_tui", "ntb_tui", OK_UTINT, KO_UTINT, "1", TDDataType.UTINYINT], + + ["db", "stb_fl", "ctb_fl", "ntb_fl", OK_FL, KO_FL, "1.0", TDDataType.FLOAT], + ["db", "stb_db", "ctb_db", "ntb_db", OK_DB, KO_DB, "1.0", TDDataType.DOUBLE], + ["db", "stb_ge", "ctb_ge", "ntb_ge", TEST, KO_GE, "\'POINT(100.0 100.0)\'", TDDataType.GEOMETRY] + ] + + # check with common function + for _pl in PARAM_LIST: + self.__insert_query_common(_pl[0], _pl[1], _pl[2], _pl[3], _pl[4], _pl[5], _pl[6], _pl[7]) + # check json + self.__insert_query_json("db", "stb_js", "ctb_js", OK_JS, KO_JS, "\'{\"k1\":\"v1\",\"k2\":\"v2\"}\'") + + + def run(self): + self.__insert_query_exec() + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/count_partition.py b/tests/system-test/2-query/count_partition.py index e970b00cec..3077f5bb13 100644 --- a/tests/system-test/2-query/count_partition.py +++ b/tests/system-test/2-query/count_partition.py @@ -22,7 +22,7 @@ class TDTestCase: for i in range(tb_nums): tbname = f"{dbname}.sub_{stb_name}_{i}" ts = self.ts + i*10000 - tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )") + tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , %d , %f , %f , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )"%(i*10,i*1.0,i*1.0)) for row in range(row_nums): ts = self.ts + row*1000 diff --git a/tests/system-test/2-query/geometry.py b/tests/system-test/2-query/geometry.py index e430b62fb2..057795743d 100644 --- a/tests/system-test/2-query/geometry.py +++ b/tests/system-test/2-query/geometry.py @@ -171,6 +171,25 @@ class TDTestCase: for i in range(tdSql.queryRows): tdSql.checkData(i, 0, expectedResults[5][i+1]) + def test_td28365(self): + # verify TD-28365 + tdSql.execute("create database db2;") + tdSql.execute("use db2;") + tdSql.execute("create table st (ts timestamp, c1 int) tags(id int, location geometry(512));") + tdSql.execute("create table ct1 using st tags(1, 'POINT (3.000000 6.000000)')") + tdSql.execute("insert into ct1 values(now, 1)") + tdSql.execute("create table ct2 using st tags(2, 'LINESTRING (1.000000 1.000000, 2.000000 2.000000, 5.000000 5.000000)')") + tdSql.execute("insert into ct2 values(now, 2)") + tdSql.execute("create table ct3 using st tags(3, 'POLYGON ((3.000000 6.000000, 5.000000 6.000000, 5.000000 8.000000, 3.000000 8.000000, 3.000000 6.000000))')") + tdSql.execute("insert into ct3 values(now, 3)") + tdSql.query("select ST_AsText(location) from st order by location;") + tdSql.checkEqual(tdSql.queryRows, 3) + tdLog.debug(tdSql.queryResult) + # check geometry data + tdSql.checkEqual(tdSql.queryResult[0][0], "POINT (3.000000 6.000000)") + tdSql.checkEqual(tdSql.queryResult[1][0], "LINESTRING (1.000000 1.000000, 2.000000 2.000000, 5.000000 5.000000)") + tdSql.checkEqual(tdSql.queryResult[2][0], "POLYGON ((3.000000 6.000000, 5.000000 6.000000, 5.000000 8.000000, 3.000000 8.000000, 3.000000 6.000000))") + def run(self): tdSql.prepare() @@ -248,6 +267,7 @@ class TDTestCase: [1, self.point] # in where clause ] self.geomRelationFunc_test('ST_ContainsProperly', expectedResults) + self.test_td28365() def stop(self): tdSql.close() diff --git a/tests/system-test/2-query/group_partition.py b/tests/system-test/2-query/group_partition.py index a20b124c33..36e3afd3ca 100644 --- a/tests/system-test/2-query/group_partition.py +++ b/tests/system-test/2-query/group_partition.py @@ -24,7 +24,7 @@ class TDTestCase: for i in range(self.tb_nums): tbname = f"{self.dbname}.sub_{self.stable}_{i}" ts = self.ts + i*10000 - tdSql.execute(f"create table {tbname} using {self.dbname}.{self.stable} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )") + tdSql.execute(f"create table {tbname} using {self.dbname}.{self.stable} tags ({ts} , {i} , %d ,%d , %f , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )"%(i*10,i*1.0,i*1.0)) def insert_db(self, tb_nums, row_nums): for i in range(tb_nums): diff --git a/tests/system-test/2-query/max_partition.py b/tests/system-test/2-query/max_partition.py index fbd3488aab..7e43597948 100644 --- a/tests/system-test/2-query/max_partition.py +++ b/tests/system-test/2-query/max_partition.py @@ -21,7 +21,7 @@ class TDTestCase: for i in range(tb_nums): tbname = f"{dbname}.sub_{stb_name}_{i}" ts = self.ts + i*1000*120 - tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , {i}*10 ,{i}*1.0,{i}*1.0 , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )") + tdSql.execute(f"create table {tbname} using {dbname}.{stb_name} tags ({ts} , {i} , %d , %f , %f , 1 , 2, 'true', 'binary_{i}' ,'nchar_{i}',{i},{i},10,20 )"%(i*10,i*1.0,i*1.0)) for row in range(row_nums): ts = ts + row*1000 diff --git a/tests/system-test/2-query/tagFilter.py b/tests/system-test/2-query/tagFilter.py index b03776c31b..a8106a7051 100644 --- a/tests/system-test/2-query/tagFilter.py +++ b/tests/system-test/2-query/tagFilter.py @@ -1,3 +1,4 @@ +import datetime from util.log import * from util.sql import * from util.cases import * @@ -52,6 +53,202 @@ class TDTestCase: ) tdSql.checkRows(0) + def __ts4421(self, dbname="db", stbname='stb4421', ctbname='ctb4421'): + TAG_BIND = [True, False] + TAG_TYPE = ['varchar', 'nchar'] + TAG_LEN = [2, 8, 200] + TAG_VAL_INT = [0, -200, 123456789] + TAG_VAL_STR = ["noW()", "now", "'now'", "todAy()", "today", "\"today\"" ] + TAG_VAL_BOOL_INT = [ -1, 1, 0, -0] + TAG_VAL_BOOL_STR = ["TrUe", "\"true\"","fALse", "'FALSE'"] + TAG_VAL_TIMESTAMP = ["now()", "NoW", "'now'", "\"now()\"", "toDay()", "toDaY", "'today'", "\"today()\"", "\"2200-01-01 08:00:00\"", "'2200-01-02'","\"2200-01-02T00:00:00.000Z\"", "'2200-01-02T00:00:00.000'", "2200-01-01 08:00:00", "\"2200-01-02'", "2200-01-02T00:00:00.000Z"] + TAG_RESULT_INT = [True,False,False,True,True,False,True,True,True,True,False,False,True,True,False,True,True,True] + TAG_RESULT_STR = [False,False,False,False,False,False,False,True,True,False,True,True,False,True,True,False,True,True,False,False,False,False,False,False,False,True,True,False,True,True,False,True,True,False,True,True] + TAG_RESULT_BOOL = ["True","True","False","False"] + TAG_RESULT_TIMESTAMP = [True, True, True, True, True, True, True, True, True, True, True, True, False, False, False] + + # check int for vartype(one tag) + nTagCtb = 0 + for tagType in TAG_TYPE: + for tagLen in TAG_LEN: + tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 %s(%d))'%(tagType,tagLen)) + for tagVal in TAG_VAL_INT: + for tagBind in TAG_BIND: + if tagBind == True: + bindStr = "(t1)" + else: + bindStr = "" + tdLog.info(f'nTagCtb={nTagCtb}, tagType={tagType}, tagLen = {tagLen}, tagVal = {tagVal}, tagBind={tagBind}') + if TAG_RESULT_INT[nTagCtb] == False: + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d)'%(bindStr,tagVal)) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d) values(now,1)'%(bindStr,tagVal)) + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d")'%(bindStr,tagVal)) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d") values(now,1)'%(bindStr,tagVal)) + tdSql.error(f"create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d')"%(bindStr,tagVal)) + tdSql.error(f"insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d') values(now,1)"%(bindStr,tagVal)) + else: + # integer as tag value + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d)'%(bindStr,tagVal)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)') + tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%d) values(now,1)'%(bindStr,tagVal)) + tdSql.query(f'select * from {dbname}.{stbname} where t1="%d"'%(tagVal)) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + # string as tag value + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d")'%(bindStr,tagVal)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)') + tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags("%d") values(now,1)'%(bindStr,tagVal)) + tdSql.query(f'select * from {dbname}.{stbname} where t1="%d"'%(tagVal)) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + tdSql.execute(f"create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d')"%(bindStr,tagVal)) + tdSql.execute(f"insert into {dbname}.{ctbname} values(now,1)") + tdSql.execute(f"insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags('%d') values(now,1)"%(bindStr,tagVal)) + tdSql.query(f"select * from {dbname}.{stbname} where t1='%d'"%(tagVal)) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + nTagCtb += 1 + tdSql.execute(f'drop table {dbname}.{stbname}') + + # check int for vartype(two tags/bind tags) + nTagCtb = 0 + for tagType in TAG_TYPE: + for tagLen in TAG_LEN: + tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 %s(%d),t2 %s(%d) )'%(tagType,tagLen,tagType,tagLen)) + for tagVal in TAG_VAL_INT: + for tagBind in TAG_BIND: + if tagBind == True: + bindStr = "(t1,t2)" + else: + bindStr = "" + if TAG_RESULT_INT[nTagCtb] == False: + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d,%d)'%(bindStr,tagVal,tagVal)) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d,%d) values(now,1)'%(bindStr,tagVal,tagVal)) + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d","%d")'%(bindStr,tagVal,tagVal)) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d","%d") values(now,1)'%(bindStr,tagVal,tagVal)) + tdSql.error(f"create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d','%d')"%(bindStr,tagVal,tagVal)) + tdSql.error(f"insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d','%d') values(now,1)"%(bindStr,tagVal,tagVal)) + else: + # integer as tag value + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d,%d)'%(bindStr,tagVal,tagVal)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)') + tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%d,%d) values(now,1)'%(bindStr,tagVal,tagVal)) + tdSql.query(f"select * from {dbname}.{stbname} where t1='%d' and t2='%d'"%(tagVal,tagVal)) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + # string as tag value + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags("%d","%d")'%(bindStr,tagVal,tagVal)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)') + tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags("%d","%d") values(now,1)'%(bindStr,tagVal,tagVal)) + tdSql.query(f'select * from {dbname}.{stbname} where t1="%d" and t2="%d"'%(tagVal,tagVal)) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + tdSql.execute(f"create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags('%d','%d')"%(bindStr,tagVal,tagVal)) + tdSql.execute(f"insert into {dbname}.{ctbname} values(now,1)") + tdSql.execute(f"insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags('%d','%d') values(now,1)"%(bindStr,tagVal,tagVal)) + tdSql.query(f"select * from {dbname}.{stbname} where t1='%d' and t2='%d'"%(tagVal,tagVal)) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + nTagCtb += 1 + tdSql.execute(f'drop table {dbname}.{stbname}') + + # check now/today for vartype + nTagCtb = 0 + for tagType in TAG_TYPE: + for tagLen in TAG_LEN: + tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 %s(%d))'%(tagType,tagLen)) + for tagVal in TAG_VAL_STR: + for tagBind in TAG_BIND: + if tagBind == True: + bindStr = "(t1)" + else: + bindStr = "" + if TAG_RESULT_STR[nTagCtb] == False: + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s)'%(bindStr,tagVal)) + tdSql.error(f'insert into {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s) values(now,1)'%(bindStr,tagVal)) + else: + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s)'%(bindStr,tagVal)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)') + tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%s) values(now,1)'%(bindStr,tagVal)) + if tagVal.startswith("'") or tagVal.startswith("\""): + tdSql.query(f'select * from {dbname}.{stbname} where t1=%s'%(tagVal)) + else: + tdSql.query(f'select * from {dbname}.{stbname} where t1=\"%s\"'%(tagVal)) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + nTagCtb += 1 + tdSql.execute(f'drop table {dbname}.{stbname}') + + # check int for bool + nTagCtb = 0 + tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 bool)') + for tagVal in TAG_VAL_BOOL_INT: + for tagBind in TAG_BIND: + if tagBind == True: + bindStr = "(t1)" + else: + bindStr = "" + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%d)'%(bindStr,tagVal)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)') + tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%d) values(now,1)'%(bindStr,tagVal)) + tdSql.query(f'select * from {dbname}.{stbname} where t1=%s'%(TAG_RESULT_BOOL[nTagCtb])) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + nTagCtb += 1 + tdSql.execute(f'drop table {dbname}.{stbname}') + + # check str for bool + nTagCtb = 0 + tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 bool)') + for tagVal in TAG_VAL_BOOL_STR: + for tagBind in TAG_BIND: + if tagBind == True: + bindStr = "(t1)" + else: + bindStr = "" + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s)'%(bindStr,tagVal)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)') + tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%s) values(now,1)'%(bindStr,tagVal)) + tdSql.query(f'select * from {dbname}.{stbname} where t1=%s'%(TAG_RESULT_BOOL[nTagCtb])) + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + nTagCtb += 1 + tdSql.execute(f'drop table {dbname}.{stbname}') + + # check misc for timestamp + nTagCtb = 0 + tdSql.execute(f'create stable {dbname}.{stbname}(ts timestamp, f1 int) tags(t1 timestamp)') + checkTS = datetime.datetime.today() - datetime.timedelta(days=1) + for tagVal in TAG_VAL_TIMESTAMP: + for tagBind in TAG_BIND: + if tagBind == True: + bindStr = "(t1)" + else: + bindStr = "" + if TAG_RESULT_TIMESTAMP[nTagCtb] == False: + tdSql.error(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s)'%(bindStr,tagVal)) + tdSql.error(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%s) values(now,1)'%(bindStr,tagVal)) + else: + tdSql.execute(f'create table {dbname}.{ctbname} using {dbname}.{stbname} %s tags(%s)'%(bindStr,tagVal)) + tdSql.execute(f'insert into {dbname}.{ctbname} values(now,1)') + tdSql.execute(f'insert into {dbname}.{ctbname}t using {dbname}.{stbname} %s tags(%s) values(now,1)'%(bindStr,tagVal)) + tdSql.query(f'select * from {dbname}.{stbname} where t1>"{checkTS}"') + tdSql.checkRows(2) + tdSql.execute(f'drop table {dbname}.{ctbname}') + tdSql.execute(f'drop table {dbname}.{ctbname}t') + nTagCtb += 1 + tdSql.execute(f'drop table {dbname}.{stbname}') + + def run(self): tdLog.printNoPrefix("==========step1:create table") self.__create_tb() @@ -59,9 +256,12 @@ class TDTestCase: tdLog.printNoPrefix("==========step2:query data") self.__query_data(10) + tdLog.printNoPrefix("==========step3:check ts4421") + self.__ts4421() + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/system-test/2-query/tsbsQuery.py b/tests/system-test/2-query/tsbsQuery.py index 5a49f653ec..60e710e4f1 100644 --- a/tests/system-test/2-query/tsbsQuery.py +++ b/tests/system-test/2-query/tsbsQuery.py @@ -33,7 +33,7 @@ class TDTestCase: for i in range(ctbNum): tagValue = 'beijing' if (i % 10 == 0): - sql += f" {dbName}.%s%d using %s (name,fleet,driver,device_version,load_capacity,fuel_capacity,nominal_fuel_consumption) tags('truck_%d', 'South%d','Trish%d','v2.%d', 1500+%d*20, 150+%d*2, 5+%d)"%(ctbPrefix,i,stbName,i,i,i,i,(1500+i*20),(150+i*2),(5+i)) + sql += f" {dbName}.%s%d using %s (name,fleet,driver,device_version,load_capacity,fuel_capacity,nominal_fuel_consumption) tags('truck_%d', 'South%d','Trish%d','v2.%d', %d, %d, %d)"%(ctbPrefix,i,stbName,i,i,i,i,1500+(1500+i*20)*20,150+(150+i*2)*2,5+(5+i)) else: model = 'H-%d'%i sql += f" {dbName}.%s%d using %s tags('truck_%d', 'South%d','Trish%d','%s','v2.%d', %d, %d,%d)"%(ctbPrefix,i,stbName,i,i,i,model,i,(1500+i*20),(150+i*2),(5+i)) diff --git a/tests/system-test/7-tmq/tmq_taosx.py b/tests/system-test/7-tmq/tmq_taosx.py index 0330454b73..94e9babf3c 100644 --- a/tests/system-test/7-tmq/tmq_taosx.py +++ b/tests/system-test/7-tmq/tmq_taosx.py @@ -16,6 +16,7 @@ sys.path.append("./7-tmq") from tmqCommon import * class TDTestCase: + updatecfgDict = {'debugFlag': 135, 'asynclog': 0} def init(self, conn, logSql, replicaVar=1): self.replicaVar = int(replicaVar) tdLog.debug(f"start to excute {__file__}") diff --git a/tests/system-test/7-tmq/tmq_ts4563.py b/tests/system-test/7-tmq/tmq_ts4563.py new file mode 100644 index 0000000000..fc1cc259ce --- /dev/null +++ b/tests/system-test/7-tmq/tmq_ts4563.py @@ -0,0 +1,149 @@ + +import taos +import sys +import time +import socket +import os +import threading + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * +from taos.tmq import * +from taos import * + +sys.path.append("./7-tmq") +from tmqCommon import * + +class TDTestCase: + updatecfgDict = {'debugFlag': 143, 'asynclog': 0} + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + #tdSql.init(conn.cursor(), logSql) # output sql.txt file + + def consumeTest_TS_4563(self): + tdSql.execute(f'use db_stmt') + + tdSql.query("select ts,k from st") + tdSql.checkRows(2) + + tdSql.execute(f'create topic t_unorder_data as select ts,k from st') + consumer_dict = { + "group.id": "g1", + "td.connect.user": "root", + "td.connect.pass": "taosdata", + "auto.offset.reset": "earliest", + } + consumer = Consumer(consumer_dict) + + try: + consumer.subscribe(["t_unorder_data"]) + except TmqError: + tdLog.exit(f"subscribe error") + + cnt = 0 + try: + while True: + res = consumer.poll(1) + print(res) + if not res: + if cnt == 0: + tdLog.exit("consume error") + break + val = res.value() + if val is None: + continue + for block in val: + cnt += len(block.fetchall()) + + if cnt != 2: + tdLog.exit("consume error") + + finally: + consumer.close() + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files or "taosd.exe" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root)-len("/build/bin")] + break + return buildPath + + def newcon(self,host,cfg): + user = "root" + password = "taosdata" + port =6030 + con=taos.connect(host=host, user=user, password=password, config=cfg ,port=port) + print(con) + return con + + def test_stmt_insert_multi(self,conn): + # type: (TaosConnection) -> None + + dbname = "db_stmt" + try: + conn.execute("drop database if exists %s" % dbname) + conn.execute("create database if not exists %s" % dbname) + conn.select_db(dbname) + + conn.execute( + "create table st(ts timestamp, i int, j int, k int)", + ) + # conn.load_table_info("log") + tdLog.debug("statement start") + start = datetime.now() + stmt = conn.statement("insert into st(ts,j) values(?, ?)") + + params = new_multi_binds(2) + params[0].timestamp((1626861392589, 1626861392590)) + params[1].int([3, None]) + + # print(type(stmt)) + tdLog.debug("bind_param_batch start") + stmt.bind_param_batch(params) + tdLog.debug("bind_param_batch end") + stmt.execute() + tdLog.debug("execute end") + end = datetime.now() + print("elapsed time: ", end - start) + assert stmt.affected_rows == 2 + tdLog.debug("close start") + + stmt.close() + + # conn.execute("drop database if exists %s" % dbname) + conn.close() + + except Exception as err: + # conn.execute("drop database if exists %s" % dbname) + conn.close() + raise err + + def run(self): + buildPath = self.getBuildPath() + config = buildPath+ "../sim/dnode1/cfg/" + host="localhost" + connectstmt=self.newcon(host,config) + self.test_stmt_insert_multi(connectstmt) + self.consumeTest_TS_4563() + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/runAllOne.sh b/tests/system-test/runAllOne.sh index 6d4c80c388..099ae1bbd3 100644 --- a/tests/system-test/runAllOne.sh +++ b/tests/system-test/runAllOne.sh @@ -22,6 +22,7 @@ python3 ./test.py -f 1-insert/update_data_muti_rows.py -P python3 ./test.py -f 1-insert/db_tb_name_check.py -P python3 ./test.py -f 1-insert/InsertFuturets.py -P python3 ./test.py -f 1-insert/insert_wide_column.py -P +python3 ./test.py -f 1-insert/insert_column_value.py python3 ./test.py -f 2-query/nestedQuery.py -P python3 ./test.py -f 2-query/nestedQuery_str.py -P python3 ./test.py -f 2-query/nestedQuery_math.py -P diff --git a/tests/system-test/win-test-file b/tests/system-test/win-test-file index 1ab0fee7bf..96f9452827 100644 --- a/tests/system-test/win-test-file +++ b/tests/system-test/win-test-file @@ -233,6 +233,7 @@ python3 ./test.py -f 1-insert/update_data_muti_rows.py python3 ./test.py -f 1-insert/db_tb_name_check.py python3 ./test.py -f 1-insert/InsertFuturets.py python3 ./test.py -f 1-insert/insert_wide_column.py +python3 ./test.py -f 1-insert/insert_column_value.py python3 ./test.py -f 1-insert/rowlength64k_benchmark.py python3 ./test.py -f 1-insert/rowlength64k.py python3 ./test.py -f 1-insert/rowlength64k.py -R diff --git a/tools/shell/inc/shellAuto.h b/tools/shell/inc/shellAuto.h index 6a317fe5c9..bcf500fefc 100644 --- a/tools/shell/inc/shellAuto.h +++ b/tools/shell/inc/shellAuto.h @@ -39,7 +39,10 @@ void shellAutoExit(); void callbackAutoTab(char* sqlstr, TAOS* pSql, bool usedb); // introduction -void printfIntroduction(); +void printfIntroduction(bool community); + +// show enterprise AD at start or end +void showAD(bool end); // show all commands help void showHelp(); diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index 847bbcf4be..6c3716519b 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -400,27 +400,41 @@ SMatch* lastMatch = NULL; // save last match result int cntDel = 0; // delete byte count after next press tab // show auto tab introduction -void printfIntroduction() { - printf(" ******************************** Tab Completion ************************************\n"); +void printfIntroduction(bool community) { + printf(" ********************************* Tab Completion *************************************\n"); char secondLine[160] = "\0"; sprintf(secondLine, " * The %s CLI supports tab completion for a variety of items, ", shell.info.cusName); printf("%s", secondLine); int secondLineLen = strlen(secondLine); - while (87 - (secondLineLen++) > 0) { + while (89 - (secondLineLen++) > 0) { printf(" "); } printf("*\n"); - printf(" * including database names, table names, function names and keywords. *\n"); - printf(" * The full list of shortcut keys is as follows: *\n"); - printf(" * [ TAB ] ...... complete the current word *\n"); - printf(" * ...... if used on a blank line, display all supported commands *\n"); - printf(" * [ Ctrl + A ] ...... move cursor to the st[A]rt of the line *\n"); - printf(" * [ Ctrl + E ] ...... move cursor to the [E]nd of the line *\n"); - printf(" * [ Ctrl + W ] ...... move cursor to the middle of the line *\n"); - printf(" * [ Ctrl + L ] ...... clear the entire screen *\n"); - printf(" * [ Ctrl + K ] ...... clear the screen after the cursor *\n"); - printf(" * [ Ctrl + U ] ...... clear the screen before the cursor *\n"); - printf(" **************************************************************************************\n\n"); + printf(" * including database names, table names, function names and keywords. *\n"); + printf(" * The full list of shortcut keys is as follows: *\n"); + printf(" * [ TAB ] ...... complete the current word *\n"); + printf(" * ...... if used on a blank line, display all supported commands *\n"); + printf(" * [ Ctrl + A ] ...... move cursor to the st[A]rt of the line *\n"); + printf(" * [ Ctrl + E ] ...... move cursor to the [E]nd of the line *\n"); + printf(" * [ Ctrl + W ] ...... move cursor to the middle of the line *\n"); + printf(" * [ Ctrl + L ] ...... clear the entire screen *\n"); + printf(" * [ Ctrl + K ] ...... clear the screen after the cursor *\n"); + printf(" * [ Ctrl + U ] ...... clear the screen before the cursor *\n"); + if(community) { + printf(" * ------------------------------------------------------------------------------------ *\n"); + printf(" * You are using TDengine OSS. To experience advanced features, like backup/restore, *\n"); + printf(" * privilege control and more, or receive 7x24 technical support, try TDengine *\n"); + printf(" * Enterprise or Free Cloud Trial. Learn more at https://tdengine.com *\n"); + } + printf(" ****************************************************************************************\n\n"); +} + +// show enterprise AD +void showAD(bool end) { + printf(" You are using TDengine OSS. To experience advanced features, like backup/restore, \n"); + printf(" privilege control and more, or receive 7x24 technical support, try TDengine Enterprise \n"); + printf(" or Free Cloud Trial. Learn more at https://tdengine.com \n"); + printf(" \n"); } void showHelp() { @@ -1852,6 +1866,9 @@ _return: // main key press tab void pressTabKey(SShellCmd* cmd) { +#ifdef WINDOWS + return ; +#endif // check empty tab key if (cmd->commandSize == 0) { // have multi line tab key @@ -1895,6 +1912,10 @@ void pressTabKey(SShellCmd* cmd) { // press othr key void pressOtherKey(char c) { +#ifdef WINDOWS + return ; +#endif + // reset global variant firstMatchIndex = -1; lastMatchIndex = -1; diff --git a/tools/shell/src/shellCommand.c b/tools/shell/src/shellCommand.c index c6459c4590..265dc4530f 100644 --- a/tools/shell/src/shellCommand.c +++ b/tools/shell/src/shellCommand.c @@ -445,7 +445,7 @@ char taosGetConsoleChar() { static char mbStr[5]; static unsigned long bufLen = 0; static uint16_t bufIndex = 0, mbStrIndex = 0, mbStrLen = 0; - CONSOLE_READCONSOLE_CONTROL inputControl={ sizeof(CONSOLE_READCONSOLE_CONTROL), 0, 1< 0 && buf[0] == 0) bufLen = 0; @@ -500,13 +500,11 @@ int32_t shellReadCommand(char *command) { } shellInsertChar(&cmd, utf8_array, count); pressOtherKey(c); -#ifndef WINDOWS } else if (c == TAB_KEY) { // press TAB key pressTabKey(&cmd); -#endif } else if (c < '\033') { - pressOtherKey(c); + pressOtherKey(c); // Ctrl keys. TODO: Implement ctrl combinations switch (c) { case 0: diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 995d3d04ec..8c78a94de6 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -56,7 +56,7 @@ static void shellWriteHistory(); static void shellPrintError(TAOS_RES *tres, int64_t st); static bool shellIsCommentLine(char *line); static void shellSourceFile(const char *file); -static void shellGetGrantInfo(); +static bool shellGetGrantInfo(); static void shellCleanup(void *arg); static void *shellCancelHandler(void *arg); @@ -1150,8 +1150,9 @@ void shellSourceFile(const char *file) { taosCloseFile(&pFile); } -void shellGetGrantInfo() { - char sinfo[1024] = {0}; +bool shellGetGrantInfo(char* buf) { + bool community = true; + char sinfo[256] = {0}; tstrncpy(sinfo, taos_get_server_info(shell.conn), sizeof(sinfo)); strtok(sinfo, "\r\n"); @@ -1165,7 +1166,7 @@ void shellGetGrantInfo() { code != TSDB_CODE_PAR_PERMISSION_DENIED) { fprintf(stderr, "Failed to check Server Edition, Reason:0x%04x:%s\r\n\r\n", code, taos_errstr(tres)); } - return; + return community; } int32_t num_fields = taos_field_count(tres); @@ -1194,11 +1195,13 @@ void shellGetGrantInfo() { memcpy(expired, row[2], fields[2].bytes); if (strcmp(serverVersion, "community") == 0) { - fprintf(stdout, "Server is Community Edition.\r\n"); + community = true; } else if (strcmp(expiretime, "unlimited") == 0) { - fprintf(stdout, "Server is Enterprise %s Edition, %s and will never expire.\r\n", serverVersion, sinfo); + community = false; + sprintf(buf, "Server is Enterprise %s Edition, %s and will never expire.\r\n", serverVersion, sinfo); } else { - fprintf(stdout, "Server is Enterprise %s Edition, %s and will expire at %s.\r\n", serverVersion, sinfo, + community = false; + sprintf(buf, "Server is Enterprise %s Edition, %s and will expire at %s.\r\n", serverVersion, sinfo, expiretime); } @@ -1206,6 +1209,7 @@ void shellGetGrantInfo() { } fprintf(stdout, "\r\n"); + return community; } #ifdef WINDOWS @@ -1364,10 +1368,23 @@ int32_t shellExecute() { #ifdef WEBSOCKET if (!shell.args.restful && !shell.args.cloud) { #endif +char* buf = taosMemoryMalloc(512); +bool community = shellGetGrantInfo(buf); #ifndef WINDOWS - printfIntroduction(); + printfIntroduction(community); +#else +#ifndef WEBSOCKET + if(community) { + showAD(false); + } +#endif #endif - shellGetGrantInfo(); +// printf version +if(!community) { + printf("%s\n", buf); +} +taosMemoryFree(buf); + #ifdef WEBSOCKET } #endif @@ -1380,6 +1397,13 @@ int32_t shellExecute() { break; } } +#ifndef WEBSOCKET + // commnuity + if (community) { + showAD(true); + } +#endif + taosThreadJoin(spid, NULL); shellCleanupHistory(); diff --git a/tools/shell/src/shellWebsocket.c b/tools/shell/src/shellWebsocket.c index 2d3aa27a3b..fc7c914c21 100644 --- a/tools/shell/src/shellWebsocket.c +++ b/tools/shell/src/shellWebsocket.c @@ -77,7 +77,7 @@ int shell_conn_ws_server(bool first) { } fprintf(stdout, "successfully connected to %s\n", host); } else { - fprintf(stdout, "successfully connected to cloud service\n"); + fprintf(stdout, "successfully connected to service\n"); } } fflush(stdout);