diff --git a/cmake/cmake.platform b/cmake/cmake.platform index acf17e9427..849d31f93e 100644 --- a/cmake/cmake.platform +++ b/cmake/cmake.platform @@ -70,5 +70,46 @@ ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows") ENDIF() +IF ("${CPUTYPE}" STREQUAL "") + MESSAGE(STATUS "The current platform " ${CMAKE_SYSTEM_PROCESSOR} " is detected") + + IF (CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64)|(AMD64)") + MESSAGE(STATUS "The current platform is amd64") + SET(PLATFORM_ARCH_STR "amd64") + ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)") + MESSAGE(STATUS "The current platform is x86") + SET(PLATFORM_ARCH_STR "i386") + ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "armv7l") + MESSAGE(STATUS "The current platform is aarch32") + SET(PLATFORM_ARCH_STR "arm") + ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") + MESSAGE(STATUS "The current platform is aarch64") + SET(PLATFORM_ARCH_STR "arm64") + ENDIF () +ELSE () + # if generate ARM version: + # cmake -DCPUTYPE=aarch32 .. or cmake -DCPUTYPE=aarch64 + IF (${CPUTYPE} MATCHES "aarch32") + SET(PLATFORM_ARCH_STR "arm") + MESSAGE(STATUS "input cpuType: aarch32") + ELSEIF (${CPUTYPE} MATCHES "aarch64") + SET(PLATFORM_ARCH_STR "arm64") + MESSAGE(STATUS "input cpuType: aarch64") + ELSEIF (${CPUTYPE} MATCHES "mips64") + SET(PLATFORM_ARCH_STR "mips") + MESSAGE(STATUS "input cpuType: mips64") + ELSEIF (${CPUTYPE} MATCHES "x64") + SET(PLATFORM_ARCH_STR "amd64") + MESSAGE(STATUS "input cpuType: x64") + ELSEIF (${CPUTYPE} MATCHES "x86") + SET(PLATFORM_ARCH_STR "i386") + MESSAGE(STATUS "input cpuType: x86") + ELSE () + MESSAGE(STATUS "input cpuType unknown " ${CPUTYPE}) + ENDIF () +ENDIF () + +MESSAGE(STATUS "platform arch:" ${PLATFORM_ARCH_STR}) + MESSAGE("C Compiler ID: ${CMAKE_C_COMPILER_ID}") MESSAGE("CXX Compiler ID: ${CMAKE_CXX_COMPILER_ID}") diff --git a/docs/en/10-cluster/02-cluster-mgmt.md b/docs/en/10-cluster/02-cluster-mgmt.md index 674c92e276..bd3386c411 100644 --- a/docs/en/10-cluster/02-cluster-mgmt.md +++ b/docs/en/10-cluster/02-cluster-mgmt.md @@ -54,14 +54,14 @@ Database changed. taos> show vgroups; vgId | tables | status | onlines | v1_dnode | v1_status | compacting | ========================================================================================== - 14 | 38000 | ready | 1 | 1 | master | 0 | - 15 | 38000 | ready | 1 | 1 | master | 0 | - 16 | 38000 | ready | 1 | 1 | master | 0 | - 17 | 38000 | ready | 1 | 1 | master | 0 | - 18 | 37001 | ready | 1 | 1 | master | 0 | - 19 | 37000 | ready | 1 | 1 | master | 0 | - 20 | 37000 | ready | 1 | 1 | master | 0 | - 21 | 37000 | ready | 1 | 1 | master | 0 | + 14 | 38000 | ready | 1 | 1 | leader | 0 | + 15 | 38000 | ready | 1 | 1 | leader | 0 | + 16 | 38000 | ready | 1 | 1 | leader | 0 | + 17 | 38000 | ready | 1 | 1 | leader | 0 | + 18 | 37001 | ready | 1 | 1 | leader | 0 | + 19 | 37000 | ready | 1 | 1 | leader | 0 | + 20 | 37000 | ready | 1 | 1 | leader | 0 | + 21 | 37000 | ready | 1 | 1 | leader | 0 | Query OK, 8 row(s) in set (0.001154s) ``` @@ -161,14 +161,14 @@ First `show vgroups` is executed to show the vgroup distribution. taos> show vgroups; vgId | tables | status | onlines | v1_dnode | v1_status | compacting | ========================================================================================== - 14 | 38000 | ready | 1 | 3 | master | 0 | - 15 | 38000 | ready | 1 | 3 | master | 0 | - 16 | 38000 | ready | 1 | 3 | master | 0 | - 17 | 38000 | ready | 1 | 3 | master | 0 | - 18 | 37001 | ready | 1 | 3 | master | 0 | - 19 | 37000 | ready | 1 | 1 | master | 0 | - 20 | 37000 | ready | 1 | 1 | master | 0 | - 21 | 37000 | ready | 1 | 1 | master | 0 | + 14 | 38000 | ready | 1 | 3 | leader | 0 | + 15 | 38000 | ready | 1 | 3 | leader | 0 | + 16 | 38000 | ready | 1 | 3 | leader | 0 | + 17 | 38000 | ready | 1 | 3 | leader | 0 | + 18 | 37001 | ready | 1 | 3 | leader | 0 | + 19 | 37000 | ready | 1 | 1 | leader | 0 | + 20 | 37000 | ready | 1 | 1 | leader | 0 | + 21 | 37000 | ready | 1 | 1 | leader | 0 | Query OK, 8 row(s) in set (0.001314s) ``` @@ -191,14 +191,14 @@ Query OK, 0 row(s) in set (0.000575s) taos> show vgroups; vgId | tables | status | onlines | v1_dnode | v1_status | v2_dnode | v2_status | compacting | ================================================================================================================= - 14 | 38000 | ready | 1 | 3 | master | 0 | NULL | 0 | - 15 | 38000 | ready | 1 | 3 | master | 0 | NULL | 0 | - 16 | 38000 | ready | 1 | 3 | master | 0 | NULL | 0 | - 17 | 38000 | ready | 1 | 3 | master | 0 | NULL | 0 | - 18 | 37001 | ready | 2 | 1 | slave | 3 | master | 0 | - 19 | 37000 | ready | 1 | 1 | master | 0 | NULL | 0 | - 20 | 37000 | ready | 1 | 1 | master | 0 | NULL | 0 | - 21 | 37000 | ready | 1 | 1 | master | 0 | NULL | 0 | + 14 | 38000 | ready | 1 | 3 | leader | 0 | NULL | 0 | + 15 | 38000 | ready | 1 | 3 | leader | 0 | NULL | 0 | + 16 | 38000 | ready | 1 | 3 | leader | 0 | NULL | 0 | + 17 | 38000 | ready | 1 | 3 | leader | 0 | NULL | 0 | + 18 | 37001 | ready | 2 | 1 | follower | 3 | leader | 0 | + 19 | 37000 | ready | 1 | 1 | leader | 0 | NULL | 0 | + 20 | 37000 | ready | 1 | 1 | leader | 0 | NULL | 0 | + 21 | 37000 | ready | 1 | 1 | leader | 0 | NULL | 0 | Query OK, 8 row(s) in set (0.001242s) ``` @@ -207,7 +207,7 @@ It can be seen from above output that vgId 18 has been moved from dnode 3 to dno :::note - Manual load balancing can only be performed when the automatic load balancing is disabled, i.e. `balance` is set to 0. -- Only a vnode in normal state, i.e. master or slave, can be moved. vnode can't be moved when its in status offline, unsynced or syncing. +- Only a vnode in normal state, i.e. leader or follower, can be moved. vnode can't be moved when its in status offline, unsynced or syncing. - Before moving a vnode, it's necessary to make sure the target dnode has enough resources: CPU, memory and disk. ::: diff --git a/docs/en/10-cluster/03-ha-and-lb.md b/docs/en/10-cluster/03-ha-and-lb.md index bd718eef9f..9780e8f6c6 100644 --- a/docs/en/10-cluster/03-ha-and-lb.md +++ b/docs/en/10-cluster/03-ha-and-lb.md @@ -27,7 +27,7 @@ There may be multiple dnodes in a cluster, but only one mnode can be started in SHOW MNODES; ``` -The end point and role/status (master, slave, unsynced, or offline) of all mnodes can be shown by the above command. When the first dnode is started in a cluster, there must be one mnode in this dnode. Without at least one mnode, the cluster cannot work. If `numOfMNodes` is configured to 2, another mnode will be started when the second dnode is launched. +The end point and role/status (leader, follower, unsynced, or offline) of all mnodes can be shown by the above command. When the first dnode is started in a cluster, there must be one mnode in this dnode. Without at least one mnode, the cluster cannot work. If `numOfMNodes` is configured to 2, another mnode will be started when the second dnode is launched. For the high availability of mnode, `numOfMnodes` needs to be configured to 2 or a higher value. Because the data consistency between mnodes must be guaranteed, the replica confirmation parameter `quorum` is set to 2 automatically if `numOfMNodes` is set to 2 or higher. @@ -58,13 +58,13 @@ When a dnode is offline, it can be detected by the TDengine cluster. There are t - If the dnode has been offline over the threshold configured in `offlineThreshold` in `taos.cfg`, the dnode will be removed from the cluster automatically. A system alert will be generated and automatic load balancing will be triggered if `balance` is set to 1. When the removed dnode is restarted and becomes online, it will not join the cluster automatically. The system administrator has to manually join the dnode to the cluster. :::note -If all the vnodes in a vgroup (or mnodes in mnode group) are in offline or unsynced status, the master node can only be voted on, after all the vnodes or mnodes in the group become online and can exchange status. Following this, the vgroup (or mnode group) is able to provide service. +If all the vnodes in a vgroup (or mnodes in mnode group) are in offline or unsynced status, the leader node can only be voted on, after all the vnodes or mnodes in the group become online and can exchange status. Following this, the vgroup (or mnode group) is able to provide service. ::: ## Arbitrator -The "arbitrator" component is used to address the special case when the number of replicas is set to an even number like 2,4 etc. If half of the vnodes in a vgroup don't work, it is impossible to vote and select a master node. This situation also applies to mnodes if the number of mnodes is set to an even number like 2,4 etc. +The "arbitrator" component is used to address the special case when the number of replicas is set to an even number like 2,4 etc. If half of the vnodes in a vgroup don't work, it is impossible to vote and select a leader node. This situation also applies to mnodes if the number of mnodes is set to an even number like 2,4 etc. To resolve this problem, a new arbitrator component named `tarbitrator`, an abbreviation of TDengine Arbitrator, was introduced. The `tarbitrator` simulates a vnode or mnode but it's only responsible for network communication and doesn't handle any actual data access. As long as more than half of the vnode or mnode, including Arbitrator, are available the vnode group or mnode group can provide data insertion or query services normally. diff --git a/docs/en/14-reference/02-rest-api/02-rest-api.mdx b/docs/en/14-reference/02-rest-api/02-rest-api.mdx index 990af86196..fe18349a6d 100644 --- a/docs/en/14-reference/02-rest-api/02-rest-api.mdx +++ b/docs/en/14-reference/02-rest-api/02-rest-api.mdx @@ -21,7 +21,7 @@ The following example is in an Ubuntu environment and uses the `curl` tool to ve The following example lists all databases on the host h1.taosdata.com. To use it in your environment, replace `h1.taosdata.com` and `6041` (the default port) with the actual running TDengine service FQDN and port number. ```html -curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' h1.taosdata.com:6041/rest/sql +curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "show databases;" h1.taosdata.com:6041/rest/sql ``` The following return value results indicate that the verification passed. @@ -106,13 +106,13 @@ The HTTP request's BODY is a complete SQL command, and the data table in the SQL Use `curl` to initiate an HTTP request with a custom authentication method, with the following syntax. ```bash -curl -H 'Authorization: Basic ' -d '' :/rest/sql/[db_name] +curl -L -H "Authorization: Basic " -d "" :/rest/sql/[db_name] ``` Or ```bash -curl -u username:password -d '' :/rest/sql/[db_name] +curl -L -u username:password -d "" :/rest/sql/[db_name] ``` where `TOKEN` is the string after Base64 encoding of `{username}:{password}`, e.g. `root:taosdata` is encoded as `cm9vdDp0YW9zZGF0YQ==`. @@ -192,7 +192,7 @@ Response body: - query all records from table d1001 of database demo ```bash - curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sql + curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.d1001" 192.168.0.1:6041/rest/sql ``` Response body: @@ -218,7 +218,7 @@ Response body: - Create database demo: ```bash - curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'create database demo' 192.168.0.1:6041/rest/sql + curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "create database demo" 192.168.0.1:6041/rest/sql ``` Response body: @@ -240,7 +240,7 @@ Response body: When the HTTP request URL uses `/rest/sqlt`, the returned result set's timestamp value will be in Unix timestamp format, for example: ```bash -curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sqlt +curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.d1001" 192.168.0.1:6041/rest/sqlt ``` Response body: @@ -268,7 +268,7 @@ Response body: When the HTTP request URL uses `/rest/sqlutc`, the timestamp of the returned result set will be expressed as a UTC format, for example: ```bash - curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.t1' 192.168.0.1:6041/rest/sqlutc + curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.t1" 192.168.0.1:6041/rest/sqlutc ``` Response body: diff --git a/docs/en/14-reference/07-tdinsight/assets/15146-tdengine-monitor-dashboard.json b/docs/en/14-reference/07-tdinsight/assets/15146-tdengine-monitor-dashboard.json index f651983528..54dc1062d6 100644 --- a/docs/en/14-reference/07-tdinsight/assets/15146-tdengine-monitor-dashboard.json +++ b/docs/en/14-reference/07-tdinsight/assets/15146-tdengine-monitor-dashboard.json @@ -211,7 +211,7 @@ ], "timeFrom": null, "timeShift": null, - "title": "Master MNode", + "title": "Leader MNode", "transformations": [ { "id": "filterByValue", @@ -221,7 +221,7 @@ "config": { "id": "regex", "options": { - "value": "master" + "value": "leader" } }, "fieldName": "role" @@ -300,7 +300,7 @@ ], "timeFrom": null, "timeShift": null, - "title": "Master MNode Create Time", + "title": "Leader MNode Create Time", "transformations": [ { "id": "filterByValue", @@ -310,7 +310,7 @@ "config": { "id": "regex", "options": { - "value": "master" + "value": "leader" } }, "fieldName": "role" diff --git a/docs/en/14-reference/07-tdinsight/assets/tdengine-grafana-7.x.json b/docs/en/14-reference/07-tdinsight/assets/tdengine-grafana-7.x.json index b4254c428b..1add8522a7 100644 --- a/docs/en/14-reference/07-tdinsight/assets/tdengine-grafana-7.x.json +++ b/docs/en/14-reference/07-tdinsight/assets/tdengine-grafana-7.x.json @@ -153,7 +153,7 @@ ], "timeFrom": null, "timeShift": null, - "title": "Master MNode", + "title": "Leader MNode", "transformations": [ { "id": "filterByValue", @@ -163,7 +163,7 @@ "config": { "id": "regex", "options": { - "value": "master" + "value": "leader" } }, "fieldName": "role" @@ -246,7 +246,7 @@ ], "timeFrom": null, "timeShift": null, - "title": "Master MNode Create Time", + "title": "Leader MNode Create Time", "transformations": [ { "id": "filterByValue", @@ -256,7 +256,7 @@ "config": { "id": "regex", "options": { - "value": "master" + "value": "leader" } }, "fieldName": "role" diff --git a/docs/en/14-reference/07-tdinsight/index.md b/docs/en/14-reference/07-tdinsight/index.md index cebfafa225..e74c9de7b2 100644 --- a/docs/en/14-reference/07-tdinsight/index.md +++ b/docs/en/14-reference/07-tdinsight/index.md @@ -274,8 +274,8 @@ Details of the metrics are as follows. This section contains the current information and status of the cluster, the alert information is also here (from left to right, top to bottom). - **First EP**: the `firstEp` setting in the current TDengine cluster. -- **Version**: TDengine server version (master mnode). -- **Master Uptime**: The time elapsed since the current Master MNode was elected as Master. +- **Version**: TDengine server version (leader mnode). +- **Leader Uptime**: The time elapsed since the current Leader MNode was elected as Leader. - **Expire Time** - Enterprise version expiration time. - **Used Measuring Points** - The number of measuring points used by the Enterprise Edition. - **Databases** - The number of databases. @@ -333,7 +333,7 @@ Data node resource usage display with repeated multiple rows for the variable `$ 2. **Has MNodes?**: whether the current dnode is a mnode. 3. **CPU Cores**: the number of CPU cores. 4. **VNodes Number**: the number of VNodes in the current dnode. -5. **VNodes Masters**: the number of vnodes in the master role. +5. **VNodes Masters**: the number of vnodes in the leader role. 6. **Current CPU Usage of taosd**: CPU usage rate of taosd processes. 7. **Current Memory Usage of taosd**: memory usage of taosd processes. 8. **Disk Used**: The total disk usage percentage of the taosd data directory. diff --git a/docs/en/14-reference/12-directory.md b/docs/en/14-reference/12-directory.md index 304e3bcb43..d6cffd22e0 100644 --- a/docs/en/14-reference/12-directory.md +++ b/docs/en/14-reference/12-directory.md @@ -26,7 +26,6 @@ All executable files of TDengine are in the _/usr/local/taos/bin_ directory by d - _remove.sh_: script to uninstall TDengine, please execute it carefully, link to the **rmtaos** command in the /usr/bin directory. Will remove the TDengine installation directory `/usr/local/taos`, but will keep `/etc/taos`, `/var/lib/taos`, `/var/log/taos` - _taosadapter_: server-side executable that provides RESTful services and accepts writing requests from a variety of other softwares - _tarbitrator_: provides arbitration for two-node cluster deployments -- _run_taosd_and_taosadapter.sh_: script to start both taosd and taosAdapter - _TDinsight.sh_: script to download TDinsight and install it - _set_core.sh_: script for setting up the system to generate core dump files for easy debugging - _taosd-dump-cfg.gdb_: script to facilitate debugging of taosd's gdb execution. diff --git a/docs/en/21-tdinternal/01-arch.md b/docs/en/21-tdinternal/01-arch.md index 4d8bed4d2d..d7d472eb98 100644 --- a/docs/en/21-tdinternal/01-arch.md +++ b/docs/en/21-tdinternal/01-arch.md @@ -22,9 +22,9 @@ A complete TDengine system runs on one or more physical nodes. Logically, it inc **Virtual node (vnode)**: To better support data sharding, load balancing and prevent data from overheating or skewing, data nodes are virtualized into multiple virtual nodes (vnode, V2, V3, V4, etc. in the figure). Each vnode is a relatively independent work unit, which is the basic unit of time-series data storage and has independent running threads, memory space and persistent storage path. A vnode contains a certain number of tables (data collection points). When a new table is created, the system checks whether a new vnode needs to be created. The number of vnodes that can be created on a data node depends on the capacity of the hardware of the physical node where the data node is located. A vnode belongs to only one DB, but a DB can have multiple vnodes. In addition to the stored time-series data, a vnode also stores the schema and tag values of the included tables. A virtual node is uniquely identified in the system by the EP of the data node and the VGroup ID to which it belongs and is created and managed by the management node. -**Management node (mnode)**: A virtual logical unit responsible for monitoring and maintaining the running status of all data nodes and load balancing among nodes (M in the figure). At the same time, the management node is also responsible for the storage and management of metadata (including users, databases, tables, static tags, etc.), so it is also called Meta Node. Multiple (up to 5) mnodes can be configured in a TDengine cluster, and they are automatically constructed into a virtual management node group (M0, M1, M2 in the figure). The master/slave mechanism is adopted for the mnode group and the data synchronization is carried out in a strongly consistent way. Any data update operation can only be executed on the master. The creation of mnode cluster is completed automatically by the system without manual intervention. There is at most one mnode on each dnode, which is uniquely identified by the EP of the data node to which it belongs. Each dnode automatically obtains the EP of the dnode where all mnodes in the whole cluster are located, through internal messaging interaction. +**Management node (mnode)**: A virtual logical unit responsible for monitoring and maintaining the running status of all data nodes and load balancing among nodes (M in the figure). At the same time, the management node is also responsible for the storage and management of metadata (including users, databases, tables, static tags, etc.), so it is also called Meta Node. Multiple (up to 5) mnodes can be configured in a TDengine cluster, and they are automatically constructed into a virtual management node group (M0, M1, M2 in the figure). The leader/follower mechanism is adopted for the mnode group and the data synchronization is carried out in a strongly consistent way. Any data update operation can only be executed on the leader. The creation of mnode cluster is completed automatically by the system without manual intervention. There is at most one mnode on each dnode, which is uniquely identified by the EP of the data node to which it belongs. Each dnode automatically obtains the EP of the dnode where all mnodes in the whole cluster are located, through internal messaging interaction. -**Virtual node group (VGroup)**: Vnodes on different data nodes can form a virtual node group to ensure the high availability of the system. The virtual node group is managed in a master/slave mechanism. Write operations can only be performed on the master vnode, and then replicated to slave vnodes, thus ensuring that one single replica of data is copied on multiple physical nodes. The number of virtual nodes in a vgroup equals the number of data replicas. If the number of replicas of a DB is N, the system must have at least N data nodes. The number of replicas can be specified by the parameter `“replica”` when creating a DB, and the default is 1. Using the multi-replication feature of TDengine, the same high data reliability can be achieved without the need for expensive storage devices such as disk arrays. Virtual node groups are created and managed by the management node, and the management node assigns a system unique ID, aka VGroup ID. If two virtual nodes have the same vnode group ID, it means that they belong to the same group and the data is backed up to each other. The number of virtual nodes in a virtual node group can be dynamically changed, allowing only one, that is, no data replication. VGroup ID is never changed. Even if a virtual node group is deleted, its ID will not be reused. +**Virtual node group (VGroup)**: Vnodes on different data nodes can form a virtual node group to ensure the high availability of the system. The virtual node group is managed in a leader/follower mechanism. Write operations can only be performed on the leader vnode, and then replicated to follower vnodes, thus ensuring that one single replica of data is copied on multiple physical nodes. The number of virtual nodes in a vgroup equals the number of data replicas. If the number of replicas of a DB is N, the system must have at least N data nodes. The number of replicas can be specified by the parameter `“replica”` when creating a DB, and the default is 1. Using the multi-replication feature of TDengine, the same high data reliability can be achieved without the need for expensive storage devices such as disk arrays. Virtual node groups are created and managed by the management node, and the management node assigns a system unique ID, aka VGroup ID. If two virtual nodes have the same vnode group ID, it means that they belong to the same group and the data is backed up to each other. The number of virtual nodes in a virtual node group can be dynamically changed, allowing only one, that is, no data replication. VGroup ID is never changed. Even if a virtual node group is deleted, its ID will not be reused. **TAOSC**: TAOSC is the driver provided by TDengine to applications. It is responsible for dealing with the interaction between application and cluster, and provides the native interface for the C/C++ language. It is also embedded in the JDBC, C #, Python, Go, Node.js language connection libraries. Applications interact with the whole cluster through TAOSC instead of directly connecting to data nodes in the cluster. This module is responsible for obtaining and caching metadata; forwarding requests for insertion, query, etc. to the correct data node; when returning the results to the application, TAOSC also needs to be responsible for the final level of aggregation, sorting, filtering and other operations. For JDBC, C/C++/C#/Python/Go/Node.js interfaces, this module runs on the physical node where the application is located. At the same time, in order to support the fully distributed RESTful interface, TAOSC has a running instance on each dnode of TDengine cluster. @@ -62,13 +62,13 @@ To explain the relationship between vnode, mnode, TAOSC and application and thei 1. Application initiates a request to insert data through JDBC, ODBC, or other APIs. 2. TAOSC checks the cache to see if meta data exists for the table. If it does, it goes straight to Step 4. If not, TAOSC sends a get meta-data request to mnode. 3. Mnode returns the meta-data of the table to TAOSC. Meta-data contains the schema of the table, and also the vgroup information to which the table belongs (the vnode ID and the End Point of the dnode where the table belongs. If the number of replicas is N, there will be N groups of End Points). If TAOSC does not receive a response from the mnode for a long time, and there are multiple mnodes, TAOSC will send a request to the next mnode. -4. TAOSC initiates an insert request to master vnode. +4. TAOSC initiates an insert request to leader vnode. 5. After vnode inserts the data, it gives a reply to TAOSC, indicating that the insertion is successful. If TAOSC doesn't get a response from vnode for a long time, TAOSC will treat this node as offline. In this case, if there are multiple replicas of the inserted database, TAOSC will issue an insert request to the next vnode in vgroup. 6. TAOSC notifies APP that writing is successful. For Step 2 and 3, when TAOSC starts, it does not know the End Point of mnode, so it will directly initiate a request to the configured serving End Point of the cluster. If the dnode that receives the request does not have a mnode configured, it will reply with the mnode EP list, so that TAOSC will re-issue a request to obtain meta-data to the EP of another mnode. -For Step 4 and 5, without caching, TAOSC can't recognize the master in the virtual node group, so assumes that the first vnode is the master and sends a request to it. If this vnode is not the master, it will reply to the actual master as a new target to which TAOSC shall send a request. Once a response of successful insertion is obtained, TAOSC will cache the information of master node. +For Step 4 and 5, without caching, TAOSC can't recognize the leader in the virtual node group, so assumes that the first vnode is the leader and sends a request to it. If this vnode is not the leader, it will reply to the actual leader as a new target to which TAOSC shall send a request. Once a response of successful insertion is obtained, TAOSC will cache the information of leader node. The above describes the process of inserting data. The processes of querying and computing are the same. TAOSC encapsulates and hides all these complicated processes, and it is transparent to applications. @@ -119,65 +119,65 @@ The load balancing process does not require any manual intervention, and it is t ## Data Writing and Replication Process -If a database has N replicas, a virtual node group has N virtual nodes. But only one is the Master and all others are slaves. When the application writes a new record to system, only the Master vnode can accept the writing request. If a slave vnode receives a writing request, the system will notifies TAOSC to redirect. +If a database has N replicas, a virtual node group has N virtual nodes. But only one is the Leader and all others are slaves. When the application writes a new record to system, only the Leader vnode can accept the writing request. If a follower vnode receives a writing request, the system will notifies TAOSC to redirect. -### Master vnode Writing Process +### Leader vnode Writing Process -Master Vnode uses a writing process as follows: +Leader Vnode uses a writing process as follows: -![TDengine Database Master Writing Process](write_master.webp) -
Figure 3: TDengine Master writing process
+![TDengine Database Leader Writing Process](write_master.webp) +
Figure 3: TDengine Leader writing process
-1. Master vnode receives the application data insertion request, verifies, and moves to next step; +1. Leader vnode receives the application data insertion request, verifies, and moves to next step; 2. If the system configuration parameter `“walLevel”` is greater than 0, vnode will write the original request packet into database log file WAL. If walLevel is set to 2 and fsync is set to 0, TDengine will make WAL data written immediately to ensure that even system goes down, all data can be recovered from database log file; -3. If there are multiple replicas, vnode will forward data packet to slave vnodes in the same virtual node group, and the forwarded packet has a version number with data; +3. If there are multiple replicas, vnode will forward data packet to follower vnodes in the same virtual node group, and the forwarded packet has a version number with data; 4. Write into memory and add the record to “skip list”; -5. Master vnode returns a confirmation message to the application, indicating a successful write. +5. Leader vnode returns a confirmation message to the application, indicating a successful write. 6. If any of Step 2, 3 or 4 fails, the error will directly return to the application. -### Slave vnode Writing Process +### Follower vnode Writing Process -For a slave vnode, the write process as follows: +For a follower vnode, the write process as follows: -![TDengine Database Slave Writing Process](write_slave.webp) -
Figure 4: TDengine Slave Writing Process
+![TDengine Database Follower Writing Process](write_slave.webp) +
Figure 4: TDengine Follower Writing Process
-1. Slave vnode receives a data insertion request forwarded by Master vnode; +1. Follower vnode receives a data insertion request forwarded by Leader vnode; 2. If the system configuration parameter `“walLevel”` is greater than 0, vnode will write the original request packet into database log file WAL. If walLevel is set to 2 and fsync is set to 0, TDengine will make WAL data written immediately to ensure that even system goes down, all data can be recovered from database log file; 3. Write into memory and add the record to “skip list”. -Compared with Master vnode, slave vnode has no forwarding or reply confirmation step, means two steps less. But writing into memory and WAL is exactly the same. +Compared with Leader vnode, follower vnode has no forwarding or reply confirmation step, means two steps less. But writing into memory and WAL is exactly the same. ### Remote Disaster Recovery and IDC (Internet Data Center) Migration -As discussed above, TDengine writes using Master and Slave processes. TDengine adopts asynchronous replication for data synchronization. This method can greatly improve write performance, with no obvious impact from network delay. By configuring IDC and rack number for each physical node, it can be ensured that for a virtual node group, virtual nodes are composed of physical nodes from different IDC and different racks, thus implementing remote disaster recovery without other tools. +As discussed above, TDengine writes using Leader and Follower processes. TDengine adopts asynchronous replication for data synchronization. This method can greatly improve write performance, with no obvious impact from network delay. By configuring IDC and rack number for each physical node, it can be ensured that for a virtual node group, virtual nodes are composed of physical nodes from different IDC and different racks, thus implementing remote disaster recovery without other tools. -On the other hand, TDengine supports dynamic modification of the replica number. Once the number of replicas increases, the newly added virtual nodes will immediately enter the data synchronization process. After synchronization is complete, added virtual nodes can provide services. In the synchronization process, master and other synchronized virtual nodes keep serving. With this feature, TDengine can provide IDC migration without service interruption. It is only necessary to add new physical nodes to the existing IDC cluster, and then remove old physical nodes after the data synchronization is completed. +On the other hand, TDengine supports dynamic modification of the replica number. Once the number of replicas increases, the newly added virtual nodes will immediately enter the data synchronization process. After synchronization is complete, added virtual nodes can provide services. In the synchronization process, leader and other synchronized virtual nodes keep serving. With this feature, TDengine can provide IDC migration without service interruption. It is only necessary to add new physical nodes to the existing IDC cluster, and then remove old physical nodes after the data synchronization is completed. However, the asynchronous replication has a very low probability scenario where data may be lost. The specific scenario is as follows: -1. Master vnode has finished its 5-step operations, confirmed the success of writing to APP, and then goes down; -2. Slave vnode receives the write request, then processing fails before writing to the log in Step 2; -3. Slave vnode will become the new master, thus losing one record. +1. Leader vnode has finished its 5-step operations, confirmed the success of writing to APP, and then goes down; +2. Follower vnode receives the write request, then processing fails before writing to the log in Step 2; +3. Follower vnode will become the new leader, thus losing one record. In theory, for asynchronous replication, there is no guarantee to prevent data loss. However, this is an extremely low probability scenario as described above. Note: Remote disaster recovery and no-downtime IDC migration are only supported by Enterprise Edition. **Hint: This function is not available yet** -### Master/slave Selection +### Leader/follower Selection Vnode maintains a version number. When memory data is persisted, the version number will also be persisted. For each data update operation, whether it is time-series data or metadata, this version number will be increased by one. -When a vnode starts, the roles (master, slave) are uncertain, and the data is in an unsynchronized state. It’s necessary to establish TCP connections with other nodes in the virtual node group and exchange status, including version and its own roles. Through the exchange, the system implements a master-selection process. The rules are as follows: +When a vnode starts, the roles (leader, follower) are uncertain, and the data is in an unsynchronized state. It’s necessary to establish TCP connections with other nodes in the virtual node group and exchange status, including version and its own roles. Through the exchange, the system implements a leader-selection process. The rules are as follows: -1. If there’s only one replica, it’s always master -2. When all replicas are online, the one with latest version is master -3. Over half of online nodes are virtual nodes, and some virtual node is slave, it will automatically become master -4. For 2 and 3, if multiple virtual nodes meet the requirement, the first vnode in virtual node group list will be selected as master. +1. If there’s only one replica, it’s always leader +2. When all replicas are online, the one with latest version is leader +3. Over half of online nodes are virtual nodes, and some virtual node is follower, it will automatically become leader +4. For 2 and 3, if multiple virtual nodes meet the requirement, the first vnode in virtual node group list will be selected as leader. ### Synchronous Replication -For scenarios with strong data consistency requirements, asynchronous data replication is not applicable, because there is a small probability of data loss. So, TDengine provides a synchronous replication mechanism for users. When creating a database, in addition to specifying the number of replicas, user also needs to specify a new parameter “quorum”. If quorum is greater than one, it means that every time the Master forwards a message to the replica, it needs to wait for “quorum-1” reply confirms before informing the application that data has been successfully written in slave. If “quorum-1” reply confirms are not received within a certain period of time, the master vnode will return an error to the application. +For scenarios with strong data consistency requirements, asynchronous data replication is not applicable, because there is a small probability of data loss. So, TDengine provides a synchronous replication mechanism for users. When creating a database, in addition to specifying the number of replicas, user also needs to specify a new parameter “quorum”. If quorum is greater than one, it means that every time the Leader forwards a message to the replica, it needs to wait for “quorum-1” reply confirms before informing the application that data has been successfully written in follower. If “quorum-1” reply confirms are not received within a certain period of time, the leader vnode will return an error to the application. With synchronous replication, performance of system will decrease and latency will increase. Because metadata needs strong consistency, the default for data synchronization between mnodes is synchronous replication. diff --git a/docs/en/27-train-faq/03-docker.md b/docs/en/27-train-faq/03-docker.md index afee13c137..0378fffb8b 100644 --- a/docs/en/27-train-faq/03-docker.md +++ b/docs/en/27-train-faq/03-docker.md @@ -109,7 +109,7 @@ taos> It's also able to access the REST interface provided by TDengine in container from the host. ``` -curl -u root:taosdata -d 'show databases' 127.0.0.1:6041/rest/sql +curl -L -u root:taosdata -d "show databases" 127.0.0.1:6041/rest/sql ``` Output is like below: @@ -147,7 +147,7 @@ docker run -d --name tdengine-taosd -p 6030-6042:6030-6042 -p 6030-6042:6030-604 - Verify the REST interface: ```bash -curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' 127.0.0.1:6041/rest/sql +curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "show databases;" 127.0.0.1:6041/rest/sql ``` Below is an example output: diff --git a/docs/zh/14-reference/02-rest-api/02-rest-api.mdx b/docs/zh/14-reference/02-rest-api/02-rest-api.mdx index 43099319b9..a8a92606e4 100644 --- a/docs/zh/14-reference/02-rest-api/02-rest-api.mdx +++ b/docs/zh/14-reference/02-rest-api/02-rest-api.mdx @@ -21,7 +21,7 @@ RESTful 接口不依赖于任何 TDengine 的库,因此客户端不需要安 下面示例是列出所有的数据库,请把 h1.taosdata.com 和 6041(缺省值)替换为实际运行的 TDengine 服务 FQDN 和端口号: ```html -curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' h1.taosdata.com:6041/rest/sql +curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "show databases;" h1.taosdata.com:6041/rest/sql ``` 返回值结果如下表示验证通过: @@ -106,13 +106,13 @@ HTTP 请求的 BODY 里就是一个完整的 SQL 语句,SQL 语句中的数据 使用 `curl` 通过自定义身份认证方式来发起一个 HTTP Request,语法如下: ```bash -curl -H 'Authorization: Basic ' -d '' :/rest/sql/[db_name] +curl -L -H "Authorization: Basic " -d "" :/rest/sql/[db_name] ``` 或者 ```bash -curl -u username:password -d '' :/rest/sql/[db_name] +curl -L -u username:password -d "" :/rest/sql/[db_name] ``` 其中,`TOKEN` 为 `{username}:{password}` 经过 Base64 编码之后的字符串,例如 `root:taosdata` 编码后为 `cm9vdDp0YW9zZGF0YQ==` @@ -192,7 +192,7 @@ curl http://192.168.0.1:6041/rest/login/root/taosdata - 在 demo 库里查询表 d1001 的所有记录: ```bash - curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sql + curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.d1001" 192.168.0.1:6041/rest/sql ``` 返回值: @@ -218,7 +218,7 @@ curl http://192.168.0.1:6041/rest/login/root/taosdata - 创建库 demo: ```bash - curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'create database demo' 192.168.0.1:6041/rest/sql + curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "create database demo" 192.168.0.1:6041/rest/sql ``` 返回值: @@ -240,7 +240,7 @@ curl http://192.168.0.1:6041/rest/login/root/taosdata HTTP 请求 URL 采用 `/rest/sqlt` 时,返回结果集的时间戳将采用 Unix 时间戳格式表示,例如 ```bash -curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001' 192.168.0.1:6041/rest/sqlt +curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.d1001" 192.168.0.1:6041/rest/sqlt ``` 返回结果: @@ -268,7 +268,7 @@ curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.d1001 HTTP 请求 URL 采用 `/rest/sqlutc` 时,返回结果集的时间戳将采用 UTC 时间字符串表示,例如 ```bash - curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'select * from demo.t1' 192.168.0.1:6041/rest/sqlutc + curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "select * from demo.t1" 192.168.0.1:6041/rest/sqlutc ``` 返回值: diff --git a/docs/zh/14-reference/12-directory.md b/docs/zh/14-reference/12-directory.md index f8c8cb4a08..0caf7e03c3 100644 --- a/docs/zh/14-reference/12-directory.md +++ b/docs/zh/14-reference/12-directory.md @@ -26,7 +26,6 @@ TDengine 的所有可执行文件默认存放在 _/usr/local/taos/bin_ 目录下 - _remove.sh_:卸载 TDengine 的脚本,请谨慎执行,链接到/usr/bin 目录下的**rmtaos**命令。会删除 TDengine 的安装目录/usr/local/taos,但会保留/etc/taos、/var/lib/taos、/var/log/taos - _taosadapter_: 提供 RESTful 服务和接受其他多种软件写入请求的服务端可执行文件 - _tarbitrator_: 提供双节点集群部署的仲裁功能 -- _run_taosd_and_taosadapter.sh_:同时启动 taosd 和 taosAdapter 的脚本 - _TDinsight.sh_:用于下载 TDinsight 并安装的脚本 - _set_core.sh_:用于方便调试设置系统生成 core dump 文件的脚本 - _taosd-dump-cfg.gdb_:用于方便调试 taosd 的 gdb 执行脚本。 diff --git a/docs/zh/27-train-faq/03-docker.md b/docs/zh/27-train-faq/03-docker.md index 7791569b25..72b4603dda 100644 --- a/docs/zh/27-train-faq/03-docker.md +++ b/docs/zh/27-train-faq/03-docker.md @@ -108,7 +108,7 @@ taos> 也可以在宿主机使用 curl 通过 RESTful 端口访问 Docker 容器内的 TDengine server。 ``` -curl -u root:taosdata -d 'show databases' 127.0.0.1:6041/rest/sql +curl -L -u root:taosdata -d "show databases" 127.0.0.1:6041/rest/sql ``` 输出示例如下: @@ -148,7 +148,7 @@ docker run -d --name tdengine-taosd -p 6030-6042:6030-6042 -p 6030-6042:6030-604 使用 curl 命令验证 RESTful 接口可以正常工作: ```bash -curl -H 'Authorization: Basic cm9vdDp0YW9zZGF0YQ==' -d 'show databases;' 127.0.0.1:6041/rest/sql +curl -L -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -d "show databases;" 127.0.0.1:6041/rest/sql ``` 输出示例如下: diff --git a/examples/c/stream_demo.c b/examples/c/stream_demo.c index 5f6e3b2aeb..961eb6c93a 100644 --- a/examples/c/stream_demo.c +++ b/examples/c/stream_demo.c @@ -90,9 +90,10 @@ int32_t create_stream() { /*const char* sql = "select min(k), max(k), sum(k) as sum_of_k from st1";*/ /*const char* sql = "select sum(k) from tu1 interval(10m)";*/ /*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/ - pRes = taos_query(pConn, - "create stream stream1 trigger window_close into outstb as select _wstartts, sum(k) from st1 " - "interval(10s) "); + pRes = taos_query( + pConn, + "create stream stream1 trigger window_close watermark 10s into outstb as select _wstartts, sum(k) from st1 " + "interval(10s) "); if (taos_errno(pRes) != 0) { printf("failed to create stream stream1, reason:%s\n", taos_errstr(pRes)); return -1; diff --git a/include/client/taos.h b/include/client/taos.h index 61538e392a..9d4da221f4 100644 --- a/include/client/taos.h +++ b/include/client/taos.h @@ -187,8 +187,8 @@ DLL_EXPORT TAOS_ROW *taos_result_block(TAOS_RES *res); DLL_EXPORT const char *taos_get_server_info(TAOS *taos); DLL_EXPORT const char *taos_get_client_info(); -DLL_EXPORT const char *taos_errstr(TAOS_RES *tres); -DLL_EXPORT int taos_errno(TAOS_RES *tres); +DLL_EXPORT const char *taos_errstr(TAOS_RES *res); +DLL_EXPORT int taos_errno(TAOS_RES *res); DLL_EXPORT void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param); DLL_EXPORT void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param); @@ -252,6 +252,16 @@ DLL_EXPORT void tmq_conf_set_auto_commit_cb(tmq_conf_t *conf, tmq_comm /* -------------------------TMQ MSG HANDLE INTERFACE---------------------- */ +enum tmq_res_t { + TMQ_RES_INVALID = -1, + TMQ_RES_DATA = 1, + TMQ_RES_TABLE_META = 2, +}; + +typedef enum tmq_res_t tmq_res_t; + +DLL_EXPORT tmq_res_t tmq_get_res_type(TAOS_RES *res); +DLL_EXPORT int32_t tmq_get_raw_meta(TAOS_RES *res, const void **raw_meta, int32_t *raw_meta_len); DLL_EXPORT const char *tmq_get_topic_name(TAOS_RES *res); DLL_EXPORT const char *tmq_get_db_name(TAOS_RES *res); DLL_EXPORT int32_t tmq_get_vgroup_id(TAOS_RES *res); diff --git a/include/common/tcommon.h b/include/common/tcommon.h index a05287761e..1b32dc26f5 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -34,6 +34,7 @@ enum { enum { TMQ_MSG_TYPE__DUMMY = 0, TMQ_MSG_TYPE__POLL_RSP, + TMQ_MSG_TYPE__POLL_META_RSP, TMQ_MSG_TYPE__EP_RSP, TMQ_MSG_TYPE__END_RSP, }; @@ -44,6 +45,8 @@ typedef enum EStreamType { STREAM_REPROCESS, STREAM_INVALID, STREAM_GET_ALL, + STREAM_DELETE, + STREAM_RETRIEVE, } EStreamType; typedef struct { diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 08e5d2ab7d..f654d523f3 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -168,7 +168,7 @@ typedef struct { int32_t vgId; char* dbFName; char* tbName; -} SBuildTableMetaInput; +} SBuildTableInput; typedef struct { char db[TSDB_DB_FNAME_LEN]; @@ -444,6 +444,7 @@ typedef struct { char* comment; char* pAst1; char* pAst2; + SArray* pFuncs; } SMCreateStbReq; int32_t tSerializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq); @@ -667,6 +668,41 @@ int32_t tSerializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp int32_t tDeserializeSQueryTableRsp(void* buf, int32_t bufLen, SQueryTableRsp* pRsp); +typedef struct { + SMsgHead header; + char dbFName[TSDB_DB_FNAME_LEN]; + char tbName[TSDB_TABLE_NAME_LEN]; +} STableCfgReq; + +typedef struct { + char tbName[TSDB_TABLE_NAME_LEN]; + char stbName[TSDB_TABLE_NAME_LEN]; + char dbFName[TSDB_DB_FNAME_LEN]; + int32_t numOfTags; + int32_t numOfColumns; + int8_t tableType; + int64_t delay1; + int64_t delay2; + int64_t watermark1; + int64_t watermark2; + int32_t ttl; + SArray* pFuncs; + int32_t commentLen; + char* pComment; + SSchema* pSchemas; + int32_t tagsLen; + char* pTags; +} STableCfg; + +typedef STableCfg STableCfgRsp; + +int32_t tSerializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq); +int32_t tDeserializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq); + +int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp); +int32_t tDeserializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp); +void tFreeSTableCfgRsp(STableCfgRsp *pRsp); + typedef struct { char db[TSDB_DB_FNAME_LEN]; int32_t numOfVgroups; @@ -1174,6 +1210,13 @@ typedef struct { char* data; } STagData; +typedef struct { + int32_t useless; // useless +} SShowVariablesReq; + +int32_t tSerializeSShowVariablesReq(void* buf, int32_t bufLen, SShowVariablesReq* pReq); +int32_t tDeserializeSShowVariablesReq(void* buf, int32_t bufLen, SShowVariablesReq* pReq); + /* * sql: show tables like '%a_%' * payload is the query condition, e.g., '%a_%' @@ -1560,6 +1603,7 @@ typedef struct { char name[TSDB_TOPIC_FNAME_LEN]; // accout.topic int8_t igExists; int8_t subType; + int8_t withMeta; char* sql; char subDbName[TSDB_DB_FNAME_LEN]; union { @@ -2306,6 +2350,7 @@ typedef struct { int64_t newConsumerId; char subKey[TSDB_SUBSCRIBE_KEY_LEN]; int8_t subType; + int8_t withMeta; char* qmsg; int64_t suid; } SMqRebVgReq; @@ -2318,6 +2363,7 @@ static FORCE_INLINE int32_t tEncodeSMqRebVgReq(void** buf, const SMqRebVgReq* pR tlen += taosEncodeFixedI64(buf, pReq->newConsumerId); tlen += taosEncodeString(buf, pReq->subKey); tlen += taosEncodeFixedI8(buf, pReq->subType); + tlen += taosEncodeFixedI8(buf, pReq->withMeta); if (pReq->subType == TOPIC_SUB_TYPE__COLUMN) { tlen += taosEncodeString(buf, pReq->qmsg); } else if (pReq->subType == TOPIC_SUB_TYPE__TABLE) { @@ -2333,6 +2379,7 @@ static FORCE_INLINE void* tDecodeSMqRebVgReq(const void* buf, SMqRebVgReq* pReq) buf = taosDecodeFixedI64(buf, &pReq->newConsumerId); buf = taosDecodeStringTo(buf, pReq->subKey); buf = taosDecodeFixedI8(buf, &pReq->subType); + buf = taosDecodeFixedI8(buf, &pReq->withMeta); if (pReq->subType == TOPIC_SUB_TYPE__COLUMN) { buf = taosDecodeString(buf, &pReq->qmsg); } else if (pReq->subType == TOPIC_SUB_TYPE__TABLE) { @@ -2677,6 +2724,34 @@ static FORCE_INLINE void tDeleteSMqSubTopicEp(SMqSubTopicEp* pSubTopicEp) { taosArrayDestroy(pSubTopicEp->vgs); } +typedef struct { + SMqRspHead head; + int64_t reqOffset; + int64_t rspOffset; + int16_t resMsgType; + int32_t metaRspLen; + void* metaRsp; +} SMqMetaRsp; + +static FORCE_INLINE int32_t tEncodeSMqMetaRsp(void** buf, const SMqMetaRsp* pRsp) { + int32_t tlen = 0; + tlen += taosEncodeFixedI64(buf, pRsp->reqOffset); + tlen += taosEncodeFixedI64(buf, pRsp->rspOffset); + tlen += taosEncodeFixedI16(buf, pRsp->resMsgType); + tlen += taosEncodeFixedI32(buf, pRsp->metaRspLen); + tlen += taosEncodeBinary(buf, pRsp->metaRsp, pRsp->metaRspLen); + return tlen; +} + +static FORCE_INLINE void* tDecodeSMqMetaRsp(const void* buf, SMqMetaRsp* pRsp) { + buf = taosDecodeFixedI64(buf, &pRsp->reqOffset); + buf = taosDecodeFixedI64(buf, &pRsp->rspOffset); + buf = taosDecodeFixedI16(buf, &pRsp->resMsgType); + buf = taosDecodeFixedI32(buf, &pRsp->metaRspLen); + buf = taosDecodeBinary(buf, &pRsp->metaRsp, pRsp->metaRspLen); + return (void*)buf; +} + typedef struct { SMqRspHead head; int64_t reqOffset; diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index eeac619105..4105774739 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -131,6 +131,7 @@ enum { TD_DEF_MSG_TYPE(TDMT_MND_DROP_INDEX, "drop-index", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_GET_INDEX, "get-index", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_GET_TABLE_INDEX, "get-table-index", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_TABLE_CFG, "table-cfg", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_CREATE_TOPIC, "create-topic", SMCreateTopicReq, SMCreateTopicRsp) TD_DEF_MSG_TYPE(TDMT_MND_ALTER_TOPIC, "alter-topic", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_DROP_TOPIC, "drop-topic", NULL, NULL) @@ -158,6 +159,7 @@ enum { TD_DEF_MSG_TYPE(TDMT_MND_MERGE_VGROUP, "merge-vgroup", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_REDISTRIBUTE_VGROUP, "redistribute-vgroup", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_SPLIT_VGROUP, "split-vgroup", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_SHOW_VARIABLES, "show-variables", NULL, NULL) TD_NEW_MSG_SEG(TDMT_VND_MSG) TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp) @@ -171,6 +173,7 @@ enum { TD_DEF_MSG_TYPE(TDMT_VND_UPDATE_TAG_VAL, "update-tag-val", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_TABLE_META, "vnode-table-meta", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_TABLES_META, "vnode-tables-meta", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_VND_TABLE_CFG, "vnode-table-cfg", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_CREATE_STB, "vnode-create-stb", SVCreateStbReq, NULL) TD_DEF_MSG_TYPE(TDMT_VND_ALTER_STB, "vnode-alter-stb", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_DROP_STB, "vnode-drop-stb", SVDropStbReq, NULL) @@ -187,7 +190,6 @@ enum { TD_DEF_MSG_TYPE(TDMT_VND_CONSUME, "vnode-consume", SMqPollReq, SMqDataBlkRsp) TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TRIGGER, "vnode-stream-trigger", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_STREAM_DISPATCH_WRITE, "vnode-stream-task-dispatch-write", NULL, NULL) - TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_DROP, "vnode-stream-task-drop", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_CREATE_SMA, "vnode-create-sma", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_CANCEL_SMA, "vnode-cancel-sma", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_DROP_SMA, "vnode-drop-sma", NULL, NULL) @@ -199,14 +201,14 @@ enum { TD_DEF_MSG_TYPE(TDMT_VND_ALTER_HASHRANGE, "alter-hashrange", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_COMPACT, "compact", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_DROP_TTL_TABLE, "drop-ttl-stb", NULL, NULL) - TD_NEW_MSG_SEG(TDMT_QND_MSG) - //shared by snode and vnode TD_NEW_MSG_SEG(TDMT_STREAM_MSG) TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_DEPLOY, "stream-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp) + TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_DROP, "stream-task-drop", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_RUN, "stream-task-run", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_DISPATCH, "stream-task-dispatch", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_RECOVER, "stream-task-recover", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_STREAM_RETRIEVE, "stream-retrieve", NULL, NULL) TD_NEW_MSG_SEG(TDMT_SCH_MSG) TD_DEF_MSG_TYPE(TDMT_SCH_LINK_BROKEN, "link-broken", NULL, NULL) diff --git a/include/common/tname.h b/include/common/tname.h index 28f97d1028..c691c2f7b2 100644 --- a/include/common/tname.h +++ b/include/common/tname.h @@ -63,6 +63,8 @@ int32_t tNameSetAcctId(SName* dst, int32_t acctId); bool tNameDBNameEqual(SName* left, SName* right); +bool tNameTbNameEqual(SName* left, SName* right); + typedef struct { // input SArray* tags; // element is SSmlKv diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 35b4a5ce7d..8e00119876 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -49,214 +49,216 @@ #define TK_CONNS 31 #define TK_STATE 32 #define TK_USER 33 -#define TK_PRIVILEGE 34 -#define TK_DROP 35 -#define TK_GRANT 36 -#define TK_ON 37 -#define TK_TO 38 -#define TK_REVOKE 39 -#define TK_FROM 40 -#define TK_NK_COMMA 41 -#define TK_READ 42 -#define TK_WRITE 43 -#define TK_NK_DOT 44 -#define TK_DNODE 45 -#define TK_PORT 46 -#define TK_NK_INTEGER 47 -#define TK_DNODES 48 -#define TK_NK_IPTOKEN 49 -#define TK_LOCAL 50 -#define TK_QNODE 51 -#define TK_BNODE 52 -#define TK_SNODE 53 -#define TK_MNODE 54 -#define TK_DATABASE 55 -#define TK_USE 56 -#define TK_IF 57 -#define TK_NOT 58 -#define TK_EXISTS 59 -#define TK_BUFFER 60 -#define TK_CACHELAST 61 -#define TK_COMP 62 -#define TK_DURATION 63 -#define TK_NK_VARIABLE 64 -#define TK_FSYNC 65 -#define TK_MAXROWS 66 -#define TK_MINROWS 67 -#define TK_KEEP 68 -#define TK_PAGES 69 -#define TK_PAGESIZE 70 -#define TK_PRECISION 71 -#define TK_REPLICA 72 -#define TK_STRICT 73 -#define TK_WAL 74 -#define TK_VGROUPS 75 -#define TK_SINGLE_STABLE 76 -#define TK_RETENTIONS 77 -#define TK_SCHEMALESS 78 -#define TK_NK_COLON 79 -#define TK_TABLE 80 -#define TK_NK_LP 81 -#define TK_NK_RP 82 -#define TK_STABLE 83 -#define TK_ADD 84 -#define TK_COLUMN 85 -#define TK_MODIFY 86 -#define TK_RENAME 87 -#define TK_TAG 88 -#define TK_SET 89 -#define TK_NK_EQ 90 -#define TK_USING 91 -#define TK_TAGS 92 -#define TK_COMMENT 93 -#define TK_BOOL 94 -#define TK_TINYINT 95 -#define TK_SMALLINT 96 -#define TK_INT 97 -#define TK_INTEGER 98 -#define TK_BIGINT 99 -#define TK_FLOAT 100 -#define TK_DOUBLE 101 -#define TK_BINARY 102 -#define TK_TIMESTAMP 103 -#define TK_NCHAR 104 -#define TK_UNSIGNED 105 -#define TK_JSON 106 -#define TK_VARCHAR 107 -#define TK_MEDIUMBLOB 108 -#define TK_BLOB 109 -#define TK_VARBINARY 110 -#define TK_DECIMAL 111 -#define TK_MAX_DELAY 112 -#define TK_WATERMARK 113 -#define TK_ROLLUP 114 -#define TK_TTL 115 -#define TK_SMA 116 -#define TK_FIRST 117 -#define TK_LAST 118 -#define TK_SHOW 119 -#define TK_DATABASES 120 -#define TK_TABLES 121 -#define TK_STABLES 122 -#define TK_MNODES 123 -#define TK_MODULES 124 -#define TK_QNODES 125 -#define TK_FUNCTIONS 126 -#define TK_INDEXES 127 -#define TK_ACCOUNTS 128 -#define TK_APPS 129 -#define TK_CONNECTIONS 130 -#define TK_LICENCE 131 -#define TK_GRANTS 132 -#define TK_QUERIES 133 -#define TK_SCORES 134 -#define TK_TOPICS 135 -#define TK_VARIABLES 136 -#define TK_BNODES 137 -#define TK_SNODES 138 -#define TK_CLUSTER 139 -#define TK_TRANSACTIONS 140 -#define TK_DISTRIBUTED 141 -#define TK_LIKE 142 -#define TK_INDEX 143 -#define TK_FULLTEXT 144 +#define TK_ENABLE 34 +#define TK_NK_INTEGER 35 +#define TK_SYSINFO 36 +#define TK_DROP 37 +#define TK_GRANT 38 +#define TK_ON 39 +#define TK_TO 40 +#define TK_REVOKE 41 +#define TK_FROM 42 +#define TK_NK_COMMA 43 +#define TK_READ 44 +#define TK_WRITE 45 +#define TK_NK_DOT 46 +#define TK_DNODE 47 +#define TK_PORT 48 +#define TK_DNODES 49 +#define TK_NK_IPTOKEN 50 +#define TK_LOCAL 51 +#define TK_QNODE 52 +#define TK_BNODE 53 +#define TK_SNODE 54 +#define TK_MNODE 55 +#define TK_DATABASE 56 +#define TK_USE 57 +#define TK_IF 58 +#define TK_NOT 59 +#define TK_EXISTS 60 +#define TK_BUFFER 61 +#define TK_CACHELAST 62 +#define TK_COMP 63 +#define TK_DURATION 64 +#define TK_NK_VARIABLE 65 +#define TK_FSYNC 66 +#define TK_MAXROWS 67 +#define TK_MINROWS 68 +#define TK_KEEP 69 +#define TK_PAGES 70 +#define TK_PAGESIZE 71 +#define TK_PRECISION 72 +#define TK_REPLICA 73 +#define TK_STRICT 74 +#define TK_WAL 75 +#define TK_VGROUPS 76 +#define TK_SINGLE_STABLE 77 +#define TK_RETENTIONS 78 +#define TK_SCHEMALESS 79 +#define TK_NK_COLON 80 +#define TK_TABLE 81 +#define TK_NK_LP 82 +#define TK_NK_RP 83 +#define TK_STABLE 84 +#define TK_ADD 85 +#define TK_COLUMN 86 +#define TK_MODIFY 87 +#define TK_RENAME 88 +#define TK_TAG 89 +#define TK_SET 90 +#define TK_NK_EQ 91 +#define TK_USING 92 +#define TK_TAGS 93 +#define TK_COMMENT 94 +#define TK_BOOL 95 +#define TK_TINYINT 96 +#define TK_SMALLINT 97 +#define TK_INT 98 +#define TK_INTEGER 99 +#define TK_BIGINT 100 +#define TK_FLOAT 101 +#define TK_DOUBLE 102 +#define TK_BINARY 103 +#define TK_TIMESTAMP 104 +#define TK_NCHAR 105 +#define TK_UNSIGNED 106 +#define TK_JSON 107 +#define TK_VARCHAR 108 +#define TK_MEDIUMBLOB 109 +#define TK_BLOB 110 +#define TK_VARBINARY 111 +#define TK_DECIMAL 112 +#define TK_MAX_DELAY 113 +#define TK_WATERMARK 114 +#define TK_ROLLUP 115 +#define TK_TTL 116 +#define TK_SMA 117 +#define TK_FIRST 118 +#define TK_LAST 119 +#define TK_SHOW 120 +#define TK_DATABASES 121 +#define TK_TABLES 122 +#define TK_STABLES 123 +#define TK_MNODES 124 +#define TK_MODULES 125 +#define TK_QNODES 126 +#define TK_FUNCTIONS 127 +#define TK_INDEXES 128 +#define TK_ACCOUNTS 129 +#define TK_APPS 130 +#define TK_CONNECTIONS 131 +#define TK_LICENCE 132 +#define TK_GRANTS 133 +#define TK_QUERIES 134 +#define TK_SCORES 135 +#define TK_TOPICS 136 +#define TK_VARIABLES 137 +#define TK_BNODES 138 +#define TK_SNODES 139 +#define TK_CLUSTER 140 +#define TK_TRANSACTIONS 141 +#define TK_DISTRIBUTED 142 +#define TK_LIKE 143 +#define TK_INDEX 144 #define TK_FUNCTION 145 #define TK_INTERVAL 146 #define TK_TOPIC 147 #define TK_AS 148 -#define TK_CONSUMER 149 -#define TK_GROUP 150 -#define TK_DESC 151 -#define TK_DESCRIBE 152 -#define TK_RESET 153 -#define TK_QUERY 154 -#define TK_CACHE 155 -#define TK_EXPLAIN 156 -#define TK_ANALYZE 157 -#define TK_VERBOSE 158 -#define TK_NK_BOOL 159 -#define TK_RATIO 160 -#define TK_NK_FLOAT 161 -#define TK_COMPACT 162 -#define TK_VNODES 163 -#define TK_IN 164 -#define TK_OUTPUTTYPE 165 -#define TK_AGGREGATE 166 -#define TK_BUFSIZE 167 -#define TK_STREAM 168 -#define TK_INTO 169 -#define TK_TRIGGER 170 -#define TK_AT_ONCE 171 -#define TK_WINDOW_CLOSE 172 -#define TK_KILL 173 -#define TK_CONNECTION 174 -#define TK_TRANSACTION 175 -#define TK_BALANCE 176 -#define TK_VGROUP 177 -#define TK_MERGE 178 -#define TK_REDISTRIBUTE 179 -#define TK_SPLIT 180 -#define TK_SYNCDB 181 -#define TK_DELETE 182 -#define TK_NULL 183 -#define TK_NK_QUESTION 184 -#define TK_NK_ARROW 185 -#define TK_ROWTS 186 -#define TK_TBNAME 187 -#define TK_QSTARTTS 188 -#define TK_QENDTS 189 -#define TK_WSTARTTS 190 -#define TK_WENDTS 191 -#define TK_WDURATION 192 -#define TK_CAST 193 -#define TK_NOW 194 -#define TK_TODAY 195 -#define TK_TIMEZONE 196 -#define TK_COUNT 197 -#define TK_LAST_ROW 198 -#define TK_BETWEEN 199 -#define TK_IS 200 -#define TK_NK_LT 201 -#define TK_NK_GT 202 -#define TK_NK_LE 203 -#define TK_NK_GE 204 -#define TK_NK_NE 205 -#define TK_MATCH 206 -#define TK_NMATCH 207 -#define TK_CONTAINS 208 -#define TK_JOIN 209 -#define TK_INNER 210 -#define TK_SELECT 211 -#define TK_DISTINCT 212 -#define TK_WHERE 213 -#define TK_PARTITION 214 -#define TK_BY 215 -#define TK_SESSION 216 -#define TK_STATE_WINDOW 217 -#define TK_SLIDING 218 -#define TK_FILL 219 -#define TK_VALUE 220 -#define TK_NONE 221 -#define TK_PREV 222 -#define TK_LINEAR 223 -#define TK_NEXT 224 -#define TK_HAVING 225 -#define TK_RANGE 226 -#define TK_EVERY 227 -#define TK_ORDER 228 -#define TK_SLIMIT 229 -#define TK_SOFFSET 230 -#define TK_LIMIT 231 -#define TK_OFFSET 232 -#define TK_ASC 233 -#define TK_NULLS 234 -#define TK_ID 235 -#define TK_NK_BITNOT 236 -#define TK_INSERT 237 -#define TK_VALUES 238 -#define TK_IMPORT 239 -#define TK_NK_SEMI 240 -#define TK_FILE 241 +#define TK_WITH 149 +#define TK_META 150 +#define TK_CONSUMER 151 +#define TK_GROUP 152 +#define TK_DESC 153 +#define TK_DESCRIBE 154 +#define TK_RESET 155 +#define TK_QUERY 156 +#define TK_CACHE 157 +#define TK_EXPLAIN 158 +#define TK_ANALYZE 159 +#define TK_VERBOSE 160 +#define TK_NK_BOOL 161 +#define TK_RATIO 162 +#define TK_NK_FLOAT 163 +#define TK_COMPACT 164 +#define TK_VNODES 165 +#define TK_IN 166 +#define TK_OUTPUTTYPE 167 +#define TK_AGGREGATE 168 +#define TK_BUFSIZE 169 +#define TK_STREAM 170 +#define TK_INTO 171 +#define TK_TRIGGER 172 +#define TK_AT_ONCE 173 +#define TK_WINDOW_CLOSE 174 +#define TK_KILL 175 +#define TK_CONNECTION 176 +#define TK_TRANSACTION 177 +#define TK_BALANCE 178 +#define TK_VGROUP 179 +#define TK_MERGE 180 +#define TK_REDISTRIBUTE 181 +#define TK_SPLIT 182 +#define TK_SYNCDB 183 +#define TK_DELETE 184 +#define TK_NULL 185 +#define TK_NK_QUESTION 186 +#define TK_NK_ARROW 187 +#define TK_ROWTS 188 +#define TK_TBNAME 189 +#define TK_QSTARTTS 190 +#define TK_QENDTS 191 +#define TK_WSTARTTS 192 +#define TK_WENDTS 193 +#define TK_WDURATION 194 +#define TK_CAST 195 +#define TK_NOW 196 +#define TK_TODAY 197 +#define TK_TIMEZONE 198 +#define TK_COUNT 199 +#define TK_LAST_ROW 200 +#define TK_BETWEEN 201 +#define TK_IS 202 +#define TK_NK_LT 203 +#define TK_NK_GT 204 +#define TK_NK_LE 205 +#define TK_NK_GE 206 +#define TK_NK_NE 207 +#define TK_MATCH 208 +#define TK_NMATCH 209 +#define TK_CONTAINS 210 +#define TK_JOIN 211 +#define TK_INNER 212 +#define TK_SELECT 213 +#define TK_DISTINCT 214 +#define TK_WHERE 215 +#define TK_PARTITION 216 +#define TK_BY 217 +#define TK_SESSION 218 +#define TK_STATE_WINDOW 219 +#define TK_SLIDING 220 +#define TK_FILL 221 +#define TK_VALUE 222 +#define TK_NONE 223 +#define TK_PREV 224 +#define TK_LINEAR 225 +#define TK_NEXT 226 +#define TK_HAVING 227 +#define TK_RANGE 228 +#define TK_EVERY 229 +#define TK_ORDER 230 +#define TK_SLIMIT 231 +#define TK_SOFFSET 232 +#define TK_LIMIT 233 +#define TK_OFFSET 234 +#define TK_ASC 235 +#define TK_NULLS 236 +#define TK_ID 237 +#define TK_NK_BITNOT 238 +#define TK_INSERT 239 +#define TK_VALUES 240 +#define TK_IMPORT 241 +#define TK_NK_SEMI 242 +#define TK_FILE 243 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/libs/catalog/catalog.h b/include/libs/catalog/catalog.h index 0c720138bd..20f4765190 100644 --- a/include/libs/catalog/catalog.h +++ b/include/libs/catalog/catalog.h @@ -68,6 +68,7 @@ typedef struct SCatalogReq { SArray* pIndex; // element is index name SArray* pUser; // element is SUserAuthInfo SArray* pTableIndex; // element is SNAME + SArray* pTableCfg; // element is SNAME bool qNodeRequired; // valid qnode bool dNodeRequired; // valid dnode bool forceUpdate; @@ -89,6 +90,7 @@ typedef struct SMetaData { SArray* pIndex; // pRes = SIndexInfo* SArray* pUser; // pRes = bool* SArray* pQnodeList; // pRes = SArray* + SArray* pTableCfg; // pRes = STableCfg* SArray* pDnodeList; // pRes = SArray* } SMetaData; @@ -284,6 +286,8 @@ int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const char* int32_t catalogGetTableIndex(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes); +int32_t catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg** pCfg); + int32_t catalogUpdateTableIndex(SCatalog* pCtg, STableIndexRsp *pRsp); int32_t catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* funcName, SFuncInfo* pInfo); diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index cbaff29cb2..1f314d19e7 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -190,6 +190,7 @@ bool fmIsForbidWindowFunc(int32_t funcId); bool fmIsForbidGroupByFunc(int32_t funcId); bool fmIsIntervalInterpoFunc(int32_t funcId); bool fmIsInterpFunc(int32_t funcId); +bool fmIsLastRowFunc(int32_t funcId); int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc); diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 4578087164..18ddcbcd94 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -28,6 +28,15 @@ extern "C" { #define DESCRIBE_RESULT_TYPE_LEN (20 + VARSTR_HEADER_SIZE) #define DESCRIBE_RESULT_NOTE_LEN (8 + VARSTR_HEADER_SIZE) +#define SHOW_CREATE_DB_RESULT_COLS 2 +#define SHOW_CREATE_DB_RESULT_FIELD1_LEN (TSDB_DB_NAME_LEN + VARSTR_HEADER_SIZE) +#define SHOW_CREATE_DB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE) + +#define SHOW_CREATE_TB_RESULT_COLS 2 +#define SHOW_CREATE_TB_RESULT_FIELD1_LEN (TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE) +#define SHOW_CREATE_TB_RESULT_FIELD2_LEN (TSDB_MAX_BINARY_LEN + VARSTR_HEADER_SIZE) + + #define PRIVILEGE_TYPE_MASK(n) (1 << n) #define PRIVILEGE_TYPE_ALL PRIVILEGE_TYPE_MASK(0) @@ -170,13 +179,16 @@ typedef struct SCreateUserStmt { ENodeType type; char useName[TSDB_USER_LEN]; char password[TSDB_USET_PASSWORD_LEN]; + int8_t sysinfo; } SCreateUserStmt; typedef struct SAlterUserStmt { ENodeType type; char useName[TSDB_USER_LEN]; - char password[TSDB_USET_PASSWORD_LEN]; int8_t alterType; + char password[TSDB_USET_PASSWORD_LEN]; + int8_t enable; + int8_t sysinfo; } SAlterUserStmt; typedef struct SDropUserStmt { @@ -221,7 +233,7 @@ typedef struct SShowCreateTableStmt { ENodeType type; char dbName[TSDB_DB_NAME_LEN]; char tableName[TSDB_TABLE_NAME_LEN]; - STableMeta* pMeta; + void* pCfg; // STableCfg } SShowCreateTableStmt; typedef struct SShowTableDistributedStmt { @@ -259,7 +271,6 @@ typedef struct SDropIndexStmt { ENodeType type; bool ignoreNotExists; char indexName[TSDB_INDEX_NAME_LEN]; - char tableName[TSDB_TABLE_NAME_LEN]; } SDropIndexStmt; typedef struct SCreateComponentNodeStmt { @@ -278,6 +289,7 @@ typedef struct SCreateTopicStmt { char subDbName[TSDB_DB_NAME_LEN]; char subSTbName[TSDB_TABLE_NAME_LEN]; bool ignoreExists; + bool withMeta; SNode* pQuery; } SCreateTopicStmt; diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 58e2393970..26a100bb1b 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -59,10 +59,10 @@ extern "C" { for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); \ (NULL != cell ? (node = &(cell->pNode), true) : (node = NULL, false)); cell = cell->pNext) -#define DESTORY_LIST(list) \ - do { \ - nodesDestroyList((list)); \ - (list) = NULL; \ +#define NODES_DESTORY_LIST(list) \ + do { \ + nodesDestroyList((list)); \ + (list) = NULL; \ } while (0) #define NODES_CLEAR_LIST(list) \ @@ -219,6 +219,7 @@ typedef enum ENodeType { QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN, QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN, + QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN, QUERY_NODE_PHYSICAL_PLAN_PROJECT, QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN, QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, @@ -227,6 +228,7 @@ typedef enum ENodeType { QUERY_NODE_PHYSICAL_PLAN_SORT, QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL, QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL, + QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL, QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL, QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL, QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL, diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index b07e8f39d5..cb09bf6a5f 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -40,7 +40,8 @@ typedef enum EScanType { SCAN_TYPE_SYSTEM_TABLE, SCAN_TYPE_STREAM, SCAN_TYPE_TABLE_MERGE, - SCAN_TYPE_BLOCK_INFO + SCAN_TYPE_BLOCK_INFO, + SCAN_TYPE_LAST_ROW } EScanType; typedef struct SScanLogicNode { @@ -260,6 +261,7 @@ typedef struct SScanPhysiNode { typedef SScanPhysiNode STagScanPhysiNode; typedef SScanPhysiNode SBlockDistScanPhysiNode; +typedef SScanPhysiNode SLastRowScanPhysiNode; typedef struct SSystemTableScanPhysiNode { SScanPhysiNode scan; @@ -375,7 +377,8 @@ typedef struct SIntervalPhysiNode { int8_t slidingUnit; } SIntervalPhysiNode; -typedef SIntervalPhysiNode SMergeIntervalPhysiNode; +typedef SIntervalPhysiNode SMergeIntervalPhysiNode; +typedef SIntervalPhysiNode SMergeAlignedIntervalPhysiNode; typedef SIntervalPhysiNode SStreamIntervalPhysiNode; typedef SIntervalPhysiNode SStreamFinalIntervalPhysiNode; typedef SIntervalPhysiNode SStreamSemiIntervalPhysiNode; diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 73e487f073..67e01e66f7 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -52,7 +52,7 @@ typedef struct SExprNode { SArray* pAssociation; } SExprNode; -typedef enum EColumnType { COLUMN_TYPE_COLUMN = 1, COLUMN_TYPE_TAG } EColumnType; +typedef enum EColumnType { COLUMN_TYPE_COLUMN = 1, COLUMN_TYPE_TAG, COLUMN_TYPE_TBNAME } EColumnType; typedef struct SColumnNode { SExprNode node; // QUERY_NODE_COLUMN @@ -258,6 +258,7 @@ typedef struct SSelectStmt { bool hasUniqueFunc; bool hasTailFunc; bool hasInterpFunc; + bool hasLastRowFunc; } SSelectStmt; typedef enum ESetOperatorType { SET_OP_TYPE_UNION_ALL = 1, SET_OP_TYPE_UNION } ESetOperatorType; @@ -384,6 +385,7 @@ bool nodesIsArithmeticOp(const SOperatorNode* pOp); bool nodesIsComparisonOp(const SOperatorNode* pOp); bool nodesIsJsonOp(const SOperatorNode* pOp); bool nodesIsRegularOp(const SOperatorNode* pOp); +bool nodesIsBitwiseOp(const SOperatorNode* pOp); bool nodesExprHasColumn(SNode* pNode); bool nodesExprsHasColumn(SNodeList* pList); diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index d562d07d77..26f2758033 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -207,6 +207,10 @@ char* jobTaskStatusStr(int32_t status); SSchema createSchema(int8_t type, int32_t bytes, col_id_t colId, const char* name); void destroyQueryExecRes(SQueryExecRes* pRes); +int32_t dataConverToStr(char *str, int type, void *buf, int32_t bufSize, int32_t *len); +char* parseTagDatatoJson(void* p); +int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst); +int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst); extern int32_t (*queryBuildMsg[TDMT_MAX])(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallocFp)(int32_t)); extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t msgSize); diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index 937ac2b408..684a605e18 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -30,9 +30,14 @@ extern "C" { typedef struct SStreamTask SStreamTask; enum { - TASK_STATUS__IDLE = 1, - TASK_STATUS__EXECUTING, - TASK_STATUS__CLOSING, + TASK_STATUS__NORMAL = 0, + TASK_STATUS__DROPPING, +}; + +enum { + TASK_EXEC_STATUS__IDLE = 1, + TASK_EXEC_STATUS__EXECUTING, + TASK_EXEC_STATUS__CLOSING, }; enum { @@ -50,16 +55,12 @@ enum { TASK_OUTPUT_STATUS__BLOCKED, }; -enum { - STREAM_CREATED_BY__USER = 1, - STREAM_CREATED_BY__SMA, -}; - enum { STREAM_INPUT__DATA_SUBMIT = 1, STREAM_INPUT__DATA_BLOCK, STREAM_INPUT__TRIGGER, STREAM_INPUT__CHECKPOINT, + STREAM_INPUT__DROP, }; typedef struct { @@ -76,7 +77,7 @@ typedef struct { typedef struct { int8_t type; - int32_t sourceVg; + int32_t srcVgId; int64_t sourceVer; SArray* blocks; // SArray @@ -144,11 +145,6 @@ void streamDataSubmitRefDec(SStreamDataSubmit* pDataSubmit); SStreamDataSubmit* streamSubmitRefClone(SStreamDataSubmit* pSubmit); -#if 0 -int32_t streamDataBlockEncode(void** buf, const SStreamDataBlock* pOutput); -void* streamDataBlockDecode(const void* buf, SStreamDataBlock* pInput); -#endif - typedef struct { char* qmsg; // followings are not applicable to encoder and decoder @@ -233,24 +229,36 @@ enum { TASK_TRIGGER_STATUS__ACTIVE, }; +typedef struct { + int32_t nodeId; + int32_t childId; + int32_t taskId; + SEpSet epSet; +} SStreamChildEpInfo; + struct SStreamTask { int64_t streamId; int32_t taskId; int8_t inputType; - int8_t status; + int8_t taskStatus; + + int8_t execStatus; int8_t execType; int8_t sinkType; int8_t dispatchType; int16_t dispatchMsgType; - int8_t dataScan; + int8_t isDataScan; // node info - int32_t childId; + int32_t selfChildId; int32_t nodeId; SEpSet epSet; + // children info + SArray* childEpInfo; // SArray + // exec STaskExec exec; @@ -288,6 +296,9 @@ struct SStreamTask { SMsgCb* pMsgCb; }; +int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo); +int32_t tDecodeStreamEpInfo(SDecoder* pDecoder, SStreamChildEpInfo* pInfo); + SStreamTask* tNewSStreamTask(int64_t streamId); int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask); int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask); @@ -366,9 +377,9 @@ typedef struct { typedef struct { int64_t streamId; int32_t taskId; - int32_t sourceTaskId; - int32_t sourceVg; - int32_t sourceChildId; + int32_t dataSrcVgId; + int32_t upstreamTaskId; + int32_t upstreamChildId; int32_t upstreamNodeId; #if 0 int64_t sourceVer; @@ -384,6 +395,23 @@ typedef struct { int8_t inputStatus; } SStreamDispatchRsp; +typedef struct { + int64_t streamId; + int32_t srcTaskId; + int32_t srcNodeId; + int32_t dstTaskId; + int32_t dstNodeId; + int32_t retrieveLen; + SRetrieveTableRsp* pRetrieve; +} SStreamRetrieveReq; + +typedef struct { + int64_t streamId; + int32_t childId; + int32_t rspFromTaskId; + int32_t rspToTaskId; +} SStreamRetrieveRsp; + typedef struct { int64_t streamId; int32_t taskId; @@ -398,6 +426,7 @@ typedef struct { } SStreamTaskRecoverRsp; int32_t tDecodeStreamDispatchReq(SDecoder* pDecoder, SStreamDispatchReq* pReq); +int32_t tDecodeStreamRetrieveReq(SDecoder* pDecoder, SStreamRetrieveReq* pReq); int32_t streamLaunchByWrite(SStreamTask* pTask, int32_t vgId); int32_t streamSetupTrigger(SStreamTask* pTask); @@ -408,6 +437,9 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp); int32_t streamProcessRecoverReq(SStreamTask* pTask, SStreamTaskRecoverReq* pReq, SRpcMsg* pMsg); int32_t streamProcessRecoverRsp(SStreamTask* pTask, SStreamTaskRecoverRsp* pRsp); +int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, SRpcMsg* pMsg); +int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp); + #ifdef __cplusplus } #endif diff --git a/include/os/osTime.h b/include/os/osTime.h index 949c15ed0d..965ec61671 100644 --- a/include/os/osTime.h +++ b/include/os/osTime.h @@ -38,7 +38,7 @@ extern "C" { #define MILLISECOND_PER_SECOND (1000i64) #else -#define MILLISECOND_PER_SECOND ((int64_t)1000L) +#define MILLISECOND_PER_SECOND ((int64_t)1000LL) #endif #define MILLISECOND_PER_MINUTE (MILLISECOND_PER_SECOND * 60) @@ -46,9 +46,9 @@ extern "C" { #define MILLISECOND_PER_DAY (MILLISECOND_PER_HOUR * 24) #define MILLISECOND_PER_WEEK (MILLISECOND_PER_DAY * 7) -#define NANOSECOND_PER_USEC (1000L) -#define NANOSECOND_PER_MSEC (1000000L) -#define NANOSECOND_PER_SEC (1000000000L) +#define NANOSECOND_PER_USEC (1000LL) +#define NANOSECOND_PER_MSEC (1000000LL) +#define NANOSECOND_PER_SEC (1000000000LL) #define NANOSECOND_PER_MINUTE (NANOSECOND_PER_SEC * 60) #define NANOSECOND_PER_HOUR (NANOSECOND_PER_MINUTE * 60) #define NANOSECOND_PER_DAY (NANOSECOND_PER_HOUR * 24) @@ -65,21 +65,21 @@ int32_t taosGetTimestampSec(); static FORCE_INLINE int64_t taosGetTimestampMs() { struct timeval systemTime; taosGetTimeOfDay(&systemTime); - return (int64_t)systemTime.tv_sec * 1000L + (int64_t)systemTime.tv_usec / 1000; + return (int64_t)systemTime.tv_sec * 1000LL + (int64_t)systemTime.tv_usec / 1000; } //@return timestamp in microsecond static FORCE_INLINE int64_t taosGetTimestampUs() { struct timeval systemTime; taosGetTimeOfDay(&systemTime); - return (int64_t)systemTime.tv_sec * 1000000L + (int64_t)systemTime.tv_usec; + return (int64_t)systemTime.tv_sec * 1000000LL + (int64_t)systemTime.tv_usec; } //@return timestamp in nanosecond static FORCE_INLINE int64_t taosGetTimestampNs() { struct timespec systemTime = {0}; taosClockGetTime(CLOCK_REALTIME, &systemTime); - return (int64_t)systemTime.tv_sec * 1000000000L + (int64_t)systemTime.tv_nsec; + return (int64_t)systemTime.tv_sec * 1000000000LL + (int64_t)systemTime.tv_nsec; } char * taosStrpTime(const char *buf, const char *fmt, struct tm *tm); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index e695a9e282..eb68f52a40 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -129,6 +129,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TSC_STMT_CLAUSE_ERROR TAOS_DEF_ERROR_CODE(0, 0X0227) #define TSDB_CODE_TSC_QUERY_KILLED TAOS_DEF_ERROR_CODE(0, 0X0228) #define TSDB_CODE_TSC_NO_EXEC_NODE TAOS_DEF_ERROR_CODE(0, 0X0229) +#define TSDB_CODE_TSC_NOT_STABLE_ERROR TAOS_DEF_ERROR_CODE(0, 0X022a) // mnode-common #define TSDB_CODE_MND_APP_ERROR TAOS_DEF_ERROR_CODE(0, 0x0300) diff --git a/include/util/tdef.h b/include/util/tdef.h index c5a8b95a08..f10bc3c7d2 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -49,12 +49,12 @@ extern const int32_t TYPE_BYTES[16]; #define TSDB_DATA_BOOL_NULL 0x02 #define TSDB_DATA_TINYINT_NULL 0x80 #define TSDB_DATA_SMALLINT_NULL 0x8000 -#define TSDB_DATA_INT_NULL 0x80000000L -#define TSDB_DATA_BIGINT_NULL 0x8000000000000000L +#define TSDB_DATA_INT_NULL 0x80000000LL +#define TSDB_DATA_BIGINT_NULL 0x8000000000000000LL #define TSDB_DATA_TIMESTAMP_NULL TSDB_DATA_BIGINT_NULL #define TSDB_DATA_FLOAT_NULL 0x7FF00000 // it is an NAN -#define TSDB_DATA_DOUBLE_NULL 0x7FFFFF0000000000L // an NAN +#define TSDB_DATA_DOUBLE_NULL 0x7FFFFF0000000000LL // an NAN #define TSDB_DATA_NCHAR_NULL 0xFFFFFFFF #define TSDB_DATA_BINARY_NULL 0xFF @@ -108,8 +108,8 @@ extern const int32_t TYPE_BYTES[16]; #define TSDB_INS_USER_STABLES_DBNAME_COLID 2 #define TSDB_TICK_PER_SECOND(precision) \ - ((int64_t)((precision) == TSDB_TIME_PRECISION_MILLI ? 1e3L \ - : ((precision) == TSDB_TIME_PRECISION_MICRO ? 1e6L : 1e9L))) + ((int64_t)((precision) == TSDB_TIME_PRECISION_MILLI ? 1000LL \ + : ((precision) == TSDB_TIME_PRECISION_MICRO ? 1000000LL : 1000000000LL))) #define T_MEMBER_SIZE(type, member) sizeof(((type *)0)->member) #define T_APPEND_MEMBER(dst, ptr, type, member) \ @@ -134,7 +134,7 @@ typedef enum EOperatorType { OP_TYPE_MINUS, OP_TYPE_ASSIGN, - // bit operator + // bitwise operator OP_TYPE_BIT_AND, OP_TYPE_BIT_OR, diff --git a/include/util/tpagedbuf.h b/include/util/tpagedbuf.h index af82e29ec5..ef266068cb 100644 --- a/include/util/tpagedbuf.h +++ b/include/util/tpagedbuf.h @@ -28,7 +28,7 @@ typedef struct SArray* SIDList; typedef struct SPageInfo SPageInfo; typedef struct SDiskbasedBuf SDiskbasedBuf; -#define DEFAULT_INTERN_BUF_PAGE_SIZE (1024L) // in bytes +#define DEFAULT_INTERN_BUF_PAGE_SIZE (1024LL) // in bytes typedef struct SFilePage { int32_t num; diff --git a/include/util/types.h b/include/util/types.h index d48995418e..ded9dc37d7 100644 --- a/include/util/types.h +++ b/include/util/types.h @@ -32,7 +32,7 @@ extern "C" { #define GET_UINT64_VAL(x) (*(uint64_t *)(x)) static FORCE_INLINE float taos_align_get_float(const char *pBuf) { -#if __STDC_VERSION__ >= 201112L +#if __STDC_VERSION__ >= 201112LL static_assert(sizeof(float) == sizeof(uint32_t), "sizeof(float) must equal to sizeof(uint32_t)"); #else assert(sizeof(float) == sizeof(uint32_t)); @@ -43,7 +43,7 @@ static FORCE_INLINE float taos_align_get_float(const char *pBuf) { } static FORCE_INLINE double taos_align_get_double(const char *pBuf) { -#if __STDC_VERSION__ >= 201112L +#if __STDC_VERSION__ >= 201112LL static_assert(sizeof(double) == sizeof(uint64_t), "sizeof(double) must equal to sizeof(uint64_t)"); #else assert(sizeof(double) == sizeof(uint64_t)); diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index f07705ff44..d730cc0d8a 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -196,7 +196,6 @@ function install_bin() { ${csudo}rm -f ${bin_link_dir}/${uninstallScript} || : ${csudo}rm -f ${bin_link_dir}/tarbitrator || : ${csudo}rm -f ${bin_link_dir}/set_core || : - ${csudo}rm -f ${bin_link_dir}/run_${serverName}_and_${adapterName}.sh || : ${csudo}rm -f ${bin_link_dir}/TDinsight.sh || : ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* @@ -211,7 +210,6 @@ function install_bin() { [ -x ${install_main_dir}/bin/TDinsight.sh ] && ${csudo}ln -s ${install_main_dir}/bin/TDinsight.sh ${bin_link_dir}/TDinsight.sh || : [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || : [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : - [ -x ${install_main_dir}/bin/run_${serverName}_and_${adapterName}.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_${serverName}_and_${adapterName}.sh ${bin_link_dir}/run_${serverName}_and_${adapterName}.sh || : [ -x ${install_main_dir}/bin/tarbitrator ] && ${csudo}ln -s ${install_main_dir}/bin/tarbitrator ${bin_link_dir}/tarbitrator || : if [ "$verMode" == "cluster" ]; then diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index 31cb5e87b9..6726b3fe2d 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -176,7 +176,6 @@ function install_bin() { if [ "$osType" != "Darwin" ]; then ${csudo}rm -f ${bin_link_dir}/perfMonitor || : ${csudo}rm -f ${bin_link_dir}/set_core || : - ${csudo}rm -f ${bin_link_dir}/run_taosd_and_taosadapter.sh || : ${csudo}rm -f ${bin_link_dir}/${uninstallScript} || : ${csudo}cp -r ${binary_dir}/build/bin/${clientName} ${install_main_dir}/bin || : @@ -191,7 +190,6 @@ function install_bin() { ${csudo}cp -r ${script_dir}/taosd-dump-cfg.gdb ${install_main_dir}/bin || : ${csudo}cp -r ${script_dir}/remove.sh ${install_main_dir}/bin || : ${csudo}cp -r ${script_dir}/set_core.sh ${install_main_dir}/bin || : - ${csudo}cp -r ${script_dir}/run_taosd_and_taosadapter.sh ${install_main_dir}/bin || : ${csudo}cp -r ${script_dir}/startPre.sh ${install_main_dir}/bin || : ${csudo}chmod 0555 ${install_main_dir}/bin/* @@ -204,7 +202,6 @@ function install_bin() { [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : [ -x ${install_main_dir}/bin/perfMonitor ] && ${csudo}ln -s ${install_main_dir}/bin/perfMonitor ${bin_link_dir}/perfMonitor || : [ -x ${install_main_dir}/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : - [ -x ${install_main_dir}/run_taosd_and_taosadapter.sh ] && ${csudo}ln -s ${install_main_dir}/bin/run_taosd_and_taosadapter.sh ${bin_link_dir}/run_taosd_and_taosadapter.sh || : [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || : else diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index ea8ebba450..d0fbf0c4d7 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -88,7 +88,6 @@ else ${build_dir}/bin/tarbitrator\ ${script_dir}/remove.sh \ ${script_dir}/set_core.sh \ - ${script_dir}/run_taosd_and_taosadapter.sh \ ${script_dir}/startPre.sh \ ${script_dir}/taosd-dump-cfg.gdb" fi @@ -152,7 +151,6 @@ if [ $adapterName != "taosadapter" ]; then sed -i "s/taosadapter/${adapterName}/g" ${install_dir}/cfg/$adapterName.service mv ${install_dir}/bin/taosadapter ${install_dir}/bin/${adapterName} - mv ${install_dir}/bin/run_taosd_and_taosadapter.sh ${install_dir}/bin/run_${serverName}_and_${adapterName}.sh mv ${install_dir}/bin/taosd-dump-cfg.gdb ${install_dir}/bin/${serverName}-dump-cfg.gdb fi diff --git a/packaging/tools/run_taosd_and_taosadapter.sh b/packaging/tools/run_taosd_and_taosadapter.sh deleted file mode 100755 index 9ab9eb484a..0000000000 --- a/packaging/tools/run_taosd_and_taosadapter.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -[[ -x /usr/bin/taosadapter ]] && /usr/bin/taosadapter & -taosd diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index c39b492620..cfe507e505 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -20,9 +20,9 @@ extern "C" { #endif +#include "catalog.h" #include "parser.h" #include "planner.h" -#include "catalog.h" #include "query.h" #include "taos.h" #include "tcommon.h" @@ -51,10 +51,12 @@ extern "C" { enum { RES_TYPE__QUERY = 1, RES_TYPE__TMQ, + RES_TYPE__TMQ_META, }; -#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY) -#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ) +#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY) +#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ) +#define TD_RES_TMQ_META(res) (*(int8_t*)res == RES_TYPE__TMQ_META) typedef struct SAppInstInfo SAppInstInfo; @@ -66,9 +68,9 @@ typedef struct { int64_t reportBytes; // not implemented int64_t startTime; // ctl - SRWLatch lock; // lock is used in serialization + SRWLatch lock; // lock is used in serialization SAppInstInfo* pAppInstInfo; - SHashObj* activeInfo; // hash + SHashObj* activeInfo; // hash } SAppHbMgr; typedef int32_t (*FHbRspHandle)(SAppHbMgr* pAppHbMgr, SClientHbRsp* pRsp); @@ -76,13 +78,13 @@ typedef int32_t (*FHbRspHandle)(SAppHbMgr* pAppHbMgr, SClientHbRsp* pRsp); typedef int32_t (*FHbReqHandle)(SClientHbKey* connKey, void* param, SClientHbReq* req); typedef struct { - int8_t inited; - int64_t appId; + int8_t inited; + int64_t appId; // ctl int8_t threadStop; TdThread thread; - TdThreadMutex lock; // used when app init and cleanup - SHashObj *appSummary; + TdThreadMutex lock; // used when app init and cleanup + SHashObj* appSummary; SArray* appHbMgrs; // SArray one for each cluster FHbReqHandle reqHandle[CONN_TYPE__MAX]; FHbRspHandle rspHandle[CONN_TYPE__MAX]; @@ -129,7 +131,7 @@ typedef struct STscObj { int8_t connType; int32_t acctId; uint32_t connId; - TAOS *id; // ref ID returned by taosAddRef + TAOS* id; // ref ID returned by taosAddRef TdThreadMutex mutex; // used to protect the operation on db int32_t numOfReqs; // number of sqlObj bound to this connection SAppInstInfo* pAppInfo; @@ -188,6 +190,14 @@ typedef struct { SReqResultInfo resInfo; } SMqRspObj; +typedef struct { + int8_t resType; + char topic[TSDB_TOPIC_FNAME_LEN]; + char db[TSDB_DB_FNAME_LEN]; + int32_t vgId; + SMqMetaRsp metaRsp; +} SMqMetaRspObj; + typedef struct SRequestObj { int8_t resType; // query or tmq uint64_t requestId; @@ -206,9 +216,9 @@ typedef struct SRequestObj { SRequestSendRecvBody body; bool stableQuery; - bool killed; - uint32_t prevCode; //previous error code: todo refactor, add update flag for catalog - uint32_t retry; + bool killed; + uint32_t prevCode; // previous error code: todo refactor, add update flag for catalog + uint32_t retry; } SRequestObj; typedef struct SSyncQueryParam { @@ -216,15 +226,15 @@ typedef struct SSyncQueryParam { SRequestObj* pRequest; } SSyncQueryParam; -void* doAsyncFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4); -void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4); +void* doAsyncFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4); +void* doFetchRows(SRequestObj* pRequest, bool setupOneRowPtr, bool convertUcs4); -void doSetOneRowPtr(SReqResultInfo* pResultInfo); -void setResPrecision(SReqResultInfo* pResInfo, int32_t precision); -int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4, - bool freeAfterUse); -void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols); -void doFreeReqResultInfo(SReqResultInfo* pResInfo); +void doSetOneRowPtr(SReqResultInfo* pResultInfo); +void setResPrecision(SReqResultInfo* pResInfo, int32_t precision); +int32_t setQueryResultFromRsp(SReqResultInfo* pResultInfo, const SRetrieveTableRsp* pRsp, bool convertUcs4, + bool freeAfterUse); +void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t numOfCols); +void doFreeReqResultInfo(SReqResultInfo* pResInfo); SRequestObj* execQuery(STscObj* pTscObj, const char* sql, int sqlLen); static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) { @@ -289,7 +299,7 @@ bool persistConnForSpecificMsg(void* parenct, tmsg_t msgType); void processMsgFromServer(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet); STscObj* taos_connect_internal(const char* ip, const char* user, const char* pass, const char* auth, const char* db, - uint16_t port, int connType); + uint16_t port, int connType); SRequestObj* launchQuery(STscObj* pTscObj, const char* sql, int sqlLen); @@ -299,7 +309,7 @@ int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArra int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj** pRequest); -void taos_close_internal(void *taos); +void taos_close_internal(void* taos); // --- heartbeat // global, called by mgmt @@ -320,12 +330,12 @@ void hbMgrInitMqHbRspHandle(); SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQuery, void** res); int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList); -void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData *pResultMeta); +void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultMeta); int32_t refreshMeta(STscObj* pTscObj, SRequestObj* pRequest); int32_t updateQnodeList(SAppInstInfo* pInfo, SArray* pNodeList); void doAsyncQuery(SRequestObj* pRequest, bool forceUpdateMeta); -int32_t removeMeta(STscObj* pTscObj, SArray* tbList);// todo move to clientImpl.c and become a static function -int32_t handleAlterTbExecRes(void* res, struct SCatalog* pCatalog);// todo move to xxx +int32_t removeMeta(STscObj* pTscObj, SArray* tbList); // todo move to clientImpl.c and become a static function +int32_t handleAlterTbExecRes(void* res, struct SCatalog* pCatalog); // todo move to xxx bool qnodeRequired(SRequestObj* pRequest); #ifdef __cplusplus diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 8920922006..37b8866e25 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -244,10 +244,10 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { } SReqResultInfo* pResultInfo = &pRequest->body.resInfo; + pRequest->code = code; if (pRequest->code != TSDB_CODE_SUCCESS) { pResultInfo->numOfRows = 0; - pRequest->code = code; tscError("0x%" PRIx64 " fetch results failed, code:%s, reqId:0x%" PRIx64, pRequest->self, tstrerror(code), pRequest->requestId); } else { @@ -256,7 +256,7 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) { pRequest->requestId); } - pRequest->body.queryFp(pRequest->body.param, pRequest, 0); + pRequest->body.queryFp(pRequest->body.param, pRequest, code); // pRequest->body.fetchFp(pRequest->body.param, pRequest, pResultInfo->numOfRows); } @@ -1444,80 +1444,6 @@ static int32_t doPrepareResPtr(SReqResultInfo* pResInfo) { return TSDB_CODE_SUCCESS; } -static char* parseTagDatatoJson(void* p) { - char* string = NULL; - cJSON* json = cJSON_CreateObject(); - if (json == NULL) { - goto end; - } - - SArray* pTagVals = NULL; - if (tTagToValArray((const STag*)p, &pTagVals) != 0) { - goto end; - } - - int16_t nCols = taosArrayGetSize(pTagVals); - char tagJsonKey[256] = {0}; - for (int j = 0; j < nCols; ++j) { - STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, j); - // json key encode by binary - memset(tagJsonKey, 0, sizeof(tagJsonKey)); - memcpy(tagJsonKey, pTagVal->pKey, strlen(pTagVal->pKey)); - // json value - char type = pTagVal->type; - if (type == TSDB_DATA_TYPE_NULL) { - cJSON* value = cJSON_CreateNull(); - if (value == NULL) { - goto end; - } - cJSON_AddItemToObject(json, tagJsonKey, value); - } else if (type == TSDB_DATA_TYPE_NCHAR) { - cJSON* value = NULL; - if (pTagVal->nData > 0) { - char* tagJsonValue = taosMemoryCalloc(pTagVal->nData, 1); - int32_t length = taosUcs4ToMbs((TdUcs4*)pTagVal->pData, pTagVal->nData, tagJsonValue); - if (length < 0) { - tscError("charset:%s to %s. val:%s convert json value failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, - pTagVal->pData); - taosMemoryFree(tagJsonValue); - goto end; - } - value = cJSON_CreateString(tagJsonValue); - taosMemoryFree(tagJsonValue); - if (value == NULL) { - goto end; - } - } else if (pTagVal->nData == 0) { - value = cJSON_CreateString(""); - } else { - ASSERT(0); - } - - cJSON_AddItemToObject(json, tagJsonKey, value); - } else if (type == TSDB_DATA_TYPE_DOUBLE) { - double jsonVd = *(double*)(&pTagVal->i64); - cJSON* value = cJSON_CreateNumber(jsonVd); - if (value == NULL) { - goto end; - } - cJSON_AddItemToObject(json, tagJsonKey, value); - } else if (type == TSDB_DATA_TYPE_BOOL) { - char jsonVd = *(char*)(&pTagVal->i64); - cJSON* value = cJSON_CreateBool(jsonVd); - if (value == NULL) { - goto end; - } - cJSON_AddItemToObject(json, tagJsonKey, value); - } else { - ASSERT(0); - } - } - string = cJSON_PrintUnformatted(json); -end: - cJSON_Delete(json); - return string; -} - static int32_t doConvertUCS4(SReqResultInfo* pResultInfo, int32_t numOfRows, int32_t numOfCols, int32_t* colLength) { for (int32_t i = 0; i < numOfCols; ++i) { int32_t type = pResultInfo->fields[i].type; diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index ba7de65931..ab4d14b1cc 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -17,6 +17,7 @@ #include "clientInt.h" #include "clientLog.h" #include "clientStmt.h" +#include "functionMgt.h" #include "os.h" #include "query.h" #include "scheduler.h" @@ -25,7 +26,6 @@ #include "tref.h" #include "trpc.h" #include "version.h" -#include "functionMgt.h" #define TSC_VAR_NOT_RELEASE 1 #define TSC_VAR_RELEASED 0 @@ -97,11 +97,11 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha pass = TSDB_DEFAULT_PASS; } - STscObj* pObj = taos_connect_internal(ip, user, pass, NULL, db, port, CONN_TYPE__QUERY); + STscObj *pObj = taos_connect_internal(ip, user, pass, NULL, db, port, CONN_TYPE__QUERY); if (pObj) { return pObj->id; } - + return NULL; } @@ -111,41 +111,40 @@ void taos_close_internal(void *taos) { } STscObj *pTscObj = (STscObj *)taos; - tscDebug("0x%" PRIx64 " try to close connection, numOfReq:%d", *(int64_t*)pTscObj->id, pTscObj->numOfReqs); + tscDebug("0x%" PRIx64 " try to close connection, numOfReq:%d", *(int64_t *)pTscObj->id, pTscObj->numOfReqs); - taosRemoveRef(clientConnRefPool, *(int64_t*)pTscObj->id); + taosRemoveRef(clientConnRefPool, *(int64_t *)pTscObj->id); } void taos_close(TAOS *taos) { if (taos == NULL) { return; } - - STscObj* pObj = acquireTscObj(*(int64_t*)taos); + + STscObj *pObj = acquireTscObj(*(int64_t *)taos); if (NULL == pObj) { return; } - + taos_close_internal(pObj); - releaseTscObj(*(int64_t*)taos); + releaseTscObj(*(int64_t *)taos); taosMemoryFree(taos); } - -int taos_errno(TAOS_RES *tres) { - if (tres == NULL) { +int taos_errno(TAOS_RES *res) { + if (res == NULL || TD_RES_TMQ_META(res)) { return terrno; } - if (TD_RES_TMQ(tres)) { + if (TD_RES_TMQ(res)) { return 0; } - return ((SRequestObj *)tres)->code; + return ((SRequestObj *)res)->code; } const char *taos_errstr(TAOS_RES *res) { - if (res == NULL) { + if (res == NULL || TD_RES_TMQ_META(res)) { return (const char *)tstrerror(terrno); } @@ -179,11 +178,15 @@ void taos_free_result(TAOS_RES *res) { if (pRsp->rsp.withSchema) taosArrayDestroyP(pRsp->rsp.blockSchema, (FDelete)tDeleteSSchemaWrapper); pRsp->resInfo.pRspMsg = NULL; doFreeReqResultInfo(&pRsp->resInfo); + } else if (TD_RES_TMQ_META(res)) { + SMqMetaRspObj *pRspObj = (SMqMetaRspObj *)res; + taosMemoryFree(pRspObj->metaRsp.metaRsp); + taosMemoryFree(pRspObj); } } int taos_field_count(TAOS_RES *res) { - if (res == NULL) { + if (res == NULL || TD_RES_TMQ_META(res)) { return 0; } @@ -194,7 +197,7 @@ int taos_field_count(TAOS_RES *res) { int taos_num_fields(TAOS_RES *res) { return taos_field_count(res); } TAOS_FIELD *taos_fetch_fields(TAOS_RES *res) { - if (taos_num_fields(res) == 0) { + if (taos_num_fields(res) == 0 || TD_RES_TMQ_META(res)) { return NULL; } @@ -215,8 +218,8 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) { terrno = TSDB_CODE_TSC_DISCONNECTED; return NULL; } - - STscObj* pTscObj = acquireTscObj(*(int64_t*)taos); + + STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); if (pTscObj == NULL || sql == NULL) { terrno = TSDB_CODE_TSC_DISCONNECTED; return NULL; @@ -229,21 +232,21 @@ TAOS_RES *taos_query(TAOS *taos, const char *sql) { taos_query_a(taos, sql, syncQueryFn, param); tsem_wait(¶m->sem); - releaseTscObj(*(int64_t*)taos); + releaseTscObj(*(int64_t *)taos); return param->pRequest; #else size_t sqlLen = strlen(sql); if (sqlLen > (size_t)TSDB_MAX_ALLOWED_SQL_LEN) { - releaseTscObj(*(int64_t*)taos); + releaseTscObj(*(int64_t *)taos); tscError("sql string exceeds max length:%d", TSDB_MAX_ALLOWED_SQL_LEN); terrno = TSDB_CODE_TSC_EXCEED_SQL_LIMIT; return NULL; } - TAOS_RES* pRes = execQuery(pTscObj, sql, sqlLen); + TAOS_RES *pRes = execQuery(pTscObj, sql, sqlLen); - releaseTscObj(*(int64_t*)taos); + releaseTscObj(*(int64_t *)taos); return pRes; #endif @@ -380,7 +383,7 @@ int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) } int *taos_fetch_lengths(TAOS_RES *res) { - if (res == NULL) { + if (res == NULL || TD_RES_TMQ_META(res)) { return NULL; } @@ -389,7 +392,7 @@ int *taos_fetch_lengths(TAOS_RES *res) { } TAOS_ROW *taos_result_block(TAOS_RES *res) { - if (res == NULL) { + if (res == NULL || TD_RES_TMQ_META(res)) { terrno = TSDB_CODE_INVALID_PARA; return NULL; } @@ -438,7 +441,7 @@ const char *taos_data_type(int type) { const char *taos_get_client_info() { return version; } int taos_affected_rows(TAOS_RES *res) { - if (res == NULL || TD_RES_TMQ(res)) { + if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res)) { return 0; } @@ -448,7 +451,7 @@ int taos_affected_rows(TAOS_RES *res) { } int taos_result_precision(TAOS_RES *res) { - if (res == NULL) { + if (res == NULL || TD_RES_TMQ_META(res)) { return TSDB_TIME_PRECISION_MILLI; } @@ -463,15 +466,15 @@ int taos_result_precision(TAOS_RES *res) { } int taos_select_db(TAOS *taos, const char *db) { - STscObj* pObj = acquireTscObj(*(int64_t*)taos); + STscObj *pObj = acquireTscObj(*(int64_t *)taos); if (pObj == NULL) { - releaseTscObj(*(int64_t*)taos); + releaseTscObj(*(int64_t *)taos); terrno = TSDB_CODE_TSC_DISCONNECTED; return TSDB_CODE_TSC_DISCONNECTED; } if (db == NULL || strlen(db) == 0) { - releaseTscObj(*(int64_t*)taos); + releaseTscObj(*(int64_t *)taos); terrno = TSDB_CODE_TSC_INVALID_INPUT; return terrno; } @@ -483,19 +486,19 @@ int taos_select_db(TAOS *taos, const char *db) { int32_t code = taos_errno(pRequest); taos_free_result(pRequest); - releaseTscObj(*(int64_t*)taos); + releaseTscObj(*(int64_t *)taos); return code; } void taos_stop_query(TAOS_RES *res) { - if (res == NULL) { + if (res == NULL || TD_RES_TMQ(res) || TD_RES_TMQ_META(res)) { return; } SRequestObj *pRequest = (SRequestObj *)res; pRequest->killed = true; - - int32_t numOfFields = taos_num_fields(pRequest); + + int32_t numOfFields = taos_num_fields(pRequest); // It is not a query, no need to stop. if (numOfFields == 0) { tscDebug("request %" PRIx64 " no need to be killed since not query", pRequest->requestId); @@ -510,6 +513,9 @@ void taos_stop_query(TAOS_RES *res) { } bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col) { + if (res == NULL || TD_RES_TMQ_META(res)) { + return true; + } SReqResultInfo *pResultInfo = tscGetCurResInfo(res); if (col >= pResultInfo->numOfCols || col < 0 || row >= pResultInfo->numOfRows || row < 0) { return true; @@ -532,7 +538,7 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) { } int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows) { - if (res == NULL) { + if (res == NULL || TD_RES_TMQ_META(res)) { return 0; } @@ -575,7 +581,7 @@ int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows) { } int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) { - if (res == NULL) { + if (res == NULL || TD_RES_TMQ_META(res)) { return 0; } @@ -615,7 +621,7 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) { } int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) { - if (res == NULL) { + if (res == NULL || TD_RES_TMQ_META(res)) { return 0; } @@ -636,7 +642,7 @@ int *taos_get_column_data_offset(TAOS_RES *res, int columnIndex) { int taos_validate_sql(TAOS *taos, const char *sql) { return true; } void taos_reset_current_db(TAOS *taos) { - STscObj* pTscObj = acquireTscObj(*(int64_t*)taos); + STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); if (pTscObj == NULL) { terrno = TSDB_CODE_TSC_DISCONNECTED; return; @@ -644,17 +650,17 @@ void taos_reset_current_db(TAOS *taos) { resetConnectDB(pTscObj); - releaseTscObj(*(int64_t*)taos); + releaseTscObj(*(int64_t *)taos); } const char *taos_get_server_info(TAOS *taos) { - STscObj* pTscObj = acquireTscObj(*(int64_t*)taos); + STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); if (pTscObj == NULL) { terrno = TSDB_CODE_TSC_DISCONNECTED; return NULL; } - releaseTscObj(*(int64_t*)taos); + releaseTscObj(*(int64_t *)taos); return pTscObj->ver; } @@ -682,7 +688,7 @@ static void destorySqlParseWrapper(SqlParseWrapper *pWrapper) { void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) { tscDebug("enter meta callback, code %s", tstrerror(code)); - + SqlParseWrapper *pWrapper = (SqlParseWrapper *)param; SQuery *pQuery = pWrapper->pQuery; SRequestObj *pRequest = pWrapper->pRequest; @@ -723,11 +729,11 @@ void retrieveMetaCallback(SMetaData *pResultMeta, void *param, int32_t code) { } void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param) { - STscObj* pTscObj = acquireTscObj(*(int64_t*)taos); + STscObj *pTscObj = acquireTscObj(*(int64_t *)taos); if (pTscObj == NULL || sql == NULL || NULL == fp) { terrno = TSDB_CODE_INVALID_PARA; if (pTscObj) { - releaseTscObj(*(int64_t*)taos); + releaseTscObj(*(int64_t *)taos); } else { terrno = TSDB_CODE_TSC_DISCONNECTED; } @@ -745,7 +751,7 @@ void taos_query_a(TAOS *taos, const char *sql, __taos_async_fn_t fp, void *param } SRequestObj *pRequest = NULL; - int32_t code = buildRequest(pTscObj, sql, sqlLen, &pRequest); + int32_t code = buildRequest(pTscObj, sql, sqlLen, &pRequest); if (code != TSDB_CODE_SUCCESS) { terrno = code; fp(param, NULL, terrno); @@ -849,8 +855,8 @@ static void fetchCallback(void *pResult, void *param, int32_t code) { SReqResultInfo *pResultInfo = &pRequest->body.resInfo; - tscDebug("0x%" PRIx64 " enter scheduler fetch cb, code:%d - %s, reqId:0x%" PRIx64, - pRequest->self, code, tstrerror(code), pRequest->requestId); + tscDebug("0x%" PRIx64 " enter scheduler fetch cb, code:%d - %s, reqId:0x%" PRIx64, pRequest->self, code, + tstrerror(code), pRequest->requestId); pResultInfo->pData = pResult; pResultInfo->numOfRows = 0; @@ -884,6 +890,7 @@ static void fetchCallback(void *pResult, void *param, int32_t code) { void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) { ASSERT(res != NULL && fp != NULL); + ASSERT(TD_RES_QUERY(res)); SRequestObj *pRequest = res; pRequest->body.fetchFp = fp; @@ -910,6 +917,7 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) { void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) { ASSERT(res != NULL && fp != NULL); + ASSERT(TD_RES_QUERY(res)); SRequestObj *pRequest = res; pRequest->body.resInfo.convertUcs4 = false; @@ -923,6 +931,7 @@ void taos_fetch_raw_block_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) { const void *taos_get_raw_block(TAOS_RES *res) { ASSERT(res != NULL); + ASSERT(TD_RES_QUERY(res)); SRequestObj *pRequest = res; return pRequest->body.resInfo.pData; @@ -949,16 +958,16 @@ int taos_load_table_info(TAOS *taos, const char *tableNameList) { } TAOS_STMT *taos_stmt_init(TAOS *taos) { - STscObj* pObj = acquireTscObj(*(int64_t*)taos); + STscObj *pObj = acquireTscObj(*(int64_t *)taos); if (NULL == pObj) { tscError("invalid parameter for %s", __FUNCTION__); terrno = TSDB_CODE_TSC_DISCONNECTED; return NULL; } - TAOS_STMT* pStmt = stmtInit(pObj); - - releaseTscObj(*(int64_t*)taos); + TAOS_STMT *pStmt = stmtInit(pObj); + + releaseTscObj(*(int64_t *)taos); return pStmt; } diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 6fa4e6bffb..7d2bf019d2 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -2389,17 +2389,19 @@ static int32_t isSchemalessDb(STscObj *taos, SRequestObj *request) { static void smlInsertCallback(void *param, void *res, int32_t code) { SRequestObj *pRequest = (SRequestObj *)res; SSmlHandle *info = (SSmlHandle *)param; + int32_t rows = taos_affected_rows(pRequest); uDebug("SML:0x%" PRIx64 " result. code:%d, msg:%s", info->id, pRequest->code, pRequest->msgBuf); // lock + taosThreadSpinLock(&info->params->lock); + info->params->request->body.resInfo.numOfRows += rows; if (code != TSDB_CODE_SUCCESS) { - taosThreadSpinLock(&info->params->lock); info->params->request->code = code; - taosThreadSpinUnlock(&info->params->lock); } + taosThreadSpinUnlock(&info->params->lock); // unlock - printf("SML:0x%" PRIx64 " insert finished, code: %d, total: %d\n", info->id, code, info->affectedRows); + uDebug("SML:0x%" PRIx64 " insert finished, code: %d, rows: %d, total: %d", info->id, code, rows, info->affectedRows); Params *pParam = info->params; bool isLast = info->isLast; info->cost.endTime = taosGetTimestampUs(); diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 638b4f1ea5..3c349f61a1 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -149,7 +149,10 @@ typedef struct { int32_t epoch; SMqClientVg* vgHandle; SMqClientTopic* topicHandle; - SMqDataBlkRsp msg; + union { + SMqDataBlkRsp dataRsp; + SMqMetaRsp metaRsp; + }; } SMqPollRspWrapper; typedef struct { @@ -401,8 +404,17 @@ int32_t tmqCommitInner2(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_ int32_t code = -1; if (msg != NULL) { - SMqRspObj* pRspObj = (SMqRspObj*)msg; - if (!TD_RES_TMQ(pRspObj)) { + char* topic; + int32_t vgId; + if (TD_RES_TMQ(msg)) { + SMqRspObj* pRspObj = (SMqRspObj*)msg; + topic = pRspObj->topic; + vgId = pRspObj->vgId; + } else if (TD_RES_TMQ_META(msg)) { + SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)msg; + topic = pMetaRspObj->topic; + vgId = pMetaRspObj->vgId; + } else { return TSDB_CODE_TMQ_INVALID_MSG; } @@ -421,10 +433,10 @@ int32_t tmqCommitInner2(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_ for (int32_t i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) { SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); - if (strcmp(pTopic->topicName, pRspObj->topic) == 0) { + if (strcmp(pTopic->topicName, topic) == 0) { for (int32_t j = 0; j < taosArrayGetSize(pTopic->vgs); j++) { SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); - if (pVg->vgId == pRspObj->vgId) { + if (pVg->vgId == vgId) { if (pVg->currentOffset < 0 || pVg->committedOffset == pVg->currentOffset) { tscDebug("consumer %ld skip commit for topic %s vg %d, current offset is %ld, committed offset is %ld", tmq->consumerId, pTopic->topicName, pVg->vgId, pVg->currentOffset, pVg->committedOffset); @@ -1131,6 +1143,11 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) { tscWarn("mismatch rsp from vg %d, epoch %d, current epoch %d", vgId, msgEpoch, tmqEpoch); } + // handle meta rsp + int8_t rspType = ((SMqRspHead*)pMsg->pData)->mqMsgType; + if (rspType == TMQ_MSG_TYPE__POLL_META_RSP) { + } + SMqPollRspWrapper* pRspWrapper = taosAllocateQitem(sizeof(SMqPollRspWrapper), DEF_QITEM); if (pRspWrapper == NULL) { taosMemoryFree(pMsg->pData); @@ -1138,17 +1155,23 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) { goto CREATE_MSG_FAIL; } - pRspWrapper->tmqRspType = TMQ_MSG_TYPE__POLL_RSP; + pRspWrapper->tmqRspType = rspType; pRspWrapper->vgHandle = pVg; pRspWrapper->topicHandle = pTopic; - memcpy(&pRspWrapper->msg, pMsg->pData, sizeof(SMqRspHead)); + memcpy(&pRspWrapper->dataRsp, pMsg->pData, sizeof(SMqRspHead)); + + if (rspType == TMQ_MSG_TYPE__POLL_RSP) { + tDecodeSMqDataBlkRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &pRspWrapper->dataRsp); + } else { + ASSERT(rspType == TMQ_MSG_TYPE__POLL_META_RSP); + tDecodeSMqMetaRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &pRspWrapper->metaRsp); + } - tDecodeSMqDataBlkRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &pRspWrapper->msg); taosMemoryFree(pMsg->pData); tscDebug("consumer %ld recv poll: vg %d, req offset %ld, rsp offset %ld", tmq->consumerId, pVg->vgId, - pRspWrapper->msg.reqOffset, pRspWrapper->msg.rspOffset); + pRspWrapper->dataRsp.reqOffset, pRspWrapper->dataRsp.rspOffset); taosWriteQitem(tmq->mqueue, pRspWrapper); tsem_post(&tmq->rspSem); @@ -1516,6 +1539,17 @@ SMqPollReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t timeout, SMqClientTopic* return pReq; } +SMqMetaRspObj* tmqBuildMetaRspFromWrapper(SMqPollRspWrapper* pWrapper) { + SMqMetaRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqMetaRspObj)); + pRspObj->resType = RES_TYPE__TMQ; + tstrncpy(pRspObj->topic, pWrapper->topicHandle->topicName, TSDB_TOPIC_FNAME_LEN); + tstrncpy(pRspObj->db, pWrapper->topicHandle->db, TSDB_DB_FNAME_LEN); + pRspObj->vgId = pWrapper->vgHandle->vgId; + + memcpy(&pRspObj->metaRsp, &pWrapper->metaRsp, sizeof(SMqMetaRsp)); + return pRspObj; +} + SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) { SMqRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqRspObj)); pRspObj->resType = RES_TYPE__TMQ; @@ -1523,11 +1557,11 @@ SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) { tstrncpy(pRspObj->db, pWrapper->topicHandle->db, TSDB_DB_FNAME_LEN); pRspObj->vgId = pWrapper->vgHandle->vgId; pRspObj->resIter = -1; - memcpy(&pRspObj->rsp, &pWrapper->msg, sizeof(SMqDataBlkRsp)); + memcpy(&pRspObj->rsp, &pWrapper->dataRsp, sizeof(SMqDataBlkRsp)); pRspObj->resInfo.totalRows = 0; pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI; - if (!pWrapper->msg.withSchema) { + if (!pWrapper->dataRsp.withSchema) { setResSchemaInfo(&pRspObj->resInfo, pWrapper->topicHandle->schema.pSchema, pWrapper->topicHandle->schema.nCols); } @@ -1643,12 +1677,12 @@ SMqRspObj* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper; /*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/ int32_t consumerEpoch = atomic_load_32(&tmq->epoch); - if (pollRspWrapper->msg.head.epoch == consumerEpoch) { + if (pollRspWrapper->dataRsp.head.epoch == consumerEpoch) { SMqClientVg* pVg = pollRspWrapper->vgHandle; /*printf("vg %d offset %ld up to %ld\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/ - pVg->currentOffset = pollRspWrapper->msg.rspOffset; + pVg->currentOffset = pollRspWrapper->dataRsp.rspOffset; atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); - if (pollRspWrapper->msg.blockNum == 0) { + if (pollRspWrapper->dataRsp.blockNum == 0) { taosFreeQitem(pollRspWrapper); rspWrapper = NULL; continue; @@ -1658,8 +1692,25 @@ SMqRspObj* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { taosFreeQitem(pollRspWrapper); return pRsp; } else { - tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d\n", pollRspWrapper->msg.head.epoch, - consumerEpoch); + tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d\n", + pollRspWrapper->dataRsp.head.epoch, consumerEpoch); + taosFreeQitem(pollRspWrapper); + } + } else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_META_RSP) { + SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper; + int32_t consumerEpoch = atomic_load_32(&tmq->epoch); + if (pollRspWrapper->dataRsp.head.epoch == consumerEpoch) { + SMqClientVg* pVg = pollRspWrapper->vgHandle; + /*printf("vg %d offset %ld up to %ld\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/ + pVg->currentOffset = pollRspWrapper->dataRsp.rspOffset; + atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); + // build rsp + SMqRspObj* pRsp = tmqBuildRspFromWrapper(pollRspWrapper); + taosFreeQitem(pollRspWrapper); + return pRsp; + } else { + tscDebug("msg discard since epoch mismatch: msg epoch %d, consumer epoch %d\n", + pollRspWrapper->dataRsp.head.epoch, consumerEpoch); taosFreeQitem(pollRspWrapper); } } else { @@ -1747,10 +1798,23 @@ const char* tmq_err2str(int32_t err) { } } +tmq_res_t tmq_get_res_type(TAOS_RES* res) { + if (TD_RES_TMQ(res)) { + return TMQ_RES_DATA; + } else if (TD_RES_TMQ_META(res)) { + return TMQ_RES_TABLE_META; + } else { + return TMQ_RES_INVALID; + } +} + const char* tmq_get_topic_name(TAOS_RES* res) { if (TD_RES_TMQ(res)) { SMqRspObj* pRspObj = (SMqRspObj*)res; return strchr(pRspObj->topic, '.') + 1; + } else if (TD_RES_TMQ_META(res)) { + SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; + return strchr(pMetaRspObj->topic, '.') + 1; } else { return NULL; } @@ -1760,6 +1824,9 @@ const char* tmq_get_db_name(TAOS_RES* res) { if (TD_RES_TMQ(res)) { SMqRspObj* pRspObj = (SMqRspObj*)res; return strchr(pRspObj->db, '.') + 1; + } else if (TD_RES_TMQ_META(res)) { + SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; + return strchr(pMetaRspObj->db, '.') + 1; } else { return NULL; } @@ -1769,6 +1836,9 @@ int32_t tmq_get_vgroup_id(TAOS_RES* res) { if (TD_RES_TMQ(res)) { SMqRspObj* pRspObj = (SMqRspObj*)res; return pRspObj->vgId; + } else if (TD_RES_TMQ_META(res)) { + SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; + return pMetaRspObj->vgId; } else { return -1; } @@ -1786,6 +1856,16 @@ const char* tmq_get_table_name(TAOS_RES* res) { return NULL; } +int32_t tmq_get_raw_meta(TAOS_RES* res, const void** raw_meta, int32_t* raw_meta_len) { + if (TD_RES_TMQ_META(res)) { + SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)res; + *raw_meta = pMetaRspObj->metaRsp.metaRsp; + *raw_meta_len = pMetaRspObj->metaRsp.metaRspLen; + return 0; + } + return -1; +} + void tmq_commit_async(tmq_t* tmq, const TAOS_RES* msg, tmq_commit_cb* cb, void* param) { tmqCommitInner2(tmq, msg, 0, 1, cb, param); } diff --git a/source/client/test/smlTest.cpp b/source/client/test/smlTest.cpp index fffb03d9a5..832564e0db 100644 --- a/source/client/test/smlTest.cpp +++ b/source/client/test/smlTest.cpp @@ -1272,10 +1272,10 @@ TEST(testCase, sml_dup_time_Test) { const char *sql[] = { //"test_ms,t0=t c0=f 1626006833641", "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=false,c1=1i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"xcxvwjvf\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", - "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=T,c1=2i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"fixrzcuq\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", - "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=3i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"iupzdqub\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", - "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=4i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"yvvtzzof\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000", - "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=5i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"vbxpilkj\",c8=L\"ncharColValue\",c9=7u64 1626006833639000000" + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=T,c1=2i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"fixrzcuq\",c8=L\"ncharColValue\",c9=7u64 1626006834639000000", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=3i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"iupzdqub\",c8=L\"ncharColValue\",c9=7u64 1626006835639000000", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=4i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"yvvtzzof\",c8=L\"ncharColValue\",c9=7u64 1626006836639000000", + "ubzlsr,id=qmtcvgd,t0=t,t1=127i8,t2=32767i16,t3=2147483647i32,t4=9223372036854775807i64,t5=11.12345f32,t6=22.123456789f64,t7=\"binaryTagValue\",t8=L\"ncharTagValue\" c0=t,c1=5i8,c2=32767i16,c3=2147483647i32,c4=9223372036854775807i64,c5=11.12345f32,c6=22.123456789f64,c7=\"vbxpilkj\",c8=L\"ncharColValue\",c9=7u64 1626006837639000000" }; pRes = taos_query(taos, "use dup_time"); taos_free_result(pRes); diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 3c3d3e953d..5594ee9bcf 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -263,6 +263,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, in pColumnInfoData->varmeta.length = len + oldLen; } else { if (finalNumOfRows > *capacity) { + ASSERT(finalNumOfRows*pColumnInfoData->info.bytes); char* tmp = taosMemoryRealloc(pColumnInfoData->pData, finalNumOfRows * pColumnInfoData->info.bytes); if (tmp == NULL) { return TSDB_CODE_VND_OUT_OF_MEMORY; @@ -1126,6 +1127,7 @@ void blockDataCleanup(SSDataBlock* pDataBlock) { } int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, size_t existRows, uint32_t numOfRows) { + ASSERT(numOfRows); if (0 == numOfRows || numOfRows <= existRows) { return TSDB_CODE_SUCCESS; } @@ -1178,6 +1180,8 @@ void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows) { int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows) { int32_t code = 0; + ASSERT(numOfRows > 0); + if (numOfRows == 0) { return TSDB_CODE_SUCCESS; } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index cc987ad6a1..11fe39903b 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -127,7 +127,7 @@ int32_t tEncodeSEpSet(SEncoder *pEncoder, const SEpSet *pEp) { if (tEncodeI8(pEncoder, pEp->numOfEps) < 0) return -1; for (int32_t i = 0; i < TSDB_MAX_REPLICA; i++) { if (tEncodeU16(pEncoder, pEp->eps[i].port) < 0) return -1; - if (tEncodeCStr(pEncoder, pEp->eps[i].fqdn) < 0) return -1; + if (tEncodeCStrWithLen(pEncoder, pEp->eps[i].fqdn, TSDB_FQDN_LEN) < 0) return -1; } return 0; } @@ -532,6 +532,14 @@ int32_t tSerializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pReq if (pReq->ast2Len > 0) { if (tEncodeBinary(&encoder, pReq->pAst2, pReq->ast2Len) < 0) return -1; } + + int32_t numOfFuncs = taosArrayGetSize(pReq->pFuncs); + if (tEncodeI32(&encoder, numOfFuncs) < 0) return -1; + for (int32_t i = 0; i < numOfFuncs; ++i) { + const char *pFunc = taosArrayGet(pReq->pFuncs, i); + if (tEncodeCStr(&encoder, pFunc) < 0) return -1; + } + tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -606,6 +614,21 @@ int32_t tDeserializeSMCreateStbReq(void *buf, int32_t bufLen, SMCreateStbReq *pR if (tDecodeCStrTo(&decoder, pReq->pAst2) < 0) return -1; } + int32_t numOfFuncs = 0; + if (tDecodeI32(&decoder, &numOfFuncs) < 0) return -1; + if (numOfFuncs > 0) { + pReq->pFuncs = taosArrayInit(numOfFuncs, TSDB_FUNC_NAME_LEN); + if (NULL == pReq->pFuncs) return -1; + } + for (int32_t i = 0; i < numOfFuncs; ++i) { + char* pFunc = NULL; + if (tDecodeCStrAlloc(&decoder, &pFunc) < 0) return -1; + if (taosArrayPush(pReq->pFuncs, pFunc) == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + } + tEndDecode(&decoder); tDecoderClear(&decoder); @@ -618,8 +641,7 @@ void tFreeSMCreateStbReq(SMCreateStbReq *pReq) { taosMemoryFreeClear(pReq->comment); taosMemoryFreeClear(pReq->pAst1); taosMemoryFreeClear(pReq->pAst2); - pReq->pColumns = NULL; - pReq->pTags = NULL; + taosArrayDestroy(pReq->pFuncs); } int32_t tSerializeSMDropStbReq(void *buf, int32_t bufLen, SMDropStbReq *pReq) { @@ -1757,6 +1779,165 @@ void tFreeSRetrieveFuncRsp(SRetrieveFuncRsp *pRsp) { taosArrayDestroy(pRsp->pFuncInfos); } +int32_t tSerializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq) { + int32_t headLen = sizeof(SMsgHead); + if (buf != NULL) { + buf = (char *)buf + headLen; + bufLen -= headLen; + } + + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->dbFName) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->tbName) < 0) return -1; + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + + if (buf != NULL) { + SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); + pHead->vgId = htonl(pReq->header.vgId); + pHead->contLen = htonl(tlen + headLen); + } + + return tlen + headLen; +} + +int32_t tDeserializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq) { + int32_t headLen = sizeof(SMsgHead); + + SMsgHead *pHead = buf; + pHead->vgId = pReq->header.vgId; + pHead->contLen = pReq->header.contLen; + + SDecoder decoder = {0}; + tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->dbFName) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->tbName) < 0) return -1; + + tEndDecode(&decoder); + tDecoderClear(&decoder); + return 0; +} + +int32_t tSerializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeCStr(&encoder, pRsp->tbName) < 0) return -1; + if (tEncodeCStr(&encoder, pRsp->stbName) < 0) return -1; + if (tEncodeCStr(&encoder, pRsp->dbFName) < 0) return -1; + if (tEncodeI32(&encoder, pRsp->numOfTags) < 0) return -1; + if (tEncodeI32(&encoder, pRsp->numOfColumns) < 0) return -1; + if (tEncodeI8(&encoder, pRsp->tableType) < 0) return -1; + if (tEncodeI64(&encoder, pRsp->delay1) < 0) return -1; + if (tEncodeI64(&encoder, pRsp->delay2) < 0) return -1; + if (tEncodeI64(&encoder, pRsp->watermark1) < 0) return -1; + if (tEncodeI64(&encoder, pRsp->watermark2) < 0) return -1; + if (tEncodeI32(&encoder, pRsp->ttl) < 0) return -1; + + int32_t numOfFuncs = taosArrayGetSize(pRsp->pFuncs); + if (tEncodeI32(&encoder, numOfFuncs) < 0) return -1; + for (int32_t i = 0; i < numOfFuncs; ++i) { + const char *pFunc = taosArrayGet(pRsp->pFuncs, i); + if (tEncodeCStr(&encoder, pFunc) < 0) return -1; + } + + if (tEncodeI32(&encoder, pRsp->commentLen) < 0) return -1; + if (pRsp->commentLen > 0) { + if (tEncodeCStr(&encoder, pRsp->pComment) < 0) return -1; + } + + for (int32_t i = 0; i < pRsp->numOfColumns + pRsp->numOfTags; ++i) { + SSchema *pSchema = &pRsp->pSchemas[i]; + if (tEncodeSSchema(&encoder, pSchema) < 0) return -1; + } + + if (tEncodeI32(&encoder, pRsp->tagsLen) < 0) return -1; + if (tEncodeBinary(&encoder, pRsp->pTags, pRsp->tagsLen) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSTableCfgRsp(void *buf, int32_t bufLen, STableCfgRsp *pRsp) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeCStrTo(&decoder, pRsp->tbName) < 0) return -1; + if (tDecodeCStrTo(&decoder, pRsp->stbName) < 0) return -1; + if (tDecodeCStrTo(&decoder, pRsp->dbFName) < 0) return -1; + if (tDecodeI32(&decoder, &pRsp->numOfTags) < 0) return -1; + if (tDecodeI32(&decoder, &pRsp->numOfColumns) < 0) return -1; + if (tDecodeI8(&decoder, &pRsp->tableType) < 0) return -1; + if (tDecodeI64(&decoder, &pRsp->delay1) < 0) return -1; + if (tDecodeI64(&decoder, &pRsp->delay2) < 0) return -1; + if (tDecodeI64(&decoder, &pRsp->watermark1) < 0) return -1; + if (tDecodeI64(&decoder, &pRsp->watermark2) < 0) return -1; + if (tDecodeI32(&decoder, &pRsp->ttl) < 0) return -1; + + int32_t numOfFuncs = 0; + if (tDecodeI32(&decoder, &numOfFuncs) < 0) return -1; + if (numOfFuncs > 0) { + pRsp->pFuncs = taosArrayInit(numOfFuncs, TSDB_FUNC_NAME_LEN); + if (NULL == pRsp->pFuncs) return -1; + } + for (int32_t i = 0; i < numOfFuncs; ++i) { + char pFunc[TSDB_FUNC_NAME_LEN]; + if (tDecodeCStrTo(&decoder, pFunc) < 0) return -1; + if (taosArrayPush(pRsp->pFuncs, pFunc) == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + } + + if (tDecodeI32(&decoder, &pRsp->commentLen) < 0) return -1; + if (pRsp->commentLen > 0) { + if (tDecodeCStrAlloc(&decoder, &pRsp->pComment) < 0) return -1; + } else { + pRsp->pComment = NULL; + } + + int32_t totalCols = pRsp->numOfTags + pRsp->numOfColumns; + pRsp->pSchemas = taosMemoryMalloc(sizeof(SSchema) * totalCols); + if (pRsp->pSchemas == NULL) return -1; + + for (int32_t i = 0; i < totalCols; ++i) { + SSchema *pSchema = &pRsp->pSchemas[i]; + if (tDecodeSSchema(&decoder, pSchema) < 0) return -1; + } + + if (tDecodeI32(&decoder, &pRsp->tagsLen) < 0) return -1; + if (tDecodeBinaryAlloc(&decoder, (void**)&pRsp->pTags, NULL) < 0) return -1; + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +void tFreeSTableCfgRsp(STableCfgRsp *pRsp) { + if (NULL == pRsp) { + return; + } + + taosMemoryFreeClear(pRsp->pComment); + taosMemoryFreeClear(pRsp->pSchemas); + taosMemoryFreeClear(pRsp->pTags); + + taosArrayDestroy(pRsp->pFuncs); +} + int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); @@ -2552,6 +2733,31 @@ void tFreeSTableIndexInfo(void *info) { taosMemoryFree(pInfo->expr); } +int32_t tSerializeSShowVariablesReq(void *buf, int32_t bufLen, SShowVariablesReq *pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeI32(&encoder, pReq->useless) < 0) return -1; + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSShowVariablesReq(void *buf, int32_t bufLen, SShowVariablesReq *pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->useless) < 0) return -1; + + tEndDecode(&decoder); + tDecoderClear(&decoder); + return 0; +} + int32_t tSerializeSShowReq(void *buf, int32_t bufLen, SShowReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); @@ -2956,6 +3162,7 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1; if (tEncodeI8(&encoder, pReq->subType) < 0) return -1; + if (tEncodeI8(&encoder, pReq->withMeta) < 0) return -1; if (tEncodeCStr(&encoder, pReq->subDbName) < 0) return -1; if (TOPIC_SUB_TYPE__DB == pReq->subType) { } else if (TOPIC_SUB_TYPE__TABLE == pReq->subType) { @@ -2985,6 +3192,7 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1; if (tDecodeI8(&decoder, &pReq->subType) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->withMeta) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->subDbName) < 0) return -1; if (TOPIC_SUB_TYPE__DB == pReq->subType) { } else if (TOPIC_SUB_TYPE__TABLE == pReq->subType) { @@ -3052,7 +3260,7 @@ int32_t tSerializeSConnectReq(void *buf, int32_t bufLen, SConnectReq *pReq) { if (tEncodeCStr(&encoder, pReq->app) < 0) return -1; if (tEncodeCStr(&encoder, pReq->db) < 0) return -1; if (tEncodeCStr(&encoder, pReq->user) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->passwd) < 0) return -1; + if (tEncodeCStrWithLen(&encoder, pReq->passwd, TSDB_PASSWORD_LEN) < 0) return -1; if (tEncodeI64(&encoder, pReq->startTime) < 0) return -1; tEndEncode(&encoder); diff --git a/source/common/src/tname.c b/source/common/src/tname.c index fd05513579..ce454d439d 100644 --- a/source/common/src/tname.c +++ b/source/common/src/tname.c @@ -240,6 +240,15 @@ bool tNameDBNameEqual(SName* left, SName* right) { return (0 == strcmp(left->dbname, right->dbname)); } +bool tNameTbNameEqual(SName* left, SName* right) { + bool equal = tNameDBNameEqual(left, right); + if (equal) { + return (0 == strcmp(left->tname, right->tname)); + } + + return equal; +} + int32_t tNameFromString(SName* dst, const char* str, uint32_t type) { assert(dst != NULL && str != NULL && strlen(str) > 0); @@ -312,8 +321,10 @@ void buildChildTableName(RandTableName* rName) { taosStringBuilderAppendStringLen(&sb, rName->sTableName, rName->sTableNameLen); taosArraySort(rName->tags, compareKv); for (int j = 0; j < taosArrayGetSize(rName->tags); ++j) { + taosStringBuilderAppendChar(&sb, ','); SSmlKv* tagKv = taosArrayGetP(rName->tags, j); taosStringBuilderAppendStringLen(&sb, tagKv->key, tagKv->keyLen); + taosStringBuilderAppendChar(&sb, '='); if (IS_VAR_DATA_TYPE(tagKv->type)) { taosStringBuilderAppendStringLen(&sb, tagKv->value, tagKv->length); } else { @@ -326,9 +337,14 @@ void buildChildTableName(RandTableName* rName) { tMD5Init(&context); tMD5Update(&context, (uint8_t*)keyJoined, (uint32_t)len); tMD5Final(&context); - uint64_t digest1 = *(uint64_t*)(context.digest); - uint64_t digest2 = *(uint64_t*)(context.digest + 8); - snprintf(rName->childTableName, TSDB_TABLE_NAME_LEN, "t_%016" PRIx64 "%016" PRIx64, digest1, digest2); + + char temp[8] = {0}; + rName->childTableName[0] = 't'; + rName->childTableName[1] = '_'; + for(int i = 0; i < 16; i++){ + sprintf(temp, "%02x", context.digest[i]); + strcat(rName->childTableName, temp); + } taosStringBuilderDestroy(&sb); - rName->uid = digest1; + rName->uid = *(uint64_t*)(context.digest); } diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index 0112feedd2..474e6ab378 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -73,6 +73,7 @@ int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { } int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { + const STraceId *trace = &pMsg->info.traceId; SDCreateMnodeReq createReq = {0}; if (tDeserializeSDCreateMnodeReq(pMsg->pCont, pMsg->contLen, &createReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; @@ -81,7 +82,7 @@ int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { if (createReq.replica != 1) { terrno = TSDB_CODE_INVALID_OPTION; - dError("failed to create mnode since %s", terrstr()); + dGError("failed to create mnode since %s", terrstr()); return -1; } @@ -91,7 +92,7 @@ int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { mgmt.path = pInput->path; mgmt.name = pInput->name; if (mmWriteFile(&mgmt, &createReq.replicas[0], deployed) != 0) { - dError("failed to write mnode file since %s", terrstr()); + dGError("failed to write mnode file since %s", terrstr()); return -1; } @@ -99,7 +100,8 @@ int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { } int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { - SDDropMnodeReq dropReq = {0}; + const STraceId *trace = &pMsg->info.traceId; + SDDropMnodeReq dropReq = {0}; if (tDeserializeSCreateDropMQSBNodeReq(pMsg->pCont, pMsg->contLen, &dropReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; return -1; @@ -107,7 +109,7 @@ int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { if (pInput->pData->dnodeId != 0 && dropReq.dnodeId != pInput->pData->dnodeId) { terrno = TSDB_CODE_INVALID_OPTION; - dError("failed to drop mnode since %s", terrstr()); + dGError("failed to drop mnode since %s", terrstr()); return -1; } @@ -117,7 +119,7 @@ int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { mgmt.path = pInput->path; mgmt.name = pInput->name; if (mmWriteFile(&mgmt, NULL, deployed) != 0) { - dError("failed to write mnode file since %s", terrstr()); + dGError("failed to write mnode file since %s", terrstr()); return -1; } @@ -180,6 +182,7 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_MND_ALTER_STB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_STB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_TABLE_META, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_TABLE_CFG, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; @@ -216,7 +219,7 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_VND_MQ_VG_DELETE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TASK, mmPutMsgToFetchQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_DROP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIRM_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c index 32477febeb..7f3f76b4b6 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c @@ -18,7 +18,6 @@ static inline int32_t mmAcquire(SMnodeMgmt *pMgmt) { int32_t code = 0; - taosThreadRwlockRdlock(&pMgmt->lock); if (pMgmt->stopped) { code = -1; @@ -48,7 +47,8 @@ static inline void mmSendRsp(SRpcMsg *pMsg, int32_t code) { static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) { SMnodeMgmt *pMgmt = pInfo->ahandle; int32_t code = -1; - STraceId * trace = &pMsg->info.traceId; + + const STraceId *trace = &pMsg->info.traceId; dGTrace("msg:%p, get from mnode queue", pMsg); switch (pMsg->msgType) { @@ -72,7 +72,7 @@ static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) { mndPostProcessQueryMsg(pMsg); } - dTrace("msg:%p, is freed, code:0x%x", pMsg, code); + dGTrace("msg:%p, is freed, code:0x%x", pMsg, code); rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); } @@ -80,7 +80,9 @@ static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) { static void mmProcessSyncMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) { SMnodeMgmt *pMgmt = pInfo->ahandle; pMsg->info.node = pMgmt->pMnode; - dTrace("msg:%p, get from mnode-sync queue", pMsg); + + const STraceId *trace = &pMsg->info.traceId; + dGTrace("msg:%p, get from mnode-sync queue", pMsg); SMsgHead *pHead = pMsg->pCont; pHead->contLen = ntohl(pHead->contLen); @@ -88,20 +90,22 @@ static void mmProcessSyncMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) { int32_t code = mndProcessSyncMsg(pMsg); - dTrace("msg:%p, is freed, code:0x%x", pMsg, code); + dGTrace("msg:%p, is freed, code:0x%x", pMsg, code); rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); } static inline int32_t mmPutMsgToWorker(SMnodeMgmt *pMgmt, SSingleWorker *pWorker, SRpcMsg *pMsg) { + const STraceId *trace = &pMsg->info.traceId; + if (mmAcquire(pMgmt) == 0) { - dTrace("msg:%p, put into %s queue, type:%s", pMsg, pWorker->name, TMSG_INFO(pMsg->msgType)); + dGTrace("msg:%p, put into %s queue, type:%s", pMsg, pWorker->name, TMSG_INFO(pMsg->msgType)); taosWriteQitem(pWorker->queue, pMsg); mmRelease(pMgmt); return 0; } else { - dTrace("msg:%p, failed to put into %s queue since %s, type:%s", pMsg, pWorker->name, terrstr(), - TMSG_INFO(pMsg->msgType)); + dGTrace("msg:%p, failed to put into %s queue since %s, type:%s", pMsg, pWorker->name, terrstr(), + TMSG_INFO(pMsg->msgType)); return -1; } } @@ -121,19 +125,17 @@ int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { int32_t mmPutMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { pMsg->info.node = pMgmt->pMnode; if (mndPreProcessQueryMsg(pMsg) != 0) { - dError("msg:%p, failed to pre-process in mnode since %s, type:%s", pMsg, terrstr(), TMSG_INFO(pMsg->msgType)); + const STraceId *trace = &pMsg->info.traceId; + dGError("msg:%p, failed to pre-process in mnode since %s, type:%s", pMsg, terrstr(), TMSG_INFO(pMsg->msgType)); return -1; } return mmPutMsgToWorker(pMgmt, &pMgmt->queryWorker, pMsg); } int32_t mmPutMsgToFetchQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { - pMsg->info.node = pMgmt->pMnode; - return mmPutMsgToWorker(pMgmt, &pMgmt->fetchWorker, pMsg); } - int32_t mmPutMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { return mmPutMsgToWorker(pMgmt, &pMgmt->monitorWorker, pMsg); } diff --git a/source/dnode/mgmt/mgmt_snode/src/smHandle.c b/source/dnode/mgmt/mgmt_snode/src/smHandle.c index 81576e153e..7cb41ca77c 100644 --- a/source/dnode/mgmt/mgmt_snode/src/smHandle.c +++ b/source/dnode/mgmt/mgmt_snode/src/smHandle.c @@ -95,12 +95,14 @@ SArray *smGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_MON_SM_INFO, smPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_DROP, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RUN, smPutNodeMsgToSharedQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH, smPutNodeMsgToSharedQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH_RSP, smPutNodeMsgToSharedQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RECOVER, smPutNodeMsgToSharedQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RECOVER_RSP, smPutNodeMsgToSharedQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE, smPutNodeMsgToSharedQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE_RSP, smPutNodeMsgToSharedQueue, 1) == NULL) goto _OVER; code = 0; _OVER: diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index c3ed6d781c..00d83f0ad4 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -330,6 +330,7 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_TABLE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_UPDATE_TAG_VAL, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_TABLE_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_TABLE_CFG, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_TABLES_META, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_CANCEL_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TASK, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; @@ -351,13 +352,15 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_VND_QUERY_HEARTBEAT, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TRIGGER, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_DROP, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RUN, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DISPATCH_RSP, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RECOVER, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RECOVER_RSP, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_STREAM_RETRIEVE_RSP, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index 71bbc8ddd4..5e1ef23f1c 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c @@ -28,10 +28,10 @@ static inline void vmSendRsp(SRpcMsg *pMsg, int32_t code) { } static void vmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { - SVnodeMgmt *pMgmt = pInfo->ahandle; - int32_t code = -1; + SVnodeMgmt *pMgmt = pInfo->ahandle; + int32_t code = -1; + const STraceId *trace = &pMsg->info.traceId; - STraceId *trace = &pMsg->info.traceId; dGTrace("msg:%p, get from vnode-mgmt queue", pMsg); switch (pMsg->msgType) { case TDMT_MON_VM_INFO: @@ -48,50 +48,52 @@ static void vmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { break; default: terrno = TSDB_CODE_MSG_NOT_PROCESSED; - dError("msg:%p, not processed in vnode-mgmt queue", pMsg); + dGError("msg:%p, not processed in vnode-mgmt queue", pMsg); } if (IsReq(pMsg)) { if (code != 0) { if (terrno != 0) code = terrno; - dError("msg:%p, failed to process since %s", pMsg, terrstr()); + dGError("msg:%p, failed to process since %s", pMsg, terrstr()); } vmSendRsp(pMsg, code); } - dTrace("msg:%p, is freed, code:0x%x", pMsg, code); + dGTrace("msg:%p, is freed, code:0x%x", pMsg, code); rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); } static void vmProcessQueryQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { - SVnodeObj *pVnode = pInfo->ahandle; + SVnodeObj *pVnode = pInfo->ahandle; + const STraceId *trace = &pMsg->info.traceId; - dTrace("vgId:%d, msg:%p get from vnode-query queue", pVnode->vgId, pMsg); + dGTrace("vgId:%d, msg:%p get from vnode-query queue", pVnode->vgId, pMsg); int32_t code = vnodeProcessQueryMsg(pVnode->pImpl, pMsg); if (code != 0) { if (terrno != 0) code = terrno; - dError("vgId:%d, msg:%p failed to query since %s", pVnode->vgId, pMsg, terrstr()); + dGError("vgId:%d, msg:%p failed to query since %s", pVnode->vgId, pMsg, terrstr()); vmSendRsp(pMsg, code); } - dTrace("vgId:%d, msg:%p is freed, code:0x%x", pVnode->vgId, pMsg, code); + dGTrace("vgId:%d, msg:%p is freed, code:0x%x", pVnode->vgId, pMsg, code); rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); } static void vmProcessFetchQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { - SVnodeObj *pVnode = pInfo->ahandle; + SVnodeObj *pVnode = pInfo->ahandle; + const STraceId *trace = &pMsg->info.traceId; - dTrace("vgId:%d, msg:%p get from vnode-fetch queue", pVnode->vgId, pMsg); + dGTrace("vgId:%d, msg:%p get from vnode-fetch queue", pVnode->vgId, pMsg); int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, pMsg, pInfo); if (code != 0) { if (terrno != 0) code = terrno; - dError("vgId:%d, msg:%p failed to fetch since %s", pVnode->vgId, pMsg, terrstr()); + dGError("vgId:%d, msg:%p failed to fetch since %s", pVnode->vgId, pMsg, terrstr()); vmSendRsp(pMsg, code); } - dTrace("vgId:%d, msg:%p is freed, code:0x%x", pVnode->vgId, pMsg, code); + dGTrace("vgId:%d, msg:%p is freed, code:0x%x", pVnode->vgId, pMsg, code); rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); } @@ -102,16 +104,17 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf for (int32_t i = 0; i < numOfMsgs; ++i) { if (taosGetQitem(qall, (void **)&pMsg) == 0) continue; - dTrace("vgId:%d, msg:%p get from vnode-sync queue", pVnode->vgId, pMsg); + const STraceId *trace = &pMsg->info.traceId; + dGTrace("vgId:%d, msg:%p get from vnode-sync queue", pVnode->vgId, pMsg); int32_t code = vnodeProcessSyncReq(pVnode->pImpl, pMsg, NULL); if (code != 0) { if (terrno != 0) code = terrno; - dError("vgId:%d, msg:%p failed to sync since %s", pVnode->vgId, pMsg, terrstr()); + dGError("vgId:%d, msg:%p failed to sync since %s", pVnode->vgId, pMsg, terrstr()); vmSendRsp(pMsg, code); } - dTrace("vgId:%d, msg:%p is freed, code:0x%x", pVnode->vgId, pMsg, code); + dGTrace("vgId:%d, msg:%p is freed, code:0x%x", pVnode->vgId, pMsg, code); rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); } @@ -123,55 +126,57 @@ static void vmProcessMergeQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO for (int32_t i = 0; i < numOfMsgs; ++i) { if (taosGetQitem(qall, (void **)&pMsg) == 0) continue; - dTrace("vgId:%d, msg:%p get from vnode-merge queue", pVnode->vgId, pMsg); + const STraceId *trace = &pMsg->info.traceId; + dGTrace("vgId:%d, msg:%p get from vnode-merge queue", pVnode->vgId, pMsg); int32_t code = vnodeProcessFetchMsg(pVnode->pImpl, pMsg, pInfo); if (code != 0) { if (terrno != 0) code = terrno; - dError("vgId:%d, msg:%p failed to merge since %s", pVnode->vgId, pMsg, terrstr()); + dGError("vgId:%d, msg:%p failed to merge since %s", pVnode->vgId, pMsg, terrstr()); vmSendRsp(pMsg, code); } - dTrace("msg:%p, is freed, code:0x%x", pMsg, code); + dGTrace("msg:%p, is freed, code:0x%x", pMsg, code); rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); } } static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtype) { - SMsgHead *pHead = pMsg->pCont; - int32_t code = 0; + const STraceId *trace = &pMsg->info.traceId; + SMsgHead *pHead = pMsg->pCont; + int32_t code = 0; pHead->contLen = ntohl(pHead->contLen); pHead->vgId = ntohl(pHead->vgId); SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pHead->vgId); if (pVnode == NULL) { - dError("vgId:%d, msg:%p failed to put into vnode queue since %s, type:%s", pHead->vgId, pMsg, terrstr(), - TMSG_INFO(pMsg->msgType)); + dGError("vgId:%d, msg:%p failed to put into vnode queue since %s, type:%s", pHead->vgId, pMsg, terrstr(), + TMSG_INFO(pMsg->msgType)); return terrno != 0 ? terrno : -1; } switch (qtype) { case QUERY_QUEUE: vnodePreprocessQueryMsg(pVnode->pImpl, pMsg); - dTrace("vgId:%d, msg:%p put into vnode-query queue", pVnode->vgId, pMsg); + dGTrace("vgId:%d, msg:%p put into vnode-query queue", pVnode->vgId, pMsg); taosWriteQitem(pVnode->pQueryQ, pMsg); break; case FETCH_QUEUE: - dTrace("vgId:%d, msg:%p put into vnode-fetch queue", pVnode->vgId, pMsg); + dGTrace("vgId:%d, msg:%p put into vnode-fetch queue", pVnode->vgId, pMsg); taosWriteQitem(pVnode->pFetchQ, pMsg); break; case WRITE_QUEUE: - dTrace("vgId:%d, msg:%p put into vnode-write queue", pVnode->vgId, pMsg); + dGTrace("vgId:%d, msg:%p put into vnode-write queue", pVnode->vgId, pMsg); taosWriteQitem(pVnode->pWriteQ, pMsg); break; case SYNC_QUEUE: - dTrace("vgId:%d, msg:%p put into vnode-sync queue", pVnode->vgId, pMsg); + dGTrace("vgId:%d, msg:%p put into vnode-sync queue", pVnode->vgId, pMsg); taosWriteQitem(pVnode->pSyncQ, pMsg); break; case APPLY_QUEUE: - dTrace("vgId:%d, msg:%p put into vnode-apply queue", pVnode->vgId, pMsg); + dGTrace("vgId:%d, msg:%p put into vnode-apply queue", pVnode->vgId, pMsg); taosWriteQitem(pVnode->pApplyQ, pMsg); break; default: @@ -193,13 +198,15 @@ int32_t vmPutMsgToQueryQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmPutMsg int32_t vmPutMsgToFetchQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmPutMsgToQueue(pMgmt, pMsg, FETCH_QUEUE); } int32_t vmPutMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { - dTrace("msg:%p, put into vnode-mgmt queue", pMsg); + const STraceId *trace = &pMsg->info.traceId; + dGTrace("msg:%p, put into vnode-mgmt queue", pMsg); taosWriteQitem(pMgmt->mgmtWorker.queue, pMsg); return 0; } int32_t vmPutMsgToMonitorQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { - dTrace("msg:%p, put into vnode-monitor queue", pMsg); + const STraceId *trace = &pMsg->info.traceId; + dGTrace("msg:%p, put into vnode-monitor queue", pMsg); taosWriteQitem(pMgmt->monitorWorker.queue, pMsg); return 0; } diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index 660f512fc5..4761e3dc36 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -17,9 +17,44 @@ #include "dmMgmt.h" #include "qworker.h" -static void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet); -static void dmSendRsp(SRpcMsg *pMsg); -static void dmBuildMnodeRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg); +static inline void dmSendRsp(SRpcMsg *pMsg) { + SMgmtWrapper *pWrapper = pMsg->info.wrapper; + if (InChildProc(pWrapper)) { + dmPutToProcPQueue(&pWrapper->proc, pMsg, DND_FUNC_RSP); + } else { + rpcSendResponse(pMsg); + } +} + +static inline void dmBuildMnodeRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg) { + SEpSet epSet = {0}; + dmGetMnodeEpSetForRedirect(&pDnode->data, pMsg, &epSet); + + const int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet); + pMsg->pCont = rpcMallocCont(contLen); + if (pMsg->pCont == NULL) { + pMsg->code = TSDB_CODE_OUT_OF_MEMORY; + } else { + tSerializeSEpSet(pMsg->pCont, contLen, &epSet); + pMsg->contLen = contLen; + } +} + +static inline void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet) { + SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info}; + int32_t contLen = tSerializeSEpSet(NULL, 0, pNewEpSet); + + rsp.pCont = rpcMallocCont(contLen); + if (rsp.pCont == NULL) { + pMsg->code = TSDB_CODE_OUT_OF_MEMORY; + } else { + tSerializeSEpSet(rsp.pCont, contLen, pNewEpSet); + rsp.contLen = contLen; + } + dmSendRsp(&rsp); + rpcFreeCont(pMsg->pCont); + pMsg->pCont = NULL; +} int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) { NodeMsgFp msgFp = pWrapper->msgFps[TMSG_INDEX(pMsg->msgType)]; @@ -28,31 +63,38 @@ int32_t dmProcessNodeMsg(SMgmtWrapper *pWrapper, SRpcMsg *pMsg) { return -1; } - dTrace("msg:%p, will be processed by %s", pMsg, pWrapper->name); + const STraceId *trace = &pMsg->info.traceId; + dGTrace("msg:%p, will be processed by %s", pMsg, pWrapper->name); pMsg->info.wrapper = pWrapper; return (*msgFp)(pWrapper->pMgmt, pMsg); } static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) { - SDnodeTrans * pTrans = &pDnode->trans; + SDnodeTrans *pTrans = &pDnode->trans; int32_t code = -1; - SRpcMsg * pMsg = NULL; + SRpcMsg *pMsg = NULL; SMgmtWrapper *pWrapper = NULL; SDnodeHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(pRpc->msgType)]; - STraceId *trace = &pRpc->info.traceId; + const STraceId *trace = &pRpc->info.traceId; dGTrace("msg:%s is received, handle:%p len:%d code:0x%x app:%p refId:%" PRId64, TMSG_INFO(pRpc->msgType), pRpc->info.handle, pRpc->contLen, pRpc->code, pRpc->info.ahandle, pRpc->info.refId); - if (pRpc->msgType == TDMT_DND_NET_TEST) { - dmProcessNetTestReq(pDnode, pRpc); - return; - } else if (pRpc->msgType == TDMT_MND_SYSTABLE_RETRIEVE_RSP || pRpc->msgType == TDMT_VND_FETCH_RSP) { - qWorkerProcessFetchRsp(NULL, NULL, pRpc, 0); - return; - } else if (pRpc->msgType == TDMT_MND_STATUS_RSP && pEpSet != NULL) { - dmSetMnodeEpSet(&pDnode->data, pEpSet); - } else { + switch (pRpc->msgType) { + case TDMT_DND_NET_TEST: + dmProcessNetTestReq(pDnode, pRpc); + return; + case TDMT_MND_SYSTABLE_RETRIEVE_RSP: + case TDMT_VND_FETCH_RSP: + qWorkerProcessFetchRsp(NULL, NULL, pRpc, 0); + return; + case TDMT_MND_STATUS_RSP: + if (pEpSet != NULL) { + dmSetMnodeEpSet(&pDnode->data, pEpSet); + } + break; + default: + break; } if (pDnode->status != DND_STAT_RUNNING) { @@ -73,39 +115,43 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) { if (pHandle->defaultNtype == NODE_END) { terrno = TSDB_CODE_MSG_NOT_PROCESSED; goto _OVER; - } else { - pWrapper = &pDnode->wrappers[pHandle->defaultNtype]; - if (pHandle->needCheckVgId) { - if (pRpc->contLen > 0) { - SMsgHead *pHead = pRpc->pCont; - int32_t vgId = ntohl(pHead->vgId); - if (vgId == QNODE_HANDLE) { + } + + pWrapper = &pDnode->wrappers[pHandle->defaultNtype]; + if (pHandle->needCheckVgId) { + if (pRpc->contLen > 0) { + const SMsgHead *pHead = pRpc->pCont; + const int32_t vgId = ntohl(pHead->vgId); + switch (vgId) { + case QNODE_HANDLE: pWrapper = &pDnode->wrappers[QNODE]; - } else if (vgId == SNODE_HANDLE) { + break; + case SNODE_HANDLE: pWrapper = &pDnode->wrappers[SNODE]; - } else if (vgId == MNODE_HANDLE) { + break; + case MNODE_HANDLE: pWrapper = &pDnode->wrappers[MNODE]; - } else { - } - } else { - terrno = TSDB_CODE_INVALID_MSG_LEN; - goto _OVER; + break; + default: + break; } + } else { + terrno = TSDB_CODE_INVALID_MSG_LEN; + goto _OVER; } } if (dmMarkWrapper(pWrapper) != 0) { pWrapper = NULL; goto _OVER; - } else { - pRpc->info.wrapper = pWrapper; } + pRpc->info.wrapper = pWrapper; pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM); if (pMsg == NULL) goto _OVER; - memcpy(pMsg, pRpc, sizeof(SRpcMsg)); - dTrace("msg:%p, is created, type:%s handle:%p", pMsg, TMSG_INFO(pRpc->msgType), pMsg->info.handle); + memcpy(pMsg, pRpc, sizeof(SRpcMsg)); + dGTrace("msg:%p, is created, type:%s handle:%p", pMsg, TMSG_INFO(pRpc->msgType), pMsg->info.handle); if (InParentProc(pWrapper)) { code = dmPutToProcCQueue(&pWrapper->proc, pMsg, DND_FUNC_REQ); @@ -115,13 +161,11 @@ static void dmProcessRpcMsg(SDnode *pDnode, SRpcMsg *pRpc, SEpSet *pEpSet) { _OVER: if (code != 0) { - dTrace("failed to process msg:%p since %s, handle:%p", pMsg, terrstr(), pRpc->info.handle); - if (terrno != 0) code = terrno; + dGTrace("msg:%p, failed to process since %s", pMsg, terrstr()); if (IsReq(pRpc)) { SRpcMsg rsp = {.code = code, .info = pRpc->info}; - if ((code == TSDB_CODE_NODE_NOT_DEPLOYED || code == TSDB_CODE_APP_NOT_READY) && pRpc->msgType > TDMT_MND_MSG && pRpc->msgType < TDMT_VND_MSG) { dmBuildMnodeRedirectRsp(pDnode, &rsp); @@ -135,7 +179,7 @@ _OVER: } if (pMsg != NULL) { - dTrace("msg:%p, is freed", pMsg); + dGTrace("msg:%p, is freed", pMsg); taosFreeQitem(pMsg); } rpcFreeCont(pRpc->pCont); @@ -149,11 +193,11 @@ int32_t dmInitMsgHandle(SDnode *pDnode) { for (EDndNodeType ntype = DNODE; ntype < NODE_END; ++ntype) { SMgmtWrapper *pWrapper = &pDnode->wrappers[ntype]; - SArray * pArray = (*pWrapper->func.getHandlesFp)(); + SArray *pArray = (*pWrapper->func.getHandlesFp)(); if (pArray == NULL) return -1; for (int32_t i = 0; i < taosArrayGetSize(pArray); ++i) { - SMgmtHandle * pMgmt = taosArrayGet(pArray, i); + SMgmtHandle *pMgmt = taosArrayGet(pArray, i); SDnodeHandle *pHandle = &pTrans->msgHandles[TMSG_INDEX(pMgmt->msgType)]; if (pMgmt->needCheckVgId) { pHandle->needCheckVgId = pMgmt->needCheckVgId; @@ -184,45 +228,6 @@ static inline int32_t dmSendReq(const SEpSet *pEpSet, SRpcMsg *pMsg) { } } -static inline void dmSendRsp(SRpcMsg *pMsg) { - SMgmtWrapper *pWrapper = pMsg->info.wrapper; - if (InChildProc(pWrapper)) { - dmPutToProcPQueue(&pWrapper->proc, pMsg, DND_FUNC_RSP); - } else { - rpcSendResponse(pMsg); - } -} - -static void dmBuildMnodeRedirectRsp(SDnode *pDnode, SRpcMsg *pMsg) { - SEpSet epSet = {0}; - dmGetMnodeEpSetForRedirect(&pDnode->data, pMsg, &epSet); - - int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet); - pMsg->pCont = rpcMallocCont(contLen); - if (pMsg->pCont == NULL) { - pMsg->code = TSDB_CODE_OUT_OF_MEMORY; - } else { - tSerializeSEpSet(pMsg->pCont, contLen, &epSet); - pMsg->contLen = contLen; - } -} - -static inline void dmSendRedirectRsp(SRpcMsg *pMsg, const SEpSet *pNewEpSet) { - SRpcMsg rsp = {.code = TSDB_CODE_RPC_REDIRECT, .info = pMsg->info}; - int32_t contLen = tSerializeSEpSet(NULL, 0, pNewEpSet); - - rsp.pCont = rpcMallocCont(contLen); - if (rsp.pCont == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - } else { - tSerializeSEpSet(rsp.pCont, contLen, pNewEpSet); - rsp.contLen = contLen; - } - dmSendRsp(&rsp); - rpcFreeCont(pMsg->pCont); - pMsg->pCont = NULL; -} - static inline void dmRegisterBrokenLinkArg(SRpcMsg *pMsg) { SMgmtWrapper *pWrapper = pMsg->info.wrapper; if (InChildProc(pWrapper)) { diff --git a/source/dnode/mgmt/node_util/inc/dmUtil.h b/source/dnode/mgmt/node_util/inc/dmUtil.h index 7897f62f62..01958aa053 100644 --- a/source/dnode/mgmt/node_util/inc/dmUtil.h +++ b/source/dnode/mgmt/node_util/inc/dmUtil.h @@ -40,18 +40,28 @@ #include "wal.h" #include "libs/function/function.h" -// clang-format off #ifdef __cplusplus extern "C" { #endif -#define dFatal(...) { if (dDebugFlag & DEBUG_FATAL) { taosPrintLog("DND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} -#define dError(...) { if (dDebugFlag & DEBUG_ERROR) { taosPrintLog("DND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} -#define dWarn(...) { if (dDebugFlag & DEBUG_WARN) { taosPrintLog("DND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} -#define dInfo(...) { if (dDebugFlag & DEBUG_INFO) { taosPrintLog("DND ", DEBUG_INFO, 255, __VA_ARGS__); }} -#define dDebug(...) { if (dDebugFlag & DEBUG_DEBUG) { taosPrintLog("DND ", DEBUG_DEBUG, dDebugFlag, __VA_ARGS__); }} -#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", DEBUG_TRACE, dDebugFlag, __VA_ARGS__); }} -#define dGTrace(param, ...) do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dTrace(param ",GTID: %s", __VA_ARGS__, buf);} while(0) + +// clang-format off + +#define dFatal(...) { if (dDebugFlag & DEBUG_FATAL) { taosPrintLog("DND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} +#define dError(...) { if (dDebugFlag & DEBUG_ERROR) { taosPrintLog("DND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} +#define dWarn(...) { if (dDebugFlag & DEBUG_WARN) { taosPrintLog("DND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} +#define dInfo(...) { if (dDebugFlag & DEBUG_INFO) { taosPrintLog("DND ", DEBUG_INFO, 255, __VA_ARGS__); }} +#define dDebug(...) { if (dDebugFlag & DEBUG_DEBUG) { taosPrintLog("DND ", DEBUG_DEBUG, dDebugFlag, __VA_ARGS__); }} +#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", DEBUG_TRACE, dDebugFlag, __VA_ARGS__); }} + +#define dGFatal(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dFatal(param ", gtid:%s", __VA_ARGS__, buf);} +#define dGError(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dError(param ", gtid:%s", __VA_ARGS__, buf);} +#define dGWarn(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dWarn (param ", gtid:%s", __VA_ARGS__, buf);} +#define dGInfo(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dInfo (param ", gtid:%s", __VA_ARGS__, buf);} +#define dGDebug(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dDebug(param ", gtid:%s", __VA_ARGS__, buf);} +#define dGTrace(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dTrace(param ", gtid:%s", __VA_ARGS__, buf);} + +// clang-format on typedef enum { DNODE = 0, @@ -185,4 +195,3 @@ void dmSetMnodeEpSet(SDnodeData *pData, SEpSet *pEpSet); #endif #endif /*_TD_DM_INT_H_*/ -// clang-format on diff --git a/source/dnode/mgmt/test/sut/src/sut.cpp b/source/dnode/mgmt/test/sut/src/sut.cpp index 6ef94481ea..21d9351ceb 100644 --- a/source/dnode/mgmt/test/sut/src/sut.cpp +++ b/source/dnode/mgmt/test/sut/src/sut.cpp @@ -102,6 +102,7 @@ int32_t Testbase::SendShowReq(int8_t showType, const char* tb, const char* db) { ASSERT(pRsp->pCont != nullptr); if (pRsp->contLen == 0) return -1; + if (pRsp->code != 0) return -1; showRsp = (SRetrieveMetaTableRsp*)pRsp->pCont; showRsp->handle = htobe64(showRsp->handle); // show Id diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 987b01b96a..0605e3a69e 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -349,6 +349,7 @@ typedef struct { int32_t commentLen; int32_t ast1Len; int32_t ast2Len; + SArray* pFuncs; SSchema* pColumns; SSchema* pTags; char* comment; @@ -420,7 +421,8 @@ typedef struct { int64_t uid; int64_t dbUid; int32_t version; - int8_t subType; // column, db or stable + int8_t subType; // column, db or stable + int8_t withMeta; // TODO SRWLatch lock; int32_t sqlLen; int32_t astLen; @@ -487,6 +489,7 @@ typedef struct { int64_t dbUid; int32_t vgNum; int8_t subType; + int8_t withMeta; int64_t stbUid; SHashObj* consumerHash; // consumerId -> SMqConsumerEp SArray* unassignedVgs; // SArray diff --git a/source/dnode/mnode/impl/inc/mndInfoSchema.h b/source/dnode/mnode/impl/inc/mndInfoSchema.h index 43d934c431..b10d92ee3d 100644 --- a/source/dnode/mnode/impl/inc/mndInfoSchema.h +++ b/source/dnode/mnode/impl/inc/mndInfoSchema.h @@ -25,6 +25,7 @@ extern "C" { int32_t mndInitInfos(SMnode *pMnode); void mndCleanupInfos(SMnode *pMnode); int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp); +int32_t mndBuildInsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbName, STableCfgRsp *pRsp); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/inc/mndInt.h b/source/dnode/mnode/impl/inc/mndInt.h index c810a0cbc7..58266724a5 100644 --- a/source/dnode/mnode/impl/inc/mndInt.h +++ b/source/dnode/mnode/impl/inc/mndInt.h @@ -34,13 +34,21 @@ extern "C" { #endif // clang-format off -#define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} -#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} -#define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("MND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} -#define mInfo(...) { if (mDebugFlag & DEBUG_INFO) { taosPrintLog("MND ", DEBUG_INFO, 255, __VA_ARGS__); }} -#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", DEBUG_DEBUG, mDebugFlag, __VA_ARGS__); }} -#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }} -#define mGTrace(param, ...) do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mTrace(param ", GTID: %s", __VA_ARGS__, buf);} while(0) + + +#define mFatal(...) { if (mDebugFlag & DEBUG_FATAL) { taosPrintLog("MND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} +#define mError(...) { if (mDebugFlag & DEBUG_ERROR) { taosPrintLog("MND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} +#define mWarn(...) { if (mDebugFlag & DEBUG_WARN) { taosPrintLog("MND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} +#define mInfo(...) { if (mDebugFlag & DEBUG_INFO) { taosPrintLog("MND ", DEBUG_INFO, 255, __VA_ARGS__); }} +#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", DEBUG_DEBUG, mDebugFlag, __VA_ARGS__); }} +#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }} + +#define mGFatal(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mFatal(param ", gtid:%s", __VA_ARGS__, buf);} +#define mGError(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mError(param ", gtid:%s", __VA_ARGS__, buf);} +#define mGWarn(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mWarn (param ", gtid:%s", __VA_ARGS__, buf);} +#define mGInfo(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mInfo (param ", gtid:%s", __VA_ARGS__, buf);} +#define mGDebug(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mDebug(param ", gtid:%s", __VA_ARGS__, buf);} +#define mGTrace(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mTrace(param ", gtid:%s", __VA_ARGS__, buf);} // clang-format on @@ -70,7 +78,7 @@ typedef struct { typedef struct { SCacheObj *connCache; - SCacheObj *appCache; + SCacheObj *appCache; } SProfileMgmt; typedef struct { diff --git a/source/dnode/mnode/impl/inc/mndPerfSchema.h b/source/dnode/mnode/impl/inc/mndPerfSchema.h index 19f60229f9..87b4626e83 100644 --- a/source/dnode/mnode/impl/inc/mndPerfSchema.h +++ b/source/dnode/mnode/impl/inc/mndPerfSchema.h @@ -23,6 +23,7 @@ extern "C" { #endif int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp); +int32_t mndBuildPerfsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbName, STableCfgRsp *pRsp); int32_t mndInitPerfs(SMnode *pMnode); void mndCleanupPerfs(SMnode *pMnode); diff --git a/source/dnode/mnode/impl/inc/mndQnode.h b/source/dnode/mnode/impl/inc/mndQnode.h index 3e38565a4f..17615500c4 100644 --- a/source/dnode/mnode/impl/inc/mndQnode.h +++ b/source/dnode/mnode/impl/inc/mndQnode.h @@ -24,12 +24,12 @@ extern "C" { #define QNODE_LOAD_VALUE(pQnode) (pQnode ? (pQnode->load.numOfQueryInQueue + pQnode->load.numOfFetchInQueue) : 0) -int32_t mndInitQnode(SMnode *pMnode); -void mndCleanupQnode(SMnode *pMnode); - +int32_t mndInitQnode(SMnode *pMnode); +void mndCleanupQnode(SMnode *pMnode); SQnodeObj *mndAcquireQnode(SMnode *pMnode, int32_t qnodeId); -void mndReleaseQnode(SMnode *pMnode, SQnodeObj *pObj); -int32_t mndCreateQnodeList(SMnode *pMnode, SArray** pList, int32_t limit); +void mndReleaseQnode(SMnode *pMnode, SQnodeObj *pObj); +int32_t mndCreateQnodeList(SMnode *pMnode, SArray **pList, int32_t limit); +int32_t mndSetDropQnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SQnodeObj *pObj); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/inc/mndSnode.h b/source/dnode/mnode/impl/inc/mndSnode.h index 180f18a6dd..ec7bb02ca7 100644 --- a/source/dnode/mnode/impl/inc/mndSnode.h +++ b/source/dnode/mnode/impl/inc/mndSnode.h @@ -22,9 +22,12 @@ extern "C" { #endif -int32_t mndInitSnode(SMnode *pMnode); -void mndCleanupSnode(SMnode *pMnode); -SEpSet mndAcquireEpFromSnode(SMnode *pMnode, const SSnodeObj *pSnode); +int32_t mndInitSnode(SMnode *pMnode); +void mndCleanupSnode(SMnode *pMnode); +SSnodeObj *mndAcquireSnode(SMnode *pMnode, int32_t qnodeId); +void mndReleaseSnode(SMnode *pMnode, SSnodeObj *pObj); +SEpSet mndAcquireEpFromSnode(SMnode *pMnode, const SSnodeObj *pSnode); +int32_t mndSetDropSnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SSnodeObj *pObj); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/src/mndDef.c b/source/dnode/mnode/impl/src/mndDef.c index 20ba71992e..dc7f08ebc2 100644 --- a/source/dnode/mnode/impl/src/mndDef.c +++ b/source/dnode/mnode/impl/src/mndDef.c @@ -381,6 +381,7 @@ SMqSubscribeObj *tCloneSubscribeObj(const SMqSubscribeObj *pSub) { pSubNew->dbUid = pSub->dbUid; pSubNew->stbUid = pSub->stbUid; pSubNew->subType = pSub->subType; + pSubNew->withMeta = pSub->withMeta; pSubNew->vgNum = pSub->vgNum; pSubNew->consumerHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); @@ -414,6 +415,7 @@ int32_t tEncodeSubscribeObj(void **buf, const SMqSubscribeObj *pSub) { tlen += taosEncodeFixedI64(buf, pSub->dbUid); tlen += taosEncodeFixedI32(buf, pSub->vgNum); tlen += taosEncodeFixedI8(buf, pSub->subType); + tlen += taosEncodeFixedI8(buf, pSub->withMeta); tlen += taosEncodeFixedI64(buf, pSub->stbUid); void *pIter = NULL; @@ -440,6 +442,7 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub) { buf = taosDecodeFixedI64(buf, &pSub->dbUid); buf = taosDecodeFixedI32(buf, &pSub->vgNum); buf = taosDecodeFixedI8(buf, &pSub->subType); + buf = taosDecodeFixedI8(buf, &pSub->withMeta); buf = taosDecodeFixedI64(buf, &pSub->stbUid); int32_t sz; diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 58c3570c36..8d06868955 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -19,6 +19,7 @@ #include "mndMnode.h" #include "mndQnode.h" #include "mndShow.h" +#include "mndSnode.h" #include "mndTrans.h" #include "mndUser.h" #include "mndVgroup.h" @@ -370,7 +371,8 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { SMnodeObj *pObj = mndAcquireMnode(pMnode, pDnode->id); if (pObj != NULL) { if (pObj->state != statusReq.mload.syncState) { - mInfo("dnode:%d, mnode syncstate from %s to %s", pObj->id, syncStr(pObj->state), syncStr(statusReq.mload.syncState)); + mInfo("dnode:%d, mnode syncstate from %s to %s", pObj->id, syncStr(pObj->state), + syncStr(statusReq.mload.syncState)); pObj->state = statusReq.mload.syncState; pObj->stateStartTime = taosGetTimestampMs(); } @@ -508,7 +510,7 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) { goto _OVER; } - mDebug("dnode:%s:%d, start to create", createReq.fqdn, createReq.port); + mInfo("dnode:%s:%d, start to create", createReq.fqdn, createReq.port); if (createReq.fqdn[0] == 0 || createReq.port <= 0 || createReq.port > UINT16_MAX) { terrno = TSDB_CODE_MND_INVALID_DNODE_EP; @@ -538,7 +540,8 @@ _OVER: return code; } -static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SMnodeObj *pMObj, int32_t numOfVnodes) { +static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SMnodeObj *pMObj, SQnodeObj *pQObj, + SSnodeObj *pSObj, int32_t numOfVnodes) { int32_t code = -1; SSdbRaw *pRaw = NULL; STrans *pTrans = NULL; @@ -546,7 +549,7 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pReq); if (pTrans == NULL) goto _OVER; mndTransSetSerial(pTrans); - mDebug("trans:%d, used to drop dnode:%d", pTrans->id, pDnode->id); + mInfo("trans:%d, used to drop dnode:%d", pTrans->id, pDnode->id); pRaw = mndDnodeActionEncode(pDnode); if (pRaw == NULL || mndTransAppendRedolog(pTrans, pRaw) != 0) goto _OVER; @@ -559,11 +562,22 @@ static int32_t mndDropDnode(SMnode *pMnode, SRpcMsg *pReq, SDnodeObj *pDnode, SM pRaw = NULL; if (pMObj != NULL) { - mDebug("trans:%d, mnode on dnode:%d will be dropped", pTrans->id, pDnode->id); + mInfo("trans:%d, mnode on dnode:%d will be dropped", pTrans->id, pDnode->id); if (mndSetDropMnodeInfoToTrans(pMnode, pTrans, pMObj) != 0) goto _OVER; } + + if (pQObj != NULL) { + mInfo("trans:%d, qnode on dnode:%d will be dropped", pTrans->id, pDnode->id); + if (mndSetDropQnodeInfoToTrans(pMnode, pTrans, pQObj) != 0) goto _OVER; + } + + if (pSObj != NULL) { + mInfo("trans:%d, snode on dnode:%d will be dropped", pTrans->id, pDnode->id); + if (mndSetDropSnodeInfoToTrans(pMnode, pTrans, pSObj) != 0) goto _OVER; + } + if (numOfVnodes > 0) { - mDebug("trans:%d, %d vnodes on dnode:%d will be dropped", pTrans->id, numOfVnodes, pDnode->id); + mInfo("trans:%d, %d vnodes on dnode:%d will be dropped", pTrans->id, numOfVnodes, pDnode->id); if (mndSetMoveVgroupsInfoToTrans(pMnode, pTrans, pDnode->id) != 0) goto _OVER; } if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; @@ -581,6 +595,8 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) { int32_t code = -1; SDnodeObj *pDnode = NULL; SMnodeObj *pMObj = NULL; + SQnodeObj *pQObj = NULL; + SSnodeObj *pSObj = NULL; SMDropMnodeReq dropReq = {0}; if (tDeserializeSCreateDropMQSBNodeReq(pReq->pCont, pReq->contLen, &dropReq) != 0) { @@ -588,7 +604,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) { goto _OVER; } - mDebug("dnode:%d, start to drop", dropReq.dnodeId); + mInfo("dnode:%d, start to drop", dropReq.dnodeId); if (dropReq.dnodeId <= 0) { terrno = TSDB_CODE_MND_INVALID_DNODE_ID; @@ -601,6 +617,8 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) { goto _OVER; } + pQObj = mndAcquireQnode(pMnode, dropReq.dnodeId); + pSObj = mndAcquireSnode(pMnode, dropReq.dnodeId); pMObj = mndAcquireMnode(pMnode, dropReq.dnodeId); if (pMObj != NULL) { if (sdbGetSize(pMnode->pSdb, SDB_MNODE) <= 1) { @@ -627,7 +645,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) { goto _OVER; } - code = mndDropDnode(pMnode, pReq, pDnode, pMObj, numOfVnodes); + code = mndDropDnode(pMnode, pReq, pDnode, pMObj, pQObj, pSObj, numOfVnodes); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; _OVER: @@ -637,6 +655,8 @@ _OVER: mndReleaseDnode(pMnode, pDnode); mndReleaseMnode(pMnode, pMObj); + mndReleaseQnode(pMnode, pQObj); + mndReleaseSnode(pMnode, pSObj); return code; } diff --git a/source/dnode/mnode/impl/src/mndInfoSchema.c b/source/dnode/mnode/impl/src/mndInfoSchema.c index c9bccaf1d0..45fefaf870 100644 --- a/source/dnode/mnode/impl/src/mndInfoSchema.c +++ b/source/dnode/mnode/impl/src/mndInfoSchema.c @@ -90,6 +90,38 @@ int32_t mndBuildInsTableSchema(SMnode *pMnode, const char *dbFName, const char * return 0; } +int32_t mndBuildInsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbName, STableCfgRsp *pRsp) { + if (NULL == pMnode->infosMeta) { + terrno = TSDB_CODE_MND_NOT_READY; + return -1; + } + + STableMetaRsp *pMeta = taosHashGet(pMnode->infosMeta, tbName, strlen(tbName)); + if (NULL == pMeta) { + mError("invalid information schema table name:%s", tbName); + terrno = TSDB_CODE_MND_INVALID_SYS_TABLENAME; + return -1; + } + + strcpy(pRsp->tbName, pMeta->tbName); + strcpy(pRsp->stbName, pMeta->stbName); + strcpy(pRsp->dbFName, pMeta->dbFName); + pRsp->numOfTags = pMeta->numOfTags; + pRsp->numOfColumns = pMeta->numOfColumns; + pRsp->tableType = pMeta->tableType; + + pRsp->pSchemas = taosMemoryCalloc(pMeta->numOfColumns, sizeof(SSchema)); + if (pRsp->pSchemas == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + pRsp->pSchemas = NULL; + return -1; + } + + memcpy(pRsp->pSchemas, pMeta->pSchemas, pMeta->numOfColumns * sizeof(SSchema)); + return 0; +} + + int32_t mndInitInfos(SMnode *pMnode) { pMnode->infosMeta = taosHashInit(20, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), false, HASH_NO_LOCK); if (pMnode->infosMeta == NULL) { diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index ef82d1131c..675a3aa03f 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -59,22 +59,28 @@ static void *mndBuildTimerMsg(int32_t *pContLen) { static void mndPullupTrans(SMnode *pMnode) { int32_t contLen = 0; void *pReq = mndBuildTimerMsg(&contLen); - SRpcMsg rpcMsg = {.msgType = TDMT_MND_TRANS_TIMER, .pCont = pReq, .contLen = contLen}; - tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + if (pReq != NULL) { + SRpcMsg rpcMsg = {.msgType = TDMT_MND_TRANS_TIMER, .pCont = pReq, .contLen = contLen}; + tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg); + } } static void mndCalMqRebalance(SMnode *pMnode) { int32_t contLen = 0; void *pReq = mndBuildTimerMsg(&contLen); - SRpcMsg rpcMsg = {.msgType = TDMT_MND_MQ_TIMER, .pCont = pReq, .contLen = contLen}; - tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg); + if (pReq != NULL) { + SRpcMsg rpcMsg = {.msgType = TDMT_MND_MQ_TIMER, .pCont = pReq, .contLen = contLen}; + tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg); + } } static void mndPullupTelem(SMnode *pMnode) { int32_t contLen = 0; void *pReq = mndBuildTimerMsg(&contLen); - SRpcMsg rpcMsg = {.msgType = TDMT_MND_TELEM_TIMER, .pCont = pReq, .contLen = contLen}; - tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg); + if (pReq != NULL) { + SRpcMsg rpcMsg = {.msgType = TDMT_MND_TELEM_TIMER, .pCont = pReq, .contLen = contLen}; + tmsgPutToQueue(&pMnode->msgCb, READ_QUEUE, &rpcMsg); + } } static void mndPushTtlTime(SMnode *pMnode) { @@ -89,10 +95,11 @@ static void mndPushTtlTime(SMnode *pMnode) { int32_t contLen = sizeof(SMsgHead) + sizeof(int32_t); SMsgHead *pHead = rpcMallocCont(contLen); if (pHead == NULL) { - mError("ttl time malloc err. contLen:%d", contLen); + sdbCancelFetch(pSdb, pIter); sdbRelease(pSdb, pVgroup); continue; } + pHead->contLen = htonl(contLen); pHead->vgId = htonl(pVgroup->vgId); @@ -100,13 +107,13 @@ static void mndPushTtlTime(SMnode *pMnode) { *(int32_t *)(POINTER_SHIFT(pHead, sizeof(SMsgHead))) = htonl(t); SRpcMsg rpcMsg = {.msgType = TDMT_VND_DROP_TTL_TABLE, .pCont = pHead, .contLen = contLen}; - SEpSet epSet = mndGetVgroupEpset(pMnode, pVgroup); int32_t code = tmsgSendReq(&epSet, &rpcMsg); if (code != 0) { - mError("ttl time seed err. code:%d", code); + mError("failed to send ttl time seed msg, code:0x%x", code); + } else { + mInfo("send ttl time seed msg, time:%d", t); } - mError("ttl time seed succ. time:%d", t); sdbRelease(pSdb, pVgroup); } } @@ -117,11 +124,12 @@ static void *mndThreadFp(void *param) { setThreadName("mnode-timer"); while (1) { - if (lastTime % (864000) == 0) { // sleep 1 day for ttl + lastTime++; + + if (lastTime % (864000) == 0) { // sleep 1 day for ttl mndPushTtlTime(pMnode); } - lastTime++; taosMsleep(100); if (mndGetStop(pMnode)) break; @@ -549,23 +557,25 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) { static int32_t mndCheckMnodeState(SRpcMsg *pMsg) { if (!IsReq(pMsg)) return 0; if (mndAcquireRpcRef(pMsg->info.node) == 0) return 0; + if (pMsg->msgType == TDMT_MND_MQ_TIMER || pMsg->msgType == TDMT_MND_TELEM_TIMER || + pMsg->msgType == TDMT_MND_TRANS_TIMER) { + return -1; + } - if (pMsg->msgType != TDMT_MND_MQ_TIMER && pMsg->msgType != TDMT_MND_TELEM_TIMER && - pMsg->msgType != TDMT_MND_TRANS_TIMER) { - mError("msg:%p, failed to check mnode state since %s, type:%s", pMsg, terrstr(), TMSG_INFO(pMsg->msgType)); + const STraceId *trace = &pMsg->info.traceId; + mGError("msg:%p, failed to check mnode state since %s, type:%s", pMsg, terrstr(), TMSG_INFO(pMsg->msgType)); - SEpSet epSet = {0}; - mndGetMnodeEpSet(pMsg->info.node, &epSet); + SEpSet epSet = {0}; + mndGetMnodeEpSet(pMsg->info.node, &epSet); - int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet); - pMsg->info.rsp = rpcMallocCont(contLen); - if (pMsg->info.rsp != NULL) { - tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet); - pMsg->info.rspLen = contLen; - terrno = TSDB_CODE_RPC_REDIRECT; - } else { - terrno = TSDB_CODE_OUT_OF_MEMORY; - } + int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet); + pMsg->info.rsp = rpcMallocCont(contLen); + if (pMsg->info.rsp != NULL) { + tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet); + pMsg->info.rspLen = contLen; + terrno = TSDB_CODE_RPC_REDIRECT; + } else { + terrno = TSDB_CODE_OUT_OF_MEMORY; } return -1; @@ -575,17 +585,20 @@ static int32_t mndCheckMsgContent(SRpcMsg *pMsg) { if (!IsReq(pMsg)) return 0; if (pMsg->contLen != 0 && pMsg->pCont != NULL) return 0; - mError("msg:%p, failed to check msg, cont:%p contLen:%d, app:%p type:%s", pMsg, pMsg->pCont, pMsg->contLen, + const STraceId *trace = &pMsg->info.traceId; + mGError("msg:%p, failed to check msg, cont:%p contLen:%d, app:%p type:%s", pMsg, pMsg->pCont, pMsg->contLen, pMsg->info.ahandle, TMSG_INFO(pMsg->msgType)); terrno = TSDB_CODE_INVALID_MSG_LEN; return -1; } int32_t mndProcessRpcMsg(SRpcMsg *pMsg) { - SMnode *pMnode = pMsg->info.node; + SMnode *pMnode = pMsg->info.node; + const STraceId *trace = &pMsg->info.traceId; + MndMsgFp fp = pMnode->msgFp[TMSG_INDEX(pMsg->msgType)]; if (fp == NULL) { - mError("msg:%p, failed to get msg handle, app:%p type:%s", pMsg, pMsg->info.ahandle, TMSG_INFO(pMsg->msgType)); + mGError("msg:%p, failed to get msg handle, app:%p type:%s", pMsg, pMsg->info.ahandle, TMSG_INFO(pMsg->msgType)); terrno = TSDB_CODE_MSG_NOT_PROCESSED; return -1; } @@ -593,18 +606,17 @@ int32_t mndProcessRpcMsg(SRpcMsg *pMsg) { if (mndCheckMsgContent(pMsg) != 0) return -1; if (mndCheckMnodeState(pMsg) != 0) return -1; - STraceId *trace = &pMsg->info.traceId; mGTrace("msg:%p, start to process in mnode, app:%p type:%s", pMsg, pMsg->info.ahandle, TMSG_INFO(pMsg->msgType)); int32_t code = (*fp)(pMsg); mndReleaseRpcRef(pMnode); if (code == TSDB_CODE_ACTION_IN_PROGRESS) { - mTrace("msg:%p, won't response immediately since in progress", pMsg); + mGTrace("msg:%p, won't response immediately since in progress", pMsg); } else if (code == 0) { - mTrace("msg:%p, successfully processed", pMsg); + mGTrace("msg:%p, successfully processed", pMsg); } else { - mError("msg:%p, failed to process since %s, app:%p type:%s", pMsg, terrstr(), pMsg->info.ahandle, - TMSG_INFO(pMsg->msgType)); + mGError("msg:%p, failed to process since %s, app:%p type:%s", pMsg, terrstr(), pMsg->info.ahandle, + TMSG_INFO(pMsg->msgType)); } return code; @@ -620,7 +632,6 @@ void mndSetMsgHandle(SMnode *pMnode, tmsg_t msgType, MndMsgFp fp) { // Note: uid 0 is reserved int64_t mndGenerateUid(char *name, int32_t len) { int32_t hashval = MurmurHash3_32(name, len); - do { int64_t us = taosGetTimestampUs(); int64_t x = (us & 0x000000FFFFFFFFFF) << 24; diff --git a/source/dnode/mnode/impl/src/mndPerfSchema.c b/source/dnode/mnode/impl/src/mndPerfSchema.c index d7b2e3ec24..7056337c8d 100644 --- a/source/dnode/mnode/impl/src/mndPerfSchema.c +++ b/source/dnode/mnode/impl/src/mndPerfSchema.c @@ -92,6 +92,37 @@ int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char return 0; } +int32_t mndBuildPerfsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbName, STableCfgRsp *pRsp) { + if (NULL == pMnode->perfsMeta) { + terrno = TSDB_CODE_MND_NOT_READY; + return -1; + } + + STableMetaRsp *pMeta = taosHashGet(pMnode->perfsMeta, tbName, strlen(tbName)); + if (NULL == pMeta) { + mError("invalid performance schema table name:%s", tbName); + terrno = TSDB_CODE_MND_INVALID_SYS_TABLENAME; + return -1; + } + + strcpy(pRsp->tbName, pMeta->tbName); + strcpy(pRsp->stbName, pMeta->stbName); + strcpy(pRsp->dbFName, pMeta->dbFName); + pRsp->numOfTags = pMeta->numOfTags; + pRsp->numOfColumns = pMeta->numOfColumns; + pRsp->tableType = pMeta->tableType; + + pRsp->pSchemas = taosMemoryCalloc(pMeta->numOfColumns, sizeof(SSchema)); + if (pRsp->pSchemas == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + pRsp->pSchemas = NULL; + return -1; + } + + memcpy(pRsp->pSchemas, pMeta->pSchemas, pMeta->numOfColumns * sizeof(SSchema)); + return 0; +} + int32_t mndInitPerfs(SMnode *pMnode) { pMnode->perfsMeta = taosHashInit(20, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); if (pMnode->perfsMeta == NULL) { diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index fd80679316..832e328d96 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -122,30 +122,33 @@ static SConnObj *mndCreateConn(SMnode *pMnode, const char *user, int8_t connType int32_t pid, const char *app, int64_t startTime) { SProfileMgmt *pMgmt = &pMnode->profileMgmt; - char connStr[255] = {0}; - int32_t len = snprintf(connStr, sizeof(connStr), "%s%d%d%d%s", user, ip, port, pid, app); + char connStr[255] = {0}; + int32_t len = snprintf(connStr, sizeof(connStr), "%s%d%d%d%s", user, ip, port, pid, app); uint32_t connId = mndGenerateUid(connStr, len); if (startTime == 0) startTime = taosGetTimestampMs(); - SConnObj connObj = {.id = connId, - .connType = connType, - .appStartTimeMs = startTime, - .pid = pid, - .ip = ip, - .port = port, - .killed = 0, - .loginTimeMs = taosGetTimestampMs(), - .lastAccessTimeMs = 0, - .killId = 0, - .numOfQueries = 0, - .pQueries = NULL}; + SConnObj connObj = { + .id = connId, + .connType = connType, + .appStartTimeMs = startTime, + .pid = pid, + .ip = ip, + .port = port, + .killed = 0, + .loginTimeMs = taosGetTimestampMs(), + .lastAccessTimeMs = 0, + .killId = 0, + .numOfQueries = 0, + .pQueries = NULL, + }; connObj.lastAccessTimeMs = connObj.loginTimeMs; tstrncpy(connObj.user, user, TSDB_USER_LEN); tstrncpy(connObj.app, app, TSDB_APP_NAME_LEN); int32_t keepTime = tsShellActivityTimer * 3; - SConnObj *pConn = taosCachePut(pMgmt->connCache, &connId, sizeof(uint32_t), &connObj, sizeof(connObj), keepTime * 1000); + SConnObj *pConn = + taosCachePut(pMgmt->connCache, &connId, sizeof(uint32_t), &connObj, sizeof(connObj), keepTime * 1000); if (pConn == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; mError("conn:%d, failed to put into cache since %s, user:%s", connId, user, terrstr()); @@ -174,7 +177,6 @@ static SConnObj *mndAcquireConn(SMnode *pMnode, uint32_t connId) { } pConn->lastAccessTimeMs = taosGetTimestampMs(); - mTrace("conn:%u, acquired from cache, data:%p", pConn->id, pConn); return pConn; } @@ -207,13 +209,14 @@ static void mndCancelGetNextConn(SMnode *pMnode, void *pIter) { } static int32_t mndProcessConnectReq(SRpcMsg *pReq) { - SMnode *pMnode = pReq->info.node; - SUserObj *pUser = NULL; - SDbObj *pDb = NULL; - SConnObj *pConn = NULL; - int32_t code = -1; - SConnectReq connReq = {0}; - char ip[30] = {0}; + SMnode *pMnode = pReq->info.node; + SUserObj *pUser = NULL; + SDbObj *pDb = NULL; + SConnObj *pConn = NULL; + int32_t code = -1; + SConnectReq connReq = {0}; + char ip[30] = {0}; + const STraceId *trace = &pReq->info.traceId; if (tDeserializeSConnectReq(pReq->pCont, pReq->contLen, &connReq) != 0) { terrno = TSDB_CODE_INVALID_MSG; @@ -224,11 +227,11 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { pUser = mndAcquireUser(pMnode, pReq->info.conn.user); if (pUser == NULL) { - mError("user:%s, failed to login while acquire user since %s", pReq->info.conn.user, terrstr()); + mGError("user:%s, failed to login while acquire user since %s", pReq->info.conn.user, terrstr()); goto CONN_OVER; } if (0 != strncmp(connReq.passwd, pUser->pass, TSDB_PASSWORD_LEN - 1)) { - mError("user:%s, failed to auth while acquire user, input:%s", pReq->info.conn.user, connReq.passwd); + mGError("user:%s, failed to auth while acquire user, input:%s", pReq->info.conn.user, connReq.passwd); code = TSDB_CODE_RPC_AUTH_FAILURE; goto CONN_OVER; } @@ -239,8 +242,8 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { pDb = mndAcquireDb(pMnode, db); if (pDb == NULL) { terrno = TSDB_CODE_MND_INVALID_DB; - mError("user:%s, failed to login from %s while use db:%s since %s", pReq->info.conn.user, ip, connReq.db, - terrstr()); + mGError("user:%s, failed to login from %s while use db:%s since %s", pReq->info.conn.user, ip, connReq.db, + terrstr()); goto CONN_OVER; } } @@ -248,7 +251,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { pConn = mndCreateConn(pMnode, pReq->info.conn.user, connReq.connType, pReq->info.conn.clientIp, pReq->info.conn.clientPort, connReq.pid, connReq.app, connReq.startTime); if (pConn == NULL) { - mError("user:%s, failed to login from %s while create connection since %s", pReq->info.conn.user, ip, terrstr()); + mGError("user:%s, failed to login from %s while create connection since %s", pReq->info.conn.user, ip, terrstr()); goto CONN_OVER; } @@ -273,7 +276,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { pReq->info.rspLen = contLen; pReq->info.rsp = pRsp; - mDebug("user:%s, login from %s:%d, conn:%u, app:%s", pReq->info.conn.user, ip, pConn->port, pConn->id, connReq.app); + mGDebug("user:%s, login from %s:%d, conn:%u, app:%s", pReq->info.conn.user, ip, pConn->port, pConn->id, connReq.app); code = 0; @@ -302,7 +305,7 @@ static int32_t mndSaveQueryList(SConnObj *pConn, SQueryHbReqBasic *pBasic) { return TSDB_CODE_SUCCESS; } -static SAppObj *mndCreateApp(SMnode *pMnode, uint32_t clientIp, SAppHbReq* pReq) { +static SAppObj *mndCreateApp(SMnode *pMnode, uint32_t clientIp, SAppHbReq *pReq) { SProfileMgmt *pMgmt = &pMnode->profileMgmt; SAppObj app; @@ -314,22 +317,19 @@ static SAppObj *mndCreateApp(SMnode *pMnode, uint32_t clientIp, SAppHbReq* pReq) memcpy(&app.summary, &pReq->summary, sizeof(pReq->summary)); app.lastAccessTimeMs = taosGetTimestampMs(); - int32_t keepTime = tsShellActivityTimer * 3; + const int32_t keepTime = tsShellActivityTimer * 3; SAppObj *pApp = taosCachePut(pMgmt->appCache, &pReq->appId, sizeof(pReq->appId), &app, sizeof(app), keepTime * 1000); if (pApp == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; mError("failed to app %" PRIx64 " into cache since %s", pReq->appId, terrstr()); return NULL; } - + mTrace("app %" PRIx64 " is put into cache", pReq->appId); return pApp; } -static void mndFreeApp(SAppObj *pApp) { - mTrace("app %" PRIx64 " is destroyed", pApp->appId); -} - +static void mndFreeApp(SAppObj *pApp) { mTrace("app %" PRIx64 " is destroyed", pApp->appId); } static SAppObj *mndAcquireApp(SMnode *pMnode, int64_t appId) { SProfileMgmt *pMgmt = &pMnode->profileMgmt; @@ -356,7 +356,7 @@ static void mndReleaseApp(SMnode *pMnode, SAppObj *pApp) { void *mndGetNextApp(SMnode *pMnode, SCacheIter *pIter) { SAppObj *pApp = NULL; - bool hasNext = taosCacheIterNext(pIter); + bool hasNext = taosCacheIterNext(pIter); if (hasNext) { size_t dataLen = 0; pApp = taosCacheIterGetData(pIter, &dataLen); @@ -439,16 +439,16 @@ static SClientHbRsp *mndMqHbBuildRsp(SMnode *pMnode, SClientHbReq *pReq) { } static int32_t mndUpdateAppInfo(SMnode *pMnode, SClientHbReq *pHbReq, SRpcConnInfo *connInfo) { - SAppHbReq* pReq = &pHbReq->app; - SAppObj *pApp = mndAcquireApp(pMnode, pReq->appId); + SAppHbReq *pReq = &pHbReq->app; + SAppObj *pApp = mndAcquireApp(pMnode, pReq->appId); if (pApp == NULL) { pApp = mndCreateApp(pMnode, connInfo->clientIp, pReq); if (pApp == NULL) { mError("failed to create new app %" PRIx64 " since %s", pReq->appId, terrstr()); return -1; } else { - mDebug("a new app %" PRIx64 "created", pReq->appId); - mndReleaseApp(pMnode, pApp); + mDebug("a new app %" PRIx64 " is created", pReq->appId); + mndReleaseApp(pMnode, pApp); return TSDB_CODE_SUCCESS; } } @@ -464,7 +464,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb SClientHbBatchRsp *pBatchRsp) { SProfileMgmt *pMgmt = &pMnode->profileMgmt; SClientHbRsp hbRsp = {.connKey = pHbReq->connKey, .status = 0, .info = NULL, .query = NULL}; - SRpcConnInfo connInfo = pMsg->info.conn; + SRpcConnInfo connInfo = pMsg->info.conn; mndUpdateAppInfo(pMnode, pHbReq, &connInfo); @@ -637,9 +637,9 @@ static int32_t mndProcessKillQueryReq(SRpcMsg *pReq) { } mInfo("kill query msg is received, queryId:%s", killReq.queryStrId); - int32_t connId = 0; + int32_t connId = 0; uint64_t queryId = 0; - char* p = strchr(killReq.queryStrId, ':'); + char *p = strchr(killReq.queryStrId, ':'); if (NULL == p) { mError("invalid query id %s", killReq.queryStrId); terrno = TSDB_CODE_MND_INVALID_QUERY_ID; @@ -853,12 +853,12 @@ static int32_t mndRetrieveQueries(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p } static int32_t mndRetrieveApps(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; - SAppObj *pApp = NULL; - + SMnode *pMnode = pReq->info.node; + SSdb *pSdb = pMnode->pSdb; + int32_t numOfRows = 0; + int32_t cols = 0; + SAppObj *pApp = NULL; + if (pShow->pIter == NULL) { SProfileMgmt *pMgmt = &pMnode->profileMgmt; pShow->pIter = taosCacheCreateIter(pMgmt->appCache); @@ -931,7 +931,6 @@ static int32_t mndRetrieveApps(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo return numOfRows; } - static void mndCancelGetNextQuery(SMnode *pMnode, void *pIter) { if (pIter != NULL) { taosCacheDestroyIter(pIter); diff --git a/source/dnode/mnode/impl/src/mndQnode.c b/source/dnode/mnode/impl/src/mndQnode.c index f5625f32d5..0a6c97e63c 100644 --- a/source/dnode/mnode/impl/src/mndQnode.c +++ b/source/dnode/mnode/impl/src/mndQnode.c @@ -354,6 +354,14 @@ static int32_t mndSetDropQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SQn return 0; } +int32_t mndSetDropQnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SQnodeObj *pObj) { + if (pObj == NULL) return 0; + if (mndSetDropQnodeRedoLogs(pTrans, pObj) != 0) return -1; + if (mndSetDropQnodeCommitLogs(pTrans, pObj) != 0) return -1; + if (mndSetDropQnodeRedoActions(pTrans, pObj->pDnode, pObj) != 0) return -1; + return 0; +} + static int32_t mndDropQnode(SMnode *pMnode, SRpcMsg *pReq, SQnodeObj *pObj) { int32_t code = -1; @@ -361,9 +369,7 @@ static int32_t mndDropQnode(SMnode *pMnode, SRpcMsg *pReq, SQnodeObj *pObj) { if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to drop qnode:%d", pTrans->id, pObj->id); - if (mndSetDropQnodeRedoLogs(pTrans, pObj) != 0) goto _OVER; - if (mndSetDropQnodeCommitLogs(pTrans, pObj) != 0) goto _OVER; - if (mndSetDropQnodeRedoActions(pTrans, pObj->pDnode, pObj) != 0) goto _OVER; + if (mndSetDropQnodeInfoToTrans(pMnode, pTrans, pObj) != 0) goto _OVER; if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; code = 0; diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index 2b6258b10a..e055e3b2ba 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -37,7 +37,7 @@ extern bool tsSchedStreamToSnode; static int32_t mndAddTaskToTaskSet(SArray* pArray, SStreamTask* pTask) { int32_t childId = taosArrayGetSize(pArray); - pTask->childId = childId; + pTask->selfChildId = childId; taosArrayPush(pArray, &pTask); return 0; } @@ -270,6 +270,8 @@ int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, STrans* pTrans, SStreamOb pTask->nodeId = pVgroup->vgId; pTask->epSet = mndGetVgroupEpset(pMnode, pVgroup); + pTask->isDataScan = 0; + // source pTask->inputType = TASK_INPUT_TYPE__DATA_BLOCK; @@ -306,6 +308,8 @@ int32_t mndAddFixedSinkTaskToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* } mndAddTaskToTaskSet(tasks, pTask); + ASSERT(pStream->fixedSinkVg.vgId == pStream->fixedSinkVgId); + pTask->nodeId = pStream->fixedSinkVgId; #if 0 SVgObj* pVgroup = mndAcquireVgroup(pMnode, pStream->fixedSinkVgId); @@ -315,6 +319,9 @@ int32_t mndAddFixedSinkTaskToStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pTask->epSet = mndGetVgroupEpset(pMnode, pVgroup); #endif pTask->epSet = mndGetVgroupEpset(pMnode, &pStream->fixedSinkVg); + + pTask->isDataScan = 0; + // source pTask->inputType = TASK_INPUT_TYPE__DATA_BLOCK; @@ -384,6 +391,11 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { pInnerTask = tNewSStreamTask(pStream->uid); mndAddTaskToTaskSet(taskInnerLevel, pInnerTask); + + pInnerTask->isDataScan = 0; + + pInnerTask->childEpInfo = taosArrayInit(0, sizeof(void*)); + // input pInnerTask->inputType = TASK_INPUT_TYPE__DATA_BLOCK; @@ -446,7 +458,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { SStreamTask* pTask = tNewSStreamTask(pStream->uid); mndAddTaskToTaskSet(taskSourceLevel, pTask); - pTask->dataScan = 1; + pTask->isDataScan = 1; // input pTask->inputType = TASK_INPUT_TYPE__SUMBIT_BLOCK; @@ -467,6 +479,20 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { qDestroyQueryPlan(pPlan); return -1; } + + SStreamChildEpInfo* pEpInfo = taosMemoryMalloc(sizeof(SStreamChildEpInfo)); + if (pEpInfo == NULL) { + ASSERT(0); + terrno = TSDB_CODE_OUT_OF_MEMORY; + sdbRelease(pSdb, pVgroup); + qDestroyQueryPlan(pPlan); + return -1; + } + pEpInfo->childId = pTask->selfChildId; + pEpInfo->epSet = pTask->epSet; + pEpInfo->nodeId = pTask->nodeId; + pEpInfo->taskId = pTask->taskId; + taosArrayPush(pInnerTask->childEpInfo, &pEpInfo); } } @@ -491,7 +517,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { SStreamTask* pTask = tNewSStreamTask(pStream->uid); mndAddTaskToTaskSet(taskOneLevel, pTask); - pTask->dataScan = 1; + pTask->isDataScan = 1; // input pTask->inputType = TASK_INPUT_TYPE__SUMBIT_BLOCK; diff --git a/source/dnode/mnode/impl/src/mndSnode.c b/source/dnode/mnode/impl/src/mndSnode.c index 12188a3b3a..df1330197a 100644 --- a/source/dnode/mnode/impl/src/mndSnode.c +++ b/source/dnode/mnode/impl/src/mndSnode.c @@ -65,7 +65,7 @@ SEpSet mndAcquireEpFromSnode(SMnode *pMnode, const SSnodeObj *pSnode) { return epSet; } -static SSnodeObj *mndAcquireSnode(SMnode *pMnode, int32_t snodeId) { +SSnodeObj *mndAcquireSnode(SMnode *pMnode, int32_t snodeId) { SSnodeObj *pObj = sdbAcquire(pMnode->pSdb, SDB_SNODE, &snodeId); if (pObj == NULL && terrno == TSDB_CODE_SDB_OBJ_NOT_THERE) { terrno = TSDB_CODE_MND_SNODE_NOT_EXIST; @@ -73,7 +73,7 @@ static SSnodeObj *mndAcquireSnode(SMnode *pMnode, int32_t snodeId) { return pObj; } -static void mndReleaseSnode(SMnode *pMnode, SSnodeObj *pObj) { +void mndReleaseSnode(SMnode *pMnode, SSnodeObj *pObj) { SSdb *pSdb = pMnode->pSdb; sdbRelease(pSdb, pObj); } @@ -361,6 +361,14 @@ static int32_t mndSetDropSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, SSn return 0; } +int32_t mndSetDropSnodeInfoToTrans(SMnode *pMnode, STrans *pTrans, SSnodeObj *pObj) { + if (pObj == NULL) return 0; + if (mndSetDropSnodeRedoLogs(pTrans, pObj) != 0) return -1; + if (mndSetDropSnodeCommitLogs(pTrans, pObj) != 0) return -1; + if (mndSetDropSnodeRedoActions(pTrans, pObj->pDnode, pObj) != 0) return -1; + return 0; +} + static int32_t mndDropSnode(SMnode *pMnode, SRpcMsg *pReq, SSnodeObj *pObj) { int32_t code = -1; @@ -368,10 +376,7 @@ static int32_t mndDropSnode(SMnode *pMnode, SRpcMsg *pReq, SSnodeObj *pObj) { if (pTrans == NULL) goto _OVER; mDebug("trans:%d, used to drop snode:%d", pTrans->id, pObj->id); - - if (mndSetDropSnodeRedoLogs(pTrans, pObj) != 0) goto _OVER; - if (mndSetDropSnodeCommitLogs(pTrans, pObj) != 0) goto _OVER; - if (mndSetDropSnodeRedoActions(pTrans, pObj->pDnode, pObj) != 0) goto _OVER; + if (mndSetDropSnodeInfoToTrans(pMnode, pTrans, pObj) != 0) goto _OVER; if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; code = 0; diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 3e50ea8262..e04662d22b 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -43,6 +43,7 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq); static int32_t mndProcessTableMetaReq(SRpcMsg *pReq); static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelGetNextStb(SMnode *pMnode, void *pIter); +static int32_t mndProcessTableCfgReq(SRpcMsg *pReq); int32_t mndInitStb(SMnode *pMnode) { SSdbTable table = { @@ -62,6 +63,7 @@ int32_t mndInitStb(SMnode *pMnode) { mndSetMsgHandle(pMnode, TDMT_VND_ALTER_STB_RSP, mndTransProcessRsp); mndSetMsgHandle(pMnode, TDMT_VND_DROP_STB_RSP, mndTransProcessRsp); mndSetMsgHandle(pMnode, TDMT_MND_TABLE_META, mndProcessTableMetaReq); + mndSetMsgHandle(pMnode, TDMT_MND_TABLE_CFG, mndProcessTableCfgReq); mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STB, mndRetrieveStb); mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STB, mndCancelGetNextStb); @@ -75,7 +77,7 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) { terrno = TSDB_CODE_OUT_OF_MEMORY; int32_t size = sizeof(SStbObj) + (pStb->numOfColumns + pStb->numOfTags) * sizeof(SSchema) + +pStb->commentLen + - pStb->ast1Len + pStb->ast2Len + STB_RESERVE_SIZE; + pStb->ast1Len + pStb->ast2Len + STB_RESERVE_SIZE + taosArrayGetSize(pStb->pFuncs) * TSDB_FUNC_NAME_LEN; SSdbRaw *pRaw = sdbAllocRaw(SDB_STB, STB_VER_NUMBER, size); if (pRaw == NULL) goto _OVER; @@ -100,6 +102,13 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) { SDB_SET_INT32(pRaw, dataPos, pStb->ast1Len, _OVER) SDB_SET_INT32(pRaw, dataPos, pStb->ast2Len, _OVER) + int32_t funcNum = taosArrayGetSize(pStb->pFuncs); + SDB_SET_INT32(pRaw, dataPos, funcNum, _OVER) + for (int32_t i = 0; i < funcNum; ++i) { + char* func = taosArrayGet(pStb->pFuncs, i); + SDB_SET_BINARY(pRaw, dataPos, func, TSDB_FUNC_NAME_LEN, _OVER) + } + for (int32_t i = 0; i < pStb->numOfColumns; ++i) { SSchema *pSchema = &pStb->pColumns[i]; SDB_SET_INT8(pRaw, dataPos, pSchema->type, _OVER) @@ -181,6 +190,20 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &pStb->ast1Len, _OVER) SDB_GET_INT32(pRaw, dataPos, &pStb->ast2Len, _OVER) + int32_t funcNum = 0; + SDB_GET_INT32(pRaw, dataPos, &funcNum, _OVER) + if (funcNum > 0) { + pStb->pFuncs = taosArrayInit(funcNum, TSDB_FUNC_NAME_LEN); + if (NULL == pStb->pFuncs) { + goto _OVER; + } + char funcName[TSDB_FUNC_NAME_LEN]; + for (int32_t i = 0; i < funcNum; ++i) { + SDB_GET_BINARY(pRaw, dataPos, funcName, TSDB_FUNC_NAME_LEN, _OVER) + taosArrayPush(pStb->pFuncs, funcName); + } + } + pStb->pColumns = taosMemoryCalloc(pStb->numOfColumns, sizeof(SSchema)); pStb->pTags = taosMemoryCalloc(pStb->numOfTags, sizeof(SSchema)); if (pStb->pColumns == NULL || pStb->pTags == NULL) { @@ -250,6 +273,7 @@ static int32_t mndStbActionDelete(SSdb *pSdb, SStbObj *pStb) { taosMemoryFreeClear(pStb->comment); taosMemoryFreeClear(pStb->pAst1); taosMemoryFreeClear(pStb->pAst2); + taosArrayDestroy(pStb->pFuncs); return 0; } @@ -680,6 +704,9 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat pDst->numOfColumns = pCreate->numOfColumns; pDst->numOfTags = pCreate->numOfTags; pDst->commentLen = pCreate->commentLen; + pDst->pFuncs = pCreate->pFuncs; + pCreate->pFuncs = NULL; + if (pDst->commentLen > 0) { pDst->comment = taosMemoryCalloc(pDst->commentLen + 1, 1); if (pDst->comment == NULL) { @@ -1277,6 +1304,60 @@ static int32_t mndBuildStbSchemaImp(SDbObj *pDb, SStbObj *pStb, const char *tbNa return 0; } +static int32_t mndBuildStbCfgImp(SDbObj *pDb, SStbObj *pStb, const char *tbName, STableCfgRsp *pRsp) { + taosRLockLatch(&pStb->lock); + + int32_t totalCols = pStb->numOfColumns + pStb->numOfTags; + pRsp->pSchemas = taosMemoryCalloc(totalCols, sizeof(SSchema)); + if (pRsp->pSchemas == NULL) { + taosRUnLockLatch(&pStb->lock); + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + strcpy(pRsp->dbFName, pStb->db); + strcpy(pRsp->tbName, tbName); + strcpy(pRsp->stbName, tbName); + pRsp->numOfTags = pStb->numOfTags; + pRsp->numOfColumns = pStb->numOfColumns; + pRsp->tableType = TSDB_SUPER_TABLE; + pRsp->delay1 = pStb->maxdelay[0]; + pRsp->delay2 = pStb->maxdelay[1]; + pRsp->watermark1 = pStb->watermark[0]; + pRsp->watermark2 = pStb->watermark[1]; + pRsp->ttl = pStb->ttl; + pRsp->commentLen = pStb->commentLen; + if (pStb->commentLen > 0) { + pRsp->pComment = strdup(pStb->comment); + } + + for (int32_t i = 0; i < pStb->numOfColumns; ++i) { + SSchema *pSchema = &pRsp->pSchemas[i]; + SSchema *pSrcSchema = &pStb->pColumns[i]; + memcpy(pSchema->name, pSrcSchema->name, TSDB_COL_NAME_LEN); + pSchema->type = pSrcSchema->type; + pSchema->colId = pSrcSchema->colId; + pSchema->bytes = pSrcSchema->bytes; + } + + for (int32_t i = 0; i < pStb->numOfTags; ++i) { + SSchema *pSchema = &pRsp->pSchemas[i + pStb->numOfColumns]; + SSchema *pSrcSchema = &pStb->pTags[i]; + memcpy(pSchema->name, pSrcSchema->name, TSDB_COL_NAME_LEN); + pSchema->type = pSrcSchema->type; + pSchema->colId = pSrcSchema->colId; + pSchema->bytes = pSrcSchema->bytes; + } + + if (pStb->pFuncs) { + pRsp->pFuncs = taosArrayDup(pStb->pFuncs); + } + + taosRUnLockLatch(&pStb->lock); + return 0; +} + + static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp, int32_t *smaVer) { char tbFName[TSDB_TABLE_FNAME_LEN] = {0}; @@ -1305,6 +1386,32 @@ static int32_t mndBuildStbSchema(SMnode *pMnode, const char *dbFName, const char return code; } +static int32_t mndBuildStbCfg(SMnode *pMnode, const char *dbFName, const char *tbName, STableCfgRsp *pRsp) { + char tbFName[TSDB_TABLE_FNAME_LEN] = {0}; + snprintf(tbFName, sizeof(tbFName), "%s.%s", dbFName, tbName); + + SDbObj *pDb = mndAcquireDb(pMnode, dbFName); + if (pDb == NULL) { + terrno = TSDB_CODE_MND_DB_NOT_SELECTED; + return -1; + } + + SStbObj *pStb = mndAcquireStb(pMnode, tbFName); + if (pStb == NULL) { + mndReleaseDb(pMnode, pDb); + terrno = TSDB_CODE_PAR_TABLE_NOT_EXIST; + return -1; + } + + int32_t code = mndBuildStbCfgImp(pDb, pStb, tbName, pRsp); + + mndReleaseDb(pMnode, pDb); + mndReleaseStb(pMnode, pStb); + return code; +} + + + static int32_t mndBuildSMAlterStbRsp(SDbObj *pDb, const SMAlterStbReq *pAlter, SStbObj *pObj, void **pCont, int32_t *pLen) { int32_t ret; @@ -1664,6 +1771,63 @@ _OVER: return code; } +static int32_t mndProcessTableCfgReq(SRpcMsg *pReq) { + SMnode *pMnode = pReq->info.node; + int32_t code = -1; + STableCfgReq cfgReq = {0}; + STableCfgRsp cfgRsp = {0}; + + if (tDeserializeSTableCfgReq(pReq->pCont, pReq->contLen, &cfgReq) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + goto _OVER; + } + + if (0 == strcmp(cfgReq.dbFName, TSDB_INFORMATION_SCHEMA_DB)) { + mDebug("information_schema table:%s.%s, start to retrieve cfg", cfgReq.dbFName, cfgReq.tbName); + if (mndBuildInsTableCfg(pMnode, cfgReq.dbFName, cfgReq.tbName, &cfgRsp) != 0) { + goto _OVER; + } + } else if (0 == strcmp(cfgReq.dbFName, TSDB_PERFORMANCE_SCHEMA_DB)) { + mDebug("performance_schema table:%s.%s, start to retrieve cfg", cfgReq.dbFName, cfgReq.tbName); + if (mndBuildPerfsTableCfg(pMnode, cfgReq.dbFName, cfgReq.tbName, &cfgRsp) != 0) { + goto _OVER; + } + } else { + mDebug("stb:%s.%s, start to retrieve cfg", cfgReq.dbFName, cfgReq.tbName); + if (mndBuildStbCfg(pMnode, cfgReq.dbFName, cfgReq.tbName, &cfgRsp) != 0) { + goto _OVER; + } + } + + int32_t rspLen = tSerializeSTableCfgRsp(NULL, 0, &cfgRsp); + if (rspLen < 0) { + terrno = TSDB_CODE_INVALID_MSG; + goto _OVER; + } + + void *pRsp = rpcMallocCont(rspLen); + if (pRsp == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + + tSerializeSTableCfgRsp(pRsp, rspLen, &cfgRsp); + pReq->info.rsp = pRsp; + pReq->info.rspLen = rspLen; + code = 0; + + mTrace("%s.%s, cfg is retrieved", cfgReq.dbFName, cfgReq.tbName); + +_OVER: + if (code != 0) { + mError("stb:%s.%s, failed to retrieve cfg since %s", cfgReq.dbFName, cfgReq.tbName, terrstr()); + } + + tFreeSTableCfgRsp(&cfgRsp); + return code; +} + + int32_t mndValidateStbInfo(SMnode *pMnode, SSTableVersion *pStbVersions, int32_t numOfStbs, void **ppRsp, int32_t *pRspLen) { SSTbHbRsp hbRsp = {0}; diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index fb92efecf6..7e9069d5fc 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -54,9 +54,10 @@ int32_t mndInitStream(SMnode *pMnode) { }; mndSetMsgHandle(pMnode, TDMT_MND_CREATE_STREAM, mndProcessCreateStreamReq); - mndSetMsgHandle(pMnode, TDMT_STREAM_TASK_DEPLOY_RSP, mndTransProcessRsp); mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM, mndProcessDropStreamReq); - mndSetMsgHandle(pMnode, TDMT_MND_DROP_STREAM_RSP, mndTransProcessRsp); + + mndSetMsgHandle(pMnode, TDMT_STREAM_TASK_DEPLOY_RSP, mndTransProcessRsp); + mndSetMsgHandle(pMnode, TDMT_STREAM_TASK_DROP_RSP, mndTransProcessRsp); mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndRetrieveStream); mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_STREAMS, mndCancelGetNextStream); @@ -477,7 +478,7 @@ static int32_t mndPersistTaskDropReq(STrans *pTrans, SStreamTask *pTask) { memcpy(&action.epSet, &pTask->epSet, sizeof(SEpSet)); action.pCont = pReq; action.contLen = sizeof(SVDropStreamTaskReq); - action.msgType = TDMT_VND_STREAM_TASK_DROP; + action.msgType = TDMT_STREAM_TASK_DROP; if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); return -1; @@ -670,20 +671,24 @@ _OVER: static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) { SMnode *pMnode = pReq->info.node; - int32_t code = -1; SStreamObj *pStream = NULL; /*SDbObj *pDb = NULL;*/ /*SUserObj *pUser = NULL;*/ - SMDropStreamReq dropReq = *(SMDropStreamReq *)pReq->pCont; + SMDropStreamReq dropReq = {0}; + if (tDeserializeSMDropStreamReq(pReq->pCont, pReq->contLen, &dropReq) < 0) { + ASSERT(0); + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } pStream = mndAcquireStream(pMnode, dropReq.name); if (pStream == NULL) { if (dropReq.igNotExists) { mDebug("stream:%s, not exist, ignore not exist is set", dropReq.name); - code = 0; - goto DROP_STREAM_OVER; + sdbRelease(pMnode->pSdb, pStream); + return -1; } else { terrno = TSDB_CODE_MND_STREAM_NOT_EXIST; return -1; @@ -701,14 +706,16 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) { STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq); if (pTrans == NULL) { mError("stream:%s, failed to drop since %s", dropReq.name, terrstr()); - return code; + sdbRelease(pMnode->pSdb, pStream); + return -1; } mDebug("trans:%d, used to drop stream:%s", pTrans->id, dropReq.name); // drop all tasks if (mndDropStreamTasks(pMnode, pTrans, pStream) < 0) { mError("stream:%s, failed to drop task since %s", dropReq.name, terrstr()); - return code; + sdbRelease(pMnode->pSdb, pStream); + return -1; } // drop stream @@ -717,8 +724,16 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) { return -1; } -DROP_STREAM_OVER: - return code; + if (mndTransPrepare(pMnode, pTrans) != 0) { + mError("trans:%d, failed to prepare drop stream trans since %s", pTrans->id, terrstr()); + sdbRelease(pMnode->pSdb, pStream); + mndTransDrop(pTrans); + return -1; + } + + sdbRelease(pMnode->pSdb, pStream); + + return TSDB_CODE_ACTION_IN_PROGRESS; } int32_t mndDropStreamByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index d2b7a61e83..8dde3e92d8 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -96,6 +96,7 @@ static SMqSubscribeObj *mndCreateSub(SMnode *pMnode, const SMqTopicObj *pTopic, pSub->dbUid = pTopic->dbUid; pSub->stbUid = pTopic->stbUid; pSub->subType = pTopic->subType; + pSub->withMeta = pTopic->withMeta; ASSERT(pSub->unassignedVgs->size == 0); ASSERT(taosHashGetSize(pSub->consumerHash) == 0); @@ -120,6 +121,7 @@ static int32_t mndBuildSubChangeReq(void **pBuf, int32_t *pLen, const SMqSubscri req.vgId = pRebVg->pVgEp->vgId; req.qmsg = pRebVg->pVgEp->qmsg; req.subType = pSub->subType; + req.withMeta = pSub->withMeta; req.suid = pSub->stbUid; strncpy(req.subKey, pSub->key, TSDB_SUBSCRIBE_KEY_LEN); diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index 8666739dab..e3358b41df 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -75,7 +75,7 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM } int32_t mndSyncGetSnapshot(struct SSyncFSM *pFsm, SSnapshot *pSnapshot, void *pReaderParam, void **ppReader) { - mInfo("start to read snapshot from sdb in atomic way"); + mDebug("start to read snapshot from sdb in atomic way"); SMnode *pMnode = pFsm->data; return sdbStartRead(pMnode->pSdb, (SSdbIter **)ppReader, &pSnapshot->lastApplyIndex, &pSnapshot->lastApplyTerm, &pSnapshot->lastConfigIndex); @@ -96,7 +96,7 @@ void mndRestoreFinish(struct SSyncFSM *pFsm) { mndTransPullup(pMnode); mndSetRestore(pMnode, true); } else { - mInfo("mnode sync restore finished, and will set ready after first deploy"); + mInfo("mnode sync restore finished"); } } @@ -118,13 +118,13 @@ void mndReConfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta cbM } int32_t mndSnapshotStartRead(struct SSyncFSM *pFsm, void **ppReader) { - mInfo("start to read snapshot from sdb"); + mDebug("start to read snapshot from sdb"); SMnode *pMnode = pFsm->data; return sdbStartRead(pMnode->pSdb, (SSdbIter **)ppReader, NULL, NULL, NULL); } int32_t mndSnapshotStopRead(struct SSyncFSM *pFsm, void *pReader) { - mInfo("stop to read snapshot from sdb"); + mDebug("stop to read snapshot from sdb"); SMnode *pMnode = pFsm->data; return sdbStopRead(pMnode->pSdb, pReader); } diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 9632c04f4c..a650ed29f1 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -141,6 +141,7 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) { SDB_SET_INT64(pRaw, dataPos, pTopic->dbUid, TOPIC_ENCODE_OVER); SDB_SET_INT32(pRaw, dataPos, pTopic->version, TOPIC_ENCODE_OVER); SDB_SET_INT8(pRaw, dataPos, pTopic->subType, TOPIC_ENCODE_OVER); + SDB_SET_INT8(pRaw, dataPos, pTopic->withMeta, TOPIC_ENCODE_OVER); SDB_SET_INT64(pRaw, dataPos, pTopic->stbUid, TOPIC_ENCODE_OVER); SDB_SET_INT32(pRaw, dataPos, pTopic->sqlLen, TOPIC_ENCODE_OVER); @@ -208,6 +209,7 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { SDB_GET_INT64(pRaw, dataPos, &pTopic->dbUid, TOPIC_DECODE_OVER); SDB_GET_INT32(pRaw, dataPos, &pTopic->version, TOPIC_DECODE_OVER); SDB_GET_INT8(pRaw, dataPos, &pTopic->subType, TOPIC_DECODE_OVER); + SDB_GET_INT8(pRaw, dataPos, &pTopic->withMeta, TOPIC_DECODE_OVER); SDB_GET_INT64(pRaw, dataPos, &pTopic->stbUid, TOPIC_DECODE_OVER); SDB_GET_INT32(pRaw, dataPos, &pTopic->sqlLen, TOPIC_DECODE_OVER); @@ -357,6 +359,10 @@ static int32_t mndCreateTopic(SMnode *pMnode, SRpcMsg *pReq, SCMCreateTopicReq * topicObj.sql = strdup(pCreate->sql); topicObj.sqlLen = strlen(pCreate->sql) + 1; topicObj.subType = pCreate->subType; + topicObj.withMeta = pCreate->withMeta; + if (topicObj.withMeta) { + ASSERT(topicObj.subType != TOPIC_SUB_TYPE__COLUMN); + } if (pCreate->subType == TOPIC_SUB_TYPE__COLUMN) { topicObj.ast = strdup(pCreate->ast); diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index de6a44d456..eec108414e 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -432,11 +432,11 @@ static const char *mndTransStr(ETrnStage stage) { } static void mndTransTestStartFunc(SMnode *pMnode, void *param, int32_t paramLen) { - mInfo("test trans start, param:%s, len:%d", (char *)param, paramLen); + mDebug("test trans start, param:%s, len:%d", (char *)param, paramLen); } static void mndTransTestStopFunc(SMnode *pMnode, void *param, int32_t paramLen) { - mInfo("test trans stop, param:%s, len:%d", (char *)param, paramLen); + mDebug("test trans stop, param:%s, len:%d", (char *)param, paramLen); } static TransCbFp mndTransGetCbFp(ETrnFunc ftype) { diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 94ddbcd409..696e714a8c 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -1017,6 +1017,11 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, if (mndAddDropVnodeAction(pMnode, pTrans, pDb, &newVg, &del, true) != 0) return -1; if (mndAddAlterVnodeConfirmAction(pMnode, pTrans, pDb, &newVg) != 0) return -1; + SSdbRaw *pRaw = mndVgroupActionEncode(&newVg); + if (pRaw == NULL || mndTransAppendCommitlog(pTrans, pRaw) != 0) return -1; + sdbSetRawStatus(pRaw, SDB_STATUS_READY); + pRaw = NULL; + mInfo("vgId:%d, vgroup info after move, replica:%d", newVg.vgId, newVg.replica); for (int32_t i = 0; i < newVg.replica; ++i) { mInfo("vgId:%d, vnode:%d dnode:%d", newVg.vgId, i, newVg.vnodeGid[i].dnodeId); @@ -1025,6 +1030,7 @@ int32_t mndSetMoveVgroupInfoToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, } int32_t mndSetMoveVgroupsInfoToTrans(SMnode *pMnode, STrans *pTrans, int32_t delDnodeId) { + int32_t code = 0; SArray *pArray = mndBuildDnodesArray(pMnode, delDnodeId); if (pArray == NULL) return -1; @@ -1042,18 +1048,24 @@ int32_t mndSetMoveVgroupsInfoToTrans(SMnode *pMnode, STrans *pTrans, int32_t del } } + code = 0; if (vnIndex != -1) { mInfo("vgId:%d, vnode:%d will be removed from dnode:%d", pVgroup->vgId, vnIndex, delDnodeId); SDbObj *pDb = mndAcquireDb(pMnode, pVgroup->dbName); - mndSetMoveVgroupInfoToTrans(pMnode, pTrans, pDb, pVgroup, vnIndex, pArray); + code = mndSetMoveVgroupInfoToTrans(pMnode, pTrans, pDb, pVgroup, vnIndex, pArray); mndReleaseDb(pMnode, pDb); } sdbRelease(pMnode->pSdb, pVgroup); + + if (code != 0) { + sdbCancelFetch(pMnode->pSdb, pIter); + break; + } } taosArrayDestroy(pArray); - return 0; + return code; } static int32_t mndAddIncVgroupReplicaToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroup, diff --git a/source/dnode/mnode/sdb/src/sdbFile.c b/source/dnode/mnode/sdb/src/sdbFile.c index 47c4a4ed0f..ff4a9e4ead 100644 --- a/source/dnode/mnode/sdb/src/sdbFile.c +++ b/source/dnode/mnode/sdb/src/sdbFile.c @@ -519,7 +519,7 @@ static void sdbCloseIter(SSdbIter *pIter) { pIter->name = NULL; } - mInfo("sdbiter:%p, is closed, total:%" PRId64, pIter, pIter->total); + mDebug("sdbiter:%p, is closed, total:%" PRId64, pIter, pIter->total); taosMemoryFree(pIter); } @@ -556,7 +556,7 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter, int64_t *index, int64_t *ter if (term != NULL) *term = commitTerm; if (config != NULL) *config = commitConfig; - mInfo("sdbiter:%p, is created to read snapshot, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64 " file:%s", + mDebug("sdbiter:%p, is created to read snapshot, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64 " file:%s", pIter, commitIndex, commitTerm, commitConfig, pIter->name); return 0; } @@ -583,14 +583,14 @@ int32_t sdbDoRead(SSdb *pSdb, SSdbIter *pIter, void **ppBuf, int32_t *len) { taosMemoryFree(pBuf); return -1; } else if (readlen == 0) { - mInfo("sdbiter:%p, read snapshot to the end, total:%" PRId64, pIter, pIter->total); + mDebug("sdbiter:%p, read snapshot to the end, total:%" PRId64, pIter, pIter->total); *ppBuf = NULL; *len = 0; taosMemoryFree(pBuf); return 0; } else { // (readlen <= maxlen) pIter->total += readlen; - mInfo("sdbiter:%p, read:%d bytes from snapshot, total:%" PRId64, pIter, readlen, pIter->total); + mDebug("sdbiter:%p, read:%d bytes from snapshot, total:%" PRId64, pIter, readlen, pIter->total); *ppBuf = pBuf; *len = readlen; return 0; @@ -609,7 +609,7 @@ int32_t sdbStartWrite(SSdb *pSdb, SSdbIter **ppIter) { } *ppIter = pIter; - mInfo("sdbiter:%p, is created to write snapshot, file:%s", pIter, pIter->name); + mDebug("sdbiter:%p, is created to write snapshot, file:%s", pIter, pIter->name); return 0; } @@ -618,7 +618,7 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply) { if (!isApply) { sdbCloseIter(pIter); - mInfo("sdbiter:%p, not apply to sdb", pIter); + mDebug("sdbiter:%p, not apply to sdb", pIter); return 0; } @@ -641,7 +641,7 @@ int32_t sdbStopWrite(SSdb *pSdb, SSdbIter *pIter, bool isApply) { return -1; } - mInfo("sdbiter:%p, successfully applyed to sdb", pIter); + mDebug("sdbiter:%p, successfully applyed to sdb", pIter); return 0; } @@ -654,6 +654,6 @@ int32_t sdbDoWrite(SSdb *pSdb, SSdbIter *pIter, void *pBuf, int32_t len) { } pIter->total += writelen; - mInfo("sdbiter:%p, write:%d bytes to snapshot, total:%" PRId64, pIter, writelen, pIter->total); + mDebug("sdbiter:%p, write:%d bytes to snapshot, total:%" PRId64, pIter, writelen, pIter->total); return 0; } \ No newline at end of file diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index 84a66c680b..3a92cba773 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -92,7 +92,7 @@ static int32_t sndProcessTaskDeployReq(SSnode *pNode, SRpcMsg *pMsg) { } tDecoderClear(&decoder); - pTask->status = TASK_STATUS__IDLE; + pTask->execStatus = TASK_EXEC_STATUS__IDLE; pTask->inputQueue = streamQueueOpen(); pTask->outputQueue = streamQueueOpen(); @@ -105,13 +105,14 @@ static int32_t sndProcessTaskDeployReq(SSnode *pNode, SRpcMsg *pMsg) { ASSERT(pTask->execType != TASK_EXEC__NONE); - ASSERT(pTask->dataScan == 0); + ASSERT(pTask->isDataScan == 0); pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, NULL); ASSERT(pTask->exec.executor); streamSetupTrigger(pTask); - qInfo("deploy stream: stream id %ld task id %d child id %d on snode", pTask->streamId, pTask->taskId, pTask->childId); + qInfo("deploy stream: stream id %ld task id %d child id %d on snode", pTask->streamId, pTask->taskId, + pTask->selfChildId); taosHashPut(pMeta->pHash, &pTask->taskId, sizeof(int32_t), &pTask, sizeof(void *)); @@ -198,6 +199,34 @@ static int32_t sndProcessTaskDropReq(SSnode *pNode, SRpcMsg *pMsg) { return code; } +static int32_t sndProcessTaskRetrieveReq(SSnode *pNode, SRpcMsg *pMsg) { + SStreamMeta *pMeta = pNode->pMeta; + + char *msgStr = pMsg->pCont; + char *msgBody = POINTER_SHIFT(msgStr, sizeof(SMsgHead)); + int32_t msgLen = pMsg->contLen - sizeof(SMsgHead); + SStreamRetrieveReq req; + SDecoder decoder; + tDecoderInit(&decoder, msgBody, msgLen); + tDecodeStreamRetrieveReq(&decoder, &req); + int32_t taskId = req.dstTaskId; + SStreamTask *pTask = *(SStreamTask **)taosHashGet(pMeta->pHash, &taskId, sizeof(int32_t)); + if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) { + return 0; + } + SRpcMsg rsp = { + .info = pMsg->info, + .code = 0, + }; + streamProcessRetrieveReq(pTask, &req, &rsp); + return 0; +} + +static int32_t sndProcessTaskRetrieveRsp(SSnode *pNode, SRpcMsg *pMsg) { + // + return 0; +} + int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) { // stream deploy // stream stop/resume @@ -205,7 +234,7 @@ int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) { switch (pMsg->msgType) { case TDMT_STREAM_TASK_DEPLOY: return sndProcessTaskDeployReq(pSnode, pMsg); - case TDMT_VND_STREAM_TASK_DROP: + case TDMT_STREAM_TASK_DROP: return sndProcessTaskDropReq(pSnode, pMsg); default: ASSERT(0); @@ -221,10 +250,14 @@ int32_t sndProcessSMsg(SSnode *pSnode, SRpcMsg *pMsg) { return sndProcessTaskDispatchReq(pSnode, pMsg); case TDMT_STREAM_TASK_RECOVER: return sndProcessTaskRecoverReq(pSnode, pMsg); + case TDMT_STREAM_RETRIEVE: + return sndProcessTaskRecoverReq(pSnode, pMsg); case TDMT_STREAM_TASK_DISPATCH_RSP: return sndProcessTaskDispatchRsp(pSnode, pMsg); case TDMT_STREAM_TASK_RECOVER_RSP: return sndProcessTaskRecoverRsp(pSnode, pMsg); + case TDMT_STREAM_RETRIEVE_RSP: + return sndProcessTaskRecoverRsp(pSnode, pMsg); default: ASSERT(0); } diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 70d89102e6..d5d6f7c58a 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -195,6 +195,7 @@ struct SVnodeCfg { typedef struct { TSKEY lastKey; uint64_t uid; + uint64_t groupId; } STableKeyInfo; struct SMetaEntry { diff --git a/source/dnode/vnode/src/inc/tq.h b/source/dnode/vnode/src/inc/tq.h index 2ee0673ce5..8f6077e996 100644 --- a/source/dnode/vnode/src/inc/tq.h +++ b/source/dnode/vnode/src/inc/tq.h @@ -114,6 +114,7 @@ typedef struct { char subKey[TSDB_SUBSCRIBE_KEY_LEN]; int64_t consumerId; int32_t epoch; + int8_t fetchMeta; // reader SWalReadHandle* pWalReader; diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index 9339402d43..32be479116 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -32,7 +32,14 @@ extern "C" { #define vInfo(...) do { if (vDebugFlag & DEBUG_INFO) { taosPrintLog("VND ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0) #define vDebug(...) do { if (vDebugFlag & DEBUG_DEBUG) { taosPrintLog("VND ", DEBUG_DEBUG, vDebugFlag, __VA_ARGS__); }} while(0) #define vTrace(...) do { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", DEBUG_TRACE, vDebugFlag, __VA_ARGS__); }} while(0) -#define vGTrace(param, ...) do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vTrace(param " GTID: %s", __VA_ARGS__, buf);} while(0)//#define vDye(...) do + +#define vGTrace(param, ...) do { if (vDebugFlag & DEBUG_TRACE) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vTrace(param ", gtid:%s", __VA_ARGS__, buf);}} while(0) +#define vGFatal(param, ...) do { if (vDebugFlag & DEBUG_FATAL) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vFatal(param ", gtid:%s", __VA_ARGS__, buf);}} while(0) +#define vGError(param, ...) do { if (vDebugFlag & DEBUG_ERROR) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vError(param ", gtid:%s", __VA_ARGS__, buf);}} while(0) +#define vGWarn(param, ...) do { if (vDebugFlag & DEBUG_WARN) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vWarn(param ", gtid:%s", __VA_ARGS__, buf);}} while(0) +#define vGInfo(param, ...) do { if (vDebugFlag & DEBUG_INFO) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vInfo(param ", gtid:%s", __VA_ARGS__, buf);}} while(0) +#define vGDebug(param, ...) do { if (vDebugFlag & DEBUG_DEBUG) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vDebug(param ", gtid:%s", __VA_ARGS__, buf);}} while(0) + // clang-format on // vnodeCfg.c @@ -71,6 +78,7 @@ void vnodeBufPoolReset(SVBufPool* pPool); int32_t vnodeQueryOpen(SVnode* pVnode); void vnodeQueryClose(SVnode* pVnode); int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg); +int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg); // vnodeCommit.c int32_t vnodeBegin(SVnode* pVnode); diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index c0dfebb08f..f8bdb63c86 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -149,6 +149,8 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg); +int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg); +int32_t tqProcessTaskRetrieveRsp(STQ* pTq, SRpcMsg* pMsg); SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pSchema, bool createTb, int64_t suid, const char* stbFullName, int32_t vgId); diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index ece4b7e2a4..691548af7a 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -85,6 +85,34 @@ void tqClose(STQ* pTq) { } } +int32_t tqSendMetaPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqMetaRsp* pRsp) { + int32_t tlen = sizeof(SMqRspHead) + tEncodeSMqMetaRsp(NULL, pRsp); + void* buf = rpcMallocCont(tlen); + if (buf == NULL) { + return -1; + } + + ((SMqRspHead*)buf)->mqMsgType = TMQ_MSG_TYPE__POLL_META_RSP; + ((SMqRspHead*)buf)->epoch = pReq->epoch; + ((SMqRspHead*)buf)->consumerId = pReq->consumerId; + + void* abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead)); + tEncodeSMqMetaRsp(&abuf, pRsp); + + SRpcMsg resp = { + .info = pMsg->info, + .pCont = buf, + .contLen = tlen, + .code = 0, + }; + tmsgSendRsp(&resp); + + tqDebug("vg %d from consumer %ld (epoch %d) send rsp, res msg type %d, reqOffset: %ld, rspOffset: %ld", + TD_VID(pTq->pVnode), pReq->consumerId, pReq->epoch, pRsp->resMsgType, pRsp->reqOffset, pRsp->rspOffset); + + return 0; +} + int32_t tqSendPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataBlkRsp* pRsp) { int32_t tlen = sizeof(SMqRspHead) + tEncodeSMqDataBlkRsp(NULL, pRsp); void* buf = rpcMallocCont(tlen); @@ -250,8 +278,23 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { /*ASSERT(0);*/ } } else { - // TODO - ASSERT(0); + ASSERT(pHandle->fetchMeta); + ASSERT(pHead->msgType == TDMT_VND_CREATE_STB || pHead->msgType == TDMT_VND_ALTER_STB || + pHead->msgType == TDMT_VND_DROP_STB || pHead->msgType == TDMT_VND_CREATE_TABLE || + pHead->msgType == TDMT_VND_ALTER_TABLE || pHead->msgType == TDMT_VND_DROP_TABLE || + pHead->msgType == TDMT_VND_DROP_TTL_TABLE); + // return + SMqMetaRsp metaRsp = {0}; + metaRsp.reqOffset = pReq->currentOffset; + metaRsp.rspOffset = fetchOffset; + metaRsp.resMsgType = pHead->msgType; + metaRsp.metaRspLen = pHead->bodyLen; + metaRsp.metaRsp = pHead->body; + if (tqSendMetaPollRsp(pTq, pMsg, pReq, &metaRsp) < 0) { + code = -1; + } + code = 0; + goto OVER; } // TODO batch optimization: @@ -276,7 +319,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) { if (tqSendPollRsp(pTq, pMsg, pReq, &rsp) < 0) { code = -1; } - +OVER: // TODO wrap in destroy func taosArrayDestroy(rsp.blockDataLen); taosArrayDestroyP(rsp.blockData, (FDelete)taosMemoryFree); @@ -384,7 +427,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) { } tDecoderClear(&decoder); - pTask->status = TASK_STATUS__IDLE; + pTask->execStatus = TASK_EXEC_STATUS__IDLE; pTask->inputQueue = streamQueueOpen(); pTask->outputQueue = streamQueueOpen(); @@ -398,7 +441,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) { // exec if (pTask->execType != TASK_EXEC__NONE) { // expand runners - if (pTask->dataScan) { + if (pTask->isDataScan) { STqReadHandle* pStreamReader = tqInitSubmitMsgScanner(pTq->pVnode->pMeta); SReadHandle handle = { .reader = pStreamReader, @@ -433,7 +476,7 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, char* msg, int32_t msgLen) { streamSetupTrigger(pTask); - tqInfo("deploy stream task id %d child id %d on vg %d", pTask->taskId, pTask->childId, TD_VID(pTq->pVnode)); + tqInfo("deploy stream task id %d child id %d on vg %d", pTask->taskId, pTask->selfChildId, TD_VID(pTq->pVnode)); taosHashPut(pTq->pStreamTasks, &pTask->taskId, sizeof(int32_t), &pTask, sizeof(void*)); @@ -459,6 +502,9 @@ int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq) { pIter = taosHashIterate(pTq->pStreamTasks, pIter); if (pIter == NULL) break; SStreamTask* pTask = *(SStreamTask**)pIter; + if (atomic_load_8(&pTask->taskStatus) == TASK_STATUS__DROPPING) { + continue; + } if (pTask->inputType != STREAM_INPUT__DATA_SUBMIT) continue; if (!failed) { @@ -487,6 +533,9 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) { SStreamTaskRunReq* pReq = pMsg->pCont; int32_t taskId = pReq->taskId; SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t)); + if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) { + return 0; + } streamProcessRunReq(pTask); return 0; } @@ -501,9 +550,12 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) { tDecodeStreamDispatchReq(&decoder, &req); int32_t taskId = req.taskId; SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t)); - SRpcMsg rsp = { - .info = pMsg->info, - .code = 0, + if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) { + return 0; + } + SRpcMsg rsp = { + .info = pMsg->info, + .code = 0, }; streamProcessDispatchReq(pTask, &req, &rsp); return 0; @@ -513,6 +565,9 @@ int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg) { SStreamTaskRecoverReq* pReq = pMsg->pCont; int32_t taskId = pReq->taskId; SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t)); + if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) { + return 0; + } streamProcessRecoverReq(pTask, pReq, pMsg); return 0; } @@ -521,6 +576,9 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) { SStreamDispatchRsp* pRsp = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); int32_t taskId = pRsp->taskId; SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t)); + if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) { + return 0; + } streamProcessDispatchRsp(pTask, pRsp); return 0; } @@ -529,16 +587,58 @@ int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) { SStreamTaskRecoverRsp* pRsp = pMsg->pCont; int32_t taskId = pRsp->taskId; SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t)); + if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) { + return 0; + } streamProcessRecoverRsp(pTask, pRsp); return 0; } int32_t tqProcessTaskDropReq(STQ* pTq, char* msg, int32_t msgLen) { SVDropStreamTaskReq* pReq = (SVDropStreamTaskReq*)msg; + + SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &pReq->taskId, sizeof(int32_t)); + atomic_store_8(&pTask->taskStatus, TASK_STATUS__DROPPING); + // todo + // clear queue + // push drop req into queue + // launch exec to free memory + // remove from hash + return 0; + +#if 0 int32_t code = taosHashRemove(pTq->pStreamTasks, &pReq->taskId, sizeof(int32_t)); + // set status dropping ASSERT(code == 0); if (code == 0) { // sendrsp } return code; +#endif +} + +int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg) { + char* msgStr = pMsg->pCont; + char* msgBody = POINTER_SHIFT(msgStr, sizeof(SMsgHead)); + int32_t msgLen = pMsg->contLen - sizeof(SMsgHead); + SStreamRetrieveReq req; + SDecoder decoder; + tDecoderInit(&decoder, msgBody, msgLen); + tDecodeStreamRetrieveReq(&decoder, &req); + int32_t taskId = req.dstTaskId; + SStreamTask* pTask = *(SStreamTask**)taosHashGet(pTq->pStreamTasks, &taskId, sizeof(int32_t)); + if (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) { + return 0; + } + SRpcMsg rsp = { + .info = pMsg->info, + .code = 0, + }; + streamProcessRetrieveReq(pTask, &req, &rsp); + return 0; +} + +int32_t tqProcessTaskRetrieveRsp(STQ* pTq, SRpcMsg* pMsg) { + // + return 0; } diff --git a/source/dnode/vnode/src/tq/tqPush.c b/source/dnode/vnode/src/tq/tqPush.c index 3af8901b2b..2ec627bd5c 100644 --- a/source/dnode/vnode/src/tq/tqPush.c +++ b/source/dnode/vnode/src/tq/tqPush.c @@ -45,9 +45,9 @@ static int32_t tqLoopExecFromQueue(STQ* pTq, STqHandle* pHandle, SStreamDataSubm int32_t tqExecFromInputQ(STQ* pTq, STqHandle* pHandle) { SMqDataBlkRsp rsp = {0}; // 1. guard and set status executing - int8_t execStatus = - atomic_val_compare_exchange_8(&pHandle->pushHandle.execStatus, TASK_STATUS__IDLE, TASK_STATUS__EXECUTING); - if (execStatus == TASK_STATUS__IDLE) { + int8_t execStatus = atomic_val_compare_exchange_8(&pHandle->pushHandle.execStatus, TASK_EXEC_STATUS__IDLE, + TASK_EXEC_STATUS__EXECUTING); + if (execStatus == TASK_EXEC_STATUS__IDLE) { SStreamDataSubmit* pSubmit = NULL; // 2. check processedVer // 2.1. if not missed, get msg from queue @@ -68,18 +68,18 @@ int32_t tqExecFromInputQ(STQ* pTq, STqHandle* pHandle) { goto SEND_RSP; } // set exec status closing - atomic_store_8(&pHandle->pushHandle.execStatus, TASK_STATUS__CLOSING); + atomic_store_8(&pHandle->pushHandle.execStatus, TASK_EXEC_STATUS__CLOSING); // second run if (tqLoopExecFromQueue(pTq, pHandle, &pSubmit, &rsp) == 0) { goto SEND_RSP; } // set exec status idle - atomic_store_8(&pHandle->pushHandle.execStatus, TASK_STATUS__IDLE); + atomic_store_8(&pHandle->pushHandle.execStatus, TASK_EXEC_STATUS__IDLE); } SEND_RSP: // 4. if get result // 4.1 set exec input status blocked and exec status idle - atomic_store_8(&pHandle->pushHandle.execStatus, TASK_STATUS__IDLE); + atomic_store_8(&pHandle->pushHandle.execStatus, TASK_EXEC_STATUS__IDLE); // 4.2 rpc send rsp.rspOffset = pHandle->pushHandle.processedVer; /*if (tqSendPollRsp(pTq, pMsg, pReq, &rsp) < 0) {*/ @@ -150,7 +150,7 @@ int32_t tqEnqueueAll(STQ* pTq, SSubmitReq* pReq) { continue; } int8_t execStatus = atomic_load_8(&pHandle->pushHandle.execStatus); - if (execStatus == TASK_STATUS__IDLE || execStatus == TASK_STATUS__CLOSING) { + if (execStatus == TASK_EXEC_STATUS__IDLE || execStatus == TASK_EXEC_STATUS__CLOSING) { tqSendExecReq(pTq, pHandle); } } diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index 0c38d6442b..6f44eb4569 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -42,6 +42,25 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalHead* code = 0; goto END; } else { + if (pHandle->fetchMeta) { + SWalReadHead* pHead = &((*ppHeadWithCkSum)->head); + if (pHead->msgType == TDMT_VND_CREATE_STB || pHead->msgType == TDMT_VND_ALTER_STB || + pHead->msgType == TDMT_VND_DROP_STB || pHead->msgType == TDMT_VND_CREATE_TABLE || + pHead->msgType == TDMT_VND_ALTER_TABLE || pHead->msgType == TDMT_VND_DROP_TABLE || + pHead->msgType == TDMT_VND_DROP_TTL_TABLE) { + code = walFetchBody(pHandle->pWalReader, ppHeadWithCkSum); + + if (code < 0) { + ASSERT(0); + *fetchOffset = offset; + code = -1; + goto END; + } + *fetchOffset = offset; + code = 0; + goto END; + } + } code = walSkipFetchBody(pHandle->pWalReader, *ppHeadWithCkSum); if (code < 0) { ASSERT(0); diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index b628f0dde5..ece66d30fb 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -16,7 +16,7 @@ #include "tq.h" SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, bool createTb, int64_t suid, - const char* stbFullName, int32_t vgId) { + const char* stbFullName, int32_t vgId) { SSubmitReq* ret = NULL; SArray* tagArray = taosArrayInit(1, sizeof(STagVal)); if (!tagArray) { @@ -80,11 +80,10 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo ret->length = sizeof(SSubmitReq); ret->numOfBlocks = htonl(sz); - void* submitBlk = POINTER_SHIFT(ret, sizeof(SSubmitReq)); + SSubmitBlk* blkHead = POINTER_SHIFT(ret, sizeof(SSubmitReq)); for (int32_t i = 0; i < sz; i++) { SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i); - SSubmitBlk* blkHead = submitBlk; blkHead->numOfRows = htons(pDataBlock->info.rows); blkHead->sversion = htonl(pTSchema->version); // TODO @@ -93,11 +92,10 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo blkHead->uid = 0; int32_t rows = pDataBlock->info.rows; - /*int32_t maxLen = TD_ROW_MAX_BYTES_FROM_SCHEMA(pTSchema);*/ - /*blkHead->dataLen = htonl(rows * maxLen);*/ - blkHead->dataLen = 0; - void* blockData = POINTER_SHIFT(submitBlk, sizeof(SSubmitBlk)); + int32_t dataLen = 0; + + void* blkSchema = POINTER_SHIFT(blkHead, sizeof(SSubmitBlk)); int32_t schemaLen = 0; if (createTb) { @@ -135,7 +133,7 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo } SEncoder encoder = {0}; - tEncoderInit(&encoder, blockData, schemaLen); + tEncoderInit(&encoder, blkSchema, schemaLen); code = tEncodeSVCreateTbReq(&encoder, &createTbReq); tEncoderClear(&encoder); tdDestroySVCreateTbReq(&createTbReq); @@ -148,7 +146,7 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo } blkHead->schemaLen = htonl(schemaLen); - STSRow* rowData = POINTER_SHIFT(blockData, schemaLen); + STSRow* rowData = POINTER_SHIFT(blkSchema, schemaLen); for (int32_t j = 0; j < rows; j++) { SRowBuilder rb = {0}; @@ -168,14 +166,12 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo } int32_t rowLen = TD_ROW_LEN(rowData); rowData = POINTER_SHIFT(rowData, rowLen); - blkHead->dataLen += rowLen; + dataLen += rowLen; } - int32_t dataLen = blkHead->dataLen; blkHead->dataLen = htonl(dataLen); ret->length += sizeof(SSubmitBlk) + schemaLen + dataLen; - blkHead = POINTER_SHIFT(blkHead, schemaLen + dataLen); - /*submitBlk = blkHead;*/ + blkHead = POINTER_SHIFT(blkHead, sizeof(SSubmitBlk) + schemaLen + dataLen); } ret->length = htonl(ret->length); diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index ce73246e51..ce39b35aaa 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -1066,11 +1066,11 @@ static int32_t getFileIdFromKey(TSKEY key, int32_t daysPerFile, int32_t precisio } int64_t fid = (int64_t)(key / (daysPerFile * tsTickPerMin[precision])); // set the starting fileId - if (fid < 0L && llabs(fid) > INT32_MAX) { // data value overflow for INT32 + if (fid < 0LL && llabs(fid) > INT32_MAX) { // data value overflow for INT32 fid = INT32_MIN; } - if (fid > 0L && fid > INT32_MAX) { + if (fid > 0LL && fid > INT32_MAX) { fid = INT32_MAX; } @@ -2845,7 +2845,7 @@ int32_t tsdbGetAllTableList(SMeta* pMeta, uint64_t uid, SArray* list) { break; } - STableKeyInfo info = {.lastKey = TSKEY_INITIAL_VAL, uid = id}; + STableKeyInfo info = {.lastKey = TSKEY_INITIAL_VAL, uid = id, .groupId = 0}; taosArrayPush(list, &info); } diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 2333a93ce0..32d183ca0a 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -124,6 +124,115 @@ _exit: return TSDB_CODE_SUCCESS; } +int vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg) { + STableCfgReq cfgReq = {0}; + STableCfgRsp cfgRsp = {0}; + SMetaReader mer1 = {0}; + SMetaReader mer2 = {0}; + char tableFName[TSDB_TABLE_FNAME_LEN]; + SRpcMsg rpcMsg; + int32_t code = 0; + int32_t rspLen = 0; + void *pRsp = NULL; + SSchemaWrapper schema = {0}; + SSchemaWrapper schemaTag = {0}; + + // decode req + if (tDeserializeSTableCfgReq(pMsg->pCont, pMsg->contLen, &cfgReq) != 0) { + code = TSDB_CODE_INVALID_MSG; + goto _exit; + } + + strcpy(cfgRsp.tbName, cfgReq.tbName); + memcpy(cfgRsp.dbFName, cfgReq.dbFName, sizeof(cfgRsp.dbFName)); + + sprintf(tableFName, "%s.%s", cfgReq.dbFName, cfgReq.tbName); + code = vnodeValidateTableHash(pVnode, tableFName); + if (code) { + goto _exit; + } + + // query meta + metaReaderInit(&mer1, pVnode->pMeta, 0); + + if (metaGetTableEntryByName(&mer1, cfgReq.tbName) < 0) { + code = terrno; + goto _exit; + } + + cfgRsp.tableType = mer1.me.type; + + if (mer1.me.type == TSDB_SUPER_TABLE) { + code = TSDB_CODE_VND_HASH_MISMATCH; + goto _exit; + } else if (mer1.me.type == TSDB_CHILD_TABLE) { + metaReaderInit(&mer2, pVnode->pMeta, 0); + if (metaGetTableEntryByUid(&mer2, mer1.me.ctbEntry.suid) < 0) goto _exit; + + strcpy(cfgRsp.stbName, mer2.me.name); + schema = mer2.me.stbEntry.schemaRow; + schemaTag = mer2.me.stbEntry.schemaTag; + cfgRsp.ttl = mer1.me.ctbEntry.ttlDays; + cfgRsp.commentLen = mer1.me.ctbEntry.commentLen; + if (mer1.me.ctbEntry.commentLen > 0) { + cfgRsp.pComment = strdup(mer1.me.ctbEntry.comment); + } + STag *pTag = (STag *)mer1.me.ctbEntry.pTags; + cfgRsp.tagsLen = pTag->len; + cfgRsp.pTags = taosMemoryMalloc(cfgRsp.tagsLen); + memcpy(cfgRsp.pTags, pTag, cfgRsp.tagsLen); + } else if (mer1.me.type == TSDB_NORMAL_TABLE) { + schema = mer1.me.ntbEntry.schemaRow; + cfgRsp.ttl = mer1.me.ntbEntry.ttlDays; + cfgRsp.commentLen = mer1.me.ntbEntry.commentLen; + if (mer1.me.ntbEntry.commentLen > 0) { + cfgRsp.pComment = strdup(mer1.me.ntbEntry.comment); + } + } else { + ASSERT(0); + } + + cfgRsp.numOfTags = schemaTag.nCols; + cfgRsp.numOfColumns = schema.nCols; + cfgRsp.pSchemas = (SSchema *)taosMemoryMalloc(sizeof(SSchema) * (cfgRsp.numOfColumns + cfgRsp.numOfTags)); + + memcpy(cfgRsp.pSchemas, schema.pSchema, sizeof(SSchema) * schema.nCols); + if (schemaTag.nCols) { + memcpy(cfgRsp.pSchemas + schema.nCols, schemaTag.pSchema, sizeof(SSchema) * schemaTag.nCols); + } + + // encode and send response + rspLen = tSerializeSTableCfgRsp(NULL, 0, &cfgRsp); + if (rspLen < 0) { + code = TSDB_CODE_INVALID_MSG; + goto _exit; + } + + pRsp = rpcMallocCont(rspLen); + if (pRsp == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _exit; + } + tSerializeSTableCfgRsp(pRsp, rspLen, &cfgRsp); + +_exit: + rpcMsg.info = pMsg->info; + rpcMsg.pCont = pRsp; + rpcMsg.contLen = rspLen; + rpcMsg.code = code; + + if (code) { + qError("get table %s cfg failed cause of %s", cfgReq.tbName, tstrerror(code)); + } + + tmsgSendRsp(&rpcMsg); + + tFreeSTableCfgRsp(&cfgRsp); + metaReaderClear(&mer2); + metaReaderClear(&mer1); + return TSDB_CODE_SUCCESS; +} + int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { pLoad->vgId = TD_VID(pVnode); pLoad->syncState = syncGetMyRole(pVnode->sync); @@ -157,4 +266,4 @@ tsdbReaderT tsdbQueryCacheLast(SVnode *pVnode, SQueryTableDataCond *pCond, STabl return tsdbQueryCacheLastT(pVnode->pTsdb, pCond, groupList, qId, pMemRef); #endif return 0; -} \ No newline at end of file +} diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index f3595ebfb0..3dd636e5a8 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -172,7 +172,7 @@ int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp goto _err; } } break; - case TDMT_VND_STREAM_TASK_DROP: { + case TDMT_STREAM_TASK_DROP: { if (tqProcessTaskDropReq(pVnode->pTq, pMsg->pCont, pMsg->contLen) < 0) { goto _err; } @@ -255,6 +255,8 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { return qWorkerProcessHbMsg(pVnode, pVnode->pQuery, pMsg, 0); case TDMT_VND_TABLE_META: return vnodeGetTableMeta(pVnode, pMsg); + case TDMT_VND_TABLE_CFG: + return vnodeGetTableCfg(pVnode, pMsg); case TDMT_VND_CONSUME: return tqProcessPollReq(pVnode->pTq, pMsg, pInfo->workerId); case TDMT_STREAM_TASK_RUN: @@ -263,10 +265,14 @@ int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { return tqProcessTaskDispatchReq(pVnode->pTq, pMsg); case TDMT_STREAM_TASK_RECOVER: return tqProcessTaskRecoverReq(pVnode->pTq, pMsg); + case TDMT_STREAM_RETRIEVE: + return tqProcessTaskRetrieveReq(pVnode->pTq, pMsg); case TDMT_STREAM_TASK_DISPATCH_RSP: return tqProcessTaskDispatchRsp(pVnode->pTq, pMsg); case TDMT_STREAM_TASK_RECOVER_RSP: return tqProcessTaskRecoverRsp(pVnode->pTq, pMsg); + case TDMT_STREAM_RETRIEVE_RSP: + return tqProcessTaskRetrieveRsp(pVnode->pTq, pMsg); default: vError("unknown msg type:%d in fetch queue", pMsg->msgType); return TSDB_CODE_VND_APP_ERROR; diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index 7c90c3538c..98a03aa39b 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -71,11 +71,18 @@ typedef enum { CTG_TASK_GET_TB_META, CTG_TASK_GET_TB_HASH, CTG_TASK_GET_TB_INDEX, + CTG_TASK_GET_TB_CFG, CTG_TASK_GET_INDEX, CTG_TASK_GET_UDF, CTG_TASK_GET_USER, } CTG_TASK_TYPE; +typedef enum { + CTG_TASK_LAUNCHED = 1, + CTG_TASK_DONE, +} CTG_TASK_STATUS; + + typedef struct SCtgDebug { bool lockEnable; bool cacheEnable; @@ -102,6 +109,12 @@ typedef struct SCtgTbIndexCtx { SName* pName; } SCtgTbIndexCtx; +typedef struct SCtgTbCfgCtx { + SName* pName; + int32_t tbType; + SVgroupInfo* pVgInfo; +} SCtgTbCfgCtx; + typedef struct SCtgDbVgCtx { char dbFName[TSDB_DB_FNAME_LEN]; } SCtgDbVgCtx; @@ -190,7 +203,9 @@ typedef struct SCtgJob { SArray* pTasks; int32_t taskDone; SMetaData jobRes; - + int32_t taskIdx; + SRWLatch taskLock; + uint64_t queryId; SCatalog* pCtg; SRequestConnInfo conn; @@ -206,6 +221,7 @@ typedef struct SCtgJob { int32_t userNum; int32_t dbInfoNum; int32_t tbIndexNum; + int32_t tbCfgNum; } SCtgJob; typedef struct SCtgMsgCtx { @@ -215,24 +231,44 @@ typedef struct SCtgMsgCtx { char* target; } SCtgMsgCtx; +typedef struct SCtgTask SCtgTask; +typedef int32_t (*ctgSubTaskCbFp)(SCtgTask*); + +typedef struct SCtgSubRes { + CTG_TASK_TYPE type; + int32_t code; + void* res; + ctgSubTaskCbFp fp; +} SCtgSubRes; + typedef struct SCtgTask { - CTG_TASK_TYPE type; - int32_t taskId; - SCtgJob* pJob; - void* taskCtx; - SCtgMsgCtx msgCtx; - int32_t code; - void* res; + CTG_TASK_TYPE type; + int32_t taskId; + SCtgJob* pJob; + void* taskCtx; + SCtgMsgCtx msgCtx; + int32_t code; + void* res; + CTG_TASK_STATUS status; + SRWLatch lock; + SArray* pParents; + SCtgSubRes subRes; } SCtgTask; +typedef int32_t (*ctgInitTaskFp)(SCtgJob*, int32_t, void*); typedef int32_t (*ctgLanchTaskFp)(SCtgTask*); typedef int32_t (*ctgHandleTaskMsgRspFp)(SCtgTask*, int32_t, const SDataBuf *, int32_t); typedef int32_t (*ctgDumpTaskResFp)(SCtgTask*); +typedef int32_t (*ctgCloneTaskResFp)(SCtgTask*, void**); +typedef int32_t (*ctgCompTaskFp)(SCtgTask*, void*, bool*); typedef struct SCtgAsyncFps { - ctgLanchTaskFp launchFp; + ctgInitTaskFp initFp; + ctgLanchTaskFp launchFp; ctgHandleTaskMsgRspFp handleRspFp; - ctgDumpTaskResFp dumpResFp; + ctgDumpTaskResFp dumpResFp; + ctgCompTaskFp compFp; + ctgCloneTaskResFp cloneFp; } SCtgAsyncFps; typedef struct SCtgApiStat { @@ -520,6 +556,8 @@ int32_t ctgDropTbIndexEnqueue(SCatalog* pCtg, SName* pName, bool syncOp); int32_t ctgOpDropTbIndex(SCtgCacheOperation *operation); int32_t ctgOpUpdateTbIndex(SCtgCacheOperation *operation); int32_t ctgOpClearCache(SCtgCacheOperation *operation); +int32_t ctgReadTbTypeFromCache(SCatalog* pCtg, char* dbFName, char *tableName, int32_t *tbType); +int32_t ctgGetTbHashVgroupFromCache(SCatalog *pCtg, const SName *pTableName, SVgroupInfo **pVgroup); @@ -535,10 +573,14 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo *pConn, char *dbFName, char* tbName, STableMetaOutput* out, SCtgTask* pTask); int32_t ctgGetTbMetaFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableMetaOutput* out, SCtgTask* pTask); int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableMetaOutput* out, SCtgTask* pTask); +int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableCfg **out, SCtgTask* pTask); +int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg **out, SCtgTask* pTask); int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint64_t reqId, const SCatalogReq* pReq, catalogCallback fp, void* param, int32_t* taskNum); int32_t ctgLaunchJob(SCtgJob *pJob); int32_t ctgMakeAsyncRes(SCtgJob *pJob); +int32_t ctgLaunchSubTask(SCtgTask *pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp, void* param); +int32_t ctgGetTbCfgCb(SCtgTask *pTask); int32_t ctgCloneVgInfo(SDBVgInfo *src, SDBVgInfo **dst); int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput); @@ -559,6 +601,7 @@ char * ctgTaskTypeStr(CTG_TASK_TYPE type); int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, SCtgTask* pTask); int32_t ctgCloneTableIndex(SArray* pIndex, SArray** pRes); void ctgFreeSTableIndex(void *info); +void ctgClearSubTaskRes(SCtgSubRes *pRes); extern SCatalogMgmt gCtgMgmt; diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index ce2456d8c3..44730cd3b5 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -22,36 +22,6 @@ SCatalogMgmt gCtgMgmt = {0}; -int32_t ctgRemoveTbMetaFromCache(SCatalog* pCtg, SName* pTableName, bool syncReq) { - int32_t code = 0; - STableMeta* tblMeta = NULL; - SCtgTbMetaCtx tbCtx = {0}; - tbCtx.flag = CTG_FLAG_UNKNOWN_STB; - tbCtx.pName = pTableName; - - CTG_ERR_JRET(ctgReadTbMetaFromCache(pCtg, &tbCtx, &tblMeta)); - - if (NULL == tblMeta) { - ctgDebug("table already not in cache, db:%s, tblName:%s", pTableName->dbname, pTableName->tname); - return TSDB_CODE_SUCCESS; - } - - char dbFName[TSDB_DB_FNAME_LEN]; - tNameGetFullDbName(pTableName, dbFName); - - if (TSDB_SUPER_TABLE == tblMeta->tableType) { - CTG_ERR_JRET(ctgDropStbMetaEnqueue(pCtg, dbFName, tbCtx.tbInfo.dbId, pTableName->tname, tblMeta->suid, syncReq)); - } else { - CTG_ERR_JRET(ctgDropTbMetaEnqueue(pCtg, dbFName, tbCtx.tbInfo.dbId, pTableName->tname, syncReq)); - } - -_return: - - taosMemoryFreeClear(tblMeta); - - CTG_RET(code); -} - int32_t ctgGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char* dbFName, SCtgDBCache** dbCache, SDBVgInfo **pInfo) { int32_t code = 0; @@ -212,29 +182,6 @@ _return: CTG_RET(code); } -int32_t ctgGetTbMetaFromCache(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta) { - if (CTG_IS_SYS_DBNAME(ctx->pName->dbname)) { - CTG_FLAG_SET_SYS_DB(ctx->flag); - } - - CTG_ERR_RET(ctgReadTbMetaFromCache(pCtg, ctx, pTableMeta)); - - if (*pTableMeta) { - if (CTG_FLAG_MATCH_STB(ctx->flag, (*pTableMeta)->tableType) && - ((!CTG_FLAG_IS_FORCE_UPDATE(ctx->flag)) || (CTG_FLAG_IS_SYS_DB(ctx->flag)))) { - return TSDB_CODE_SUCCESS; - } - - taosMemoryFreeClear(*pTableMeta); - } - - if (CTG_FLAG_IS_UNKNOWN_STB(ctx->flag)) { - CTG_FLAG_SET_STB(ctx->flag, ctx->tbInfo.tbType); - } - - return TSDB_CODE_SUCCESS; -} - int32_t ctgGetTbMeta(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta) { int32_t code = 0; STableMetaOutput *output = NULL; @@ -381,6 +328,23 @@ _return: return TSDB_CODE_SUCCESS; } +int32_t ctgGetTbType(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName, int32_t *tbType) { + char dbFName[TSDB_DB_FNAME_LEN]; + tNameGetFullDbName(pTableName, dbFName); + CTG_ERR_RET(ctgReadTbTypeFromCache(pCtg, dbFName, pTableName->tname, tbType)); + if (*tbType > 0) { + return TSDB_CODE_SUCCESS; + } + + STableMeta* pMeta = NULL; + CTG_ERR_RET(catalogGetTableMeta(pCtg, pConn, pTableName, &pMeta)); + + *tbType = pMeta->tableType; + taosMemoryFree(pMeta); + + return TSDB_CODE_SUCCESS; +} + int32_t ctgGetTbIndex(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName, SArray** pRes) { CTG_ERR_RET(ctgReadTbIndexFromCache(pCtg, pTableName, pRes)); if (*pRes) { @@ -419,6 +383,20 @@ _return: CTG_RET(code); } +int32_t ctgGetTbCfg(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName, STableCfg** pCfg) { + int32_t tbType = 0; + CTG_ERR_RET(ctgGetTbType(pCtg, pConn, pTableName, &tbType)); + + if (TSDB_SUPER_TABLE == tbType) { + CTG_ERR_RET(ctgGetTableCfgFromMnode(pCtg, pConn, pTableName, pCfg, NULL)); + } else { + SVgroupInfo vgroupInfo = {0}; + CTG_ERR_RET(catalogGetTableHashVgroup(pCtg, pConn, pTableName, &vgroupInfo)); + CTG_ERR_RET(ctgGetTableCfgFromVnode(pCtg, pConn, pTableName, &vgroupInfo, pCfg, NULL)); + } + + CTG_RET(TSDB_CODE_SUCCESS); +} int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName, SArray** pVgList) { STableMeta *tbMeta = NULL; @@ -1211,6 +1189,23 @@ _return: CTG_API_LEAVE(code); } +int32_t catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg** pCfg) { + CTG_API_ENTER(); + + if (NULL == pCtg || NULL == pConn || NULL == pTableName || NULL == pCfg) { + CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); + } + + int32_t code = 0; + CTG_ERR_JRET(catalogRemoveTableMeta(pCtg, (SName*)pTableName)); + + CTG_ERR_JRET(ctgGetTbCfg(pCtg, pConn, (SName*)pTableName, pCfg)); + +_return: + + CTG_API_LEAVE(code); +} + int32_t catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char* funcName, SFuncInfo* pInfo) { CTG_API_ENTER(); diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index 6adadf5045..df986fd4d6 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -20,7 +20,8 @@ #include "systable.h" #include "tref.h" -int32_t ctgInitGetTbMetaTask(SCtgJob *pJob, int32_t taskIdx, SName *name) { +int32_t ctgInitGetTbMetaTask(SCtgJob *pJob, int32_t taskIdx, void* param) { + SName *name = (SName*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_TB_META; @@ -44,12 +45,13 @@ int32_t ctgInitGetTbMetaTask(SCtgJob *pJob, int32_t taskIdx, SName *name) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %d task type %s initialized, tbName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name->tname); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, tbName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name->tname); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetDbVgTask(SCtgJob *pJob, int32_t taskIdx, char *dbFName) { +int32_t ctgInitGetDbVgTask(SCtgJob *pJob, int32_t taskIdx, void* param) { + char *dbFName = (char*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_DB_VGROUP; @@ -67,12 +69,13 @@ int32_t ctgInitGetDbVgTask(SCtgJob *pJob, int32_t taskIdx, char *dbFName) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %d task type %s initialized, dbFName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), dbFName); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbFName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), dbFName); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetDbCfgTask(SCtgJob *pJob, int32_t taskIdx, char *dbFName) { +int32_t ctgInitGetDbCfgTask(SCtgJob *pJob, int32_t taskIdx, void* param) { + char *dbFName = (char*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_DB_CFG; @@ -90,12 +93,13 @@ int32_t ctgInitGetDbCfgTask(SCtgJob *pJob, int32_t taskIdx, char *dbFName) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %d task type %s initialized, dbFName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), dbFName); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbFName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), dbFName); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetDbInfoTask(SCtgJob *pJob, int32_t taskIdx, char *dbFName) { +int32_t ctgInitGetDbInfoTask(SCtgJob *pJob, int32_t taskIdx, void* param) { + char *dbFName = (char*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_DB_INFO; @@ -113,13 +117,14 @@ int32_t ctgInitGetDbInfoTask(SCtgJob *pJob, int32_t taskIdx, char *dbFName) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %d task type %s initialized, dbFName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), dbFName); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, dbFName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), dbFName); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetTbHashTask(SCtgJob *pJob, int32_t taskIdx, SName *name) { +int32_t ctgInitGetTbHashTask(SCtgJob *pJob, int32_t taskIdx, void* param) { + SName *name = (SName*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_TB_HASH; @@ -143,12 +148,12 @@ int32_t ctgInitGetTbHashTask(SCtgJob *pJob, int32_t taskIdx, SName *name) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %d task type %s initialized, tableName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name->tname); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, tableName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name->tname); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetQnodeTask(SCtgJob *pJob, int32_t taskIdx) { +int32_t ctgInitGetQnodeTask(SCtgJob *pJob, int32_t taskIdx, void* param) { SCtgTask task = {0}; task.type = CTG_TASK_GET_QNODE; @@ -163,7 +168,8 @@ int32_t ctgInitGetQnodeTask(SCtgJob *pJob, int32_t taskIdx) { return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetIndexTask(SCtgJob *pJob, int32_t taskIdx, char *name) { +int32_t ctgInitGetIndexTask(SCtgJob *pJob, int32_t taskIdx, void* param) { + char *name = (char*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_INDEX; @@ -181,12 +187,13 @@ int32_t ctgInitGetIndexTask(SCtgJob *pJob, int32_t taskIdx, char *name) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %d task type %s initialized, indexFName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, indexFName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetUdfTask(SCtgJob *pJob, int32_t taskIdx, char *name) { +int32_t ctgInitGetUdfTask(SCtgJob *pJob, int32_t taskIdx, void* param) { + char *name = (char*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_UDF; @@ -204,12 +211,13 @@ int32_t ctgInitGetUdfTask(SCtgJob *pJob, int32_t taskIdx, char *name) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %d task type %s initialized, udfName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, udfName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetUserTask(SCtgJob *pJob, int32_t taskIdx, SUserAuthInfo *user) { +int32_t ctgInitGetUserTask(SCtgJob *pJob, int32_t taskIdx, void* param) { + SUserAuthInfo *user = (SUserAuthInfo*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_USER; @@ -227,12 +235,13 @@ int32_t ctgInitGetUserTask(SCtgJob *pJob, int32_t taskIdx, SUserAuthInfo *user) taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %d task type %s initialized, user:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), user->user); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, user:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), user->user); return TSDB_CODE_SUCCESS; } -int32_t ctgInitGetTbIndexTask(SCtgJob *pJob, int32_t taskIdx, SName *name) { +int32_t ctgInitGetTbIndexTask(SCtgJob *pJob, int32_t taskIdx, void* param) { + SName *name = (SName*)param; SCtgTask task = {0}; task.type = CTG_TASK_GET_TB_INDEX; @@ -255,11 +264,41 @@ int32_t ctgInitGetTbIndexTask(SCtgJob *pJob, int32_t taskIdx, SName *name) { taosArrayPush(pJob->pTasks, &task); - qDebug("QID:0x%" PRIx64 " the %d task type %s initialized, tbName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name->tname); + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, tbName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name->tname); return TSDB_CODE_SUCCESS; } +int32_t ctgInitGetTbCfgTask(SCtgJob *pJob, int32_t taskIdx, void* param) { + SName *name = (SName*)param; + SCtgTask task = {0}; + + task.type = CTG_TASK_GET_TB_CFG; + task.taskId = taskIdx; + task.pJob = pJob; + + task.taskCtx = taosMemoryCalloc(1, sizeof(SCtgTbCfgCtx)); + if (NULL == task.taskCtx) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + + SCtgTbCfgCtx* ctx = task.taskCtx; + ctx->pName = taosMemoryMalloc(sizeof(*name)); + if (NULL == ctx->pName) { + taosMemoryFree(task.taskCtx); + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + + memcpy(ctx->pName, name, sizeof(*name)); + + taosArrayPush(pJob->pTasks, &task); + + qDebug("QID:0x%" PRIx64 " the %dth task type %s initialized, tbName:%s", pJob->queryId, taskIdx, ctgTaskTypeStr(task.type), name->tname); + + return TSDB_CODE_SUCCESS; +} + + int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob *pJob, const SCatalogReq* pReq) { SHashObj* pDb = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); @@ -296,6 +335,13 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob *pJob, con taosHashPut(pDb, dbFName, strlen(dbFName), dbFName, TSDB_DB_FNAME_LEN); } + for (int32_t i = 0; i < pJob->tbCfgNum; ++i) { + SName* name = taosArrayGet(pReq->pTableCfg, i); + char dbFName[TSDB_DB_FNAME_LEN]; + tNameGetFullDbName(name, dbFName); + taosHashPut(pDb, dbFName, strlen(dbFName), dbFName, TSDB_DB_FNAME_LEN); + } + char* dbFName = taosHashIterate(pDb, NULL); while (dbFName) { ctgDropDbVgroupEnqueue(pCtg, dbFName, true); @@ -304,39 +350,31 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob *pJob, con taosHashCleanup(pDb); - int32_t tbNum = pJob->tbMetaNum + pJob->tbHashNum; - if (tbNum > 0) { - if (tbNum > pJob->tbMetaNum && tbNum > pJob->tbHashNum) { - SHashObj* pTb = taosHashInit(tbNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); - for (int32_t i = 0; i < pJob->tbMetaNum; ++i) { - SName* name = taosArrayGet(pReq->pTableMeta, i); - taosHashPut(pTb, name, sizeof(SName), name, sizeof(SName)); - } - - for (int32_t i = 0; i < pJob->tbHashNum; ++i) { - SName* name = taosArrayGet(pReq->pTableHash, i); - taosHashPut(pTb, name, sizeof(SName), name, sizeof(SName)); - } - - SName* name = taosHashIterate(pTb, NULL); - while (name) { - catalogRemoveTableMeta(pCtg, name); - name = taosHashIterate(pTb, name); - } - - taosHashCleanup(pTb); - } else { - for (int32_t i = 0; i < pJob->tbMetaNum; ++i) { - SName* name = taosArrayGet(pReq->pTableMeta, i); - catalogRemoveTableMeta(pCtg, name); - } - - for (int32_t i = 0; i < pJob->tbHashNum; ++i) { - SName* name = taosArrayGet(pReq->pTableHash, i); - catalogRemoveTableMeta(pCtg, name); - } - } + // REFRESH TABLE META + SHashObj* pTb = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); + for (int32_t i = 0; i < pJob->tbMetaNum; ++i) { + SName* name = taosArrayGet(pReq->pTableMeta, i); + taosHashPut(pTb, name, sizeof(SName), name, sizeof(SName)); } + + for (int32_t i = 0; i < pJob->tbHashNum; ++i) { + SName* name = taosArrayGet(pReq->pTableHash, i); + taosHashPut(pTb, name, sizeof(SName), name, sizeof(SName)); + } + + for (int32_t i = 0; i < pJob->tbCfgNum; ++i) { + SName* name = taosArrayGet(pReq->pTableCfg, i); + taosHashPut(pTb, name, sizeof(SName), name, sizeof(SName)); + } + + SName* name = taosHashIterate(pTb, NULL); + while (name) { + catalogRemoveTableMeta(pCtg, name); + name = taosHashIterate(pTb, name); + } + + taosHashCleanup(pTb); + for (int32_t i = 0; i < pJob->tbIndexNum; ++i) { SName* name = taosArrayGet(pReq->pTableIndex, i); @@ -346,6 +384,20 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob *pJob, con return TSDB_CODE_SUCCESS; } +int32_t ctgInitTask(SCtgJob *pJob, CTG_TASK_TYPE type, void* param, int32_t *taskId) { + int32_t tid = atomic_fetch_add_32(&pJob->taskIdx, 1); + + CTG_LOCK(CTG_WRITE, &pJob->taskLock); + CTG_ERR_RET((*gCtgAsyncFps[type].initFp)(pJob, tid, param)); + CTG_UNLOCK(CTG_WRITE, &pJob->taskLock); + + if (taskId) { + *taskId = tid; + } + + return TSDB_CODE_SUCCESS; +} + int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint64_t reqId, const SCatalogReq* pReq, catalogCallback fp, void* param, int32_t* taskNum) { int32_t code = 0; int32_t tbMetaNum = (int32_t)taosArrayGetSize(pReq->pTableMeta); @@ -358,8 +410,9 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint6 int32_t userNum = (int32_t)taosArrayGetSize(pReq->pUser); int32_t dbInfoNum = (int32_t)taosArrayGetSize(pReq->pDbInfo); int32_t tbIndexNum = (int32_t)taosArrayGetSize(pReq->pTableIndex); + int32_t tbCfgNum = (int32_t)taosArrayGetSize(pReq->pTableCfg); - *taskNum = tbMetaNum + dbVgNum + udfNum + tbHashNum + qnodeNum + dbCfgNum + indexNum + userNum + dbInfoNum + tbIndexNum; + *taskNum = tbMetaNum + dbVgNum + udfNum + tbHashNum + qnodeNum + dbCfgNum + indexNum + userNum + dbInfoNum + tbIndexNum + tbCfgNum; if (*taskNum <= 0) { ctgDebug("Empty input for job, no need to retrieve meta, reqId:0x%" PRIx64, reqId); return TSDB_CODE_SUCCESS; @@ -389,6 +442,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint6 pJob->userNum = userNum; pJob->dbInfoNum = dbInfoNum; pJob->tbIndexNum = tbIndexNum; + pJob->tbCfgNum = tbCfgNum; pJob->pTasks = taosArrayInit(*taskNum, sizeof(SCtgTask)); @@ -401,54 +455,58 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, uint6 CTG_ERR_JRET(ctgHandleForceUpdate(pCtg, *taskNum, pJob, pReq)); } - int32_t taskIdx = 0; for (int32_t i = 0; i < dbVgNum; ++i) { char* dbFName = taosArrayGet(pReq->pDbVgroup, i); - CTG_ERR_JRET(ctgInitGetDbVgTask(pJob, taskIdx++, dbFName)); + CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_DB_VGROUP, dbFName, NULL)); } for (int32_t i = 0; i < dbCfgNum; ++i) { char* dbFName = taosArrayGet(pReq->pDbCfg, i); - CTG_ERR_JRET(ctgInitGetDbCfgTask(pJob, taskIdx++, dbFName)); + CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_DB_CFG, dbFName, NULL)); } for (int32_t i = 0; i < dbInfoNum; ++i) { char* dbFName = taosArrayGet(pReq->pDbInfo, i); - CTG_ERR_JRET(ctgInitGetDbInfoTask(pJob, taskIdx++, dbFName)); + CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_DB_INFO, dbFName, NULL)); } for (int32_t i = 0; i < tbMetaNum; ++i) { SName* name = taosArrayGet(pReq->pTableMeta, i); - CTG_ERR_JRET(ctgInitGetTbMetaTask(pJob, taskIdx++, name)); + CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_TB_META, name, NULL)); } for (int32_t i = 0; i < tbHashNum; ++i) { SName* name = taosArrayGet(pReq->pTableHash, i); - CTG_ERR_JRET(ctgInitGetTbHashTask(pJob, taskIdx++, name)); + CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_TB_HASH, name, NULL)); } for (int32_t i = 0; i < tbIndexNum; ++i) { SName* name = taosArrayGet(pReq->pTableIndex, i); - CTG_ERR_JRET(ctgInitGetTbIndexTask(pJob, taskIdx++, name)); + CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_TB_INDEX, name, NULL)); + } + + for (int32_t i = 0; i < tbCfgNum; ++i) { + SName* name = taosArrayGet(pReq->pTableCfg, i); + CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_TB_CFG, name, NULL)); } for (int32_t i = 0; i < indexNum; ++i) { char* indexName = taosArrayGet(pReq->pIndex, i); - CTG_ERR_JRET(ctgInitGetIndexTask(pJob, taskIdx++, indexName)); + CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_INDEX, indexName, NULL)); } for (int32_t i = 0; i < udfNum; ++i) { char* udfName = taosArrayGet(pReq->pUdf, i); - CTG_ERR_JRET(ctgInitGetUdfTask(pJob, taskIdx++, udfName)); + CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_UDF, udfName, NULL)); } for (int32_t i = 0; i < userNum; ++i) { SUserAuthInfo* user = taosArrayGet(pReq->pUser, i); - CTG_ERR_JRET(ctgInitGetUserTask(pJob, taskIdx++, user)); + CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_USER, user, NULL)); } if (qnodeNum) { - CTG_ERR_JRET(ctgInitGetQnodeTask(pJob, taskIdx++)); + CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_QNODE, NULL, NULL)); } pJob->refId = taosAddRef(gCtgMgmt.jobPool, pJob); @@ -528,6 +586,21 @@ int32_t ctgDumpTbIndexRes(SCtgTask* pTask) { return TSDB_CODE_SUCCESS; } +int32_t ctgDumpTbCfgRes(SCtgTask* pTask) { + SCtgJob* pJob = pTask->pJob; + if (NULL == pJob->jobRes.pTableCfg) { + pJob->jobRes.pTableCfg = taosArrayInit(pJob->tbCfgNum, sizeof(SMetaRes)); + if (NULL == pJob->jobRes.pTableCfg) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + } + + SMetaRes res = {.code = pTask->code, .pRes = pTask->res}; + taosArrayPush(pJob->jobRes.pTableCfg, &res); + + return TSDB_CODE_SUCCESS; +} + int32_t ctgDumpIndexRes(SCtgTask* pTask) { SCtgJob* pJob = pTask->pJob; if (NULL == pJob->jobRes.pIndex) { @@ -618,13 +691,48 @@ int32_t ctgDumpUserRes(SCtgTask* pTask) { return TSDB_CODE_SUCCESS; } +int32_t ctgInvokeSubCb(SCtgTask *pTask) { + int32_t code = 0; + + CTG_LOCK(CTG_WRITE, &pTask->lock); + + int32_t parentNum = taosArrayGetSize(pTask->pParents); + for (int32_t i = 0; i < parentNum; ++i) { + SCtgTask* pParent = taosArrayGetP(pTask->pParents, i); + + pParent->subRes.code = pTask->code; + if (TSDB_CODE_SUCCESS == pTask->code) { + code = (*gCtgAsyncFps[pTask->type].cloneFp)(pTask, &pParent->subRes.res); + if (code) { + pParent->subRes.code = code; + } + } + + CTG_ERR_JRET(pParent->subRes.fp(pParent)); + } + +_return: + + CTG_UNLOCK(CTG_WRITE, &pTask->lock); + + CTG_RET(code); +} + + int32_t ctgHandleTaskEnd(SCtgTask* pTask, int32_t rspCode) { SCtgJob* pJob = pTask->pJob; int32_t code = 0; + if (CTG_TASK_DONE == pTask->status) { + return TSDB_CODE_SUCCESS; + } + qDebug("QID:0x%" PRIx64 " task %d end with res %s", pJob->queryId, pTask->taskId, tstrerror(rspCode)); pTask->code = rspCode; + pTask->status = CTG_TASK_DONE; + + ctgInvokeSubCb(pTask); int32_t taskDone = atomic_add_fetch_32(&pJob->taskDone, 1); if (taskDone < taosArrayGetSize(pJob->pTasks)) { @@ -636,7 +744,7 @@ int32_t ctgHandleTaskEnd(SCtgTask* pTask, int32_t rspCode) { _return: - qDebug("QID:0x%" PRIx64 " user callback with rsp %s", pJob->queryId, tstrerror(code)); + qDebug("QID:0x%" PRIx64 " ctg call user callback with rsp %s", pJob->queryId, tstrerror(code)); (*pJob->userFp)(&pJob->jobRes, pJob->userParam, code); @@ -802,11 +910,12 @@ int32_t ctgHandleGetDbVgRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pM switch (reqType) { case TDMT_MND_USE_DB: { SUseDbOutput* pOut = (SUseDbOutput*)pTask->msgCtx.out; - - CTG_ERR_JRET(ctgGenerateVgList(pCtg, pOut->dbVgroup->vgHash, (SArray**)&pTask->res)); + SDBVgInfo* pDb = NULL; - CTG_ERR_JRET(ctgUpdateVgroupEnqueue(pCtg, ctx->dbFName, pOut->dbId, pOut->dbVgroup, false)); - pOut->dbVgroup = NULL; + CTG_ERR_JRET(ctgGenerateVgList(pCtg, pOut->dbVgroup->vgHash, (SArray**)&pTask->res)); + + CTG_ERR_JRET(cloneDbVgInfo(pOut->dbVgroup, &pDb)); + CTG_ERR_JRET(ctgUpdateVgroupEnqueue(pCtg, ctx->dbFName, pOut->dbId, pDb, false)); break; } @@ -874,6 +983,7 @@ int32_t ctgHandleGetTbIndexRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf CTG_ERR_JRET(ctgUpdateTbIndexEnqueue(pTask->pJob->pCtg, (STableIndex**)&pTask->msgCtx.out, false)); _return: + if (TSDB_CODE_MND_DB_INDEX_NOT_EXIST == code) { code = TSDB_CODE_SUCCESS; } @@ -882,6 +992,18 @@ _return: CTG_RET(code); } +int32_t ctgHandleGetTbCfgRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { + int32_t code = 0; + CTG_ERR_JRET(ctgProcessRspMsg(&pTask->msgCtx.out, reqType, pMsg->pData, pMsg->len, rspCode, pTask->msgCtx.target)); + + TSWAP(pTask->res, pTask->msgCtx.out); + +_return: + + ctgHandleTaskEnd(pTask, code); + + CTG_RET(code); +} int32_t ctgHandleGetDbCfgRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pMsg, int32_t rspCode) { int32_t code = 0; @@ -1138,6 +1260,48 @@ int32_t ctgLaunchGetTbIndexTask(SCtgTask *pTask) { return TSDB_CODE_SUCCESS; } +int32_t ctgLaunchGetTbCfgTask(SCtgTask *pTask) { + int32_t code = 0; + SCatalog* pCtg = pTask->pJob->pCtg; + SRequestConnInfo* pConn = &pTask->pJob->conn; + SCtgTbCfgCtx* pCtx = (SCtgTbCfgCtx*)pTask->taskCtx; + SArray* pRes = NULL; + char dbFName[TSDB_DB_FNAME_LEN]; + tNameGetFullDbName(pCtx->pName, dbFName); + + if (pCtx->tbType <= 0) { + CTG_ERR_JRET(ctgReadTbTypeFromCache(pCtg, dbFName, pCtx->pName->tname, &pCtx->tbType)); + if (pCtx->tbType <= 0) { + CTG_ERR_JRET(ctgLaunchSubTask(pTask, CTG_TASK_GET_TB_META, ctgGetTbCfgCb, pCtx->pName)); + return TSDB_CODE_SUCCESS; + } + } + + if (TSDB_SUPER_TABLE == pCtx->tbType) { + CTG_ERR_JRET(ctgGetTableCfgFromMnode(pCtg, pConn, pCtx->pName, NULL, pTask)); + } else { + if (NULL == pCtx->pVgInfo) { + CTG_ERR_JRET(ctgGetTbHashVgroupFromCache(pCtg, pCtx->pName, &pCtx->pVgInfo)); + if (NULL == pCtx->pVgInfo) { + CTG_ERR_JRET(ctgLaunchSubTask(pTask, CTG_TASK_GET_DB_VGROUP, ctgGetTbCfgCb, dbFName)); + return TSDB_CODE_SUCCESS; + } + } + + CTG_ERR_JRET(ctgGetTableCfgFromVnode(pCtg, pConn, pCtx->pName, pCtx->pVgInfo, NULL, pTask)); + } + + return TSDB_CODE_SUCCESS; + +_return: + + if (CTG_TASK_LAUNCHED == pTask->status) { + ctgHandleTaskEnd(pTask, code); + } + + CTG_RET(code); +} + int32_t ctgLaunchGetQnodeTask(SCtgTask *pTask) { SCatalog* pCtg = pTask->pJob->pCtg; @@ -1244,17 +1408,70 @@ int32_t ctgRelaunchGetTbMetaTask(SCtgTask *pTask) { return TSDB_CODE_SUCCESS; } +int32_t ctgGetTbCfgCb(SCtgTask *pTask) { + int32_t code = 0; + + CTG_ERR_JRET(pTask->subRes.code); + + SCtgTbCfgCtx* pCtx = (SCtgTbCfgCtx*)pTask->taskCtx; + if (CTG_TASK_GET_TB_META == pTask->subRes.type) { + pCtx->tbType = ((STableMeta*)pTask->subRes.res)->tableType; + } else if (CTG_TASK_GET_DB_VGROUP == pTask->subRes.type) { + SDBVgInfo* pDb = (SDBVgInfo*)pTask->subRes.res; + + pCtx->pVgInfo = taosMemoryCalloc(1, sizeof(SVgroupInfo)); + CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pTask->pJob->pCtg, pDb, pCtx->pName, pCtx->pVgInfo)); + } + + CTG_RET(ctgLaunchGetTbCfgTask(pTask)); + +_return: + + CTG_RET(ctgHandleTaskEnd(pTask, pTask->subRes.code)); +} + +int32_t ctgCompDbVgTasks(SCtgTask* pTask, void* param, bool* equal) { + SCtgDbVgCtx* ctx = pTask->taskCtx; + + *equal = (0 == strcmp(ctx->dbFName, param)); + + return TSDB_CODE_SUCCESS; +} + + +int32_t ctgCompTbMetaTasks(SCtgTask* pTask, void* param, bool* equal) { + SCtgTbMetaCtx* ctx = pTask->taskCtx; + + *equal = tNameTbNameEqual(ctx->pName, (SName*)param); + + return TSDB_CODE_SUCCESS; +} + +int32_t ctgCloneTbMeta(SCtgTask* pTask, void** pRes) { + STableMeta* pMeta = (STableMeta*)pTask->res; + + CTG_RET(cloneTableMeta(pMeta, (STableMeta**)pRes)); +} + +int32_t ctgCloneDbVg(SCtgTask* pTask, void** pRes) { + SUseDbOutput* pOut = (SUseDbOutput*)pTask->msgCtx.out; + + CTG_RET(cloneDbVgInfo(pOut->dbVgroup, (SDBVgInfo**)pRes)); +} + + SCtgAsyncFps gCtgAsyncFps[] = { - {ctgLaunchGetQnodeTask, ctgHandleGetQnodeRsp, ctgDumpQnodeRes}, - {ctgLaunchGetDbVgTask, ctgHandleGetDbVgRsp, ctgDumpDbVgRes}, - {ctgLaunchGetDbCfgTask, ctgHandleGetDbCfgRsp, ctgDumpDbCfgRes}, - {ctgLaunchGetDbInfoTask, ctgHandleGetDbInfoRsp, ctgDumpDbInfoRes}, - {ctgLaunchGetTbMetaTask, ctgHandleGetTbMetaRsp, ctgDumpTbMetaRes}, - {ctgLaunchGetTbHashTask, ctgHandleGetTbHashRsp, ctgDumpTbHashRes}, - {ctgLaunchGetTbIndexTask, ctgHandleGetTbIndexRsp, ctgDumpTbIndexRes}, - {ctgLaunchGetIndexTask, ctgHandleGetIndexRsp, ctgDumpIndexRes}, - {ctgLaunchGetUdfTask, ctgHandleGetUdfRsp, ctgDumpUdfRes}, - {ctgLaunchGetUserTask, ctgHandleGetUserRsp, ctgDumpUserRes}, + {ctgInitGetQnodeTask, ctgLaunchGetQnodeTask, ctgHandleGetQnodeRsp, ctgDumpQnodeRes, NULL, NULL}, + {ctgInitGetDbVgTask, ctgLaunchGetDbVgTask, ctgHandleGetDbVgRsp, ctgDumpDbVgRes, ctgCompDbVgTasks, ctgCloneDbVg}, + {ctgInitGetDbCfgTask, ctgLaunchGetDbCfgTask, ctgHandleGetDbCfgRsp, ctgDumpDbCfgRes, NULL, NULL}, + {ctgInitGetDbInfoTask, ctgLaunchGetDbInfoTask, ctgHandleGetDbInfoRsp, ctgDumpDbInfoRes, NULL, NULL}, + {ctgInitGetTbMetaTask, ctgLaunchGetTbMetaTask, ctgHandleGetTbMetaRsp, ctgDumpTbMetaRes, ctgCompTbMetaTasks, ctgCloneTbMeta}, + {ctgInitGetTbHashTask, ctgLaunchGetTbHashTask, ctgHandleGetTbHashRsp, ctgDumpTbHashRes, NULL, NULL}, + {ctgInitGetTbIndexTask, ctgLaunchGetTbIndexTask, ctgHandleGetTbIndexRsp, ctgDumpTbIndexRes, NULL, NULL}, + {ctgInitGetTbCfgTask, ctgLaunchGetTbCfgTask, ctgHandleGetTbCfgRsp, ctgDumpTbCfgRes, NULL, NULL}, + {ctgInitGetIndexTask, ctgLaunchGetIndexTask, ctgHandleGetIndexRsp, ctgDumpIndexRes, NULL, NULL}, + {ctgInitGetUdfTask, ctgLaunchGetUdfTask, ctgHandleGetUdfRsp, ctgDumpUdfRes, NULL, NULL}, + {ctgInitGetUserTask, ctgLaunchGetUserTask, ctgHandleGetUserRsp, ctgDumpUserRes, NULL, NULL}, }; int32_t ctgMakeAsyncRes(SCtgJob *pJob) { @@ -1269,6 +1486,86 @@ int32_t ctgMakeAsyncRes(SCtgJob *pJob) { return TSDB_CODE_SUCCESS; } +int32_t ctgSearchExistingTask(SCtgJob *pJob, CTG_TASK_TYPE type, void* param, int32_t* taskId) { + bool equal = false; + SCtgTask* pTask = NULL; + int32_t code = 0; + + CTG_LOCK(CTG_READ, &pJob->taskLock); + + int32_t taskNum = taosArrayGetSize(pJob->pTasks); + for (int32_t i = 0; i < taskNum; ++i) { + pTask = taosArrayGet(pJob->pTasks, i); + if (type != pTask->type) { + continue; + } + + CTG_ERR_JRET((*gCtgAsyncFps[type].compFp)(pTask, param, &equal)); + if (equal) { + break; + } + } + +_return: + + CTG_UNLOCK(CTG_READ, &pJob->taskLock); + if (equal) { + *taskId = pTask->taskId; + } + + CTG_RET(code); +} + +int32_t ctgSetSubTaskCb(SCtgTask *pSub, SCtgTask *pTask) { + int32_t code = 0; + + CTG_LOCK(CTG_WRITE, &pSub->lock); + if (CTG_TASK_DONE == pSub->status) { + pTask->subRes.code = pSub->code; + CTG_ERR_JRET((*gCtgAsyncFps[pTask->type].cloneFp)(pSub, &pTask->subRes.res)); + CTG_ERR_JRET(pTask->subRes.fp(pTask)); + } else { + if (NULL == pSub->pParents) { + pSub->pParents = taosArrayInit(4, POINTER_BYTES); + } + + taosArrayPush(pSub->pParents, &pTask); + } + +_return: + + CTG_UNLOCK(CTG_WRITE, &pSub->lock); + + CTG_RET(code); +} + + +int32_t ctgLaunchSubTask(SCtgTask *pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp, void* param) { + SCtgJob* pJob = pTask->pJob; + int32_t subTaskId = -1; + bool newTask = false; + + ctgClearSubTaskRes(&pTask->subRes); + pTask->subRes.type = type; + pTask->subRes.fp = fp; + + CTG_ERR_RET(ctgSearchExistingTask(pJob, type, param, &subTaskId)); + if (subTaskId < 0) { + CTG_ERR_RET(ctgInitTask(pJob, type, param, &subTaskId)); + newTask = true; + } + + SCtgTask* pSub = taosArrayGet(pJob->pTasks, subTaskId); + + CTG_ERR_RET(ctgSetSubTaskCb(pSub, pTask)); + + if (newTask) { + CTG_ERR_RET((*gCtgAsyncFps[pSub->type].launchFp)(pSub)); + pSub->status = CTG_TASK_LAUNCHED; + } + + return TSDB_CODE_SUCCESS; +} int32_t ctgLaunchJob(SCtgJob *pJob) { int32_t taskNum = taosArrayGetSize(pJob->pTasks); @@ -1278,6 +1575,7 @@ int32_t ctgLaunchJob(SCtgJob *pJob) { qDebug("QID:0x%" PRIx64 " ctg start to launch task %d", pJob->queryId, pTask->taskId); CTG_ERR_RET((*gCtgAsyncFps[pTask->type].launchFp)(pTask)); + pTask->status = CTG_TASK_LAUNCHED; } return TSDB_CODE_SUCCESS; diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index 1de5ee3d7d..eeb627624b 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -326,6 +326,7 @@ _return: int32_t ctgAcquireTbIndexFromCache(SCatalog* pCtg, char *dbFName, char* tbName, SCtgDBCache **pDb, SCtgTbCache** pTb) { SCtgDBCache *dbCache = NULL; + SCtgTbCache* pCache = NULL; ctgAcquireDBCache(pCtg, dbFName, &dbCache); if (NULL == dbCache) { ctgDebug("db %s not in cache", dbFName); @@ -333,7 +334,7 @@ int32_t ctgAcquireTbIndexFromCache(SCatalog* pCtg, char *dbFName, char* tbName, } int32_t sz = 0; - SCtgTbCache* pCache = taosHashAcquire(dbCache->tbCache, tbName, strlen(tbName)); + pCache = taosHashAcquire(dbCache->tbCache, tbName, strlen(tbName)); if (NULL == pCache) { ctgDebug("tb %s not in cache, dbFName:%s", tbName, dbFName); goto _return; @@ -540,10 +541,10 @@ int32_t ctgReadTbVerFromCache(SCatalog *pCtg, SName *pTableName, int32_t *sver, } -int32_t ctgReadTbTypeFromCache(SCatalog* pCtg, char* dbFName, char *tableName, int32_t *tbType) { +int32_t ctgReadTbTypeFromCache(SCatalog* pCtg, char* dbFName, char *tbName, int32_t *tbType) { SCtgDBCache *dbCache = NULL; SCtgTbCache *tbCache = NULL; - CTG_ERR_RET(ctgAcquireTbMetaFromCache(pCtg, dbFName, tableName, &dbCache, &tbCache)); + CTG_ERR_RET(ctgAcquireTbMetaFromCache(pCtg, dbFName, tbName, &dbCache, &tbCache)); if (NULL == tbCache) { ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache); return TSDB_CODE_SUCCESS; @@ -552,7 +553,7 @@ int32_t ctgReadTbTypeFromCache(SCatalog* pCtg, char* dbFName, char *tableName, i *tbType = tbCache->pMeta->tableType; ctgReleaseTbMetaToCache(pCtg, dbCache, tbCache); - ctgDebug("Got tb %s tbType %d from cache, dbFName:%s", tableName, *tbType, dbFName); + ctgDebug("Got tb %s tbType %d from cache, dbFName:%s", tbName, *tbType, dbFName); return TSDB_CODE_SUCCESS; } @@ -1394,7 +1395,7 @@ int32_t ctgWriteTbMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFNam if (orig) { origType = orig->tableType; - if (origType == meta->tableType && orig->uid == meta->uid && orig->sversion >= meta->sversion && orig->tversion >= meta->tversion) { + if (origType == meta->tableType && orig->uid == meta->uid && (origType == TSDB_CHILD_TABLE || (orig->sversion >= meta->sversion && orig->tversion >= meta->tversion))) { taosMemoryFree(meta); ctgDebug("ignore table %s meta update", tbName); return TSDB_CODE_SUCCESS; @@ -2060,4 +2061,92 @@ int32_t ctgStartUpdateThread() { } +int32_t ctgGetTbMetaFromCache(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta) { + if (CTG_IS_SYS_DBNAME(ctx->pName->dbname)) { + CTG_FLAG_SET_SYS_DB(ctx->flag); + } + + CTG_ERR_RET(ctgReadTbMetaFromCache(pCtg, ctx, pTableMeta)); + + if (*pTableMeta) { + if (CTG_FLAG_MATCH_STB(ctx->flag, (*pTableMeta)->tableType) && + ((!CTG_FLAG_IS_FORCE_UPDATE(ctx->flag)) || (CTG_FLAG_IS_SYS_DB(ctx->flag)))) { + return TSDB_CODE_SUCCESS; + } + + taosMemoryFreeClear(*pTableMeta); + } + + if (CTG_FLAG_IS_UNKNOWN_STB(ctx->flag)) { + CTG_FLAG_SET_STB(ctx->flag, ctx->tbInfo.tbType); + } + + return TSDB_CODE_SUCCESS; +} + + +int32_t ctgRemoveTbMetaFromCache(SCatalog* pCtg, SName* pTableName, bool syncReq) { + int32_t code = 0; + STableMeta* tblMeta = NULL; + SCtgTbMetaCtx tbCtx = {0}; + tbCtx.flag = CTG_FLAG_UNKNOWN_STB; + tbCtx.pName = pTableName; + + CTG_ERR_JRET(ctgReadTbMetaFromCache(pCtg, &tbCtx, &tblMeta)); + + if (NULL == tblMeta) { + ctgDebug("table already not in cache, db:%s, tblName:%s", pTableName->dbname, pTableName->tname); + return TSDB_CODE_SUCCESS; + } + + char dbFName[TSDB_DB_FNAME_LEN]; + tNameGetFullDbName(pTableName, dbFName); + + if (TSDB_SUPER_TABLE == tblMeta->tableType) { + CTG_ERR_JRET(ctgDropStbMetaEnqueue(pCtg, dbFName, tbCtx.tbInfo.dbId, pTableName->tname, tblMeta->suid, syncReq)); + } else { + CTG_ERR_JRET(ctgDropTbMetaEnqueue(pCtg, dbFName, tbCtx.tbInfo.dbId, pTableName->tname, syncReq)); + } + +_return: + + taosMemoryFreeClear(tblMeta); + + CTG_RET(code); +} + +int32_t ctgGetTbHashVgroupFromCache(SCatalog *pCtg, const SName *pTableName, SVgroupInfo **pVgroup) { + if (CTG_IS_SYS_DBNAME(pTableName->dbname)) { + ctgError("no valid vgInfo for db, dbname:%s", pTableName->dbname); + CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); + } + + SCtgDBCache* dbCache = NULL; + int32_t code = 0; + char dbFName[TSDB_DB_FNAME_LEN] = {0}; + tNameGetFullDbName(pTableName, dbFName); + + CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, dbFName, &dbCache)); + + if (NULL == dbCache) { + *pVgroup = NULL; + return TSDB_CODE_SUCCESS; + } + + *pVgroup = taosMemoryCalloc(1, sizeof(SVgroupInfo)); + CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgCache.vgInfo, pTableName, *pVgroup)); + +_return: + + if (dbCache) { + ctgReleaseVgInfoToCache(pCtg, dbCache); + } + + if (code) { + taosMemoryFreeClear(*pVgroup); + } + + CTG_RET(code); +} + diff --git a/source/libs/catalog/src/ctgRemote.c b/source/libs/catalog/src/ctgRemote.c index fa1a262832..81dabffb4e 100644 --- a/source/libs/catalog/src/ctgRemote.c +++ b/source/libs/catalog/src/ctgRemote.c @@ -172,6 +172,39 @@ int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, qDebug("Got table meta from vnode, tbFName:%s", target); break; } + case TDMT_VND_TABLE_CFG: { + if (TSDB_CODE_SUCCESS != rspCode) { + qError("error rsp for table cfg from vnode, code:%s, tbFName:%s", tstrerror(rspCode), target); + CTG_ERR_RET(rspCode); + } + + code = queryProcessMsgRsp[TMSG_INDEX(reqType)](out, msg, msgSize); + if (code) { + qError("Process vnode tb cfg rsp failed, code:%s, tbFName:%s", tstrerror(code), target); + CTG_ERR_RET(code); + } + + qDebug("Got table cfg from vnode, tbFName:%s", target); + break; + } + case TDMT_MND_TABLE_CFG: { + if (TSDB_CODE_SUCCESS != rspCode) { + qError("error rsp for stb cfg from mnode, error:%s, tbFName:%s", tstrerror(rspCode), target); + CTG_ERR_RET(rspCode); + } + + code = queryProcessMsgRsp[TMSG_INDEX(reqType)](out, msg, msgSize); + if (code) { + qError("Process mnode stb cfg rsp failed, error:%s, tbFName:%s", tstrerror(code), target); + CTG_ERR_RET(code); + } + + qDebug("Got stb cfg from mnode, tbFName:%s", target); + break; + } + default: + qError("invalid req type %s", TMSG_INFO(reqType)); + return TSDB_CODE_APP_ERROR; } return TSDB_CODE_SUCCESS; @@ -550,7 +583,7 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo *pConn, char *dbFName, char* tbName, STableMetaOutput* out, SCtgTask* pTask) { - SBuildTableMetaInput bInput = {.vgId = 0, .dbFName = dbFName, .tbName = tbName}; + SBuildTableInput bInput = {.vgId = 0, .dbFName = dbFName, .tbName = tbName}; char *msg = NULL; SEpSet *pVnodeEpSet = NULL; int32_t msgLen = 0; @@ -606,9 +639,11 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SNa sprintf(tbFName, "%s.%s", dbFName, pTableName->tname); void*(*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; - ctgDebug("try to get table meta from vnode, vgId:%d, tbFName:%s", vgroupInfo->vgId, tbFName); + SEp* pEp = &vgroupInfo->epSet.eps[vgroupInfo->epSet.inUse]; + ctgDebug("try to get table meta from vnode, vgId:%d, ep num:%d, ep %s:%d, tbFName:%s", + vgroupInfo->vgId, vgroupInfo->epSet.numOfEps, pEp->fqdn, pEp->port, tbFName); - SBuildTableMetaInput bInput = {.vgId = vgroupInfo->vgId, .dbFName = dbFName, .tbName = (char *)tNameGetTableName(pTableName)}; + SBuildTableInput bInput = {.vgId = vgroupInfo->vgId, .dbFName = dbFName, .tbName = (char *)tNameGetTableName(pTableName)}; char *msg = NULL; int32_t msgLen = 0; @@ -646,4 +681,89 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SNa return TSDB_CODE_SUCCESS; } +int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableCfg **out, SCtgTask* pTask) { + char *msg = NULL; + int32_t msgLen = 0; + int32_t reqType = TDMT_VND_TABLE_CFG; + char tbFName[TSDB_TABLE_FNAME_LEN]; + tNameExtractFullName(pTableName, tbFName); + void*(*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; + char dbFName[TSDB_DB_FNAME_LEN]; + tNameGetFullDbName(pTableName, dbFName); + SBuildTableInput bInput = {.vgId = vgroupInfo->vgId, .dbFName = dbFName, .tbName = (char*)pTableName->tname}; + + SEp* pEp = &vgroupInfo->epSet.eps[vgroupInfo->epSet.inUse]; + ctgDebug("try to get table cfg from vnode, vgId:%d, ep num:%d, ep %s:%d, tbFName:%s", + vgroupInfo->vgId, vgroupInfo->epSet.numOfEps, pEp->fqdn, pEp->port, tbFName); + + int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](&bInput, &msg, 0, &msgLen, mallocFp); + if (code) { + ctgError("Build get tb cfg msg failed, code:%s, tbFName:%s", tstrerror(code), tbFName); + CTG_ERR_RET(code); + } + + if (pTask) { + CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, (char*)tbFName)); + + SRequestConnInfo vConn = {.pTrans = pConn->pTrans, + .requestId = pConn->requestId, + .requestObjRefId = pConn->requestObjRefId, + .mgmtEps = vgroupInfo->epSet}; + CTG_RET(ctgAsyncSendMsg(pCtg, &vConn, pTask, reqType, msg, msgLen)); + } + + SRpcMsg rpcMsg = { + .msgType = reqType, + .pCont = msg, + .contLen = msgLen, + }; + + SRpcMsg rpcRsp = {0}; + rpcSendRecv(pConn->pTrans, &vgroupInfo->epSet, &rpcMsg, &rpcRsp); + + CTG_ERR_RET(ctgProcessRspMsg(out, reqType, rpcRsp.pCont, rpcRsp.contLen, rpcRsp.code, (char*)tbFName)); + + return TSDB_CODE_SUCCESS; +} + + +int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg **out, SCtgTask* pTask) { + char *msg = NULL; + int32_t msgLen = 0; + int32_t reqType = TDMT_MND_TABLE_CFG; + char tbFName[TSDB_TABLE_FNAME_LEN]; + tNameExtractFullName(pTableName, tbFName); + void*(*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; + char dbFName[TSDB_DB_FNAME_LEN]; + tNameGetFullDbName(pTableName, dbFName); + SBuildTableInput bInput = {.vgId = 0, .dbFName = dbFName, .tbName = (char*)pTableName->tname}; + + ctgDebug("try to get table cfg from mnode, tbFName:%s", tbFName); + + int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](&bInput, &msg, 0, &msgLen, mallocFp); + if (code) { + ctgError("Build get tb cfg msg failed, code:%s, tbFName:%s", tstrerror(code), tbFName); + CTG_ERR_RET(code); + } + + if (pTask) { + CTG_ERR_RET(ctgUpdateMsgCtx(&pTask->msgCtx, reqType, NULL, (char*)tbFName)); + + CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask, reqType, msg, msgLen)); + } + + SRpcMsg rpcMsg = { + .msgType = reqType, + .pCont = msg, + .contLen = msgLen, + }; + + SRpcMsg rpcRsp = {0}; + rpcSendRecv(pConn->pTrans, &pConn->mgmtEps, &rpcMsg, &rpcRsp); + + CTG_ERR_RET(ctgProcessRspMsg(out, reqType, rpcRsp.pCont, rpcRsp.contLen, rpcRsp.code, (char*)tbFName)); + + return TSDB_CODE_SUCCESS; +} + diff --git a/source/libs/catalog/src/ctgUtil.c b/source/libs/catalog/src/ctgUtil.c index 476eb371b0..8635457dfe 100644 --- a/source/libs/catalog/src/ctgUtil.c +++ b/source/libs/catalog/src/ctgUtil.c @@ -33,6 +33,10 @@ char *ctgTaskTypeStr(CTG_TASK_TYPE type) { return "[get table meta]"; case CTG_TASK_GET_TB_HASH: return "[get table hash]"; + case CTG_TASK_GET_TB_INDEX: + return "[get table index]"; + case CTG_TASK_GET_TB_CFG: + return "[get table cfg]"; case CTG_TASK_GET_INDEX: return "[get index]"; case CTG_TASK_GET_UDF: @@ -96,6 +100,9 @@ void ctgFreeSMetaData(SMetaData* pData) { taosArrayDestroy(pData->pQnodeList); pData->pQnodeList = NULL; + + taosArrayDestroy(pData->pTableCfg); + pData->pTableCfg = NULL; } void ctgFreeSCtgUserAuth(SCtgUserAuth *userCache) { @@ -280,6 +287,13 @@ void ctgFreeMsgCtx(SCtgMsgCtx* pCtx) { } break; } + case TDMT_VND_TABLE_CFG: + case TDMT_MND_TABLE_CFG: { + STableCfgRsp* pOut = (STableCfgRsp*)pCtx->out; + tFreeSTableCfgRsp(pOut); + taosMemoryFreeClear(pCtx->out); + break; + } case TDMT_MND_RETRIEVE_FUNC: { SFuncInfo* pOut = (SFuncInfo*)pCtx->out; taosMemoryFree(pOut->pCode); @@ -328,14 +342,151 @@ void ctgResetTbMetaTask(SCtgTask* pTask) { taosMemoryFreeClear(pTask->res); } -void ctgFreeTask(SCtgTask* pTask) { - ctgFreeMsgCtx(&pTask->msgCtx); - +void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) { + switch (type) { + case CTG_TASK_GET_QNODE: { + taosArrayDestroy((SArray*)*pRes); + *pRes = NULL; + break; + } + case CTG_TASK_GET_TB_META: { + taosMemoryFreeClear(*pRes); + break; + } + case CTG_TASK_GET_DB_VGROUP: { + taosArrayDestroy((SArray*)*pRes); + *pRes = NULL; + break; + } + case CTG_TASK_GET_DB_CFG: { + if (*pRes) { + SDbCfgInfo* pInfo = (SDbCfgInfo*)*pRes; + taosArrayDestroy(pInfo->pRetensions); + taosMemoryFreeClear(*pRes); + } + break; + } + case CTG_TASK_GET_DB_INFO: { + taosMemoryFreeClear(*pRes); + break; + } + case CTG_TASK_GET_TB_HASH: { + taosMemoryFreeClear(*pRes); + break; + } + case CTG_TASK_GET_TB_INDEX: { + taosArrayDestroyEx(*pRes, tFreeSTableIndexInfo); + *pRes = NULL; + break; + } + case CTG_TASK_GET_TB_CFG: { + if (*pRes) { + STableCfg* pInfo = (STableCfg*)*pRes; + tFreeSTableCfgRsp(pInfo); + taosMemoryFreeClear(*pRes); + } + break; + } + case CTG_TASK_GET_INDEX: { + taosMemoryFreeClear(*pRes); + break; + } + case CTG_TASK_GET_UDF: { + taosMemoryFreeClear(*pRes); + break; + } + case CTG_TASK_GET_USER: { + taosMemoryFreeClear(*pRes); + break; + } + default: + qError("invalid task type %d", type); + break; + } +} + + +void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void **pRes) { + switch (type) { + case CTG_TASK_GET_QNODE: { + taosArrayDestroy((SArray*)*pRes); + *pRes = NULL; + break; + } + case CTG_TASK_GET_TB_META: { + taosMemoryFreeClear(*pRes); + break; + } + case CTG_TASK_GET_DB_VGROUP: { + if (*pRes) { + SDBVgInfo* pInfo = (SDBVgInfo*)*pRes; + taosHashCleanup(pInfo->vgHash); + taosMemoryFreeClear(*pRes); + } + break; + } + case CTG_TASK_GET_DB_CFG: { + if (*pRes) { + SDbCfgInfo* pInfo = (SDbCfgInfo*)*pRes; + taosArrayDestroy(pInfo->pRetensions); + taosMemoryFreeClear(*pRes); + } + break; + } + case CTG_TASK_GET_DB_INFO: { + taosMemoryFreeClear(*pRes); + break; + } + case CTG_TASK_GET_TB_HASH: { + taosMemoryFreeClear(*pRes); + break; + } + case CTG_TASK_GET_TB_INDEX: { + taosArrayDestroyEx(*pRes, tFreeSTableIndexInfo); + *pRes = NULL; + break; + } + case CTG_TASK_GET_TB_CFG: { + if (*pRes) { + STableCfg* pInfo = (STableCfg*)*pRes; + tFreeSTableCfgRsp(pInfo); + taosMemoryFreeClear(*pRes); + } + break; + } + case CTG_TASK_GET_INDEX: { + taosMemoryFreeClear(*pRes); + break; + } + case CTG_TASK_GET_UDF: { + taosMemoryFreeClear(*pRes); + break; + } + case CTG_TASK_GET_USER: { + taosMemoryFreeClear(*pRes); + break; + } + default: + qError("invalid task type %d", type); + break; + } +} + + +void ctgClearSubTaskRes(SCtgSubRes *pRes) { + pRes->code = 0; + + if (NULL == pRes->res) { + return; + } + + ctgFreeSubTaskRes(pRes->type, &pRes->res); +} + +void ctgFreeTaskCtx(SCtgTask* pTask) { switch (pTask->type) { case CTG_TASK_GET_QNODE: { - taosArrayDestroy((SArray*)pTask->res); taosMemoryFreeClear(pTask->taskCtx); - pTask->res = NULL; break; } case CTG_TASK_GET_TB_META: { @@ -346,56 +497,49 @@ void ctgFreeTask(SCtgTask* pTask) { pTask->msgCtx.lastOut = NULL; } taosMemoryFreeClear(pTask->taskCtx); - taosMemoryFreeClear(pTask->res); break; } case CTG_TASK_GET_DB_VGROUP: { - taosArrayDestroy((SArray*)pTask->res); taosMemoryFreeClear(pTask->taskCtx); - pTask->res = NULL; break; } case CTG_TASK_GET_DB_CFG: { taosMemoryFreeClear(pTask->taskCtx); - if (pTask->res) { - SDbCfgInfo* pInfo = (SDbCfgInfo*)pTask->res; - taosArrayDestroy(pInfo->pRetensions); - taosMemoryFreeClear(pTask->res); - } break; } case CTG_TASK_GET_DB_INFO: { taosMemoryFreeClear(pTask->taskCtx); - taosMemoryFreeClear(pTask->res); break; } case CTG_TASK_GET_TB_HASH: { SCtgTbHashCtx* taskCtx = (SCtgTbHashCtx*)pTask->taskCtx; taosMemoryFreeClear(taskCtx->pName); taosMemoryFreeClear(pTask->taskCtx); - taosMemoryFreeClear(pTask->res); break; } case CTG_TASK_GET_TB_INDEX: { SCtgTbIndexCtx* taskCtx = (SCtgTbIndexCtx*)pTask->taskCtx; taosMemoryFreeClear(taskCtx->pName); taosMemoryFreeClear(pTask->taskCtx); - taosArrayDestroyEx(pTask->res, tFreeSTableIndexInfo); + break; + } + case CTG_TASK_GET_TB_CFG: { + SCtgTbCfgCtx* taskCtx = (SCtgTbCfgCtx*)pTask->taskCtx; + taosMemoryFreeClear(taskCtx->pName); + taosMemoryFreeClear(taskCtx->pVgInfo); + taosMemoryFreeClear(pTask->taskCtx); break; } case CTG_TASK_GET_INDEX: { taosMemoryFreeClear(pTask->taskCtx); - taosMemoryFreeClear(pTask->res); break; } case CTG_TASK_GET_UDF: { taosMemoryFreeClear(pTask->taskCtx); - taosMemoryFreeClear(pTask->res); break; } case CTG_TASK_GET_USER: { taosMemoryFreeClear(pTask->taskCtx); - taosMemoryFreeClear(pTask->res); break; } default: @@ -404,6 +548,16 @@ void ctgFreeTask(SCtgTask* pTask) { } } + +void ctgFreeTask(SCtgTask* pTask) { + ctgFreeMsgCtx(&pTask->msgCtx); + ctgFreeTaskRes(pTask->type, &pTask->res); + ctgFreeTaskCtx(pTask); + + taosArrayDestroy(pTask->pParents); + ctgClearSubTaskRes(&pTask->subRes); +} + void ctgFreeTasks(SArray* pArray) { if (NULL == pArray) { return; diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index 6a3852abbc..778742b0fa 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -16,6 +16,7 @@ #include "command.h" #include "catalog.h" #include "tdatablock.h" +#include "tglobal.h" static int32_t getSchemaBytes(const SSchema* pSchema) { switch (pSchema->type) { @@ -123,11 +124,430 @@ static int32_t execDescribe(SNode* pStmt, SRetrieveTableRsp** pRsp) { static int32_t execResetQueryCache() { return catalogClearCache(); } -static int32_t execShowCreateDatabase(SShowCreateDatabaseStmt* pStmt) { return TSDB_CODE_FAILED; } -static int32_t execShowCreateTable(SShowCreateTableStmt* pStmt) { return TSDB_CODE_FAILED; } +static SSDataBlock* buildCreateDBResultDataBlock() { + SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); + pBlock->info.numOfCols = SHOW_CREATE_DB_RESULT_COLS; + pBlock->info.hasVarCol = true; -static int32_t execShowCreateSTable(SShowCreateTableStmt* pStmt) { return TSDB_CODE_FAILED; } + pBlock->pDataBlock = taosArrayInit(pBlock->info.numOfCols, sizeof(SColumnInfoData)); + + SColumnInfoData infoData = {0}; + infoData.info.type = TSDB_DATA_TYPE_VARCHAR; + infoData.info.bytes = SHOW_CREATE_DB_RESULT_FIELD1_LEN; + + taosArrayPush(pBlock->pDataBlock, &infoData); + + infoData.info.type = TSDB_DATA_TYPE_VARCHAR; + infoData.info.bytes = SHOW_CREATE_DB_RESULT_FIELD2_LEN; + taosArrayPush(pBlock->pDataBlock, &infoData); + + return pBlock; +} + +int64_t getValOfDiffPrecision(int8_t unit, int64_t val) { + int64_t v = 0; + switch (unit) { + case 's': + v = val / 1000; + break; + case 'm': + v = val / tsTickPerMin[TSDB_TIME_PRECISION_MILLI]; + break; + case 'h': + v = val / (tsTickPerMin[TSDB_TIME_PRECISION_MILLI] * 60); + break; + case 'd': + v = val / (tsTickPerMin[TSDB_TIME_PRECISION_MILLI] * 24 * 60); + break; + case 'w': + v = val / (tsTickPerMin[TSDB_TIME_PRECISION_MILLI] * 24 * 60 * 7); + break; + default: + break; + } + + return v; +} + +char *buildRetension(SArray *pRetension) { + size_t size = taosArrayGetSize(pRetension); + if (size == 0) { + return NULL; + } + + char *p1 = taosMemoryCalloc(1, 100); + SRetention *p = taosArrayGet(pRetension, 0); + + int32_t len = 0; + + int64_t v1 = getValOfDiffPrecision(p->freqUnit, p->freq); + int64_t v2 = getValOfDiffPrecision(p->keepUnit, p->keep); + len += sprintf(p1 + len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit); + + if (size > 1) { + len += sprintf(p1 + len, ","); + p = taosArrayGet(pRetension, 1); + + v1 = getValOfDiffPrecision(p->freqUnit, p->freq); + v2 = getValOfDiffPrecision(p->keepUnit, p->keep); + len += sprintf(p1 + len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit); + } + + if (size > 2) { + len += sprintf(p1 + len, ","); + p = taosArrayGet(pRetension, 2); + + v1 = getValOfDiffPrecision(p->freqUnit, p->freq); + v2 = getValOfDiffPrecision(p->keepUnit, p->keep); + len += sprintf(p1 + len, "%" PRId64 "%c:%" PRId64 "%c", v1, p->freqUnit, v2, p->keepUnit); + } + + return p1; +} + + +static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char *dbFName, SDbCfgInfo* pCfg) { + blockDataEnsureCapacity(pBlock, 1); + pBlock->info.rows = 1; + + SColumnInfoData* pCol1 = taosArrayGet(pBlock->pDataBlock, 0); + char buf1[SHOW_CREATE_DB_RESULT_FIELD1_LEN] = {0}; + STR_TO_VARSTR(buf1, dbFName); + colDataAppend(pCol1, 0, buf1, false); + + SColumnInfoData* pCol2 = taosArrayGet(pBlock->pDataBlock, 1); + char buf2[SHOW_CREATE_DB_RESULT_FIELD2_LEN] = {0}; + int32_t len = 0; + char *prec = NULL; + switch (pCfg->precision) { + case TSDB_TIME_PRECISION_MILLI: + prec = TSDB_TIME_PRECISION_MILLI_STR; + break; + case TSDB_TIME_PRECISION_MICRO: + prec = TSDB_TIME_PRECISION_MICRO_STR; + break; + case TSDB_TIME_PRECISION_NANO: + prec = TSDB_TIME_PRECISION_NANO_STR; + break; + default: + prec = "none"; + break; + } + + char *retentions = buildRetension(pCfg->pRetensions); + + len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE DATABASE `%s` BUFFER %d CACHELAST %d COMP %d DURATION %dm " + "FSYNC %d MAXROWS %d MINROWS %d KEEP %dm,%dm,%dm PAGES %d PAGESIZE %d PRECISION '%s' REPLICA %d " + "STRICT %d WAL %d VGROUPS %d SINGLE_STABLE %d", + dbFName, pCfg->buffer, pCfg->cacheLastRow, pCfg->compression, pCfg->daysPerFile, + pCfg->fsyncPeriod, pCfg->maxRows, pCfg->minRows, pCfg->daysToKeep0, pCfg->daysToKeep1, pCfg->daysToKeep2, + pCfg->pages, pCfg->pageSize, prec, pCfg->replications, pCfg->strict, pCfg->walLevel, pCfg->numOfVgroups, + 1 == pCfg->numOfStables); + + if (retentions) { + len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, " RETENTIONS %s", retentions); + taosMemoryFree(retentions); + } + + (varDataLen(buf2)) = len; + + colDataAppend(pCol2, 0, buf2, false); +} + + +static int32_t execShowCreateDatabase(SShowCreateDatabaseStmt* pStmt, SRetrieveTableRsp** pRsp) { + SSDataBlock* pBlock = buildCreateDBResultDataBlock(); + setCreateDBResultIntoDataBlock(pBlock, pStmt->dbName, pStmt->pCfg); + + size_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); + *pRsp = taosMemoryCalloc(1, rspSize); + if (NULL == *pRsp) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + (*pRsp)->useconds = 0; + (*pRsp)->completed = 1; + (*pRsp)->precision = 0; + (*pRsp)->compressed = 0; + (*pRsp)->compLen = 0; + (*pRsp)->numOfRows = htonl(1); + (*pRsp)->numOfCols = htonl(SHOW_CREATE_DB_RESULT_COLS); + + int32_t len = 0; + blockCompressEncode(pBlock, (*pRsp)->data, &len, SHOW_CREATE_DB_RESULT_COLS, false); + ASSERT(len == rspSize - sizeof(SRetrieveTableRsp)); + + blockDataDestroy(pBlock); + return TSDB_CODE_SUCCESS; +} + +static SSDataBlock* buildCreateTbResultDataBlock() { + SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock)); + pBlock->info.numOfCols = SHOW_CREATE_TB_RESULT_COLS; + pBlock->info.hasVarCol = true; + + pBlock->pDataBlock = taosArrayInit(pBlock->info.numOfCols, sizeof(SColumnInfoData)); + + SColumnInfoData infoData = {0}; + infoData.info.type = TSDB_DATA_TYPE_VARCHAR; + infoData.info.bytes = SHOW_CREATE_TB_RESULT_FIELD1_LEN; + + taosArrayPush(pBlock->pDataBlock, &infoData); + + infoData.info.type = TSDB_DATA_TYPE_VARCHAR; + infoData.info.bytes = SHOW_CREATE_TB_RESULT_FIELD2_LEN; + taosArrayPush(pBlock->pDataBlock, &infoData); + + return pBlock; +} + +void appendColumnFields(char* buf, int32_t* len, STableCfg* pCfg) { + for (int32_t i = 0; i < pCfg->numOfColumns; ++i) { + SSchema* pSchema = pCfg->pSchemas + i; + char type[32]; + sprintf(type, "%s", tDataTypes[pSchema->type].name); + if (TSDB_DATA_TYPE_VARCHAR == pSchema->type) { + sprintf(type + strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE)); + } else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) { + sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE)/TSDB_NCHAR_SIZE)); + } + + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s", ((i > 0) ? ", " : ""), pSchema->name, type); + } +} + +void appendTagFields(char* buf, int32_t* len, STableCfg* pCfg) { + for (int32_t i = 0; i < pCfg->numOfTags; ++i) { + SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i; + char type[32]; + sprintf(type, "%s", tDataTypes[pSchema->type].name); + if (TSDB_DATA_TYPE_VARCHAR == pSchema->type) { + sprintf(type + strlen(type), "(%d)", (int32_t)(pSchema->bytes - VARSTR_HEADER_SIZE)); + } else if (TSDB_DATA_TYPE_NCHAR == pSchema->type) { + sprintf(type + strlen(type), "(%d)", (int32_t)((pSchema->bytes - VARSTR_HEADER_SIZE)/TSDB_NCHAR_SIZE)); + } + + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s` %s", ((i > 0) ? ", " : ""), pSchema->name, type); + } +} + + +void appendTagNameFields(char* buf, int32_t* len, STableCfg* pCfg) { + for (int32_t i = 0; i < pCfg->numOfTags; ++i) { + SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i; + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s`%s`", ((i > 0) ? ", " : ""), pSchema->name); + } +} + + +int32_t appendTagValues(char* buf, int32_t* len, STableCfg* pCfg) { + SArray *pTagVals = NULL; + STag *pTag = (STag*)pCfg->pTags; + + if (pCfg->pTags && pTag->flags & TD_TAG_JSON) { + char *pJson = parseTagDatatoJson(pTag); + if (pJson) { + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s", pJson); + taosMemoryFree(pJson); + } + + return TSDB_CODE_SUCCESS; + } + + int32_t code = tTagToValArray((const STag *)pCfg->pTags, &pTagVals); + if (code) { + return code; + } + + int16_t valueNum = taosArrayGetSize(pTagVals); + int32_t num = 0; + int32_t j = 0; + for (int32_t i = 0; i < pCfg->numOfTags; ++i) { + SSchema* pSchema = pCfg->pSchemas + pCfg->numOfColumns + i; + if (i > 0) { + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", "); + } + + if (j >= valueNum) { + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "NULL"); + continue; + } + + STagVal *pTagVal = (STagVal *)taosArrayGet(pTagVals, j); + if (pSchema->colId > pTagVal->cid) { + qError("tag value and column mismatch, schemaId:%d, valId:%d", pSchema->colId, pTagVal->cid); + taosArrayDestroy(pTagVals); + return TSDB_CODE_APP_ERROR; + } else if (pSchema->colId == pTagVal->cid) { + char type = pTagVal->type; + int32_t tlen = 0; + + if (IS_VAR_DATA_TYPE(type)) { + dataConverToStr(buf + VARSTR_HEADER_SIZE + *len, type, pTagVal->pData, pTagVal->nData, &tlen); + } else { + dataConverToStr(buf + VARSTR_HEADER_SIZE + *len, type, &pTagVal->i64, tDataTypes[type].bytes, &tlen); + } + *len += tlen; + j++; + } else { + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "NULL"); + } + + + /* + if (type == TSDB_DATA_TYPE_BINARY) { + if (pTagVal->nData > 0) { + if (num) { + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", "); + } + + memcpy(buf + VARSTR_HEADER_SIZE + *len, pTagVal->pData, pTagVal->nData); + *len += pTagVal->nData; + } + } else if (type == TSDB_DATA_TYPE_NCHAR) { + if (pTagVal->nData > 0) { + if (num) { + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", "); + } + int32_t tlen = taosUcs4ToMbs((TdUcs4 *)pTagVal->pData, pTagVal->nData, buf + VARSTR_HEADER_SIZE + *len); + } + } else if (type == TSDB_DATA_TYPE_DOUBLE) { + double val = *(double *)(&pTagVal->i64); + int len = 0; + term = indexTermCreate(suid, ADD_VALUE, type, key, nKey, (const char *)&val, len); + } else if (type == TSDB_DATA_TYPE_BOOL) { + int val = *(int *)(&pTagVal->i64); + int len = 0; + term = indexTermCreate(suid, ADD_VALUE, TSDB_DATA_TYPE_INT, key, nKey, (const char *)&val, len); + } + */ + } + + taosArrayDestroy(pTagVals); + + return TSDB_CODE_SUCCESS; +} + +void appendTableOptions(char* buf, int32_t* len, STableCfg* pCfg) { + if (pCfg->commentLen > 0) { + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " COMMENT '%s'", pCfg->pComment); + } else if (0 == pCfg->commentLen) { + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " COMMENT ''"); + } + + if (pCfg->watermark1 > 0) { + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " WATERMARK %" PRId64 "a", pCfg->watermark1); + if (pCfg->watermark2 > 0) { + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", %" PRId64 "a", pCfg->watermark2); + } + } + + if (pCfg->delay1 > 0) { + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " MAX_DELAY %" PRId64 "a", pCfg->delay1); + if (pCfg->delay2 > 0) { + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ", %" PRId64 "a", pCfg->delay2); + } + } + + int32_t funcNum = taosArrayGetSize(pCfg->pFuncs); + if (funcNum > 0) { + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " ROLLUP("); + for (int32_t i = 0; i < funcNum; ++i) { + char* pFunc = taosArrayGet(pCfg->pFuncs, i); + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, "%s%s", ((i > 0) ? ", " : ""), pFunc); + } + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, ")"); + } + + if (pCfg->ttl > 0) { + *len += sprintf(buf + VARSTR_HEADER_SIZE + *len, " TTL %d", pCfg->ttl); + } +} + +static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, char *tbName, STableCfg* pCfg) { + int32_t code = 0; + blockDataEnsureCapacity(pBlock, 1); + pBlock->info.rows = 1; + + SColumnInfoData* pCol1 = taosArrayGet(pBlock->pDataBlock, 0); + char buf1[SHOW_CREATE_TB_RESULT_FIELD1_LEN] = {0}; + STR_TO_VARSTR(buf1, tbName); + colDataAppend(pCol1, 0, buf1, false); + + SColumnInfoData* pCol2 = taosArrayGet(pBlock->pDataBlock, 1); + char buf2[SHOW_CREATE_TB_RESULT_FIELD2_LEN] = {0}; + int32_t len = 0; + + if (TSDB_SUPER_TABLE == pCfg->tableType) { + len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE STABLE `%s` (", tbName); + appendColumnFields(buf2, &len, pCfg); + len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ") TAGS ("); + appendTagFields(buf2, &len, pCfg); + len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ")"); + appendTableOptions(buf2, &len, pCfg); + } else if (TSDB_CHILD_TABLE == pCfg->tableType) { + len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE TABLE `%s` USING `%s` (", tbName, pCfg->stbName); + appendTagNameFields(buf2, &len, pCfg); + len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ") TAGS ("); + code = appendTagValues(buf2, &len, pCfg); + if (code) { + return code; + } + len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ")"); + appendTableOptions(buf2, &len, pCfg); + } else { + len += sprintf(buf2 + VARSTR_HEADER_SIZE, "CREATE TABLE `%s` (", tbName); + appendColumnFields(buf2, &len, pCfg); + len += sprintf(buf2 + VARSTR_HEADER_SIZE + len, ")"); + } + + varDataLen(buf2) = len; + + colDataAppend(pCol2, 0, buf2, false); + + return TSDB_CODE_SUCCESS; +} + + +static int32_t execShowCreateTable(SShowCreateTableStmt* pStmt, SRetrieveTableRsp** pRsp) { + SSDataBlock* pBlock = buildCreateTbResultDataBlock(); + int32_t code = setCreateTBResultIntoDataBlock(pBlock, pStmt->tableName, pStmt->pCfg); + if (code) { + return code; + } + + size_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); + *pRsp = taosMemoryCalloc(1, rspSize); + if (NULL == *pRsp) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + (*pRsp)->useconds = 0; + (*pRsp)->completed = 1; + (*pRsp)->precision = 0; + (*pRsp)->compressed = 0; + (*pRsp)->compLen = 0; + (*pRsp)->numOfRows = htonl(1); + (*pRsp)->numOfCols = htonl(SHOW_CREATE_TB_RESULT_COLS); + + int32_t len = 0; + blockCompressEncode(pBlock, (*pRsp)->data, &len, SHOW_CREATE_TB_RESULT_COLS, false); + ASSERT(len == rspSize - sizeof(SRetrieveTableRsp)); + + blockDataDestroy(pBlock); + return TSDB_CODE_SUCCESS; +} + +static int32_t execShowCreateSTable(SShowCreateTableStmt* pStmt, SRetrieveTableRsp** pRsp) { + STableCfg* pCfg = (STableCfg*)pStmt->pCfg; + if (TSDB_SUPER_TABLE != pCfg->tableType) { + terrno = TSDB_CODE_TSC_NOT_STABLE_ERROR; + return terrno; + } + + return execShowCreateTable(pStmt, pRsp); +} static int32_t execAlterLocal(SAlterLocalStmt* pStmt) { return TSDB_CODE_FAILED; } @@ -140,11 +560,11 @@ int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp) { case QUERY_NODE_RESET_QUERY_CACHE_STMT: return execResetQueryCache(); case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: - return execShowCreateDatabase((SShowCreateDatabaseStmt*)pStmt); + return execShowCreateDatabase((SShowCreateDatabaseStmt*)pStmt, pRsp); case QUERY_NODE_SHOW_CREATE_TABLE_STMT: - return execShowCreateTable((SShowCreateTableStmt*)pStmt); + return execShowCreateTable((SShowCreateTableStmt*)pStmt, pRsp); case QUERY_NODE_SHOW_CREATE_STABLE_STMT: - return execShowCreateSTable((SShowCreateTableStmt*)pStmt); + return execShowCreateSTable((SShowCreateTableStmt*)pStmt, pRsp); case QUERY_NODE_ALTER_LOCAL_STMT: return execAlterLocal((SAlterLocalStmt*)pStmt); case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT: diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index ae0f669d65..2d55b06f06 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -184,8 +184,8 @@ int32_t qExplainGenerateResChildren(SPhysiNode *pNode, SExplainGroup *group, SNo pPhysiChildren = indefPhysiNode->node.pChildren; break; } - case QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL: { - SMergeIntervalPhysiNode *intPhysiNode = (SMergeIntervalPhysiNode *)pNode; + case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: { + SMergeAlignedIntervalPhysiNode *intPhysiNode = (SMergeAlignedIntervalPhysiNode *)pNode; pPhysiChildren = intPhysiNode->window.node.pChildren; break; } @@ -841,8 +841,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i } break; } - case QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL: { - SMergeIntervalPhysiNode *pIntNode = (SMergeIntervalPhysiNode *)pNode; + case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: { + SMergeAlignedIntervalPhysiNode *pIntNode = (SMergeAlignedIntervalPhysiNode *)pNode; EXPLAIN_ROW_NEW(level, EXPLAIN_INTERVAL_FORMAT, nodesGetNameFromColumnNode(pIntNode->window.pTspk)); EXPLAIN_ROW_APPEND(EXPLAIN_LEFT_PARENTHESIS_FORMAT); if (pResNode->pExecInfo) { diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 2a0f34cd03..654cf681e6 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -234,6 +234,7 @@ typedef struct SColMatchInfo { int32_t colId; int32_t targetSlotId; bool output; + bool reserved; int32_t matchType; // determinate the source according to col id or slot id } SColMatchInfo; @@ -253,7 +254,6 @@ typedef struct STableScanInfo { SFileBlockLoadRecorder readRecorder; int64_t numOfRows; -// int32_t prevGroupId; // previous table group id SScanInfo scanInfo; int32_t scanTimes; SNode* pFilterNode; // filter info, which is push down by optimizer @@ -733,6 +733,10 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SExprI SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, + SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId, + SExecTaskInfo* pTaskInfo); + SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, int32_t numOfChild); SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, @@ -834,14 +838,19 @@ int32_t finalizeResultRowIntoResultDataBlock(SDiskbasedBuf* pBuf, SResultRowPosi SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, int32_t numOfExprs, const int32_t* rowCellOffset, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo); -int32_t createMultipleDataReaders(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, +int32_t createScanTableListInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, + STableListInfo* pTableListInfo, uint64_t queryId, uint64_t taskId, + SNode* pTagCond); +int32_t doCreateMultipleDataReaders(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, STableListInfo* pTableListInfo, SArray* arrayReader, uint64_t queryId, - uint64_t taskId, SNode* pTagCond); + uint64_t taskId); SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SArray* dataReaders, SReadHandle* readHandle, SExecTaskInfo* pTaskInfo); void copyUpdateDataBlock(SSDataBlock* pDest, SSDataBlock* pSource, int32_t tsColIndex); +int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SArray* groupKey); + #ifdef __cplusplus } #endif diff --git a/source/libs/executor/inc/tsort.h b/source/libs/executor/inc/tsort.h index 363f379ee4..35bdd4ee55 100644 --- a/source/libs/executor/inc/tsort.h +++ b/source/libs/executor/inc/tsort.h @@ -50,6 +50,7 @@ typedef struct SMsortComparParam { void **pSources; int32_t numOfSources; SArray *orderInfo; // SArray + bool cmpGroupId; } SMsortComparParam; typedef struct SSortHandle SSortHandle; @@ -99,6 +100,11 @@ int32_t tsortSetFetchRawDataFp(SSortHandle* pHandle, _sort_fetch_block_fn_t fetc */ int32_t tsortSetComparFp(SSortHandle* pHandle, _sort_merge_compar_fn_t fp); +/** + * + */ +int32_t tsortSetCompareGroupId(SSortHandle* pHandle, bool compareGroupId); + /** * * @param pHandle diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 27096fe7f9..891ffec09b 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -239,7 +239,7 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo } for (int i = 0; i < taosArrayGetSize(res); i++) { - STableKeyInfo info = {.lastKey = TSKEY_INITIAL_VAL, .uid = *(uint64_t*)taosArrayGet(res, i)}; + STableKeyInfo info = {.lastKey = TSKEY_INITIAL_VAL, .uid = *(uint64_t*)taosArrayGet(res, i), .groupId = 0}; taosArrayPush(pListInfo->pTableList, &info); } taosArrayDestroy(res); @@ -247,7 +247,7 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo code = tsdbGetAllTableList(metaHandle, tableUid, pListInfo->pTableList); } } else { // Create one table group. - STableKeyInfo info = {.lastKey = 0, .uid = tableUid}; + STableKeyInfo info = {.lastKey = 0, .uid = tableUid, .groupId = 0}; taosArrayPush(pListInfo->pTableList, &info); } @@ -300,7 +300,7 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod SColMatchInfo c = {0}; c.output = true; - c.colId = pColNode->colId; + c.colId = pColNode->colId; c.srcSlotId = pColNode->slotId; c.matchType = type; c.targetSlotId = pNode->slotId; diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 94675ce253..828da0bcf8 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -609,7 +609,7 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc } int32_t startOffset = createNewColModel ? 0 : pResult->info.rows; - colInfoDataEnsureCapacity(pResColData, startOffset, pResult->info.capacity); + ASSERT(pResult->info.capacity > 0); colDataMergeCol(pResColData, startOffset, &pResult->info.capacity, &idata, dest.numOfRows); numOfRows = dest.numOfRows; @@ -649,7 +649,7 @@ int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBloc } int32_t startOffset = createNewColModel ? 0 : pResult->info.rows; - colInfoDataEnsureCapacity(pResColData, startOffset, pResult->info.capacity); + ASSERT(pResult->info.capacity > 0); colDataMergeCol(pResColData, startOffset, &pResult->info.capacity, &idata, dest.numOfRows); numOfRows = dest.numOfRows; @@ -1340,9 +1340,9 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const int8_t* rowR } if (rowRes != NULL) { + int32_t totalRows = pBlock->info.rows; SSDataBlock* px = createOneDataBlock(pBlock, true); - int32_t totalRows = pBlock->info.rows; for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) { SColumnInfoData* pSrc = taosArrayGet(px->pDataBlock, i); SColumnInfoData* pDst = taosArrayGet(pBlock->pDataBlock, i); @@ -2765,7 +2765,7 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t goto _error; } - size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; + size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; code = doInitAggInfoSup(&pInfo->aggSup, pOperator->exprSupp.pCtx, num, keyBufSize, pTaskInfo->id.str); if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -2787,9 +2787,9 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t pOperator->name = "SortedMerge"; // pOperator->operatorType = OP_SortedMerge; - pOperator->blocking = true; - pOperator->status = OP_NOT_OPENED; - pOperator->info = pInfo; + pOperator->blocking = true; + pOperator->status = OP_NOT_OPENED; + pOperator->info = pInfo; pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doSortedMerge, NULL, NULL, destroySortedMergeOperatorInfo, @@ -2844,8 +2844,8 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SAggOperatorInfo* pAggInfo = pOperator->info; - SExprSupp* pSup = &pOperator->exprSupp; - SOperatorInfo* downstream = pOperator->pDownstream[0]; + SExprSupp* pSup = &pOperator->exprSupp; + SOperatorInfo* downstream = pOperator->pDownstream[0]; int64_t st = taosGetTimestampUs(); @@ -3736,9 +3736,9 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy SExprInfo* pExprInfo = createExprInfo(pPhyNode->pFuncs, NULL, &numOfExpr); if (pPhyNode->pExprs != NULL) { - int32_t num = 0; + int32_t num = 0; SExprInfo* pSExpr = createExprInfo(pPhyNode->pExprs, NULL, &num); - int32_t code = initExprSupp(&pInfo->scalarSup, pSExpr, num); + int32_t code = initExprSupp(&pInfo->scalarSup, pSExpr, num); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -3761,14 +3761,14 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy setFunctionResultOutput(pOperator, &pInfo->binfo, &pInfo->aggSup, MAIN_SCAN, numOfExpr); - pInfo->binfo.pRes = pResBlock; - pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pSup->pCtx, numOfExpr); + pInfo->binfo.pRes = pResBlock; + pInfo->pPseudoColInfo = setRowTsColumnOutputInfo(pSup->pCtx, numOfExpr); pOperator->name = "IndefinitOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_PROJECT; - pOperator->blocking = false; - pOperator->status = OP_NOT_OPENED; - pOperator->info = pInfo; + pOperator->blocking = false; + pOperator->status = OP_NOT_OPENED; + pOperator->info = pInfo; pOperator->exprSupp.numOfExprs = numOfExpr; pOperator->pTaskInfo = pTaskInfo; @@ -3838,10 +3838,10 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pOperator->blocking = false; pOperator->status = OP_NOT_OPENED; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_FILL; - pOperator->exprSupp.pExprInfo = pExprInfo; - pOperator->exprSupp.numOfExprs = num; - pOperator->info = pInfo; - pOperator->pTaskInfo = pTaskInfo; + pOperator->exprSupp.pExprInfo = pExprInfo; + pOperator->exprSupp.numOfExprs = num; + pOperator->info = pInfo; + pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doFill, NULL, NULL, destroySFillOperatorInfo, NULL, NULL, NULL); @@ -3968,14 +3968,16 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, } } } - int32_t len = (int32_t)(pStart - (char*)keyBuf); - uint64_t* groupId = taosHashGet(pTableListInfo->map, keyBuf, len); - if (groupId) { - taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), groupId, sizeof(uint64_t)); - } else { + + uint64_t* pGroupId = taosHashGet(pTableListInfo->map, keyBuf, len); + + if (!pGroupId) { uint64_t tmpId = calcGroupId(keyBuf, len); + info->groupId = tmpId; taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &tmpId, sizeof(uint64_t)); + } else { + info->groupId = *pGroupId; } metaReaderClear(&mr); @@ -4023,11 +4025,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode; SArray* dataReaders = taosArrayInit(8, POINTER_BYTES); - createMultipleDataReaders(pTableScanNode, pHandle, pTableListInfo, dataReaders, queryId, taskId, pTagCond); + createScanTableListInfo(pTableScanNode, pHandle, pTableListInfo, queryId, taskId, pTagCond); + doCreateMultipleDataReaders(pTableScanNode, pHandle, pTableListInfo, dataReaders, queryId, taskId); + extractTableSchemaVersion(pHandle, pTableScanNode->scan.uid, pTaskInfo); - SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionTags); - generateGroupIdMap(pTableListInfo, pHandle, groupKeys); // todo for json - taosArrayDestroy(groupKeys); + SOperatorInfo* pOperator = createTableMergeScanOperatorInfo(pTableScanNode, dataReaders, pHandle, pTaskInfo); STableScanInfo* pScanInfo = pOperator->info; pTaskInfo->cost.pRecoder = &pScanInfo->readRecorder; @@ -4087,7 +4089,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return createTagScanOperatorInfo(pHandle, pScanPhyNode, pTableListInfo, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN == type) { - SBlockDistScanPhysiNode* pBlockNode = (SBlockDistScanPhysiNode*) pPhyNode; + SBlockDistScanPhysiNode* pBlockNode = (SBlockDistScanPhysiNode*)pPhyNode; pTableListInfo->pTableList = taosArrayInit(4, sizeof(STableKeyInfo)); if (pBlockNode->tableType == TSDB_SUPER_TABLE) { @@ -4097,7 +4099,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return NULL; } } else { // Create one table group. - STableKeyInfo info = {.lastKey = 0, .uid = pBlockNode->uid}; + STableKeyInfo info = {.lastKey = 0, .uid = pBlockNode->uid, .groupId = 0}; taosArrayPush(pTableListInfo->pTableList, &info); } @@ -4190,6 +4192,21 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pOptr = createIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, tsSlotId, &as, pTaskInfo, isStream); + } else if (QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL == type) { + SMergeAlignedIntervalPhysiNode* pIntervalPhyNode = (SMergeAlignedIntervalPhysiNode*)pPhyNode; + + SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &num); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); + + SInterval interval = {.interval = pIntervalPhyNode->interval, + .sliding = pIntervalPhyNode->sliding, + .intervalUnit = pIntervalPhyNode->intervalUnit, + .slidingUnit = pIntervalPhyNode->slidingUnit, + .offset = pIntervalPhyNode->offset, + .precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision}; + + int32_t tsSlotId = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId; + pOptr = createMergeAlignedIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, tsSlotId, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL == type) { SMergeIntervalPhysiNode* pIntervalPhyNode = (SMergeIntervalPhysiNode*)pPhyNode; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 788464ac66..62167ec9ff 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -112,12 +112,12 @@ static void getNextTimeWindow(SInterval* pInterval, STimeWindow* tw, int32_t ord int mon = (int)(tm.tm_year * 12 + tm.tm_mon + interval * factor); tm.tm_year = mon / 12; tm.tm_mon = mon % 12; - tw->skey = convertTimePrecision((int64_t)taosMktime(&tm) * 1000L, TSDB_TIME_PRECISION_MILLI, pInterval->precision); + tw->skey = convertTimePrecision((int64_t)taosMktime(&tm) * 1000LL, TSDB_TIME_PRECISION_MILLI, pInterval->precision); mon = (int)(mon + interval); tm.tm_year = mon / 12; tm.tm_mon = mon % 12; - tw->ekey = convertTimePrecision((int64_t)taosMktime(&tm) * 1000L, TSDB_TIME_PRECISION_MILLI, pInterval->precision); + tw->ekey = convertTimePrecision((int64_t)taosMktime(&tm) * 1000LL, TSDB_TIME_PRECISION_MILLI, pInterval->precision); tw->ekey -= 1; } @@ -224,7 +224,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca pBlock->pBlockAgg = taosMemoryCalloc(numOfCols, POINTER_BYTES); } - for (int32_t i = 0; i < numOfCols; ++i) { + for (int32_t i = 0; i < taosArrayGetSize(pTableScanInfo->pColMatchInfo); ++i) { SColMatchInfo* pColMatchInfo = taosArrayGet(pTableScanInfo->pColMatchInfo, i); if (!pColMatchInfo->output) { continue; @@ -384,7 +384,14 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { continue; } - tsdbRetrieveDataBlockInfo(pTableScanInfo->dataReader, &pBlock->info); + blockDataCleanup(pBlock); + + SDataBlockInfo binfo = pBlock->info; + tsdbRetrieveDataBlockInfo(pTableScanInfo->dataReader, &binfo); + + binfo.capacity = binfo.rows; + blockDataEnsureCapacity(pBlock, binfo.rows); + pBlock->info = binfo; uint32_t status = 0; int32_t code = loadDataBlock(pOperator, pTableScanInfo, pBlock, &status); @@ -530,7 +537,6 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, // taosSsleep(20); SDataBlockDescNode* pDescNode = pTableScanNode->scan.node.pOutputDataBlockDesc; - int32_t numOfCols = 0; SArray* pColList = extractColMatchInfo(pTableScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID); @@ -591,12 +597,12 @@ SOperatorInfo* createTableSeqScanOperatorInfo(void* pReadHandle, SExecTaskInfo* pInfo->dataReader = pReadHandle; // pInfo->prevGroupId = -1; - pOperator->name = "TableSeqScanOperator"; + pOperator->name = "TableSeqScanOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN; - pOperator->blocking = false; - pOperator->status = OP_NOT_OPENED; - pOperator->info = pInfo; - pOperator->pTaskInfo = pTaskInfo; + pOperator->blocking = false; + pOperator->status = OP_NOT_OPENED; + pOperator->info = pInfo; + pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTableScanImpl, NULL, NULL, NULL, NULL, NULL, NULL); return pOperator; @@ -610,7 +616,7 @@ static int32_t doGetTableRowSize(void* pMeta, uint64_t uid) { metaGetTableEntryByUid(&mr, uid); if (mr.me.type == TSDB_SUPER_TABLE) { int32_t numOfCols = mr.me.stbEntry.schemaRow.nCols; - for(int32_t i = 0; i < numOfCols; ++i) { + for (int32_t i = 0; i < numOfCols; ++i) { rowLen += mr.me.stbEntry.schemaRow.pSchema[i].bytes; } } else if (mr.me.type == TSDB_CHILD_TABLE) { @@ -618,12 +624,12 @@ static int32_t doGetTableRowSize(void* pMeta, uint64_t uid) { metaGetTableEntryByUid(&mr, suid); int32_t numOfCols = mr.me.stbEntry.schemaRow.nCols; - for(int32_t i = 0; i < numOfCols; ++i) { + for (int32_t i = 0; i < numOfCols; ++i) { rowLen += mr.me.stbEntry.schemaRow.pSchema[i].bytes; } } else if (mr.me.type == TSDB_NORMAL_TABLE) { int32_t numOfCols = mr.me.ntbEntry.schemaRow.nCols; - for(int32_t i = 0; i < numOfCols; ++i) { + for (int32_t i = 0; i < numOfCols; ++i) { rowLen += mr.me.ntbEntry.schemaRow.pSchema[i].bytes; } } @@ -647,7 +653,7 @@ static SSDataBlock* doBlockInfoScan(SOperatorInfo* pOperator) { SSDataBlock* pBlock = pBlockScanInfo->pResBlock; - int32_t slotId = pOperator->exprSupp.pExprInfo->base.resSchema.slotId; + int32_t slotId = pOperator->exprSupp.pExprInfo->base.resSchema.slotId; SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, slotId); int32_t len = tSerializeBlockDistInfo(NULL, 0, &blockDistInfo); @@ -679,23 +685,23 @@ SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SReadHandle* re goto _error; } - pInfo->pHandle = dataReader; + pInfo->pHandle = dataReader; pInfo->readHandle = *readHandle; - pInfo->uid = uid; - pInfo->pResBlock = createResDataBlock(pBlockScanNode->node.pOutputDataBlockDesc); + pInfo->uid = uid; + pInfo->pResBlock = createResDataBlock(pBlockScanNode->node.pOutputDataBlockDesc); - int32_t numOfCols = 0; + int32_t numOfCols = 0; SExprInfo* pExprInfo = createExprInfo(pBlockScanNode->pScanPseudoCols, NULL, &numOfCols); - int32_t code = initExprSupp(&pOperator->exprSupp, pExprInfo, numOfCols); + int32_t code = initExprSupp(&pOperator->exprSupp, pExprInfo, numOfCols); if (code != TSDB_CODE_SUCCESS) { goto _error; } - pOperator->name = "DataBlockDistScanOperator"; + pOperator->name = "DataBlockDistScanOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN; - pOperator->blocking = false; - pOperator->status = OP_NOT_OPENED; - pOperator->info = pInfo; + pOperator->blocking = false; + pOperator->status = OP_NOT_OPENED; + pOperator->info = pInfo; pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doBlockInfoScan, NULL, NULL, @@ -903,7 +909,6 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) { // NOTE: this operator does never check if current status is done or not SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SStreamBlockScanInfo* pInfo = pOperator->info; - int32_t rows = 0; pTaskInfo->code = pOperator->fpSet._openFn(pOperator); if (pTaskInfo->code != TSDB_CODE_SUCCESS || pOperator->status == OP_EXEC_DONE) { @@ -1023,9 +1028,6 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) { pTaskInfo->code = terrno; return NULL; } - - rows = pBlockInfo->rows; - // currently only the tbname pseudo column if (pInfo->numOfPseudoExpr > 0) { addTagPseudoColumnData(&pInfo->readHandle, pInfo->pPseudoExpr, pInfo->numOfPseudoExpr, pInfo->pRes); @@ -1033,14 +1035,16 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) { doFilter(pInfo->pCondition, pInfo->pRes); blockDataUpdateTsWindow(pInfo->pRes, pInfo->primaryTsIndex); - break; + if (pBlockInfo->rows > 0) { + break; + } } // record the scan action. pInfo->numOfExec++; pOperator->resultInfo.totalRows += pBlockInfo->rows; - if (rows == 0) { + if (pBlockInfo->rows == 0) { pOperator->status = OP_EXEC_DONE; } else if (pInfo->pUpdateInfo) { pInfo->tsArrayIndex = 0; @@ -1056,7 +1060,7 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator) { } } - return (rows == 0) ? NULL : pInfo->pRes; + return (pBlockInfo->rows == 0) ? NULL : pInfo->pRes; } } @@ -1874,26 +1878,25 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi SExprInfo* pExprInfo = createExprInfo(pPhyNode->pScanPseudoCols, NULL, &numOfExprs); SArray* colList = extractColMatchInfo(pPhyNode->pScanPseudoCols, pDescNode, &num, COL_MATCH_FROM_COL_ID); - int32_t code = initExprSupp(&pOperator->exprSupp, pExprInfo, numOfExprs); if (code != TSDB_CODE_SUCCESS) { goto _error; } - pInfo->pTableList = pTableListInfo; - pInfo->pColMatchInfo = colList; - pInfo->pRes = createResDataBlock(pDescNode); - pInfo->readHandle = *pReadHandle; - pInfo->curPos = 0; - pInfo->pFilterNode = pPhyNode->node.pConditions; + pInfo->pTableList = pTableListInfo; + pInfo->pColMatchInfo = colList; + pInfo->pRes = createResDataBlock(pDescNode); + pInfo->readHandle = *pReadHandle; + pInfo->curPos = 0; + pInfo->pFilterNode = pPhyNode->node.pConditions; pOperator->name = "TagScanOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN; - pOperator->blocking = false; - pOperator->status = OP_NOT_OPENED; - pOperator->info = pInfo; - pOperator->pTaskInfo = pTaskInfo; + pOperator->blocking = false; + pOperator->status = OP_NOT_OPENED; + pOperator->info = pInfo; + pOperator->pTaskInfo = pTaskInfo; initResultSizeInfo(pOperator, 4096); blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity); @@ -1959,25 +1962,42 @@ typedef struct STableMergeScanInfo { } STableMergeScanInfo; -int32_t createMultipleDataReaders(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, - STableListInfo* pTableListInfo, SArray* arrayReader, uint64_t queryId, - uint64_t taskId, SNode* pTagCond) { +int32_t compareTableKeyInfoByGid(const void* p1, const void* p2) { + const STableKeyInfo* info1 = p1; + const STableKeyInfo* info2 = p2; + return info1->groupId - info2->groupId; +} + +int32_t createScanTableListInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, + STableListInfo* pTableListInfo, uint64_t queryId, uint64_t taskId, + SNode* pTagCond) { int32_t code = getTableList(pHandle->meta, &pTableScanNode->scan, pTableListInfo, pTagCond); if (code != TSDB_CODE_SUCCESS) { - goto _error; + return code; } if (taosArrayGetSize(pTableListInfo->pTableList) == 0) { qDebug("no table qualified for query, TID:0x%" PRIx64 ", QID:0x%" PRIx64, taskId, queryId); - goto _error; + return TSDB_CODE_SUCCESS; } + SArray* groupKeys = extractPartitionColInfo(pTableScanNode->pPartitionTags); + generateGroupIdMap(pTableListInfo, pHandle, groupKeys); // todo for json + if (groupKeys) { + taosArraySort(pTableListInfo->pTableList, compareTableKeyInfoByGid); + } + taosArrayDestroy(groupKeys); + return TSDB_CODE_SUCCESS; +} + +int32_t doCreateMultipleDataReaders(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, + STableListInfo* pTableListInfo, SArray* arrayReader, uint64_t queryId, + uint64_t taskId) { SQueryTableDataCond cond = {0}; - code = initQueryTableDataCond(&cond, pTableScanNode); + int32_t code = initQueryTableDataCond(&cond, pTableScanNode); if (code != TSDB_CODE_SUCCESS) { goto _error; } - // TODO: free the sublist info and the table list in it for (int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); ++i) { STableListInfo* subListInfo = taosMemoryCalloc(1, sizeof(subListInfo)); subListInfo->pTableList = taosArrayInit(1, sizeof(STableKeyInfo)); @@ -1991,7 +2011,7 @@ int32_t createMultipleDataReaders(STableScanPhysiNode* pTableScanNode, SReadHand } cleanupQueryTableDataCond(&cond); - return 0; + return TSDB_CODE_SUCCESS; _error: return code; diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index 9d13276e6d..97be4645a8 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -22,10 +22,11 @@ static int32_t getExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain static void destroyOrderOperatorInfo(void* param, int32_t numOfOutput); -SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* pSortPhyNode, SExecTaskInfo* pTaskInfo) { +SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* pSortPhyNode, + SExecTaskInfo* pTaskInfo) { SSortOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SSortOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); - if (pInfo == NULL || pOperator == NULL/* || rowSize > 100 * 1024 * 1024*/) { + if (pInfo == NULL || pOperator == NULL /* || rowSize > 100 * 1024 * 1024*/) { goto _error; } @@ -44,16 +45,17 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* initResultSizeInfo(pOperator, 1024); - pInfo->pSortInfo = createSortInfo(pSortPhyNode->pSortKeys);; - pInfo->pColMatchInfo = pColMatchColInfo; - pOperator->name = "SortOperator"; + pInfo->pSortInfo = createSortInfo(pSortPhyNode->pSortKeys); + ; + pInfo->pColMatchInfo = pColMatchColInfo; + pOperator->name = "SortOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_SORT; - pOperator->blocking = true; - pOperator->status = OP_NOT_OPENED; - pOperator->info = pInfo; - pOperator->exprSupp.pExprInfo = pExprInfo; - pOperator->exprSupp.numOfExprs = numOfCols; - pOperator->pTaskInfo = pTaskInfo; + pOperator->blocking = true; + pOperator->status = OP_NOT_OPENED; + pOperator->info = pInfo; + pOperator->exprSupp.pExprInfo = pExprInfo; + pOperator->exprSupp.numOfExprs = numOfCols; + pOperator->pTaskInfo = pTaskInfo; // lazy evaluation for the following parameter since the input datablock is not known till now. // pInfo->bufPageSize = rowSize < 1024 ? 1024 * 2 : rowSize * 2; @@ -146,8 +148,8 @@ void applyScalarFunction(SSDataBlock* pBlock, void* param) { SOperatorInfo* pOperator = param; SSortOperatorInfo* pSort = pOperator->info; if (pOperator->exprSupp.pExprInfo != NULL) { - int32_t code = - projectApplyFunctions(pOperator->exprSupp.pExprInfo, pBlock, pBlock, pOperator->exprSupp.pCtx, pOperator->exprSupp.numOfExprs, NULL); + int32_t code = projectApplyFunctions(pOperator->exprSupp.pExprInfo, pBlock, pBlock, pOperator->exprSupp.pCtx, + pOperator->exprSupp.numOfExprs, NULL); if (code != TSDB_CODE_SUCCESS) { longjmp(pOperator->pTaskInfo->env, code); } @@ -165,8 +167,7 @@ int32_t doOpenSortOperator(SOperatorInfo* pOperator) { pInfo->startTs = taosGetTimestampUs(); // pInfo->binfo.pRes is not equalled to the input datablock. - pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, SORT_SINGLESOURCE_SORT, -1, -1, - NULL, pTaskInfo->id.str); + pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, SORT_SINGLESOURCE_SORT, -1, -1, NULL, pTaskInfo->id.str); tsortSetFetchRawDataFp(pInfo->pSortHandle, loadNextDataBlock, applyScalarFunction, pOperator); @@ -232,6 +233,265 @@ int32_t getExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* return TSDB_CODE_SUCCESS; } +//===================================================================================== +// Group Sort Operator +typedef enum EChildOperatorStatus { CHILD_OP_NEW_GROUP, CHILD_OP_SAME_GROUP, CHILD_OP_FINISHED } EChildOperatorStatus; + +typedef struct SGroupSortOperatorInfo { + SOptrBasicInfo binfo; + SArray* pSortInfo; + SArray* pColMatchInfo; + + int64_t startTs; + uint64_t sortElapsed; + bool hasGroupId; + uint64_t currGroupId; + + SSDataBlock* prefetchedSortInput; + SSortHandle* pCurrSortHandle; + EChildOperatorStatus childOpStatus; + + SSortExecInfo sortExecInfo; +} SGroupSortOperatorInfo; + +SSDataBlock* getGroupSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, int32_t capacity, + SArray* pColMatchInfo, SGroupSortOperatorInfo* pInfo) { + blockDataCleanup(pDataBlock); + + SSDataBlock* p = tsortGetSortedDataBlock(pHandle); + if (p == NULL) { + return NULL; + } + + blockDataEnsureCapacity(p, capacity); + + while (1) { + STupleHandle* pTupleHandle = tsortNextTuple(pHandle); + if (pTupleHandle == NULL) { + break; + } + + appendOneRowToDataBlock(p, pTupleHandle); + if (p->info.rows >= capacity) { + break; + } + } + + if (p->info.rows > 0) { + int32_t numOfCols = taosArrayGetSize(pColMatchInfo); + for (int32_t i = 0; i < numOfCols; ++i) { + SColMatchInfo* pmInfo = taosArrayGet(pColMatchInfo, i); + ASSERT(pmInfo->matchType == COL_MATCH_FROM_SLOT_ID); + + SColumnInfoData* pSrc = taosArrayGet(p->pDataBlock, pmInfo->srcSlotId); + SColumnInfoData* pDst = taosArrayGet(pDataBlock->pDataBlock, pmInfo->targetSlotId); + colDataAssign(pDst, pSrc, p->info.rows); + } + + pDataBlock->info.rows = p->info.rows; + pDataBlock->info.capacity = p->info.rows; + } + + blockDataDestroy(p); + return (pDataBlock->info.rows > 0) ? pDataBlock : NULL; +} + +typedef struct SGroupSortSourceParam { + SOperatorInfo* childOpInfo; + SGroupSortOperatorInfo* grpSortOpInfo; +} SGroupSortSourceParam; + +SSDataBlock* fetchNextGroupSortDataBlock(void* param) { + SGroupSortSourceParam* source = param; + SGroupSortOperatorInfo* grpSortOpInfo = source->grpSortOpInfo; + if (grpSortOpInfo->prefetchedSortInput) { + SSDataBlock* block = grpSortOpInfo->prefetchedSortInput; + grpSortOpInfo->prefetchedSortInput = NULL; + return block; + } else { + SOperatorInfo* childOp = source->childOpInfo; + SSDataBlock* block = childOp->fpSet.getNextFn(childOp); + if (block != NULL) { + if (block->info.groupId == grpSortOpInfo->currGroupId) { + grpSortOpInfo->childOpStatus = CHILD_OP_SAME_GROUP; + return block; + } else { + grpSortOpInfo->childOpStatus = CHILD_OP_NEW_GROUP; + grpSortOpInfo->prefetchedSortInput = block; + return NULL; + } + } else { + grpSortOpInfo->childOpStatus = CHILD_OP_FINISHED; + return NULL; + } + } +} + +int32_t beginSortGroup(SOperatorInfo* pOperator) { + SGroupSortOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + + // pInfo->binfo.pRes is not equalled to the input datablock. + pInfo->pCurrSortHandle = + tsortCreateSortHandle(pInfo->pSortInfo, SORT_SINGLESOURCE_SORT, -1, -1, NULL, pTaskInfo->id.str); + + tsortSetFetchRawDataFp(pInfo->pCurrSortHandle, fetchNextGroupSortDataBlock, applyScalarFunction, pOperator); + + SSortSource* ps = taosMemoryCalloc(1, sizeof(SSortSource)); + SGroupSortSourceParam* param = taosMemoryCalloc(1, sizeof(SGroupSortSourceParam)); + param->childOpInfo = pOperator->pDownstream[0]; + param->grpSortOpInfo = pInfo; + ps->param = param; + tsortAddSource(pInfo->pCurrSortHandle, ps); + + int32_t code = tsortOpen(pInfo->pCurrSortHandle); + taosMemoryFreeClear(ps); + + if (code != TSDB_CODE_SUCCESS) { + longjmp(pTaskInfo->env, terrno); + } + + return TSDB_CODE_SUCCESS; +} + +int32_t finishSortGroup(SOperatorInfo* pOperator) { + SGroupSortOperatorInfo* pInfo = pOperator->info; + + SSortExecInfo sortExecInfo = tsortGetSortExecInfo(pInfo->pCurrSortHandle); + pInfo->sortExecInfo.sortMethod = sortExecInfo.sortMethod; + pInfo->sortExecInfo.sortBuffer = sortExecInfo.sortBuffer; + pInfo->sortExecInfo.loops += sortExecInfo.loops; + pInfo->sortExecInfo.readBytes += sortExecInfo.readBytes; + pInfo->sortExecInfo.writeBytes += sortExecInfo.writeBytes; + if (pInfo->pCurrSortHandle != NULL) { + tsortDestroySortHandle(pInfo->pCurrSortHandle); + } + pInfo->pCurrSortHandle = NULL; + return TSDB_CODE_SUCCESS; +} + +SSDataBlock* doGroupSort(SOperatorInfo* pOperator) { + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } + + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SGroupSortOperatorInfo* pInfo = pOperator->info; + + int32_t code = pOperator->fpSet._openFn(pOperator); + if (code != TSDB_CODE_SUCCESS) { + longjmp(pTaskInfo->env, code); + } + + if (!pInfo->hasGroupId) { + pInfo->hasGroupId = true; + + pInfo->prefetchedSortInput = pOperator->pDownstream[0]->fpSet.getNextFn(pOperator->pDownstream[0]); + pInfo->currGroupId = pInfo->prefetchedSortInput->info.groupId; + pInfo->childOpStatus = CHILD_OP_NEW_GROUP; + beginSortGroup(pOperator); + } + + SSDataBlock* pBlock = NULL; + while (pInfo->pCurrSortHandle != NULL) { + // beginSortGroup would fetch all child blocks of pInfo->currGroupId; + ASSERT(pInfo->childOpStatus != CHILD_OP_SAME_GROUP); + pBlock = getGroupSortedBlockData(pInfo->pCurrSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity, + pInfo->pColMatchInfo, pInfo); + if (pBlock != NULL) { + pBlock->info.groupId = pInfo->currGroupId; + pOperator->resultInfo.totalRows += pBlock->info.rows; + return pBlock; + } else { + if (pInfo->childOpStatus == CHILD_OP_NEW_GROUP) { + finishSortGroup(pOperator); + pInfo->currGroupId = pInfo->prefetchedSortInput->info.groupId; + beginSortGroup(pOperator); + } else if (pInfo->childOpStatus == CHILD_OP_FINISHED) { + finishSortGroup(pOperator); + doSetOperatorCompleted(pOperator); + return NULL; + } + } + } + return NULL; +} + +int32_t getGroupSortExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) { + SGroupSortOperatorInfo* pInfo = (SGroupSortOperatorInfo*)pOptr->info; + *pOptrExplain = &pInfo->sortExecInfo; + *len = sizeof(SSortExecInfo); + return TSDB_CODE_SUCCESS; +} + +// TODO: +SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* pSortPhyNode, + SExecTaskInfo* pTaskInfo) { + SSortOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SSortOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + if (pInfo == NULL || pOperator == NULL /* || rowSize > 100 * 1024 * 1024*/) { + goto _error; + } + + SDataBlockDescNode* pDescNode = pSortPhyNode->node.pOutputDataBlockDesc; + + int32_t numOfCols = 0; + SSDataBlock* pResBlock = createResDataBlock(pDescNode); + SExprInfo* pExprInfo = createExprInfo(pSortPhyNode->pExprs, NULL, &numOfCols); + + int32_t numOfOutputCols = 0; + SArray* pColMatchColInfo = + extractColMatchInfo(pSortPhyNode->pTargets, pDescNode, &numOfOutputCols, COL_MATCH_FROM_SLOT_ID); + + pOperator->exprSupp.pCtx = createSqlFunctionCtx(pExprInfo, numOfCols, &pOperator->exprSupp.rowEntryInfoOffset); + pInfo->binfo.pRes = pResBlock; + + initResultSizeInfo(pOperator, 1024); + + pInfo->pSortInfo = createSortInfo(pSortPhyNode->pSortKeys); + ; + pInfo->pColMatchInfo = pColMatchColInfo; + pOperator->name = "GroupSortOperator"; + // TODO + pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_SORT; + pOperator->blocking = true; + pOperator->status = OP_NOT_OPENED; + pOperator->info = pInfo; + pOperator->exprSupp.pExprInfo = pExprInfo; + pOperator->exprSupp.numOfExprs = numOfCols; + pOperator->pTaskInfo = pTaskInfo; + + pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doGroupSort, NULL, NULL, destroyOrderOperatorInfo, NULL, + NULL, getGroupSortExplainExecInfo); + + int32_t code = appendDownstream(pOperator, &downstream, 1); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + return pOperator; + +_error: + pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; + taosMemoryFree(pInfo); + taosMemoryFree(pOperator); + return NULL; +} + +void destroyGroupSortOperatorInfo(void* param, int32_t numOfOutput) { + SGroupSortOperatorInfo* pInfo = (SGroupSortOperatorInfo*)param; + pInfo->binfo.pRes = blockDataDestroy(pInfo->binfo.pRes); + + taosArrayDestroy(pInfo->pSortInfo); + taosArrayDestroy(pInfo->pColMatchInfo); +} + +// TODO: sort group +// TODO: msortCompare compare group id in multiway merge sort. +// TODO: table merge scan, group first, then for each group, multiple readers + +//===================================================================================== +// Multiway Sort Merge operator typedef struct SMultiwaySortMergeOperatorInfo { SOptrBasicInfo binfo; @@ -259,11 +519,12 @@ int32_t doOpenMultiwaySortMergeOperator(SOperatorInfo* pOperator) { int32_t numOfBufPage = pInfo->sortBufSize / pInfo->bufPageSize; - pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, SORT_MULTISOURCE_MERGE, - pInfo->bufPageSize, numOfBufPage, pInfo->pInputBlock, pTaskInfo->id.str); + pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, SORT_MULTISOURCE_MERGE, pInfo->bufPageSize, numOfBufPage, + pInfo->pInputBlock, pTaskInfo->id.str); tsortSetFetchRawDataFp(pInfo->pSortHandle, loadNextDataBlock, NULL, NULL); - + tsortSetCompareGroupId(pInfo->pSortHandle, true); + for (int32_t i = 0; i < pOperator->numOfDownstream; ++i) { SSortSource* ps = taosMemoryCalloc(1, sizeof(SSortSource)); ps->param = pOperator->pDownstream[i]; @@ -286,7 +547,7 @@ int32_t doOpenMultiwaySortMergeOperator(SOperatorInfo* pOperator) { SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, int32_t capacity, SArray* pColMatchInfo, SOperatorInfo* pOperator) { SMultiwaySortMergeOperatorInfo* pInfo = pOperator->info; - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; blockDataCleanup(pDataBlock); @@ -387,24 +648,23 @@ SOperatorInfo* createMultiwaySortMergeOperatorInfo(SOperatorInfo** downStreams, goto _error; } - initResultSizeInfo(pOperator, 1024); - pInfo->binfo.pRes = pResBlock; - pInfo->pSortInfo = pSortInfo; + pInfo->binfo.pRes = pResBlock; + pInfo->pSortInfo = pSortInfo; pInfo->pColMatchInfo = pColMatchColInfo; - pInfo->pInputBlock = pInputBlock; - pOperator->name = "MultiwaySortMerge"; + pInfo->pInputBlock = pInputBlock; + pOperator->name = "MultiwaySortMerge"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE; - pOperator->blocking = false; - pOperator->status = OP_NOT_OPENED; - pOperator->info = pInfo; + pOperator->blocking = false; + pOperator->status = OP_NOT_OPENED; + pOperator->info = pInfo; pOperator->pTaskInfo = pTaskInfo; - pInfo->bufPageSize = getProperSortPageSize(rowSize); + pInfo->bufPageSize = getProperSortPageSize(rowSize); // one additional is reserved for merged result. - pInfo->sortBufSize = pInfo->bufPageSize * (numStreams + 1); + pInfo->sortBufSize = pInfo->bufPageSize * (numStreams + 1); pOperator->fpSet = createOperatorFpSet(doOpenMultiwaySortMergeOperator, doMultiwaySortMerge, NULL, NULL, @@ -421,4 +681,4 @@ _error: taosMemoryFree(pInfo); taosMemoryFree(pOperator); return NULL; -} \ No newline at end of file +} diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 63285daa3a..3ff45d7237 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -16,8 +16,8 @@ #include "function.h" #include "functionMgt.h" #include "tdatablock.h" -#include "ttime.h" #include "tfill.h" +#include "ttime.h" typedef enum SResultTsInterpType { RESULT_ROW_START_INTERP = 1, @@ -42,7 +42,7 @@ static void doCloseWindow(SResultRowInfo* pResultRowInfo, const SIntervalAggOper // * merged during merge stage. In this case, we need the pTableQueryInfo->lastResRows to decide if there // * is a previous result generated or not. // */ -//static void setIntervalQueryRange(STableQueryInfo* pTableQueryInfo, TSKEY key, STimeWindow* pQRange) { +// static void setIntervalQueryRange(STableQueryInfo* pTableQueryInfo, TSKEY key, STimeWindow* pQRange) { // // do nothing //} @@ -314,18 +314,18 @@ static void getNextTimeWindow(SInterval* pInterval, int32_t precision, int32_t o int mon = (int)(tm.tm_year * 12 + tm.tm_mon + interval * factor); tm.tm_year = mon / 12; tm.tm_mon = mon % 12; - tw->skey = convertTimePrecision((int64_t)taosMktime(&tm) * 1000L, TSDB_TIME_PRECISION_MILLI, precision); + tw->skey = convertTimePrecision((int64_t)taosMktime(&tm) * 1000LL, TSDB_TIME_PRECISION_MILLI, precision); mon = (int)(mon + interval); tm.tm_year = mon / 12; tm.tm_mon = mon % 12; - tw->ekey = convertTimePrecision((int64_t)taosMktime(&tm) * 1000L, TSDB_TIME_PRECISION_MILLI, precision); + tw->ekey = convertTimePrecision((int64_t)taosMktime(&tm) * 1000LL, TSDB_TIME_PRECISION_MILLI, precision); tw->ekey -= 1; } -void doTimeWindowInterpolation(SArray* pPrevValues, SArray* pDataBlock, TSKEY prevTs, int32_t prevRowIndex, - TSKEY curTs, int32_t curRowIndex, TSKEY windowKey, int32_t type, SExprSupp* pSup) { +void doTimeWindowInterpolation(SArray* pPrevValues, SArray* pDataBlock, TSKEY prevTs, int32_t prevRowIndex, TSKEY curTs, + int32_t curRowIndex, TSKEY windowKey, int32_t type, SExprSupp* pSup) { SqlFunctionCtx* pCtx = pSup->pCtx; int32_t index = 1; @@ -405,8 +405,8 @@ static void setNotInterpoWindowKey(SqlFunctionCtx* pCtx, int32_t numOfOutput, in } } -static bool setTimeWindowInterpolationStartTs(SIntervalAggOperatorInfo* pInfo, int32_t pos, SSDataBlock* pBlock, const TSKEY* tsCols, - STimeWindow* win, SExprSupp* pSup) { +static bool setTimeWindowInterpolationStartTs(SIntervalAggOperatorInfo* pInfo, int32_t pos, SSDataBlock* pBlock, + const TSKEY* tsCols, STimeWindow* win, SExprSupp* pSup) { bool ascQuery = (pInfo->order == TSDB_ORDER_ASC); TSKEY curTs = tsCols[pos]; @@ -434,9 +434,9 @@ static bool setTimeWindowInterpolationStartTs(SIntervalAggOperatorInfo* pInfo, i return true; } -static bool setTimeWindowInterpolationEndTs(SIntervalAggOperatorInfo* pInfo, SExprSupp* pSup, - int32_t endRowIndex, SArray* pDataBlock, const TSKEY* tsCols, - TSKEY blockEkey, STimeWindow* win) { +static bool setTimeWindowInterpolationEndTs(SIntervalAggOperatorInfo* pInfo, SExprSupp* pSup, int32_t endRowIndex, + SArray* pDataBlock, const TSKEY* tsCols, TSKEY blockEkey, + STimeWindow* win) { int32_t order = pInfo->order; TSKEY actualEndKey = tsCols[endRowIndex]; @@ -548,8 +548,8 @@ static void setResultRowInterpo(SResultRow* pResult, SResultTsInterpType type) { } } -static void doWindowBorderInterpolation(SIntervalAggOperatorInfo* pInfo, SSDataBlock* pBlock, SResultRow* pResult, STimeWindow* win, int32_t startPos, - int32_t forwardRows, SExprSupp* pSup) { +static void doWindowBorderInterpolation(SIntervalAggOperatorInfo* pInfo, SSDataBlock* pBlock, SResultRow* pResult, + STimeWindow* win, int32_t startPos, int32_t forwardRows, SExprSupp* pSup) { if (!pInfo->timeWindowInterpo) { return; } @@ -628,7 +628,7 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; SIntervalAggOperatorInfo* pInfo = (SIntervalAggOperatorInfo*)pOperatorInfo->info; - SExprSupp* pSup = &pOperatorInfo->exprSupp; + SExprSupp* pSup = &pOperatorInfo->exprSupp; int32_t startPos = 0; int32_t numOfOutput = pSup->numOfExprs; @@ -655,9 +655,8 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num } STimeWindow w = pr->win; - int32_t ret = - setTimeWindowOutputBuf(pResultRowInfo, &w, (scanFlag == MAIN_SCAN), &pResult, groupId, pSup->pCtx, - numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); + int32_t ret = setTimeWindowOutputBuf(pResultRowInfo, &w, (scanFlag == MAIN_SCAN), &pResult, groupId, pSup->pCtx, + numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -672,8 +671,8 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num setResultRowInterpo(pResult, RESULT_ROW_END_INTERP); setNotInterpoWindowKey(pSup->pCtx, numOfExprs, RESULT_ROW_START_INTERP); - doApplyFunctions(pTaskInfo, pSup->pCtx, &w, &pInfo->twAggSup.timeWindowData, startPos, 0, tsCols, - pBlock->info.rows, numOfExprs, pInfo->order); + doApplyFunctions(pTaskInfo, pSup->pCtx, &w, &pInfo->twAggSup.timeWindowData, startPos, 0, tsCols, pBlock->info.rows, + numOfExprs, pInfo->order); if (isResultRowInterpolated(pResult, RESULT_ROW_END_INTERP)) { closeResultRow(pr); @@ -685,6 +684,7 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num } void printDataBlock(SSDataBlock* pBlock, const char* flag) { + if (pBlock == NULL) return; SArray* blocks = taosArrayInit(1, sizeof(SSDataBlock)); taosArrayPush(blocks, pBlock); blockDebugShowData(blocks, flag); @@ -753,8 +753,7 @@ int64_t getReskey(void* data, int32_t index) { return *(int64_t*)pos->key; } -static int32_t saveResult(int64_t ts, int32_t pageId, int32_t offset, uint64_t groupId, - SArray* pUpdated) { +static int32_t saveResult(int64_t ts, int32_t pageId, int32_t offset, uint64_t groupId, SArray* pUpdated) { int32_t size = taosArrayGetSize(pUpdated); int32_t index = binarySearch(pUpdated, size, ts, TSDB_ORDER_DESC, getReskey); if (index == -1) { @@ -806,7 +805,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul SIntervalAggOperatorInfo* pInfo = (SIntervalAggOperatorInfo*)pOperatorInfo->info; SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; - SExprSupp* pSup = &pOperatorInfo->exprSupp; + SExprSupp* pSup = &pOperatorInfo->exprSupp; int32_t startPos = 0; int32_t numOfOutput = pSup->numOfExprs; @@ -819,9 +818,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul STimeWindow win = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, pInfo->interval.precision, &pInfo->win); - int32_t ret = - setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx, - numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); + int32_t ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, + pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -843,9 +841,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul doInterpUnclosedTimeWindow(pOperatorInfo, numOfOutput, pResultRowInfo, pBlock, scanFlag, tsCols, &pos); // restore current time window - ret = - setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx, - numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); + ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx, + numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -870,8 +867,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul // null data, failed to allocate more memory buffer int32_t code = setTimeWindowOutputBuf(pResultRowInfo, &nextWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, - pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, - &pInfo->aggSup, pTaskInfo); + pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); if (code != TSDB_CODE_SUCCESS || pResult == NULL) { longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -890,8 +886,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul doWindowBorderInterpolation(pInfo, pBlock, pResult, &nextWin, startPos, forwardRows, pSup); updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true); - doApplyFunctions(pTaskInfo, pSup->pCtx, &nextWin, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, - tsCols, pBlock->info.rows, numOfOutput, pInfo->order); + doApplyFunctions(pTaskInfo, pSup->pCtx, &nextWin, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, tsCols, + pBlock->info.rows, numOfOutput, pInfo->order); doCloseWindow(pResultRowInfo, pInfo, pResult); } @@ -1002,7 +998,7 @@ static bool compareVal(const char* v, const SStateKeys* pKey) { static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorInfo* pInfo, SSDataBlock* pBlock) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - SExprSupp* pSup = &pOperator->exprSupp; + SExprSupp* pSup = &pOperator->exprSupp; SColumnInfoData* pStateColInfoData = taosArrayGet(pBlock->pDataBlock, pInfo->stateCol.slotId); int64_t gid = pBlock->info.groupId; @@ -1050,9 +1046,8 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI STimeWindow window = pRowSup->win; pRowSup->win.ekey = pRowSup->win.skey; - int32_t ret = - setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &window, masterScan, &pResult, gid, pSup->pCtx, - numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); + int32_t ret = setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &window, masterScan, &pResult, gid, pSup->pCtx, + numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code longjmp(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR); } @@ -1076,9 +1071,8 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI SResultRow* pResult = NULL; pRowSup->win.ekey = tsList[pBlock->info.rows - 1]; - int32_t ret = - setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &pRowSup->win, masterScan, &pResult, gid, pSup->pCtx, - numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); + int32_t ret = setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &pRowSup->win, masterScan, &pResult, gid, + pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code longjmp(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR); } @@ -1095,8 +1089,8 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo* pOperator) { SStateWindowOperatorInfo* pInfo = pOperator->info; - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - SExprSupp* pSup = &pOperator->exprSupp; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SExprSupp* pSup = &pOperator->exprSupp; SOptrBasicInfo* pBInfo = &pInfo->binfo; @@ -1207,7 +1201,7 @@ static void setInverFunction(SqlFunctionCtx* pCtx, int32_t num, EStreamType type } } -void doClearWindowImpl(SResultRowPosition* p1, SDiskbasedBuf* pResultBuf, SExprSupp *pSup, int32_t numOfOutput) { +void doClearWindowImpl(SResultRowPosition* p1, SDiskbasedBuf* pResultBuf, SExprSupp* pSup, int32_t numOfOutput) { SResultRow* pResult = getResultRowByPos(pResultBuf, p1); SqlFunctionCtx* pCtx = pSup->pCtx; for (int32_t i = 0; i < numOfOutput; ++i) { @@ -1223,7 +1217,7 @@ void doClearWindowImpl(SResultRowPosition* p1, SDiskbasedBuf* pResultBuf, SExprS } } -void doClearWindow(SAggSupporter* pAggSup, SExprSupp *pSup, char* pData, int16_t bytes, uint64_t groupId, +void doClearWindow(SAggSupporter* pAggSup, SExprSupp* pSup, char* pData, int16_t bytes, uint64_t groupId, int32_t numOfOutput) { SET_RES_WINDOW_KEY(pAggSup->keyBuf, pData, bytes, groupId); SResultRowPosition* p1 = @@ -1259,9 +1253,9 @@ static int32_t getAllIntervalWindow(SHashObj* pHashMap, SArray* resWins) { void* key = taosHashGetKey(pIte, &keyLen); uint64_t groupId = *(uint64_t*)key; ASSERT(keyLen == GET_RES_WINDOW_KEY_LEN(sizeof(TSKEY))); - TSKEY ts = *(int64_t*)((char*)key + sizeof(uint64_t)); + TSKEY ts = *(int64_t*)((char*)key + sizeof(uint64_t)); SResultRowPosition* pPos = (SResultRowPosition*)pIte; - int32_t code = saveResult(ts, pPos->pageId, pPos->offset, groupId, resWins); + int32_t code = saveResult(ts, pPos->pageId, pPos->offset, groupId, resWins); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -1269,8 +1263,9 @@ static int32_t getAllIntervalWindow(SHashObj* pHashMap, SArray* resWins) { return TSDB_CODE_SUCCESS; } -bool isCloseWindow(STimeWindow *pWin, STimeWindowAggSupp* pSup) { - return pWin->ekey < pSup->maxTs - pSup->waterMark; +bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup) { + ASSERT(pSup->maxTs == INT64_MIN || pSup->maxTs > 0); + return pSup->maxTs != INT64_MIN && pWin->ekey < pSup->maxTs - pSup->waterMark; } static int32_t closeIntervalWindow(SHashObj* pHashMap, STimeWindowAggSupp* pSup, SInterval* pInterval, @@ -1330,7 +1325,8 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) { } if (pBlock->info.type == STREAM_REPROCESS) { - doClearWindows(&pInfo->aggSup, &pOperator->exprSupp, &pInfo->interval, 0, pOperator->exprSupp.numOfExprs, pBlock, NULL); + doClearWindows(&pInfo->aggSup, &pOperator->exprSupp, &pInfo->interval, 0, pOperator->exprSupp.numOfExprs, pBlock, + NULL); qDebug("%s clear existed time window results for updates checked", GET_TASKID(pTaskInfo)); continue; } else if (pBlock->info.type == STREAM_GET_ALL) { @@ -1580,7 +1576,7 @@ _error: // todo handle multiple tables cases. static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperatorInfo* pInfo, SSDataBlock* pBlock) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - SExprSupp* pSup = &pOperator->exprSupp; + SExprSupp* pSup = &pOperator->exprSupp; SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pInfo->tsSlotId); @@ -1617,9 +1613,8 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator STimeWindow window = pRowSup->win; pRowSup->win.ekey = pRowSup->win.skey; - int32_t ret = - setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &window, masterScan, &pResult, gid, pSup->pCtx, - numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); + int32_t ret = setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &window, masterScan, &pResult, gid, pSup->pCtx, + numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code longjmp(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR); } @@ -1637,9 +1632,8 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator SResultRow* pResult = NULL; pRowSup->win.ekey = tsList[pBlock->info.rows - 1]; - int32_t ret = - setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &pRowSup->win, masterScan, &pResult, gid, pSup->pCtx, - numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); + int32_t ret = setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, &pRowSup->win, masterScan, &pResult, gid, + pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code longjmp(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR); } @@ -1656,7 +1650,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) { SSessionAggOperatorInfo* pInfo = pOperator->info; SOptrBasicInfo* pBInfo = &pInfo->binfo; - SExprSupp* pSup = &pOperator->exprSupp; + SExprSupp* pSup = &pOperator->exprSupp; if (pOperator->status == OP_RES_TO_RETURN) { doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf); @@ -1707,8 +1701,8 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) { static void doKeepPrevRows(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlock* pBlock, int32_t rowIndex) { int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); - for(int32_t i = 0; i < numOfCols; ++i) { - SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i); + for (int32_t i = 0; i < numOfCols; ++i) { + SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i); // null data should not be kept since it can not be used to perform interpolation if (!colDataIsNull_s(pColInfoData, i)) { @@ -1844,22 +1838,22 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; STimeSliceOperatorInfo* pSliceInfo = pOperator->info; - SSDataBlock* pResBlock = pSliceInfo->pRes; - SExprSupp* pSup = &pOperator->exprSupp; + SSDataBlock* pResBlock = pSliceInfo->pRes; + SExprSupp* pSup = &pOperator->exprSupp; blockDataEnsureCapacity(pResBlock, pOperator->resultInfo.capacity); -// if (pOperator->status == OP_RES_TO_RETURN) { -// // doBuildResultDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes); -// if (pResBlock->info.rows == 0 || !hasDataInGroupInfo(&pSliceInfo->groupResInfo)) { -// doSetOperatorCompleted(pOperator); -// } -// -// return pResBlock; -// } + // if (pOperator->status == OP_RES_TO_RETURN) { + // // doBuildResultDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes); + // if (pResBlock->info.rows == 0 || !hasDataInGroupInfo(&pSliceInfo->groupResInfo)) { + // doSetOperatorCompleted(pOperator); + // } + // + // return pResBlock; + // } - int32_t order = TSDB_ORDER_ASC; - SInterval* pInterval = &pSliceInfo->interval; + int32_t order = TSDB_ORDER_ASC; + SInterval* pInterval = &pSliceInfo->interval; SOperatorInfo* downstream = pOperator->pDownstream[0]; int32_t numOfRows = 0; @@ -1878,14 +1872,14 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { setInputDataBlock(pOperator, pSup->pCtx, pBlock, order, MAIN_SCAN, true); SColumnInfoData* pTsCol = taosArrayGet(pBlock->pDataBlock, pSliceInfo->tsCol.slotId); - for(int32_t i = 0; i < pBlock->info.rows; ++i) { - int64_t ts = *(int64_t*) colDataGetData(pTsCol, i); + for (int32_t i = 0; i < pBlock->info.rows; ++i) { + int64_t ts = *(int64_t*)colDataGetData(pTsCol, i); if (ts == pSliceInfo->current) { - for(int32_t j = 0; j < pOperator->exprSupp.numOfExprs; ++j) { + for (int32_t j = 0; j < pOperator->exprSupp.numOfExprs; ++j) { SExprInfo* pExprInfo = &pOperator->exprSupp.pExprInfo[j]; - int32_t dstSlot = pExprInfo->base.resSchema.slotId; - int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId; + int32_t dstSlot = pExprInfo->base.resSchema.slotId; + int32_t srcSlot = pExprInfo->base.pParam[0].pCol->slotId; SColumnInfoData* pSrc = taosArrayGet(pBlock->pDataBlock, srcSlot); SColumnInfoData* pDst = taosArrayGet(pResBlock->pDataBlock, dstSlot); @@ -1897,7 +1891,8 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { pResBlock->info.rows += 1; doKeepPrevRows(pSliceInfo, pBlock, i); - pSliceInfo->current = taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); + pSliceInfo->current = + taosTimeAdd(pSliceInfo->current, pInterval->interval, pInterval->intervalUnit, pInterval->precision); if (pSliceInfo->current > pSliceInfo->win.ekey) { doSetOperatorCompleted(pOperator); break; @@ -1908,7 +1903,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { } } else if (ts < pSliceInfo->current) { if (i < pBlock->info.rows - 1) { - int64_t nextTs = *(int64_t*) colDataGetData(pTsCol, i + 1); + int64_t nextTs = *(int64_t*)colDataGetData(pTsCol, i + 1); if (nextTs > pSliceInfo->current) { while (pSliceInfo->current < nextTs && pSliceInfo->current <= pSliceInfo->win.ekey) { genInterpolationResult(pSliceInfo, &pOperator->exprSupp, pBlock, i, pResBlock); @@ -1956,7 +1951,7 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) { return pResBlock->info.rows == 0 ? NULL : pResBlock; } -SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode *pPhyNode, SExecTaskInfo* pTaskInfo) { +SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo) { STimeSliceOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(STimeSliceOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pOperator == NULL || pInfo == NULL) { @@ -1964,17 +1959,17 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode } SInterpFuncPhysiNode* pInterpPhyNode = (SInterpFuncPhysiNode*)pPhyNode; - SExprSupp* pSup = &pOperator->exprSupp; + SExprSupp* pSup = &pOperator->exprSupp; - int32_t numOfExprs = 0; + int32_t numOfExprs = 0; SExprInfo* pExprInfo = createExprInfo(pInterpPhyNode->pFuncs, NULL, &numOfExprs); - int32_t code = initExprSupp(pSup, pExprInfo, numOfExprs); + int32_t code = initExprSupp(pSup, pExprInfo, numOfExprs); if (code != TSDB_CODE_SUCCESS) { goto _error; } if (pInterpPhyNode->pExprs != NULL) { - int32_t num = 0; + int32_t num = 0; SExprInfo* pScalarExprInfo = createExprInfo(pInterpPhyNode->pExprs, NULL, &num); code = initExprSupp(&pInfo->scalarSup, pScalarExprInfo, num); if (code != TSDB_CODE_SUCCESS) { @@ -1986,21 +1981,21 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode pInfo->fillType = convertFillType(pInterpPhyNode->fillMode); initResultSizeInfo(pOperator, 4096); - pInfo->pFillColInfo = createFillColInfo(pExprInfo, numOfExprs, (SNodeListNode*)pInterpPhyNode->pFillValues); - pInfo->pRes = createResDataBlock(pPhyNode->pOutputDataBlockDesc); - pInfo->win = pInterpPhyNode->timeRange; + pInfo->pFillColInfo = createFillColInfo(pExprInfo, numOfExprs, (SNodeListNode*)pInterpPhyNode->pFillValues); + pInfo->pRes = createResDataBlock(pPhyNode->pOutputDataBlockDesc); + pInfo->win = pInterpPhyNode->timeRange; pInfo->interval.interval = pInterpPhyNode->interval; - pInfo->current = pInfo->win.skey; + pInfo->current = pInfo->win.skey; - pOperator->name = "TimeSliceOperator"; + pOperator->name = "TimeSliceOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC; - pOperator->blocking = false; - pOperator->status = OP_NOT_OPENED; - pOperator->info = pInfo; - pOperator->pTaskInfo = pTaskInfo; + pOperator->blocking = false; + pOperator->status = OP_NOT_OPENED; + pOperator->info = pInfo; + pOperator->pTaskInfo = pTaskInfo; - pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doTimeslice, NULL, NULL, destroyBasicOperatorInfo, - NULL, NULL, NULL); + pOperator->fpSet = + createOperatorFpSet(operatorDummyOpenFn, doTimeslice, NULL, NULL, destroyBasicOperatorInfo, NULL, NULL, NULL); code = appendDownstream(pOperator, &downstream, 1); return pOperator; @@ -2138,22 +2133,24 @@ void compactFunctions(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx, int3 } } -static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExprSupp* pSup, SArray* pWinArray, int32_t groupId, - int32_t numOfOutput, SExecTaskInfo* pTaskInfo) { +static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExprSupp* pSup, SArray* pWinArray, + int32_t groupId, int32_t numOfOutput, SExecTaskInfo* pTaskInfo) { int32_t size = taosArrayGetSize(pWinArray); - ASSERT(pInfo->pChildren); + if (!pInfo->pChildren) { + return; + } for (int32_t i = 0; i < size; i++) { STimeWindow* pParentWin = taosArrayGet(pWinArray, i); SResultRow* pCurResult = NULL; - setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, pParentWin, true, &pCurResult, 0, pSup->pCtx, - numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); + setTimeWindowOutputBuf(&pInfo->binfo.resultRowInfo, pParentWin, true, &pCurResult, 0, pSup->pCtx, numOfOutput, + pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo); int32_t numOfChildren = taosArrayGetSize(pInfo->pChildren); for (int32_t j = 0; j < numOfChildren; j++) { SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, j); SIntervalAggOperatorInfo* pChInfo = pChildOp->info; - SExprSupp* pChildSup = &pChildOp->exprSupp; + SExprSupp* pChildSup = &pChildOp->exprSupp; - SResultRow* pChResult = NULL; + SResultRow* pChResult = NULL; setTimeWindowOutputBuf(&pChInfo->binfo.resultRowInfo, pParentWin, true, &pChResult, 0, pChildSup->pCtx, pChildSup->numOfExprs, pChildSup->rowEntryInfoOffset, &pChInfo->aggSup, pTaskInfo); compactFunctions(pSup->pCtx, pChildSup->pCtx, numOfOutput, pTaskInfo); @@ -2163,8 +2160,8 @@ static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExpr bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup) { SET_RES_WINDOW_KEY(pSup->keyBuf, &pWin->skey, sizeof(int64_t), groupId); - SResultRowPosition* p1 = (SResultRowPosition*)taosHashGet(pSup->pResultRowHashTable, - pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(sizeof(int64_t))); + SResultRowPosition* p1 = (SResultRowPosition*)taosHashGet(pSup->pResultRowHashTable, pSup->keyBuf, + GET_RES_WINDOW_KEY_LEN(sizeof(int64_t))); return p1 == NULL; } @@ -2197,7 +2194,8 @@ static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBloc isDeletedWindow(&nextWin, tableGroupId, &pInfo->aggSup)) { SArray* pUpWins = taosArrayInit(8, sizeof(STimeWindow)); taosArrayPush(pUpWins, &nextWin); - rebuildIntervalWindow(pInfo, pSup, pUpWins, pInfo->binfo.pRes->info.groupId, pSup->numOfExprs, pOperatorInfo->pTaskInfo); + rebuildIntervalWindow(pInfo, pSup, pUpWins, pInfo->binfo.pRes->info.groupId, pSup->numOfExprs, + pOperatorInfo->pTaskInfo); taosArrayDestroy(pUpWins); } int32_t code = setTimeWindowOutputBuf(pResultRowInfo, &nextWin, true, &pResult, tableGroupId, pSup->pCtx, @@ -2215,8 +2213,8 @@ static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBloc saveResultRow(pResult, tableGroupId, pUpdated); } updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true); - doApplyFunctions(pTaskInfo, pSup->pCtx, &nextWin, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, - tsCols, pSDataBlock->info.rows, numOfOutput, TSDB_ORDER_ASC); + doApplyFunctions(pTaskInfo, pSup->pCtx, &nextWin, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, tsCols, + pSDataBlock->info.rows, numOfOutput, TSDB_ORDER_ASC); int32_t prevEndPos = (forwardRows - 1) * step + startPos; ASSERT(pSDataBlock->info.window.skey > 0 && pSDataBlock->info.window.ekey > 0); startPos = getNextQualifiedWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos, pInfo->order); @@ -2257,9 +2255,7 @@ void copyUpdateDataBlock(SSDataBlock* pDest, SSDataBlock* pSource, int32_t tsCol blockDataUpdateTsWindow(pDest, 0); } -static int32_t getChildIndex(SSDataBlock* pBlock) { - return pBlock->info.childId; -} +static int32_t getChildIndex(SSDataBlock* pBlock) { return pBlock->info.childId; } static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { SStreamFinalIntervalOperatorInfo* pInfo = pOperator->info; @@ -2304,7 +2300,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { int32_t childIndex = getChildIndex(pBlock); SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex); SIntervalAggOperatorInfo* pChildInfo = pChildOp->info; - SExprSupp* pChildSup = &pChildOp->exprSupp; + SExprSupp* pChildSup = &pChildOp->exprSupp; doClearWindows(&pChildInfo->aggSup, pChildSup, &pChildInfo->interval, pChildInfo->primaryTsIndex, pChildSup->numOfExprs, pBlock, NULL); @@ -2339,6 +2335,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) { SStreamFinalIntervalOperatorInfo* pChInfo = pChildOp->info; setInputDataBlock(pChildOp, pChildOp->exprSupp.pCtx, pBlock, pChInfo->order, MAIN_SCAN, true); doHashInterval(pChildOp, pBlock, pBlock->info.groupId, NULL); + pChInfo->twAggSup.maxTs = TMAX(pChInfo->twAggSup.maxTs, pBlock->info.window.ekey); } maxTs = TMAX(maxTs, pBlock->info.window.ekey); } @@ -2406,7 +2403,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, initResultRowInfo(&pInfo->binfo.resultRowInfo); pInfo->pChildren = NULL; if (numOfChild > 0) { - pInfo->pChildren = taosArrayInit(numOfChild, sizeof(SOperatorInfo)); + pInfo->pChildren = taosArrayInit(numOfChild, sizeof(void*)); for (int32_t i = 0; i < numOfChild; i++) { SOperatorInfo* pChildOp = createStreamFinalIntervalOperatorInfo(NULL, pPhyNode, pTaskInfo, 0); if (pChildOp) { @@ -2463,9 +2460,9 @@ _error: void destroyStreamAggSupporter(SStreamAggSupporter* pSup) { taosMemoryFreeClear(pSup->pKeyBuf); - void **pIte = NULL; + void** pIte = NULL; while ((pIte = taosHashIterate(pSup->pResultRows, pIte)) != NULL) { - SArray *pWins = (SArray *) (*pIte); + SArray* pWins = (SArray*)(*pIte); taosArrayDestroy(pWins); } taosHashCleanup(pSup->pResultRows); @@ -2489,18 +2486,19 @@ void destroyStreamSessionAggOperatorInfo(void* param, int32_t numOfOutput) { } } -int32_t initBasicInfoEx(SOptrBasicInfo* pBasicInfo, SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock) { +int32_t initBasicInfoEx(SOptrBasicInfo* pBasicInfo, SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfCols, + SSDataBlock* pResultBlock) { int32_t code = initExprSupp(pSup, pExprInfo, numOfCols); if (code != TSDB_CODE_SUCCESS) { return code; } initBasicInfo(pBasicInfo, pResultBlock); - + for (int32_t i = 0; i < numOfCols; ++i) { pSup->pCtx[i].pBuf = NULL; } - + ASSERT(numOfCols > 0); increaseTs(pSup->pCtx); return TSDB_CODE_SUCCESS; @@ -2519,18 +2517,20 @@ void initDownStream(SOperatorInfo* downstream, SStreamAggSupporter* pAggSup, int pScanInfo->pUpdateInfo = updateInfoInit(60000, TSDB_TIME_PRECISION_MILLI, waterMark); } -int32_t initSessionAggSupporter(SStreamAggSupporter* pSup, const char* pKey, SqlFunctionCtx* pCtx, int32_t numOfOutput) { +int32_t initSessionAggSupporter(SStreamAggSupporter* pSup, const char* pKey, SqlFunctionCtx* pCtx, + int32_t numOfOutput) { return initStreamAggSupporter(pSup, pKey, pCtx, numOfOutput, sizeof(SResultWindowInfo)); } -SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo) { - SSessionWinodwPhysiNode* pSessionNode = (SSessionWinodwPhysiNode*)pPhyNode; - int32_t numOfCols = 0; - SExprInfo* pExprInfo = createExprInfo(pSessionNode->window.pFuncs, NULL, &numOfCols); - SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); - int32_t code = TSDB_CODE_OUT_OF_MEMORY; +SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, + SExecTaskInfo* pTaskInfo) { + SSessionWinodwPhysiNode* pSessionNode = (SSessionWinodwPhysiNode*)pPhyNode; + int32_t numOfCols = 0; + SExprInfo* pExprInfo = createExprInfo(pSessionNode->window.pFuncs, NULL, &numOfCols); + SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc); + int32_t code = TSDB_CODE_OUT_OF_MEMORY; SStreamSessionAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamSessionAggOperatorInfo)); - SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { goto _error; } @@ -2542,8 +2542,7 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh if (code != TSDB_CODE_SUCCESS) { goto _error; } - - + code = initSessionAggSupporter(&pInfo->streamAggSup, "StreamSessionAggOperatorInfo", pSup->pCtx, numOfCols); if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -2555,10 +2554,8 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh } initDummyFunction(pInfo->pDummyCtx, pSup->pCtx, numOfCols); - pInfo->twAggSup = (STimeWindowAggSupp) { - .waterMark = pSessionNode->window.watermark, - .calTrigger = pSessionNode->window.triggerType, - .maxTs = INT64_MIN}; + pInfo->twAggSup = (STimeWindowAggSupp){ + .waterMark = pSessionNode->window.watermark, .calTrigger = pSessionNode->window.triggerType, .maxTs = INT64_MIN}; initResultRowInfo(&pInfo->binfo.resultRowInfo); initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window); @@ -2574,6 +2571,7 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh pInfo->pStDeleted = taosHashInit(64, hashFn, true, HASH_NO_LOCK); pInfo->pDelIterator = NULL; pInfo->pDelRes = createOneDataBlock(pResBlock, false); + pInfo->pDelRes->info.type = STREAM_DELETE; blockDataEnsureCapacity(pInfo->pDelRes, 64); pInfo->pChildren = NULL; pInfo->isFinal = false; @@ -2632,19 +2630,19 @@ static SResultWindowInfo* addNewSessionWindow(SArray* pWinInfos, TSKEY ts) { } SArray* getWinInfos(SStreamAggSupporter* pAggSup, uint64_t groupId) { - void** ite = taosHashGet(pAggSup->pResultRows, &groupId, sizeof(uint64_t)); + void** ite = taosHashGet(pAggSup->pResultRows, &groupId, sizeof(uint64_t)); SArray* pWinInfos = NULL; if (ite == NULL) { pWinInfos = taosArrayInit(1024, pAggSup->valueSize); - taosHashPut(pAggSup->pResultRows, &groupId, sizeof(uint64_t), &pWinInfos, sizeof(void *)); + taosHashPut(pAggSup->pResultRows, &groupId, sizeof(uint64_t), &pWinInfos, sizeof(void*)); } else { pWinInfos = *ite; } return pWinInfos; } -SResultWindowInfo* getSessionTimeWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, - TSKEY endTs, uint64_t groupId, int64_t gap, int32_t* pIndex) { +SResultWindowInfo* getSessionTimeWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, TSKEY endTs, uint64_t groupId, + int64_t gap, int32_t* pIndex) { SArray* pWinInfos = getWinInfos(pAggSup, groupId); pAggSup->pCurWins = pWinInfos; @@ -2683,10 +2681,10 @@ SResultWindowInfo* getSessionTimeWindow(SStreamAggSupporter* pAggSup, TSKEY star return insertNewSessionWindow(pWinInfos, startTs, index + 1); } -int32_t updateSessionWindowInfo(SResultWindowInfo* pWinInfo, TSKEY* pStartTs, - TSKEY* pEndTs, int32_t rows, int32_t start, int64_t gap, SHashObj* pStDeleted) { +int32_t updateSessionWindowInfo(SResultWindowInfo* pWinInfo, TSKEY* pStartTs, TSKEY* pEndTs, int32_t rows, + int32_t start, int64_t gap, SHashObj* pStDeleted) { for (int32_t i = start; i < rows; ++i) { - if (!isInWindow(pWinInfo, pStartTs[i], gap) && (!pEndTs || !isInWindow(pWinInfo, pEndTs[i], gap)) ) { + if (!isInWindow(pWinInfo, pStartTs[i], gap) && (!pEndTs || !isInWindow(pWinInfo, pEndTs[i], gap))) { return i - start; } if (pWinInfo->win.skey > pStartTs[i]) { @@ -2742,7 +2740,7 @@ static int32_t doOneWindowAggImpl(int32_t tsColId, SOptrBasicInfo* pBinfo, SStre SColumnInfoData* pTimeWindowData, SSDataBlock* pSDataBlock, SResultWindowInfo* pCurWin, SResultRow** pResult, int32_t startIndex, int32_t winRows, int32_t numOutput, SOperatorInfo* pOperator) { - SExprSupp* pSup = &pOperator->exprSupp; + SExprSupp* pSup = &pOperator->exprSupp; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, tsColId); @@ -2760,14 +2758,14 @@ static int32_t doOneWindowAggImpl(int32_t tsColId, SOptrBasicInfo* pBinfo, SStre static int32_t doOneWindowAgg(SStreamSessionAggOperatorInfo* pInfo, SSDataBlock* pSDataBlock, SResultWindowInfo* pCurWin, SResultRow** pResult, int32_t startIndex, int32_t winRows, - int32_t numOutput, SOperatorInfo * pOperator) { + int32_t numOutput, SOperatorInfo* pOperator) { return doOneWindowAggImpl(pInfo->primaryTsIndex, &pInfo->binfo, &pInfo->streamAggSup, &pInfo->twAggSup.timeWindowData, pSDataBlock, pCurWin, pResult, startIndex, winRows, numOutput, pOperator); } static int32_t doOneStateWindowAgg(SStreamStateAggOperatorInfo* pInfo, SSDataBlock* pSDataBlock, SResultWindowInfo* pCurWin, SResultRow** pResult, int32_t startIndex, - int32_t winRows, int32_t numOutput, SOperatorInfo * pOperator) { + int32_t winRows, int32_t numOutput, SOperatorInfo* pOperator) { return doOneWindowAggImpl(pInfo->primaryTsIndex, &pInfo->binfo, &pInfo->streamAggSup, &pInfo->twAggSup.timeWindowData, pSDataBlock, pCurWin, pResult, startIndex, winRows, numOutput, pOperator); } @@ -2788,7 +2786,7 @@ int32_t getNumCompactWindow(SArray* pWinInfos, int32_t startIndex, int64_t gap) void compactTimeWindow(SStreamSessionAggOperatorInfo* pInfo, int32_t startIndex, int32_t num, uint64_t groupId, int32_t numOfOutput, SHashObj* pStUpdated, SHashObj* pStDeleted, SOperatorInfo* pOperator) { - SExprSupp* pSup = &pOperator->exprSupp; + SExprSupp* pSup = &pOperator->exprSupp; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SResultWindowInfo* pCurWin = taosArrayGet(pInfo->streamAggSup.pCurWins, startIndex); @@ -2819,8 +2817,8 @@ typedef struct SWinRes { uint64_t groupId; } SWinRes; -static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBlock, - SHashObj* pStUpdated, SHashObj* pStDeleted, bool hasEndTs) { +static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBlock, SHashObj* pStUpdated, + SHashObj* pStDeleted, bool hasEndTs) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SStreamSessionAggOperatorInfo* pInfo = pOperator->info; bool masterScan = true; @@ -2838,14 +2836,14 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData if (pSDataBlock->pDataBlock != NULL) { SColumnInfoData* pStartTsCol = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); - startTsCols = (int64_t*) pStartTsCol->pData; + startTsCols = (int64_t*)pStartTsCol->pData; SColumnInfoData* pEndTsCol = NULL; if (hasEndTs) { pEndTsCol = taosArrayGet(pSDataBlock->pDataBlock, pInfo->endTsIndex); } else { pEndTsCol = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex); } - endTsCols = (int64_t*) pEndTsCol->pData; + endTsCols = (int64_t*)pEndTsCol->pData; } else { return; } @@ -2853,10 +2851,9 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData SStreamAggSupporter* pAggSup = &pInfo->streamAggSup; for (int32_t i = 0; i < pSDataBlock->info.rows;) { int32_t winIndex = 0; - SResultWindowInfo* pCurWin = getSessionTimeWindow(pAggSup, startTsCols[i], - endTsCols[i], groupId, gap, &winIndex); - winRows = updateSessionWindowInfo(pCurWin, startTsCols, endTsCols, - pSDataBlock->info.rows, i, pInfo->gap, pStDeleted); + SResultWindowInfo* pCurWin = getSessionTimeWindow(pAggSup, startTsCols[i], endTsCols[i], groupId, gap, &winIndex); + winRows = + updateSessionWindowInfo(pCurWin, startTsCols, endTsCols, pSDataBlock->info.rows, i, pInfo->gap, pStDeleted); code = doOneWindowAgg(pInfo, pSDataBlock, pCurWin, &pResult, i, winRows, numOfOutput, pOperator); if (code != TSDB_CODE_SUCCESS || pResult == NULL) { longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -2879,14 +2876,15 @@ static void doStreamSessionAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSData } } -static void doClearSessionWindows(SStreamAggSupporter* pAggSup, SExprSupp* pSup, SSDataBlock* pBlock, - int32_t tsIndex, int32_t numOfOutput, int64_t gap, SArray* result) { +static void doClearSessionWindows(SStreamAggSupporter* pAggSup, SExprSupp* pSup, SSDataBlock* pBlock, int32_t tsIndex, + int32_t numOfOutput, int64_t gap, SArray* result) { SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, tsIndex); TSKEY* tsCols = (TSKEY*)pColDataInfo->pData; int32_t step = 0; for (int32_t i = 0; i < pBlock->info.rows; i += step) { int32_t winIndex = 0; - SResultWindowInfo* pCurWin = getSessionTimeWindow(pAggSup, tsCols[i], INT64_MIN, pBlock->info.groupId, gap, &winIndex); + SResultWindowInfo* pCurWin = + getSessionTimeWindow(pAggSup, tsCols[i], INT64_MIN, pBlock->info.groupId, gap, &winIndex); step = updateSessionWindowInfo(pCurWin, tsCols, NULL, pBlock->info.rows, i, gap, NULL); ASSERT(isInWindow(pCurWin, tsCols[i], gap)); doClearWindowImpl(&pCurWin->pos, pAggSup->pResultBuf, pSup, numOfOutput); @@ -2936,7 +2934,7 @@ void doBuildDeleteDataBlock(SHashObj* pStDeleted, SSDataBlock* pBlock, void** It static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWinArray, int32_t groupId, int32_t numOfOutput, SOperatorInfo* pOperator) { - SExprSupp* pSup = &pOperator->exprSupp; + SExprSupp* pSup = &pOperator->exprSupp; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; int32_t size = taosArrayGetSize(pWinArray); @@ -2955,7 +2953,7 @@ static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWin int32_t chWinSize = taosArrayGetSize(pChWins); int32_t index = binarySearch(pChWins, chWinSize, pParentWin->win.skey, TSDB_ORDER_DESC, getSessionWindowEndkey); if (index < 0) { - index = 0; + index = 0; } for (int32_t k = index; k < chWinSize; k++) { SResultWindowInfo* pcw = taosArrayGet(pChWins, k); @@ -2976,15 +2974,14 @@ typedef SResultWindowInfo* (*__get_win_info_)(void*); SResultWindowInfo* getResWinForSession(void* pData) { return (SResultWindowInfo*)pData; } SResultWindowInfo* getResWinForState(void* pData) { return &((SStateWindowInfo*)pData)->winInfo; } -int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArray* pClosed, - __get_win_info_ fn) { +int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArray* pClosed, __get_win_info_ fn) { // Todo(liuyao) save window to tdb - void **pIte = NULL; + void** pIte = NULL; size_t keyLen = 0; while ((pIte = taosHashIterate(pHashMap, pIte)) != NULL) { uint64_t* pGroupId = taosHashGetKey(pIte, &keyLen); - SArray *pWins = (SArray *) (*pIte); - int32_t size = taosArrayGetSize(pWins); + SArray* pWins = (SArray*)(*pIte); + int32_t size = taosArrayGetSize(pWins); for (int32_t i = 0; i < size; i++) { void* pWin = taosArrayGet(pWins, i); SResultWindowInfo* pSeWin = fn(pWin); @@ -3005,9 +3002,9 @@ int32_t closeSessionWindow(SHashObj* pHashMap, STimeWindowAggSupp* pTwSup, SArra } int32_t getAllSessionWindow(SHashObj* pHashMap, SArray* pClosed, __get_win_info_ fn) { - void **pIte = NULL; + void** pIte = NULL; while ((pIte = taosHashIterate(pHashMap, pIte)) != NULL) { - SArray *pWins = (SArray *) (*pIte); + SArray* pWins = (SArray*)(*pIte); int32_t size = taosArrayGetSize(pWins); for (int32_t i = 0; i < size; i++) { void* pWin = taosArrayGet(pWins, i); @@ -3031,12 +3028,14 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { } else if (pOperator->status == OP_RES_TO_RETURN) { doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator); if (pInfo->pDelRes->info.rows > 0) { + /*printDataBlock(pInfo->pDelRes, "session del");*/ return pInfo->pDelRes; } doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf); if (pBInfo->pRes->info.rows == 0 || !hasDataInGroupInfo(&pInfo->groupResInfo)) { doSetOperatorCompleted(pOperator); } + /*printDataBlock(pBInfo->pRes, "session insert");*/ return pBInfo->pRes->info.rows == 0 ? NULL : pBInfo->pRes; } @@ -3052,7 +3051,8 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { if (pBlock->info.type == STREAM_REPROCESS) { SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo)); - doClearSessionWindows(&pInfo->streamAggSup, &pOperator->exprSupp, pBlock, 0, pOperator->exprSupp.numOfExprs, pInfo->gap, pWins); + doClearSessionWindows(&pInfo->streamAggSup, &pOperator->exprSupp, pBlock, 0, pOperator->exprSupp.numOfExprs, + pInfo->gap, pWins); if (IS_FINAL_OP(pInfo)) { int32_t childIndex = getChildIndex(pBlock); SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex); @@ -3076,13 +3076,14 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { int32_t size = taosArrayGetSize(pInfo->pChildren); // if chIndex + 1 - size > 0, add new child for (int32_t i = 0; i < chIndex + 1 - size; i++) { - SOperatorInfo* pChildOp = createStreamFinalSessionAggOperatorInfo(NULL, pInfo->pPhyNode, pOperator->pTaskInfo, 0); + SOperatorInfo* pChildOp = + createStreamFinalSessionAggOperatorInfo(NULL, pInfo->pPhyNode, pOperator->pTaskInfo, 0); if (!pChildOp) { longjmp(pOperator->pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } taosArrayPush(pInfo->pChildren, &pChildOp); } - SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, chIndex); + SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, chIndex); setInputDataBlock(pChildOp, pChildOp->exprSupp.pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true); doStreamSessionAggImpl(pChildOp, pBlock, NULL, NULL, true); } @@ -3093,27 +3094,27 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) { // restore the value pOperator->status = OP_RES_TO_RETURN; - closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, - getResWinForSession); + closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, getResWinForSession); copyUpdateResult(pStUpdated, pUpdated); taosHashCleanup(pStUpdated); - finalizeUpdatedResult(pSup->numOfExprs, pInfo->streamAggSup.pResultBuf, pUpdated, - pSup->rowEntryInfoOffset); + finalizeUpdatedResult(pSup->numOfExprs, pInfo->streamAggSup.pResultBuf, pUpdated, pSup->rowEntryInfoOffset); initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated); blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity); doBuildDeleteDataBlock(pInfo->pStDeleted, pInfo->pDelRes, &pInfo->pDelIterator); if (pInfo->pDelRes->info.rows > 0) { + /*printDataBlock(pInfo->pDelRes, "session del");*/ return pInfo->pDelRes; } doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf); + /*printDataBlock(pBInfo->pRes, "session insert");*/ return pBInfo->pRes->info.rows == 0 ? NULL : pBInfo->pRes; } static void clearStreamSessionOperator(SStreamSessionAggOperatorInfo* pInfo) { - void **pIte = NULL; + void** pIte = NULL; while ((pIte = taosHashIterate(pInfo->streamAggSup.pResultRows, pIte)) != NULL) { - SArray *pWins = (SArray *) (*pIte); + SArray* pWins = (SArray*)(*pIte); int32_t size = taosArrayGetSize(pWins); for (int32_t i = 0; i < size; i++) { SResultWindowInfo* pWin = (SResultWindowInfo*)taosArrayGet(pWins, i); @@ -3139,7 +3140,7 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) { SOptrBasicInfo* pBInfo = &pInfo->binfo; TSKEY maxTs = INT64_MIN; SExprSupp* pSup = &pOperator->exprSupp; - + if (pOperator->status == OP_EXEC_DONE) { return NULL; } else if (pOperator->status == OP_RES_TO_RETURN) { @@ -3221,8 +3222,8 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) { return pBInfo->pRes->info.rows == 0 ? NULL : pBInfo->pRes; } -SOperatorInfo* createStreamFinalSessionAggOperatorInfo(SOperatorInfo* downstream, - SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, int32_t numOfChild) { +SOperatorInfo* createStreamFinalSessionAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, + SExecTaskInfo* pTaskInfo, int32_t numOfChild) { int32_t code = TSDB_CODE_OUT_OF_MEMORY; SOperatorInfo* pOperator = createStreamSessionAggOperatorInfo(downstream, pPhyNode, pTaskInfo); if (pOperator == NULL) { @@ -3240,15 +3241,14 @@ SOperatorInfo* createStreamFinalSessionAggOperatorInfo(SOperatorInfo* downstream blockDataEnsureCapacity(pInfo->pUpdateRes, 128); pOperator->name = "StreamSessionSemiAggOperator"; pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doStreamSessionSemiAgg, NULL, NULL, destroyStreamSessionAggOperatorInfo, - aggEncodeResultRow, aggDecodeResultRow, NULL); + createOperatorFpSet(operatorDummyOpenFn, doStreamSessionSemiAgg, NULL, NULL, + destroyStreamSessionAggOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL); } pOperator->operatorType = pPhyNode->type; if (numOfChild > 0) { pInfo->pChildren = taosArrayInit(numOfChild, sizeof(void*)); for (int32_t i = 0; i < numOfChild; i++) { - SOperatorInfo* pChild = - createStreamFinalSessionAggOperatorInfo(NULL, pPhyNode, pTaskInfo, 0); + SOperatorInfo* pChild = createStreamFinalSessionAggOperatorInfo(NULL, pPhyNode, pTaskInfo, 0); if (pChild == NULL) { goto _error; } @@ -3366,8 +3366,8 @@ SStateWindowInfo* getStateWindowByTs(SStreamAggSupporter* pAggSup, TSKEY ts, uin return NULL; } -SStateWindowInfo* getStateWindow(SStreamAggSupporter* pAggSup, TSKEY ts, - uint64_t groupId, char* pKeyData, SColumn* pCol, int32_t* pIndex) { +SStateWindowInfo* getStateWindow(SStreamAggSupporter* pAggSup, TSKEY ts, uint64_t groupId, char* pKeyData, + SColumn* pCol, int32_t* pIndex) { SArray* pWinInfos = getWinInfos(pAggSup, groupId); pAggSup->pCurWins = pWinInfos; int32_t size = taosArrayGetSize(pWinInfos); @@ -3499,11 +3499,10 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl char* pKeyData = colDataGetData(pKeyColInfo, i); int32_t winIndex = 0; bool allEqual = true; - SStateWindowInfo* pCurWin = - getStateWindow(pAggSup, tsCols[i], pSDataBlock->info.groupId, pKeyData, - &pInfo->stateCol, &winIndex); - winRows = updateStateWindowInfo(pAggSup->pCurWins, winIndex, tsCols, pKeyColInfo, - pSDataBlock->info.rows, i, &allEqual, pInfo->pSeDeleted); + SStateWindowInfo* pCurWin = + getStateWindow(pAggSup, tsCols[i], pSDataBlock->info.groupId, pKeyData, &pInfo->stateCol, &winIndex); + winRows = updateStateWindowInfo(pAggSup->pCurWins, winIndex, tsCols, pKeyColInfo, pSDataBlock->info.rows, i, + &allEqual, pInfo->pSeDeleted); if (!allEqual) { taosArrayPush(pAggSup->pScanWindow, &pCurWin->winInfo.win); taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition)); @@ -3517,8 +3516,7 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl pCurWin->winInfo.isClosed = false; if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) { SWinRes value = {.ts = pCurWin->winInfo.win.skey, .groupId = groupId}; - code = taosHashPut(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition), - &value, sizeof(SWinRes)); + code = taosHashPut(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition), &value, sizeof(SWinRes)); if (code != TSDB_CODE_SUCCESS) { longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -3532,7 +3530,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) { return NULL; } - SExprSupp* pSup = &pOperator->exprSupp; + SExprSupp* pSup = &pOperator->exprSupp; SStreamStateAggOperatorInfo* pInfo = pOperator->info; SOptrBasicInfo* pBInfo = &pInfo->binfo; if (pOperator->status == OP_RES_TO_RETURN) { @@ -3574,8 +3572,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) { // restore the value pOperator->status = OP_RES_TO_RETURN; - closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, - getResWinForState); + closeSessionWindow(pInfo->streamAggSup.pResultRows, &pInfo->twAggSup, pUpdated, getResWinForState); copyUpdateResult(pSeUpdated, pUpdated); taosHashCleanup(pSeUpdated); @@ -3646,6 +3643,7 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys pInfo->pSeDeleted = taosHashInit(64, hashFn, true, HASH_NO_LOCK); pInfo->pDelIterator = NULL; pInfo->pDelRes = createOneDataBlock(pResBlock, false); + pInfo->pDelRes->info.type = STREAM_DELETE; blockDataEnsureCapacity(pInfo->pDelRes, 64); pInfo->pChildren = NULL; @@ -3674,48 +3672,48 @@ _error: return NULL; } -typedef struct SMergeIntervalAggOperatorInfo { +typedef struct SMergeAlignedIntervalAggOperatorInfo { SIntervalAggOperatorInfo intervalAggOperatorInfo; bool hasGroupId; uint64_t groupId; SSDataBlock* prefetchedBlock; bool inputBlocksFinished; -} SMergeIntervalAggOperatorInfo; +} SMergeAlignedIntervalAggOperatorInfo; -void destroyMergeIntervalOperatorInfo(void* param, int32_t numOfOutput) { - SMergeIntervalAggOperatorInfo* miaInfo = (SMergeIntervalAggOperatorInfo*)param; +void destroyMergeAlignedIntervalOperatorInfo(void* param, int32_t numOfOutput) { + SMergeAlignedIntervalAggOperatorInfo* miaInfo = (SMergeAlignedIntervalAggOperatorInfo*)param; destroyIntervalOperatorInfo(&miaInfo->intervalAggOperatorInfo, numOfOutput); } -static int32_t outputMergeIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t tableGroupId, SSDataBlock* pResultBlock, TSKEY wstartTs) { - SMergeIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info; - SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; - SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; +static int32_t outputMergeAlignedIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t tableGroupId, + SSDataBlock* pResultBlock, TSKEY wstartTs) { + SMergeAlignedIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info; + SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; + SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; SExprSupp* pSup = &pOperatorInfo->exprSupp; - bool ascScan = (iaInfo->order == TSDB_ORDER_ASC); + bool ascScan = (iaInfo->order == TSDB_ORDER_ASC); SET_RES_WINDOW_KEY(iaInfo->aggSup.keyBuf, &wstartTs, TSDB_KEYSIZE, tableGroupId); SResultRowPosition* p1 = (SResultRowPosition*)taosHashGet(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE)); ASSERT(p1 != NULL); - finalizeResultRowIntoResultDataBlock(iaInfo->aggSup.pResultBuf, p1, pSup->pCtx, pSup->pExprInfo, - pSup->numOfExprs, pSup->rowEntryInfoOffset, pResultBlock, - pTaskInfo); + finalizeResultRowIntoResultDataBlock(iaInfo->aggSup.pResultBuf, p1, pSup->pCtx, pSup->pExprInfo, pSup->numOfExprs, + pSup->rowEntryInfoOffset, pResultBlock, pTaskInfo); taosHashRemove(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE)); return 0; } -static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pBlock, - int32_t scanFlag, SSDataBlock* pResultBlock) { - SMergeIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info; - SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; +static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, + SSDataBlock* pBlock, int32_t scanFlag, SSDataBlock* pResultBlock) { + SMergeAlignedIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info; + SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; - SExprSupp* pSup = &pOperatorInfo->exprSupp; + SExprSupp* pSup = &pOperatorInfo->exprSupp; int32_t startPos = 0; int32_t numOfOutput = pSup->numOfExprs; @@ -3726,18 +3724,18 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* STimeWindow win; win.skey = blockStartTs; - win.ekey = taosTimeAdd(win.skey, iaInfo->interval.interval, iaInfo->interval.intervalUnit, iaInfo->interval.precision) - 1; + win.ekey = + taosTimeAdd(win.skey, iaInfo->interval.interval, iaInfo->interval.intervalUnit, iaInfo->interval.precision) - 1; - //TODO: remove the hash table usage (groupid + winkey => result row position) - int32_t ret = - setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx, - numOfOutput, pSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); + // TODO: remove the hash table (groupid + winkey => result row position) + int32_t ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, + pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } - TSKEY currTs = blockStartTs; - TSKEY currPos = startPos; + TSKEY currTs = blockStartTs; + TSKEY currPos = startPos; STimeWindow currWin = win; while (1) { ++currPos; @@ -3748,39 +3746,41 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* continue; } else { updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &currWin, true); - doApplyFunctions(pTaskInfo, pSup->pCtx, &currWin, &iaInfo->twAggSup.timeWindowData, startPos, - currPos - startPos, tsCols, pBlock->info.rows, numOfOutput, iaInfo->order); + doApplyFunctions(pTaskInfo, pSup->pCtx, &currWin, &iaInfo->twAggSup.timeWindowData, startPos, currPos - startPos, + tsCols, pBlock->info.rows, numOfOutput, iaInfo->order); - outputMergeIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, currTs); + outputMergeAlignedIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, currTs); currTs = tsCols[currPos]; currWin.skey = currTs; - currWin.ekey = taosTimeAdd(currWin.skey, iaInfo->interval.interval, iaInfo->interval.intervalUnit, iaInfo->interval.precision) - 1; + currWin.ekey = taosTimeAdd(currWin.skey, iaInfo->interval.interval, iaInfo->interval.intervalUnit, + iaInfo->interval.precision) - + 1; startPos = currPos; - ret = setTimeWindowOutputBuf(pResultRowInfo, &currWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx, - numOfOutput, pSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); + ret = setTimeWindowOutputBuf(pResultRowInfo, &currWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, + pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } } } updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &currWin, true); - doApplyFunctions(pTaskInfo, pSup->pCtx, &currWin, &iaInfo->twAggSup.timeWindowData, startPos, - currPos - startPos, tsCols, pBlock->info.rows, numOfOutput, iaInfo->order); + doApplyFunctions(pTaskInfo, pSup->pCtx, &currWin, &iaInfo->twAggSup.timeWindowData, startPos, currPos - startPos, + tsCols, pBlock->info.rows, numOfOutput, iaInfo->order); - outputMergeIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, currTs); + outputMergeAlignedIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, currTs); } -static SSDataBlock* doMergeIntervalAgg(SOperatorInfo* pOperator) { +static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - SMergeIntervalAggOperatorInfo* miaInfo = pOperator->info; - SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; + SMergeAlignedIntervalAggOperatorInfo* miaInfo = pOperator->info; + SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; if (pOperator->status == OP_EXEC_DONE) { return NULL; } - SExprSupp* pSup = &pOperator->exprSupp; + SExprSupp* pSup = &pOperator->exprSupp; SSDataBlock* pRes = iaInfo->binfo.pRes; blockDataCleanup(pRes); blockDataEnsureCapacity(pRes, pOperator->resultInfo.capacity); @@ -3795,6 +3795,7 @@ static SSDataBlock* doMergeIntervalAgg(SOperatorInfo* pOperator) { } else { pBlock = miaInfo->prefetchedBlock; miaInfo->groupId = pBlock->info.groupId; + miaInfo->prefetchedBlock = NULL; } if (pBlock == NULL) { @@ -3812,6 +3813,276 @@ static SSDataBlock* doMergeIntervalAgg(SOperatorInfo* pOperator) { getTableScanInfo(pOperator, &iaInfo->order, &scanFlag); setInputDataBlock(pOperator, pSup->pCtx, pBlock, iaInfo->order, scanFlag, true); + doMergeAlignedIntervalAggImpl(pOperator, &iaInfo->binfo.resultRowInfo, pBlock, scanFlag, pRes); + + if (pRes->info.rows >= pOperator->resultInfo.threshold) { + break; + } + } + + pRes->info.groupId = miaInfo->groupId; + } + + if (pRes->info.rows == 0) { + doSetOperatorCompleted(pOperator); + } + + size_t rows = pRes->info.rows; + pOperator->resultInfo.totalRows += rows; + return (rows == 0) ? NULL : pRes; +} + +SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, + int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval, + int32_t primaryTsSlotId, SExecTaskInfo* pTaskInfo) { + SMergeAlignedIntervalAggOperatorInfo* miaInfo = taosMemoryCalloc(1, sizeof(SMergeAlignedIntervalAggOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + if (miaInfo == NULL || pOperator == NULL) { + goto _error; + } + + SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; + SExprSupp* pSup = &pOperator->exprSupp; + + iaInfo->win = pTaskInfo->window; + iaInfo->order = TSDB_ORDER_ASC; + iaInfo->interval = *pInterval; + iaInfo->execModel = pTaskInfo->execModel; + iaInfo->primaryTsIndex = primaryTsSlotId; + + size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; + initResultSizeInfo(pOperator, 4096); + + int32_t code = + initAggInfo(&pOperator->exprSupp, &iaInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str); + initBasicInfo(&iaInfo->binfo, pResBlock); + + initExecTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &iaInfo->win); + + iaInfo->timeWindowInterpo = timeWindowinterpNeeded(pSup->pCtx, numOfCols, iaInfo); + if (iaInfo->timeWindowInterpo) { + iaInfo->binfo.resultRowInfo.openWindow = tdListNew(sizeof(SResultRowPosition)); + } + + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + initResultRowInfo(&iaInfo->binfo.resultRowInfo); + + pOperator->name = "TimeMergeAlignedIntervalAggOperator"; + pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL; + pOperator->blocking = false; + pOperator->status = OP_NOT_OPENED; + pOperator->exprSupp.pExprInfo = pExprInfo; + pOperator->pTaskInfo = pTaskInfo; + pOperator->exprSupp.numOfExprs = numOfCols; + pOperator->info = miaInfo; + + pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doMergeAlignedIntervalAgg, NULL, NULL, + destroyMergeAlignedIntervalOperatorInfo, NULL, NULL, NULL); + + code = appendDownstream(pOperator, &downstream, 1); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + return pOperator; + +_error: + destroyMergeAlignedIntervalOperatorInfo(miaInfo, numOfCols); + taosMemoryFreeClear(miaInfo); + taosMemoryFreeClear(pOperator); + pTaskInfo->code = code; + return NULL; +} + +//===================================================================================================================== +// merge interval operator +typedef struct SMergeIntervalAggOperatorInfo { + SIntervalAggOperatorInfo intervalAggOperatorInfo; + + SHashObj* groupIntervalHash; + bool hasGroupId; + uint64_t groupId; + SSDataBlock* prefetchedBlock; + bool inputBlocksFinished; +} SMergeIntervalAggOperatorInfo; + +void destroyMergeIntervalOperatorInfo(void* param, int32_t numOfOutput) { + SMergeIntervalAggOperatorInfo* miaInfo = (SMergeIntervalAggOperatorInfo*)param; + taosHashCleanup(miaInfo->groupIntervalHash); + destroyIntervalOperatorInfo(&miaInfo->intervalAggOperatorInfo, numOfOutput); +} + +static int32_t outputPrevIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t tableGroupId, SSDataBlock* pResultBlock, + STimeWindow* newWin) { + SMergeIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info; + SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; + SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; + bool ascScan = (iaInfo->order == TSDB_ORDER_ASC); + SExprSupp* pExprSup = &pOperatorInfo->exprSupp; + + STimeWindow* prevWin = taosHashGet(miaInfo->groupIntervalHash, &tableGroupId, sizeof(tableGroupId)); + if (prevWin == NULL) { + taosHashPut(miaInfo->groupIntervalHash, &tableGroupId, sizeof(tableGroupId), newWin, sizeof(STimeWindow)); + return 0; + } + + if (newWin == NULL || (ascScan && newWin->skey > prevWin->ekey || (!ascScan) && newWin->skey < prevWin->ekey)) { + SET_RES_WINDOW_KEY(iaInfo->aggSup.keyBuf, &prevWin->skey, TSDB_KEYSIZE, tableGroupId); + SResultRowPosition* p1 = (SResultRowPosition*)taosHashGet(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, + GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE)); + ASSERT(p1 != NULL); + + finalizeResultRowIntoResultDataBlock(iaInfo->aggSup.pResultBuf, p1, pExprSup->pCtx, pExprSup->pExprInfo, + pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset, pResultBlock, pTaskInfo); + taosHashRemove(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE)); + if (newWin == NULL) { + taosHashRemove(miaInfo->groupIntervalHash, &tableGroupId, sizeof(tableGroupId)); + } else { + taosHashPut(miaInfo->groupIntervalHash, &tableGroupId, sizeof(tableGroupId), newWin, sizeof(STimeWindow)); + } + } + + return 0; +} + +static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pBlock, + int32_t scanFlag, SSDataBlock* pResultBlock) { + SMergeIntervalAggOperatorInfo* miaInfo = pOperatorInfo->info; + SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; + + SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo; + SExprSupp* pExprSup = &pOperatorInfo->exprSupp; + + int32_t startPos = 0; + int32_t numOfOutput = pExprSup->numOfExprs; + int64_t* tsCols = extractTsCol(pBlock, iaInfo); + uint64_t tableGroupId = pBlock->info.groupId; + bool ascScan = (iaInfo->order == TSDB_ORDER_ASC); + TSKEY blockStartTs = getStartTsKey(&pBlock->info.window, tsCols); + SResultRow* pResult = NULL; + + STimeWindow win = getActiveTimeWindow(iaInfo->aggSup.pResultBuf, pResultRowInfo, blockStartTs, &iaInfo->interval, + iaInfo->interval.precision, &iaInfo->win); + + int32_t ret = + setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx, + numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); + if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { + longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + TSKEY ekey = ascScan ? win.ekey : win.skey; + int32_t forwardRows = + getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, iaInfo->order); + ASSERT(forwardRows > 0); + + // prev time window not interpolation yet. + if (iaInfo->timeWindowInterpo) { + SResultRowPosition pos = addToOpenWindowList(pResultRowInfo, pResult); + doInterpUnclosedTimeWindow(pOperatorInfo, numOfOutput, pResultRowInfo, pBlock, scanFlag, tsCols, &pos); + + // restore current time window + ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pExprSup->pCtx, + numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); + if (ret != TSDB_CODE_SUCCESS) { + longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + // window start key interpolation + doWindowBorderInterpolation(iaInfo, pBlock, pResult, &win, startPos, forwardRows, pExprSup); + } + + updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &win, true); + doApplyFunctions(pTaskInfo, pExprSup->pCtx, &win, &iaInfo->twAggSup.timeWindowData, startPos, forwardRows, tsCols, + pBlock->info.rows, numOfOutput, iaInfo->order); + doCloseWindow(pResultRowInfo, iaInfo, pResult); + + // output previous interval results after this interval (&win) is closed + outputPrevIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, &win); + + STimeWindow nextWin = win; + while (1) { + int32_t prevEndPos = forwardRows - 1 + startPos; + startPos = getNextQualifiedWindow(&iaInfo->interval, &nextWin, &pBlock->info, tsCols, prevEndPos, iaInfo->order); + if (startPos < 0) { + break; + } + + // null data, failed to allocate more memory buffer + int32_t code = + setTimeWindowOutputBuf(pResultRowInfo, &nextWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, + pExprSup->pCtx, numOfOutput, pExprSup->rowEntryInfoOffset, &iaInfo->aggSup, pTaskInfo); + if (code != TSDB_CODE_SUCCESS || pResult == NULL) { + longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + ekey = ascScan ? nextWin.ekey : nextWin.skey; + forwardRows = + getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, iaInfo->order); + + // window start(end) key interpolation + doWindowBorderInterpolation(iaInfo, pBlock, pResult, &nextWin, startPos, forwardRows, pExprSup); + + updateTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &nextWin, true); + doApplyFunctions(pTaskInfo, pExprSup->pCtx, &nextWin, &iaInfo->twAggSup.timeWindowData, startPos, forwardRows, + tsCols, pBlock->info.rows, numOfOutput, iaInfo->order); + doCloseWindow(pResultRowInfo, iaInfo, pResult); + + // output previous interval results after this interval (&nextWin) is closed + outputPrevIntervalResult(pOperatorInfo, tableGroupId, pResultBlock, &nextWin); + } + + if (iaInfo->timeWindowInterpo) { + saveDataBlockLastRow(iaInfo->pPrevValues, pBlock, iaInfo->pInterpCols); + } +} + +static SSDataBlock* doMergeIntervalAgg(SOperatorInfo* pOperator) { + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + + SMergeIntervalAggOperatorInfo* miaInfo = pOperator->info; + SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; + SExprSupp* pExpSupp = &pOperator->exprSupp; + + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } + + SSDataBlock* pRes = iaInfo->binfo.pRes; + blockDataCleanup(pRes); + blockDataEnsureCapacity(pRes, pOperator->resultInfo.capacity); + + if (!miaInfo->inputBlocksFinished) { + SOperatorInfo* downstream = pOperator->pDownstream[0]; + int32_t scanFlag = MAIN_SCAN; + while (1) { + SSDataBlock* pBlock = NULL; + if (miaInfo->prefetchedBlock == NULL) { + pBlock = downstream->fpSet.getNextFn(downstream); + } else { + pBlock = miaInfo->prefetchedBlock; + miaInfo->groupId = pBlock->info.groupId; + miaInfo->prefetchedBlock = NULL; + } + + if (pBlock == NULL) { + miaInfo->inputBlocksFinished = true; + break; + } + + if (!miaInfo->hasGroupId) { + miaInfo->hasGroupId = true; + miaInfo->groupId = pBlock->info.groupId; + } else if (miaInfo->groupId != pBlock->info.groupId) { + miaInfo->prefetchedBlock = pBlock; + break; + } + + getTableScanInfo(pOperator, &iaInfo->order, &scanFlag); + setInputDataBlock(pOperator, pExpSupp->pCtx, pBlock, iaInfo->order, scanFlag, true); doMergeIntervalAggImpl(pOperator, &iaInfo->binfo.resultRowInfo, pBlock, scanFlag, pRes); if (pRes->info.rows >= pOperator->resultInfo.threshold) { @@ -3820,6 +4091,13 @@ static SSDataBlock* doMergeIntervalAgg(SOperatorInfo* pOperator) { } pRes->info.groupId = miaInfo->groupId; + } else { + void* p = taosHashIterate(miaInfo->groupIntervalHash, NULL); + if (p != NULL) { + size_t len = 0; + uint64_t* pKey = taosHashGetKey(p, &len); + outputPrevIntervalResult(pOperator, *pKey, pRes, NULL); + } } if (pRes->info.rows == 0) { @@ -3841,29 +4119,30 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SExprI } SIntervalAggOperatorInfo* iaInfo = &miaInfo->intervalAggOperatorInfo; - SExprSupp* pSup = &pOperator->exprSupp; - iaInfo->win = pTaskInfo->window; - iaInfo->order = TSDB_ORDER_ASC; - iaInfo->interval = *pInterval; + iaInfo->win = pTaskInfo->window; + iaInfo->order = TSDB_ORDER_ASC; + iaInfo->interval = *pInterval; iaInfo->execModel = pTaskInfo->execModel; + iaInfo->primaryTsIndex = primaryTsSlotId; + SExprSupp* pExprSupp = &pOperator->exprSupp; + size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; initResultSizeInfo(pOperator, 4096); - int32_t code = initAggInfo(&pOperator->exprSupp, &iaInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str); + int32_t code = initAggInfo(pExprSupp, &iaInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str); initBasicInfo(&iaInfo->binfo, pResBlock); initExecTimeWindowInfo(&iaInfo->twAggSup.timeWindowData, &iaInfo->win); - iaInfo->timeWindowInterpo = timeWindowinterpNeeded(pSup->pCtx, numOfCols, iaInfo); + iaInfo->timeWindowInterpo = timeWindowinterpNeeded(pExprSupp->pCtx, numOfCols, iaInfo); if (iaInfo->timeWindowInterpo) { iaInfo->binfo.resultRowInfo.openWindow = tdListNew(sizeof(SResultRowPosition)); - } - - if (code != TSDB_CODE_SUCCESS) { - goto _error; + if (iaInfo->binfo.resultRowInfo.openWindow == NULL) { + goto _error; + } } initResultRowInfo(&iaInfo->binfo.resultRowInfo); @@ -3893,4 +4172,4 @@ _error: taosMemoryFreeClear(pOperator); pTaskInfo->code = code; return NULL; -} +} \ No newline at end of file diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 581935514e..1dd72fd83f 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -86,6 +86,7 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t page pSortHandle->pOrderedSource = taosArrayInit(4, POINTER_BYTES); pSortHandle->cmpParam.orderInfo = pSortInfo; + pSortHandle->cmpParam.cmpGroupId = false; tsortSetComparFp(pSortHandle, msortComparFn); @@ -374,6 +375,12 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) { SSDataBlock* pLeftBlock = pLeftSource->src.pBlock; SSDataBlock* pRightBlock = pRightSource->src.pBlock; + if (pParam->cmpGroupId) { + if (pLeftBlock->info.groupId != pRightBlock->info.groupId) { + return pLeftBlock->info.groupId < pRightBlock->info.groupId ? -1 : 1; + } + } + for(int32_t i = 0; i < pInfo->size; ++i) { SBlockOrderInfo* pOrder = TARRAY_GET_ELEM(pInfo, i); SColumnInfoData* pLeftColInfoData = TARRAY_GET_ELEM(pLeftBlock->pDataBlock, pOrder->slotId); @@ -680,6 +687,11 @@ int32_t tsortSetComparFp(SSortHandle* pHandle, _sort_merge_compar_fn_t fp) { return TSDB_CODE_SUCCESS; } +int32_t tsortSetCompareGroupId(SSortHandle* pHandle, bool compareGroupId) { + pHandle->cmpParam.cmpGroupId = compareGroupId; + return TSDB_CODE_SUCCESS; +} + STupleHandle* tsortNextTuple(SSortHandle* pHandle) { if (pHandle->cmpParam.numOfSources == pHandle->numOfCompletedSources) { return NULL; diff --git a/source/libs/function/inc/builtinsimpl.h b/source/libs/function/inc/builtinsimpl.h index e691d562c6..4d2f926c12 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -101,6 +101,11 @@ bool getDerivativeFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); bool derivativeFuncSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResInfo); int32_t derivativeFunction(SqlFunctionCtx *pCtx); +bool getIrateFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool irateFuncSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResInfo); +int32_t irateFunction(SqlFunctionCtx *pCtx); +int32_t irateFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); + bool getFirstLastFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); int32_t firstFunction(SqlFunctionCtx *pCtx); int32_t firstFunctionMerge(SqlFunctionCtx *pCtx); diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index cfad00f458..6baf45a5b3 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -978,6 +978,21 @@ static int32_t translateDerivative(SFunctionNode* pFunc, char* pErrBuf, int32_t return TSDB_CODE_SUCCESS; } +static int32_t translateIrate(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t colType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; + + if (!IS_NUMERIC_TYPE(colType)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes, .type = TSDB_DATA_TYPE_DOUBLE}; + return TSDB_CODE_SUCCESS; +} + static int32_t translateFirstLast(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { // first(col_list) will be rewritten as first(col) if (1 != LIST_LENGTH(pFunc->pParameterList)) { @@ -1796,6 +1811,16 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .processFunc = derivativeFunction, .finalizeFunc = functionFinalize }, + { + .name = "irate", + .type = FUNCTION_TYPE_IRATE, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC, + .translateFunc = translateIrate, + .getEnvFunc = getIrateFuncEnv, + .initFunc = irateFuncSetup, + .processFunc = irateFunction, + .finalizeFunc = irateFinalize + }, { .name = "last_row", .type = FUNCTION_TYPE_LAST_ROW, diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 076ae61460..d7ff03ec59 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -59,6 +59,12 @@ typedef struct STuplePos { int32_t offset; } STuplePos; +typedef struct SMinmaxResInfo { + bool assign; // assign the first value or not + int64_t v; + STuplePos tuplePos; +} SMinmaxResInfo; + typedef struct STopBotResItem { SVariant v; uint64_t uid; // it is a table uid, used to extract tag data during building of the final result for the tag data @@ -148,6 +154,12 @@ typedef struct SElapsedInfo { int64_t timeUnit; } SElapsedInfo; +typedef struct STwaInfo { + double dOutput; + SPoint1 p; + STimeWindow win; +} STwaInfo; + typedef struct SHistoFuncBin { double lower; double upper; @@ -195,13 +207,13 @@ typedef struct SMavgInfo { } SMavgInfo; typedef struct SSampleInfo { - int32_t samples; - int32_t totalPoints; - int32_t numSampled; - uint8_t colType; - int16_t colBytes; - char* data; - int64_t* timestamp; + int32_t samples; + int32_t totalPoints; + int32_t numSampled; + uint8_t colType; + int16_t colBytes; + char* data; + STuplePos* tuplePos; } SSampleInfo; typedef struct STailItem { @@ -234,6 +246,22 @@ typedef struct SUniqueInfo { char pItems[]; } SUniqueInfo; +typedef struct SDerivInfo { + double prevValue; // previous value + TSKEY prevTs; // previous timestamp + bool ignoreNegative; // ignore the negative value + int64_t tsWindow; // time window for derivative + bool valueSet; // the value has been set already +} SDerivInfo; + +typedef struct SRateInfo { + double firstValue; + TSKEY firstKey; + double lastValue; + TSKEY lastKey; + int8_t hasResult; // flag to denote has value +} SRateInfo; + #define SET_VAL(_info, numOfElem, res) \ do { \ if ((numOfElem) <= 0) { \ @@ -927,12 +955,6 @@ EFuncDataRequired statisDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWin return FUNC_DATA_REQUIRED_STATIS_LOAD; } -typedef struct SMinmaxResInfo { - bool assign; // assign the first value or not - int64_t v; - STuplePos tuplePos; -} SMinmaxResInfo; - bool minmaxFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) { if (!functionSetup(pCtx, pResultInfo)) { return false; // not initialized since it has been initialized @@ -1844,9 +1866,8 @@ int32_t leastSQRFunction(SqlFunctionCtx* pCtx) { } numOfElem++; LEASTSQR_CAL(param, x, plist, i, pInfo->stepVal); - - break; } + break; } case TSDB_DATA_TYPE_SMALLINT: { int16_t* plist = (int16_t*)pCol->pData; @@ -1871,7 +1892,6 @@ int32_t leastSQRFunction(SqlFunctionCtx* pCtx) { numOfElem++; LEASTSQR_CAL(param, x, plist, i, pInfo->stepVal); } - break; } @@ -4350,7 +4370,7 @@ bool getSampleFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { SColumnNode* pCol = (SColumnNode*)nodesListGetNode(pFunc->pParameterList, 0); SValueNode* pVal = (SValueNode*)nodesListGetNode(pFunc->pParameterList, 1); int32_t numOfSamples = pVal->datum.i; - pEnv->calcMemSize = sizeof(SSampleInfo) + numOfSamples * (pCol->node.resType.bytes + sizeof(int64_t)); + pEnv->calcMemSize = sizeof(SSampleInfo) + numOfSamples * (pCol->node.resType.bytes + sizeof(STuplePos)); return true; } @@ -4371,25 +4391,30 @@ bool sampleFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo) return false; } pInfo->data = (char*)pInfo + sizeof(SSampleInfo); - pInfo->timestamp = (int64_t*)((char*)pInfo + sizeof(SSampleInfo) + pInfo->samples * pInfo->colBytes); + pInfo->tuplePos = (STuplePos*)((char*)pInfo + sizeof(SSampleInfo) + pInfo->samples * pInfo->colBytes); return true; } -static void sampleAssignResult(SSampleInfo* pInfo, char* data, TSKEY ts, int32_t index) { +static void sampleAssignResult(SSampleInfo* pInfo, char* data, int32_t index) { assignVal(pInfo->data + index * pInfo->colBytes, data, pInfo->colBytes, pInfo->colType); - *(pInfo->timestamp + index) = ts; } -static void doReservoirSample(SSampleInfo* pInfo, char* data, TSKEY ts, int32_t index) { +static void doReservoirSample(SqlFunctionCtx* pCtx, SSampleInfo* pInfo, char* data, int32_t index) { pInfo->totalPoints++; if (pInfo->numSampled < pInfo->samples) { - sampleAssignResult(pInfo, data, ts, pInfo->numSampled); + sampleAssignResult(pInfo, data, pInfo->numSampled); + if (pCtx->subsidiaries.num > 0) { + saveTupleData(pCtx, index, pCtx->pSrcBlock, pInfo->tuplePos + pInfo->numSampled * sizeof(STuplePos)); + } pInfo->numSampled++; } else { int32_t j = taosRand() % (pInfo->totalPoints); if (j < pInfo->samples) { - sampleAssignResult(pInfo, data, ts, j); + sampleAssignResult(pInfo, data, j); + if (pCtx->subsidiaries.num > 0) { + copyTupleData(pCtx, index, pCtx->pSrcBlock, pInfo->tuplePos + j * sizeof(STuplePos)); + } } } } @@ -4400,11 +4425,6 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; - TSKEY* tsList = NULL; - if (pInput->pPTS != NULL) { - tsList = (int64_t*)pInput->pPTS->pData; - } - SColumnInfoData* pInputCol = pInput->pData[0]; for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; i += 1) { if (colDataIsNull_s(pInputCol, i)) { @@ -4412,7 +4432,7 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) { } char* data = colDataGetData(pInputCol, i); - doReservoirSample(pInfo, data, /*tsList[i]*/ 0, i); + doReservoirSample(pCtx, pInfo, data, i); } SET_VAL(pResInfo, pInfo->numSampled, pInfo->numSampled); @@ -4431,6 +4451,7 @@ int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { int32_t currentRow = pBlock->info.rows; for (int32_t i = 0; i < pInfo->numSampled; ++i) { colDataAppend(pCol, currentRow + i, pInfo->data + i * pInfo->colBytes, false); + setSelectivityValue(pCtx, pBlock, pInfo->tuplePos + i * sizeof(STuplePos), currentRow + i); } return pInfo->numSampled; @@ -4666,12 +4687,6 @@ int32_t uniqueFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return pResInfo->numOfRes; } -typedef struct STwaInfo { - double dOutput; - SPoint1 p; - STimeWindow win; -} STwaInfo; - bool getTwaFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv) { pEnv->calcMemSize = sizeof(STwaInfo); return true; @@ -5120,14 +5135,6 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return TSDB_CODE_SUCCESS; } -typedef struct SDerivInfo { - double prevValue; // previous value - TSKEY prevTs; // previous timestamp - bool ignoreNegative; // ignore the negative value - int64_t tsWindow; // time window for derivative - bool valueSet; // the value has been set already -} SDerivInfo; - bool getDerivativeFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv) { pEnv->calcMemSize = sizeof(SDerivInfo); return true; @@ -5222,6 +5229,117 @@ int32_t derivativeFunction(SqlFunctionCtx* pCtx) { return numOfElems; } +bool getIrateFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv) { + pEnv->calcMemSize = sizeof(SRateInfo); + return true; +} + +bool irateFuncSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) { + if (!functionSetup(pCtx, pResInfo)) { + return false; // not initialized since it has been initialized + } + + SRateInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); + + pInfo->firstKey = INT64_MIN; + pInfo->lastKey = INT64_MIN; + pInfo->firstValue = (double)INT64_MIN; + pInfo->lastValue = (double)INT64_MIN; + + pInfo->hasResult = 0; + return true; +} + +int32_t irateFunction(SqlFunctionCtx* pCtx) { + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); + SRateInfo* pRateInfo = GET_ROWCELL_INTERBUF(pResInfo); + + SInputColumnInfoData* pInput = &pCtx->input; + SColumnInfoData* pInputCol = pInput->pData[0]; + + SColumnInfoData* pOutput = (SColumnInfoData*)pCtx->pOutput; + + TSKEY* tsList = (int64_t*)pInput->pPTS->pData; + + int32_t numOfElems = 0; + int32_t type = pInputCol->info.type; + + for (int32_t i = pInput->startRowIndex; i < pInput->numOfRows + pInput->startRowIndex; i += 1) { + if (colDataIsNull_f(pInputCol->nullbitmap, i)) { + continue; + } + + numOfElems++; + + char* data = colDataGetData(pInputCol, i); + double v = 0; + GET_TYPED_DATA(v, double, type, data); + + if (INT64_MIN == pRateInfo->lastKey) { + pRateInfo->lastValue = v; + pRateInfo->lastKey = tsList[i]; + continue; + } + + if (tsList[i] > pRateInfo->lastKey) { + if ((INT64_MIN == pRateInfo->firstKey) || pRateInfo->lastKey > pRateInfo->firstKey) { + pRateInfo->firstValue = pRateInfo->lastValue; + pRateInfo->firstKey = pRateInfo->lastKey; + } + + pRateInfo->lastValue = v; + pRateInfo->lastKey = tsList[i]; + + continue; + } + + if ((INT64_MIN == pRateInfo->firstKey) || tsList[i] > pRateInfo->firstKey) { + pRateInfo->firstValue = v; + pRateInfo->firstKey = tsList[i]; + } + + } + + SET_VAL(pResInfo, numOfElems, 1); + return TSDB_CODE_SUCCESS; +} + +static double doCalcRate(const SRateInfo* pRateInfo, double tickPerSec) { + if ((INT64_MIN == pRateInfo->lastKey) || (INT64_MIN == pRateInfo->firstKey) || + (pRateInfo->firstKey >= pRateInfo->lastKey)) { + return 0.0; + } + + double diff = 0; + // If the previous value of the last is greater than the last value, only keep the last point instead of the delta + // value between two values. + diff = pRateInfo->lastValue; + if (diff >= pRateInfo->firstValue) { + diff -= pRateInfo->firstValue; + } + + int64_t duration = pRateInfo->lastKey - pRateInfo->firstKey; + if (duration == 0) { + return 0; + } + + return (duration > 0)? ((double)diff) / (duration/tickPerSec):0.0; +} + +int32_t irateFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { + int32_t slotId = pCtx->pExpr->base.resSchema.slotId; + SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); + + SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); + pResInfo->isNullRes = (pResInfo->numOfRes == 0) ? 1 : 0; + + SRateInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); + double result = doCalcRate(pInfo, 1000); + colDataAppend(pCol, pBlock->info.rows, (const char*)&result, pResInfo->isNullRes); + + return pResInfo->numOfRes; +} + int32_t interpFunction(SqlFunctionCtx* pCtx) { #if 0 int32_t fillType = (int32_t) pCtx->param[2].i64; diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index 710b01ce59..5fcf5e239c 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -186,6 +186,13 @@ bool fmIsInterpFunc(int32_t funcId) { return FUNCTION_TYPE_INTERP == funcMgtBuiltins[funcId].type; } +bool fmIsLastRowFunc(int32_t funcId) { + if (funcId < 0 || funcId >= funcMgtBuiltinsNum) { + return false; + } + return FUNCTION_TYPE_LAST_ROW == funcMgtBuiltins[funcId].type; +} + void fmFuncMgtDestroy() { void* m = gFunMgtService.pFuncNameHashTable; if (m != NULL && atomic_val_compare_exchange_ptr((void**)&gFunMgtService.pFuncNameHashTable, m, 0) == m) { diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index f6ae027e48..f6370be6f4 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -467,7 +467,7 @@ int32_t getUdfdPipeName(char* pipeName, int32_t size) { dnodeId[0] = '1'; } #ifdef _WIN32 - snprintf(pipeName, size, "%s%s", UDF_LISTEN_PIPE_NAME_PREFIX, dnodeId); + snprintf(pipeName, size, "%s.%x.%s", UDF_LISTEN_PIPE_NAME_PREFIX,MurmurHash3_32(tsDataDir, strlen(tsDataDir)), dnodeId); #else snprintf(pipeName, size, "%s/%s%s", tsDataDir, UDF_LISTEN_PIPE_NAME_PREFIX, dnodeId); #endif diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index 04d7e04b30..d6d55c6be0 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -35,12 +35,12 @@ #define INDEX_DATA_BOOL_NULL 0x02 #define INDEX_DATA_TINYINT_NULL 0x80 #define INDEX_DATA_SMALLINT_NULL 0x8000 -#define INDEX_DATA_INT_NULL 0x80000000L -#define INDEX_DATA_BIGINT_NULL 0x8000000000000000L +#define INDEX_DATA_INT_NULL 0x80000000LL +#define INDEX_DATA_BIGINT_NULL 0x8000000000000000LL #define INDEX_DATA_TIMESTAMP_NULL TSDB_DATA_BIGINT_NULL #define INDEX_DATA_FLOAT_NULL 0x7FF00000 // it is an NAN -#define INDEX_DATA_DOUBLE_NULL 0x7FFFFF0000000000L // an NAN +#define INDEX_DATA_DOUBLE_NULL 0x7FFFFF0000000000LL // an NAN #define INDEX_DATA_NCHAR_NULL 0xFFFFFFFF #define INDEX_DATA_BINARY_NULL 0xFF #define INDEX_DATA_JSON_NULL 0xFFFFFFFF diff --git a/source/libs/index/src/indexComm.c b/source/libs/index/src/indexComm.c index 99b49f97bd..383d47e9c1 100644 --- a/source/libs/index/src/indexComm.c +++ b/source/libs/index/src/indexComm.c @@ -25,12 +25,12 @@ #define INDEX_DATA_BOOL_NULL 0x02 #define INDEX_DATA_TINYINT_NULL 0x80 #define INDEX_DATA_SMALLINT_NULL 0x8000 -#define INDEX_DATA_INT_NULL 0x80000000L -#define INDEX_DATA_BIGINT_NULL 0x8000000000000000L +#define INDEX_DATA_INT_NULL 0x80000000LL +#define INDEX_DATA_BIGINT_NULL 0x8000000000000000LL #define INDEX_DATA_TIMESTAMP_NULL TSDB_DATA_BIGINT_NULL #define INDEX_DATA_FLOAT_NULL 0x7FF00000 // it is an NAN -#define INDEX_DATA_DOUBLE_NULL 0x7FFFFF0000000000L // an NAN +#define INDEX_DATA_DOUBLE_NULL 0x7FFFFF0000000000LL // an NAN #define INDEX_DATA_NCHAR_NULL 0xFFFFFFFF #define INDEX_DATA_BINARY_NULL 0xFF #define INDEX_DATA_JSON_NULL 0xFFFFFFFF diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 5eaca60ea5..0bde0d0581 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -557,6 +557,14 @@ static SNode* physiSessionCopy(const SSessionWinodwPhysiNode* pSrc, SSessionWino return (SNode*)pDst; } +static SNode* physiPartitionCopy(const SPartitionPhysiNode* pSrc, SPartitionPhysiNode* pDst) { + COPY_BASE_OBJECT_FIELD(node, physiNodeCopy); + CLONE_NODE_LIST_FIELD(pExprs); + CLONE_NODE_LIST_FIELD(pPartitionKeys); + CLONE_NODE_LIST_FIELD(pTargets); + return (SNode*)pDst; +} + static SNode* dataBlockDescCopy(const SDataBlockDescNode* pSrc, SDataBlockDescNode* pDst) { COPY_SCALAR_FIELD(dataBlockId); CLONE_NODE_LIST_FIELD(pSlots); @@ -694,7 +702,7 @@ SNode* nodesCloneNode(const SNode* pNode) { case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: return physiSysTableScanCopy((const SSystemTableScanPhysiNode*)pNode, (SSystemTableScanPhysiNode*)pDst); case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: - case QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: @@ -702,6 +710,8 @@ SNode* nodesCloneNode(const SNode* pNode) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION: return physiSessionCopy((const SSessionWinodwPhysiNode*)pNode, (SSessionWinodwPhysiNode*)pDst); + case QUERY_NODE_PHYSICAL_PLAN_PARTITION: + return physiPartitionCopy((const SPartitionPhysiNode*)pNode, (SPartitionPhysiNode*)pDst); default: break; } diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index bde5159087..10a933b00b 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -220,6 +220,8 @@ const char* nodesNodeName(ENodeType type) { return "PhysiSystemTableScan"; case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: return "PhysiBlockDistScan"; + case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: + return "PhysiLastRowScan"; case QUERY_NODE_PHYSICAL_PLAN_PROJECT: return "PhysiProject"; case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN: @@ -234,8 +236,8 @@ const char* nodesNodeName(ENodeType type) { return "PhysiSort"; case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: return "PhysiHashInterval"; - case QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL: - return "PhysiMergeInterval"; + case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: + return "PhysiMergeAlignedInterval"; case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: return "PhysiStreamInterval"; case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: @@ -4105,6 +4107,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { return logicPlanToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: + case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: return physiTagScanNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN: @@ -4125,7 +4128,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { case QUERY_NODE_PHYSICAL_PLAN_SORT: return physiSortNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: - case QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: @@ -4245,6 +4248,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { return jsonToLogicPlan(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: + case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: return jsonToPhysiTagScanNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN: @@ -4265,7 +4269,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { case QUERY_NODE_PHYSICAL_PLAN_SORT: return jsonToPhysiSortNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: - case QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index ebacf5574f..ff55195bee 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -273,6 +273,8 @@ SNode* nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SSystemTableScanPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: return makeNode(type, sizeof(SBlockDistScanPhysiNode)); + case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: + return makeNode(type, sizeof(SLastRowScanPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_PROJECT: return makeNode(type, sizeof(SProjectPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN: @@ -287,8 +289,8 @@ SNode* nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SSortPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: return makeNode(type, sizeof(SIntervalPhysiNode)); - case QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL: - return makeNode(type, sizeof(SMergeIntervalPhysiNode)); + case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: + return makeNode(type, sizeof(SMergeAlignedIntervalPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: return makeNode(type, sizeof(SStreamIntervalPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: @@ -655,7 +657,7 @@ void nodesDestroyNode(SNode* pNode) { break; case QUERY_NODE_SHOW_CREATE_TABLE_STMT: case QUERY_NODE_SHOW_CREATE_STABLE_STMT: - taosMemoryFreeClear(((SShowCreateTableStmt*)pNode)->pMeta); + taosMemoryFreeClear(((SShowCreateTableStmt*)pNode)->pCfg); break; case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT: // no pointer field case QUERY_NODE_KILL_CONNECTION_STMT: // no pointer field @@ -781,6 +783,7 @@ void nodesDestroyNode(SNode* pNode) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: + case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: destroyScanPhysiNode((SScanPhysiNode*)pNode); break; case QUERY_NODE_PHYSICAL_PLAN_PROJECT: { @@ -825,7 +828,7 @@ void nodesDestroyNode(SNode* pNode) { break; } case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL: - case QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL: + case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL: case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL: @@ -1354,6 +1357,17 @@ bool nodesIsRegularOp(const SOperatorNode* pOp) { return false; } +bool nodesIsBitwiseOp(const SOperatorNode* pOp) { + switch (pOp->opType) { + case OP_TYPE_BIT_AND: + case OP_TYPE_BIT_OR: + return true; + default: + break; + } + return false; +} + typedef struct SCollectColumnsCxt { int32_t errCode; const char* pTableAlias; diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 2d9bb49762..213e21cdcf 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -162,7 +162,7 @@ SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName); SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable); SNode* createShowTableDistributedStmt(SAstCreateContext* pCxt, SNode* pRealTable); SNode* createShowDnodeVariablesStmt(SAstCreateContext* pCxt, SNode* pDnodeId); -SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword); +SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo); SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t alterType, const SToken* pVal); SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName); SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort); @@ -171,12 +171,15 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName, SToken* pTableName, SNodeList* pCols, SNode* pOptions); SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding); -SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pIndexName, SToken* pTableName); +SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pIndexName); SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId); SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId); -SNode* createTopicOptions(SAstCreateContext* pCxt); -SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, - const SToken* pSubDbName, SNode* pRealTable); +SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, + SNode* pQuery); +SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, + const SToken* pSubDbName, bool withMeta); +SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, + SNode* pRealTable, bool withMeta); SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName); SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pCGroupId, const SToken* pTopicName); diff --git a/source/libs/parser/inc/parUtil.h b/source/libs/parser/inc/parUtil.h index e08f813c19..d06d6ec527 100644 --- a/source/libs/parser/inc/parUtil.h +++ b/source/libs/parser/inc/parUtil.h @@ -47,6 +47,7 @@ typedef struct SParseMetaCache { SHashObj* pUserAuth; // key is SUserAuthInfo serialized string, element is bool indicating whether or not to pass SHashObj* pUdf; // key is funcName, element is SFuncInfo* SHashObj* pTableIndex; // key is tbFName, element is SArray* + SHashObj* pTableCfg; // key is tbFName, element is STableCfg* SArray* pDnodes; // element is SEpSet bool dnodeRequired; } SParseMetaCache; @@ -79,6 +80,7 @@ int32_t reserveUserAuthInCache(int32_t acctId, const char* pUser, const char* pD int32_t reserveUserAuthInCacheExt(const char* pUser, const SName* pName, AUTH_TYPE type, SParseMetaCache* pMetaCache); int32_t reserveUdfInCache(const char* pFunc, SParseMetaCache* pMetaCache); int32_t reserveTableIndexInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache); +int32_t reserveTableCfgInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache); int32_t reserveDnodeRequiredInCache(SParseMetaCache* pMetaCache); int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta); int32_t getDbVgInfoFromCache(SParseMetaCache* pMetaCache, const char* pDbFName, SArray** pVgInfo); @@ -90,6 +92,7 @@ int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, const char* pUser, con bool* pPass); int32_t getUdfInfoFromCache(SParseMetaCache* pMetaCache, const char* pFunc, SFuncInfo* pInfo); int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName, SArray** pIndexes); +int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableCfg** pOutput); int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes); void destoryParseMetaCache(SParseMetaCache* pMetaCache); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 54c46ecb5d..08199c4f37 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -80,11 +80,18 @@ alter_account_option ::= CONNS literal. alter_account_option ::= STATE literal. { } /************************************************ create/alter/drop user **********************************************/ -cmd ::= CREATE USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B); } +cmd ::= CREATE USER user_name(A) PASS NK_STRING(B) sysinfo_opt(C). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B, C); } cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B); } -cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B); } +//cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B); } +cmd ::= ALTER USER user_name(A) ENABLE NK_INTEGER(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_ENABLE, &B); } +cmd ::= ALTER USER user_name(A) SYSINFO NK_INTEGER(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_SYSINFO, &B); } cmd ::= DROP USER user_name(A). { pCxt->pRootNode = createDropUserStmt(pCxt, &A); } +%type sysinfo_opt { int8_t } +%destructor sysinfo_opt { } +sysinfo_opt(A) ::= . { A = 1; } +sysinfo_opt(A) ::= SYSINFO NK_INTEGER(B). { A = taosStr2Int8(B.z, NULL, 10); } + /************************************************ grant/revoke ********************************************************/ cmd ::= GRANT privileges(A) ON priv_level(B) TO user_name(C). { pCxt->pRootNode = createGrantStmt(pCxt, A, &B, &C); } cmd ::= REVOKE privileges(A) ON priv_level(B) FROM user_name(C). { pCxt->pRootNode = createRevokeStmt(pCxt, A, &B, &C); } @@ -396,9 +403,9 @@ from_db_opt(A) ::= FROM db_name(B). /************************************************ create index ********************************************************/ cmd ::= CREATE SMA INDEX not_exists_opt(D) index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, &A, &B, NULL, C); } -cmd ::= CREATE FULLTEXT INDEX not_exists_opt(D) - index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, D, &A, &B, C, NULL); } -cmd ::= DROP INDEX exists_opt(C) index_name(A) ON table_name(B). { pCxt->pRootNode = createDropIndexStmt(pCxt, C, &A, &B); } +//cmd ::= CREATE FULLTEXT INDEX not_exists_opt(D) +// index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, D, &A, &B, C, NULL); } +cmd ::= DROP INDEX exists_opt(B) index_name(A). { pCxt->pRootNode = createDropIndexStmt(pCxt, B, &A); } index_options(A) ::= . { A = NULL; } index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL @@ -414,10 +421,14 @@ func_list(A) ::= func_list(B) NK_COMMA func(C). func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); } /************************************************ create/drop topic ***************************************************/ -cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, C, NULL, NULL); } -cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS DATABASE db_name(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, NULL, &C, NULL); } -cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) - AS STABLE full_table_name(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, NULL, NULL, C); } +cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, A, &B, C); } +cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS DATABASE db_name(C). { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, A, &B, &C, false); } +cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) + WITH META AS DATABASE db_name(C). { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, A, &B, &C, true); } +cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) + AS STABLE full_table_name(C). { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, A, &B, C, false); } +cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) + WITH META AS STABLE full_table_name(C). { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, A, &B, C, true); } cmd ::= DROP TOPIC exists_opt(A) topic_name(B). { pCxt->pRootNode = createDropTopicStmt(pCxt, A, &B); } cmd ::= DROP CONSUMER GROUP exists_opt(A) cgroup_name(B) ON topic_name(C). { pCxt->pRootNode = createDropCGroupStmt(pCxt, A, &B, &C); } @@ -627,6 +638,16 @@ expression(A) ::= column_reference(B) NK_ARROW NK_STRING(C). SToken s = getTokenFromRawExprNode(pCxt, B); A = createRawExprNodeExt(pCxt, &s, &C, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, B), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &C))); } +expression(A) ::= expression(B) NK_BITAND expression(C). { + SToken s = getTokenFromRawExprNode(pCxt, B); + SToken e = getTokenFromRawExprNode(pCxt, C); + A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C))); + } +expression(A) ::= expression(B) NK_BITOR expression(C). { + SToken s = getTokenFromRawExprNode(pCxt, B); + SToken e = getTokenFromRawExprNode(pCxt, C); + A = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C))); + } %type expression_list { SNodeList* } %destructor expression_list { nodesDestroyList($$); } @@ -757,8 +778,9 @@ boolean_primary(A) ::= NK_LP(C) boolean_value_expression(B) NK_RP(D). common_expression(A) ::= expression(B). { A = B; } common_expression(A) ::= boolean_value_expression(B). { A = B; } -/************************************************ from_clause *********************************************************/ -from_clause(A) ::= FROM table_reference_list(B). { A = B; } +/************************************************ from_clause_opt *********************************************************/ +from_clause_opt(A) ::= . { A = NULL; } +from_clause_opt(A) ::= FROM table_reference_list(B). { A = B; } table_reference_list(A) ::= table_reference(B). { A = B; } table_reference_list(A) ::= table_reference_list(B) NK_COMMA table_reference(C). { A = createJoinTableNode(pCxt, JOIN_TYPE_INNER, B, C, NULL); } @@ -792,9 +814,9 @@ join_type(A) ::= INNER. /************************************************ query_specification *************************************************/ query_specification(A) ::= - SELECT set_quantifier_opt(B) select_list(C) from_clause(D) where_clause_opt(E) - partition_by_clause_opt(F) range_opt(J) every_opt(K) fill_opt(L) twindow_clause_opt(G) - group_by_clause_opt(H) having_clause_opt(I). { + SELECT set_quantifier_opt(B) select_list(C) from_clause_opt(D) + where_clause_opt(E) partition_by_clause_opt(F) range_opt(J) every_opt(K) + fill_opt(L) twindow_clause_opt(G) group_by_clause_opt(H) having_clause_opt(I). { A = createSelectStmt(pCxt, B, C, D); A = addWhereClause(pCxt, A, E); A = addPartitionByClause(pCxt, A, F); diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 4fc5cf96e5..ef7f17a460 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -1205,7 +1205,7 @@ SNode* createShowDnodeVariablesStmt(SAstCreateContext* pCxt, SNode* pDnodeId) { return (SNode*)pStmt; } -SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword) { +SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo) { CHECK_PARSER_STATUS(pCxt); char password[TSDB_USET_PASSWORD_LEN] = {0}; if (!checkUserName(pCxt, pUserName) || !checkPassword(pCxt, pPassword, password)) { @@ -1215,6 +1215,7 @@ SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const ST CHECK_OUT_OF_MEM(pStmt); COPY_STRING_FORM_ID_TOKEN(pStmt->useName, pUserName); strcpy(pStmt->password, password); + pStmt->sysinfo = sysinfo; return (SNode*)pStmt; } @@ -1226,15 +1227,26 @@ SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t al SAlterUserStmt* pStmt = (SAlterUserStmt*)nodesMakeNode(QUERY_NODE_ALTER_USER_STMT); CHECK_OUT_OF_MEM(pStmt); COPY_STRING_FORM_ID_TOKEN(pStmt->useName, pUserName); - if (TSDB_ALTER_USER_PASSWD == alterType) { - char password[TSDB_USET_PASSWORD_LEN] = {0}; - if (!checkPassword(pCxt, pVal, password)) { - nodesDestroyNode((SNode*)pStmt); - return NULL; - } - strcpy(pStmt->password, password); - } pStmt->alterType = alterType; + switch (alterType) { + case TSDB_ALTER_USER_PASSWD: { + char password[TSDB_USET_PASSWORD_LEN] = {0}; + if (!checkPassword(pCxt, pVal, password)) { + nodesDestroyNode((SNode*)pStmt); + return NULL; + } + strcpy(pStmt->password, password); + break; + } + case TSDB_ALTER_USER_ENABLE: + pStmt->enable = taosStr2Int8(pVal->z, NULL, 10); + break; + case TSDB_ALTER_USER_SYSINFO: + pStmt->sysinfo = taosStr2Int8(pVal->z, NULL, 10); + break; + default: + break; + } return (SNode*)pStmt; } @@ -1317,16 +1329,15 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt return (SNode*)pOptions; } -SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pIndexName, SToken* pTableName) { +SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pIndexName) { CHECK_PARSER_STATUS(pCxt); - if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) { + if (!checkDbName(pCxt, NULL, true) || !checkIndexName(pCxt, pIndexName)) { return NULL; } SDropIndexStmt* pStmt = (SDropIndexStmt*)nodesMakeNode(QUERY_NODE_DROP_INDEX_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->ignoreNotExists = ignoreNotExists; COPY_STRING_FORM_ID_TOKEN(pStmt->indexName, pIndexName); - COPY_STRING_FORM_ID_TOKEN(pStmt->tableName, pTableName); return (SNode*)pStmt; } @@ -1346,22 +1357,40 @@ SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, cons return (SNode*)pStmt; } -SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, - const SToken* pSubDbName, SNode* pRealTable) { +SNode* createCreateTopicStmtUseQuery(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, + SNode* pQuery) { CHECK_PARSER_STATUS(pCxt); SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT); CHECK_OUT_OF_MEM(pStmt); COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName); pStmt->ignoreExists = ignoreExists; - if (NULL != pRealTable) { - strcpy(pStmt->subDbName, ((SRealTableNode*)pRealTable)->table.dbName); - strcpy(pStmt->subSTbName, ((SRealTableNode*)pRealTable)->table.tableName); - nodesDestroyNode(pRealTable); - } else if (NULL != pSubDbName) { - COPY_STRING_FORM_ID_TOKEN(pStmt->subDbName, pSubDbName); - } else { - pStmt->pQuery = pQuery; - } + pStmt->pQuery = pQuery; + return (SNode*)pStmt; +} + +SNode* createCreateTopicStmtUseDb(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, + const SToken* pSubDbName, bool withMeta) { + CHECK_PARSER_STATUS(pCxt); + SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT); + CHECK_OUT_OF_MEM(pStmt); + COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName); + pStmt->ignoreExists = ignoreExists; + COPY_STRING_FORM_ID_TOKEN(pStmt->subDbName, pSubDbName); + pStmt->withMeta = withMeta; + return (SNode*)pStmt; +} + +SNode* createCreateTopicStmtUseTable(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, + SNode* pRealTable, bool withMeta) { + CHECK_PARSER_STATUS(pCxt); + SCreateTopicStmt* pStmt = (SCreateTopicStmt*)nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT); + CHECK_OUT_OF_MEM(pStmt); + COPY_STRING_FORM_ID_TOKEN(pStmt->topicName, pTopicName); + pStmt->ignoreExists = ignoreExists; + pStmt->withMeta = withMeta; + strcpy(pStmt->subDbName, ((SRealTableNode*)pRealTable)->table.dbName); + strcpy(pStmt->subSTbName, ((SRealTableNode*)pRealTable)->table.tableName); + nodesDestroyNode(pRealTable); return (SNode*)pStmt; } diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index 131eccae24..46d2ae8383 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -411,7 +411,14 @@ static int32_t collectMetaKeyFromShowCreateDatabase(SCollectMetaKeyCxt* pCxt, SS } static int32_t collectMetaKeyFromShowCreateTable(SCollectMetaKeyCxt* pCxt, SShowCreateTableStmt* pStmt) { - return reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache); + SName name = {.type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId}; + strcpy(name.dbname, pStmt->dbName); + strcpy(name.tname, pStmt->tableName); + int32_t code = catalogRemoveTableMeta(pCxt->pParseCxt->pCatalog, &name); + if (TSDB_CODE_SUCCESS == code) { + code = reserveTableCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache); + } + return code; } static int32_t collectMetaKeyFromShowApps(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index 22d7afd642..0dfc79269e 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -227,12 +227,16 @@ static int32_t calcConstGroupBy(SCalcConstContext* pCxt, SSelectStmt* pSelect) { } } } - DESTORY_LIST(pSelect->pGroupByList); + NODES_DESTORY_LIST(pSelect->pGroupByList); } return code; } -static int32_t calcConstSelect(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) { +static int32_t calcConstSelectWithoutFrom(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) { + return calcConstProjections(pCxt, pSelect, subquery); +} + +static int32_t calcConstSelectFrom(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) { int32_t code = calcConstFromTable(pCxt, pSelect->pFromTable); if (TSDB_CODE_SUCCESS == code) { code = calcConstProjections(pCxt, pSelect, subquery); @@ -258,6 +262,14 @@ static int32_t calcConstSelect(SCalcConstContext* pCxt, SSelectStmt* pSelect, bo return code; } +static int32_t calcConstSelect(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) { + if (NULL == pSelect->pFromTable) { + return calcConstSelectWithoutFrom(pCxt, pSelect, subquery); + } else { + return calcConstSelectFrom(pCxt, pSelect, subquery); + } +} + static int32_t calcConstDelete(SCalcConstContext* pCxt, SDeleteStmt* pDelete) { int32_t code = calcConstFromTable(pCxt, pDelete->pFromTable); if (TSDB_CODE_SUCCESS == code) { diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index c8b78fcc8b..5d34250444 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -257,7 +257,7 @@ static int32_t checkAuth(SInsertParseContext* pCxt, char* pDbFname, bool* pPass) if (pBasicCtx->async) { return getUserAuthFromCache(pCxt->pMetaCache, pBasicCtx->pUser, pDbFname, AUTH_TYPE_WRITE, pPass); } - SRequestConnInfo conn = {.pTrans = pBasicCtx->pTransporter, + SRequestConnInfo conn = {.pTrans = pBasicCtx->pTransporter, .requestId = pBasicCtx->requestId, .requestObjRefId = pBasicCtx->requestRid, .mgmtEps = pBasicCtx->mgmtEpSet}; @@ -270,11 +270,11 @@ static int32_t getTableSchema(SInsertParseContext* pCxt, SName* pTbName, bool is if (pBasicCtx->async) { return getTableMetaFromCache(pCxt->pMetaCache, pTbName, pTableMeta); } - SRequestConnInfo conn = {.pTrans = pBasicCtx->pTransporter, + SRequestConnInfo conn = {.pTrans = pBasicCtx->pTransporter, .requestId = pBasicCtx->requestId, .requestObjRefId = pBasicCtx->requestRid, .mgmtEps = pBasicCtx->mgmtEpSet}; - + if (isStb) { return catalogGetSTableMeta(pBasicCtx->pCatalog, &conn, pTbName, pTableMeta); } @@ -286,7 +286,7 @@ static int32_t getTableVgroup(SInsertParseContext* pCxt, SName* pTbName, SVgroup if (pBasicCtx->async) { return getTableVgroupFromCache(pCxt->pMetaCache, pTbName, pVg); } - SRequestConnInfo conn = {.pTrans = pBasicCtx->pTransporter, + SRequestConnInfo conn = {.pTrans = pBasicCtx->pTransporter, .requestId = pBasicCtx->requestId, .requestObjRefId = pBasicCtx->requestRid, .mgmtEps = pBasicCtx->mgmtEpSet}; @@ -322,7 +322,7 @@ static int32_t getDBCfg(SInsertParseContext* pCxt, const char* pDbFName, SDbCfgI if (pBasicCtx->async) { CHECK_CODE(getDbCfgFromCache(pCxt->pMetaCache, pDbFName, pInfo)); } else { - SRequestConnInfo conn = {.pTrans = pBasicCtx->pTransporter, + SRequestConnInfo conn = {.pTrans = pBasicCtx->pTransporter, .requestId = pBasicCtx->requestId, .requestObjRefId = pBasicCtx->requestRid, .mgmtEps = pBasicCtx->mgmtEpSet}; @@ -1081,15 +1081,6 @@ end: return code; } -static int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst) { - *pDst = taosMemoryMalloc(TABLE_META_SIZE(pSrc)); - if (NULL == *pDst) { - return TSDB_CODE_TSC_OUT_OF_MEMORY; - } - memcpy(*pDst, pSrc, TABLE_META_SIZE(pSrc)); - return TSDB_CODE_SUCCESS; -} - static int32_t storeTableMeta(SInsertParseContext* pCxt, SHashObj* pHash, SName* pTableName, const char* pName, int32_t len, STableMeta* pMeta) { SVgroupInfo vg; @@ -1315,15 +1306,6 @@ static void destroyInsertParseContext(SInsertParseContext* pCxt) { destroyBlockArrayList(pCxt->pVgDataBlocks); } -static int32_t checkSchemalessDb(SInsertParseContext* pCxt, char* pDbName) { -// SDbCfgInfo pInfo = {0}; -// char fullName[TSDB_TABLE_FNAME_LEN]; -// snprintf(fullName, sizeof(fullName), "%d.%s", pCxt->pComCxt->acctId, pDbName); -// CHECK_CODE(getDBCfg(pCxt, fullName, &pInfo)); -// return pInfo.schemaless ? TSDB_CODE_SML_INVALID_DB_CONF : TSDB_CODE_SUCCESS; - return TSDB_CODE_SUCCESS; -} - // tb_name // [USING stb_name [(tag1_name, ...)] TAGS (tag1_value, ...)] // [(field1_name, ...)] @@ -1377,8 +1359,6 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) { SName name; CHECK_CODE(createSName(&name, &tbnameToken, pCxt->pComCxt->acctId, pCxt->pComCxt->db, &pCxt->msg)); - CHECK_CODE(checkSchemalessDb(pCxt, name.dbname)); - tNameExtractFullName(&name, tbFName); CHECK_CODE(taosHashPut(pCxt->pTableNameHashObj, tbFName, strlen(tbFName), &name, sizeof(SName))); char dbFName[TSDB_DB_FNAME_LEN]; diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 21f227b7ea..12b717e56a 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -79,6 +79,7 @@ static SKeyword keywordTable[] = { {"DOUBLE", TK_DOUBLE}, {"DROP", TK_DROP}, {"DURATION", TK_DURATION}, + {"ENABLE", TK_ENABLE}, {"EXISTS", TK_EXISTS}, {"EXPLAIN", TK_EXPLAIN}, {"EVERY", TK_EVERY}, @@ -120,6 +121,7 @@ static SKeyword keywordTable[] = { {"MAXROWS", TK_MAXROWS}, {"MAX_DELAY", TK_MAX_DELAY}, {"MERGE", TK_MERGE}, + {"META", TK_META}, {"MINROWS", TK_MINROWS}, {"MINUS", TK_MINUS}, {"MNODE", TK_MNODE}, @@ -146,7 +148,7 @@ static SKeyword keywordTable[] = { {"PORT", TK_PORT}, {"PPS", TK_PPS}, {"PRECISION", TK_PRECISION}, - {"PRIVILEGE", TK_PRIVILEGE}, + // {"PRIVILEGE", TK_PRIVILEGE}, {"PREV", TK_PREV}, {"QNODE", TK_QNODE}, {"QNODES", TK_QNODES}, @@ -187,6 +189,7 @@ static SKeyword keywordTable[] = { {"STREAMS", TK_STREAMS}, {"STRICT", TK_STRICT}, {"SYNCDB", TK_SYNCDB}, + {"SYSINFO", TK_SYSINFO}, {"TABLE", TK_TABLE}, {"TABLES", TK_TABLES}, {"TAG", TK_TAG}, @@ -222,6 +225,7 @@ static SKeyword keywordTable[] = { {"WATERMARK", TK_WATERMARK}, {"WHERE", TK_WHERE}, {"WINDOW_CLOSE", TK_WINDOW_CLOSE}, + {"WITH", TK_WITH}, {"WRITE", TK_WRITE}, {"_C0", TK_ROWTS}, {"_QENDTS", TK_QENDTS}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index fa0a66820f..43a4cf0ed6 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -133,6 +133,30 @@ static int32_t getTableMeta(STranslateContext* pCxt, const char* pDbName, const return getTableMetaImpl(pCxt, toName(pCxt->pParseCxt->acctId, pDbName, pTableName, &name), pMeta); } +static int32_t getTableCfg(STranslateContext* pCxt, const SName* pName, STableCfg** pCfg) { + SParseContext* pParCxt = pCxt->pParseCxt; + int32_t code = collectUseDatabase(pName, pCxt->pDbs); + if (TSDB_CODE_SUCCESS == code) { + code = collectUseTable(pName, pCxt->pTables); + } + if (TSDB_CODE_SUCCESS == code) { + if (pParCxt->async) { + code = getTableCfgFromCache(pCxt->pMetaCache, pName, pCfg); + } else { + SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, + .requestId = pParCxt->requestId, + .requestObjRefId = pParCxt->requestRid, + .mgmtEps = pParCxt->mgmtEpSet}; + code = catalogRefreshGetTableCfg(pParCxt->pCatalog, &conn, pName, pCfg); + } + } + if (TSDB_CODE_SUCCESS != code) { + parserError("catalogRefreshGetTableCfg error, code:%s, dbName:%s, tbName:%s", tstrerror(code), pName->dbname, + pName->tname); + } + return code; +} + static int32_t refreshGetTableMeta(STranslateContext* pCxt, const char* pDbName, const char* pTableName, STableMeta** pMeta) { SParseContext* pParCxt = pCxt->pParseCxt; @@ -665,6 +689,10 @@ static EDealRes translateColumnUseAlias(STranslateContext* pCxt, SColumnNode** p } static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) { + if (NULL != pCxt->pCurrSelectStmt && NULL == pCxt->pCurrSelectStmt->pFromTable) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_COLUMN, (*pCol)->colName); + } + // count(*)/first(*)/last(*) and so on if (0 == strcmp((*pCol)->colName, "*")) { return DEAL_RES_CONTINUE; @@ -984,6 +1012,17 @@ static EDealRes translateJsonOperator(STranslateContext* pCxt, SOperatorNode* pO return DEAL_RES_CONTINUE; } +static EDealRes translateBitwiseOperator(STranslateContext* pCxt, SOperatorNode* pOp) { + SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType; + SDataType rdt = ((SExprNode*)(pOp->pRight))->resType; + if (TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_BLOB == rdt.type) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); + } + pOp->node.resType.type = TSDB_DATA_TYPE_BIGINT; + pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; + return DEAL_RES_CONTINUE; +} + static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode** pOpRef) { SOperatorNode* pOp = *pOpRef; @@ -1002,6 +1041,8 @@ static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode** pOpRe return translateComparisonOperator(pCxt, pOp); } else if (nodesIsJsonOp(pOp)) { return translateJsonOperator(pCxt, pOp); + } else if (nodesIsBitwiseOp(pOp)) { + return translateBitwiseOperator(pCxt, pOp); } return DEAL_RES_CONTINUE; } @@ -1176,6 +1217,7 @@ static void setFuncClassification(SSelectStmt* pSelect, SFunctionNode* pFunc) { pSelect->hasUniqueFunc = pSelect->hasUniqueFunc ? true : (FUNCTION_TYPE_UNIQUE == pFunc->funcType); pSelect->hasTailFunc = pSelect->hasTailFunc ? true : (FUNCTION_TYPE_TAIL == pFunc->funcType); pSelect->hasInterpFunc = pSelect->hasInterpFunc ? true : (FUNCTION_TYPE_INTERP == pFunc->funcType); + pSelect->hasLastRowFunc = pSelect->hasLastRowFunc ? true : (FUNCTION_TYPE_LAST_ROW == pFunc->funcType); } } @@ -2005,9 +2047,9 @@ static int32_t checkFill(STranslateContext* pCxt, SFillNode* pFill, SValueNode* if (TIME_IS_VAR_DURATION(pInterval->unit)) { int64_t f = 1; if (pInterval->unit == 'n') { - f = 30L * MILLISECOND_PER_DAY; + f = 30LL * MILLISECOND_PER_DAY; } else if (pInterval->unit == 'y') { - f = 365L * MILLISECOND_PER_DAY; + f = 365LL * MILLISECOND_PER_DAY; } intervalRange = pInterval->datum.i * f; } else { @@ -2352,6 +2394,8 @@ static SNode* createGroupingSet(SNode* pExpr) { return (SNode*)pGroupingSet; } +// from: select unique(expr), col1 + col2 from t where_clause partition_by_clause order_by_clause ... +// to: select expr, first(col1) + first(col2) from t where_clause partition_by_clause group by expr order_by_clause ... static int32_t rewriteUniqueStmt(STranslateContext* pCxt, SSelectStmt* pSelect) { if (!pSelect->hasUniqueFunc) { return TSDB_CODE_SUCCESS; @@ -2417,6 +2461,8 @@ static SNode* createOrderByExpr(STranslateContext* pCxt) { return (SNode*)pOrder; } +// from: select tail(expr, k, f) from t where_clause partition_by_clause order_by_clause ... +// to: select expr from t where_clause order by _rowts desc limit k offset f static int32_t rewriteTailStmt(STranslateContext* pCxt, SSelectStmt* pSelect) { if (!pSelect->hasTailFunc) { return TSDB_CODE_SUCCESS; @@ -2465,7 +2511,13 @@ static int32_t replaceOrderByAlias(STranslateContext* pCxt, SNodeList* pProjecti return pCxt->errCode; } -static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) { +static int32_t translateSelectWithoutFrom(STranslateContext* pCxt, SSelectStmt* pSelect) { + pCxt->pCurrSelectStmt = pSelect; + pCxt->currClause = SQL_CLAUSE_SELECT; + return translateExprList(pCxt, pSelect->pProjectionList); +} + +static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect) { pCxt->pCurrSelectStmt = pSelect; int32_t code = translateFrom(pCxt, pSelect->pFromTable); if (TSDB_CODE_SUCCESS == code) { @@ -2514,6 +2566,14 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) { return code; } +static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) { + if (NULL == pSelect->pFromTable) { + return translateSelectWithoutFrom(pCxt, pSelect); + } else { + return translateSelectFrom(pCxt, pSelect); + } +} + static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) { SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { @@ -2666,7 +2726,7 @@ static int64_t getUnitPerMinute(uint8_t precision) { case TSDB_TIME_PRECISION_MILLI: return MILLISECOND_PER_MINUTE; case TSDB_TIME_PRECISION_MICRO: - return MILLISECOND_PER_MINUTE * 1000L; + return MILLISECOND_PER_MINUTE * 1000LL; case TSDB_TIME_PRECISION_NANO: return NANOSECOND_PER_MINUTE; default: @@ -3503,13 +3563,24 @@ static int32_t buildRollupAst(STranslateContext* pCxt, SCreateTableStmt* pStmt, return code; } +static int32_t buildRollupFuncs(SNodeList* pFuncs, SArray** pArray) { + if (NULL == pFuncs) { + return TSDB_CODE_SUCCESS; + } + *pArray = taosArrayInit(LIST_LENGTH(pFuncs), TSDB_FUNC_NAME_LEN); + SNode* pNode; + FOREACH(pNode, pFuncs) { + taosArrayPush(*pArray, ((SFunctionNode*)pNode)->functionName); + } + return TSDB_CODE_SUCCESS; +} + static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStmt, SMCreateStbReq* pReq) { pReq->igExists = pStmt->ignoreExists; pReq->delay1 = pStmt->pOptions->maxDelay1; pReq->delay2 = pStmt->pOptions->maxDelay2; pReq->watermark1 = pStmt->pOptions->watermark1; pReq->watermark2 = pStmt->pOptions->watermark2; - // pReq->ttl = pStmt->pOptions->ttl; columnDefNodeToField(pStmt->pCols, &pReq->pColumns); columnDefNodeToField(pStmt->pTags, &pReq->pTags); pReq->numOfColumns = LIST_LENGTH(pStmt->pCols); @@ -3523,6 +3594,7 @@ static int32_t buildCreateStbReq(STranslateContext* pCxt, SCreateTableStmt* pStm } else { pReq->commentLen = -1; } + buildRollupFuncs(pStmt->pOptions->pRollupFuncs, &pReq->pFuncs); SName tableName; tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tableName), pReq->name); @@ -3685,7 +3757,7 @@ static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pSt strcpy(createReq.user, pStmt->useName); createReq.createType = 0; createReq.superUser = 0; - createReq.sysInfo = 1; + createReq.sysInfo = pStmt->sysinfo; createReq.enable = 1; strcpy(createReq.pass, pStmt->password); @@ -3697,6 +3769,8 @@ static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt strcpy(alterReq.user, pStmt->useName); alterReq.alterType = pStmt->alterType; alterReq.superUser = 0; + alterReq.enable = pStmt->enable; + alterReq.sysInfo = pStmt->sysinfo; strcpy(alterReq.pass, pStmt->password); if (NULL != pCxt->pParseCxt->db) { strcpy(alterReq.dbname, pCxt->pParseCxt->db); @@ -3851,36 +3925,11 @@ static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* p } static int32_t translateDropIndex(STranslateContext* pCxt, SDropIndexStmt* pStmt) { - SEncoder encoder = {0}; - int32_t contLen = 0; - SVDropTSmaReq dropSmaReq = {0}; - strcpy(dropSmaReq.indexName, pStmt->indexName); - - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - int32_t ret = 0; - tEncodeSize(tEncodeSVDropTSmaReq, &dropSmaReq, contLen, ret); - if (ret < 0) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; - pCxt->pCmdMsg->msgType = TDMT_VND_DROP_SMA; - pCxt->pCmdMsg->msgLen = contLen; - pCxt->pCmdMsg->pMsg = taosMemoryMalloc(pCxt->pCmdMsg->msgLen); - if (NULL == pCxt->pCmdMsg->pMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - void* pBuf = pCxt->pCmdMsg->pMsg; - if (tEncodeSVDropTSmaReq(&encoder, &dropSmaReq) < 0) { - tEncoderClear(&encoder); - return TSDB_CODE_OUT_OF_MEMORY; - } - tEncoderClear(&encoder); - return TSDB_CODE_SUCCESS; + SMDropSmaReq dropSmaReq = {0}; + SName name; + tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pCxt->pParseCxt->db, pStmt->indexName, &name), dropSmaReq.name); + dropSmaReq.igNotExists = pStmt->ignoreNotExists; + return buildCmdMsg(pCxt, TDMT_MND_DROP_SMA, (FSerializeFunc)tSerializeSMDropSmaReq, &dropSmaReq); } static int16_t getCreateComponentNodeMsgType(ENodeType type) { @@ -3932,6 +3981,7 @@ static int32_t buildCreateTopicReq(STranslateContext* pCxt, SCreateTopicStmt* pS tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->topicName, strlen(pStmt->topicName)); tNameGetFullDbName(&name, pReq->name); pReq->igExists = pStmt->ignoreExists; + pReq->withMeta = pStmt->withMeta; pReq->sql = strdup(pCxt->pParseCxt->pSql); if (NULL == pReq->sql) { @@ -4287,6 +4337,11 @@ static int32_t translateSplitVgroup(STranslateContext* pCxt, SSplitVgroupStmt* p return buildCmdMsg(pCxt, TDMT_MND_SPLIT_VGROUP, (FSerializeFunc)tSerializeSSplitVgroupReq, &req); } +static int32_t translateShowVariables(STranslateContext* pCxt, SShowStmt* pStmt) { + SShowVariablesReq req = {0}; + return buildCmdMsg(pCxt, TDMT_MND_SHOW_VARIABLES, (FSerializeFunc)tSerializeSShowVariablesReq, &req); +} + static int32_t translateShowCreateDatabase(STranslateContext* pCxt, SShowCreateDatabaseStmt* pStmt) { pStmt->pCfg = taosMemoryCalloc(1, sizeof(SDbCfgInfo)); if (NULL == pStmt->pCfg) { @@ -4296,7 +4351,10 @@ static int32_t translateShowCreateDatabase(STranslateContext* pCxt, SShowCreateD } static int32_t translateShowCreateTable(STranslateContext* pCxt, SShowCreateTableStmt* pStmt) { - return getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pStmt->pMeta); + SName name; + toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &name); + + return getTableCfg(pCxt, &name, (STableCfg**)&pStmt->pCfg); } static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { @@ -4428,6 +4486,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_SPLIT_VGROUP_STMT: code = translateSplitVgroup(pCxt, (SSplitVgroupStmt*)pNode); break; + case QUERY_NODE_SHOW_VARIABLES_STMT: + code = translateShowVariables(pCxt, (SShowStmt*)pNode); + break; case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: code = translateShowCreateDatabase(pCxt, (SShowCreateDatabaseStmt*)pNode); break; diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 51e0dd58d8..b474d95b3c 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -561,6 +561,9 @@ int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalog if (TSDB_CODE_SUCCESS == code) { code = buildTableReq(pMetaCache->pTableIndex, &pCatalogReq->pTableIndex); } + if (TSDB_CODE_SUCCESS == code) { + code = buildTableReq(pMetaCache->pTableCfg, &pCatalogReq->pTableCfg); + } pCatalogReq->dNodeRequired = pMetaCache->dnodeRequired; return code; } @@ -657,6 +660,9 @@ int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMet if (TSDB_CODE_SUCCESS == code) { code = putTableDataToCache(pCatalogReq->pTableIndex, pMetaData->pTableIndex, &pMetaCache->pTableIndex); } + if (TSDB_CODE_SUCCESS == code) { + code = putTableDataToCache(pCatalogReq->pTableCfg, pMetaData->pTableCfg, &pMetaCache->pTableCfg); + } pMetaCache->pDnodes = pMetaData->pDnodeList; return code; } @@ -863,6 +869,10 @@ int32_t reserveTableIndexInCache(int32_t acctId, const char* pDb, const char* pT return reserveTableReqInCache(acctId, pDb, pTable, &pMetaCache->pTableIndex); } +int32_t reserveTableCfgInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache) { + return reserveTableReqInCache(acctId, pDb, pTable, &pMetaCache->pTableCfg); +} + int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName, SArray** pIndexes) { char fullName[TSDB_TABLE_FNAME_LEN]; tNameExtractFullName(pName, fullName); @@ -877,6 +887,41 @@ int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName, return code; } +STableCfg* tableCfgDup(STableCfg* pCfg) { + STableCfg* pNew = taosMemoryMalloc(sizeof(*pNew)); + + memcpy(pNew, pCfg, sizeof(*pNew)); + if (pNew->pComment) { + pNew->pComment = strdup(pNew->pComment); + } + if (pNew->pFuncs) { + pNew->pFuncs = taosArrayDup(pNew->pFuncs); + } + + int32_t schemaSize = (pCfg->numOfColumns + pCfg->numOfTags) * sizeof(SSchema); + + SSchema* pSchema = taosMemoryMalloc(schemaSize); + memcpy(pSchema, pCfg->pSchemas, schemaSize); + + pNew->pSchemas = pSchema; + + return pNew; +} + +int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableCfg** pOutput) { + char fullName[TSDB_TABLE_FNAME_LEN]; + tNameExtractFullName(pName, fullName); + STableCfg* pCfg = NULL; + int32_t code = getMetaDataFromHash(fullName, strlen(fullName), pMetaCache->pTableCfg, (void**)&pCfg); + if (TSDB_CODE_SUCCESS == code) { + *pOutput = tableCfgDup(pCfg); + if (NULL == *pOutput) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + return code; +} + int32_t reserveDnodeRequiredInCache(SParseMetaCache* pMetaCache) { pMetaCache->dnodeRequired = true; return TSDB_CODE_SUCCESS; @@ -899,4 +944,5 @@ void destoryParseMetaCache(SParseMetaCache* pMetaCache) { taosHashCleanup(pMetaCache->pUserAuth); taosHashCleanup(pMetaCache->pUdf); taosHashCleanup(pMetaCache->pTableIndex); + taosHashCleanup(pMetaCache->pTableCfg); } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index c7651137b1..b632f2eb32 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -104,25 +104,26 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 364 +#define YYNOCODE 367 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SToken yy57; - EOrder yy162; - EJoinType yy204; - SAlterOption yy221; - int32_t yy228; - EFillMode yy270; - EOperatorType yy324; - int64_t yy389; - SNode* yy392; - SDataType yy448; - bool yy481; - ENullOrder yy529; - SNodeList* yy600; + bool yy197; + EJoinType yy208; + SToken yy241; + SAlterOption yy301; + EOrder yy362; + SNodeList* yy368; + EFillMode yy388; + SDataType yy392; + EOperatorType yy412; + ENullOrder yy417; + SNode* yy442; + int32_t yy578; + int8_t yy629; + int64_t yy683; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -138,17 +139,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 641 -#define YYNRULE 466 -#define YYNTOKEN 242 -#define YY_MAX_SHIFT 640 -#define YY_MIN_SHIFTREDUCE 933 -#define YY_MAX_SHIFTREDUCE 1398 -#define YY_ERROR_ACTION 1399 -#define YY_ACCEPT_ACTION 1400 -#define YY_NO_ACTION 1401 -#define YY_MIN_REDUCE 1402 -#define YY_MAX_REDUCE 1867 +#define YYNSTATE 645 +#define YYNRULE 473 +#define YYNTOKEN 244 +#define YY_MAX_SHIFT 644 +#define YY_MIN_SHIFTREDUCE 938 +#define YY_MAX_SHIFTREDUCE 1410 +#define YY_ERROR_ACTION 1411 +#define YY_ACCEPT_ACTION 1412 +#define YY_NO_ACTION 1413 +#define YY_MIN_REDUCE 1414 +#define YY_MAX_REDUCE 1886 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -215,619 +216,631 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2192) +#define YY_ACTTAB_COUNT (2260) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 1697, 1845, 1522, 309, 412, 1697, 413, 1434, 326, 1400, - /* 10 */ 137, 1694, 37, 35, 1490, 1844, 1694, 1710, 417, 1842, - /* 20 */ 318, 556, 1208, 556, 1230, 38, 36, 34, 33, 32, - /* 30 */ 325, 324, 109, 420, 109, 413, 1434, 1690, 1696, 451, - /* 40 */ 1222, 456, 1690, 1696, 1726, 30, 240, 1206, 559, 1533, - /* 50 */ 1793, 1533, 540, 559, 22, 556, 555, 1680, 14, 539, - /* 60 */ 37, 35, 1335, 322, 1214, 1215, 157, 335, 318, 1710, - /* 70 */ 1208, 134, 520, 365, 1790, 38, 36, 34, 33, 32, - /* 80 */ 1535, 1, 1214, 1533, 1739, 67, 555, 85, 1711, 542, - /* 90 */ 1713, 1714, 538, 58, 559, 1206, 1726, 1779, 113, 76, - /* 100 */ 371, 292, 1775, 637, 519, 556, 14, 1528, 1845, 1680, - /* 110 */ 1425, 539, 1214, 1845, 1845, 543, 369, 1277, 1278, 963, - /* 120 */ 1526, 560, 152, 470, 555, 1631, 1842, 154, 152, 2, - /* 130 */ 430, 1842, 1842, 1533, 206, 82, 1739, 290, 478, 86, - /* 140 */ 1711, 542, 1713, 1714, 538, 1369, 559, 40, 118, 1779, - /* 150 */ 1680, 637, 198, 311, 1775, 148, 1525, 967, 968, 1209, - /* 160 */ 58, 1207, 70, 328, 473, 1277, 1278, 232, 56, 467, - /* 170 */ 364, 134, 363, 1233, 197, 495, 1806, 1223, 330, 1218, - /* 180 */ 1535, 1578, 1580, 1212, 1213, 41, 1259, 1260, 1262, 1263, - /* 190 */ 1264, 1265, 1266, 535, 557, 1274, 1275, 1276, 1279, 53, - /* 200 */ 1232, 1226, 52, 1579, 1580, 26, 59, 1209, 1845, 1207, - /* 210 */ 510, 155, 557, 1274, 1275, 38, 36, 34, 33, 32, - /* 220 */ 37, 35, 153, 155, 1424, 1710, 1842, 402, 318, 67, - /* 230 */ 1208, 1212, 1213, 302, 1259, 1260, 1262, 1263, 1264, 1265, - /* 240 */ 1266, 535, 557, 1274, 1275, 1276, 1279, 516, 1726, 465, - /* 250 */ 464, 1529, 1726, 489, 463, 1206, 509, 114, 460, 1668, - /* 260 */ 540, 459, 458, 457, 1680, 1680, 14, 539, 37, 35, - /* 270 */ 1112, 1113, 1214, 166, 165, 117, 318, 155, 1208, 1299, - /* 280 */ 520, 1511, 303, 58, 301, 300, 356, 453, 58, 2, - /* 290 */ 155, 455, 1739, 508, 1845, 85, 1711, 542, 1713, 1714, - /* 300 */ 538, 1304, 559, 1206, 344, 1779, 358, 354, 152, 292, - /* 310 */ 1775, 637, 1842, 454, 115, 38, 36, 34, 33, 32, - /* 320 */ 1214, 1845, 136, 1524, 1414, 1277, 1278, 1509, 518, 149, - /* 330 */ 1786, 1787, 1233, 1791, 1694, 152, 27, 8, 430, 1842, - /* 340 */ 1070, 582, 581, 580, 1074, 579, 1076, 1077, 578, 1079, - /* 350 */ 575, 1403, 1085, 572, 1087, 1088, 569, 566, 81, 637, - /* 360 */ 1690, 1696, 38, 36, 34, 33, 32, 1209, 78, 1207, - /* 370 */ 1359, 559, 99, 1277, 1278, 98, 97, 96, 95, 94, - /* 380 */ 93, 92, 91, 90, 593, 1349, 38, 36, 34, 33, - /* 390 */ 32, 1212, 1213, 522, 1259, 1260, 1262, 1263, 1264, 1265, - /* 400 */ 1266, 535, 557, 1274, 1275, 1276, 1279, 502, 1357, 1358, - /* 410 */ 1360, 1361, 980, 155, 979, 1209, 99, 1207, 155, 98, - /* 420 */ 97, 96, 95, 94, 93, 92, 91, 90, 37, 35, - /* 430 */ 1280, 11, 10, 1710, 462, 461, 318, 162, 1208, 1212, - /* 440 */ 1213, 981, 1259, 1260, 1262, 1263, 1264, 1265, 1266, 535, - /* 450 */ 557, 1274, 1275, 1276, 1279, 38, 36, 34, 33, 32, - /* 460 */ 1726, 479, 65, 1206, 1845, 64, 593, 155, 540, 980, - /* 470 */ 147, 979, 1585, 1680, 1231, 539, 37, 35, 1843, 308, - /* 480 */ 1214, 1461, 1842, 1572, 318, 1793, 1208, 1423, 1583, 1214, - /* 490 */ 38, 36, 34, 33, 32, 1422, 449, 9, 981, 1234, - /* 500 */ 1739, 1395, 1845, 87, 1711, 542, 1713, 1714, 538, 1789, - /* 510 */ 559, 1206, 1311, 1779, 199, 134, 152, 1778, 1775, 637, - /* 520 */ 1842, 543, 133, 1585, 1536, 1246, 1342, 1680, 1214, 321, - /* 530 */ 323, 1630, 1232, 1277, 1278, 1680, 293, 609, 607, 1583, - /* 540 */ 1421, 615, 614, 613, 333, 9, 612, 611, 610, 119, - /* 550 */ 605, 604, 603, 602, 601, 600, 599, 598, 127, 594, - /* 560 */ 1246, 1402, 38, 36, 34, 33, 32, 637, 1297, 505, - /* 570 */ 69, 291, 1285, 967, 968, 1209, 1420, 1207, 1232, 1419, - /* 580 */ 1680, 1277, 1278, 1394, 28, 108, 107, 106, 105, 104, - /* 590 */ 103, 102, 101, 100, 38, 36, 34, 33, 32, 1212, - /* 600 */ 1213, 1510, 1259, 1260, 1262, 1263, 1264, 1265, 1266, 535, - /* 610 */ 557, 1274, 1275, 1276, 1279, 556, 1680, 1585, 1585, 1680, - /* 620 */ 1298, 331, 585, 1209, 329, 1207, 370, 231, 1518, 134, - /* 630 */ 34, 33, 32, 1583, 1584, 1418, 37, 35, 1535, 511, - /* 640 */ 506, 200, 1303, 1533, 318, 591, 1208, 1212, 1213, 1417, - /* 650 */ 1259, 1260, 1262, 1263, 1264, 1265, 1266, 535, 557, 1274, - /* 660 */ 1275, 1276, 1279, 556, 125, 124, 588, 587, 586, 411, - /* 670 */ 419, 1206, 415, 415, 372, 1680, 556, 29, 316, 1292, - /* 680 */ 1293, 1294, 1295, 1296, 1300, 1301, 1302, 387, 1214, 1680, - /* 690 */ 185, 1533, 556, 263, 591, 597, 1563, 1505, 1416, 1261, - /* 700 */ 1190, 1191, 140, 388, 1533, 2, 1413, 556, 447, 443, - /* 710 */ 439, 435, 184, 125, 124, 588, 587, 586, 429, 1793, - /* 720 */ 1533, 1698, 1710, 1334, 289, 1232, 1230, 637, 1412, 1700, - /* 730 */ 1411, 455, 1694, 395, 7, 1533, 407, 68, 1680, 556, - /* 740 */ 182, 1277, 1278, 1788, 556, 1261, 1680, 1410, 1409, 1726, - /* 750 */ 1530, 380, 1235, 454, 408, 1657, 382, 540, 1690, 1696, - /* 760 */ 135, 524, 1680, 556, 539, 269, 1702, 1533, 1680, 559, - /* 770 */ 1680, 1621, 1533, 556, 487, 496, 589, 267, 55, 1576, - /* 780 */ 527, 54, 164, 1209, 553, 1207, 373, 1680, 1680, 1739, - /* 790 */ 596, 1533, 287, 1711, 542, 1713, 1714, 538, 167, 559, - /* 800 */ 181, 1533, 173, 1464, 178, 1520, 425, 1212, 1213, 1408, - /* 810 */ 1259, 1260, 1262, 1263, 1264, 1265, 1266, 535, 557, 1274, - /* 820 */ 1275, 1276, 1279, 58, 590, 171, 406, 1576, 1516, 401, - /* 830 */ 400, 399, 398, 397, 394, 393, 392, 391, 390, 386, - /* 840 */ 385, 384, 383, 377, 376, 375, 374, 203, 1032, 1680, - /* 850 */ 38, 36, 34, 33, 32, 556, 556, 1208, 556, 516, - /* 860 */ 1407, 84, 1406, 465, 464, 1034, 554, 253, 463, 332, - /* 870 */ 1405, 114, 460, 1798, 1330, 459, 458, 457, 608, 1451, - /* 880 */ 212, 534, 1206, 1533, 1533, 190, 1533, 117, 188, 486, - /* 890 */ 1710, 1508, 1261, 62, 61, 368, 293, 1217, 161, 1214, - /* 900 */ 1680, 466, 1680, 192, 362, 516, 191, 1330, 194, 196, - /* 910 */ 1680, 193, 195, 1446, 1444, 288, 584, 1726, 352, 359, - /* 920 */ 350, 346, 342, 158, 337, 519, 115, 477, 1297, 1415, - /* 930 */ 1680, 1333, 539, 117, 1216, 468, 471, 123, 637, 1004, - /* 940 */ 475, 150, 1786, 1787, 532, 1791, 235, 11, 10, 48, - /* 950 */ 525, 216, 1491, 155, 448, 503, 1005, 1739, 1710, 480, - /* 960 */ 86, 1711, 542, 1713, 1714, 538, 1440, 559, 1397, 1398, - /* 970 */ 1779, 528, 115, 39, 311, 1775, 148, 223, 491, 39, - /* 980 */ 1298, 1727, 1710, 334, 591, 1726, 39, 151, 1786, 1787, - /* 990 */ 1356, 1791, 218, 540, 1209, 242, 1207, 1807, 1680, 1435, - /* 1000 */ 539, 1573, 1303, 125, 124, 588, 587, 586, 1809, 1726, - /* 1010 */ 121, 1220, 633, 517, 1305, 234, 237, 540, 1212, 1213, - /* 1020 */ 1267, 239, 1680, 1710, 539, 1739, 3, 1163, 272, 1711, - /* 1030 */ 542, 1713, 1714, 538, 122, 559, 244, 29, 316, 1292, - /* 1040 */ 1293, 1294, 1295, 1296, 1300, 1301, 1302, 123, 1219, 1739, - /* 1050 */ 1726, 548, 86, 1711, 542, 1713, 1714, 538, 540, 559, - /* 1060 */ 48, 564, 1779, 1680, 1710, 539, 311, 1775, 1858, 1289, - /* 1070 */ 122, 123, 110, 122, 5, 250, 336, 1813, 1230, 339, - /* 1080 */ 343, 298, 1174, 1032, 299, 259, 389, 163, 1063, 396, - /* 1090 */ 1739, 1726, 1623, 86, 1711, 542, 1713, 1714, 538, 540, - /* 1100 */ 559, 262, 1091, 1779, 1680, 404, 539, 311, 1775, 1858, - /* 1110 */ 403, 1095, 1102, 1100, 126, 405, 409, 1236, 1836, 410, - /* 1120 */ 418, 1239, 421, 170, 172, 1238, 422, 423, 1240, 426, - /* 1130 */ 424, 1739, 175, 177, 86, 1711, 542, 1713, 1714, 538, - /* 1140 */ 1710, 559, 427, 1237, 1779, 428, 180, 450, 311, 1775, - /* 1150 */ 1858, 431, 452, 66, 183, 1523, 187, 1519, 481, 1797, - /* 1160 */ 189, 128, 307, 89, 260, 129, 1521, 1726, 482, 485, - /* 1170 */ 201, 204, 488, 1517, 130, 540, 131, 490, 207, 1235, - /* 1180 */ 1680, 210, 539, 1810, 504, 546, 6, 492, 1662, 1820, - /* 1190 */ 1661, 1819, 513, 1800, 222, 520, 142, 499, 500, 224, - /* 1200 */ 498, 225, 493, 1710, 501, 1330, 310, 1739, 497, 226, - /* 1210 */ 278, 1711, 542, 1713, 1714, 538, 507, 559, 214, 217, - /* 1220 */ 1710, 116, 1234, 42, 1841, 18, 526, 529, 227, 523, - /* 1230 */ 1726, 233, 312, 1861, 544, 545, 1845, 320, 540, 1794, - /* 1240 */ 1629, 549, 246, 1680, 1628, 539, 551, 1726, 261, 550, - /* 1250 */ 154, 77, 1534, 248, 1842, 540, 75, 562, 520, 264, - /* 1260 */ 1680, 228, 539, 1760, 1577, 1506, 256, 49, 636, 266, - /* 1270 */ 1739, 270, 1674, 278, 1711, 542, 1713, 1714, 538, 279, - /* 1280 */ 559, 271, 268, 1710, 141, 236, 1673, 1739, 530, 60, - /* 1290 */ 87, 1711, 542, 1713, 1714, 538, 238, 559, 1672, 1845, - /* 1300 */ 1779, 1710, 338, 1669, 531, 1775, 340, 341, 1201, 1202, - /* 1310 */ 1726, 159, 345, 152, 1667, 347, 348, 1842, 537, 349, - /* 1320 */ 1666, 1665, 351, 1680, 353, 539, 1664, 355, 1726, 1663, - /* 1330 */ 357, 1647, 160, 360, 361, 1177, 540, 1176, 1641, 1640, - /* 1340 */ 366, 1680, 367, 539, 1639, 1638, 1149, 1616, 63, 1615, - /* 1350 */ 1739, 378, 1710, 286, 1711, 542, 1713, 1714, 538, 536, - /* 1360 */ 559, 533, 1751, 1614, 1613, 1612, 1611, 1610, 1739, 379, - /* 1370 */ 640, 138, 1711, 542, 1713, 1714, 538, 381, 559, 1726, - /* 1380 */ 1609, 1608, 1607, 1606, 258, 1605, 1604, 540, 1603, 1602, - /* 1390 */ 1601, 1600, 1680, 516, 539, 1599, 145, 1598, 1597, 1596, - /* 1400 */ 120, 1595, 631, 627, 623, 619, 257, 1594, 1593, 1592, - /* 1410 */ 1591, 1590, 1589, 1710, 1151, 1588, 521, 1859, 1587, 1739, - /* 1420 */ 1586, 117, 87, 1711, 542, 1713, 1714, 538, 1463, 559, - /* 1430 */ 1431, 83, 1779, 168, 251, 146, 970, 1776, 969, 111, - /* 1440 */ 1726, 520, 1430, 169, 414, 1655, 1649, 416, 540, 1637, - /* 1450 */ 112, 174, 1636, 1680, 176, 539, 1626, 1512, 179, 1462, - /* 1460 */ 115, 1460, 434, 998, 433, 1458, 1710, 552, 438, 1456, - /* 1470 */ 432, 1454, 437, 436, 441, 229, 1786, 515, 442, 514, - /* 1480 */ 1739, 440, 1845, 282, 1711, 542, 1713, 1714, 538, 1710, - /* 1490 */ 559, 444, 445, 1726, 1443, 494, 154, 446, 208, 1442, - /* 1500 */ 1842, 540, 1429, 1514, 186, 1106, 1680, 516, 539, 1105, - /* 1510 */ 1513, 1031, 1452, 1030, 1029, 1028, 1726, 1182, 606, 202, - /* 1520 */ 608, 1025, 512, 47, 540, 1024, 304, 1023, 1447, 1680, - /* 1530 */ 305, 539, 469, 1739, 1445, 117, 138, 1711, 542, 1713, - /* 1540 */ 1714, 538, 315, 559, 306, 1710, 1428, 472, 474, 1427, - /* 1550 */ 88, 476, 1654, 1184, 51, 520, 1739, 1648, 483, 287, - /* 1560 */ 1711, 542, 1713, 1714, 538, 1635, 559, 1634, 1633, 1625, - /* 1570 */ 71, 15, 1726, 4, 115, 209, 39, 1371, 23, 213, - /* 1580 */ 537, 205, 1860, 484, 45, 1680, 211, 539, 50, 229, - /* 1590 */ 1786, 515, 139, 514, 220, 215, 1845, 132, 1710, 1355, - /* 1600 */ 219, 24, 221, 1348, 1700, 72, 230, 1710, 143, 1327, - /* 1610 */ 152, 25, 1739, 1326, 1842, 286, 1711, 542, 1713, 1714, - /* 1620 */ 538, 1710, 559, 44, 1752, 1726, 1388, 17, 1383, 1377, - /* 1630 */ 10, 1382, 313, 540, 1726, 1387, 1386, 314, 1680, 19, - /* 1640 */ 539, 1269, 540, 1268, 31, 1290, 144, 1680, 1726, 539, - /* 1650 */ 156, 317, 16, 12, 13, 20, 540, 43, 1254, 21, - /* 1660 */ 319, 1680, 1710, 539, 1624, 1739, 541, 247, 287, 1711, - /* 1670 */ 542, 1713, 1714, 538, 1739, 559, 241, 287, 1711, 542, - /* 1680 */ 1713, 1714, 538, 1710, 559, 1353, 243, 547, 1739, 1726, - /* 1690 */ 245, 273, 1711, 542, 1713, 1714, 538, 540, 559, 73, - /* 1700 */ 74, 78, 1680, 1699, 539, 252, 1742, 1224, 1271, 249, - /* 1710 */ 1726, 1092, 558, 46, 561, 563, 327, 1089, 540, 565, - /* 1720 */ 567, 568, 570, 1680, 1086, 539, 571, 573, 1080, 1739, - /* 1730 */ 574, 576, 274, 1711, 542, 1713, 1714, 538, 1078, 559, - /* 1740 */ 1069, 1710, 1084, 583, 577, 1101, 1083, 79, 1082, 1081, - /* 1750 */ 1739, 80, 1710, 281, 1711, 542, 1713, 1714, 538, 57, - /* 1760 */ 559, 254, 1097, 1710, 996, 592, 1020, 595, 1726, 255, - /* 1770 */ 1038, 1013, 1018, 1017, 1016, 1035, 540, 1015, 1014, 1726, - /* 1780 */ 1012, 1680, 1011, 539, 1033, 1008, 1007, 540, 1006, 1003, - /* 1790 */ 1726, 1002, 1680, 1001, 539, 1459, 617, 616, 540, 618, - /* 1800 */ 1457, 620, 621, 1680, 622, 539, 1455, 624, 1739, 625, - /* 1810 */ 626, 283, 1711, 542, 1713, 1714, 538, 1453, 559, 1739, - /* 1820 */ 629, 628, 275, 1711, 542, 1713, 1714, 538, 1710, 559, - /* 1830 */ 1739, 630, 1441, 284, 1711, 542, 1713, 1714, 538, 632, - /* 1840 */ 559, 1426, 634, 635, 1710, 1210, 265, 638, 639, 1401, - /* 1850 */ 1401, 1401, 1401, 1401, 1401, 1726, 1401, 1401, 1401, 1401, - /* 1860 */ 1401, 1401, 1401, 540, 1401, 1401, 1401, 1401, 1680, 1401, - /* 1870 */ 539, 1726, 1401, 1401, 1401, 1401, 1401, 1401, 1401, 540, - /* 1880 */ 1401, 1401, 1401, 1401, 1680, 1401, 539, 1401, 1401, 1401, - /* 1890 */ 1401, 1401, 1401, 1710, 1401, 1739, 1401, 1401, 276, 1711, - /* 1900 */ 542, 1713, 1714, 538, 1401, 559, 1401, 1710, 1401, 1401, - /* 1910 */ 1401, 1739, 1401, 1401, 285, 1711, 542, 1713, 1714, 538, - /* 1920 */ 1726, 559, 1401, 1401, 1401, 1401, 1401, 1401, 540, 1401, - /* 1930 */ 1401, 1401, 1401, 1680, 1726, 539, 1401, 1401, 1401, 1401, - /* 1940 */ 1401, 1401, 540, 1401, 1401, 1401, 1401, 1680, 1710, 539, - /* 1950 */ 1401, 1401, 1401, 1401, 1401, 1401, 1401, 1401, 1401, 1401, - /* 1960 */ 1739, 1401, 1401, 277, 1711, 542, 1713, 1714, 538, 1710, - /* 1970 */ 559, 1401, 1401, 1401, 1739, 1726, 1401, 1722, 1711, 542, - /* 1980 */ 1713, 1714, 538, 540, 559, 1401, 1401, 1401, 1680, 1401, - /* 1990 */ 539, 1401, 1401, 1401, 1401, 1401, 1726, 1401, 1401, 1401, - /* 2000 */ 1401, 1401, 1401, 1401, 540, 1401, 1401, 1401, 1401, 1680, - /* 2010 */ 1401, 539, 1401, 1401, 1401, 1739, 1401, 1401, 1721, 1711, - /* 2020 */ 542, 1713, 1714, 538, 1401, 559, 1401, 1710, 1401, 1401, - /* 2030 */ 1401, 1401, 1401, 1401, 1401, 1401, 1739, 1401, 1710, 1720, - /* 2040 */ 1711, 542, 1713, 1714, 538, 1401, 559, 1401, 1401, 1710, - /* 2050 */ 1401, 1401, 1401, 1401, 1726, 1401, 1401, 1401, 1401, 1401, - /* 2060 */ 1401, 1401, 540, 1401, 1401, 1726, 1401, 1680, 1401, 539, - /* 2070 */ 1401, 1401, 1401, 540, 1401, 1401, 1726, 1401, 1680, 1401, - /* 2080 */ 539, 1401, 1401, 1401, 540, 1401, 1401, 1401, 1401, 1680, - /* 2090 */ 1710, 539, 1401, 1401, 1739, 1401, 1401, 296, 1711, 542, - /* 2100 */ 1713, 1714, 538, 1401, 559, 1739, 1401, 1401, 295, 1711, - /* 2110 */ 542, 1713, 1714, 538, 1710, 559, 1739, 1726, 1401, 297, - /* 2120 */ 1711, 542, 1713, 1714, 538, 540, 559, 1401, 1401, 1401, - /* 2130 */ 1680, 1401, 539, 1401, 1401, 1401, 1401, 1401, 1401, 1401, - /* 2140 */ 1401, 1726, 1401, 1401, 1401, 1401, 1401, 1401, 1401, 540, - /* 2150 */ 1401, 1401, 1401, 1401, 1680, 1401, 539, 1739, 1401, 1401, - /* 2160 */ 294, 1711, 542, 1713, 1714, 538, 1401, 559, 1401, 1401, - /* 2170 */ 1401, 1401, 1401, 1401, 1401, 1401, 1401, 1401, 1401, 1401, - /* 2180 */ 1401, 1739, 1401, 1401, 280, 1711, 542, 1713, 1714, 538, - /* 2190 */ 1401, 559, + /* 0 */ 78, 415, 1726, 416, 1449, 30, 239, 423, 61, 416, + /* 10 */ 1449, 1864, 39, 37, 1864, 40, 38, 36, 35, 34, + /* 20 */ 321, 1541, 1217, 333, 69, 1863, 1593, 1595, 155, 1861, + /* 30 */ 1744, 1713, 1861, 1600, 312, 1215, 558, 115, 522, 519, + /* 40 */ 326, 26, 1710, 1696, 971, 542, 1543, 33, 32, 1598, + /* 50 */ 28, 40, 38, 36, 35, 34, 33, 32, 1744, 14, + /* 60 */ 40, 38, 36, 35, 34, 1223, 512, 119, 1706, 1712, + /* 70 */ 1757, 368, 1726, 88, 1727, 545, 1729, 1730, 541, 562, + /* 80 */ 562, 84, 1, 1797, 975, 976, 60, 314, 1793, 150, + /* 90 */ 1684, 33, 32, 1864, 120, 40, 38, 36, 35, 34, + /* 100 */ 1744, 231, 1540, 511, 641, 432, 117, 1862, 543, 498, + /* 110 */ 1825, 1861, 1864, 1696, 558, 542, 149, 60, 1288, 1289, + /* 120 */ 521, 151, 1805, 1806, 559, 1810, 154, 559, 523, 1587, + /* 130 */ 1861, 39, 37, 1347, 1726, 159, 1217, 347, 372, 321, + /* 140 */ 1757, 1217, 296, 87, 1727, 545, 1729, 1730, 541, 1215, + /* 150 */ 562, 513, 1548, 1797, 1215, 1548, 508, 295, 1793, 467, + /* 160 */ 466, 1218, 1744, 1216, 465, 1242, 1255, 116, 462, 1864, + /* 170 */ 522, 461, 460, 459, 1308, 1696, 43, 542, 14, 1223, + /* 180 */ 1241, 11, 10, 156, 1223, 1221, 1222, 1861, 1270, 1271, + /* 190 */ 1273, 1274, 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, + /* 200 */ 1290, 2, 1757, 1240, 305, 88, 1727, 545, 1729, 1730, + /* 210 */ 541, 186, 562, 157, 546, 1797, 374, 157, 641, 314, + /* 220 */ 1793, 150, 324, 641, 1644, 142, 1309, 1371, 514, 509, + /* 230 */ 449, 445, 441, 437, 185, 1354, 1223, 1288, 1289, 33, + /* 240 */ 32, 1241, 1826, 40, 38, 36, 35, 34, 157, 1314, + /* 250 */ 39, 37, 306, 292, 304, 303, 596, 455, 321, 70, + /* 260 */ 1217, 457, 183, 1322, 505, 1369, 1370, 1372, 1373, 1594, + /* 270 */ 1595, 39, 37, 1215, 22, 1218, 599, 1216, 519, 321, + /* 280 */ 1218, 1217, 1216, 456, 29, 319, 1303, 1304, 1305, 1306, + /* 290 */ 1307, 1311, 1312, 1313, 1215, 1242, 1296, 14, 414, 1221, + /* 300 */ 1222, 418, 1241, 1223, 1221, 1222, 119, 1270, 1271, 1273, + /* 310 */ 1274, 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, + /* 320 */ 2, 519, 182, 175, 1223, 180, 523, 101, 1539, 428, + /* 330 */ 100, 99, 98, 97, 96, 95, 94, 93, 92, 1710, + /* 340 */ 139, 8, 641, 1726, 1505, 117, 33, 32, 173, 119, + /* 350 */ 40, 38, 36, 35, 34, 481, 1288, 1289, 1714, 588, + /* 360 */ 228, 1805, 518, 641, 517, 1706, 1712, 1864, 479, 1710, + /* 370 */ 477, 1744, 988, 138, 987, 1426, 562, 1288, 1289, 543, + /* 380 */ 600, 156, 1520, 420, 1696, 1861, 542, 451, 117, 1239, + /* 390 */ 39, 37, 1291, 1120, 1121, 1706, 1712, 499, 321, 1218, + /* 400 */ 1217, 1216, 989, 152, 1805, 1806, 562, 1810, 1526, 422, + /* 410 */ 1272, 1757, 418, 1215, 284, 1727, 545, 1729, 1730, 541, + /* 420 */ 1218, 562, 1216, 1221, 1222, 1537, 1270, 1271, 1273, 1274, + /* 430 */ 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, 519, + /* 440 */ 1437, 558, 594, 1223, 1221, 1222, 69, 1270, 1271, 1273, + /* 450 */ 1274, 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, + /* 460 */ 9, 127, 126, 591, 590, 589, 432, 119, 1544, 33, + /* 470 */ 32, 1272, 157, 40, 38, 36, 35, 34, 988, 200, + /* 480 */ 987, 1696, 641, 1436, 33, 32, 135, 523, 40, 38, + /* 490 */ 36, 35, 34, 359, 33, 32, 1288, 1289, 40, 38, + /* 500 */ 36, 35, 34, 42, 60, 1812, 117, 559, 989, 39, + /* 510 */ 37, 464, 463, 361, 357, 559, 559, 321, 373, 1217, + /* 520 */ 296, 228, 1805, 518, 1696, 517, 111, 111, 1864, 1809, + /* 530 */ 39, 37, 1215, 453, 458, 1548, 71, 294, 321, 1218, + /* 540 */ 1217, 1216, 154, 1548, 1548, 1243, 1861, 36, 35, 34, + /* 550 */ 33, 32, 1308, 1215, 40, 38, 36, 35, 34, 1381, + /* 560 */ 612, 610, 1223, 1221, 1222, 1415, 1270, 1271, 1273, 1274, + /* 570 */ 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, 9, + /* 580 */ 1524, 490, 367, 1223, 366, 405, 101, 1533, 1636, 100, + /* 590 */ 99, 98, 97, 96, 95, 94, 93, 92, 1600, 166, + /* 600 */ 2, 641, 33, 32, 1309, 332, 40, 38, 36, 35, + /* 610 */ 34, 325, 559, 331, 1598, 1288, 1289, 1414, 1435, 136, + /* 620 */ 1427, 136, 641, 375, 1455, 1361, 164, 1314, 1550, 208, + /* 630 */ 1550, 168, 167, 1434, 157, 157, 1288, 1289, 596, 201, + /* 640 */ 1548, 110, 109, 108, 107, 106, 105, 104, 103, 102, + /* 650 */ 559, 67, 1812, 7, 66, 60, 519, 73, 1218, 1696, + /* 660 */ 1216, 390, 29, 319, 1303, 1304, 1305, 1306, 1307, 1311, + /* 670 */ 1312, 1313, 636, 230, 1696, 1310, 1808, 1255, 1548, 1218, + /* 680 */ 1433, 1216, 1221, 1222, 119, 1270, 1271, 1273, 1274, 1275, + /* 690 */ 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, 1315, 1199, + /* 700 */ 1200, 1535, 497, 1221, 1222, 1476, 1270, 1271, 1273, 1274, + /* 710 */ 1275, 1276, 1277, 538, 560, 1285, 1286, 1287, 1290, 334, + /* 720 */ 136, 1696, 291, 117, 1239, 137, 1040, 136, 1812, 1551, + /* 730 */ 269, 398, 592, 27, 410, 1591, 1550, 58, 153, 1805, + /* 740 */ 1806, 457, 1810, 1864, 267, 57, 1600, 1432, 56, 1479, + /* 750 */ 546, 383, 1807, 411, 1412, 385, 1042, 154, 1241, 559, + /* 760 */ 1645, 1861, 1599, 456, 169, 527, 618, 617, 616, 336, + /* 770 */ 391, 615, 614, 613, 121, 608, 607, 606, 605, 604, + /* 780 */ 603, 602, 601, 129, 597, 376, 157, 1548, 1696, 60, + /* 790 */ 1078, 585, 584, 583, 1082, 582, 1084, 1085, 581, 1087, + /* 800 */ 578, 1525, 1093, 575, 1095, 1096, 572, 569, 1523, 593, + /* 810 */ 467, 466, 1591, 338, 483, 465, 1531, 263, 116, 462, + /* 820 */ 1578, 204, 461, 460, 459, 409, 1342, 86, 404, 403, + /* 830 */ 402, 401, 400, 397, 396, 395, 394, 393, 389, 388, + /* 840 */ 387, 386, 380, 379, 378, 377, 975, 976, 559, 1244, + /* 850 */ 537, 1431, 1430, 559, 1864, 1864, 1429, 328, 327, 431, + /* 860 */ 64, 63, 371, 1428, 1545, 163, 559, 1231, 154, 154, + /* 870 */ 1726, 365, 1861, 1861, 1346, 559, 1548, 1673, 1425, 1466, + /* 880 */ 1224, 1548, 290, 1817, 1342, 355, 556, 353, 349, 345, + /* 890 */ 160, 340, 1696, 1696, 1548, 594, 1424, 1696, 1744, 1423, + /* 900 */ 530, 468, 594, 1548, 1696, 191, 543, 1506, 189, 1422, + /* 910 */ 1223, 1696, 1421, 542, 127, 126, 591, 590, 589, 1696, + /* 920 */ 157, 127, 126, 591, 590, 589, 523, 1272, 1420, 1726, + /* 930 */ 1419, 207, 1418, 1417, 52, 494, 193, 1696, 1757, 192, + /* 940 */ 1696, 87, 1727, 545, 1729, 1730, 541, 472, 562, 563, + /* 950 */ 1696, 1797, 559, 1696, 528, 295, 1793, 1744, 195, 72, + /* 960 */ 535, 194, 482, 491, 525, 543, 1461, 1864, 559, 1696, + /* 970 */ 1696, 1696, 542, 1696, 1696, 1713, 199, 211, 329, 495, + /* 980 */ 1548, 154, 11, 10, 197, 1861, 1710, 196, 470, 1226, + /* 990 */ 475, 611, 1726, 587, 469, 1459, 1548, 1757, 559, 198, + /* 1000 */ 88, 1727, 545, 1729, 1730, 541, 1232, 562, 1227, 557, + /* 1010 */ 1797, 559, 1706, 1712, 314, 1793, 1877, 473, 50, 215, + /* 1020 */ 1744, 41, 252, 562, 55, 1832, 1548, 54, 543, 559, + /* 1030 */ 1235, 362, 41, 1696, 83, 542, 1409, 1410, 1716, 1548, + /* 1040 */ 335, 560, 1285, 1286, 80, 41, 1225, 241, 506, 234, + /* 1050 */ 123, 450, 124, 1726, 222, 125, 1745, 1548, 1368, 217, + /* 1060 */ 1757, 1316, 50, 88, 1727, 545, 1729, 1730, 541, 1012, + /* 1070 */ 562, 484, 1278, 1797, 1718, 1726, 337, 314, 1793, 1877, + /* 1080 */ 567, 1744, 124, 125, 1345, 1170, 1300, 243, 1855, 543, + /* 1090 */ 551, 531, 249, 1450, 1696, 1071, 542, 112, 1588, 1013, + /* 1100 */ 1828, 124, 262, 1744, 520, 233, 236, 238, 3, 5, + /* 1110 */ 339, 543, 1239, 342, 346, 301, 1696, 1229, 542, 1040, + /* 1120 */ 1099, 1757, 1103, 1110, 89, 1727, 545, 1729, 1730, 541, + /* 1130 */ 302, 562, 1183, 392, 1797, 259, 1726, 1108, 1796, 1793, + /* 1140 */ 1638, 128, 165, 1757, 399, 406, 88, 1727, 545, 1729, + /* 1150 */ 1730, 541, 408, 562, 412, 1245, 1797, 407, 413, 421, + /* 1160 */ 314, 1793, 1877, 1248, 1744, 424, 172, 425, 1247, 426, + /* 1170 */ 174, 1816, 543, 1249, 1228, 427, 177, 1696, 429, 542, + /* 1180 */ 179, 1246, 430, 181, 68, 433, 184, 452, 454, 1726, + /* 1190 */ 1538, 188, 523, 1678, 1534, 190, 293, 130, 131, 91, + /* 1200 */ 1677, 1536, 260, 1726, 1757, 485, 1532, 276, 1727, 545, + /* 1210 */ 1729, 1730, 541, 492, 562, 132, 133, 1744, 202, 489, + /* 1220 */ 205, 209, 486, 496, 502, 543, 1244, 507, 6, 516, + /* 1230 */ 1696, 1744, 542, 1864, 311, 549, 213, 1839, 504, 543, + /* 1240 */ 1838, 313, 144, 510, 1696, 523, 542, 156, 216, 1819, + /* 1250 */ 1829, 1861, 221, 503, 224, 1726, 501, 1757, 500, 226, + /* 1260 */ 276, 1727, 545, 1729, 1730, 541, 118, 562, 1342, 1243, + /* 1270 */ 44, 1757, 529, 1726, 89, 1727, 545, 1729, 1730, 541, + /* 1280 */ 532, 562, 225, 1744, 1797, 1813, 1864, 315, 534, 1793, + /* 1290 */ 18, 540, 227, 1643, 223, 1860, 1696, 1642, 542, 232, + /* 1300 */ 154, 1744, 1778, 552, 1861, 547, 548, 553, 323, 543, + /* 1310 */ 245, 79, 554, 1549, 1696, 261, 542, 1880, 247, 77, + /* 1320 */ 526, 533, 235, 1757, 565, 1726, 283, 1727, 545, 1729, + /* 1330 */ 1730, 541, 539, 562, 536, 1769, 1592, 237, 1521, 255, + /* 1340 */ 264, 1757, 1726, 637, 140, 1727, 545, 1729, 1730, 541, + /* 1350 */ 640, 562, 638, 1744, 266, 51, 143, 285, 287, 286, + /* 1360 */ 268, 543, 1690, 1689, 62, 1688, 1696, 341, 542, 1685, + /* 1370 */ 1744, 343, 344, 1210, 1211, 161, 348, 1683, 543, 350, + /* 1380 */ 351, 352, 1682, 1696, 354, 542, 1681, 356, 1680, 524, + /* 1390 */ 1878, 1726, 358, 1757, 1679, 360, 89, 1727, 545, 1729, + /* 1400 */ 1730, 541, 1663, 562, 363, 162, 1797, 364, 1186, 1185, + /* 1410 */ 1757, 1794, 1657, 279, 1727, 545, 1729, 1730, 541, 1744, + /* 1420 */ 562, 1656, 369, 370, 1655, 1654, 1157, 543, 1631, 65, + /* 1430 */ 1630, 1629, 1696, 1628, 542, 1627, 1626, 381, 382, 1625, + /* 1440 */ 384, 1624, 1623, 1622, 1621, 1620, 1619, 1618, 1617, 1616, + /* 1450 */ 1615, 1726, 515, 1614, 1613, 1612, 1611, 122, 1610, 1757, + /* 1460 */ 1726, 170, 140, 1727, 545, 1729, 1730, 541, 113, 562, + /* 1470 */ 1609, 1608, 1607, 1606, 1605, 1604, 33, 32, 1603, 1744, + /* 1480 */ 40, 38, 36, 35, 34, 1159, 1602, 543, 1744, 1601, + /* 1490 */ 1478, 1446, 1696, 978, 542, 977, 540, 417, 1445, 171, + /* 1500 */ 148, 1696, 1671, 542, 114, 318, 419, 1665, 1879, 1726, + /* 1510 */ 178, 1652, 1640, 1527, 1477, 176, 1475, 1473, 434, 1757, + /* 1520 */ 1653, 1726, 284, 1727, 545, 1729, 1730, 541, 1757, 562, + /* 1530 */ 438, 283, 1727, 545, 1729, 1730, 541, 1744, 562, 435, + /* 1540 */ 1770, 439, 1006, 436, 440, 543, 1471, 443, 444, 1744, + /* 1550 */ 1696, 1469, 542, 442, 446, 447, 1458, 543, 1457, 1442, + /* 1560 */ 448, 1529, 1696, 320, 542, 1114, 1113, 1528, 49, 187, + /* 1570 */ 1039, 1038, 644, 1037, 1726, 322, 1036, 1757, 1033, 1467, + /* 1580 */ 284, 1727, 545, 1729, 1730, 541, 258, 562, 609, 1757, + /* 1590 */ 1726, 611, 284, 1727, 545, 1729, 1730, 541, 1032, 562, + /* 1600 */ 147, 1031, 1744, 307, 1462, 634, 630, 626, 622, 256, + /* 1610 */ 543, 308, 1460, 471, 309, 1696, 1441, 542, 1744, 474, + /* 1620 */ 476, 1407, 1440, 478, 1439, 480, 543, 90, 1670, 1193, + /* 1630 */ 1664, 1696, 53, 542, 85, 487, 134, 250, 493, 1726, + /* 1640 */ 1651, 488, 1757, 1649, 206, 270, 1727, 545, 1729, 1730, + /* 1650 */ 541, 310, 562, 1650, 1648, 1647, 23, 4, 1757, 1383, + /* 1660 */ 41, 271, 1727, 545, 1729, 1730, 541, 1744, 562, 214, + /* 1670 */ 555, 220, 212, 141, 47, 543, 1367, 218, 24, 15, + /* 1680 */ 1696, 1360, 542, 1716, 219, 25, 10, 74, 46, 1339, + /* 1690 */ 229, 1338, 145, 1400, 17, 1395, 1394, 316, 45, 1726, + /* 1700 */ 210, 1389, 16, 1406, 1399, 1398, 317, 1757, 1726, 1301, + /* 1710 */ 272, 1727, 545, 1729, 1730, 541, 19, 562, 13, 1280, + /* 1720 */ 146, 1191, 1279, 203, 158, 1263, 544, 1744, 550, 31, + /* 1730 */ 12, 20, 1639, 246, 21, 543, 1744, 1715, 251, 240, + /* 1740 */ 1696, 1365, 542, 248, 543, 242, 1233, 244, 75, 1696, + /* 1750 */ 76, 542, 564, 566, 1760, 330, 570, 1726, 1282, 80, + /* 1760 */ 1100, 561, 48, 568, 573, 1097, 1094, 1757, 571, 1726, + /* 1770 */ 278, 1727, 545, 1729, 1730, 541, 1757, 562, 574, 280, + /* 1780 */ 1727, 545, 1729, 1730, 541, 1744, 562, 1088, 576, 577, + /* 1790 */ 579, 1086, 580, 543, 1092, 1091, 1090, 1744, 1696, 1089, + /* 1800 */ 542, 1077, 1109, 586, 81, 543, 253, 82, 59, 1105, + /* 1810 */ 1696, 1004, 542, 595, 1046, 1028, 598, 254, 1026, 1025, + /* 1820 */ 1726, 1024, 1021, 1023, 1022, 1757, 1020, 1019, 273, 1727, + /* 1830 */ 545, 1729, 1730, 541, 1726, 562, 1043, 1757, 1041, 1016, + /* 1840 */ 281, 1727, 545, 1729, 1730, 541, 1015, 562, 1744, 1014, + /* 1850 */ 1011, 1010, 1009, 1474, 619, 620, 543, 621, 1472, 623, + /* 1860 */ 624, 1696, 1744, 542, 625, 1470, 627, 628, 629, 1468, + /* 1870 */ 543, 631, 633, 632, 1456, 1696, 635, 542, 968, 1438, + /* 1880 */ 643, 257, 639, 1413, 1219, 1726, 265, 642, 1757, 1413, + /* 1890 */ 1413, 274, 1727, 545, 1729, 1730, 541, 1726, 562, 1413, + /* 1900 */ 1413, 1413, 1757, 1413, 1413, 282, 1727, 545, 1729, 1730, + /* 1910 */ 541, 1726, 562, 1744, 1413, 1413, 1413, 1413, 1413, 1413, + /* 1920 */ 1413, 543, 1413, 1413, 1413, 1744, 1696, 1413, 542, 1413, + /* 1930 */ 1413, 1413, 1413, 543, 1413, 1413, 1413, 1413, 1696, 1744, + /* 1940 */ 542, 1413, 1413, 1413, 1413, 1413, 1413, 543, 1413, 1413, + /* 1950 */ 1413, 1413, 1696, 1757, 542, 1413, 275, 1727, 545, 1729, + /* 1960 */ 1730, 541, 1726, 562, 1413, 1757, 1413, 1413, 288, 1727, + /* 1970 */ 545, 1729, 1730, 541, 1413, 562, 1413, 1413, 1413, 1757, + /* 1980 */ 1413, 1413, 289, 1727, 545, 1729, 1730, 541, 1726, 562, + /* 1990 */ 1744, 1413, 1413, 1413, 1413, 1413, 1413, 1413, 543, 1413, + /* 2000 */ 1413, 1413, 1413, 1696, 1413, 542, 1413, 1413, 1413, 1413, + /* 2010 */ 1413, 1413, 1413, 1413, 1413, 1413, 1744, 1413, 1413, 1413, + /* 2020 */ 1413, 1413, 1413, 1413, 543, 1413, 1413, 1413, 1413, 1696, + /* 2030 */ 1757, 542, 1413, 1738, 1727, 545, 1729, 1730, 541, 1413, + /* 2040 */ 562, 1726, 1413, 1413, 1413, 1413, 1413, 1413, 1413, 1413, + /* 2050 */ 1413, 1413, 1413, 1726, 1413, 1413, 1757, 1413, 1413, 1737, + /* 2060 */ 1727, 545, 1729, 1730, 541, 1413, 562, 1413, 1413, 1744, + /* 2070 */ 1413, 1413, 1413, 1413, 1413, 1413, 1413, 543, 1413, 1413, + /* 2080 */ 1413, 1744, 1696, 1413, 542, 1413, 1413, 1413, 1413, 543, + /* 2090 */ 1413, 1413, 1413, 1413, 1696, 1413, 542, 1413, 1413, 1413, + /* 2100 */ 1413, 1413, 1413, 1413, 1726, 1413, 1413, 1413, 1413, 1757, + /* 2110 */ 1413, 1413, 1736, 1727, 545, 1729, 1730, 541, 1726, 562, + /* 2120 */ 1413, 1757, 1413, 1413, 299, 1727, 545, 1729, 1730, 541, + /* 2130 */ 1413, 562, 1744, 1413, 1413, 1413, 1413, 1413, 1413, 1413, + /* 2140 */ 543, 1413, 1413, 1413, 1413, 1696, 1744, 542, 1413, 1413, + /* 2150 */ 1413, 1413, 1413, 1413, 543, 1413, 1413, 1413, 1413, 1696, + /* 2160 */ 1413, 542, 1413, 1413, 1413, 1413, 1413, 1413, 1413, 1726, + /* 2170 */ 1413, 1413, 1757, 1413, 1413, 298, 1727, 545, 1729, 1730, + /* 2180 */ 541, 1726, 562, 1413, 1413, 1413, 1757, 1413, 1413, 300, + /* 2190 */ 1727, 545, 1729, 1730, 541, 1413, 562, 1744, 1413, 1413, + /* 2200 */ 1413, 1413, 1413, 1413, 1413, 543, 1413, 1413, 1413, 1744, + /* 2210 */ 1696, 1413, 542, 1413, 1413, 1413, 1413, 543, 1413, 1413, + /* 2220 */ 1413, 1413, 1696, 1413, 542, 1413, 1413, 1413, 1413, 1413, + /* 2230 */ 1413, 1413, 1413, 1413, 1413, 1413, 1413, 1757, 1413, 1413, + /* 2240 */ 297, 1727, 545, 1729, 1730, 541, 1413, 562, 1413, 1757, + /* 2250 */ 1413, 1413, 277, 1727, 545, 1729, 1730, 541, 1413, 562, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 274, 341, 273, 277, 248, 274, 250, 251, 277, 242, - /* 10 */ 257, 285, 12, 13, 261, 355, 285, 245, 14, 359, - /* 20 */ 20, 252, 22, 252, 20, 12, 13, 14, 15, 16, - /* 30 */ 12, 13, 263, 248, 263, 250, 251, 311, 312, 270, - /* 40 */ 22, 270, 311, 312, 272, 326, 327, 47, 322, 280, - /* 50 */ 313, 280, 280, 322, 41, 252, 20, 285, 58, 287, - /* 60 */ 12, 13, 14, 264, 64, 47, 263, 300, 20, 245, - /* 70 */ 22, 272, 300, 300, 337, 12, 13, 14, 15, 16, - /* 80 */ 281, 81, 64, 280, 312, 256, 20, 315, 316, 317, - /* 90 */ 318, 319, 320, 81, 322, 47, 272, 325, 269, 254, - /* 100 */ 252, 329, 330, 103, 280, 252, 58, 278, 341, 285, - /* 110 */ 245, 287, 64, 341, 341, 287, 263, 117, 118, 4, - /* 120 */ 275, 103, 355, 4, 20, 297, 359, 355, 355, 81, - /* 130 */ 57, 359, 359, 280, 55, 254, 312, 289, 19, 315, - /* 140 */ 316, 317, 318, 319, 320, 82, 322, 81, 267, 325, - /* 150 */ 285, 103, 33, 329, 330, 331, 275, 42, 43, 159, - /* 160 */ 81, 161, 83, 264, 45, 117, 118, 343, 3, 50, - /* 170 */ 158, 272, 160, 20, 55, 351, 352, 159, 283, 161, - /* 180 */ 281, 286, 287, 183, 184, 81, 186, 187, 188, 189, - /* 190 */ 190, 191, 192, 193, 194, 195, 196, 197, 198, 80, - /* 200 */ 20, 183, 83, 286, 287, 2, 4, 159, 341, 161, - /* 210 */ 20, 211, 194, 195, 196, 12, 13, 14, 15, 16, - /* 220 */ 12, 13, 355, 211, 245, 245, 359, 75, 20, 256, - /* 230 */ 22, 183, 184, 35, 186, 187, 188, 189, 190, 191, - /* 240 */ 192, 193, 194, 195, 196, 197, 198, 252, 272, 60, - /* 250 */ 61, 278, 272, 300, 65, 47, 280, 68, 69, 0, - /* 260 */ 280, 72, 73, 74, 285, 285, 58, 287, 12, 13, - /* 270 */ 117, 118, 64, 121, 122, 280, 20, 211, 22, 142, - /* 280 */ 300, 0, 84, 81, 86, 87, 154, 89, 81, 81, - /* 290 */ 211, 93, 312, 317, 341, 315, 316, 317, 318, 319, - /* 300 */ 320, 164, 322, 47, 45, 325, 174, 175, 355, 329, - /* 310 */ 330, 103, 359, 115, 319, 12, 13, 14, 15, 16, - /* 320 */ 64, 341, 244, 274, 246, 117, 118, 0, 333, 334, - /* 330 */ 335, 336, 20, 338, 285, 355, 199, 81, 57, 359, - /* 340 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, - /* 350 */ 104, 0, 106, 107, 108, 109, 110, 111, 81, 103, - /* 360 */ 311, 312, 12, 13, 14, 15, 16, 159, 91, 161, - /* 370 */ 183, 322, 21, 117, 118, 24, 25, 26, 27, 28, - /* 380 */ 29, 30, 31, 32, 57, 82, 12, 13, 14, 15, - /* 390 */ 16, 183, 184, 228, 186, 187, 188, 189, 190, 191, - /* 400 */ 192, 193, 194, 195, 196, 197, 198, 220, 221, 222, - /* 410 */ 223, 224, 20, 211, 22, 159, 21, 161, 211, 24, - /* 420 */ 25, 26, 27, 28, 29, 30, 31, 32, 12, 13, - /* 430 */ 14, 1, 2, 245, 258, 259, 20, 55, 22, 183, - /* 440 */ 184, 49, 186, 187, 188, 189, 190, 191, 192, 193, - /* 450 */ 194, 195, 196, 197, 198, 12, 13, 14, 15, 16, - /* 460 */ 272, 300, 80, 47, 341, 83, 57, 211, 280, 20, - /* 470 */ 271, 22, 272, 285, 20, 287, 12, 13, 355, 279, - /* 480 */ 64, 0, 359, 284, 20, 313, 22, 245, 288, 64, - /* 490 */ 12, 13, 14, 15, 16, 245, 47, 81, 49, 20, - /* 500 */ 312, 151, 341, 315, 316, 317, 318, 319, 320, 337, - /* 510 */ 322, 47, 82, 325, 113, 272, 355, 329, 330, 103, - /* 520 */ 359, 287, 148, 272, 281, 82, 14, 285, 64, 295, - /* 530 */ 279, 297, 20, 117, 118, 285, 58, 258, 259, 288, - /* 540 */ 245, 60, 61, 62, 63, 81, 65, 66, 67, 68, - /* 550 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, - /* 560 */ 82, 0, 12, 13, 14, 15, 16, 103, 90, 146, - /* 570 */ 169, 170, 14, 42, 43, 159, 245, 161, 20, 245, - /* 580 */ 285, 117, 118, 233, 2, 24, 25, 26, 27, 28, - /* 590 */ 29, 30, 31, 32, 12, 13, 14, 15, 16, 183, - /* 600 */ 184, 0, 186, 187, 188, 189, 190, 191, 192, 193, - /* 610 */ 194, 195, 196, 197, 198, 252, 285, 272, 272, 285, - /* 620 */ 142, 264, 92, 159, 279, 161, 263, 148, 273, 272, - /* 630 */ 14, 15, 16, 288, 288, 245, 12, 13, 281, 216, - /* 640 */ 217, 112, 164, 280, 20, 93, 22, 183, 184, 245, - /* 650 */ 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, - /* 660 */ 196, 197, 198, 252, 112, 113, 114, 115, 116, 249, - /* 670 */ 249, 47, 252, 252, 263, 285, 252, 199, 200, 201, - /* 680 */ 202, 203, 204, 205, 206, 207, 208, 263, 64, 285, - /* 690 */ 33, 280, 252, 265, 93, 260, 268, 262, 245, 187, - /* 700 */ 171, 172, 45, 263, 280, 81, 245, 252, 51, 52, - /* 710 */ 53, 54, 55, 112, 113, 114, 115, 116, 263, 313, - /* 720 */ 280, 274, 245, 4, 18, 20, 20, 103, 245, 44, - /* 730 */ 245, 93, 285, 27, 37, 280, 30, 80, 285, 252, - /* 740 */ 83, 117, 118, 337, 252, 187, 285, 245, 245, 272, - /* 750 */ 263, 45, 20, 115, 48, 263, 50, 280, 311, 312, - /* 760 */ 18, 41, 285, 252, 287, 23, 81, 280, 285, 322, - /* 770 */ 285, 280, 280, 252, 263, 298, 282, 35, 36, 285, - /* 780 */ 41, 39, 291, 159, 263, 161, 80, 285, 285, 312, - /* 790 */ 64, 280, 315, 316, 317, 318, 319, 320, 56, 322, - /* 800 */ 143, 280, 145, 0, 147, 273, 149, 183, 184, 245, - /* 810 */ 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, - /* 820 */ 196, 197, 198, 81, 282, 168, 120, 285, 273, 123, - /* 830 */ 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, - /* 840 */ 134, 135, 136, 137, 138, 139, 140, 273, 47, 285, - /* 850 */ 12, 13, 14, 15, 16, 252, 252, 22, 252, 252, - /* 860 */ 245, 119, 245, 60, 61, 64, 263, 263, 65, 263, - /* 870 */ 245, 68, 69, 209, 210, 72, 73, 74, 41, 0, - /* 880 */ 148, 273, 47, 280, 280, 85, 280, 280, 88, 304, - /* 890 */ 245, 0, 187, 151, 152, 153, 58, 47, 156, 64, - /* 900 */ 285, 22, 285, 85, 162, 252, 88, 210, 85, 85, - /* 910 */ 285, 88, 88, 0, 0, 173, 273, 272, 176, 82, - /* 920 */ 178, 179, 180, 181, 182, 280, 319, 21, 90, 246, - /* 930 */ 285, 212, 287, 280, 47, 22, 22, 41, 103, 47, - /* 940 */ 34, 334, 335, 336, 58, 338, 362, 1, 2, 41, - /* 950 */ 230, 41, 261, 211, 253, 353, 64, 312, 245, 308, - /* 960 */ 315, 316, 317, 318, 319, 320, 0, 322, 117, 118, - /* 970 */ 325, 232, 319, 41, 329, 330, 331, 348, 82, 41, - /* 980 */ 142, 272, 245, 253, 93, 272, 41, 334, 335, 336, - /* 990 */ 82, 338, 82, 280, 159, 41, 161, 352, 285, 251, - /* 1000 */ 287, 284, 164, 112, 113, 114, 115, 116, 314, 272, - /* 1010 */ 41, 161, 46, 339, 82, 356, 356, 280, 183, 184, - /* 1020 */ 82, 356, 285, 245, 287, 312, 342, 82, 315, 316, - /* 1030 */ 317, 318, 319, 320, 41, 322, 82, 199, 200, 201, - /* 1040 */ 202, 203, 204, 205, 206, 207, 208, 41, 161, 312, - /* 1050 */ 272, 82, 315, 316, 317, 318, 319, 320, 280, 322, - /* 1060 */ 41, 41, 325, 285, 245, 287, 329, 330, 331, 183, - /* 1070 */ 41, 41, 41, 41, 213, 82, 310, 340, 20, 252, - /* 1080 */ 45, 309, 157, 47, 258, 302, 252, 40, 82, 292, - /* 1090 */ 312, 272, 252, 315, 316, 317, 318, 319, 320, 280, - /* 1100 */ 322, 82, 82, 325, 285, 142, 287, 329, 330, 331, - /* 1110 */ 290, 82, 82, 82, 82, 290, 252, 20, 340, 247, - /* 1120 */ 247, 20, 306, 256, 256, 20, 287, 299, 20, 299, - /* 1130 */ 301, 312, 256, 256, 315, 316, 317, 318, 319, 320, - /* 1140 */ 245, 322, 280, 20, 325, 293, 256, 247, 329, 330, - /* 1150 */ 331, 252, 272, 256, 256, 272, 272, 272, 167, 340, - /* 1160 */ 272, 272, 247, 252, 306, 272, 272, 272, 305, 287, - /* 1170 */ 254, 254, 252, 272, 272, 280, 272, 299, 254, 20, - /* 1180 */ 285, 254, 287, 314, 219, 218, 225, 280, 285, 347, - /* 1190 */ 285, 347, 150, 350, 349, 300, 347, 285, 227, 346, - /* 1200 */ 226, 345, 293, 245, 285, 210, 285, 312, 214, 344, - /* 1210 */ 315, 316, 317, 318, 319, 320, 285, 322, 296, 296, - /* 1220 */ 245, 280, 20, 40, 358, 81, 229, 231, 310, 358, - /* 1230 */ 272, 357, 234, 363, 285, 285, 341, 285, 280, 313, - /* 1240 */ 296, 145, 280, 285, 296, 287, 293, 272, 268, 294, - /* 1250 */ 355, 81, 280, 254, 359, 280, 254, 276, 300, 252, - /* 1260 */ 285, 332, 287, 328, 285, 262, 254, 303, 247, 255, - /* 1270 */ 312, 266, 0, 315, 316, 317, 318, 319, 320, 266, - /* 1280 */ 322, 266, 243, 245, 307, 357, 0, 312, 358, 40, - /* 1290 */ 315, 316, 317, 318, 319, 320, 357, 322, 0, 341, - /* 1300 */ 325, 245, 72, 0, 329, 330, 47, 177, 47, 47, - /* 1310 */ 272, 47, 177, 355, 0, 47, 47, 359, 280, 177, - /* 1320 */ 0, 0, 177, 285, 47, 287, 0, 22, 272, 0, - /* 1330 */ 47, 0, 81, 164, 163, 161, 280, 159, 0, 0, - /* 1340 */ 155, 285, 154, 287, 0, 0, 44, 0, 141, 0, - /* 1350 */ 312, 136, 245, 315, 316, 317, 318, 319, 320, 321, - /* 1360 */ 322, 323, 324, 0, 0, 0, 0, 0, 312, 47, - /* 1370 */ 19, 315, 316, 317, 318, 319, 320, 136, 322, 272, - /* 1380 */ 0, 0, 0, 0, 33, 0, 0, 280, 0, 0, - /* 1390 */ 0, 0, 285, 252, 287, 0, 45, 0, 0, 0, - /* 1400 */ 40, 0, 51, 52, 53, 54, 55, 0, 0, 0, - /* 1410 */ 0, 0, 0, 245, 22, 0, 360, 361, 0, 312, - /* 1420 */ 0, 280, 315, 316, 317, 318, 319, 320, 0, 322, - /* 1430 */ 0, 80, 325, 40, 83, 41, 14, 330, 14, 37, - /* 1440 */ 272, 300, 0, 38, 44, 0, 0, 44, 280, 0, - /* 1450 */ 37, 37, 0, 285, 150, 287, 0, 0, 37, 0, - /* 1460 */ 319, 0, 37, 59, 45, 0, 245, 116, 37, 0, - /* 1470 */ 47, 0, 45, 47, 45, 334, 335, 336, 37, 338, - /* 1480 */ 312, 47, 341, 315, 316, 317, 318, 319, 320, 245, - /* 1490 */ 322, 47, 45, 272, 0, 144, 355, 37, 147, 0, - /* 1500 */ 359, 280, 0, 0, 88, 47, 285, 252, 287, 22, - /* 1510 */ 0, 47, 0, 47, 47, 47, 272, 166, 41, 168, - /* 1520 */ 41, 47, 354, 90, 280, 47, 22, 47, 0, 285, - /* 1530 */ 22, 287, 48, 312, 0, 280, 315, 316, 317, 318, - /* 1540 */ 319, 320, 298, 322, 22, 245, 0, 47, 22, 0, - /* 1550 */ 20, 22, 0, 47, 148, 300, 312, 0, 22, 315, - /* 1560 */ 316, 317, 318, 319, 320, 0, 322, 0, 0, 0, - /* 1570 */ 81, 215, 272, 41, 319, 37, 41, 82, 81, 81, - /* 1580 */ 280, 145, 361, 148, 41, 285, 143, 287, 148, 334, - /* 1590 */ 335, 336, 81, 338, 41, 82, 341, 165, 245, 82, - /* 1600 */ 81, 81, 44, 82, 44, 81, 44, 245, 44, 82, - /* 1610 */ 355, 41, 312, 82, 359, 315, 316, 317, 318, 319, - /* 1620 */ 320, 245, 322, 41, 324, 272, 82, 41, 47, 82, - /* 1630 */ 2, 47, 47, 280, 272, 47, 47, 47, 285, 41, - /* 1640 */ 287, 82, 280, 82, 81, 183, 44, 285, 272, 287, - /* 1650 */ 44, 298, 215, 81, 215, 81, 280, 209, 22, 81, - /* 1660 */ 298, 285, 245, 287, 0, 312, 185, 37, 315, 316, - /* 1670 */ 317, 318, 319, 320, 312, 322, 82, 315, 316, 317, - /* 1680 */ 318, 319, 320, 245, 322, 82, 81, 146, 312, 272, - /* 1690 */ 81, 315, 316, 317, 318, 319, 320, 280, 322, 81, - /* 1700 */ 81, 91, 285, 44, 287, 44, 81, 22, 82, 143, - /* 1710 */ 272, 82, 81, 81, 92, 47, 47, 82, 280, 81, - /* 1720 */ 47, 81, 47, 285, 82, 287, 81, 47, 82, 312, - /* 1730 */ 81, 47, 315, 316, 317, 318, 319, 320, 82, 322, - /* 1740 */ 22, 245, 105, 93, 81, 47, 105, 81, 105, 105, - /* 1750 */ 312, 81, 245, 315, 316, 317, 318, 319, 320, 81, - /* 1760 */ 322, 41, 22, 245, 59, 58, 47, 79, 272, 41, - /* 1770 */ 64, 22, 47, 47, 47, 64, 280, 47, 47, 272, - /* 1780 */ 47, 285, 47, 287, 47, 47, 47, 280, 47, 47, - /* 1790 */ 272, 47, 285, 47, 287, 0, 45, 47, 280, 37, - /* 1800 */ 0, 47, 45, 285, 37, 287, 0, 47, 312, 45, - /* 1810 */ 37, 315, 316, 317, 318, 319, 320, 0, 322, 312, - /* 1820 */ 45, 47, 315, 316, 317, 318, 319, 320, 245, 322, - /* 1830 */ 312, 37, 0, 315, 316, 317, 318, 319, 320, 47, - /* 1840 */ 322, 0, 22, 21, 245, 22, 22, 21, 20, 364, - /* 1850 */ 364, 364, 364, 364, 364, 272, 364, 364, 364, 364, - /* 1860 */ 364, 364, 364, 280, 364, 364, 364, 364, 285, 364, - /* 1870 */ 287, 272, 364, 364, 364, 364, 364, 364, 364, 280, - /* 1880 */ 364, 364, 364, 364, 285, 364, 287, 364, 364, 364, - /* 1890 */ 364, 364, 364, 245, 364, 312, 364, 364, 315, 316, - /* 1900 */ 317, 318, 319, 320, 364, 322, 364, 245, 364, 364, - /* 1910 */ 364, 312, 364, 364, 315, 316, 317, 318, 319, 320, - /* 1920 */ 272, 322, 364, 364, 364, 364, 364, 364, 280, 364, - /* 1930 */ 364, 364, 364, 285, 272, 287, 364, 364, 364, 364, - /* 1940 */ 364, 364, 280, 364, 364, 364, 364, 285, 245, 287, - /* 1950 */ 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, - /* 1960 */ 312, 364, 364, 315, 316, 317, 318, 319, 320, 245, - /* 1970 */ 322, 364, 364, 364, 312, 272, 364, 315, 316, 317, - /* 1980 */ 318, 319, 320, 280, 322, 364, 364, 364, 285, 364, - /* 1990 */ 287, 364, 364, 364, 364, 364, 272, 364, 364, 364, - /* 2000 */ 364, 364, 364, 364, 280, 364, 364, 364, 364, 285, - /* 2010 */ 364, 287, 364, 364, 364, 312, 364, 364, 315, 316, - /* 2020 */ 317, 318, 319, 320, 364, 322, 364, 245, 364, 364, - /* 2030 */ 364, 364, 364, 364, 364, 364, 312, 364, 245, 315, - /* 2040 */ 316, 317, 318, 319, 320, 364, 322, 364, 364, 245, - /* 2050 */ 364, 364, 364, 364, 272, 364, 364, 364, 364, 364, - /* 2060 */ 364, 364, 280, 364, 364, 272, 364, 285, 364, 287, - /* 2070 */ 364, 364, 364, 280, 364, 364, 272, 364, 285, 364, - /* 2080 */ 287, 364, 364, 364, 280, 364, 364, 364, 364, 285, - /* 2090 */ 245, 287, 364, 364, 312, 364, 364, 315, 316, 317, - /* 2100 */ 318, 319, 320, 364, 322, 312, 364, 364, 315, 316, - /* 2110 */ 317, 318, 319, 320, 245, 322, 312, 272, 364, 315, - /* 2120 */ 316, 317, 318, 319, 320, 280, 322, 364, 364, 364, - /* 2130 */ 285, 364, 287, 364, 364, 364, 364, 364, 364, 364, - /* 2140 */ 364, 272, 364, 364, 364, 364, 364, 364, 364, 280, - /* 2150 */ 364, 364, 364, 364, 285, 364, 287, 312, 364, 364, - /* 2160 */ 315, 316, 317, 318, 319, 320, 364, 322, 364, 364, - /* 2170 */ 364, 364, 364, 364, 364, 364, 364, 364, 364, 364, - /* 2180 */ 364, 312, 364, 364, 315, 316, 317, 318, 319, 320, - /* 2190 */ 364, 322, + /* 0 */ 257, 251, 247, 253, 254, 329, 330, 251, 4, 253, + /* 10 */ 254, 344, 12, 13, 344, 12, 13, 14, 15, 16, + /* 20 */ 20, 278, 22, 286, 259, 358, 289, 290, 358, 362, + /* 30 */ 275, 277, 362, 275, 280, 35, 20, 272, 283, 255, + /* 40 */ 282, 2, 288, 288, 4, 290, 281, 8, 9, 291, + /* 50 */ 2, 12, 13, 14, 15, 16, 8, 9, 275, 59, + /* 60 */ 12, 13, 14, 15, 16, 65, 283, 283, 314, 315, + /* 70 */ 315, 303, 247, 318, 319, 320, 321, 322, 323, 325, + /* 80 */ 325, 257, 82, 328, 44, 45, 82, 332, 333, 334, + /* 90 */ 0, 8, 9, 344, 270, 12, 13, 14, 15, 16, + /* 100 */ 275, 346, 278, 320, 104, 58, 322, 358, 283, 354, + /* 110 */ 355, 362, 344, 288, 20, 290, 274, 82, 118, 119, + /* 120 */ 336, 337, 338, 339, 255, 341, 358, 255, 303, 287, + /* 130 */ 362, 12, 13, 14, 247, 266, 22, 47, 266, 20, + /* 140 */ 315, 22, 59, 318, 319, 320, 321, 322, 323, 35, + /* 150 */ 325, 20, 283, 328, 35, 283, 146, 332, 333, 61, + /* 160 */ 62, 161, 275, 163, 66, 20, 83, 69, 70, 344, + /* 170 */ 283, 73, 74, 75, 91, 288, 82, 290, 59, 65, + /* 180 */ 20, 1, 2, 358, 65, 185, 186, 362, 188, 189, + /* 190 */ 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, + /* 200 */ 200, 82, 315, 20, 37, 318, 319, 320, 321, 322, + /* 210 */ 323, 33, 325, 213, 290, 328, 255, 213, 104, 332, + /* 220 */ 333, 334, 298, 104, 300, 47, 143, 185, 218, 219, + /* 230 */ 52, 53, 54, 55, 56, 14, 65, 118, 119, 8, + /* 240 */ 9, 20, 355, 12, 13, 14, 15, 16, 213, 166, + /* 250 */ 12, 13, 85, 292, 87, 88, 58, 90, 20, 81, + /* 260 */ 22, 94, 84, 83, 222, 223, 224, 225, 226, 289, + /* 270 */ 290, 12, 13, 35, 43, 161, 65, 163, 255, 20, + /* 280 */ 161, 22, 163, 116, 201, 202, 203, 204, 205, 206, + /* 290 */ 207, 208, 209, 210, 35, 20, 14, 59, 252, 185, + /* 300 */ 186, 255, 20, 65, 185, 186, 283, 188, 189, 190, + /* 310 */ 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, + /* 320 */ 82, 255, 144, 145, 65, 147, 303, 21, 277, 151, + /* 330 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 288, + /* 340 */ 260, 82, 104, 247, 264, 322, 8, 9, 170, 283, + /* 350 */ 12, 13, 14, 15, 16, 21, 118, 119, 277, 93, + /* 360 */ 337, 338, 339, 104, 341, 314, 315, 344, 34, 288, + /* 370 */ 36, 275, 20, 246, 22, 248, 325, 118, 119, 283, + /* 380 */ 263, 358, 265, 14, 288, 362, 290, 35, 322, 20, + /* 390 */ 12, 13, 14, 118, 119, 314, 315, 301, 20, 161, + /* 400 */ 22, 163, 50, 337, 338, 339, 325, 341, 0, 252, + /* 410 */ 189, 315, 255, 35, 318, 319, 320, 321, 322, 323, + /* 420 */ 161, 325, 163, 185, 186, 276, 188, 189, 190, 191, + /* 430 */ 192, 193, 194, 195, 196, 197, 198, 199, 200, 255, + /* 440 */ 247, 20, 94, 65, 185, 186, 259, 188, 189, 190, + /* 450 */ 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, + /* 460 */ 82, 113, 114, 115, 116, 117, 58, 283, 281, 8, + /* 470 */ 9, 189, 213, 12, 13, 14, 15, 16, 20, 114, + /* 480 */ 22, 288, 104, 247, 8, 9, 148, 303, 12, 13, + /* 490 */ 14, 15, 16, 156, 8, 9, 118, 119, 12, 13, + /* 500 */ 14, 15, 16, 82, 82, 316, 322, 255, 50, 12, + /* 510 */ 13, 261, 262, 176, 177, 255, 255, 20, 266, 22, + /* 520 */ 59, 337, 338, 339, 288, 341, 266, 266, 344, 340, + /* 530 */ 12, 13, 35, 273, 273, 283, 171, 172, 20, 161, + /* 540 */ 22, 163, 358, 283, 283, 20, 362, 14, 15, 16, + /* 550 */ 8, 9, 91, 35, 12, 13, 14, 15, 16, 83, + /* 560 */ 261, 262, 65, 185, 186, 0, 188, 189, 190, 191, + /* 570 */ 192, 193, 194, 195, 196, 197, 198, 199, 200, 82, + /* 580 */ 0, 307, 160, 65, 162, 76, 21, 276, 283, 24, + /* 590 */ 25, 26, 27, 28, 29, 30, 31, 32, 275, 294, + /* 600 */ 82, 104, 8, 9, 143, 282, 12, 13, 14, 15, + /* 610 */ 16, 267, 255, 267, 291, 118, 119, 0, 247, 275, + /* 620 */ 248, 275, 104, 266, 0, 83, 56, 166, 284, 56, + /* 630 */ 284, 122, 123, 247, 213, 213, 118, 119, 58, 113, + /* 640 */ 283, 24, 25, 26, 27, 28, 29, 30, 31, 32, + /* 650 */ 255, 81, 316, 39, 84, 82, 255, 84, 161, 288, + /* 660 */ 163, 266, 201, 202, 203, 204, 205, 206, 207, 208, + /* 670 */ 209, 210, 48, 148, 288, 143, 340, 83, 283, 161, + /* 680 */ 247, 163, 185, 186, 283, 188, 189, 190, 191, 192, + /* 690 */ 193, 194, 195, 196, 197, 198, 199, 200, 166, 173, + /* 700 */ 174, 276, 303, 185, 186, 0, 188, 189, 190, 191, + /* 710 */ 192, 193, 194, 195, 196, 197, 198, 199, 200, 267, + /* 720 */ 275, 288, 18, 322, 20, 18, 35, 275, 316, 284, + /* 730 */ 23, 27, 285, 201, 30, 288, 284, 3, 337, 338, + /* 740 */ 339, 94, 341, 344, 37, 38, 275, 247, 41, 0, + /* 750 */ 290, 47, 340, 49, 244, 51, 65, 358, 20, 255, + /* 760 */ 300, 362, 291, 116, 57, 43, 61, 62, 63, 64, + /* 770 */ 266, 66, 67, 68, 69, 70, 71, 72, 73, 74, + /* 780 */ 75, 76, 77, 78, 79, 81, 213, 283, 288, 82, + /* 790 */ 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, + /* 800 */ 105, 0, 107, 108, 109, 110, 111, 112, 0, 285, + /* 810 */ 61, 62, 288, 303, 303, 66, 276, 268, 69, 70, + /* 820 */ 271, 276, 73, 74, 75, 121, 212, 120, 124, 125, + /* 830 */ 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, + /* 840 */ 136, 137, 138, 139, 140, 141, 44, 45, 255, 20, + /* 850 */ 276, 247, 247, 255, 344, 344, 247, 12, 13, 266, + /* 860 */ 153, 154, 155, 247, 266, 158, 255, 22, 358, 358, + /* 870 */ 247, 164, 362, 362, 4, 255, 283, 266, 247, 0, + /* 880 */ 35, 283, 175, 211, 212, 178, 266, 180, 181, 182, + /* 890 */ 183, 184, 288, 288, 283, 94, 247, 288, 275, 247, + /* 900 */ 43, 22, 94, 283, 288, 86, 283, 264, 89, 247, + /* 910 */ 65, 288, 247, 290, 113, 114, 115, 116, 117, 288, + /* 920 */ 213, 113, 114, 115, 116, 117, 303, 189, 247, 247, + /* 930 */ 247, 56, 247, 247, 148, 149, 86, 288, 315, 89, + /* 940 */ 288, 318, 319, 320, 321, 322, 323, 4, 325, 104, + /* 950 */ 288, 328, 255, 288, 232, 332, 333, 275, 86, 84, + /* 960 */ 59, 89, 19, 266, 230, 283, 0, 344, 255, 288, + /* 970 */ 288, 288, 290, 288, 288, 277, 33, 148, 280, 266, + /* 980 */ 283, 358, 1, 2, 86, 362, 288, 89, 22, 35, + /* 990 */ 47, 43, 247, 276, 51, 0, 283, 315, 255, 56, + /* 1000 */ 318, 319, 320, 321, 322, 323, 161, 325, 163, 266, + /* 1010 */ 328, 255, 314, 315, 332, 333, 334, 22, 43, 43, + /* 1020 */ 275, 43, 266, 325, 81, 343, 283, 84, 283, 255, + /* 1030 */ 185, 83, 43, 288, 82, 290, 118, 119, 46, 283, + /* 1040 */ 266, 196, 197, 198, 92, 43, 35, 43, 356, 365, + /* 1050 */ 43, 256, 43, 247, 351, 43, 275, 283, 83, 83, + /* 1060 */ 315, 83, 43, 318, 319, 320, 321, 322, 323, 35, + /* 1070 */ 325, 311, 83, 328, 82, 247, 256, 332, 333, 334, + /* 1080 */ 43, 275, 43, 43, 214, 83, 185, 83, 343, 283, + /* 1090 */ 83, 234, 83, 254, 288, 83, 290, 43, 287, 65, + /* 1100 */ 317, 43, 83, 275, 342, 359, 359, 359, 345, 215, + /* 1110 */ 313, 283, 20, 255, 47, 312, 288, 163, 290, 35, + /* 1120 */ 83, 315, 83, 83, 318, 319, 320, 321, 322, 323, + /* 1130 */ 261, 325, 159, 255, 328, 305, 247, 83, 332, 333, + /* 1140 */ 255, 83, 42, 315, 295, 293, 318, 319, 320, 321, + /* 1150 */ 322, 323, 293, 325, 255, 20, 328, 143, 249, 249, + /* 1160 */ 332, 333, 334, 20, 275, 309, 259, 290, 20, 302, + /* 1170 */ 259, 343, 283, 20, 163, 304, 259, 288, 302, 290, + /* 1180 */ 259, 20, 296, 259, 259, 255, 259, 249, 275, 247, + /* 1190 */ 275, 275, 303, 288, 275, 275, 249, 275, 275, 255, + /* 1200 */ 288, 275, 309, 247, 315, 169, 275, 318, 319, 320, + /* 1210 */ 321, 322, 323, 255, 325, 275, 275, 275, 257, 290, + /* 1220 */ 257, 257, 308, 255, 288, 283, 20, 221, 227, 152, + /* 1230 */ 288, 275, 290, 344, 302, 220, 299, 350, 288, 283, + /* 1240 */ 350, 288, 350, 288, 288, 303, 290, 358, 299, 353, + /* 1250 */ 317, 362, 352, 229, 348, 247, 228, 315, 216, 313, + /* 1260 */ 318, 319, 320, 321, 322, 323, 283, 325, 212, 20, + /* 1270 */ 42, 315, 231, 247, 318, 319, 320, 321, 322, 323, + /* 1280 */ 233, 325, 347, 275, 328, 316, 344, 236, 332, 333, + /* 1290 */ 82, 283, 335, 299, 349, 361, 288, 299, 290, 360, + /* 1300 */ 358, 275, 331, 145, 362, 288, 288, 297, 288, 283, + /* 1310 */ 283, 82, 296, 283, 288, 271, 290, 366, 257, 257, + /* 1320 */ 361, 361, 360, 315, 279, 247, 318, 319, 320, 321, + /* 1330 */ 322, 323, 324, 325, 326, 327, 288, 360, 265, 257, + /* 1340 */ 255, 315, 247, 36, 318, 319, 320, 321, 322, 323, + /* 1350 */ 249, 325, 250, 275, 258, 306, 310, 269, 269, 269, + /* 1360 */ 245, 283, 0, 0, 42, 0, 288, 73, 290, 0, + /* 1370 */ 275, 35, 179, 35, 35, 35, 179, 0, 283, 35, + /* 1380 */ 35, 179, 0, 288, 179, 290, 0, 35, 0, 363, + /* 1390 */ 364, 247, 22, 315, 0, 35, 318, 319, 320, 321, + /* 1400 */ 322, 323, 0, 325, 166, 82, 328, 165, 163, 161, + /* 1410 */ 315, 333, 0, 318, 319, 320, 321, 322, 323, 275, + /* 1420 */ 325, 0, 157, 156, 0, 0, 46, 283, 0, 142, + /* 1430 */ 0, 0, 288, 0, 290, 0, 0, 137, 35, 0, + /* 1440 */ 137, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 1450 */ 0, 247, 357, 0, 0, 0, 0, 42, 0, 315, + /* 1460 */ 247, 42, 318, 319, 320, 321, 322, 323, 39, 325, + /* 1470 */ 0, 0, 0, 0, 0, 0, 8, 9, 0, 275, + /* 1480 */ 12, 13, 14, 15, 16, 22, 0, 283, 275, 0, + /* 1490 */ 0, 0, 288, 14, 290, 14, 283, 46, 0, 40, + /* 1500 */ 43, 288, 0, 290, 39, 301, 46, 0, 364, 247, + /* 1510 */ 152, 0, 0, 0, 0, 39, 0, 0, 35, 315, + /* 1520 */ 0, 247, 318, 319, 320, 321, 322, 323, 315, 325, + /* 1530 */ 35, 318, 319, 320, 321, 322, 323, 275, 325, 47, + /* 1540 */ 327, 47, 60, 39, 39, 283, 0, 47, 39, 275, + /* 1550 */ 288, 0, 290, 35, 35, 47, 0, 283, 0, 0, + /* 1560 */ 39, 0, 288, 301, 290, 35, 22, 0, 91, 89, + /* 1570 */ 35, 35, 19, 35, 247, 301, 35, 315, 35, 0, + /* 1580 */ 318, 319, 320, 321, 322, 323, 33, 325, 43, 315, + /* 1590 */ 247, 43, 318, 319, 320, 321, 322, 323, 35, 325, + /* 1600 */ 47, 35, 275, 22, 0, 52, 53, 54, 55, 56, + /* 1610 */ 283, 22, 0, 49, 22, 288, 0, 290, 275, 35, + /* 1620 */ 35, 153, 0, 35, 0, 22, 283, 20, 0, 35, + /* 1630 */ 0, 288, 148, 290, 81, 22, 167, 84, 150, 247, + /* 1640 */ 0, 148, 315, 0, 145, 318, 319, 320, 321, 322, + /* 1650 */ 323, 148, 325, 0, 0, 0, 82, 43, 315, 83, + /* 1660 */ 43, 318, 319, 320, 321, 322, 323, 275, 325, 83, + /* 1670 */ 117, 46, 82, 82, 43, 283, 83, 82, 82, 217, + /* 1680 */ 288, 83, 290, 46, 43, 43, 2, 82, 43, 83, + /* 1690 */ 46, 83, 46, 83, 43, 35, 35, 35, 211, 247, + /* 1700 */ 147, 83, 217, 235, 35, 35, 35, 315, 247, 185, + /* 1710 */ 318, 319, 320, 321, 322, 323, 43, 325, 217, 83, + /* 1720 */ 46, 168, 83, 170, 46, 22, 187, 275, 146, 82, + /* 1730 */ 82, 82, 0, 39, 82, 283, 275, 46, 46, 83, + /* 1740 */ 288, 83, 290, 144, 283, 82, 22, 82, 82, 288, + /* 1750 */ 82, 290, 93, 35, 82, 35, 35, 247, 83, 92, + /* 1760 */ 83, 82, 82, 82, 35, 83, 83, 315, 82, 247, + /* 1770 */ 318, 319, 320, 321, 322, 323, 315, 325, 82, 318, + /* 1780 */ 319, 320, 321, 322, 323, 275, 325, 83, 35, 82, + /* 1790 */ 35, 83, 82, 283, 106, 106, 106, 275, 288, 106, + /* 1800 */ 290, 22, 35, 94, 82, 283, 43, 82, 82, 22, + /* 1810 */ 288, 60, 290, 59, 65, 35, 80, 43, 35, 35, + /* 1820 */ 247, 35, 22, 35, 35, 315, 35, 35, 318, 319, + /* 1830 */ 320, 321, 322, 323, 247, 325, 65, 315, 35, 35, + /* 1840 */ 318, 319, 320, 321, 322, 323, 35, 325, 275, 35, + /* 1850 */ 35, 35, 35, 0, 35, 47, 283, 39, 0, 35, + /* 1860 */ 47, 288, 275, 290, 39, 0, 35, 47, 39, 0, + /* 1870 */ 283, 35, 39, 47, 0, 288, 35, 290, 35, 0, + /* 1880 */ 20, 22, 21, 367, 22, 247, 22, 21, 315, 367, + /* 1890 */ 367, 318, 319, 320, 321, 322, 323, 247, 325, 367, + /* 1900 */ 367, 367, 315, 367, 367, 318, 319, 320, 321, 322, + /* 1910 */ 323, 247, 325, 275, 367, 367, 367, 367, 367, 367, + /* 1920 */ 367, 283, 367, 367, 367, 275, 288, 367, 290, 367, + /* 1930 */ 367, 367, 367, 283, 367, 367, 367, 367, 288, 275, + /* 1940 */ 290, 367, 367, 367, 367, 367, 367, 283, 367, 367, + /* 1950 */ 367, 367, 288, 315, 290, 367, 318, 319, 320, 321, + /* 1960 */ 322, 323, 247, 325, 367, 315, 367, 367, 318, 319, + /* 1970 */ 320, 321, 322, 323, 367, 325, 367, 367, 367, 315, + /* 1980 */ 367, 367, 318, 319, 320, 321, 322, 323, 247, 325, + /* 1990 */ 275, 367, 367, 367, 367, 367, 367, 367, 283, 367, + /* 2000 */ 367, 367, 367, 288, 367, 290, 367, 367, 367, 367, + /* 2010 */ 367, 367, 367, 367, 367, 367, 275, 367, 367, 367, + /* 2020 */ 367, 367, 367, 367, 283, 367, 367, 367, 367, 288, + /* 2030 */ 315, 290, 367, 318, 319, 320, 321, 322, 323, 367, + /* 2040 */ 325, 247, 367, 367, 367, 367, 367, 367, 367, 367, + /* 2050 */ 367, 367, 367, 247, 367, 367, 315, 367, 367, 318, + /* 2060 */ 319, 320, 321, 322, 323, 367, 325, 367, 367, 275, + /* 2070 */ 367, 367, 367, 367, 367, 367, 367, 283, 367, 367, + /* 2080 */ 367, 275, 288, 367, 290, 367, 367, 367, 367, 283, + /* 2090 */ 367, 367, 367, 367, 288, 367, 290, 367, 367, 367, + /* 2100 */ 367, 367, 367, 367, 247, 367, 367, 367, 367, 315, + /* 2110 */ 367, 367, 318, 319, 320, 321, 322, 323, 247, 325, + /* 2120 */ 367, 315, 367, 367, 318, 319, 320, 321, 322, 323, + /* 2130 */ 367, 325, 275, 367, 367, 367, 367, 367, 367, 367, + /* 2140 */ 283, 367, 367, 367, 367, 288, 275, 290, 367, 367, + /* 2150 */ 367, 367, 367, 367, 283, 367, 367, 367, 367, 288, + /* 2160 */ 367, 290, 367, 367, 367, 367, 367, 367, 367, 247, + /* 2170 */ 367, 367, 315, 367, 367, 318, 319, 320, 321, 322, + /* 2180 */ 323, 247, 325, 367, 367, 367, 315, 367, 367, 318, + /* 2190 */ 319, 320, 321, 322, 323, 367, 325, 275, 367, 367, + /* 2200 */ 367, 367, 367, 367, 367, 283, 367, 367, 367, 275, + /* 2210 */ 288, 367, 290, 367, 367, 367, 367, 283, 367, 367, + /* 2220 */ 367, 367, 288, 367, 290, 367, 367, 367, 367, 367, + /* 2230 */ 367, 367, 367, 367, 367, 367, 367, 315, 367, 367, + /* 2240 */ 318, 319, 320, 321, 322, 323, 367, 325, 367, 315, + /* 2250 */ 367, 367, 318, 319, 320, 321, 322, 323, 367, 325, }; -#define YY_SHIFT_COUNT (640) +#define YY_SHIFT_COUNT (644) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1841) +#define YY_SHIFT_MAX (1879) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 742, 0, 0, 48, 208, 208, 208, 208, 256, 256, - /* 10 */ 208, 208, 416, 464, 624, 464, 464, 464, 464, 464, - /* 20 */ 464, 464, 464, 464, 464, 464, 464, 464, 464, 464, - /* 30 */ 464, 464, 464, 464, 464, 464, 464, 464, 464, 464, - /* 40 */ 66, 66, 104, 104, 104, 18, 18, 18, 18, 12, - /* 50 */ 79, 207, 36, 36, 115, 115, 202, 153, 207, 207, - /* 60 */ 36, 36, 36, 36, 36, 36, 36, 36, 73, 36, - /* 70 */ 36, 180, 190, 312, 180, 36, 36, 180, 36, 180, - /* 80 */ 180, 180, 36, 409, 706, 478, 838, 838, 395, 189, - /* 90 */ 835, 835, 835, 835, 835, 835, 835, 835, 835, 835, - /* 100 */ 835, 835, 835, 835, 835, 835, 835, 835, 835, 198, - /* 110 */ 153, 4, 4, 281, 801, 479, 479, 479, 327, 801, - /* 120 */ 454, 312, 180, 180, 425, 425, 530, 726, 246, 246, - /* 130 */ 246, 246, 246, 246, 246, 1351, 351, 803, 350, 187, - /* 140 */ 449, 401, 423, 512, 558, 392, 531, 638, 732, 664, - /* 150 */ 697, 664, 165, 165, 165, 719, 705, 861, 1058, 1035, - /* 160 */ 1036, 925, 1058, 1058, 1047, 963, 963, 1058, 1097, 1097, - /* 170 */ 1101, 73, 312, 73, 1105, 1108, 73, 1105, 73, 454, - /* 180 */ 1123, 73, 73, 1058, 73, 1097, 180, 180, 180, 180, - /* 190 */ 180, 180, 180, 180, 180, 180, 180, 1058, 1097, 425, - /* 200 */ 425, 1101, 409, 991, 312, 409, 1058, 1105, 409, 454, - /* 210 */ 1123, 409, 1159, 425, 965, 967, 425, 965, 967, 425, - /* 220 */ 425, 180, 961, 1042, 965, 971, 974, 994, 861, 995, - /* 230 */ 454, 1202, 1183, 996, 997, 998, 996, 997, 996, 997, - /* 240 */ 1144, 967, 425, 425, 967, 425, 1096, 454, 1123, 409, - /* 250 */ 530, 409, 454, 1170, 425, 726, 1058, 409, 1097, 2192, - /* 260 */ 2192, 2192, 2192, 2192, 2192, 2192, 481, 657, 561, 119, - /* 270 */ 601, 891, 63, 13, 303, 203, 582, 374, 443, 552, - /* 280 */ 550, 550, 550, 550, 550, 550, 550, 550, 132, 382, - /* 290 */ 152, 529, 430, 137, 616, 616, 616, 616, 259, 837, - /* 300 */ 800, 818, 823, 824, 879, 913, 914, 906, 896, 908, - /* 310 */ 910, 946, 851, 720, 739, 932, 886, 938, 685, 945, - /* 320 */ 954, 969, 993, 1006, 850, 887, 1019, 1020, 1029, 1030, - /* 330 */ 1031, 1032, 277, 892, 966, 1272, 1286, 1249, 1298, 1230, - /* 340 */ 1303, 1259, 1130, 1261, 1262, 1264, 1135, 1314, 1268, 1269, - /* 350 */ 1142, 1320, 1145, 1321, 1277, 1326, 1305, 1329, 1283, 1331, - /* 360 */ 1251, 1169, 1171, 1174, 1178, 1338, 1339, 1185, 1188, 1344, - /* 370 */ 1345, 1302, 1347, 1207, 1349, 1363, 1364, 1365, 1366, 1215, - /* 380 */ 1322, 1367, 1241, 1380, 1381, 1382, 1383, 1385, 1386, 1388, - /* 390 */ 1389, 1390, 1391, 1395, 1397, 1398, 1399, 1360, 1401, 1407, - /* 400 */ 1408, 1409, 1410, 1411, 1392, 1412, 1415, 1418, 1420, 1428, - /* 410 */ 1430, 1393, 1402, 1394, 1422, 1400, 1424, 1403, 1442, 1405, - /* 420 */ 1413, 1445, 1446, 1449, 1414, 1304, 1452, 1456, 1421, 1457, - /* 430 */ 1404, 1459, 1461, 1423, 1419, 1425, 1465, 1426, 1427, 1431, - /* 440 */ 1469, 1434, 1429, 1441, 1471, 1444, 1447, 1460, 1494, 1499, - /* 450 */ 1502, 1503, 1433, 1416, 1458, 1487, 1510, 1464, 1466, 1467, - /* 460 */ 1468, 1477, 1479, 1474, 1478, 1480, 1512, 1504, 1528, 1508, - /* 470 */ 1484, 1534, 1522, 1500, 1546, 1526, 1549, 1529, 1530, 1552, - /* 480 */ 1406, 1506, 1557, 1432, 1536, 1435, 1436, 1565, 1567, 1568, - /* 490 */ 1440, 1569, 1489, 1538, 1443, 1532, 1535, 1356, 1497, 1495, - /* 500 */ 1498, 1513, 1543, 1517, 1511, 1519, 1520, 1521, 1553, 1558, - /* 510 */ 1560, 1524, 1570, 1437, 1527, 1531, 1562, 1448, 1582, 1564, - /* 520 */ 1544, 1586, 1439, 1547, 1581, 1584, 1585, 1588, 1589, 1590, - /* 530 */ 1547, 1628, 1462, 1598, 1559, 1563, 1561, 1602, 1572, 1574, - /* 540 */ 1606, 1636, 1481, 1578, 1594, 1603, 1605, 1609, 1541, 1618, - /* 550 */ 1664, 1630, 1566, 1619, 1610, 1659, 1661, 1625, 1626, 1631, - /* 560 */ 1685, 1632, 1622, 1629, 1668, 1669, 1638, 1635, 1673, 1640, - /* 570 */ 1642, 1675, 1645, 1646, 1680, 1649, 1656, 1684, 1663, 1637, - /* 580 */ 1641, 1643, 1644, 1718, 1650, 1666, 1670, 1698, 1678, 1720, - /* 590 */ 1720, 1740, 1705, 1707, 1719, 1706, 1688, 1728, 1725, 1726, - /* 600 */ 1727, 1730, 1731, 1749, 1733, 1735, 1711, 1477, 1737, 1479, - /* 610 */ 1738, 1739, 1741, 1742, 1744, 1746, 1795, 1750, 1751, 1762, - /* 620 */ 1800, 1754, 1757, 1767, 1806, 1760, 1764, 1773, 1817, 1774, - /* 630 */ 1775, 1794, 1832, 1792, 1841, 1820, 1822, 1823, 1824, 1826, - /* 640 */ 1828, + /* 0 */ 707, 0, 0, 119, 238, 238, 238, 238, 259, 259, + /* 10 */ 238, 238, 378, 497, 518, 497, 497, 497, 497, 497, + /* 20 */ 497, 497, 497, 497, 497, 497, 497, 497, 497, 497, + /* 30 */ 497, 497, 497, 497, 497, 497, 497, 497, 497, 497, + /* 40 */ 497, 497, 421, 421, 94, 94, 94, 845, 845, 845, + /* 50 */ 845, 422, 573, 35, 16, 16, 40, 40, 4, 275, + /* 60 */ 35, 35, 16, 16, 16, 16, 16, 16, 16, 16, + /* 70 */ 47, 16, 16, 16, 131, 145, 160, 16, 16, 160, + /* 80 */ 16, 160, 160, 160, 16, 198, 704, 83, 461, 461, + /* 90 */ 306, 98, 114, 114, 114, 114, 114, 114, 114, 114, + /* 100 */ 114, 114, 114, 114, 114, 114, 114, 114, 114, 114, + /* 110 */ 114, 167, 275, 369, 369, 408, 691, 525, 525, 525, + /* 120 */ 580, 691, 183, 145, 160, 160, 171, 171, 266, 211, + /* 130 */ 695, 695, 695, 695, 695, 695, 695, 1553, 565, 749, + /* 140 */ 1468, 42, 352, 365, 10, 221, 282, 458, 802, 647, + /* 150 */ 829, 672, 614, 672, 734, 734, 734, 870, 738, 894, + /* 160 */ 1092, 1067, 1084, 973, 1092, 1092, 1100, 1014, 1014, 1092, + /* 170 */ 1135, 1135, 1143, 47, 145, 47, 1148, 1153, 47, 1148, + /* 180 */ 47, 1161, 47, 47, 1092, 47, 1135, 160, 160, 160, + /* 190 */ 160, 160, 160, 160, 160, 160, 160, 160, 1092, 1135, + /* 200 */ 171, 171, 1143, 198, 1036, 145, 198, 1092, 1092, 1148, + /* 210 */ 198, 1206, 171, 1006, 1015, 171, 1006, 1015, 171, 171, + /* 220 */ 160, 1001, 1077, 1006, 1024, 1028, 1042, 894, 1056, 183, + /* 230 */ 1249, 1228, 1047, 1041, 1051, 1047, 1041, 1047, 1041, 1208, + /* 240 */ 1015, 171, 171, 1015, 171, 1158, 183, 1161, 198, 266, + /* 250 */ 198, 183, 1229, 171, 211, 1092, 198, 1307, 1135, 2260, + /* 260 */ 2260, 2260, 2260, 2260, 2260, 2260, 705, 178, 617, 943, + /* 270 */ 476, 231, 542, 39, 48, 338, 594, 486, 486, 486, + /* 280 */ 486, 486, 486, 486, 486, 801, 808, 348, 3, 3, + /* 290 */ 337, 570, 509, 334, 526, 180, 532, 533, 533, 533, + /* 300 */ 533, 90, 948, 819, 850, 872, 898, 879, 966, 995, + /* 310 */ 875, 786, 975, 976, 981, 918, 722, 857, 978, 901, + /* 320 */ 989, 992, 1002, 1004, 1007, 1009, 1012, 954, 1011, 1019, + /* 330 */ 1037, 1039, 1040, 1054, 1058, 952, 1034, 624, 1362, 1363, + /* 340 */ 1322, 1365, 1294, 1369, 1336, 1193, 1338, 1339, 1340, 1197, + /* 350 */ 1377, 1344, 1345, 1202, 1382, 1205, 1386, 1352, 1388, 1370, + /* 360 */ 1394, 1360, 1402, 1323, 1238, 1242, 1245, 1248, 1412, 1421, + /* 370 */ 1265, 1267, 1424, 1425, 1380, 1428, 1287, 1430, 1431, 1433, + /* 380 */ 1435, 1436, 1300, 1403, 1439, 1303, 1441, 1442, 1443, 1444, + /* 390 */ 1445, 1446, 1447, 1448, 1449, 1450, 1453, 1454, 1455, 1456, + /* 400 */ 1415, 1458, 1470, 1471, 1472, 1473, 1474, 1463, 1475, 1478, + /* 410 */ 1486, 1489, 1490, 1491, 1419, 1429, 1457, 1479, 1451, 1481, + /* 420 */ 1460, 1498, 1459, 1465, 1502, 1507, 1520, 1476, 1358, 1511, + /* 430 */ 1512, 1513, 1482, 1514, 1516, 1483, 1492, 1504, 1517, 1495, + /* 440 */ 1494, 1505, 1546, 1518, 1500, 1509, 1551, 1519, 1508, 1521, + /* 450 */ 1556, 1558, 1559, 1561, 1477, 1480, 1530, 1544, 1567, 1535, + /* 460 */ 1536, 1538, 1541, 1545, 1548, 1543, 1563, 1566, 1579, 1581, + /* 470 */ 1604, 1589, 1564, 1612, 1592, 1584, 1616, 1585, 1622, 1588, + /* 480 */ 1624, 1603, 1607, 1628, 1484, 1594, 1630, 1469, 1613, 1493, + /* 490 */ 1499, 1640, 1643, 1503, 1488, 1653, 1654, 1655, 1614, 1617, + /* 500 */ 1462, 1574, 1576, 1590, 1586, 1631, 1593, 1591, 1595, 1596, + /* 510 */ 1598, 1641, 1625, 1637, 1605, 1642, 1485, 1606, 1608, 1644, + /* 520 */ 1487, 1645, 1646, 1610, 1651, 1501, 1618, 1660, 1661, 1662, + /* 530 */ 1669, 1670, 1671, 1618, 1684, 1524, 1673, 1636, 1647, 1639, + /* 540 */ 1674, 1648, 1649, 1678, 1703, 1539, 1652, 1656, 1658, 1663, + /* 550 */ 1665, 1582, 1666, 1732, 1694, 1599, 1668, 1667, 1691, 1692, + /* 560 */ 1672, 1675, 1679, 1724, 1680, 1659, 1677, 1718, 1720, 1681, + /* 570 */ 1682, 1721, 1686, 1683, 1729, 1696, 1704, 1753, 1707, 1708, + /* 580 */ 1755, 1710, 1688, 1689, 1690, 1693, 1779, 1709, 1722, 1725, + /* 590 */ 1767, 1726, 1763, 1763, 1787, 1751, 1754, 1780, 1749, 1736, + /* 600 */ 1774, 1783, 1784, 1786, 1788, 1789, 1800, 1791, 1792, 1771, + /* 610 */ 1545, 1803, 1548, 1804, 1811, 1814, 1815, 1816, 1817, 1853, + /* 620 */ 1819, 1808, 1818, 1858, 1824, 1813, 1825, 1865, 1831, 1820, + /* 630 */ 1829, 1869, 1836, 1826, 1833, 1874, 1841, 1843, 1879, 1859, + /* 640 */ 1861, 1862, 1864, 1866, 1860, }; #define YY_REDUCE_COUNT (265) -#define YY_REDUCE_MIN (-340) -#define YY_REDUCE_MAX (1869) +#define YY_REDUCE_MIN (-333) +#define YY_REDUCE_MAX (1934) static const short yy_reduce_ofst[] = { - /* 0 */ -233, -228, -20, -176, 645, 737, 778, 819, 895, 958, - /* 10 */ 188, 975, 1038, 1056, 1107, 477, 1168, 1221, 1244, 1300, - /* 20 */ 1353, 1362, 713, 1376, 1417, 1438, 1496, 1507, 1518, 1583, - /* 30 */ 1599, 1648, 1662, 1703, 1724, 1782, 1793, 1804, 1845, 1869, - /* 40 */ 1141, 1255, -5, 607, 653, -274, -269, 49, 447, -227, - /* 50 */ -47, 161, -231, -229, -244, -215, -340, -105, -133, 123, - /* 60 */ -197, -147, 363, 411, 424, 440, 455, 487, -171, 492, - /* 70 */ 511, 200, -24, 234, -201, 521, 603, 251, 604, -101, - /* 80 */ 345, 357, 606, -119, -152, -281, -281, -281, 78, -247, - /* 90 */ -135, -21, 242, 250, 295, 331, 334, 390, 404, 453, - /* 100 */ 461, 483, 485, 502, 503, 564, 615, 617, 625, 199, - /* 110 */ -83, 420, 421, -27, 176, -263, 172, 406, -155, 279, - /* 120 */ 491, -172, 243, 346, 494, 542, 428, 435, -271, 355, - /* 130 */ 532, 555, 574, 608, 643, 585, 683, 691, 584, 602, - /* 140 */ 701, 651, 629, 709, 709, 730, 748, 717, 694, 674, - /* 150 */ 674, 674, 659, 660, 665, 684, 709, 766, 827, 772, - /* 160 */ 826, 783, 834, 840, 797, 820, 825, 864, 872, 873, - /* 170 */ 816, 867, 839, 868, 828, 829, 876, 830, 877, 862, - /* 180 */ 852, 890, 897, 899, 898, 900, 880, 883, 884, 885, - /* 190 */ 888, 889, 893, 894, 901, 902, 904, 911, 915, 903, - /* 200 */ 905, 858, 916, 863, 882, 917, 920, 878, 924, 907, - /* 210 */ 909, 927, 869, 912, 842, 922, 919, 844, 923, 921, - /* 220 */ 931, 709, 843, 845, 849, 853, 856, 865, 918, 674, - /* 230 */ 941, 926, 929, 866, 874, 870, 871, 928, 930, 939, - /* 240 */ 935, 944, 949, 950, 948, 952, 955, 962, 953, 999, - /* 250 */ 980, 1002, 972, 981, 979, 1003, 1007, 1012, 1021, 964, - /* 260 */ 977, 1005, 1013, 1015, 1014, 1039, + /* 0 */ 510, -175, 623, -245, -113, 682, 745, 828, 889, 942, + /* 10 */ 806, 956, 1008, 1026, 1078, 96, 1095, 1144, 1204, 1213, + /* 20 */ 1262, 1274, 1327, 1343, 1392, 1452, 1461, 1510, 1522, 1573, + /* 30 */ 1587, 1638, 1650, 1664, 1715, 1741, 1794, 1806, 1857, 1871, + /* 40 */ 1922, 1934, 23, 184, -216, 66, 401, -246, 698, 51, + /* 50 */ 81, -232, 399, 511, 260, 261, -250, -244, -333, -263, + /* 60 */ -330, -251, -131, -128, 252, 357, 395, 504, 593, 598, + /* 70 */ -235, 611, 697, 713, -217, -76, 344, 620, 743, -242, + /* 80 */ 756, 346, 323, 452, 774, -176, -39, -324, -324, -324, + /* 90 */ 127, 80, 193, 236, 371, 386, 433, 500, 604, 605, + /* 100 */ 609, 616, 631, 649, 652, 662, 665, 681, 683, 685, + /* 110 */ 686, -158, -20, 46, 157, 187, 250, 189, 336, 412, + /* 120 */ -257, 299, 305, 460, 445, 471, 447, 524, 549, 117, + /* 130 */ 149, 311, 425, 540, 545, 574, 717, 274, 372, 643, + /* 140 */ 684, 692, 795, 760, 703, 781, 781, 820, 839, 811, + /* 150 */ 783, 762, 762, 762, 746, 747, 748, 763, 781, 797, + /* 160 */ 858, 803, 869, 830, 878, 885, 849, 852, 859, 899, + /* 170 */ 909, 910, 856, 907, 877, 911, 867, 871, 917, 876, + /* 180 */ 921, 886, 924, 925, 930, 927, 938, 913, 915, 916, + /* 190 */ 919, 920, 922, 923, 926, 931, 940, 941, 944, 947, + /* 200 */ 905, 912, 893, 961, 914, 929, 963, 958, 968, 932, + /* 210 */ 964, 933, 936, 887, 937, 950, 890, 949, 953, 955, + /* 220 */ 781, 896, 900, 892, 945, 906, 935, 946, 762, 983, + /* 230 */ 969, 957, 934, 939, 951, 959, 962, 960, 977, 971, + /* 240 */ 994, 1017, 1018, 998, 1020, 1010, 1027, 1016, 1061, 1044, + /* 250 */ 1062, 1030, 1045, 1048, 1073, 1085, 1082, 1102, 1101, 1049, + /* 260 */ 1046, 1088, 1089, 1090, 1096, 1115, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 10 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 20 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 30 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 40 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 50 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 60 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1468, 1399, - /* 70 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 80 */ 1399, 1399, 1399, 1466, 1617, 1399, 1781, 1399, 1399, 1399, - /* 90 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 100 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 110 */ 1399, 1399, 1399, 1468, 1399, 1792, 1792, 1792, 1466, 1399, - /* 120 */ 1399, 1399, 1399, 1399, 1399, 1399, 1562, 1399, 1399, 1399, - /* 130 */ 1399, 1399, 1399, 1399, 1399, 1650, 1399, 1399, 1862, 1399, - /* 140 */ 1399, 1656, 1816, 1399, 1399, 1399, 1399, 1515, 1808, 1784, - /* 150 */ 1798, 1785, 1847, 1847, 1847, 1801, 1399, 1812, 1399, 1399, - /* 160 */ 1399, 1642, 1399, 1399, 1622, 1619, 1619, 1399, 1399, 1399, - /* 170 */ 1399, 1468, 1399, 1468, 1399, 1399, 1468, 1399, 1468, 1399, - /* 180 */ 1399, 1468, 1468, 1399, 1468, 1399, 1399, 1399, 1399, 1399, - /* 190 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 200 */ 1399, 1399, 1466, 1652, 1399, 1466, 1399, 1399, 1466, 1399, - /* 210 */ 1399, 1466, 1399, 1399, 1823, 1821, 1399, 1823, 1821, 1399, - /* 220 */ 1399, 1399, 1835, 1831, 1823, 1839, 1837, 1814, 1812, 1798, - /* 230 */ 1399, 1399, 1399, 1853, 1849, 1865, 1853, 1849, 1853, 1849, - /* 240 */ 1399, 1821, 1399, 1399, 1821, 1399, 1627, 1399, 1399, 1466, - /* 250 */ 1399, 1466, 1399, 1531, 1399, 1399, 1399, 1466, 1399, 1644, - /* 260 */ 1658, 1565, 1565, 1565, 1469, 1404, 1399, 1399, 1399, 1399, - /* 270 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1527, - /* 280 */ 1725, 1834, 1833, 1757, 1756, 1755, 1753, 1724, 1399, 1399, - /* 290 */ 1399, 1399, 1399, 1399, 1718, 1719, 1717, 1716, 1399, 1399, - /* 300 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 310 */ 1399, 1782, 1399, 1850, 1854, 1399, 1399, 1399, 1701, 1399, - /* 320 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 330 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 340 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 350 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 360 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 370 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 380 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 390 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 400 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 410 */ 1399, 1399, 1399, 1433, 1399, 1399, 1399, 1399, 1399, 1399, - /* 420 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 430 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 440 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 450 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 460 */ 1399, 1496, 1495, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 470 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 480 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 490 */ 1399, 1399, 1399, 1399, 1399, 1805, 1815, 1399, 1399, 1399, - /* 500 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 510 */ 1701, 1399, 1832, 1399, 1791, 1787, 1399, 1399, 1783, 1399, - /* 520 */ 1399, 1848, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 530 */ 1399, 1777, 1399, 1750, 1399, 1399, 1399, 1399, 1399, 1399, - /* 540 */ 1399, 1399, 1712, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 550 */ 1399, 1399, 1399, 1399, 1399, 1700, 1399, 1741, 1399, 1399, - /* 560 */ 1399, 1399, 1399, 1399, 1399, 1399, 1559, 1399, 1399, 1399, - /* 570 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1544, - /* 580 */ 1542, 1541, 1540, 1399, 1537, 1399, 1399, 1399, 1399, 1568, - /* 590 */ 1567, 1399, 1399, 1399, 1399, 1399, 1399, 1488, 1399, 1399, - /* 600 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1479, 1399, 1478, - /* 610 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 620 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 630 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 640 */ 1399, + /* 0 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 10 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 20 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 30 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 40 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 50 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 60 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 70 */ 1483, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 80 */ 1411, 1411, 1411, 1411, 1411, 1481, 1632, 1411, 1799, 1411, + /* 90 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 100 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 110 */ 1411, 1411, 1411, 1411, 1411, 1483, 1411, 1811, 1811, 1811, + /* 120 */ 1481, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1577, 1411, + /* 130 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1666, 1411, 1411, + /* 140 */ 1881, 1411, 1411, 1672, 1835, 1411, 1411, 1411, 1411, 1530, + /* 150 */ 1827, 1803, 1817, 1804, 1866, 1866, 1866, 1820, 1411, 1831, + /* 160 */ 1411, 1411, 1411, 1658, 1411, 1411, 1637, 1634, 1634, 1411, + /* 170 */ 1411, 1411, 1411, 1483, 1411, 1483, 1411, 1411, 1483, 1411, + /* 180 */ 1483, 1411, 1483, 1483, 1411, 1483, 1411, 1411, 1411, 1411, + /* 190 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 200 */ 1411, 1411, 1411, 1481, 1668, 1411, 1481, 1411, 1411, 1411, + /* 210 */ 1481, 1411, 1411, 1842, 1840, 1411, 1842, 1840, 1411, 1411, + /* 220 */ 1411, 1854, 1850, 1842, 1858, 1856, 1833, 1831, 1817, 1411, + /* 230 */ 1411, 1801, 1872, 1868, 1884, 1872, 1868, 1872, 1868, 1411, + /* 240 */ 1840, 1411, 1411, 1840, 1411, 1641, 1411, 1411, 1481, 1411, + /* 250 */ 1481, 1411, 1546, 1411, 1411, 1411, 1481, 1443, 1411, 1660, + /* 260 */ 1674, 1580, 1580, 1580, 1484, 1416, 1411, 1411, 1411, 1411, + /* 270 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1743, 1853, 1852, + /* 280 */ 1775, 1774, 1773, 1771, 1742, 1411, 1411, 1542, 1741, 1740, + /* 290 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1734, 1735, 1733, + /* 300 */ 1732, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 310 */ 1411, 1411, 1411, 1411, 1800, 1411, 1869, 1873, 1411, 1411, + /* 320 */ 1411, 1717, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 330 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 340 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 350 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 360 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 370 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 380 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 390 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 400 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 410 */ 1411, 1411, 1411, 1411, 1411, 1411, 1448, 1411, 1411, 1411, + /* 420 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 430 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 440 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 450 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 460 */ 1411, 1411, 1411, 1511, 1510, 1411, 1411, 1411, 1411, 1411, + /* 470 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 480 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 490 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1824, 1834, + /* 500 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 510 */ 1411, 1411, 1411, 1717, 1411, 1851, 1411, 1810, 1806, 1411, + /* 520 */ 1411, 1802, 1411, 1411, 1867, 1411, 1411, 1411, 1411, 1411, + /* 530 */ 1411, 1411, 1411, 1411, 1795, 1411, 1768, 1411, 1411, 1411, + /* 540 */ 1411, 1411, 1411, 1411, 1411, 1728, 1411, 1411, 1411, 1411, + /* 550 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1716, 1411, + /* 560 */ 1759, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1574, + /* 570 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 580 */ 1411, 1411, 1559, 1557, 1556, 1555, 1411, 1552, 1411, 1411, + /* 590 */ 1411, 1411, 1583, 1582, 1411, 1411, 1411, 1411, 1411, 1411, + /* 600 */ 1503, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 610 */ 1494, 1411, 1493, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 620 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 630 */ 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, 1411, + /* 640 */ 1411, 1411, 1411, 1411, 1411, }; /********** End of lemon-generated parsing tables *****************************/ @@ -881,7 +894,9 @@ static const YYCODETYPE yyFallback[] = { 0, /* CONNS => nothing */ 0, /* STATE => nothing */ 0, /* USER => nothing */ - 0, /* PRIVILEGE => nothing */ + 0, /* ENABLE => nothing */ + 0, /* NK_INTEGER => nothing */ + 0, /* SYSINFO => nothing */ 0, /* DROP => nothing */ 0, /* GRANT => nothing */ 0, /* ON => nothing */ @@ -894,7 +909,6 @@ static const YYCODETYPE yyFallback[] = { 0, /* NK_DOT => nothing */ 0, /* DNODE => nothing */ 0, /* PORT => nothing */ - 0, /* NK_INTEGER => nothing */ 0, /* DNODES => nothing */ 0, /* NK_IPTOKEN => nothing */ 0, /* LOCAL => nothing */ @@ -991,11 +1005,12 @@ static const YYCODETYPE yyFallback[] = { 0, /* DISTRIBUTED => nothing */ 0, /* LIKE => nothing */ 0, /* INDEX => nothing */ - 0, /* FULLTEXT => nothing */ 0, /* FUNCTION => nothing */ 0, /* INTERVAL => nothing */ 0, /* TOPIC => nothing */ 0, /* AS => nothing */ + 0, /* WITH => nothing */ + 0, /* META => nothing */ 0, /* CONSUMER => nothing */ 0, /* GROUP => nothing */ 0, /* DESC => nothing */ @@ -1083,12 +1098,12 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ID => nothing */ - 235, /* NK_BITNOT => ID */ - 235, /* INSERT => ID */ - 235, /* VALUES => ID */ - 235, /* IMPORT => ID */ - 235, /* NK_SEMI => ID */ - 235, /* FILE => ID */ + 237, /* NK_BITNOT => ID */ + 237, /* INSERT => ID */ + 237, /* VALUES => ID */ + 237, /* IMPORT => ID */ + 237, /* NK_SEMI => ID */ + 237, /* FILE => ID */ }; #endif /* YYFALLBACK */ @@ -1210,336 +1225,339 @@ static const char *const yyTokenName[] = { /* 31 */ "CONNS", /* 32 */ "STATE", /* 33 */ "USER", - /* 34 */ "PRIVILEGE", - /* 35 */ "DROP", - /* 36 */ "GRANT", - /* 37 */ "ON", - /* 38 */ "TO", - /* 39 */ "REVOKE", - /* 40 */ "FROM", - /* 41 */ "NK_COMMA", - /* 42 */ "READ", - /* 43 */ "WRITE", - /* 44 */ "NK_DOT", - /* 45 */ "DNODE", - /* 46 */ "PORT", - /* 47 */ "NK_INTEGER", - /* 48 */ "DNODES", - /* 49 */ "NK_IPTOKEN", - /* 50 */ "LOCAL", - /* 51 */ "QNODE", - /* 52 */ "BNODE", - /* 53 */ "SNODE", - /* 54 */ "MNODE", - /* 55 */ "DATABASE", - /* 56 */ "USE", - /* 57 */ "IF", - /* 58 */ "NOT", - /* 59 */ "EXISTS", - /* 60 */ "BUFFER", - /* 61 */ "CACHELAST", - /* 62 */ "COMP", - /* 63 */ "DURATION", - /* 64 */ "NK_VARIABLE", - /* 65 */ "FSYNC", - /* 66 */ "MAXROWS", - /* 67 */ "MINROWS", - /* 68 */ "KEEP", - /* 69 */ "PAGES", - /* 70 */ "PAGESIZE", - /* 71 */ "PRECISION", - /* 72 */ "REPLICA", - /* 73 */ "STRICT", - /* 74 */ "WAL", - /* 75 */ "VGROUPS", - /* 76 */ "SINGLE_STABLE", - /* 77 */ "RETENTIONS", - /* 78 */ "SCHEMALESS", - /* 79 */ "NK_COLON", - /* 80 */ "TABLE", - /* 81 */ "NK_LP", - /* 82 */ "NK_RP", - /* 83 */ "STABLE", - /* 84 */ "ADD", - /* 85 */ "COLUMN", - /* 86 */ "MODIFY", - /* 87 */ "RENAME", - /* 88 */ "TAG", - /* 89 */ "SET", - /* 90 */ "NK_EQ", - /* 91 */ "USING", - /* 92 */ "TAGS", - /* 93 */ "COMMENT", - /* 94 */ "BOOL", - /* 95 */ "TINYINT", - /* 96 */ "SMALLINT", - /* 97 */ "INT", - /* 98 */ "INTEGER", - /* 99 */ "BIGINT", - /* 100 */ "FLOAT", - /* 101 */ "DOUBLE", - /* 102 */ "BINARY", - /* 103 */ "TIMESTAMP", - /* 104 */ "NCHAR", - /* 105 */ "UNSIGNED", - /* 106 */ "JSON", - /* 107 */ "VARCHAR", - /* 108 */ "MEDIUMBLOB", - /* 109 */ "BLOB", - /* 110 */ "VARBINARY", - /* 111 */ "DECIMAL", - /* 112 */ "MAX_DELAY", - /* 113 */ "WATERMARK", - /* 114 */ "ROLLUP", - /* 115 */ "TTL", - /* 116 */ "SMA", - /* 117 */ "FIRST", - /* 118 */ "LAST", - /* 119 */ "SHOW", - /* 120 */ "DATABASES", - /* 121 */ "TABLES", - /* 122 */ "STABLES", - /* 123 */ "MNODES", - /* 124 */ "MODULES", - /* 125 */ "QNODES", - /* 126 */ "FUNCTIONS", - /* 127 */ "INDEXES", - /* 128 */ "ACCOUNTS", - /* 129 */ "APPS", - /* 130 */ "CONNECTIONS", - /* 131 */ "LICENCE", - /* 132 */ "GRANTS", - /* 133 */ "QUERIES", - /* 134 */ "SCORES", - /* 135 */ "TOPICS", - /* 136 */ "VARIABLES", - /* 137 */ "BNODES", - /* 138 */ "SNODES", - /* 139 */ "CLUSTER", - /* 140 */ "TRANSACTIONS", - /* 141 */ "DISTRIBUTED", - /* 142 */ "LIKE", - /* 143 */ "INDEX", - /* 144 */ "FULLTEXT", + /* 34 */ "ENABLE", + /* 35 */ "NK_INTEGER", + /* 36 */ "SYSINFO", + /* 37 */ "DROP", + /* 38 */ "GRANT", + /* 39 */ "ON", + /* 40 */ "TO", + /* 41 */ "REVOKE", + /* 42 */ "FROM", + /* 43 */ "NK_COMMA", + /* 44 */ "READ", + /* 45 */ "WRITE", + /* 46 */ "NK_DOT", + /* 47 */ "DNODE", + /* 48 */ "PORT", + /* 49 */ "DNODES", + /* 50 */ "NK_IPTOKEN", + /* 51 */ "LOCAL", + /* 52 */ "QNODE", + /* 53 */ "BNODE", + /* 54 */ "SNODE", + /* 55 */ "MNODE", + /* 56 */ "DATABASE", + /* 57 */ "USE", + /* 58 */ "IF", + /* 59 */ "NOT", + /* 60 */ "EXISTS", + /* 61 */ "BUFFER", + /* 62 */ "CACHELAST", + /* 63 */ "COMP", + /* 64 */ "DURATION", + /* 65 */ "NK_VARIABLE", + /* 66 */ "FSYNC", + /* 67 */ "MAXROWS", + /* 68 */ "MINROWS", + /* 69 */ "KEEP", + /* 70 */ "PAGES", + /* 71 */ "PAGESIZE", + /* 72 */ "PRECISION", + /* 73 */ "REPLICA", + /* 74 */ "STRICT", + /* 75 */ "WAL", + /* 76 */ "VGROUPS", + /* 77 */ "SINGLE_STABLE", + /* 78 */ "RETENTIONS", + /* 79 */ "SCHEMALESS", + /* 80 */ "NK_COLON", + /* 81 */ "TABLE", + /* 82 */ "NK_LP", + /* 83 */ "NK_RP", + /* 84 */ "STABLE", + /* 85 */ "ADD", + /* 86 */ "COLUMN", + /* 87 */ "MODIFY", + /* 88 */ "RENAME", + /* 89 */ "TAG", + /* 90 */ "SET", + /* 91 */ "NK_EQ", + /* 92 */ "USING", + /* 93 */ "TAGS", + /* 94 */ "COMMENT", + /* 95 */ "BOOL", + /* 96 */ "TINYINT", + /* 97 */ "SMALLINT", + /* 98 */ "INT", + /* 99 */ "INTEGER", + /* 100 */ "BIGINT", + /* 101 */ "FLOAT", + /* 102 */ "DOUBLE", + /* 103 */ "BINARY", + /* 104 */ "TIMESTAMP", + /* 105 */ "NCHAR", + /* 106 */ "UNSIGNED", + /* 107 */ "JSON", + /* 108 */ "VARCHAR", + /* 109 */ "MEDIUMBLOB", + /* 110 */ "BLOB", + /* 111 */ "VARBINARY", + /* 112 */ "DECIMAL", + /* 113 */ "MAX_DELAY", + /* 114 */ "WATERMARK", + /* 115 */ "ROLLUP", + /* 116 */ "TTL", + /* 117 */ "SMA", + /* 118 */ "FIRST", + /* 119 */ "LAST", + /* 120 */ "SHOW", + /* 121 */ "DATABASES", + /* 122 */ "TABLES", + /* 123 */ "STABLES", + /* 124 */ "MNODES", + /* 125 */ "MODULES", + /* 126 */ "QNODES", + /* 127 */ "FUNCTIONS", + /* 128 */ "INDEXES", + /* 129 */ "ACCOUNTS", + /* 130 */ "APPS", + /* 131 */ "CONNECTIONS", + /* 132 */ "LICENCE", + /* 133 */ "GRANTS", + /* 134 */ "QUERIES", + /* 135 */ "SCORES", + /* 136 */ "TOPICS", + /* 137 */ "VARIABLES", + /* 138 */ "BNODES", + /* 139 */ "SNODES", + /* 140 */ "CLUSTER", + /* 141 */ "TRANSACTIONS", + /* 142 */ "DISTRIBUTED", + /* 143 */ "LIKE", + /* 144 */ "INDEX", /* 145 */ "FUNCTION", /* 146 */ "INTERVAL", /* 147 */ "TOPIC", /* 148 */ "AS", - /* 149 */ "CONSUMER", - /* 150 */ "GROUP", - /* 151 */ "DESC", - /* 152 */ "DESCRIBE", - /* 153 */ "RESET", - /* 154 */ "QUERY", - /* 155 */ "CACHE", - /* 156 */ "EXPLAIN", - /* 157 */ "ANALYZE", - /* 158 */ "VERBOSE", - /* 159 */ "NK_BOOL", - /* 160 */ "RATIO", - /* 161 */ "NK_FLOAT", - /* 162 */ "COMPACT", - /* 163 */ "VNODES", - /* 164 */ "IN", - /* 165 */ "OUTPUTTYPE", - /* 166 */ "AGGREGATE", - /* 167 */ "BUFSIZE", - /* 168 */ "STREAM", - /* 169 */ "INTO", - /* 170 */ "TRIGGER", - /* 171 */ "AT_ONCE", - /* 172 */ "WINDOW_CLOSE", - /* 173 */ "KILL", - /* 174 */ "CONNECTION", - /* 175 */ "TRANSACTION", - /* 176 */ "BALANCE", - /* 177 */ "VGROUP", - /* 178 */ "MERGE", - /* 179 */ "REDISTRIBUTE", - /* 180 */ "SPLIT", - /* 181 */ "SYNCDB", - /* 182 */ "DELETE", - /* 183 */ "NULL", - /* 184 */ "NK_QUESTION", - /* 185 */ "NK_ARROW", - /* 186 */ "ROWTS", - /* 187 */ "TBNAME", - /* 188 */ "QSTARTTS", - /* 189 */ "QENDTS", - /* 190 */ "WSTARTTS", - /* 191 */ "WENDTS", - /* 192 */ "WDURATION", - /* 193 */ "CAST", - /* 194 */ "NOW", - /* 195 */ "TODAY", - /* 196 */ "TIMEZONE", - /* 197 */ "COUNT", - /* 198 */ "LAST_ROW", - /* 199 */ "BETWEEN", - /* 200 */ "IS", - /* 201 */ "NK_LT", - /* 202 */ "NK_GT", - /* 203 */ "NK_LE", - /* 204 */ "NK_GE", - /* 205 */ "NK_NE", - /* 206 */ "MATCH", - /* 207 */ "NMATCH", - /* 208 */ "CONTAINS", - /* 209 */ "JOIN", - /* 210 */ "INNER", - /* 211 */ "SELECT", - /* 212 */ "DISTINCT", - /* 213 */ "WHERE", - /* 214 */ "PARTITION", - /* 215 */ "BY", - /* 216 */ "SESSION", - /* 217 */ "STATE_WINDOW", - /* 218 */ "SLIDING", - /* 219 */ "FILL", - /* 220 */ "VALUE", - /* 221 */ "NONE", - /* 222 */ "PREV", - /* 223 */ "LINEAR", - /* 224 */ "NEXT", - /* 225 */ "HAVING", - /* 226 */ "RANGE", - /* 227 */ "EVERY", - /* 228 */ "ORDER", - /* 229 */ "SLIMIT", - /* 230 */ "SOFFSET", - /* 231 */ "LIMIT", - /* 232 */ "OFFSET", - /* 233 */ "ASC", - /* 234 */ "NULLS", - /* 235 */ "ID", - /* 236 */ "NK_BITNOT", - /* 237 */ "INSERT", - /* 238 */ "VALUES", - /* 239 */ "IMPORT", - /* 240 */ "NK_SEMI", - /* 241 */ "FILE", - /* 242 */ "cmd", - /* 243 */ "account_options", - /* 244 */ "alter_account_options", - /* 245 */ "literal", - /* 246 */ "alter_account_option", - /* 247 */ "user_name", - /* 248 */ "privileges", - /* 249 */ "priv_level", - /* 250 */ "priv_type_list", - /* 251 */ "priv_type", - /* 252 */ "db_name", - /* 253 */ "dnode_endpoint", - /* 254 */ "not_exists_opt", - /* 255 */ "db_options", - /* 256 */ "exists_opt", - /* 257 */ "alter_db_options", - /* 258 */ "integer_list", - /* 259 */ "variable_list", - /* 260 */ "retention_list", - /* 261 */ "alter_db_option", - /* 262 */ "retention", - /* 263 */ "full_table_name", - /* 264 */ "column_def_list", - /* 265 */ "tags_def_opt", - /* 266 */ "table_options", - /* 267 */ "multi_create_clause", - /* 268 */ "tags_def", - /* 269 */ "multi_drop_clause", - /* 270 */ "alter_table_clause", - /* 271 */ "alter_table_options", - /* 272 */ "column_name", - /* 273 */ "type_name", - /* 274 */ "signed_literal", - /* 275 */ "create_subtable_clause", - /* 276 */ "specific_tags_opt", - /* 277 */ "literal_list", - /* 278 */ "drop_table_clause", - /* 279 */ "col_name_list", - /* 280 */ "table_name", - /* 281 */ "column_def", - /* 282 */ "duration_list", - /* 283 */ "rollup_func_list", - /* 284 */ "alter_table_option", - /* 285 */ "duration_literal", - /* 286 */ "rollup_func_name", - /* 287 */ "function_name", - /* 288 */ "col_name", - /* 289 */ "db_name_cond_opt", - /* 290 */ "like_pattern_opt", - /* 291 */ "table_name_cond", - /* 292 */ "from_db_opt", - /* 293 */ "index_name", - /* 294 */ "index_options", - /* 295 */ "func_list", - /* 296 */ "sliding_opt", - /* 297 */ "func", - /* 298 */ "expression_list", - /* 299 */ "topic_name", - /* 300 */ "query_expression", - /* 301 */ "cgroup_name", - /* 302 */ "analyze_opt", - /* 303 */ "explain_options", - /* 304 */ "agg_func_opt", - /* 305 */ "bufsize_opt", - /* 306 */ "stream_name", - /* 307 */ "stream_options", - /* 308 */ "into_opt", - /* 309 */ "dnode_list", - /* 310 */ "where_clause_opt", - /* 311 */ "signed", - /* 312 */ "literal_func", - /* 313 */ "table_alias", - /* 314 */ "column_alias", - /* 315 */ "expression", - /* 316 */ "pseudo_column", - /* 317 */ "column_reference", - /* 318 */ "function_expression", - /* 319 */ "subquery", - /* 320 */ "star_func", - /* 321 */ "star_func_para_list", - /* 322 */ "noarg_func", - /* 323 */ "other_para_list", - /* 324 */ "star_func_para", - /* 325 */ "predicate", - /* 326 */ "compare_op", - /* 327 */ "in_op", - /* 328 */ "in_predicate_value", - /* 329 */ "boolean_value_expression", - /* 330 */ "boolean_primary", - /* 331 */ "common_expression", - /* 332 */ "from_clause", - /* 333 */ "table_reference_list", - /* 334 */ "table_reference", - /* 335 */ "table_primary", - /* 336 */ "joined_table", - /* 337 */ "alias_opt", - /* 338 */ "parenthesized_joined_table", - /* 339 */ "join_type", - /* 340 */ "search_condition", - /* 341 */ "query_specification", - /* 342 */ "set_quantifier_opt", - /* 343 */ "select_list", - /* 344 */ "partition_by_clause_opt", - /* 345 */ "range_opt", - /* 346 */ "every_opt", - /* 347 */ "fill_opt", - /* 348 */ "twindow_clause_opt", - /* 349 */ "group_by_clause_opt", - /* 350 */ "having_clause_opt", - /* 351 */ "select_sublist", - /* 352 */ "select_item", - /* 353 */ "fill_mode", - /* 354 */ "group_by_list", - /* 355 */ "query_expression_body", - /* 356 */ "order_by_clause_opt", - /* 357 */ "slimit_clause_opt", - /* 358 */ "limit_clause_opt", - /* 359 */ "query_primary", - /* 360 */ "sort_specification_list", - /* 361 */ "sort_specification", - /* 362 */ "ordering_specification_opt", - /* 363 */ "null_ordering_opt", + /* 149 */ "WITH", + /* 150 */ "META", + /* 151 */ "CONSUMER", + /* 152 */ "GROUP", + /* 153 */ "DESC", + /* 154 */ "DESCRIBE", + /* 155 */ "RESET", + /* 156 */ "QUERY", + /* 157 */ "CACHE", + /* 158 */ "EXPLAIN", + /* 159 */ "ANALYZE", + /* 160 */ "VERBOSE", + /* 161 */ "NK_BOOL", + /* 162 */ "RATIO", + /* 163 */ "NK_FLOAT", + /* 164 */ "COMPACT", + /* 165 */ "VNODES", + /* 166 */ "IN", + /* 167 */ "OUTPUTTYPE", + /* 168 */ "AGGREGATE", + /* 169 */ "BUFSIZE", + /* 170 */ "STREAM", + /* 171 */ "INTO", + /* 172 */ "TRIGGER", + /* 173 */ "AT_ONCE", + /* 174 */ "WINDOW_CLOSE", + /* 175 */ "KILL", + /* 176 */ "CONNECTION", + /* 177 */ "TRANSACTION", + /* 178 */ "BALANCE", + /* 179 */ "VGROUP", + /* 180 */ "MERGE", + /* 181 */ "REDISTRIBUTE", + /* 182 */ "SPLIT", + /* 183 */ "SYNCDB", + /* 184 */ "DELETE", + /* 185 */ "NULL", + /* 186 */ "NK_QUESTION", + /* 187 */ "NK_ARROW", + /* 188 */ "ROWTS", + /* 189 */ "TBNAME", + /* 190 */ "QSTARTTS", + /* 191 */ "QENDTS", + /* 192 */ "WSTARTTS", + /* 193 */ "WENDTS", + /* 194 */ "WDURATION", + /* 195 */ "CAST", + /* 196 */ "NOW", + /* 197 */ "TODAY", + /* 198 */ "TIMEZONE", + /* 199 */ "COUNT", + /* 200 */ "LAST_ROW", + /* 201 */ "BETWEEN", + /* 202 */ "IS", + /* 203 */ "NK_LT", + /* 204 */ "NK_GT", + /* 205 */ "NK_LE", + /* 206 */ "NK_GE", + /* 207 */ "NK_NE", + /* 208 */ "MATCH", + /* 209 */ "NMATCH", + /* 210 */ "CONTAINS", + /* 211 */ "JOIN", + /* 212 */ "INNER", + /* 213 */ "SELECT", + /* 214 */ "DISTINCT", + /* 215 */ "WHERE", + /* 216 */ "PARTITION", + /* 217 */ "BY", + /* 218 */ "SESSION", + /* 219 */ "STATE_WINDOW", + /* 220 */ "SLIDING", + /* 221 */ "FILL", + /* 222 */ "VALUE", + /* 223 */ "NONE", + /* 224 */ "PREV", + /* 225 */ "LINEAR", + /* 226 */ "NEXT", + /* 227 */ "HAVING", + /* 228 */ "RANGE", + /* 229 */ "EVERY", + /* 230 */ "ORDER", + /* 231 */ "SLIMIT", + /* 232 */ "SOFFSET", + /* 233 */ "LIMIT", + /* 234 */ "OFFSET", + /* 235 */ "ASC", + /* 236 */ "NULLS", + /* 237 */ "ID", + /* 238 */ "NK_BITNOT", + /* 239 */ "INSERT", + /* 240 */ "VALUES", + /* 241 */ "IMPORT", + /* 242 */ "NK_SEMI", + /* 243 */ "FILE", + /* 244 */ "cmd", + /* 245 */ "account_options", + /* 246 */ "alter_account_options", + /* 247 */ "literal", + /* 248 */ "alter_account_option", + /* 249 */ "user_name", + /* 250 */ "sysinfo_opt", + /* 251 */ "privileges", + /* 252 */ "priv_level", + /* 253 */ "priv_type_list", + /* 254 */ "priv_type", + /* 255 */ "db_name", + /* 256 */ "dnode_endpoint", + /* 257 */ "not_exists_opt", + /* 258 */ "db_options", + /* 259 */ "exists_opt", + /* 260 */ "alter_db_options", + /* 261 */ "integer_list", + /* 262 */ "variable_list", + /* 263 */ "retention_list", + /* 264 */ "alter_db_option", + /* 265 */ "retention", + /* 266 */ "full_table_name", + /* 267 */ "column_def_list", + /* 268 */ "tags_def_opt", + /* 269 */ "table_options", + /* 270 */ "multi_create_clause", + /* 271 */ "tags_def", + /* 272 */ "multi_drop_clause", + /* 273 */ "alter_table_clause", + /* 274 */ "alter_table_options", + /* 275 */ "column_name", + /* 276 */ "type_name", + /* 277 */ "signed_literal", + /* 278 */ "create_subtable_clause", + /* 279 */ "specific_tags_opt", + /* 280 */ "literal_list", + /* 281 */ "drop_table_clause", + /* 282 */ "col_name_list", + /* 283 */ "table_name", + /* 284 */ "column_def", + /* 285 */ "duration_list", + /* 286 */ "rollup_func_list", + /* 287 */ "alter_table_option", + /* 288 */ "duration_literal", + /* 289 */ "rollup_func_name", + /* 290 */ "function_name", + /* 291 */ "col_name", + /* 292 */ "db_name_cond_opt", + /* 293 */ "like_pattern_opt", + /* 294 */ "table_name_cond", + /* 295 */ "from_db_opt", + /* 296 */ "index_name", + /* 297 */ "index_options", + /* 298 */ "func_list", + /* 299 */ "sliding_opt", + /* 300 */ "func", + /* 301 */ "expression_list", + /* 302 */ "topic_name", + /* 303 */ "query_expression", + /* 304 */ "cgroup_name", + /* 305 */ "analyze_opt", + /* 306 */ "explain_options", + /* 307 */ "agg_func_opt", + /* 308 */ "bufsize_opt", + /* 309 */ "stream_name", + /* 310 */ "stream_options", + /* 311 */ "into_opt", + /* 312 */ "dnode_list", + /* 313 */ "where_clause_opt", + /* 314 */ "signed", + /* 315 */ "literal_func", + /* 316 */ "table_alias", + /* 317 */ "column_alias", + /* 318 */ "expression", + /* 319 */ "pseudo_column", + /* 320 */ "column_reference", + /* 321 */ "function_expression", + /* 322 */ "subquery", + /* 323 */ "star_func", + /* 324 */ "star_func_para_list", + /* 325 */ "noarg_func", + /* 326 */ "other_para_list", + /* 327 */ "star_func_para", + /* 328 */ "predicate", + /* 329 */ "compare_op", + /* 330 */ "in_op", + /* 331 */ "in_predicate_value", + /* 332 */ "boolean_value_expression", + /* 333 */ "boolean_primary", + /* 334 */ "common_expression", + /* 335 */ "from_clause_opt", + /* 336 */ "table_reference_list", + /* 337 */ "table_reference", + /* 338 */ "table_primary", + /* 339 */ "joined_table", + /* 340 */ "alias_opt", + /* 341 */ "parenthesized_joined_table", + /* 342 */ "join_type", + /* 343 */ "search_condition", + /* 344 */ "query_specification", + /* 345 */ "set_quantifier_opt", + /* 346 */ "select_list", + /* 347 */ "partition_by_clause_opt", + /* 348 */ "range_opt", + /* 349 */ "every_opt", + /* 350 */ "fill_opt", + /* 351 */ "twindow_clause_opt", + /* 352 */ "group_by_clause_opt", + /* 353 */ "having_clause_opt", + /* 354 */ "select_sublist", + /* 355 */ "select_item", + /* 356 */ "fill_mode", + /* 357 */ "group_by_list", + /* 358 */ "query_expression_body", + /* 359 */ "order_by_clause_opt", + /* 360 */ "slimit_clause_opt", + /* 361 */ "limit_clause_opt", + /* 362 */ "query_primary", + /* 363 */ "sort_specification_list", + /* 364 */ "sort_specification", + /* 365 */ "ordering_specification_opt", + /* 366 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1571,448 +1589,455 @@ static const char *const yyRuleName[] = { /* 21 */ "alter_account_option ::= USERS literal", /* 22 */ "alter_account_option ::= CONNS literal", /* 23 */ "alter_account_option ::= STATE literal", - /* 24 */ "cmd ::= CREATE USER user_name PASS NK_STRING", + /* 24 */ "cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt", /* 25 */ "cmd ::= ALTER USER user_name PASS NK_STRING", - /* 26 */ "cmd ::= ALTER USER user_name PRIVILEGE NK_STRING", - /* 27 */ "cmd ::= DROP USER user_name", - /* 28 */ "cmd ::= GRANT privileges ON priv_level TO user_name", - /* 29 */ "cmd ::= REVOKE privileges ON priv_level FROM user_name", - /* 30 */ "privileges ::= ALL", - /* 31 */ "privileges ::= priv_type_list", - /* 32 */ "priv_type_list ::= priv_type", - /* 33 */ "priv_type_list ::= priv_type_list NK_COMMA priv_type", - /* 34 */ "priv_type ::= READ", - /* 35 */ "priv_type ::= WRITE", - /* 36 */ "priv_level ::= NK_STAR NK_DOT NK_STAR", - /* 37 */ "priv_level ::= db_name NK_DOT NK_STAR", - /* 38 */ "cmd ::= CREATE DNODE dnode_endpoint", - /* 39 */ "cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER", - /* 40 */ "cmd ::= DROP DNODE NK_INTEGER", - /* 41 */ "cmd ::= DROP DNODE dnode_endpoint", - /* 42 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING", - /* 43 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING", - /* 44 */ "cmd ::= ALTER ALL DNODES NK_STRING", - /* 45 */ "cmd ::= ALTER ALL DNODES NK_STRING NK_STRING", - /* 46 */ "dnode_endpoint ::= NK_STRING", - /* 47 */ "dnode_endpoint ::= NK_ID", - /* 48 */ "dnode_endpoint ::= NK_IPTOKEN", - /* 49 */ "cmd ::= ALTER LOCAL NK_STRING", - /* 50 */ "cmd ::= ALTER LOCAL NK_STRING NK_STRING", - /* 51 */ "cmd ::= CREATE QNODE ON DNODE NK_INTEGER", - /* 52 */ "cmd ::= DROP QNODE ON DNODE NK_INTEGER", - /* 53 */ "cmd ::= CREATE BNODE ON DNODE NK_INTEGER", - /* 54 */ "cmd ::= DROP BNODE ON DNODE NK_INTEGER", - /* 55 */ "cmd ::= CREATE SNODE ON DNODE NK_INTEGER", - /* 56 */ "cmd ::= DROP SNODE ON DNODE NK_INTEGER", - /* 57 */ "cmd ::= CREATE MNODE ON DNODE NK_INTEGER", - /* 58 */ "cmd ::= DROP MNODE ON DNODE NK_INTEGER", - /* 59 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", - /* 60 */ "cmd ::= DROP DATABASE exists_opt db_name", - /* 61 */ "cmd ::= USE db_name", - /* 62 */ "cmd ::= ALTER DATABASE db_name alter_db_options", - /* 63 */ "not_exists_opt ::= IF NOT EXISTS", - /* 64 */ "not_exists_opt ::=", - /* 65 */ "exists_opt ::= IF EXISTS", - /* 66 */ "exists_opt ::=", - /* 67 */ "db_options ::=", - /* 68 */ "db_options ::= db_options BUFFER NK_INTEGER", - /* 69 */ "db_options ::= db_options CACHELAST NK_INTEGER", - /* 70 */ "db_options ::= db_options COMP NK_INTEGER", - /* 71 */ "db_options ::= db_options DURATION NK_INTEGER", - /* 72 */ "db_options ::= db_options DURATION NK_VARIABLE", - /* 73 */ "db_options ::= db_options FSYNC NK_INTEGER", - /* 74 */ "db_options ::= db_options MAXROWS NK_INTEGER", - /* 75 */ "db_options ::= db_options MINROWS NK_INTEGER", - /* 76 */ "db_options ::= db_options KEEP integer_list", - /* 77 */ "db_options ::= db_options KEEP variable_list", - /* 78 */ "db_options ::= db_options PAGES NK_INTEGER", - /* 79 */ "db_options ::= db_options PAGESIZE NK_INTEGER", - /* 80 */ "db_options ::= db_options PRECISION NK_STRING", - /* 81 */ "db_options ::= db_options REPLICA NK_INTEGER", - /* 82 */ "db_options ::= db_options STRICT NK_INTEGER", - /* 83 */ "db_options ::= db_options WAL NK_INTEGER", - /* 84 */ "db_options ::= db_options VGROUPS NK_INTEGER", - /* 85 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", - /* 86 */ "db_options ::= db_options RETENTIONS retention_list", - /* 87 */ "db_options ::= db_options SCHEMALESS NK_INTEGER", - /* 88 */ "alter_db_options ::= alter_db_option", - /* 89 */ "alter_db_options ::= alter_db_options alter_db_option", - /* 90 */ "alter_db_option ::= BUFFER NK_INTEGER", - /* 91 */ "alter_db_option ::= CACHELAST NK_INTEGER", - /* 92 */ "alter_db_option ::= FSYNC NK_INTEGER", - /* 93 */ "alter_db_option ::= KEEP integer_list", - /* 94 */ "alter_db_option ::= KEEP variable_list", - /* 95 */ "alter_db_option ::= PAGES NK_INTEGER", - /* 96 */ "alter_db_option ::= REPLICA NK_INTEGER", - /* 97 */ "alter_db_option ::= STRICT NK_INTEGER", - /* 98 */ "alter_db_option ::= WAL NK_INTEGER", - /* 99 */ "integer_list ::= NK_INTEGER", - /* 100 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", - /* 101 */ "variable_list ::= NK_VARIABLE", - /* 102 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", - /* 103 */ "retention_list ::= retention", - /* 104 */ "retention_list ::= retention_list NK_COMMA retention", - /* 105 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", - /* 106 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 107 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 108 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 109 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 110 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 111 */ "cmd ::= ALTER TABLE alter_table_clause", - /* 112 */ "cmd ::= ALTER STABLE alter_table_clause", - /* 113 */ "alter_table_clause ::= full_table_name alter_table_options", - /* 114 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", - /* 115 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", - /* 116 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", - /* 117 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", - /* 118 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", - /* 119 */ "alter_table_clause ::= full_table_name DROP TAG column_name", - /* 120 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", - /* 121 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 122 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", - /* 123 */ "multi_create_clause ::= create_subtable_clause", - /* 124 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 125 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options", - /* 126 */ "multi_drop_clause ::= drop_table_clause", - /* 127 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 128 */ "drop_table_clause ::= exists_opt full_table_name", - /* 129 */ "specific_tags_opt ::=", - /* 130 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", - /* 131 */ "full_table_name ::= table_name", - /* 132 */ "full_table_name ::= db_name NK_DOT table_name", - /* 133 */ "column_def_list ::= column_def", - /* 134 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 135 */ "column_def ::= column_name type_name", - /* 136 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 137 */ "type_name ::= BOOL", - /* 138 */ "type_name ::= TINYINT", - /* 139 */ "type_name ::= SMALLINT", - /* 140 */ "type_name ::= INT", - /* 141 */ "type_name ::= INTEGER", - /* 142 */ "type_name ::= BIGINT", - /* 143 */ "type_name ::= FLOAT", - /* 144 */ "type_name ::= DOUBLE", - /* 145 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 146 */ "type_name ::= TIMESTAMP", - /* 147 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 148 */ "type_name ::= TINYINT UNSIGNED", - /* 149 */ "type_name ::= SMALLINT UNSIGNED", - /* 150 */ "type_name ::= INT UNSIGNED", - /* 151 */ "type_name ::= BIGINT UNSIGNED", - /* 152 */ "type_name ::= JSON", - /* 153 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 154 */ "type_name ::= MEDIUMBLOB", - /* 155 */ "type_name ::= BLOB", - /* 156 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 157 */ "type_name ::= DECIMAL", - /* 158 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 159 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 160 */ "tags_def_opt ::=", - /* 161 */ "tags_def_opt ::= tags_def", - /* 162 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 163 */ "table_options ::=", - /* 164 */ "table_options ::= table_options COMMENT NK_STRING", - /* 165 */ "table_options ::= table_options MAX_DELAY duration_list", - /* 166 */ "table_options ::= table_options WATERMARK duration_list", - /* 167 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", - /* 168 */ "table_options ::= table_options TTL NK_INTEGER", - /* 169 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 170 */ "alter_table_options ::= alter_table_option", - /* 171 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 172 */ "alter_table_option ::= COMMENT NK_STRING", - /* 173 */ "alter_table_option ::= TTL NK_INTEGER", - /* 174 */ "duration_list ::= duration_literal", - /* 175 */ "duration_list ::= duration_list NK_COMMA duration_literal", - /* 176 */ "rollup_func_list ::= rollup_func_name", - /* 177 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", - /* 178 */ "rollup_func_name ::= function_name", - /* 179 */ "rollup_func_name ::= FIRST", - /* 180 */ "rollup_func_name ::= LAST", - /* 181 */ "col_name_list ::= col_name", - /* 182 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 183 */ "col_name ::= column_name", - /* 184 */ "cmd ::= SHOW DNODES", - /* 185 */ "cmd ::= SHOW USERS", - /* 186 */ "cmd ::= SHOW DATABASES", - /* 187 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", - /* 188 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 189 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 190 */ "cmd ::= SHOW MNODES", - /* 191 */ "cmd ::= SHOW MODULES", - /* 192 */ "cmd ::= SHOW QNODES", - /* 193 */ "cmd ::= SHOW FUNCTIONS", - /* 194 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 195 */ "cmd ::= SHOW STREAMS", - /* 196 */ "cmd ::= SHOW ACCOUNTS", - /* 197 */ "cmd ::= SHOW APPS", - /* 198 */ "cmd ::= SHOW CONNECTIONS", - /* 199 */ "cmd ::= SHOW LICENCE", - /* 200 */ "cmd ::= SHOW GRANTS", - /* 201 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 202 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 203 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 204 */ "cmd ::= SHOW QUERIES", - /* 205 */ "cmd ::= SHOW SCORES", - /* 206 */ "cmd ::= SHOW TOPICS", - /* 207 */ "cmd ::= SHOW VARIABLES", - /* 208 */ "cmd ::= SHOW LOCAL VARIABLES", - /* 209 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES", - /* 210 */ "cmd ::= SHOW BNODES", - /* 211 */ "cmd ::= SHOW SNODES", - /* 212 */ "cmd ::= SHOW CLUSTER", - /* 213 */ "cmd ::= SHOW TRANSACTIONS", - /* 214 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", - /* 215 */ "db_name_cond_opt ::=", - /* 216 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 217 */ "like_pattern_opt ::=", - /* 218 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 219 */ "table_name_cond ::= table_name", - /* 220 */ "from_db_opt ::=", - /* 221 */ "from_db_opt ::= FROM db_name", - /* 222 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", - /* 223 */ "cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP", - /* 224 */ "cmd ::= DROP INDEX exists_opt index_name ON table_name", - /* 225 */ "index_options ::=", - /* 226 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", - /* 227 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", - /* 228 */ "func_list ::= func", - /* 229 */ "func_list ::= func_list NK_COMMA func", - /* 230 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 231 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", - /* 232 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", - /* 233 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", - /* 234 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 235 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 236 */ "cmd ::= DESC full_table_name", - /* 237 */ "cmd ::= DESCRIBE full_table_name", - /* 238 */ "cmd ::= RESET QUERY CACHE", - /* 239 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", - /* 240 */ "analyze_opt ::=", - /* 241 */ "analyze_opt ::= ANALYZE", - /* 242 */ "explain_options ::=", - /* 243 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 244 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 245 */ "cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP", - /* 246 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", - /* 247 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 248 */ "agg_func_opt ::=", - /* 249 */ "agg_func_opt ::= AGGREGATE", - /* 250 */ "bufsize_opt ::=", - /* 251 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 252 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression", - /* 253 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 254 */ "into_opt ::=", - /* 255 */ "into_opt ::= INTO full_table_name", - /* 256 */ "stream_options ::=", - /* 257 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 258 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 259 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 260 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 261 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 262 */ "cmd ::= KILL QUERY NK_STRING", - /* 263 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 264 */ "cmd ::= BALANCE VGROUP", - /* 265 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 266 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 267 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 268 */ "dnode_list ::= DNODE NK_INTEGER", - /* 269 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 270 */ "cmd ::= SYNCDB db_name REPLICA", - /* 271 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 272 */ "cmd ::= query_expression", - /* 273 */ "literal ::= NK_INTEGER", - /* 274 */ "literal ::= NK_FLOAT", - /* 275 */ "literal ::= NK_STRING", - /* 276 */ "literal ::= NK_BOOL", - /* 277 */ "literal ::= TIMESTAMP NK_STRING", - /* 278 */ "literal ::= duration_literal", - /* 279 */ "literal ::= NULL", - /* 280 */ "literal ::= NK_QUESTION", - /* 281 */ "duration_literal ::= NK_VARIABLE", - /* 282 */ "signed ::= NK_INTEGER", - /* 283 */ "signed ::= NK_PLUS NK_INTEGER", - /* 284 */ "signed ::= NK_MINUS NK_INTEGER", - /* 285 */ "signed ::= NK_FLOAT", - /* 286 */ "signed ::= NK_PLUS NK_FLOAT", - /* 287 */ "signed ::= NK_MINUS NK_FLOAT", - /* 288 */ "signed_literal ::= signed", - /* 289 */ "signed_literal ::= NK_STRING", - /* 290 */ "signed_literal ::= NK_BOOL", - /* 291 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 292 */ "signed_literal ::= duration_literal", - /* 293 */ "signed_literal ::= NULL", - /* 294 */ "signed_literal ::= literal_func", - /* 295 */ "literal_list ::= signed_literal", - /* 296 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 297 */ "db_name ::= NK_ID", - /* 298 */ "table_name ::= NK_ID", - /* 299 */ "column_name ::= NK_ID", - /* 300 */ "function_name ::= NK_ID", - /* 301 */ "table_alias ::= NK_ID", - /* 302 */ "column_alias ::= NK_ID", - /* 303 */ "user_name ::= NK_ID", - /* 304 */ "index_name ::= NK_ID", - /* 305 */ "topic_name ::= NK_ID", - /* 306 */ "stream_name ::= NK_ID", - /* 307 */ "cgroup_name ::= NK_ID", - /* 308 */ "expression ::= literal", - /* 309 */ "expression ::= pseudo_column", - /* 310 */ "expression ::= column_reference", - /* 311 */ "expression ::= function_expression", - /* 312 */ "expression ::= subquery", - /* 313 */ "expression ::= NK_LP expression NK_RP", - /* 314 */ "expression ::= NK_PLUS expression", - /* 315 */ "expression ::= NK_MINUS expression", - /* 316 */ "expression ::= expression NK_PLUS expression", - /* 317 */ "expression ::= expression NK_MINUS expression", - /* 318 */ "expression ::= expression NK_STAR expression", - /* 319 */ "expression ::= expression NK_SLASH expression", - /* 320 */ "expression ::= expression NK_REM expression", - /* 321 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 322 */ "expression_list ::= expression", - /* 323 */ "expression_list ::= expression_list NK_COMMA expression", - /* 324 */ "column_reference ::= column_name", - /* 325 */ "column_reference ::= table_name NK_DOT column_name", - /* 326 */ "pseudo_column ::= ROWTS", - /* 327 */ "pseudo_column ::= TBNAME", - /* 328 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 329 */ "pseudo_column ::= QSTARTTS", - /* 330 */ "pseudo_column ::= QENDTS", - /* 331 */ "pseudo_column ::= WSTARTTS", - /* 332 */ "pseudo_column ::= WENDTS", - /* 333 */ "pseudo_column ::= WDURATION", - /* 334 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 335 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 336 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", - /* 337 */ "function_expression ::= literal_func", - /* 338 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 339 */ "literal_func ::= NOW", - /* 340 */ "noarg_func ::= NOW", - /* 341 */ "noarg_func ::= TODAY", - /* 342 */ "noarg_func ::= TIMEZONE", - /* 343 */ "star_func ::= COUNT", - /* 344 */ "star_func ::= FIRST", - /* 345 */ "star_func ::= LAST", - /* 346 */ "star_func ::= LAST_ROW", - /* 347 */ "star_func_para_list ::= NK_STAR", - /* 348 */ "star_func_para_list ::= other_para_list", - /* 349 */ "other_para_list ::= star_func_para", - /* 350 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 351 */ "star_func_para ::= expression", - /* 352 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 353 */ "predicate ::= expression compare_op expression", - /* 354 */ "predicate ::= expression BETWEEN expression AND expression", - /* 355 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 356 */ "predicate ::= expression IS NULL", - /* 357 */ "predicate ::= expression IS NOT NULL", - /* 358 */ "predicate ::= expression in_op in_predicate_value", - /* 359 */ "compare_op ::= NK_LT", - /* 360 */ "compare_op ::= NK_GT", - /* 361 */ "compare_op ::= NK_LE", - /* 362 */ "compare_op ::= NK_GE", - /* 363 */ "compare_op ::= NK_NE", - /* 364 */ "compare_op ::= NK_EQ", - /* 365 */ "compare_op ::= LIKE", - /* 366 */ "compare_op ::= NOT LIKE", - /* 367 */ "compare_op ::= MATCH", - /* 368 */ "compare_op ::= NMATCH", - /* 369 */ "compare_op ::= CONTAINS", - /* 370 */ "in_op ::= IN", - /* 371 */ "in_op ::= NOT IN", - /* 372 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 373 */ "boolean_value_expression ::= boolean_primary", - /* 374 */ "boolean_value_expression ::= NOT boolean_primary", - /* 375 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 376 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 377 */ "boolean_primary ::= predicate", - /* 378 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 379 */ "common_expression ::= expression", - /* 380 */ "common_expression ::= boolean_value_expression", - /* 381 */ "from_clause ::= FROM table_reference_list", - /* 382 */ "table_reference_list ::= table_reference", - /* 383 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 384 */ "table_reference ::= table_primary", - /* 385 */ "table_reference ::= joined_table", - /* 386 */ "table_primary ::= table_name alias_opt", - /* 387 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 388 */ "table_primary ::= subquery alias_opt", - /* 389 */ "table_primary ::= parenthesized_joined_table", - /* 390 */ "alias_opt ::=", - /* 391 */ "alias_opt ::= table_alias", - /* 392 */ "alias_opt ::= AS table_alias", - /* 393 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 394 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 395 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 396 */ "join_type ::=", - /* 397 */ "join_type ::= INNER", - /* 398 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 399 */ "set_quantifier_opt ::=", - /* 400 */ "set_quantifier_opt ::= DISTINCT", - /* 401 */ "set_quantifier_opt ::= ALL", - /* 402 */ "select_list ::= NK_STAR", - /* 403 */ "select_list ::= select_sublist", - /* 404 */ "select_sublist ::= select_item", - /* 405 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 406 */ "select_item ::= common_expression", - /* 407 */ "select_item ::= common_expression column_alias", - /* 408 */ "select_item ::= common_expression AS column_alias", - /* 409 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 410 */ "where_clause_opt ::=", - /* 411 */ "where_clause_opt ::= WHERE search_condition", - /* 412 */ "partition_by_clause_opt ::=", - /* 413 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 414 */ "twindow_clause_opt ::=", - /* 415 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 416 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 417 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 418 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 419 */ "sliding_opt ::=", - /* 420 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 421 */ "fill_opt ::=", - /* 422 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 423 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 424 */ "fill_mode ::= NONE", - /* 425 */ "fill_mode ::= PREV", - /* 426 */ "fill_mode ::= NULL", - /* 427 */ "fill_mode ::= LINEAR", - /* 428 */ "fill_mode ::= NEXT", - /* 429 */ "group_by_clause_opt ::=", - /* 430 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 431 */ "group_by_list ::= expression", - /* 432 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 433 */ "having_clause_opt ::=", - /* 434 */ "having_clause_opt ::= HAVING search_condition", - /* 435 */ "range_opt ::=", - /* 436 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", - /* 437 */ "every_opt ::=", - /* 438 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 439 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 440 */ "query_expression_body ::= query_primary", - /* 441 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 442 */ "query_expression_body ::= query_expression_body UNION query_expression_body", - /* 443 */ "query_primary ::= query_specification", - /* 444 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", - /* 445 */ "order_by_clause_opt ::=", - /* 446 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 447 */ "slimit_clause_opt ::=", - /* 448 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 449 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 450 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 451 */ "limit_clause_opt ::=", - /* 452 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 453 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 454 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 455 */ "subquery ::= NK_LP query_expression NK_RP", - /* 456 */ "search_condition ::= common_expression", - /* 457 */ "sort_specification_list ::= sort_specification", - /* 458 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 459 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 460 */ "ordering_specification_opt ::=", - /* 461 */ "ordering_specification_opt ::= ASC", - /* 462 */ "ordering_specification_opt ::= DESC", - /* 463 */ "null_ordering_opt ::=", - /* 464 */ "null_ordering_opt ::= NULLS FIRST", - /* 465 */ "null_ordering_opt ::= NULLS LAST", + /* 26 */ "cmd ::= ALTER USER user_name ENABLE NK_INTEGER", + /* 27 */ "cmd ::= ALTER USER user_name SYSINFO NK_INTEGER", + /* 28 */ "cmd ::= DROP USER user_name", + /* 29 */ "sysinfo_opt ::=", + /* 30 */ "sysinfo_opt ::= SYSINFO NK_INTEGER", + /* 31 */ "cmd ::= GRANT privileges ON priv_level TO user_name", + /* 32 */ "cmd ::= REVOKE privileges ON priv_level FROM user_name", + /* 33 */ "privileges ::= ALL", + /* 34 */ "privileges ::= priv_type_list", + /* 35 */ "priv_type_list ::= priv_type", + /* 36 */ "priv_type_list ::= priv_type_list NK_COMMA priv_type", + /* 37 */ "priv_type ::= READ", + /* 38 */ "priv_type ::= WRITE", + /* 39 */ "priv_level ::= NK_STAR NK_DOT NK_STAR", + /* 40 */ "priv_level ::= db_name NK_DOT NK_STAR", + /* 41 */ "cmd ::= CREATE DNODE dnode_endpoint", + /* 42 */ "cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER", + /* 43 */ "cmd ::= DROP DNODE NK_INTEGER", + /* 44 */ "cmd ::= DROP DNODE dnode_endpoint", + /* 45 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING", + /* 46 */ "cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING", + /* 47 */ "cmd ::= ALTER ALL DNODES NK_STRING", + /* 48 */ "cmd ::= ALTER ALL DNODES NK_STRING NK_STRING", + /* 49 */ "dnode_endpoint ::= NK_STRING", + /* 50 */ "dnode_endpoint ::= NK_ID", + /* 51 */ "dnode_endpoint ::= NK_IPTOKEN", + /* 52 */ "cmd ::= ALTER LOCAL NK_STRING", + /* 53 */ "cmd ::= ALTER LOCAL NK_STRING NK_STRING", + /* 54 */ "cmd ::= CREATE QNODE ON DNODE NK_INTEGER", + /* 55 */ "cmd ::= DROP QNODE ON DNODE NK_INTEGER", + /* 56 */ "cmd ::= CREATE BNODE ON DNODE NK_INTEGER", + /* 57 */ "cmd ::= DROP BNODE ON DNODE NK_INTEGER", + /* 58 */ "cmd ::= CREATE SNODE ON DNODE NK_INTEGER", + /* 59 */ "cmd ::= DROP SNODE ON DNODE NK_INTEGER", + /* 60 */ "cmd ::= CREATE MNODE ON DNODE NK_INTEGER", + /* 61 */ "cmd ::= DROP MNODE ON DNODE NK_INTEGER", + /* 62 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", + /* 63 */ "cmd ::= DROP DATABASE exists_opt db_name", + /* 64 */ "cmd ::= USE db_name", + /* 65 */ "cmd ::= ALTER DATABASE db_name alter_db_options", + /* 66 */ "not_exists_opt ::= IF NOT EXISTS", + /* 67 */ "not_exists_opt ::=", + /* 68 */ "exists_opt ::= IF EXISTS", + /* 69 */ "exists_opt ::=", + /* 70 */ "db_options ::=", + /* 71 */ "db_options ::= db_options BUFFER NK_INTEGER", + /* 72 */ "db_options ::= db_options CACHELAST NK_INTEGER", + /* 73 */ "db_options ::= db_options COMP NK_INTEGER", + /* 74 */ "db_options ::= db_options DURATION NK_INTEGER", + /* 75 */ "db_options ::= db_options DURATION NK_VARIABLE", + /* 76 */ "db_options ::= db_options FSYNC NK_INTEGER", + /* 77 */ "db_options ::= db_options MAXROWS NK_INTEGER", + /* 78 */ "db_options ::= db_options MINROWS NK_INTEGER", + /* 79 */ "db_options ::= db_options KEEP integer_list", + /* 80 */ "db_options ::= db_options KEEP variable_list", + /* 81 */ "db_options ::= db_options PAGES NK_INTEGER", + /* 82 */ "db_options ::= db_options PAGESIZE NK_INTEGER", + /* 83 */ "db_options ::= db_options PRECISION NK_STRING", + /* 84 */ "db_options ::= db_options REPLICA NK_INTEGER", + /* 85 */ "db_options ::= db_options STRICT NK_INTEGER", + /* 86 */ "db_options ::= db_options WAL NK_INTEGER", + /* 87 */ "db_options ::= db_options VGROUPS NK_INTEGER", + /* 88 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", + /* 89 */ "db_options ::= db_options RETENTIONS retention_list", + /* 90 */ "db_options ::= db_options SCHEMALESS NK_INTEGER", + /* 91 */ "alter_db_options ::= alter_db_option", + /* 92 */ "alter_db_options ::= alter_db_options alter_db_option", + /* 93 */ "alter_db_option ::= BUFFER NK_INTEGER", + /* 94 */ "alter_db_option ::= CACHELAST NK_INTEGER", + /* 95 */ "alter_db_option ::= FSYNC NK_INTEGER", + /* 96 */ "alter_db_option ::= KEEP integer_list", + /* 97 */ "alter_db_option ::= KEEP variable_list", + /* 98 */ "alter_db_option ::= PAGES NK_INTEGER", + /* 99 */ "alter_db_option ::= REPLICA NK_INTEGER", + /* 100 */ "alter_db_option ::= STRICT NK_INTEGER", + /* 101 */ "alter_db_option ::= WAL NK_INTEGER", + /* 102 */ "integer_list ::= NK_INTEGER", + /* 103 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", + /* 104 */ "variable_list ::= NK_VARIABLE", + /* 105 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", + /* 106 */ "retention_list ::= retention", + /* 107 */ "retention_list ::= retention_list NK_COMMA retention", + /* 108 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", + /* 109 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 110 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 111 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 112 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 113 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 114 */ "cmd ::= ALTER TABLE alter_table_clause", + /* 115 */ "cmd ::= ALTER STABLE alter_table_clause", + /* 116 */ "alter_table_clause ::= full_table_name alter_table_options", + /* 117 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", + /* 118 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", + /* 119 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", + /* 120 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", + /* 121 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", + /* 122 */ "alter_table_clause ::= full_table_name DROP TAG column_name", + /* 123 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", + /* 124 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", + /* 125 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", + /* 126 */ "multi_create_clause ::= create_subtable_clause", + /* 127 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 128 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options", + /* 129 */ "multi_drop_clause ::= drop_table_clause", + /* 130 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 131 */ "drop_table_clause ::= exists_opt full_table_name", + /* 132 */ "specific_tags_opt ::=", + /* 133 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", + /* 134 */ "full_table_name ::= table_name", + /* 135 */ "full_table_name ::= db_name NK_DOT table_name", + /* 136 */ "column_def_list ::= column_def", + /* 137 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 138 */ "column_def ::= column_name type_name", + /* 139 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 140 */ "type_name ::= BOOL", + /* 141 */ "type_name ::= TINYINT", + /* 142 */ "type_name ::= SMALLINT", + /* 143 */ "type_name ::= INT", + /* 144 */ "type_name ::= INTEGER", + /* 145 */ "type_name ::= BIGINT", + /* 146 */ "type_name ::= FLOAT", + /* 147 */ "type_name ::= DOUBLE", + /* 148 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 149 */ "type_name ::= TIMESTAMP", + /* 150 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 151 */ "type_name ::= TINYINT UNSIGNED", + /* 152 */ "type_name ::= SMALLINT UNSIGNED", + /* 153 */ "type_name ::= INT UNSIGNED", + /* 154 */ "type_name ::= BIGINT UNSIGNED", + /* 155 */ "type_name ::= JSON", + /* 156 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 157 */ "type_name ::= MEDIUMBLOB", + /* 158 */ "type_name ::= BLOB", + /* 159 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 160 */ "type_name ::= DECIMAL", + /* 161 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 162 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 163 */ "tags_def_opt ::=", + /* 164 */ "tags_def_opt ::= tags_def", + /* 165 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 166 */ "table_options ::=", + /* 167 */ "table_options ::= table_options COMMENT NK_STRING", + /* 168 */ "table_options ::= table_options MAX_DELAY duration_list", + /* 169 */ "table_options ::= table_options WATERMARK duration_list", + /* 170 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", + /* 171 */ "table_options ::= table_options TTL NK_INTEGER", + /* 172 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 173 */ "alter_table_options ::= alter_table_option", + /* 174 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 175 */ "alter_table_option ::= COMMENT NK_STRING", + /* 176 */ "alter_table_option ::= TTL NK_INTEGER", + /* 177 */ "duration_list ::= duration_literal", + /* 178 */ "duration_list ::= duration_list NK_COMMA duration_literal", + /* 179 */ "rollup_func_list ::= rollup_func_name", + /* 180 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", + /* 181 */ "rollup_func_name ::= function_name", + /* 182 */ "rollup_func_name ::= FIRST", + /* 183 */ "rollup_func_name ::= LAST", + /* 184 */ "col_name_list ::= col_name", + /* 185 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 186 */ "col_name ::= column_name", + /* 187 */ "cmd ::= SHOW DNODES", + /* 188 */ "cmd ::= SHOW USERS", + /* 189 */ "cmd ::= SHOW DATABASES", + /* 190 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", + /* 191 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", + /* 192 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", + /* 193 */ "cmd ::= SHOW MNODES", + /* 194 */ "cmd ::= SHOW MODULES", + /* 195 */ "cmd ::= SHOW QNODES", + /* 196 */ "cmd ::= SHOW FUNCTIONS", + /* 197 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 198 */ "cmd ::= SHOW STREAMS", + /* 199 */ "cmd ::= SHOW ACCOUNTS", + /* 200 */ "cmd ::= SHOW APPS", + /* 201 */ "cmd ::= SHOW CONNECTIONS", + /* 202 */ "cmd ::= SHOW LICENCE", + /* 203 */ "cmd ::= SHOW GRANTS", + /* 204 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 205 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 206 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 207 */ "cmd ::= SHOW QUERIES", + /* 208 */ "cmd ::= SHOW SCORES", + /* 209 */ "cmd ::= SHOW TOPICS", + /* 210 */ "cmd ::= SHOW VARIABLES", + /* 211 */ "cmd ::= SHOW LOCAL VARIABLES", + /* 212 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES", + /* 213 */ "cmd ::= SHOW BNODES", + /* 214 */ "cmd ::= SHOW SNODES", + /* 215 */ "cmd ::= SHOW CLUSTER", + /* 216 */ "cmd ::= SHOW TRANSACTIONS", + /* 217 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", + /* 218 */ "db_name_cond_opt ::=", + /* 219 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 220 */ "like_pattern_opt ::=", + /* 221 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 222 */ "table_name_cond ::= table_name", + /* 223 */ "from_db_opt ::=", + /* 224 */ "from_db_opt ::= FROM db_name", + /* 225 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", + /* 226 */ "cmd ::= DROP INDEX exists_opt index_name", + /* 227 */ "index_options ::=", + /* 228 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", + /* 229 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", + /* 230 */ "func_list ::= func", + /* 231 */ "func_list ::= func_list NK_COMMA func", + /* 232 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 233 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", + /* 234 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", + /* 235 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", + /* 236 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", + /* 237 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", + /* 238 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 239 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 240 */ "cmd ::= DESC full_table_name", + /* 241 */ "cmd ::= DESCRIBE full_table_name", + /* 242 */ "cmd ::= RESET QUERY CACHE", + /* 243 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", + /* 244 */ "analyze_opt ::=", + /* 245 */ "analyze_opt ::= ANALYZE", + /* 246 */ "explain_options ::=", + /* 247 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 248 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 249 */ "cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP", + /* 250 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 251 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 252 */ "agg_func_opt ::=", + /* 253 */ "agg_func_opt ::= AGGREGATE", + /* 254 */ "bufsize_opt ::=", + /* 255 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 256 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression", + /* 257 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 258 */ "into_opt ::=", + /* 259 */ "into_opt ::= INTO full_table_name", + /* 260 */ "stream_options ::=", + /* 261 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 262 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 263 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 264 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 265 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 266 */ "cmd ::= KILL QUERY NK_STRING", + /* 267 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 268 */ "cmd ::= BALANCE VGROUP", + /* 269 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 270 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 271 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 272 */ "dnode_list ::= DNODE NK_INTEGER", + /* 273 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 274 */ "cmd ::= SYNCDB db_name REPLICA", + /* 275 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 276 */ "cmd ::= query_expression", + /* 277 */ "literal ::= NK_INTEGER", + /* 278 */ "literal ::= NK_FLOAT", + /* 279 */ "literal ::= NK_STRING", + /* 280 */ "literal ::= NK_BOOL", + /* 281 */ "literal ::= TIMESTAMP NK_STRING", + /* 282 */ "literal ::= duration_literal", + /* 283 */ "literal ::= NULL", + /* 284 */ "literal ::= NK_QUESTION", + /* 285 */ "duration_literal ::= NK_VARIABLE", + /* 286 */ "signed ::= NK_INTEGER", + /* 287 */ "signed ::= NK_PLUS NK_INTEGER", + /* 288 */ "signed ::= NK_MINUS NK_INTEGER", + /* 289 */ "signed ::= NK_FLOAT", + /* 290 */ "signed ::= NK_PLUS NK_FLOAT", + /* 291 */ "signed ::= NK_MINUS NK_FLOAT", + /* 292 */ "signed_literal ::= signed", + /* 293 */ "signed_literal ::= NK_STRING", + /* 294 */ "signed_literal ::= NK_BOOL", + /* 295 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 296 */ "signed_literal ::= duration_literal", + /* 297 */ "signed_literal ::= NULL", + /* 298 */ "signed_literal ::= literal_func", + /* 299 */ "literal_list ::= signed_literal", + /* 300 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 301 */ "db_name ::= NK_ID", + /* 302 */ "table_name ::= NK_ID", + /* 303 */ "column_name ::= NK_ID", + /* 304 */ "function_name ::= NK_ID", + /* 305 */ "table_alias ::= NK_ID", + /* 306 */ "column_alias ::= NK_ID", + /* 307 */ "user_name ::= NK_ID", + /* 308 */ "index_name ::= NK_ID", + /* 309 */ "topic_name ::= NK_ID", + /* 310 */ "stream_name ::= NK_ID", + /* 311 */ "cgroup_name ::= NK_ID", + /* 312 */ "expression ::= literal", + /* 313 */ "expression ::= pseudo_column", + /* 314 */ "expression ::= column_reference", + /* 315 */ "expression ::= function_expression", + /* 316 */ "expression ::= subquery", + /* 317 */ "expression ::= NK_LP expression NK_RP", + /* 318 */ "expression ::= NK_PLUS expression", + /* 319 */ "expression ::= NK_MINUS expression", + /* 320 */ "expression ::= expression NK_PLUS expression", + /* 321 */ "expression ::= expression NK_MINUS expression", + /* 322 */ "expression ::= expression NK_STAR expression", + /* 323 */ "expression ::= expression NK_SLASH expression", + /* 324 */ "expression ::= expression NK_REM expression", + /* 325 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 326 */ "expression ::= expression NK_BITAND expression", + /* 327 */ "expression ::= expression NK_BITOR expression", + /* 328 */ "expression_list ::= expression", + /* 329 */ "expression_list ::= expression_list NK_COMMA expression", + /* 330 */ "column_reference ::= column_name", + /* 331 */ "column_reference ::= table_name NK_DOT column_name", + /* 332 */ "pseudo_column ::= ROWTS", + /* 333 */ "pseudo_column ::= TBNAME", + /* 334 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 335 */ "pseudo_column ::= QSTARTTS", + /* 336 */ "pseudo_column ::= QENDTS", + /* 337 */ "pseudo_column ::= WSTARTTS", + /* 338 */ "pseudo_column ::= WENDTS", + /* 339 */ "pseudo_column ::= WDURATION", + /* 340 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 341 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 342 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", + /* 343 */ "function_expression ::= literal_func", + /* 344 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 345 */ "literal_func ::= NOW", + /* 346 */ "noarg_func ::= NOW", + /* 347 */ "noarg_func ::= TODAY", + /* 348 */ "noarg_func ::= TIMEZONE", + /* 349 */ "star_func ::= COUNT", + /* 350 */ "star_func ::= FIRST", + /* 351 */ "star_func ::= LAST", + /* 352 */ "star_func ::= LAST_ROW", + /* 353 */ "star_func_para_list ::= NK_STAR", + /* 354 */ "star_func_para_list ::= other_para_list", + /* 355 */ "other_para_list ::= star_func_para", + /* 356 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 357 */ "star_func_para ::= expression", + /* 358 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 359 */ "predicate ::= expression compare_op expression", + /* 360 */ "predicate ::= expression BETWEEN expression AND expression", + /* 361 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 362 */ "predicate ::= expression IS NULL", + /* 363 */ "predicate ::= expression IS NOT NULL", + /* 364 */ "predicate ::= expression in_op in_predicate_value", + /* 365 */ "compare_op ::= NK_LT", + /* 366 */ "compare_op ::= NK_GT", + /* 367 */ "compare_op ::= NK_LE", + /* 368 */ "compare_op ::= NK_GE", + /* 369 */ "compare_op ::= NK_NE", + /* 370 */ "compare_op ::= NK_EQ", + /* 371 */ "compare_op ::= LIKE", + /* 372 */ "compare_op ::= NOT LIKE", + /* 373 */ "compare_op ::= MATCH", + /* 374 */ "compare_op ::= NMATCH", + /* 375 */ "compare_op ::= CONTAINS", + /* 376 */ "in_op ::= IN", + /* 377 */ "in_op ::= NOT IN", + /* 378 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 379 */ "boolean_value_expression ::= boolean_primary", + /* 380 */ "boolean_value_expression ::= NOT boolean_primary", + /* 381 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 382 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 383 */ "boolean_primary ::= predicate", + /* 384 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 385 */ "common_expression ::= expression", + /* 386 */ "common_expression ::= boolean_value_expression", + /* 387 */ "from_clause_opt ::=", + /* 388 */ "from_clause_opt ::= FROM table_reference_list", + /* 389 */ "table_reference_list ::= table_reference", + /* 390 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 391 */ "table_reference ::= table_primary", + /* 392 */ "table_reference ::= joined_table", + /* 393 */ "table_primary ::= table_name alias_opt", + /* 394 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 395 */ "table_primary ::= subquery alias_opt", + /* 396 */ "table_primary ::= parenthesized_joined_table", + /* 397 */ "alias_opt ::=", + /* 398 */ "alias_opt ::= table_alias", + /* 399 */ "alias_opt ::= AS table_alias", + /* 400 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 401 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 402 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 403 */ "join_type ::=", + /* 404 */ "join_type ::= INNER", + /* 405 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 406 */ "set_quantifier_opt ::=", + /* 407 */ "set_quantifier_opt ::= DISTINCT", + /* 408 */ "set_quantifier_opt ::= ALL", + /* 409 */ "select_list ::= NK_STAR", + /* 410 */ "select_list ::= select_sublist", + /* 411 */ "select_sublist ::= select_item", + /* 412 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 413 */ "select_item ::= common_expression", + /* 414 */ "select_item ::= common_expression column_alias", + /* 415 */ "select_item ::= common_expression AS column_alias", + /* 416 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 417 */ "where_clause_opt ::=", + /* 418 */ "where_clause_opt ::= WHERE search_condition", + /* 419 */ "partition_by_clause_opt ::=", + /* 420 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 421 */ "twindow_clause_opt ::=", + /* 422 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 423 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 424 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 425 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 426 */ "sliding_opt ::=", + /* 427 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 428 */ "fill_opt ::=", + /* 429 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 430 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 431 */ "fill_mode ::= NONE", + /* 432 */ "fill_mode ::= PREV", + /* 433 */ "fill_mode ::= NULL", + /* 434 */ "fill_mode ::= LINEAR", + /* 435 */ "fill_mode ::= NEXT", + /* 436 */ "group_by_clause_opt ::=", + /* 437 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 438 */ "group_by_list ::= expression", + /* 439 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 440 */ "having_clause_opt ::=", + /* 441 */ "having_clause_opt ::= HAVING search_condition", + /* 442 */ "range_opt ::=", + /* 443 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", + /* 444 */ "every_opt ::=", + /* 445 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 446 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 447 */ "query_expression_body ::= query_primary", + /* 448 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 449 */ "query_expression_body ::= query_expression_body UNION query_expression_body", + /* 450 */ "query_primary ::= query_specification", + /* 451 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", + /* 452 */ "order_by_clause_opt ::=", + /* 453 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 454 */ "slimit_clause_opt ::=", + /* 455 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 456 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 457 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 458 */ "limit_clause_opt ::=", + /* 459 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 460 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 461 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 462 */ "subquery ::= NK_LP query_expression NK_RP", + /* 463 */ "search_condition ::= common_expression", + /* 464 */ "sort_specification_list ::= sort_specification", + /* 465 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 466 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 467 */ "ordering_specification_opt ::=", + /* 468 */ "ordering_specification_opt ::= ASC", + /* 469 */ "ordering_specification_opt ::= DESC", + /* 470 */ "null_ordering_opt ::=", + /* 471 */ "null_ordering_opt ::= NULLS FIRST", + /* 472 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2139,176 +2164,181 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 242: /* cmd */ - case 245: /* literal */ - case 255: /* db_options */ - case 257: /* alter_db_options */ - case 262: /* retention */ - case 263: /* full_table_name */ - case 266: /* table_options */ - case 270: /* alter_table_clause */ - case 271: /* alter_table_options */ - case 274: /* signed_literal */ - case 275: /* create_subtable_clause */ - case 278: /* drop_table_clause */ - case 281: /* column_def */ - case 285: /* duration_literal */ - case 286: /* rollup_func_name */ - case 288: /* col_name */ - case 289: /* db_name_cond_opt */ - case 290: /* like_pattern_opt */ - case 291: /* table_name_cond */ - case 292: /* from_db_opt */ - case 294: /* index_options */ - case 296: /* sliding_opt */ - case 297: /* func */ - case 300: /* query_expression */ - case 303: /* explain_options */ - case 307: /* stream_options */ - case 308: /* into_opt */ - case 310: /* where_clause_opt */ - case 311: /* signed */ - case 312: /* literal_func */ - case 315: /* expression */ - case 316: /* pseudo_column */ - case 317: /* column_reference */ - case 318: /* function_expression */ - case 319: /* subquery */ - case 324: /* star_func_para */ - case 325: /* predicate */ - case 328: /* in_predicate_value */ - case 329: /* boolean_value_expression */ - case 330: /* boolean_primary */ - case 331: /* common_expression */ - case 332: /* from_clause */ - case 333: /* table_reference_list */ - case 334: /* table_reference */ - case 335: /* table_primary */ - case 336: /* joined_table */ - case 338: /* parenthesized_joined_table */ - case 340: /* search_condition */ - case 341: /* query_specification */ - case 345: /* range_opt */ - case 346: /* every_opt */ - case 347: /* fill_opt */ - case 348: /* twindow_clause_opt */ - case 350: /* having_clause_opt */ - case 352: /* select_item */ - case 355: /* query_expression_body */ - case 357: /* slimit_clause_opt */ - case 358: /* limit_clause_opt */ - case 359: /* query_primary */ - case 361: /* sort_specification */ + case 244: /* cmd */ + case 247: /* literal */ + case 258: /* db_options */ + case 260: /* alter_db_options */ + case 265: /* retention */ + case 266: /* full_table_name */ + case 269: /* table_options */ + case 273: /* alter_table_clause */ + case 274: /* alter_table_options */ + case 277: /* signed_literal */ + case 278: /* create_subtable_clause */ + case 281: /* drop_table_clause */ + case 284: /* column_def */ + case 288: /* duration_literal */ + case 289: /* rollup_func_name */ + case 291: /* col_name */ + case 292: /* db_name_cond_opt */ + case 293: /* like_pattern_opt */ + case 294: /* table_name_cond */ + case 295: /* from_db_opt */ + case 297: /* index_options */ + case 299: /* sliding_opt */ + case 300: /* func */ + case 303: /* query_expression */ + case 306: /* explain_options */ + case 310: /* stream_options */ + case 311: /* into_opt */ + case 313: /* where_clause_opt */ + case 314: /* signed */ + case 315: /* literal_func */ + case 318: /* expression */ + case 319: /* pseudo_column */ + case 320: /* column_reference */ + case 321: /* function_expression */ + case 322: /* subquery */ + case 327: /* star_func_para */ + case 328: /* predicate */ + case 331: /* in_predicate_value */ + case 332: /* boolean_value_expression */ + case 333: /* boolean_primary */ + case 334: /* common_expression */ + case 335: /* from_clause_opt */ + case 336: /* table_reference_list */ + case 337: /* table_reference */ + case 338: /* table_primary */ + case 339: /* joined_table */ + case 341: /* parenthesized_joined_table */ + case 343: /* search_condition */ + case 344: /* query_specification */ + case 348: /* range_opt */ + case 349: /* every_opt */ + case 350: /* fill_opt */ + case 351: /* twindow_clause_opt */ + case 353: /* having_clause_opt */ + case 355: /* select_item */ + case 358: /* query_expression_body */ + case 360: /* slimit_clause_opt */ + case 361: /* limit_clause_opt */ + case 362: /* query_primary */ + case 364: /* sort_specification */ { - nodesDestroyNode((yypminor->yy392)); + nodesDestroyNode((yypminor->yy442)); } break; - case 243: /* account_options */ - case 244: /* alter_account_options */ - case 246: /* alter_account_option */ - case 305: /* bufsize_opt */ + case 245: /* account_options */ + case 246: /* alter_account_options */ + case 248: /* alter_account_option */ + case 308: /* bufsize_opt */ { } break; - case 247: /* user_name */ - case 249: /* priv_level */ - case 252: /* db_name */ - case 253: /* dnode_endpoint */ - case 272: /* column_name */ - case 280: /* table_name */ - case 287: /* function_name */ - case 293: /* index_name */ - case 299: /* topic_name */ - case 301: /* cgroup_name */ - case 306: /* stream_name */ - case 313: /* table_alias */ - case 314: /* column_alias */ - case 320: /* star_func */ - case 322: /* noarg_func */ - case 337: /* alias_opt */ + case 249: /* user_name */ + case 252: /* priv_level */ + case 255: /* db_name */ + case 256: /* dnode_endpoint */ + case 275: /* column_name */ + case 283: /* table_name */ + case 290: /* function_name */ + case 296: /* index_name */ + case 302: /* topic_name */ + case 304: /* cgroup_name */ + case 309: /* stream_name */ + case 316: /* table_alias */ + case 317: /* column_alias */ + case 323: /* star_func */ + case 325: /* noarg_func */ + case 340: /* alias_opt */ { } break; - case 248: /* privileges */ - case 250: /* priv_type_list */ - case 251: /* priv_type */ + case 250: /* sysinfo_opt */ { } break; - case 254: /* not_exists_opt */ - case 256: /* exists_opt */ - case 302: /* analyze_opt */ - case 304: /* agg_func_opt */ - case 342: /* set_quantifier_opt */ + case 251: /* privileges */ + case 253: /* priv_type_list */ + case 254: /* priv_type */ { } break; - case 258: /* integer_list */ - case 259: /* variable_list */ - case 260: /* retention_list */ - case 264: /* column_def_list */ - case 265: /* tags_def_opt */ - case 267: /* multi_create_clause */ - case 268: /* tags_def */ - case 269: /* multi_drop_clause */ - case 276: /* specific_tags_opt */ - case 277: /* literal_list */ - case 279: /* col_name_list */ - case 282: /* duration_list */ - case 283: /* rollup_func_list */ - case 295: /* func_list */ - case 298: /* expression_list */ - case 309: /* dnode_list */ - case 321: /* star_func_para_list */ - case 323: /* other_para_list */ - case 343: /* select_list */ - case 344: /* partition_by_clause_opt */ - case 349: /* group_by_clause_opt */ - case 351: /* select_sublist */ - case 354: /* group_by_list */ - case 356: /* order_by_clause_opt */ - case 360: /* sort_specification_list */ -{ - nodesDestroyList((yypminor->yy600)); -} - break; - case 261: /* alter_db_option */ - case 284: /* alter_table_option */ + case 257: /* not_exists_opt */ + case 259: /* exists_opt */ + case 305: /* analyze_opt */ + case 307: /* agg_func_opt */ + case 345: /* set_quantifier_opt */ { } break; - case 273: /* type_name */ + case 261: /* integer_list */ + case 262: /* variable_list */ + case 263: /* retention_list */ + case 267: /* column_def_list */ + case 268: /* tags_def_opt */ + case 270: /* multi_create_clause */ + case 271: /* tags_def */ + case 272: /* multi_drop_clause */ + case 279: /* specific_tags_opt */ + case 280: /* literal_list */ + case 282: /* col_name_list */ + case 285: /* duration_list */ + case 286: /* rollup_func_list */ + case 298: /* func_list */ + case 301: /* expression_list */ + case 312: /* dnode_list */ + case 324: /* star_func_para_list */ + case 326: /* other_para_list */ + case 346: /* select_list */ + case 347: /* partition_by_clause_opt */ + case 352: /* group_by_clause_opt */ + case 354: /* select_sublist */ + case 357: /* group_by_list */ + case 359: /* order_by_clause_opt */ + case 363: /* sort_specification_list */ +{ + nodesDestroyList((yypminor->yy368)); +} + break; + case 264: /* alter_db_option */ + case 287: /* alter_table_option */ { } break; - case 326: /* compare_op */ - case 327: /* in_op */ + case 276: /* type_name */ { } break; - case 339: /* join_type */ + case 329: /* compare_op */ + case 330: /* in_op */ { } break; - case 353: /* fill_mode */ + case 342: /* join_type */ { } break; - case 362: /* ordering_specification_opt */ + case 356: /* fill_mode */ { } break; - case 363: /* null_ordering_opt */ + case 365: /* ordering_specification_opt */ +{ + +} + break; + case 366: /* null_ordering_opt */ { } @@ -2607,472 +2637,479 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { - { 242, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 242, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 243, 0 }, /* (2) account_options ::= */ - { 243, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 243, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 243, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 243, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 243, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 243, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 243, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 243, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 243, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 244, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 244, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 246, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 246, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 246, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 246, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 246, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 246, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 246, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 246, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 246, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 246, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 242, -5 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 242, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 242, -5 }, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 242, -3 }, /* (27) cmd ::= DROP USER user_name */ - { 242, -6 }, /* (28) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 242, -6 }, /* (29) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 248, -1 }, /* (30) privileges ::= ALL */ - { 248, -1 }, /* (31) privileges ::= priv_type_list */ - { 250, -1 }, /* (32) priv_type_list ::= priv_type */ - { 250, -3 }, /* (33) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 251, -1 }, /* (34) priv_type ::= READ */ - { 251, -1 }, /* (35) priv_type ::= WRITE */ - { 249, -3 }, /* (36) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 249, -3 }, /* (37) priv_level ::= db_name NK_DOT NK_STAR */ - { 242, -3 }, /* (38) cmd ::= CREATE DNODE dnode_endpoint */ - { 242, -5 }, /* (39) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - { 242, -3 }, /* (40) cmd ::= DROP DNODE NK_INTEGER */ - { 242, -3 }, /* (41) cmd ::= DROP DNODE dnode_endpoint */ - { 242, -4 }, /* (42) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 242, -5 }, /* (43) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 242, -4 }, /* (44) cmd ::= ALTER ALL DNODES NK_STRING */ - { 242, -5 }, /* (45) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 253, -1 }, /* (46) dnode_endpoint ::= NK_STRING */ - { 253, -1 }, /* (47) dnode_endpoint ::= NK_ID */ - { 253, -1 }, /* (48) dnode_endpoint ::= NK_IPTOKEN */ - { 242, -3 }, /* (49) cmd ::= ALTER LOCAL NK_STRING */ - { 242, -4 }, /* (50) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 242, -5 }, /* (51) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 242, -5 }, /* (52) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 242, -5 }, /* (53) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 242, -5 }, /* (54) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 242, -5 }, /* (55) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 242, -5 }, /* (56) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 242, -5 }, /* (57) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 242, -5 }, /* (58) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 242, -5 }, /* (59) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 242, -4 }, /* (60) cmd ::= DROP DATABASE exists_opt db_name */ - { 242, -2 }, /* (61) cmd ::= USE db_name */ - { 242, -4 }, /* (62) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 254, -3 }, /* (63) not_exists_opt ::= IF NOT EXISTS */ - { 254, 0 }, /* (64) not_exists_opt ::= */ - { 256, -2 }, /* (65) exists_opt ::= IF EXISTS */ - { 256, 0 }, /* (66) exists_opt ::= */ - { 255, 0 }, /* (67) db_options ::= */ - { 255, -3 }, /* (68) db_options ::= db_options BUFFER NK_INTEGER */ - { 255, -3 }, /* (69) db_options ::= db_options CACHELAST NK_INTEGER */ - { 255, -3 }, /* (70) db_options ::= db_options COMP NK_INTEGER */ - { 255, -3 }, /* (71) db_options ::= db_options DURATION NK_INTEGER */ - { 255, -3 }, /* (72) db_options ::= db_options DURATION NK_VARIABLE */ - { 255, -3 }, /* (73) db_options ::= db_options FSYNC NK_INTEGER */ - { 255, -3 }, /* (74) db_options ::= db_options MAXROWS NK_INTEGER */ - { 255, -3 }, /* (75) db_options ::= db_options MINROWS NK_INTEGER */ - { 255, -3 }, /* (76) db_options ::= db_options KEEP integer_list */ - { 255, -3 }, /* (77) db_options ::= db_options KEEP variable_list */ - { 255, -3 }, /* (78) db_options ::= db_options PAGES NK_INTEGER */ - { 255, -3 }, /* (79) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 255, -3 }, /* (80) db_options ::= db_options PRECISION NK_STRING */ - { 255, -3 }, /* (81) db_options ::= db_options REPLICA NK_INTEGER */ - { 255, -3 }, /* (82) db_options ::= db_options STRICT NK_INTEGER */ - { 255, -3 }, /* (83) db_options ::= db_options WAL NK_INTEGER */ - { 255, -3 }, /* (84) db_options ::= db_options VGROUPS NK_INTEGER */ - { 255, -3 }, /* (85) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 255, -3 }, /* (86) db_options ::= db_options RETENTIONS retention_list */ - { 255, -3 }, /* (87) db_options ::= db_options SCHEMALESS NK_INTEGER */ - { 257, -1 }, /* (88) alter_db_options ::= alter_db_option */ - { 257, -2 }, /* (89) alter_db_options ::= alter_db_options alter_db_option */ - { 261, -2 }, /* (90) alter_db_option ::= BUFFER NK_INTEGER */ - { 261, -2 }, /* (91) alter_db_option ::= CACHELAST NK_INTEGER */ - { 261, -2 }, /* (92) alter_db_option ::= FSYNC NK_INTEGER */ - { 261, -2 }, /* (93) alter_db_option ::= KEEP integer_list */ - { 261, -2 }, /* (94) alter_db_option ::= KEEP variable_list */ - { 261, -2 }, /* (95) alter_db_option ::= PAGES NK_INTEGER */ - { 261, -2 }, /* (96) alter_db_option ::= REPLICA NK_INTEGER */ - { 261, -2 }, /* (97) alter_db_option ::= STRICT NK_INTEGER */ - { 261, -2 }, /* (98) alter_db_option ::= WAL NK_INTEGER */ - { 258, -1 }, /* (99) integer_list ::= NK_INTEGER */ - { 258, -3 }, /* (100) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 259, -1 }, /* (101) variable_list ::= NK_VARIABLE */ - { 259, -3 }, /* (102) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 260, -1 }, /* (103) retention_list ::= retention */ - { 260, -3 }, /* (104) retention_list ::= retention_list NK_COMMA retention */ - { 262, -3 }, /* (105) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 242, -9 }, /* (106) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 242, -3 }, /* (107) cmd ::= CREATE TABLE multi_create_clause */ - { 242, -9 }, /* (108) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 242, -3 }, /* (109) cmd ::= DROP TABLE multi_drop_clause */ - { 242, -4 }, /* (110) cmd ::= DROP STABLE exists_opt full_table_name */ - { 242, -3 }, /* (111) cmd ::= ALTER TABLE alter_table_clause */ - { 242, -3 }, /* (112) cmd ::= ALTER STABLE alter_table_clause */ - { 270, -2 }, /* (113) alter_table_clause ::= full_table_name alter_table_options */ - { 270, -5 }, /* (114) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 270, -4 }, /* (115) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 270, -5 }, /* (116) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 270, -5 }, /* (117) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 270, -5 }, /* (118) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 270, -4 }, /* (119) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 270, -5 }, /* (120) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 270, -5 }, /* (121) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 270, -6 }, /* (122) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 267, -1 }, /* (123) multi_create_clause ::= create_subtable_clause */ - { 267, -2 }, /* (124) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 275, -10 }, /* (125) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ - { 269, -1 }, /* (126) multi_drop_clause ::= drop_table_clause */ - { 269, -2 }, /* (127) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 278, -2 }, /* (128) drop_table_clause ::= exists_opt full_table_name */ - { 276, 0 }, /* (129) specific_tags_opt ::= */ - { 276, -3 }, /* (130) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 263, -1 }, /* (131) full_table_name ::= table_name */ - { 263, -3 }, /* (132) full_table_name ::= db_name NK_DOT table_name */ - { 264, -1 }, /* (133) column_def_list ::= column_def */ - { 264, -3 }, /* (134) column_def_list ::= column_def_list NK_COMMA column_def */ - { 281, -2 }, /* (135) column_def ::= column_name type_name */ - { 281, -4 }, /* (136) column_def ::= column_name type_name COMMENT NK_STRING */ - { 273, -1 }, /* (137) type_name ::= BOOL */ - { 273, -1 }, /* (138) type_name ::= TINYINT */ - { 273, -1 }, /* (139) type_name ::= SMALLINT */ - { 273, -1 }, /* (140) type_name ::= INT */ - { 273, -1 }, /* (141) type_name ::= INTEGER */ - { 273, -1 }, /* (142) type_name ::= BIGINT */ - { 273, -1 }, /* (143) type_name ::= FLOAT */ - { 273, -1 }, /* (144) type_name ::= DOUBLE */ - { 273, -4 }, /* (145) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 273, -1 }, /* (146) type_name ::= TIMESTAMP */ - { 273, -4 }, /* (147) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 273, -2 }, /* (148) type_name ::= TINYINT UNSIGNED */ - { 273, -2 }, /* (149) type_name ::= SMALLINT UNSIGNED */ - { 273, -2 }, /* (150) type_name ::= INT UNSIGNED */ - { 273, -2 }, /* (151) type_name ::= BIGINT UNSIGNED */ - { 273, -1 }, /* (152) type_name ::= JSON */ - { 273, -4 }, /* (153) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 273, -1 }, /* (154) type_name ::= MEDIUMBLOB */ - { 273, -1 }, /* (155) type_name ::= BLOB */ - { 273, -4 }, /* (156) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 273, -1 }, /* (157) type_name ::= DECIMAL */ - { 273, -4 }, /* (158) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 273, -6 }, /* (159) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 265, 0 }, /* (160) tags_def_opt ::= */ - { 265, -1 }, /* (161) tags_def_opt ::= tags_def */ - { 268, -4 }, /* (162) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 266, 0 }, /* (163) table_options ::= */ - { 266, -3 }, /* (164) table_options ::= table_options COMMENT NK_STRING */ - { 266, -3 }, /* (165) table_options ::= table_options MAX_DELAY duration_list */ - { 266, -3 }, /* (166) table_options ::= table_options WATERMARK duration_list */ - { 266, -5 }, /* (167) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - { 266, -3 }, /* (168) table_options ::= table_options TTL NK_INTEGER */ - { 266, -5 }, /* (169) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 271, -1 }, /* (170) alter_table_options ::= alter_table_option */ - { 271, -2 }, /* (171) alter_table_options ::= alter_table_options alter_table_option */ - { 284, -2 }, /* (172) alter_table_option ::= COMMENT NK_STRING */ - { 284, -2 }, /* (173) alter_table_option ::= TTL NK_INTEGER */ - { 282, -1 }, /* (174) duration_list ::= duration_literal */ - { 282, -3 }, /* (175) duration_list ::= duration_list NK_COMMA duration_literal */ - { 283, -1 }, /* (176) rollup_func_list ::= rollup_func_name */ - { 283, -3 }, /* (177) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - { 286, -1 }, /* (178) rollup_func_name ::= function_name */ - { 286, -1 }, /* (179) rollup_func_name ::= FIRST */ - { 286, -1 }, /* (180) rollup_func_name ::= LAST */ - { 279, -1 }, /* (181) col_name_list ::= col_name */ - { 279, -3 }, /* (182) col_name_list ::= col_name_list NK_COMMA col_name */ - { 288, -1 }, /* (183) col_name ::= column_name */ - { 242, -2 }, /* (184) cmd ::= SHOW DNODES */ - { 242, -2 }, /* (185) cmd ::= SHOW USERS */ - { 242, -2 }, /* (186) cmd ::= SHOW DATABASES */ - { 242, -4 }, /* (187) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 242, -4 }, /* (188) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 242, -3 }, /* (189) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 242, -2 }, /* (190) cmd ::= SHOW MNODES */ - { 242, -2 }, /* (191) cmd ::= SHOW MODULES */ - { 242, -2 }, /* (192) cmd ::= SHOW QNODES */ - { 242, -2 }, /* (193) cmd ::= SHOW FUNCTIONS */ - { 242, -5 }, /* (194) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 242, -2 }, /* (195) cmd ::= SHOW STREAMS */ - { 242, -2 }, /* (196) cmd ::= SHOW ACCOUNTS */ - { 242, -2 }, /* (197) cmd ::= SHOW APPS */ - { 242, -2 }, /* (198) cmd ::= SHOW CONNECTIONS */ - { 242, -2 }, /* (199) cmd ::= SHOW LICENCE */ - { 242, -2 }, /* (200) cmd ::= SHOW GRANTS */ - { 242, -4 }, /* (201) cmd ::= SHOW CREATE DATABASE db_name */ - { 242, -4 }, /* (202) cmd ::= SHOW CREATE TABLE full_table_name */ - { 242, -4 }, /* (203) cmd ::= SHOW CREATE STABLE full_table_name */ - { 242, -2 }, /* (204) cmd ::= SHOW QUERIES */ - { 242, -2 }, /* (205) cmd ::= SHOW SCORES */ - { 242, -2 }, /* (206) cmd ::= SHOW TOPICS */ - { 242, -2 }, /* (207) cmd ::= SHOW VARIABLES */ - { 242, -3 }, /* (208) cmd ::= SHOW LOCAL VARIABLES */ - { 242, -4 }, /* (209) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ - { 242, -2 }, /* (210) cmd ::= SHOW BNODES */ - { 242, -2 }, /* (211) cmd ::= SHOW SNODES */ - { 242, -2 }, /* (212) cmd ::= SHOW CLUSTER */ - { 242, -2 }, /* (213) cmd ::= SHOW TRANSACTIONS */ - { 242, -4 }, /* (214) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - { 289, 0 }, /* (215) db_name_cond_opt ::= */ - { 289, -2 }, /* (216) db_name_cond_opt ::= db_name NK_DOT */ - { 290, 0 }, /* (217) like_pattern_opt ::= */ - { 290, -2 }, /* (218) like_pattern_opt ::= LIKE NK_STRING */ - { 291, -1 }, /* (219) table_name_cond ::= table_name */ - { 292, 0 }, /* (220) from_db_opt ::= */ - { 292, -2 }, /* (221) from_db_opt ::= FROM db_name */ - { 242, -8 }, /* (222) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - { 242, -10 }, /* (223) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ - { 242, -6 }, /* (224) cmd ::= DROP INDEX exists_opt index_name ON table_name */ - { 294, 0 }, /* (225) index_options ::= */ - { 294, -9 }, /* (226) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 294, -11 }, /* (227) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 295, -1 }, /* (228) func_list ::= func */ - { 295, -3 }, /* (229) func_list ::= func_list NK_COMMA func */ - { 297, -4 }, /* (230) func ::= function_name NK_LP expression_list NK_RP */ - { 242, -6 }, /* (231) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 242, -7 }, /* (232) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 242, -7 }, /* (233) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 242, -4 }, /* (234) cmd ::= DROP TOPIC exists_opt topic_name */ - { 242, -7 }, /* (235) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 242, -2 }, /* (236) cmd ::= DESC full_table_name */ - { 242, -2 }, /* (237) cmd ::= DESCRIBE full_table_name */ - { 242, -3 }, /* (238) cmd ::= RESET QUERY CACHE */ - { 242, -4 }, /* (239) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - { 302, 0 }, /* (240) analyze_opt ::= */ - { 302, -1 }, /* (241) analyze_opt ::= ANALYZE */ - { 303, 0 }, /* (242) explain_options ::= */ - { 303, -3 }, /* (243) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 303, -3 }, /* (244) explain_options ::= explain_options RATIO NK_FLOAT */ - { 242, -6 }, /* (245) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ - { 242, -10 }, /* (246) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 242, -4 }, /* (247) cmd ::= DROP FUNCTION exists_opt function_name */ - { 304, 0 }, /* (248) agg_func_opt ::= */ - { 304, -1 }, /* (249) agg_func_opt ::= AGGREGATE */ - { 305, 0 }, /* (250) bufsize_opt ::= */ - { 305, -2 }, /* (251) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 242, -8 }, /* (252) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ - { 242, -4 }, /* (253) cmd ::= DROP STREAM exists_opt stream_name */ - { 308, 0 }, /* (254) into_opt ::= */ - { 308, -2 }, /* (255) into_opt ::= INTO full_table_name */ - { 307, 0 }, /* (256) stream_options ::= */ - { 307, -3 }, /* (257) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 307, -3 }, /* (258) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 307, -4 }, /* (259) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 307, -3 }, /* (260) stream_options ::= stream_options WATERMARK duration_literal */ - { 242, -3 }, /* (261) cmd ::= KILL CONNECTION NK_INTEGER */ - { 242, -3 }, /* (262) cmd ::= KILL QUERY NK_STRING */ - { 242, -3 }, /* (263) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 242, -2 }, /* (264) cmd ::= BALANCE VGROUP */ - { 242, -4 }, /* (265) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 242, -4 }, /* (266) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 242, -3 }, /* (267) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 309, -2 }, /* (268) dnode_list ::= DNODE NK_INTEGER */ - { 309, -3 }, /* (269) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 242, -3 }, /* (270) cmd ::= SYNCDB db_name REPLICA */ - { 242, -4 }, /* (271) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 242, -1 }, /* (272) cmd ::= query_expression */ - { 245, -1 }, /* (273) literal ::= NK_INTEGER */ - { 245, -1 }, /* (274) literal ::= NK_FLOAT */ - { 245, -1 }, /* (275) literal ::= NK_STRING */ - { 245, -1 }, /* (276) literal ::= NK_BOOL */ - { 245, -2 }, /* (277) literal ::= TIMESTAMP NK_STRING */ - { 245, -1 }, /* (278) literal ::= duration_literal */ - { 245, -1 }, /* (279) literal ::= NULL */ - { 245, -1 }, /* (280) literal ::= NK_QUESTION */ - { 285, -1 }, /* (281) duration_literal ::= NK_VARIABLE */ - { 311, -1 }, /* (282) signed ::= NK_INTEGER */ - { 311, -2 }, /* (283) signed ::= NK_PLUS NK_INTEGER */ - { 311, -2 }, /* (284) signed ::= NK_MINUS NK_INTEGER */ - { 311, -1 }, /* (285) signed ::= NK_FLOAT */ - { 311, -2 }, /* (286) signed ::= NK_PLUS NK_FLOAT */ - { 311, -2 }, /* (287) signed ::= NK_MINUS NK_FLOAT */ - { 274, -1 }, /* (288) signed_literal ::= signed */ - { 274, -1 }, /* (289) signed_literal ::= NK_STRING */ - { 274, -1 }, /* (290) signed_literal ::= NK_BOOL */ - { 274, -2 }, /* (291) signed_literal ::= TIMESTAMP NK_STRING */ - { 274, -1 }, /* (292) signed_literal ::= duration_literal */ - { 274, -1 }, /* (293) signed_literal ::= NULL */ - { 274, -1 }, /* (294) signed_literal ::= literal_func */ - { 277, -1 }, /* (295) literal_list ::= signed_literal */ - { 277, -3 }, /* (296) literal_list ::= literal_list NK_COMMA signed_literal */ - { 252, -1 }, /* (297) db_name ::= NK_ID */ - { 280, -1 }, /* (298) table_name ::= NK_ID */ - { 272, -1 }, /* (299) column_name ::= NK_ID */ - { 287, -1 }, /* (300) function_name ::= NK_ID */ - { 313, -1 }, /* (301) table_alias ::= NK_ID */ - { 314, -1 }, /* (302) column_alias ::= NK_ID */ - { 247, -1 }, /* (303) user_name ::= NK_ID */ - { 293, -1 }, /* (304) index_name ::= NK_ID */ - { 299, -1 }, /* (305) topic_name ::= NK_ID */ - { 306, -1 }, /* (306) stream_name ::= NK_ID */ - { 301, -1 }, /* (307) cgroup_name ::= NK_ID */ - { 315, -1 }, /* (308) expression ::= literal */ - { 315, -1 }, /* (309) expression ::= pseudo_column */ - { 315, -1 }, /* (310) expression ::= column_reference */ - { 315, -1 }, /* (311) expression ::= function_expression */ - { 315, -1 }, /* (312) expression ::= subquery */ - { 315, -3 }, /* (313) expression ::= NK_LP expression NK_RP */ - { 315, -2 }, /* (314) expression ::= NK_PLUS expression */ - { 315, -2 }, /* (315) expression ::= NK_MINUS expression */ - { 315, -3 }, /* (316) expression ::= expression NK_PLUS expression */ - { 315, -3 }, /* (317) expression ::= expression NK_MINUS expression */ - { 315, -3 }, /* (318) expression ::= expression NK_STAR expression */ - { 315, -3 }, /* (319) expression ::= expression NK_SLASH expression */ - { 315, -3 }, /* (320) expression ::= expression NK_REM expression */ - { 315, -3 }, /* (321) expression ::= column_reference NK_ARROW NK_STRING */ - { 298, -1 }, /* (322) expression_list ::= expression */ - { 298, -3 }, /* (323) expression_list ::= expression_list NK_COMMA expression */ - { 317, -1 }, /* (324) column_reference ::= column_name */ - { 317, -3 }, /* (325) column_reference ::= table_name NK_DOT column_name */ - { 316, -1 }, /* (326) pseudo_column ::= ROWTS */ - { 316, -1 }, /* (327) pseudo_column ::= TBNAME */ - { 316, -3 }, /* (328) pseudo_column ::= table_name NK_DOT TBNAME */ - { 316, -1 }, /* (329) pseudo_column ::= QSTARTTS */ - { 316, -1 }, /* (330) pseudo_column ::= QENDTS */ - { 316, -1 }, /* (331) pseudo_column ::= WSTARTTS */ - { 316, -1 }, /* (332) pseudo_column ::= WENDTS */ - { 316, -1 }, /* (333) pseudo_column ::= WDURATION */ - { 318, -4 }, /* (334) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 318, -4 }, /* (335) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 318, -6 }, /* (336) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ - { 318, -1 }, /* (337) function_expression ::= literal_func */ - { 312, -3 }, /* (338) literal_func ::= noarg_func NK_LP NK_RP */ - { 312, -1 }, /* (339) literal_func ::= NOW */ - { 322, -1 }, /* (340) noarg_func ::= NOW */ - { 322, -1 }, /* (341) noarg_func ::= TODAY */ - { 322, -1 }, /* (342) noarg_func ::= TIMEZONE */ - { 320, -1 }, /* (343) star_func ::= COUNT */ - { 320, -1 }, /* (344) star_func ::= FIRST */ - { 320, -1 }, /* (345) star_func ::= LAST */ - { 320, -1 }, /* (346) star_func ::= LAST_ROW */ - { 321, -1 }, /* (347) star_func_para_list ::= NK_STAR */ - { 321, -1 }, /* (348) star_func_para_list ::= other_para_list */ - { 323, -1 }, /* (349) other_para_list ::= star_func_para */ - { 323, -3 }, /* (350) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 324, -1 }, /* (351) star_func_para ::= expression */ - { 324, -3 }, /* (352) star_func_para ::= table_name NK_DOT NK_STAR */ - { 325, -3 }, /* (353) predicate ::= expression compare_op expression */ - { 325, -5 }, /* (354) predicate ::= expression BETWEEN expression AND expression */ - { 325, -6 }, /* (355) predicate ::= expression NOT BETWEEN expression AND expression */ - { 325, -3 }, /* (356) predicate ::= expression IS NULL */ - { 325, -4 }, /* (357) predicate ::= expression IS NOT NULL */ - { 325, -3 }, /* (358) predicate ::= expression in_op in_predicate_value */ - { 326, -1 }, /* (359) compare_op ::= NK_LT */ - { 326, -1 }, /* (360) compare_op ::= NK_GT */ - { 326, -1 }, /* (361) compare_op ::= NK_LE */ - { 326, -1 }, /* (362) compare_op ::= NK_GE */ - { 326, -1 }, /* (363) compare_op ::= NK_NE */ - { 326, -1 }, /* (364) compare_op ::= NK_EQ */ - { 326, -1 }, /* (365) compare_op ::= LIKE */ - { 326, -2 }, /* (366) compare_op ::= NOT LIKE */ - { 326, -1 }, /* (367) compare_op ::= MATCH */ - { 326, -1 }, /* (368) compare_op ::= NMATCH */ - { 326, -1 }, /* (369) compare_op ::= CONTAINS */ - { 327, -1 }, /* (370) in_op ::= IN */ - { 327, -2 }, /* (371) in_op ::= NOT IN */ - { 328, -3 }, /* (372) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 329, -1 }, /* (373) boolean_value_expression ::= boolean_primary */ - { 329, -2 }, /* (374) boolean_value_expression ::= NOT boolean_primary */ - { 329, -3 }, /* (375) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 329, -3 }, /* (376) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 330, -1 }, /* (377) boolean_primary ::= predicate */ - { 330, -3 }, /* (378) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 331, -1 }, /* (379) common_expression ::= expression */ - { 331, -1 }, /* (380) common_expression ::= boolean_value_expression */ - { 332, -2 }, /* (381) from_clause ::= FROM table_reference_list */ - { 333, -1 }, /* (382) table_reference_list ::= table_reference */ - { 333, -3 }, /* (383) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 334, -1 }, /* (384) table_reference ::= table_primary */ - { 334, -1 }, /* (385) table_reference ::= joined_table */ - { 335, -2 }, /* (386) table_primary ::= table_name alias_opt */ - { 335, -4 }, /* (387) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 335, -2 }, /* (388) table_primary ::= subquery alias_opt */ - { 335, -1 }, /* (389) table_primary ::= parenthesized_joined_table */ - { 337, 0 }, /* (390) alias_opt ::= */ - { 337, -1 }, /* (391) alias_opt ::= table_alias */ - { 337, -2 }, /* (392) alias_opt ::= AS table_alias */ - { 338, -3 }, /* (393) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 338, -3 }, /* (394) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 336, -6 }, /* (395) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 339, 0 }, /* (396) join_type ::= */ - { 339, -1 }, /* (397) join_type ::= INNER */ - { 341, -12 }, /* (398) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 342, 0 }, /* (399) set_quantifier_opt ::= */ - { 342, -1 }, /* (400) set_quantifier_opt ::= DISTINCT */ - { 342, -1 }, /* (401) set_quantifier_opt ::= ALL */ - { 343, -1 }, /* (402) select_list ::= NK_STAR */ - { 343, -1 }, /* (403) select_list ::= select_sublist */ - { 351, -1 }, /* (404) select_sublist ::= select_item */ - { 351, -3 }, /* (405) select_sublist ::= select_sublist NK_COMMA select_item */ - { 352, -1 }, /* (406) select_item ::= common_expression */ - { 352, -2 }, /* (407) select_item ::= common_expression column_alias */ - { 352, -3 }, /* (408) select_item ::= common_expression AS column_alias */ - { 352, -3 }, /* (409) select_item ::= table_name NK_DOT NK_STAR */ - { 310, 0 }, /* (410) where_clause_opt ::= */ - { 310, -2 }, /* (411) where_clause_opt ::= WHERE search_condition */ - { 344, 0 }, /* (412) partition_by_clause_opt ::= */ - { 344, -3 }, /* (413) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 348, 0 }, /* (414) twindow_clause_opt ::= */ - { 348, -6 }, /* (415) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 348, -4 }, /* (416) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - { 348, -6 }, /* (417) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 348, -8 }, /* (418) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 296, 0 }, /* (419) sliding_opt ::= */ - { 296, -4 }, /* (420) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 347, 0 }, /* (421) fill_opt ::= */ - { 347, -4 }, /* (422) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 347, -6 }, /* (423) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 353, -1 }, /* (424) fill_mode ::= NONE */ - { 353, -1 }, /* (425) fill_mode ::= PREV */ - { 353, -1 }, /* (426) fill_mode ::= NULL */ - { 353, -1 }, /* (427) fill_mode ::= LINEAR */ - { 353, -1 }, /* (428) fill_mode ::= NEXT */ - { 349, 0 }, /* (429) group_by_clause_opt ::= */ - { 349, -3 }, /* (430) group_by_clause_opt ::= GROUP BY group_by_list */ - { 354, -1 }, /* (431) group_by_list ::= expression */ - { 354, -3 }, /* (432) group_by_list ::= group_by_list NK_COMMA expression */ - { 350, 0 }, /* (433) having_clause_opt ::= */ - { 350, -2 }, /* (434) having_clause_opt ::= HAVING search_condition */ - { 345, 0 }, /* (435) range_opt ::= */ - { 345, -6 }, /* (436) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ - { 346, 0 }, /* (437) every_opt ::= */ - { 346, -4 }, /* (438) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 300, -4 }, /* (439) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 355, -1 }, /* (440) query_expression_body ::= query_primary */ - { 355, -4 }, /* (441) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 355, -3 }, /* (442) query_expression_body ::= query_expression_body UNION query_expression_body */ - { 359, -1 }, /* (443) query_primary ::= query_specification */ - { 359, -6 }, /* (444) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ - { 356, 0 }, /* (445) order_by_clause_opt ::= */ - { 356, -3 }, /* (446) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 357, 0 }, /* (447) slimit_clause_opt ::= */ - { 357, -2 }, /* (448) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 357, -4 }, /* (449) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 357, -4 }, /* (450) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 358, 0 }, /* (451) limit_clause_opt ::= */ - { 358, -2 }, /* (452) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 358, -4 }, /* (453) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 358, -4 }, /* (454) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 319, -3 }, /* (455) subquery ::= NK_LP query_expression NK_RP */ - { 340, -1 }, /* (456) search_condition ::= common_expression */ - { 360, -1 }, /* (457) sort_specification_list ::= sort_specification */ - { 360, -3 }, /* (458) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 361, -3 }, /* (459) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 362, 0 }, /* (460) ordering_specification_opt ::= */ - { 362, -1 }, /* (461) ordering_specification_opt ::= ASC */ - { 362, -1 }, /* (462) ordering_specification_opt ::= DESC */ - { 363, 0 }, /* (463) null_ordering_opt ::= */ - { 363, -2 }, /* (464) null_ordering_opt ::= NULLS FIRST */ - { 363, -2 }, /* (465) null_ordering_opt ::= NULLS LAST */ + { 244, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 244, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 245, 0 }, /* (2) account_options ::= */ + { 245, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 245, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 245, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 245, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 245, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 245, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 245, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 245, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 245, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 246, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 246, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 248, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 248, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 248, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 248, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 248, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 248, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 248, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 248, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 248, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 248, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 244, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ + { 244, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 244, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + { 244, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + { 244, -3 }, /* (28) cmd ::= DROP USER user_name */ + { 250, 0 }, /* (29) sysinfo_opt ::= */ + { 250, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ + { 244, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 244, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 251, -1 }, /* (33) privileges ::= ALL */ + { 251, -1 }, /* (34) privileges ::= priv_type_list */ + { 253, -1 }, /* (35) priv_type_list ::= priv_type */ + { 253, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 254, -1 }, /* (37) priv_type ::= READ */ + { 254, -1 }, /* (38) priv_type ::= WRITE */ + { 252, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 252, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */ + { 244, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */ + { 244, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + { 244, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */ + { 244, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */ + { 244, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 244, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 244, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */ + { 244, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 256, -1 }, /* (49) dnode_endpoint ::= NK_STRING */ + { 256, -1 }, /* (50) dnode_endpoint ::= NK_ID */ + { 256, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */ + { 244, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */ + { 244, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 244, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 244, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 244, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 244, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 244, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 244, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 244, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 244, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 244, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 244, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */ + { 244, -2 }, /* (64) cmd ::= USE db_name */ + { 244, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 257, -3 }, /* (66) not_exists_opt ::= IF NOT EXISTS */ + { 257, 0 }, /* (67) not_exists_opt ::= */ + { 259, -2 }, /* (68) exists_opt ::= IF EXISTS */ + { 259, 0 }, /* (69) exists_opt ::= */ + { 258, 0 }, /* (70) db_options ::= */ + { 258, -3 }, /* (71) db_options ::= db_options BUFFER NK_INTEGER */ + { 258, -3 }, /* (72) db_options ::= db_options CACHELAST NK_INTEGER */ + { 258, -3 }, /* (73) db_options ::= db_options COMP NK_INTEGER */ + { 258, -3 }, /* (74) db_options ::= db_options DURATION NK_INTEGER */ + { 258, -3 }, /* (75) db_options ::= db_options DURATION NK_VARIABLE */ + { 258, -3 }, /* (76) db_options ::= db_options FSYNC NK_INTEGER */ + { 258, -3 }, /* (77) db_options ::= db_options MAXROWS NK_INTEGER */ + { 258, -3 }, /* (78) db_options ::= db_options MINROWS NK_INTEGER */ + { 258, -3 }, /* (79) db_options ::= db_options KEEP integer_list */ + { 258, -3 }, /* (80) db_options ::= db_options KEEP variable_list */ + { 258, -3 }, /* (81) db_options ::= db_options PAGES NK_INTEGER */ + { 258, -3 }, /* (82) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 258, -3 }, /* (83) db_options ::= db_options PRECISION NK_STRING */ + { 258, -3 }, /* (84) db_options ::= db_options REPLICA NK_INTEGER */ + { 258, -3 }, /* (85) db_options ::= db_options STRICT NK_INTEGER */ + { 258, -3 }, /* (86) db_options ::= db_options WAL NK_INTEGER */ + { 258, -3 }, /* (87) db_options ::= db_options VGROUPS NK_INTEGER */ + { 258, -3 }, /* (88) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 258, -3 }, /* (89) db_options ::= db_options RETENTIONS retention_list */ + { 258, -3 }, /* (90) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 260, -1 }, /* (91) alter_db_options ::= alter_db_option */ + { 260, -2 }, /* (92) alter_db_options ::= alter_db_options alter_db_option */ + { 264, -2 }, /* (93) alter_db_option ::= BUFFER NK_INTEGER */ + { 264, -2 }, /* (94) alter_db_option ::= CACHELAST NK_INTEGER */ + { 264, -2 }, /* (95) alter_db_option ::= FSYNC NK_INTEGER */ + { 264, -2 }, /* (96) alter_db_option ::= KEEP integer_list */ + { 264, -2 }, /* (97) alter_db_option ::= KEEP variable_list */ + { 264, -2 }, /* (98) alter_db_option ::= PAGES NK_INTEGER */ + { 264, -2 }, /* (99) alter_db_option ::= REPLICA NK_INTEGER */ + { 264, -2 }, /* (100) alter_db_option ::= STRICT NK_INTEGER */ + { 264, -2 }, /* (101) alter_db_option ::= WAL NK_INTEGER */ + { 261, -1 }, /* (102) integer_list ::= NK_INTEGER */ + { 261, -3 }, /* (103) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 262, -1 }, /* (104) variable_list ::= NK_VARIABLE */ + { 262, -3 }, /* (105) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 263, -1 }, /* (106) retention_list ::= retention */ + { 263, -3 }, /* (107) retention_list ::= retention_list NK_COMMA retention */ + { 265, -3 }, /* (108) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 244, -9 }, /* (109) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 244, -3 }, /* (110) cmd ::= CREATE TABLE multi_create_clause */ + { 244, -9 }, /* (111) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 244, -3 }, /* (112) cmd ::= DROP TABLE multi_drop_clause */ + { 244, -4 }, /* (113) cmd ::= DROP STABLE exists_opt full_table_name */ + { 244, -3 }, /* (114) cmd ::= ALTER TABLE alter_table_clause */ + { 244, -3 }, /* (115) cmd ::= ALTER STABLE alter_table_clause */ + { 273, -2 }, /* (116) alter_table_clause ::= full_table_name alter_table_options */ + { 273, -5 }, /* (117) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 273, -4 }, /* (118) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 273, -5 }, /* (119) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 273, -5 }, /* (120) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 273, -5 }, /* (121) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 273, -4 }, /* (122) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 273, -5 }, /* (123) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 273, -5 }, /* (124) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 273, -6 }, /* (125) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 270, -1 }, /* (126) multi_create_clause ::= create_subtable_clause */ + { 270, -2 }, /* (127) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 278, -10 }, /* (128) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ + { 272, -1 }, /* (129) multi_drop_clause ::= drop_table_clause */ + { 272, -2 }, /* (130) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 281, -2 }, /* (131) drop_table_clause ::= exists_opt full_table_name */ + { 279, 0 }, /* (132) specific_tags_opt ::= */ + { 279, -3 }, /* (133) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 266, -1 }, /* (134) full_table_name ::= table_name */ + { 266, -3 }, /* (135) full_table_name ::= db_name NK_DOT table_name */ + { 267, -1 }, /* (136) column_def_list ::= column_def */ + { 267, -3 }, /* (137) column_def_list ::= column_def_list NK_COMMA column_def */ + { 284, -2 }, /* (138) column_def ::= column_name type_name */ + { 284, -4 }, /* (139) column_def ::= column_name type_name COMMENT NK_STRING */ + { 276, -1 }, /* (140) type_name ::= BOOL */ + { 276, -1 }, /* (141) type_name ::= TINYINT */ + { 276, -1 }, /* (142) type_name ::= SMALLINT */ + { 276, -1 }, /* (143) type_name ::= INT */ + { 276, -1 }, /* (144) type_name ::= INTEGER */ + { 276, -1 }, /* (145) type_name ::= BIGINT */ + { 276, -1 }, /* (146) type_name ::= FLOAT */ + { 276, -1 }, /* (147) type_name ::= DOUBLE */ + { 276, -4 }, /* (148) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 276, -1 }, /* (149) type_name ::= TIMESTAMP */ + { 276, -4 }, /* (150) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 276, -2 }, /* (151) type_name ::= TINYINT UNSIGNED */ + { 276, -2 }, /* (152) type_name ::= SMALLINT UNSIGNED */ + { 276, -2 }, /* (153) type_name ::= INT UNSIGNED */ + { 276, -2 }, /* (154) type_name ::= BIGINT UNSIGNED */ + { 276, -1 }, /* (155) type_name ::= JSON */ + { 276, -4 }, /* (156) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 276, -1 }, /* (157) type_name ::= MEDIUMBLOB */ + { 276, -1 }, /* (158) type_name ::= BLOB */ + { 276, -4 }, /* (159) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 276, -1 }, /* (160) type_name ::= DECIMAL */ + { 276, -4 }, /* (161) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 276, -6 }, /* (162) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 268, 0 }, /* (163) tags_def_opt ::= */ + { 268, -1 }, /* (164) tags_def_opt ::= tags_def */ + { 271, -4 }, /* (165) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 269, 0 }, /* (166) table_options ::= */ + { 269, -3 }, /* (167) table_options ::= table_options COMMENT NK_STRING */ + { 269, -3 }, /* (168) table_options ::= table_options MAX_DELAY duration_list */ + { 269, -3 }, /* (169) table_options ::= table_options WATERMARK duration_list */ + { 269, -5 }, /* (170) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + { 269, -3 }, /* (171) table_options ::= table_options TTL NK_INTEGER */ + { 269, -5 }, /* (172) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 274, -1 }, /* (173) alter_table_options ::= alter_table_option */ + { 274, -2 }, /* (174) alter_table_options ::= alter_table_options alter_table_option */ + { 287, -2 }, /* (175) alter_table_option ::= COMMENT NK_STRING */ + { 287, -2 }, /* (176) alter_table_option ::= TTL NK_INTEGER */ + { 285, -1 }, /* (177) duration_list ::= duration_literal */ + { 285, -3 }, /* (178) duration_list ::= duration_list NK_COMMA duration_literal */ + { 286, -1 }, /* (179) rollup_func_list ::= rollup_func_name */ + { 286, -3 }, /* (180) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + { 289, -1 }, /* (181) rollup_func_name ::= function_name */ + { 289, -1 }, /* (182) rollup_func_name ::= FIRST */ + { 289, -1 }, /* (183) rollup_func_name ::= LAST */ + { 282, -1 }, /* (184) col_name_list ::= col_name */ + { 282, -3 }, /* (185) col_name_list ::= col_name_list NK_COMMA col_name */ + { 291, -1 }, /* (186) col_name ::= column_name */ + { 244, -2 }, /* (187) cmd ::= SHOW DNODES */ + { 244, -2 }, /* (188) cmd ::= SHOW USERS */ + { 244, -2 }, /* (189) cmd ::= SHOW DATABASES */ + { 244, -4 }, /* (190) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 244, -4 }, /* (191) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 244, -3 }, /* (192) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 244, -2 }, /* (193) cmd ::= SHOW MNODES */ + { 244, -2 }, /* (194) cmd ::= SHOW MODULES */ + { 244, -2 }, /* (195) cmd ::= SHOW QNODES */ + { 244, -2 }, /* (196) cmd ::= SHOW FUNCTIONS */ + { 244, -5 }, /* (197) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 244, -2 }, /* (198) cmd ::= SHOW STREAMS */ + { 244, -2 }, /* (199) cmd ::= SHOW ACCOUNTS */ + { 244, -2 }, /* (200) cmd ::= SHOW APPS */ + { 244, -2 }, /* (201) cmd ::= SHOW CONNECTIONS */ + { 244, -2 }, /* (202) cmd ::= SHOW LICENCE */ + { 244, -2 }, /* (203) cmd ::= SHOW GRANTS */ + { 244, -4 }, /* (204) cmd ::= SHOW CREATE DATABASE db_name */ + { 244, -4 }, /* (205) cmd ::= SHOW CREATE TABLE full_table_name */ + { 244, -4 }, /* (206) cmd ::= SHOW CREATE STABLE full_table_name */ + { 244, -2 }, /* (207) cmd ::= SHOW QUERIES */ + { 244, -2 }, /* (208) cmd ::= SHOW SCORES */ + { 244, -2 }, /* (209) cmd ::= SHOW TOPICS */ + { 244, -2 }, /* (210) cmd ::= SHOW VARIABLES */ + { 244, -3 }, /* (211) cmd ::= SHOW LOCAL VARIABLES */ + { 244, -4 }, /* (212) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + { 244, -2 }, /* (213) cmd ::= SHOW BNODES */ + { 244, -2 }, /* (214) cmd ::= SHOW SNODES */ + { 244, -2 }, /* (215) cmd ::= SHOW CLUSTER */ + { 244, -2 }, /* (216) cmd ::= SHOW TRANSACTIONS */ + { 244, -4 }, /* (217) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 292, 0 }, /* (218) db_name_cond_opt ::= */ + { 292, -2 }, /* (219) db_name_cond_opt ::= db_name NK_DOT */ + { 293, 0 }, /* (220) like_pattern_opt ::= */ + { 293, -2 }, /* (221) like_pattern_opt ::= LIKE NK_STRING */ + { 294, -1 }, /* (222) table_name_cond ::= table_name */ + { 295, 0 }, /* (223) from_db_opt ::= */ + { 295, -2 }, /* (224) from_db_opt ::= FROM db_name */ + { 244, -8 }, /* (225) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + { 244, -4 }, /* (226) cmd ::= DROP INDEX exists_opt index_name */ + { 297, 0 }, /* (227) index_options ::= */ + { 297, -9 }, /* (228) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 297, -11 }, /* (229) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 298, -1 }, /* (230) func_list ::= func */ + { 298, -3 }, /* (231) func_list ::= func_list NK_COMMA func */ + { 300, -4 }, /* (232) func ::= function_name NK_LP expression_list NK_RP */ + { 244, -6 }, /* (233) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 244, -7 }, /* (234) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 244, -9 }, /* (235) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 244, -7 }, /* (236) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 244, -9 }, /* (237) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 244, -4 }, /* (238) cmd ::= DROP TOPIC exists_opt topic_name */ + { 244, -7 }, /* (239) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 244, -2 }, /* (240) cmd ::= DESC full_table_name */ + { 244, -2 }, /* (241) cmd ::= DESCRIBE full_table_name */ + { 244, -3 }, /* (242) cmd ::= RESET QUERY CACHE */ + { 244, -4 }, /* (243) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + { 305, 0 }, /* (244) analyze_opt ::= */ + { 305, -1 }, /* (245) analyze_opt ::= ANALYZE */ + { 306, 0 }, /* (246) explain_options ::= */ + { 306, -3 }, /* (247) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 306, -3 }, /* (248) explain_options ::= explain_options RATIO NK_FLOAT */ + { 244, -6 }, /* (249) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ + { 244, -10 }, /* (250) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 244, -4 }, /* (251) cmd ::= DROP FUNCTION exists_opt function_name */ + { 307, 0 }, /* (252) agg_func_opt ::= */ + { 307, -1 }, /* (253) agg_func_opt ::= AGGREGATE */ + { 308, 0 }, /* (254) bufsize_opt ::= */ + { 308, -2 }, /* (255) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 244, -8 }, /* (256) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ + { 244, -4 }, /* (257) cmd ::= DROP STREAM exists_opt stream_name */ + { 311, 0 }, /* (258) into_opt ::= */ + { 311, -2 }, /* (259) into_opt ::= INTO full_table_name */ + { 310, 0 }, /* (260) stream_options ::= */ + { 310, -3 }, /* (261) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 310, -3 }, /* (262) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 310, -4 }, /* (263) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 310, -3 }, /* (264) stream_options ::= stream_options WATERMARK duration_literal */ + { 244, -3 }, /* (265) cmd ::= KILL CONNECTION NK_INTEGER */ + { 244, -3 }, /* (266) cmd ::= KILL QUERY NK_STRING */ + { 244, -3 }, /* (267) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 244, -2 }, /* (268) cmd ::= BALANCE VGROUP */ + { 244, -4 }, /* (269) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 244, -4 }, /* (270) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 244, -3 }, /* (271) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 312, -2 }, /* (272) dnode_list ::= DNODE NK_INTEGER */ + { 312, -3 }, /* (273) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 244, -3 }, /* (274) cmd ::= SYNCDB db_name REPLICA */ + { 244, -4 }, /* (275) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 244, -1 }, /* (276) cmd ::= query_expression */ + { 247, -1 }, /* (277) literal ::= NK_INTEGER */ + { 247, -1 }, /* (278) literal ::= NK_FLOAT */ + { 247, -1 }, /* (279) literal ::= NK_STRING */ + { 247, -1 }, /* (280) literal ::= NK_BOOL */ + { 247, -2 }, /* (281) literal ::= TIMESTAMP NK_STRING */ + { 247, -1 }, /* (282) literal ::= duration_literal */ + { 247, -1 }, /* (283) literal ::= NULL */ + { 247, -1 }, /* (284) literal ::= NK_QUESTION */ + { 288, -1 }, /* (285) duration_literal ::= NK_VARIABLE */ + { 314, -1 }, /* (286) signed ::= NK_INTEGER */ + { 314, -2 }, /* (287) signed ::= NK_PLUS NK_INTEGER */ + { 314, -2 }, /* (288) signed ::= NK_MINUS NK_INTEGER */ + { 314, -1 }, /* (289) signed ::= NK_FLOAT */ + { 314, -2 }, /* (290) signed ::= NK_PLUS NK_FLOAT */ + { 314, -2 }, /* (291) signed ::= NK_MINUS NK_FLOAT */ + { 277, -1 }, /* (292) signed_literal ::= signed */ + { 277, -1 }, /* (293) signed_literal ::= NK_STRING */ + { 277, -1 }, /* (294) signed_literal ::= NK_BOOL */ + { 277, -2 }, /* (295) signed_literal ::= TIMESTAMP NK_STRING */ + { 277, -1 }, /* (296) signed_literal ::= duration_literal */ + { 277, -1 }, /* (297) signed_literal ::= NULL */ + { 277, -1 }, /* (298) signed_literal ::= literal_func */ + { 280, -1 }, /* (299) literal_list ::= signed_literal */ + { 280, -3 }, /* (300) literal_list ::= literal_list NK_COMMA signed_literal */ + { 255, -1 }, /* (301) db_name ::= NK_ID */ + { 283, -1 }, /* (302) table_name ::= NK_ID */ + { 275, -1 }, /* (303) column_name ::= NK_ID */ + { 290, -1 }, /* (304) function_name ::= NK_ID */ + { 316, -1 }, /* (305) table_alias ::= NK_ID */ + { 317, -1 }, /* (306) column_alias ::= NK_ID */ + { 249, -1 }, /* (307) user_name ::= NK_ID */ + { 296, -1 }, /* (308) index_name ::= NK_ID */ + { 302, -1 }, /* (309) topic_name ::= NK_ID */ + { 309, -1 }, /* (310) stream_name ::= NK_ID */ + { 304, -1 }, /* (311) cgroup_name ::= NK_ID */ + { 318, -1 }, /* (312) expression ::= literal */ + { 318, -1 }, /* (313) expression ::= pseudo_column */ + { 318, -1 }, /* (314) expression ::= column_reference */ + { 318, -1 }, /* (315) expression ::= function_expression */ + { 318, -1 }, /* (316) expression ::= subquery */ + { 318, -3 }, /* (317) expression ::= NK_LP expression NK_RP */ + { 318, -2 }, /* (318) expression ::= NK_PLUS expression */ + { 318, -2 }, /* (319) expression ::= NK_MINUS expression */ + { 318, -3 }, /* (320) expression ::= expression NK_PLUS expression */ + { 318, -3 }, /* (321) expression ::= expression NK_MINUS expression */ + { 318, -3 }, /* (322) expression ::= expression NK_STAR expression */ + { 318, -3 }, /* (323) expression ::= expression NK_SLASH expression */ + { 318, -3 }, /* (324) expression ::= expression NK_REM expression */ + { 318, -3 }, /* (325) expression ::= column_reference NK_ARROW NK_STRING */ + { 318, -3 }, /* (326) expression ::= expression NK_BITAND expression */ + { 318, -3 }, /* (327) expression ::= expression NK_BITOR expression */ + { 301, -1 }, /* (328) expression_list ::= expression */ + { 301, -3 }, /* (329) expression_list ::= expression_list NK_COMMA expression */ + { 320, -1 }, /* (330) column_reference ::= column_name */ + { 320, -3 }, /* (331) column_reference ::= table_name NK_DOT column_name */ + { 319, -1 }, /* (332) pseudo_column ::= ROWTS */ + { 319, -1 }, /* (333) pseudo_column ::= TBNAME */ + { 319, -3 }, /* (334) pseudo_column ::= table_name NK_DOT TBNAME */ + { 319, -1 }, /* (335) pseudo_column ::= QSTARTTS */ + { 319, -1 }, /* (336) pseudo_column ::= QENDTS */ + { 319, -1 }, /* (337) pseudo_column ::= WSTARTTS */ + { 319, -1 }, /* (338) pseudo_column ::= WENDTS */ + { 319, -1 }, /* (339) pseudo_column ::= WDURATION */ + { 321, -4 }, /* (340) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 321, -4 }, /* (341) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 321, -6 }, /* (342) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ + { 321, -1 }, /* (343) function_expression ::= literal_func */ + { 315, -3 }, /* (344) literal_func ::= noarg_func NK_LP NK_RP */ + { 315, -1 }, /* (345) literal_func ::= NOW */ + { 325, -1 }, /* (346) noarg_func ::= NOW */ + { 325, -1 }, /* (347) noarg_func ::= TODAY */ + { 325, -1 }, /* (348) noarg_func ::= TIMEZONE */ + { 323, -1 }, /* (349) star_func ::= COUNT */ + { 323, -1 }, /* (350) star_func ::= FIRST */ + { 323, -1 }, /* (351) star_func ::= LAST */ + { 323, -1 }, /* (352) star_func ::= LAST_ROW */ + { 324, -1 }, /* (353) star_func_para_list ::= NK_STAR */ + { 324, -1 }, /* (354) star_func_para_list ::= other_para_list */ + { 326, -1 }, /* (355) other_para_list ::= star_func_para */ + { 326, -3 }, /* (356) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 327, -1 }, /* (357) star_func_para ::= expression */ + { 327, -3 }, /* (358) star_func_para ::= table_name NK_DOT NK_STAR */ + { 328, -3 }, /* (359) predicate ::= expression compare_op expression */ + { 328, -5 }, /* (360) predicate ::= expression BETWEEN expression AND expression */ + { 328, -6 }, /* (361) predicate ::= expression NOT BETWEEN expression AND expression */ + { 328, -3 }, /* (362) predicate ::= expression IS NULL */ + { 328, -4 }, /* (363) predicate ::= expression IS NOT NULL */ + { 328, -3 }, /* (364) predicate ::= expression in_op in_predicate_value */ + { 329, -1 }, /* (365) compare_op ::= NK_LT */ + { 329, -1 }, /* (366) compare_op ::= NK_GT */ + { 329, -1 }, /* (367) compare_op ::= NK_LE */ + { 329, -1 }, /* (368) compare_op ::= NK_GE */ + { 329, -1 }, /* (369) compare_op ::= NK_NE */ + { 329, -1 }, /* (370) compare_op ::= NK_EQ */ + { 329, -1 }, /* (371) compare_op ::= LIKE */ + { 329, -2 }, /* (372) compare_op ::= NOT LIKE */ + { 329, -1 }, /* (373) compare_op ::= MATCH */ + { 329, -1 }, /* (374) compare_op ::= NMATCH */ + { 329, -1 }, /* (375) compare_op ::= CONTAINS */ + { 330, -1 }, /* (376) in_op ::= IN */ + { 330, -2 }, /* (377) in_op ::= NOT IN */ + { 331, -3 }, /* (378) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 332, -1 }, /* (379) boolean_value_expression ::= boolean_primary */ + { 332, -2 }, /* (380) boolean_value_expression ::= NOT boolean_primary */ + { 332, -3 }, /* (381) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 332, -3 }, /* (382) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 333, -1 }, /* (383) boolean_primary ::= predicate */ + { 333, -3 }, /* (384) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 334, -1 }, /* (385) common_expression ::= expression */ + { 334, -1 }, /* (386) common_expression ::= boolean_value_expression */ + { 335, 0 }, /* (387) from_clause_opt ::= */ + { 335, -2 }, /* (388) from_clause_opt ::= FROM table_reference_list */ + { 336, -1 }, /* (389) table_reference_list ::= table_reference */ + { 336, -3 }, /* (390) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 337, -1 }, /* (391) table_reference ::= table_primary */ + { 337, -1 }, /* (392) table_reference ::= joined_table */ + { 338, -2 }, /* (393) table_primary ::= table_name alias_opt */ + { 338, -4 }, /* (394) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 338, -2 }, /* (395) table_primary ::= subquery alias_opt */ + { 338, -1 }, /* (396) table_primary ::= parenthesized_joined_table */ + { 340, 0 }, /* (397) alias_opt ::= */ + { 340, -1 }, /* (398) alias_opt ::= table_alias */ + { 340, -2 }, /* (399) alias_opt ::= AS table_alias */ + { 341, -3 }, /* (400) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 341, -3 }, /* (401) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 339, -6 }, /* (402) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 342, 0 }, /* (403) join_type ::= */ + { 342, -1 }, /* (404) join_type ::= INNER */ + { 344, -12 }, /* (405) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 345, 0 }, /* (406) set_quantifier_opt ::= */ + { 345, -1 }, /* (407) set_quantifier_opt ::= DISTINCT */ + { 345, -1 }, /* (408) set_quantifier_opt ::= ALL */ + { 346, -1 }, /* (409) select_list ::= NK_STAR */ + { 346, -1 }, /* (410) select_list ::= select_sublist */ + { 354, -1 }, /* (411) select_sublist ::= select_item */ + { 354, -3 }, /* (412) select_sublist ::= select_sublist NK_COMMA select_item */ + { 355, -1 }, /* (413) select_item ::= common_expression */ + { 355, -2 }, /* (414) select_item ::= common_expression column_alias */ + { 355, -3 }, /* (415) select_item ::= common_expression AS column_alias */ + { 355, -3 }, /* (416) select_item ::= table_name NK_DOT NK_STAR */ + { 313, 0 }, /* (417) where_clause_opt ::= */ + { 313, -2 }, /* (418) where_clause_opt ::= WHERE search_condition */ + { 347, 0 }, /* (419) partition_by_clause_opt ::= */ + { 347, -3 }, /* (420) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 351, 0 }, /* (421) twindow_clause_opt ::= */ + { 351, -6 }, /* (422) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 351, -4 }, /* (423) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + { 351, -6 }, /* (424) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 351, -8 }, /* (425) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 299, 0 }, /* (426) sliding_opt ::= */ + { 299, -4 }, /* (427) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 350, 0 }, /* (428) fill_opt ::= */ + { 350, -4 }, /* (429) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 350, -6 }, /* (430) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 356, -1 }, /* (431) fill_mode ::= NONE */ + { 356, -1 }, /* (432) fill_mode ::= PREV */ + { 356, -1 }, /* (433) fill_mode ::= NULL */ + { 356, -1 }, /* (434) fill_mode ::= LINEAR */ + { 356, -1 }, /* (435) fill_mode ::= NEXT */ + { 352, 0 }, /* (436) group_by_clause_opt ::= */ + { 352, -3 }, /* (437) group_by_clause_opt ::= GROUP BY group_by_list */ + { 357, -1 }, /* (438) group_by_list ::= expression */ + { 357, -3 }, /* (439) group_by_list ::= group_by_list NK_COMMA expression */ + { 353, 0 }, /* (440) having_clause_opt ::= */ + { 353, -2 }, /* (441) having_clause_opt ::= HAVING search_condition */ + { 348, 0 }, /* (442) range_opt ::= */ + { 348, -6 }, /* (443) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ + { 349, 0 }, /* (444) every_opt ::= */ + { 349, -4 }, /* (445) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 303, -4 }, /* (446) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 358, -1 }, /* (447) query_expression_body ::= query_primary */ + { 358, -4 }, /* (448) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 358, -3 }, /* (449) query_expression_body ::= query_expression_body UNION query_expression_body */ + { 362, -1 }, /* (450) query_primary ::= query_specification */ + { 362, -6 }, /* (451) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ + { 359, 0 }, /* (452) order_by_clause_opt ::= */ + { 359, -3 }, /* (453) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 360, 0 }, /* (454) slimit_clause_opt ::= */ + { 360, -2 }, /* (455) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 360, -4 }, /* (456) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 360, -4 }, /* (457) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 361, 0 }, /* (458) limit_clause_opt ::= */ + { 361, -2 }, /* (459) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 361, -4 }, /* (460) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 361, -4 }, /* (461) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 322, -3 }, /* (462) subquery ::= NK_LP query_expression NK_RP */ + { 343, -1 }, /* (463) search_condition ::= common_expression */ + { 363, -1 }, /* (464) sort_specification_list ::= sort_specification */ + { 363, -3 }, /* (465) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 364, -3 }, /* (466) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 365, 0 }, /* (467) ordering_specification_opt ::= */ + { 365, -1 }, /* (468) ordering_specification_opt ::= ASC */ + { 365, -1 }, /* (469) ordering_specification_opt ::= DESC */ + { 366, 0 }, /* (470) null_ordering_opt ::= */ + { 366, -2 }, /* (471) null_ordering_opt ::= NULLS FIRST */ + { 366, -2 }, /* (472) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3161,11 +3198,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,243,&yymsp[0].minor); + yy_destructor(yypParser,245,&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,244,&yymsp[0].minor); + yy_destructor(yypParser,246,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3179,20 +3216,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,243,&yymsp[-2].minor); +{ yy_destructor(yypParser,245,&yymsp[-2].minor); { } - yy_destructor(yypParser,245,&yymsp[0].minor); + yy_destructor(yypParser,247,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,246,&yymsp[0].minor); +{ yy_destructor(yypParser,248,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,244,&yymsp[-1].minor); +{ yy_destructor(yypParser,246,&yymsp[-1].minor); { } - yy_destructor(yypParser,246,&yymsp[0].minor); + yy_destructor(yypParser,248,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3206,1309 +3243,1338 @@ 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,245,&yymsp[0].minor); + yy_destructor(yypParser,247,&yymsp[0].minor); break; - case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy57, &yymsp[0].minor.yy0); } + case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy241, &yymsp[-1].minor.yy0, yymsp[0].minor.yy629); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy57, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy241, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; - case 26: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy57, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } + case 26: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy241, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } break; - case 27: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy57); } + case 27: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy241, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; - case 28: /* cmd ::= GRANT privileges ON priv_level TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy389, &yymsp[-2].minor.yy57, &yymsp[0].minor.yy57); } + case 28: /* cmd ::= DROP USER user_name */ +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy241); } break; - case 29: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy389, &yymsp[-2].minor.yy57, &yymsp[0].minor.yy57); } + case 29: /* sysinfo_opt ::= */ +{ yymsp[1].minor.yy629 = 1; } break; - case 30: /* privileges ::= ALL */ -{ yymsp[0].minor.yy389 = PRIVILEGE_TYPE_ALL; } + case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ +{ yymsp[-1].minor.yy629 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 31: /* privileges ::= priv_type_list */ - case 32: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==32); -{ yylhsminor.yy389 = yymsp[0].minor.yy389; } - yymsp[0].minor.yy389 = yylhsminor.yy389; + case 31: /* cmd ::= GRANT privileges ON priv_level TO user_name */ +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy683, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241); } break; - case 33: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy389 = yymsp[-2].minor.yy389 | yymsp[0].minor.yy389; } - yymsp[-2].minor.yy389 = yylhsminor.yy389; + case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy683, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241); } break; - case 34: /* priv_type ::= READ */ -{ yymsp[0].minor.yy389 = PRIVILEGE_TYPE_READ; } + case 33: /* privileges ::= ALL */ +{ yymsp[0].minor.yy683 = PRIVILEGE_TYPE_ALL; } break; - case 35: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy389 = PRIVILEGE_TYPE_WRITE; } + case 34: /* privileges ::= priv_type_list */ + case 35: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==35); +{ yylhsminor.yy683 = yymsp[0].minor.yy683; } + yymsp[0].minor.yy683 = yylhsminor.yy683; break; - case 36: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy57 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy57 = yylhsminor.yy57; + case 36: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ +{ yylhsminor.yy683 = yymsp[-2].minor.yy683 | yymsp[0].minor.yy683; } + yymsp[-2].minor.yy683 = yylhsminor.yy683; break; - case 37: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy57 = yymsp[-2].minor.yy57; } - yymsp[-2].minor.yy57 = yylhsminor.yy57; + case 37: /* priv_type ::= READ */ +{ yymsp[0].minor.yy683 = PRIVILEGE_TYPE_READ; } break; - case 38: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy57, NULL); } + case 38: /* priv_type ::= WRITE */ +{ yymsp[0].minor.yy683 = PRIVILEGE_TYPE_WRITE; } break; - case 39: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy57, &yymsp[0].minor.yy0); } + case 39: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ +{ yylhsminor.yy241 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy241 = yylhsminor.yy241; break; - case 40: /* cmd ::= DROP DNODE NK_INTEGER */ + case 40: /* priv_level ::= db_name NK_DOT NK_STAR */ +{ yylhsminor.yy241 = yymsp[-2].minor.yy241; } + yymsp[-2].minor.yy241 = yylhsminor.yy241; + break; + case 41: /* cmd ::= CREATE DNODE dnode_endpoint */ +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy241, NULL); } + break; + case 42: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0); } + break; + case 43: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 41: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy57); } + case 44: /* cmd ::= DROP DNODE dnode_endpoint */ +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy241); } break; - case 42: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + case 45: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } break; - case 43: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + case 46: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 44: /* cmd ::= ALTER ALL DNODES NK_STRING */ + case 47: /* cmd ::= ALTER ALL DNODES NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[0].minor.yy0, NULL); } break; - case 45: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + case 48: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 46: /* dnode_endpoint ::= NK_STRING */ - case 47: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==47); - case 48: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==48); - case 297: /* db_name ::= NK_ID */ yytestcase(yyruleno==297); - case 298: /* table_name ::= NK_ID */ yytestcase(yyruleno==298); - case 299: /* column_name ::= NK_ID */ yytestcase(yyruleno==299); - case 300: /* function_name ::= NK_ID */ yytestcase(yyruleno==300); - case 301: /* table_alias ::= NK_ID */ yytestcase(yyruleno==301); - case 302: /* column_alias ::= NK_ID */ yytestcase(yyruleno==302); - case 303: /* user_name ::= NK_ID */ yytestcase(yyruleno==303); - case 304: /* index_name ::= NK_ID */ yytestcase(yyruleno==304); - case 305: /* topic_name ::= NK_ID */ yytestcase(yyruleno==305); - case 306: /* stream_name ::= NK_ID */ yytestcase(yyruleno==306); - case 307: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==307); - case 340: /* noarg_func ::= NOW */ yytestcase(yyruleno==340); - case 341: /* noarg_func ::= TODAY */ yytestcase(yyruleno==341); - case 342: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==342); - case 343: /* star_func ::= COUNT */ yytestcase(yyruleno==343); - case 344: /* star_func ::= FIRST */ yytestcase(yyruleno==344); - case 345: /* star_func ::= LAST */ yytestcase(yyruleno==345); - case 346: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==346); -{ yylhsminor.yy57 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy57 = yylhsminor.yy57; + case 49: /* dnode_endpoint ::= NK_STRING */ + case 50: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==50); + case 51: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==51); + case 301: /* db_name ::= NK_ID */ yytestcase(yyruleno==301); + case 302: /* table_name ::= NK_ID */ yytestcase(yyruleno==302); + case 303: /* column_name ::= NK_ID */ yytestcase(yyruleno==303); + case 304: /* function_name ::= NK_ID */ yytestcase(yyruleno==304); + case 305: /* table_alias ::= NK_ID */ yytestcase(yyruleno==305); + case 306: /* column_alias ::= NK_ID */ yytestcase(yyruleno==306); + case 307: /* user_name ::= NK_ID */ yytestcase(yyruleno==307); + case 308: /* index_name ::= NK_ID */ yytestcase(yyruleno==308); + case 309: /* topic_name ::= NK_ID */ yytestcase(yyruleno==309); + case 310: /* stream_name ::= NK_ID */ yytestcase(yyruleno==310); + case 311: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==311); + case 346: /* noarg_func ::= NOW */ yytestcase(yyruleno==346); + case 347: /* noarg_func ::= TODAY */ yytestcase(yyruleno==347); + case 348: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==348); + case 349: /* star_func ::= COUNT */ yytestcase(yyruleno==349); + case 350: /* star_func ::= FIRST */ yytestcase(yyruleno==350); + case 351: /* star_func ::= LAST */ yytestcase(yyruleno==351); + case 352: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==352); +{ yylhsminor.yy241 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy241 = yylhsminor.yy241; break; - case 49: /* cmd ::= ALTER LOCAL NK_STRING */ + case 52: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 50: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + case 53: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 51: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + case 54: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_QNODE_STMT, &yymsp[0].minor.yy0); } break; - case 52: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + case 55: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_QNODE_STMT, &yymsp[0].minor.yy0); } break; - case 53: /* cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + case 56: /* cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_BNODE_STMT, &yymsp[0].minor.yy0); } break; - case 54: /* cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + case 57: /* cmd ::= DROP BNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_BNODE_STMT, &yymsp[0].minor.yy0); } break; - case 55: /* cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + case 58: /* cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_SNODE_STMT, &yymsp[0].minor.yy0); } break; - case 56: /* cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + case 59: /* cmd ::= DROP SNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_SNODE_STMT, &yymsp[0].minor.yy0); } break; - case 57: /* cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + case 60: /* cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_MNODE_STMT, &yymsp[0].minor.yy0); } break; - case 58: /* cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + case 61: /* cmd ::= DROP MNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; - case 59: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy481, &yymsp[-1].minor.yy57, yymsp[0].minor.yy392); } + case 62: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy197, &yymsp[-1].minor.yy241, yymsp[0].minor.yy442); } break; - case 60: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy481, &yymsp[0].minor.yy57); } + case 63: /* cmd ::= DROP DATABASE exists_opt db_name */ +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy197, &yymsp[0].minor.yy241); } break; - case 61: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy57); } + case 64: /* cmd ::= USE db_name */ +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy241); } break; - case 62: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy57, yymsp[0].minor.yy392); } + case 65: /* cmd ::= ALTER DATABASE db_name alter_db_options */ +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy241, yymsp[0].minor.yy442); } break; - case 63: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy481 = true; } + case 66: /* not_exists_opt ::= IF NOT EXISTS */ +{ yymsp[-2].minor.yy197 = true; } break; - case 64: /* not_exists_opt ::= */ - case 66: /* exists_opt ::= */ yytestcase(yyruleno==66); - case 240: /* analyze_opt ::= */ yytestcase(yyruleno==240); - case 248: /* agg_func_opt ::= */ yytestcase(yyruleno==248); - case 399: /* set_quantifier_opt ::= */ yytestcase(yyruleno==399); -{ yymsp[1].minor.yy481 = false; } + case 67: /* not_exists_opt ::= */ + case 69: /* exists_opt ::= */ yytestcase(yyruleno==69); + case 244: /* analyze_opt ::= */ yytestcase(yyruleno==244); + case 252: /* agg_func_opt ::= */ yytestcase(yyruleno==252); + case 406: /* set_quantifier_opt ::= */ yytestcase(yyruleno==406); +{ yymsp[1].minor.yy197 = false; } break; - case 65: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy481 = true; } + case 68: /* exists_opt ::= IF EXISTS */ +{ yymsp[-1].minor.yy197 = true; } break; - case 67: /* db_options ::= */ -{ yymsp[1].minor.yy392 = createDefaultDatabaseOptions(pCxt); } + case 70: /* db_options ::= */ +{ yymsp[1].minor.yy442 = createDefaultDatabaseOptions(pCxt); } break; - case 68: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 71: /* db_options ::= db_options BUFFER NK_INTEGER */ +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 69: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 72: /* db_options ::= db_options CACHELAST NK_INTEGER */ +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 70: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 73: /* db_options ::= db_options COMP NK_INTEGER */ +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 71: /* db_options ::= db_options DURATION NK_INTEGER */ - case 72: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==72); -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 74: /* db_options ::= db_options DURATION NK_INTEGER */ + case 75: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==75); +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 73: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 76: /* db_options ::= db_options FSYNC NK_INTEGER */ +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 74: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 77: /* db_options ::= db_options MAXROWS NK_INTEGER */ +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 75: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 78: /* db_options ::= db_options MINROWS NK_INTEGER */ +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 76: /* db_options ::= db_options KEEP integer_list */ - case 77: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==77); -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_KEEP, yymsp[0].minor.yy600); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 79: /* db_options ::= db_options KEEP integer_list */ + case 80: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==80); +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_KEEP, yymsp[0].minor.yy368); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 78: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 81: /* db_options ::= db_options PAGES NK_INTEGER */ +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 79: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; - break; - case 80: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; - break; - case 81: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; - break; - case 82: /* db_options ::= db_options STRICT NK_INTEGER */ -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; - break; - case 83: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; - break; - case 84: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; - break; - case 85: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; - break; - case 86: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_RETENTIONS, yymsp[0].minor.yy600); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; - break; - case 87: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy392 = setDatabaseOption(pCxt, yymsp[-2].minor.yy392, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; - break; - case 88: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy392 = createAlterDatabaseOptions(pCxt); yylhsminor.yy392 = setAlterDatabaseOption(pCxt, yylhsminor.yy392, &yymsp[0].minor.yy221); } - yymsp[0].minor.yy392 = yylhsminor.yy392; - break; - case 89: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy392 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy392, &yymsp[0].minor.yy221); } - yymsp[-1].minor.yy392 = yylhsminor.yy392; - break; - case 90: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy221.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy221.val = yymsp[0].minor.yy0; } - break; - case 91: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy221.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy221.val = yymsp[0].minor.yy0; } - break; - case 92: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy221.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy221.val = yymsp[0].minor.yy0; } - break; - case 93: /* alter_db_option ::= KEEP integer_list */ - case 94: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==94); -{ yymsp[-1].minor.yy221.type = DB_OPTION_KEEP; yymsp[-1].minor.yy221.pList = yymsp[0].minor.yy600; } - break; - case 95: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy221.type = DB_OPTION_PAGES; yymsp[-1].minor.yy221.val = yymsp[0].minor.yy0; } - break; - case 96: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy221.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy221.val = yymsp[0].minor.yy0; } - break; - case 97: /* alter_db_option ::= STRICT NK_INTEGER */ -{ yymsp[-1].minor.yy221.type = DB_OPTION_STRICT; yymsp[-1].minor.yy221.val = yymsp[0].minor.yy0; } - break; - case 98: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy221.type = DB_OPTION_WAL; yymsp[-1].minor.yy221.val = yymsp[0].minor.yy0; } - break; - case 99: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy600 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 100: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 269: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==269); -{ yylhsminor.yy600 = addNodeToList(pCxt, yymsp[-2].minor.yy600, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; - break; - case 101: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy600 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 102: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy600 = addNodeToList(pCxt, yymsp[-2].minor.yy600, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; - break; - case 103: /* retention_list ::= retention */ - case 123: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==123); - case 126: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==126); - case 133: /* column_def_list ::= column_def */ yytestcase(yyruleno==133); - case 176: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==176); - case 181: /* col_name_list ::= col_name */ yytestcase(yyruleno==181); - case 228: /* func_list ::= func */ yytestcase(yyruleno==228); - case 295: /* literal_list ::= signed_literal */ yytestcase(yyruleno==295); - case 349: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==349); - case 404: /* select_sublist ::= select_item */ yytestcase(yyruleno==404); - case 457: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==457); -{ yylhsminor.yy600 = createNodeList(pCxt, yymsp[0].minor.yy392); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 104: /* retention_list ::= retention_list NK_COMMA retention */ - case 134: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==134); - case 177: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==177); - case 182: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==182); - case 229: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==229); - case 296: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==296); - case 350: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==350); - case 405: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==405); - case 458: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==458); -{ yylhsminor.yy600 = addNodeToList(pCxt, yymsp[-2].minor.yy600, yymsp[0].minor.yy392); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; - break; - case 105: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy392 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; - break; - case 106: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 108: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==108); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy481, yymsp[-5].minor.yy392, yymsp[-3].minor.yy600, yymsp[-1].minor.yy600, yymsp[0].minor.yy392); } - break; - case 107: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy600); } - break; - case 109: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy600); } - break; - case 110: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy481, yymsp[0].minor.yy392); } - break; - case 111: /* cmd ::= ALTER TABLE alter_table_clause */ - case 112: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==112); - case 272: /* cmd ::= query_expression */ yytestcase(yyruleno==272); -{ pCxt->pRootNode = yymsp[0].minor.yy392; } - break; - case 113: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy392 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy392, yymsp[0].minor.yy392); } - yymsp[-1].minor.yy392 = yylhsminor.yy392; - break; - case 114: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy392 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy392, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy57, yymsp[0].minor.yy448); } - yymsp[-4].minor.yy392 = yylhsminor.yy392; - break; - case 115: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy392 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy392, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy57); } - yymsp[-3].minor.yy392 = yylhsminor.yy392; - break; - case 116: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy392 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy392, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy57, yymsp[0].minor.yy448); } - yymsp[-4].minor.yy392 = yylhsminor.yy392; + case 82: /* db_options ::= db_options PAGESIZE NK_INTEGER */ +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; + break; + case 83: /* db_options ::= db_options PRECISION NK_STRING */ +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; + break; + case 84: /* db_options ::= db_options REPLICA NK_INTEGER */ +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; + break; + case 85: /* db_options ::= db_options STRICT NK_INTEGER */ +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; + break; + case 86: /* db_options ::= db_options WAL NK_INTEGER */ +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; + break; + case 87: /* db_options ::= db_options VGROUPS NK_INTEGER */ +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; + break; + case 88: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; + break; + case 89: /* db_options ::= db_options RETENTIONS retention_list */ +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_RETENTIONS, yymsp[0].minor.yy368); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; + break; + case 90: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ +{ yylhsminor.yy442 = setDatabaseOption(pCxt, yymsp[-2].minor.yy442, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; + break; + case 91: /* alter_db_options ::= alter_db_option */ +{ yylhsminor.yy442 = createAlterDatabaseOptions(pCxt); yylhsminor.yy442 = setAlterDatabaseOption(pCxt, yylhsminor.yy442, &yymsp[0].minor.yy301); } + yymsp[0].minor.yy442 = yylhsminor.yy442; + break; + case 92: /* alter_db_options ::= alter_db_options alter_db_option */ +{ yylhsminor.yy442 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy442, &yymsp[0].minor.yy301); } + yymsp[-1].minor.yy442 = yylhsminor.yy442; + break; + case 93: /* alter_db_option ::= BUFFER NK_INTEGER */ +{ yymsp[-1].minor.yy301.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } + break; + case 94: /* alter_db_option ::= CACHELAST NK_INTEGER */ +{ yymsp[-1].minor.yy301.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } + break; + case 95: /* alter_db_option ::= FSYNC NK_INTEGER */ +{ yymsp[-1].minor.yy301.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } + break; + case 96: /* alter_db_option ::= KEEP integer_list */ + case 97: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==97); +{ yymsp[-1].minor.yy301.type = DB_OPTION_KEEP; yymsp[-1].minor.yy301.pList = yymsp[0].minor.yy368; } + break; + case 98: /* alter_db_option ::= PAGES NK_INTEGER */ +{ yymsp[-1].minor.yy301.type = DB_OPTION_PAGES; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } + break; + case 99: /* alter_db_option ::= REPLICA NK_INTEGER */ +{ yymsp[-1].minor.yy301.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } + break; + case 100: /* alter_db_option ::= STRICT NK_INTEGER */ +{ yymsp[-1].minor.yy301.type = DB_OPTION_STRICT; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } + break; + case 101: /* alter_db_option ::= WAL NK_INTEGER */ +{ yymsp[-1].minor.yy301.type = DB_OPTION_WAL; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } + break; + case 102: /* integer_list ::= NK_INTEGER */ +{ yylhsminor.yy368 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy368 = yylhsminor.yy368; + break; + case 103: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ + case 273: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==273); +{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-2].minor.yy368, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy368 = yylhsminor.yy368; + break; + case 104: /* variable_list ::= NK_VARIABLE */ +{ yylhsminor.yy368 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy368 = yylhsminor.yy368; + break; + case 105: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ +{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-2].minor.yy368, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy368 = yylhsminor.yy368; + break; + case 106: /* retention_list ::= retention */ + case 126: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==126); + case 129: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==129); + case 136: /* column_def_list ::= column_def */ yytestcase(yyruleno==136); + case 179: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==179); + case 184: /* col_name_list ::= col_name */ yytestcase(yyruleno==184); + case 230: /* func_list ::= func */ yytestcase(yyruleno==230); + case 299: /* literal_list ::= signed_literal */ yytestcase(yyruleno==299); + case 355: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==355); + case 411: /* select_sublist ::= select_item */ yytestcase(yyruleno==411); + case 464: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==464); +{ yylhsminor.yy368 = createNodeList(pCxt, yymsp[0].minor.yy442); } + yymsp[0].minor.yy368 = yylhsminor.yy368; + break; + case 107: /* retention_list ::= retention_list NK_COMMA retention */ + case 137: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==137); + case 180: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==180); + case 185: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==185); + case 231: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==231); + case 300: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==300); + case 356: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==356); + case 412: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==412); + case 465: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==465); +{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-2].minor.yy368, yymsp[0].minor.yy442); } + yymsp[-2].minor.yy368 = yylhsminor.yy368; + break; + case 108: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ +{ yylhsminor.yy442 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; + break; + case 109: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 111: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==111); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy197, yymsp[-5].minor.yy442, yymsp[-3].minor.yy368, yymsp[-1].minor.yy368, yymsp[0].minor.yy442); } + break; + case 110: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy368); } + break; + case 112: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy368); } + break; + case 113: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy197, yymsp[0].minor.yy442); } + break; + case 114: /* cmd ::= ALTER TABLE alter_table_clause */ + case 115: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==115); + case 276: /* cmd ::= query_expression */ yytestcase(yyruleno==276); +{ pCxt->pRootNode = yymsp[0].minor.yy442; } + break; + case 116: /* alter_table_clause ::= full_table_name alter_table_options */ +{ yylhsminor.yy442 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy442, yymsp[0].minor.yy442); } + yymsp[-1].minor.yy442 = yylhsminor.yy442; + break; + case 117: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ +{ yylhsminor.yy442 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy241, yymsp[0].minor.yy392); } + yymsp[-4].minor.yy442 = yylhsminor.yy442; + break; + case 118: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ +{ yylhsminor.yy442 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy442, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy241); } + yymsp[-3].minor.yy442 = yylhsminor.yy442; + break; + case 119: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ +{ yylhsminor.yy442 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy241, yymsp[0].minor.yy392); } + yymsp[-4].minor.yy442 = yylhsminor.yy442; break; - case 117: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy392 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy392, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy57, &yymsp[0].minor.yy57); } - yymsp[-4].minor.yy392 = yylhsminor.yy392; - break; - case 118: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy392 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy392, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy57, yymsp[0].minor.yy448); } - yymsp[-4].minor.yy392 = yylhsminor.yy392; - break; - case 119: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy392 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy392, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy57); } - yymsp[-3].minor.yy392 = yylhsminor.yy392; + case 120: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ +{ yylhsminor.yy442 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } + yymsp[-4].minor.yy442 = yylhsminor.yy442; + break; + case 121: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ +{ yylhsminor.yy442 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy241, yymsp[0].minor.yy392); } + yymsp[-4].minor.yy442 = yylhsminor.yy442; + break; + case 122: /* alter_table_clause ::= full_table_name DROP TAG column_name */ +{ yylhsminor.yy442 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy442, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy241); } + yymsp[-3].minor.yy442 = yylhsminor.yy442; break; - case 120: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy392 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy392, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy57, yymsp[0].minor.yy448); } - yymsp[-4].minor.yy392 = yylhsminor.yy392; + case 123: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ +{ yylhsminor.yy442 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy241, yymsp[0].minor.yy392); } + yymsp[-4].minor.yy442 = yylhsminor.yy442; break; - case 121: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy392 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy392, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy57, &yymsp[0].minor.yy57); } - yymsp[-4].minor.yy392 = yylhsminor.yy392; - break; - case 122: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy392 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy392, &yymsp[-2].minor.yy57, yymsp[0].minor.yy392); } - yymsp[-5].minor.yy392 = yylhsminor.yy392; + case 124: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ +{ yylhsminor.yy442 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy442, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } + yymsp[-4].minor.yy442 = yylhsminor.yy442; + break; + case 125: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ +{ yylhsminor.yy442 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy442, &yymsp[-2].minor.yy241, yymsp[0].minor.yy442); } + yymsp[-5].minor.yy442 = yylhsminor.yy442; break; - case 124: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 127: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==127); -{ yylhsminor.yy600 = addNodeToList(pCxt, yymsp[-1].minor.yy600, yymsp[0].minor.yy392); } - yymsp[-1].minor.yy600 = yylhsminor.yy600; + case 127: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 130: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==130); +{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-1].minor.yy368, yymsp[0].minor.yy442); } + yymsp[-1].minor.yy368 = yylhsminor.yy368; break; - case 125: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ -{ yylhsminor.yy392 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy481, yymsp[-8].minor.yy392, yymsp[-6].minor.yy392, yymsp[-5].minor.yy600, yymsp[-2].minor.yy600, yymsp[0].minor.yy392); } - yymsp[-9].minor.yy392 = yylhsminor.yy392; + case 128: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP table_options */ +{ yylhsminor.yy442 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy197, yymsp[-8].minor.yy442, yymsp[-6].minor.yy442, yymsp[-5].minor.yy368, yymsp[-2].minor.yy368, yymsp[0].minor.yy442); } + yymsp[-9].minor.yy442 = yylhsminor.yy442; break; - case 128: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy392 = createDropTableClause(pCxt, yymsp[-1].minor.yy481, yymsp[0].minor.yy392); } - yymsp[-1].minor.yy392 = yylhsminor.yy392; + case 131: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy442 = createDropTableClause(pCxt, yymsp[-1].minor.yy197, yymsp[0].minor.yy442); } + yymsp[-1].minor.yy442 = yylhsminor.yy442; break; - case 129: /* specific_tags_opt ::= */ - case 160: /* tags_def_opt ::= */ yytestcase(yyruleno==160); - case 412: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==412); - case 429: /* group_by_clause_opt ::= */ yytestcase(yyruleno==429); - case 445: /* order_by_clause_opt ::= */ yytestcase(yyruleno==445); -{ yymsp[1].minor.yy600 = NULL; } + case 132: /* specific_tags_opt ::= */ + case 163: /* tags_def_opt ::= */ yytestcase(yyruleno==163); + case 419: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==419); + case 436: /* group_by_clause_opt ::= */ yytestcase(yyruleno==436); + case 452: /* order_by_clause_opt ::= */ yytestcase(yyruleno==452); +{ yymsp[1].minor.yy368 = NULL; } break; - case 130: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy600 = yymsp[-1].minor.yy600; } + case 133: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy368 = yymsp[-1].minor.yy368; } break; - case 131: /* full_table_name ::= table_name */ -{ yylhsminor.yy392 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy57, NULL); } - yymsp[0].minor.yy392 = yylhsminor.yy392; + case 134: /* full_table_name ::= table_name */ +{ yylhsminor.yy442 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy241, NULL); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 132: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy392 = createRealTableNode(pCxt, &yymsp[-2].minor.yy57, &yymsp[0].minor.yy57, NULL); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 135: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy442 = createRealTableNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241, NULL); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 135: /* column_def ::= column_name type_name */ -{ yylhsminor.yy392 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy57, yymsp[0].minor.yy448, NULL); } - yymsp[-1].minor.yy392 = yylhsminor.yy392; + case 138: /* column_def ::= column_name type_name */ +{ yylhsminor.yy442 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy241, yymsp[0].minor.yy392, NULL); } + yymsp[-1].minor.yy442 = yylhsminor.yy442; break; - case 136: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy392 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy57, yymsp[-2].minor.yy448, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy392 = yylhsminor.yy392; + case 139: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy442 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-2].minor.yy392, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy442 = yylhsminor.yy442; break; - case 137: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 140: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 138: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 141: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 139: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 142: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 140: /* type_name ::= INT */ - case 141: /* type_name ::= INTEGER */ yytestcase(yyruleno==141); -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_INT); } + case 143: /* type_name ::= INT */ + case 144: /* type_name ::= INTEGER */ yytestcase(yyruleno==144); +{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 142: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 145: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 143: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 146: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 144: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 147: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 145: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 148: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy392 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 146: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 149: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 147: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 150: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy392 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 148: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 151: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy392 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 149: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 152: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy392 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 150: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UINT); } + case 153: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy392 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 151: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy448 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 154: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy392 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 152: /* type_name ::= JSON */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_JSON); } + case 155: /* type_name ::= JSON */ +{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 153: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 156: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy392 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 154: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 157: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 155: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 158: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 156: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy448 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 159: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy392 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 157: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 160: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy392 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 158: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 161: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy392 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 159: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy448 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 162: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy392 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 161: /* tags_def_opt ::= tags_def */ - case 348: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==348); - case 403: /* select_list ::= select_sublist */ yytestcase(yyruleno==403); -{ yylhsminor.yy600 = yymsp[0].minor.yy600; } - yymsp[0].minor.yy600 = yylhsminor.yy600; + case 164: /* tags_def_opt ::= tags_def */ + case 354: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==354); + case 410: /* select_list ::= select_sublist */ yytestcase(yyruleno==410); +{ yylhsminor.yy368 = yymsp[0].minor.yy368; } + yymsp[0].minor.yy368 = yylhsminor.yy368; break; - case 162: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy600 = yymsp[-1].minor.yy600; } + case 165: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy368 = yymsp[-1].minor.yy368; } break; - case 163: /* table_options ::= */ -{ yymsp[1].minor.yy392 = createDefaultTableOptions(pCxt); } + case 166: /* table_options ::= */ +{ yymsp[1].minor.yy442 = createDefaultTableOptions(pCxt); } break; - case 164: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy392 = setTableOption(pCxt, yymsp[-2].minor.yy392, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 167: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-2].minor.yy442, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 165: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy392 = setTableOption(pCxt, yymsp[-2].minor.yy392, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy600); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 168: /* table_options ::= table_options MAX_DELAY duration_list */ +{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-2].minor.yy442, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy368); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 166: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy392 = setTableOption(pCxt, yymsp[-2].minor.yy392, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy600); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 169: /* table_options ::= table_options WATERMARK duration_list */ +{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-2].minor.yy442, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy368); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 167: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy392 = setTableOption(pCxt, yymsp[-4].minor.yy392, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy600); } - yymsp[-4].minor.yy392 = yylhsminor.yy392; + case 170: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ +{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-4].minor.yy442, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy368); } + yymsp[-4].minor.yy442 = yylhsminor.yy442; break; - case 168: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy392 = setTableOption(pCxt, yymsp[-2].minor.yy392, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 171: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-2].minor.yy442, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 169: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy392 = setTableOption(pCxt, yymsp[-4].minor.yy392, TABLE_OPTION_SMA, yymsp[-1].minor.yy600); } - yymsp[-4].minor.yy392 = yylhsminor.yy392; + case 172: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-4].minor.yy442, TABLE_OPTION_SMA, yymsp[-1].minor.yy368); } + yymsp[-4].minor.yy442 = yylhsminor.yy442; break; - case 170: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy392 = createAlterTableOptions(pCxt); yylhsminor.yy392 = setTableOption(pCxt, yylhsminor.yy392, yymsp[0].minor.yy221.type, &yymsp[0].minor.yy221.val); } - yymsp[0].minor.yy392 = yylhsminor.yy392; + case 173: /* alter_table_options ::= alter_table_option */ +{ yylhsminor.yy442 = createAlterTableOptions(pCxt); yylhsminor.yy442 = setTableOption(pCxt, yylhsminor.yy442, yymsp[0].minor.yy301.type, &yymsp[0].minor.yy301.val); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 171: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy392 = setTableOption(pCxt, yymsp[-1].minor.yy392, yymsp[0].minor.yy221.type, &yymsp[0].minor.yy221.val); } - yymsp[-1].minor.yy392 = yylhsminor.yy392; + case 174: /* alter_table_options ::= alter_table_options alter_table_option */ +{ yylhsminor.yy442 = setTableOption(pCxt, yymsp[-1].minor.yy442, yymsp[0].minor.yy301.type, &yymsp[0].minor.yy301.val); } + yymsp[-1].minor.yy442 = yylhsminor.yy442; break; - case 172: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy221.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy221.val = yymsp[0].minor.yy0; } + case 175: /* alter_table_option ::= COMMENT NK_STRING */ +{ yymsp[-1].minor.yy301.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } break; - case 173: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy221.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy221.val = yymsp[0].minor.yy0; } + case 176: /* alter_table_option ::= TTL NK_INTEGER */ +{ yymsp[-1].minor.yy301.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy301.val = yymsp[0].minor.yy0; } break; - case 174: /* duration_list ::= duration_literal */ - case 322: /* expression_list ::= expression */ yytestcase(yyruleno==322); -{ yylhsminor.yy600 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy392)); } - yymsp[0].minor.yy600 = yylhsminor.yy600; + case 177: /* duration_list ::= duration_literal */ + case 328: /* expression_list ::= expression */ yytestcase(yyruleno==328); +{ yylhsminor.yy368 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy442)); } + yymsp[0].minor.yy368 = yylhsminor.yy368; break; - case 175: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 323: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==323); -{ yylhsminor.yy600 = addNodeToList(pCxt, yymsp[-2].minor.yy600, releaseRawExprNode(pCxt, yymsp[0].minor.yy392)); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 178: /* duration_list ::= duration_list NK_COMMA duration_literal */ + case 329: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==329); +{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-2].minor.yy368, releaseRawExprNode(pCxt, yymsp[0].minor.yy442)); } + yymsp[-2].minor.yy368 = yylhsminor.yy368; break; - case 178: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy392 = createFunctionNode(pCxt, &yymsp[0].minor.yy57, NULL); } - yymsp[0].minor.yy392 = yylhsminor.yy392; + case 181: /* rollup_func_name ::= function_name */ +{ yylhsminor.yy442 = createFunctionNode(pCxt, &yymsp[0].minor.yy241, NULL); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 179: /* rollup_func_name ::= FIRST */ - case 180: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==180); -{ yylhsminor.yy392 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy392 = yylhsminor.yy392; + case 182: /* rollup_func_name ::= FIRST */ + case 183: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==183); +{ yylhsminor.yy442 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 183: /* col_name ::= column_name */ -{ yylhsminor.yy392 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy57); } - yymsp[0].minor.yy392 = yylhsminor.yy392; + case 186: /* col_name ::= column_name */ +{ yylhsminor.yy442 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy241); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 184: /* cmd ::= SHOW DNODES */ + case 187: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } break; - case 185: /* cmd ::= SHOW USERS */ + case 188: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } break; - case 186: /* cmd ::= SHOW DATABASES */ + case 189: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } break; - case 187: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy392, yymsp[0].minor.yy392, OP_TYPE_LIKE); } + case 190: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy442, yymsp[0].minor.yy442, OP_TYPE_LIKE); } break; - case 188: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy392, yymsp[0].minor.yy392, OP_TYPE_LIKE); } + case 191: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy442, yymsp[0].minor.yy442, OP_TYPE_LIKE); } break; - case 189: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy392, NULL, OP_TYPE_LIKE); } + case 192: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy442, NULL, OP_TYPE_LIKE); } break; - case 190: /* cmd ::= SHOW MNODES */ + case 193: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } break; - case 191: /* cmd ::= SHOW MODULES */ + case 194: /* cmd ::= SHOW MODULES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT); } break; - case 192: /* cmd ::= SHOW QNODES */ + case 195: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } break; - case 193: /* cmd ::= SHOW FUNCTIONS */ + case 196: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; - case 194: /* 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); } + case 197: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy442, yymsp[-1].minor.yy442, OP_TYPE_EQUAL); } break; - case 195: /* cmd ::= SHOW STREAMS */ + case 198: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } break; - case 196: /* cmd ::= SHOW ACCOUNTS */ + case 199: /* cmd ::= SHOW ACCOUNTS */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } break; - case 197: /* cmd ::= SHOW APPS */ + case 200: /* cmd ::= SHOW APPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } break; - case 198: /* cmd ::= SHOW CONNECTIONS */ + case 201: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } break; - case 199: /* cmd ::= SHOW LICENCE */ - case 200: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==200); + case 202: /* cmd ::= SHOW LICENCE */ + case 203: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==203); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT); } break; - case 201: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy57); } + case 204: /* cmd ::= SHOW CREATE DATABASE db_name */ +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy241); } break; - case 202: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy392); } + case 205: /* cmd ::= SHOW CREATE TABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy442); } break; - case 203: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy392); } + case 206: /* cmd ::= SHOW CREATE STABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy442); } break; - case 204: /* cmd ::= SHOW QUERIES */ + case 207: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } break; - case 205: /* cmd ::= SHOW SCORES */ + case 208: /* cmd ::= SHOW SCORES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } break; - case 206: /* cmd ::= SHOW TOPICS */ + case 209: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } break; - case 207: /* cmd ::= SHOW VARIABLES */ + case 210: /* cmd ::= SHOW VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } break; - case 208: /* cmd ::= SHOW LOCAL VARIABLES */ + case 211: /* cmd ::= SHOW LOCAL VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } break; - case 209: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + case 212: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ { pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-1].minor.yy0)); } break; - case 210: /* cmd ::= SHOW BNODES */ + case 213: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } break; - case 211: /* cmd ::= SHOW SNODES */ + case 214: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } break; - case 212: /* cmd ::= SHOW CLUSTER */ + case 215: /* cmd ::= SHOW CLUSTER */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } break; - case 213: /* cmd ::= SHOW TRANSACTIONS */ + case 216: /* cmd ::= SHOW TRANSACTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; - case 214: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy392); } + case 217: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy442); } break; - case 215: /* db_name_cond_opt ::= */ - case 220: /* from_db_opt ::= */ yytestcase(yyruleno==220); -{ yymsp[1].minor.yy392 = createDefaultDatabaseCondValue(pCxt); } + case 218: /* db_name_cond_opt ::= */ + case 223: /* from_db_opt ::= */ yytestcase(yyruleno==223); +{ yymsp[1].minor.yy442 = createDefaultDatabaseCondValue(pCxt); } break; - case 216: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy57); } - yymsp[-1].minor.yy392 = yylhsminor.yy392; + case 219: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy241); } + yymsp[-1].minor.yy442 = yylhsminor.yy442; break; - case 217: /* like_pattern_opt ::= */ - case 225: /* index_options ::= */ yytestcase(yyruleno==225); - case 254: /* into_opt ::= */ yytestcase(yyruleno==254); - case 410: /* where_clause_opt ::= */ yytestcase(yyruleno==410); - case 414: /* twindow_clause_opt ::= */ yytestcase(yyruleno==414); - case 419: /* sliding_opt ::= */ yytestcase(yyruleno==419); - case 421: /* fill_opt ::= */ yytestcase(yyruleno==421); - case 433: /* having_clause_opt ::= */ yytestcase(yyruleno==433); - case 435: /* range_opt ::= */ yytestcase(yyruleno==435); - case 437: /* every_opt ::= */ yytestcase(yyruleno==437); - case 447: /* slimit_clause_opt ::= */ yytestcase(yyruleno==447); - case 451: /* limit_clause_opt ::= */ yytestcase(yyruleno==451); -{ yymsp[1].minor.yy392 = NULL; } + case 220: /* like_pattern_opt ::= */ + case 227: /* index_options ::= */ yytestcase(yyruleno==227); + case 258: /* into_opt ::= */ yytestcase(yyruleno==258); + case 387: /* from_clause_opt ::= */ yytestcase(yyruleno==387); + case 417: /* where_clause_opt ::= */ yytestcase(yyruleno==417); + case 421: /* twindow_clause_opt ::= */ yytestcase(yyruleno==421); + case 426: /* sliding_opt ::= */ yytestcase(yyruleno==426); + case 428: /* fill_opt ::= */ yytestcase(yyruleno==428); + case 440: /* having_clause_opt ::= */ yytestcase(yyruleno==440); + case 442: /* range_opt ::= */ yytestcase(yyruleno==442); + case 444: /* every_opt ::= */ yytestcase(yyruleno==444); + case 454: /* slimit_clause_opt ::= */ yytestcase(yyruleno==454); + case 458: /* limit_clause_opt ::= */ yytestcase(yyruleno==458); +{ yymsp[1].minor.yy442 = NULL; } break; - case 218: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 221: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 219: /* table_name_cond ::= table_name */ -{ yylhsminor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy57); } - yymsp[0].minor.yy392 = yylhsminor.yy392; + case 222: /* table_name_cond ::= table_name */ +{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy241); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 221: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy57); } + case 224: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy241); } break; - case 222: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy481, &yymsp[-3].minor.yy57, &yymsp[-1].minor.yy57, NULL, yymsp[0].minor.yy392); } + case 225: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy197, &yymsp[-3].minor.yy241, &yymsp[-1].minor.yy241, NULL, yymsp[0].minor.yy442); } break; - case 223: /* cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy481, &yymsp[-5].minor.yy57, &yymsp[-3].minor.yy57, yymsp[-1].minor.yy600, NULL); } + case 226: /* cmd ::= DROP INDEX exists_opt index_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy197, &yymsp[0].minor.yy241); } break; - case 224: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy481, &yymsp[-2].minor.yy57, &yymsp[0].minor.yy57); } + case 228: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ +{ yymsp[-8].minor.yy442 = createIndexOption(pCxt, yymsp[-6].minor.yy368, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), NULL, yymsp[0].minor.yy442); } break; - case 226: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy392 = createIndexOption(pCxt, yymsp[-6].minor.yy600, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), NULL, yymsp[0].minor.yy392); } + case 229: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ +{ yymsp[-10].minor.yy442 = createIndexOption(pCxt, yymsp[-8].minor.yy368, releaseRawExprNode(pCxt, yymsp[-4].minor.yy442), releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), yymsp[0].minor.yy442); } break; - case 227: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ -{ yymsp[-10].minor.yy392 = createIndexOption(pCxt, yymsp[-8].minor.yy600, releaseRawExprNode(pCxt, yymsp[-4].minor.yy392), releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), yymsp[0].minor.yy392); } + case 232: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy442 = createFunctionNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-1].minor.yy368); } + yymsp[-3].minor.yy442 = yylhsminor.yy442; break; - case 230: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy392 = createFunctionNode(pCxt, &yymsp[-3].minor.yy57, yymsp[-1].minor.yy600); } - yymsp[-3].minor.yy392 = yylhsminor.yy392; + case 233: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy197, &yymsp[-2].minor.yy241, yymsp[0].minor.yy442); } break; - case 231: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy481, &yymsp[-2].minor.yy57, yymsp[0].minor.yy392, NULL, NULL); } + case 234: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy197, &yymsp[-3].minor.yy241, &yymsp[0].minor.yy241, false); } break; - case 232: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-4].minor.yy481, &yymsp[-3].minor.yy57, NULL, &yymsp[0].minor.yy57, NULL); } + case 235: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy197, &yymsp[-5].minor.yy241, &yymsp[0].minor.yy241, true); } break; - case 233: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-4].minor.yy481, &yymsp[-3].minor.yy57, NULL, NULL, yymsp[0].minor.yy392); } + case 236: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy197, &yymsp[-3].minor.yy241, yymsp[0].minor.yy442, false); } break; - case 234: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy481, &yymsp[0].minor.yy57); } + case 237: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy197, &yymsp[-5].minor.yy241, yymsp[0].minor.yy442, true); } break; - case 235: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy481, &yymsp[-2].minor.yy57, &yymsp[0].minor.yy57); } + case 238: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy197, &yymsp[0].minor.yy241); } break; - case 236: /* cmd ::= DESC full_table_name */ - case 237: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==237); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy392); } + case 239: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy197, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241); } break; - case 238: /* cmd ::= RESET QUERY CACHE */ + case 240: /* cmd ::= DESC full_table_name */ + case 241: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==241); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy442); } + break; + case 242: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 239: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy481, yymsp[-1].minor.yy392, yymsp[0].minor.yy392); } + case 243: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy197, yymsp[-1].minor.yy442, yymsp[0].minor.yy442); } break; - case 241: /* analyze_opt ::= ANALYZE */ - case 249: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==249); - case 400: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==400); -{ yymsp[0].minor.yy481 = true; } + case 245: /* analyze_opt ::= ANALYZE */ + case 253: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==253); + case 407: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==407); +{ yymsp[0].minor.yy197 = true; } break; - case 242: /* explain_options ::= */ -{ yymsp[1].minor.yy392 = createDefaultExplainOptions(pCxt); } + case 246: /* explain_options ::= */ +{ yymsp[1].minor.yy442 = createDefaultExplainOptions(pCxt); } break; - case 243: /* 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; + case 247: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy442 = setExplainVerbose(pCxt, yymsp[-2].minor.yy442, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 244: /* 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; + case 248: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy442 = setExplainRatio(pCxt, yymsp[-2].minor.yy442, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 245: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ -{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy600); } + case 249: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ +{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy368); } break; - case 246: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy481, yymsp[-8].minor.yy481, &yymsp[-5].minor.yy57, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy448, yymsp[0].minor.yy228); } + case 250: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy197, yymsp[-8].minor.yy197, &yymsp[-5].minor.yy241, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy392, yymsp[0].minor.yy578); } break; - case 247: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy481, &yymsp[0].minor.yy57); } + case 251: /* cmd ::= DROP FUNCTION exists_opt function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy197, &yymsp[0].minor.yy241); } break; - case 250: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy228 = 0; } + case 254: /* bufsize_opt ::= */ +{ yymsp[1].minor.yy578 = 0; } break; - case 251: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy228 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + case 255: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ +{ yymsp[-1].minor.yy578 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 252: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy481, &yymsp[-4].minor.yy57, yymsp[-2].minor.yy392, yymsp[-3].minor.yy392, yymsp[0].minor.yy392); } + case 256: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy197, &yymsp[-4].minor.yy241, yymsp[-2].minor.yy442, yymsp[-3].minor.yy442, yymsp[0].minor.yy442); } break; - case 253: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy481, &yymsp[0].minor.yy57); } + case 257: /* cmd ::= DROP STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy197, &yymsp[0].minor.yy241); } break; - case 255: /* into_opt ::= INTO full_table_name */ - case 381: /* from_clause ::= FROM table_reference_list */ yytestcase(yyruleno==381); - case 411: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==411); - case 434: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==434); -{ yymsp[-1].minor.yy392 = yymsp[0].minor.yy392; } + case 259: /* into_opt ::= INTO full_table_name */ + case 388: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==388); + case 418: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==418); + case 441: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==441); +{ yymsp[-1].minor.yy442 = yymsp[0].minor.yy442; } break; - case 256: /* stream_options ::= */ -{ yymsp[1].minor.yy392 = createStreamOptions(pCxt); } + case 260: /* stream_options ::= */ +{ yymsp[1].minor.yy442 = createStreamOptions(pCxt); } break; - case 257: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy392)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy392 = yymsp[-2].minor.yy392; } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 261: /* stream_options ::= stream_options TRIGGER AT_ONCE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy442)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy442 = yymsp[-2].minor.yy442; } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 258: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy392)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy392 = yymsp[-2].minor.yy392; } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 262: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy442)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy442 = yymsp[-2].minor.yy442; } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 259: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-3].minor.yy392)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy392)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy392); yylhsminor.yy392 = yymsp[-3].minor.yy392; } - yymsp[-3].minor.yy392 = yylhsminor.yy392; + case 263: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-3].minor.yy442)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy442)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy442); yylhsminor.yy442 = yymsp[-3].minor.yy442; } + yymsp[-3].minor.yy442 = yylhsminor.yy442; break; - case 260: /* stream_options ::= stream_options 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; + case 264: /* stream_options ::= stream_options WATERMARK duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy442)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy442); yylhsminor.yy442 = yymsp[-2].minor.yy442; } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 261: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 265: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 262: /* cmd ::= KILL QUERY NK_STRING */ + case 266: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 263: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 267: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 264: /* cmd ::= BALANCE VGROUP */ + case 268: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 265: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 269: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 266: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy600); } + case 270: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy368); } break; - case 267: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 271: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 268: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy600 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 272: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy368 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 270: /* cmd ::= SYNCDB db_name REPLICA */ -{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy57); } + case 274: /* cmd ::= SYNCDB db_name REPLICA */ +{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy241); } break; - case 271: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy392, yymsp[0].minor.yy392); } + case 275: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy442, yymsp[0].minor.yy442); } break; - case 273: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy392 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy392 = yylhsminor.yy392; + case 277: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 274: /* 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; + case 278: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 275: /* 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; + case 279: /* literal ::= NK_STRING */ +{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 276: /* 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; + case 280: /* literal ::= NK_BOOL */ +{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 277: /* 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; + case 281: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy442 = yylhsminor.yy442; break; - case 278: /* literal ::= duration_literal */ - case 288: /* signed_literal ::= signed */ yytestcase(yyruleno==288); - case 308: /* expression ::= literal */ yytestcase(yyruleno==308); - case 309: /* expression ::= pseudo_column */ yytestcase(yyruleno==309); - case 310: /* expression ::= column_reference */ yytestcase(yyruleno==310); - case 311: /* expression ::= function_expression */ yytestcase(yyruleno==311); - case 312: /* expression ::= subquery */ yytestcase(yyruleno==312); - case 337: /* function_expression ::= literal_func */ yytestcase(yyruleno==337); - case 373: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==373); - case 377: /* boolean_primary ::= predicate */ yytestcase(yyruleno==377); - case 379: /* common_expression ::= expression */ yytestcase(yyruleno==379); - case 380: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==380); - case 382: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==382); - case 384: /* table_reference ::= table_primary */ yytestcase(yyruleno==384); - case 385: /* table_reference ::= joined_table */ yytestcase(yyruleno==385); - case 389: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==389); - case 440: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==440); - case 443: /* query_primary ::= query_specification */ yytestcase(yyruleno==443); -{ yylhsminor.yy392 = yymsp[0].minor.yy392; } - yymsp[0].minor.yy392 = yylhsminor.yy392; + case 282: /* literal ::= duration_literal */ + case 292: /* signed_literal ::= signed */ yytestcase(yyruleno==292); + case 312: /* expression ::= literal */ yytestcase(yyruleno==312); + case 313: /* expression ::= pseudo_column */ yytestcase(yyruleno==313); + case 314: /* expression ::= column_reference */ yytestcase(yyruleno==314); + case 315: /* expression ::= function_expression */ yytestcase(yyruleno==315); + case 316: /* expression ::= subquery */ yytestcase(yyruleno==316); + case 343: /* function_expression ::= literal_func */ yytestcase(yyruleno==343); + case 379: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==379); + case 383: /* boolean_primary ::= predicate */ yytestcase(yyruleno==383); + case 385: /* common_expression ::= expression */ yytestcase(yyruleno==385); + case 386: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==386); + case 389: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==389); + case 391: /* table_reference ::= table_primary */ yytestcase(yyruleno==391); + case 392: /* table_reference ::= joined_table */ yytestcase(yyruleno==392); + case 396: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==396); + case 447: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==447); + case 450: /* query_primary ::= query_specification */ yytestcase(yyruleno==450); +{ yylhsminor.yy442 = yymsp[0].minor.yy442; } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 279: /* 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; + case 283: /* literal ::= NULL */ +{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 280: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy392 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy392 = yylhsminor.yy392; + case 284: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 281: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy392 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy392 = yylhsminor.yy392; + case 285: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 282: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy392 = yylhsminor.yy392; + case 286: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 283: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + case 287: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; - case 284: /* signed ::= NK_MINUS NK_INTEGER */ + case 288: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy392 = yylhsminor.yy392; + yymsp[-1].minor.yy442 = yylhsminor.yy442; break; - case 285: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy392 = yylhsminor.yy392; + case 289: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 286: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 290: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 287: /* signed ::= NK_MINUS NK_FLOAT */ + case 291: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy392 = yylhsminor.yy392; + yymsp[-1].minor.yy442 = yylhsminor.yy442; break; - case 289: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy392 = yylhsminor.yy392; + case 293: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 290: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy392 = yylhsminor.yy392; + case 294: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 291: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 295: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 292: /* signed_literal ::= duration_literal */ - case 294: /* signed_literal ::= literal_func */ yytestcase(yyruleno==294); - case 351: /* star_func_para ::= expression */ yytestcase(yyruleno==351); - case 406: /* select_item ::= common_expression */ yytestcase(yyruleno==406); - case 456: /* search_condition ::= common_expression */ yytestcase(yyruleno==456); -{ yylhsminor.yy392 = releaseRawExprNode(pCxt, yymsp[0].minor.yy392); } - yymsp[0].minor.yy392 = yylhsminor.yy392; + case 296: /* signed_literal ::= duration_literal */ + case 298: /* signed_literal ::= literal_func */ yytestcase(yyruleno==298); + case 357: /* star_func_para ::= expression */ yytestcase(yyruleno==357); + case 413: /* select_item ::= common_expression */ yytestcase(yyruleno==413); + case 463: /* search_condition ::= common_expression */ yytestcase(yyruleno==463); +{ yylhsminor.yy442 = releaseRawExprNode(pCxt, yymsp[0].minor.yy442); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 293: /* signed_literal ::= NULL */ -{ yylhsminor.yy392 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy392 = yylhsminor.yy392; + case 297: /* signed_literal ::= NULL */ +{ yylhsminor.yy442 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy442 = yylhsminor.yy442; break; - case 313: /* expression ::= NK_LP expression NK_RP */ - case 378: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==378); -{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy392)); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 317: /* expression ::= NK_LP expression NK_RP */ + case 384: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==384); +{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy442)); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 314: /* expression ::= NK_PLUS expression */ + case 318: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy392); - yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy392)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy442)); } - yymsp[-1].minor.yy392 = yylhsminor.yy392; + yymsp[-1].minor.yy442 = yylhsminor.yy442; break; - case 315: /* expression ::= NK_MINUS expression */ + case 319: /* expression ::= NK_MINUS expression */ { - 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)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy442), NULL)); } - yymsp[-1].minor.yy392 = yylhsminor.yy392; + yymsp[-1].minor.yy442 = yylhsminor.yy442; break; - case 316: /* expression ::= expression NK_PLUS expression */ + case 320: /* expression ::= expression NK_PLUS expression */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 317: /* expression ::= expression NK_MINUS expression */ + case 321: /* expression ::= expression NK_MINUS expression */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 318: /* expression ::= expression NK_STAR expression */ + case 322: /* expression ::= expression NK_STAR expression */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 319: /* expression ::= expression NK_SLASH expression */ + case 323: /* expression ::= expression NK_SLASH expression */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 320: /* expression ::= expression NK_REM expression */ + case 324: /* expression ::= expression NK_REM expression */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 321: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 325: /* expression ::= column_reference NK_ARROW NK_STRING */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 324: /* column_reference ::= column_name */ -{ yylhsminor.yy392 = createRawExprNode(pCxt, &yymsp[0].minor.yy57, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy57)); } - yymsp[0].minor.yy392 = yylhsminor.yy392; - break; - case 325: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy57, &yymsp[0].minor.yy57, createColumnNode(pCxt, &yymsp[-2].minor.yy57, &yymsp[0].minor.yy57)); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; - break; - case 326: /* pseudo_column ::= ROWTS */ - case 327: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==327); - case 329: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==329); - case 330: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==330); - case 331: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==331); - case 332: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==332); - case 333: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==333); - case 339: /* literal_func ::= NOW */ yytestcase(yyruleno==339); -{ yylhsminor.yy392 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy392 = yylhsminor.yy392; - break; - case 328: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy57, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy57)))); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; - break; - case 334: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 335: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==335); -{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy57, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy57, yymsp[-1].minor.yy600)); } - yymsp[-3].minor.yy392 = yylhsminor.yy392; - break; - case 336: /* function_expression ::= CAST NK_LP expression 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.yy448)); } - yymsp[-5].minor.yy392 = yylhsminor.yy392; - break; - case 338: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy57, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy57, NULL)); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; - break; - case 347: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy600 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy600 = yylhsminor.yy600; - break; - case 352: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 409: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==409); -{ yylhsminor.yy392 = createColumnNode(pCxt, &yymsp[-2].minor.yy57, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; - break; - case 353: /* predicate ::= expression compare_op expression */ - case 358: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==358); + case 326: /* expression ::= expression NK_BITAND expression */ { - 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.yy324, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 354: /* predicate ::= expression BETWEEN expression AND expression */ + case 327: /* expression ::= expression NK_BITOR expression */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); } - yymsp[-4].minor.yy392 = yylhsminor.yy392; + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 355: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 330: /* column_reference ::= column_name */ +{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy241, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy241)); } + yymsp[0].minor.yy442 = yylhsminor.yy442; + break; + case 331: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241, createColumnNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241)); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; + break; + case 332: /* pseudo_column ::= ROWTS */ + case 333: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==333); + case 335: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==335); + case 336: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==336); + case 337: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==337); + case 338: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==338); + case 339: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==339); + case 345: /* literal_func ::= NOW */ yytestcase(yyruleno==345); +{ yylhsminor.yy442 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy442 = yylhsminor.yy442; + break; + case 334: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy241)))); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; + break; + case 340: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 341: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==341); +{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy241, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-1].minor.yy368)); } + yymsp[-3].minor.yy442 = yylhsminor.yy442; + break; + case 342: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ +{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), yymsp[-1].minor.yy392)); } + yymsp[-5].minor.yy442 = yylhsminor.yy442; + break; + case 344: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy241, NULL)); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; + break; + case 353: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy368 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy368 = yylhsminor.yy368; + break; + case 358: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 416: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==416); +{ yylhsminor.yy442 = createColumnNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; + break; + case 359: /* predicate ::= expression compare_op expression */ + case 364: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==364); { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy412, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); } - yymsp[-5].minor.yy392 = yylhsminor.yy392; + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 356: /* predicate ::= expression IS NULL */ + case 360: /* predicate ::= expression BETWEEN expression AND expression */ { - 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)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy442); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy442), releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + yymsp[-4].minor.yy442 = yylhsminor.yy442; break; - case 357: /* predicate ::= expression IS NOT NULL */ + case 361: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - 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)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy442); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy442), releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); } - yymsp[-3].minor.yy392 = yylhsminor.yy392; + yymsp[-5].minor.yy442 = yylhsminor.yy442; break; - case 359: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy324 = OP_TYPE_LOWER_THAN; } - break; - case 360: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy324 = OP_TYPE_GREATER_THAN; } - break; - case 361: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy324 = OP_TYPE_LOWER_EQUAL; } - break; - case 362: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy324 = OP_TYPE_GREATER_EQUAL; } - break; - case 363: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy324 = OP_TYPE_NOT_EQUAL; } - break; - case 364: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy324 = OP_TYPE_EQUAL; } - break; - case 365: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy324 = OP_TYPE_LIKE; } - break; - case 366: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy324 = OP_TYPE_NOT_LIKE; } - break; - case 367: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy324 = OP_TYPE_MATCH; } - break; - case 368: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy324 = OP_TYPE_NMATCH; } - break; - case 369: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy324 = OP_TYPE_JSON_CONTAINS; } - break; - case 370: /* in_op ::= IN */ -{ yymsp[0].minor.yy324 = OP_TYPE_IN; } - break; - case 371: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy324 = OP_TYPE_NOT_IN; } - break; - case 372: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy600)); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; - break; - case 374: /* boolean_value_expression ::= NOT boolean_primary */ + case 362: /* predicate ::= expression IS NULL */ { - 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)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), NULL)); } - yymsp[-1].minor.yy392 = yylhsminor.yy392; + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 375: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 363: /* predicate ::= expression IS NOT NULL */ { - 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))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), NULL)); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + yymsp[-3].minor.yy442 = yylhsminor.yy442; break; - case 376: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 365: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy412 = OP_TYPE_LOWER_THAN; } + break; + case 366: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy412 = OP_TYPE_GREATER_THAN; } + break; + case 367: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy412 = OP_TYPE_LOWER_EQUAL; } + break; + case 368: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy412 = OP_TYPE_GREATER_EQUAL; } + break; + case 369: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy412 = OP_TYPE_NOT_EQUAL; } + break; + case 370: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy412 = OP_TYPE_EQUAL; } + break; + case 371: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy412 = OP_TYPE_LIKE; } + break; + case 372: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy412 = OP_TYPE_NOT_LIKE; } + break; + case 373: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy412 = OP_TYPE_MATCH; } + break; + case 374: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy412 = OP_TYPE_NMATCH; } + break; + case 375: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy412 = OP_TYPE_JSON_CONTAINS; } + break; + case 376: /* in_op ::= IN */ +{ yymsp[0].minor.yy412 = OP_TYPE_IN; } + break; + case 377: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy412 = OP_TYPE_NOT_IN; } + break; + case 378: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy368)); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; + break; + case 380: /* boolean_value_expression ::= NOT boolean_primary */ { - 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))); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy442), NULL)); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + yymsp[-1].minor.yy442 = yylhsminor.yy442; break; - case 383: /* 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; + case 381: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 386: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy392 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy57, &yymsp[0].minor.yy57); } - yymsp[-1].minor.yy392 = yylhsminor.yy392; + case 382: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy442); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy442); + yylhsminor.yy442 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); + } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 387: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy392 = createRealTableNode(pCxt, &yymsp[-3].minor.yy57, &yymsp[-1].minor.yy57, &yymsp[0].minor.yy57); } - yymsp[-3].minor.yy392 = yylhsminor.yy392; + case 390: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy442 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy442, yymsp[0].minor.yy442, NULL); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 388: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy392 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy392), &yymsp[0].minor.yy57); } - yymsp[-1].minor.yy392 = yylhsminor.yy392; + case 393: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy442 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } + yymsp[-1].minor.yy442 = yylhsminor.yy442; break; - case 390: /* alias_opt ::= */ -{ yymsp[1].minor.yy57 = nil_token; } + case 394: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy442 = createRealTableNode(pCxt, &yymsp[-3].minor.yy241, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } + yymsp[-3].minor.yy442 = yylhsminor.yy442; break; - case 391: /* alias_opt ::= table_alias */ -{ yylhsminor.yy57 = yymsp[0].minor.yy57; } - yymsp[0].minor.yy57 = yylhsminor.yy57; + case 395: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy442 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy442), &yymsp[0].minor.yy241); } + yymsp[-1].minor.yy442 = yylhsminor.yy442; break; - case 392: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy57 = yymsp[0].minor.yy57; } + case 397: /* alias_opt ::= */ +{ yymsp[1].minor.yy241 = nil_token; } break; - case 393: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 394: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==394); -{ yymsp[-2].minor.yy392 = yymsp[-1].minor.yy392; } + case 398: /* alias_opt ::= table_alias */ +{ yylhsminor.yy241 = yymsp[0].minor.yy241; } + yymsp[0].minor.yy241 = yylhsminor.yy241; break; - case 395: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy392 = createJoinTableNode(pCxt, yymsp[-4].minor.yy204, yymsp[-5].minor.yy392, yymsp[-2].minor.yy392, yymsp[0].minor.yy392); } - yymsp[-5].minor.yy392 = yylhsminor.yy392; + case 399: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy241 = yymsp[0].minor.yy241; } break; - case 396: /* join_type ::= */ -{ yymsp[1].minor.yy204 = JOIN_TYPE_INNER; } + case 400: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 401: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==401); +{ yymsp[-2].minor.yy442 = yymsp[-1].minor.yy442; } break; - case 397: /* join_type ::= INNER */ -{ yymsp[0].minor.yy204 = JOIN_TYPE_INNER; } + case 402: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy442 = createJoinTableNode(pCxt, yymsp[-4].minor.yy208, yymsp[-5].minor.yy442, yymsp[-2].minor.yy442, yymsp[0].minor.yy442); } + yymsp[-5].minor.yy442 = yylhsminor.yy442; break; - case 398: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 403: /* join_type ::= */ +{ yymsp[1].minor.yy208 = JOIN_TYPE_INNER; } + break; + case 404: /* join_type ::= INNER */ +{ yymsp[0].minor.yy208 = JOIN_TYPE_INNER; } + break; + case 405: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-11].minor.yy392 = createSelectStmt(pCxt, yymsp[-10].minor.yy481, yymsp[-9].minor.yy600, yymsp[-8].minor.yy392); - yymsp[-11].minor.yy392 = addWhereClause(pCxt, yymsp[-11].minor.yy392, yymsp[-7].minor.yy392); - yymsp[-11].minor.yy392 = addPartitionByClause(pCxt, yymsp[-11].minor.yy392, yymsp[-6].minor.yy600); - yymsp[-11].minor.yy392 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy392, yymsp[-2].minor.yy392); - yymsp[-11].minor.yy392 = addGroupByClause(pCxt, yymsp[-11].minor.yy392, yymsp[-1].minor.yy600); - yymsp[-11].minor.yy392 = addHavingClause(pCxt, yymsp[-11].minor.yy392, yymsp[0].minor.yy392); - yymsp[-11].minor.yy392 = addRangeClause(pCxt, yymsp[-11].minor.yy392, yymsp[-5].minor.yy392); - yymsp[-11].minor.yy392 = addEveryClause(pCxt, yymsp[-11].minor.yy392, yymsp[-4].minor.yy392); - yymsp[-11].minor.yy392 = addFillClause(pCxt, yymsp[-11].minor.yy392, yymsp[-3].minor.yy392); + yymsp[-11].minor.yy442 = createSelectStmt(pCxt, yymsp[-10].minor.yy197, yymsp[-9].minor.yy368, yymsp[-8].minor.yy442); + yymsp[-11].minor.yy442 = addWhereClause(pCxt, yymsp[-11].minor.yy442, yymsp[-7].minor.yy442); + yymsp[-11].minor.yy442 = addPartitionByClause(pCxt, yymsp[-11].minor.yy442, yymsp[-6].minor.yy368); + yymsp[-11].minor.yy442 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy442, yymsp[-2].minor.yy442); + yymsp[-11].minor.yy442 = addGroupByClause(pCxt, yymsp[-11].minor.yy442, yymsp[-1].minor.yy368); + yymsp[-11].minor.yy442 = addHavingClause(pCxt, yymsp[-11].minor.yy442, yymsp[0].minor.yy442); + yymsp[-11].minor.yy442 = addRangeClause(pCxt, yymsp[-11].minor.yy442, yymsp[-5].minor.yy442); + yymsp[-11].minor.yy442 = addEveryClause(pCxt, yymsp[-11].minor.yy442, yymsp[-4].minor.yy442); + yymsp[-11].minor.yy442 = addFillClause(pCxt, yymsp[-11].minor.yy442, yymsp[-3].minor.yy442); } break; - case 401: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy481 = false; } + case 408: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy197 = false; } break; - case 402: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy600 = NULL; } + case 409: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy368 = NULL; } break; - case 407: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy392 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy392), &yymsp[0].minor.yy57); } - yymsp[-1].minor.yy392 = yylhsminor.yy392; + case 414: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy442 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy442), &yymsp[0].minor.yy241); } + yymsp[-1].minor.yy442 = yylhsminor.yy442; break; - case 408: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy392 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), &yymsp[0].minor.yy57); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 415: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy442 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), &yymsp[0].minor.yy241); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 413: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 430: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==430); - case 446: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==446); -{ yymsp[-2].minor.yy600 = yymsp[0].minor.yy600; } + case 420: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 437: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==437); + case 453: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==453); +{ yymsp[-2].minor.yy368 = yymsp[0].minor.yy368; } break; - case 415: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy392 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy392), releaseRawExprNode(pCxt, yymsp[-1].minor.yy392)); } + case 422: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy442 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), releaseRawExprNode(pCxt, yymsp[-1].minor.yy442)); } break; - case 416: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ -{ yymsp[-3].minor.yy392 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy392)); } + case 423: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ +{ yymsp[-3].minor.yy442 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy442)); } break; - case 417: /* twindow_clause_opt ::= INTERVAL NK_LP 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); } + case 424: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy442 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), NULL, yymsp[-1].minor.yy442, yymsp[0].minor.yy442); } break; - case 418: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA 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); } + case 425: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy442 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy442), releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), yymsp[-1].minor.yy442, yymsp[0].minor.yy442); } break; - case 420: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - case 438: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==438); -{ yymsp[-3].minor.yy392 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy392); } + case 427: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + case 445: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==445); +{ yymsp[-3].minor.yy442 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy442); } break; - case 422: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy392 = createFillNode(pCxt, yymsp[-1].minor.yy270, NULL); } + case 429: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy442 = createFillNode(pCxt, yymsp[-1].minor.yy388, NULL); } break; - case 423: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy392 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy600)); } + case 430: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy442 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy368)); } break; - case 424: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy270 = FILL_MODE_NONE; } + case 431: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy388 = FILL_MODE_NONE; } break; - case 425: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy270 = FILL_MODE_PREV; } + case 432: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy388 = FILL_MODE_PREV; } break; - case 426: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy270 = FILL_MODE_NULL; } + case 433: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy388 = FILL_MODE_NULL; } break; - case 427: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy270 = FILL_MODE_LINEAR; } + case 434: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy388 = FILL_MODE_LINEAR; } break; - case 428: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy270 = FILL_MODE_NEXT; } + case 435: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy388 = FILL_MODE_NEXT; } break; - case 431: /* group_by_list ::= expression */ -{ yylhsminor.yy600 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } - yymsp[0].minor.yy600 = yylhsminor.yy600; + case 438: /* group_by_list ::= expression */ +{ yylhsminor.yy368 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); } + yymsp[0].minor.yy368 = yylhsminor.yy368; break; - case 432: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy600 = addNodeToList(pCxt, yymsp[-2].minor.yy600, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } - yymsp[-2].minor.yy600 = yylhsminor.yy600; + case 439: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy368 = addNodeToList(pCxt, yymsp[-2].minor.yy368, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy442))); } + yymsp[-2].minor.yy368 = yylhsminor.yy368; break; - case 436: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ -{ yymsp[-5].minor.yy392 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy392), releaseRawExprNode(pCxt, yymsp[-1].minor.yy392)); } + case 443: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ +{ yymsp[-5].minor.yy442 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy442), releaseRawExprNode(pCxt, yymsp[-1].minor.yy442)); } break; - case 439: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 446: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy392 = addOrderByClause(pCxt, yymsp[-3].minor.yy392, yymsp[-2].minor.yy600); - yylhsminor.yy392 = addSlimitClause(pCxt, yylhsminor.yy392, yymsp[-1].minor.yy392); - yylhsminor.yy392 = addLimitClause(pCxt, yylhsminor.yy392, yymsp[0].minor.yy392); + yylhsminor.yy442 = addOrderByClause(pCxt, yymsp[-3].minor.yy442, yymsp[-2].minor.yy368); + yylhsminor.yy442 = addSlimitClause(pCxt, yylhsminor.yy442, yymsp[-1].minor.yy442); + yylhsminor.yy442 = addLimitClause(pCxt, yylhsminor.yy442, yymsp[0].minor.yy442); } - yymsp[-3].minor.yy392 = yylhsminor.yy392; + yymsp[-3].minor.yy442 = yylhsminor.yy442; break; - case 441: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy392 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy392, yymsp[0].minor.yy392); } - yymsp[-3].minor.yy392 = yylhsminor.yy392; + case 448: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy442 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy442, yymsp[0].minor.yy442); } + yymsp[-3].minor.yy442 = yylhsminor.yy442; break; - case 442: /* query_expression_body ::= query_expression_body UNION query_expression_body */ -{ yylhsminor.yy392 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy392, yymsp[0].minor.yy392); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 449: /* query_expression_body ::= query_expression_body UNION query_expression_body */ +{ yylhsminor.yy442 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy442, yymsp[0].minor.yy442); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 444: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ -{ yymsp[-5].minor.yy392 = yymsp[-4].minor.yy392; } - yy_destructor(yypParser,356,&yymsp[-3].minor); - yy_destructor(yypParser,357,&yymsp[-2].minor); - yy_destructor(yypParser,358,&yymsp[-1].minor); + case 451: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ +{ yymsp[-5].minor.yy442 = yymsp[-4].minor.yy442; } + yy_destructor(yypParser,359,&yymsp[-3].minor); + yy_destructor(yypParser,360,&yymsp[-2].minor); + yy_destructor(yypParser,361,&yymsp[-1].minor); break; - case 448: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 452: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==452); -{ yymsp[-1].minor.yy392 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 455: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 459: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==459); +{ yymsp[-1].minor.yy442 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 449: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 453: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==453); -{ yymsp[-3].minor.yy392 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 456: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 460: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==460); +{ yymsp[-3].minor.yy442 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 450: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 454: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==454); -{ yymsp[-3].minor.yy392 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 457: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 461: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==461); +{ yymsp[-3].minor.yy442 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 455: /* 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; + case 462: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy442 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy442); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 459: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy392 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), yymsp[-1].minor.yy162, yymsp[0].minor.yy529); } - yymsp[-2].minor.yy392 = yylhsminor.yy392; + case 466: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy442 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy442), yymsp[-1].minor.yy362, yymsp[0].minor.yy417); } + yymsp[-2].minor.yy442 = yylhsminor.yy442; break; - case 460: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy162 = ORDER_ASC; } + case 467: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy362 = ORDER_ASC; } break; - case 461: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy162 = ORDER_ASC; } + case 468: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy362 = ORDER_ASC; } break; - case 462: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy162 = ORDER_DESC; } + case 469: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy362 = ORDER_DESC; } break; - case 463: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy529 = NULL_ORDER_DEFAULT; } + case 470: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy417 = NULL_ORDER_DEFAULT; } break; - case 464: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy529 = NULL_ORDER_FIRST; } + case 471: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy417 = NULL_ORDER_FIRST; } break; - case 465: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy529 = NULL_ORDER_LAST; } + case 472: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy417 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/mockCatalog.cpp b/source/libs/parser/test/mockCatalog.cpp index 0213a3a854..8802f91bdf 100644 --- a/source/libs/parser/test/mockCatalog.cpp +++ b/source/libs/parser/test/mockCatalog.cpp @@ -261,6 +261,11 @@ int32_t __catalogGetDnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArra return g_mockCatalogService->catalogGetDnodeList(pDnodeList); } +int32_t __catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg** pCfg) { + *pCfg = (STableCfg*)taosMemoryCalloc(1, sizeof(STableCfg)); + return 0; +} + void initMetaDataEnv() { g_mockCatalogService.reset(new MockCatalogService()); @@ -279,6 +284,7 @@ void initMetaDataEnv() { stub.set(catalogRemoveTableMeta, __catalogRemoveTableMeta); stub.set(catalogGetTableIndex, __catalogGetTableIndex); stub.set(catalogGetDnodeList, __catalogGetDnodeList); + stub.set(catalogRefreshGetTableCfg, __catalogRefreshGetTableCfg); // { // AddrAny any("libcatalog.so"); // std::map result; diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp index 7915c32437..1f7657146b 100644 --- a/source/libs/parser/test/mockCatalogService.cpp +++ b/source/libs/parser/test/mockCatalogService.cpp @@ -199,6 +199,9 @@ class MockCatalogServiceImpl { if (TSDB_CODE_SUCCESS == code && pCatalogReq->dNodeRequired) { code = catalogGetDnodeList(&pMetaData->pDnodeList); } + if (TSDB_CODE_SUCCESS == code) { + code = getAllTableCfg(pCatalogReq->pTableCfg, &pMetaData->pTableCfg); + } return code; } @@ -545,6 +548,20 @@ class MockCatalogServiceImpl { return TSDB_CODE_SUCCESS; } + int32_t getAllTableCfg(SArray* pTableCfgReq, SArray** pTableCfgData) const { + if (NULL != pTableCfgReq) { + int32_t ntables = taosArrayGetSize(pTableCfgReq); + *pTableCfgData = taosArrayInit(ntables, sizeof(SMetaRes)); + for (int32_t i = 0; i < ntables; ++i) { + SMetaRes res = {0}; + res.pRes = taosMemoryCalloc(1, sizeof(STableCfg)); + res.code = TSDB_CODE_SUCCESS; + taosArrayPush(*pTableCfgData, &res); + } + } + return TSDB_CODE_SUCCESS; + } + uint64_t id_; std::unique_ptr builder_; DbMetaCache meta_; diff --git a/source/libs/parser/test/parInitialATest.cpp b/source/libs/parser/test/parInitialATest.cpp index 021348dcc7..ee9dae2a01 100644 --- a/source/libs/parser/test/parInitialATest.cpp +++ b/source/libs/parser/test/parInitialATest.cpp @@ -121,7 +121,7 @@ TEST_F(ParserInitialATest, alterSTable) { int32_t len = snprintf(expect.name, sizeof(expect.name), "0.test.%s", pTbname); expect.name[len] = '\0'; expect.alterType = alterType; -// expect.ttl = ttl; + // expect.ttl = ttl; if (nullptr != pComment) { expect.comment = strdup(pComment); expect.commentLen = strlen(pComment); @@ -180,9 +180,9 @@ TEST_F(ParserInitialATest, alterSTable) { tFreeSMAltertbReq(&req); }); -// setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_OPTIONS, 0, nullptr, 0, 0, nullptr, nullptr, 10); -// run("ALTER TABLE st1 TTL 10"); -// clearAlterStbReq(); + // setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_OPTIONS, 0, nullptr, 0, 0, nullptr, nullptr, 10); + // run("ALTER TABLE st1 TTL 10"); + // clearAlterStbReq(); setAlterStbReqFunc("st1", TSDB_ALTER_TABLE_UPDATE_OPTIONS, 0, nullptr, 0, 0, nullptr, "test"); run("ALTER TABLE st1 COMMENT 'test'"); @@ -381,9 +381,48 @@ TEST_F(ParserInitialATest, alterTableSemanticCheck) { TEST_F(ParserInitialATest, alterUser) { useDb("root", "test"); - run("ALTER user wxy PASS '123456'"); + SAlterUserReq expect = {0}; - run("ALTER user wxy privilege 'write'"); + auto clearAlterUserReq = [&]() { memset(&expect, 0, sizeof(SAlterUserReq)); }; + + auto setAlterUserReq = [&](const char* pUser, int8_t alterType, const char* pPass = nullptr, int8_t sysInfo = 0, + int8_t enable = 0) { + strcpy(expect.user, pUser); + expect.alterType = alterType; + expect.superUser = 0; + expect.sysInfo = sysInfo; + expect.enable = enable; + if (nullptr != pPass) { + strcpy(expect.pass, pPass); + } + strcpy(expect.dbname, "test"); + }; + + setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { + ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_ALTER_USER_STMT); + SAlterUserReq req = {0}; + ASSERT_TRUE(TSDB_CODE_SUCCESS == tDeserializeSAlterUserReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req)); + + ASSERT_EQ(req.alterType, expect.alterType); + ASSERT_EQ(req.superUser, expect.superUser); + ASSERT_EQ(req.sysInfo, expect.sysInfo); + ASSERT_EQ(req.enable, expect.enable); + ASSERT_EQ(std::string(req.user), std::string(expect.user)); + ASSERT_EQ(std::string(req.pass), std::string(expect.pass)); + ASSERT_EQ(std::string(req.dbname), std::string(expect.dbname)); + }); + + setAlterUserReq("wxy", TSDB_ALTER_USER_PASSWD, "123456"); + run("ALTER USER wxy PASS '123456'"); + clearAlterUserReq(); + + setAlterUserReq("wxy", TSDB_ALTER_USER_ENABLE, nullptr, 0, 1); + run("ALTER USER wxy ENABLE 1"); + clearAlterUserReq(); + + setAlterUserReq("wxy", TSDB_ALTER_USER_SYSINFO, nullptr, 1); + run("ALTER USER wxy SYSINFO 1"); + clearAlterUserReq(); } TEST_F(ParserInitialATest, balanceVgroup) { diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp index d188744adf..7de92bba0c 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -370,7 +370,7 @@ TEST_F(ParserInitialCTest, createStable) { expect.delay2 = delay2; expect.watermark1 = watermark1; expect.watermark2 = watermark2; -// expect.ttl = ttl; + // expect.ttl = ttl; if (nullptr != pComment) { expect.comment = strdup(pComment); expect.commentLen = strlen(pComment); @@ -414,7 +414,7 @@ TEST_F(ParserInitialCTest, createStable) { ASSERT_EQ(req.ttl, expect.ttl); ASSERT_EQ(req.numOfColumns, expect.numOfColumns); ASSERT_EQ(req.numOfTags, expect.numOfTags); -// ASSERT_EQ(req.commentLen, expect.commentLen); + // ASSERT_EQ(req.commentLen, expect.commentLen); ASSERT_EQ(req.ast1Len, expect.ast1Len); ASSERT_EQ(req.ast2Len, expect.ast2Len); @@ -621,10 +621,11 @@ TEST_F(ParserInitialCTest, createTopic) { auto clearCreateTopicReq = [&]() { memset(&expect, 0, sizeof(SCMCreateTopicReq)); }; auto setCreateTopicReqFunc = [&](const char* pTopicName, int8_t igExists, const char* pSql, const char* pAst, - const char* pDbName = nullptr, const char* pTbname = nullptr) { + const char* pDbName = nullptr, const char* pTbname = nullptr, int8_t withMeta = 0) { snprintf(expect.name, sizeof(expect.name), "0.%s", pTopicName); expect.igExists = igExists; expect.sql = (char*)pSql; + expect.withMeta = withMeta; if (nullptr != pTbname) { expect.subType = TOPIC_SUB_TYPE__TABLE; snprintf(expect.subStbName, sizeof(expect.subStbName), "0.%s.%s", pDbName, pTbname); @@ -647,6 +648,7 @@ TEST_F(ParserInitialCTest, createTopic) { ASSERT_EQ(req.igExists, expect.igExists); ASSERT_EQ(req.subType, expect.subType); ASSERT_EQ(std::string(req.sql), std::string(expect.sql)); + ASSERT_EQ(req.withMeta, expect.withMeta); switch (expect.subType) { case TOPIC_SUB_TYPE__DB: ASSERT_EQ(std::string(req.subDbName), std::string(expect.subDbName)); @@ -675,15 +677,55 @@ TEST_F(ParserInitialCTest, createTopic) { run("CREATE TOPIC tp1 AS DATABASE test"); clearCreateTopicReq(); + setCreateTopicReqFunc("tp1", 0, "create topic tp1 with meta as database test", nullptr, "test", nullptr, 1); + run("CREATE TOPIC tp1 WITH META AS DATABASE test"); + clearCreateTopicReq(); + setCreateTopicReqFunc("tp1", 1, "create topic if not exists tp1 as stable st1", nullptr, "test", "st1"); run("CREATE TOPIC IF NOT EXISTS tp1 AS STABLE st1"); clearCreateTopicReq(); + + setCreateTopicReqFunc("tp1", 1, "create topic if not exists tp1 with meta as stable st1", nullptr, "test", "st1", 1); + run("CREATE TOPIC IF NOT EXISTS tp1 WITH META AS STABLE st1"); + clearCreateTopicReq(); } TEST_F(ParserInitialCTest, createUser) { useDb("root", "test"); + SCreateUserReq expect = {0}; + + auto clearCreateUserReq = [&]() { memset(&expect, 0, sizeof(SCreateUserReq)); }; + + auto setCreateUserReq = [&](const char* pUser, const char* pPass, int8_t sysInfo = 1) { + strcpy(expect.user, pUser); + strcpy(expect.pass, pPass); + expect.createType = 0; + expect.superUser = 0; + expect.sysInfo = sysInfo; + expect.enable = 1; + }; + + setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { + ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_CREATE_USER_STMT); + SCreateUserReq req = {0}; + ASSERT_TRUE(TSDB_CODE_SUCCESS == tDeserializeSCreateUserReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req)); + + ASSERT_EQ(req.createType, expect.createType); + ASSERT_EQ(req.superUser, expect.superUser); + ASSERT_EQ(req.sysInfo, expect.sysInfo); + ASSERT_EQ(req.enable, expect.enable); + ASSERT_EQ(std::string(req.user), std::string(expect.user)); + ASSERT_EQ(std::string(req.pass), std::string(expect.pass)); + }); + + setCreateUserReq("wxy", "123456"); run("CREATE USER wxy PASS '123456'"); + clearCreateUserReq(); + + setCreateUserReq("wxy1", "a123456", 1); + run("CREATE USER wxy1 PASS 'a123456' SYSINFO 1"); + clearCreateUserReq(); } } // namespace ParserTest diff --git a/source/libs/parser/test/parInitialDTest.cpp b/source/libs/parser/test/parInitialDTest.cpp index c2039718d0..870afa694a 100644 --- a/source/libs/parser/test/parInitialDTest.cpp +++ b/source/libs/parser/test/parInitialDTest.cpp @@ -132,7 +132,31 @@ TEST_F(ParserInitialDTest, dropDnode) { TEST_F(ParserInitialDTest, dropIndex) { useDb("root", "test"); - run("DROP index index1 on t1"); + SMDropSmaReq expect = {0}; + + auto clearDropSmaReq = [&]() { memset(&expect, 0, sizeof(SMDropSmaReq)); }; + + auto setDropSmaReq = [&](const char* pName, int8_t igNotExists = 0) { + sprintf(expect.name, "0.test.%s", pName); + expect.igNotExists = igNotExists; + }; + + setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { + ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_DROP_INDEX_STMT); + SMDropSmaReq req = {0}; + ASSERT_TRUE(TSDB_CODE_SUCCESS == tDeserializeSMDropSmaReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req)); + + ASSERT_EQ(std::string(req.name), std::string(expect.name)); + ASSERT_EQ(req.igNotExists, expect.igNotExists); + }); + + setDropSmaReq("index1"); + run("DROP INDEX index1"); + clearDropSmaReq(); + + setDropSmaReq("index2", 1); + run("DROP INDEX IF EXISTS index2"); + clearDropSmaReq(); } TEST_F(ParserInitialDTest, dropMnode) { diff --git a/source/libs/parser/test/parSelectTest.cpp b/source/libs/parser/test/parSelectTest.cpp index 11e09cd83d..dd154427c6 100644 --- a/source/libs/parser/test/parSelectTest.cpp +++ b/source/libs/parser/test/parSelectTest.cpp @@ -58,6 +58,8 @@ TEST_F(ParserSelectTest, expression) { run("SELECT ts > 0, c1 < 20 and c2 = 'qaz' FROM t1"); run("SELECT ts > 0, c1 between 10 and 20 and c2 = 'qaz' FROM t1"); + + run("SELECT c1 | 10, c2 & 20, c4 | c5 FROM t1"); } TEST_F(ParserSelectTest, condition) { @@ -388,4 +390,10 @@ TEST_F(ParserSelectTest, informationSchema) { run("SELECT * FROM information_schema.user_databases WHERE name = 'information_schema'"); } +TEST_F(ParserSelectTest, withoutFrom) { + useDb("root", "test"); + + run("SELECT 1"); +} + } // namespace ParserTest diff --git a/source/libs/parser/test/parShowToUse.cpp b/source/libs/parser/test/parShowToUse.cpp index 1a68e80872..81a09114e3 100644 --- a/source/libs/parser/test/parShowToUse.cpp +++ b/source/libs/parser/test/parShowToUse.cpp @@ -45,7 +45,7 @@ TEST_F(ParserShowToUseTest, showCreateSTable) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_SHOW_CREATE_STABLE_STMT); ASSERT_EQ(pQuery->execMode, QUERY_EXEC_MODE_LOCAL); ASSERT_TRUE(pQuery->haveResultSet); - ASSERT_NE(((SShowCreateTableStmt*)pQuery->pRoot)->pMeta, nullptr); + ASSERT_NE(((SShowCreateTableStmt*)pQuery->pRoot)->pCfg, nullptr); }); run("SHOW CREATE STABLE st1"); @@ -58,7 +58,7 @@ TEST_F(ParserShowToUseTest, showCreateTable) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_SHOW_CREATE_TABLE_STMT); ASSERT_EQ(pQuery->execMode, QUERY_EXEC_MODE_LOCAL); ASSERT_TRUE(pQuery->haveResultSet); - ASSERT_NE(((SShowCreateTableStmt*)pQuery->pRoot)->pMeta, nullptr); + ASSERT_NE(((SShowCreateTableStmt*)pQuery->pRoot)->pCfg, nullptr); }); run("SHOW CREATE TABLE t1"); diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index c7490faa0c..eafc6ba37a 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -56,8 +56,12 @@ static EDealRes doRewriteExpr(SNode** pNode, void* pContext) { pCol->node.resType = pToBeRewrittenExpr->resType; strcpy(pCol->node.aliasName, pToBeRewrittenExpr->aliasName); strcpy(pCol->colName, ((SExprNode*)pExpr)->aliasName); - if (QUERY_NODE_FUNCTION == nodeType(pExpr) && FUNCTION_TYPE_WSTARTTS == ((SFunctionNode*)pExpr)->funcType) { - pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID; + if (QUERY_NODE_FUNCTION == nodeType(pExpr)) { + if (FUNCTION_TYPE_WSTARTTS == ((SFunctionNode*)pExpr)->funcType) { + pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID; + } else if (FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pExpr)->funcType) { + pCol->colType = COLUMN_TYPE_TBNAME; + } } nodesDestroyNode(*pNode); *pNode = (SNode*)pCol; @@ -292,6 +296,59 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect return code; } +static int32_t createColumnByLastRow(SNodeList* pFuncs, SNodeList** pOutput) { + int32_t code = TSDB_CODE_SUCCESS; + SNodeList* pCols = NULL; + SNode* pFunc = NULL; + FOREACH(pFunc, pFuncs) { + SFunctionNode* pLastRow = (SFunctionNode*)pFunc; + SColumnNode* pCol = (SColumnNode*)nodesListGetNode(pLastRow->pParameterList, 0); + snprintf(pCol->colName, sizeof(pCol->colName), "%s", pLastRow->node.aliasName); + snprintf(pCol->node.aliasName, sizeof(pCol->colName), "%s", pLastRow->node.aliasName); + NODES_CLEAR_LIST(pLastRow->pParameterList); + code = nodesListMakeStrictAppend(&pCols, (SNode*)pCol); + if (TSDB_CODE_SUCCESS != code) { + break; + } + } + if (TSDB_CODE_SUCCESS == code) { + *pOutput = pCols; + } else { + nodesDestroyList(pCols); + } + return code; +} + +static int32_t createLastRowScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable, + SLogicNode** pLogicNode) { + SScanLogicNode* pScan = NULL; + int32_t code = makeScanLogicNode(pCxt, pRealTable, false, (SLogicNode**)&pScan); + + SNodeList* pFuncs = NULL; + if (TSDB_CODE_SUCCESS == code) { + pScan->scanType = SCAN_TYPE_LAST_ROW; + code = nodesCollectFuncs(pSelect, SQL_CLAUSE_FROM, fmIsLastRowFunc, &pFuncs); + } + if (TSDB_CODE_SUCCESS == code) { + code = rewriteExprsForSelect(pFuncs, pSelect, SQL_CLAUSE_FROM); + } + if (TSDB_CODE_SUCCESS == code) { + code = createColumnByLastRow(pFuncs, &pScan->pScanCols); + } + if (TSDB_CODE_SUCCESS == code) { + code = createColumnByRewriteExprs(pScan->pScanCols, &pScan->node.pTargets); + } + + if (TSDB_CODE_SUCCESS == code) { + *pLogicNode = (SLogicNode*)pScan; + } else { + nodesDestroyNode((SNode*)pScan); + } + nodesDestroyList(pFuncs); + + return code; +} + static int32_t createSubqueryLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, STempTableNode* pTable, SLogicNode** pLogicNode) { return createQueryLogicNode(pCxt, pTable->pSubquery, pLogicNode); @@ -363,7 +420,11 @@ static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pS SLogicNode** pLogicNode) { switch (nodeType(pTable)) { case QUERY_NODE_REAL_TABLE: - return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode); + if (pSelect->hasLastRowFunc) { + return createLastRowScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode); + } else { + return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode); + } case QUERY_NODE_TEMP_TABLE: return createSubqueryLogicNode(pCxt, pSelect, (STempTableNode*)pTable, pLogicNode); case QUERY_NODE_JOIN_TABLE: @@ -840,7 +901,12 @@ static int32_t createDistinctLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe return code; } -static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { +static int32_t createSelectWithoutFromLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, + SLogicNode** pLogicNode) { + return createProjectLogicNode(pCxt, pSelect, pLogicNode); +} + +static int32_t createSelectFromLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { SLogicNode* pRoot = NULL; int32_t code = createLogicNodeByTable(pCxt, pSelect, pSelect->pFromTable, &pRoot); if (TSDB_CODE_SUCCESS == code) { @@ -880,6 +946,14 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele return code; } +static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { + if (NULL == pSelect->pFromTable) { + return createSelectWithoutFromLogicNode(pCxt, pSelect, pLogicNode); + } else { + return createSelectFromLogicNode(pCxt, pSelect, pLogicNode); + } +} + static int32_t createSetOpRootLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator, FCreateSetOpLogicNode func, SLogicNode** pRoot) { return createRootLogicNode(pCxt, pSetOperator, pSetOperator->precision, (FCreateLogicNode)func, pRoot); diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 5249bd913d..6a71b1370e 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -79,7 +79,8 @@ static SLogicNode* optFindPossibleNode(SLogicNode* pNode, FMayBeOptimized func) EDealRes osdHaveNormalColImpl(SNode* pNode, void* pContext) { if (QUERY_NODE_COLUMN == nodeType(pNode)) { - *((bool*)pContext) = (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType); + // *((bool*)pContext) = (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType); + *((bool*)pContext) = true; return *((bool*)pContext) ? DEAL_RES_END : DEAL_RES_IGNORE_CHILD; } return DEAL_RES_CONTINUE; @@ -98,11 +99,6 @@ static bool osdMayBeOptimized(SLogicNode* pNode) { if (QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(pNode)) { return false; } - // todo: release after function splitting - if (TSDB_SUPER_TABLE == ((SScanLogicNode*)pNode)->tableType && - SCAN_TYPE_STREAM != ((SScanLogicNode*)pNode)->scanType) { - return false; - } if (NULL == pNode->pParent || (QUERY_NODE_LOGIC_PLAN_WINDOW != nodeType(pNode->pParent) && QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode->pParent) && QUERY_NODE_LOGIC_PLAN_PARTITION != nodeType(pNode->pParent))) { @@ -293,16 +289,22 @@ static int32_t cpdCondAppend(SNode** pCond, SNode** pAdditionalCond) { return code; } -static int32_t cpdCalcTimeRange(SScanLogicNode* pScan, SNode** pPrimaryKeyCond, SNode** pOtherCond) { - bool isStrict = false; - int32_t code = filterGetTimeRange(*pPrimaryKeyCond, &pScan->scanRange, &isStrict); - if (TSDB_CODE_SUCCESS == code) { - if (isStrict) { - nodesDestroyNode(*pPrimaryKeyCond); - } else { - code = cpdCondAppend(pOtherCond, pPrimaryKeyCond); +static int32_t cpdCalcTimeRange(SOptimizeContext* pCxt, SScanLogicNode* pScan, SNode** pPrimaryKeyCond, + SNode** pOtherCond) { + int32_t code = TSDB_CODE_SUCCESS; + if (pCxt->pPlanCxt->topicQuery || pCxt->pPlanCxt->streamQuery) { + code = cpdCondAppend(pOtherCond, pPrimaryKeyCond); + } else { + bool isStrict = false; + code = filterGetTimeRange(*pPrimaryKeyCond, &pScan->scanRange, &isStrict); + if (TSDB_CODE_SUCCESS == code) { + if (isStrict) { + nodesDestroyNode(*pPrimaryKeyCond); + } else { + code = cpdCondAppend(pOtherCond, pPrimaryKeyCond); + } + *pPrimaryKeyCond = NULL; } - *pPrimaryKeyCond = NULL; } return code; } @@ -344,7 +346,7 @@ static int32_t cpdOptimizeScanCondition(SOptimizeContext* pCxt, SScanLogicNode* SNode* pOtherCond = NULL; int32_t code = nodesPartitionCond(&pScan->node.pConditions, &pPrimaryKeyCond, &pTagCond, &pOtherCond); if (TSDB_CODE_SUCCESS == code && NULL != pPrimaryKeyCond) { - code = cpdCalcTimeRange(pScan, &pPrimaryKeyCond, &pOtherCond); + code = cpdCalcTimeRange(pCxt, pScan, &pPrimaryKeyCond, &pOtherCond); } if (TSDB_CODE_SUCCESS == code && NULL != pTagCond) { code = cpdApplyTagIndex(pScan, &pTagCond, &pOtherCond); @@ -769,7 +771,7 @@ static bool smaOptMayBeOptimized(SLogicNode* pNode) { } SScanLogicNode* pScan = (SScanLogicNode*)pNode; - if (0 == pScan->interval || NULL == pScan->pSmaIndexes || NULL != pScan->node.pConditions) { + if (NULL == pScan->pSmaIndexes || NULL != pScan->node.pConditions) { return false; } @@ -1042,7 +1044,7 @@ static int32_t smaOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) static EDealRes partTagsOptHasColImpl(SNode* pNode, void* pContext) { if (QUERY_NODE_COLUMN == nodeType(pNode)) { - if (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType) { + if (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType && COLUMN_TYPE_TBNAME != ((SColumnNode*)pNode)->colType) { *(bool*)pContext = true; return DEAL_RES_END; } @@ -1057,9 +1059,9 @@ static bool partTagsOptHasCol(SNodeList* pPartKeys) { } static bool partTagsIsOptimizableNode(SLogicNode* pNode) { - return ((QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode) /*|| + return ((QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode) || (QUERY_NODE_LOGIC_PLAN_AGG == nodeType(pNode) && NULL != ((SAggLogicNode*)pNode)->pGroupKeys && - NULL != ((SAggLogicNode*)pNode)->pAggFuncs)*/) && + NULL != ((SAggLogicNode*)pNode)->pAggFuncs)) && 1 == LIST_LENGTH(pNode->pChildren) && QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(nodesListGetNode(pNode->pChildren, 0))); } @@ -1080,6 +1082,28 @@ static bool partTagsOptMayBeOptimized(SLogicNode* pNode) { return !partTagsOptHasCol(partTagsGetPartKeys(pNode)); } +static EDealRes partTagsOptRebuildTbanmeImpl(SNode** pNode, void* pContext) { + if (QUERY_NODE_COLUMN == nodeType(*pNode) && COLUMN_TYPE_TBNAME == ((SColumnNode*)*pNode)->colType) { + SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); + if (NULL == pFunc) { + *(int32_t*)pContext = TSDB_CODE_OUT_OF_MEMORY; + return DEAL_RES_ERROR; + } + strcpy(pFunc->functionName, "tbname"); + pFunc->funcType = FUNCTION_TYPE_TBNAME; + nodesDestroyNode(*pNode); + *pNode = (SNode*)pFunc; + return DEAL_RES_IGNORE_CHILD; + } + return DEAL_RES_CONTINUE; +} + +static int32_t partTagsOptRebuildTbanme(SNodeList* pPartKeys) { + int32_t code = TSDB_CODE_SUCCESS; + nodesRewriteExprs(pPartKeys, partTagsOptRebuildTbanmeImpl, &code); + return code; +} + static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { SLogicNode* pNode = optFindPossibleNode(pLogicSubplan->pNode, partTagsOptMayBeOptimized); if (NULL == pNode) { @@ -1096,7 +1120,18 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub nodesDestroyNode((SNode*)pNode); } } else { - TSWAP(((SAggLogicNode*)pNode)->pGroupKeys, pScan->pPartTags); + SNode* pGroupKey = NULL; + FOREACH(pGroupKey, ((SAggLogicNode*)pNode)->pGroupKeys) { + code = nodesListMakeStrictAppend( + &pScan->pPartTags, nodesCloneNode(nodesListGetNode(((SGroupingSetNode*)pGroupKey)->pParameterList, 0))); + if (TSDB_CODE_SUCCESS != code) { + break; + } + } + NODES_DESTORY_LIST(((SAggLogicNode*)pNode)->pGroupKeys); + } + if (TSDB_CODE_SUCCESS == code) { + code = partTagsOptRebuildTbanme(pScan->pPartTags); } return code; } @@ -1184,7 +1219,7 @@ static const SOptimizeRule optimizeRuleSet[] = { {.pName = "ConditionPushDown", .optimizeFunc = cpdOptimize}, {.pName = "OrderByPrimaryKey", .optimizeFunc = opkOptimize}, {.pName = "SmaIndex", .optimizeFunc = smaOptimize}, - {.pName = "PartitionByTags", .optimizeFunc = partTagsOptimize}, + // {.pName = "PartitionTags", .optimizeFunc = partTagsOptimize}, {.pName = "EliminateProject", .optimizeFunc = eliminateProjOptimize} }; // clang-format on diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index ff78370c52..37765edfc5 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -462,6 +462,8 @@ static ENodeType getScanOperatorType(EScanType scanType) { return QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN; case SCAN_TYPE_BLOCK_INFO: return QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN; + case SCAN_TYPE_LAST_ROW: + return QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN; default: break; } @@ -559,6 +561,7 @@ static int32_t createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, switch (pScanLogicNode->scanType) { case SCAN_TYPE_TAG: case SCAN_TYPE_BLOCK_INFO: + case SCAN_TYPE_LAST_ROW: return createSimpleScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode); case SCAN_TYPE_TABLE: return createTableScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode); @@ -732,7 +735,7 @@ static int32_t rewritePrecalcExprs(SPhysiPlanContext* pCxt, SNodeList* pList, SN SRewritePrecalcExprsCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pPrecalcExprs = *pPrecalcExprs}; nodesRewriteExprs(*pRewrittenList, doRewritePrecalcExprs, &cxt); if (0 == LIST_LENGTH(cxt.pPrecalcExprs) || TSDB_CODE_SUCCESS != cxt.errCode) { - DESTORY_LIST(*pPrecalcExprs); + NODES_DESTORY_LIST(*pPrecalcExprs); } return cxt.errCode; } @@ -914,8 +917,16 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild pProject->slimit = pProjectLogicNode->slimit; pProject->soffset = pProjectLogicNode->soffset; - int32_t code = setListSlotId(pCxt, ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc->dataBlockId, - -1, pProjectLogicNode->pProjections, &pProject->pProjections); + int32_t code = TSDB_CODE_SUCCESS; + if (0 == LIST_LENGTH(pChildren)) { + pProject->pProjections = nodesCloneList(pProjectLogicNode->pProjections); + if (NULL == pProject->pProjections) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } else { + code = setListSlotId(pCxt, ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc->dataBlockId, -1, + pProjectLogicNode->pProjections, &pProject->pProjections); + } if (TSDB_CODE_SUCCESS == code) { code = addDataBlockSlotsForProject(pCxt, pProjectLogicNode->stmtName, pProject->pProjections, pProject->node.pOutputDataBlockDesc); @@ -1038,7 +1049,7 @@ static ENodeType getIntervalOperatorType(EWindowAlgorithm windowAlgo) { case INTERVAL_ALGO_HASH: return QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL; case INTERVAL_ALGO_MERGE: - return QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL; + return QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL; case INTERVAL_ALGO_STREAM_FINAL: return QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL; case INTERVAL_ALGO_STREAM_SEMI: diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 390d665760..f0e0e84bd9 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -176,7 +176,7 @@ static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) { return !stbSplHasGatherExecFunc(((SAggLogicNode*)pNode)->pAggFuncs) && stbSplHasMultiTbScan(streamQuery, pNode); case QUERY_NODE_LOGIC_PLAN_WINDOW: { SWindowLogicNode* pWindow = (SWindowLogicNode*)pNode; - if (WINDOW_TYPE_STATE == pWindow->winType || (!streamQuery && WINDOW_TYPE_SESSION == pWindow->winType) ) { + if (WINDOW_TYPE_STATE == pWindow->winType || (!streamQuery && WINDOW_TYPE_SESSION == pWindow->winType)) { return false; } return !stbSplHasGatherExecFunc(pWindow->pFuncs) && stbSplHasMultiTbScan(streamQuery, pNode); @@ -380,6 +380,7 @@ static int32_t stbSplCreateExchangeNode(SSplitContext* pCxt, SLogicNode* pParent SExchangeLogicNode* pExchange = NULL; int32_t code = splCreateExchangeNode(pCxt, pPartChild, &pExchange); if (TSDB_CODE_SUCCESS == code) { + pExchange->node.pParent = pParent; code = nodesListMakeAppend(&pParent->pChildren, (SNode*)pExchange); } return code; @@ -484,7 +485,27 @@ static int32_t stbSplSplitSession(SSplitContext* pCxt, SStableSplitInfo* pInfo) } } -static int32_t stbSplSplitWindowNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) { +static SNodeList* stbSplGetPartKeys(SLogicNode* pNode) { + if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) { + return ((SScanLogicNode*)pNode)->pPartTags; + } else { + return NULL; + } +} + +static bool stbSplIsPartTbanme(SNodeList* pPartKeys) { + if (NULL == pPartKeys || 1 != LIST_LENGTH(pPartKeys)) { + return false; + } + SNode* pPartKey = nodesListGetNode(pPartKeys, 0); + return QUERY_NODE_FUNCTION == nodeType(pPartKey) && FUNCTION_TYPE_TBNAME == ((SFunctionNode*)pPartKey)->funcType; +} + +static bool stbSplIsMultiTableWinodw(SWindowLogicNode* pWindow) { + return stbSplIsPartTbanme(stbSplGetPartKeys((SLogicNode*)nodesListGetNode(pWindow->node.pChildren, 0))); +} + +static int32_t stbSplSplitWindowForMergeTable(SSplitContext* pCxt, SStableSplitInfo* pInfo) { switch (((SWindowLogicNode*)pInfo->pSplitNode)->winType) { case WINDOW_TYPE_INTERVAL: return stbSplSplitInterval(pCxt, pInfo); @@ -496,6 +517,34 @@ static int32_t stbSplSplitWindowNode(SSplitContext* pCxt, SStableSplitInfo* pInf return TSDB_CODE_PLAN_INTERNAL_ERROR; } +static int32_t stbSplSplitWindowForMultiTable(SSplitContext* pCxt, SStableSplitInfo* pInfo) { + if (pCxt->pPlanCxt->streamQuery) { + SPLIT_FLAG_SET_MASK(pInfo->pSubplan->splitFlag, SPLIT_FLAG_STABLE_SPLIT); + return TSDB_CODE_SUCCESS; + } + + SExchangeLogicNode* pExchange = NULL; + int32_t code = splCreateExchangeNode(pCxt, pInfo->pSplitNode, &pExchange); + if (TSDB_CODE_SUCCESS == code) { + code = replaceLogicNode(pInfo->pSubplan, pInfo->pSplitNode, (SLogicNode*)pExchange); + } + if (TSDB_CODE_SUCCESS == code) { + code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, + (SNode*)splCreateScanSubplan(pCxt, pInfo->pSplitNode, SPLIT_FLAG_STABLE_SPLIT)); + } + pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; + ++(pCxt->groupId); + return code; +} + +static int32_t stbSplSplitWindowNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) { + if (stbSplIsMultiTableWinodw((SWindowLogicNode*)pInfo->pSplitNode)) { + return stbSplSplitWindowForMultiTable(pCxt, pInfo); + } else { + return stbSplSplitWindowForMergeTable(pCxt, pInfo); + } +} + static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pOutput) { SNodeList* pFunc = pMergeAgg->pAggFuncs; pMergeAgg->pAggFuncs = NULL; @@ -885,7 +934,7 @@ static int32_t unionSplitSubplan(SSplitContext* pCxt, SLogicSubplan* pUnionSubpl } if (TSDB_CODE_SUCCESS == code) { nodesDestroyList(pSubplanChildren); - DESTORY_LIST(pSplitNode->pChildren); + NODES_DESTORY_LIST(pSplitNode->pChildren); } return code; } diff --git a/source/libs/planner/test/planBasicTest.cpp b/source/libs/planner/test/planBasicTest.cpp index f74c7df355..790c418b17 100644 --- a/source/libs/planner/test/planBasicTest.cpp +++ b/source/libs/planner/test/planBasicTest.cpp @@ -83,3 +83,21 @@ TEST_F(PlanBasicTest, interpFunc) { run("SELECT INTERP(c1) FROM t1 RANGE('2017-7-14 18:00:00', '2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR)"); } + +TEST_F(PlanBasicTest, lastRowFunc) { + useDb("root", "test"); + + run("SELECT LAST_ROW(c1) FROM t1"); + + run("SELECT LAST_ROW(*) FROM t1"); + + run("SELECT LAST_ROW(c1, c2) FROM t1"); + + run("SELECT LAST_ROW(c1) FROM st1"); +} + +TEST_F(PlanBasicTest, withoutFrom) { + useDb("root", "test"); + + run("SELECT 1"); +} diff --git a/source/libs/planner/test/planOtherTest.cpp b/source/libs/planner/test/planOtherTest.cpp index 12d14369de..b8963c29f9 100644 --- a/source/libs/planner/test/planOtherTest.cpp +++ b/source/libs/planner/test/planOtherTest.cpp @@ -37,7 +37,9 @@ TEST_F(PlanOtherTest, createStream) { TEST_F(PlanOtherTest, createStreamUseSTable) { useDb("root", "test"); - run("create stream if not exists s1 as select count(*) from st1 interval(10s)"); + run("CREATE STREAM IF NOT EXISTS s1 as SELECT COUNT(*) FROM st1 INTERVAL(10s)"); + + run("CREATE STREAM IF NOT EXISTS s1 as SELECT COUNT(*) FROM st1 PARTITION BY TBNAME INTERVAL(10s)"); } TEST_F(PlanOtherTest, createSmaIndex) { diff --git a/source/libs/qcom/src/queryUtil.c b/source/libs/qcom/src/queryUtil.c index 2120d24d26..c807c1c4cd 100644 --- a/source/libs/qcom/src/queryUtil.c +++ b/source/libs/qcom/src/queryUtil.c @@ -19,6 +19,7 @@ #include "tmsg.h" #include "trpc.h" #include "tsched.h" +#include "cJSON.h" #define VALIDNUMOFCOLS(x) ((x) >= TSDB_MIN_COLUMNS && (x) <= TSDB_MAX_COLUMNS) #define VALIDNUMOFTAGS(x) ((x) >= 0 && (x) <= TSDB_MAX_TAGS) @@ -220,3 +221,209 @@ void destroyQueryExecRes(SQueryExecRes* pRes) { qError("invalid exec result for request type %d", pRes->msgType); } } + +int32_t dataConverToStr(char *str, int type, void *buf, int32_t bufSize, int32_t *len) { + int32_t n = 0; + + switch (type) { + case TSDB_DATA_TYPE_NULL: + n = sprintf(str, "null"); + break; + + case TSDB_DATA_TYPE_BOOL: + n = sprintf(str, (*(int8_t*)buf) ? "true" : "false"); + break; + + case TSDB_DATA_TYPE_TINYINT: + n = sprintf(str, "%d", *(int8_t*)buf); + break; + + case TSDB_DATA_TYPE_SMALLINT: + n = sprintf(str, "%d", *(int16_t*)buf); + break; + + case TSDB_DATA_TYPE_INT: + n = sprintf(str, "%d", *(int32_t*)buf); + break; + + case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_TIMESTAMP: + n = sprintf(str, "%" PRId64, *(int64_t*)buf); + break; + + case TSDB_DATA_TYPE_FLOAT: + n = sprintf(str, "%e", GET_FLOAT_VAL(buf)); + break; + + case TSDB_DATA_TYPE_DOUBLE: + n = sprintf(str, "%e", GET_DOUBLE_VAL(buf)); + break; + + case TSDB_DATA_TYPE_BINARY: + case TSDB_DATA_TYPE_NCHAR: + if (bufSize < 0) { +// tscError("invalid buf size"); + return TSDB_CODE_TSC_INVALID_VALUE; + } + + *str = '"'; + memcpy(str + 1, buf, bufSize); + *(str + bufSize + 1) = '"'; + n = bufSize + 2; + break; + + case TSDB_DATA_TYPE_UTINYINT: + n = sprintf(str, "%d", *(uint8_t*)buf); + break; + + case TSDB_DATA_TYPE_USMALLINT: + n = sprintf(str, "%d", *(uint16_t*)buf); + break; + + case TSDB_DATA_TYPE_UINT: + n = sprintf(str, "%u", *(uint32_t*)buf); + break; + + case TSDB_DATA_TYPE_UBIGINT: + n = sprintf(str, "%" PRIu64, *(uint64_t*)buf); + break; + + default: +// tscError("unsupported type:%d", type); + return TSDB_CODE_TSC_INVALID_VALUE; + } + + *len = n; + + return TSDB_CODE_SUCCESS; +} + +char* parseTagDatatoJson(void* p) { + char* string = NULL; + cJSON* json = cJSON_CreateObject(); + if (json == NULL) { + goto end; + } + + SArray* pTagVals = NULL; + if (tTagToValArray((const STag*)p, &pTagVals) != 0) { + goto end; + } + + int16_t nCols = taosArrayGetSize(pTagVals); + char tagJsonKey[256] = {0}; + for (int j = 0; j < nCols; ++j) { + STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, j); + // json key encode by binary + memset(tagJsonKey, 0, sizeof(tagJsonKey)); + memcpy(tagJsonKey, pTagVal->pKey, strlen(pTagVal->pKey)); + // json value + char type = pTagVal->type; + if (type == TSDB_DATA_TYPE_NULL) { + cJSON* value = cJSON_CreateNull(); + if (value == NULL) { + goto end; + } + cJSON_AddItemToObject(json, tagJsonKey, value); + } else if (type == TSDB_DATA_TYPE_NCHAR) { + cJSON* value = NULL; + if (pTagVal->nData > 0) { + char* tagJsonValue = taosMemoryCalloc(pTagVal->nData, 1); + int32_t length = taosUcs4ToMbs((TdUcs4*)pTagVal->pData, pTagVal->nData, tagJsonValue); + if (length < 0) { + qError("charset:%s to %s. val:%s convert json value failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, + pTagVal->pData); + taosMemoryFree(tagJsonValue); + goto end; + } + value = cJSON_CreateString(tagJsonValue); + taosMemoryFree(tagJsonValue); + if (value == NULL) { + goto end; + } + } else if (pTagVal->nData == 0) { + value = cJSON_CreateString(""); + } else { + ASSERT(0); + } + + cJSON_AddItemToObject(json, tagJsonKey, value); + } else if (type == TSDB_DATA_TYPE_DOUBLE) { + double jsonVd = *(double*)(&pTagVal->i64); + cJSON* value = cJSON_CreateNumber(jsonVd); + if (value == NULL) { + goto end; + } + cJSON_AddItemToObject(json, tagJsonKey, value); + } else if (type == TSDB_DATA_TYPE_BOOL) { + char jsonVd = *(char*)(&pTagVal->i64); + cJSON* value = cJSON_CreateBool(jsonVd); + if (value == NULL) { + goto end; + } + cJSON_AddItemToObject(json, tagJsonKey, value); + } else { + ASSERT(0); + } + } + string = cJSON_PrintUnformatted(json); +end: + cJSON_Delete(json); + return string; +} + + +int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst) { + if (NULL == pSrc) { + *pDst = NULL; + return TSDB_CODE_SUCCESS; + } + + int32_t metaSize = (pSrc->tableInfo.numOfColumns + pSrc->tableInfo.numOfTags) * sizeof(SSchema); + *pDst = taosMemoryMalloc(metaSize); + if (NULL == *pDst) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + memcpy(*pDst, pSrc, metaSize); + return TSDB_CODE_SUCCESS; +} + +int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst) { + if (NULL == pSrc) { + *pDst = NULL; + return TSDB_CODE_SUCCESS; + } + + *pDst = taosMemoryMalloc(sizeof(*pSrc)); + if (NULL == *pDst) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + memcpy(*pDst, pSrc, sizeof(*pSrc)); + if (pSrc->vgHash) { + (*pDst)->vgHash = taosHashInit(taosHashGetSize(pSrc->vgHash), taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK); + if (NULL == (*pDst)->vgHash) { + return TSDB_CODE_TSC_OUT_OF_MEMORY; + } + + SVgroupInfo* vgInfo = NULL; + void *pIter = taosHashIterate(pSrc->vgHash, NULL); + while (pIter) { + vgInfo = pIter; + int32_t* vgId = taosHashGetKey(pIter, NULL); + + if (0 != taosHashPut((*pDst)->vgHash, vgId, sizeof(*vgId), vgInfo, sizeof(*vgInfo))) { + qError("taosHashPut failed, vgId:%d", vgInfo->vgId); + taosHashCancelIterate(pSrc->vgHash, pIter); + taosHashCleanup((*pDst)->vgHash); + taosMemoryFreeClear(*pDst); + return TSDB_CODE_CTG_MEM_ERROR; + } + + pIter = taosHashIterate(pSrc->vgHash, pIter); + } + } + + return TSDB_CODE_SUCCESS; +} + + diff --git a/source/libs/qcom/src/querymsg.c b/source/libs/qcom/src/querymsg.c index b89c220519..e2dfd9682b 100644 --- a/source/libs/qcom/src/querymsg.c +++ b/source/libs/qcom/src/querymsg.c @@ -63,7 +63,7 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) { } int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { - SBuildTableMetaInput *pInput = input; + SBuildTableInput *pInput = input; if (NULL == input || NULL == msg || NULL == msgLen) { return TSDB_CODE_TSC_INVALID_INPUT; } @@ -221,6 +221,27 @@ int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_ return TSDB_CODE_SUCCESS; } +int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { + if (NULL == msg || NULL == msgLen) { + return TSDB_CODE_TSC_INVALID_INPUT; + } + + SBuildTableInput *pInput = input; + STableCfgReq cfgReq = {0}; + cfgReq.header.vgId = pInput->vgId; + strcpy(cfgReq.dbFName, pInput->dbFName); + strcpy(cfgReq.tbName, pInput->tbName); + + int32_t bufLen = tSerializeSTableCfgReq(NULL, 0, &cfgReq); + void *pBuf = (*mallcFp)(bufLen); + tSerializeSTableCfgReq(pBuf, bufLen, &cfgReq); + + *msg = pBuf; + *msgLen = bufLen; + + return TSDB_CODE_SUCCESS; +} + int32_t queryProcessUseDBRsp(void *output, char *msg, int32_t msgSize) { SUseDbOutput *pOut = output; @@ -493,6 +514,21 @@ int32_t queryProcessGetTbIndexRsp(void *output, char *msg, int32_t msgSize) { return TSDB_CODE_SUCCESS; } +int32_t queryProcessGetTbCfgRsp(void *output, char *msg, int32_t msgSize) { + if (NULL == output || NULL == msg || msgSize <= 0) { + return TSDB_CODE_TSC_INVALID_INPUT; + } + + STableCfgRsp *out = taosMemoryCalloc(1, sizeof(STableCfgRsp)); + if (tDeserializeSTableCfgRsp(msg, msgSize, out) != 0) { + qError("tDeserializeSTableCfgRsp failed, msgSize:%d", msgSize); + return TSDB_CODE_INVALID_MSG; + } + + *(STableCfgRsp**)output = out; + + return TSDB_CODE_SUCCESS; +} void initQueryModuleMsgHandle() { queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryBuildTableMetaReqMsg; @@ -504,6 +540,8 @@ void initQueryModuleMsgHandle() { queryBuildMsg[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)] = queryBuildRetrieveFuncMsg; queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_USER_AUTH)] = queryBuildGetUserAuthMsg; queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TABLE_INDEX)] = queryBuildGetTbIndexMsg; + queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryBuildGetTbCfgMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryBuildGetTbCfgMsg; queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryProcessTableMetaRsp; queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryProcessTableMetaRsp; @@ -514,6 +552,8 @@ void initQueryModuleMsgHandle() { queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)] = queryProcessRetrieveFuncRsp; queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_USER_AUTH)] = queryProcessGetUserAuthRsp; queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TABLE_INDEX)] = queryProcessGetTbIndexRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryProcessGetTbCfgRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryProcessGetTbCfgRsp; } #pragma GCC diagnostic pop diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 2369779105..d335b04ea4 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1415,11 +1415,19 @@ int32_t roundFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOut } int32_t lowerFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { +#ifdef WINDOWS + return doCaseConvFunction(pInput, inputNum, pOutput, towlower); +#else return doCaseConvFunction(pInput, inputNum, pOutput, tolower); +#endif } int32_t upperFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { +#ifdef WINDOWS + return doCaseConvFunction(pInput, inputNum, pOutput, towupper); +#else return doCaseConvFunction(pInput, inputNum, pOutput, toupper); +#endif } int32_t ltrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { diff --git a/source/libs/stream/inc/streamInc.h b/source/libs/stream/inc/streamInc.h index 8aaf4953de..9654e21d24 100644 --- a/source/libs/stream/inc/streamInc.h +++ b/source/libs/stream/inc/streamInc.h @@ -33,8 +33,13 @@ static SStreamGlobalEnv streamEnv; int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb); int32_t streamDispatch(SStreamTask* pTask, SMsgCb* pMsgCb); int32_t streamDispatchReqToData(const SStreamDispatchReq* pReq, SStreamDataBlock* pData); +int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock* pData); int32_t streamBuildDispatchMsg(SStreamTask* pTask, SStreamDataBlock* data, SRpcMsg* pMsg, SEpSet** ppEpSet); +int32_t streamBroadcastToChildren(SStreamTask* pTask, const SSDataBlock* pBlock); + +int32_t tEncodeStreamRetrieveReq(SEncoder* pEncoder, const SStreamRetrieveReq* pReq); + #ifdef __cplusplus } #endif diff --git a/source/libs/stream/src/stream.c b/source/libs/stream/src/stream.c index 38a1ad14b1..9d92865e47 100644 --- a/source/libs/stream/src/stream.c +++ b/source/libs/stream/src/stream.c @@ -50,6 +50,10 @@ void streamCleanUp() { void streamTriggerByTimer(void* param, void* tmrId) { SStreamTask* pTask = (void*)param; + if (atomic_load_8(&pTask->taskStatus) == TASK_STATUS__DROPPING) { + return; + } + if (atomic_load_8(&pTask->triggerStatus) == TASK_TRIGGER_STATUS__ACTIVE) { SStreamTrigger* trigger = taosAllocateQitem(sizeof(SStreamTrigger), DEF_QITEM); if (trigger == NULL) return; @@ -82,8 +86,8 @@ int32_t streamSetupTrigger(SStreamTask* pTask) { } int32_t streamLaunchByWrite(SStreamTask* pTask, int32_t vgId) { - int8_t execStatus = atomic_load_8(&pTask->status); - if (execStatus == TASK_STATUS__IDLE || execStatus == TASK_STATUS__CLOSING) { + int8_t execStatus = atomic_load_8(&pTask->execStatus); + if (execStatus == TASK_EXEC_STATUS__IDLE || execStatus == TASK_EXEC_STATUS__CLOSING) { SStreamTaskRunReq* pRunReq = rpcMallocCont(sizeof(SStreamTaskRunReq)); if (pRunReq == NULL) return -1; @@ -108,7 +112,7 @@ int32_t streamTaskEnqueue(SStreamTask* pTask, SStreamDispatchReq* pReq, SRpcMsg* // enqueue if (pData != NULL) { pData->type = STREAM_DATA_TYPE_SSDATA_BLOCK; - pData->sourceVg = pReq->sourceVg; + pData->srcVgId = pReq->dataSrcVgId; // decode /*pData->blocks = pReq->data;*/ /*pBlock->sourceVer = pReq->sourceVer;*/ @@ -129,7 +133,42 @@ int32_t streamTaskEnqueue(SStreamTask* pTask, SStreamDispatchReq* pReq, SRpcMsg* SStreamDispatchRsp* pCont = POINTER_SHIFT(buf, sizeof(SMsgHead)); pCont->inputStatus = status; pCont->streamId = pReq->streamId; - pCont->taskId = pReq->sourceTaskId; + pCont->taskId = pReq->upstreamTaskId; + pRsp->pCont = buf; + pRsp->contLen = sizeof(SMsgHead) + sizeof(SStreamDispatchRsp); + tmsgSendRsp(pRsp); + return status == TASK_INPUT_STATUS__NORMAL ? 0 : -1; +} + +int32_t streamTaskEnqueueRetrieve(SStreamTask* pTask, SStreamRetrieveReq* pReq, SRpcMsg* pRsp) { + SStreamDataBlock* pData = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM); + int8_t status = TASK_INPUT_STATUS__NORMAL; + + // enqueue + if (pData != NULL) { + pData->type = STREAM_DATA_TYPE_SSDATA_BLOCK; + pData->srcVgId = 0; + // decode + /*pData->blocks = pReq->data;*/ + /*pBlock->sourceVer = pReq->sourceVer;*/ + streamRetrieveReqToData(pReq, pData); + if (streamTaskInput(pTask, (SStreamQueueItem*)pData) == 0) { + status = TASK_INPUT_STATUS__NORMAL; + } else { + status = TASK_INPUT_STATUS__FAILED; + } + } else { + /*streamTaskInputFail(pTask);*/ + /*status = TASK_INPUT_STATUS__FAILED;*/ + } + + // rsp by input status + void* buf = rpcMallocCont(sizeof(SMsgHead) + sizeof(SStreamRetrieveRsp)); + ((SMsgHead*)buf)->vgId = htonl(pReq->srcNodeId); + SStreamRetrieveRsp* pCont = POINTER_SHIFT(buf, sizeof(SMsgHead)); + pCont->streamId = pReq->streamId; + pCont->rspToTaskId = pReq->srcTaskId; + pCont->rspFromTaskId = pReq->dstTaskId; pRsp->pCont = buf; pRsp->contLen = sizeof(SMsgHead) + sizeof(SStreamDispatchRsp); tmsgSendRsp(pRsp); @@ -137,7 +176,7 @@ int32_t streamTaskEnqueue(SStreamTask* pTask, SStreamDispatchReq* pReq, SRpcMsg* } int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, SRpcMsg* pRsp) { - qInfo("task %d receive dispatch req from node %d task %d", pTask->taskId, pReq->upstreamNodeId, pReq->sourceTaskId); + qInfo("task %d receive dispatch req from node %d task %d", pTask->taskId, pReq->upstreamNodeId, pReq->upstreamTaskId); // 1. handle input streamTaskEnqueue(pTask, pReq, pRsp); @@ -188,6 +227,7 @@ int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp) { int32_t streamProcessRunReq(SStreamTask* pTask) { streamExec(pTask, pTask->pMsgCb); + if (pTask->dispatchType != TASK_DISPATCH__NONE) { streamDispatch(pTask, pTask->pMsgCb); } @@ -203,3 +243,22 @@ int32_t streamProcessRecoverRsp(SStreamTask* pTask, SStreamTaskRecoverRsp* pRsp) // return 0; } + +int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, SRpcMsg* pRsp) { + qInfo("task %d receive retrieve req from node %d task %d", pTask->taskId, pReq->srcNodeId, pReq->srcTaskId); + + streamTaskEnqueueRetrieve(pTask, pReq, pRsp); + + ASSERT(pTask->execType != TASK_EXEC__NONE); + streamExec(pTask, pTask->pMsgCb); + + ASSERT(pTask->dispatchType != TASK_DISPATCH__NONE); + streamDispatch(pTask, pTask->pMsgCb); + + return 0; +} + +int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp) { + // + return 0; +} diff --git a/source/libs/stream/src/streamData.c b/source/libs/stream/src/streamData.c index 6699e86b1e..ef328ecf84 100644 --- a/source/libs/stream/src/streamData.c +++ b/source/libs/stream/src/streamData.c @@ -15,27 +15,6 @@ #include "streamInc.h" -#if 0 -int32_t streamDataBlockEncode(void** buf, const SStreamDataBlock* pOutput) { - int32_t tlen = 0; - tlen += taosEncodeFixedI8(buf, pOutput->type); - tlen += taosEncodeFixedI32(buf, pOutput->sourceVg); - tlen += taosEncodeFixedI64(buf, pOutput->sourceVer); - ASSERT(pOutput->type == STREAM_INPUT__DATA_BLOCK); - tlen += tEncodeDataBlocks(buf, pOutput->blocks); - return tlen; -} - -void* streamDataBlockDecode(const void* buf, SStreamDataBlock* pInput) { - buf = taosDecodeFixedI8(buf, &pInput->type); - buf = taosDecodeFixedI32(buf, &pInput->sourceVg); - buf = taosDecodeFixedI64(buf, &pInput->sourceVer); - ASSERT(pInput->type == STREAM_INPUT__DATA_BLOCK); - buf = tDecodeDataBlocks(buf, &pInput->blocks); - return (void*)buf; -} -#endif - int32_t streamDispatchReqToData(const SStreamDispatchReq* pReq, SStreamDataBlock* pData) { int32_t blockNum = pReq->blockNum; SArray* pArray = taosArrayInit(blockNum, sizeof(SSDataBlock)); @@ -54,12 +33,25 @@ int32_t streamDispatchReqToData(const SStreamDispatchReq* pReq, SStreamDataBlock blockCompressDecode(pDataBlock, htonl(pRetrieve->numOfCols), htonl(pRetrieve->numOfRows), pRetrieve->data); // TODO: refactor pDataBlock->info.type = pRetrieve->streamBlockType; - pDataBlock->info.childId = pReq->sourceChildId; + pDataBlock->info.childId = pReq->upstreamChildId; } pData->blocks = pArray; return 0; } +int32_t streamRetrieveReqToData(const SStreamRetrieveReq* pReq, SStreamDataBlock* pData) { + SArray* pArray = taosArrayInit(1, sizeof(SSDataBlock)); + if (pArray == NULL) { + return -1; + } + taosArraySetSize(pArray, 1); + SRetrieveTableRsp* pRetrieve = pReq->pRetrieve; + SSDataBlock* pBlock = taosArrayGet(pArray, 0); + blockCompressDecode(pBlock, htonl(pRetrieve->numOfCols), htonl(pRetrieve->numOfRows), pRetrieve->data); + pData->blocks = pArray; + return 0; +} + SStreamDataSubmit* streamDataSubmitNew(SSubmitReq* pReq) { SStreamDataSubmit* pDataSubmit = (SStreamDataSubmit*)taosAllocateQitem(sizeof(SStreamDataSubmit), DEF_QITEM); if (pDataSubmit == NULL) return NULL; diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c index 1894f697c0..993fd3dbd7 100644 --- a/source/libs/stream/src/streamDispatch.c +++ b/source/libs/stream/src/streamDispatch.c @@ -19,9 +19,9 @@ int32_t tEncodeStreamDispatchReq(SEncoder* pEncoder, const SStreamDispatchReq* p if (tStartEncode(pEncoder) < 0) return -1; if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1; if (tEncodeI32(pEncoder, pReq->taskId) < 0) return -1; - if (tEncodeI32(pEncoder, pReq->sourceTaskId) < 0) return -1; - if (tEncodeI32(pEncoder, pReq->sourceVg) < 0) return -1; - if (tEncodeI32(pEncoder, pReq->sourceChildId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->upstreamTaskId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->dataSrcVgId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->upstreamChildId) < 0) return -1; if (tEncodeI32(pEncoder, pReq->upstreamNodeId) < 0) return -1; if (tEncodeI32(pEncoder, pReq->blockNum) < 0) return -1; ASSERT(taosArrayGetSize(pReq->data) == pReq->blockNum); @@ -40,9 +40,9 @@ int32_t tDecodeStreamDispatchReq(SDecoder* pDecoder, SStreamDispatchReq* pReq) { if (tStartDecode(pDecoder) < 0) return -1; if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1; if (tDecodeI32(pDecoder, &pReq->taskId) < 0) return -1; - if (tDecodeI32(pDecoder, &pReq->sourceTaskId) < 0) return -1; - if (tDecodeI32(pDecoder, &pReq->sourceVg) < 0) return -1; - if (tDecodeI32(pDecoder, &pReq->sourceChildId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->upstreamTaskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->dataSrcVgId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->upstreamChildId) < 0) return -1; if (tDecodeI32(pDecoder, &pReq->upstreamNodeId) < 0) return -1; if (tDecodeI32(pDecoder, &pReq->blockNum) < 0) return -1; ASSERT(pReq->blockNum > 0); @@ -62,6 +62,102 @@ int32_t tDecodeStreamDispatchReq(SDecoder* pDecoder, SStreamDispatchReq* pReq) { return 0; } +int32_t tEncodeStreamRetrieveReq(SEncoder* pEncoder, const SStreamRetrieveReq* pReq) { + // + if (tStartEncode(pEncoder) < 0) return -1; + if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->dstNodeId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->dstTaskId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->srcNodeId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->srcTaskId) < 0) return -1; + if (tEncodeBinary(pEncoder, (const uint8_t*)&pReq->pRetrieve, pReq->retrieveLen) < 0) return -1; + tEndEncode(pEncoder); + return pEncoder->pos; +} + +int32_t tDecodeStreamRetrieveReq(SDecoder* pDecoder, SStreamRetrieveReq* pReq) { + int32_t tlen = 0; + if (tStartDecode(pDecoder) < 0) return -1; + if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->dstNodeId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->dstTaskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->srcNodeId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->srcTaskId) < 0) return -1; + if (tDecodeBinary(pDecoder, (uint8_t**)&pReq->pRetrieve, &pReq->retrieveLen) < 0) return -1; + tEndDecode(pDecoder); + return 0; +} + +int32_t streamBroadcastToChildren(SStreamTask* pTask, const SSDataBlock* pBlock) { + SRetrieveTableRsp* pRetrieve = NULL; + void* buf = NULL; + int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); + + pRetrieve = taosMemoryCalloc(1, dataStrLen); + if (pRetrieve == NULL) return -1; + + pRetrieve->useconds = 0; + pRetrieve->precision = TSDB_DEFAULT_PRECISION; + pRetrieve->compressed = 0; + pRetrieve->completed = 1; + pRetrieve->streamBlockType = pBlock->info.type; + pRetrieve->numOfRows = htonl(pBlock->info.rows); + pRetrieve->numOfCols = htonl(pBlock->info.numOfCols); + + int32_t actualLen = 0; + blockCompressEncode(pBlock, pRetrieve->data, &actualLen, pBlock->info.numOfCols, false); + + SStreamRetrieveReq req = { + .streamId = pTask->streamId, + .srcNodeId = pTask->nodeId, + .srcTaskId = pTask->taskId, + .pRetrieve = pRetrieve, + }; + + int32_t sz = taosArrayGetSize(pTask->childEpInfo); + ASSERT(sz > 0); + for (int32_t i = 0; i < sz; i++) { + SStreamChildEpInfo* pEpInfo = taosArrayGetP(pTask->childEpInfo, i); + req.dstNodeId = pEpInfo->nodeId; + req.dstTaskId = pEpInfo->taskId; + int32_t code; + int32_t len; + tEncodeSize(tEncodeStreamRetrieveReq, &req, len, code); + if (code < 0) { + ASSERT(0); + return -1; + } + + buf = rpcMallocCont(sizeof(SMsgHead) + len); + if (buf == NULL) { + goto FAIL; + } + + ((SMsgHead*)buf)->vgId = htonl(pEpInfo->nodeId); + void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead)); + SEncoder encoder; + tEncoderInit(&encoder, abuf, len); + tEncodeStreamRetrieveReq(&encoder, &req); + + SRpcMsg rpcMsg = { + .code = 0, + .msgType = TDMT_STREAM_RETRIEVE, + .pCont = buf, + .contLen = len, + }; + + if (tmsgSendReq(&pEpInfo->epSet, &rpcMsg) < 0) { + ASSERT(0); + return -1; + } + } + return 0; +FAIL: + if (pRetrieve) taosMemoryFree(pRetrieve); + if (buf) taosMemoryFree(buf); + return -1; +} + static int32_t streamAddBlockToDispatchMsg(const SSDataBlock* pBlock, SStreamDispatchReq* pReq) { int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); void* buf = taosMemoryCalloc(1, dataStrLen); @@ -94,9 +190,9 @@ int32_t streamBuildDispatchMsg(SStreamTask* pTask, SStreamDataBlock* data, SRpcM SStreamDispatchReq req = { .streamId = pTask->streamId, - .sourceTaskId = pTask->taskId, - .sourceVg = data->sourceVg, - .sourceChildId = pTask->childId, + .dataSrcVgId = data->srcVgId, + .upstreamTaskId = pTask->taskId, + .upstreamChildId = pTask->selfChildId, .upstreamNodeId = pTask->nodeId, .blockNum = blockNum, }; @@ -147,7 +243,7 @@ int32_t streamBuildDispatchMsg(SStreamTask* pTask, SStreamDataBlock* data, SRpcM ASSERT(vgId > 0 || vgId == SNODE_HANDLE); req.taskId = downstreamTaskId; - qInfo("dispatch from task %d (child id %d) to down stream task %d in vnode %d", pTask->taskId, pTask->childId, + qInfo("dispatch from task %d (child id %d) to down stream task %d in vnode %d", pTask->taskId, pTask->selfChildId, downstreamTaskId, vgId); // serialize diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index 5a71fccab8..4d9916e196 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -13,8 +13,7 @@ * along with this program. If not, see . */ -#include "executor.h" -#include "tstream.h" +#include "streamInc.h" static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes) { void* exec = pTask->exec.executor; @@ -33,6 +32,9 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes) ASSERT(pTask->inputType == STREAM_INPUT__DATA_BLOCK); SArray* blocks = pBlock->blocks; qSetMultiStreamInput(exec, blocks->pData, blocks->size, STREAM_DATA_TYPE_SSDATA_BLOCK, false); + } else if (pItem->type == STREAM_INPUT__DROP) { + // TODO exec drop + return 0; } // exec @@ -43,9 +45,17 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes) ASSERT(false); } if (output == NULL) break; + + if (output->info.type == STREAM_RETRIEVE) { + if (streamBroadcastToChildren(pTask, output) < 0) { + // TODO + } + continue; + } + // TODO: do we need free memory? SSDataBlock* outputCopy = createOneDataBlock(output, true); - outputCopy->info.childId = pTask->childId; + outputCopy->info.childId = pTask->selfChildId; taosArrayPush(pRes, outputCopy); } return 0; @@ -58,6 +68,10 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) { streamTaskExecImpl(pTask, data, pRes); + if (pTask->taskStatus == TASK_STATUS__DROPPING) { + return NULL; + } + if (taosArrayGetSize(pRes) != 0) { SStreamDataBlock* qRes = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM); if (qRes == NULL) { @@ -75,12 +89,17 @@ static SArray* streamExecForQall(SStreamTask* pTask, SArray* pRes) { return NULL; } - if (pTask->inputType == STREAM_INPUT__DATA_SUBMIT) { - streamDataSubmitRefDec((SStreamDataSubmit*)data); + if (((SStreamQueueItem*)data)->type == STREAM_INPUT__TRIGGER) { + blockDataDestroy(((SStreamTrigger*)data)->pBlock); taosFreeQitem(data); } else { - taosArrayDestroyEx(((SStreamDataBlock*)data)->blocks, (FDelete)tDeleteSSDataBlock); - taosFreeQitem(data); + if (pTask->inputType == STREAM_INPUT__DATA_SUBMIT) { + streamDataSubmitRefDec((SStreamDataSubmit*)data); + taosFreeQitem(data); + } else { + taosArrayDestroyEx(((SStreamDataBlock*)data)->blocks, (FDelete)tDeleteSSDataBlock); + taosFreeQitem(data); + } } streamQueueProcessSuccess(pTask->inputQueue); return taosArrayInit(0, sizeof(SSDataBlock)); @@ -94,25 +113,26 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) { SArray* pRes = taosArrayInit(0, sizeof(SSDataBlock)); if (pRes == NULL) return -1; while (1) { - int8_t execStatus = atomic_val_compare_exchange_8(&pTask->status, TASK_STATUS__IDLE, TASK_STATUS__EXECUTING); - if (execStatus == TASK_STATUS__IDLE) { + int8_t execStatus = + atomic_val_compare_exchange_8(&pTask->execStatus, TASK_EXEC_STATUS__IDLE, TASK_EXEC_STATUS__EXECUTING); + if (execStatus == TASK_EXEC_STATUS__IDLE) { // first run pRes = streamExecForQall(pTask, pRes); if (pRes == NULL) goto FAIL; // set status closing - atomic_store_8(&pTask->status, TASK_STATUS__CLOSING); + atomic_store_8(&pTask->execStatus, TASK_EXEC_STATUS__CLOSING); // second run, make sure inputQ and qall are cleared pRes = streamExecForQall(pTask, pRes); if (pRes == NULL) goto FAIL; taosArrayDestroy(pRes); - atomic_store_8(&pTask->status, TASK_STATUS__IDLE); + atomic_store_8(&pTask->execStatus, TASK_EXEC_STATUS__IDLE); return 0; - } else if (execStatus == TASK_STATUS__CLOSING) { + } else if (execStatus == TASK_EXEC_STATUS__CLOSING) { continue; - } else if (execStatus == TASK_STATUS__EXECUTING) { + } else if (execStatus == TASK_EXEC_STATUS__EXECUTING) { ASSERT(taosArrayGetSize(pRes) == 0); taosArrayDestroy(pRes); return 0; @@ -122,7 +142,7 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) { } FAIL: if (pRes) taosArrayDestroy(pRes); - atomic_store_8(&pTask->status, TASK_STATUS__IDLE); + atomic_store_8(&pTask->execStatus, TASK_EXEC_STATUS__IDLE); return -1; } diff --git a/source/libs/stream/src/streamTask.c b/source/libs/stream/src/streamTask.c index b5a63d937a..8a7c425f79 100644 --- a/source/libs/stream/src/streamTask.c +++ b/source/libs/stream/src/streamTask.c @@ -23,29 +23,53 @@ SStreamTask* tNewSStreamTask(int64_t streamId) { } pTask->taskId = tGenIdPI32(); pTask->streamId = streamId; - pTask->status = TASK_STATUS__IDLE; + pTask->execStatus = TASK_EXEC_STATUS__IDLE; pTask->inputStatus = TASK_INPUT_STATUS__NORMAL; pTask->outputStatus = TASK_OUTPUT_STATUS__NORMAL; return pTask; } +int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo) { + if (tEncodeI32(pEncoder, pInfo->taskId) < 0) return -1; + if (tEncodeI32(pEncoder, pInfo->nodeId) < 0) return -1; + if (tEncodeI32(pEncoder, pInfo->childId) < 0) return -1; + if (tEncodeSEpSet(pEncoder, &pInfo->epSet) < 0) return -1; + return 0; +} + +int32_t tDecodeStreamEpInfo(SDecoder* pDecoder, SStreamChildEpInfo* pInfo) { + if (tDecodeI32(pDecoder, &pInfo->taskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pInfo->nodeId) < 0) return -1; + if (tDecodeI32(pDecoder, &pInfo->childId) < 0) return -1; + if (tDecodeSEpSet(pDecoder, &pInfo->epSet) < 0) return -1; + return 0; +} + int32_t tEncodeSStreamTask(SEncoder* pEncoder, const SStreamTask* pTask) { /*if (tStartEncode(pEncoder) < 0) return -1;*/ if (tEncodeI64(pEncoder, pTask->streamId) < 0) return -1; if (tEncodeI32(pEncoder, pTask->taskId) < 0) return -1; if (tEncodeI8(pEncoder, pTask->inputType) < 0) return -1; - if (tEncodeI8(pEncoder, pTask->status) < 0) return -1; + if (tEncodeI8(pEncoder, pTask->taskStatus) < 0) return -1; + if (tEncodeI8(pEncoder, pTask->execStatus) < 0) return -1; if (tEncodeI8(pEncoder, pTask->execType) < 0) return -1; if (tEncodeI8(pEncoder, pTask->sinkType) < 0) return -1; if (tEncodeI8(pEncoder, pTask->dispatchType) < 0) return -1; if (tEncodeI16(pEncoder, pTask->dispatchMsgType) < 0) return -1; - if (tEncodeI8(pEncoder, pTask->dataScan) < 0) return -1; + if (tEncodeI8(pEncoder, pTask->isDataScan) < 0) return -1; - if (tEncodeI32(pEncoder, pTask->childId) < 0) return -1; + if (tEncodeI32(pEncoder, pTask->selfChildId) < 0) return -1; if (tEncodeI32(pEncoder, pTask->nodeId) < 0) return -1; if (tEncodeSEpSet(pEncoder, &pTask->epSet) < 0) return -1; + int32_t epSz = taosArrayGetSize(pTask->childEpInfo); + if (tEncodeI32(pEncoder, epSz) < 0) return -1; + for (int32_t i = 0; i < epSz; i++) { + SStreamChildEpInfo* pInfo = taosArrayGetP(pTask->childEpInfo, i); + if (tEncodeStreamEpInfo(pEncoder, pInfo) < 0) return -1; + } + if (pTask->execType != TASK_EXEC__NONE) { if (tEncodeCStr(pEncoder, pTask->exec.qmsg) < 0) return -1; } @@ -83,17 +107,28 @@ int32_t tDecodeSStreamTask(SDecoder* pDecoder, SStreamTask* pTask) { if (tDecodeI64(pDecoder, &pTask->streamId) < 0) return -1; if (tDecodeI32(pDecoder, &pTask->taskId) < 0) return -1; if (tDecodeI8(pDecoder, &pTask->inputType) < 0) return -1; - if (tDecodeI8(pDecoder, &pTask->status) < 0) return -1; + if (tDecodeI8(pDecoder, &pTask->taskStatus) < 0) return -1; + if (tDecodeI8(pDecoder, &pTask->execStatus) < 0) return -1; if (tDecodeI8(pDecoder, &pTask->execType) < 0) return -1; if (tDecodeI8(pDecoder, &pTask->sinkType) < 0) return -1; if (tDecodeI8(pDecoder, &pTask->dispatchType) < 0) return -1; if (tDecodeI16(pDecoder, &pTask->dispatchMsgType) < 0) return -1; - if (tDecodeI8(pDecoder, &pTask->dataScan) < 0) return -1; + if (tDecodeI8(pDecoder, &pTask->isDataScan) < 0) return -1; - if (tDecodeI32(pDecoder, &pTask->childId) < 0) return -1; + if (tDecodeI32(pDecoder, &pTask->selfChildId) < 0) return -1; if (tDecodeI32(pDecoder, &pTask->nodeId) < 0) return -1; if (tDecodeSEpSet(pDecoder, &pTask->epSet) < 0) return -1; + int32_t epSz; + if (tDecodeI32(pDecoder, &epSz) < 0) return -1; + pTask->childEpInfo = taosArrayInit(epSz, sizeof(void*)); + for (int32_t i = 0; i < epSz; i++) { + SStreamChildEpInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamChildEpInfo)); + if (pInfo == NULL) return -1; + if (tDecodeStreamEpInfo(pDecoder, pInfo) < 0) return -1; + taosArrayPush(pTask->childEpInfo, &pInfo); + } + if (pTask->execType != TASK_EXEC__NONE) { if (tDecodeCStrAlloc(pDecoder, &pTask->exec.qmsg) < 0) return -1; } diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index 45e71f6c0d..1c924fa636 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -56,14 +56,9 @@ typedef struct { } SIntHdr; #pragma pack(pop) -typedef struct { - u8 flags; - SBTree *pBt; -} SBtreeInitPageArg; - static int tdbDefaultKeyCmprFn(const void *pKey1, int keyLen1, const void *pKey2, int keyLen2); static int tdbBtreeOpenImpl(SBTree *pBt); -static int tdbBtreeInitPage(SPage *pPage, void *arg, int init); +//static int tdbBtreeInitPage(SPage *pPage, void *arg, int init); static int tdbBtreeEncodeCell(SPage *pPage, const void *pKey, int kLen, const void *pVal, int vLen, SCell *pCell, int *szCell, TXN *pTxn, SBTree *pBt); static int tdbBtreeDecodeCell(SPage *pPage, const SCell *pCell, SCellDecoder *pDecoder, TXN *pTxn, SBTree *pBt); @@ -348,7 +343,7 @@ static int tdbBtreeOpenImpl(SBTree *pBt) { return 0; } -static int tdbBtreeInitPage(SPage *pPage, void *arg, int init) { +int tdbBtreeInitPage(SPage *pPage, void *arg, int init) { SBTree *pBt; u8 flags; u8 leaf; diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index a74bb54883..dd3f09d5d2 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -424,4 +424,71 @@ static int tdbPagerWritePageToDB(SPager *pPager, SPage *pPage) { } return 0; -} \ No newline at end of file +} + +int tdbPagerRestore(SPager *pPager, SBTree *pBt) { + int ret = 0; + SPgno journalSize = 0; + u8 *pageBuf = NULL; + + tdb_fd_t jfd = tdbOsOpen(pPager->jFileName, TDB_O_RDWR, 0755); + if (jfd == NULL) { + return 0; + } + + ret = tdbGetFileSize(jfd, pPager->pageSize, &journalSize); + if (ret < 0) { + return -1; + } + + pageBuf = tdbOsCalloc(1, pPager->pageSize); + if (pageBuf == NULL) { + return -1; + } + + TXN txn; + tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0); + SBtreeInitPageArg iArg; + iArg.pBt = pBt; + iArg.flags = 0; + + for (int pgIndex = 0; pgIndex < journalSize; ++pgIndex) { + // read pgno & the page from journal + SPgno pgno; + SPage *pPage; + + int ret = tdbOsRead(jfd, &pgno, sizeof(pgno)); + if (ret < 0) { + return -1; + } + + ret = tdbOsRead(jfd, pageBuf, pPager->pageSize); + if (ret < 0) { + return -1; + } + + ret = tdbPagerFetchPage(pPager, &pgno, &pPage, tdbBtreeInitPage, &iArg, &txn); + if (ret < 0) { + return -1; + } + + // write the page to db + ret = tdbPagerWritePageToDB(pPager, pPage); + if (ret < 0) { + return -1; + } + + tdbPCacheRelease(pPager->pCache, pPage, &txn); + } + + tdbOsFSync(pPager->fd); + + tdbTxnClose(&txn); + + tdbOsFree(pageBuf); + + tdbOsClose(jfd); + tdbOsRemove(pPager->jFileName); + + return 0; +} diff --git a/source/libs/tdb/src/db/tdbTable.c b/source/libs/tdb/src/db/tdbTable.c index 1575f9f206..f1bfb4eabc 100644 --- a/source/libs/tdb/src/db/tdbTable.c +++ b/source/libs/tdb/src/db/tdbTable.c @@ -61,6 +61,11 @@ int tdbTbOpen(const char *tbname, int keyLen, int valLen, tdb_cmpr_fn_t keyCmprF return -1; } + ret = tdbPagerRestore(pPager, pTb->pBt); + if (ret < 0) { + return -1; + } + *ppTb = pTb; return 0; } diff --git a/source/libs/tdb/src/db/tdbUtil.c b/source/libs/tdb/src/db/tdbUtil.c index 4acb83c8e4..9021e08ffe 100644 --- a/source/libs/tdb/src/db/tdbUtil.c +++ b/source/libs/tdb/src/db/tdbUtil.c @@ -64,4 +64,4 @@ int tdbGetFileSize(tdb_fd_t fd, int szPage, SPgno *size) { *size = szBytes / szPage; return 0; -} \ No newline at end of file +} diff --git a/source/libs/tdb/src/inc/tdbInt.h b/source/libs/tdb/src/inc/tdbInt.h index 39b5584fab..c914e098f7 100644 --- a/source/libs/tdb/src/inc/tdbInt.h +++ b/source/libs/tdb/src/inc/tdbInt.h @@ -158,6 +158,13 @@ int tdbBtreeUpsert(SBTree *pBt, const void *pKey, int nKey, const void *pData, i int tdbBtreeGet(SBTree *pBt, const void *pKey, int kLen, void **ppVal, int *vLen); int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkLen, void **ppVal, int *vLen); +typedef struct { + u8 flags; + SBTree *pBt; +} SBtreeInitPageArg; + +int tdbBtreeInitPage(SPage *pPage, void *arg, int init); + // SBTC int tdbBtcOpen(SBTC *pBtc, SBTree *pBt, TXN *pTxn); int tdbBtcClose(SBTC *pBtc); @@ -185,6 +192,7 @@ int tdbPagerFetchPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initP TXN *pTxn); void tdbPagerReturnPage(SPager *pPager, SPage *pPage, TXN *pTxn); int tdbPagerAllocPage(SPager *pPager, SPgno *ppgno); +int tdbPagerRestore(SPager *pPager, SBTree *pBt); // tdbPCache.c ==================================== #define TDB_PCACHE_PAGE \ diff --git a/source/libs/tdb/src/inc/tdbUtil.h b/source/libs/tdb/src/inc/tdbUtil.h index c518e8efcc..fe97f9c986 100644 --- a/source/libs/tdb/src/inc/tdbUtil.h +++ b/source/libs/tdb/src/inc/tdbUtil.h @@ -20,7 +20,7 @@ extern "C" { #endif -#if __STDC_VERSION__ >= 201112L +#if __STDC_VERSION__ >= 201112LL #define TDB_STATIC_ASSERT(op, info) static_assert(op, info) #else #define TDB_STATIC_ASSERT(op, info) diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index 146b127422..327fe50814 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -183,6 +183,8 @@ typedef enum { ConnNormal, ConnAcquire, ConnRelease, ConnBroken, ConnInPool } Co #define transContLenFromMsg(msgLen) (msgLen - sizeof(STransMsgHead)); #define transIsReq(type) (type & 1U) +#define transLabel(trans) ((STrans*)trans)->label + // int rpcAuthenticateMsg(void* pMsg, int msgLen, void* pAuth, void* pKey); // void rpcBuildAuthHead(void* pMsg, int msgLen, void* pAuth, void* pKey); //// int32_t rpcCompressRpcMsg(char* pCont, int32_t contLen); diff --git a/source/libs/transport/inc/transLog.h b/source/libs/transport/inc/transLog.h index 9947ba803f..121939787c 100644 --- a/source/libs/transport/inc/transLog.h +++ b/source/libs/transport/inc/transLog.h @@ -24,16 +24,21 @@ extern "C" { #include "tlog.h" #include "ttrace.h" -#define tFatal(...) do {if (rpcDebugFlag & DEBUG_FATAL){ taosPrintLog("RPC FATAL ", DEBUG_FATAL, rpcDebugFlag, __VA_ARGS__); }} while (0) -#define tError(...)do { if (rpcDebugFlag & DEBUG_ERROR){ taosPrintLog("RPC ERROR ", DEBUG_ERROR, rpcDebugFlag, __VA_ARGS__); } } while(0) -#define tWarn(...) do { if (rpcDebugFlag & DEBUG_WARN) { taosPrintLog("RPC WARN ", DEBUG_WARN, rpcDebugFlag, __VA_ARGS__); }} while(0) -#define tInfo(...) do { if (rpcDebugFlag & DEBUG_INFO) { taosPrintLog("RPC ", DEBUG_INFO, rpcDebugFlag, __VA_ARGS__); }} while(0) -#define tDebug(...) do {if (rpcDebugFlag & DEBUG_DEBUG){ taosPrintLog("RPC ", DEBUG_DEBUG, rpcDebugFlag, __VA_ARGS__); }} while(0) -#define tTrace(...) do {if (rpcDebugFlag & DEBUG_TRACE){ taosPrintLog("RPC ", DEBUG_TRACE, rpcDebugFlag, __VA_ARGS__); }} while(0) -#define tDump(x, y) do {if (rpcDebugFlag & DEBUG_DUMP) { taosDumpData((unsigned char *)x, y); } } while(0) +#define tFatal(...) { if (rpcDebugFlag & DEBUG_FATAL) { taosPrintLog("RPC FATAL ", DEBUG_FATAL, rpcDebugFlag, __VA_ARGS__); }} +#define tError(...) { if (rpcDebugFlag & DEBUG_ERROR ){ taosPrintLog("RPC ERROR ", DEBUG_ERROR, rpcDebugFlag, __VA_ARGS__); }} +#define tWarn(...) { if (rpcDebugFlag & DEBUG_WARN) { taosPrintLog("RPC WARN ", DEBUG_WARN, rpcDebugFlag, __VA_ARGS__); }} +#define tInfo(...) { if (rpcDebugFlag & DEBUG_INFO) { taosPrintLog("RPC ", DEBUG_INFO, rpcDebugFlag, __VA_ARGS__); }} +#define tDebug(...) { if (rpcDebugFlag & DEBUG_DEBUG) { taosPrintLog("RPC ", DEBUG_DEBUG, rpcDebugFlag, __VA_ARGS__); }} +#define tTrace(...) { if (rpcDebugFlag & DEBUG_TRACE) { taosPrintLog("RPC ", DEBUG_TRACE, rpcDebugFlag, __VA_ARGS__); }} +#define tDump(x, y) { if (rpcDebugFlag & DEBUG_DUMP) { taosDumpData((unsigned char *)x, y); } } + +#define tGTrace(param, ...) do { if (rpcDebugFlag & DEBUG_TRACE){char buf[40] = {0}; TRACE_TO_STR(trace, buf); tTrace(param ", gtid:%s", __VA_ARGS__, buf);}} while(0) +#define tGFatal(param, ...) do {if (rpcDebugFlag & DEBUG_FATAL){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); tFatal(param ", gtid:%s", __VA_ARGS__, buf); }} while (0) +#define tGError(param, ...) do { if (rpcDebugFlag & DEBUG_ERROR){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); tError(param ", gtid:%s", __VA_ARGS__, buf);} } while(0) +#define tGWarn(param, ...) do { if (rpcDebugFlag & DEBUG_WARN) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); tWarn(param ", gtid:%s", __VA_ARGS__, buf); }} while(0) +#define tGInfo(param, ...) do { if (rpcDebugFlag & DEBUG_INFO) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); tInfo(param ", gtid:%s", __VA_ARGS__, buf); }} while(0) +#define tGDebug(param,...) do {if (rpcDebugFlag & DEBUG_DEBUG){ char buf[40] = {0}; TRACE_TO_STR(trace, buf); tDebug(param ", gtid:%s", __VA_ARGS__, buf); }} while(0) -//#define tTR(param, ...) do { char buf[40] = {0};TRACE_TO_STR(trace, buf);tTrace("TRID: %s "param, buf, __VA_ARGS__);} while(0) -#define tGTrace(param, ...) do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); tTrace(param ", GTID: %s", __VA_ARGS__, buf);} while(0) // clang-format on #ifdef __cplusplus diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 912c8b59c2..bf03ea26ba 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -175,6 +175,7 @@ static void cliReleaseUnfinishedMsg(SCliConn* conn) { #define CONN_SHOULD_RELEASE(conn, head) \ do { \ if ((head)->release == 1 && (head->msgLen) == sizeof(*head)) { \ + int connStatus = conn->status; \ uint64_t ahandle = head->ahandle; \ CONN_GET_MSGCTX_BY_AHANDLE(conn, ahandle); \ conn->status = ConnRelease; \ @@ -186,7 +187,9 @@ static void cliReleaseUnfinishedMsg(SCliConn* conn) { } \ destroyCmsg(pMsg); \ cliReleaseUnfinishedMsg(conn); \ - addConnToPool(((SCliThrdObj*)conn->hostThrd)->pool, conn); \ + if (connStatus != ConnInPool) { \ + addConnToPool(((SCliThrdObj*)conn->hostThrd)->pool, conn); \ + } \ return; \ } \ } while (0) @@ -450,7 +453,7 @@ void* destroyConnPool(void* pool) { while (connList != NULL) { while (!QUEUE_IS_EMPTY(&connList->conn)) { queue* h = QUEUE_HEAD(&connList->conn); - QUEUE_REMOVE(h); + // QUEUE_REMOVE(h); SCliConn* c = QUEUE_DATA(h, SCliConn, conn); cliDestroyConn(c, true); } @@ -476,18 +479,19 @@ static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port) { if (QUEUE_IS_EMPTY(&plist->conn)) { return NULL; } - queue* h = QUEUE_HEAD(&plist->conn); - QUEUE_REMOVE(h); + queue* h = QUEUE_HEAD(&plist->conn); SCliConn* conn = QUEUE_DATA(h, SCliConn, conn); conn->status = ConnNormal; + QUEUE_REMOVE(&conn->conn); QUEUE_INIT(&conn->conn); + assert(h == &conn->conn); return conn; } static void addConnToPool(void* pool, SCliConn* conn) { SCliThrdObj* thrd = conn->hostThrd; CONN_HANDLE_THREAD_QUIT(thrd); - STrans* pTransInst = ((SCliThrdObj*)conn->hostThrd)->pTransInst; + STrans* pTransInst = thrd->pTransInst; conn->expireTime = taosGetTimestampMs() + CONN_PERSIST_TIME(pTransInst->idleTime); transQueueClear(&conn->cliMsgs); transCtxCleanup(&conn->ctx); @@ -500,6 +504,7 @@ static void addConnToPool(void* pool, SCliConn* conn) { SConnList* plist = taosHashGet((SHashObj*)pool, key, strlen(key)); // list already create before assert(plist != NULL); + QUEUE_INIT(&conn->conn); QUEUE_PUSH(&plist->conn, &conn->conn); assert(!QUEUE_IS_EMPTY(&plist->conn)); } @@ -561,7 +566,6 @@ static SCliConn* cliCreateConn(SCliThrdObj* pThrd) { } static void cliDestroyConn(SCliConn* conn, bool clear) { tTrace("%s conn %p remove from conn pool", CONN_GET_INST_LABEL(conn), conn); - QUEUE_REMOVE(&conn->conn); if (clear) { uv_close((uv_handle_t*)conn->stream, cliDestroy); @@ -778,11 +782,11 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) { int ret = transSetConnOption((uv_tcp_t*)conn->stream); if (ret) { - tError("%s conn %p failed to set conn option, errmsg %s", pTransInst->label, conn, uv_err_name(ret)); + tError("%s conn %p failed to set conn option, errmsg %s", transLabel(pTransInst), conn, uv_err_name(ret)); } int fd = taosCreateSocketWithTimeOutOpt(TRANS_CONN_TIMEOUT); if (fd == -1) { - tTrace("%s conn %p failed to create socket", pTransInst->label, conn); + tTrace("%s conn %p failed to create socket", transLabel(pTransInst), conn); cliHandleExcept(conn); return; } @@ -1006,7 +1010,9 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) { tTrace("%s use remote epset, inUse: %d, retry count:%d, limit: %d", pTransInst->label, pEpSet->inUse, pCtx->retryCount + 1, TRANS_RETRY_COUNT_LIMIT); } - addConnToPool(pThrd->pool, pConn); + if (pConn->status != ConnInPool) { + addConnToPool(pThrd->pool, pConn); + } STaskArg* arg = taosMemoryMalloc(sizeof(STaskArg)); arg->param1 = pMsg; @@ -1110,7 +1116,7 @@ void transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STra SCliThrdObj* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[idx]; STraceId* trace = &pReq->info.traceId; - tGTrace("%s send request at thread:%08" PRId64 ", dst: %s:%d, app:%p", pTransInst->label, thrd->pid, + tGTrace("%s send request at thread:%08" PRId64 ", dst: %s:%d, app:%p", transLabel(pTransInst), thrd->pid, EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); ASSERT(transSendAsync(thrd->asyncPool, &(cliMsg->q)) == 0); } @@ -1143,7 +1149,7 @@ void transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransM SCliThrdObj* thrd = ((SCliObj*)pTransInst->tcphandle)->pThreadObj[idx]; STraceId* trace = &pReq->info.traceId; - tGTrace("%s send request at thread:%08" PRId64 ", dst: %s:%d, app:%p", pTransInst->label, thrd->pid, + tGTrace("%s send request at thread:%08" PRId64 ", dst: %s:%d, app:%p", transLabel(pTransInst), thrd->pid, EPSET_GET_INUSE_IP(&pCtx->epSet), EPSET_GET_INUSE_PORT(&pCtx->epSet), pReq->info.ahandle); transSendAsync(thrd->asyncPool, &(cliMsg->q)); diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index f9558d7252..593a790a21 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -284,12 +284,12 @@ static void uvHandleReq(SSvrConn* pConn) { if (pConn->status == ConnNormal && pHead->noResp == 0) { transRefSrvHandle(pConn); - tGTrace("conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pConn, TMSG_INFO(transMsg.msgType), - taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->localAddr.sin_addr), - ntohs(pConn->localAddr.sin_port), transMsg.contLen); - } else { - tGTrace("conn %p %s received from %s:%d, local info: %s:%d, msg size: %d, resp:%d, code: %d", pConn, + tGTrace("%s conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", transLabel(pConn), pConn, TMSG_INFO(transMsg.msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), + taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port), transMsg.contLen); + } else { + tGTrace("%s conn %p %s received from %s:%d, local info: %s:%d, msg size: %d, resp:%d, code: %d", transLabel(pConn), + pConn, TMSG_INFO(transMsg.msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port), transMsg.contLen, pHead->noResp, transMsg.code); // no ref here @@ -304,7 +304,8 @@ static void uvHandleReq(SSvrConn* pConn) { transMsg.info.refId = pConn->refId; transMsg.info.traceId = pHead->traceId; - tGTrace("handle %p conn: %p translated to app, refId: %" PRIu64 "", transMsg.info.handle, pConn, pConn->refId); + tGTrace("%s handle %p conn: %p translated to app, refId: %" PRIu64 "", transLabel(pConn), transMsg.info.handle, pConn, + pConn->refId); assert(transMsg.info.handle != NULL); if (pHead->noResp == 1) { @@ -330,12 +331,12 @@ void uvOnRecvCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf) { SConnBuffer* pBuf = &conn->readBuf; if (nread > 0) { pBuf->len += nread; - tTrace("conn %p total read: %d, current read: %d", conn, pBuf->len, (int)nread); + tTrace("%s conn %p total read: %d, current read: %d", transLabel(conn->pTransInst), conn, pBuf->len, (int)nread); if (transReadComplete(pBuf)) { - tTrace("conn %p alread read complete packet", conn); + tTrace("%s conn %p alread read complete packet", transLabel(conn->pTransInst), conn); uvHandleReq(conn); } else { - tTrace("conn %p read partial packet, continue to read", conn); + tTrace("%s conn %p read partial packet, continue to read", transLabel(conn->pTransInst), conn); } return; } @@ -343,12 +344,12 @@ void uvOnRecvCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf) { return; } - tError("conn %p read error: %s", conn, uv_err_name(nread)); + tError("%s conn %p read error: %s", transLabel(conn->pTransInst), conn, uv_err_name(nread)); if (nread < 0) { conn->broken = true; if (conn->status == ConnAcquire) { if (conn->regArg.init) { - tTrace("conn %p broken, notify server app", conn); + tTrace("%s conn %p broken, notify server app", transLabel(conn->pTransInst), conn); STrans* pTransInst = conn->pTransInst; (*pTransInst->cfp)(pTransInst->parent, &(conn->regArg.msg), NULL); memset(&conn->regArg, 0, sizeof(conn->regArg)); @@ -457,9 +458,9 @@ static void uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) { int32_t len = transMsgLenFromCont(pMsg->contLen); STraceId* trace = &pMsg->info.traceId; - tGTrace("conn %p %s is sent to %s:%d, local info: %s:%d, msglen:%d", pConn, TMSG_INFO(pHead->msgType), - taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), taosInetNtoa(pConn->localAddr.sin_addr), - ntohs(pConn->localAddr.sin_port), len); + tGTrace("%s conn %p %s is sent to %s:%d, local info: %s:%d, msglen:%d", transLabel(pConn->pTransInst), pConn, + TMSG_INFO(pHead->msgType), taosInetNtoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), + taosInetNtoa(pConn->localAddr.sin_addr), ntohs(pConn->localAddr.sin_port), len); pHead->msgLen = htonl(len); wb->base = msg; @@ -737,7 +738,7 @@ static bool addHandleToWorkloop(SWorkThrdObj* pThrd, char* pipeName) { // conn set QUEUE_INIT(&pThrd->conn); - pThrd->asyncPool = transCreateAsyncPool(pThrd->loop, 5, pThrd, uvWorkerAsyncCb); + pThrd->asyncPool = transCreateAsyncPool(pThrd->loop, 1, pThrd, uvWorkerAsyncCb); uv_pipe_connect(&pThrd->connect_req, pThrd->pipe, pipeName, uvOnPipeConnectionCb); // uv_read_start((uv_stream_t*)pThrd->pipe, uvAllocConnBufferCb, uvOnConnectionCb); return true; @@ -801,7 +802,7 @@ static SSvrConn* createConn(void* hThrd) { pConn->refId = exh->refId; transRefSrvHandle(pConn); - tTrace("handle %p, conn %p created, refId: %" PRId64 "", exh, pConn, pConn->refId); + tTrace("%s handle %p, conn %p created, refId: %" PRId64 "", transLabel(pThrd->pTransInst), exh, pConn, pConn->refId); return pConn; } @@ -848,7 +849,7 @@ static void uvDestroyConn(uv_handle_t* handle) { transReleaseExHandle(refMgt, conn->refId); transRemoveExHandle(refMgt, conn->refId); - tDebug("conn %p destroy", conn); + tDebug("%s conn %p destroy", transLabel(thrd->pTransInst), conn); // uv_timer_stop(&conn->pTimer); transQueueDestroy(&conn->srvMsgs); @@ -977,18 +978,18 @@ void uvHandleRelease(SSvrMsg* msg, SWorkThrdObj* thrd) { uvStartSendRespInternal(msg); return; } else if (conn->status == ConnRelease || conn->status == ConnNormal) { - tDebug("conn %p already released, ignore release-msg", conn); + tDebug("%s conn %p already released, ignore release-msg", transLabel(thrd->pTransInst), conn); } destroySmsg(msg); } void uvHandleResp(SSvrMsg* msg, SWorkThrdObj* thrd) { // send msg to client - tDebug("conn %p start to send resp (2/2)", msg->pConn); + tDebug("%s conn %p start to send resp (2/2)", transLabel(thrd->pTransInst), msg->pConn); uvStartSendResp(msg); } void uvHandleRegister(SSvrMsg* msg, SWorkThrdObj* thrd) { SSvrConn* conn = msg->pConn; - tDebug("conn %p register brokenlink callback", conn); + tDebug("%s conn %p register brokenlink callback", transLabel(thrd->pTransInst), conn); if (conn->status == ConnAcquire) { if (!transQueuePush(&conn->srvMsgs, msg)) { return; @@ -1094,7 +1095,7 @@ void transReleaseSrvHandle(void* handle) { m->msg = tmsg; m->type = Release; - tTrace("conn %p start to release", exh->handle); + tTrace("%s conn %p start to release", transLabel(pThrd->pTransInst), exh->handle); transSendAsync(pThrd->asyncPool, &m->q); transReleaseExHandle(refMgt, refId); return; @@ -1152,7 +1153,7 @@ void transRegisterMsg(const STransMsg* msg) { m->msg = tmsg; m->type = Register; - tTrace("conn %p start to register brokenlink callback", exh->handle); + tTrace("%s conn %p start to register brokenlink callback", transLabel(pThrd->pTransInst), exh->handle); transSendAsync(pThrd->asyncPool, &m->q); transReleaseExHandle(refMgt, refId); return; diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index b1129b441c..9bed6d230b 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -100,7 +100,6 @@ static int32_t walReadChangeFile(SWalReadHandle *pRead, int64_t fileFirstVer) { TdFilePtr pLogTFile = taosOpenFile(fnameStr, TD_FILE_READ); if (pLogTFile == NULL) { terrno = TAOS_SYSTEM_ERROR(errno); - terrno = TSDB_CODE_WAL_INVALID_VER; wError("cannot open file %s, since %s", fnameStr, terrstr()); return -1; } diff --git a/source/util/src/tbuffer.c b/source/util/src/tbuffer.c index 8552ccac2c..d2fac72c77 100644 --- a/source/util/src/tbuffer.c +++ b/source/util/src/tbuffer.c @@ -21,7 +21,7 @@ typedef union Un4B { uint32_t ui; float f; } Un4B; -#if __STDC_VERSION__ >= 201112L +#if __STDC_VERSION__ >= 201112LL static_assert(sizeof(Un4B) == sizeof(uint32_t), "sizeof(Un4B) must equal to sizeof(uint32_t)"); static_assert(sizeof(Un4B) == sizeof(float), "sizeof(Un4B) must equal to sizeof(float)"); #endif @@ -30,7 +30,7 @@ typedef union Un8B { uint64_t ull; double d; } Un8B; -#if __STDC_VERSION__ >= 201112L +#if __STDC_VERSION__ >= 201112LL static_assert(sizeof(Un8B) == sizeof(uint64_t), "sizeof(Un8B) must equal to sizeof(uint64_t)"); static_assert(sizeof(Un8B) == sizeof(double), "sizeof(Un8B) must equal to sizeof(double)"); #endif diff --git a/source/util/src/tcompression.c b/source/util/src/tcompression.c index 041aec4054..38613a77e6 100644 --- a/source/util/src/tcompression.c +++ b/source/util/src/tcompression.c @@ -58,7 +58,7 @@ static const int32_t TEST_NUMBER = 1; #define is_bigendian() ((*(char *)&TEST_NUMBER) == 0) -#define SIMPLE8B_MAX_INT64 ((uint64_t)2305843009213693951L) +#define SIMPLE8B_MAX_INT64 ((uint64_t)2305843009213693951LL) #define safeInt64Add(a, b) (((a >= 0) && (b <= INT64_MAX - a)) || ((a < 0) && (b >= INT64_MIN - a))) #define ZIGZAG_ENCODE(T, v) ((u##T)((v) >> (sizeof(T) * 8 - 1))) ^ (((u##T)(v)) << 1) // zigzag encode diff --git a/source/util/src/tencode.c b/source/util/src/tencode.c index 185daf9e45..2267c90783 100644 --- a/source/util/src/tencode.c +++ b/source/util/src/tencode.c @@ -16,7 +16,7 @@ #define _DEFAULT_SOURCE #include "tencode.h" -#if __STDC_VERSION__ >= 201112L +#if __STDC_VERSION__ >= 201112LL static_assert(sizeof(float) == sizeof(uint32_t), "sizeof(float) must equal to sizeof(uint32_t)"); static_assert(sizeof(double) == sizeof(uint64_t), "sizeof(double) must equal to sizeof(uint64_t)"); #endif diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 66a73ac92b..b89e908df7 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -134,6 +134,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSC_STMT_TBNAME_ERROR, "Stmt table name not s TAOS_DEFINE_ERROR(TSDB_CODE_TSC_STMT_CLAUSE_ERROR, "not supported stmt clause") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_QUERY_KILLED, "Query killed") TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NO_EXEC_NODE, "No available execution node") +TAOS_DEFINE_ERROR(TSDB_CODE_TSC_NOT_STABLE_ERROR, "Table is not a super table") // mnode-common TAOS_DEFINE_ERROR(TSDB_CODE_MND_APP_ERROR, "Mnode internal error") diff --git a/source/util/src/thash.c b/source/util/src/thash.c index 98762d8fb0..8275072748 100644 --- a/source/util/src/thash.c +++ b/source/util/src/thash.c @@ -31,12 +31,12 @@ #define GET_HASH_NODE_DATA(_n) ((char *)(_n) + sizeof(SHashNode)) #define GET_HASH_PNODE(_n) ((SHashNode *)((char *)(_n) - sizeof(SHashNode))) -#define FREE_HASH_NODE(_fp, _n) \ - do { \ - if (_fp != NULL) { \ - (_fp)(_n); \ - } \ - taosMemoryFreeClear(_n); \ +#define FREE_HASH_NODE(_fp, _n) \ + do { \ + if (_fp != NULL) { \ + (_fp)(GET_HASH_NODE_DATA(_n)); \ + } \ + taosMemoryFreeClear(_n); \ } while (0); struct SHashNode { @@ -56,7 +56,7 @@ typedef struct SHashEntry { } SHashEntry; struct SHashObj { - SHashEntry ** hashList; + SHashEntry **hashList; size_t capacity; // number of slots int64_t size; // number of elements in hash table _hash_fn_t hashFp; // hash function @@ -65,7 +65,7 @@ struct SHashObj { SRWLatch lock; // read-write spin lock SHashLockTypeE type; // lock type bool enableUpdate; // enable update - SArray * pMemBlock; // memory block allocated for SHashEntry + SArray *pMemBlock; // memory block allocated for SHashEntry _hash_before_fn_t callbackFp; // function invoked before return the value to caller }; @@ -633,7 +633,7 @@ void taosHashTableResize(SHashObj *pHashObj) { } int64_t st = taosGetTimestampUs(); - void * pNewEntryList = taosMemoryRealloc(pHashObj->hashList, sizeof(void *) * newCapacity); + void *pNewEntryList = taosMemoryRealloc(pHashObj->hashList, sizeof(void *) * newCapacity); if (pNewEntryList == NULL) { // uDebug("cache resize failed due to out of memory, capacity remain:%zu", pHashObj->capacity); return; @@ -642,7 +642,7 @@ void taosHashTableResize(SHashObj *pHashObj) { pHashObj->hashList = pNewEntryList; size_t inc = newCapacity - pHashObj->capacity; - void * p = taosMemoryCalloc(inc, sizeof(SHashEntry)); + void *p = taosMemoryCalloc(inc, sizeof(SHashEntry)); for (int32_t i = 0; i < inc; ++i) { pHashObj->hashList[i + pHashObj->capacity] = (void *)((char *)p + i * sizeof(SHashEntry)); @@ -653,9 +653,9 @@ void taosHashTableResize(SHashObj *pHashObj) { pHashObj->capacity = newCapacity; for (int32_t idx = 0; idx < pHashObj->capacity; ++idx) { SHashEntry *pe = pHashObj->hashList[idx]; - SHashNode * pNode; - SHashNode * pNext; - SHashNode * pPrev = NULL; + SHashNode *pNode; + SHashNode *pNext; + SHashNode *pPrev = NULL; if (pe->num == 0) { assert(pe->next == NULL); diff --git a/tests/pytest/util/boundary.py b/tests/pytest/util/boundary.py new file mode 100644 index 0000000000..4cef926f2e --- /dev/null +++ b/tests/pytest/util/boundary.py @@ -0,0 +1,44 @@ +class DataBoundary: + def __init__(self): + self.TINYINT_BOUNDARY = [-128, 127] + self.SMALLINT_BOUNDARY = [-32768, 32767] + self.INT_BOUNDARY = [-2147483648, 2147483647] + self.BIGINT_BOUNDARY = [-9223372036854775808, 9223372036854775807] + self.UTINYINT_BOUNDARY = [0, 255] + self.USMALLINT_BOUNDARY = [0, 65535] + self.UINT_BOUNDARY = [0, 4294967295] + self.UBIGINT_BOUNDARY = [0, 18446744073709551615] + self.FLOAT_BOUNDARY = [-3.40E+38, 3.40E+38] + self.DOUBLE_BOUNDARY = [-1.7e+308, 1.7e+308] + self.BOOL_BOUNDARY = [True, False] + self.BINARY_MAX_LENGTH = 16374 + self.NCHAR_MAX_LENGTH = 4093 + self.DBNAME_MAX_LENGTH = 64 + self.STBNAME_MAX_LENGTH = 192 + self.TBNAME_MAX_LENGTH = 192 + self.CHILD_TBNAME_MAX_LENGTH = 192 + self.TAG_KEY_MAX_LENGTH = 64 + self.COL_KEY_MAX_LENGTH = 64 + self.MAX_TAG_COUNT = 128 + self.MAX_TAG_COL_COUNT = 4096 + self.mnodeShmSize = [6292480, 2147483647] + self.mnodeShmSize_default = 6292480 + self.vnodeShmSize = [6292480, 2147483647] + self.vnodeShmSize_default = 31458304 + self.DB_PARAM_BUFFER_CONFIG = {"create_name": "buffer", "query_name": "buffer", "vnode_json_key": "szBuf", "boundary": [3, 16384], "default": 96} + self.DB_PARAM_CACHELAST_CONFIG = {"create_name": "cachelast", "query_name": "cache_model", "vnode_json_key": "", "boundary": [0, 1, 2, 3], "default": 0} + self.DB_PARAM_COMP_CONFIG = {"create_name": "comp", "query_name": "compression", "vnode_json_key": "", "boundary": [0, 1, 2], "default": 2} + self.DB_PARAM_DURATION_CONFIG = {"create_name": "duration", "query_name": "duration", "vnode_json_key": "daysPerFile", "boundary": [1, 3650, '60m', '5256000m', '1h', '87600h', '1d', '3650d'], "default": "14400m"} + self.DB_PARAM_FSYNC_CONFIG = {"create_name": "fsync", "query_name": "fsync", "vnode_json_key": "", "boundary": [0, 180000], "default": 3000} + self.DB_PARAM_KEEP_CONFIG = {"create_name": "keep", "query_name": "fsync", "vnode_json_key": "", "boundary": [1, 365000,'1440m','525600000m','24h','8760000h','1d','365000d'], "default": "5256000m,5256000m,5256000m"} + self.DB_PARAM_MAXROWS_CONFIG = {"create_name": "maxrows", "query_name": "maxrows", "vnode_json_key": "maxRows", "boundary": [200, 10000], "default": 4096} + self.DB_PARAM_MINROWS_CONFIG = {"create_name": "minrows", "query_name": "minrows", "vnode_json_key": "minRows", "boundary": [10, 1000], "default": 100} + self.DB_PARAM_NTABLES_CONFIG = {"create_name": "ntables", "query_name": "ntables", "vnode_json_key": "", "boundary": 0, "default": 0} + self.DB_PARAM_PAGES_CONFIG = {"create_name": "pages", "query_name": "pages", "vnode_json_key": "szCache", "boundary": [64], "default": 256} + self.DB_PARAM_PAGESIZE_CONFIG = {"create_name": "pagesize", "query_name": "pagesize", "vnode_json_key": "szPage", "boundary": [1, 16384], "default": 4} + self.DB_PARAM_PRECISION_CONFIG = {"create_name": "precision", "query_name": "precision", "vnode_json_key": "", "boundary": ['ms', 'us', 'ns'], "default": "ms"} + self.DB_PARAM_REPLICA_CONFIG = {"create_name": "replica", "query_name": "replica", "vnode_json_key": "", "boundary": [1], "default": 1} + self.DB_PARAM_SINGLE_STABLE_CONFIG = {"create_name": "single_stable", "query_name": "single_stable_model", "vnode_json_key": "", "boundary": [0, 1], "default": 0} + self.DB_PARAM_STRICT_CONFIG = {"create_name": "strict", "query_name": "strict", "vnode_json_key": "", "boundary": {"no_strict": 0, "strict": 1}, "default": "no_strict"} + self.DB_PARAM_VGROUPS_CONFIG = {"create_name": "vgroups", "query_name": "vgroups", "vnode_json_key": "", "boundary": [1, 32], "default": 2} + self.DB_PARAM_WAL_CONFIG = {"create_name": "wal", "query_name": "wal", "vnode_json_key": "", "boundary": [1, 2], "default": 1} \ No newline at end of file diff --git a/tests/pytest/util/cluster.py b/tests/pytest/util/cluster.py new file mode 100644 index 0000000000..5debfab2c4 --- /dev/null +++ b/tests/pytest/util/cluster.py @@ -0,0 +1,302 @@ +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE +import taos +import sys +import time +import os +import socket + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * + +class ClusterDnodes(TDDnodes): + """rewrite TDDnodes and make MyDdnodes as TDDnodes child class""" + def __init__(self ,dnodes_lists): + + super(ClusterDnodes,self).__init__() + self.dnodes = dnodes_lists # dnode must be TDDnode instance + self.simDeployed = False + self.testCluster = False + self.valgrind = 0 + self.killValgrind = 1 + self.independent = True + self.dnodeNums = 5 + + # def getTDDnodes(dnodeNums): + + # return + + +class ConfigureyCluster: + """configure dnodes and return TDDnodes list, it can """ + + def __init__(self): + self.dnodes = None + self.dnodes_nums = 5 + self.independent = True + self.start_port = 6030 + self.portStep = 100 + hostname1= socket.gethostname() + + def configure_cluster(self ,dnodes_nums=5,independent=True,start_port=6030,portStep=100,hostname="%s"%hostname1): + self.start_port=int(start_port) + self.portStep=int(portStep) + self.hostname=hostname + self.dnodes_nums = int(dnodes_nums) + self.independent = independent + self.dnodes = [] + start_port_sec = 6130 + for num in range(1, (self.dnodes_nums+1)): + dnode = TDDnode(num) + dnode.addExtraCfg("firstEp", f"{hostname}:{self.start_port}") + dnode.addExtraCfg("fqdn", f"{hostname}") + dnode.addExtraCfg("serverPort", f"{self.start_port + (num-1)*self.portStep}") + # dnode.addExtraCfg("monitorFqdn", hostname) + # dnode.addExtraCfg("monitorPort", 7043) + dnode.addExtraCfg("secondEp", f"{hostname}:{start_port_sec}") + # configure three dnoe don't support vnodes + if self.dnodes_nums > 4 : + if self.independent and (num < 4): + dnode.addExtraCfg("supportVnodes", 0) + # print(dnode) + self.dnodes.append(dnode) + return self.dnodes + + def create_dnode(self,conn): + tdSql.init(conn.cursor()) + for dnode in self.dnodes[1:]: + # print(dnode.cfgDict) + dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] + print(dnode_id) + tdSql.execute(" create dnode '%s';"%dnode_id) + # count=0 + # while count < 10: + # time.sleep(1) + # tdSql.query("show dnodes;") + # if tdSql.checkRows(self.dnodes_nums) : + # print("mnode is three nodes") + # if tdSql.queryResult[0][4]=='leader' : + # if tdSql.queryResult[2][4]=='offline': + # if tdSql.queryResult[1][2]=='follower': + # print("stop mnodes on dnode 3 successfully in 10s") + # break + # count+=1 + # else: + # print("stop mnodes on dnode 3 failed in 10s") + # return -1 + checkstatus=False + + + + def check_dnode(self,conn): + tdSql.init(conn.cursor()) + count=0 + while count < 5: + tdSql.query("show dnodes") + # tdLog.debug(tdSql.queryResult) + status=0 + for i in range(self.dnodes_nums): + if tdSql.queryResult[i][4] == "ready": + status+=1 + tdLog.debug(status) + + if status == self.dnodes_nums: + tdLog.debug(" create cluster with %d dnode and check cluster dnode all ready within 5s! " %self.dnodes_nums) + break + count+=1 + time.sleep(1) + else: + tdLog.debug("create cluster with %d dnode but check dnode not ready within 5s ! "%self.dnodes_nums) + return -1 + + +cluster = ConfigureyCluster() + + # def start(self ,dnodes_nums): + + # self.TDDnodes = ClusterDnodes(dnodes) + # self.TDDnodes.init("") + # self.TDDnodes.setTestCluster(testCluster) + # self.TDDnodes.setValgrind(valgrind) + # self.TDDnodes.stopAll() + # for dnode in self.TDDnodes.dnodes: + # self.TDDnodes.deploy(dnode.index,{}) + + # for dnode in self.TDDnodes.dnodes: + # self.TDDnodes.starttaosd(dnode.index) + + # # create cluster + # for dnode in self.TDDnodes.dnodes[1:]: + # # print(dnode.cfgDict) + # dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] + # dnode_first_host = dnode.cfgDict["firstEp"].split(":")[0] + # dnode_first_port = dnode.cfgDict["firstEp"].split(":")[-1] + # cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;" + # print(cmd) + # os.system(cmd) + + # time.sleep(2) + # tdLog.info(" create cluster with %d dnode done! " %dnodes_nums) + + # def buildcluster(self,dnodenumber): + # self.depoly_cluster(dnodenumber) + # self.master_dnode = self.TDDnodes.dnodes[0] + # self.host=self.master_dnode.cfgDict["fqdn"] + # conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir) + # tdSql.init(conn1.cursor()) + + # def checkdnodes(self,dnodenumber): + # count=0 + # while count < 10: + # time.sleep(1) + # statusReadyBumber=0 + # tdSql.query("show dnodes;") + # if tdSql.checkRows(dnodenumber) : + # print("dnode is %d nodes"%dnodenumber) + # for i in range(dnodenumber): + # if tdSql.queryResult[i][4] !='ready' : + # status=tdSql.queryResult[i][4] + # print("dnode:%d status is %s "%(i,status)) + # break + # else: + # statusReadyBumber+=1 + # print(statusReadyBumber) + # if statusReadyBumber == dnodenumber : + # print("all of %d mnodes is ready in 10s "%dnodenumber) + # return True + # break + # count+=1 + # else: + # print("%d mnodes is not ready in 10s "%dnodenumber) + # return False + + + # def check3mnode(self): + # count=0 + # while count < 10: + # time.sleep(1) + # tdSql.query("show mnodes;") + # if tdSql.checkRows(3) : + # print("mnode is three nodes") + # if tdSql.queryResult[0][2]=='leader' : + # if tdSql.queryResult[1][2]=='follower': + # if tdSql.queryResult[2][2]=='follower': + # print("three mnodes is ready in 10s") + # break + # elif tdSql.queryResult[0][2]=='follower' : + # if tdSql.queryResult[1][2]=='leader': + # if tdSql.queryResult[2][2]=='follower': + # print("three mnodes is ready in 10s") + # break + # elif tdSql.queryResult[0][2]=='follower' : + # if tdSql.queryResult[1][2]=='follower': + # if tdSql.queryResult[2][2]=='leader': + # print("three mnodes is ready in 10s") + # break + # count+=1 + # else: + # print("three mnodes is not ready in 10s ") + # return -1 + + # tdSql.query("show mnodes;") + # tdSql.checkRows(3) + # tdSql.checkData(0,1,'%s:6030'%self.host) + # tdSql.checkData(0,3,'ready') + # tdSql.checkData(1,1,'%s:6130'%self.host) + # tdSql.checkData(1,3,'ready') + # tdSql.checkData(2,1,'%s:6230'%self.host) + # tdSql.checkData(2,3,'ready') + + # def check3mnode1off(self): + # count=0 + # while count < 10: + # time.sleep(1) + # tdSql.query("show mnodes;") + # if tdSql.checkRows(3) : + # print("mnode is three nodes") + # if tdSql.queryResult[0][2]=='offline' : + # if tdSql.queryResult[1][2]=='leader': + # if tdSql.queryResult[2][2]=='follower': + # print("stop mnodes on dnode 2 successfully in 10s") + # break + # elif tdSql.queryResult[1][2]=='follower': + # if tdSql.queryResult[2][2]=='leader': + # print("stop mnodes on dnode 2 successfully in 10s") + # break + # count+=1 + # else: + # print("stop mnodes on dnode 2 failed in 10s ") + # return -1 + # tdSql.error("drop mnode on dnode 1;") + + # tdSql.query("show mnodes;") + # tdSql.checkRows(3) + # tdSql.checkData(0,1,'%s:6030'%self.host) + # tdSql.checkData(0,2,'offline') + # tdSql.checkData(0,3,'ready') + # tdSql.checkData(1,1,'%s:6130'%self.host) + # tdSql.checkData(1,3,'ready') + # tdSql.checkData(2,1,'%s:6230'%self.host) + # tdSql.checkData(2,3,'ready') + + # def check3mnode2off(self): + # count=0 + # while count < 40: + # time.sleep(1) + # tdSql.query("show mnodes;") + # if tdSql.checkRows(3) : + # print("mnode is three nodes") + # if tdSql.queryResult[0][2]=='leader' : + # if tdSql.queryResult[1][2]=='offline': + # if tdSql.queryResult[2][2]=='follower': + # print("stop mnodes on dnode 2 successfully in 10s") + # break + # count+=1 + # else: + # print("stop mnodes on dnode 2 failed in 10s ") + # return -1 + # tdSql.error("drop mnode on dnode 2;") + + # tdSql.query("show mnodes;") + # tdSql.checkRows(3) + # tdSql.checkData(0,1,'%s:6030'%self.host) + # tdSql.checkData(0,2,'leader') + # tdSql.checkData(0,3,'ready') + # tdSql.checkData(1,1,'%s:6130'%self.host) + # tdSql.checkData(1,2,'offline') + # tdSql.checkData(1,3,'ready') + # tdSql.checkData(2,1,'%s:6230'%self.host) + # tdSql.checkData(2,2,'follower') + # tdSql.checkData(2,3,'ready') + + # def check3mnode3off(self): + # count=0 + # while count < 10: + # time.sleep(1) + # tdSql.query("show mnodes;") + # if tdSql.checkRows(3) : + # print("mnode is three nodes") + # if tdSql.queryResult[0][2]=='leader' : + # if tdSql.queryResult[2][2]=='offline': + # if tdSql.queryResult[1][2]=='follower': + # print("stop mnodes on dnode 3 successfully in 10s") + # break + # count+=1 + # else: + # print("stop mnodes on dnode 3 failed in 10s") + # return -1 + # tdSql.error("drop mnode on dnode 3;") + # tdSql.query("show mnodes;") + # tdSql.checkRows(3) + # tdSql.checkData(0,1,'%s:6030'%self.host) + # tdSql.checkData(0,2,'leader') + # tdSql.checkData(0,3,'ready') + # tdSql.checkData(1,1,'%s:6130'%self.host) + # tdSql.checkData(1,2,'follower') + # tdSql.checkData(1,3,'ready') + # tdSql.checkData(2,1,'%s:6230'%self.host) + # tdSql.checkData(2,2,'offline') + # tdSql.checkData(2,3,'ready') + diff --git a/tests/pytest/util/common.py b/tests/pytest/util/common.py index e158f8edd2..b43f87be29 100644 --- a/tests/pytest/util/common.py +++ b/tests/pytest/util/common.py @@ -17,7 +17,7 @@ import string import requests import time import socket - +from .boundary import DataBoundary import taos from util.log import * from util.sql import * @@ -25,9 +25,45 @@ from util.cases import * from util.dnodes import * from util.common import * -class TDCom: - def init(self, conn, logSql): - tdSql.init(conn.cursor(), logSql) +class TDCom: + def __init__(self): + self.sml_type = None + self.env_setting = None + self.smlChildTableName_value = None + self.defaultJSONStrType_value = None + self.smlTagNullName_value = None + self.default_varchar_length = 256 + self.default_nchar_length = 256 + self.default_varchar_datatype = "letters" + self.default_nchar_datatype = "letters" + self.default_tagname_prefix = "t" + self.default_colname_prefix = "c" + self.default_stbname_prefix = "stb" + self.default_ctbname_prefix = "ctb" + self.default_tbname_prefix = "tb" + self.default_tag_index_start_num = 1 + self.default_column_index_start_num = 1 + self.default_stbname_index_start_num = 1 + self.default_ctbname_index_start_num = 1 + self.default_tbname_index_start_num = 1 + self.default_tagts_name = "ts" + self.default_colts_name = "ts" + self.dbname = "test" + self.stb_name = "stb" + self.ctb_name = "ctb" + self.tb_name = "tb" + self.need_tagts = False + self.tag_type_str = "" + self.column_type_str = "" + self.columns_str = None + self.ts_value = None + self.tag_value_list = list() + self.column_value_list = list() + self.full_type_list = ["tinyint", "smallint", "int", "bigint", "tinyint unsigned", "smallint unsigned", "int unsigned", "bigint unsigned", "float", "double", "binary", "nchar", "bool"] + self.white_list = ["statsd", "node_exporter", "collectd", "icinga2", "tcollector", "information_schema", "performance_schema"] + self.Boundary = DataBoundary() + # def init(self, conn, logSql): + # # tdSql.init(conn.cursor(), logSql) def preDefine(self): header = {'Authorization': 'Basic cm9vdDp0YW9zZGF0YQ=='} @@ -113,6 +149,59 @@ class TDCom: def dateToTs(self, datetime_input): return int(time.mktime(time.strptime(datetime_input, "%Y-%m-%d %H:%M:%S.%f"))) + def genTs(self, precision="ms", ts="", protype="taosc", ns_tag=None): + """ + protype = "taosc" or "restful" + gen ts and datetime + """ + if precision == "ns": + if ts == "" or ts is None: + ts = time.time_ns() + else: + ts = ts + if ns_tag is None: + dt = ts + else: + dt = datetime.fromtimestamp(ts // 1000000000) + dt = dt.strftime('%Y-%m-%d %H:%M:%S') + '.' + str(int(ts % 1000000000)).zfill(9) + if protype == "restful": + dt = datetime.fromtimestamp(ts // 1000000000) + dt = dt.strftime('%Y-%m-%d %H:%M:%S') + '.' + str(int(ts % 1000000000)).zfill(9) + else: + if ts == "" or ts is None: + ts = time.time() + else: + ts = ts + if precision == "ms" or precision is None: + ts = int(round(ts * 1000)) + dt = datetime.fromtimestamp(ts // 1000) + if protype == "taosc": + dt = dt.strftime('%Y-%m-%d %H:%M:%S') + '.' + str(int(ts % 1000)).zfill(3) + '000' + elif protype == "restful": + dt = dt.strftime('%Y-%m-%d %H:%M:%S') + '.' + str(int(ts % 1000)).zfill(3) + else: + pass + elif precision == "us": + ts = int(round(ts * 1000000)) + dt = datetime.fromtimestamp(ts // 1000000) + dt = dt.strftime('%Y-%m-%d %H:%M:%S') + '.' + str(int(ts % 1000000)).zfill(6) + return ts, dt + + def get_long_name(self, length=10, mode="letters"): + """ + generate long name + mode could be numbers/letters/letters_mixed/mixed + """ + if mode == "numbers": + population = string.digits + elif mode == "letters": + population = string.ascii_letters.lower() + elif mode == "letters_mixed": + population = string.ascii_letters.upper() + string.ascii_letters.lower() + else: + population = string.ascii_letters.lower() + string.digits + return "".join(random.choices(population, k=length)) + def getLongName(self, len, mode = "mixed"): """ generate long name @@ -177,84 +266,92 @@ class TDCom: def close(self): self.cursor.close() - def create_database(self,tsql, dbName='test',dropFlag=1,precision="ms", **kwargs): + ######################################################################################################################################## + # new common API + ######################################################################################################################################## + def create_database(self,tsql, dbName='test',dropFlag=1,**kwargs): if dropFlag == 1: tsql.execute("drop database if exists %s"%(dbName)) ''' vgroups replica precision strict wal fsync comp cachelast single_stable buffer pagesize pages minrows maxrows duration keep retentions ''' - sqlString = f'create database if not exists {dbName} precision "{precision}" vgroups 4' + sqlString = f'create database if not exists {dbName} ' + + dbParams = "" if len(kwargs) > 0: - dbParams = "" for param, value in kwargs.items(): - dbParams += f'{param} {value} ' + if param == "precision": + dbParams += f'{param} "{value}" ' + else: + dbParams += f'{param} {value} ' sqlString += f'{dbParams}' + tdLog.debug("create db sql: %s"%sqlString) tsql.execute(sqlString) tdLog.debug("complete to create database %s"%(dbName)) return - def create_stable(self,tsql, dbName,stbName,columnDict,tagDict): - colSchema = '' - for i in range(columnDict['int']): - colSchema += ', c%d int'%i - tagSchema = '' - for i in range(tagDict['int']): - if i > 0: - tagSchema += ',' - tagSchema += 't%d int'%i + # def create_stable(self,tsql, dbName,stbName,column_elm_list=None, tag_elm_list=None): + # colSchema = '' + # for i in range(columnDict['int']): + # colSchema += ', c%d int'%i + # tagSchema = '' + # for i in range(tagDict['int']): + # if i > 0: + # tagSchema += ',' + # tagSchema += 't%d int'%i - tsql.execute("create table if not exists %s.%s (ts timestamp %s) tags(%s)"%(dbName, stbName, colSchema, tagSchema)) - tdLog.debug("complete to create %s.%s" %(dbName, stbName)) - return + # tsql.execute("create table if not exists %s.%s (ts timestamp %s) tags(%s)"%(dbName, stbName, colSchema, tagSchema)) + # tdLog.debug("complete to create %s.%s" %(dbName, stbName)) + # return - def create_ctables(self,tsql, dbName,stbName,ctbNum,tagDict): - tsql.execute("use %s" %dbName) - tagsValues = '' - for i in range(tagDict['int']): - if i > 0: - tagsValues += ',' - tagsValues += '%d'%i + # def create_ctables(self,tsql, dbName,stbName,ctbNum,tagDict): + # tsql.execute("use %s" %dbName) + # tagsValues = '' + # for i in range(tagDict['int']): + # if i > 0: + # tagsValues += ',' + # tagsValues += '%d'%i - pre_create = "create table" - sql = pre_create - #tdLog.debug("doing create one stable %s and %d child table in %s ..." %(stbname, count ,dbname)) - for i in range(ctbNum): - sql += " %s_%d using %s tags(%s)"%(stbName,i,stbName,tagsValues) - if (i > 0) and (i%100 == 0): - tsql.execute(sql) - sql = pre_create - if sql != pre_create: - tsql.execute(sql) + # pre_create = "create table" + # sql = pre_create + # #tdLog.debug("doing create one stable %s and %d child table in %s ..." %(stbname, count ,dbname)) + # for i in range(ctbNum): + # sql += " %s_%d using %s tags(%s)"%(stbName,i,stbName,tagsValues) + # if (i > 0) and (i%100 == 0): + # tsql.execute(sql) + # sql = pre_create + # if sql != pre_create: + # tsql.execute(sql) - tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) - return + # tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) + # return - def insert_data(self,tsql,dbName,stbName,ctbNum,rowsPerTbl,batchNum,startTs=0): - tdLog.debug("start to insert data ............") - tsql.execute("use %s" %dbName) - pre_insert = "insert into " - sql = pre_insert - if startTs == 0: - t = time.time() - startTs = int(round(t * 1000)) - #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) - for i in range(ctbNum): - sql += " %s_%d values "%(stbName,i) - for j in range(rowsPerTbl): - sql += "(%d, %d, %d)"%(startTs + j, j, j) - if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)): - tsql.execute(sql) - if j < rowsPerTbl - 1: - sql = "insert into %s_%d values " %(stbName,i) - else: - sql = "insert into " - #end sql - if sql != pre_insert: - #print("insert sql:%s"%sql) - tsql.execute(sql) - tdLog.debug("insert data ............ [OK]") - return + # def insert_data(self,tsql,dbName,stbName,ctbNum,rowsPerTbl,batchNum,startTs=0): + # tdLog.debug("start to insert data ............") + # tsql.execute("use %s" %dbName) + # pre_insert = "insert into " + # sql = pre_insert + # if startTs == 0: + # t = time.time() + # startTs = int(round(t * 1000)) + # #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) + # for i in range(ctbNum): + # sql += " %s_%d values "%(stbName,i) + # for j in range(rowsPerTbl): + # sql += "(%d, %d, %d)"%(startTs + j, j, j) + # if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)): + # tsql.execute(sql) + # if j < rowsPerTbl - 1: + # sql = "insert into %s_%d values " %(stbName,i) + # else: + # sql = "insert into " + # #end sql + # if sql != pre_insert: + # #print("insert sql:%s"%sql) + # tsql.execute(sql) + # tdLog.debug("insert data ............ [OK]") + # return def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -295,4 +392,250 @@ class TDCom: newTdSql.init(cur, False) return newTdSql + ################################################################################################################ + # port from the common.py of new test frame + ################################################################################################################ + def gen_default_tag_str(self): + default_tag_str = "" + for tag_type in self.full_type_list: + if tag_type.lower() not in ["varchar", "binary", "nchar"]: + default_tag_str += f" {self.default_tagname_prefix}{self.default_tag_index_start_num} {tag_type}," + else: + if tag_type.lower() in ["varchar", "binary"]: + default_tag_str += f" {self.default_tagname_prefix}{self.default_tag_index_start_num} {tag_type}({self.default_varchar_length})," + else: + default_tag_str += f" {self.default_tagname_prefix}{self.default_tag_index_start_num} {tag_type}({self.default_nchar_length})," + self.default_tag_index_start_num += 1 + if self.need_tagts: + default_tag_str = self.default_tagts_name + " timestamp," + default_tag_str + return default_tag_str[:-1].lstrip() + + def gen_default_column_str(self): + self.default_column_index_start_num = 1 + default_column_str = "" + for col_type in self.full_type_list: + if col_type.lower() not in ["varchar", "binary", "nchar"]: + default_column_str += f" {self.default_colname_prefix}{self.default_column_index_start_num} {col_type}," + else: + if col_type.lower() in ["varchar", "binary"]: + default_column_str += f" {self.default_colname_prefix}{self.default_column_index_start_num} {col_type}({self.default_varchar_length})," + else: + default_column_str += f" {self.default_colname_prefix}{self.default_column_index_start_num} {col_type}({self.default_nchar_length})," + self.default_column_index_start_num += 1 + default_column_str = self.default_colts_name + " timestamp," + default_column_str + return default_column_str[:-1].lstrip() + + def gen_tag_type_str(self, tagname_prefix, tag_elm_list): + tag_index_start_num = 1 + tag_type_str = "" + if tag_elm_list is None: + tag_type_str = self.gen_default_tag_str() + else: + for tag_elm in tag_elm_list: + if "count" in tag_elm: + total_count = int(tag_elm["count"]) + else: + total_count = 1 + if total_count > 0: + for _ in range(total_count): + tag_type_str += f'{tagname_prefix}{tag_index_start_num} {tag_elm["type"]}, ' + if tag_elm["type"] in ["varchar", "binary", "nchar"]: + tag_type_str = tag_type_str.rstrip()[:-1] + f'({tag_elm["len"]}), ' + tag_index_start_num += 1 + else: + continue + tag_type_str = tag_type_str.rstrip()[:-1] + + return tag_type_str + + def gen_column_type_str(self, colname_prefix, column_elm_list): + column_index_start_num = 1 + column_type_str = "" + if column_elm_list is None: + column_type_str = self.gen_default_column_str() + else: + for column_elm in column_elm_list: + if "count" in column_elm: + total_count = int(column_elm["count"]) + else: + total_count = 1 + if total_count > 0: + for _ in range(total_count): + column_type_str += f'{colname_prefix}{column_index_start_num} {column_elm["type"]}, ' + if column_elm["type"] in ["varchar", "binary", "nchar"]: + column_type_str = column_type_str.rstrip()[:-1] + f'({column_elm["len"]}), ' + column_index_start_num += 1 + else: + continue + column_type_str = self.default_colts_name + " timestamp, " + column_type_str.rstrip()[:-1] + return column_type_str + + def gen_random_type_value(self, type_name, binary_length, binary_type, nchar_length, nchar_type): + if type_name.lower() == "tinyint": + return random.randint(self.Boundary.TINYINT_BOUNDARY[0], self.Boundary.TINYINT_BOUNDARY[1]) + elif type_name.lower() == "smallint": + return random.randint(self.Boundary.SMALLINT_BOUNDARY[0], self.Boundary.SMALLINT_BOUNDARY[1]) + elif type_name.lower() == "int": + return random.randint(self.Boundary.INT_BOUNDARY[0], self.Boundary.INT_BOUNDARY[1]) + elif type_name.lower() == "bigint": + return random.randint(self.Boundary.BIGINT_BOUNDARY[0], self.Boundary.BIGINT_BOUNDARY[1]) + elif type_name.lower() == "tinyint unsigned": + return random.randint(self.Boundary.UTINYINT_BOUNDARY[0], self.Boundary.UTINYINT_BOUNDARY[1]) + elif type_name.lower() == "smallint unsigned": + return random.randint(self.Boundary.USMALLINT_BOUNDARY[0], self.Boundary.USMALLINT_BOUNDARY[1]) + elif type_name.lower() == "int unsigned": + return random.randint(self.Boundary.UINT_BOUNDARY[0], self.Boundary.UINT_BOUNDARY[1]) + elif type_name.lower() == "bigint unsigned": + return random.randint(self.Boundary.UBIGINT_BOUNDARY[0], self.Boundary.UBIGINT_BOUNDARY[1]) + elif type_name.lower() == "float": + return random.uniform(self.Boundary.FLOAT_BOUNDARY[0], self.Boundary.FLOAT_BOUNDARY[1]) + elif type_name.lower() == "double": + return random.uniform(self.Boundary.FLOAT_BOUNDARY[0], self.Boundary.FLOAT_BOUNDARY[1]) + elif type_name.lower() == "binary": + return f'{self.get_long_name(binary_length, binary_type)}' + elif type_name.lower() == "varchar": + return self.get_long_name(binary_length, binary_type) + elif type_name.lower() == "nchar": + return self.get_long_name(nchar_length, nchar_type) + elif type_name.lower() == "bool": + return random.choice(self.Boundary.BOOL_BOUNDARY) + elif type_name.lower() == "timestamp": + return self.genTs()[0] + else: + pass + + def gen_tag_value_list(self, tag_elm_list): + tag_value_list = list() + if tag_elm_list is None: + tag_value_list = list(map(lambda i: self.gen_random_type_value(i, self.default_varchar_length, self.default_varchar_datatype, self.default_nchar_length, self.default_nchar_datatype), self.full_type_list)) + else: + for tag_elm in tag_elm_list: + if "count" in tag_elm: + total_count = int(tag_elm["count"]) + else: + total_count = 1 + if total_count > 0: + for _ in range(total_count): + if tag_elm["type"] in ["varchar", "binary", "nchar"]: + tag_value_list.append(self.gen_random_type_value(tag_elm["type"], tag_elm["len"], self.default_varchar_datatype, tag_elm["len"], self.default_nchar_datatype)) + else: + tag_value_list.append(self.gen_random_type_value(tag_elm["type"], "", "", "", "")) + else: + continue + return tag_value_list + + def gen_column_value_list(self, column_elm_list, ts_value=None): + if ts_value is None: + ts_value = self.genTs()[0] + + column_value_list = list() + if column_elm_list is None: + column_value_list = list(map(lambda i: self.gen_random_type_value(i, self.default_varchar_length, self.default_varchar_datatype, self.default_nchar_length, self.default_nchar_datatype), self.full_type_list)) + else: + for column_elm in column_elm_list: + if "count" in column_elm: + total_count = int(column_elm["count"]) + else: + total_count = 1 + if total_count > 0: + for _ in range(total_count): + if column_elm["type"] in ["varchar", "binary", "nchar"]: + column_value_list.append(self.gen_random_type_value(column_elm["type"], column_elm["len"], self.default_varchar_datatype, column_elm["len"], self.default_nchar_datatype)) + else: + column_value_list.append(self.gen_random_type_value(column_elm["type"], "", "", "", "")) + else: + continue + column_value_list = [self.ts_value] + self.column_value_list + return column_value_list + + def create_stable(self, tsql, dbname=None, stbname="stb", column_elm_list=None, tag_elm_list=None, + count=1, default_stbname_prefix="stb", **kwargs): + colname_prefix = 'c' + tagname_prefix = 't' + stbname_index_start_num = 1 + stb_params = "" + if len(kwargs) > 0: + for param, value in kwargs.items(): + stb_params += f'{param} "{value}" ' + column_type_str = self.gen_column_type_str(colname_prefix, column_elm_list) + tag_type_str = self.gen_tag_type_str(tagname_prefix, tag_elm_list) + + if int(count) <= 1: + create_stable_sql = f'create table {dbname}.{stbname} ({column_type_str}) tags ({tag_type_str}) {stb_params};' + tdLog.info("create stb sql: %s"%create_stable_sql) + tsql.execute(create_stable_sql) + else: + for _ in range(count): + create_stable_sql = f'create table {dbname}.{default_stbname_prefix}{stbname_index_start_num} ({column_type_str}) tags ({tag_type_str}) {stb_params};' + stbname_index_start_num += 1 + tsql.execute(create_stable_sql) + + def create_ctable(self, tsql, dbname=None, stbname=None, tag_elm_list=None, count=1, default_ctbname_prefix="ctb", **kwargs): + ctbname_index_start_num = 0 + ctb_params = "" + if len(kwargs) > 0: + for param, value in kwargs.items(): + ctb_params += f'{param} "{value}" ' + tag_value_list = self.gen_tag_value_list(tag_elm_list) + tag_value_str = "" + # tag_value_str = ", ".join(str(v) for v in self.tag_value_list) + for tag_value in tag_value_list: + if isinstance(tag_value, str): + tag_value_str += f'"{tag_value}", ' + else: + tag_value_str += f'{tag_value}, ' + tag_value_str = tag_value_str.rstrip()[:-1] + + if int(count) <= 1: + create_ctable_sql = f'create table {dbname}.{default_ctbname_prefix}{ctbname_index_start_num} using {dbname}.{stbname} tags ({tag_value_str}) {ctb_params};' + tsql.execute(create_ctable_sql) + else: + for _ in range(count): + create_ctable_sql = f'create table {dbname}.{default_ctbname_prefix}{ctbname_index_start_num} using {dbname}.{stbname} tags ({tag_value_str}) {ctb_params};' + ctbname_index_start_num += 1 + tdLog.info("create ctb sql: %s"%create_ctable_sql) + tsql.execute(create_ctable_sql) + + def create_table(self, tsql, dbname=None, tbname="ntb", column_elm_list=None, count=1, **kwargs): + tbname_index_start_num = 1 + tbname_prefix="ntb" + + tb_params = "" + if len(kwargs) > 0: + for param, value in kwargs.items(): + tb_params += f'{param} "{value}" ' + column_type_str = self.gen_column_type_str(tbname_prefix, column_elm_list) + + if int(count) <= 1: + create_table_sql = f'create table {dbname}.{tbname} ({column_type_str}) {tb_params};' + tsql.execute(create_table_sql) + else: + for _ in range(count): + create_table_sql = f'create table {dbname}.{tbname_prefix}{tbname_index_start_num} ({column_type_str}) {tb_params};' + tbname_index_start_num += 1 + tsql.execute(create_table_sql) + + def insert_rows(self, tsql, dbname=None, tbname=None, column_ele_list=None, start_ts_value=None, count=1): + if start_ts_value is None: + start_ts_value = self.genTs()[0] + + column_value_list = self.gen_column_value_list(column_ele_list, start_ts_value) + # column_value_str = ", ".join(str(v) for v in self.column_value_list) + column_value_str = "" + for column_value in column_value_list: + if isinstance(column_value, str): + column_value_str += f'"{column_value}", ' + else: + column_value_str += f'{column_value}, ' + column_value_str = column_value_str.rstrip()[:-1] + if int(count) <= 1: + insert_sql = f'insert into {self.tb_name} values ({column_value_str});' + tsql.execute(insert_sql) + else: + for num in range(count): + column_value_list = self.gen_column_value_list(column_ele_list, f'{start_ts_value}+{num}s') + column_value_str = ", ".join(str(v) for v in column_value_list) + insert_sql = f'insert into {dbname}.{tbname} values ({column_value_str});' + tsql.execute(insert_sql) + tdCom = TDCom() diff --git a/tests/pytest/util/constant.py b/tests/pytest/util/constant.py new file mode 100644 index 0000000000..e5095c74dc --- /dev/null +++ b/tests/pytest/util/constant.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- + +# basic data type boundary +TINYINT_MAX = 127 +TINYINT_MIN = -128 + +TINYINT_UN_MAX = 255 +TINYINT_UN_MIN = 0 + +SMALLINT_MAX = 32767 +SMALLINT_MIN = -32768 + +SMALLINT_UN_MAX = 65535 +MALLINT_UN_MIN = 0 + +INT_MAX = 2147483647 +INT_MIN = -2147483648 + +INT_UN_MAX = 4294967295 +INT_UN_MIN = 0 + +BIGINT_MAX = 9223372036854775807 +BIGINT_MIN = -9223372036854775808 + +BIGINT_UN_MAX = 18446744073709551615 +BIGINT_UN_MIN = 0 + +FLOAT_MAX = 3.40E+38 +FLOAT_MIN = -3.40E+38 + +DOUBLE_MAX = 1.7E+308 +DOUBLE_MIN = -1.7E+308 + +# schema boundary +BINARY_LENGTH_MAX = 16374 +NCAHR_LENGTH_MAX_ = 4093 +DBNAME_LENGTH_MAX_ = 64 + +STBNAME_LENGTH_MAX = 192 +STBNAME_LENGTH_MIN = 1 + +TBNAME_LENGTH_MAX = 192 +TBNAME_LENGTH_MIN = 1 + +CHILD_TBNAME_LENGTH_MAX = 192 +CHILD_TBNAME_LENGTH_MIN = 1 + +TAG_NAME_LENGTH_MAX = 64 +TAG_NAME_LENGTH_MIN = 1 + +COL_NAME_LENGTH_MAX = 64 +COL_NAME_LENGTH_MIN = 1 + +TAG_COUNT_MAX = 128 +TAG_COUNT_MIN = 1 + +COL_COUNT_MAX = 4096 +COL_COUNT_MIN = 2 + +TAG_COL_COUNT_MAX = 4096 +TAG_COL_COUNT_MIN = 3 + +MNODE_SHM_SIZE_MAX = 2147483647 +MNODE_SHM_SIZE_MIN = 6292480 +MNODE_SHM_SIZE_DEFAULT = 6292480 + +VNODE_SHM_SIZE_MAX = 2147483647 +VNODE_SHM_SIZE_MIN = 6292480 +VNODE_SHM_SIZE_DEFAULT = 31458304 \ No newline at end of file diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index b7c6dce018..580fc8ee47 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -61,7 +61,7 @@ class TDSql: self.cursor.execute(s) s = 'use db' self.cursor.execute(s) - time.sleep(2) + time.sleep(2) def error(self, sql): expectErrNotOccured = True @@ -249,7 +249,7 @@ class TDSql: raise Exception(repr(e)) return self.queryResult - + def executeTimes(self, sql, times): for i in range(times): try: diff --git a/tests/pytest/util/sqlset.py b/tests/pytest/util/sqlset.py new file mode 100644 index 0000000000..939f53154a --- /dev/null +++ b/tests/pytest/util/sqlset.py @@ -0,0 +1,46 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +from util.sql import tdSql + +class TDSetSql: + def init(self, conn, logSql): + tdSql.init(conn.cursor(), logSql) + self.stbname = 'stb' + + def set_create_normaltable_sql(self, ntbname='ntb', + column_dict={'ts':'timestamp','col1':'tinyint','col2':'smallint','col3':'int','col4':'bigint','col5': 'unsigned int','col6': 'unsigned tinyint','col7': 'unsigned smallint', + 'col8': 'unsigned int','col9': 'unsigned bigint','col10': 'float','col11': 'double','col12': 'bool','col13': 'binary(20)','col14': 'nchar(20)'}): + column_sql = '' + for k, v in column_dict.items(): + column_sql += f"{k} {v}," + create_ntb_sql = f'create table {ntbname} ({column_sql[:-1]})' + return create_ntb_sql + + def set_create_stable_sql(self,stbname='stb', + column_dict={'ts':'timestamp','col1':'tinyint','col2':'smallint','col3':'int','col4':'bigint','col5': 'unsigned int','col6': 'unsigned tinyint','col7': 'unsigned smallint', + 'col8': 'unsigned int','col9': 'unsigned bigint','col10': 'float','col11': 'double','col12': 'bool','col13': 'binary(20)','col14': 'nchar(20)'}, + tag_dict={'ts_tag':'timestamp','t1':'tinyint','t2':'smallint','t3':'int','t4':'bigint','t5': 'unsigned int','t6': 'unsigned tinyint','t7': 'unsigned smallint', + 't8': 'unsigned int','t9': 'unsigned bigint','t10': 'float','t11': 'double','t12': 'bool','t13': 'binary(20)','t14': 'nchar(20)'}): + column_sql = '' + tag_sql = '' + for k,v in column_dict.items(): + column_sql += f"{k} {v}," + for k,v in tag_dict.items(): + tag_sql += f"{k} {v}," + create_stb_sql = f'create table {stbname} ({column_sql[:-1]}) tags({tag_sql[:-1]})' + return create_stb_sql + + + + \ No newline at end of file diff --git a/tests/script/api/batchprepare.c b/tests/script/api/batchprepare.c index 7dd7621d0b..0e7030b230 100644 --- a/tests/script/api/batchprepare.c +++ b/tests/script/api/batchprepare.c @@ -353,13 +353,13 @@ void taosMemoryFree(const void *ptr) { static int64_t taosGetTimestampMs() { struct timeval systemTime; taosGetTimeOfDay(&systemTime); - return (int64_t)systemTime.tv_sec * 1000L + (int64_t)systemTime.tv_usec/1000; + return (int64_t)systemTime.tv_sec * 1000LL + (int64_t)systemTime.tv_usec/1000; } static int64_t taosGetTimestampUs() { struct timeval systemTime; taosGetTimeOfDay(&systemTime); - return (int64_t)systemTime.tv_sec * 1000000L + (int64_t)systemTime.tv_usec; + return (int64_t)systemTime.tv_sec * 1000000LL + (int64_t)systemTime.tv_usec; } bool colExists(TAOS_MULTI_BIND* pBind, int32_t dataType) { diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 276b5e6e34..1ab6491736 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -23,6 +23,11 @@ # ---- dnode ./test.sh -f tsim/dnode/create_dnode.sim ./test.sh -f tsim/dnode/drop_dnode_has_mnode.sim +./test.sh -f tsim/dnode/drop_dnode_has_qnode_snode.sim +./test.sh -f tsim/dnode/drop_dnode_has_vnode_replica1.sim +#./test.sh -f tsim/dnode/drop_dnode_has_vnode_replica3.sim +#./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim +#./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim # ---- insert ./test.sh -f tsim/insert/basic0.sim @@ -75,7 +80,7 @@ ./test.sh -f tsim/stream/distributeInterval0.sim # ./test.sh -f tsim/stream/distributesession0.sim # ./test.sh -f tsim/stream/session0.sim -# ./test.sh -f tsim/stream/session1.sim +./test.sh -f tsim/stream/session1.sim # ./test.sh -f tsim/stream/state0.sim ./test.sh -f tsim/stream/triggerInterval0.sim # ./test.sh -f tsim/stream/triggerSession0.sim diff --git a/tests/script/sh/abs_max.c b/tests/script/sh/abs_max.c index cd8ba0ff15..d623adacf9 100644 --- a/tests/script/sh/abs_max.c +++ b/tests/script/sh/abs_max.c @@ -11,8 +11,8 @@ typedef struct SUdfInit{ } SUdfInit; -#define TSDB_DATA_INT_NULL 0x80000000L -#define TSDB_DATA_BIGINT_NULL 0x8000000000000000L +#define TSDB_DATA_INT_NULL 0x80000000LL +#define TSDB_DATA_BIGINT_NULL 0x8000000000000000LL void abs_max(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBuf, char* tsOutput, int* numOfOutput, short otype, short obytes, SUdfInit* buf) { diff --git a/tests/script/sh/demo.c b/tests/script/sh/demo.c index 23d2174448..2a862c0464 100644 --- a/tests/script/sh/demo.c +++ b/tests/script/sh/demo.c @@ -17,7 +17,7 @@ typedef struct SDemo{ }SDemo; #define FLOAT_NULL 0x7FF00000 // it is an NAN -#define DOUBLE_NULL 0x7FFFFF0000000000L // it is an NAN +#define DOUBLE_NULL 0x7FFFFF0000000000LL // it is an NAN void demo(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBuf, char* tsOutput, diff --git a/tests/script/sh/deploy.bat b/tests/script/sh/deploy.bat index 921f1611fb..f0d8c10b7e 100644 --- a/tests/script/sh/deploy.bat +++ b/tests/script/sh/deploy.bat @@ -59,48 +59,29 @@ for /f "skip=1" %%A in ( 'wmic computersystem get caption' ) do if not defined fqdn set "fqdn=%%A" -echo firstEp %fqdn%:7100 > %TAOS_CFG% +echo firstEp %fqdn%:7100 >> %TAOS_CFG% +echo secondEp %fqdn%:7200 >> %TAOS_CFG% echo fqdn %fqdn% >> %TAOS_CFG% echo serverPort %NODE% >> %TAOS_CFG% +echo supportVnodes 128 >> %TAOS_CFG% echo dataDir %DATA_DIR% >> %TAOS_CFG% echo logDir %LOG_DIR% >> %TAOS_CFG% echo debugFlag 0 >> %TAOS_CFG% -echo mDebugFlag 135 >> %TAOS_CFG% -echo sdbDebugFlag 135 >> %TAOS_CFG% -echo dDebugFlag 135 >> %TAOS_CFG% -echo vDebugFlag 135 >> %TAOS_CFG% -echo tsdbDebugFlag 135 >> %TAOS_CFG% -echo cDebugFlag 135 >> %TAOS_CFG% -echo jnidebugFlag 135 >> %TAOS_CFG% -echo odbcdebugFlag 135 >> %TAOS_CFG% -echo httpDebugFlag 135 >> %TAOS_CFG% -echo monDebugFlag 135 >> %TAOS_CFG% -echo mqttDebugFlag 135 >> %TAOS_CFG% -echo qdebugFlag 135 >> %TAOS_CFG% -echo rpcDebugFlag 135 >> %TAOS_CFG% +echo mDebugFlag 143 >> %TAOS_CFG% +echo dDebugFlag 143 >> %TAOS_CFG% +echo vDebugFlag 143 >> %TAOS_CFG% +echo tqDebugFlag 143 >> %TAOS_CFG% +echo tsdbDebugFlag 143 >> %TAOS_CFG% +echo cDebugFlag 143 >> %TAOS_CFG% +echo jniDebugFlag 143 >> %TAOS_CFG% +echo qDebugFlag 143 >> %TAOS_CFG% +echo rpcDebugFlag 143 >> %TAOS_CFG% echo tmrDebugFlag 131 >> %TAOS_CFG% -echo udebugFlag 135 >> %TAOS_CFG% -echo sdebugFlag 135 >> %TAOS_CFG% -echo wdebugFlag 135 >> %TAOS_CFG% -echo cqdebugFlag 135 >> %TAOS_CFG% -echo monitor 0 >> %TAOS_CFG% -echo monitorInterval 1 >> %TAOS_CFG% -echo http 0 >> %TAOS_CFG% -echo slaveQuery 0 >> %TAOS_CFG% -echo numOfThreadsPerCore 2.0 >> %TAOS_CFG% -echo defaultPass taosdata >> %TAOS_CFG% +echo uDebugFlag 143 >> %TAOS_CFG% +echo sDebugFlag 143 >> %TAOS_CFG% +echo wDebugFlag 143 >> %TAOS_CFG% echo numOfLogLines 20000000 >> %TAOS_CFG% -echo mnodeEqualVnodeNum 0 >> %TAOS_CFG% -echo balanceInterval 1 >> %TAOS_CFG% -echo clog 2 >> %TAOS_CFG% -echo days 10 >> %TAOS_CFG% echo statusInterval 1 >> %TAOS_CFG% -echo maxVgroupsPerDb 4 >> %TAOS_CFG% -echo minTablesPerVnode 4 >> %TAOS_CFG% -echo maxTablesPerVnode 1000 >> %TAOS_CFG% -echo tableIncStepPerVnode 10000 >> %TAOS_CFG% echo asyncLog 0 >> %TAOS_CFG% -echo numOfMnodes 1 >> %TAOS_CFG% echo locale en_US.UTF-8 >> %TAOS_CFG% -echo fsync 0 >> %TAOS_CFG% echo telemetryReporting 0 >> %TAOS_CFG% diff --git a/tests/script/sh/exec.bat b/tests/script/sh/exec.bat index 6651c7aa8f..7a2c58fc66 100644 --- a/tests/script/sh/exec.bat +++ b/tests/script/sh/exec.bat @@ -30,9 +30,28 @@ rem echo CFG_DIR: %CFG_DIR% set TAOS_CFG=%CFG_DIR%taos.cfg rem echo TAOS_CFG: %TAOS_CFG% +set LOG_DIR=%NODE_DIR%log\ +rem echo LOG_DIR: %LOG_DIR% + +set TAOS_LOG=%LOG_DIR%taosdlog.0 +rem echo TAOS_LOG: %TAOS_LOG% + if %EXEC_OPTON% == start ( + rm -rf %TAOS_LOG% echo start %TAOSD% -c %CFG_DIR% start %TAOSD% -c %CFG_DIR% + set /a check_num=0 +:check_online + sleep 1 + set /a check_num=check_num+1 + if "%check_num%" == "11" ( + echo check online out time. + goto :finish + ) + echo check taosd online + tail -n +0 %TAOS_LOG% | grep -q "TDengine initialized successfully" || goto :check_online + echo finish + goto :finish ) if %EXEC_OPTON% == stop ( @@ -44,5 +63,8 @@ if %EXEC_OPTON% == stop ( ) do ( rem echo taskkill /IM %%A taskkill /IM %%A > NUL 2>&1 + goto :finish ) ) + +:finish \ No newline at end of file diff --git a/tests/script/sh/sum_double.c b/tests/script/sh/sum_double.c index 0297920361..d6eea5d291 100644 --- a/tests/script/sh/sum_double.c +++ b/tests/script/sh/sum_double.c @@ -10,7 +10,7 @@ typedef struct SUdfInit{ int const_item; /* 0 if result is independent of arguments */ } SUdfInit; -#define TSDB_DATA_INT_NULL 0x80000000L +#define TSDB_DATA_INT_NULL 0x80000000LL void sum_double(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBuf, char* tsOutput, diff --git a/tests/script/tsim/db/alter_option.sim b/tests/script/tsim/db/alter_option.sim index fede960a6a..f24e32279d 100644 --- a/tests/script/tsim/db/alter_option.sim +++ b/tests/script/tsim/db/alter_option.sim @@ -43,8 +43,16 @@ print ===> $data20 $data21 $data22 $data23 $data24 $data25 if $data00 != 1 then return -1 endi -if $data01 != localhost:7100 then - return -1 +system_content printf %OS% +if $system_content == Windows_NT then + system_content printf %COMPUTERNAME%:7100 + if $data01 != $system_content then + return -1 + endi +else + if $data01 != localhost:7100 then + return -1 + endi endi if $data04 != ready then goto check_dnode_ready_1 diff --git a/tests/script/tsim/db/create_all_options.sim b/tests/script/tsim/db/create_all_options.sim index efe7ff99cf..3979ef1ec1 100644 --- a/tests/script/tsim/db/create_all_options.sim +++ b/tests/script/tsim/db/create_all_options.sim @@ -43,8 +43,16 @@ print ===> $data20 $data21 $data22 $data23 $data24 $data25 if $data00 != 1 then return -1 endi -if $data01 != localhost:7100 then - return -1 +system_content printf %OS% +if $system_content == Windows_NT then + system_content printf %COMPUTERNAME%:7100 + if $data01 != $system_content then + return -1 + endi +else + if $data01 != localhost:7100 then + return -1 + endi endi if $data04 != ready then goto check_dnode_ready_1 diff --git a/tests/script/tsim/dnode/drop_dnode_has_mnode.sim b/tests/script/tsim/dnode/drop_dnode_has_mnode.sim index 1dbec2c04d..16cd2bb3b0 100644 --- a/tests/script/tsim/dnode/drop_dnode_has_mnode.sim +++ b/tests/script/tsim/dnode/drop_dnode_has_mnode.sim @@ -70,6 +70,7 @@ if $data(2)[2] != follower then endi print =============== step4: drop dnode 2 +sql_error drop dnode 1 sql drop dnode 2 print show dnodes; @@ -83,7 +84,7 @@ if $data00 != 1 then return -1 endi -print show dnodes; +print show mnodes; sql show mnodes print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] diff --git a/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim b/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim new file mode 100644 index 0000000000..15ad13b6fa --- /dev/null +++ b/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim @@ -0,0 +1,135 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sql connect + +print =============== step1 create dnode2 +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 + +$x = 0 +step1: + $ = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not online! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 3 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != offline then + goto step1 +endi + +print =============== step2 create database +sql create database d1 vgroups 4 +sql use d1 +sql create table d1.st (ts timestamp, i int) tags (j int) +sql create table d1.c1 using st tags(1) +sql show d1.tables +if $rows != 1 then + return -1 +endi + +sql show d1.vgroups +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +if $rows != 4 then + return -1 +endi +if $data(2)[3] != 2 then + return -1 +endi +if $data(3)[3] != 2 then + return -1 +endi +if $data(4)[3] != 2 then + return -1 +endi +if $data(5)[3] != 2 then + return -1 +endi + +print =============== step3: start dnode 3 +system sh/exec.sh -n dnode3 -s start +$x = 0 +step4: + $ = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not online! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 3 then + return -1 +endi +if $data(1)[4] != ready then + goto step4 +endi +if $data(2)[4] != ready then + goto step4 +endi +if $data(3)[4] != ready then + goto step4 +endi + +print =============== step3: drop dnode2 +sql drop dnode 2 + +print show dnodes; +sql show dnodes; +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] +if $rows != 2 then + return -1 +endi + +sql show d1.vgroups +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +if $rows != 4 then + return -1 +endi +if $data(2)[3] != 3 then + return -1 +endi +if $data(3)[3] != 3 then + return -1 +endi +if $data(4)[3] != 3 then + return -1 +endi +if $data(5)[3] != 3 then + return -1 +endi + +print =============== step4: select data +sql show d1.tables +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim b/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim new file mode 100644 index 0000000000..35a2466297 --- /dev/null +++ b/tests/script/tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim @@ -0,0 +1,135 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql connect + +print =============== step1 create dnode2 dnode3 dnode4 dnode 5 +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 +sql create dnode $hostname port 7500 + +$x = 0 +step1: + $ = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not online! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 3 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != ready then + goto step1 +endi +if $data(4)[4] != ready then + goto step1 +endi +if $data(5)[4] != offline then + goto step1 +endi + +print =============== step3 create database +sql create database d1 vgroups 4 replica 3 +sql use d1 +sql create table d1.st (ts timestamp, i int) tags (j int) +sql create table d1.c1 using st tags(1) +sql show d1.tables +if $rows != 1 then + return -1 +endi + +sql show d1.vgroups +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +if $rows != 1 then + return -1 +endi +if $data(2)[3] != 2 then + return -1 +endi +if $data(2)[5] != 3 then + return -1 +endi +if $data(2)[7] != 4 then + return -1 +endi + +print =============== step4: drop dnode 2 +system sh/exec.sh -n dnode5 -s start +$x = 0 +step4: + $ = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not online! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 3 then + return -1 +endi +if $data(1)[4] != ready then + goto step4 +endi +if $data(2)[4] != ready then + goto step4 +endi +if $data(3)[4] != ready then + goto step4 +endi +if $data(4)[4] != ready then + goto step4 +endi +if $data(5)[4] != ready then + goto step4 +endi + +print =============== step5: drop dnode2 +sql drop dnode 2 + +print show dnodes; +sql show dnodes; +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] +if $rows != 4 then + return -1 +endi + +print show d1.vgroups +sql show d1.vgroups +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +if $rows != 1 then + return -1 +endi + + +print =============== step6: select data +sql show d1.tables +if $rows != 1 then + return -1 +endi + +return +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/drop_dnode_has_qnode_snode.sim b/tests/script/tsim/dnode/drop_dnode_has_qnode_snode.sim new file mode 100644 index 0000000000..6641ce053c --- /dev/null +++ b/tests/script/tsim/dnode/drop_dnode_has_qnode_snode.sim @@ -0,0 +1,71 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sql connect + +print =============== step1 create dnode2 +sql create dnode $hostname port 7200 + +$x = 0 +step1: + $ = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not online! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 2 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi + +print =============== step2: create qnode snode on dnode 2 +sql create qnode on dnode 2 +sql create snode on dnode 2 + +sql show qnodes +if $rows != 1 then + return -1 +endi + +sql show snodes +if $rows != 1 then + return -1 +endi + +print =============== step3: drop dnode 2 +sql drop dnode 2 + +print show dnodes; +sql show dnodes; +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] +if $rows != 1 then + return -1 +endi +if $data00 != 1 then + return -1 +endi + +sql show qnodes +if $rows != 0 then + return -1 +endi + +sql show snodes +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/drop_dnode_has_vnode_replica1.sim b/tests/script/tsim/dnode/drop_dnode_has_vnode_replica1.sim new file mode 100644 index 0000000000..63639877ee --- /dev/null +++ b/tests/script/tsim/dnode/drop_dnode_has_vnode_replica1.sim @@ -0,0 +1,151 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +sql connect + +print =============== step1 create dnode2 +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 + +$x = 0 +step1: + $ = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not online! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 3 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != offline then + goto step1 +endi + +print =============== step2 drop dnode which not exist +sql_error drop dnode 1 +sql_error drop dnode 4 + +print =============== step3 create database +sql create database d1 vgroups 1 +sql use d1 +sql create table d1.st (ts timestamp, i int) tags (j int) +sql create table d1.c1 using st tags(1) +sql show d1.tables +if $rows != 1 then + return -1 +endi + +sql show d1.vgroups +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +if $rows != 1 then + return -1 +endi +if $data(2)[3] != 2 then + return -1 +endi + +print =============== step4: drop dnode 2 +print cant drop since no enough vnodes +sql_error drop dnode 2 + +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s start +$x = 0 +step4: + $ = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not online! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 3 then + return -1 +endi +if $data(1)[4] != ready then + goto step4 +endi +if $data(2)[4] != offline then + goto step4 +endi +if $data(3)[4] != ready then + goto step4 +endi + +# cant drop since offline +sql_error drop dnode 2 + +print =============== step5: start dnode2 +system sh/exec.sh -n dnode2 -s start + +$x = 0 +step5: + $ = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not online! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 3 then + return -1 +endi +if $data(1)[4] != ready then + goto step5 +endi +if $data(2)[4] != ready then + goto step5 +endi +if $data(3)[4] != ready then + goto step5 +endi + +print =============== step6: drop dnode2 +sql drop dnode 2 + +print show dnodes; +sql show dnodes; +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] +if $rows != 2 then + return -1 +endi + +print show d1.vgroups +sql show d1.vgroups +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +if $rows != 1 then + return -1 +endi +if $data(2)[3] != 3 then + return -1 +endi + +print =============== step7: select data +sql show d1.tables +if $rows != 1 then + return -1 +endi + +return +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/tsim/dnode/drop_dnode_has_vnode_replica3.sim b/tests/script/tsim/dnode/drop_dnode_has_vnode_replica3.sim new file mode 100644 index 0000000000..91679a7e81 --- /dev/null +++ b/tests/script/tsim/dnode/drop_dnode_has_vnode_replica3.sim @@ -0,0 +1,137 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 +system sh/deploy.sh -n dnode5 -i 5 +system sh/cfg.sh -n dnode1 -c supportVnodes -v 0 +system sh/exec.sh -n dnode1 -s start +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +system sh/exec.sh -n dnode4 -s start +sql connect + +print =============== step1 create dnode2 dnode3 dnode4 dnode 5 +sql create dnode $hostname port 7200 +sql create dnode $hostname port 7300 +sql create dnode $hostname port 7400 +sql create dnode $hostname port 7500 + +$x = 0 +step1: + $ = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not online! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 3 then + return -1 +endi +if $data(1)[4] != ready then + goto step1 +endi +if $data(2)[4] != ready then + goto step1 +endi +if $data(3)[4] != ready then + goto step1 +endi +if $data(4)[4] != ready then + goto step1 +endi +if $data(5)[4] != offline then + goto step1 +endi + +print =============== step3 create database +sql create database d1 vgroups 1 replica 3 +sql use d1 +sql create table d1.st (ts timestamp, i int) tags (j int) +sql create table d1.c1 using st tags(1) +sql show d1.tables +if $rows != 1 then + return -1 +endi + +sql show d1.vgroups +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +if $rows != 1 then + return -1 +endi +if $data(2)[3] != 2 then + return -1 +endi +if $data(2)[5] != 3 then + return -1 +endi +if $data(2)[7] != 4 then + return -1 +endi + +print =============== step4: drop dnode 2 +system sh/exec.sh -n dnode5 -s start +$x = 0 +step4: + $ = $x + 1 + sleep 1000 + if $x == 10 then + print ====> dnode not online! + return -1 + endi +sql show dnodes +print ===> $data00 $data01 $data02 $data03 $data04 $data05 +print ===> $data10 $data11 $data12 $data13 $data14 $data15 +if $rows != 3 then + return -1 +endi +if $data(1)[4] != ready then + goto step4 +endi +if $data(2)[4] != ready then + goto step4 +endi +if $data(3)[4] != ready then + goto step4 +endi +if $data(4)[4] != ready then + goto step4 +endi +if $data(5)[4] != ready then + goto step4 +endi + +print =============== step5: drop dnode2 +sql drop dnode 2 + +print show dnodes; +sql show dnodes; +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +print $data[1][0] $data[1][1] $data[1][2] $data[1][3] $data[1][4] +if $rows != 4 then + return -1 +endi + +print show d1.vgroups +sql show d1.vgroups +print $data[0][0] $data[0][1] $data[0][2] $data[0][3] $data[0][4] +if $rows != 1 then + return -1 +endi +#if $data(2)[3] != 3 then +# return -1 +#endi + +print =============== step6: select data +sql show d1.tables +if $rows != 1 then + return -1 +endi + +return +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode2 -s stop -x SIGINT +system sh/exec.sh -n dnode3 -s stop -x SIGINT diff --git a/tests/script/tsim/show/basic.sim b/tests/script/tsim/show/basic.sim index f23d75d78b..94ca2f6550 100644 --- a/tests/script/tsim/show/basic.sim +++ b/tests/script/tsim/show/basic.sim @@ -36,6 +36,7 @@ sql create database db vgroups 3 sql use db sql create table stb (ts timestamp, c int) tags (t int) sql create table t0 using stb tags (0) +sql create table tba (ts timestamp, c1 binary(10), c2 nchar(10)); print =============== run show xxxx sql show dnodes @@ -62,7 +63,7 @@ if $rows != 1 then endi #sql show streams, sql show tables -if $rows != 1 then +if $rows != 2 then return -1 endi #sql show user_table_distributed @@ -98,7 +99,7 @@ if $rows != 1 then endi #sql select * from information_schema.`streams` sql select * from information_schema.user_tables -if $rows != 29 then +if $rows != 30 then return -1 endi #sql select * from information_schema.user_table_distributed @@ -160,7 +161,7 @@ if $rows != 1 then endi #sql show streams, sql show tables -if $rows != 1 then +if $rows != 2 then return -1 endi #sql show user_table_distributed @@ -196,7 +197,7 @@ if $rows != 1 then endi #sql select * from performance_schema.`streams` sql select * from information_schema.user_tables -if $rows != 29 then +if $rows != 30 then return -1 endi #sql select * from information_schema.user_table_distributed @@ -209,5 +210,22 @@ if $rows != 3 then return -1 endi +sql show create stable stb; +if $rows != 1 then + return -1 +endi + +sql show create table t0; +if $rows != 1 then + return -1 +endi + +sql show create table tba; +if $rows != 1 then + return -1 +endi + +sql_error show create stable t0; + system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT diff --git a/tests/script/tsim/trans/create_db.sim b/tests/script/tsim/trans/create_db.sim index f730f2fb67..d4d158ede0 100644 --- a/tests/script/tsim/trans/create_db.sim +++ b/tests/script/tsim/trans/create_db.sim @@ -96,50 +96,53 @@ sql_error create database d1 vgroups 2; print =============== kill dnode2 system sh/exec.sh -n dnode2 -s stop -x SIGINT -print =============== create database -sql show transactions -if $rows != 0 then - return -1 -endi +system_content printf %OS% +if $system_content != Windows_NT then + print =============== create database + sql show transactions + if $rows != 0 then + return -1 + endi -sql_error create database d2 vgroups 2; + sql_error create database d2 vgroups 2; -print =============== show transactions -sql show transactions -if $rows != 1 then - return -1 -endi + print =============== show transactions + sql show transactions + if $rows != 1 then + return -1 + endi -if $data[0][0] != 8 then - return -1 -endi + if $data[0][0] != 8 then + return -1 + endi -if $data[0][2] != redoAction then - return -1 -endi + if $data[0][2] != redoAction then + return -1 + endi -if $data[0][3] != d2 then - return -1 -endi + if $data[0][3] != d2 then + return -1 + endi -sql show databases ; -if $rows != 4 then - return -1 -endi -print d2 ==> $data(d2)[19] -if $data(d2)[19] != creating then - return -1 -endi + sql show databases ; + if $rows != 4 then + return -1 + endi + print d2 ==> $data(d2)[19] + if $data(d2)[19] != creating then + return -1 + endi -sql_error create database d2 vgroups 2; + sql_error create database d2 vgroups 2; -print =============== kill transaction -sql kill transaction 8; -sleep 2000 + print =============== kill transaction + sql kill transaction 8; + sleep 2000 -sql show transactions -if $rows != 0 then - return -1 + sql show transactions + if $rows != 0 then + return -1 + endi endi print =============== start dnode2 @@ -153,25 +156,25 @@ step3: print ====> dnode not ready! return -1 endi -sql show dnodes -print ===> $data00 $data01 $data02 $data03 $data04 $data05 -print ===> $data10 $data11 $data12 $data13 $data14 $data15 -if $rows != 2 then - return -1 -endi -if $data(1)[4] != ready then - goto step3 -endi -if $data(2)[4] != ready then - goto step3 -endi + sql show dnodes + print ===> $data00 $data01 $data02 $data03 $data04 $data05 + print ===> $data10 $data11 $data12 $data13 $data14 $data15 + if $rows != 2 then + return -1 + endi + if $data(1)[4] != ready then + goto step3 + endi + if $data(2)[4] != ready then + goto step3 + endi sql show transactions if $rows != 0 then return -1 endi -sql drop database d2; +sql drop database if exists d2; sql show transactions if $rows != 0 then diff --git a/tests/script/wtest.bat b/tests/script/wtest.bat index 9ed58a90d1..1aa27202c6 100644 --- a/tests/script/wtest.bat +++ b/tests/script/wtest.bat @@ -52,6 +52,7 @@ echo wal 0 >> %TAOS_CFG% echo asyncLog 0 >> %TAOS_CFG% echo locale en_US.UTF-8 >> %TAOS_CFG% echo enableCoreFile 1 >> %TAOS_CFG% +echo charset cp65001 >> %TAOS_CFG% set "FILE_NAME=testSuite.sim" if "%1" == "-f" set "FILE_NAME=%2" diff --git a/tests/system-test/1-insert/create_retentions.py b/tests/system-test/1-insert/create_retentions.py index 313c643822..5a0684e2ee 100644 --- a/tests/system-test/1-insert/create_retentions.py +++ b/tests/system-test/1-insert/create_retentions.py @@ -1,5 +1,7 @@ import datetime +from dataclasses import dataclass +from typing import List from util.log import * from util.sql import * from util.cases import * @@ -28,6 +30,28 @@ CHAR_COL = [ BINARY_COL, NCHAR_COL, ] BOOLEAN_COL = [ BOOL_COL, ] TS_TYPE_COL = [ TS_COL, ] +## insert data args: +TIME_STEP = 10000 +NOW = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) + +@dataclass +class DataSet: + ts_data : List[int] = None + int_data : List[int] = None + bint_data : List[int] = None + sint_data : List[int] = None + tint_data : List[int] = None + int_un_data : List[int] = None + bint_un_data : List[int] = None + sint_un_data : List[int] = None + tint_un_data : List[int] = None + float_data : List[float] = None + double_data : List[float] = None + bool_data : List[int] = None + binary_data : List[str] = None + nchar_data : List[str] = None + + class TDTestCase: def init(self, conn, logSql): @@ -37,10 +61,13 @@ class TDTestCase: @property def create_databases_sql_err(self): return [ - "create database if not exists db1 retentions 0s:1d", - "create database if not exists db1 retentions 1s:1y", - "create database if not exists db1 retentions 1s:1n", - "create database if not exists db1 retentions 1s:1n,2s:2d,3s:3d,4s:4d", + "create database db1 retentions 0s:1d", + "create database db3 retentions 1s:0d", + "create database db1 retentions 1s:1y", + "create database db1 retentions 1s:1n", + "create database db2 retentions 1w:1d ;", + "create database db5 retentions 1s:1d,3s:3d,2s:2d", + "create database db1 retentions 1s:1n,2s:2d,3s:3d,4s:4d", ] @property @@ -60,16 +87,41 @@ class TDTestCase: @property def create_stable_sql_err(self): return [ - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(ceil) delay 1", - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(count) delay 1", - f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} binary(16)) tags (tag1 int) rollup(avg) delay 1", - f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) tags (tag1 int) rollup(avg) delay 1", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(ceil) watermark 1s maxdelay 1m", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(count) watermark 1min", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay -1s", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark -1m", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) watermark 1m ", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) maxdelay 1m ", + f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} binary(16)) tags (tag1 int) rollup(avg) watermark 1s", + f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) tags (tag1 int) rollup(avg) maxdelay 1m", + # f"create table ntb_1 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) rollup(avg) watermark 1s maxdelay 1s", + # f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) tags (tag1 int) " , + # f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) " , + # f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) " , + # f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) " , + + # watermark, maxdelay: [0, 900000], [ms, s, m, ?] + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 1u", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 1b", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 900001ms", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 16m", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 901s", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 1h", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) maxdelay 0.2h", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 0.002d", + ] @property def create_stable_sql_current(self): return [ - f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(avg) delay 5", + f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(avg)", + f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 5s maxdelay 1m", + f"create stable stb3 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(max) watermark 5s maxdelay 1m", + f"create stable stb4 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(sum) watermark 5s maxdelay 1m", + # f"create stable stb5 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(last) watermark 5s maxdelay 1m", + # f"create stable stb6 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s maxdelay 1m", ] def test_create_stb(self): @@ -79,14 +131,19 @@ class TDTestCase: for cur_sql in self.create_stable_sql_current: tdSql.execute(cur_sql) tdSql.query("show stables") + # assert "rollup" in tdSql.description tdSql.checkRows(len(self.create_stable_sql_current)) + # tdSql.execute("use db") # because db is a noraml database, not a rollup database, should not be able to create a rollup database + # tdSql.error(f"create stable nor_db_rollup_stb ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) file_factor 5.0") + + def test_create_databases(self): for err_sql in self.create_databases_sql_err: tdSql.error(err_sql) for cur_sql in self.create_databases_sql_current: tdSql.execute(cur_sql) - tdSql.query("show databases") + # tdSql.query("show databases") for alter_sql in self.alter_database_sql: tdSql.error(alter_sql) @@ -95,9 +152,7 @@ class TDTestCase: self.test_create_stb() def __create_tb(self): - tdSql.prepare() - - tdLog.printNoPrefix("==========step1:create table") + tdLog.printNoPrefix("==========step: create table") create_stb_sql = f'''create table stb1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, @@ -120,129 +175,118 @@ class TDTestCase: for i in range(4): tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') - def __create_data_set(self, rows): - now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) - pos_data = [] - neg_data = [] - spec_data = [] - for i in range(rows): - pos_data.append( - ( - now_time - i * 1000, i, 11111 * i, 111 * i % 32767 , 11 * i % 127, 1.11 * i, 1100.0011 * i, - i % 2, f'binary{i}', f'nchar_测试_{i}', now_time + 1 * i, 11 * i % 127, 111 * i % 32767, i, 11111 * i - ) - ) - neg_data.append( - ( - now_time - i * 7776000000, -i, -11111 * i, -111 * i % 32767, -11 * i % 127, -1.11 * i, -1100.0011 * i, - i % 2, f'binary{i}', f'nchar_测试_{i}', now_time + 1 * i, 11 * i % 127, 111 * i % 32767, i, 11111 * i - ) - ) - - def __insert_data(self, rows): - now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) - for i in range(rows): - tdSql.execute( - f'''insert into ct1 values ( - { now_time - i * 1000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, - {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i }, {11 * i % 127}, {111 * i % 32767}, {i}, {11111 * i} )''' - ) - tdSql.execute( - f'''insert into ct4 values ( - { now_time - i * 7776000000 }, {i}, {11111 * i}, {111 * i % 32767 }, {11 * i % 127}, {1.11*i}, {1100.0011*i}, - {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i }, {11 * i % 127}, {111 * i % 32767}, {i}, {11111 * i} )''' - ) - tdSql.execute( - f'''insert into ct2 values ( - { now_time - i * 7776000000 }, {-i}, {-11111 * i}, {-111 * i % 32767 }, {-11 * i % 127}, {-1.11*i}, {-1100.0011*i}, - {i%2}, 'binary{i}', 'nchar_测试_{i}', { now_time + 1 * i }, {11 * i % 127}, {111 * i % 32767}, {i}, {11111 * i} )''' - ) - tdSql.execute( - f'''insert into ct1 values - ( { now_time - rows * 5 }, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar_测试_0', { now_time + 8 }, 0, 0, 0, 0) - ( { now_time + 10000 }, { rows }, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar_测试_9', { now_time + 9 }, 0, 0, 0, 0 ) - ''' - ) - - tdSql.execute( - f'''insert into ct4 values - ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( - { now_time + 5184000000}, {pow(2,31)-pow(2,15)}, {pow(2,63)-pow(2,30)}, 32767, 127, - { 3.3 * pow(10,38) }, { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000}, - 254, 65534, {pow(2,32)-pow(2,16)}, {pow(2,64)-pow(2,31)} - ) - ( - { now_time + 2592000000 }, {pow(2,31)-pow(2,16)}, {pow(2,63)-pow(2,31)}, 32766, 126, - { 3.2 * pow(10,38) }, { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000}, - 255, 65535, {pow(2,32)-pow(2,15)}, {pow(2,64)-pow(2,30)} - ) - ''' - ) - - tdSql.execute( - f'''insert into ct2 values - ( { now_time - rows * 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time - rows * 3888000000 + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time + 7776000000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( - { now_time + 5184000000 }, { -1 * pow(2,31) + pow(2,15) }, { -1 * pow(2,63) + pow(2,30) }, -32766, -126, { -1 * 3.2 * pow(10,38) }, - { -1.2 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 }, 1, 1, 1, 1 - ) - ( - { now_time + 2592000000 }, { -1 * pow(2,31) + pow(2,16) }, { -1 * pow(2,63) + pow(2,31) }, -32767, -127, { - 3.3 * pow(10,38) }, - { -1.3 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 }, 1, 1, 1, 1 - ) - ''' - ) + def __data_set(self, rows): + data_set = DataSet() + # neg_data_set = DataSet() + data_set.ts_data = [] + data_set.int_data = [] + data_set.bint_data = [] + data_set.sint_data = [] + data_set.tint_data = [] + data_set.int_un_data = [] + data_set.bint_un_data = [] + data_set.sint_un_data = [] + data_set.tint_un_data = [] + data_set.float_data = [] + data_set.double_data = [] + data_set.bool_data = [] + data_set.binary_data = [] + data_set.nchar_data = [] for i in range(rows): - insert_data = f'''insert into t1 values - ( { now_time - i * 3600000 }, {i}, {i * 11111}, { i % 32767 }, { i % 127}, { i * 1.11111 }, { i * 1000.1111 }, { i % 2}, - "binary_{i}", "nchar_测试_{i}", { now_time - 1000 * i }, {i % 127}, {i % 32767}, {i}, {i * 11111}) - ''' - tdSql.execute(insert_data) - tdSql.execute( - f'''insert into t1 values - ( { now_time + 10800000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( { now_time - (( rows // 2 ) * 60 + 30) * 60000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) - ( { now_time - rows * 3600000 }, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) - ( - { now_time + 7200000 }, { pow(2,31) - pow(2,15) }, { pow(2,63) - pow(2,30) }, 32767, 127, { 3.3 * pow(10,38) }, - { 1.3 * pow(10,308) }, { rows % 2 }, "binary_limit-1", "nchar_测试_limit-1", { now_time - 86400000 }, - 254, 65534, {pow(2,32)-pow(2,16)}, {pow(2,64)-pow(2,31)} - ) - ( - { now_time + 3600000 } , { pow(2,31) - pow(2,16) }, { pow(2,63) - pow(2,31) }, 32766, 126, { 3.2 * pow(10,38) }, - { 1.2 * pow(10,308) }, { (rows-1) % 2 }, "binary_limit-2", "nchar_测试_limit-2", { now_time - 172800000 }, - 255, 65535, {pow(2,32)-pow(2,15)}, {pow(2,64)-pow(2,30)} - ) + data_set.ts_data.append(NOW + 1 * (rows - i)) + data_set.int_data.append(rows - i) + data_set.bint_data.append(11111 * (rows - i)) + data_set.sint_data.append(111 * (rows - i) % 32767) + data_set.tint_data.append(11 * (rows - i) % 127) + data_set.int_un_data.append(rows - i) + data_set.bint_un_data.append(11111 * (rows - i)) + data_set.sint_un_data.append(111 * (rows - i) % 32767) + data_set.tint_un_data.append(11 * (rows - i) % 127) + data_set.float_data.append(1.11 * (rows - i)) + data_set.double_data.append(1100.0011 * (rows - i)) + data_set.bool_data.append((rows - i) % 2) + data_set.binary_data.append(f'binary{(rows - i)}') + data_set.nchar_data.append(f'nchar_测试_{(rows - i)}') + + # neg_data_set.ts_data.append(-1 * i) + # neg_data_set.int_data.append(-i) + # neg_data_set.bint_data.append(-11111 * i) + # neg_data_set.sint_data.append(-111 * i % 32767) + # neg_data_set.tint_data.append(-11 * i % 127) + # neg_data_set.int_un_data.append(-i) + # neg_data_set.bint_un_data.append(-11111 * i) + # neg_data_set.sint_un_data.append(-111 * i % 32767) + # neg_data_set.tint_un_data.append(-11 * i % 127) + # neg_data_set.float_data.append(-1.11 * i) + # neg_data_set.double_data.append(-1100.0011 * i) + # neg_data_set.binary_data.append(f'binary{i}') + # neg_data_set.nchar_data.append(f'nchar_测试_{i}') + + return data_set + + def __insert_data(self): + data = self.__data_set(rows=self.rows) + + # now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) + null_data = '''null, null, null, null, null, null, null, null, null, null, null, null, null, null''' + zero_data = "0, 0, 0, 0, 0, 0, 0, 'binary_0', 'nchar_0', 0, 0, 0, 0, 0" + + for i in range(self.rows): + row_data = f''' + {data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]}, + {data.bool_data[i]}, '{data.binary_data[i]}', '{data.nchar_data[i]}', {data.ts_data[i]}, {data.tint_un_data[i]}, + {data.sint_un_data[i]}, {data.int_un_data[i]}, {data.bint_un_data[i]} ''' - ) + neg_row_data = f''' + {-1 * data.int_data[i]}, {-1 * data.bint_data[i]}, {-1 * data.sint_data[i]}, {-1 * data.tint_data[i]}, {-1 * data.float_data[i]}, {-1 * data.double_data[i]}, + {data.bool_data[i]}, '{data.binary_data[i]}', '{data.nchar_data[i]}', {data.ts_data[i]}, {1 * data.tint_un_data[i]}, + {1 * data.sint_un_data[i]}, {1 * data.int_un_data[i]}, {1 * data.bint_un_data[i]} + ''' + + tdSql.execute( f"insert into ct1 values ( {NOW - i * TIME_STEP}, {row_data} )" ) + tdSql.execute( f"insert into ct2 values ( {NOW - i * int(TIME_STEP * 0.6)}, {neg_row_data} )" ) + tdSql.execute( f"insert into ct4 values ( {NOW - i * int(TIME_STEP * 0.8) }, {row_data} )" ) + tdSql.execute( f"insert into t1 values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )" ) + + tdSql.execute( f"insert into ct2 values ( {NOW + int(TIME_STEP * 0.6)}, {null_data} )" ) + tdSql.execute( f"insert into ct2 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 0.6)}, {null_data} )" ) + tdSql.execute( f"insert into ct2 values ( {NOW - self.rows * int(TIME_STEP * 0.29) }, {null_data} )" ) + + tdSql.execute( f"insert into ct4 values ( {NOW + int(TIME_STEP * 0.8)}, {null_data} )" ) + tdSql.execute( f"insert into ct4 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 0.8)}, {null_data} )" ) + tdSql.execute( f"insert into ct4 values ( {NOW - self.rows * int(TIME_STEP * 0.39)}, {null_data} )" ) + + tdSql.execute( f"insert into t1 values ( {NOW + int(TIME_STEP * 1.2)}, {null_data} )" ) + tdSql.execute( f"insert into t1 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 1.2)}, {null_data} )" ) + tdSql.execute( f"insert into t1 values ( {NOW - self.rows * int(TIME_STEP * 0.59)}, {null_data} )" ) def run(self): - tdSql.prepare() - - tdLog.printNoPrefix("==========step1:create table") - self.__create_tb() - - tdLog.printNoPrefix("==========step2:insert data") self.rows = 10 - self.__insert_data(self.rows) - tdLog.printNoPrefix("==========step3:all check") - self.all_test() + + tdLog.printNoPrefix("==========step0:all check") + # self.all_test() + + tdLog.printNoPrefix("==========step1:create table in normal database") + tdSql.prepare() + self.__create_tb() + self.__insert_data() + # return + + tdLog.printNoPrefix("==========step2:create table in rollup database") + tdSql.execute("create database db3 retentions 1s:4m,2s:8m,3s:12m") + tdSql.execute("use db3") + self.__create_tb() + self.__insert_data() + tdSql.execute("drop database if exists db1 ") tdSql.execute("drop database if exists db2 ") tdDnodes.stop(1) tdDnodes.start(1) - tdSql.execute("use db") - tdLog.printNoPrefix("==========step4:after wal, all check again ") self.all_test() diff --git a/tests/system-test/1-insert/time_range_wise.py b/tests/system-test/1-insert/time_range_wise.py new file mode 100644 index 0000000000..5387970d56 --- /dev/null +++ b/tests/system-test/1-insert/time_range_wise.py @@ -0,0 +1,343 @@ +import datetime + +from dataclasses import dataclass +from typing import List, Any, Tuple +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.constant import * + +PRIMARY_COL = "ts" + +INT_COL = "c_int" +BINT_COL = "c_bint" +SINT_COL = "c_sint" +TINT_COL = "c_tint" +FLOAT_COL = "c_float" +DOUBLE_COL = "c_double" +BOOL_COL = "c_bool" +TINT_UN_COL = "c_tint_un" +SINT_UN_COL = "c_sint_un" +BINT_UN_COL = "c_bint_un" +INT_UN_COL = "c_int_un" +BINARY_COL = "c_binary" +NCHAR_COL = "c_nchar" +TS_COL = "c_ts" + + + +NUM_COL = [INT_COL, BINT_COL, SINT_COL, TINT_COL, FLOAT_COL, DOUBLE_COL, ] +CHAR_COL = [BINARY_COL, NCHAR_COL, ] +BOOLEAN_COL = [BOOL_COL, ] +TS_TYPE_COL = [TS_COL, ] + +# insert data args: +TIME_STEP = 10000 +NOW = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) + + +@dataclass +class DataSet: + ts_data : List[int] = None + int_data : List[int] = None + bint_data : List[int] = None + sint_data : List[int] = None + tint_data : List[int] = None + int_un_data : List[int] = None + bint_un_data: List[int] = None + sint_un_data: List[int] = None + tint_un_data: List[int] = None + float_data : List[float] = None + double_data : List[float] = None + bool_data : List[int] = None + binary_data : List[str] = None + nchar_data : List[str] = None + + def __post_init__(self): + self.ts_data = [] + self.int_data = [] + self.bint_data = [] + self.sint_data = [] + self.tint_data = [] + self.int_un_data = [] + self.bint_un_data = [] + self.sint_un_data = [] + self.tint_un_data = [] + self.float_data = [] + self.double_data = [] + self.bool_data = [] + self.binary_data = [] + self.nchar_data = [] + + +@dataclass +class SMAschema: + creation : str = "CREATE" + index_name : str = "sma_index_1" + index_flag : str = "SMA INDEX" + operator : str = "ON" + tbname : str = None + watermark : str = None + maxdelay : str = None + func : Tuple[str] = None + interval : Tuple[str] = None + sliding : str = None + other : Any = None + drop : str = "DROP" + drop_flag : str = "INDEX" + + def __post_init__(self): + if isinstance(self.other, dict): + for k,v in self.other.items(): + + if k.lower() == "index_name" and isinstance(v, str) and not self.index_name: + self.index_name = v + del self.other[k] + + if k.lower() == "index_flag" and isinstance(v, str) and not self.index_flag: + self.index_flag = v + del self.other[k] + + if k.lower() == "operator" and isinstance(v, str) and not self.operator: + self.operator = v + del self.other[k] + + if k.lower() == "tbname" and isinstance(v, str) and not self.tbname: + self.tbname = v + del self.other[k] + + if k.lower() == "watermark" and isinstance(v, str) and not self.watermark: + self.watermark = v + del self.other[k] + + if k.lower() == "maxdelay" and isinstance(v, str) and not self.maxdelay: + self.maxdelay = v + del self.other[k] + + if k.lower() == "functions" and isinstance(v, tuple) and not self.func: + self.func = v + del self.other[k] + + if k.lower() == "interval" and isinstance(v, tuple) and not self.interval: + self.interval = v + del self.other[k] + + if k.lower() == "sliding" and isinstance(v, str) and not self.sliding: + self.sliding = v + del self.other[k] + + if k.lower() == "drop_flag" and isinstance(v, str) and not self.drop_flag: + self.drop_flag = v + del self.other[k] + + +class TDTestCase: + + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), False) + + """ + create sma index : + 1. only create on stable, err_type: [child-table, normal-table] + 2. one taosd, one sma index , err_type: [ + one stb --> multi sma index, + multi stb in one db--> multi sma index, + multi stb in multi db --> multi sma index + ] + 3. arg of (interval/sliding) in query sql is equal to this arg in sma index + 4. client timezone is equal to timezone of sma index + 5. does not take effect unless querySmaOptimize flag is turned on, + """ + def __create_sma_index(self, sma:SMAschema): + sql = f"{sma.creation} {sma.index_flag} {sma.index_name} {sma.operator} {sma.tbname}" + if sma.func: + sql += f" function({', '.join(sma.func)})" + if sma.interval: + sql += f" interval({', '.join(sma.interval)})" + if sma.sliding: + sql += f" sliding({sma.sliding})" + if sma.watermark: + sql += f" watermark {sma.watermark}" + if sma.maxdelay: + sql += f" maxdelay {sma.maxdelay}" + if isinstance(sma.other, dict): + for k,v in sma.other.items(): + if isinstance(v,tuple) or isinstance(v, list): + sql += f" {k} ({' '.join(v)})" + else: + sql += f" {k} {v}" + if isinstance(sma.other, tuple) or isinstance(sma.other, list): + sql += " ".join(sma.other) + if isinstance(sma.other, int) or isinstance(sma.other, float) or isinstance(sma.other, str): + sql += sma.other + + return sql + + def sma_create_check(self, sma:SMAschema): + tdSql.query("show stables") + stb_in_list = False + for row in tdSql.queryResult: + if sma.tbname == row[0]: + stb_in_list = True + break + if not stb_in_list: + tdSql.error(self.__create_sma_index(sma)) + if not sma.creation: + tdSql.error(self.__create_sma_index(sma)) + if not sma.index_flag: + tdSql.error(self.__create_sma_index(sma)) + if not sma.index_name: + tdSql.error(self.__create_sma_index(sma)) + if not sma.operator: + tdSql.error(self.__create_sma_index(sma)) + if not sma.tbname: + tdSql.error(self.__create_sma_index(sma)) + if not sma.func: + tdSql.error(self.__create_sma_index(sma)) + if not sma.interval: + tdSql.error(self.__create_sma_index(sma)) + if not sma.sliding: + tdSql.error(self.__create_sma_index(sma)) + if sma.other: + tdSql.error(self.__create_sma_index(sma)) + + + def all_test(self): + pass + + def __create_tb(self): + tdLog.printNoPrefix("==========step: create table") + create_stb_sql = f'''create table stb1( + ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, + {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, + {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp, + {TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned, + {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned + ) tags (tag1 int) + ''' + create_ntb_sql = f'''create table t1( + ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, + {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, + {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp, + {TINT_UN_COL} tinyint unsigned, {SINT_UN_COL} smallint unsigned, + {INT_UN_COL} int unsigned, {BINT_UN_COL} bigint unsigned + ) + ''' + tdSql.execute(create_stb_sql) + tdSql.execute(create_ntb_sql) + + for i in range(4): + tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') + + def __data_set(self, rows): + data_set = DataSet() + + for i in range(rows): + data_set.ts_data.append(NOW + 1 * (rows - i)) + data_set.int_data.append(rows - i) + data_set.bint_data.append(11111 * (rows - i)) + data_set.sint_data.append(111 * (rows - i) % 32767) + data_set.tint_data.append(11 * (rows - i) % 127) + data_set.int_un_data.append(rows - i) + data_set.bint_un_data.append(11111 * (rows - i)) + data_set.sint_un_data.append(111 * (rows - i) % 32767) + data_set.tint_un_data.append(11 * (rows - i) % 127) + data_set.float_data.append(1.11 * (rows - i)) + data_set.double_data.append(1100.0011 * (rows - i)) + data_set.bool_data.append((rows - i) % 2) + data_set.binary_data.append(f'binary{(rows - i)}') + data_set.nchar_data.append(f'nchar_测试_{(rows - i)}') + + return data_set + + def __insert_data(self): + data = self.__data_set(rows=self.rows) + + # now_time = int(datetime.datetime.timestamp(datetime.datetime.now()) * 1000) + null_data = '''null, null, null, null, null, null, null, null, null, null, null, null, null, null''' + zero_data = "0, 0, 0, 0, 0, 0, 0, 'binary_0', 'nchar_0', 0, 0, 0, 0, 0" + + for i in range(self.rows): + row_data = f''' + {data.int_data[i]}, {data.bint_data[i]}, {data.sint_data[i]}, {data.tint_data[i]}, {data.float_data[i]}, {data.double_data[i]}, + {data.bool_data[i]}, '{data.binary_data[i]}', '{data.nchar_data[i]}', {data.ts_data[i]}, {data.tint_un_data[i]}, + {data.sint_un_data[i]}, {data.int_un_data[i]}, {data.bint_un_data[i]} + ''' + neg_row_data = f''' + {-1 * data.int_data[i]}, {-1 * data.bint_data[i]}, {-1 * data.sint_data[i]}, {-1 * data.tint_data[i]}, {-1 * data.float_data[i]}, {-1 * data.double_data[i]}, + {data.bool_data[i]}, '{data.binary_data[i]}', '{data.nchar_data[i]}', {data.ts_data[i]}, {1 * data.tint_un_data[i]}, + {1 * data.sint_un_data[i]}, {1 * data.int_un_data[i]}, {1 * data.bint_un_data[i]} + ''' + + tdSql.execute( + f"insert into ct1 values ( {NOW - i * TIME_STEP}, {row_data} )") + tdSql.execute( + f"insert into ct2 values ( {NOW - i * int(TIME_STEP * 0.6)}, {neg_row_data} )") + tdSql.execute( + f"insert into ct4 values ( {NOW - i * int(TIME_STEP * 0.8) }, {row_data} )") + tdSql.execute( + f"insert into t1 values ( {NOW - i * int(TIME_STEP * 1.2)}, {row_data} )") + + tdSql.execute( + f"insert into ct2 values ( {NOW + int(TIME_STEP * 0.6)}, {null_data} )") + tdSql.execute( + f"insert into ct2 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 0.6)}, {null_data} )") + tdSql.execute( + f"insert into ct2 values ( {NOW - self.rows * int(TIME_STEP * 0.29) }, {null_data} )") + + tdSql.execute( + f"insert into ct4 values ( {NOW + int(TIME_STEP * 0.8)}, {null_data} )") + tdSql.execute( + f"insert into ct4 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 0.8)}, {null_data} )") + tdSql.execute( + f"insert into ct4 values ( {NOW - self.rows * int(TIME_STEP * 0.39)}, {null_data} )") + + tdSql.execute( + f"insert into t1 values ( {NOW + int(TIME_STEP * 1.2)}, {null_data} )") + tdSql.execute( + f"insert into t1 values ( {NOW - (self.rows + 1) * int(TIME_STEP * 1.2)}, {null_data} )") + tdSql.execute( + f"insert into t1 values ( {NOW - self.rows * int(TIME_STEP * 0.59)}, {null_data} )") + + def run(self): + sma1 = SMAschema(func=("min(c1)","max(c2)")) + sql1 = self.__create_sma_index(sma1) + print("================") + print(sql1) + # a = DataSet() + # return + self.rows = 10 + + tdLog.printNoPrefix("==========step0:all check") + # self.all_test() + + tdLog.printNoPrefix("==========step1:create table in normal database") + tdSql.prepare() + self.__create_tb() + self.__insert_data() + return + + tdLog.printNoPrefix("==========step2:create table in rollup database") + tdSql.execute("create database db3 retentions 1s:4m,2s:8m,3s:12m") + tdSql.execute("use db3") + self.__create_tb() + self.__insert_data() + + tdSql.execute("drop database if exists db1 ") + tdSql.execute("drop database if exists db2 ") + + tdDnodes.stop(1) + tdDnodes.start(1) + + tdLog.printNoPrefix("==========step4:after wal, all check again ") + self.all_test() + + 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/abs.py b/tests/system-test/2-query/abs.py index d779cc26cd..244cccb041 100644 --- a/tests/system-test/2-query/abs.py +++ b/tests/system-test/2-query/abs.py @@ -6,15 +6,63 @@ import inspect from util.log import * from util.sql import * from util.cases import * +import random + class TDTestCase: - updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , - "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, - "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143} + updatecfgDict = {'debugFlag': 143, "cDebugFlag": 143, "uDebugFlag": 143, "rpcDebugFlag": 143, "tmrDebugFlag": 143, + "jniDebugFlag": 143, "simDebugFlag": 143, "dDebugFlag": 143, "dDebugFlag": 143, "vDebugFlag": 143, "mDebugFlag": 143, "qDebugFlag": 143, + "wDebugFlag": 143, "sDebugFlag": 143, "tsdbDebugFlag": 143, "tqDebugFlag": 143, "fsDebugFlag": 143, "fnDebugFlag": 143} + def init(self, conn, logSql): tdLog.debug(f"start to excute {__file__}") tdSql.init(conn.cursor(), True) + self.tb_nums = 10 + self.row_nums = 20 + self.ts = 1434938400000 + self.time_step = 1000 + + def insert_datas_and_check_abs(self ,tbnums , rownums , time_step ): + tdLog.info(" prepare datas for auto check abs function ") + + tdSql.execute(" create database test ") + tdSql.execute(" use test ") + tdSql.execute(" create stable stb (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint,\ + c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) tags (t1 int)") + for tbnum in range(tbnums): + tbname = "sub_tb_%d"%tbnum + tdSql.execute(" create table %s using stb tags(%d) "%(tbname , tbnum)) + + ts = self.ts + for row in range(rownums): + ts += time_step*row + c1 = random.randint(0,10000) + c2 = random.randint(0,100000) + c3 = random.randint(0,125) + c4 = random.randint(0,125) + c5 = random.random()/1.0 + c6 = random.random()/1.0 + c7 = "'true'" + c8 = "'binary_val'" + c9 = "'nchar_val'" + c10 = ts + tdSql.execute(f" insert into {tbname} values ({ts},{c1},{c2},{c3},{c4},{c5},{c6},{c7},{c8},{c9},{c10})") + + tdSql.execute("use test") + tbnames = ["stb", "sub_tb_1"] + support_types = ["BIGINT", "SMALLINT", "TINYINT", "FLOAT", "DOUBLE", "INT"] + for tbname in tbnames: + tdSql.query("desc {}".format(tbname)) + coltypes = tdSql.queryResult + for coltype in coltypes: + colname = coltype[0] + abs_sql = "select abs({}) from {} order by tbname ".format(colname, tbname) + origin_sql = "select {} from {} order by tbname".format(colname, tbname) + if coltype[1] in support_types: + self.check_result_auto(origin_sql , abs_sql) + + def prepare_datas(self): tdSql.execute( '''create table stb1 @@ -22,7 +70,7 @@ class TDTestCase: tags (t1 int) ''' ) - + tdSql.execute( ''' create table t1 @@ -39,14 +87,21 @@ class TDTestCase: tdSql.execute( f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute( + "insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute( + "insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute( + "insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute( + "insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute( + "insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute( + "insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute( + "insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute( f'''insert into t1 values @@ -64,11 +119,11 @@ class TDTestCase: ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ''' ) - def prepare_tag_datas(self): - # prepare datas - tdSql.execute("create database if not exists testdb keep 3650 duration 1000") + # prepare datas + tdSql.execute( + "create database if not exists testdb keep 3650 duration 1000") tdSql.execute(" use testdb ") tdSql.execute( '''create table stb1 @@ -84,7 +139,8 @@ class TDTestCase: ''' ) for i in range(4): - tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') + tdSql.execute( + f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') for i in range(9): tdSql.execute( @@ -93,14 +149,21 @@ class TDTestCase: tdSql.execute( f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" ) - tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") - tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute( + "insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute( + "insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute( + "insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute( + "insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") - tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") - tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute( + "insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute( + "insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute( + "insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") tdSql.execute( f'''insert into t1 values @@ -119,18 +182,18 @@ class TDTestCase: ''' ) - def check_result_auto(self ,origin_query , abs_query): + def check_result_auto(self, origin_query, abs_query): abs_result = tdSql.getResult(abs_query) origin_result = tdSql.getResult(origin_query) - auto_result =[] - + auto_result = [] + for row in origin_result: row_check = [] for elem in row: if elem == None: elem = None - elif elem >=0: + elif elem >= 0: elem = elem else: elem = -elem @@ -138,21 +201,23 @@ class TDTestCase: auto_result.append(row_check) check_status = True - for row_index , row in enumerate(abs_result): - for col_index , elem in enumerate(row): + for row_index, row in enumerate(abs_result): + for col_index, elem in enumerate(row): if auto_result[row_index][col_index] != elem: - check_status = False + check_status = False if not check_status: - tdLog.notice("abs function value has not as expected , sql is \"%s\" "%abs_query ) + tdLog.notice( + "abs function value has not as expected , sql is \"%s\" " % abs_query) sys.exit(1) else: - tdLog.info("abs value check pass , it work as expected ,sql is \"%s\" "%abs_query ) - + tdLog.info( + "abs value check pass , it work as expected ,sql is \"%s\" " % abs_query) + def test_errors(self): tdSql.execute("use testdb") error_sql_lists = [ "select abs from t1", - # "select abs(-+--+c1) from t1", + "select abs(-+--+c1) from t1", # "select +-abs(c1) from t1", # "select ++-abs(c1) from t1", # "select ++--abs(c1) from t1", @@ -182,93 +247,25 @@ class TDTestCase: ] for error_sql in error_sql_lists: tdSql.error(error_sql) - + def support_types(self): tdSql.execute("use testdb") - type_error_sql_lists = [ - "select abs(ts) from t1" , - "select abs(t0) from t1" , - "select abs(c7) from t1", - "select abs(c8) from t1", - "select abs(c9) from t1", - "select abs(t7) from t1", - "select abs(t8) from t1", - "select abs(t9) from t1", - "select abs(ts) from ct1" , - "select abs(c7) from ct1", - "select abs(c8) from ct1", - "select abs(c9) from ct1", - "select abs(ts) from ct3" , - "select abs(c7) from ct3", - "select abs(c8) from ct3", - "select abs(c9) from ct3", - "select abs(ts) from ct4" , - "select abs(c7) from ct4", - "select abs(c8) from ct4", - "select abs(c9) from ct4", - "select abs(ts) from stb1" , - "select abs(c7) from stb1", - "select abs(c8) from stb1", - "select abs(c9) from stb1" , + tbnames = ["stb1", "t1", "ct1", "ct2"] + support_types = ["BIGINT", "SMALLINT", "TINYINT", "FLOAT", "DOUBLE", "INT"] + for tbname in tbnames: + tdSql.query("desc {}".format(tbname)) + coltypes = tdSql.queryResult + for coltype in coltypes: + colname = coltype[0] + abs_sql = "select abs({}) from {}".format(colname, tbname) + if coltype[1] in support_types: + tdSql.query(abs_sql) + else: + tdSql.error(abs_sql) - "select abs(ts) from stbbb1" , - "select abs(c7) from stbbb1", - - "select abs(ts) from tbname", - "select abs(c9) from tbname" - - ] - - for type_sql in type_error_sql_lists: - tdSql.error(type_sql) - - - type_sql_lists = [ - "select abs(c1) from t1", - "select abs(c2) from t1", - "select abs(c3) from t1", - "select abs(c4) from t1", - "select abs(c5) from t1", - "select abs(c6) from t1", - - "select abs(t1) from ct1", - "select abs(t2) from ct1", - "select abs(t3) from ct1", - "select abs(t4) from ct1", - "select abs(t5) from ct1", - "select abs(t6) from ct1", - - "select abs(c1) from ct1", - "select abs(c2) from ct1", - "select abs(c3) from ct1", - "select abs(c4) from ct1", - "select abs(c5) from ct1", - "select abs(c6) from ct1", - - "select abs(c1) from ct3", - "select abs(c2) from ct3", - "select abs(c3) from ct3", - "select abs(c4) from ct3", - "select abs(c5) from ct3", - "select abs(c6) from ct3", - - "select abs(c1) from stb1", - "select abs(c2) from stb1", - "select abs(c3) from stb1", - "select abs(c4) from stb1", - "select abs(c5) from stb1", - "select abs(c6) from stb1", - - "select abs(c6) as alisb from stb1", - "select abs(c6) alisb from stb1", - ] - - for type_sql in type_sql_lists: - tdSql.query(type_sql) - def basic_abs_function(self): - # basic query + # basic query tdSql.query("select c1 from ct3") tdSql.checkRows(0) tdSql.query("select c1 from t1") @@ -288,13 +285,13 @@ class TDTestCase: tdSql.query("select abs(c5) from ct3") tdSql.checkRows(0) tdSql.query("select abs(c6) from ct3") - + # used for regular table tdSql.query("select abs(c1) from t1") tdSql.checkData(0, 0, None) - tdSql.checkData(1 , 0, 1) - tdSql.checkData(3 , 0, 3) - tdSql.checkData(5 , 0, None) + tdSql.checkData(1, 0, 1) + tdSql.checkData(3, 0, 3) + tdSql.checkData(5, 0, None) tdSql.query("select c1, c2, c3 , c4, c5 from t1") tdSql.checkData(1, 4, 1.11000) @@ -305,62 +302,66 @@ class TDTestCase: tdSql.checkData(3, 4, 33) tdSql.checkData(5, 5, None) - self.check_result_auto( "select c1, c2, c3 , c4, c5 from t1", "select (c1), abs(c2) ,abs(c3), abs(c4), abs(c5) from t1") - + self.check_result_auto("select c1, c2, c3 , c4, c5 from t1", + "select (c1), abs(c2) ,abs(c3), abs(c4), abs(c5) from t1") + # used for sub table tdSql.query("select abs(c1) from ct1") tdSql.checkData(0, 0, 8) - tdSql.checkData(1 , 0, 7) - tdSql.checkData(3 , 0, 5) - tdSql.checkData(5 , 0, 4) + tdSql.checkData(1, 0, 7) + tdSql.checkData(3, 0, 5) + tdSql.checkData(5, 0, 4) tdSql.query("select abs(c1) from ct1") - self.check_result_auto( "select c1, c2, c3 , c4, c5 from ct1", "select (c1), abs(c2) ,abs(c3), abs(c4), abs(c5) from ct1") - self.check_result_auto("select abs(abs(abs(abs(abs(abs(abs(abs(abs(abs(c1)))))))))) nest_col_func from ct1;","select c1 from ct1" ) + self.check_result_auto("select c1, c2, c3 , c4, c5 from ct1", + "select (c1), abs(c2) ,abs(c3), abs(c4), abs(c5) from ct1") + self.check_result_auto( + "select abs(abs(abs(abs(abs(abs(abs(abs(abs(abs(c1)))))))))) nest_col_func from ct1;", "select c1 from ct1") + + # used for stable table - # used for stable table - tdSql.query("select abs(c1) from stb1") tdSql.checkRows(25) - self.check_result_auto( "select c1, c2, c3 , c4, c5 from ct4 ", "select (c1), abs(c2) ,abs(c3), abs(c4), abs(c5) from ct4") - self.check_result_auto("select abs(abs(abs(abs(abs(abs(abs(abs(abs(abs(c1)))))))))) nest_col_func from ct4;" , "select c1 from ct4" ) - + self.check_result_auto("select c1, c2, c3 , c4, c5 from ct4 ", + "select (c1), abs(c2) ,abs(c3), abs(c4), abs(c5) from ct4") + self.check_result_auto( + "select abs(abs(abs(abs(abs(abs(abs(abs(abs(abs(c1)))))))))) nest_col_func from ct4;", "select c1 from ct4") # used for not exists table tdSql.error("select abs(c1) from stbbb1") tdSql.error("select abs(c1) from tbname") tdSql.error("select abs(c1) from ct5") - # mix with common col + # mix with common col tdSql.query("select c1, abs(c1) from ct1") - tdSql.checkData(0 , 0 ,8) - tdSql.checkData(0 , 1 ,8) - tdSql.checkData(4 , 0 ,0) - tdSql.checkData(4 , 1 ,0) + tdSql.checkData(0, 0, 8) + tdSql.checkData(0, 1, 8) + tdSql.checkData(4, 0, 0) + tdSql.checkData(4, 1, 0) tdSql.query("select c1, abs(c1) from ct4") - tdSql.checkData(0 , 0 , None) - tdSql.checkData(0 , 1 ,None) - tdSql.checkData(4 , 0 ,5) - tdSql.checkData(4 , 1 ,5) - tdSql.checkData(5 , 0 ,None) - tdSql.checkData(5 , 1 ,None) + tdSql.checkData(0, 0, None) + tdSql.checkData(0, 1, None) + tdSql.checkData(4, 0, 5) + tdSql.checkData(4, 1, 5) + tdSql.checkData(5, 0, None) + tdSql.checkData(5, 1, None) tdSql.query("select c1, abs(c1) from ct4 ") - tdSql.checkData(0 , 0 ,None) - tdSql.checkData(0 , 1 ,None) - tdSql.checkData(4 , 0 ,5) - tdSql.checkData(4 , 1 ,5) + tdSql.checkData(0, 0, None) + tdSql.checkData(0, 1, None) + tdSql.checkData(4, 0, 5) + tdSql.checkData(4, 1, 5) # mix with common functions tdSql.query("select c1, abs(c1),c5, floor(c5) from ct4 ") - tdSql.checkData(0 , 0 ,None) - tdSql.checkData(0 , 1 ,None) - tdSql.checkData(0 , 2 ,None) - tdSql.checkData(0 , 3 ,None) - - tdSql.checkData(3 , 0 , 6) - tdSql.checkData(3 , 1 , 6) - tdSql.checkData(3 , 2 ,6.66000) - tdSql.checkData(3 , 3 ,6.00000) + tdSql.checkData(0, 0, None) + tdSql.checkData(0, 1, None) + tdSql.checkData(0, 2, None) + tdSql.checkData(0, 3, None) + + tdSql.checkData(3, 0, 6) + tdSql.checkData(3, 1, 6) + tdSql.checkData(3, 2, 6.66000) + tdSql.checkData(3, 3, 6.00000) tdSql.query("select c1, abs(c1),c5, floor(c5) from stb1 ") @@ -377,18 +378,17 @@ class TDTestCase: tdSql.query("select max(c5), count(c5) from stb1") tdSql.query("select max(c5), count(c5) from ct1") - # bug fix for count tdSql.query("select count(c1) from ct4 ") - tdSql.checkData(0,0,9) + tdSql.checkData(0, 0, 9) tdSql.query("select count(*) from ct4 ") - tdSql.checkData(0,0,12) + tdSql.checkData(0, 0, 12) tdSql.query("select count(c1) from stb1 ") - tdSql.checkData(0,0,22) + tdSql.checkData(0, 0, 22) tdSql.query("select count(*) from stb1 ") - tdSql.checkData(0,0,25) + tdSql.checkData(0, 0, 25) - # bug fix for compute + # bug fix for compute tdSql.query("select c1, abs(c1) -0 ,ceil(c1)-0 from ct4 ") tdSql.checkData(0, 0, None) tdSql.checkData(0, 1, None) @@ -405,47 +405,48 @@ class TDTestCase: tdSql.checkData(1, 1, 8.000000000) tdSql.checkData(1, 2, 7.900000000) - - def abs_func_filter(self): tdSql.execute("use db") - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1>5 ") + tdSql.query( + "select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1>5 ") tdSql.checkRows(3) - tdSql.checkData(0,0,8) - tdSql.checkData(0,1,8.000000000) - tdSql.checkData(0,2,8.000000000) - tdSql.checkData(0,3,7.900000000) - tdSql.checkData(0,4,3.000000000) + tdSql.checkData(0, 0, 8) + tdSql.checkData(0, 1, 8.000000000) + tdSql.checkData(0, 2, 8.000000000) + tdSql.checkData(0, 3, 7.900000000) + tdSql.checkData(0, 4, 3.000000000) - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1=5 ") + tdSql.query( + "select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1=5 ") tdSql.checkRows(1) - tdSql.checkData(0,0,5) - tdSql.checkData(0,1,5.000000000) - tdSql.checkData(0,2,5.000000000) - tdSql.checkData(0,3,4.900000000) - tdSql.checkData(0,4,2.000000000) + tdSql.checkData(0, 0, 5) + tdSql.checkData(0, 1, 5.000000000) + tdSql.checkData(0, 2, 5.000000000) + tdSql.checkData(0, 3, 4.900000000) + tdSql.checkData(0, 4, 2.000000000) - tdSql.query("select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1=5 ") + tdSql.query( + "select c1, abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1=5 ") tdSql.checkRows(1) - tdSql.checkData(0,0,5) - tdSql.checkData(0,1,5.000000000) - tdSql.checkData(0,2,5.000000000) - tdSql.checkData(0,3,4.900000000) - tdSql.checkData(0,4,2.000000000) + tdSql.checkData(0, 0, 5) + tdSql.checkData(0, 1, 5.000000000) + tdSql.checkData(0, 2, 5.000000000) + tdSql.checkData(0, 3, 4.900000000) + tdSql.checkData(0, 4, 2.000000000) - tdSql.query("select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1>log(c1,2) limit 1 ") + tdSql.query( + "select c1,c2 , abs(c1) -0 ,ceil(c1-0.1)-0 ,floor(c1+0.1)-0.1 ,ceil(log(c1,2)-0.5) from ct4 where c1>log(c1,2) limit 1 ") tdSql.checkRows(1) - tdSql.checkData(0,0,8) - tdSql.checkData(0,1,88888) - tdSql.checkData(0,2,8.000000000) - tdSql.checkData(0,3,8.000000000) - tdSql.checkData(0,4,7.900000000) - tdSql.checkData(0,5,3.000000000) - + tdSql.checkData(0, 0, 8) + tdSql.checkData(0, 1, 88888) + tdSql.checkData(0, 2, 8.000000000) + tdSql.checkData(0, 3, 8.000000000) + tdSql.checkData(0, 4, 7.900000000) + tdSql.checkData(0, 5, 3.000000000) def abs_Arithmetic(self): pass - + def check_boundary_values(self): tdSql.execute("drop database if exists bound_test") @@ -457,74 +458,84 @@ class TDTestCase: ) tdSql.execute(f'create table sub1_bound using stb_bound tags ( 1 )') tdSql.execute( - f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" - ) + f"insert into sub1_bound values ( now()-1s, 2147483647, 9223372036854775807, 32767, 127, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + ) tdSql.execute( - f"insert into sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" - ) + f"insert into sub1_bound values ( now()-1s, -2147483647, -9223372036854775807, -32767, -127, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + ) tdSql.execute( - f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" - ) + f"insert into sub1_bound values ( now(), 2147483646, 9223372036854775806, 32766, 126, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + ) tdSql.execute( - f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" - ) + f"insert into sub1_bound values ( now(), -2147483646, -9223372036854775806, -32766, -126, -3.40E+38, -1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + ) tdSql.error( - f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" - ) - self.check_result_auto( "select c1, c2, c3 , c4, c5 ,c6 from sub1_bound ", "select abs(c1), abs(c2) ,abs(c3), abs(c4), abs(c5) ,abs(c6) from sub1_bound") - self.check_result_auto( "select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", "select abs(c1), abs(c2) ,abs(c3), abs(c3), abs(c2) ,abs(c1) from sub1_bound") - self.check_result_auto("select abs(abs(abs(abs(abs(abs(abs(abs(abs(abs(c1)))))))))) nest_col_func from sub1_bound;" , "select abs(c1) from sub1_bound" ) - + f"insert into sub1_bound values ( now()+1s, 2147483648, 9223372036854775808, 32768, 128, 3.40E+38, 1.7e+308, True, 'binary_tb1', 'nchar_tb1', now() )" + ) + self.check_result_auto("select c1, c2, c3 , c4, c5 ,c6 from sub1_bound ", + "select abs(c1), abs(c2) ,abs(c3), abs(c4), abs(c5) ,abs(c6) from sub1_bound") + self.check_result_auto("select c1, c2, c3 , c3, c2 ,c1 from sub1_bound ", + "select abs(c1), abs(c2) ,abs(c3), abs(c3), abs(c2) ,abs(c1) from sub1_bound") + self.check_result_auto( + "select abs(abs(abs(abs(abs(abs(abs(abs(abs(abs(c1)))))))))) nest_col_func from sub1_bound;", "select abs(c1) from sub1_bound") + # check basic elem for table per row - tdSql.query("select abs(c1) ,abs(c2) , abs(c3) , abs(c4), abs(c5), abs(c6) from sub1_bound ") - tdSql.checkData(0,0,2147483647) - tdSql.checkData(0,1,9223372036854775807) - tdSql.checkData(0,2,32767) - tdSql.checkData(0,3,127) - tdSql.checkData(0,4,339999995214436424907732413799364296704.00000) - tdSql.checkData(0,5,169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000) - tdSql.checkData(1,0,2147483647) - tdSql.checkData(1,1,9223372036854775807) - tdSql.checkData(1,2,32767) - tdSql.checkData(1,3,127) - tdSql.checkData(1,4,339999995214436424907732413799364296704.00000) - tdSql.checkData(1,5,169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000) - tdSql.checkData(3,0,2147483646) - tdSql.checkData(3,1,9223372036854775806) - tdSql.checkData(3,2,32766) - tdSql.checkData(3,3,126) - tdSql.checkData(3,4,339999995214436424907732413799364296704.00000) - tdSql.checkData(3,5,169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000) + tdSql.query( + "select abs(c1) ,abs(c2) , abs(c3) , abs(c4), abs(c5), abs(c6) from sub1_bound ") + tdSql.checkData(0, 0, 2147483647) + tdSql.checkData(0, 1, 9223372036854775807) + tdSql.checkData(0, 2, 32767) + tdSql.checkData(0, 3, 127) + tdSql.checkData(0, 4, 339999995214436424907732413799364296704.00000) + tdSql.checkData(0, 5, 169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000) + tdSql.checkData(1, 0, 2147483647) + tdSql.checkData(1, 1, 9223372036854775807) + tdSql.checkData(1, 2, 32767) + tdSql.checkData(1, 3, 127) + tdSql.checkData(1, 4, 339999995214436424907732413799364296704.00000) + tdSql.checkData(1, 5, 169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000) + tdSql.checkData(3, 0, 2147483646) + tdSql.checkData(3, 1, 9223372036854775806) + tdSql.checkData(3, 2, 32766) + tdSql.checkData(3, 3, 126) + tdSql.checkData(3, 4, 339999995214436424907732413799364296704.00000) + tdSql.checkData(3, 5, 169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000) # check + - * / in functions - tdSql.query("select abs(c1+1) ,abs(c2) , abs(c3*1) , abs(c4/2), abs(c5)/2, abs(c6) from sub1_bound ") - tdSql.checkData(0,0,2147483648.000000000) - tdSql.checkData(0,1,9223372036854775807) - tdSql.checkData(0,2,32767.000000000) - tdSql.checkData(0,3,63.500000000) - tdSql.checkData(0,4,169999997607218212453866206899682148352.000000000) - tdSql.checkData(0,5,169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000) - - - tdSql.checkData(1,0,2147483646.000000000) - tdSql.checkData(1,1,9223372036854775808.000000000) - tdSql.checkData(1,2,32767.000000000) - tdSql.checkData(1,3,63.500000000) - tdSql.checkData(1,4,169999997607218212453866206899682148352.000000000) + tdSql.query( + "select abs(c1+1) ,abs(c2) , abs(c3*1) , abs(c4/2), abs(c5)/2, abs(c6) from sub1_bound ") + tdSql.checkData(0, 0, 2147483648.000000000) + tdSql.checkData(0, 1, 9223372036854775807) + tdSql.checkData(0, 2, 32767.000000000) + tdSql.checkData(0, 3, 63.500000000) + tdSql.checkData( + 0, 4, 169999997607218212453866206899682148352.000000000) + tdSql.checkData(0, 5, 169999999999999993883079578865998174333346074304075874502773119193537729178160565864330091787584707988572262467983188919169916105593357174268369962062473635296474636515660464935663040684957844303524367815028553272712298986386310828644513212353921123253311675499856875650512437415429217994623324794855339589632.000000000) + + tdSql.checkData(1, 0, 2147483646.000000000) + tdSql.checkData(1, 1, 9223372036854775808.000000000) + tdSql.checkData(1, 2, 32767.000000000) + tdSql.checkData(1, 3, 63.500000000) + tdSql.checkData( + 1, 4, 169999997607218212453866206899682148352.000000000) + + self.check_result_auto("select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from sub1_bound", + "select abs(c1+1) ,abs(c2) , abs(c3*1) , abs(c4/2), abs(c5)/2, abs(c6) from sub1_bound ") - self.check_result_auto("select c1+1 ,c2 , c3*1 , c4/2, c5/2, c6 from sub1_bound" ,"select abs(c1+1) ,abs(c2) , abs(c3*1) , abs(c4/2), abs(c5)/2, abs(c6) from sub1_bound ") - def test_tag_compute_for_scalar_function(self): - + tdSql.execute("use testdb") - self.check_result_auto( "select c1, t2, t3 , t4, t5 from ct4 ", "select (c1), abs(t2) ,abs(t3), abs(t4), abs(t5) from ct4") - self.check_result_auto( "select c1+2, t2+2, t3 , t4, t5 from ct4 ", "select (c1)+2, abs(t2)+2 ,abs(t3), abs(t4), abs(t5) from ct4") - self.check_result_auto( "select c1+2, t2+2, t3 , t4, t5 from stb1 order by t1 ", "select (c1)+2, abs(t2)+2 ,abs(t3), abs(t4), abs(t5) from stb1 order by t1") + self.check_result_auto("select c1, t2, t3 , t4, t5 from ct4 ", + "select (c1), abs(t2) ,abs(t3), abs(t4), abs(t5) from ct4") + self.check_result_auto("select c1+2, t2+2, t3 , t4, t5 from ct4 ", + "select (c1)+2, abs(t2)+2 ,abs(t3), abs(t4), abs(t5) from ct4") + self.check_result_auto("select c1+2, t2+2, t3 , t4, t5 from stb1 order by t1 ", + "select (c1)+2, abs(t2)+2 ,abs(t3), abs(t4), abs(t5) from stb1 order by t1") - # bug need fix + # bug need fix - # tdSql.query(" select sum(c1) from stb1 where t1+10 >1; ") # taosd crash + # tdSql.query(" select sum(c1) from stb1 where t1+10 >1; ") # taosd crash tdSql.query("select c1 ,t1 from stb1 where t1 =0 ") tdSql.checkRows(13) # tdSql.query("select t1 from stb1 where t1 >0 ") @@ -532,7 +543,7 @@ class TDTestCase: # tdSql.query("select sum(t1) from (select c1 ,t1 from stb1)") # tdSql.checkData(0,0,61) # tdSql.query("select distinct(c1) ,t1 from stb1") - # tdSql.checkRows(11) + # tdSql.checkRows(20) # tdSql.query("select max(t2) , t1 ,c1, t2 from stb1") # tdSql.checkData(0,3,33333) @@ -543,45 +554,49 @@ class TDTestCase: tdSql.checkRows(1) # tdSql.query("select t1 from stb1 where abs(t1+c1)=1") # tdSql.checkRows(1) - tdSql.query("select abs(c1+t1)*t1 from stb1 where abs(c1)/floor(abs(ceil(t1))) ==1") - - + tdSql.query( + "select abs(c1+t1)*t1 from stb1 where abs(c1)/floor(abs(ceil(t1))) ==1") def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() tdLog.printNoPrefix("==========step1:create table ==============") - + self.prepare_datas() self.prepare_tag_datas() - tdLog.printNoPrefix("==========step2:test errors ==============") + tdLog.printNoPrefix("==========step2:test errors ==============") self.test_errors() - - tdLog.printNoPrefix("==========step3:support types ============") + + tdLog.printNoPrefix("==========step3:support types ============") self.support_types() - tdLog.printNoPrefix("==========step4: abs basic query ============") + tdLog.printNoPrefix("==========step4: abs basic query ============") self.basic_abs_function() - tdLog.printNoPrefix("==========step5: abs boundary query ============") + tdLog.printNoPrefix("==========step5: abs boundary query ============") self.check_boundary_values() - tdLog.printNoPrefix("==========step6: abs filter query ============") + tdLog.printNoPrefix("==========step6: abs filter query ============") self.abs_func_filter() - tdLog.printNoPrefix("==========step6: tag coumpute query ============") - + tdLog.printNoPrefix("==========step6: tag coumpute query ============") + self.test_tag_compute_for_scalar_function() + tdLog.printNoPrefix("==========step7: check result of query ============") + + self.insert_datas_and_check_abs(self.tb_nums,self.row_nums,self.time_step) + 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/distribute_agg_avg.py b/tests/system-test/2-query/distribute_agg_avg.py new file mode 100644 index 0000000000..647a262558 --- /dev/null +++ b/tests/system-test/2-query/distribute_agg_avg.py @@ -0,0 +1,279 @@ +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np +import random ,os ,sys +import platform + + +class TDTestCase: + updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , + "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143, + "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + self.vnode_disbutes = None + self.ts = 1537146000000 + + + def check_avg_functions(self, tbname , col_name): + + avg_sql = f"select avg({col_name}) from {tbname};" + + same_sql = f"select {col_name} from {tbname} where {col_name} is not null " + + tdSql.query(same_sql) + pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] + if (platform.system().lower() == 'windows' and pre_data.dtype == 'int32'): + pre_data = np.array(pre_data, dtype = 'int64') + pre_avg = np.sum(pre_data)/len(pre_data) + + tdSql.query(avg_sql) + tdSql.checkData(0,0,pre_avg) + + def prepare_datas_of_distribute(self): + + # prepate datas for 20 tables distributed at different vgroups + tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") + tdSql.execute(" use testdb ") + tdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32)) + ''' + ) + + tdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + ''' + ) + for i in range(20): + tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') + + for i in range(9): + tdSql.execute( + f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + ) + tdSql.execute( + f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + ) + + for i in range(1,21): + if i ==1 or i == 4: + continue + else: + tbname = "ct"+f'{i}' + for j in range(9): + tdSql.execute( + f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )" + ) + tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + + tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + + tdSql.execute( + f'''insert into t1 values + ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) + ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) + ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a ) + ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a ) + ( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a ) + ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a ) + ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) + ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) + ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) + ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ''' + ) + + tdLog.info(" prepare data for distributed_aggregate done! ") + + def check_distribute_datas(self): + # get vgroup_ids of all + tdSql.query("show vgroups ") + vgroups = tdSql.queryResult + + vnode_tables={} + + for vgroup_id in vgroups: + vnode_tables[vgroup_id[0]]=[] + + + # check sub_table of per vnode ,make sure sub_table has been distributed + tdSql.query("show tables like 'ct%'") + table_names = tdSql.queryResult + tablenames = [] + for table_name in table_names: + vnode_tables[table_name[6]].append(table_name[0]) + self.vnode_disbutes = vnode_tables + + count = 0 + for k ,v in vnode_tables.items(): + if len(v)>=2: + count+=1 + if count < 2: + tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") + + def check_avg_distribute_diff_vnode(self,col_name): + + vgroup_ids = [] + for k ,v in self.vnode_disbutes.items(): + if len(v)>=2: + vgroup_ids.append(k) + + distribute_tbnames = [] + + for vgroup_id in vgroup_ids: + vnode_tables = self.vnode_disbutes[vgroup_id] + distribute_tbnames.append(random.sample(vnode_tables,1)[0]) + tbname_ins = "" + for tbname in distribute_tbnames: + tbname_ins += "'%s' ,"%tbname + + tbname_filters = tbname_ins[:-1] + + avg_sql = f"select avg({col_name}) from stb1 where tbname in ({tbname_filters});" + + same_sql = f"select {col_name} from stb1 where tbname in ({tbname_filters}) and {col_name} is not null " + + tdSql.query(same_sql) + pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] + if (platform.system().lower() == 'windows' and pre_data.dtype == 'int32'): + pre_data = np.array(pre_data, dtype = 'int64') + pre_avg = np.sum(pre_data)/len(pre_data) + + tdSql.query(avg_sql) + tdSql.checkData(0,0,pre_avg) + + def check_avg_status(self): + # check max function work status + + tdSql.query("show tables like 'ct%'") + table_names = tdSql.queryResult + tablenames = [] + for table_name in table_names: + tablenames.append(table_name[0]) + + tdSql.query("desc stb1") + col_names = tdSql.queryResult + + colnames = [] + for col_name in col_names: + if col_name[1] in ["INT" ,"BIGINT" ,"SMALLINT" ,"TINYINT" , "FLOAT" ,"DOUBLE"]: + colnames.append(col_name[0]) + + for tablename in tablenames: + for colname in colnames: + self.check_avg_functions(tablename,colname) + + # check max function for different vnode + + for colname in colnames: + if colname.startswith("c"): + self.check_avg_distribute_diff_vnode(colname) + else: + # self.check_avg_distribute_diff_vnode(colname) # bug for tag + pass + + + def distribute_agg_query(self): + # basic filter + tdSql.query(" select avg(c1) from stb1 ") + tdSql.checkData(0,0,14.086956522) + + tdSql.query(" select avg(a) from (select avg(c1) a from stb1 partition by tbname) ") + tdSql.checkData(0,0,14.292307692) + + tdSql.query(" select avg(c1) from stb1 where t1=1") + tdSql.checkData(0,0,6.000000000) + + tdSql.query("select avg(c1+c2) from stb1 where c1 =1 ") + tdSql.checkData(0,0,11112.000000000) + + tdSql.query("select avg(c1) from stb1 where tbname=\"ct2\"") + tdSql.checkData(0,0,6.000000000) + + tdSql.query("select avg(c1) from stb1 partition by tbname") + tdSql.checkRows(20) + + tdSql.query("select avg(c1) from stb1 where t1> 4 partition by tbname") + tdSql.checkRows(15) + + # union all + tdSql.query("select avg(c1) from stb1 union all select avg(c1) from stb1 ") + tdSql.checkRows(2) + tdSql.checkData(0,0,14.086956522) + + tdSql.query("select avg(a) from (select avg(c1) a from stb1 union all select avg(c1) a from stb1)") + tdSql.checkRows(1) + tdSql.checkData(0,0,14.086956522) + + # join + + tdSql.execute(" create database if not exists db ") + tdSql.execute(" use db ") + tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") + tdSql.execute(" create table tb1 using st tags(1) ") + tdSql.execute(" create table tb2 using st tags(2) ") + + + for i in range(10): + ts = i*10 + self.ts + tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") + tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)") + + tdSql.query("select avg(tb1.c1), avg(tb2.c2) from tb1, tb2 where tb1.ts=tb2.ts") + tdSql.checkRows(1) + tdSql.checkData(0,0,4.500000000) + tdSql.checkData(0,1,4.500000000) + + # group by + tdSql.execute(" use testdb ") + + # partition by tbname or partition by tag + tdSql.query("select avg(c1) from stb1 partition by tbname") + tdSql.checkRows(20) + + # nest query for support max + tdSql.query("select avg(c2+2)+1 from (select avg(c1) c2 from stb1)") + tdSql.checkData(0,0,17.086956522) + tdSql.query("select avg(c1+2) as c2 from (select ts ,c1 ,c2 from stb1)") + tdSql.checkData(0,0,16.086956522) + tdSql.query("select avg(a+2) as c2 from (select ts ,abs(c1) a ,c2 from stb1)") + tdSql.checkData(0,0,16.086956522) + + # mixup with other functions + tdSql.query("select max(c1),count(c1),last(c2,c3),sum(c1+c2),avg(c1) from stb1") + tdSql.checkData(0,0,28) + tdSql.checkData(0,1,184) + tdSql.checkData(0,2,-99999) + tdSql.checkData(0,3,-999) + tdSql.checkData(0,4,28202310.000000000) + tdSql.checkData(0,5,14.086956522) + + def run(self): + + self.prepare_datas_of_distribute() + self.check_distribute_datas() + self.check_avg_status() + self.distribute_agg_query() + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/distribute_agg_max.py b/tests/system-test/2-query/distribute_agg_max.py index ae0ab5aafa..5c9760cbcf 100644 --- a/tests/system-test/2-query/distribute_agg_max.py +++ b/tests/system-test/2-query/distribute_agg_max.py @@ -245,6 +245,27 @@ class TDTestCase: tdSql.query(" select max(c1),c2 from stb1 group by c2 ") tdSql.checkRows(31) + # selective common cols of datas + tdSql.query("select max(c1),c2,c3,c5 from stb1") + tdSql.checkRows(1) + tdSql.checkData(0,0,28) + tdSql.checkData(0,1,311108) + tdSql.checkData(0,2,3108) + tdSql.checkData(0,3,31.08000) + + tdSql.query("select max(c1),t1,c2,t3 from stb1") + tdSql.checkRows(1) + tdSql.checkData(0,0,28) + tdSql.checkData(0,1,19) + tdSql.checkData(0,2,311108) + + tdSql.query("select max(c1),ceil(t1),pow(c2,1)+2,abs(t3) from stb1") + tdSql.checkRows(1) + tdSql.checkData(0,0,28) + tdSql.checkData(0,1,19) + tdSql.checkData(0,2,311110.000000000) + tdSql.checkData(0,3,2109) + # partition by tbname or partition by tag tdSql.query("select max(c1),tbname from stb1 partition by tbname") query_data = tdSql.queryResult diff --git a/tests/system-test/2-query/distribute_agg_min.py b/tests/system-test/2-query/distribute_agg_min.py index 8a458c74df..dd20d88229 100644 --- a/tests/system-test/2-query/distribute_agg_min.py +++ b/tests/system-test/2-query/distribute_agg_min.py @@ -245,6 +245,24 @@ class TDTestCase: tdSql.query(" select min(c1),c2 from stb1 group by c2 ") tdSql.checkRows(31) + # selective common cols of datas + tdSql.query("select min(c1),c2,c3,c5 from stb1") + tdSql.checkRows(1) + tdSql.checkData(0,0,0) + tdSql.checkData(0,1,0) + tdSql.checkData(0,2,0) + tdSql.checkData(0,3,0) + + tdSql.query("select min(c1),t1,c2,t3 from stb1 where c1 >5") + tdSql.checkRows(1) + tdSql.checkData(0,0,6) + tdSql.checkData(0,2,66666) + + tdSql.query("select min(c1),ceil(t1),pow(c2,1)+2,abs(t3) from stb1 where c1>12") + tdSql.checkRows(1) + tdSql.checkData(0,0,13) + tdSql.checkData(0,2,144445.000000000) + # partition by tbname or partition by tag tdSql.query("select min(c1),tbname from stb1 partition by tbname") query_data = tdSql.queryResult diff --git a/tests/system-test/2-query/distribute_agg_stddev.py b/tests/system-test/2-query/distribute_agg_stddev.py new file mode 100644 index 0000000000..5050e6e940 --- /dev/null +++ b/tests/system-test/2-query/distribute_agg_stddev.py @@ -0,0 +1,304 @@ +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np +import random ,os ,sys +import platform +import math + +class TDTestCase: + updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , + "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143, + "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + self.vnode_disbutes = None + self.ts = 1537146000000 + + + def check_stddev_functions(self, tbname , col_name): + + stddev_sql = f"select stddev({col_name}) from {tbname};" + + same_sql = f"select {col_name} from {tbname} where {col_name} is not null " + + tdSql.query(same_sql) + pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] + if (platform.system().lower() == 'windows' and pre_data.dtype == 'int32'): + pre_data = np.array(pre_data, dtype = 'int64') + pre_avg = np.sum(pre_data)/len(pre_data) + + # Calculate variance + stddev_result = 0 + for num in tdSql.queryResult: + stddev_result += (num-pre_avg)*(num-pre_avg)/len(tdSql.queryResult) + + stddev_result = math.sqrt(stddev_result) + + tdSql.query(stddev_sql) + + if -0.0001 < tdSql.queryResult[0][0]-stddev_result < 0.0001: + tdLog.info(" sql:%s; row:0 col:0 data:%d , expect:%d"%(stddev_sql,tdSql.queryResult[0][0],stddev_result)) + else: + tdLog.exit(" sql:%s; row:0 col:0 data:%d , expect:%d"%(stddev_sql,tdSql.queryResult[0][0],stddev_result)) + + def prepare_datas_of_distribute(self): + + # prepate datas for 20 tables distributed at different vgroups + tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") + tdSql.execute(" use testdb ") + tdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32)) + ''' + ) + + tdSql.execute( + ''' + create table t1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + ''' + ) + for i in range(20): + tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') + + for i in range(9): + tdSql.execute( + f"insert into ct1 values ( now()-{i*10}s, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + ) + tdSql.execute( + f"insert into ct4 values ( now()-{i*90}d, {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, 'binary{i}', 'nchar{i}', now()+{1*i}a )" + ) + + for i in range(1,21): + if i ==1 or i == 4: + continue + else: + tbname = "ct"+f'{i}' + for j in range(9): + tdSql.execute( + f"insert into {tbname} values ( now()-{(i+j)*10}s, {1*(j+i)}, {11111*(j+i)}, {111*(j+i)}, {11*(j)}, {1.11*(j+i)}, {11.11*(j+i)}, {(j+i)%2}, 'binary{j}', 'nchar{j}', now()+{1*j}a )" + ) + tdSql.execute("insert into ct1 values (now()-45s, 0, 0, 0, 0, 0, 0, 0, 'binary0', 'nchar0', now()+8a )") + tdSql.execute("insert into ct1 values (now()+10s, 9, -99999, -999, -99, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute("insert into ct1 values (now()+15s, 9, -99999, -999, -99, -9.99, NULL, 1, 'binary9', 'nchar9', now()+9a )") + tdSql.execute("insert into ct1 values (now()+20s, 9, -99999, -999, NULL, -9.99, -99.99, 1, 'binary9', 'nchar9', now()+9a )") + + tdSql.execute("insert into ct4 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute("insert into ct4 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute("insert into ct4 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + + tdSql.execute( + f'''insert into t1 values + ( '2020-04-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( '2020-10-21 01:01:01.000', 1, 11111, 111, 11, 1.11, 11.11, 1, "binary1", "nchar1", now()+1a ) + ( '2020-12-31 01:01:01.000', 2, 22222, 222, 22, 2.22, 22.22, 0, "binary2", "nchar2", now()+2a ) + ( '2021-01-01 01:01:06.000', 3, 33333, 333, 33, 3.33, 33.33, 0, "binary3", "nchar3", now()+3a ) + ( '2021-05-07 01:01:10.000', 4, 44444, 444, 44, 4.44, 44.44, 1, "binary4", "nchar4", now()+4a ) + ( '2021-07-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ( '2021-09-30 01:01:16.000', 5, 55555, 555, 55, 5.55, 55.55, 0, "binary5", "nchar5", now()+5a ) + ( '2022-02-01 01:01:20.000', 6, 66666, 666, 66, 6.66, 66.66, 1, "binary6", "nchar6", now()+6a ) + ( '2022-10-28 01:01:26.000', 7, 00000, 000, 00, 0.00, 00.00, 1, "binary7", "nchar7", "1970-01-01 08:00:00.000" ) + ( '2022-12-01 01:01:30.000', 8, -88888, -888, -88, -8.88, -88.88, 0, "binary8", "nchar8", "1969-01-01 01:00:00.000" ) + ( '2022-12-31 01:01:36.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00:00:00.000" ) + ( '2023-02-21 01:01:01.000', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) + ''' + ) + + tdLog.info(" prepare data for distributed_aggregate done! ") + + def check_distribute_datas(self): + # get vgroup_ids of all + tdSql.query("show vgroups ") + vgroups = tdSql.queryResult + + vnode_tables={} + + for vgroup_id in vgroups: + vnode_tables[vgroup_id[0]]=[] + + + # check sub_table of per vnode ,make sure sub_table has been distributed + tdSql.query("show tables like 'ct%'") + table_names = tdSql.queryResult + tablenames = [] + for table_name in table_names: + vnode_tables[table_name[6]].append(table_name[0]) + self.vnode_disbutes = vnode_tables + + count = 0 + for k ,v in vnode_tables.items(): + if len(v)>=2: + count+=1 + if count < 2: + tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") + + def check_stddev_distribute_diff_vnode(self,col_name): + + vgroup_ids = [] + for k ,v in self.vnode_disbutes.items(): + if len(v)>=2: + vgroup_ids.append(k) + + distribute_tbnames = [] + + for vgroup_id in vgroup_ids: + vnode_tables = self.vnode_disbutes[vgroup_id] + distribute_tbnames.append(random.sample(vnode_tables,1)[0]) + tbname_ins = "" + for tbname in distribute_tbnames: + tbname_ins += "'%s' ,"%tbname + + tbname_filters = tbname_ins[:-1] + + stddev_sql = f"select stddev({col_name}) from stb1 where tbname in ({tbname_filters});" + + same_sql = f"select {col_name} from stb1 where tbname in ({tbname_filters}) and {col_name} is not null " + + tdSql.query(same_sql) + pre_data = np.array(tdSql.queryResult)[np.array(tdSql.queryResult) != None] + if (platform.system().lower() == 'windows' and pre_data.dtype == 'int32'): + pre_data = np.array(pre_data, dtype = 'int64') + pre_avg = np.sum(pre_data)/len(pre_data) + + # Calculate variance + stddev_result = 0 + for num in tdSql.queryResult: + stddev_result += (num-pre_avg)*(num-pre_avg)/len(tdSql.queryResult) + + stddev_result = math.sqrt(stddev_result) + + tdSql.query(stddev_sql) + tdSql.checkData(0,0,stddev_result) + + + def check_stddev_status(self): + # check max function work status + + tdSql.query("show tables like 'ct%'") + table_names = tdSql.queryResult + tablenames = [] + for table_name in table_names: + tablenames.append(table_name[0]) + + tdSql.query("desc stb1") + col_names = tdSql.queryResult + + colnames = [] + for col_name in col_names: + if col_name[1] in ["INT" ,"BIGINT" ,"SMALLINT" ,"TINYINT" , "FLOAT" ,"DOUBLE"]: + colnames.append(col_name[0]) + + for tablename in tablenames: + for colname in colnames: + if colname.startswith("c"): + self.check_stddev_functions(tablename,colname) + else: + # self.check_stddev_functions(tablename,colname) + pass + + + # check max function for different vnode + + for colname in colnames: + if colname.startswith("c"): + self.check_stddev_distribute_diff_vnode(colname) + else: + # self.check_stddev_distribute_diff_vnode(colname) # bug for tag + pass + + + def distribute_agg_query(self): + # basic filter + tdSql.query(" select stddev(c1) from stb1 ") + tdSql.checkData(0,0,6.694663959) + + tdSql.query(" select stddev(a) from (select stddev(c1) a from stb1 partition by tbname) ") + tdSql.checkData(0,0,0.156797505) + + tdSql.query(" select stddev(c1) from stb1 where t1=1") + tdSql.checkData(0,0,2.581988897) + + tdSql.query("select stddev(c1+c2) from stb1 where c1 =1 ") + tdSql.checkData(0,0,0.000000000) + + tdSql.query("select stddev(c1) from stb1 where tbname=\"ct2\"") + tdSql.checkData(0,0,2.581988897) + + tdSql.query("select stddev(c1) from stb1 partition by tbname") + tdSql.checkRows(20) + + tdSql.query("select stddev(c1) from stb1 where t1> 4 partition by tbname") + tdSql.checkRows(15) + + # union all + tdSql.query("select stddev(c1) from stb1 union all select stddev(c1) from stb1 ") + tdSql.checkRows(2) + tdSql.checkData(0,0,6.694663959) + + tdSql.query("select stddev(a) from (select stddev(c1) a from stb1 union all select stddev(c1) a from stb1)") + tdSql.checkRows(1) + tdSql.checkData(0,0,0.000000000) + + # join + + tdSql.execute(" create database if not exists db ") + tdSql.execute(" use db ") + tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") + tdSql.execute(" create table tb1 using st tags(1) ") + tdSql.execute(" create table tb2 using st tags(2) ") + + + for i in range(10): + ts = i*10 + self.ts + tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") + tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)") + + tdSql.query("select stddev(tb1.c1), stddev(tb2.c2) from tb1, tb2 where tb1.ts=tb2.ts") + tdSql.checkRows(1) + tdSql.checkData(0,0,2.872281323) + tdSql.checkData(0,1,2.872281323) + + # group by + tdSql.execute(" use testdb ") + + # partition by tbname or partition by tag + tdSql.query("select stddev(c1) from stb1 partition by tbname") + tdSql.checkRows(20) + + # nest query for support max + tdSql.query("select stddev(c2+2)+1 from (select stddev(c1) c2 from stb1)") + tdSql.checkData(0,0,1.000000000) + tdSql.query("select stddev(c1+2) as c2 from (select ts ,c1 ,c2 from stb1)") + tdSql.checkData(0,0,6.694663959) + tdSql.query("select stddev(a+2) as c2 from (select ts ,abs(c1) a ,c2 from stb1)") + tdSql.checkData(0,0,6.694663959) + + # mixup with other functions + tdSql.query("select max(c1),count(c1),last(c2,c3),sum(c1+c2),avg(c1),stddev(c1) from stb1") + tdSql.checkData(0,0,28) + tdSql.checkData(0,1,184) + tdSql.checkData(0,2,-99999) + tdSql.checkData(0,3,-999) + tdSql.checkData(0,4,28202310.000000000) + tdSql.checkData(0,5,14.086956522) + tdSql.checkData(0,6,6.694663959) + + def run(self): + + self.prepare_datas_of_distribute() + self.check_distribute_datas() + self.check_stddev_status() + self.distribute_agg_query() + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/join.py b/tests/system-test/2-query/join.py index 140808d387..5ff11c84dd 100644 --- a/tests/system-test/2-query/join.py +++ b/tests/system-test/2-query/join.py @@ -238,7 +238,7 @@ class TDTestCase: ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp - ) tags (t1 int) + ) tags (tag1 int) ''' create_ntb_sql = f'''create table t1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, diff --git a/tests/system-test/2-query/json_tag.py b/tests/system-test/2-query/json_tag.py index 957e916e34..052ff923ac 100644 --- a/tests/system-test/2-query/json_tag.py +++ b/tests/system-test/2-query/json_tag.py @@ -518,7 +518,7 @@ class TDTestCase: tdSql.query("select avg(dataint) from jsons1 where jtag is not null") tdSql.checkData(0, 0, 5.3) #tdSql.error("select twa(dataint) from jsons1 where jtag is not null") - tdSql.error("select irate(dataint) from jsons1 where jtag is not null") + tdSql.query("select irate(dataint) from jsons1 where jtag is not null") #tdSql.query("select sum(dataint) from jsons1 where jtag->'tag1' is not null") #tdSql.checkData(0, 0, 49) tdSql.query("select stddev(dataint) from jsons1 where jtag->'tag1'>1") diff --git a/tests/system-test/2-query/sample.py b/tests/system-test/2-query/sample.py index a84d93404a..33ef7e65db 100644 --- a/tests/system-test/2-query/sample.py +++ b/tests/system-test/2-query/sample.py @@ -624,8 +624,7 @@ class TDTestCase: tdLog.info(" sample data is in datas groups ,successed sql is : %s" % sample_query ) else: tdLog.exit(" sample data is not in datas groups ,failed sql is : %s" % sample_query ) - - + def basic_sample_query(self): tdSql.execute(" drop database if exists db ") tdSql.execute(" create database if not exists db duration 300 ") @@ -760,6 +759,14 @@ class TDTestCase: self.check_sample("select sample( c1 ,3 ) from t1 where c1 between 1 and 10" ,"select c1 from t1 where c1 between 1 and 10") + tdSql.query("select sample(c1,2) ,c2,c3 ,c5 from stb1") + tdSql.checkRows(2) + tdSql.checkCols(4) + + self.check_sample("select sample( c1 ,3 ),c2,c3,c4,c5 from t1 where c1 between 1 and 10" ,"select c1,c2,c3,c4,c5 from t1 where c1 between 1 and 10") + self.check_sample("select sample( c1 ,3 ),c2,c3,c4,c5 from stb1 where c1 between 1 and 10" ,"select c1,c2,c3,c4,c5 from stb1 where c1 between 1 and 10") + self.check_sample("select sample( c1 ,3 ),t1 from stb1 where c1 between 1 and 10" ,"select c1,t1 from stb1 where c1 between 1 and 10") + # join tdSql.query("select sample( ct4.c1 , 1 ) from ct1, ct4 where ct4.ts=ct1.ts") @@ -772,8 +779,8 @@ class TDTestCase: self.check_sample("select sample(c1,2) from stb1 partition by tbname" , "select c1 from stb1 partition by tbname") # nest query - # tdSql.query("select sample(c1,2) from (select c1 from t1); ") - # tdSql.checkRows(2) + tdSql.query("select sample(c1,2) from (select c1 from t1); ") + tdSql.checkRows(2) # union all tdSql.query("select sample(c1,2) from t1 union all select sample(c1,3) from t1") diff --git a/tests/system-test/2-query/substr.py b/tests/system-test/2-query/substr.py index e78606826b..79b5ac515b 100644 --- a/tests/system-test/2-query/substr.py +++ b/tests/system-test/2-query/substr.py @@ -23,6 +23,9 @@ CHAR_COL = [ BINARY_COL, NCHAR_COL, ] BOOLEAN_COL = [ BOOL_COL, ] TS_TYPE_COL = [ TS_COL, ] +ERR_POS = 0 +CURRENT_POS = 1 +LENS = 6 class TDTestCase: @@ -76,6 +79,7 @@ class TDTestCase: if pos < 1: tdSql.error(f"select substr( {condition}, {pos}, {lens}) , {condition} from {tbname} ") + break tdSql.query(f"select substr( {condition}, {pos}, {lens}) , {condition} from {tbname} ") for j in range(tdSql.queryRows): @@ -127,7 +131,7 @@ class TDTestCase: tdLog.printNoPrefix("==========current sql condition check , must return query ok==========") tbname = ["ct1", "ct2", "ct4", "t1", "stb1"] for tb in tbname: - self.__substr_check(tb, 1, 6) + self.__substr_check(tb, CURRENT_POS, LENS) tdLog.printNoPrefix(f"==========current sql condition check in {tb} over==========") def __test_error(self): @@ -137,7 +141,7 @@ class TDTestCase: for tb in tbname: for errsql in self.__substr_err_check(tb): tdSql.error(sql=errsql) - self.__substr_check(tb, 0, 6) + self.__substr_check(tb, ERR_POS, LENS) tdLog.printNoPrefix(f"==========err sql condition check in {tb} over==========") @@ -154,7 +158,7 @@ class TDTestCase: ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, {FLOAT_COL} float, {DOUBLE_COL} double, {BOOL_COL} bool, {BINARY_COL} binary(16), {NCHAR_COL} nchar(32), {TS_COL} timestamp - ) tags (t1 int) + ) tags (tag1 int) ''' create_ntb_sql = f'''create table t1( ts timestamp, {INT_COL} int, {BINT_COL} bigint, {SINT_COL} smallint, {TINT_COL} tinyint, diff --git a/tests/system-test/2-query/sum.py b/tests/system-test/2-query/sum.py index ea0e1f7fae..f6ff4989e7 100644 --- a/tests/system-test/2-query/sum.py +++ b/tests/system-test/2-query/sum.py @@ -73,7 +73,7 @@ class TDTestCase: f"select sum(ceil( {un_num_col} )) from {tbanme} ", ) ) - sqls.extend( f"select sum( {un_num_col} + {un_num_col_2} ) from {tbanme} " for un_num_col_2 in UN_NUM_COL ) + # sqls.extend( f"select sum( {un_num_col} + {un_num_col_2} ) from {tbanme} " for un_num_col_2 in UN_NUM_COL ) sqls.extend( f"select sum( {num_col} + {ts_col} ) from {tbanme} " for num_col in NUM_COL for ts_col in TS_TYPE_COL) sqls.extend( diff --git a/tests/system-test/2-query/top.py b/tests/system-test/2-query/top.py index 83f535856e..86e201ea9a 100644 --- a/tests/system-test/2-query/top.py +++ b/tests/system-test/2-query/top.py @@ -11,103 +11,159 @@ # -*- coding: utf-8 -*- -import random import string from util.common import * from util.log import * from util.cases import * from util.sql import * - +from util.sqlset import * class TDTestCase: def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor()) - + self.setsql = TDSetSql() + self.ntbname = 'ntb' self.rowNum = 10 self.tbnum = 20 self.ts = 1537146000000 self.binary_str = 'taosdata' self.nchar_str = '涛思数据' - def top_check_base(self): - tdSql.prepare() - tdSql.execute('''create table stb(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, - col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') - tdSql.execute("create table stb_1 using stb tags('beijing')") - for i in range(self.rowNum): - tdSql.execute(f"insert into stb_1 values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" - % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) - column_list = ['col1','col2','col3','col4','col5','col6','col7','col8'] - error_column_list = ['col11','col12','col13'] - error_param_list = [0,101] - for i in column_list: - tdSql.query(f'select top({i},2) from stb_1') - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(9,),(10,)]) - for j in error_param_list: - tdSql.error(f'select top({i},{j}) from stb_1') - for i in error_column_list: - tdSql.error(f'select top({i},10) from stb_1') - tdSql.query("select ts,top(col1, 2),ts from stb_1 group by tbname") - tdSql.checkRows(2) - tdSql.query('select top(col2,1) from stb_1 interval(1y) order by col2') - tdSql.checkData(0,0,10) - tdSql.error("select * from stb_1 where top(col2,1)=1") - tdSql.execute('drop database db') - def top_check_stb_distribute(self): - # prepare data for vgroup 4 + self.column_dict = { + 'ts' : 'timestamp', + 'col1': 'tinyint', + 'col2': 'smallint', + 'col3': 'int', + 'col4': 'bigint', + 'col5': 'tinyint unsigned', + 'col6': 'smallint unsigned', + 'col7': 'int unsigned', + 'col8': 'bigint unsigned', + 'col9': 'float', + 'col10': 'double', + 'col11': 'bool', + 'col12': 'binary(20)', + 'col13': 'nchar(20)' + } + + self.param_list = [1,100] + + def insert_data(self,column_dict,tbname,row_num): + sql = '' + for k, v in column_dict.items(): + if v.lower() == 'timestamp' or v.lower() == 'tinyint' or v.lower() == 'smallint' or v.lower() == 'int' or v.lower() == 'bigint' or \ + v.lower() == 'tinyint unsigned' or v.lower() == 'smallint unsigned' or v.lower() == 'int unsigned' or v.lower() == 'bigint unsigned' or v.lower() == 'bool': + sql += '%d,' + elif v.lower() == 'float' or v.lower() == 'double': + sql += '%f,' + elif 'binary' in v.lower(): + sql += f'"{self.binary_str}%d",' + elif 'nchar' in v.lower(): + sql += f'"{self.nchar_str}%d",' + insert_sql = f'insert into {tbname} values({sql[:-1]})' + for i in range(row_num): + insert_list = [] + for k, v in column_dict.items(): + if v.lower() in[ 'tinyint' , 'smallint' , 'int', 'bigint' , 'tinyint unsigned' , 'smallint unsigned' , 'int unsigned' , 'bigint unsigned'] or\ + 'binary' in v.lower() or 'nchar' in v.lower(): + insert_list.append(1 + i) + elif v.lower() == 'float' or v.lower() == 'double': + insert_list.append(0.1 + i) + elif v.lower() == 'bool': + insert_list.append(i % 2) + elif v.lower() == 'timestamp': + insert_list.append(self.ts + i) + tdSql.execute(insert_sql%(tuple(insert_list))) + pass + def top_check_data(self,tbname,tb_type): + new_column_dict = {} + for param in self.param_list: + for k,v in self.column_dict.items(): + if v.lower() in ['tinyint','smallint','int','bigint','tinyint unsigned','smallint unsigned','int unsigned','bigint unsigned']: + tdSql.query(f'select top({k},{param}) from {tbname}') + if param >= self.rowNum: + if tb_type in ['normal_table','child_table']: + tdSql.checkRows(self.rowNum) + values_list = [] + for i in range(self.rowNum): + tp = (self.rowNum-i,) + values_list.insert(0,tp) + tdSql.checkEqual(tdSql.queryResult,values_list) + elif tb_type == 'stable': + tdSql.checkRows(param) + elif param < self.rowNum: + if tb_type in ['normal_table','child_table']: + tdSql.checkRows(param) + values_list = [] + for i in range(param): + tp = (self.rowNum-i,) + values_list.insert(0,tp) + tdSql.checkEqual(tdSql.queryResult,values_list) + elif tb_type == 'stable': + tdSql.checkRows(param) + for i in [self.param_list[0]-1,self.param_list[-1]+1]: + tdSql.error(f'select top({k},{i}) from {tbname}') + new_column_dict.update({k:v}) + elif v.lower() == 'bool' or 'binary' in v.lower() or 'nchar' in v.lower(): + tdSql.error(f'select top({k},{param}) from {tbname}') + tdSql.error(f'select * from {tbname} where top({k},{param})=1') + for key in new_column_dict.keys(): + for k in self.column_dict.keys(): + if key == k : + continue + else: + tdSql.query(f'select top({key},2),{k} from {tbname} group by tbname') + if tb_type == 'normal_table' or tb_type == 'child_table': + tdSql.checkRows(2) + else: + tdSql.checkRows(2*self.tbnum) + def top_check_stb(self): dbname = tdCom.getLongName(10, "letters") stbname = tdCom.getLongName(5, "letters") + tag_dict = { + 't0':'int' + } + tag_values = [ + f'1' + ] tdSql.execute(f"create database if not exists {dbname} vgroups 2") tdSql.execute(f'use {dbname}') - # build 20 child tables,every table insert 10 rows - tdSql.execute(f'''create table {stbname}(ts timestamp, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 tinyint unsigned, col6 smallint unsigned, - col7 int unsigned, col8 bigint unsigned, col9 float, col10 double, col11 bool, col12 binary(20), col13 nchar(20)) tags(loc nchar(20))''') + tdSql.execute(self.setsql.set_create_stable_sql(stbname,self.column_dict,tag_dict)) + for i in range(self.tbnum): - tdSql.execute(f"create table {stbname}_{i} using {stbname} tags('beijing')") - tdSql.execute(f"insert into {stbname}_{i}(ts) values(%d)" % (self.ts - 1-i)) - column_list = ['col1','col2','col3','col4','col5','col6','col7','col8'] - for i in [f'{stbname}', f'{dbname}.{stbname}']: - for j in column_list: - tdSql.query(f"select top({j},1) from {i}") - tdSql.checkRows(0) + tdSql.execute(f"create table {stbname}_{i} using {stbname} tags({tag_values[0]})") + tdSql.execute(self.insert_data(self.column_dict,f'{stbname}_{i}',self.rowNum)) tdSql.query('show tables') vgroup_list = [] for i in range(len(tdSql.queryResult)): vgroup_list.append(tdSql.queryResult[i][6]) - vgroup_list_set = set(vgroup_list) + vgroup_list_set = set(vgroup_list) for i in vgroup_list_set: vgroups_num = vgroup_list.count(i) - if vgroups_num >=2: + if vgroups_num >= 2: tdLog.info(f'This scene with {vgroups_num} vgroups is ok!') - continue - else: - tdLog.exit(f'This scene does not meet the requirements with {vgroups_num} vgroup!\n') - for i in range(self.rowNum): - for j in range(self.tbnum): - tdSql.execute(f"insert into {stbname}_{j} values(%d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %d, '{self.binary_str}%d', '{self.nchar_str}%d')" - % (self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1)) - - error_column_list = ['col11','col12','col13'] - error_param_list = [0,101] - for i in column_list: - tdSql.query(f'select top({i},2) from {stbname}') - tdSql.checkRows(2) - tdSql.checkEqual(tdSql.queryResult,[(10,),(10,)]) - for j in error_param_list: - tdSql.error(f'select top({i},{j}) from {stbname}') - for i in error_column_list: - tdSql.error(f'select top({i},10) from {stbname}') - tdSql.query(f"select ts,top(col1, 2),ts from {stbname} group by tbname") - tdSql.checkRows(2*self.tbnum) - tdSql.query(f'select top(col2,1) from {stbname} interval(1y) order by col2') - tdSql.checkData(0,0,10) - tdSql.error(f"select * from {stbname} where top(col2,1)=1") + else: + tdLog.exit( + 'This scene does not meet the requirements with {vgroups_num} vgroup!\n') + for i in range(self.tbnum): + self.top_check_data(f'{stbname}_{i}','child_table') + self.top_check_data(stbname,'stable') + tdSql.execute(f'drop database {dbname}') + + def top_check_ntb(self): + tdSql.prepare() + tdSql.execute(self.setsql.set_create_normaltable_sql(self.ntbname,self.column_dict)) + self.insert_data(self.column_dict,self.ntbname,self.rowNum) + self.top_check_data(self.ntbname,'normal_table') + tdSql.execute('drop database db') + def run(self): - self.top_check_base() - self.top_check_stb_distribute() + self.top_check_ntb() + self.top_check_stb() + + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/system-test/2-query/twa.py b/tests/system-test/2-query/twa.py new file mode 100644 index 0000000000..b400e503d9 --- /dev/null +++ b/tests/system-test/2-query/twa.py @@ -0,0 +1,150 @@ +from util.log import * +from util.cases import * +from util.sql import * +import numpy as np +import random ,os ,sys +import platform +import math + +class TDTestCase: + updatecfgDict = {'debugFlag': 143 ,"cDebugFlag":143,"uDebugFlag":143 ,"rpcDebugFlag":143 , "tmrDebugFlag":143 , + "jniDebugFlag":143 ,"simDebugFlag":143,"dDebugFlag":143, "dDebugFlag":143,"vDebugFlag":143,"mDebugFlag":143,"qDebugFlag":143, + "wDebugFlag":143,"sDebugFlag":143,"tsdbDebugFlag":143,"tqDebugFlag":143 ,"fsDebugFlag":143 ,"fnDebugFlag":143, + "maxTablesPerVnode":2 ,"minTablesPerVnode":2,"tableIncStepPerVnode":2 } + + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + self.vnode_disbutes = None + self.ts = 1537146000000 + self.tb_nums = 20 + self.row_nums = 100 + self.time_step = 1000 + + def prepare_datas_of_distribute(self): + + # prepate datas for 20 tables distributed at different vgroups + tdSql.execute("create database if not exists testdb keep 3650 duration 1000 vgroups 5") + tdSql.execute(" use testdb ") + tdSql.execute( + '''create table stb1 + (ts timestamp, c1 int, c2 bigint, c3 smallint, c4 tinyint, c5 float, c6 double, c7 bool, c8 binary(16),c9 nchar(32), c10 timestamp) + tags (t0 timestamp, t1 int, t2 bigint, t3 smallint, t4 tinyint, t5 float, t6 double, t7 bool, t8 binary(16),t9 nchar(32)) + ''' + ) + + for i in range(self.tb_nums): + tdSql.execute(f'create table ct{i+1} using stb1 tags ( now(), {1*i}, {11111*i}, {111*i}, {11*i}, {1.11*i}, {11.11*i}, {i%2}, "binary{i}", "nchar{i}" )') + ts = self.ts + for j in range(self.row_nums): + ts+=j*self.time_step + tdSql.execute( + f"insert into ct{i+1} values({ts}, 1, 11111, 111, 1, 1.11, 11.11, 2, 'binary{j}', 'nchar{j}', now()+{1*j}a )" + ) + + tdSql.execute("insert into ct1 values (now()-810d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute("insert into ct1 values (now()-400d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + tdSql.execute("insert into ct1 values (now()+90d, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ) ") + + tdLog.info(" prepare data for distributed_aggregate done! ") + + def twa_support_types(self): + tdSql.query("desc stb1 ") + schema_list = tdSql.queryResult + for col_type in schema_list: + if col_type[1] in ["TINYINT" ,"SMALLINT","BIGINT" ,"INT","FLOAT","DOUBLE"]: + tdSql.query(f" select twa({col_type[0]}) from stb1 partition by tbname ") + else: + tdSql.error(f" select twa({col_type[0]}) from stb1 partition by tbname ") + + + def check_distribute_datas(self): + # get vgroup_ids of all + tdSql.query("show vgroups ") + vgroups = tdSql.queryResult + + vnode_tables={} + + for vgroup_id in vgroups: + vnode_tables[vgroup_id[0]]=[] + + # check sub_table of per vnode ,make sure sub_table has been distributed + tdSql.query("show tables like 'ct%'") + table_names = tdSql.queryResult + tablenames = [] + for table_name in table_names: + vnode_tables[table_name[6]].append(table_name[0]) + self.vnode_disbutes = vnode_tables + + count = 0 + for k ,v in vnode_tables.items(): + if len(v)>=2: + count+=1 + if count < 2: + tdLog.exit(" the datas of all not satisfy sub_table has been distributed ") + + def distribute_twa_query(self): + # basic filter + tdSql.query(" select twa(c1) from ct1 ") + tdSql.checkData(0,0,1.000000000) + + tdSql.query(" select twa(c1) from stb1 partition by tbname ") + tdSql.checkRows(self.tb_nums) + tdSql.checkData(0,0,1.000000000) + + tdSql.query(" select twa(c2) from stb1 group by tbname ") + tdSql.checkRows(self.tb_nums) + tdSql.checkData(0,0,11111.000000000) + + tdSql.query("select twa(c1+c2) from stb1 partition by tbname ") + tdSql.checkData(0,0,11112.000000000) + + tdSql.query("select twa(c1) from stb1 partition by t1") + tdSql.checkRows(self.tb_nums) + tdSql.checkData(0,0,1.000000000) + + # union all + tdSql.query(" select twa(c1) from stb1 partition by tbname union all select twa(c1) from stb1 partition by tbname ") + tdSql.checkRows(40) + tdSql.checkData(0,0,1.000000000) + + # join + + tdSql.execute(" create database if not exists db ") + tdSql.execute(" use db ") + tdSql.execute(" create stable st (ts timestamp , c1 int ,c2 float) tags(t1 int) ") + tdSql.execute(" create table tb1 using st tags(1) ") + tdSql.execute(" create table tb2 using st tags(2) ") + + + for i in range(10): + ts = i*10 + self.ts + tdSql.execute(f" insert into tb1 values({ts},{i},{i}.0)") + tdSql.execute(f" insert into tb2 values({ts},{i},{i}.0)") + + tdSql.query(" select twa(tb1.c1), twa(tb2.c2) from tb1, tb2 where tb1.ts=tb2.ts ") + tdSql.checkRows(1) + tdSql.checkData(0,0,4.500000000) + tdSql.checkData(0,1,4.500000000) + + # group by + tdSql.execute(" use testdb ") + + # mixup with other functions + tdSql.query(" select twa(c1),twa(c2),max(c1),elapsed(ts) from stb1 ") + tdSql.checkData(0,0,1.000000000) + tdSql.checkData(0,1,11111.000000000) + tdSql.checkData(0,2,1) + + def run(self): + self.prepare_datas_of_distribute() + self.check_distribute_datas() + self.twa_support_types() + self.distribute_twa_query() + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/6-cluster/5dnode3mnodeStop.py b/tests/system-test/6-cluster/5dnode3mnodeStop.py index 654b27bfc0..e1f66ceacb 100644 --- a/tests/system-test/6-cluster/5dnode3mnodeStop.py +++ b/tests/system-test/6-cluster/5dnode3mnodeStop.py @@ -7,31 +7,25 @@ import os from util.log import * from util.sql import * from util.cases import * +from util.dnodes import * from util.dnodes import TDDnodes from util.dnodes import TDDnode +from util.cluster import * +from test import tdDnodes + import time import socket import subprocess from multiprocessing import Process -class MyDnodes(TDDnodes): - def __init__(self ,dnodes_lists): - super(MyDnodes,self).__init__() - self.dnodes = dnodes_lists # dnode must be TDDnode instance - self.simDeployed = False + class TDTestCase: def init(self,conn ,logSql): tdLog.debug(f"start to excute {__file__}") - self.TDDnodes = None + tdSql.init(conn.cursor()) + self.host = socket.gethostname() - def buildcluster(self,dnodenumber): - self.depoly_cluster(dnodenumber) - self.master_dnode = self.TDDnodes.dnodes[0] - self.host=self.master_dnode.cfgDict["fqdn"] - conn1 = taos.connect(self.master_dnode.cfgDict["fqdn"] , config=self.master_dnode.cfgDir) - tdSql.init(conn1.cursor()) - def getBuildPath(self): selfPath = os.path.dirname(os.path.realpath(__file__)) @@ -70,72 +64,34 @@ class TDTestCase: for i in range(4): tdSql.execute(f'create table ct{i+1} using stb1 tags ( {i+1} )') - def depoly_cluster(self ,dnodes_nums): - - testCluster = False - valgrind = 0 - hostname = socket.gethostname() - dnodes = [] - start_port = 6030 - for num in range(1, dnodes_nums+1): - dnode = TDDnode(num) - dnode.addExtraCfg("firstEp", f"{hostname}:{start_port}") - dnode.addExtraCfg("fqdn", f"{hostname}") - dnode.addExtraCfg("serverPort", f"{start_port + (num-1)*100}") - dnode.addExtraCfg("monitorFqdn", hostname) - dnode.addExtraCfg("monitorPort", 7043) - dnodes.append(dnode) - - self.TDDnodes = MyDnodes(dnodes) - self.TDDnodes.init("") - self.TDDnodes.setTestCluster(testCluster) - self.TDDnodes.setValgrind(valgrind) - self.TDDnodes.stopAll() - for dnode in self.TDDnodes.dnodes: - self.TDDnodes.deploy(dnode.index,{}) - - for dnode in self.TDDnodes.dnodes: - self.TDDnodes.starttaosd(dnode.index) - - # create cluster - for dnode in self.TDDnodes.dnodes[1:]: - # tdLog.debug(dnode.cfgDict) - dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] - dnode_first_host = dnode.cfgDict["firstEp"].split(":")[0] - dnode_first_port = dnode.cfgDict["firstEp"].split(":")[-1] - cmd = f" taos -h {dnode_first_host} -P {dnode_first_port} -s ' create dnode \"{dnode_id} \" ' ;" - tdLog.debug(cmd) - os.system(cmd) - - time.sleep(2) - tdLog.info(" create cluster with %d dnode done! " %dnodes_nums) - + def check3mnode(self): count=0 while count < 10: time.sleep(1) tdSql.query("show mnodes;") if tdSql.checkRows(3) : - tdLog.debug("mnode is three nodes") + tdLog.debug("mnode is three nodes") + else: + tdLog.exit("mnode number is correct") if tdSql.queryResult[0][2]=='leader' : if tdSql.queryResult[1][2]=='follower': if tdSql.queryResult[2][2]=='follower': tdLog.debug("three mnodes is ready in 10s") break - elif tdSql.queryResult[0][2]=='follower' : - if tdSql.queryResult[1][2]=='leader': + elif tdSql.queryResult[1][2]=='leader' : + if tdSql.queryResult[0][2]=='follower': if tdSql.queryResult[2][2]=='follower': tdLog.debug("three mnodes is ready in 10s") break - elif tdSql.queryResult[0][2]=='follower' : + elif tdSql.queryResult[2][2]=='leader' : if tdSql.queryResult[1][2]=='follower': - if tdSql.queryResult[2][2]=='leader': + if tdSql.queryResult[0][2]=='follower': tdLog.debug("three mnodes is ready in 10s") break count+=1 else: - tdLog.debug("three mnodes is not ready in 10s ") - return -1 + tdLog.exit("three mnodes is not ready in 10s ") tdSql.query("show mnodes;") tdSql.checkRows(3) @@ -153,6 +109,8 @@ class TDTestCase: tdSql.query("show mnodes;") if tdSql.checkRows(3) : tdLog.debug("mnode is three nodes") + else: + tdLog.exit("mnode number is correct") if tdSql.queryResult[0][2]=='offline' : if tdSql.queryResult[1][2]=='leader': if tdSql.queryResult[2][2]=='follower': @@ -164,8 +122,8 @@ class TDTestCase: break count+=1 else: - tdLog.debug("stop mnodes on dnode 2 failed in 10s ") - return -1 + tdLog.exit("stop mnodes on dnode 2 failed in 10s ") + tdSql.error("drop mnode on dnode 1;") tdSql.query("show mnodes;") @@ -185,6 +143,8 @@ class TDTestCase: tdSql.query("show mnodes;") if tdSql.checkRows(3) : tdLog.debug("mnode is three nodes") + else: + tdLog.exit("mnode number is correct") if tdSql.queryResult[0][2]=='leader' : if tdSql.queryResult[1][2]=='offline': if tdSql.queryResult[2][2]=='follower': @@ -192,8 +152,8 @@ class TDTestCase: break count+=1 else: - tdLog.debug("stop mnodes on dnode 2 failed in 10s ") - return -1 + tdLog.exit("stop mnodes on dnode 2 failed in 10s ") + tdSql.error("drop mnode on dnode 2;") tdSql.query("show mnodes;") @@ -215,6 +175,8 @@ class TDTestCase: tdSql.query("show mnodes;") if tdSql.checkRows(3) : tdLog.debug("mnode is three nodes") + else: + tdLog.exit("mnode number is correct") if tdSql.queryResult[0][2]=='leader' : if tdSql.queryResult[2][2]=='offline': if tdSql.queryResult[1][2]=='follower': @@ -222,8 +184,8 @@ class TDTestCase: break count+=1 else: - tdLog.debug("stop mnodes on dnode 3 failed in 10s") - return -1 + tdLog.exit("stop mnodes on dnode 3 failed in 10s") + tdSql.error("drop mnode on dnode 3;") tdSql.query("show mnodes;") tdSql.checkRows(3) @@ -237,15 +199,30 @@ class TDTestCase: tdSql.checkData(2,2,'offline') tdSql.checkData(2,3,'ready') - + + def check_dnodes_status(self,dnodeNumbers): + count=0 + while count < 5: + tdSql.query("show dnodes") + # tdLog.debug(tdSql.queryResult) + status=0 + for i in range(dnodeNumbers): + if tdSql.queryResult[i][4] == "ready": + status+=1 + tdLog.debug(status) + + if status == dnodeNumbers: + tdLog.debug(" create cluster with %d dnode and check cluster dnode all ready within 5s! " %dnodeNumbers) + break + count+=1 + time.sleep(1) + else: + tdLog.exit("create cluster with %d dnode but check dnode not ready within 5s ! "%dnodeNumbers) def five_dnode_three_mnode(self,dnodenumber): - tdSql.query("show dnodes;") - tdSql.checkData(0,1,'%s:6030'%self.host) - tdSql.checkData(4,1,'%s:6430'%self.host) - tdSql.checkData(0,4,'ready') - tdSql.checkData(4,4,'ready') + self.check_dnodes_status(5) tdSql.query("show mnodes;") + tdLog.debug(self.host) tdSql.checkRows(1) tdSql.checkData(0,1,'%s:6030'%self.host) tdSql.checkData(0,2,'leader') @@ -262,26 +239,32 @@ class TDTestCase: tdSql.error("create mnode on dnode 2") tdSql.query("show dnodes;") - tdLog.debug(tdSql.queryResult) + # tdLog.debug(tdSql.queryResult) tdLog.debug("stop and follower of mnode") - self.TDDnodes.stoptaosd(2) + tdDnodes=cluster.dnodes + # tdLog.debug(tdDnodes[0]) + + tdDnodes[1].stoptaosd() self.check3mnode2off() - self.TDDnodes.starttaosd(2) + tdDnodes[1].starttaosd() + self.check3mnode() - self.TDDnodes.stoptaosd(3) + tdDnodes[2].stoptaosd() self.check3mnode3off() - self.TDDnodes.starttaosd(3) + tdDnodes[2].starttaosd() + self.check3mnode() - self.TDDnodes.stoptaosd(1) + tdDnodes[0].stoptaosd() self.check3mnode1off() - self.TDDnodes.starttaosd(1) + tdDnodes[0].starttaosd() + self.check3mnode() self.check3mnode() stopcount =0 while stopcount <= 2: for i in range(dnodenumber): - self.TDDnodes.stoptaosd(i+1) + tdDnodes[i].stoptaosd() # if i == 1 : # self.check3mnode2off() # elif i == 2 : @@ -289,24 +272,14 @@ class TDTestCase: # elif i == 0: # self.check3mnode1off() - self.TDDnodes.starttaosd(i+1) + tdDnodes[i].starttaosd() # self.check3mnode() stopcount+=1 self.check3mnode() - - def getConnection(self, dnode): - host = dnode.cfgDict["fqdn"] - port = dnode.cfgDict["serverPort"] - config_dir = dnode.cfgDir - return taos.connect(host=host, port=int(port), config=config_dir) - - def run(self): - # tdLog.debug(self.master_dnode.cfgDict) - self.buildcluster(5) self.five_dnode_three_mnode(5) - + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/7-tmq/stbFilter.py b/tests/system-test/7-tmq/stbFilter.py new file mode 100644 index 0000000000..542894574b --- /dev/null +++ b/tests/system-test/7-tmq/stbFilter.py @@ -0,0 +1,260 @@ + +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 * +sys.path.append("./7-tmq") +from tmqCommon import * + +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + #tdSql.init(conn.cursor(), logSql) # output sql.txt file + + def tmqCase1(self): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'db1', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 10, + 'rowsPerTbl': 10000, + 'batchNum': 100, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 10, + 'showMsg': 1, + 'showRow': 1} + + topicNameList = ['topic1', 'topic2', 'topic3'] + expectRowsList = [] + tmqCom.initConsumerTable() + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + tdLog.info("create stb") + tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema']) + tdLog.info("create ctb") + tdCom.create_ctable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) + tdLog.info("insert data") + tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) + + tdLog.info("create topics from stb with filter") + queryString = "select ts, log(c1), ceil(pow(c1,3)) from %s.%s where c1 %% 4 == 0" %(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[0], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + queryString = "select ts, log(c1), cos(c1) from %s.%s where c1 > 5000" %(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[1], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + queryString = "select ts, log(c1), atan(c1) from %s.%s where ts >= %d" %(paraDict['dbName'], paraDict['stbName'], paraDict["startTs"]+9000) + sqlString = "create topic %s as %s" %(topicNameList[2], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + # init consume info, and start tmq_sim, then check consume result + tdLog.info("insert consume info to consume processor") + consumerId = 0 + expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] + topicList = topicNameList[0] + ifcheckdata = 0 + ifManualCommit = 1 + keyList = 'group.id:cgrp1, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + tdLog.info("wait the consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + + if expectRowsList[0] != resultList[0]: + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) + tdLog.exit("0 tmq consume rows error!") + + # reinit consume info, and start tmq_sim, then check consume result + tmqCom.initConsumerTable() + consumerId = 1 + topicList = topicNameList[1] + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + tdLog.info("wait the consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + if expectRowsList[1] != resultList[0]: + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[1], resultList[0])) + tdLog.exit("1 tmq consume rows error!") + + # reinit consume info, and start tmq_sim, then check consume result + tmqCom.initConsumerTable() + consumerId = 2 + topicList = topicNameList[2] + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + tdLog.info("wait the consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + # if expectRowsList[2] != resultList[0]: + # tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[2], resultList[0])) + # tdLog.exit("2 tmq consume rows error!") + + time.sleep(10) + for i in range(len(topicNameList)): + tdSql.query("drop topic %s"%topicNameList[i]) + + tdLog.printNoPrefix("======== test case 1 end ...... ") + + def tmqCase2(self): + tdLog.printNoPrefix("======== test case 2: ") + paraDict = {'dbName': 'db2', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':2}, {'type': 'binary', 'len':20, 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1}, {'type': 'binary', 'len':20, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbNum': 10, + 'rowsPerTbl': 10000, + 'batchNum': 100, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 10, + 'showMsg': 1, + 'showRow': 1} + + topicNameList = ['topic1', 'topic2', 'topic3'] + expectRowsList = [] + tmqCom.initConsumerTable() + tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + tdLog.info("create stb") + tdCom.create_stable(tdSql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema']) + tdLog.info("create ctb") + tmqCom.create_ctable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict['ctbPrefix'], ctbNum=paraDict['ctbNum']) + tdLog.info("insert data") + tmqCom.insert_data_1(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) + + tdLog.info("create topics from stb with filter") + # sqlString = "create topic %s as select ts, sin(c1), pow(c2,3) from %s.%s where c2 >= 0" %(topicNameList[0], paraDict['dbName'], paraDict['stbName']) + queryString = "select ts, sin(c1), pow(c2,3) from %s.%s where c2 >= 0" %(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[0], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + queryString = "select ts, sin(c1), pow(c2,3) from %s.%s where sin(c2) >= 0" %(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[1], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + queryString = "select ts, sin(c1), floor(pow(c2,3)), c2 from %s.%s where (sin(c2) >= 0) and (floor(pow(c2,3)) %% 9 == 0)" %(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[2], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + tdSql.query(queryString) + expectRowsList.append(tdSql.getRows()) + + # start tmq consume processor + tdLog.info("insert consume info to consume processor") + consumerId = 0 + expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] + topicList = topicNameList[0] + ifcheckdata = 0 + ifManualCommit = 1 + keyList = 'group.id:cgrp1, enable.auto.commit:false, auto.commit.interval.ms:6000, auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + tdLog.info("wait the consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + + if expectRowsList[0] != resultList[0]: + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[0], resultList[0])) + tdLog.exit("0 tmq consume rows error!") + + # reinit consume info, and start tmq_sim, then check consume result + tmqCom.initConsumerTable() + consumerId = 1 + topicList = topicNameList[1] + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + tdLog.info("wait the consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + if expectRowsList[1] != resultList[0]: + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[1], resultList[0])) + tdLog.exit("1 tmq consume rows error!") + + # # reinit consume info, and start tmq_sim, then check consume result + tmqCom.initConsumerTable() + consumerId = 2 + topicList = topicNameList[2] + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(paraDict['pollDelay'],paraDict["dbName"],paraDict['showMsg'], paraDict['showRow']) + + tdLog.info("wait the consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + if expectRowsList[2] != resultList[0]: + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectRowsList[2], resultList[0])) + tdLog.exit("2 tmq consume rows error!") + + # time.sleep(10) + # for i in range(len(topicNameList)): + # tdSql.query("drop topic %s"%topicNameList[i]) + + tdLog.printNoPrefix("======== test case 2 end ...... ") + + def run(self): + tdSql.prepare() + self.tmqCase1() + self.tmqCase2() + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + +event = threading.Event() + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/7-tmq/tmqCommon.py b/tests/system-test/7-tmq/tmqCommon.py index 68adaa4126..9b23056546 100644 --- a/tests/system-test/7-tmq/tmqCommon.py +++ b/tests/system-test/7-tmq/tmqCommon.py @@ -42,9 +42,11 @@ class TMQCom: tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) + tdSql.query("drop table if exists %s.notifyinfo "%(cdbName)) tdSql.query("create table %s.consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int)"%cdbName) tdSql.query("create table %s.consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int)"%cdbName) + tdSql.query("create table %s.notifyinfo (ts timestamp, cmdid int, consumerid int)"%cdbName) def initConsumerInfoTable(self,cdbName='cdb'): tdLog.info("drop consumeinfo table") @@ -92,13 +94,190 @@ class TMQCom: tdLog.info(shellCmd) os.system(shellCmd) + def getStartConsumeNotifyFromTmqsim(self,cdbName='cdb'): + while 1: + tdSql.query("select * from %s.notifyinfo"%cdbName) + #tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3)) + if (tdSql.getRows() == 1) and (tdSql.getData(0, 1) == 0): + break + else: + time.sleep(0.1) + return + + def getStartCommitNotifyFromTmqsim(self,cdbName='cdb'): + while 1: + tdSql.query("select * from %s.notifyinfo"%cdbName) + #tdLog.info("row: %d, %l64d, %l64d"%(tdSql.getData(0, 1),tdSql.getData(0, 2),tdSql.getData(0, 3)) + if tdSql.getRows() == 2 : + print(tdSql.getData(0, 1), tdSql.getData(1, 1)) + if tdSql.getData(1, 1) == 1: + break + time.sleep(0.1) + return + + def create_database(self,tsql, dbName,dropFlag=1,vgroups=4,replica=1): + if dropFlag == 1: + tsql.execute("drop database if exists %s"%(dbName)) + + tsql.execute("create database if not exists %s vgroups %d replica %d"%(dbName, vgroups, replica)) + tdLog.debug("complete to create database %s"%(dbName)) + return + + def create_stable(self,tsql, dbName,stbName): + tsql.execute("create table if not exists %s.%s (ts timestamp, c1 int, c2 int, c3 binary(16)) tags(t1 int, t2 binary(32))"%(dbName, stbName)) + tdLog.debug("complete to create %s.%s" %(dbName, stbName)) + return + + def create_ctable(self,tsql=None, dbName='dbx',stbName='stb',ctbPrefix='ctb',ctbNum=1): + tsql.execute("use %s" %dbName) + pre_create = "create table" + sql = pre_create + #tdLog.debug("doing create one stable %s and %d child table in %s ..." %(stbname, count ,dbname)) + for i in range(ctbNum): + tagValue = 'beijing' + if (i % 2 == 0): + tagValue = 'shanghai' + + sql += " %s%d using %s tags(%d, '%s')"%(ctbPrefix,i,stbName,i+1, tagValue) + if (i > 0) and (i%100 == 0): + tsql.execute(sql) + sql = pre_create + if sql != pre_create: + tsql.execute(sql) + + tdLog.debug("complete to create %d child tables in %s.%s" %(ctbNum, dbName, stbName)) + return + + def insert_data(self,tsql,dbName,stbName,ctbNum,rowsPerTbl,batchNum,startTs=None): + tdLog.debug("start to insert data ............") + tsql.execute("use %s" %dbName) + pre_insert = "insert into " + sql = pre_insert + + if startTs is None: + t = time.time() + startTs = int(round(t * 1000)) + #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) + for i in range(ctbNum): + sql += " %s%d values "%(stbName,i) + for j in range(rowsPerTbl): + sql += "(%d, %d, 'tmqrow_%d') "%(startTs + j, j, j) + if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)): + tsql.execute(sql) + if j < rowsPerTbl - 1: + sql = "insert into %s%d values " %(stbName,i) + else: + sql = "insert into " + #end sql + if sql != pre_insert: + #print("insert sql:%s"%sql) + tsql.execute(sql) + tdLog.debug("insert data ............ [OK]") + return + + def insert_data_1(self,tsql,dbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs): + tdLog.debug("start to insert data ............") + tsql.execute("use %s" %dbName) + pre_insert = "insert into " + sql = pre_insert + + t = time.time() + startTs = int(round(t * 1000)) + #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) + for i in range(ctbNum): + sql += " %s%d values "%(ctbPrefix,i) + for j in range(rowsPerTbl): + if (j % 2 == 0): + sql += "(%d, %d, %d, 'tmqrow_%d') "%(startTs + j, j, j, j) + else: + sql += "(%d, %d, %d, 'tmqrow_%d') "%(startTs + j, j, -j, j) + if (j > 0) and ((j%batchNum == 0) or (j == rowsPerTbl - 1)): + tsql.execute(sql) + if j < rowsPerTbl - 1: + sql = "insert into %s%d values " %(ctbPrefix,i) + else: + sql = "insert into " + #end sql + if sql != pre_insert: + #print("insert sql:%s"%sql) + tsql.execute(sql) + tdLog.debug("insert data ............ [OK]") + return + + def insert_data_interlaceByMultiTbl(self,tsql,dbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs=0): + tdLog.debug("start to insert data ............") + tsql.execute("use %s" %dbName) + pre_insert = "insert into " + sql = pre_insert + + if startTs == 0: + t = time.time() + startTs = int(round(t * 1000)) + + ctbDict = {} + for i in range(ctbNum): + ctbDict[i] = 0 + + #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) + rowsOfCtb = 0 + while rowsOfCtb < rowsPerTbl: + for i in range(ctbNum): + sql += " %s.%s_%d values "%(dbName,ctbPrefix,i) + for k in range(batchNum): + sql += "(%d, %d, 'tmqrow_%d') "%(startTs + ctbDict[i], ctbDict[i], ctbDict[i]) + ctbDict[i] += 1 + if (0 == ctbDict[i]%batchNum) or (ctbDict[i] == rowsPerTbl): + tsql.execute(sql) + sql = "insert into " + break + rowsOfCtb = ctbDict[0] + + tdLog.debug("insert data ............ [OK]") + return + + def insert_data_with_autoCreateTbl(self,tsql,dbName,stbName,ctbPrefix,ctbNum,rowsPerTbl,batchNum,startTs=0): + tdLog.debug("start to insert data wiht auto create child table ............") + tsql.execute("use %s" %dbName) + pre_insert = "insert into " + sql = pre_insert + + if startTs == 0: + t = time.time() + startTs = int(round(t * 1000)) + + #tdLog.debug("doing insert data into stable:%s rows:%d ..."%(stbName, allRows)) + rowsOfSql = 0 + for i in range(ctbNum): + sql += " %s.%s_%d using %s.%s tags (%d) values "%(dbName,ctbPrefix,i,dbName,stbName,i) + for j in range(rowsPerTbl): + sql += "(%d, %d, 'tmqrow_%d') "%(startTs + j, j, j) + rowsOfSql += 1 + if (j > 0) and ((rowsOfSql == batchNum) or (j == rowsPerTbl - 1)): + tsql.execute(sql) + rowsOfSql = 0 + if j < rowsPerTbl - 1: + sql = "insert into %s.%s_%d using %s.%s tags (%d) values " %(dbName,ctbPrefix,i,dbName,stbName,i) + else: + sql = "insert into " + #end sql + if sql != pre_insert: + #print("insert sql:%s"%sql) + tsql.execute(sql) + tdLog.debug("insert data ............ [OK]") + return + def syncCreateDbStbCtbInsertData(self, tsql, paraDict): - tdCom.create_database(tsql, paraDict["dbName"],paraDict["dropFlag"], paraDict['precision']) - tdCom.create_stable(tsql, paraDict["dbName"],paraDict["stbName"], paraDict["columnDict"], paraDict["tagDict"]) - tdCom.create_ctables(tsql, paraDict["dbName"],paraDict["stbName"],paraDict["ctbNum"],paraDict["tagDict"]) + tdCom.create_database(tsql, paraDict["dbName"],paraDict["dropFlag"]) + tdCom.create_stable(tsql, dbname=paraDict["dbName"],stbname=paraDict["stbName"], column_elm_list=paraDict['colSchema'], tag_elm_list=paraDict['tagSchema']) + tdCom.create_ctable(tsql, dbname=paraDict["dbName"],stbname=paraDict["stbName"],tag_elm_list=paraDict['tagSchema'],count=paraDict["ctbNum"], default_ctbname_prefix=paraDict['ctbPrefix']) if "event" in paraDict and type(paraDict['event']) == type(threading.Event()): paraDict["event"].set() - tdCom.insert_data(tsql,paraDict["dbName"],paraDict["stbName"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) + + ctbPrefix = paraDict['ctbPrefix'] + ctbNum = paraDict["ctbNum"] + for i in range(ctbNum): + tbName = '%s%s'%(ctbPrefix,i) + tdCom.insert_rows(tsql,dbname=paraDict["dbName"],tbname=tbName,start_ts_value=paraDict['startTs'],count=paraDict['rowsPerTbl']) return def threadFunction(self, **paraDict): diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh index db3f7216ab..64ba0183c5 100755 --- a/tests/system-test/fulltest.sh +++ b/tests/system-test/fulltest.sh @@ -35,6 +35,7 @@ python3 ./test.py -f 2-query/lower.py python3 ./test.py -f 2-query/join.py python3 ./test.py -f 2-query/join2.py python3 ./test.py -f 2-query/cast.py +python3 ./test.py -f 2-query/substr.py python3 ./test.py -f 2-query/union.py python3 ./test.py -f 2-query/union1.py python3 ./test.py -f 2-query/concat.py @@ -105,11 +106,14 @@ python3 ./test.py -f 2-query/distribute_agg_min.py python3 ./test.py -f 2-query/distribute_agg_sum.py python3 ./test.py -f 2-query/distribute_agg_spread.py python3 ./test.py -f 2-query/distribute_agg_apercentile.py +python3 ./test.py -f 2-query/distribute_agg_avg.py +python3 ./test.py -f 2-query/distribute_agg_stddev.py +python3 ./test.py -f 2-query/twa.py python3 ./test.py -f 6-cluster/5dnode1mnode.py python3 ./test.py -f 6-cluster/5dnode2mnode.py -#python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -#python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py +python3 ./test.py -f 6-cluster/5dnode3mnodeStop.py -N 5 +# python3 ./test.py -f 6-cluster/5dnode3mnodeDrop.py -N 5 # BUG python3 ./test.py -f 6-cluster/5dnode3mnodeStopInsert.py python3 ./test.py -f 7-tmq/basic5.py @@ -127,3 +131,4 @@ python3 ./test.py -f 7-tmq/subscribeStb4.py python3 ./test.py -f 7-tmq/db.py python3 ./test.py -f 7-tmq/tmqError.py python3 ./test.py -f 7-tmq/schema.py +python3 ./test.py -f 7-tmq/stbFilter.py diff --git a/tests/system-test/test.py b/tests/system-test/test.py index 55bfd8c945..4ca16e7a57 100644 --- a/tests/system-test/test.py +++ b/tests/system-test/test.py @@ -28,6 +28,7 @@ sys.path.append("../pytest") from util.log import * from util.dnodes import * from util.cases import * +from util.cluster import * import taos @@ -58,10 +59,11 @@ if __name__ == "__main__": logSql = True stop = 0 restart = False + dnodeNums = 1 updateCfgDict = {} execCmd = "" - opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:', [ - 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'killv', 'execCmd']) + opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrd:k:e:N:', [ + 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'restart', 'updateCfgDict', 'killv', 'execCmd','dnodeNums']) for key, value in opts: if key in ['-h', '--help']: tdLog.printNoPrefix( @@ -77,6 +79,8 @@ if __name__ == "__main__": tdLog.printNoPrefix('-d update cfg dict, base64 json str') tdLog.printNoPrefix('-k not kill valgrind processer') tdLog.printNoPrefix('-e eval str to run') + tdLog.printNoPrefix('-N create dnodes numbers clusters') + sys.exit(0) if key in ['-r', '--restart']: @@ -126,6 +130,9 @@ if __name__ == "__main__": print('updateCfgDict convert fail.') sys.exit(0) + if key in ['-N', '--dnodeNums']: + dnodeNums = value + if not execCmd == "": tdDnodes.init(deployPath) print(execCmd) @@ -232,11 +239,36 @@ if __name__ == "__main__": updateCfgDict = ucase.updatecfgDict except: pass - tdDnodes.deploy(1,updateCfgDict) - tdDnodes.start(1) - - tdCases.logSql(logSql) - + if dnodeNums == 1 : + tdDnodes.deploy(1,updateCfgDict) + tdDnodes.start(1) + tdCases.logSql(logSql) + else : + print("start cluster and dnodes number") + + dnodeslist = cluster.configure_cluster(dnodes_nums=dnodeNums,independent=True) + tdDnodes = ClusterDnodes(dnodeslist) + tdDnodes.init(deployPath, masterIp) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + tdDnodes.stopAll() + for dnode in tdDnodes.dnodes: + tdDnodes.deploy(dnode.index,{}) + for dnode in tdDnodes.dnodes: + tdDnodes.starttaosd(dnode.index) + tdCases.logSql(logSql) + conn = taos.connect( + host, + config=tdDnodes.getSimCfgPath()) + print(tdDnodes.getSimCfgPath(),host) + cluster.create_dnode(conn) + try: + if cluster.check_dnode(conn) : + print("check dnode ready") + except Exception as r: + print(r) + + if testCluster: tdLog.info("Procedures for testing cluster") if fileName == "all": @@ -248,10 +280,12 @@ if __name__ == "__main__": conn = taos.connect( host, config=tdDnodes.getSimCfgPath()) + if fileName == "all": tdCases.runAllLinux(conn) else: tdCases.runOneLinux(conn, fileName) + if restart: if fileName == "all": tdLog.info("not need to query ") diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index f97a13d2c5..aaad76bb53 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -39,13 +39,26 @@ void simLogSql(char *sql, bool useSharp) { char *simParseArbitratorName(char *varName) { static char hostName[140]; +#ifdef WINDOWS + taosGetFqdn(hostName); + sprintf(&hostName[strlen(hostName)], ":%d", 8000); +#else sprintf(hostName, "%s:%d", "localhost", 8000); +#endif return hostName; } char *simParseHostName(char *varName) { static char hostName[140]; +#ifdef WINDOWS + hostName[0] = '\"'; + taosGetFqdn(&hostName[1]); + int strEndIndex = strlen(hostName); + hostName[strEndIndex] = '\"'; + hostName[strEndIndex + 1] = '\0'; +#else sprintf(hostName, "%s", "localhost"); +#endif return hostName; } @@ -399,7 +412,8 @@ bool simExecuteSystemCmd(SScript *script, char *option) { sprintf(buf, "cd %s; ", simScriptDir); simVisuallizeOption(script, option, buf + strlen(buf)); #else - sprintf(buf, "%s%s", simScriptDir, option); + sprintf(buf, "%s", simScriptDir); + simVisuallizeOption(script, option, buf + strlen(buf)); simReplaceStr(buf, ".sh", ".bat"); #endif diff --git a/tools/taosadapter b/tools/taosadapter index 29926478ed..c1dc11f3ca 160000 --- a/tools/taosadapter +++ b/tools/taosadapter @@ -1 +1 @@ -Subproject commit 29926478edd87533a043f91c1a9ed0e27671e626 +Subproject commit c1dc11f3cae64adf31dbd9a954ef8372d1e8f671