diff --git a/CMakeLists.txt b/CMakeLists.txt index 566d4ad29d7dff9c43ab61cac03da9a4dfdef63a..fb2b306f65467361dd5612f5bf1e6629a7a0c306 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,8 @@ if (NOT DEFINED TD_SOURCE_DIR) set( TD_SOURCE_DIR ${PROJECT_SOURCE_DIR} ) endif() +SET(TD_COMMUNITY_DIR ${PROJECT_SOURCE_DIR}) + set(TD_SUPPORT_DIR "${TD_SOURCE_DIR}/cmake") set(TD_CONTRIB_DIR "${TD_SOURCE_DIR}/contrib") diff --git a/CODE_OF_CONDUCT-CN.md b/CODE_OF_CONDUCT-CN.md new file mode 100644 index 0000000000000000000000000000000000000000..cd14ea9c1c5c51aeaa93f7e6eccd4108a0ff9ec4 --- /dev/null +++ b/CODE_OF_CONDUCT-CN.md @@ -0,0 +1,47 @@ +# 贡献者契约行为准则 + +[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](code_of_conduct.md) + +## 我们的承诺 + +为了营造一个开放和热情的环境,作为贡献者和维护者,我们承诺让每个人参与我们的项目和社区成为一种无骚扰的体验,无论年龄、体型、残疾、种族、性别特征、性别认同和表达、经验水平、教育、社会经济地位、国籍、个人外表、种族、宗教或性认同和取向如何。 + +## 我们的标准 + +有助于创造积极环境的行为示例包括: + +- 使用热情和包容的语言 +- 尊重不同的观点和经历 +- 优雅地接受建设性的批评 +- 专注于对社区最有利的事情 +- 对其他社区成员表示同情 + +参与者不可接受的行为示例包括: + +- 使用性感的语言或图像以及不受欢迎的性关注或进步 +- 拖钓、侮辱/贬损评论以及人身或政治攻击 +- 公共或私人骚扰 +- 未经明确许可发布他人的私人信息,例如物理地址或电子地址 +- 在专业环境中可能被合理认为不适当的其他行为 + +## 我们的责任 + +项目维护人员负责阐明可接受行为的标准,并期望针对任何不可接受行为的情况采取适当和公平的纠正措施。 + +项目维护者有权利和责任删除、编辑或拒绝评论、提交、代码、wiki 编辑、问题和其他不符合本行为准则的贡献,或暂时或永久禁止任何贡献者从事他们认为不适当、威胁、冒犯或有害的其他行为。 + +## 范围 + +本行为准则适用于所有项目空间,也适用于个人在公共场所代表项目或其社区时。 代表项目或社区的示例包括使用官方项目电子邮件地址、通过官方社交媒体帐户发布信息或在在线或离线活动中担任指定代表。 项目的表示可以由项目维护者进一步定义和澄清。 + +## 执法 + +可以通过 support@taosdata.com 联系项目团队来报告辱骂、骚扰或其他不可接受的行为。 所有投诉都将被审查和调查,并将产生被认为必要且适合具体情况的回应。 项目团队有义务对事件的报告者保密。 具体执行政策的更多细节可能会单独发布。 + +不善意遵守或执行行为准则的项目维护者可能会面临由项目领导的其他成员确定的临时或永久影响。 + +## 来源 + +本行为准则改编自贡献者公约 1.4 版,可在 https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 获取 + +有关此行为准则的常见问题的答案,请参阅 https://www.contributor-covenant.org/faq \ No newline at end of file diff --git a/Jenkinsfile2 b/Jenkinsfile2 index bb7fa70c57fb7957967b59c04ce908a417ad4b56..55bd5466ed4abe40cfaedc634b75a59b43668759 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -460,7 +460,7 @@ pipeline { cd ${WKC}/tests/parallel_test export DEFAULT_RETRY_TIME=2 date - ''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 480 ''' + extra_param + ''' + ''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 600 ''' + extra_param + ''' ''' } } diff --git a/cmake/cmake.define b/cmake/cmake.define index 10f217254152db82518099560ef902b2ebabf499..5b65738c700bd7fa862da6284881ada17f245302 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -121,7 +121,7 @@ ELSE () MESSAGE(STATUS "Compile with Address Sanitizer!") ELSE () SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-reserved-user-defined-literal -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -g3 -Wformat=2 -Wno-format-nonliteral -Wno-format-truncation -Wno-format-y2k") ENDIF () # disable all assert diff --git a/cmake/cmake.version b/cmake/cmake.version index d38ac40b90c932b41717d6d16dadc176a842a2b2..5150ee3b75e2ac429961850995d06b5b2fd40cc9 100644 --- a/cmake/cmake.version +++ b/cmake/cmake.version @@ -2,7 +2,7 @@ IF (DEFINED VERNUMBER) SET(TD_VER_NUMBER ${VERNUMBER}) ELSE () - SET(TD_VER_NUMBER "3.0.3.0") + SET(TD_VER_NUMBER "3.0.3.2") ENDIF () IF (DEFINED VERCOMPATIBLE) @@ -16,7 +16,7 @@ find_program(HAVE_GIT NAMES git) IF (DEFINED GITINFO) SET(TD_VER_GIT ${GITINFO}) ELSEIF (HAVE_GIT) - execute_process(COMMAND git log -1 --format=%H WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMITID) + execute_process(COMMAND git log -1 --format=%H WORKING_DIRECTORY ${TD_COMMUNITY_DIR} OUTPUT_VARIABLE GIT_COMMITID) #message(STATUS "git log result:${GIT_COMMITID}") IF (GIT_COMMITID) string (REGEX REPLACE "[\n\t\r]" "" GIT_COMMITID ${GIT_COMMITID}) @@ -30,6 +30,23 @@ ELSE () SET(TD_VER_GIT "no git commit id") ENDIF () +IF (DEFINED GITINFOI) + SET(TD_VER_GIT_INTERNAL ${GITINFOI}) +ELSEIF (HAVE_GIT) + execute_process(COMMAND git log -1 --format=%H WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMITID) + message(STATUS "git log result:${GIT_COMMITID}") + IF (GIT_COMMITID) + string (REGEX REPLACE "[\n\t\r]" "" GIT_COMMITID ${GIT_COMMITID}) + SET(TD_VER_GIT_INTERNAL ${GIT_COMMITID}) + ELSE () + message(STATUS "not a git repository") + SET(TD_VER_GIT "no git commit id") + ENDIF () +ELSE () + message(STATUS "no git cmd") + SET(TD_VER_GIT_INTERNAL "no git commit id") +ENDIF () + IF (DEFINED VERDATE) SET(TD_VER_DATE ${VERDATE}) ELSE () diff --git a/cmake/taosadapter_CMakeLists.txt.in b/cmake/taosadapter_CMakeLists.txt.in index 1c401ae80e0a7a1ec11701c39842f5a0eb1052ce..b2f335e1f7b8a30a46713a322c2ef95b5605c9d9 100644 --- a/cmake/taosadapter_CMakeLists.txt.in +++ b/cmake/taosadapter_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taosadapter ExternalProject_Add(taosadapter GIT_REPOSITORY https://github.com/taosdata/taosadapter.git - GIT_TAG d8059ff + GIT_TAG cb1e89c SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in index 87f0579f44045f07794e522df4ee4f5ae1a0644d..0110b27b325e9479455bbbf1e8c77e73f69d950d 100644 --- a/cmake/taostools_CMakeLists.txt.in +++ b/cmake/taostools_CMakeLists.txt.in @@ -2,7 +2,7 @@ # taos-tools ExternalProject_Add(taos-tools GIT_REPOSITORY https://github.com/taosdata/taos-tools.git - GIT_TAG d11f210 + GIT_TAG 149ac34 SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools" BINARY_DIR "" #BUILD_IN_SOURCE TRUE diff --git a/docs/en/07-develop/07-tmq.mdx b/docs/en/07-develop/07-tmq.mdx index 71abe5905559b2df70977b773b22c2d6cbafcbb0..7465cc0a12ecc9c92a48a2308fe101d057f80492 100644 --- a/docs/en/07-develop/07-tmq.mdx +++ b/docs/en/07-develop/07-tmq.mdx @@ -23,7 +23,7 @@ By subscribing to a topic, a consumer can obtain the latest data in that topic i To implement these features, TDengine indexes its write-ahead log (WAL) file for fast random access and provides configurable methods for replacing and retaining this file. You can define a retention period and size for this file. For information, see the CREATE DATABASE statement. In this way, the WAL file is transformed into a persistent storage engine that remembers the order in which events occur. However, note that configuring an overly long retention period for your WAL files makes database compression inefficient. TDengine then uses the WAL file instead of the time-series database as its storage engine for queries in the form of topics. TDengine reads the data from the WAL file; uses a unified query engine instance to perform filtering, transformations, and other operations; and finally pushes the data to consumers. - +Tips:The default data subscription is to consume data from the wal. If the wal is deleted, the consumed data will be incomplete. At this time, you can set the parameter experimental.snapshot.enable to true to obtain all data from the tsdb, but in this way, the consumption order of the data cannot be guaranteed. Therefore, it is recommended to set a reasonable retention policy for WAL based on your consumption situation to ensure that you can subscribe all data from WAL. ## Data Schema and API @@ -285,18 +285,17 @@ You configure the following parameters when creating a consumer: | Parameter | Type | Description | Remarks | | :----------------------------: | :-----: | -------------------------------------------------------- | ------------------------------------------- | -| `td.connect.ip` | string | Used in establishing a connection; same as `taos_connect` | | -| `td.connect.user` | string | Used in establishing a connection; same as `taos_connect` | | -| `td.connect.pass` | string | Used in establishing a connection; same as `taos_connect` | | -| `td.connect.port` | string | Used in establishing a connection; same as `taos_connect` | | +| `td.connect.ip` | string | Used in establishing a connection; same as `taos_connect` | Only valid for establishing native connection | +| `td.connect.user` | string | Used in establishing a connection; same as `taos_connect` | Only valid for establishing native connection | +| `td.connect.pass` | string | Used in establishing a connection; same as `taos_connect` | Only valid for establishing native connection | +| `td.connect.port` | string | Used in establishing a connection; same as `taos_connect` | Only valid for establishing native connection | | `group.id` | string | Consumer group ID; consumers with the same ID are in the same group | **Required**. Maximum length: 192. | | `client.id` | string | Client ID | Maximum length: 192. | | `auto.offset.reset` | enum | Initial offset for the consumer group | Specify `earliest`, `latest`, or `none`(default) | -| `enable.auto.commit` | boolean | Commit automatically | Specify `true` or `false`. | +| `enable.auto.commit` | boolean | Commit automatically; true: user application doesn't need to explicitly commit; false: user application need to handle commit by itself | Default value is true | | `auto.commit.interval.ms` | integer | Interval for automatic commits, in milliseconds | -| `enable.heartbeat.background` | boolean | Backend heartbeat; if enabled, the consumer does not go offline even if it has not polled for a long time | | -| `experimental.snapshot.enable` | boolean | Specify whether to consume messages from TSDB | | -| `msg.with.table.name` | boolean | Specify whether to deserialize table names from messages | +| `experimental.snapshot.enable` | boolean | Specify whether to consume data in TSDB; true: both data in WAL and in TSDB can be consumed; false: only data in WAL can be consumed | default value: false | +| `msg.with.table.name` | boolean | Specify whether to deserialize table names from messages | default value: false The method of specifying these parameters depends on the language used: @@ -369,7 +368,6 @@ conf := &tmq.ConfigMap{ "td.connect.port": "6030", "client.id": "test_tmq_c", "enable.auto.commit": "false", - "enable.heartbeat.background": "true", "experimental.snapshot.enable": "true", "msg.with.table.name": "true", } diff --git a/docs/en/12-taos-sql/02-database.md b/docs/en/12-taos-sql/02-database.md index a1c46875aa59b7ce6eb099d4c13a20a1a68e560b..ec007d68302f719ec09b1b13f58a1a6bddb2748c 100644 --- a/docs/en/12-taos-sql/02-database.md +++ b/docs/en/12-taos-sql/02-database.md @@ -35,8 +35,8 @@ database_option: { | TABLE_SUFFIX value | TSDB_PAGESIZE value | WAL_RETENTION_PERIOD value - | WAL_ROLL_PERIOD value | WAL_RETENTION_SIZE value + | WAL_ROLL_PERIOD value | WAL_SEGMENT_SIZE value } ``` @@ -75,11 +75,10 @@ database_option: { - TABLE_PREFIX:The prefix length in the table name that is ignored when distributing table to vnode based on table name. - TABLE_SUFFIX:The suffix length in the table name that is ignored when distributing table to vnode based on table name. - TSDB_PAGESIZE: The page size of the data storage engine in a vnode. The unit is KB. The default is 4 KB. The range is 1 to 16384, that is, 1 KB to 16 MB. -- WAL_RETENTION_PERIOD: specifies the maximum time of which WAL files are to be kept after consumption. This parameter is used for data subscription. Enter a time in seconds. The default value 0. A value of 0 indicates that WAL files are not required to keep after consumption. -1: the time of WAL files to keep has no upper limit. -- WAL_RETENTION_SIZE: specifies the maximum total size of which WAL files are to be kept after consumption. This parameter is used for data subscription. Enter a size in KB. The default value is 0. A value of 0 indicates that WAL files are not required to keep after consumption. -1: the total size of WAL files to keep has no upper limit. +- WAL_RETENTION_PERIOD: specifies the maximum time of which WAL files are to be kept for consumption. This parameter is used for data subscription. Enter a time in seconds. The default value 0. A value of 0 indicates that WAL files are not required to keep for consumption. Alter it with a proper value at first to create topics. +- WAL_RETENTION_SIZE: specifies the maximum total size of which WAL files are to be kept for consumption. This parameter is used for data subscription. Enter a size in KB. The default value is 0. A value of 0 indicates that the total size of WAL files to keep for consumption has no upper limit. - WAL_ROLL_PERIOD: specifies the time after which WAL files are rotated. After this period elapses, a new WAL file is created. The default value is 0. A value of 0 indicates that a new WAL file is created only after TSDB data in memory are flushed to disk. - WAL_SEGMENT_SIZE: specifies the maximum size of a WAL file. After the current WAL file reaches this size, a new WAL file is created. The default value is 0. A value of 0 indicates that a new WAL file is created only after TSDB data in memory are flushed to disk. - ### Example Statement ```sql @@ -123,6 +122,8 @@ alter_database_option: { | WAL_LEVEL value | WAL_FSYNC_PERIOD value | KEEP value + | WAL_RETENTION_PERIOD value + | WAL_RETENTION_SIZE value } ``` @@ -179,6 +180,14 @@ TRIM DATABASE db_name; The preceding SQL statement deletes data that has expired and orders the remaining data in accordance with the storage configuration. +## Flush Data + +```sql +FLUSH DATABASE db_name; +``` + +Flush data from memory onto disk. Before shutting down a node, executing this command can avoid data restore after restarting and speed up the startup process. + ## Redistribute Vgroup ```sql diff --git a/docs/en/12-taos-sql/04-stable.md b/docs/en/12-taos-sql/04-stable.md index 37257286372b403721032e48d56cc1f1c3559538..a1d103eaf04a30214a8c1ef88e43a949710bcdbc 100644 --- a/docs/en/12-taos-sql/04-stable.md +++ b/docs/en/12-taos-sql/04-stable.md @@ -13,12 +13,11 @@ create_definition: col_name column_definition column_definition: - type_name [COMMENT 'string_value'] + type_name ``` **More explanations** - Each supertable can have a maximum of 4096 columns, including tags. The minimum number of columns is 3: a timestamp column used as the key, one tag column, and one data column. -- When you create a supertable, you can add comments to columns and tags. - The TAGS keyword defines the tag columns for the supertable. The following restrictions apply to tag columns: - A tag column can use the TIMESTAMP data type, but the values in the column must be fixed numbers. Timestamps including formulae, such as "now + 10s", cannot be stored in a tag column. - The name of a tag column cannot be the same as the name of any other column. diff --git a/docs/en/12-taos-sql/06-select.md b/docs/en/12-taos-sql/06-select.md index 75462c3d96c7f5e7368a80a2d21441449cf67fc5..de7294f7a9dbc78b854dffa25ffd0e7edd7e7b66 100644 --- a/docs/en/12-taos-sql/06-select.md +++ b/docs/en/12-taos-sql/06-select.md @@ -248,13 +248,13 @@ You can also use the NULLS keyword to specify the position of null values. Ascen The LIMIT keyword controls the number of results that are displayed. You can also use the OFFSET keyword to specify the result to display first. `LIMIT` and `OFFSET` are executed after `ORDER BY` in the query execution. You can include an offset in a LIMIT clause. For example, LIMIT 5 OFFSET 2 can also be written LIMIT 2, 5. Both of these clauses display the third through the seventh results. -In a statement that includes a PARTITION BY clause, the LIMIT keyword is performed on each partition, not on the entire set of results. +In a statement that includes a PARTITION BY/GROUP BY clause, the LIMIT keyword is performed on each partition/group, not on the entire set of results. ## SLIMIT -The SLIMIT keyword is used with a PARTITION BY clause to control the number of partitions that are displayed. You can include an offset in a SLIMIT clause. For example, SLIMIT 5 OFFSET 2 can also be written LIMIT 2, 5. Both of these clauses display the third through the seventh partitions. +The SLIMIT keyword is used with a PARTITION BY/GROUP BY clause to control the number of partitions/groups that are displayed. You can include an offset in a SLIMIT clause. For example, SLIMIT 5 OFFSET 2 can also be written LIMIT 2, 5. Both of these clauses display the third through the seventh partitions/groups. -Note: If you include an ORDER BY clause, only one partition can be displayed. +Note: If you include an ORDER BY clause, only one partition/group can be displayed. ## Special Query diff --git a/docs/en/12-taos-sql/12-distinguished.md b/docs/en/12-taos-sql/12-distinguished.md index 3f81b51dd3df2722a295f51230f1b1d23bce934f..01d7065905359dd312346f54293c5cf8d8f04afb 100644 --- a/docs/en/12-taos-sql/12-distinguished.md +++ b/docs/en/12-taos-sql/12-distinguished.md @@ -171,7 +171,7 @@ If you want to perform event window based query on the result set of a sub-query For example, the diagram below illustrates the event windows generated by the query below: ```sql -select _wstart, _wend, count(*) from t start with c1 > 0 end with c2 < 10 +select _wstart, _wend, count(*) from t event_window start with c1 > 0 end with c2 < 10 ``` ![Event Window Illustration](./event_window.webp) diff --git a/docs/en/12-taos-sql/24-show.md b/docs/en/12-taos-sql/24-show.md index 65aab4c47b3487fc75518a97b7bef6299a5a83d4..e2aff7a878893eda03c998d963840ffa046e6405 100644 --- a/docs/en/12-taos-sql/24-show.md +++ b/docs/en/12-taos-sql/24-show.md @@ -308,9 +308,11 @@ Query OK, 24 row(s) in set (0.002444s) - The above show the block distribution percentage according to the number of rows in each block. In the above example, we can get below information: - - `_block_dist: 3483 ||||||||||||||||| 1 (20.00%)` means there is one block whose rows is between 3,483 and 3,681. - - `_block_dist: 3881 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 4 (80.00%)` means there are 4 blocks whose rows is between 3,881 and 4,096. - The number of blocks whose rows fall in other range is zero. +The above show the block distribution percentage according to the number of rows in each block. In the above example, we can get below information: +- `_block_dist: 3483 ||||||||||||||||| 1 (20.00%)` means there is one block whose rows is between 3,483 and 3,681. +- `_block_dist: 3881 ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| 4 (80.00%)` means there are 4 blocks whose rows is between 3,881 and 4,096. - The number of blocks whose rows fall in other range is zero. + +Note that only the information about the data blocks in the data file will be displayed here, and the information about the data in the stt file will not be displayed. ## SHOW TAGS diff --git a/docs/en/12-taos-sql/29-changes.md b/docs/en/12-taos-sql/29-changes.md index 341791d6755aa66fddd98561823ee0e5ac74ba3f..a695a2cae18f28e090816ec98a978674a028df30 100644 --- a/docs/en/12-taos-sql/29-changes.md +++ b/docs/en/12-taos-sql/29-changes.md @@ -27,7 +27,7 @@ The following data types can be used in the schema for standard tables. | - | :------- | :-------- | :------- | | 1 | ALTER ACCOUNT | Deprecated| This Enterprise Edition-only statement has been removed. It returns the error "This statement is no longer supported." | 2 | ALTER ALL DNODES | Added | Modifies the configuration of all dnodes. -| 3 | ALTER DATABASE | Modified | Deprecated +| 3 | ALTER DATABASE | Modified | Deprecated | 4 | ALTER STABLE | Modified | Deprecated | 5 | ALTER TABLE | Modified | Deprecated | 6 | ALTER USER | Modified | Deprecated diff --git a/docs/en/13-operation/01-pkg-install.md b/docs/en/13-operation/01-pkg-install.md index 1ba016428eac43fa2423d798d46902880e086b87..561013947100a0c938154c37fa9e11b17fd428b6 100644 --- a/docs/en/13-operation/01-pkg-install.md +++ b/docs/en/13-operation/01-pkg-install.md @@ -15,14 +15,14 @@ About details of installing TDenine, please refer to [Installation Guide](../../ ## Uninstall - + -Apt-get package of TDengine can be uninstalled as below: +Uninstall package of TDengine by apt-get can be uninstalled as below: ```bash $ sudo apt-get remove tdengine Reading package lists... Done -Building dependency tree +Building dependency tree Reading state information... Done The following packages will be REMOVED: tdengine @@ -35,7 +35,7 @@ TDengine is removed successfully! ``` -Apt-get package of taosTools can be uninstalled as below: +If you have installed taos-tools, please uninstall it first before uninstall TDengine. The command of uninstall is following: ``` $ sudo apt remove taostools @@ -111,8 +111,20 @@ taos tools is uninstalled successfully! ``` + Run C:\TDengine\unins000.exe to uninstall TDengine on a Windows system. + + + + +TDengine can be uninstalled as below: + +``` +$ rmtaos +TDengine is removed successfully! +``` + @@ -156,7 +168,7 @@ Upgrading a running server is much more complex. First please check the version - Stop the cluster of TDengine - Uninstall old version and install new version - Start the cluster of TDengine -- Execute simple queries, such as the ones executed prior to installing the new package, to make sure there is no data loss +- Execute simple queries, such as the ones executed prior to installing the new package, to make sure there is no data loss - Run some simple data insertion statements to make sure the cluster works well - Restore business services diff --git a/docs/en/13-operation/03-tolerance.md b/docs/en/13-operation/03-tolerance.md index 4f33748e68a0b51be619fe7aa8cc3b2152c71bf2..c8d2c3f3f62f3eeba950de335ef636d08d19f180 100644 --- a/docs/en/13-operation/03-tolerance.md +++ b/docs/en/13-operation/03-tolerance.md @@ -18,14 +18,8 @@ To achieve absolutely no data loss, set wal_level to 2 and wal_fsync_period to 0 ## Disaster Recovery -TDengine uses replication to provide high availability. +TDengine provides disaster recovery by using taosX to replicate data between two TDengine clusters which are deployed in two distant data centers. Assume there are two TDengine clusters, A and B, A is the source and B is the target, and A takes the workload of writing and querying. You can deploy `taosX` in the data center where cluster A resides in, `taosX` consumes the data written into cluster A and writes into cluster B. If the data center of cluster A is disrupted because of disaster, you can switch to cluster B to take the workload of data writing and querying, and deploy a `taosX` in the data center of cluster B to replicate data from cluster B to cluster A if cluster A has been recovered, or another cluster C if cluster A has not been recovered. -A TDengine cluster is managed by mnodes. You can configure up to three mnodes to ensure high availability. The data replication between mnode replicas is performed in a synchronous way to guarantee metadata consistency. +You can use the data replication feature of `taosX` to build more complicated disaster recovery solution. -The number of replicas for time series data in TDengine is associated with each database. There can be many databases in a cluster and each database can be configured with a different number of replicas. When creating a database, the parameter `replica` is used to specify the number of replicas. To achieve high availability, set `replica` to 3. - -The number of dnodes in a TDengine cluster must NOT be lower than the number of replicas for any database, otherwise it would fail when trying to create a table. - -As long as the dnodes of a TDengine cluster are deployed on different physical machines and the replica number is higher than 1, high availability can be achieved without any other assistance. For disaster recovery, dnodes of a TDengine cluster should be deployed in geographically different data centers. - -Alternatively, you can use taosX to synchronize the data from one TDengine cluster to another cluster in a remote location. However, taosX is only available in TDengine enterprise version, for more information please contact tdengine.com. +taosX is only provided in TDengine enterprise edition, for more details please contact business@tdengine.com. diff --git a/docs/en/14-reference/03-connector/04-java.mdx b/docs/en/14-reference/03-connector/04-java.mdx index e7a1303aafc641981fe5166df37d9f2f888b33e7..fd4b4641d75e2116267b3f7f13a995079913f663 100644 --- a/docs/en/14-reference/03-connector/04-java.mdx +++ b/docs/en/14-reference/03-connector/04-java.mdx @@ -725,7 +725,7 @@ consumer.close() For more information, see [Data Subscription](../../../develop/tmq). -### Usage examples +#### Full Sample Code diff --git a/docs/en/14-reference/03-connector/05-go.mdx b/docs/en/14-reference/03-connector/05-go.mdx index da2f54708f550bc4ba9f35da81ad59a575bda169..0088f230069b15f12e455b5b6d2d6fa261fc5a14 100644 --- a/docs/en/14-reference/03-connector/05-go.mdx +++ b/docs/en/14-reference/03-connector/05-go.mdx @@ -120,7 +120,7 @@ _taosSql_ implements Go's `database/sql/driver` interface via cgo. You can use t Use `taosSql` as `driverName` and use a correct [DSN](#DSN) as `dataSourceName`, DSN supports the following parameters. -* configPath specifies the `taos.cfg` directory +* cfg specifies the `taos.cfg` directory For example: diff --git a/docs/en/14-reference/03-connector/07-python.mdx b/docs/en/14-reference/03-connector/07-python.mdx index c885d416c8303ecb95a55b42125de31aa5dcd65a..bfbdd929c263a59df42e1f310b267ba1521032c2 100644 --- a/docs/en/14-reference/03-connector/07-python.mdx +++ b/docs/en/14-reference/03-connector/07-python.mdx @@ -10,10 +10,11 @@ import TabItem from "@theme/TabItem"; `taospy` is the official Python connector for TDengine. taospy provides a rich API that makes it easy for Python applications to use TDengine. `taospy` wraps both the [native interface](/reference/connector/cpp) and [REST interface](/reference/rest-api) of TDengine, which correspond to the `taos` and `taosrest` modules of the `taospy` package, respectively. In addition to wrapping the native and REST interfaces, `taospy` also provides a set of programming interfaces that conforms to the [Python Data Access Specification (PEP 249)](https://peps.python.org/pep-0249/). It is easy to integrate `taospy` with many third-party tools, such as [SQLAlchemy](https://www.sqlalchemy.org/) and [pandas](https://pandas.pydata.org/). -The direct connection to the server using the native interface provided by the client driver is referred to hereinafter as a "native connection"; the connection to the server using the REST interface provided by taosAdapter is referred to hereinafter as a "REST connection". +`taos-ws-py` is an optional package to enable using WebSocket to connect TDengine. -The source code for the Python connector is hosted on [GitHub](https://github.com/taosdata/taos-connector-python). +The direct connection to the server using the native interface provided by the client driver is referred to hereinafter as a "native connection"; the connection to the server using the REST or WebSocket interface provided by taosAdapter is referred to hereinafter as a "REST connection" or "WebSocket connection". +The source code for the Python connector is hosted on [GitHub](https://github.com/taosdata/taos-connector-python). ## Supported platforms - The [supported platforms](/reference/connector/#supported-platforms) for the native connection are the same as the ones supported by the TDengine client. @@ -114,6 +115,15 @@ For REST connections, verifying that the `taosrest` module can be imported succe import taosrest ``` + + + +For WebSocket connection, verifying that the `taosws` module can be imported successfully can be done in the Python Interactive Shell by typing. + +```python +import taosws +``` + @@ -182,6 +192,28 @@ If the test is successful, it will output the server version information, e.g. } ``` + + + +For WebSocket connection, make sure the cluster and taosAdapter component, are running. This can be testetd using the following `curl` command. + +``` +curl -i -N -d "show databases" -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: :" -H "Origin: http://:" http://:/rest/sql +``` + +The FQDN above is the FQDN of the machine running taosAdapter, PORT is the port taosAdapter listening, default is `6041`. + +If the test is successful, it will output the server version information, e.g. + +```json +HTTP/1.1 200 OK +Content-Type: application/json; charset=utf-8 +Date: Tue, 21 Mar 2023 09:29:17 GMT +Transfer-Encoding: chunked + +{"status":"succ","head":["server_version()"],"column_meta":[["server_version()",8,8]],"data":[["2.6.0.27"]],"rows":1} +``` + @@ -321,6 +353,86 @@ For a more detailed description of the `sql()` method, please refer to [RestClie +### Usage with req_id + +By using the optional req_id parameter, you can specify a request ID that can be used for tracing. + + + + +##### TaosConnection class + +The `TaosConnection` class contains both an implementation of the PEP249 Connection interface (e.g., the `cursor()` method and the `close()` method) and many extensions (e.g., the `execute()`, `query()`, `schemaless_insert()`, and `subscribe()` methods). + +```python title="execute method" +{{#include docs/examples/python/connection_usage_native_reference_with_req_id.py:insert}} +``` + +```python title="query method" +{{#include docs/examples/python/connection_usage_native_reference_with_req_id.py:query}} +``` + +:::tip +The queried results can only be fetched once. For example, only one of `fetch_all()` and `fetch_all_into_dict()` can be used in the example above. Repeated fetches will result in an empty list. +::: + +##### Use of TaosResult class + +In the above example of using the `TaosConnection` class, we have shown two ways to get the result of a query: `fetch_all()` and `fetch_all_into_dict()`. In addition, `TaosResult` also provides methods to iterate through the result set by rows (`rows_iter`) or by data blocks (`blocks_iter`). Using these two methods will be more efficient in scenarios where the query has a large amount of data. + +```python title="blocks_iter method" +{{#include docs/examples/python/result_set_with_req_id_examples.py}} +``` +##### Use of the TaosCursor class + +The `TaosConnection` class and the `TaosResult` class already implement all the functionality of the native interface. If you are familiar with the interfaces in the PEP249 specification, you can also use the methods provided by the `TaosCursor` class. + +```python title="Use of TaosCursor" +{{#include docs/examples/python/cursor_usage_native_reference_with_req_id.py}} +``` + +:::note +The TaosCursor class uses native connections for write and query operations. In a client-side multi-threaded scenario, this cursor instance must remain thread exclusive and cannot be shared across threads for use, otherwise, it will result in errors in the returned results. + +::: + + + + +##### Use of TaosRestCursor class + +The `TaosRestCursor` class is an implementation of the PEP249 Cursor interface. + +```python title="Use of TaosRestCursor" +{{#include docs/examples/python/connect_rest_with_req_id_examples.py:basic}} +``` +- `cursor.execute`: Used to execute arbitrary SQL statements. +- `cursor.rowcount` : For write operations, returns the number of successful rows written. For query operations, returns the number of rows in the result set. +- `cursor.description` : Returns the description of the field. Please refer to [TaosRestCursor](https://docs.taosdata.com/api/taospy/taosrest/cursor.html) for the specific format of the description information. + +##### Use of the RestClient class + +The `RestClient` class is a direct wrapper for the [REST API](/reference/rest-api). It contains only a `sql()` method for executing arbitrary SQL statements and returning the result. + +```python title="Use of RestClient" +{{#include docs/examples/python/rest_client_with_req_id_example.py}} +``` + +For a more detailed description of the `sql()` method, please refer to [RestClient](https://docs.taosdata.com/api/taospy/taosrest/restclient.html). + + + + +```python +{{#include docs/examples/python/connect_websocket_with_req_id_examples.py:basic}} +``` + +- `conn.execute`: can use to execute arbitrary SQL statements, and return the number of rows affected. +- `conn.query`: can use to execute query SQL statements, and return the query results. + + + + ### Used with pandas diff --git a/docs/en/14-reference/03-connector/_linux_install.mdx b/docs/en/14-reference/03-connector/_linux_install.mdx index 97f6cd333961d24bd015a2ebcf7223f89fecca2c..398593cfe6b23cbb3269182a68fb7563e2964484 100644 --- a/docs/en/14-reference/03-connector/_linux_install.mdx +++ b/docs/en/14-reference/03-connector/_linux_install.mdx @@ -14,7 +14,7 @@ import PkgListV3 from "/components/PkgListV3"; Once the package is unzipped, you will see the following files in the directory: - _ install_client.sh_: install script - - _ taos.tar.gz_: client driver package + - _ package.tar.gz_: client driver package - _ driver_: TDengine client driver - _examples_: some example programs of different programming languages (C/C#/go/JDBC/MATLAB/python/R) You can run `install_client.sh` to install it. diff --git a/docs/en/14-reference/12-config/index.md b/docs/en/14-reference/12-config/index.md index a76074f5078f1273cea06d1404230b8ad389455e..430487a3af9f8729e199251b9cb6c913ee059769 100644 --- a/docs/en/14-reference/12-config/index.md +++ b/docs/en/14-reference/12-config/index.md @@ -99,6 +99,9 @@ The parameters described in this document by the effect that they have on the sy ## Monitoring Parameters +:::note +Please note the `taoskeeper` needs to be installed and running to create the `log` database and receiving metrics sent by `taosd` as the full monitoring solution. + ### monitor | Attribute | Description | diff --git a/docs/en/14-reference/14-taosKeeper.md b/docs/en/14-reference/14-taosKeeper.md index 16c591154705521fc194a13ddcf6d2bbb5552470..895bd82e1924a59227bc8193c277b96eccd6cd66 100644 --- a/docs/en/14-reference/14-taosKeeper.md +++ b/docs/en/14-reference/14-taosKeeper.md @@ -4,23 +4,24 @@ title: taosKeeper description: This document describes how to use taosKeeper, a tool for exporting TDengine monitoring metrics. --- +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; + ## Introduction taosKeeper is a tool for TDengine that exports monitoring metrics. With taosKeeper, you can easily monitor the operational status of your TDengine deployment. taosKeeper uses the TDengine REST API. It is not necessary to install TDengine Client to use taosKeeper. ## Installation - +There are two ways to install taosKeeper: Methods of installing taosKeeper: - - -- You can compile taosKeeper separately and install it. Please refer to the [taosKeeper](https://github.com/taosdata/taoskeeper) repository for details. --> -You can compile taosKeeper separately and install it. Please refer to the [taosKeeper](https://github.com/taosdata/taoskeeper) repository for details. +- Installing the official TDengine installer will automatically install taosKeeper. Please refer to [TDengine installation](/operation/pkg-install) for details. -## Run +- You can compile taosKeeper separately and install it. Please refer to the [taosKeeper](https://github.com/taosdata/taoskeeper) repository for details. +## Configuration and Launch -### Configuration and running methods +### Configuration taosKeeper needs to be executed on the terminal of the operating system, it supports three configuration methods: [Command-line arguments](#command-line-arguments-in-detail), [environment variable](#environment-variable-in-detail) and [configuration file](#configuration-file-parameters-in-detail). The precedence of those is Command-line, environment variable and configuration file. @@ -33,28 +34,81 @@ monitorFqdn localhost # taoskeeper's FQDN For more information, see [TDengine Monitoring Configuration](../config/#monitoring). -### Command-Line Parameters +### Quick Launch -You can use command-line parameters to run taosKeeper and control its behavior: + + -```shell -$ taosKeeper +After the installation is complete, run the following command to start the taoskeeper service: + +```bash +systemctl start taoskeeper ``` -### Environment variable -You can use Environment variable to run taosKeeper and control its behavior: +Run the following command to confirm that taoskeeper is running normally: -```shell -$ export TAOS_KEEPER_TDENGINE_HOST=192.168.64.3 - -$ taoskeeper +```bash +systemctl status taoskeeper +``` + +Output similar to the following indicates that taoskeeper is running normally: + +``` +Active: active (running) +``` + +Output similar to the following indicates that taoskeeper has not started successfully: + +``` +Active: inactive (dead) ``` -you can run `taoskeeper -h` for more detail. +The following `systemctl` commands can help you manage taoskeeper service: + +- Start taoskeeper Server: `systemctl start taoskeeper` + +- Stop taoskeeper Server: `systemctl stop taoskeeper` + +- Restart taoskeeper Server: `systemctl restart taoskeeper` + +- Check taoskeeper Server status: `systemctl status taoskeeper` + +:::info + +- The `systemctl` command requires _root_ privileges. If you are not logged in as the _root_ user, use the `sudo` command. +- The `systemctl stop taoskeeper` command will instantly stop taoskeeper Server. +- If your system does not include `systemd`, you can run `/usr/local/taos/bin/taoskeeper` to start taoskeeper manually. + +::: + -### Configuration File + -You can quickly launch taosKeeper with the following commands. If you do not specify a configuration file, `/etc/taos/keeper.toml` is used by default. If this file does not specify configurations, the default values are used. +After the installation is complete, run `launchctl start com.tdengine.taoskeeper` to start taoskeeper Server. + +The following `launchctl` commands can help you manage taoskeeper service: + +- Start taoskeeper Server: `sudo launchctl start com.tdengine.taoskeeper` + +- Stop taoskeeper Server: `sudo launchctl stop com.tdengine.taoskeeper` + +- Check taoskeeper Server status: `sudo launchctl list | grep taoskeeper` + +:::info +- Please use `sudo` to run `launchctl` to manage _com.tdengine.taoskeeper_ with administrator privileges. +- The administrator privilege is required for service management to enhance security. +- Troubleshooting: +- The first column returned by the command `launchctl list | grep taoskeeper` is the PID of the program. If it's `-`, that means the taoskeeper service is not running. +- If the service is abnormal, please check the `launchd.log` file from the system log. + +::: + + + + +#### Launch With Configuration File + +You can quickly launch taosKeeper with the following commands. If you do not specify a configuration file, `/etc/taos/keeper.toml` is used by default. If this file does not specify configurations, the default values are used. ```shell $ taoskeeper -c @@ -132,19 +186,36 @@ $ curl http://127.0.0.1:6043/metrics Sample result set (excerpt): ```shell -# HELP taos_cluster_info_connections_total +# HELP taos_cluster_info_connections_total # TYPE taos_cluster_info_connections_total counter taos_cluster_info_connections_total{cluster_id="5981392874047724755"} 16 -# HELP taos_cluster_info_dbs_total +# HELP taos_cluster_info_dbs_total # TYPE taos_cluster_info_dbs_total counter taos_cluster_info_dbs_total{cluster_id="5981392874047724755"} 2 -# HELP taos_cluster_info_dnodes_alive +# HELP taos_cluster_info_dnodes_alive # TYPE taos_cluster_info_dnodes_alive counter taos_cluster_info_dnodes_alive{cluster_id="5981392874047724755"} 1 -# HELP taos_cluster_info_dnodes_total +# HELP taos_cluster_info_dnodes_total # TYPE taos_cluster_info_dnodes_total counter taos_cluster_info_dnodes_total{cluster_id="5981392874047724755"} 1 -# HELP taos_cluster_info_first_ep +# HELP taos_cluster_info_first_ep # TYPE taos_cluster_info_first_ep gauge taos_cluster_info_first_ep{cluster_id="5981392874047724755",value="hlb:6030"} 1 -``` \ No newline at end of file +``` + +### check_health + +``` +$ curl -i http://127.0.0.1:6043/check_health +``` + +Response: + +``` +HTTP/1.1 200 OK +Content-Type: application/json; charset=utf-8 +Date: Mon, 03 Apr 2023 07:20:38 GMT +Content-Length: 19 + +{"version":"1.0.0"} +``` diff --git a/docs/en/20-third-party/01-grafana.mdx b/docs/en/20-third-party/01-grafana.mdx index 5a2942b14497401ef1a2cb8f31ad2773f6b828e3..b0e9dea707fb2fb326329895921850cd6d721b6d 100644 --- a/docs/en/20-third-party/01-grafana.mdx +++ b/docs/en/20-third-party/01-grafana.mdx @@ -77,7 +77,7 @@ sudo -u grafana grafana-cli plugins install tdengine-datasource You can also download zip files from [GitHub](https://github.com/taosdata/grafanaplugin/releases/tag/latest) or [Grafana](https://grafana.com/grafana/plugins/tdengine-datasource/?tab=installation) and install manually. The commands are as follows: ```bash -GF_VERSION=3.2.7 +GF_VERSION=3.3.1 # from GitHub wget https://github.com/taosdata/grafanaplugin/releases/download/v$GF_VERSION/tdengine-datasource-$GF_VERSION.zip # from Grafana diff --git a/docs/en/28-releases/01-tdengine.md b/docs/en/28-releases/01-tdengine.md index 088c4ba2dcd5f2e6cd4fce789d9d24db8ab006e8..b160058d02c22dc824b0e960ad61cbe596999a70 100644 --- a/docs/en/28-releases/01-tdengine.md +++ b/docs/en/28-releases/01-tdengine.md @@ -10,6 +10,18 @@ For TDengine 2.x installation packages by version, please visit [here](https://w import Release from "/components/ReleaseV3"; +## 3.0.3.2 + + + +## 3.0.3.1 + + + +## 3.0.3.1 + + + ## 3.0.3.0 diff --git a/docs/en/28-releases/02-tools.md b/docs/en/28-releases/02-tools.md index 7d45110bb06fcc504f6393b6d6132d5541f98b2c..17581b780a8cba5e0e73ef7d0ff8da8e54f0de56 100644 --- a/docs/en/28-releases/02-tools.md +++ b/docs/en/28-releases/02-tools.md @@ -10,6 +10,14 @@ For other historical version installers, please visit [here](https://www.taosdat import Release from "/components/ReleaseV3"; +## 2.4.11 + + + +## 2.4.10 + + + ## 2.4.9 diff --git a/docs/examples/c/tmq_example.c b/docs/examples/c/tmq_example.c index a3bade308a4ce41f556878d90861e299893315c4..d958428b8ffec9064166ddfd502cc0e2dbd9a200 100644 --- a/docs/examples/c/tmq_example.c +++ b/docs/examples/c/tmq_example.c @@ -70,7 +70,7 @@ static int32_t init_env() { taos_free_result(pRes); // create database - pRes = taos_query(pConn, "create database tmqdb"); + pRes = taos_query(pConn, "create database tmqdb wal_retention_period 3600"); if (taos_errno(pRes) != 0) { printf("error in create tmqdb, reason:%s\n", taos_errstr(pRes)); return -1; diff --git a/docs/examples/csharp/influxdbLine/Program.cs b/docs/examples/csharp/influxdbLine/Program.cs index fa3cb21fe04977b5081c922d623dee5514056770..a620c016090c9177966f8361eac0e65d23192bd8 100644 --- a/docs/examples/csharp/influxdbLine/Program.cs +++ b/docs/examples/csharp/influxdbLine/Program.cs @@ -48,7 +48,7 @@ namespace TDengineExample static void PrepareDatabase(IntPtr conn) { - IntPtr res = TDengine.Query(conn, "CREATE DATABASE test"); + IntPtr res = TDengine.Query(conn, "CREATE DATABASE test WAL_RETENTION_PERIOD 3600"); if (TDengine.ErrorNo(res) != 0) { throw new Exception("failed to create database, reason: " + TDengine.Error(res)); diff --git a/docs/examples/csharp/optsJSON/Program.cs b/docs/examples/csharp/optsJSON/Program.cs index b67b5af62bf0a1fd9028125da0b665f723f2e4ec..8dcc1dce92be2f134ce68910c916896c07fc4003 100644 --- a/docs/examples/csharp/optsJSON/Program.cs +++ b/docs/examples/csharp/optsJSON/Program.cs @@ -54,7 +54,7 @@ namespace TDengineExample static void PrepareDatabase(IntPtr conn) { - IntPtr res = TDengine.Query(conn, "CREATE DATABASE test"); + IntPtr res = TDengine.Query(conn, "CREATE DATABASE test WAL_RETENTION_PERIOD 3600"); if (TDengine.ErrorNo(res) != 0) { throw new Exception("failed to create database, reason: " + TDengine.Error(res)); diff --git a/docs/examples/csharp/optsTelnet/Program.cs b/docs/examples/csharp/optsTelnet/Program.cs index e73ceb041accf88222176342d46fe1a669584211..ccd29d0cfc62ac1a59bea8465630595c2e65b5c0 100644 --- a/docs/examples/csharp/optsTelnet/Program.cs +++ b/docs/examples/csharp/optsTelnet/Program.cs @@ -58,7 +58,7 @@ namespace TDengineExample static void PrepareDatabase(IntPtr conn) { - IntPtr res = TDengine.Query(conn, "CREATE DATABASE test"); + IntPtr res = TDengine.Query(conn, "CREATE DATABASE test WAL_RETENTION_PERIOD 3600"); if (TDengine.ErrorNo(res) != 0) { throw new Exception("failed to create database, reason: " + TDengine.Error(res)); diff --git a/docs/examples/csharp/sqlInsert/Program.cs b/docs/examples/csharp/sqlInsert/Program.cs index f23a6e1663023d1d2fafb3e92e0b605f8ac55e52..25a945a45952d596153707bb4ea8d6c6e327b098 100644 --- a/docs/examples/csharp/sqlInsert/Program.cs +++ b/docs/examples/csharp/sqlInsert/Program.cs @@ -11,7 +11,7 @@ namespace TDengineExample IntPtr conn = GetConnection(); try { - IntPtr res = TDengine.Query(conn, "CREATE DATABASE power"); + IntPtr res = TDengine.Query(conn, "CREATE DATABASE power WAL_RETENTION_PERIOD 3600"); CheckRes(conn, res, "failed to create database"); res = TDengine.Query(conn, "USE power"); CheckRes(conn, res, "failed to change database"); diff --git a/docs/examples/csharp/stmtInsert/Program.cs b/docs/examples/csharp/stmtInsert/Program.cs index 80cadb2ff8b596a0484d05ff15aeaa50f22ff859..2e856a49bbbbae5424a517363e3ae1360ba6a0c7 100644 --- a/docs/examples/csharp/stmtInsert/Program.cs +++ b/docs/examples/csharp/stmtInsert/Program.cs @@ -76,7 +76,7 @@ namespace TDengineExample static void PrepareSTable() { - IntPtr res = TDengine.Query(conn, "CREATE DATABASE power"); + IntPtr res = TDengine.Query(conn, "CREATE DATABASE power WAL_RETENTION_PERIOD 3600"); CheckResPtr(res, "failed to create database"); res = TDengine.Query(conn, "USE power"); CheckResPtr(res, "failed to change database"); diff --git a/docs/examples/go/sub/main.go b/docs/examples/go/sub/main.go index 1f7218936fbe457615562ded1b938daca95225cb..cb24e351ab8cc5265cefbed9565d9a404aadf08d 100644 --- a/docs/examples/go/sub/main.go +++ b/docs/examples/go/sub/main.go @@ -15,7 +15,7 @@ func main() { panic(err) } defer db.Close() - _, err = db.Exec("create database if not exists example_tmq") + _, err = db.Exec("create database if not exists example_tmq wal_retention_period 3600") if err != nil { panic(err) } @@ -35,7 +35,6 @@ func main() { "td.connect.port": "6030", "client.id": "test_tmq_client", "enable.auto.commit": "false", - "enable.heartbeat.background": "true", "experimental.snapshot.enable": "true", "msg.with.table.name": "true", }) diff --git a/docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java b/docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java index e9af5e9ce0c0473f4513cbb949dcbd9f433c0c92..8da6f77bae432dee987d4567229c2fbebd657be8 100644 --- a/docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java +++ b/docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java @@ -35,7 +35,7 @@ public class SubscribeDemo { try (Statement statement = connection.createStatement()) { statement.executeUpdate("drop topic if exists " + TOPIC); statement.executeUpdate("drop database if exists " + DB_NAME); - statement.executeUpdate("create database " + DB_NAME); + statement.executeUpdate("create database " + DB_NAME + " wal_retention_period 3600"); statement.executeUpdate("use " + DB_NAME); statement.executeUpdate( "CREATE TABLE `meters` (`ts` TIMESTAMP, `current` FLOAT, `voltage` INT) TAGS (`groupid` INT, `location` BINARY(24))"); diff --git a/docs/examples/java/src/main/java/com/taos/example/WebsocketSubscribeDemo.java b/docs/examples/java/src/main/java/com/taos/example/WebsocketSubscribeDemo.java index d953a7364160a686d67b4390f3370999b02ce5d4..83cb04f55244aacf860573a42ddc952e1e522803 100644 --- a/docs/examples/java/src/main/java/com/taos/example/WebsocketSubscribeDemo.java +++ b/docs/examples/java/src/main/java/com/taos/example/WebsocketSubscribeDemo.java @@ -35,7 +35,7 @@ public class WebsocketSubscribeDemo { Statement statement = connection.createStatement()) { statement.executeUpdate("drop topic if exists " + TOPIC); statement.executeUpdate("drop database if exists " + DB_NAME); - statement.executeUpdate("create database " + DB_NAME); + statement.executeUpdate("create database " + DB_NAME + " wal_retention_period 3600"); statement.executeUpdate("use " + DB_NAME); statement.executeUpdate( "CREATE TABLE `meters` (`ts` TIMESTAMP, `current` FLOAT, `voltage` INT) TAGS (`groupid` INT, `location` BINARY(24))"); diff --git a/docs/examples/python/conn_websocket_pandas.py b/docs/examples/python/conn_websocket_pandas.py index eac386732c6ec6e512c6f6723f47f1f09751d9f9..5cad5384b251b7016f895d4d0e8792e42bfc395f 100644 --- a/docs/examples/python/conn_websocket_pandas.py +++ b/docs/examples/python/conn_websocket_pandas.py @@ -4,7 +4,7 @@ import taos taos_conn = taos.connect() taos_conn.execute('drop database if exists power') -taos_conn.execute('create database if not exists power') +taos_conn.execute('create database if not exists power wal_retention_period 3600') taos_conn.execute("use power") taos_conn.execute( "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)") diff --git a/docs/examples/python/connect_rest_with_req_id_examples.py b/docs/examples/python/connect_rest_with_req_id_examples.py new file mode 100644 index 0000000000000000000000000000000000000000..3feb574fa60d5701aa040b606846cb6cf7a28aaa --- /dev/null +++ b/docs/examples/python/connect_rest_with_req_id_examples.py @@ -0,0 +1,44 @@ +# ANCHOR: connect +from taosrest import connect, TaosRestConnection, TaosRestCursor + +conn = connect(url="http://localhost:6041", + user="root", + password="taosdata", + timeout=30) + +# ANCHOR_END: connect +# ANCHOR: basic +# create STable +cursor = conn.cursor() +cursor.execute("DROP DATABASE IF EXISTS power", req_id=1) +cursor.execute("CREATE DATABASE power", req_id=2) +cursor.execute( + "CREATE STABLE power.meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)", req_id=3) + +# insert data +cursor.execute("""INSERT INTO power.d1001 USING power.meters TAGS('California.SanFrancisco', 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000) + power.d1002 USING power.meters TAGS('California.SanFrancisco', 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000) + power.d1003 USING power.meters TAGS('California.LosAngeles', 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000) + power.d1004 USING power.meters TAGS('California.LosAngeles', 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)""", req_id=4) +print("inserted row count:", cursor.rowcount) + +# query data +cursor.execute("SELECT * FROM power.meters LIMIT 3", req_id=5) +# get total rows +print("queried row count:", cursor.rowcount) +# get column names from cursor +column_names = [meta[0] for meta in cursor.description] +# get rows +data = cursor.fetchall() +print(column_names) +for row in data: + print(row) + +# output: +# inserted row count: 8 +# queried row count: 3 +# ['ts', 'current', 'voltage', 'phase', 'location', 'groupid'] +# [datetime.datetime(2018, 10, 3, 14, 38, 5, 500000, tzinfo=datetime.timezone(datetime.timedelta(seconds=28800), '+08:00')), 11.8, 221, 0.28, 'california.losangeles', 2] +# [datetime.datetime(2018, 10, 3, 14, 38, 16, 600000, tzinfo=datetime.timezone(datetime.timedelta(seconds=28800), '+08:00')), 13.4, 223, 0.29, 'california.losangeles', 2] +# [datetime.datetime(2018, 10, 3, 14, 38, 5, tzinfo=datetime.timezone(datetime.timedelta(seconds=28800), '+08:00')), 10.8, 223, 0.29, 'california.losangeles', 3] +# ANCHOR_END: basic diff --git a/docs/examples/python/connect_websocket_examples.py b/docs/examples/python/connect_websocket_examples.py index c50976efbf595e63b91f16faff0af7eb37e90756..29452bbf9d32b2e630575ef4f51fd2d10b59495a 100644 --- a/docs/examples/python/connect_websocket_examples.py +++ b/docs/examples/python/connect_websocket_examples.py @@ -6,7 +6,7 @@ conn = taosws.connect("taosws://root:taosdata@localhost:6041") # ANCHOR: basic conn.execute("drop database if exists connwspy") -conn.execute("create database if not exists connwspy") +conn.execute("create database if not exists connwspy wal_retention_period 3600") conn.execute("use connwspy") conn.execute("create table if not exists stb (ts timestamp, c1 int) tags (t1 int)") conn.execute("create table if not exists tb1 using stb tags (1)") diff --git a/docs/examples/python/connect_websocket_with_req_id_examples.py b/docs/examples/python/connect_websocket_with_req_id_examples.py new file mode 100644 index 0000000000000000000000000000000000000000..f5f76c8446649e8b9b77b754d45eca0cb5d5a210 --- /dev/null +++ b/docs/examples/python/connect_websocket_with_req_id_examples.py @@ -0,0 +1,29 @@ +# ANCHOR: connect +import taosws + +conn = taosws.connect("taosws://root:taosdata@localhost:6041") +# ANCHOR_END: connect + +# ANCHOR: basic +conn.execute("drop database if exists connwspy", req_id=1) +conn.execute("create database if not exists connwspy", req_id=2) +conn.execute("use connwspy", req_id=3) +conn.execute("create table if not exists stb (ts timestamp, c1 int) tags (t1 int)", req_id=4) +conn.execute("create table if not exists tb1 using stb tags (1)", req_id=5) +conn.execute("insert into tb1 values (now, 1)", req_id=6) +conn.execute("insert into tb1 values (now, 2)", req_id=7) +conn.execute("insert into tb1 values (now, 3)", req_id=8) + +r = conn.execute("select * from stb", req_id=9) +result = conn.query("select * from stb", req_id=10) +num_of_fields = result.field_count +print(num_of_fields) + +for row in result: + print(row) + +# output: +# 3 +# ('2023-02-28 15:56:13.329 +08:00', 1, 1) +# ('2023-02-28 15:56:13.333 +08:00', 2, 1) +# ('2023-02-28 15:56:13.337 +08:00', 3, 1) diff --git a/docs/examples/python/connection_usage_native_reference_with_req_id.py b/docs/examples/python/connection_usage_native_reference_with_req_id.py new file mode 100644 index 0000000000000000000000000000000000000000..24d0914ad54eb9545ab56468230201f3e2bd3484 --- /dev/null +++ b/docs/examples/python/connection_usage_native_reference_with_req_id.py @@ -0,0 +1,45 @@ +import taos + +# ANCHOR: insert +conn = taos.connect() +# Execute a sql, ignore the result set, just get affected rows. It's useful for DDL and DML statement. +conn.execute("DROP DATABASE IF EXISTS test", req_id=1) +conn.execute("CREATE DATABASE test", req_id=2) +# change database. same as execute "USE db" +conn.select_db("test") +conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=3) +affected_row = conn.execute("INSERT INTO t1 USING weather TAGS(1) VALUES (now, 23.5) (now+1m, 23.5) (now+2m, 24.4)", req_id=4) +print("affected_row", affected_row) +# output: +# affected_row 3 +# ANCHOR_END: insert + +# ANCHOR: query +# Execute a sql and get its result set. It's useful for SELECT statement +result = conn.query("SELECT * from weather", req_id=5) + +# Get fields from result +fields = result.fields +for field in fields: + print(field) # {name: ts, type: 9, bytes: 8} + +# output: +# {name: ts, type: 9, bytes: 8} +# {name: temperature, type: 6, bytes: 4} +# {name: location, type: 4, bytes: 4} + +# Get data from result as list of tuple +data = result.fetch_all() +print(data) +# output: +# [(datetime.datetime(2022, 4, 27, 9, 4, 25, 367000), 23.5, 1), (datetime.datetime(2022, 4, 27, 9, 5, 25, 367000), 23.5, 1), (datetime.datetime(2022, 4, 27, 9, 6, 25, 367000), 24.399999618530273, 1)] + +# Or get data from result as a list of dict +# map_data = result.fetch_all_into_dict() +# print(map_data) +# output: +# [{'ts': datetime.datetime(2022, 4, 27, 9, 1, 15, 343000), 'temperature': 23.5, 'location': 1}, {'ts': datetime.datetime(2022, 4, 27, 9, 2, 15, 343000), 'temperature': 23.5, 'location': 1}, {'ts': datetime.datetime(2022, 4, 27, 9, 3, 15, 343000), 'temperature': 24.399999618530273, 'location': 1}] +# ANCHOR_END: query + + +conn.close() \ No newline at end of file diff --git a/docs/examples/python/cursor_usage_native_reference_with_req_id.py b/docs/examples/python/cursor_usage_native_reference_with_req_id.py new file mode 100644 index 0000000000000000000000000000000000000000..15207ee6bc97fdb00918b98439fff785770f1334 --- /dev/null +++ b/docs/examples/python/cursor_usage_native_reference_with_req_id.py @@ -0,0 +1,32 @@ +import taos + +conn = taos.connect() +cursor = conn.cursor() + +cursor.execute("DROP DATABASE IF EXISTS test", req_id=1) +cursor.execute("CREATE DATABASE test", req_id=2) +cursor.execute("USE test", req_id=3) +cursor.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=4) + +for i in range(1000): + location = str(i % 10) + tb = "t" + location + cursor.execute(f"INSERT INTO {tb} USING weather TAGS({location}) VALUES (now+{i}a, 23.5) (now+{i + 1}a, 23.5)", req_id=5+i) + +cursor.execute("SELECT count(*) FROM weather", req_id=1005) +data = cursor.fetchall() +print("count:", data[0][0]) +cursor.execute("SELECT tbname, * FROM weather LIMIT 2", req_id=1006) +col_names = [meta[0] for meta in cursor.description] +print(col_names) +rows = cursor.fetchall() +print(rows) + +cursor.close() +conn.close() + +# output: +# count: 2000 +# ['tbname', 'ts', 'temperature', 'location'] +# row_count: -1 +# [('t0', datetime.datetime(2022, 4, 27, 14, 54, 24, 392000), 23.5, 0), ('t0', datetime.datetime(2022, 4, 27, 14, 54, 24, 393000), 23.5, 0)] diff --git a/docs/examples/python/kafka_example_common.py b/docs/examples/python/kafka_example_common.py index 566748c94e2542aabe8265ed55c85e4b725d69bb..1c735abfc080f63f5bc4126a7f44474dbf5d157c 100644 --- a/docs/examples/python/kafka_example_common.py +++ b/docs/examples/python/kafka_example_common.py @@ -5,7 +5,7 @@ LOCATIONS = ['California.SanFrancisco', 'California.LosAngles', 'California.SanD 'California.PaloAlto', 'California.Campbell', 'California.MountainView', 'California.Sunnyvale', 'California.SantaClara', 'California.Cupertino'] -CREATE_DATABASE_SQL = 'create database if not exists {} keep 365 duration 10 buffer 16 wal_level 1' +CREATE_DATABASE_SQL = 'create database if not exists {} keep 365 duration 10 buffer 16 wal_level 1 wal_retention_period 3600' USE_DATABASE_SQL = 'use {}' DROP_TABLE_SQL = 'drop table if exists meters' DROP_DATABASE_SQL = 'drop database if exists {}' diff --git a/docs/examples/python/rest_client_with_req_id_example.py b/docs/examples/python/rest_client_with_req_id_example.py new file mode 100644 index 0000000000000000000000000000000000000000..918398e51eb8c5e33c6fed3b7e05afdbd1c66878 --- /dev/null +++ b/docs/examples/python/rest_client_with_req_id_example.py @@ -0,0 +1,9 @@ +from taosrest import RestClient + +client = RestClient("http://localhost:6041", user="root", password="taosdata") +res: dict = client.sql("SELECT ts, current FROM power.meters LIMIT 1", req_id=1) +print(res) + +# output: +# {'status': 'succ', 'head': ['ts', 'current'], 'column_meta': [['ts', 9, 8], ['current', 6, 4]], 'data': [[datetime.datetime(2018, 10, 3, 14, 38, 5, tzinfo=datetime.timezone(datetime.timedelta(seconds=28800), '+08:00')), 10.3]], 'rows': 1} + diff --git a/docs/examples/python/result_set_with_req_id_examples.py b/docs/examples/python/result_set_with_req_id_examples.py new file mode 100644 index 0000000000000000000000000000000000000000..90ae2f4f2671bf00669adc69270dc943a02c16aa --- /dev/null +++ b/docs/examples/python/result_set_with_req_id_examples.py @@ -0,0 +1,33 @@ +import taos + +conn = taos.connect() +conn.execute("DROP DATABASE IF EXISTS test", req_id=1) +conn.execute("CREATE DATABASE test", req_id=2) +conn.select_db("test") +conn.execute("CREATE STABLE weather(ts TIMESTAMP, temperature FLOAT) TAGS (location INT)", req_id=3) +# prepare data +for i in range(2000): + location = str(i % 10) + tb = "t" + location + conn.execute(f"INSERT INTO {tb} USING weather TAGS({location}) VALUES (now+{i}a, 23.5) (now+{i + 1}a, 23.5)", req_id=4+i) + +result: taos.TaosResult = conn.query("SELECT * FROM weather", req_id=2004) + +block_index = 0 +blocks: taos.TaosBlocks = result.blocks_iter() +for rows, length in blocks: + print("block ", block_index, " length", length) + print("first row in this block:", rows[0]) + block_index += 1 + +conn.close() + +# possible output: +# block 0 length 1200 +# first row in this block: (datetime.datetime(2022, 4, 27, 15, 14, 52, 46000), 23.5, 0) +# block 1 length 1200 +# first row in this block: (datetime.datetime(2022, 4, 27, 15, 14, 52, 76000), 23.5, 3) +# block 2 length 1200 +# first row in this block: (datetime.datetime(2022, 4, 27, 15, 14, 52, 99000), 23.5, 6) +# block 3 length 400 +# first row in this block: (datetime.datetime(2022, 4, 27, 15, 14, 52, 122000), 23.5, 9) diff --git a/docs/examples/python/tmq_example.py b/docs/examples/python/tmq_example.py index 6f7fb87c89ce4cb96793d09a837f60ad54ae69bc..5b462fa1536d34a11824eed09310f1068735a7dc 100644 --- a/docs/examples/python/tmq_example.py +++ b/docs/examples/python/tmq_example.py @@ -6,7 +6,7 @@ def init_tmq_env(db, topic): conn = taos.connect() conn.execute("drop topic if exists {}".format(topic)) conn.execute("drop database if exists {}".format(db)) - conn.execute("create database if not exists {}".format(db)) + conn.execute("create database if not exists {} wal_retention_period 3600".format(db)) conn.select_db(db) conn.execute( "create stable if not exists stb1 (ts timestamp, c1 int, c2 float, c3 varchar(16)) tags(t1 int, t3 varchar(16))") diff --git a/docs/zh/05-get-started/index.md b/docs/zh/05-get-started/index.md index 62eeb2f1c222ecc85bf6866ff5147ed881dcf005..16172277b5accef4e0e5c707d1bb7f09ace23446 100644 --- a/docs/zh/05-get-started/index.md +++ b/docs/zh/05-get-started/index.md @@ -4,7 +4,7 @@ description: '快速设置 TDengine 环境并体验其高效写入和查询' --- import xiaot from './xiaot.webp' -import xiaot_new from './xiaot-new.webp' +import xiaot_new from './xiaot-03.webp' import channel from './channel.webp' import official_account from './official-account.webp' diff --git a/docs/zh/05-get-started/xiaot-03.webp b/docs/zh/05-get-started/xiaot-03.webp new file mode 100644 index 0000000000000000000000000000000000000000..c115346e9e84ffb990aec5947b2107b5daf6e19b Binary files /dev/null and b/docs/zh/05-get-started/xiaot-03.webp differ diff --git a/docs/zh/07-develop/06-stream.md b/docs/zh/07-develop/06-stream.md index a2e1d1a1dac5af44e053aa314ede45005e2de587..4a5ebb96e8add2a8756b3e21d29f4ba40d5b927f 100644 --- a/docs/zh/07-develop/06-stream.md +++ b/docs/zh/07-develop/06-stream.md @@ -52,7 +52,7 @@ CREATE TABLE d1004 USING meters TAGS ("California.LosAngeles", 3); ### 创建流 ```sql -create stream current_stream into current_stream_output_stb as select _wstart as start, _wend as wend, max(current) as max_current from meters where voltage <= 220 interval (5s); +create stream current_stream trigger at_once into current_stream_output_stb as select _wstart as wstart, _wend as wend, max(current) as max_current from meters where voltage <= 220 interval (5s); ``` ### 写入数据 @@ -70,8 +70,8 @@ insert into d1004 values("2018-10-03 14:38:06.500", 11.50000, 221, 0.35000); ### 查询以观察结果 ```sql -taos> select start, wend, max_current from current_stream_output_stb; - start | wend | max_current | +taos> select wstart, wend, max_current from current_stream_output_stb; + wstart | wend | max_current | =========================================================================== 2018-10-03 14:38:05.000 | 2018-10-03 14:38:10.000 | 10.30000 | 2018-10-03 14:38:15.000 | 2018-10-03 14:38:20.000 | 12.60000 | @@ -89,7 +89,7 @@ Query OK, 2 rows in database (0.018762s) ### 创建流 ```sql -create stream power_stream into power_stream_output_stb as select ts, concat_ws(".", location, tbname) as meter_location, current*voltage*cos(phase) as active_power, current*voltage*sin(phase) as reactive_power from meters partition by tbname; +create stream power_stream trigger at_once into power_stream_output_stb as select ts, concat_ws(".", location, tbname) as meter_location, current*voltage*cos(phase) as active_power, current*voltage*sin(phase) as reactive_power from meters partition by tbname; ``` ### 写入数据 diff --git a/docs/zh/07-develop/07-tmq.mdx b/docs/zh/07-develop/07-tmq.mdx index 1d834cfff020ce782d4821cfc055c0cff08b4584..036c9aa86e5c91903a74bffd1f9c59a13a97c116 100644 --- a/docs/zh/07-develop/07-tmq.mdx +++ b/docs/zh/07-develop/07-tmq.mdx @@ -25,6 +25,7 @@ import CDemo from "./_sub_c.mdx"; 本文档不对消息队列本身的基础知识做介绍,如果需要了解,请自行搜索。 +注意:默认是从wal消费数据,如果wal被删除,消费到的数据会不全,此时可以将参数 experimental.snapshot.enable 设置为true,从tsdb获取全部数据,但是这样的话就不能保证数据的消费顺序。所以建议根据自己的消费情况合理的设置wal的保留策略,保证可以从wal里订阅到全部数据。 ## 主要数据结构和 API 不同语言下, TMQ 订阅相关的 API 及数据结构如下: @@ -283,18 +284,17 @@ CREATE TOPIC topic_name AS DATABASE db_name; | 参数名称 | 类型 | 参数说明 | 备注 | | :----------------------------: | :-----: | -------------------------------------------------------- | ------------------------------------------- | -| `td.connect.ip` | string | 用于创建连接,同 `taos_connect` | | -| `td.connect.user` | string | 用于创建连接,同 `taos_connect` | | -| `td.connect.pass` | string | 用于创建连接,同 `taos_connect` | | -| `td.connect.port` | integer | 用于创建连接,同 `taos_connect` | | +| `td.connect.ip` | string | 用于创建连接,同 `taos_connect` | 仅用于建立原生连接 | +| `td.connect.user` | string | 用于创建连接,同 `taos_connect` | 仅用于建立原生连接 | +| `td.connect.pass` | string | 用于创建连接,同 `taos_connect` | 仅用于建立原生连接 | +| `td.connect.port` | integer | 用于创建连接,同 `taos_connect` | 仅用于建立原生连接 | | `group.id` | string | 消费组 ID,同一消费组共享消费进度 | **必填项**。最大长度:192。 | | `client.id` | string | 客户端 ID | 最大长度:192。 | | `auto.offset.reset` | enum | 消费组订阅的初始位置 |
`earliest`: default;从头开始订阅;
`latest`: 仅从最新数据开始订阅;
`none`: 没有提交的 offset 无法订阅 | -| `enable.auto.commit` | boolean | 是否启用消费位点自动提交 | 合法值:`true`, `false`。 | -| `auto.commit.interval.ms` | integer | 以毫秒为单位的消费记录自动提交消费位点时间间隔 | 默认 5000 m | -| `enable.heartbeat.background` | boolean | 启用后台心跳,启用后即使长时间不 poll 消息也不会造成离线 | 默认开启 | -| `experimental.snapshot.enable` | boolean | 是否允许从 TSDB 消费数据 | 实验功能,默认关闭 | -| `msg.with.table.name` | boolean | 是否允许从消息中解析表名, 不适用于列订阅(列订阅时可将 tbname 作为列写入 subquery 语句) | | +| `enable.auto.commit` | boolean | 是否启用消费位点自动提交,true: 自动提交,客户端应用无需commit;false:客户端应用需要自行commit | 默认值为 true | +| `auto.commit.interval.ms` | integer | 消费记录自动提交消费位点时间间隔,单位为毫秒 | 默认值为 5000 | +| `experimental.snapshot.enable` | boolean | 是否允许从 TSDB 消费数据。当其关闭时,只能消费依据 WAL 保留策略仍然在WAL中的数据;当其打开时,除WAL中的数据以外,也能够消费已经从WAL中删除但落盘到TSDB中的数据 | 实验功能,默认关闭 | +| `msg.with.table.name` | boolean | 是否允许从消息中解析表名, 不适用于列订阅(列订阅时可将 tbname 作为列写入 subquery 语句) |默认关闭 | 对于不同编程语言,其设置方式如下: @@ -367,7 +367,6 @@ conf := &tmq.ConfigMap{ "td.connect.port": "6030", "client.id": "test_tmq_c", "enable.auto.commit": "false", - "enable.heartbeat.background": "true", "experimental.snapshot.enable": "true", "msg.with.table.name": "true", } @@ -419,7 +418,6 @@ consumer = Consumer({"group.id": "local", "td.connect.ip": "127.0.0.1"}) | `auto.commit.interval.ms` | string | 以毫秒为单位的自动提交时间间隔 | 默认值:5000 ms | | `auto.offset.reset` | string | 消费组订阅的初始位置 | 可选:`earliest`(default), `latest`, `none` | | `experimental.snapshot.enable` | string | 是否允许从 TSDB 消费数据 | 合法值:`true`, `false` | -| `enable.heartbeat.background` | string | 启用后台心跳,启用后即使长时间不 poll 消息也不会造成离线 | 合法值:`true`, `false` | diff --git a/docs/zh/08-connector/14-java.mdx b/docs/zh/08-connector/14-java.mdx index 061475f51e0cf9c25ba09d670e9ceef0bd2bab71..d1c12583659e2f6dd2a63357669b92c3b1ff29b1 100644 --- a/docs/zh/08-connector/14-java.mdx +++ b/docs/zh/08-connector/14-java.mdx @@ -17,7 +17,7 @@ import TabItem from '@theme/TabItem'; - JDBC 原生连接:Java 应用在物理节点 1(pnode1)上使用 TSDBDriver 直接调用客户端驱动(libtaos.so 或 taos.dll)的 API 将写入和查询请求发送到位于物理节点 2(pnode2)上的 taosd 实例。 - JDBC REST 连接:Java 应用通过 RestfulDriver 将 SQL 封装成一个 REST 请求,发送给物理节点 2 的 REST 服务器(taosAdapter),通过 REST 服务器请求 taosd 并返回结果。 -使用 REST 连接,不依赖 TDengine 客户端驱动,可以跨平台,更加方便灵活,但性能比原生连接器低约 30%。 +使用 REST 连接,不依赖 TDengine 客户端驱动,可以跨平台,更加方便灵活。 :::info TDengine 的 JDBC 驱动实现尽可能与关系型数据库驱动保持一致,但 TDengine 与关系对象型数据库的使用场景和技术特征存在差异,所以`taos-jdbcdriver` 与传统的 JDBC driver 也存在一定差异。在使用时需要注意以下几点: @@ -728,7 +728,7 @@ consumer.close() 详情请参考:[数据订阅](../../../develop/tmq) -### 使用示例如下: +#### 完整示例 diff --git a/docs/zh/08-connector/20-go.mdx b/docs/zh/08-connector/20-go.mdx index 2aa1a58e49f34b412f12bd0d67586dc6e56cf0bc..fd6df992b530fdce4427e34ef8bc227f449eaac7 100644 --- a/docs/zh/08-connector/20-go.mdx +++ b/docs/zh/08-connector/20-go.mdx @@ -122,7 +122,7 @@ _taosSql_ 通过 cgo 实现了 Go 的 `database/sql/driver` 接口。只需要 使用 `taosSql` 作为 `driverName` 并且使用一个正确的 [DSN](#DSN) 作为 `dataSourceName`,DSN 支持的参数: -* configPath 指定 taos.cfg 目录 +* cfg 指定 taos.cfg 目录 示例: diff --git a/docs/zh/08-connector/30-python.mdx b/docs/zh/08-connector/30-python.mdx index b57f02ac80c8d8cee8577b1a1d33b22317d7bdef..5395610df3ce5535293f8017f5e14c403e9a8279 100644 --- a/docs/zh/08-connector/30-python.mdx +++ b/docs/zh/08-connector/30-python.mdx @@ -10,7 +10,9 @@ import TabItem from "@theme/TabItem"; `taospy` 是 TDengine 的官方 Python 连接器。`taospy` 提供了丰富的 API, 使得 Python 应用可以很方便地使用 TDengine。`taospy` 对 TDengine 的[原生接口](../cpp)和 [REST 接口](../rest-api)都进行了封装, 分别对应 `taospy` 包的 `taos` 模块 和 `taosrest` 模块。 除了对原生接口和 REST 接口的封装,`taospy` 还提供了符合 [Python 数据访问规范(PEP 249)](https://peps.python.org/pep-0249/) 的编程接口。这使得 `taospy` 和很多第三方工具集成变得简单,比如 [SQLAlchemy](https://www.sqlalchemy.org/) 和 [pandas](https://pandas.pydata.org/)。 -使用客户端驱动提供的原生接口直接与服务端建立的连接的方式下文中称为“原生连接”;使用 taosAdapter 提供的 REST 接口与服务端建立的连接的方式下文中称为“REST 连接”。 +`taos-ws-py` 是使用 WebSocket 方式连接 TDengine 的 Python 连接器包。可以选装。 + +使用客户端驱动提供的原生接口直接与服务端建立的连接的方式下文中称为“原生连接”;使用 taosAdapter 提供的 REST 接口或 WebSocket 接口与服务端建立的连接的方式下文中称为“REST 连接”或“WebSocket 连接”。 Python 连接器的源码托管在 [GitHub](https://github.com/taosdata/taos-connector-python)。 @@ -115,6 +117,15 @@ import taos import taosrest ``` + + + +对于 WebSocket 连接,只需验证是否能成功导入 `taosws` 模块。可在 Python 交互式 Shell 中输入: + +```python +import taosws +``` + @@ -183,6 +194,27 @@ curl -u root:taosdata http://:/rest/sql -d "select server_version()" } ``` + + + +对于 WebSocket 连接, 除了确保集群已经启动,还要确保 taosAdapter 组件已经启动。可以使用如下 curl 命令测试: + +``` +curl -i -N -d "show databases" -H "Authorization: Basic cm9vdDp0YW9zZGF0YQ==" -H "Connection: Upgrade" -H "Upgrade: websocket" -H "Host: :" -H "Origin: http://:" http://:/rest/sql +``` + +上面的 FQDN 为运行 taosAdapter 的机器的 FQDN, PORT 为 taosAdapter 配置的监听端口, 默认为 6041。 +如果测试成功,会输出服务器版本信息,比如: + +```json +HTTP/1.1 200 OK +Content-Type: application/json; charset=utf-8 +Date: Tue, 21 Mar 2023 09:29:17 GMT +Transfer-Encoding: chunked + +{"status":"succ","head":["server_version()"],"column_meta":[["server_version()",8,8]],"data":[["2.6.0.27"]],"rows":1} +``` +
@@ -321,6 +353,85 @@ TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线 +### 与 req_id 一起使用 + +使用可选的 req_id 参数,指定请求 id,可以用于 tracing + + + + +##### TaosConnection 类的使用 + +`TaosConnection` 类既包含对 PEP249 Connection 接口的实现(如:`cursor`方法和 `close` 方法),也包含很多扩展功能(如: `execute`、 `query`、`schemaless_insert` 和 `subscribe` 方法。 + +```python title="execute 方法" +{{#include docs/examples/python/connection_usage_native_reference_with_req_id.py:insert}} +``` + +```python title="query 方法" +{{#include docs/examples/python/connection_usage_native_reference_with_req_id.py:query}} +``` + +:::tip +查询结果只能获取一次。比如上面的示例中 `fetch_all()` 和 `fetch_all_into_dict()` 只能用一个。重复获取得到的结果为空列表。 +::: + +##### TaosResult 类的使用 + +上面 `TaosConnection` 类的使用示例中,我们已经展示了两种获取查询结果的方法: `fetch_all()` 和 `fetch_all_into_dict()`。除此之外 `TaosResult` 还提供了按行迭代(`rows_iter`)或按数据块迭代(`blocks_iter`)结果集的方法。在查询数据量较大的场景,使用这两个方法会更高效。 + +```python title="blocks_iter 方法" +{{#include docs/examples/python/result_set_with_req_id_examples.py}} +``` +##### TaosCursor 类的使用 + +`TaosConnection` 类和 `TaosResult` 类已经实现了原生接口的所有功能。如果你对 PEP249 规范中的接口比较熟悉也可以使用 `TaosCursor` 类提供的方法。 + +```python title="TaosCursor 的使用" +{{#include docs/examples/python/cursor_usage_native_reference_with_req_id.py}} +``` + +:::note +TaosCursor 类使用原生连接进行写入、查询操作。在客户端多线程的场景下,这个游标实例必须保持线程独享,不能跨线程共享使用,否则会导致返回结果出现错误。 + +::: + + + + +##### TaosRestCursor 类的使用 + +`TaosRestCursor` 类是对 PEP249 Cursor 接口的实现。 + +```python title="TaosRestCursor 的使用" +{{#include docs/examples/python/connect_rest_with_req_id_examples.py:basic}} +``` +- `cursor.execute` : 用来执行任意 SQL 语句。 +- `cursor.rowcount`: 对于写入操作返回写入成功记录数。对于查询操作,返回结果集行数。 +- `cursor.description` : 返回字段的描述信息。关于描述信息的具体格式请参考[TaosRestCursor](https://docs.taosdata.com/api/taospy/taosrest/cursor.html)。 + +##### RestClient 类的使用 + +`RestClient` 类是对于 [REST API](../rest-api) 的直接封装。它只包含一个 `sql()` 方法用于执行任意 SQL 语句, 并返回执行结果。 + +```python title="RestClient 的使用" +{{#include docs/examples/python/rest_client_with_req_id_example.py}} +``` + +对于 `sql()` 方法更详细的介绍, 请参考 [RestClient](https://docs.taosdata.com/api/taospy/taosrest/restclient.html)。 + + + +```python +{{#include docs/examples/python/connect_websocket_with_req_id_examples.py:basic}} +``` + +- `conn.execute`: 用来执行任意 SQL 语句,返回影响的行数 +- `conn.query`: 用来执行查询 SQL 语句,返回查询结果 + + + + ### 与 pandas 一起使用 diff --git a/docs/zh/08-connector/_linux_install.mdx b/docs/zh/08-connector/_linux_install.mdx index 0b1f415f54d28e65a519d35ab94a84b3aa8338ba..b16ab2ac5b0696ee8e4077706e80f6e4267faf1b 100644 --- a/docs/zh/08-connector/_linux_install.mdx +++ b/docs/zh/08-connector/_linux_install.mdx @@ -14,7 +14,7 @@ import PkgListV3 from "/components/PkgListV3"; 解压软件包之后,会在解压目录下看到以下文件(目录): - _ install_client.sh_:安装脚本,用于应用驱动程序 - - _ taos.tar.gz_:应用驱动安装包 + - _ package.tar.gz_:应用驱动安装包 - _ driver_:TDengine 应用驱动 driver - _examples_: 各种编程语言的示例程序(c/C#/go/JDBC/MATLAB/python/R) 运行 install_client.sh 进行安装。 diff --git a/docs/zh/12-taos-sql/02-database.md b/docs/zh/12-taos-sql/02-database.md index 91ba8fdbfdefe37d0eb42a35ec9bec367cb507df..b54998e08d33869d113ae883b14f929e5381f168 100644 --- a/docs/zh/12-taos-sql/02-database.md +++ b/docs/zh/12-taos-sql/02-database.md @@ -35,8 +35,8 @@ database_option: { | TABLE_SUFFIX value | TSDB_PAGESIZE value | WAL_RETENTION_PERIOD value - | WAL_ROLL_PERIOD value | WAL_RETENTION_SIZE value + | WAL_ROLL_PERIOD value | WAL_SEGMENT_SIZE value } ``` @@ -75,11 +75,10 @@ database_option: { - TABLE_PREFIX:内部存储引擎根据表名分配存储该表数据的 VNODE 时要忽略的前缀的长度。 - TABLE_SUFFIX:内部存储引擎根据表名分配存储该表数据的 VNODE 时要忽略的后缀的长度。 - TSDB_PAGESIZE:一个 VNODE 中时序数据存储引擎的页大小,单位为 KB,默认为 4 KB。范围为 1 到 16384,即 1 KB到 16 MB。 -- WAL_RETENTION_PERIOD:数据订阅已消费WAL日志,WAL文件的最大额外保留的时长策略。单位为 s。默认为 0,表示无需额外保留。-1, 表示额外保留,时间无上限。 -- WAL_RETENTION_SIZE:数据订阅已消费WAL日志,WAL文件的最大额外保留的累计大小策略。单位为 KB。默认为 0,表示无需额外保留。-1, 表示额外保留,累计大小无上限。 +- WAL_RETENTION_PERIOD: 为了数据订阅消费,需要WAL日志文件额外保留的最大时长策略。WAL日志清理,不受订阅客户端消费状态影响。单位为 s。默认为 0,表示无需为订阅保留。新建订阅,应先设置恰当的时长策略。 +- WAL_RETENTION_SIZE:为了数据订阅消费,需要WAL日志文件额外保留的最大累计大小策略。单位为 KB。默认为 0,表示累计大小无上限。 - WAL_ROLL_PERIOD:wal 文件切换时长,单位为 s。当WAL文件创建并写入后,经过该时间,会自动创建一个新的WAL文件。默认为 0,即仅在TSDB落盘时创建新文件。 - WAL_SEGMENT_SIZE:wal 单个文件大小,单位为 KB。当前写入文件大小超过上限后会自动创建一个新的WAL文件。默认为 0,即仅在TSDB落盘时创建新文件。 - ### 创建数据库示例 ```sql @@ -179,6 +178,14 @@ TRIM DATABASE db_name; 删除过期数据,并根据多级存储的配置归整数据。 +## 落盘内存数据 + +```sql +FLUSH DATABASE db_name; +``` + +落盘内存中的数据。在关闭节点之前,执行这条命令可以避免重启后的数据回放,加速启动过程。 + ## 调整VGROUP中VNODE的分布 ```sql diff --git a/docs/zh/12-taos-sql/04-stable.md b/docs/zh/12-taos-sql/04-stable.md index c5933228decfb3eb865cad058fa6fbba77fefb58..74ef52ee7c53d6c619a47d7e6453b56f152104a2 100644 --- a/docs/zh/12-taos-sql/04-stable.md +++ b/docs/zh/12-taos-sql/04-stable.md @@ -13,12 +13,11 @@ create_definition: col_name column_definition column_definition: - type_name [COMMENT 'string_value'] + type_name ``` **使用说明** - 超级表中列的最大个数为 4096,需要注意,这里的 4096 是包含 TAG 列在内的,最小个数为 3,包含一个时间戳主键、一个 TAG 列和一个数据列。 -- 建表时可以给列或标签附加注释。 - TAGS语法指定超级表的标签列,标签列需要遵循以下约定: - TAGS 中的 TIMESTAMP 列写入数据时需要提供给定值,而暂不支持四则运算,例如 NOW + 10s 这类表达式。 - TAGS 列名不能与其他列名相同。 diff --git a/docs/zh/12-taos-sql/06-select.md b/docs/zh/12-taos-sql/06-select.md index dcc085b3bd714116455badbdc268c41b717b818f..e4ba5b76e487e2ac739d0797a32f2a6a04d849e3 100644 --- a/docs/zh/12-taos-sql/06-select.md +++ b/docs/zh/12-taos-sql/06-select.md @@ -248,11 +248,11 @@ NULLS 语法用来指定 NULL 值在排序中输出的位置。NULLS LAST 是升 LIMIT 控制输出条数,OFFSET 指定从第几条之后开始输出。LIMIT/OFFSET 对结果集的执行顺序在 ORDER BY 之后。LIMIT 5 OFFSET 2 可以简写为 LIMIT 2, 5,都输出第 3 行到第 7 行数据。 -在有 PARTITION BY 子句时,LIMIT 控制的是每个切分的分片中的输出,而不是总的结果集输出。 +在有 PARTITION BY/GROUP BY 子句时,LIMIT 控制的是每个切分的分片中的输出,而不是总的结果集输出。 ## SLIMIT -SLIMIT 和 PARTITION BY 子句一起使用,用来控制输出的分片的数量。SLIMIT 5 SOFFSET 2 可以简写为 SLIMIT 2, 5,都表示输出第 3 个到第 7 个分片。 +SLIMIT 和 PARTITION BY/GROUP BY 子句一起使用,用来控制输出的分片的数量。SLIMIT 5 SOFFSET 2 可以简写为 SLIMIT 2, 5,都表示输出第 3 个到第 7 个分片。 需要注意,如果有 ORDER BY 子句,则输出只有一个分片。 diff --git a/docs/zh/12-taos-sql/12-distinguished.md b/docs/zh/12-taos-sql/12-distinguished.md index 9ef6a7f1ce12069dfd3bf0f27d00e412d0b4d32b..f750124049c5b0dabecb359fe8c1b9d28ca1f431 100644 --- a/docs/zh/12-taos-sql/12-distinguished.md +++ b/docs/zh/12-taos-sql/12-distinguished.md @@ -163,7 +163,7 @@ SELECT COUNT(*), FIRST(ts) FROM temp_tb_1 SESSION(ts, tol_val); 以下面的 SQL 语句为例,事件窗口切分如图所示: ```sql -select _wstart, _wend, count(*) from t start with c1 > 0 end with c2 < 10 +select _wstart, _wend, count(*) from t event_window start with c1 > 0 end with c2 < 10 ``` ![TDengine Database 事件窗口示意图](./event_window.webp) diff --git a/docs/zh/12-taos-sql/14-stream.md b/docs/zh/12-taos-sql/14-stream.md index 9e2fde526e1e63e3fbfb6124420caee3491cf965..f10077345f394936d3df4eccf8811fc67f862c15 100644 --- a/docs/zh/12-taos-sql/14-stream.md +++ b/docs/zh/12-taos-sql/14-stream.md @@ -8,7 +8,7 @@ description: 流式计算的相关 SQL 的详细语法 ## 创建流式计算 ```sql -CREATE STREAM [IF NOT EXISTS] stream_name [stream_options] INTO stb_name SUBTABLE(expression) AS subquery +CREATE STREAM [IF NOT EXISTS] stream_name [stream_options] INTO stb_name[(field1_name, ...)] [TAGS (create_definition [, create_definition] ...)] SUBTABLE(expression) AS subquery stream_options: { TRIGGER [AT_ONCE | WINDOW_CLOSE | MAX_DELAY time] WATERMARK time @@ -28,6 +28,15 @@ subquery: SELECT select_list 支持会话窗口、状态窗口与滑动窗口,其中,会话窗口与状态窗口搭配超级表时必须与partition by tbname一起使用 +stb_name 是保存计算结果的超级表的表名,如果该超级表不存在,会自动创建;如果已存在,则检查列的schema信息。详见 写入已存在的超级表 + +TAGS 字句定义了流计算中创建TAG的规则,可以为每个partition对应的子表生成自定义的TAG值,详见 自定义TAG +```sql +create_definition: + col_name column_definition +column_definition: + type_name [COMMENT 'string_value'] +``` subtable 子句定义了流式计算中创建的子表的命名规则,详见 流式计算的 partition 部分。 @@ -114,7 +123,7 @@ SELECT * from information_schema.`ins_streams`; 在创建流时,可以通过 TRIGGER 指令指定流式计算的触发模式。 -对于非窗口计算,流式计算的触发是实时的;对于窗口计算,目前提供 3 种触发模式,默认为 AT_ONCE: +对于非窗口计算,流式计算的触发是实时的;对于窗口计算,目前提供 3 种触发模式,默认为 WINDOW_CLOSE: 1. AT_ONCE:写入立即触发 @@ -163,9 +172,33 @@ T3 时刻,最新事件到达,T 向后推移超过了第二个窗口关闭的 TDengine 对于过期数据提供两种处理方式,由 IGNORE EXPIRED 选项指定: -1. 重新计算,即 IGNORE EXPIRED 0:默认配置,从 TSDB 中重新查找对应窗口的所有数据并重新计算得到最新结果 +1. 重新计算,即 IGNORE EXPIRED 0:从 TSDB 中重新查找对应窗口的所有数据并重新计算得到最新结果 -2. 直接丢弃, 即 IGNORE EXPIRED 1:忽略过期数据 +2. 直接丢弃, 即 IGNORE EXPIRED 1:默认配置,忽略过期数据 无论在哪种模式下,watermark 都应该被妥善设置,来得到正确结果(直接丢弃模式)或避免频繁触发重算带来的性能开销(重新计算模式)。 + +## 写入已存在的超级表 +```sql +[field1_name,...] +``` +用来指定stb_name的列与subquery输出结果的对应关系。如果stb_name的列与subquery输出结果的位置、数量全部匹配,则不需要显示指定对应关系。如果stb_name的列与subquery输出结果的数据类型不匹配,会把subquery输出结果的类型转换成对应的stb_name的列的类型。 + +对于已经存在的超级表,检查列的schema信息 +1. 检查列的schema信息是否匹配,对于不匹配的,则自动进行类型转换,当前只有数据长度大于4096byte时才报错,其余场景都能进行类型转换。 +2. 检查列的个数是否相同,如果不同,需要显示的指定超级表与subquery的列的对应关系,否则报错;如果相同,可以指定对应关系,也可以不指定,不指定则按位置顺序对应。 +3. 至少自定义一个tag,否则报错。详见 自定义TAG + +## 自定义TAG + +用户可以为每个 partition 对应的子表生成自定义的TAG值。 +```sql +CREATE STREAM streams2 trigger at_once INTO st1 TAGS(cc varchar(100)) as select _wstart, count(*) c1 from st partition by concat("tag-", tbname) as cc interval(10s)); +``` + +PARTITION 子句中,为 concat("tag-", tbname)定义了一个别名cc, 对应超级表st1的自定义TAG的名字。在上述示例中,流新创建的子表的TAG将以前缀 'new-' 连接原表名作为TAG的值。 + +会对TAG信息进行如下检查 +1.检查tag的schema信息是否匹配,对于不匹配的,则自动进行数据类型转换,当前只有数据长度大于4096byte时才报错,其余场景都能进行类型转换。 +2.检查tag的个数是否相同,如果不同,需要显示的指定超级表与subquery的tag的对应关系,否则报错;如果相同,可以指定对应关系,也可以不指定,不指定则按位置顺序对应。 diff --git a/docs/zh/12-taos-sql/20-keywords.md b/docs/zh/12-taos-sql/20-keywords.md index 8fd704ef551c9ebda61678bd129917e67cbfbef8..d416febd55521853812fbe6952d403f4d265ac4e 100644 --- a/docs/zh/12-taos-sql/20-keywords.md +++ b/docs/zh/12-taos-sql/20-keywords.md @@ -269,7 +269,7 @@ description: TDengine 保留关键字的详细列表 - SPLIT - STABLE - STABLES -- STAR +- START - STATE - STATE_WINDOW - STATEMENT diff --git a/docs/zh/12-taos-sql/24-show.md b/docs/zh/12-taos-sql/24-show.md index 5348233d5af20f0bb65360775e7c6497beb62f21..c85efa2376f3f3d78b2775a6e1408a307b212607 100644 --- a/docs/zh/12-taos-sql/24-show.md +++ b/docs/zh/12-taos-sql/24-show.md @@ -253,8 +253,9 @@ Query OK, 24 row(s) in set (0.002444s) - 上面是块中包含数据行数的块儿分布情况图,这里的 0100 0299 0498 … 表示的是每个块中包含的数据行数,上面的意思就是这个表的 5 个块,分布在 3483 ~3681 行的块有 1 个,占整个块的 20%,分布在 3881 ~ 4096(最大行数)的块数为 4 个,占整个块的 80%, 其它区域内分布块数为 0。 +上面是块中包含数据行数的块儿分布情况图,这里的 0100 0299 0498 … 表示的是每个块中包含的数据行数,上面的意思就是这个表的 5 个块,分布在 3483 ~3681 行的块有 1 个,占整个块的 20%,分布在 3881 ~ 4096(最大行数)的块数为 4 个,占整个块的 80%, 其它区域内分布块数为 0。 +需要注意,这里只会显示 data 文件中数据块的信息,stt 文件中的数据的信息不会被显示。 ## SHOW TAGS diff --git a/docs/zh/12-taos-sql/29-changes.md b/docs/zh/12-taos-sql/29-changes.md index 9d67533cdea5c055c8d3ff58000fb80ac640e271..73fa15313b183d3731592f6c3e84e8f01e581301 100644 --- a/docs/zh/12-taos-sql/29-changes.md +++ b/docs/zh/12-taos-sql/29-changes.md @@ -27,7 +27,7 @@ description: "TDengine 3.0 版本的语法变更说明" | - | :------- | :-------- | :------- | | 1 | ALTER ACCOUNT | 废除 | 2.x中为企业版功能,3.0不再支持。语法暂时保留了,执行报“This statement is no longer supported”错误。 | 2 | ALTER ALL DNODES | 新增 | 修改所有DNODE的参数。 -| 3 | ALTER DATABASE | 调整 | 废除 +| 3 | ALTER DATABASE | 调整 | 废除 | 4 | ALTER STABLE | 调整 | 废除 | 5 | ALTER TABLE | 调整 | 废除 | 6 | ALTER USER | 调整 | 废除 diff --git a/docs/zh/14-reference/07-tdinsight/index.mdx b/docs/zh/14-reference/07-tdinsight/index.mdx index 8783d47f001249ea74a6f11a7f2709ae318152a0..b4eda61ebdb4f6ab9b8b650571a35196c76eda56 100644 --- a/docs/zh/14-reference/07-tdinsight/index.mdx +++ b/docs/zh/14-reference/07-tdinsight/index.mdx @@ -43,8 +43,6 @@ sudo apt-get update sudo apt-get install grafana ``` -### 在 CentOS / RHEL 上安装 Grafana - @@ -79,7 +77,37 @@ sudo yum install \ - +### 安装 TDengine 数据源插件 + + + + +从 GitHub 安装 TDengine 最新版数据源插件。 + +```bash +get_latest_release() { + curl --silent "https://api.github.com/repos/taosdata/grafanaplugin/releases/latest" | + grep '"tag_name":' | + sed -E 's/.*"v([^"]+)".*/\1/' +} +TDENGINE_PLUGIN_VERSION=$(get_latest_release) +sudo grafana-cli \ + --pluginUrl https://github.com/taosdata/grafanaplugin/releases/download/v$TDENGINE_PLUGIN_VERSION/tdengine-datasource-$TDENGINE_PLUGIN_VERSION.zip \ + plugins install tdengine-datasource +``` + +:::note +3.1.6 和更早版本插件需要在配置文件 `/etc/grafana/grafana.ini` 中添加如下设置,以启用未签名插件。 + +```ini +[plugins] +allow_loading_unsigned_plugins = tdengine-datasource +``` + +::: + + + 我们提供了一个自动化安装脚本 [`TDinsight.sh`](https://github.com/taosdata/grafanaplugin/releases/latest/download/TDinsight.sh) 脚本以便用户快速进行安装配置。 @@ -175,33 +203,7 @@ sudo ./TDengine.sh -n TDengine-Env1 -a http://another:6041 -u root -p taosdata - 特别地,当您使用 Grafana Cloud 或其他组织时,`-O` 可用于设置组织 ID。 `-G` 可指定 Grafana 插件安装目录。 `-e` 参数将仪表盘设置为可编辑。 - - -### 安装 TDengine 数据源插件 - -从 GitHub 安装 TDengine 最新版数据源插件。 - -```bash -get_latest_release() { - curl --silent "https://api.github.com/repos/taosdata/grafanaplugin/releases/latest" | - grep '"tag_name":' | - sed -E 's/.*"v([^"]+)".*/\1/' -} -TDENGINE_PLUGIN_VERSION=$(get_latest_release) -sudo grafana-cli \ - --pluginUrl https://github.com/taosdata/grafanaplugin/releases/download/v$TDENGINE_PLUGIN_VERSION/tdengine-datasource-$TDENGINE_PLUGIN_VERSION.zip \ - plugins install tdengine-datasource -``` - -:::note -3.1.6 和更早版本插件需要在配置文件 `/etc/grafana/grafana.ini` 中添加如下设置,以启用未签名插件。 - -```ini -[plugins] -allow_loading_unsigned_plugins = tdengine-datasource -``` - -::: + ### 启动 Grafana 服务 @@ -233,8 +235,7 @@ sudo systemctl enable grafana-server ![TDengine Database TDinsight 数据源测试](./assets/howto-add-datasource-test.webp) - - + ### 导入仪表盘 diff --git a/docs/zh/14-reference/12-config/index.md b/docs/zh/14-reference/12-config/index.md index 6eeb577ab597baf7d7547d15a5048018ee8ef497..e5efd77f8050ae2305a02a5bd70367d259cb971c 100644 --- a/docs/zh/14-reference/12-config/index.md +++ b/docs/zh/14-reference/12-config/index.md @@ -99,6 +99,9 @@ taos --dump-config ## 监控相关 +:::note +请注意,完整的监控功能需要安装并运行 `taoskeeper` 服务。taoskeeper 负责接收监控指标数据并创建 `log` 库。 + ### monitor | 属性 | 说明 | diff --git a/docs/zh/14-reference/14-taosKeeper.md b/docs/zh/14-reference/14-taosKeeper.md index ac0c8754b5a200ec571c956dc0308df6c1b026a3..12b609584a65d729c93e256b3918bd04d03e2010 100644 --- a/docs/zh/14-reference/14-taosKeeper.md +++ b/docs/zh/14-reference/14-taosKeeper.md @@ -4,23 +4,25 @@ title: taosKeeper description: TDengine 3.0 版本监控指标的导出工具 --- +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; + ## 简介 taosKeeper 是 TDengine 3.0 版本监控指标的导出工具,通过简单的几项配置即可获取 TDengine 的运行状态。taosKeeper 使用 TDengine RESTful 接口,所以不需要安装 TDengine 客户端即可使用。 ## 安装 - +taosKeeper 有两种安装方式: taosKeeper 安装方式: - +- 安装 TDengine 官方安装包的同时会自动安装 taosKeeper, 详情请参考[ TDengine 安装](/operation/pkg-install)。 - - 单独编译 taosKeeper 并安装,详情请参考 [taosKeeper](https://github.com/taosdata/taoskeeper) 仓库。 -## 运行 +## 配置和运行方式 -### 配置和运行方式 +### 配置 taosKeeper 需要在操作系统终端执行,该工具支持三种配置方式:[命令行参数](#命令行参数启动)、[环境变量](#环境变量启动) 和 [配置文件](#配置文件启动)。优先级为:命令行参数、环境变量、配置文件参数。 @@ -34,29 +36,82 @@ monitorFqdn localhost # taoskeeper 服务的 FQDN TDengine 监控配置相关,具体请参考:[TDengine 监控配置](../config/#监控相关)。 -### 命令行参数启动 +### 启动 -在使用命令行参数运行 taosKeeper 并控制其行为。 + + -```shell -$ taosKeeper +安装后,请使用 `systemctl` 命令来启动 taoskeeper 的服务进程。 + +```bash +systemctl start taoskeeper ``` -### 环境变量启动 +检查服务是否正常工作: -通过设置环境变量达到控制启动参数的目的,通常在容器中运行时使用。 +```bash +systemctl status taoskeeper +``` + +如果服务进程处于活动状态,则 status 指令会显示如下的相关信息: + +``` +Active: active (running) +``` + +如果后台服务进程处于停止状态,则 status 指令会显示如下的相关信息: -```shell -$ export TAOS_KEEPER_TDENGINE_HOST=192.168.64.3 - -$ taoskeeper ``` +Active: inactive (dead) +``` + +如下 `systemctl` 命令可以帮助你管理 taoskeeper 服务: + +- 启动服务进程:`systemctl start taoskeeper` + +- 停止服务进程:`systemctl stop taoskeeper` + +- 重启服务进程:`systemctl restart taoskeeper` + +- 查看服务状态:`systemctl status taoskeeper` + +:::info + +- `systemctl` 命令需要 _root_ 权限来运行,如果您非 _root_ 用户,请在命令前添加 `sudo`。 +- 如果系统中不支持 `systemd`,也可以用手动运行 `/usr/local/taos/bin/taoskeeper` 方式启动 taoskeeper 服务。 +- 故障排查: +- 如果服务异常请查看系统日志获取更多信息。 +::: + + + -具体参数列表请参照 `taoskeeper -h` 输入结果。 +安装后,可以运行 `sudo launchctl start com.tdengine.taoskeeper` 来启动 taoskeeper 服务进程。 -### 配置文件启动 +如下 `launchctl` 命令用于管理 taoskeeper 服务: -执行以下命令即可快速体验 taosKeeper。当不指定 taosKeeper 配置文件时,优先使用 `/etc/taos/keeper.toml` 配置,否则将使用默认配置。 +- 启动服务进程:`sudo launchctl start com.tdengine.taoskeeper` + +- 停止服务进程:`sudo launchctl stop com.tdengine.taoskeeper` + +- 查看服务状态:`sudo launchctl list | grep taoskeeper` + +:::info + +- `launchctl` 命令管理`com.tdengine.taoskeeper`需要管理员权限,务必在前面加 `sudo` 来增强安全性。 +- `sudo launchctl list | grep taoskeeper` 指令返回的第一列是 `taoskeeper` 程序的 PID,若为 `-` 则说明 taoskeeper 服务未运行。 +- 故障排查: +- 如果服务异常请查看系统日志获取更多信息。 + +::: + + + + + +#### 配置文件启动 + +执行以下命令即可快速体验 taosKeeper。当不指定 taosKeeper 配置文件时,优先使用 `/etc/taos/keeper.toml` 配置,否则将使用默认配置。 ```shell $ taoskeeper -c @@ -134,19 +189,36 @@ $ curl http://127.0.0.1:6043/metrics 部分结果集: ```shell -# HELP taos_cluster_info_connections_total +# HELP taos_cluster_info_connections_total # TYPE taos_cluster_info_connections_total counter taos_cluster_info_connections_total{cluster_id="5981392874047724755"} 16 -# HELP taos_cluster_info_dbs_total +# HELP taos_cluster_info_dbs_total # TYPE taos_cluster_info_dbs_total counter taos_cluster_info_dbs_total{cluster_id="5981392874047724755"} 2 -# HELP taos_cluster_info_dnodes_alive +# HELP taos_cluster_info_dnodes_alive # TYPE taos_cluster_info_dnodes_alive counter taos_cluster_info_dnodes_alive{cluster_id="5981392874047724755"} 1 -# HELP taos_cluster_info_dnodes_total +# HELP taos_cluster_info_dnodes_total # TYPE taos_cluster_info_dnodes_total counter taos_cluster_info_dnodes_total{cluster_id="5981392874047724755"} 1 -# HELP taos_cluster_info_first_ep +# HELP taos_cluster_info_first_ep # TYPE taos_cluster_info_first_ep gauge taos_cluster_info_first_ep{cluster_id="5981392874047724755",value="hlb:6030"} 1 ``` + +### check_health + +``` +$ curl -i http://127.0.0.1:6043/check_health +``` + +返回结果: + +``` +HTTP/1.1 200 OK +Content-Type: application/json; charset=utf-8 +Date: Mon, 03 Apr 2023 07:20:38 GMT +Content-Length: 19 + +{"version":"1.0.0"} +``` diff --git a/docs/zh/17-operation/01-pkg-install.md b/docs/zh/17-operation/01-pkg-install.md index 6d93c1697b1e0936b3f6539d3b1fb95db0baa956..6272c14db79537dd65c93e424097b9c31e88ddb9 100644 --- a/docs/zh/17-operation/01-pkg-install.md +++ b/docs/zh/17-operation/01-pkg-install.md @@ -141,8 +141,20 @@ taos tools is uninstalled successfully! ``` + 在 C:\TDengine 目录下,通过运行 unins000.exe 卸载程序来卸载 TDengine。 + + + + +卸载 TDengine 命令如下: + +``` +$ rmtaos +TDengine is removed successfully! +``` + diff --git a/docs/zh/17-operation/03-tolerance.md b/docs/zh/17-operation/03-tolerance.md index 79cf10c39a7028e04e7c1ebbea54738dcdc528af..bf2a651c1a9a68411a2348eccda7e0e44db75214 100644 --- a/docs/zh/17-operation/03-tolerance.md +++ b/docs/zh/17-operation/03-tolerance.md @@ -19,12 +19,8 @@ TDengine 接收到应用的请求数据包时,先将请求的原始数据包 ## 灾备 -TDengine 的集群通过多个副本的机制,来提供系统的高可用性,同时具备一定的灾备能力。 +TDengine 灾备是通过在异地的两个数据中心中设置两个 TDengine 集群并利用 taosX 的数据复制能力来实现的。假定两个集群为集群 A 和集群 B,其中集群 A 为源集群,承担写入请求并提供查询服务。则在集群 A 所在数据中心中可以配置 taosX 利用 TDengine 提供的数据订阅能力,实时消费集群 A 中新写入的数据,并同步到集群 B。如果发生了灾难导致集群 A 所在数据中心不可用,则可以启用集群 B 作为数据写入和查询的主节点,并在集群 B 所处数据中心中配置 taosX 将数据复制到已经恢复的集群 A 或者新建的集群 C。 -TDengine 集群是由 mnode 负责管理的,为保证 mnode 的高可靠,可以配置 三个 mnode 副本。为保证元数据的强一致性,mnode 副本之间通过同步方式进行数据复制,保证了元数据的强一致性。 +利用 taosX 的数据复制能力也可以构造出更复杂的灾备方案。 -TDengine 集群中的时序数据的副本数是与数据库关联的,一个集群里可以有多个数据库,每个数据库可以配置不同的副本数。创建数据库时,通过参数 replica 指定副本数。为了支持高可靠,需要设置副本数为 3。 - -TDengine 集群的节点数必须大于等于副本数,否则创建表时将报错。 - -当 TDengine 集群中的节点部署在不同的物理机上,并设置多个副本数时,就实现了系统的高可靠性,无需再使用其他软件或工具。TDengine 企业版还可以将副本部署在不同机房,从而实现异地容灾。 +taosX 只在 TDengine 企业版中提供,关于其具体细节,请联系 business@taosdata.com diff --git a/docs/zh/20-third-party/01-grafana.mdx b/docs/zh/20-third-party/01-grafana.mdx index 5927dc4fcacc0b947e3a4c44778d9d5979bfc196..7980736a1c62150df1c2742c788aabde9b1dbc3b 100644 --- a/docs/zh/20-third-party/01-grafana.mdx +++ b/docs/zh/20-third-party/01-grafana.mdx @@ -77,7 +77,7 @@ sudo -u grafana grafana-cli plugins install tdengine-datasource 或者从 [GitHub](https://github.com/taosdata/grafanaplugin/releases/tag/latest) 或 [Grafana](https://grafana.com/grafana/plugins/tdengine-datasource/?tab=installation) 下载 .zip 文件到本地并解压到 Grafana 插件目录。命令行下载示例如下: ```bash -GF_VERSION=3.2.9 +GF_VERSION=3.3.1 # from GitHub wget https://github.com/taosdata/grafanaplugin/releases/download/v$GF_VERSION/tdengine-datasource-$GF_VERSION.zip # from Grafana diff --git a/docs/zh/28-releases/01-tdengine.md b/docs/zh/28-releases/01-tdengine.md index 5c8c5edd0519764ec893b551a2dfc934ad44e5c4..b4441ad078059f51d8632e0db9c8007db9eb804e 100644 --- a/docs/zh/28-releases/01-tdengine.md +++ b/docs/zh/28-releases/01-tdengine.md @@ -10,6 +10,14 @@ TDengine 2.x 各版本安装包请访问[这里](https://www.taosdata.com/all-do import Release from "/components/ReleaseV3"; +## 3.0.3.2 + + + +## 3.0.3.1 + + + ## 3.0.3.0 diff --git a/docs/zh/28-releases/02-tools.md b/docs/zh/28-releases/02-tools.md index a9c9ea5ac7d153df6353ffebf59c77b7a5c5867b..cce6834f12af02568632949bde044b81ea718808 100644 --- a/docs/zh/28-releases/02-tools.md +++ b/docs/zh/28-releases/02-tools.md @@ -10,6 +10,14 @@ taosTools 各版本安装包下载链接如下: import Release from "/components/ReleaseV3"; +## 2.4.11 + + + +## 2.4.10 + + + ## 2.4.9 diff --git a/examples/JDBC/taosdemo/pom.xml b/examples/JDBC/taosdemo/pom.xml index 68224bbad5f719b74ff7ed103d4024985bbb2887..4731d8e2370687a0fce0cb68d09ff4948266c30b 100644 --- a/examples/JDBC/taosdemo/pom.xml +++ b/examples/JDBC/taosdemo/pom.xml @@ -10,7 +10,7 @@ Demo project for TDengine - 5.3.20 + 5.3.26 diff --git a/examples/lua/OpenResty/rest/tdpool/init.lua b/examples/lua/OpenResty/rest/tdpool/init.lua index ebf8e91756539cc8af5db38232a40bf42aeaa245..c0c6d5659013b4a4586c286741a20867fafd9c9f 100644 --- a/examples/lua/OpenResty/rest/tdpool/init.lua +++ b/examples/lua/OpenResty/rest/tdpool/init.lua @@ -1,16 +1,15 @@ local _M = {} local driver = require "luaconnector51" -local water_mark = 0 -local occupied = 0 -local connection_pool = {} +td_pool_watermark = 0 +td_pool_occupied = 0 +td_connection_pool = {} -function _M.new(o,config) +function _M.new(o, config) o = o or {} - o.connection_pool = connection_pool - o.water_mark = water_mark - o.occupied = occupied - if #connection_pool == 0 then - + o.connection_pool = td_connection_pool + o.watermark = td_pool_watermark + o.occupied = td_pool_occupied + if #td_connection_pool == 0 then for i = 1, config.connection_pool_size do local res = driver.connect(config) if res.code ~= 0 then @@ -18,8 +17,8 @@ function _M.new(o,config) return nil else local object = {obj = res.conn, state = 0} - table.insert(o.connection_pool,i, object) - ngx.log(ngx.INFO, "add connection, now pool size:"..#(o.connection_pool)) + table.insert(td_connection_pool, i, object) + ngx.log(ngx.INFO, "add connection, now pool size:"..#(td_connection_pool)) end end @@ -32,13 +31,13 @@ function _M:get_connection() local connection_obj - for i = 1, #connection_pool do - connection_obj = connection_pool[i] + for i = 1, #td_connection_pool do + connection_obj = td_connection_pool[i] if connection_obj.state == 0 then connection_obj.state = 1 - occupied = occupied +1 - if occupied > water_mark then - water_mark = occupied + td_pool_occupied = td_pool_occupied + 1 + if td_pool_occupied > td_pool_watermark then + td_pool_watermark = td_pool_occupied end return connection_obj["obj"] end @@ -49,21 +48,27 @@ function _M:get_connection() return nil end -function _M:get_water_mark() +function _M:get_watermark() + + return td_pool_watermark +end + + +function _M:get_current_load() - return water_mark + return td_pool_occupied end function _M:release_connection(conn) local connection_obj - for i = 1, #connection_pool do - connection_obj = connection_pool[i] + for i = 1, #td_connection_pool do + connection_obj = td_connection_pool[i] if connection_obj["obj"] == conn then connection_obj["state"] = 0 - occupied = occupied -1 + td_pool_occupied = td_pool_occupied -1 return end end diff --git a/examples/lua/OpenResty/rest/test.lua b/examples/lua/OpenResty/rest/test.lua index 48aeef3fb4dd8c9a0dc18e8039b4b8c781760666..cb4a1479f34600f6e43802c6c7d82754a93433ad 100644 --- a/examples/lua/OpenResty/rest/test.lua +++ b/examples/lua/OpenResty/rest/test.lua @@ -4,8 +4,21 @@ local Pool = require "tdpool" local config = require "config" ngx.say("start time:"..os.time()) -local pool = Pool.new(Pool,config) -local conn = pool:get_connection() +local pool = Pool.new(Pool, config) +local another_pool = Pool.new(Pool, config) +local conn, conn1, conn2 +conn = pool:get_connection() +conn1 = pool:get_connection() +conn2 = pool:get_connection() +local temp_conn = another_pool:get_connection() +ngx.say("pool size:"..config.connection_pool_size) +ngx.say("pool watermark:"..pool:get_watermark()) +ngx.say("pool current load:"..pool:get_current_load()) +pool:release_connection(conn1) +pool:release_connection(conn2) +another_pool:release_connection(temp_conn) +ngx.say("pool watermark:"..pool:get_watermark()) +ngx.say("pool current load:"..pool:get_current_load()) local res = driver.query(conn,"drop database if exists nginx") if res.code ~=0 then @@ -31,7 +44,6 @@ end res = driver.query(conn,"create table m1 (ts timestamp, speed int,owner binary(20))") if res.code ~=0 then ngx.say("create table---failed: "..res.error) - else ngx.say("create table--- pass.") end @@ -83,8 +95,5 @@ while not flag do -- ngx.say("i am here once...") ngx.sleep(0.001) -- time unit is second end - -ngx.say("pool water_mark:"..pool:get_water_mark()) - pool:release_connection(conn) ngx.say("end time:"..os.time()) diff --git a/examples/python/taosdemo/taosdemo.py b/examples/python/taosdemo/taosdemo.py index d55023bdbf119544a788aa6246c9d63dbf024872..13896bf54117d80d67a840fdb1158e3cbf793229 100755 --- a/examples/python/taosdemo/taosdemo.py +++ b/examples/python/taosdemo/taosdemo.py @@ -21,7 +21,7 @@ import json import random import time import datetime -from multiprocessing import Manager, Pool, Lock +from multiprocessing import Manager, Pool from multipledispatch import dispatch from concurrent.futures import ThreadPoolExecutor, wait, ALL_COMPLETED @@ -102,12 +102,7 @@ def restful_execute(host: str, port: int, user: str, password: str, cmd: str): v_print("resp status: %d", resp.status_code) if debug: - v_print( - "resp text: %s", - json.dumps( - resp.json(), - sort_keys=True, - indent=2)) + v_print("resp text: %s", json.dumps(resp.json(), sort_keys=True, indent=2)) else: print("resp: %s" % json.dumps(resp.json())) @@ -115,34 +110,29 @@ def restful_execute(host: str, port: int, user: str, password: str, cmd: str): def query_func(process: int, thread: int, cmd: str): v_print("%d process %d thread cmd: %s", process, thread, cmd) - if oneMoreHost != "NotSupported" and random.randint( - 0, 1) == 1: + if oneMoreHost != "NotSupported" and random.randint(0, 1) == 1: v_print("%s", "Send to second host") if native: - cursor2.execute(cmd) + cursor.execute(cmd) else: - restful_execute( - oneMoreHost, port, user, password, cmd) + restful_execute(oneMoreHost, port, user, password, cmd) else: v_print("%s%s%s", "Send ", cmd, " to the host") if native: pass -# cursor.execute(cmd) + # cursor.execute(cmd) else: - restful_execute( - host, port, user, password, cmd) + restful_execute(host, port, user, password, cmd) def query_data_process(cmd: str): # establish connection if native if native: - v_print("host:%s, user:%s passwd:%s configDir:%s ", host, user, password, configDir) + v_print("host:%s, user:%s passwd:xxxxxx configDir:%s ", host, user, configDir) try: conn = taos.connect( - host=host, - user=user, - password=password, - config=configDir) + host=host, user=user, password=password, config=configDir + ) v_print("conn: %s", str(conn.__class__)) except Exception as e: print("Error: %s" % e.args[0]) @@ -160,6 +150,7 @@ def query_data_process(cmd: str): try: cursor.execute(cmd) cols = cursor.description + print(cols) data = cursor.fetchall() for col in data: @@ -170,12 +161,7 @@ def query_data_process(cmd: str): sys.exit(1) else: - restful_execute( - host, - port, - user, - password, - cmd) + restful_execute(host, port, user, password, cmd) if native: cursor.close() @@ -186,21 +172,21 @@ def create_stb(): for i in range(0, numOfStb): if native: cursor.execute( - "CREATE TABLE IF NOT EXISTS %s%d (ts timestamp, value float) TAGS (uuid binary(50))" % - (stbName, i)) + "CREATE TABLE IF NOT EXISTS %s%d (ts timestamp, value float) TAGS (uuid binary(50))" + % (stbName, i) + ) else: restful_execute( host, port, user, password, - "CREATE TABLE IF NOT EXISTS %s%d (ts timestamp, value float) TAGS (uuid binary(50))" % - (stbName, i) + "CREATE TABLE IF NOT EXISTS %s%d (ts timestamp, value float) TAGS (uuid binary(50))" + % (stbName, i), ) def use_database(): - if native: cursor.execute("USE %s" % current_db) else: @@ -212,15 +198,15 @@ def create_databases(): v_print("will create database db%d", int(i)) if native: - cursor.execute( - "CREATE DATABASE IF NOT EXISTS %s%d" % (dbName, i)) + cursor.execute("CREATE DATABASE IF NOT EXISTS %s%d" % (dbName, i)) else: restful_execute( host, port, user, password, - "CREATE DATABASE IF NOT EXISTS %s%d" % (dbName, i)) + "CREATE DATABASE IF NOT EXISTS %s%d" % (dbName, i), + ) def drop_tables(): @@ -243,17 +229,11 @@ def drop_databases(): v_print("will drop database db%d", int(i)) if native: - cursor.execute( - "DROP DATABASE IF EXISTS %s%d" % - (dbName, i)) + cursor.execute("DROP DATABASE IF EXISTS %s%d" % (dbName, i)) else: restful_execute( - host, - port, - user, - password, - "DROP DATABASE IF EXISTS %s%d" % - (dbName, i)) + host, port, user, password, "DROP DATABASE IF EXISTS %s%d" % (dbName, i) + ) def insert_func(process: int, thread: int): @@ -266,13 +246,11 @@ def insert_func(process: int, thread: int): # establish connection if native if native: - v_print("host:%s, user:%s passwd:%s configDir:%s ", host, user, password, configDir) + v_print("host:%s, user:%s passwd:xxxxxx configDir:%s ", host, user, configDir) try: conn = taos.connect( - host=host, - user=user, - password=password, - config=configDir) + host=host, user=user, password=password, config=configDir + ) v_print("conn: %s", str(conn.__class__)) except Exception as e: print("Error: %s" % e.args[0]) @@ -291,26 +269,29 @@ def insert_func(process: int, thread: int): row = 0 while row < numOfRec: v_print("row: %d", row) - sqlCmd = ['INSERT INTO '] + sqlCmd = ["INSERT INTO "] try: - sqlCmd.append( - "%s.%s%d " % (current_db, tbName, thread)) + sqlCmd.append("%s.%s%d " % (current_db, tbName, thread)) - if (numOfStb > 0 and autosubtable): - sqlCmd.append("USING %s.%s%d TAGS('%s') " % - (current_db, stbName, numOfStb - 1, uuid)) + if numOfStb > 0 and autosubtable: + sqlCmd.append( + "USING %s.%s%d TAGS('%s') " + % (current_db, stbName, numOfStb - 1, uuid) + ) - start_time = datetime.datetime( - 2021, 1, 25) + datetime.timedelta(seconds=row) + start_time = datetime.datetime(2021, 1, 25) + datetime.timedelta( + seconds=row + ) sqlCmd.append("VALUES ") for batchIter in range(0, batch): - sqlCmd.append("('%s', %f) " % - ( - start_time + - datetime.timedelta( - milliseconds=batchIter), - random.random())) + sqlCmd.append( + "('%s', %f) " + % ( + start_time + datetime.timedelta(milliseconds=batchIter), + random.random(), + ) + ) row = row + 1 if row >= numOfRec: v_print("BREAK, row: %d numOfRec:%d", row, numOfRec) @@ -319,23 +300,21 @@ def insert_func(process: int, thread: int): except Exception as e: print("Error: %s" % e.args[0]) - cmd = ' '.join(sqlCmd) + cmd = " ".join(sqlCmd) if measure: exec_start_time = datetime.datetime.now() if native: affectedRows = cursor.execute(cmd) + print("affectedRows: %d" % affectedRows) else: - restful_execute( - host, port, user, password, cmd) + restful_execute(host, port, user, password, cmd) if measure: exec_end_time = datetime.datetime.now() exec_delta = exec_end_time - exec_start_time - v_print( - "consume %d microseconds", - exec_delta.microseconds) + v_print("consume %d microseconds", exec_delta.microseconds) v_print("cmd: %s, length:%d", cmd, len(cmd)) @@ -355,51 +334,39 @@ def create_tb(): if native: cursor.execute("USE %s%d" % (dbName, i)) else: - restful_execute( - host, port, user, password, "USE %s%d" % - (dbName, i)) + restful_execute(host, port, user, password, "USE %s%d" % (dbName, i)) for j in range(0, numOfTb): if native: cursor.execute( - "CREATE TABLE %s%d (ts timestamp, value float)" % - (tbName, j)) + "CREATE TABLE %s%d (ts timestamp, value float)" % (tbName, j) + ) else: restful_execute( host, port, user, password, - "CREATE TABLE %s%d (ts timestamp, value float)" % - (tbName, j)) + "CREATE TABLE %s%d (ts timestamp, value float)" % (tbName, j), + ) def insert_data_process(lock, i: int, begin: int, end: int): lock.acquire() tasks = end - begin - v_print("insert_data_process:%d table from %d to %d, tasks %d", i, begin, end, tasks) + v_print( + "insert_data_process:%d table from %d to %d, tasks %d", i, begin, end, tasks + ) - if (threads < (end - begin)): + if threads < (end - begin): for j in range(begin, end, threads): with ThreadPoolExecutor(max_workers=threads) as executor: k = end if ((j + threads) > end) else (j + threads) - workers = [ - executor.submit( - insert_func, - i, - n) for n in range( - j, - k)] + workers = [executor.submit(insert_func, i, n) for n in range(j, k)] wait(workers, return_when=ALL_COMPLETED) else: with ThreadPoolExecutor(max_workers=threads) as executor: - workers = [ - executor.submit( - insert_func, - i, - j) for j in range( - begin, - end)] + workers = [executor.submit(insert_func, i, j) for j in range(begin, end)] wait(workers, return_when=ALL_COMPLETED) lock.release() @@ -409,22 +376,18 @@ def query_db(i): if native: cursor.execute("USE %s%d" % (dbName, i)) else: - restful_execute( - host, port, user, password, "USE %s%d" % - (dbName, i)) + restful_execute(host, port, user, password, "USE %s%d" % (dbName, i)) for j in range(0, numOfTb): if native: - cursor.execute( - "SELECT COUNT(*) FROM %s%d" % (tbName, j)) + cursor.execute("SELECT COUNT(*) FROM %s%d" % (tbName, j)) else: restful_execute( - host, port, user, password, "SELECT COUNT(*) FROM %s%d" % - (tbName, j)) + host, port, user, password, "SELECT COUNT(*) FROM %s%d" % (tbName, j) + ) def printConfig(): - print("###################################################################") print("# Use native interface: %s" % native) print("# Server IP: %s" % host) @@ -435,7 +398,6 @@ def printConfig(): print("# Configuration Dir: %s" % configDir) print("# User: %s" % user) - print("# Password: %s" % password) print("# Number of Columns per record: %s" % colsPerRecord) print("# Number of Threads: %s" % threads) print("# Number of Processes: %s" % processes) @@ -455,13 +417,14 @@ def printConfig(): print("# Query command: %s" % queryCmd) print("# Insert Only: %s" % insertOnly) print("# Verbose output %s" % verbose) - print("# Test time: %s" % - datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S")) + print( + "# Test time: %s" + % datetime.datetime.now().strftime("%d/%m/%Y %H:%M:%S") + ) print("###################################################################") if __name__ == "__main__": - native = False verbose = False debug = False @@ -497,73 +460,131 @@ if __name__ == "__main__": skipPrompt = False try: - opts, args = getopt.gnu_getopt(sys.argv[1:], - 'Nh:p:u:P:d:a:m:Ms:Q:T:C:r:l:t:n:c:xOR:D:vgyH', - [ - 'native', 'host', 'port', 'user', 'password', 'dbname', 'replica', 'tbname', - 'stable', 'stbname', 'query', 'threads', 'processes', - 'recPerReq', 'colsPerRecord', 'numOfTb', 'numOfRec', 'config', - 'insertOnly', 'outOfOrder', 'rateOOOO', 'deleteMethod', - 'verbose', 'debug', 'skipPrompt', 'help' - ]) + opts, args = getopt.gnu_getopt( + sys.argv[1:], + "Nh:p:u:P:d:a:m:Ms:Q:T:C:r:l:t:n:c:xOR:D:vgyH", + [ + "native", + "host", + "port", + "user", + "password", + "dbname", + "replica", + "tbname", + "stable", + "stbname", + "query", + "threads", + "processes", + "recPerReq", + "colsPerRecord", + "numOfTb", + "numOfRec", + "config", + "insertOnly", + "outOfOrder", + "rateOOOO", + "deleteMethod", + "verbose", + "debug", + "skipPrompt", + "help", + ], + ) except getopt.GetoptError as err: - print('ERROR:', err) - print('Try `taosdemo.py --help` for more options.') + print("ERROR:", err) + print("Try `taosdemo.py --help` for more options.") sys.exit(1) if bool(opts) is False: - print('Try `taosdemo.py --help` for more options.') + print("Try `taosdemo.py --help` for more options.") sys.exit(1) for key, value in opts: - if key in ['-H', '--help']: - print('') + if key in ["-H", "--help"]: + print("") + print("taosdemo.py for TDengine") + print("") + print("Author: Shuduo Sang ") + print("") + + print("\t-H, --help Show usage.") + print("") + + print( + "\t-N, --native flag, Use native interface if set. Default is using RESTful interface." + ) + print( + "\t-h, --host host, The host to connect to TDengine. Default is localhost." + ) + print( + "\t-p, --port port, The TCP/IP port number to use for the connection. Default is 0." + ) print( - 'taosdemo.py for TDengine') - print('') - print('Author: Shuduo Sang ') - print('') - - print('\t-H, --help Show usage.') - print('') - - print('\t-N, --native flag, Use native interface if set. Default is using RESTful interface.') - print('\t-h, --host host, The host to connect to TDengine. Default is localhost.') - print('\t-p, --port port, The TCP/IP port number to use for the connection. Default is 0.') - print('\t-u, --user user, The user name to use when connecting to the server. Default is \'root\'.') - print('\t-P, --password password, The password to use when connecting to the server. Default is \'taosdata\'.') - print('\t-l, --colsPerRec num_of_columns_per_record, The number of columns per record. Default is 3.') + "\t-u, --user user, The user name to use when connecting to the server. Default is 'root'." + ) + print( + "\t-P, --password password, The password to use when connecting to the server. Default is 'taosdata'." + ) + print( + "\t-l, --colsPerRec num_of_columns_per_record, The number of columns per record. Default is 3." + ) + print( + "\t-d, --dbname database, Destination database. Default is 'test'." + ) + print( + "\t-a, --replica replica, Set the replica parameters of the database, Default 1, min: 1, max: 5." + ) print( - '\t-d, --dbname database, Destination database. Default is \'test\'.') - print('\t-a, --replica replica, Set the replica parameters of the database, Default 1, min: 1, max: 5.') + "\t-m, --tbname table_prefix, Table prefix name. Default is 't'." + ) print( - '\t-m, --tbname
table_prefix, Table prefix name. Default is \'t\'.') + "\t-M, --stable flag, Use super table. Default is no" + ) print( - '\t-M, --stable flag, Use super table. Default is no') + "\t-s, --stbname stable_prefix, STable prefix name. Default is 'st'" + ) print( - '\t-s, --stbname stable_prefix, STable prefix name. Default is \'st\'') - print('\t-Q, --query [NO|EACHTB|command] query, Execute query command. set \'EACHTB\' means select * from each table') + "\t-Q, --query [NO|EACHTB|command] query, Execute query command. set 'EACHTB' means select * from each table" + ) print( - '\t-T, --threads num_of_threads, The number of threads. Default is 1.') + "\t-T, --threads num_of_threads, The number of threads. Default is 1." + ) print( - '\t-C, --processes num_of_processes, The number of threads. Default is 1.') - print('\t-r, --batch num_of_records_per_req, The number of records per request. Default is 1000.') + "\t-C, --processes num_of_processes, The number of threads. Default is 1." + ) + print( + "\t-r, --batch num_of_records_per_req, The number of records per request. Default is 1000." + ) print( - '\t-t, --numOfTb num_of_tables, The number of tables. Default is 1.') - print('\t-n, --numOfRec num_of_records_per_table, The number of records per table. Default is 1.') - print('\t-c, --config config_directory, Configuration directory. Default is \'/etc/taos/\'.') - print('\t-x, --inserOnly flag, Insert only flag.') - print('\t-O, --outOfOrder out of order data insert, 0: In order, 1: Out of order. Default is in order.') - print('\t-R, --rateOOOO rate, Out of order data\'s rate--if order=1 Default 10, min: 0, max: 50.') - print('\t-D, --deleteMethod Delete data methods 0: don\'t delete, 1: delete by table, 2: delete by stable, 3: delete by database.') - print('\t-v, --verbose Print verbose output') - print('\t-g, --debug Print debug output') + "\t-t, --numOfTb num_of_tables, The number of tables. Default is 1." + ) print( - '\t-y, --skipPrompt Skip read key for continous test, default is not skip') - print('') + "\t-n, --numOfRec num_of_records_per_table, The number of records per table. Default is 1." + ) + print( + "\t-c, --config config_directory, Configuration directory. Default is '/etc/taos/'." + ) + print("\t-x, --inserOnly flag, Insert only flag.") + print( + "\t-O, --outOfOrder out of order data insert, 0: In order, 1: Out of order. Default is in order." + ) + print( + "\t-R, --rateOOOO rate, Out of order data's rate--if order=1 Default 10, min: 0, max: 50." + ) + print( + "\t-D, --deleteMethod Delete data methods 0: don't delete, 1: delete by table, 2: delete by stable, 3: delete by database." + ) + print("\t-v, --verbose Print verbose output") + print("\t-g, --debug Print debug output") + print( + "\t-y, --skipPrompt Skip read key for continous test, default is not skip" + ) + print("") sys.exit(0) - if key in ['-N', '--native']: + if key in ["-N", "--native"]: try: import taos except Exception as e: @@ -571,104 +592,104 @@ if __name__ == "__main__": sys.exit(1) native = True - if key in ['-h', '--host']: + if key in ["-h", "--host"]: host = value - if key in ['-p', '--port']: + if key in ["-p", "--port"]: port = int(value) - if key in ['-u', '--user']: + if key in ["-u", "--user"]: user = value - if key in ['-P', '--password']: + if key in ["-P", "--password"]: password = value else: password = defaultPass - if key in ['-d', '--dbname']: + if key in ["-d", "--dbname"]: dbName = value - if key in ['-a', '--replica']: + if key in ["-a", "--replica"]: replica = int(value) if replica < 1: print("FATAL: number of replica need > 0") sys.exit(1) - if key in ['-m', '--tbname']: + if key in ["-m", "--tbname"]: tbName = value - if key in ['-M', '--stable']: + if key in ["-M", "--stable"]: useStable = True numOfStb = 1 - if key in ['-s', '--stbname']: + if key in ["-s", "--stbname"]: stbName = value - if key in ['-Q', '--query']: + if key in ["-Q", "--query"]: queryCmd = str(value) - if key in ['-T', '--threads']: + if key in ["-T", "--threads"]: threads = int(value) if threads < 1: print("FATAL: number of threads must be larger than 0") sys.exit(1) - if key in ['-C', '--processes']: + if key in ["-C", "--processes"]: processes = int(value) if processes < 1: print("FATAL: number of processes must be larger than 0") sys.exit(1) - if key in ['-r', '--batch']: + if key in ["-r", "--batch"]: batch = int(value) - if key in ['-l', '--colsPerRec']: + if key in ["-l", "--colsPerRec"]: colsPerRec = int(value) - if key in ['-t', '--numOfTb']: + if key in ["-t", "--numOfTb"]: numOfTb = int(value) v_print("numOfTb is %d", numOfTb) - if key in ['-n', '--numOfRec']: + if key in ["-n", "--numOfRec"]: numOfRec = int(value) v_print("numOfRec is %d", numOfRec) if numOfRec < 1: print("FATAL: number of records must be larger than 0") sys.exit(1) - - if key in ['-c', '--config']: + if key in ["-c", "--config"]: configDir = value v_print("config dir: %s", configDir) - if key in ['-x', '--insertOnly']: + if key in ["-x", "--insertOnly"]: insertOnly = True v_print("insert only: %d", insertOnly) - if key in ['-O', '--outOfOrder']: + if key in ["-O", "--outOfOrder"]: outOfOrder = int(value) v_print("out of order is %d", outOfOrder) - if key in ['-R', '--rateOOOO']: + if key in ["-R", "--rateOOOO"]: rateOOOO = int(value) v_print("the rate of out of order is %d", rateOOOO) - if key in ['-D', '--deleteMethod']: + if key in ["-D", "--deleteMethod"]: deleteMethod = int(value) if (deleteMethod < 0) or (deleteMethod > 3): print( - "inputed delete method is %d, valid value is 0~3, set to default 0" % - deleteMethod) + "inputed delete method is %d, valid value is 0~3, set to default 0" + % deleteMethod + ) deleteMethod = 0 v_print("the delete method is %d", deleteMethod) - if key in ['-v', '--verbose']: + if key in ["-v", "--verbose"]: verbose = True - if key in ['-g', '--debug']: + if key in ["-g", "--debug"]: debug = True - if key in ['-y', '--skipPrompt']: + if key in ["-y", "--skipPrompt"]: skipPrompt = True if verbose: @@ -679,13 +700,11 @@ if __name__ == "__main__": # establish connection first if native if native: - v_print("host:%s, user:%s passwd:%s configDir:%s ", host, user, password, configDir) + v_print("host:%s, user:%s passwd:xxxxxx configDir:%s ", host, user, configDir) try: conn = taos.connect( - host=host, - user=user, - password=password, - config=configDir) + host=host, user=user, password=password, config=configDir + ) v_print("conn: %s", str(conn.__class__)) except Exception as e: print("Error: %s" % e.args[0]) @@ -705,7 +724,7 @@ if __name__ == "__main__": drop_tables() print("Drop tables done.") elif deleteMethod == 2: - drop_stables() + drop_stable() print("Drop super tables done.") elif deleteMethod == 3: drop_databases() @@ -725,7 +744,7 @@ if __name__ == "__main__": if numOfStb > 0: create_stb() - if (autosubtable == False): + if autosubtable is False: create_tb_using_stb() else: create_tb() @@ -734,7 +753,9 @@ if __name__ == "__main__": end_time = time.time() print( "Total time consumed {} seconds for create table.".format( - (end_time - start_time_begin))) + (end_time - start_time_begin) + ) + ) if native: cursor.close() @@ -758,10 +779,8 @@ if __name__ == "__main__": remainder = numOfTb % processes v_print( - "num of tables: %d, quotient: %d, remainder: %d", - numOfTb, - quotient, - remainder) + "num of tables: %d, quotient: %d, remainder: %d", numOfTb, quotient, remainder + ) for i in range(processes): begin = end @@ -770,7 +789,15 @@ if __name__ == "__main__": end = begin + quotient + 1 else: end = begin + quotient - pool.apply_async(insert_data_process, args=(lock, i, begin, end,)) + pool.apply_async( + insert_data_process, + args=( + lock, + i, + begin, + end, + ), + ) pool.close() pool.join() @@ -780,8 +807,9 @@ if __name__ == "__main__": end_time = time.time() print( "Total time consumed {} seconds for insert data.".format( - (end_time - start_time))) - + (end_time - start_time) + ) + ) # query data if queryCmd != "NO": @@ -790,8 +818,6 @@ if __name__ == "__main__": if measure: end_time = time.time() - print( - "Total time consumed {} seconds.".format( - (end_time - start_time_begin))) + print("Total time consumed {} seconds.".format((end_time - start_time_begin))) print("done") diff --git a/examples/rust/wrapper.h b/examples/rust/wrapper.h new file mode 100644 index 0000000000000000000000000000000000000000..78857597a9dc0c9a0f35194339a0d132f788d592 --- /dev/null +++ b/examples/rust/wrapper.h @@ -0,0 +1 @@ +#include diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 31c4ec41eab34a02d6bde9a50c60c423812dac6b..61adccf5c0e4db4644cf0edca53e44cc6ab45f8b 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -25,13 +25,6 @@ extern "C" { #endif -// TODO remove it -enum { - TMQ_CONF__RESET_OFFSET__NONE = -3, - TMQ_CONF__RESET_OFFSET__EARLIEAST = -2, - TMQ_CONF__RESET_OFFSET__LATEST = -1, -}; - // clang-format off #define IS_META_MSG(x) ( \ x == TDMT_VND_CREATE_STB \ @@ -192,7 +185,7 @@ typedef struct SBlockID { typedef struct SDataBlockInfo { STimeWindow window; int32_t rowSize; - int32_t rows; // todo hide this attribute + int64_t rows; // todo hide this attribute uint32_t capacity; SBlockID id; int16_t hasVarCol; diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index 84d696e518c45c65d7fbb2f6d87689a656121dab..99fffa2cf1d6f28697fea0a96562707aeb3e3a71 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -178,7 +178,7 @@ int32_t getJsonValueLen(const char* data); int32_t colDataSetVal(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, bool isNull); int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, bool isNull); -int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, uint32_t numOfRows); +int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, uint32_t numOfRows, bool trimValue); int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int32_t* capacity, const SColumnInfoData* pSource, int32_t numOfRow2); int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows, diff --git a/include/common/tglobal.h b/include/common/tglobal.h index c5200fb21dd81b82e6a7c1c44ed8248699f82151..c52c8227934125cf6a1e5d8b3ac94dc388f11b12 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -98,7 +98,8 @@ extern char *tsSvrCrashReportUri; // query buffer management extern int32_t tsQueryBufferSize; // maximum allowed usage buffer size in MB for each data node during query processing -extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in byte for each data node +extern int64_t tsQueryBufferSizeBytes; // maximum allowed usage buffer size in byte for each data node +extern int32_t tsCacheLazyLoadThreshold; // cost threshold for last/last_row loading cache as much as possible // query client extern int32_t tsQueryPolicy; @@ -145,10 +146,10 @@ extern char tsUdfdResFuncs[]; extern char tsUdfdLdLibPath[]; // schemaless -extern char tsSmlChildTableName[]; -extern char tsSmlTagName[]; -//extern bool tsSmlDataFormat; -//extern int32_t tsSmlBatchSize; +extern char tsSmlChildTableName[]; +extern char tsSmlTagName[]; +// extern bool tsSmlDataFormat; +// extern int32_t tsSmlBatchSize; // wal extern int64_t tsWalFsyncDataSizeLimit; diff --git a/include/common/tmsg.h b/include/common/tmsg.h index d9d3c7e2977f7b88b759f9d4cc7bc216b91e06fc..eefb8fc99e89c1758fd31e2dd9aba0dee0984227 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -846,6 +846,8 @@ typedef struct { int8_t replications; int32_t sstTrigger; int32_t minRows; + int32_t walRetentionPeriod; + int32_t walRetentionSize; } SAlterDbReq; int32_t tSerializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq); @@ -1052,6 +1054,7 @@ typedef struct { int64_t signature; char* pComment; char* pCode; + int8_t orReplace; } SCreateFuncReq; int32_t tSerializeSCreateFuncReq(void* buf, int32_t bufLen, SCreateFuncReq* pReq); @@ -1090,9 +1093,15 @@ typedef struct { char* pCode; } SFuncInfo; +typedef struct { + int32_t funcVersion; + int64_t funcCreatedTime; +} SFuncExtraInfo; + typedef struct { int32_t numOfFuncs; SArray* pFuncInfos; + SArray* pFuncExtraInfos; } SRetrieveFuncRsp; int32_t tSerializeSRetrieveFuncRsp(void* buf, int32_t bufLen, SRetrieveFuncRsp* pRsp); @@ -1136,6 +1145,7 @@ typedef struct { int64_t numOfInsertSuccessReqs; int64_t numOfBatchInsertReqs; int64_t numOfBatchInsertSuccessReqs; + int32_t numOfCachedTables; } SVnodeLoad; typedef struct { @@ -1320,6 +1330,9 @@ typedef struct { // 1st modification int16_t sttTrigger; int32_t minRows; + // 2nd modification + int32_t walRetentionPeriod; + int32_t walRetentionSize; } SAlterVnodeConfigReq; int32_t tSerializeSAlterVnodeConfigReq(void* buf, int32_t bufLen, SAlterVnodeConfigReq* pReq); @@ -1655,6 +1668,20 @@ typedef struct { int32_t tSerializeSRedistributeVgroupReq(void* buf, int32_t bufLen, SRedistributeVgroupReq* pReq); int32_t tDeserializeSRedistributeVgroupReq(void* buf, int32_t bufLen, SRedistributeVgroupReq* pReq); +typedef struct { + int32_t useless; +} SBalanceVgroupLeaderReq; + +int32_t tSerializeSBalanceVgroupLeaderReq(void* buf, int32_t bufLen, SBalanceVgroupLeaderReq* pReq); +int32_t tDeserializeSBalanceVgroupLeaderReq(void* buf, int32_t bufLen, SBalanceVgroupLeaderReq* pReq); + +typedef struct { + int32_t vgId; +} SForceBecomeFollowerReq; + +int32_t tSerializeSForceBecomeFollowerReq(void* buf, int32_t bufLen, SForceBecomeFollowerReq* pReq); +int32_t tDeserializeSForceBecomeFollowerReq(void* buf, int32_t bufLen, SForceBecomeFollowerReq* pReq); + typedef struct { int32_t vgId; } SSplitVgroupReq; @@ -3185,9 +3212,10 @@ typedef struct { SArray* blockData; SArray* blockTbName; SArray* blockSchema; - int32_t createTableNum; - SArray* createTableLen; - SArray* createTableReq; + // the following attributes are extended from SMqDataRsp + int32_t createTableNum; + SArray* createTableLen; + SArray* createTableReq; } STaosxRsp; int32_t tEncodeSTaosxRsp(SEncoder* pEncoder, const STaosxRsp* pRsp); diff --git a/include/common/tmsgcb.h b/include/common/tmsgcb.h index eca8740d2864612ff604601d089b206690854290..9b709272b2f5473828eee762a0834b999c2ec4bd 100644 --- a/include/common/tmsgcb.h +++ b/include/common/tmsgcb.h @@ -34,7 +34,7 @@ typedef enum { WRITE_QUEUE, APPLY_QUEUE, SYNC_QUEUE, - SYNC_CTRL_QUEUE, + SYNC_RD_QUEUE, STREAM_QUEUE, QUEUE_MAX, } EQueueType; diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index 46ca814e50ac6d33f24456e6ed9ecb7e8769dd41..6cf6140815cf1663392950b0ee119b0ae65db126 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -175,6 +175,7 @@ enum { // TD_DEF_MSG_TYPE(TDMT_MND_STREAM_CHECKPOINT_TIMER, "stream-checkpoint-tmr", NULL, NULL) // TD_DEF_MSG_TYPE(TDMT_MND_STREAM_BEGIN_CHECKPOINT, "stream-begin-checkpoint", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_BALANCE_VGROUP_LEADER, "balance-vgroup-leader", NULL, NULL) TD_NEW_MSG_SEG(TDMT_VND_MSG) TD_DEF_MSG_TYPE(TDMT_VND_SUBMIT, "submit", SSubmitReq, SSubmitRsp) @@ -259,7 +260,7 @@ enum { TD_NEW_MSG_SEG(TDMT_SYNC_MSG) TD_DEF_MSG_TYPE(TDMT_SYNC_TIMEOUT, "sync-timer", NULL, NULL) - TD_DEF_MSG_TYPE(TDMT_SYNC_PING, "sync-ping", NULL, NULL) // no longer used + TD_DEF_MSG_TYPE(TDMT_SYNC_TIMEOUT_ELECTION, "sync-elect", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_PING_REPLY, "sync-ping-reply", NULL, NULL) // no longer used TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST, "sync-client-request", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_SYNC_CLIENT_REQUEST_BATCH, "sync-client-request-batch", NULL, NULL) @@ -286,6 +287,7 @@ enum { TD_DEF_MSG_TYPE(TDMT_SYNC_PRE_SNAPSHOT, "sync-pre-snapshot", NULL, NULL) // no longer used TD_DEF_MSG_TYPE(TDMT_SYNC_PRE_SNAPSHOT_REPLY, "sync-pre-snapshot-reply", NULL, NULL) // no longer used TD_DEF_MSG_TYPE(TDMT_SYNC_MAX_MSG, "sync-max", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_SYNC_FORCE_FOLLOWER, "sync-force-become-follower", NULL, NULL) TD_NEW_MSG_SEG(TDMT_VND_STREAM_MSG) TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TRIGGER, "vnode-stream-trigger", NULL, NULL) diff --git a/include/common/ttime.h b/include/common/ttime.h index 4a7c47d1725dcc3dd1fde1e5c17a021e992156fb..f189959f22ca4bee4b07518aff00e7bbc527fb87 100644 --- a/include/common/ttime.h +++ b/include/common/ttime.h @@ -64,7 +64,7 @@ static FORCE_INLINE int64_t taosGetTimestampToday(int32_t precision) { : 1000000000; time_t t = taosTime(NULL); struct tm tm; - taosLocalTime(&t, &tm); + taosLocalTime(&t, &tm, NULL); tm.tm_hour = 0; tm.tm_min = 0; tm.tm_sec = 0; diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 1235dd344736d1245fd6cbc17ae7961554c6317d..fc66363603fb177b98b805bd84daefeaafaaff75 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -208,142 +208,143 @@ #define TK_AGGREGATE 190 #define TK_BUFSIZE 191 #define TK_LANGUAGE 192 -#define TK_STREAM 193 -#define TK_INTO 194 -#define TK_TRIGGER 195 -#define TK_AT_ONCE 196 -#define TK_WINDOW_CLOSE 197 -#define TK_IGNORE 198 -#define TK_EXPIRED 199 -#define TK_FILL_HISTORY 200 -#define TK_UPDATE 201 -#define TK_SUBTABLE 202 -#define TK_KILL 203 -#define TK_CONNECTION 204 -#define TK_TRANSACTION 205 -#define TK_BALANCE 206 -#define TK_VGROUP 207 -#define TK_MERGE 208 -#define TK_REDISTRIBUTE 209 -#define TK_SPLIT 210 -#define TK_DELETE 211 -#define TK_INSERT 212 -#define TK_NULL 213 -#define TK_NK_QUESTION 214 -#define TK_NK_ARROW 215 -#define TK_ROWTS 216 -#define TK_QSTART 217 -#define TK_QEND 218 -#define TK_QDURATION 219 -#define TK_WSTART 220 -#define TK_WEND 221 -#define TK_WDURATION 222 -#define TK_IROWTS 223 -#define TK_ISFILLED 224 -#define TK_CAST 225 -#define TK_NOW 226 -#define TK_TODAY 227 -#define TK_TIMEZONE 228 -#define TK_CLIENT_VERSION 229 -#define TK_SERVER_VERSION 230 -#define TK_SERVER_STATUS 231 -#define TK_CURRENT_USER 232 -#define TK_CASE 233 -#define TK_WHEN 234 -#define TK_THEN 235 -#define TK_ELSE 236 -#define TK_BETWEEN 237 -#define TK_IS 238 -#define TK_NK_LT 239 -#define TK_NK_GT 240 -#define TK_NK_LE 241 -#define TK_NK_GE 242 -#define TK_NK_NE 243 -#define TK_MATCH 244 -#define TK_NMATCH 245 -#define TK_CONTAINS 246 -#define TK_IN 247 -#define TK_JOIN 248 -#define TK_INNER 249 -#define TK_SELECT 250 -#define TK_DISTINCT 251 -#define TK_WHERE 252 -#define TK_PARTITION 253 -#define TK_BY 254 -#define TK_SESSION 255 -#define TK_STATE_WINDOW 256 -#define TK_EVENT_WINDOW 257 -#define TK_SLIDING 258 -#define TK_FILL 259 -#define TK_VALUE 260 -#define TK_VALUE_F 261 -#define TK_NONE 262 -#define TK_PREV 263 -#define TK_NULL_F 264 -#define TK_LINEAR 265 -#define TK_NEXT 266 -#define TK_HAVING 267 -#define TK_RANGE 268 -#define TK_EVERY 269 -#define TK_ORDER 270 -#define TK_SLIMIT 271 -#define TK_SOFFSET 272 -#define TK_LIMIT 273 -#define TK_OFFSET 274 -#define TK_ASC 275 -#define TK_NULLS 276 -#define TK_ABORT 277 -#define TK_AFTER 278 -#define TK_ATTACH 279 -#define TK_BEFORE 280 -#define TK_BEGIN 281 -#define TK_BITAND 282 -#define TK_BITNOT 283 -#define TK_BITOR 284 -#define TK_BLOCKS 285 -#define TK_CHANGE 286 -#define TK_COMMA 287 -#define TK_CONCAT 288 -#define TK_CONFLICT 289 -#define TK_COPY 290 -#define TK_DEFERRED 291 -#define TK_DELIMITERS 292 -#define TK_DETACH 293 -#define TK_DIVIDE 294 -#define TK_DOT 295 -#define TK_EACH 296 -#define TK_FAIL 297 -#define TK_FILE 298 -#define TK_FOR 299 -#define TK_GLOB 300 -#define TK_ID 301 -#define TK_IMMEDIATE 302 -#define TK_IMPORT 303 -#define TK_INITIALLY 304 -#define TK_INSTEAD 305 -#define TK_ISNULL 306 -#define TK_KEY 307 -#define TK_MODULES 308 -#define TK_NK_BITNOT 309 -#define TK_NK_SEMI 310 -#define TK_NOTNULL 311 -#define TK_OF 312 -#define TK_PLUS 313 -#define TK_PRIVILEGE 314 -#define TK_RAISE 315 -#define TK_REPLACE 316 -#define TK_RESTRICT 317 -#define TK_ROW 318 -#define TK_SEMI 319 -#define TK_STAR 320 -#define TK_STATEMENT 321 -#define TK_STRICT 322 -#define TK_STRING 323 -#define TK_TIMES 324 -#define TK_VALUES 325 -#define TK_VARIABLE 326 -#define TK_VIEW 327 -#define TK_WAL 328 +#define TK_REPLACE 193 +#define TK_STREAM 194 +#define TK_INTO 195 +#define TK_TRIGGER 196 +#define TK_AT_ONCE 197 +#define TK_WINDOW_CLOSE 198 +#define TK_IGNORE 199 +#define TK_EXPIRED 200 +#define TK_FILL_HISTORY 201 +#define TK_UPDATE 202 +#define TK_SUBTABLE 203 +#define TK_KILL 204 +#define TK_CONNECTION 205 +#define TK_TRANSACTION 206 +#define TK_BALANCE 207 +#define TK_VGROUP 208 +#define TK_LEADER 209 +#define TK_MERGE 210 +#define TK_REDISTRIBUTE 211 +#define TK_SPLIT 212 +#define TK_DELETE 213 +#define TK_INSERT 214 +#define TK_NULL 215 +#define TK_NK_QUESTION 216 +#define TK_NK_ARROW 217 +#define TK_ROWTS 218 +#define TK_QSTART 219 +#define TK_QEND 220 +#define TK_QDURATION 221 +#define TK_WSTART 222 +#define TK_WEND 223 +#define TK_WDURATION 224 +#define TK_IROWTS 225 +#define TK_ISFILLED 226 +#define TK_CAST 227 +#define TK_NOW 228 +#define TK_TODAY 229 +#define TK_TIMEZONE 230 +#define TK_CLIENT_VERSION 231 +#define TK_SERVER_VERSION 232 +#define TK_SERVER_STATUS 233 +#define TK_CURRENT_USER 234 +#define TK_CASE 235 +#define TK_WHEN 236 +#define TK_THEN 237 +#define TK_ELSE 238 +#define TK_BETWEEN 239 +#define TK_IS 240 +#define TK_NK_LT 241 +#define TK_NK_GT 242 +#define TK_NK_LE 243 +#define TK_NK_GE 244 +#define TK_NK_NE 245 +#define TK_MATCH 246 +#define TK_NMATCH 247 +#define TK_CONTAINS 248 +#define TK_IN 249 +#define TK_JOIN 250 +#define TK_INNER 251 +#define TK_SELECT 252 +#define TK_DISTINCT 253 +#define TK_WHERE 254 +#define TK_PARTITION 255 +#define TK_BY 256 +#define TK_SESSION 257 +#define TK_STATE_WINDOW 258 +#define TK_EVENT_WINDOW 259 +#define TK_SLIDING 260 +#define TK_FILL 261 +#define TK_VALUE 262 +#define TK_VALUE_F 263 +#define TK_NONE 264 +#define TK_PREV 265 +#define TK_NULL_F 266 +#define TK_LINEAR 267 +#define TK_NEXT 268 +#define TK_HAVING 269 +#define TK_RANGE 270 +#define TK_EVERY 271 +#define TK_ORDER 272 +#define TK_SLIMIT 273 +#define TK_SOFFSET 274 +#define TK_LIMIT 275 +#define TK_OFFSET 276 +#define TK_ASC 277 +#define TK_NULLS 278 +#define TK_ABORT 279 +#define TK_AFTER 280 +#define TK_ATTACH 281 +#define TK_BEFORE 282 +#define TK_BEGIN 283 +#define TK_BITAND 284 +#define TK_BITNOT 285 +#define TK_BITOR 286 +#define TK_BLOCKS 287 +#define TK_CHANGE 288 +#define TK_COMMA 289 +#define TK_CONCAT 290 +#define TK_CONFLICT 291 +#define TK_COPY 292 +#define TK_DEFERRED 293 +#define TK_DELIMITERS 294 +#define TK_DETACH 295 +#define TK_DIVIDE 296 +#define TK_DOT 297 +#define TK_EACH 298 +#define TK_FAIL 299 +#define TK_FILE 300 +#define TK_FOR 301 +#define TK_GLOB 302 +#define TK_ID 303 +#define TK_IMMEDIATE 304 +#define TK_IMPORT 305 +#define TK_INITIALLY 306 +#define TK_INSTEAD 307 +#define TK_ISNULL 308 +#define TK_KEY 309 +#define TK_MODULES 310 +#define TK_NK_BITNOT 311 +#define TK_NK_SEMI 312 +#define TK_NOTNULL 313 +#define TK_OF 314 +#define TK_PLUS 315 +#define TK_PRIVILEGE 316 +#define TK_RAISE 317 +#define TK_RESTRICT 318 +#define TK_ROW 319 +#define TK_SEMI 320 +#define TK_STAR 321 +#define TK_STATEMENT 322 +#define TK_STRICT 323 +#define TK_STRING 324 +#define TK_TIMES 325 +#define TK_VALUES 326 +#define TK_VARIABLE 327 +#define TK_VIEW 328 +#define TK_WAL 329 #define TK_NK_SPACE 600 #define TK_NK_COMMENT 601 diff --git a/include/libs/executor/executor.h b/include/libs/executor/executor.h index e3ac462e9b2abc8dfc6a546f5183181bd3c0af51..0b987516522b4612d334731b44e8e053eb487a24 100644 --- a/include/libs/executor/executor.h +++ b/include/libs/executor/executor.h @@ -67,9 +67,10 @@ typedef enum { * Create the exec task for stream mode * @param pMsg * @param SReadHandle + * @param vgId * @return */ -qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers); +qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers, int32_t vgId); /** * Create the exec task for queue mode @@ -77,13 +78,20 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers); * @param SReadHandle * @return */ -qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols, SSchemaWrapper** pSchema); +qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int32_t vgId, int32_t* numOfCols, + uint64_t id); + +/** + * set the task Id, usually used by message queue process + * @param tinfo + * @param taskId + * @param queryId + */ +void qSetTaskId(qTaskInfo_t tinfo, uint64_t taskId, uint64_t queryId); int32_t qSetStreamOpOpen(qTaskInfo_t tinfo); -// todo refactor void qGetCheckpointVersion(qTaskInfo_t tinfo, int64_t* dataVer, int64_t* ckId); - /** * Set multiple input data blocks for the stream scan. * @param tinfo @@ -144,7 +152,6 @@ int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* table * @param handle * @return */ - int32_t qExecTaskOpt(qTaskInfo_t tinfo, SArray* pResList, uint64_t* useconds, bool* hasMore, SLocalFetch* pLocal); int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pBlock, uint64_t* useconds); @@ -157,6 +164,7 @@ void qCleanExecTaskBlockBuf(qTaskInfo_t tinfo); * @return */ int32_t qAsyncKillTask(qTaskInfo_t tinfo, int32_t rspCode); +int32_t qKillTask(qTaskInfo_t tinfo, int32_t rspCode); bool qTaskIsExecuting(qTaskInfo_t qinfo); @@ -166,14 +174,6 @@ bool qTaskIsExecuting(qTaskInfo_t qinfo); */ void qDestroyTask(qTaskInfo_t tinfo); -/** - * Extract the qualified table id list, and than pass them to the TSDB driver to load the required table data blocks. - * - * @param iter the table iterator to traverse all tables belongs to a super table, or an invert index - * @return - */ -int32_t qGetQualifiedTableIdList(void* pTableList, const char* tagCond, int32_t tagCondLen, SArray* pTableIdList); - void qProcessRspMsg(void* parent, struct SRpcMsg* pMsg, struct SEpSet* pEpSet); int32_t qGetExplainExecInfo(qTaskInfo_t tinfo, SArray* pExecInfoList /*,int32_t* resNum, SExplainExecInfo** pRes*/); diff --git a/include/libs/function/function.h b/include/libs/function/function.h index fb6ef26a8acf92c76cd022440a5b33ad3ca469e8..aa5c78195aff3bcb2b685921228cf843a7ea1e9a 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -112,7 +112,7 @@ typedef struct SResultDataInfo { typedef struct SInputColumnInfoData { int32_t totalRows; // total rows in current columnar data int32_t startRowIndex; // handle started row index - int32_t numOfRows; // the number of rows needs to be handled + int64_t numOfRows; // the number of rows needs to be handled int32_t numOfInputCols; // PTS is not included bool colDataSMAIsSet; // if agg is set or not SColumnInfoData *pPTS; // primary timestamp column diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index 7b65c06b85f990b87c0c819f1d7627d8f28e8cc0..60a4a8c6056763c6670cc209eb406c79e5ad47a6 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -241,6 +241,7 @@ int32_t fmGetUdafExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet); int32_t fmSetInvertFunc(int32_t funcId, SFuncExecFuncs* pFpSet); int32_t fmSetNormalFunc(int32_t funcId, SFuncExecFuncs* pFpSet); bool fmIsInvertible(int32_t funcId); +char* fmGetFuncName(int32_t funcId); #ifdef __cplusplus } diff --git a/include/libs/function/taosudf.h b/include/libs/function/taosudf.h index b4daa895fd1a66ae01db72704c37c7a8707a8ace..5703df87faedc88efed4b81bfbfdd0fddc2d561f 100644 --- a/include/libs/function/taosudf.h +++ b/include/libs/function/taosudf.h @@ -276,6 +276,8 @@ typedef enum EUdfFuncType { UDF_FUNC_TYPE_SCALAR = 1, UDF_FUNC_TYPE_AGG = 2 } EU typedef struct SScriptUdfInfo { const char *name; + int32_t version; + int64_t createdTime; EUdfFuncType funcType; int8_t scriptType; diff --git a/include/libs/monitor/monitor.h b/include/libs/monitor/monitor.h index 3dee59ab14a0ac780f18f731a5abb6dbe559b6fd..607179c4464f157aca7d757403775b634b694d8b 100644 --- a/include/libs/monitor/monitor.h +++ b/include/libs/monitor/monitor.h @@ -116,6 +116,8 @@ typedef struct { int32_t vnodes_total; int32_t vnodes_alive; int32_t connections_total; + int32_t topics_toal; + int32_t streams_total; SArray *dnodes; // array of SMonDnodeDesc SArray *mnodes; // array of SMonMnodeDesc } SMonClusterInfo; @@ -147,9 +149,9 @@ typedef struct { } SMonStbInfo; typedef struct { - int32_t expire_time; - int64_t timeseries_used; - int64_t timeseries_total; + uint32_t expire_time; + int64_t timeseries_used; + int64_t timeseries_total; } SMonGrantInfo; typedef struct { diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index fefcc28bc29213d6aad0b9e9f93c9d76193cf4e4..3ae3900a5c501944676ed34de35c92da1cd8670a 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -438,6 +438,7 @@ typedef struct SDropStreamStmt { typedef struct SCreateFunctionStmt { ENodeType type; + bool orReplace; bool ignoreExists; char funcName[TSDB_FUNC_NAME_LEN]; bool isAgg; @@ -466,6 +467,10 @@ typedef struct SBalanceVgroupStmt { ENodeType type; } SBalanceVgroupStmt; +typedef struct SBalanceVgroupLeaderStmt { + ENodeType type; +} SBalanceVgroupLeaderStmt; + typedef struct SMergeVgroupStmt { ENodeType type; int32_t vgId1; diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index a2e4c76adccc91d5a1f8689643f3d7a93089eba0..3556a8ac9520bdfd7b58fa490c3b333aa034e9ed 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -209,7 +209,8 @@ typedef enum ENodeType { QUERY_NODE_INSERT_STMT, QUERY_NODE_QUERY, QUERY_NODE_SHOW_DB_ALIVE_STMT, - QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT, + QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT, + QUERY_NODE_BALANCE_VGROUP_LEADER_STMT, // logic plan node QUERY_NODE_LOGIC_PLAN_SCAN = 1000, diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index cb547ee6b3732e391ca943bcb9b3e9783d587e36..b6ada5a0c7c22bbbe1bd938faa1080464c98ae5a 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -33,6 +33,7 @@ typedef enum { JOB_TASK_STATUS_INIT, JOB_TASK_STATUS_EXEC, JOB_TASK_STATUS_PART_SUCC, + JOB_TASK_STATUS_FETCH, JOB_TASK_STATUS_SUCC, JOB_TASK_STATUS_FAIL, JOB_TASK_STATUS_DROP, diff --git a/include/libs/qworker/qworker.h b/include/libs/qworker/qworker.h index 2be0561ce7940e2c17dd49d71f62486d80538fc0..60ed94d4de5a9c43dc64ba2041073eb67889608e 100644 --- a/include/libs/qworker/qworker.h +++ b/include/libs/qworker/qworker.h @@ -106,6 +106,8 @@ int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64 int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId, void **pRsp, SArray *explainRes); +int32_t qWorkerDbgEnableDebug(char *option); + #ifdef __cplusplus } #endif diff --git a/include/libs/stream/streamState.h b/include/libs/stream/streamState.h index f7c022924ab42508d72086c7efb8482432e30ebf..6103262e1775e94a780901f2764984a5e913b834 100644 --- a/include/libs/stream/streamState.h +++ b/include/libs/stream/streamState.h @@ -27,13 +27,9 @@ extern "C" { #ifndef _STREAM_STATE_H_ #define _STREAM_STATE_H_ -typedef struct SStreamTask SStreamTask; - typedef bool (*state_key_cmpr_fn)(void* pKey1, void* pKey2); typedef struct STdbState { - SStreamTask* pOwner; - rocksdb_t* rocksdb; rocksdb_column_family_handle_t** pHandle; rocksdb_writeoptions_t* writeOpts; @@ -41,6 +37,7 @@ typedef struct STdbState { rocksdb_options_t** cfOpts; rocksdb_comparator_t** pCompare; rocksdb_options_t* dbOpt; + struct SStreamTask* pOwner; TDB* db; TTB* pStateDb; @@ -50,7 +47,6 @@ typedef struct STdbState { TTB* pParNameDb; TTB* pParTagDb; TXN* txn; - } STdbState; // incremental state storage @@ -62,7 +58,7 @@ typedef struct { int64_t checkPointId; } SStreamState; -SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int32_t szPage, int32_t pages); +SStreamState* streamStateOpen(char* path, struct SStreamTask* pTask, bool specPath, int32_t szPage, int32_t pages); void streamStateClose(SStreamState* pState); int32_t streamStateBegin(SStreamState* pState); int32_t streamStateCommit(SStreamState* pState); diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index d1e6de71da2350b12de9945d9fd28d0c56b021a6..66682799d3ce72866b442f05346d5b390afb2c40 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -295,7 +295,7 @@ typedef struct { SEpSet epSet; } SStreamChildEpInfo; -typedef struct SStreamTask { +struct SStreamTask { int64_t streamId; int32_t taskId; int32_t totalLevel; @@ -362,8 +362,7 @@ typedef struct SStreamTask { int64_t checkpointingId; int32_t checkpointAlignCnt; - -} SStreamTask; +}; int32_t tEncodeStreamEpInfo(SEncoder* pEncoder, const SStreamChildEpInfo* pInfo); int32_t tDecodeStreamEpInfo(SDecoder* pDecoder, SStreamChildEpInfo* pInfo); @@ -589,7 +588,7 @@ int32_t streamProcessDispatchReq(SStreamTask* pTask, SStreamDispatchReq* pReq, S int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, int32_t code); int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, SRpcMsg* pMsg); -int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp); +// int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp); int32_t streamTryExec(SStreamTask* pTask); int32_t streamSchedExec(SStreamTask* pTask); diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index 189484d1a6c98f298c5e8e7910cacba12d309b39..fdb4506cf3c00d04b6f5981601eb6915d3cd381b 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -48,7 +48,7 @@ extern "C" { #define SYNC_HEARTBEAT_REPLY_SLOW_MS 1500 #define SYNC_SNAP_RESEND_MS 1000 * 60 -#define SYNC_VND_COMMIT_MIN_MS 1000 +#define SYNC_VND_COMMIT_MIN_MS 3000 #define SYNC_MAX_BATCH_SIZE 1 #define SYNC_INDEX_BEGIN 0 @@ -143,10 +143,11 @@ typedef struct SSyncFSM { void* data; int32_t (*FpCommitCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta); + SyncIndex (*FpAppliedIndexCb)(const struct SSyncFSM* pFsm); int32_t (*FpPreCommitCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta); void (*FpRollBackCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta); - void (*FpRestoreFinishCb)(const struct SSyncFSM* pFsm); + void (*FpRestoreFinishCb)(const struct SSyncFSM* pFsm, const SyncIndex commitIdx); void (*FpReConfigCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SReConfigCbMeta* pMeta); void (*FpLeaderTransferCb)(const struct SSyncFSM* pFsm, SRpcMsg* pMsg, const SFsmCbMeta* pMeta); bool (*FpApplyQueueEmptyCb)(const struct SSyncFSM* pFsm); @@ -245,6 +246,7 @@ bool syncIsReadyForRead(int64_t rid); bool syncSnapshotSending(int64_t rid); bool syncSnapshotRecving(int64_t rid); int32_t syncSendTimeoutRsp(int64_t rid, int64_t seq); +int32_t syncForceBecomeFollower(SSyncNode* ths, const SRpcMsg* pRpcMsg); SSyncState syncGetState(int64_t rid); void syncGetRetryEpSet(int64_t rid, SEpSet* pEpSet); diff --git a/include/os/osDir.h b/include/os/osDir.h index 73871602c5e7818f0d9b050280d7326ee39678ef..55c7a15764cf68a15e37602d1182a56d859091b1 100644 --- a/include/os/osDir.h +++ b/include/os/osDir.h @@ -31,21 +31,49 @@ extern "C" { #endif +#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL) +#include "cus_name.h" +#endif + #ifdef WINDOWS + #define TD_TMP_DIR_PATH "C:\\Windows\\Temp\\" +#ifdef CUS_NAME +#define TD_CFG_DIR_PATH "C:\\"CUS_NAME"\\cfg\\" +#define TD_DATA_DIR_PATH "C:\\"CUS_NAME"\\data\\" +#define TD_LOG_DIR_PATH "C:\\"CUS_NAME"\\log\\" +#else #define TD_CFG_DIR_PATH "C:\\TDengine\\cfg\\" #define TD_DATA_DIR_PATH "C:\\TDengine\\data\\" #define TD_LOG_DIR_PATH "C:\\TDengine\\log\\" +#endif // CUS_NAME + #elif defined(_TD_DARWIN_64) + +#ifdef CUS_PROMPT +#define TD_TMP_DIR_PATH "/tmp/"CUS_PROMPT"d/" +#define TD_CFG_DIR_PATH "/etc/"CUS_PROMPT"/" +#define TD_DATA_DIR_PATH "/var/lib/"CUS_PROMPT"/" +#define TD_LOG_DIR_PATH "/var/log/"CUS_PROMPT"/" +#else #define TD_TMP_DIR_PATH "/tmp/taosd/" #define TD_CFG_DIR_PATH "/etc/taos/" #define TD_DATA_DIR_PATH "/var/lib/taos/" #define TD_LOG_DIR_PATH "/var/log/taos/" +#endif // CUS_PROMPT + #else + #define TD_TMP_DIR_PATH "/tmp/" +#ifdef CUS_PROMPT +#define TD_CFG_DIR_PATH "/etc/"CUS_PROMPT"/" +#define TD_DATA_DIR_PATH "/var/lib/"CUS_PROMPT"/" +#define TD_LOG_DIR_PATH "/var/log/"CUS_PROMPT"/" +#else #define TD_CFG_DIR_PATH "/etc/taos/" #define TD_DATA_DIR_PATH "/var/lib/taos/" #define TD_LOG_DIR_PATH "/var/log/taos/" +#endif // CUS_PROMPT #endif typedef struct TdDir *TdDirPtr; diff --git a/include/os/osTime.h b/include/os/osTime.h index 0a0a54119b4a40b79e54b7183b0cdc57cac03ca7..51a285a1393171ea59940498a4c8134afa270366 100644 --- a/include/os/osTime.h +++ b/include/os/osTime.h @@ -91,7 +91,7 @@ static FORCE_INLINE int64_t taosGetMonoTimestampMs() { } char *taosStrpTime(const char *buf, const char *fmt, struct tm *tm); -struct tm *taosLocalTime(const time_t *timep, struct tm *result); +struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf); struct tm *taosLocalTimeNolock(struct tm *result, const time_t *timep, int dst); time_t taosTime(time_t *t); time_t taosMktime(struct tm *timep); diff --git a/include/util/cus_name.h b/include/util/cus_name.h new file mode 100644 index 0000000000000000000000000000000000000000..16f677f855ba07403d292e4e64dd6060fb2ccf31 --- /dev/null +++ b/include/util/cus_name.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef _CUS_NAME_H_ +#define _CUS_NAME_H_ + +#ifndef CUS_NAME +#define CUS_NAME "TDengine" +#endif + +#ifndef CUS_PROMPT +#define CUS_PROMPT "taos" +#endif + +#ifndef CUS_EMAIL +#define CUS_EMAIL "" +#endif + +#endif // _CUS_NAME_H_ diff --git a/include/util/taoserror.h b/include/util/taoserror.h index a068de2686e49e90f6f9a31de41bc28a6ce5a2f5..adce476cf0c6c2539411ed580500fb9213555c09 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -223,6 +223,7 @@ int32_t* taosGetErrno(); // #define TSDB_CODE_MND_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x033C) // 2.x // #define TSDB_CODE_MND_DNODE_ID_NOT_CONFIGUREDTAOS_DEF_ERROR_CODE(0, 0x033D) // 2.x // #define TSDB_CODE_MND_DNODE_EP_NOT_CONFIGUREDTAOS_DEF_ERROR_CODE(0, 0x033E) // 2.x +#define TSDB_CODE_MND_DNODE_DIFF_CLUSTER TAOS_DEF_ERROR_CODE(0, 0x033F) // internal // mnode-acct #define TSDB_CODE_MND_ACCT_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0340) @@ -288,6 +289,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_INVALID_DB_ACCT TAOS_DEF_ERROR_CODE(0, 0x0389) // internal #define TSDB_CODE_MND_DB_OPTION_UNCHANGED TAOS_DEF_ERROR_CODE(0, 0x038A) // #define TSDB_CODE_MND_DB_INDEX_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x038B) +#define TSDB_CODE_MND_DB_RETENTION_PERIOD_ZERO TAOS_DEF_ERROR_CODE(0, 0x038C) // #define TSDB_CODE_MND_INVALID_DB_OPTION_DAYS TAOS_DEF_ERROR_CODE(0, 0x0390) // 2.x // #define TSDB_CODE_MND_INVALID_DB_OPTION_KEEP TAOS_DEF_ERROR_CODE(0, 0x0391) // 2.x // #define TSDB_CODE_MND_INVALID_TOPIC TAOS_DEF_ERROR_CODE(0, 0x0392) // 2.x @@ -542,7 +544,8 @@ int32_t* taosGetErrno(); #define TSDB_CODE_SYN_BATCH_ERROR TAOS_DEF_ERROR_CODE(0, 0x0913) #define TSDB_CODE_SYN_RESTORING TAOS_DEF_ERROR_CODE(0, 0x0914) #define TSDB_CODE_SYN_INVALID_SNAPSHOT_MSG TAOS_DEF_ERROR_CODE(0, 0x0915) // internal -#define TSDB_CODE_SYN_BUFFER_FULL TAOS_DEF_ERROR_CODE(0, 0x0916) // +#define TSDB_CODE_SYN_BUFFER_FULL TAOS_DEF_ERROR_CODE(0, 0x0916) +#define TSDB_CODE_SYN_WRITE_STALL TAOS_DEF_ERROR_CODE(0, 0x0917) #define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF) // tq @@ -642,7 +645,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_INCORRECT_NUM_OF_COL TAOS_DEF_ERROR_CODE(0, 0x2634) #define TSDB_CODE_PAR_INCORRECT_TIMESTAMP_VAL TAOS_DEF_ERROR_CODE(0, 0x2635) #define TSDB_CODE_PAR_OFFSET_LESS_ZERO TAOS_DEF_ERROR_CODE(0, 0x2637) -#define TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_BY TAOS_DEF_ERROR_CODE(0, 0x2638) +#define TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_GROUP_BY TAOS_DEF_ERROR_CODE(0, 0x2638) #define TSDB_CODE_PAR_INVALID_TOPIC_QUERY TAOS_DEF_ERROR_CODE(0, 0x2639) #define TSDB_CODE_PAR_INVALID_DROP_STABLE TAOS_DEF_ERROR_CODE(0, 0x263A) #define TSDB_CODE_PAR_INVALID_FILL_TIME_RANGE TAOS_DEF_ERROR_CODE(0, 0x263B) @@ -687,6 +690,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_NOT_SUPPORT_JOIN TAOS_DEF_ERROR_CODE(0, 0x2664) #define TSDB_CODE_PAR_INVALID_TAGS_PC TAOS_DEF_ERROR_CODE(0, 0x2665) #define TSDB_CODE_PAR_INVALID_TIMELINE_QUERY TAOS_DEF_ERROR_CODE(0, 0x2666) +#define TSDB_CODE_PAR_INVALID_OPTR_USAGE TAOS_DEF_ERROR_CODE(0, 0x2667) #define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF) //planner diff --git a/include/util/tarray.h b/include/util/tarray.h index a8510e4bc8295e7e40092ea5ae687717bda20676..4bf24b46b9d913c00d11b5ef53f8630f3ad4dbf5 100644 --- a/include/util/tarray.h +++ b/include/util/tarray.h @@ -69,14 +69,6 @@ void* taosArrayAddBatch(SArray* pArray, const void* pData, int32_t nEles); */ void taosArrayRemoveDuplicate(SArray* pArray, __compar_fn_t comparFn, void (*fp)(void*)); -/** - * - * @param pArray - * @param comparFn - * @param fp - */ -void taosArrayRemoveDuplicateP(SArray* pArray, __compar_fn_t comparFn, void (*fp)(void*)); - /** * add all element from the source array list into the destination * @param pArray @@ -216,6 +208,8 @@ void taosArrayDestroyP(SArray* pArray, FDelete fp); void taosArrayDestroyEx(SArray* pArray, FDelete fp); +void taosArraySwap(SArray* a, SArray* b); + /** * sort the array * @param pArray @@ -252,14 +246,6 @@ void taosArraySortPWithExt(SArray* pArray, __ext_compar_fn_t fn, const void* par int32_t taosEncodeArray(void** buf, const SArray* pArray, FEncode encode); void* taosDecodeArray(const void* buf, SArray** pArray, FDecode decode, int32_t dataSz); -/** - * swap array - * @param a - * @param b - * @return - */ -void taosArraySwap(SArray* a, SArray* b); - #ifdef __cplusplus } #endif diff --git a/include/util/tdef.h b/include/util/tdef.h index eac783cb256f62b84b5d59bcd17a5d7efc40d68f..e5000891c95e3a2b9722c86434b1010490377e2a 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -248,7 +248,7 @@ typedef enum ELogicConditionType { #define TSDB_AUTH_LEN 16 #define TSDB_PASSWORD_LEN 32 #define TSDB_USET_PASSWORD_LEN 129 -#define TSDB_VERSION_LEN 12 +#define TSDB_VERSION_LEN 32 #define TSDB_LABEL_LEN 8 #define TSDB_JOB_STATUS_LEN 32 @@ -316,10 +316,10 @@ typedef enum ELogicConditionType { #define TSDB_MAX_KEEP_NS (365 * 292 * 1440) // data in db to be reserved. #define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years #define TSDB_MIN_MINROWS_FBLOCK 10 -#define TSDB_MAX_MINROWS_FBLOCK 1000 +#define TSDB_MAX_MINROWS_FBLOCK 1000000 #define TSDB_DEFAULT_MINROWS_FBLOCK 100 #define TSDB_MIN_MAXROWS_FBLOCK 200 -#define TSDB_MAX_MAXROWS_FBLOCK 10000 +#define TSDB_MAX_MAXROWS_FBLOCK 10000000 #define TSDB_DEFAULT_MAXROWS_FBLOCK 4096 #define TSDB_MIN_FSYNC_PERIOD 0 #define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond diff --git a/include/util/tjson.h b/include/util/tjson.h index af0b163986e41a10fef13e412dfd508a47364d9c..6922930c13625e0a5722bc07af1578feee42c7ff 100644 --- a/include/util/tjson.h +++ b/include/util/tjson.h @@ -25,7 +25,7 @@ extern "C" { #define tjsonGetNumberValue(pJson, pName, val, code) \ do { \ - int64_t _tmp = 0; \ + uint64_t _tmp = 0; \ code = tjsonGetBigIntValue(pJson, pName, &_tmp); \ val = _tmp; \ } while (0) diff --git a/include/util/tlrucache.h b/include/util/tlrucache.h index 19009342484bce74c5173e7bf61ab52d6ddae767..c9cf71c2fd99398bd3f5e55bd08127f4278ed1f4 100644 --- a/include/util/tlrucache.h +++ b/include/util/tlrucache.h @@ -55,6 +55,8 @@ void *taosLRUCacheValue(SLRUCache *cache, LRUHandle *handle); size_t taosLRUCacheGetUsage(SLRUCache *cache); size_t taosLRUCacheGetPinnedUsage(SLRUCache *cache); +int32_t taosLRUCacheGetElems(SLRUCache *cache); + void taosLRUCacheSetCapacity(SLRUCache *cache, size_t capacity); size_t taosLRUCacheGetCapacity(SLRUCache *cache); diff --git a/include/util/tsimplehash.h b/include/util/tsimplehash.h index c9df9114763549da1b88c551f9efcc421e0e5c14..987a9fe2a847549bd9eb645fc33b880ed9773186 100644 --- a/include/util/tsimplehash.h +++ b/include/util/tsimplehash.h @@ -48,6 +48,13 @@ SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn); */ int32_t tSimpleHashGetSize(const SSHashObj *pHashObj); +/** + * set the free function pointer + * @param pHashObj + * @param freeFp + */ +void tSimpleHashSetFreeFp(SSHashObj* pHashObj, _hash_free_fn_t freeFp); + int32_t tSimpleHashPrint(const SSHashObj *pHashObj); /** diff --git a/include/util/tutil.h b/include/util/tutil.h index c8f1b29e10878efcddbebe736fa8bd5d107d6060..e0801e529507bd3152037e646895f66c6eefa35c 100644 --- a/include/util/tutil.h +++ b/include/util/tutil.h @@ -29,7 +29,7 @@ extern "C" { int32_t strdequote(char *src); size_t strtrim(char *src); char *strnchr(const char *haystack, char needle, int32_t len, bool skipquote); -TdUcs4 *wcsnchr(const TdUcs4 *haystack, TdUcs4 needle, size_t len); +TdUcs4* wcsnchr(const TdUcs4* haystack, TdUcs4 needle, size_t len); char **strsplit(char *src, const char *delim, int32_t *num); char *strtolower(char *dst, const char *src); @@ -37,11 +37,11 @@ char *strntolower(char *dst, const char *src, int32_t n); char *strntolower_s(char *dst, const char *src, int32_t n); int64_t strnatoi(char *num, int32_t len); -size_t tstrncspn(const char *str, size_t ssize, const char *reject, size_t rsize); -size_t twcsncspn(const TdUcs4 *wcs, size_t size, const TdUcs4 *reject, size_t rsize); +size_t tstrncspn(const char *str, size_t ssize, const char *reject, size_t rsize); +size_t twcsncspn(const TdUcs4 *wcs, size_t size, const TdUcs4 *reject, size_t rsize); -char *strbetween(char *string, char *begin, char *end); -char *paGetToken(char *src, char **token, int32_t *tokenLen); +char *strbetween(char *string, char *begin, char *end); +char *paGetToken(char *src, char **token, int32_t *tokenLen); int32_t taosByteArrayToHexStr(char bytes[], int32_t len, char hexstr[]); int32_t taosHexStrToByteArray(char hexstr[], char bytes[]); @@ -92,26 +92,12 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen, } } -#define TSDB_CHECK(condition, CODE, LINO, LABEL, ERRNO) \ - if (!(condition)) { \ - (CODE) = (ERRNO); \ - (LINO) = __LINE__; \ - goto LABEL; \ - } - #define TSDB_CHECK_CODE(CODE, LINO, LABEL) \ - if ((CODE)) { \ - (LINO) = __LINE__; \ + if (CODE) { \ + LINO = __LINE__; \ goto LABEL; \ } -#define TSDB_CHECK_NULL(ptr, CODE, LINO, LABEL, ERRNO) \ - if ((ptr) == NULL) { \ - (CODE) = (ERRNO); \ - (LINO) = __LINE__; \ - goto LABEL; \ - } - #ifdef __cplusplus } #endif diff --git a/include/util/version.h b/include/util/version.h index bac29e5baf6f7a754aa6d1b0bcfd2a06b841b0da..b241dd248b9a673591bbc94e1a71a78ad721919e 100644 --- a/include/util/version.h +++ b/include/util/version.h @@ -23,6 +23,7 @@ extern "C" { extern char version[]; extern char compatible_version[]; extern char gitinfo[]; +extern char gitinfoOfInternal[]; extern char buildinfo[]; #ifdef __cplusplus diff --git a/packaging/cfg/taos.cfg b/packaging/cfg/taos.cfg index 3d3dfc8e7322ac11ca7bc30b95127c2d4590271d..2159899aa277f550adf76eb7c107bf3da17c9ab1 100644 --- a/packaging/cfg/taos.cfg +++ b/packaging/cfg/taos.cfg @@ -1,19 +1,18 @@ ######################################################## # # -# TDengine Configuration # -# Any questions, please email support@taosdata.com # +# Configuration # # # ######################################################## ######### 0. Client only configurations ############# -# The interval for TDengine CLI to send heartbeat to mnode +# The interval for CLI to send heartbeat to mnode # shellActivityTimer 3 ############### 1. Cluster End point ############################ -# The end point of the first dnode in the cluster to be connected to when this dnode or a TDengine CLI `taos` is started +# The end point of the first dnode in the cluster to be connected to when this dnode or the CLI utility is started # firstEp hostname:6030 # The end point of the second dnode to be connected to if the firstEp is not available @@ -25,7 +24,7 @@ # The FQDN of the host on which this dnode will be started. It can be IP address # fqdn hostname -# The port for external access after this dnode is started +# The port for external access after this dnode is started # serverPort 6030 # The maximum number of connections a dnode can accept @@ -40,10 +39,10 @@ # temporary file's directory, if you are using Windows platform please change to Windows path # tempDir /tmp/ -# Switch for allowing TDengine to collect and report service usage information +# Switch for allowing to collect and report service usage information # telemetryReporting 1 -# Switch for allowing TDengine to collect and report crash information +# Switch for allowing to collect and report crash information # crashReporting 1 # The maximum number of vnodes supported by this dnode @@ -96,7 +95,7 @@ # if free disk space is less than this value, this dnode will fail to start # minimalDataDirGB 2.0 -# enable/disable system monitor +# enable/disable system monitor # monitor 1 # The following parameter is used to limit the maximum number of lines in log files. @@ -114,8 +113,8 @@ # The following parameters are used for debug purpose only by this dnode. # debugFlag is a 8 bits mask: FILE-SCREEN-UNUSED-HeartBeat-DUMP-TRACE_WARN-ERROR -# Available debug levels are: -# 131: output warning and error +# Available debug levels are: +# 131: output warning and error # 135: output debug, warning and error # 143: output trace, debug, warning and error to log # 199: output debug, warning and error to both screen and file @@ -130,7 +129,7 @@ # debug flag for util # uDebugFlag 131 -# debug flag for rpc +# debug flag for rpc # rpcDebugFlag 131 # debug flag for jni @@ -139,7 +138,7 @@ # debug flag for query # qDebugFlag 131 -# debug flag for taosc driver +# debug flag for client driver # cDebugFlag 131 # debug flag for dnode messages diff --git a/packaging/cfg/taosd.service b/packaging/cfg/taosd.service index fff4b74e62a6da8f2bda9a6306a79132d7585e42..52c4b1d1e2d7aeb3447633353f48b2363c16efaa 100644 --- a/packaging/cfg/taosd.service +++ b/packaging/cfg/taosd.service @@ -1,5 +1,5 @@ [Unit] -Description=TDengine server service +Description=server service After=network-online.target Wants=network-online.target diff --git a/packaging/debRpmAutoInstall.sh b/packaging/debRpmAutoInstall.sh index 3579f813e5b6ce91f0daa1fd230af14a4bf3d4b9..2fe18fd7a939ddf614e7f8a565ad9448d46f4122 100755 --- a/packaging/debRpmAutoInstall.sh +++ b/packaging/debRpmAutoInstall.sh @@ -1,15 +1,15 @@ #!/usr/bin/expect -set packgeName [lindex $argv 0] +set packageName [lindex $argv 0] set packageSuffix [lindex $argv 1] set timeout 3 if { ${packageSuffix} == "deb" } { - spawn dpkg -i ${packgeName} + spawn dpkg -i ${packageName} } elseif { ${packageSuffix} == "rpm"} { - spawn rpm -ivh ${packgeName} + spawn rpm -ivh ${packageName} } expect "*one:" send "\r" expect "*skip:" send "\r" -expect eof \ No newline at end of file +expect eof diff --git a/packaging/rpm/tdengine.spec b/packaging/rpm/tdengine.spec index e9d86219cb635d29cfc360314d122362d3285c0c..c21063e6a42a8642b0195640c1d7044be700c7da 100644 --- a/packaging/rpm/tdengine.spec +++ b/packaging/rpm/tdengine.spec @@ -90,45 +90,33 @@ cp %{_compiledir}/../include/libs/function/taosudf.h %{buildroot}%{homepat cp -r %{_compiledir}/../examples/* %{buildroot}%{homepath}/examples if [ -f %{_compiledir}/build/bin/jemalloc-config ]; then - mkdir -p %{buildroot}%{userlocalpath}/bin - mkdir -p %{buildroot}%{userlocalpath}/lib - mkdir -p %{buildroot}%{userlocalpath}/lib/pkgconfig - mkdir -p %{buildroot}%{userlocalpath}/include - mkdir -p %{buildroot}%{userlocalpath}/include/jemalloc - mkdir -p %{buildroot}%{userlocalpath}/share - mkdir -p %{buildroot}%{userlocalpath}/share/doc - mkdir -p %{buildroot}%{userlocalpath}/share/doc/jemalloc - mkdir -p %{buildroot}%{userlocalpath}/share/man - mkdir -p %{buildroot}%{userlocalpath}/share/man/man3 - - cp %{_compiledir}/build/bin/jemalloc-config %{buildroot}%{userlocalpath}/bin/ + mkdir -p %{buildroot}%{homepath}/jemalloc/ ||: + mkdir -p %{buildroot}%{homepath}/jemalloc/include/jemalloc/ ||: + mkdir -p %{buildroot}%{homepath}/jemalloc/lib/ ||: + mkdir -p %{buildroot}%{homepath}/jemalloc/lib/pkgconfig ||: + + cp %{_compiledir}/build/bin/jemalloc-config %{buildroot}%{homepath}/jemalloc/bin if [ -f %{_compiledir}/build/bin/jemalloc.sh ]; then - cp %{_compiledir}/build/bin/jemalloc.sh %{buildroot}%{userlocalpath}/bin/ + cp %{_compiledir}/build/bin/jemalloc.sh %{buildroot}%{homepath}/jemalloc/bin fi if [ -f %{_compiledir}/build/bin/jeprof ]; then - cp %{_compiledir}/build/bin/jeprof %{buildroot}%{userlocalpath}/bin/ + cp %{_compiledir}/build/bin/jeprof %{buildroot}%{homepath}/jemalloc/bin fi if [ -f %{_compiledir}/build/include/jemalloc/jemalloc.h ]; then - cp %{_compiledir}/build/include/jemalloc/jemalloc.h %{buildroot}%{userlocalpath}/include/jemalloc/ + cp %{_compiledir}/build/include/jemalloc/jemalloc.h %{buildroot}%{homepath}/jemalloc/include/jemalloc/ fi if [ -f %{_compiledir}/build/lib/libjemalloc.so.2 ]; then - cp %{_compiledir}/build/lib/libjemalloc.so.2 %{buildroot}%{userlocalpath}/lib/ - ln -sf libjemalloc.so.2 %{buildroot}%{userlocalpath}/lib/libjemalloc.so + cp %{_compiledir}/build/lib/libjemalloc.so.2 %{buildroot}%{homepath}/jemalloc/lib + ln -sf libjemalloc.so.2 %{buildroot}%{homepath}/jemalloc/lib/libjemalloc.so fi if [ -f %{_compiledir}/build/lib/libjemalloc.a ]; then - cp %{_compiledir}/build/lib/libjemalloc.a %{buildroot}%{userlocalpath}/lib/ + cp %{_compiledir}/build/lib/libjemalloc.a %{buildroot}%{homepath}/jemalloc/lib fi if [ -f %{_compiledir}/build/lib/libjemalloc_pic.a ]; then - cp %{_compiledir}/build/lib/libjemalloc_pic.a %{buildroot}%{userlocalpath}/lib/ + cp %{_compiledir}/build/lib/libjemalloc_pic.a %{buildroot}%{homepath}/jemalloc/lib fi if [ -f %{_compiledir}/build/lib/pkgconfig/jemalloc.pc ]; then - cp %{_compiledir}/build/lib/pkgconfig/jemalloc.pc %{buildroot}%{userlocalpath}/lib/pkgconfig/ - fi - if [ -f %{_compiledir}/build/share/doc/jemalloc/jemalloc.html ]; then - cp %{_compiledir}/build/share/doc/jemalloc/jemalloc.html %{buildroot}%{userlocalpath}/share/doc/jemalloc/ - fi - if [ -f %{_compiledir}/build/share/man/man3/jemalloc.3 ]; then - cp %{_compiledir}/build/share/man/man3/jemalloc.3 %{buildroot}%{userlocalpath}/share/man/man3/ + cp %{_compiledir}/build/lib/pkgconfig/jemalloc.pc %{buildroot}%{homepath}/jemalloc/lib/pkgconfig fi fi diff --git a/packaging/testpackage.sh b/packaging/testpackage.sh index 78d5043b0cf664e02d840fe307b93dc9cc8d9a68..97226a86b5a4cdb9eac50abee4da54dfdfa46996 100755 --- a/packaging/testpackage.sh +++ b/packaging/testpackage.sh @@ -25,7 +25,7 @@ sourcePath="nas" cpuType="x64" lite="true" packageType="tar" -subFile="taos.tar.gz" +subFile="package.tar.gz" while getopts "m:c:f:l:s:o:t:v:h" opt; do case $opt in m) @@ -79,9 +79,9 @@ GREEN_UNDERLINE='\033[4;32m' NC='\033[0m' if [[ ${verMode} = "enterprise" ]];then - prePackag="TDengine-enterprise-${testFile}" + prePackage="TDengine-enterprise-${testFile}" elif [ ${verMode} = "community" ];then - prePackag="TDengine-${testFile}" + prePackage="TDengine-${testFile}" fi if [ ${lite} = "true" ];then packageLite="-Lite" @@ -92,10 +92,10 @@ if [[ "$packageType" = "tar" ]] ;then packageType="tar.gz" fi -tdPath="${prePackag}-${version}" -originTdpPath="${prePackag}-${originversion}" +tdPath="${prePackage}-${version}" +originTdpPath="${prePackage}-${originversion}" -packgeName="${tdPath}-Linux-${cpuType}${packageLite}.${packageType}" +packageName="${tdPath}-Linux-${cpuType}${packageLite}.${packageType}" originPackageName="${originTdpPath}-Linux-${cpuType}${packageLite}.${packageType}" if [ "$testFile" == "server" ] ;then @@ -105,13 +105,13 @@ elif [ ${testFile} = "client" ];then elif [ ${testFile} = "tools" ];then tdPath="taosTools-${version}" originTdpPath="taosTools-${originversion}" - packgeName="${tdPath}-Linux-${cpuType}${packageLite}.${packageType}" + packageName="${tdPath}-Linux-${cpuType}${packageLite}.${packageType}" originPackageName="${originTdpPath}-Linux-${cpuType}${packageLite}.${packageType}" installCmd="install-taostools.sh" fi -echo "tdPath:${tdPath},originTdpPath:${originTdpPath},packgeName:${packgeName},originPackageName:${originPackageName}" +echo "tdPath:${tdPath},originTdpPath:${originTdpPath},packageName:${packageName},originPackageName:${originPackageName}" function cmdInstall { command=$1 if command -v ${command} ;then @@ -206,7 +206,7 @@ else fi -if [[ ${packgeName} =~ "server" ]] ;then +if [[ ${packageName} =~ "server" ]] ;then echoColor BD " pkill -9 taosd " pkill -9 taosd fi @@ -232,25 +232,25 @@ if [ -d ${installPath}/${tdPath} ] ;then fi echoColor G "===== download installPackage =====" -cd ${installPath} && wgetFile ${packgeName} ${version} ${sourcePath} +cd ${installPath} && wgetFile ${packageName} ${version} ${sourcePath} cd ${oriInstallPath} && wgetFile ${originPackageName} ${originversion} ${sourcePath} cd ${installPath} cp -r ${scriptDir}/debRpmAutoInstall.sh . -packageSuffix=$(echo ${packgeName} | awk -F '.' '{print $NF}') +packageSuffix=$(echo ${packageName} | awk -F '.' '{print $NF}') if [ ! -f debRpmAutoInstall.sh ];then echo '#!/usr/bin/expect ' > debRpmAutoInstall.sh - echo 'set packgeName [lindex $argv 0]' >> debRpmAutoInstall.sh + echo 'set packageName [lindex $argv 0]' >> debRpmAutoInstall.sh echo 'set packageSuffix [lindex $argv 1]' >> debRpmAutoInstall.sh echo 'set timeout 3 ' >> debRpmAutoInstall.sh echo 'if { ${packageSuffix} == "deb" } {' >> debRpmAutoInstall.sh - echo ' spawn dpkg -i ${packgeName} ' >> debRpmAutoInstall.sh + echo ' spawn dpkg -i ${packageName} ' >> debRpmAutoInstall.sh echo '} elseif { ${packageSuffix} == "rpm"} {' >> debRpmAutoInstall.sh - echo ' spawn rpm -ivh ${packgeName}' >> debRpmAutoInstall.sh + echo ' spawn rpm -ivh ${packageName}' >> debRpmAutoInstall.sh echo '}' >> debRpmAutoInstall.sh echo 'expect "*one:"' >> debRpmAutoInstall.sh echo 'send "\r"' >> debRpmAutoInstall.sh @@ -261,25 +261,25 @@ fi echoColor G "===== instal Package =====" -if [[ ${packgeName} =~ "deb" ]];then +if [[ ${packageName} =~ "deb" ]];then cd ${installPath} dpkg -r taostools dpkg -r tdengine - if [[ ${packgeName} =~ "TDengine" ]];then - echoColor BD "./debRpmAutoInstall.sh ${packgeName} ${packageSuffix}" && chmod 755 debRpmAutoInstall.sh && ./debRpmAutoInstall.sh ${packgeName} ${packageSuffix} + if [[ ${packageName} =~ "TDengine" ]];then + echoColor BD "./debRpmAutoInstall.sh ${packageName} ${packageSuffix}" && chmod 755 debRpmAutoInstall.sh && ./debRpmAutoInstall.sh ${packageName} ${packageSuffix} else - echoColor BD "dpkg -i ${packgeName}" && dpkg -i ${packgeName} + echoColor BD "dpkg -i ${packageName}" && dpkg -i ${packageName} fi -elif [[ ${packgeName} =~ "rpm" ]];then +elif [[ ${packageName} =~ "rpm" ]];then cd ${installPath} sudo rpm -e tdengine sudo rpm -e taostools - if [[ ${packgeName} =~ "TDengine" ]];then - echoColor BD "./debRpmAutoInstall.sh ${packgeName} ${packageSuffix}" && chmod 755 debRpmAutoInstall.sh && ./debRpmAutoInstall.sh ${packgeName} ${packageSuffix} + if [[ ${packageName} =~ "TDengine" ]];then + echoColor BD "./debRpmAutoInstall.sh ${packageName} ${packageSuffix}" && chmod 755 debRpmAutoInstall.sh && ./debRpmAutoInstall.sh ${packageName} ${packageSuffix} else - echoColor BD "rpm -ivh ${packgeName}" && rpm -ivh ${packgeName} + echoColor BD "rpm -ivh ${packageName}" && rpm -ivh ${packageName} fi -elif [[ ${packgeName} =~ "tar" ]];then +elif [[ ${packageName} =~ "tar" ]];then echoColor G "===== check installPackage File of tar =====" cd ${oriInstallPath} if [ ! -f {originPackageName} ];then @@ -290,7 +290,7 @@ elif [[ ${packgeName} =~ "tar" ]];then echoColor BD "tar -xf ${originPackageName}" && tar -xf ${originPackageName} cd ${installPath} echoColor YD "unzip the new installation package" - echoColor BD "tar -xf ${packgeName}" && tar -xf ${packgeName} + echoColor BD "tar -xf ${packageName}" && tar -xf ${packageName} if [ ${testFile} != "tools" ] ;then cd ${installPath}/${tdPath} && tar xf ${subFile} @@ -326,7 +326,7 @@ fi cd ${installPath} -if [[ ${packgeName} =~ "Lite" ]] || ([[ ${packgeName} =~ "x64" ]] && [[ ${packgeName} =~ "client" ]]) || ([[ ${packgeName} =~ "deb" ]] && [[ ${packgeName} =~ "server" ]]) || ([[ ${packgeName} =~ "rpm" ]] && [[ ${packgeName} =~ "server" ]]) ;then +if [[ ${packageName} =~ "Lite" ]] || ([[ ${packageName} =~ "x64" ]] && [[ ${packageName} =~ "client" ]]) || ([[ ${packageName} =~ "deb" ]] && [[ ${packageName} =~ "server" ]]) || ([[ ${packageName} =~ "rpm" ]] && [[ ${packageName} =~ "server" ]]) ;then echoColor G "===== install taos-tools when package is lite or client =====" cd ${installPath} if [ ! -f "taosTools-2.1.3-Linux-x64.tar.gz " ];then @@ -334,7 +334,7 @@ if [[ ${packgeName} =~ "Lite" ]] || ([[ ${packgeName} =~ "x64" ]] && [[ ${pac tar xf taosTools-2.1.3-Linux-x64.tar.gz fi cd taosTools-2.1.3 && bash install-taostools.sh -elif ([[ ${packgeName} =~ "arm64" ]] && [[ ${packgeName} =~ "client" ]]);then +elif ([[ ${packageName} =~ "arm64" ]] && [[ ${packageName} =~ "client" ]]);then echoColor G "===== install taos-tools arm when package is arm64-client =====" cd ${installPath} if [ ! -f "taosTools-2.1.3-Linux-x64.tar.gz " ];then @@ -347,28 +347,28 @@ fi echoColor G "===== start TDengine =====" -if [[ ${packgeName} =~ "server" ]] ;then +if [[ ${packageName} =~ "server" ]] ;then echoColor BD " rm -rf /var/lib/taos/* && systemctl restart taosd " rm -rf /var/lib/taos/* systemctl restart taosd fi -rm -rf ${installPath}/${packgeName} +rm -rf ${installPath}/${packageName} rm -rf ${installPath}/${tdPath}/ -# if ([[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "tar" ]]) || [[ ${packgeName} =~ "client" ]] ;then +# if ([[ ${packageName} =~ "Lite" ]] && [[ ${packageName} =~ "tar" ]]) || [[ ${packageName} =~ "client" ]] ;then # echoColor G "===== install taos-tools when package is lite or client =====" # cd ${installPath} # wgetFile taosTools-2.1.2-Linux-x64.tar.gz . # tar xf taosTools-2.1.2-Linux-x64.tar.gz # cd taosTools-2.1.2 && bash install-taostools.sh -# elif [[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "deb" ]] ;then +# elif [[ ${packageName} =~ "Lite" ]] && [[ ${packageName} =~ "deb" ]] ;then # echoColor G "===== install taos-tools when package is lite or client =====" # cd ${installPath} # wgetFile taosTools-2.1.2-Linux-x64.tar.gz . # tar xf taosTools-2.1.2-Linux-x64.tar.gz # cd taosTools-2.1.2 && bash install-taostools.sh -# elif [[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "rpm" ]] ;then +# elif [[ ${packageName} =~ "Lite" ]] && [[ ${packageName} =~ "rpm" ]] ;then # echoColor G "===== install taos-tools when package is lite or client =====" # cd ${installPath} # wgetFile taosTools-2.1.2-Linux-x64.tar.gz . diff --git a/packaging/tools/com.taosdata.taoskeeper.plist b/packaging/tools/com.taosdata.taoskeeper.plist new file mode 100644 index 0000000000000000000000000000000000000000..338b5d8e79c4a6f529f70e85bdd2d8b64d67264f --- /dev/null +++ b/packaging/tools/com.taosdata.taoskeeper.plist @@ -0,0 +1,33 @@ + + + + + Label + com.tdengine.taoskeeper + ProgramArguments + + /usr/local/bin/taoskeeper + + ProcessType + Interactive + Disabled + + RunAtLoad + + LaunchOnlyOnce + + SessionCreate + + ExitTimeOut + 600 + KeepAlive + + SuccessfulExit + + AfterInitialDemand + + + Program + /usr/local/bin/taoskeeper + + \ No newline at end of file diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 2495e177e1b0a8a20ecf6527862cc310c4ef34df..0a4f3ff6227b9710a8a533e0af55d1abc0a594c7 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -4,7 +4,7 @@ # is required to use systemd to manage services at boot set -e -#set -x +# set -x verMode=edge pagMode=full @@ -24,7 +24,7 @@ productName="TDengine" emailName="taosdata.com" uninstallScript="rmtaos" historyFile="taos_history" -tarName="taos.tar.gz" +tarName="package.tar.gz" dataDir="/var/lib/taos" logDir="/var/log/taos" configDir="/etc/taos" @@ -34,21 +34,25 @@ benchmarkName="taosBenchmark" dumpName="taosdump" demoName="taosdemo" xname="taosx" -explorerName="${clientName}-explorer" clientName2="taos" -serverName2="taosd" +serverName2="${clientName2}d" +configFile2="${clientName2}.cfg" productName2="TDengine" emailName2="taosdata.com" +xname2="${clientName2}x" +adapterName2="${clientName2}adapter" +explorerName="${clientName2}-explorer" benchmarkName2="${clientName2}Benchmark" +demoName2="${clientName2}demo" dumpName2="${clientName2}dump" uninstallScript2="rm${clientName2}" historyFile="${clientName2}_history" logDir="/var/log/${clientName2}" configDir="/etc/${clientName2}" -installDir="/usr/local/${clientName}" +installDir="/usr/local/${clientName2}" data_dir=${dataDir} log_dir=${logDir} @@ -206,15 +210,15 @@ function install_main_path() { function install_bin() { # Remove links - ${csudo}rm -f ${bin_link_dir}/${clientName} || : - ${csudo}rm -f ${bin_link_dir}/${serverName} || : + ${csudo}rm -f ${bin_link_dir}/${clientName2} || : + ${csudo}rm -f ${bin_link_dir}/${serverName2} || : ${csudo}rm -f ${bin_link_dir}/${udfdName} || : ${csudo}rm -f ${bin_link_dir}/${adapterName} || : - ${csudo}rm -f ${bin_link_dir}/${uninstallScript} || : - ${csudo}rm -f ${bin_link_dir}/${demoName} || : - ${csudo}rm -f ${bin_link_dir}/${benchmarkName} || : - ${csudo}rm -f ${bin_link_dir}/${dumpName} || : - ${csudo}rm -f ${bin_link_dir}/${xname} || : + ${csudo}rm -f ${bin_link_dir}/${uninstallScript2} || : + ${csudo}rm -f ${bin_link_dir}/${demoName2} || : + ${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || : + ${csudo}rm -f ${bin_link_dir}/${dumpName2} || : + ${csudo}rm -f ${bin_link_dir}/${xname2} || : ${csudo}rm -f ${bin_link_dir}/${explorerName} || : ${csudo}rm -f ${bin_link_dir}/set_core || : ${csudo}rm -f ${bin_link_dir}/TDinsight.sh || : @@ -222,23 +226,22 @@ function install_bin() { ${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin && ${csudo}chmod 0555 ${install_main_dir}/bin/* #Make link - [ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName} || : - [ -x ${install_main_dir}/bin/${serverName} ] && ${csudo}ln -s ${install_main_dir}/bin/${serverName} ${bin_link_dir}/${serverName} || : - [ -x ${install_main_dir}/bin/${udfdName} ] && ${csudo}ln -s ${install_main_dir}/bin/${udfdName} ${bin_link_dir}/${udfdName} || : - [ -x ${install_main_dir}/bin/${adapterName} ] && ${csudo}ln -s ${install_main_dir}/bin/${adapterName} ${bin_link_dir}/${adapterName} || : - [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${demoName} || : - [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName} || : - [ -x ${install_main_dir}/bin/${dumpName} ] && ${csudo}ln -s ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName} || : - [ -x ${install_main_dir}/bin/${xname} ] && ${csudo}ln -s ${install_main_dir}/bin/${xname} ${bin_link_dir}/${xname} || : - [ -x ${install_main_dir}/bin/${explorerName} ] && ${csudo}ln -s ${install_main_dir}/bin/${explorerName} ${bin_link_dir}/${explorerName} || : - [ -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/${clientName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${clientName2} ${bin_link_dir}/${clientName2} || : + [ -x ${install_main_dir}/bin/${serverName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${serverName2} ${bin_link_dir}/${serverName2} || : + [ -x ${install_main_dir}/bin/${udfdName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${udfdName} ${bin_link_dir}/${udfdName} || : + [ -x ${install_main_dir}/bin/${adapterName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${adapterName2} ${bin_link_dir}/${adapterName2} || : + [ -x ${install_main_dir}/bin/${benchmarkName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName2} ${bin_link_dir}/${demoName2} || : + [ -x ${install_main_dir}/bin/${benchmarkName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${benchmarkName2} ${bin_link_dir}/${benchmarkName2} || : + [ -x ${install_main_dir}/bin/${dumpName2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${dumpName2} ${bin_link_dir}/${dumpName2} || : + [ -x ${install_main_dir}/bin/${xname2} ] && ${csudo}ln -sf ${install_main_dir}/bin/${xname2} ${bin_link_dir}/${xname2} || : + [ -x ${install_main_dir}/bin/${explorerName} ] && ${csudo}ln -sf ${install_main_dir}/bin/${explorerName} ${bin_link_dir}/${explorerName} || : + [ -x ${install_main_dir}/bin/TDinsight.sh ] && ${csudo}ln -sf ${install_main_dir}/bin/TDinsight.sh ${bin_link_dir}/TDinsight.sh || : + if [ "$clientName2" == "${clientName}" ]; then + [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || : + fi [ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || : if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then - [ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName2} || : - [ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName2} || : - [ -x ${install_main_dir}/bin/${dumpName} ] && ${csudo}ln -s ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName2} || : [ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript2} || : fi } @@ -250,14 +253,14 @@ function install_lib() { #${csudo}rm -rf ${v15_java_app_dir} || : ${csudo}cp -rf ${script_dir}/driver/* ${install_main_dir}/driver && ${csudo}chmod 777 ${install_main_dir}/driver/* - ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 - ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib_link_dir}/libtaos.so.1 + ${csudo}ln -sf ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so [ -f ${install_main_dir}/driver/libtaosws.so ] && ${csudo}ln -sf ${install_main_dir}/driver/libtaosws.so ${lib_link_dir}/libtaosws.so || : if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then - ${csudo}ln -s ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : - ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + ${csudo}ln -sf ${install_main_dir}/driver/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : + ${csudo}ln -sf ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : [ -f ${install_main_dir}/libtaosws.so ] && ${csudo}ln -sf ${install_main_dir}/libtaosws.so ${lib64_link_dir}/libtaosws.so || : fi @@ -347,10 +350,10 @@ function install_header() { [ -f ${inc_link_dir}/taosws.h ] && ${csudo}rm -f ${inc_link_dir}/taosws.h || : ${csudo}cp -f ${script_dir}/inc/* ${install_main_dir}/include && ${csudo}chmod 644 ${install_main_dir}/include/* - ${csudo}ln -s ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h - ${csudo}ln -s ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h - ${csudo}ln -s ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h - ${csudo}ln -s ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h + ${csudo}ln -sf ${install_main_dir}/include/taos.h ${inc_link_dir}/taos.h + ${csudo}ln -sf ${install_main_dir}/include/taosdef.h ${inc_link_dir}/taosdef.h + ${csudo}ln -sf ${install_main_dir}/include/taoserror.h ${inc_link_dir}/taoserror.h + ${csudo}ln -sf ${install_main_dir}/include/taosudf.h ${inc_link_dir}/taosudf.h [ -f ${install_main_dir}/include/taosws.h ] && ${csudo}ln -sf ${install_main_dir}/include/taosws.h ${inc_link_dir}/taosws.h || : } @@ -399,7 +402,7 @@ function set_hostname() { ${csudo}sed -i -r "s/#*\s*(HOSTNAME=\s*).*/\1$newHostname/" /etc/sysconfig/network || : fi - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/${configFile} + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$newHostname/" ${cfg_install_dir}/${configFile2} serverFqdn=$newHostname if [[ -e /etc/hosts ]]; then @@ -433,7 +436,7 @@ function set_ipAsFqdn() { echo -e -n "${GREEN}Unable to get local ip, use 127.0.0.1${NC}" localFqdn="127.0.0.1" # Write the local FQDN to configuration file - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/${configFile} + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/${configFile2} serverFqdn=$localFqdn echo return @@ -455,7 +458,7 @@ function set_ipAsFqdn() { read -p "Please choose an IP from local IP list:" localFqdn else # Write the local FQDN to configuration file - ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/${configFile} + ${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$localFqdn/" ${cfg_install_dir}/${configFile2} serverFqdn=$localFqdn break fi @@ -511,7 +514,7 @@ function install_adapter_config() { fi [ -f ${cfg_install_dir}/${adapterName}.toml ] && - ${csudo}ln -s ${cfg_install_dir}/${adapterName}.toml ${install_main_dir}/cfg/${adapterName}.toml + ${csudo}ln -sf ${cfg_install_dir}/${adapterName}.toml ${install_main_dir}/cfg/${adapterName}.toml [ ! -z $1 ] && return 0 || : # only install client @@ -519,15 +522,15 @@ function install_adapter_config() { function install_config() { - if [ ! -f "${cfg_install_dir}/${configFile}" ]; then + if [ ! -f "${cfg_install_dir}/${configFile2}" ]; then ${csudo}mkdir -p ${cfg_install_dir} - [ -f ${script_dir}/cfg/${configFile} ] && ${csudo}cp ${script_dir}/cfg/${configFile} ${cfg_install_dir} + [ -f ${script_dir}/cfg/${configFile2} ] && ${csudo}cp ${script_dir}/cfg/${configFile2} ${cfg_install_dir} ${csudo}chmod 644 ${cfg_install_dir}/* else - ${csudo}cp -f ${script_dir}/cfg/${configFile} ${cfg_install_dir}/${configFile}.new + ${csudo}cp -f ${script_dir}/cfg/${configFile2} ${cfg_install_dir}/${configFile2}.new fi - ${csudo}ln -s ${cfg_install_dir}/${configFile} ${install_main_dir}/cfg + ${csudo}ln -sf ${cfg_install_dir}/${configFile2} ${install_main_dir}/cfg [ ! -z $1 ] && return 0 || : # only install client @@ -548,7 +551,7 @@ function install_config() { read firstEp while true; do if [ ! -z "$firstEp" ]; then - ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/${configFile} + ${csudo}sed -i -r "s/#*\s*(firstEp\s*).*/\1$firstEp/" ${cfg_install_dir}/${configFile2} break else break @@ -573,22 +576,24 @@ function install_log() { ${csudo}rm -rf ${log_dir} || : ${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir} - ${csudo}ln -s ${log_dir} ${install_main_dir}/log + ${csudo}ln -sf ${log_dir} ${install_main_dir}/log } function install_data() { ${csudo}mkdir -p ${data_dir} - ${csudo}ln -s ${data_dir} ${install_main_dir}/data + ${csudo}ln -sf ${data_dir} ${install_main_dir}/data } function install_connector() { - [ -d "${script_dir}/connector/" ] && ${csudo}cp -rf ${script_dir}/connector/ ${install_main_dir}/ + if [ -d "${script_dir}/connector/" ]; then + ${csudo}cp -rf ${script_dir}/connector/ ${install_main_dir}/ || echo "failed to copy connector" + fi } function install_examples() { if [ -d ${script_dir}/examples ]; then - ${csudo}cp -rf ${script_dir}/examples/* ${install_main_dir}/examples + ${csudo}cp -rf ${script_dir}/examples/* ${install_main_dir}/examples || echo "failed to copy examples" fi } @@ -600,8 +605,8 @@ function install_web() { function clean_service_on_sysvinit() { - if ps aux | grep -v grep | grep ${serverName} &>/dev/null; then - ${csudo}service ${serverName} stop || : + if ps aux | grep -v grep | grep ${serverName2} &>/dev/null; then + ${csudo}service ${serverName2} stop || : fi if ps aux | grep -v grep | grep tarbitrator &>/dev/null; then @@ -609,30 +614,30 @@ function clean_service_on_sysvinit() { fi if ((${initd_mod} == 1)); then - if [ -e ${service_config_dir}/${serverName} ]; then - ${csudo}chkconfig --del ${serverName} || : + if [ -e ${service_config_dir}/${serverName2} ]; then + ${csudo}chkconfig --del ${serverName2} || : fi if [ -e ${service_config_dir}/tarbitratord ]; then ${csudo}chkconfig --del tarbitratord || : fi elif ((${initd_mod} == 2)); then - if [ -e ${service_config_dir}/${serverName} ]; then - ${csudo}insserv -r ${serverName} || : + if [ -e ${service_config_dir}/${serverName2} ]; then + ${csudo}insserv -r ${serverName2} || : fi if [ -e ${service_config_dir}/tarbitratord ]; then ${csudo}insserv -r tarbitratord || : fi elif ((${initd_mod} == 3)); then - if [ -e ${service_config_dir}/${serverName} ]; then - ${csudo}update-rc.d -f ${serverName} remove || : + if [ -e ${service_config_dir}/${serverName2} ]; then + ${csudo}update-rc.d -f ${serverName2} remove || : fi if [ -e ${service_config_dir}/tarbitratord ]; then ${csudo}update-rc.d -f tarbitratord remove || : fi fi - ${csudo}rm -f ${service_config_dir}/${serverName} || : + ${csudo}rm -f ${service_config_dir}/${serverName2} || : ${csudo}rm -f ${service_config_dir}/tarbitratord || : if $(which init &>/dev/null); then @@ -653,24 +658,24 @@ function install_service_on_sysvinit() { fi if ((${initd_mod} == 1)); then - ${csudo}chkconfig --add ${serverName} || : - ${csudo}chkconfig --level 2345 ${serverName} on || : + ${csudo}chkconfig --add ${serverName2} || : + ${csudo}chkconfig --level 2345 ${serverName2} on || : elif ((${initd_mod} == 2)); then - ${csudo}insserv ${serverName} || : - ${csudo}insserv -d ${serverName} || : + ${csudo}insserv ${serverName2} || : + ${csudo}insserv -d ${serverName2} || : elif ((${initd_mod} == 3)); then - ${csudo}update-rc.d ${serverName} defaults || : + ${csudo}update-rc.d ${serverName2} defaults || : fi } function clean_service_on_systemd() { - taosd_service_config="${service_config_dir}/${serverName}.service" - if systemctl is-active --quiet ${serverName}; then + service_config="${service_config_dir}/${serverName2}.service" + if systemctl is-active --quiet ${serverName2}; then echo "${productName} is running, stopping it..." - ${csudo}systemctl stop ${serverName} &>/dev/null || echo &>/dev/null + ${csudo}systemctl stop ${serverName2} &>/dev/null || echo &>/dev/null fi - ${csudo}systemctl disable ${serverName} &>/dev/null || echo &>/dev/null - ${csudo}rm -f ${taosd_service_config} + ${csudo}systemctl disable ${serverName2} &>/dev/null || echo &>/dev/null + ${csudo}rm -f ${service_config} tarbitratord_service_config="${service_config_dir}/tarbitratord.service" if systemctl is-active --quiet tarbitratord; then @@ -687,19 +692,19 @@ function clean_service_on_systemd() { function install_service_on_systemd() { clean_service_on_systemd - [ -f ${script_dir}/cfg/${serverName}.service ] && - ${csudo}cp ${script_dir}/cfg/${serverName}.service \ + [ -f ${script_dir}/cfg/${serverName2}.service ] && + ${csudo}cp ${script_dir}/cfg/${serverName2}.service \ ${service_config_dir}/ || : # if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then - # [ -f ${script_dir}/cfg/${serverName}.service ] && - # ${csudo}cp ${script_dir}/cfg/${serverName}.service \ + # [ -f ${script_dir}/cfg/${serverName2}.service ] && + # ${csudo}cp ${script_dir}/cfg/${serverName2}.service \ # ${service_config_dir}/${serverName2}.service || : # fi ${csudo}systemctl daemon-reload - ${csudo}systemctl enable ${serverName} + ${csudo}systemctl enable ${serverName2} ${csudo}systemctl daemon-reload } @@ -719,7 +724,7 @@ function install_service() { elif ((${service_mod} == 1)); then install_service_on_sysvinit else - kill_process ${serverName} + kill_process ${serverName2} fi } @@ -756,10 +761,10 @@ function is_version_compatible() { if [ -f ${script_dir}/driver/vercomp.txt ]; then min_compatible_version=$(cat ${script_dir}/driver/vercomp.txt) else - min_compatible_version=$(${script_dir}/bin/${serverName} -V | head -1 | cut -d ' ' -f 5) + min_compatible_version=$(${script_dir}/bin/${serverName2} -V | head -1 | cut -d ' ' -f 5) fi - exist_version=$(${installDir}/bin/${serverName} -V | head -1 | cut -d ' ' -f 3) + exist_version=$(${installDir}/bin/${serverName2} -V | head -1 | cut -d ' ' -f 3) vercomp $exist_version "3.0.0.0" case $? in 2) @@ -829,13 +834,13 @@ function updateProduct() { echo -e "${GREEN}Start to update ${productName2}...${NC}" # Stop the service if running - if ps aux | grep -v grep | grep ${serverName} &>/dev/null; then + if ps aux | grep -v grep | grep ${serverName2} &>/dev/null; then if ((${service_mod} == 0)); then - ${csudo}systemctl stop ${serverName} || : + ${csudo}systemctl stop ${serverName2} || : elif ((${service_mod} == 1)); then - ${csudo}service ${serverName} stop || : + ${csudo}service ${serverName2} stop || : else - kill_process ${serverName} + kill_process ${serverName2} fi sleep 1 fi @@ -862,21 +867,21 @@ function updateProduct() { openresty_work=false echo - echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${cfg_install_dir}/${configFile}" - [ -f ${configDir}/taosadapter.toml ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To configure Adapter ${NC}: edit ${configDir}/taosadapter.toml" + echo -e "${GREEN_DARK}To configure ${productName2} ${NC}: edit ${cfg_install_dir}/${configFile2}" + [ -f ${configDir}/${clientName2}adapter.toml ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ + echo -e "${GREEN_DARK}To configure ${clientName2} Adapter ${NC}: edit ${configDir}/${clientName2}adapter.toml" if ((${service_mod} == 0)); then - echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}systemctl start ${serverName}${NC}" - [ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start Adatper ${NC}: ${csudo}systemctl start taosadapter ${NC}" + echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${csudo}systemctl start ${serverName2}${NC}" + [ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ + echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: ${csudo}systemctl start ${clientName2}adapter ${NC}" elif ((${service_mod} == 1)); then - echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}service ${serverName} start${NC}" - [ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start Adapter ${NC}: ${csudo}service taosadapter start${NC}" + echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${csudo}service ${serverName2} start${NC}" + [ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ + echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: ${csudo}service ${clientName2}adapter start${NC}" else - echo -e "${GREEN_DARK}To start ${productName} ${NC}: ./${serverName}${NC}" - [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start ${clientName} Adapter ${NC}: taosadapter &${NC}" + echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ./${serverName2}${NC}" + [ -f ${installDir}/bin/${clientName2}adapter ] && \ + echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: ${clientName2}adapter &${NC}" fi if [ ${openresty_work} = 'true' ]; then @@ -887,7 +892,7 @@ function updateProduct() { if ((${prompt_force} == 1)); then echo "" - echo -e "${RED}Please run '${serverName} --force-keep-file' at first time for the exist ${productName} $exist_version!${NC}" + echo -e "${RED}Please run '${serverName2} --force-keep-file' at first time for the exist ${productName2} $exist_version!${NC}" fi echo echo -e "\033[44;32;1m${productName2} is updated successfully!${NC}" @@ -899,7 +904,7 @@ function updateProduct() { echo -e "\033[44;32;1m${productName2} client is updated successfully!${NC}" fi - rm -rf $(tar -tf ${tarName} | grep -v "^\./$") + rm -rf $(tar -tf ${tarName} | grep -Ev "^\./$|^\/") } function installProduct() { @@ -944,21 +949,21 @@ function installProduct() { # Ask if to start the service echo - echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${cfg_install_dir}/${configFile}" - [ -f ${configDir}/taosadapter.toml ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To configure Taos Adapter ${NC}: edit ${configDir}/taosadapter.toml" + echo -e "${GREEN_DARK}To configure ${productName2} ${NC}: edit ${cfg_install_dir}/${configFile2}" + [ -f ${configDir}/${clientName2}adapter.toml ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ + echo -e "${GREEN_DARK}To configure ${clientName2} Adapter ${NC}: edit ${configDir}/${clientName2}adapter.toml" if ((${service_mod} == 0)); then - echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}systemctl start ${serverName}${NC}" - [ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start Taos Adatper ${NC}: ${csudo}systemctl start taosadapter ${NC}" + echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${csudo}systemctl start ${serverName2}${NC}" + [ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ + echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: ${csudo}systemctl start ${clientName2}adapter ${NC}" elif ((${service_mod} == 1)); then - echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}service ${serverName} start${NC}" - [ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: ${csudo}service taosadapter start${NC}" + echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${csudo}service ${serverName2} start${NC}" + [ -f ${service_config_dir}/${clientName2}adapter.service ] && [ -f ${installDir}/bin/${clientName2}adapter ] && \ + echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: ${csudo}service ${clientName2}adapter start${NC}" else - echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}" - [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: taosadapter &${NC}" + echo -e "${GREEN_DARK}To start ${productName2} ${NC}: ${serverName2}${NC}" + [ -f ${installDir}/bin/${clientName2}adapter ] && \ + echo -e "${GREEN_DARK}To start ${clientName2} Adapter ${NC}: ${clientName2}adapter &${NC}" fi if [ ! -z "$firstEp" ]; then @@ -970,28 +975,28 @@ function installProduct() { tmpPort="" fi if [[ "$tmpPort" != "" ]]; then - echo -e "${GREEN_DARK}To access ${productName} ${NC}: ${clientName} -h $tmpFqdn -P $tmpPort${GREEN_DARK} to login into cluster, then${NC}" + echo -e "${GREEN_DARK}To access ${productName2} ${NC}: ${clientName2} -h $tmpFqdn -P $tmpPort${GREEN_DARK} to login into cluster, then${NC}" else - echo -e "${GREEN_DARK}To access ${productName} ${NC}: ${clientName} -h $tmpFqdn${GREEN_DARK} to login into cluster, then${NC}" + echo -e "${GREEN_DARK}To access ${productName2} ${NC}: ${clientName2} -h $tmpFqdn${GREEN_DARK} to login into cluster, then${NC}" fi echo -e "${GREEN_DARK}execute ${NC}: create dnode 'newDnodeFQDN:port'; ${GREEN_DARK}to add this new node${NC}" echo elif [ ! -z "$serverFqdn" ]; then - echo -e "${GREEN_DARK}To access ${productName} ${NC}: ${clientName} -h $serverFqdn${GREEN_DARK} to login into ${productName} server${NC}" + echo -e "${GREEN_DARK}To access ${productName2} ${NC}: ${clientName2} -h $serverFqdn${GREEN_DARK} to login into ${productName2} server${NC}" echo fi - echo -e "\033[44;32;1m${productName} is installed successfully!${NC}" + echo -e "\033[44;32;1m${productName2} is installed successfully!${NC}" echo else # Only install client install_bin install_config echo - echo -e "\033[44;32;1m${productName} client is installed successfully!${NC}" + echo -e "\033[44;32;1m${productName2} client is installed successfully!${NC}" fi touch ~/.${historyFile} - rm -rf $(tar -tf ${tarName} | grep -v "^\./$") + rm -rf $(tar -tf ${tarName} | grep -Ev "^\./$|^\/") } ## ==============================Main program starts from here============================ @@ -1002,7 +1007,7 @@ if [ "$verType" == "server" ]; then echo -e "\033[44;31;5mThe default data directory ${data_dir} contains old data of ${productName2} 2.x, please clear it before installing!\033[0m" else # Install server and client - if [ -x ${bin_dir}/${serverName} ]; then + if [ -x ${bin_dir}/${serverName2} ]; then update_flag=1 updateProduct else @@ -1012,7 +1017,7 @@ if [ "$verType" == "server" ]; then elif [ "$verType" == "client" ]; then interactiveFqdn=no # Only install client - if [ -x ${bin_dir}/${clientName} ]; then + if [ -x ${bin_dir}/${clientName2} ]; then update_flag=1 updateProduct client else diff --git a/packaging/tools/install_client.sh b/packaging/tools/install_client.sh index 1543c59297d663f0579d53f5c9778385cbef3ba8..53b9c80f10082a1aa70dc6aec54ea54b25be66f1 100755 --- a/packaging/tools/install_client.sh +++ b/packaging/tools/install_client.sh @@ -17,7 +17,7 @@ serverName="taosd" clientName="taos" uninstallScript="rmtaos" configFile="taos.cfg" -tarName="taos.tar.gz" +tarName="package.tar.gz" osType=Linux pagMode=full @@ -95,7 +95,7 @@ function install_main_path() { ${csudo}mkdir -p ${install_main_dir}/cfg ${csudo}mkdir -p ${install_main_dir}/bin ${csudo}mkdir -p ${install_main_dir}/driver - if [ $productName == "TDengine" ]; then + if [ "$productName2" == "TDengine" ]; then ${csudo}mkdir -p ${install_main_dir}/examples fi ${csudo}mkdir -p ${install_main_dir}/include @@ -118,18 +118,19 @@ function install_bin() { #Make link [ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName} || : if [ "$osType" != "Darwin" ]; then - [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/taosdemo || : + [ -x ${install_main_dir}/bin/${demoName2} ] && ${csudo}ln -s ${install_main_dir}/bin/${demoName2} ${bin_link_dir}/${demoName2} || : fi [ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_client.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 || : if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then #Make link - [ -x ${install_main_dir}/bin/${clientName} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName} ${bin_link_dir}/${clientName2} || : + [ -x ${install_main_dir}/bin/${clientName2} ] && ${csudo}ln -s ${install_main_dir}/bin/${clientName2} ${bin_link_dir}/${clientName2} || : if [ "$osType" != "Darwin" ]; then - [ -x ${install_main_dir}/bin/taosdemo ] && ${csudo}ln -s ${install_main_dir}/bin/taosdemo ${bin_link_dir}/${demoName2} || : + [ -x ${install_main_dir}/bin/${demoName2} ] && ${csudo}ln -s ${install_main_dir}/bin/${demoName2} ${bin_link_dir}/${demoName2} || : + [ -x ${install_main_dir}/bin/${benchmarkName2} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName2} ${bin_link_dir}/${benchmarkName2} || : fi - [ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove_client.sh ${bin_link_dir}/${uninstallScript2} || : + [ -x ${install_main_dir}/bin/remove_client.sh ] && ${csudo}ln -sf ${install_main_dir}/bin/remove_client.sh ${bin_link_dir}/${uninstallScript2} || : fi } @@ -305,7 +306,7 @@ function update_TDengine() { echo echo -e "\033[44;32;1m${productName2} client is updated successfully!${NC}" - rm -rf $(tar -tf ${tarName}) + rm -rf $(tar -tf ${tarName} | grep -Ev "^\./$|^\/") } function install_TDengine() { @@ -332,7 +333,7 @@ function install_TDengine() { echo echo -e "\033[44;32;1m${productName2} client is installed successfully!${NC}" - rm -rf $(tar -tf ${tarName}) + rm -rf $(tar -tf ${tarName} | grep -Ev "^\./$|^\/") } diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index 87c72c6a7c9985cffa13a112fbfbb5261d228632..98c5245cd39367203d7a8d8387b56846d1e19083 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -608,23 +608,23 @@ function update_TDengine() { echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${configDir}/${configFile}" [ -f ${configDir}/taosadapter.toml ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To configure Taos Adapter ${NC}: edit ${configDir}/taosadapter.toml" + echo -e "${GREEN_DARK}To configure Adapter ${NC}: edit ${configDir}/taosadapter.toml" if ((${service_mod} == 0)); then echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}systemctl start ${serverName}${NC}" [ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start Taos Adatper ${NC}: ${csudo}systemctl start taosadapter ${NC}" + echo -e "${GREEN_DARK}To start Adapter ${NC}: ${csudo}systemctl start taosadapter ${NC}" elif ((${service_mod} == 1)); then echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}service ${serverName} start${NC}" [ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: ${csudo}service taosadapter start${NC}" + echo -e "${GREEN_DARK}To start Adapter ${NC}: ${csudo}service taosadapter start${NC}" else if [ "$osType" != "Darwin" ]; then echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}" [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: taosadapter &${NC}" + echo -e "${GREEN_DARK}To start Adapter ${NC}: taosadapter &${NC}" else echo -e "${GREEN_DARK}To start service ${NC}: launchctl start com.tdengine.taosd${NC}" - echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: launchctl start com.tdengine.taosadapter${NC}" + echo -e "${GREEN_DARK}To start Adapter ${NC}: launchctl start com.tdengine.taosadapter${NC}" fi fi @@ -660,23 +660,23 @@ function install_TDengine() { echo echo -e "${GREEN_DARK}To configure ${productName} ${NC}: edit ${configDir}/${configFile}" [ -f ${configDir}/taosadapter.toml ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To configure Taos Adapter ${NC}: edit ${configDir}/taosadapter.toml" + echo -e "${GREEN_DARK}To configure Adapter ${NC}: edit ${configDir}/taosadapter.toml" if ((${service_mod} == 0)); then echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}systemctl start ${serverName}${NC}" [ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: ${csudo}systemctl start taosadapter ${NC}" + echo -e "${GREEN_DARK}To start Adapter ${NC}: ${csudo}systemctl start taosadapter ${NC}" elif ((${service_mod} == 1)); then echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${csudo}service ${serverName} start${NC}" [ -f ${service_config_dir}/taosadapter.service ] && [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: ${csudo}service taosadapter start${NC}" + echo -e "${GREEN_DARK}To start Adapter ${NC}: ${csudo}service taosadapter start${NC}" else if [ "$osType" != "Darwin" ]; then echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}" [ -f ${installDir}/bin/taosadapter ] && \ - echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: taosadapter &${NC}" + echo -e "${GREEN_DARK}To start Adapter ${NC}: taosadapter &${NC}" else echo -e "${GREEN_DARK}To start service ${NC}: launchctl start com.tdengine.taosd${NC}" - echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: launchctl start com.tdengine.taosadapter${NC}" + echo -e "${GREEN_DARK}To start Adapter ${NC}: launchctl start com.tdengine.taosadapter${NC}" fi fi diff --git a/packaging/tools/makeclient.sh b/packaging/tools/makeclient.sh index 208bfc183c91bba96be689fe6a475a5ae6e38649..b473f3b52728714276b8493ea0bc96094e880e34 100755 --- a/packaging/tools/makeclient.sh +++ b/packaging/tools/makeclient.sh @@ -2,7 +2,7 @@ # # Generate tar.gz package for linux client in all os system set -e -# set -x +set -x curr_dir=$(pwd) compile_dir=$1 @@ -23,8 +23,11 @@ clientName2="${12}" productName="TDengine" clientName="taos" +benchmarkName="taosBenchmark" configFile="taos.cfg" -tarName="taos.tar.gz" +tarName="package.tar.gz" + +benchmarkName2="${clientName2}Benchmark" if [ "$osType" != "Darwin" ]; then script_dir="$(dirname $(readlink -f $0))" @@ -53,11 +56,12 @@ fi # Directories and files. -if [ "$verMode" == "cluster" ]; then - sed -i 's/verMode=edge/verMode=cluster/g' ${script_dir}/remove_client.sh - sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" ${script_dir}/remove_client.sh - sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" ${script_dir}/remove_client.sh -fi +#if [ "$verMode" == "cluster" ]; then +# sed -i 's/verMode=edge/verMode=cluster/g' ${script_dir}/remove_client.sh +# sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" ${script_dir}/remove_client.sh +# sed -i "s/configFile2=\"taos\"/configFile2=\"${clientName2}\"/g" ${script_dir}/remove_client.sh +# sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" ${script_dir}/remove_client.sh +#fi if [ "$osType" != "Darwin" ]; then if [ "$pagMode" == "lite" ]; then @@ -66,6 +70,7 @@ if [ "$osType" != "Darwin" ]; then ${script_dir}/remove_client.sh" else bin_files="${build_dir}/bin/${clientName} \ + ${build_dir}/bin/${benchmarkName} \ ${script_dir}/remove_client.sh \ ${script_dir}/set_core.sh \ ${script_dir}/get_client.sh" @@ -153,6 +158,7 @@ if [ "$verMode" == "cluster" ]; then sed -i 's/verMode=edge/verMode=cluster/g' install_client_temp.sh sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" install_client_temp.sh sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" install_client_temp.sh + sed -i "s/configFile2=\"taos.cfg\"/configFile2=\"${clientName2}.cfg\"/g" install_client_temp.sh sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" install_client_temp.sh sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusEmail2}\"/g" install_client_temp.sh diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index 7ad3cf7b0aecf14bb984e98304bb78513bfb077b..1a1622cb9368c00a40105daa653639b94e46fb94 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -28,7 +28,7 @@ productName="TDengine" serverName="taosd" clientName="taos" configFile="taos.cfg" -tarName="taos.tar.gz" +tarName="package.tar.gz" dumpName="taosdump" benchmarkName="taosBenchmark" toolsName="taostools" @@ -51,9 +51,11 @@ fi if [ -d ${top_dir}/tools/taos-tools/packaging/deb ]; then cd ${top_dir}/tools/taos-tools/packaging/deb + + taostools_ver=$(git for-each-ref --sort=taggerdate --format '%(tag)' refs/tags|grep -v taos | tail -1) [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" - taostools_ver=$(git tag |grep -v taos | sort | tail -1) + taostools_ver=$(git for-each-ref --sort=taggerdate --format '%(tag)' refs/tags|grep -v taos | tail -1) taostools_install_dir="${release_dir}/${clientName2}Tools-${taostools_ver}" cd ${curr_dir} @@ -96,7 +98,7 @@ else ${taostools_bin_files} \ ${taosx_bin} \ ${explorer_bin_files} \ - ${build_dir}/bin/taosadapter \ + ${build_dir}/bin/${clientName}adapter \ ${build_dir}/bin/udfd \ ${script_dir}/remove.sh \ ${script_dir}/set_core.sh \ @@ -135,12 +137,12 @@ mkdir -p ${install_dir}/inc && cp ${header_files} ${install_dir}/inc mkdir -p ${install_dir}/cfg && cp ${cfg_dir}/${configFile} ${install_dir}/cfg/${configFile} -if [ -f "${compile_dir}/test/cfg/taosadapter.toml" ]; then - cp ${compile_dir}/test/cfg/taosadapter.toml ${install_dir}/cfg || : +if [ -f "${compile_dir}/test/cfg/${clientName}adapter.toml" ]; then + cp ${compile_dir}/test/cfg/${clientName}adapter.toml ${install_dir}/cfg || : fi -if [ -f "${compile_dir}/test/cfg/taosadapter.service" ]; then - cp ${compile_dir}/test/cfg/taosadapter.service ${install_dir}/cfg || : +if [ -f "${compile_dir}/test/cfg/${clientName}adapter.service" ]; then + cp ${compile_dir}/test/cfg/${clientName}adapter.service ${install_dir}/cfg || : fi if [ -f "${cfg_dir}/${serverName}.service" ]; then @@ -152,16 +154,16 @@ mkdir -p ${install_dir}/init.d && cp ${init_file_deb} ${install_dir}/init.d/${se mkdir -p ${install_dir}/init.d && cp ${init_file_rpm} ${install_dir}/init.d/${serverName}.rpm if [ $adapterName != "taosadapter" ]; then - mv ${install_dir}/cfg/taosadapter.toml ${install_dir}/cfg/$adapterName.toml + mv ${install_dir}/cfg/${clientName2}adapter.toml ${install_dir}/cfg/$adapterName.toml sed -i "s/path = \"\/var\/log\/taos\"/path = \"\/var\/log\/${productName}\"/g" ${install_dir}/cfg/$adapterName.toml sed -i "s/password = \"taosdata\"/password = \"${defaultPasswd}\"/g" ${install_dir}/cfg/$adapterName.toml - mv ${install_dir}/cfg/taosadapter.service ${install_dir}/cfg/$adapterName.service + mv ${install_dir}/cfg/${clientName2}adapter.service ${install_dir}/cfg/$adapterName.service sed -i "s/TDengine/${productName}/g" ${install_dir}/cfg/$adapterName.service sed -i "s/taosAdapter/${adapterName}/g" ${install_dir}/cfg/$adapterName.service sed -i "s/taosadapter/${adapterName}/g" ${install_dir}/cfg/$adapterName.service - mv ${install_dir}/bin/taosadapter ${install_dir}/bin/${adapterName} + mv ${install_dir}/bin/${clientName2}adapter ${install_dir}/bin/${adapterName} mv ${install_dir}/bin/taosd-dump-cfg.gdb ${install_dir}/bin/${serverName}-dump-cfg.gdb fi @@ -171,22 +173,22 @@ if [ -n "${taostools_bin_files}" ]; then && cp ${taostools_bin_files} ${taostools_install_dir}/bin \ && chmod a+x ${taostools_install_dir}/bin/* || : - if [ -f ${top_dir}/tools/taos-tools/packaging/tools/install-taostools.sh ]; then - cp ${top_dir}/tools/taos-tools/packaging/tools/install-taostools.sh \ + if [ -f ${top_dir}/tools/taos-tools/packaging/tools/install-tools.sh ]; then + cp ${top_dir}/tools/taos-tools/packaging/tools/install-tools.sh \ ${taostools_install_dir}/ > /dev/null \ - && chmod a+x ${taostools_install_dir}/install-taostools.sh \ - || echo -e "failed to copy install-taostools.sh" + && chmod a+x ${taostools_install_dir}/install-tools.sh \ + || echo -e "failed to copy install-tools.sh" else - echo -e "install-taostools.sh not found" + echo -e "install-tools.sh not found" fi - if [ -f ${top_dir}/tools/taos-tools/packaging/tools/uninstall-taostools.sh ]; then - cp ${top_dir}/tools/taos-tools/packaging/tools/uninstall-taostools.sh \ + if [ -f ${top_dir}/tools/taos-tools/packaging/tools/uninstall-tools.sh ]; then + cp ${top_dir}/tools/taos-tools/packaging/tools/uninstall-tools.sh \ ${taostools_install_dir}/ > /dev/null \ - && chmod a+x ${taostools_install_dir}/uninstall-taostools.sh \ - || echo -e "failed to copy uninstall-taostools.sh" + && chmod a+x ${taostools_install_dir}/uninstall-tools.sh \ + || echo -e "failed to copy uninstall-tools.sh" else - echo -e "uninstall-taostools.sh not found" + echo -e "uninstall-tools.sh not found" fi if [ -f ${build_dir}/lib/libavro.so.23.0.0 ]; then @@ -233,8 +235,10 @@ if [ "$verMode" == "cluster" ]; then sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/bin/remove.sh >>remove_temp.sh sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" remove_temp.sh sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" remove_temp.sh + sed -i "s/configFile2=\"taos.cfg\"/configFile2=\"${clientName2}.cfg\"/g" remove_temp.sh sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" remove_temp.sh - sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusEmail2}\"/g" remove_temp.sh + cusDomain=`echo "${cusEmail2}" | sed 's/^[^@]*@//'` + sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusDomain}\"/g" remove_temp.sh mv remove_temp.sh ${install_dir}/bin/remove.sh fi if [ "$verMode" == "cloud" ]; then @@ -262,8 +266,10 @@ if [ "$verMode" == "cluster" ]; then sed -i 's/verMode=edge/verMode=cluster/g' install_temp.sh sed -i "s/serverName2=\"taosd\"/serverName2=\"${serverName2}\"/g" install_temp.sh sed -i "s/clientName2=\"taos\"/clientName2=\"${clientName2}\"/g" install_temp.sh + sed -i "s/configFile2=\"taos.cfg\"/configFile2=\"${clientName2}.cfg\"/g" install_temp.sh sed -i "s/productName2=\"TDengine\"/productName2=\"${productName2}\"/g" install_temp.sh - sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusEmail2}\"/g" install_temp.sh + cusDomain=`echo "${cusEmail2}" | sed 's/^[^@]*@//'` + sed -i "s/emailName2=\"taosdata.com\"/emailName2=\"${cusDomain}\"/g" install_temp.sh mv install_temp.sh ${install_dir}/install.sh fi if [ "$verMode" == "cloud" ]; then diff --git a/packaging/tools/post.sh b/packaging/tools/post.sh index b2fc488a19bbf2c9425c4a48596326b2c7070dc2..3a013ade2cef2859151971d5da70ea4e0df6e681 100755 --- a/packaging/tools/post.sh +++ b/packaging/tools/post.sh @@ -145,6 +145,59 @@ function install_include() { log_print "install include success" } +function install_jemalloc() { + jemalloc_dir=${script_dir}/../jemalloc + + if [ -d ${jemalloc_dir} ]; then + ${csudo}/usr/bin/install -c -d /usr/local/bin + + if [ -f ${jemalloc_dir}/bin/jemalloc-config ]; then + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc-config /usr/local/bin + fi + if [ -f ${jemalloc_dir}/bin/jemalloc.sh ]; then + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jemalloc.sh /usr/local/bin + fi + if [ -f ${jemalloc_dir}/bin/jeprof ]; then + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/bin/jeprof /usr/local/bin + fi + if [ -f ${jemalloc_dir}/include/jemalloc/jemalloc.h ]; then + ${csudo}/usr/bin/install -c -d /usr/local/include/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/include/jemalloc/jemalloc.h /usr/local/include/jemalloc + fi + if [ -f ${jemalloc_dir}/lib/libjemalloc.so.2 ]; then + ${csudo}/usr/bin/install -c -d /usr/local/lib + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.so.2 /usr/local/lib + ${csudo}ln -sf libjemalloc.so.2 /usr/local/lib/libjemalloc.so + ${csudo}/usr/bin/install -c -d /usr/local/lib + if [ -f ${jemalloc_dir}/lib/libjemalloc.a ]; then + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc.a /usr/local/lib + fi + if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then + ${csudo}/usr/bin/install -c -m 755 ${jemalloc_dir}/lib/libjemalloc_pic.a /usr/local/lib + fi + if [ -f ${jemalloc_dir}/lib/libjemalloc_pic.a ]; then + ${csudo}/usr/bin/install -c -d /usr/local/lib/pkgconfig + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/lib/pkgconfig/jemalloc.pc /usr/local/lib/pkgconfig + fi + fi + if [ -f ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html ]; then + ${csudo}/usr/bin/install -c -d /usr/local/share/doc/jemalloc + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/doc/jemalloc/jemalloc.html /usr/local/share/doc/jemalloc + fi + if [ -f ${jemalloc_dir}/share/man/man3/jemalloc.3 ]; then + ${csudo}/usr/bin/install -c -d /usr/local/share/man/man3 + ${csudo}/usr/bin/install -c -m 644 ${jemalloc_dir}/share/man/man3/jemalloc.3 /usr/local/share/man/man3 + fi + + if [ -d /etc/ld.so.conf.d ]; then + echo "/usr/local/lib" | ${csudo}tee /etc/ld.so.conf.d/jemalloc.conf >/dev/null || echo -e "failed to write /etc/ld.so.conf.d/jemalloc.conf" + ${csudo}ldconfig + else + echo "/etc/ld.so.conf.d not found!" + fi + fi +} + function install_lib() { log_print "start install lib from ${lib_dir} to ${lib_link_dir}" ${csudo}rm -f ${lib_link_dir}/libtaos* || : @@ -534,7 +587,7 @@ function install_service_on_sysvinit() { function clean_service_on_systemd() { taosd_service_config="${service_config_dir}/taosd.service" - # taosd service already is stoped before install in preinst script + # taosd service already is stopped before install in preinst script #if systemctl is-active --quiet taosd; then # echo "TDengine is running, stopping it..." # ${csudo}systemctl stop taosd &> /dev/null || echo &> /dev/null @@ -586,6 +639,11 @@ function install_service_on_launchctl() { ${csudo}cp ${install_main_dir}/service/com.taosdata.taosadapter.plist /Library/LaunchDaemons/com.taosdata.taosadapter.plist || : ${csudo}launchctl load -w /Library/LaunchDaemons/com.taosdata.taosadapter.plist || : fi + if [ -f ${install_main_dir}/service/com.taosdata.taoskeeper.plist ]; then + ${csudo}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taoskeeper.plist > /dev/null 2>&1 || : + ${csudo}cp ${install_main_dir}/service/com.taosdata.taoskeeper.plist /Library/LaunchDaemons/com.taosdata.taoskeeper.plist || : + ${csudo}launchctl load -w /Library/LaunchDaemons/com.taosdata.taoskeeper.plist || : + fi } function install_taosadapter_service() { @@ -662,6 +720,7 @@ function install_TDengine() { # Install include, lib, binary and service install_include && install_lib && + install_jemalloc install_bin if [[ "$?" != 0 ]];then diff --git a/packaging/tools/release_note b/packaging/tools/release_note index 4578a4523c50f3b0764ce05add5920cf0be72172..81b09ba69c1485804e194a760e4aedde10014388 100644 --- a/packaging/tools/release_note +++ b/packaging/tools/release_note @@ -72,7 +72,7 @@ New Features: taos-1.4.13 (Released on 2018-12-14) Bugs Fixed: - - Clients failed to connect to server due to unexpected and invalid packets recieved by the server. + - Clients failed to connect to server due to unexpected and invalid packets received by the server. Features Added: - Add support to HikariCP in TSDB JDBC driver. diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index 2479e48670bacb014c9209c8db11c8b0e09f5889..8ed3bd74b9f6b822c15bf568256f5f80f2b8b618 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -40,11 +40,16 @@ serverName2="taosd" clientName2="taos" productName2="TDengine" +adapterName2="${clientName2}adapter" +demoName2="${clientName2}demo" benchmarkName2="${clientName2}Benchmark" dumpName2="${clientName2}dump" +keeperName2="${clientName2}keeper" +xName2="${clientName2}x" +explorerName2="${clientName2}-explorer" uninstallScript2="rm${clientName2}" -installDir="/usr/local/${clientName}" +installDir="/usr/local/${clientName2}" #install main path install_main_dir=${installDir} @@ -55,8 +60,8 @@ local_bin_link_dir="/usr/local/bin" service_config_dir="/etc/systemd/system" -taos_service_name=${serverName} -taosadapter_service_name="taosadapter" +taos_service_name=${serverName2} +taosadapter_service_name="${clientName2}adapter" tarbitrator_service_name="tarbitratord" csudo="" if command -v sudo >/dev/null; then @@ -84,14 +89,14 @@ else fi function kill_taosadapter() { - pid=$(ps -ef | grep "taosadapter" | grep -v "grep" | awk '{print $2}') + pid=$(ps -ef | grep "${adapterName2}" | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then ${csudo}kill -9 $pid || : fi } function kill_taosd() { - pid=$(ps -ef | grep ${serverName} | grep -v "grep" | awk '{print $2}') + pid=$(ps -ef | grep ${serverName2} | grep -v "grep" | awk '{print $2}') if [ -n "$pid" ]; then ${csudo}kill -9 $pid || : fi @@ -109,17 +114,17 @@ function clean_bin() { ${csudo}rm -f ${bin_link_dir}/${clientName} || : ${csudo}rm -f ${bin_link_dir}/${serverName} || : ${csudo}rm -f ${bin_link_dir}/udfd || : - ${csudo}rm -f ${bin_link_dir}/taosadapter || : - ${csudo}rm -f ${bin_link_dir}/taosBenchmark || : - ${csudo}rm -f ${bin_link_dir}/taosdemo || : - ${csudo}rm -f ${bin_link_dir}/taosdump || : - ${csudo}rm -f ${bin_link_dir}/${uninstallScript} || : + ${csudo}rm -f ${bin_link_dir}/${adapterName2} || : + ${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || : + ${csudo}rm -f ${bin_link_dir}/${demoName2} || : + ${csudo}rm -f ${bin_link_dir}/${dumpName2} || : + ${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}/TDinsight.sh || : - ${csudo}rm -f ${bin_link_dir}/taoskeeper || : - ${csudo}rm -f ${bin_link_dir}/taosx || : - ${csudo}rm -f ${bin_link_dir}/taos-explorer || : + ${csudo}rm -f ${bin_link_dir}/${keeperName2} || : + ${csudo}rm -f ${bin_link_dir}/${xName2} || : + ${csudo}rm -f ${bin_link_dir}/${explorerName2} || : if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then ${csudo}rm -f ${bin_link_dir}/${clientName2} || : @@ -130,8 +135,8 @@ function clean_bin() { } function clean_local_bin() { - ${csudo}rm -f ${local_bin_link_dir}/taosBenchmark || : - ${csudo}rm -f ${local_bin_link_dir}/taosdemo || : + ${csudo}rm -f ${local_bin_link_dir}/${benchmarkName2} || : + ${csudo}rm -f ${local_bin_link_dir}/${demoName2} || : } function clean_lib() { @@ -173,7 +178,7 @@ function clean_service_on_systemd() { ${csudo}systemctl disable ${taos_service_name} &>/dev/null || echo &>/dev/null ${csudo}rm -f ${taosd_service_config} - taosadapter_service_config="${service_config_dir}/taosadapter.service" + taosadapter_service_config="${service_config_dir}/${clientName2}adapter.service" if systemctl is-active --quiet ${taosadapter_service_name}; then echo "${productName2} ${clientName2}Adapter is running, stopping it..." ${csudo}systemctl stop ${taosadapter_service_name} &>/dev/null || echo &>/dev/null @@ -235,8 +240,8 @@ function clean_service_on_sysvinit() { function clean_service_on_launchctl() { ${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || : ${csudo}rm /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || : - ${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosadapter.plist > /dev/null 2>&1 || : - ${csudo}rm /Library/LaunchDaemons/com.taosdata.taosadapter.plist > /dev/null 2>&1 || : + ${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.${clientName2}adapter.plist > /dev/null 2>&1 || : + ${csudo}rm /Library/LaunchDaemons/com.taosdata.${clientName2}adapter.plist > /dev/null 2>&1 || : } function clean_service() { diff --git a/packaging/tools/remove_client.sh b/packaging/tools/remove_client.sh index 10a0fb5e02a7fbc10b05765d4036e76b0bd1e4c8..2bdb56fac210982048d630469fbb10942bc15f69 100755 --- a/packaging/tools/remove_client.sh +++ b/packaging/tools/remove_client.sh @@ -15,11 +15,12 @@ uninstallScript="rmtaos" clientName2="taos" productName2="TDengine" -benchmarkName2="${clientName}Benchmark" -dumpName2="${clientName}dump" -uninstallScript2="rm${clientName}" +benchmarkName2="${clientName2}Benchmark" +demoName2="${clientName2}demo" +dumpName2="${clientName2}dump" +uninstallScript2="rm${clientName2}" -installDir="/usr/local/${clientName}" +installDir="/usr/local/${clientName2}" #install main path install_main_dir=${installDir} @@ -44,14 +45,17 @@ function kill_client() { function clean_bin() { # Remove link - ${csudo}rm -f ${bin_link_dir}/${clientName} || : - ${csudo}rm -f ${bin_link_dir}/taosdemo || : - ${csudo}rm -f ${bin_link_dir}/taosdump || : + ${csudo}rm -f ${bin_link_dir}/${clientName2} || : + ${csudo}rm -f ${bin_link_dir}/${demoName2} || : + ${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || : + ${csudo}rm -f ${bin_link_dir}/${dumpName2} || : ${csudo}rm -f ${bin_link_dir}/${uninstallScript} || : ${csudo}rm -f ${bin_link_dir}/set_core || : if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then ${csudo}rm -f ${bin_link_dir}/${clientName2} || : + ${csudo}rm -f ${bin_link_dir}/${demoName2} || : + ${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || : ${csudo}rm -f ${bin_link_dir}/${dumpName2} || : ${csudo}rm -f ${bin_link_dir}/${uninstallScript2} || : fi diff --git a/packaging/tools/repair_link.sh b/packaging/tools/repair_link.sh index 7fd503f27013a9fce7208ece4335a1f427e05c9d..d71a16023eaabb3248283ed54a786a7cf0caf728 100755 --- a/packaging/tools/repair_link.sh +++ b/packaging/tools/repair_link.sh @@ -8,7 +8,7 @@ read -p "Please enter link directory such as /var/lib/taos/tsdb: " linkDir while true; do if [ ! -d $linkDir ]; then - read -p "Paht not exists, please enter the correct link path:" linkDir + read -p "Path not exists, please enter the correct link path:" linkDir continue fi break @@ -28,12 +28,12 @@ for linkFile in $(find -L $linkDir -xtype l); do if [ -z "${dirHash["$dirName"]}" ]; then read -p "Please enter the directory to replace ${dirName}:" newDir - read -p "Do you want to replcace all[y/N]?" replcaceAll - if [[ ( "${replcaceAll}" == "y") || ( "${replcaceAll}" == "Y") ]]; then + read -p "Do you want to replace all[y/N]?" replaceAll + if [[ ( "${replaceAll}" == "y") || ( "${replaceAll}" == "Y") ]]; then dirHash["$dirName"]="$newDir" fi fi - # Replcace the file + # Replace the file ln -sf "${newDir}/${baseName}" "${linkFile}" done diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index b10daa9c210ed1a39198a3cf1d0f59ab77be6bee..86db35b4123c87c3d3f6d546caa15e70d09884e4 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -287,22 +287,25 @@ static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) { } static FORCE_INLINE SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4) { - SMqRspObj* msg = (SMqRspObj*)res; - msg->resIter++; - if (msg->resIter < msg->rsp.blockNum) { - SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(msg->rsp.blockData, msg->resIter); - if (msg->rsp.withSchema) { - SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(msg->rsp.blockSchema, msg->resIter); - setResSchemaInfo(&msg->resInfo, pSW->pSchema, pSW->nCols); - taosMemoryFreeClear(msg->resInfo.row); - taosMemoryFreeClear(msg->resInfo.pCol); - taosMemoryFreeClear(msg->resInfo.length); - taosMemoryFreeClear(msg->resInfo.convertBuf); - taosMemoryFreeClear(msg->resInfo.convertJson); + SMqRspObj* pRspObj = (SMqRspObj*)res; + pRspObj->resIter++; + + if (pRspObj->resIter < pRspObj->rsp.blockNum) { + SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(pRspObj->rsp.blockData, pRspObj->resIter); + if (pRspObj->rsp.withSchema) { + SSchemaWrapper* pSW = (SSchemaWrapper*)taosArrayGetP(pRspObj->rsp.blockSchema, pRspObj->resIter); + setResSchemaInfo(&pRspObj->resInfo, pSW->pSchema, pSW->nCols); + taosMemoryFreeClear(pRspObj->resInfo.row); + taosMemoryFreeClear(pRspObj->resInfo.pCol); + taosMemoryFreeClear(pRspObj->resInfo.length); + taosMemoryFreeClear(pRspObj->resInfo.convertBuf); + taosMemoryFreeClear(pRspObj->resInfo.convertJson); } - setQueryResultFromRsp(&msg->resInfo, pRetrieve, convertUcs4, false); - return &msg->resInfo; + + setQueryResultFromRsp(&pRspObj->resInfo, pRetrieve, convertUcs4, false); + return &pRspObj->resInfo; } + return NULL; } diff --git a/source/client/inc/clientSml.h b/source/client/inc/clientSml.h index d8d41d8be6e75c32c7c5da06dbcfca5c508a8b62..92896e6f23ffd0b37e3387ac800417519f19dd6a 100644 --- a/source/client/inc/clientSml.h +++ b/source/client/inc/clientSml.h @@ -70,7 +70,7 @@ extern "C" { #define VALUE_LEN 6 #define OTD_JSON_FIELDS_NUM 4 -#define MAX_RETRY_TIMES 5 +#define MAX_RETRY_TIMES 100 typedef TSDB_SML_PROTOCOL_TYPE SMLProtocolType; typedef enum { diff --git a/source/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h b/source/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h index a88bf0f7a6bfd74bc92a82e57a44c5fc2957f6a8..2921afc3f827d233b2b4a6fd0d2886e97dfaf325 100644 --- a/source/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h +++ b/source/client/jni/com_taosdata_jdbc_TSDBJNIConnector.h @@ -75,6 +75,14 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_connectImp(JNIEn */ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp(JNIEnv *, jobject, jbyteArray, jlong); +/* + * Class: com_taosdata_jdbc_TSDBJNIConnector + * Method: executeQueryWithReqId + * Signature: ([BJJ)I + */ +JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryWithReqId(JNIEnv *, jobject, jbyteArray, + jlong, jlong); + /* * Class: com_taosdata_jdbc_TSDBJNIConnector * Method: getErrCodeImp @@ -186,6 +194,14 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab */ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_prepareStmtImp(JNIEnv *, jobject, jbyteArray, jlong); +/* + * Class: com_taosdata_jdbc_TSDBJNIConnector + * Method: prepareStmtWithReqId + * Signature: ([BJJ)I + */ +JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_prepareStmtWithReqId(JNIEnv *, jobject, jbyteArray, + jlong, jlong); + /* * Class: com_taosdata_jdbc_TSDBJNIConnector * Method: setBindTableNameImp @@ -260,6 +276,32 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(JN JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertImp(JNIEnv *, jobject, jobjectArray, jlong, jint, jint); +JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertWithReqId(JNIEnv *, jobject, jlong, + jobjectArray, jint, jint, + jlong); + +JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertWithTtl(JNIEnv *, jobject, jlong, + jobjectArray, jint, jint, jint); + +JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertWithTtlAndReqId(JNIEnv *, jobject, + jlong, jobjectArray, + jint, jint, jint, + jlong); + +JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertRaw(JNIEnv *, jobject, jlong, jstring, + jint, jint); + +JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertRawWithReqId(JNIEnv *, jobject, jlong, + jstring, jint, jint, + jlong); + +JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertRawWithTtl(JNIEnv *, jobject, jlong, + jstring, jint, jint, jint); + +JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertRawWithTtlAndReqId(JNIEnv *, jobject, + jlong, jstring, + jint, jint, jint, + jlong); /** * Class: com_taosdata_jdbc_TSDBJNIConnector * Method: getTableVgID diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index e3e20ee85d4de996b664ccbaeed7514a992c9937..874ac12f5c97befe568e6c6488ca52f1fb32f34c 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -30,6 +30,10 @@ #include "tsched.h" #include "ttime.h" +#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL) +#include "cus_name.h" +#endif + #define TSC_VAR_NOT_RELEASE 1 #define TSC_VAR_RELEASED 0 @@ -541,9 +545,15 @@ void taos_init_imp(void) { deltaToUtcInitOnce(); - if (taosCreateLog("taoslog", 10, configDir, NULL, NULL, NULL, NULL, 1) != 0) { + char logDirName[64] = {0}; +#ifdef CUS_PROMPT + snprintf(logDirName, 64, "%slog", CUS_PROMPT); +#else + snprintf(logDirName, 64, "taoslog"); +#endif + if (taosCreateLog(logDirName, 10, configDir, NULL, NULL, NULL, NULL, 1) != 0) { // ignore create log failed, only print - printf(" WARING: Create taoslog failed. configDir=%s\n", configDir); + printf(" WARING: Create %s failed:%s. configDir=%s\n", logDirName, strerror(errno), configDir); } if (taosInitCfg(configDir, NULL, NULL, NULL, NULL, 1) != 0) { diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index d5247d4b8aaeeddda1768ecc02b565e26da11446..dac44bd9c4511261124d43d19db214cac3300b49 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1085,6 +1085,10 @@ static int32_t asyncExecSchQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaDat tscDebug("0x%" PRIx64 " plan not executed, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code), pRequest->requestId); destorySqlCallbackWrapper(pWrapper); + if (TSDB_CODE_SUCCESS != code) { + pRequest->code = terrno; + } + pRequest->body.queryFp(pRequest->body.param, pRequest, code); } @@ -1132,11 +1136,6 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM pRequest->body.queryFp(pRequest->body.param, pRequest, -1); break; } - - // TODO weired responding code? - if (TSDB_CODE_SUCCESS != code) { - pRequest->code = terrno; - } } int32_t refreshMeta(STscObj* pTscObj, SRequestObj* pRequest) { diff --git a/source/client/src/clientJniConnector.c b/source/client/src/clientJniConnector.c index cfa6f84bd242199a332dbc3da8675dd18b0407cd..2f4bafe26aa29a48e7c51c82275f14dba15a400d 100644 --- a/source/client/src/clientJniConnector.c +++ b/source/client/src/clientJniConnector.c @@ -55,7 +55,7 @@ jclass g_tmqClass; jmethodID g_createConsumerErrorCallback; jmethodID g_topicListCallback; -jclass g_consumerClass; +jclass g_consumerClass; // deprecated jmethodID g_commitCallback; @@ -331,13 +331,58 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryImp( int32_t code = taos_errno(tres); if (code != TSDB_CODE_SUCCESS) { - jniError("jobj:%p, conn:%p, code:%s, msg:%s", jobj, tscon, tstrerror(code), taos_errstr(tres)); + jniError("jobj:%p, conn:%p, code:0x%x, msg:%s", jobj, tscon, code, taos_errstr(tres)); } else { if (taos_is_update_query(tres)) { int32_t affectRows = taos_affected_rows(tres); - jniDebug("jobj:%p, conn:%p, code:%s, affect rows:%d", jobj, tscon, tstrerror(code), affectRows); + jniDebug("jobj:%p, conn:%p, code:0x%x, affect rows:%d", jobj, tscon, code, affectRows); } else { - jniDebug("jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code)); + jniDebug("jobj:%p, conn:%p, code:0x%x", jobj, tscon, code); + } + } + + taosMemoryFreeClear(str); + return (jlong)tres; +} + +JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeQueryWithReqId(JNIEnv *env, jobject jobj, + jbyteArray jsql, jlong con, + jlong reqId) { + TAOS *tscon = (TAOS *)con; + if (tscon == NULL) { + jniError("jobj:%p, connection already closed", jobj); + return JNI_CONNECTION_NULL; + } + + if (jsql == NULL) { + jniError("jobj:%p, conn:%p, empty sql string", jobj, tscon); + return JNI_SQL_NULL; + } + + jsize len = (*env)->GetArrayLength(env, jsql); + + char *str = (char *)taosMemoryCalloc(1, sizeof(char) * (len + 1)); + if (str == NULL) { + jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon); + return JNI_OUT_OF_MEMORY; + } + + (*env)->GetByteArrayRegion(env, jsql, 0, len, (jbyte *)str); + if ((*env)->ExceptionCheck(env)) { + // todo handle error + } + + TAOS_RES *tres = taos_query_with_reqid(tscon, str, reqId); + int32_t code = taos_errno(tres); + + if (code != TSDB_CODE_SUCCESS) { + jniError("jobj:%p, conn:%p, code:0x%x, msg:%s", jobj, tscon, code, taos_errstr(tres)); + } else { + if (taos_is_update_query(tres)) { + int32_t affectRows = taos_affected_rows(tres); + jniDebug("jobj:%p, conn:%p, code:0x%x, affect rows:%d", jobj, tscon, code, affectRows); + } else { + jniDebug("jobj:%p, conn:%p, code:0x%x", jobj, tscon, code); } } @@ -489,7 +534,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn numOfFields); return JNI_FETCH_END; } else { - jniDebug("jobj:%p, conn:%p, interrupted query. fetch row error code: %d, msg:%s", jobj, tscon, code, + jniDebug("jobj:%p, conn:%p, interrupted query. fetch row error code: 0x%x, msg:%s", jobj, tscon, code, taos_errstr(result)); return JNI_RESULT_SET_NULL; } @@ -575,21 +620,21 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchBlockImp(JNI TAOS_RES *tres = (TAOS_RES *)res; int32_t numOfFields = taos_num_fields(tres); - if(numOfFields <= 0){ - jniError("jobj:%p, conn:%p, query interrupted. taos_num_fields error code:%d, msg:%s", jobj, tscon, numOfFields, - taos_errstr(tres)); + if (numOfFields <= 0) { + jniError("jobj:%p, conn:%p, query interrupted. taos_num_fields error code: 0x%x, msg:%s", jobj, tscon, + taos_errno(tres), taos_errstr(tres)); return JNI_RESULT_SET_NULL; } - void *data; - int32_t numOfRows; + void *data = NULL; + int32_t numOfRows = 0; int error_code = taos_fetch_raw_block(tres, &numOfRows, &data); if (numOfRows == 0) { if (error_code == JNI_SUCCESS) { jniDebug("jobj:%p, conn:%p, resultset:%p, no data to retrieve", jobj, tscon, (void *)res); return JNI_FETCH_END; } else { - jniError("jobj:%p, conn:%p, query interrupted. fetch block error code:%d, msg:%s", jobj, tscon, error_code, + jniError("jobj:%p, conn:%p, query interrupted. fetch block error code: 0x%x, msg:%s", jobj, tscon, error_code, taos_errstr(tres)); return JNI_RESULT_SET_NULL; } @@ -639,7 +684,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_validateCreateTab } int code = taos_validate_sql(tscon, str); - jniDebug("jobj:%p, conn:%p, code is %d", jobj, tscon, code); + jniDebug("jobj:%p, conn:%p, code: 0x%x", jobj, tscon, code); taosMemoryFreeClear(str); return code; @@ -704,7 +749,45 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_prepareStmtImp(J int32_t code = taos_stmt_prepare(pStmt, str, len); taosMemoryFreeClear(str); if (code != TSDB_CODE_SUCCESS) { - jniError("prepareStmt jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code)); + jniError("prepareStmt jobj:%p, conn:%p, code: 0x%x", jobj, tscon, code); + return JNI_TDENGINE_ERROR; + } + + return (jlong)pStmt; +} + +JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_prepareStmtWithReqId(JNIEnv *env, jobject jobj, + jbyteArray jsql, jlong con, + jlong reqId) { + TAOS *tscon = (TAOS *)con; + if (tscon == NULL) { + jniError("jobj:%p, connection already closed", jobj); + return JNI_CONNECTION_NULL; + } + + if (jsql == NULL) { + jniError("jobj:%p, conn:%p, empty sql string", jobj, tscon); + return JNI_SQL_NULL; + } + + jsize len = (*env)->GetArrayLength(env, jsql); + + char *str = (char *)taosMemoryCalloc(1, sizeof(char) * (len + 1)); + if (str == NULL) { + jniError("jobj:%p, conn:%p, alloc memory failed", jobj, tscon); + return JNI_OUT_OF_MEMORY; + } + + (*env)->GetByteArrayRegion(env, jsql, 0, len, (jbyte *)str); + if ((*env)->ExceptionCheck(env)) { + // todo handle error + } + + TAOS_STMT *pStmt = taos_stmt_init_with_reqid(tscon, reqId); + int32_t code = taos_stmt_prepare(pStmt, str, len); + taosMemoryFreeClear(str); + if (code != TSDB_CODE_SUCCESS) { + jniError("prepareStmtWithReqId jobj:%p, conn:%p, code: 0x%x", jobj, tscon, code); return JNI_TDENGINE_ERROR; } @@ -732,7 +815,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setBindTableNameI if (code != TSDB_CODE_SUCCESS) { (*env)->ReleaseStringUTFChars(env, jname, name); - jniError("bindTableName jobj:%p, conn:%p, code:%s", jobj, tsconn, tstrerror(code)); + jniError("bindTableName jobj:%p, conn:%p, code: 0x%x", jobj, tsconn, code); return JNI_TDENGINE_ERROR; } @@ -807,7 +890,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setTableNameTagsI (*env)->ReleaseStringUTFChars(env, tableName, name); if (code != TSDB_CODE_SUCCESS) { - jniError("tableNameTags jobj:%p, conn:%p, code:%s", jobj, tsconn, tstrerror(code)); + jniError("tableNameTags jobj:%p, conn:%p, code: 0x%x", jobj, tsconn, code); return JNI_TDENGINE_ERROR; } return JNI_SUCCESS; @@ -873,7 +956,7 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_bindColDataImp( taosMemoryFreeClear(b); if (code != TSDB_CODE_SUCCESS) { - jniError("bindColData jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code)); + jniError("bindColData jobj:%p, conn:%p, code: 0x%x", jobj, tscon, code); return JNI_TDENGINE_ERROR; } @@ -896,7 +979,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_addBatchImp(JNIEn int32_t code = taos_stmt_add_batch(pStmt); if (code != TSDB_CODE_SUCCESS) { - jniError("add batch jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code)); + jniError("add batch jobj:%p, conn:%p, code: 0x%x", jobj, tscon, code); return JNI_TDENGINE_ERROR; } @@ -920,7 +1003,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_executeBatchImp(J int32_t code = taos_stmt_execute(pStmt); if (code != TSDB_CODE_SUCCESS) { - jniError("excute batch jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code)); + jniError("excute batch jobj:%p, conn:%p, code: 0x%x", jobj, tscon, code); return JNI_TDENGINE_ERROR; } @@ -944,7 +1027,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_closeStmt(JNIEnv int32_t code = taos_stmt_close(pStmt); if (code != TSDB_CODE_SUCCESS) { - jniError("close stmt jobj:%p, conn:%p, code:%s", jobj, tscon, tstrerror(code)); + jniError("close stmt jobj:%p, conn:%p, code: 0x%x", jobj, tscon, code); return JNI_TDENGINE_ERROR; } @@ -1006,12 +1089,9 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_insertLinesImp(JN TAOS_RES *tres = schemalessInsert(env, jobj, lines, taos, protocol, precision); - if (tres == NULL) { - return JNI_OUT_OF_MEMORY; - } int code = taos_errno(tres); if (code != TSDB_CODE_SUCCESS) { - jniError("jobj:%p, conn:%p, code:%s, msg:%s", jobj, taos, tstrerror(code), taos_errstr(tres)); + jniError("jobj:%p, conn:%p, code: 0x%x, msg:%s", jobj, taos, code, taos_errstr(tres)); taos_free_result(tres); return JNI_TDENGINE_ERROR; } @@ -1030,12 +1110,247 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsert } TAOS_RES *tres = schemalessInsert(env, jobj, lines, taos, protocol, precision); - if (tres == NULL) { + + return (jlong)tres; +} + +JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertWithReqId( + JNIEnv *env, jobject jobj, jlong conn, jobjectArray lines, jint protocol, jint precision, jlong reqId) { + TAOS *taos = (TAOS *)conn; + if (taos == NULL) { + jniError("jobj:%p, connection already closed", jobj); + return JNI_CONNECTION_NULL; + } + + int numLines = (*env)->GetArrayLength(env, lines); + char **c_lines = taosMemoryCalloc(numLines, sizeof(char *)); + if (c_lines == NULL) { + jniError("c_lines:%p, alloc memory failed", c_lines); + return JNI_OUT_OF_MEMORY; + } + + for (int i = 0; i < numLines; ++i) { + jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i)); + c_lines[i] = (char *)(*env)->GetStringUTFChars(env, line, 0); + } + + TAOS_RES *tres = taos_schemaless_insert_with_reqid(taos, c_lines, numLines, protocol, precision, reqId); + + for (int i = 0; i < numLines; ++i) { + jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i)); + (*env)->ReleaseStringUTFChars(env, line, c_lines[i]); + } + + taosMemoryFreeClear(c_lines); + + return (jlong)tres; +} + +JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertWithTtl(JNIEnv *env, jobject jobj, + jlong conn, jobjectArray lines, + jint protocol, jint precision, + jint ttl) { + TAOS *taos = (TAOS *)conn; + if (taos == NULL) { + jniError("jobj:%p, connection already closed", jobj); + return JNI_CONNECTION_NULL; + } + + int numLines = (*env)->GetArrayLength(env, lines); + char **c_lines = taosMemoryCalloc(numLines, sizeof(char *)); + if (c_lines == NULL) { + jniError("c_lines:%p, alloc memory failed", c_lines); return JNI_OUT_OF_MEMORY; } + + for (int i = 0; i < numLines; ++i) { + jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i)); + c_lines[i] = (char *)(*env)->GetStringUTFChars(env, line, 0); + } + + TAOS_RES *tres = taos_schemaless_insert_ttl(taos, c_lines, numLines, protocol, precision, ttl); + + for (int i = 0; i < numLines; ++i) { + jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i)); + (*env)->ReleaseStringUTFChars(env, line, c_lines[i]); + } + + taosMemoryFreeClear(c_lines); + return (jlong)tres; } +JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertWithTtlAndReqId( + JNIEnv *env, jobject jobj, jlong conn, jobjectArray lines, jint protocol, jint precision, jint ttl, jlong reqId) { + TAOS *taos = (TAOS *)conn; + if (taos == NULL) { + jniError("jobj:%p, connection already closed", jobj); + return JNI_CONNECTION_NULL; + } + + int numLines = (*env)->GetArrayLength(env, lines); + char **c_lines = taosMemoryCalloc(numLines, sizeof(char *)); + if (c_lines == NULL) { + jniError("c_lines:%p, alloc memory failed", c_lines); + return JNI_OUT_OF_MEMORY; + } + + for (int i = 0; i < numLines; ++i) { + jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i)); + c_lines[i] = (char *)(*env)->GetStringUTFChars(env, line, 0); + } + + TAOS_RES *tres = taos_schemaless_insert_ttl_with_reqid(taos, c_lines, numLines, protocol, precision, ttl, reqId); + + for (int i = 0; i < numLines; ++i) { + jstring line = (jstring)((*env)->GetObjectArrayElement(env, lines, i)); + (*env)->ReleaseStringUTFChars(env, line, c_lines[i]); + } + + taosMemoryFreeClear(c_lines); + + return (jlong)tres; +} + +JNIEXPORT jobject createSchemalessResp(JNIEnv *env, int totalRows, int code, const char *msg) { + // find class + jclass schemaless_clazz = (*env)->FindClass(env, "com/taosdata/jdbc/SchemalessResp"); + // find methods + jmethodID init_method = (*env)->GetMethodID(env, schemaless_clazz, "", "()V"); + jmethodID setCode_method = (*env)->GetMethodID(env, schemaless_clazz, "setCode", "(I)V"); + jmethodID setMsg_method = (*env)->GetMethodID(env, schemaless_clazz, "setMsg", "(Ljava/lang/String;)V"); + jmethodID setTotalRows_method = (*env)->GetMethodID(env, schemaless_clazz, "setTotalRows", "(I)V"); + // new schemaless + jobject schemaless_obj = (*env)->NewObject(env, schemaless_clazz, init_method); + // set code + (*env)->CallVoidMethod(env, schemaless_obj, setCode_method, code); + // set totalRows + (*env)->CallVoidMethod(env, schemaless_obj, setTotalRows_method, totalRows); + // set message + jstring message = (*env)->NewStringUTF(env, msg); + (*env)->CallVoidMethod(env, schemaless_obj, setMsg_method, message); + + return schemaless_obj; +} + +JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertRaw(JNIEnv *env, jobject jobj, + jlong conn, jstring data, + jint protocol, jint precision) { + TAOS *taos = (TAOS *)conn; + if (taos == NULL) { + jniError("jobj:%p, connection already closed", jobj); + char *msg = "JNI connection is NULL"; + return createSchemalessResp(env, 0, JNI_CONNECTION_NULL, msg); + } + + char *line = (char *)(*env)->GetStringUTFChars(env, data, NULL); + jint len = (*env)->GetStringUTFLength(env, data); + int32_t totalRows; + TAOS_RES *tres = taos_schemaless_insert_raw(taos, line, len, &totalRows, protocol, precision); + + (*env)->ReleaseStringUTFChars(env, data, line); + + // if (tres == NULL) { + // jniError("jobj:%p, schemaless raw insert failed", jobj); + // char *msg = "JNI schemaless raw insert return null"; + // return createSchemalessResp(env, 0, JNI_TDENGINE_ERROR, msg); + // } + + int code = taos_errno(tres); + if (code != TSDB_CODE_SUCCESS) { + jniError("jobj:%p, conn:%p, code: 0x%x, msg:%s", jobj, taos, code, taos_errstr(tres)); + taos_free_result(tres); + return createSchemalessResp(env, 0, code, taos_errstr(tres)); + } + taos_free_result(tres); + + return createSchemalessResp(env, totalRows, JNI_SUCCESS, NULL); +} + +JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertRawWithReqId( + JNIEnv *env, jobject jobj, jlong conn, jstring data, jint protocol, jint precision, jlong reqId) { + TAOS *taos = (TAOS *)conn; + if (taos == NULL) { + jniError("jobj:%p, connection already closed", jobj); + char *msg = "JNI connection is NULL"; + return createSchemalessResp(env, 0, JNI_CONNECTION_NULL, msg); + } + + char *line = (char *)(*env)->GetStringUTFChars(env, data, NULL); + jint len = (*env)->GetStringUTFLength(env, data); + int32_t totalRows; + TAOS_RES *tres = taos_schemaless_insert_raw_with_reqid(taos, line, len, &totalRows, protocol, precision, reqId); + + (*env)->ReleaseStringUTFChars(env, data, line); + + int code = taos_errno(tres); + if (code != TSDB_CODE_SUCCESS) { + jniError("jobj:%p, conn:%p, code: 0x%x, msg:%s", jobj, taos, code, taos_errstr(tres)); + taos_free_result(tres); + return createSchemalessResp(env, 0, code, taos_errstr(tres)); + } + taos_free_result(tres); + + return createSchemalessResp(env, totalRows, JNI_SUCCESS, NULL); +} + +JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertRawWithTtl(JNIEnv *env, jobject jobj, + jlong conn, jstring data, + jint protocol, + jint precision, jint ttl) { + TAOS *taos = (TAOS *)conn; + if (taos == NULL) { + jniError("jobj:%p, connection already closed", jobj); + char *msg = "JNI connection is NULL"; + return createSchemalessResp(env, 0, JNI_CONNECTION_NULL, msg); + } + + char *line = (char *)(*env)->GetStringUTFChars(env, data, NULL); + jint len = (*env)->GetStringUTFLength(env, data); + int32_t totalRows; + TAOS_RES *tres = taos_schemaless_insert_raw_ttl(taos, line, len, &totalRows, protocol, precision, ttl); + + (*env)->ReleaseStringUTFChars(env, data, line); + + int code = taos_errno(tres); + if (code != TSDB_CODE_SUCCESS) { + jniError("jobj:%p, conn:%p, code: 0x%x, msg:%s", jobj, taos, code, taos_errstr(tres)); + taos_free_result(tres); + return createSchemalessResp(env, 0, code, taos_errstr(tres)); + } + taos_free_result(tres); + + return createSchemalessResp(env, totalRows, JNI_SUCCESS, NULL); +} + +JNIEXPORT jobject JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_schemalessInsertRawWithTtlAndReqId( + JNIEnv *env, jobject jobj, jlong conn, jstring data, jint protocol, jint precision, jint ttl, jlong reqId) { + TAOS *taos = (TAOS *)conn; + if (taos == NULL) { + jniError("jobj:%p, connection already closed", jobj); + char *msg = "JNI connection is NULL"; + return createSchemalessResp(env, 0, JNI_CONNECTION_NULL, msg); + } + + char *line = (char *)(*env)->GetStringUTFChars(env, data, NULL); + jint len = (*env)->GetStringUTFLength(env, data); + int32_t totalRows; + TAOS_RES *tres = + taos_schemaless_insert_raw_ttl_with_reqid(taos, line, len, &totalRows, protocol, precision, ttl, reqId); + + (*env)->ReleaseStringUTFChars(env, data, line); + + int code = taos_errno(tres); + if (code != TSDB_CODE_SUCCESS) { + jniError("jobj:%p, conn:%p, code: 0x%x, msg:%s", jobj, taos, code, taos_errstr(tres)); + taos_free_result(tres); + return createSchemalessResp(env, 0, code, taos_errstr(tres)); + } + taos_free_result(tres); + + return createSchemalessResp(env, totalRows, JNI_SUCCESS, NULL); +} + // TABLE_VG_ID_FID_CACHE cache resp object for getTableVgID typedef struct TABLE_VG_ID_FIELD_CACHE { int cached; diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 63db9a679cdd0e312596b891a4a399db133aa00d..60c7b44b3d078e4102c6a6a5920f4fce61f8afbc 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -271,8 +271,6 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) { SReqResultInfo *pResultInfo; if (msg->resIter == -1) { pResultInfo = tmqGetNextResInfo(res, true); - tscDebug("consumer:0x%" PRIx64 ", vgId:%d, numOfRows:%" PRId64 ", total rows:%" PRId64, msg->rsp.head.consumerId, - msg->vgId, pResultInfo->numOfRows, pResultInfo->totalRows); } else { pResultInfo = tmqGetCurResInfo(res); } @@ -287,9 +285,6 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) { return NULL; } - tscDebug("consumer:0x%" PRIx64 " vgId:%d, numOfRows:%" PRId64 ", total rows:%" PRId64, msg->rsp.head.consumerId, - msg->vgId, pResultInfo->numOfRows, pResultInfo->totalRows); - doSetOneRowPtr(pResultInfo); pResultInfo->current += 1; return pResultInfo->row; @@ -611,6 +606,9 @@ 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) { + *numOfRows = 0; + *pData = NULL; + if (res == NULL || TD_RES_TMQ_META(res)) { return 0; } diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 21590022b13663f20a28f35565c0f69cdccba9f3..a0146cfa39fee78fee7287526a3a1c7ea7a8c2da 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -76,7 +76,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) { goto End; } - if ((code = taosCheckVersionCompatibleFromStr(version, connectRsp.sVer, 2)) != 0) { + if ((code = taosCheckVersionCompatibleFromStr(version, connectRsp.sVer, 3)) != 0) { setErrno(pRequest, code); tsem_post(&pRequest->body.rspSem); goto End; @@ -506,7 +506,7 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) { code = setQueryResultFromRsp(&pRequest->body.resInfo, pRes, false, true); } - if(code != 0){ + if (code != 0) { taosMemoryFree(pRes); } tFreeSShowVariablesRsp(&rsp); diff --git a/source/client/src/clientRawBlockWrite.c b/source/client/src/clientRawBlockWrite.c index a12f94cf1d88f3f52c958e20dfa130f98813da70..a09780dc153db0512d3c2678646397a68cafb53e 100644 --- a/source/client/src/clientRawBlockWrite.c +++ b/source/client/src/clientRawBlockWrite.c @@ -25,9 +25,7 @@ #include "tref.h" #include "ttimer.h" -static tb_uid_t processSuid(tb_uid_t suid, char* db){ - return suid + MurmurHash3_32(db, strlen(db)); -} +static tb_uid_t processSuid(tb_uid_t suid, char* db) { return suid + MurmurHash3_32(db, strlen(db)); } static char* buildCreateTableJson(SSchemaWrapper* schemaRow, SSchemaWrapper* schemaTag, char* name, int64_t id, int8_t t) { @@ -194,6 +192,7 @@ static char* processCreateStb(SMqMetaRsp* metaRsp) { SDecoder coder; char* string = NULL; + uDebug("processCreateStb called"); // decode and process req void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead)); int32_t len = metaRsp->metaRspLen - sizeof(SMsgHead); @@ -203,7 +202,7 @@ static char* processCreateStb(SMqMetaRsp* metaRsp) { goto _err; } string = buildCreateTableJson(&req.schemaRow, &req.schemaTag, req.name, req.suid, TSDB_SUPER_TABLE); - + uDebug("processCreateStb %s", string); _err: tDecoderClear(&coder); return string; @@ -213,6 +212,7 @@ static char* processAlterStb(SMqMetaRsp* metaRsp) { SVCreateStbReq req = {0}; SDecoder coder; char* string = NULL; + uDebug("processAlterStb called"); // decode and process req void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead)); @@ -223,6 +223,7 @@ static char* processAlterStb(SMqMetaRsp* metaRsp) { goto _err; } string = buildAlterSTableJson(req.alterOriData, req.alterOriDataLen); + uDebug("processAlterStb %s", string); _err: tDecoderClear(&coder); @@ -346,6 +347,7 @@ static char* processCreateTable(SMqMetaRsp* metaRsp) { SVCreateTbReq* pCreateReq; char* string = NULL; // decode + uDebug("processCreateTable called"); void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead)); int32_t len = metaRsp->metaRspLen - sizeof(SMsgHead); tDecoderInit(&decoder, data, len); @@ -362,6 +364,7 @@ static char* processCreateTable(SMqMetaRsp* metaRsp) { string = buildCreateTableJson(&pCreateReq->ntb.schemaRow, NULL, pCreateReq->name, pCreateReq->uid, TSDB_NORMAL_TABLE); } + uDebug("processCreateTable :%s", string); } _exit: @@ -377,6 +380,7 @@ _exit: } static char* processAutoCreateTable(STaosxRsp* rsp) { + uDebug("processAutoCreateTable called"); if (rsp->createTableNum <= 0) { uError("WriteRaw:processAutoCreateTable rsp->createTableNum <= 0"); goto _exit; @@ -402,7 +406,7 @@ static char* processAutoCreateTable(STaosxRsp* rsp) { } } string = buildCreateCTableJson(pCreateReq, rsp->createTableNum); - + uDebug("processAutoCreateTable :%s", string); _exit: for (int i = 0; i < rsp->createTableNum; i++) { tDecoderClear(&decoder[i]); @@ -422,6 +426,7 @@ static char* processAlterTable(SMqMetaRsp* metaRsp) { char* string = NULL; cJSON* json = NULL; + uDebug("processAlterTable called"); // decode void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead)); int32_t len = metaRsp->metaRspLen - sizeof(SMsgHead); @@ -527,6 +532,7 @@ static char* processAlterTable(SMqMetaRsp* metaRsp) { break; } string = cJSON_PrintUnformatted(json); + uDebug("processAlterTable :%s", string); _exit: cJSON_Delete(json); @@ -539,6 +545,7 @@ static char* processDropSTable(SMqMetaRsp* metaRsp) { SVDropStbReq req = {0}; char* string = NULL; cJSON* json = NULL; + uDebug("processDropSTable called"); // decode void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead)); @@ -560,7 +567,7 @@ static char* processDropSTable(SMqMetaRsp* metaRsp) { cJSON_AddItemToObject(json, "tableName", tableName); string = cJSON_PrintUnformatted(json); - + uDebug("processDropSTable :%s", string); _exit: cJSON_Delete(json); tDecoderClear(&decoder); @@ -573,6 +580,7 @@ static char* processDeleteTable(SMqMetaRsp* metaRsp) { cJSON* json = NULL; char* string = NULL; + uDebug("processDeleteTable called"); // decode and process req void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead)); int32_t len = metaRsp->metaRspLen - sizeof(SMsgHead); @@ -599,7 +607,7 @@ static char* processDeleteTable(SMqMetaRsp* metaRsp) { cJSON_AddItemToObject(json, "sql", sqlJson); string = cJSON_PrintUnformatted(json); - + uDebug("processDeleteTable :%s", string); _exit: cJSON_Delete(json); tDecoderClear(&coder); @@ -612,6 +620,7 @@ static char* processDropTable(SMqMetaRsp* metaRsp) { char* string = NULL; cJSON* json = NULL; + uDebug("processDropTable called"); // decode void* data = POINTER_SHIFT(metaRsp->metaRsp, sizeof(SMsgHead)); int32_t len = metaRsp->metaRspLen - sizeof(SMsgHead); @@ -641,7 +650,7 @@ static char* processDropTable(SMqMetaRsp* metaRsp) { cJSON_AddItemToObject(json, "tableNameList", tableNameList); string = cJSON_PrintUnformatted(json); - + uDebug("processDropTable :%s", string); _exit: cJSON_Delete(json); tDecoderClear(&decoder); @@ -655,6 +664,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) { int32_t code = TSDB_CODE_SUCCESS; SRequestObj* pRequest = NULL; + uDebug("taosCreateStb called"); code = buildRequest(*(int64_t*)taos, "", 0, NULL, false, &pRequest, 0); if (code != TSDB_CODE_SUCCESS) { goto end; @@ -698,6 +708,7 @@ static int32_t taosCreateStb(TAOS* taos, void* meta, int32_t metaLen) { pReq.source = TD_REQ_FROM_TAOX; pReq.igExists = true; + uDebug("taosCreateStb name:%s suid:%" PRId64 " processSuid:%" PRId64, req.name, req.suid, pReq.suid); STscObj* pTscObj = pRequest->pTscObj; SName tableName; tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name); @@ -744,6 +755,7 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) { int32_t code = TSDB_CODE_SUCCESS; SRequestObj* pRequest = NULL; + uDebug("taosDropStb called"); code = buildRequest(*(int64_t*)taos, "", 0, NULL, false, &pRequest, 0); if (code != TSDB_CODE_SUCCESS) { goto end; @@ -763,11 +775,37 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) { goto end; } + SCatalog* pCatalog = NULL; + code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); + if (code != TSDB_CODE_SUCCESS) { + goto end; + } + SRequestConnInfo conn = {.pTrans = pRequest->pTscObj->pAppInfo->pTransporter, + .requestId = pRequest->requestId, + .requestObjRefId = pRequest->self, + .mgmtEps = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp)}; + SName pName = {0}; + toName(pRequest->pTscObj->acctId, pRequest->pDb, req.name, &pName); + STableMeta* pTableMeta = NULL; + code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta); + if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) { + code = TSDB_CODE_SUCCESS; + taosMemoryFreeClear(pTableMeta); + goto end; + } + if (code != TSDB_CODE_SUCCESS) { + uError("taosCreateTable:catalogGetTableMeta failed. table name: %s", req.name); + goto end; + } + pReq.suid = pTableMeta->uid; + taosMemoryFreeClear(pTableMeta); + // build drop stable pReq.igNotExists = true; pReq.source = TD_REQ_FROM_TAOX; - pReq.suid = processSuid(req.suid, pRequest->pDb); + // pReq.suid = processSuid(req.suid, pRequest->pDb); + uDebug("taosDropStb name:%s suid:%" PRId64 " new suid:%" PRId64, req.name, req.suid, pReq.suid); STscObj* pTscObj = pRequest->pTscObj; SName tableName = {0}; tNameExtractFullName(toName(pTscObj->acctId, pRequest->pDb, req.name, &tableName), pReq.name); @@ -792,7 +830,7 @@ static int32_t taosDropStb(TAOS* taos, void* meta, int32_t metaLen) { launchQueryImpl(pRequest, &pQuery, true, NULL); if (pRequest->code == TSDB_CODE_SUCCESS) { - SCatalog* pCatalog = NULL; + // SCatalog* pCatalog = NULL; catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog); catalogRemoveTableMeta(pCatalog, &tableName); } @@ -825,6 +863,7 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { SQuery* pQuery = NULL; SHashObj* pVgroupHashmap = NULL; + uDebug("taosCreateTable called"); code = buildRequest(*(int64_t*)taos, "", 0, NULL, false, &pRequest, 0); if (code != TSDB_CODE_SUCCESS) { goto end; @@ -884,13 +923,17 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) { if (pCreateReq->type == TSDB_CHILD_TABLE) { STableMeta* pTableMeta = NULL; SName sName = {0}; - pCreateReq->ctb.suid = processSuid(pCreateReq->ctb.suid, pRequest->pDb); + tb_uid_t oldSuid = pCreateReq->ctb.suid; + // pCreateReq->ctb.suid = processSuid(pCreateReq->ctb.suid, pRequest->pDb); toName(pTscObj->acctId, pRequest->pDb, pCreateReq->ctb.stbName, &sName); code = catalogGetTableMeta(pCatalog, &conn, &sName, &pTableMeta); if (code != TSDB_CODE_SUCCESS) { uError("taosCreateTable:catalogGetTableMeta failed. table name: %s", pCreateReq->ctb.stbName); goto end; } + pCreateReq->ctb.suid = pTableMeta->uid; + uDebug("taosCreateTable name:%s sname:%s suid:%" PRId64 " new suid:%" PRId64, pCreateReq->name, + pCreateReq->ctb.stbName, oldSuid, pCreateReq->ctb.suid); for (int32_t i = 0; i < taosArrayGetSize(pCreateReq->ctb.tagName); i++) { char* tName = taosArrayGet(pCreateReq->ctb.tagName, i); @@ -979,6 +1022,7 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) { SQuery* pQuery = NULL; SHashObj* pVgroupHashmap = NULL; + uDebug("taosDropTable called"); code = buildRequest(*(int64_t*)taos, "", 0, NULL, false, &pRequest, 0); if (code != TSDB_CODE_SUCCESS) { goto end; @@ -1022,7 +1066,7 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) { for (int32_t iReq = 0; iReq < req.nReqs; iReq++) { pDropReq = req.pReqs + iReq; pDropReq->igNotExists = true; - pDropReq->suid = processSuid(pDropReq->suid, pRequest->pDb); + // pDropReq->suid = processSuid(pDropReq->suid, pRequest->pDb); SVgroupInfo pInfo = {0}; SName pName = {0}; @@ -1032,6 +1076,22 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) { goto end; } + STableMeta* pTableMeta = NULL; + code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta); + if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) { + code = TSDB_CODE_SUCCESS; + taosMemoryFreeClear(pTableMeta); + continue; + } + if (code != TSDB_CODE_SUCCESS) { + uError("taosDropTable:catalogGetTableMeta failed. table name: %s", pDropReq->name); + goto end; + } + tb_uid_t oldSuid = pDropReq->suid; + pDropReq->suid = pTableMeta->suid; + taosMemoryFreeClear(pTableMeta); + uDebug("taosDropTable name:%s suid:%" PRId64 " new suid:%" PRId64, pDropReq->name, oldSuid, pDropReq->suid); + taosArrayPush(pRequest->tableList, &pName); SVgroupDropTableBatch* pTableBatch = taosHashGet(pVgroupHashmap, &pInfo.vgId, sizeof(pInfo.vgId)); if (pTableBatch == NULL) { @@ -1046,6 +1106,9 @@ static int32_t taosDropTable(TAOS* taos, void* meta, int32_t metaLen) { } } + if (taosHashGetSize(pVgroupHashmap) == 0) { + goto end; + } SArray* pBufArray = serializeVgroupsDropTableBatch(pVgroupHashmap); if (NULL == pBufArray) { code = TSDB_CODE_OUT_OF_MEMORY; @@ -1114,6 +1177,7 @@ static int32_t taosDeleteData(TAOS* taos, void* meta, int32_t metaLen) { SDecoder coder = {0}; int32_t code = TSDB_CODE_SUCCESS; + uDebug("taosDeleteData called"); // decode and process req void* data = POINTER_SHIFT(meta, sizeof(SMsgHead)); int32_t len = metaLen - sizeof(SMsgHead); @@ -1151,6 +1215,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) { SArray* pArray = NULL; SVgDataBlocks* pVgData = NULL; + uDebug("taosAlterTable called"); code = buildRequest(*(int64_t*)taos, "", 0, NULL, false, &pRequest, 0); if (code != TSDB_CODE_SUCCESS) { @@ -1196,6 +1261,7 @@ static int32_t taosAlterTable(TAOS* taos, void* meta, int32_t metaLen) { goto end; } + uDebug("taosAlterTable name:%s", req.tbName); pArray = taosArrayInit(1, sizeof(void*)); if (NULL == pArray) { code = TSDB_CODE_OUT_OF_MEMORY; @@ -1261,6 +1327,7 @@ int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const ch STableMeta* pTableMeta = NULL; SQuery* pQuery = NULL; SHashObj* pVgHash = NULL; + uDebug("taos_write_raw_block_with_fields called"); SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0); if (!pRequest) { @@ -1280,6 +1347,7 @@ int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const ch tstrncpy(pName.dbname, pRequest->pDb, sizeof(pName.dbname)); tstrncpy(pName.tname, tbname, sizeof(pName.tname)); + uDebug("taos_write_raw_block_with_fields name:%s", tbname); struct SCatalog* pCatalog = NULL; code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); if (code != TSDB_CODE_SUCCESS) { @@ -1305,6 +1373,8 @@ int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const ch uError("WriteRaw:catalogGetTableMeta failed. table name: %s", tbname); goto end; } + // uError("td23101 0vgId:%d, vgId:%d, name:%s, uid:%"PRIu64, vgData.vgId, pTableMeta->vgId, tbname, pTableMeta->uid); + pQuery = smlInitHandle(); if (pQuery == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; @@ -1312,6 +1382,8 @@ int taos_write_raw_block_with_fields(TAOS* taos, int rows, char* pData, const ch } pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); taosHashPut(pVgHash, (const char*)&vgData.vgId, sizeof(vgData.vgId), (char*)&vgData, sizeof(vgData)); + // uError("td23101 1vgId:%d, numEps:%d, name:%s, uid:%"PRIu64, vgData.vgId, vgData.epSet.numOfEps, tbname, + // pTableMeta->uid); code = rawBlockBindData(pQuery, pTableMeta, pData, NULL, fields, numFields, false); if (code != TSDB_CODE_SUCCESS) { @@ -1342,6 +1414,7 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname) SQuery* pQuery = NULL; SHashObj* pVgHash = NULL; + uDebug("taos_write_raw_block called"); SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0); if (!pRequest) { uError("WriteRaw:createRequest error request is null"); @@ -1360,6 +1433,7 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname) tstrncpy(pName.dbname, pRequest->pDb, sizeof(pName.dbname)); tstrncpy(pName.tname, tbname, sizeof(pName.tname)); + uDebug("taos_write_raw_block name:%s", tbname); struct SCatalog* pCatalog = NULL; code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog); if (code != TSDB_CODE_SUCCESS) { @@ -1423,6 +1497,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { SMqRspObj rspObj = {0}; SDecoder decoder = {0}; STableMeta* pTableMeta = NULL; + uDebug("tmqWriteRawDataImpl called"); terrno = TSDB_CODE_SUCCESS; SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0); @@ -1468,7 +1543,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { goto end; } pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); - uDebug("raw data block num:%d\n", rspObj.rsp.blockNum); + uDebug("tmqWriteRawDataImpl raw data block num:%d", rspObj.rsp.blockNum); while (++rspObj.resIter < rspObj.rsp.blockNum) { SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter); if (!rspObj.rsp.withSchema) { @@ -1483,7 +1558,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { goto end; } - uDebug("raw data tbname:%s\n", tbName); + uDebug("tmqWriteRawDataImpl raw data tbname:%s", tbName); SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}}; strcpy(pName.dbname, pRequest->pDb); strcpy(pName.tname, tbName); @@ -1527,6 +1602,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) { uError("WriteRaw:rawBlockBindData failed"); goto end; } + taosMemoryFreeClear(pTableMeta); } code = smlBuildOutput(pQuery, pVgHash); @@ -1556,6 +1632,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) SDecoder decoder = {0}; STableMeta* pTableMeta = NULL; SVCreateTbReq* pCreateReqDst = NULL; + uDebug("tmqWriteRawMetaDataImpl called"); terrno = TSDB_CODE_SUCCESS; SRequestObj* pRequest = (SRequestObj*)createRequest(*(int64_t*)taos, TSDB_SQL_INSERT, 0); @@ -1602,7 +1679,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) } pVgHash = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); - uDebug("raw data block num:%d\n", rspObj.rsp.blockNum); + uDebug("tmqWriteRawMetaDataImpl raw data block num:%d", rspObj.rsp.blockNum); while (++rspObj.resIter < rspObj.rsp.blockNum) { SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(rspObj.rsp.blockData, rspObj.resIter); if (!rspObj.rsp.withSchema) { @@ -1617,7 +1694,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) goto end; } - uDebug("raw data tbname:%s\n", tbName); + uDebug("tmqWriteRawMetaDataImpl raw data tbname:%s\n", tbName); SName pName = {TSDB_TABLE_NAME_T, pRequest->pTscObj->acctId, {0}, {0}}; strcpy(pName.dbname, pRequest->pDb); strcpy(pName.tname, tbName); @@ -1632,6 +1709,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) tDecoderInit(&decoderTmp, *dataTmp, *lenTmp); if (tDecodeSVCreateTbReq(&decoderTmp, &pCreateReq) < 0) { tDecoderClear(&decoderTmp); + tDestroySVCreateTbReq(&pCreateReq, TSDB_MSG_FLG_DECODE); uError("WriteRaw: tDecodeSVCreateTbReq error"); code = TSDB_CODE_TMQ_INVALID_MSG; goto end; @@ -1640,21 +1718,30 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) if (pCreateReq.type != TSDB_CHILD_TABLE) { uError("WriteRaw:pCreateReq.type != TSDB_CHILD_TABLE. table name: %s", tbName); code = TSDB_CODE_TSC_INVALID_VALUE; + tDecoderClear(&decoderTmp); + tDestroySVCreateTbReq(&pCreateReq, TSDB_MSG_FLG_DECODE); goto end; } if (strcmp(tbName, pCreateReq.name) == 0) { cloneSVreateTbReq(&pCreateReq, &pCreateReqDst); - pCreateReqDst->ctb.suid = processSuid(pCreateReqDst->ctb.suid, pRequest->pDb); + // pCreateReqDst->ctb.suid = processSuid(pCreateReqDst->ctb.suid, pRequest->pDb); tDecoderClear(&decoderTmp); + tDestroySVCreateTbReq(&pCreateReq, TSDB_MSG_FLG_DECODE); break; } tDecoderClear(&decoderTmp); + tDestroySVCreateTbReq(&pCreateReq, TSDB_MSG_FLG_DECODE); } - if (pCreateReqDst) { + SVgroupInfo vg; + code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vg); + if (code != TSDB_CODE_SUCCESS) { + uError("WriteRaw:catalogGetTableHashVgroup failed. table name: %s", tbName); + goto end; + } + + if (pCreateReqDst) { // change stable name to get meta strcpy(pName.tname, pCreateReqDst->ctb.stbName); - } else { - strcpy(pName.tname, tbName); } code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta); if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) { @@ -1667,16 +1754,10 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) goto end; } - SVgroupInfo vg; - code = catalogGetTableHashVgroup(pCatalog, &conn, &pName, &vg); - if (code != TSDB_CODE_SUCCESS) { - uError("WriteRaw:catalogGetTableHashVgroup failed. table name: %s", tbName); - goto end; - } - if (pCreateReqDst) { pTableMeta->vgId = vg.vgId; pTableMeta->uid = pCreateReqDst->uid; + pCreateReqDst->ctb.suid = pTableMeta->suid; } void* hData = taosHashGet(pVgHash, &vg.vgId, sizeof(vg.vgId)); if (hData == NULL) { @@ -1700,6 +1781,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen) goto end; } pCreateReqDst = NULL; + taosMemoryFreeClear(pTableMeta); } code = smlBuildOutput(pQuery, pVgHash); @@ -1726,6 +1808,7 @@ end: } char* tmq_get_json_meta(TAOS_RES* res) { + uDebug("tmq_get_json_meta called"); if (!TD_RES_TMQ_META(res) && !TD_RES_TMQ_METADATA(res)) { return NULL; } @@ -1760,6 +1843,7 @@ char* tmq_get_json_meta(TAOS_RES* res) { void tmq_free_json_meta(char* jsonMeta) { taosMemoryFreeClear(jsonMeta); } int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) { + uDebug("tmq_get_raw called"); if (!raw || !res) { return TSDB_CODE_INVALID_PARA; } @@ -1768,6 +1852,7 @@ int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) { raw->raw = pMetaRspObj->metaRsp.metaRsp; raw->raw_len = pMetaRspObj->metaRsp.metaRspLen; raw->raw_type = pMetaRspObj->metaRsp.resMsgType; + uDebug("tmq_get_raw meta"); } else if (TD_RES_TMQ(res)) { SMqRspObj* rspObj = ((SMqRspObj*)res); @@ -1787,6 +1872,7 @@ int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) { raw->raw = buf; raw->raw_len = len; raw->raw_type = RES_TYPE__TMQ; + uDebug("tmq_get_raw data"); } else if (TD_RES_TMQ_METADATA(res)) { SMqTaosxRspObj* rspObj = ((SMqTaosxRspObj*)res); @@ -1806,19 +1892,23 @@ int32_t tmq_get_raw(TAOS_RES* res, tmq_raw_data* raw) { raw->raw = buf; raw->raw_len = len; raw->raw_type = RES_TYPE__TMQ_METADATA; + uDebug("tmq_get_raw meta data"); } else { + uError("tmq_get_raw error:%d", *(int8_t*)res); return TSDB_CODE_TMQ_INVALID_MSG; } return TSDB_CODE_SUCCESS; } void tmq_free_raw(tmq_raw_data raw) { + uDebug("tmq_free_raw raw_type:%d", raw.raw_type); if (raw.raw_type == RES_TYPE__TMQ || raw.raw_type == RES_TYPE__TMQ_METADATA) { taosMemoryFree(raw.raw); } } int32_t tmq_write_raw(TAOS* taos, tmq_raw_data raw) { + uDebug("tmq_write_raw called"); if (!taos) { return TSDB_CODE_INVALID_PARA; } diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index 885a0019cb64c2f7128f429579813a27f8421de9..ef7bd546c1a911200e1fa0e878ba21b43e0b19e0 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -117,7 +117,7 @@ int64_t smlGetTimeValue(const char *value, int32_t len, uint8_t fromPrecision, u if (unlikely(fromPrecision >= TSDB_TIME_PRECISION_HOURS)) { int64_t unit = smlToMilli[fromPrecision - TSDB_TIME_PRECISION_HOURS]; - if (unit > INT64_MAX / tsInt64) { + if (tsInt64 != 0 && unit > INT64_MAX / tsInt64) { return -1; } tsInt64 *= unit; @@ -256,20 +256,15 @@ cleanup: kvVal->type = TSDB_DATA_TYPE_FLOAT; \ kvVal->f = (float)result; -#define SET_BIGINT \ - if (smlDoubleToInt64OverFlow(result)) { \ - errno = 0; \ - int64_t tmp = taosStr2Int64(pVal, &endptr, 10); \ - if (errno == ERANGE) { \ - smlBuildInvalidDataMsg(msg, "big int out of range[-9223372036854775808,9223372036854775807]", pVal); \ - return false; \ - } \ - kvVal->type = TSDB_DATA_TYPE_BIGINT; \ - kvVal->i = tmp; \ - return true; \ - } \ - kvVal->type = TSDB_DATA_TYPE_BIGINT; \ - kvVal->i = (int64_t)result; +#define SET_BIGINT \ + errno = 0; \ + int64_t tmp = taosStr2Int64(pVal, &endptr, 10); \ + if (errno == ERANGE) { \ + smlBuildInvalidDataMsg(msg, "big int out of range[-9223372036854775808,9223372036854775807]", pVal); \ + return false; \ + } \ + kvVal->type = TSDB_DATA_TYPE_BIGINT; \ + kvVal->i = tmp; #define SET_INT \ if (!IS_VALID_INT(result)) { \ @@ -287,20 +282,15 @@ cleanup: kvVal->type = TSDB_DATA_TYPE_SMALLINT; \ kvVal->i = result; -#define SET_UBIGINT \ - if (result >= (double)UINT64_MAX || result < 0) { \ - errno = 0; \ - uint64_t tmp = taosStr2UInt64(pVal, &endptr, 10); \ - if (errno == ERANGE || result < 0) { \ - smlBuildInvalidDataMsg(msg, "unsigned big int out of range[0,18446744073709551615]", pVal); \ - return false; \ - } \ - kvVal->type = TSDB_DATA_TYPE_UBIGINT; \ - kvVal->u = tmp; \ - return true; \ - } \ - kvVal->type = TSDB_DATA_TYPE_UBIGINT; \ - kvVal->u = result; +#define SET_UBIGINT \ + errno = 0; \ + uint64_t tmp = taosStr2UInt64(pVal, &endptr, 10); \ + if (errno == ERANGE || result < 0) { \ + smlBuildInvalidDataMsg(msg, "unsigned big int out of range[0,18446744073709551615]", pVal); \ + return false; \ + } \ + kvVal->type = TSDB_DATA_TYPE_UBIGINT; \ + kvVal->u = tmp; #define SET_UINT \ if (!IS_VALID_UINT(result)) { \ @@ -637,7 +627,10 @@ static int32_t smlBuildFieldsList(SSmlHandle *info, SSchema *schemaField, SHashO for (int j = 0; j < taosArrayGetSize(cols); ++j) { SSmlKv *kv = (SSmlKv *)taosArrayGet(cols, j); ESchemaAction action = SCHEMA_ACTION_NULL; - smlGenerateSchemaAction(schemaField, schemaHash, kv, isTag, &action, info); + int code = smlGenerateSchemaAction(schemaField, schemaHash, kv, isTag, &action, info); + if (code != 0) { + return code; + } if (action == SCHEMA_ACTION_ADD_COLUMN || action == SCHEMA_ACTION_ADD_TAG) { SField field = {0}; field.type = kv->type; @@ -646,7 +639,11 @@ static int32_t smlBuildFieldsList(SSmlHandle *info, SSchema *schemaField, SHashO taosArrayPush(results, &field); } else if (action == SCHEMA_ACTION_CHANGE_COLUMN_SIZE || action == SCHEMA_ACTION_CHANGE_TAG_SIZE) { uint16_t *index = (uint16_t *)taosHashGet(schemaHash, kv->key, kv->keyLen); - uint16_t newIndex = *index; + if (index == NULL) { + uError("smlBuildFieldsList get error, key:%s", kv->key); + return TSDB_CODE_SML_INVALID_DATA; + } + uint16_t newIndex = *index; if (isTag) newIndex -= numOfCols; SField *field = (SField *)taosArrayGet(results, newIndex); field->bytes = getBytes(kv->type, kv->length); @@ -743,6 +740,8 @@ end: } static int32_t smlModifyDBSchemas(SSmlHandle *info) { + uDebug("SML:0x%" PRIx64 " smlModifyDBSchemas start, format:%d, needModifySchema:%d", info->id, info->dataFormat, + info->needModifySchema); if (info->dataFormat && !info->needModifySchema) { return TSDB_CODE_SUCCESS; } @@ -772,11 +771,19 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { code = catalogGetSTableMeta(info->pCatalog, &conn, &pName, &pTableMeta); if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST || code == TSDB_CODE_MND_STB_NOT_EXIST) { + uDebug("SML:0x%" PRIx64 " smlModifyDBSchemas create table:%s", info->id, pName.tname); SArray *pColumns = taosArrayInit(taosArrayGetSize(sTableData->cols), sizeof(SField)); SArray *pTags = taosArrayInit(taosArrayGetSize(sTableData->tags), sizeof(SField)); - smlBuildFieldsList(info, NULL, NULL, sTableData->tags, pTags, 0, true); - smlBuildFieldsList(info, NULL, NULL, sTableData->cols, pColumns, 0, false); - + code = smlBuildFieldsList(info, NULL, NULL, sTableData->tags, pTags, 0, true); + if (code != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " smlBuildFieldsList tag1 failed. %s", info->id, pName.tname); + goto end; + } + code = smlBuildFieldsList(info, NULL, NULL, sTableData->cols, pColumns, 0, false); + if (code != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " smlBuildFieldsList col1 failed. %s", info->id, pName.tname); + goto end; + } code = smlSendMetaMsg(info, &pName, pColumns, pTags, NULL, SCHEMA_ACTION_CREATE_STABLE); if (code != TSDB_CODE_SUCCESS) { uError("SML:0x%" PRIx64 " smlSendMetaMsg failed. can not create %s", info->id, pName.tname); @@ -804,6 +811,8 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { goto end; } if (action != SCHEMA_ACTION_NULL) { + uDebug("SML:0x%" PRIx64 " smlModifyDBSchemas change table tag, table:%s, action:%d", info->id, pName.tname, + action); SArray *pColumns = taosArrayInit(taosArrayGetSize(sTableData->cols) + pTableMeta->tableInfo.numOfColumns, sizeof(SField)); SArray *pTags = @@ -820,8 +829,12 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { taosArrayPush(pTags, &field); } } - smlBuildFieldsList(info, pTableMeta->schema, hashTmp, sTableData->tags, pTags, - pTableMeta->tableInfo.numOfColumns, true); + code = smlBuildFieldsList(info, pTableMeta->schema, hashTmp, sTableData->tags, pTags, + pTableMeta->tableInfo.numOfColumns, true); + if (code != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " smlBuildFieldsList tag2 failed. %s", info->id, pName.tname); + goto end; + } code = smlSendMetaMsg(info, &pName, pColumns, pTags, pTableMeta, action); if (code != TSDB_CODE_SUCCESS) { @@ -851,6 +864,8 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { goto end; } if (action != SCHEMA_ACTION_NULL) { + uDebug("SML:0x%" PRIx64 " smlModifyDBSchemas change table col, table:%s, action:%d", info->id, pName.tname, + action); SArray *pColumns = taosArrayInit(taosArrayGetSize(sTableData->cols) + pTableMeta->tableInfo.numOfColumns, sizeof(SField)); SArray *pTags = @@ -868,8 +883,12 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { } } - smlBuildFieldsList(info, pTableMeta->schema, hashTmp, sTableData->cols, pColumns, - pTableMeta->tableInfo.numOfColumns, false); + code = smlBuildFieldsList(info, pTableMeta->schema, hashTmp, sTableData->cols, pColumns, + pTableMeta->tableInfo.numOfColumns, false); + if (code != TSDB_CODE_SUCCESS) { + uError("SML:0x%" PRIx64 " smlBuildFieldsList col2 failed. %s", info->id, pName.tname); + goto end; + } code = smlSendMetaMsg(info, &pName, pColumns, pTags, pTableMeta, action); if (code != TSDB_CODE_SUCCESS) { @@ -913,15 +932,21 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) { } sTableData->tableMeta = pTableMeta; - - tmp = (SSmlSTableMeta **)taosHashIterate(info->superTables, tmp); + uDebug("SML:0x%" PRIx64 "modify schema uid:%" PRIu64 ", sversion:%d, tversion:%d", info->id, pTableMeta->uid, + pTableMeta->sversion, pTableMeta->tversion) tmp = (SSmlSTableMeta **)taosHashIterate(info->superTables, tmp); } + uDebug("SML:0x%" PRIx64 " smlModifyDBSchemas end success, format:%d, needModifySchema:%d", info->id, info->dataFormat, + info->needModifySchema); + return 0; end: taosHashCleanup(hashTmp); taosMemoryFreeClear(pTableMeta); - // catalogRefreshTableMeta(info->pCatalog, &conn, &pName, 1); + catalogRefreshTableMeta(info->pCatalog, &conn, &pName, 1); + uError("SML:0x%" PRIx64 " smlModifyDBSchemas end failed:%d:%s, format:%d, needModifySchema:%d", info->id, code, + tstrerror(code), info->dataFormat, info->needModifySchema); + return code; } @@ -997,8 +1022,9 @@ static int32_t smlUpdateMeta(SHashObj *metaHash, SArray *metaArray, SArray *cols } else { size_t tmp = taosArrayGetSize(metaArray); if (tmp > INT16_MAX) { + smlBuildInvalidDataMsg(msg, "too many cols or tags", kv->key); uError("too many cols or tags"); - return -1; + return TSDB_CODE_SML_INVALID_DATA; } int16_t size = tmp; int ret = taosHashPut(metaHash, kv->key, kv->keyLen, &size, SHORT_BYTES); @@ -1097,6 +1123,9 @@ SSmlHandle *smlBuildSmlInfo(TAOS *taos) { } if (taos != NULL) { info->taos = acquireTscObj(*(int64_t *)taos); + if (info->taos == NULL) { + goto cleanup; + } code = catalogGetHandle(info->taos->pAppInfo->clusterId, &info->pCatalog); if (code != TSDB_CODE_SUCCESS) { uError("SML:0x%" PRIx64 " get catalog error %d", info->id, code); @@ -1137,7 +1166,9 @@ static int32_t smlPushCols(SArray *colsArray, SArray *cols) { for (size_t i = 0; i < taosArrayGetSize(cols); i++) { SSmlKv *kv = (SSmlKv *)taosArrayGet(cols, i); taosHashPut(kvHash, kv->key, kv->keyLen, &kv, POINTER_BYTES); - if(terrno == TSDB_CODE_DUP_KEY){return terrno;} + if (terrno == TSDB_CODE_DUP_KEY) { + return terrno; + } } taosArrayPush(colsArray, &kvHash); @@ -1145,22 +1176,25 @@ static int32_t smlPushCols(SArray *colsArray, SArray *cols) { } static int32_t smlParseLineBottom(SSmlHandle *info) { + uDebug("SML:0x%" PRIx64 " smlParseLineBottom start, format:%d, linenum:%d", info->id, info->dataFormat, + info->lineNum); if (info->dataFormat) return TSDB_CODE_SUCCESS; for (int32_t i = 0; i < info->lineNum; i++) { SSmlLineInfo *elements = info->lines + i; SSmlTableInfo *tinfo = NULL; if (info->protocol == TSDB_SML_LINE_PROTOCOL) { - SSmlTableInfo** tmp = (SSmlTableInfo **)taosHashGet(info->childTables, elements->measure, elements->measureTagsLen); - if(tmp) tinfo = *tmp; + SSmlTableInfo **tmp = + (SSmlTableInfo **)taosHashGet(info->childTables, elements->measure, elements->measureTagsLen); + if (tmp) tinfo = *tmp; } else if (info->protocol == TSDB_SML_TELNET_PROTOCOL) { - SSmlTableInfo** tmp = (SSmlTableInfo **)taosHashGet(info->childTables, elements->measureTag, - elements->measureLen + elements->tagsLen); - if(tmp) tinfo = *tmp; + SSmlTableInfo **tmp = (SSmlTableInfo **)taosHashGet(info->childTables, elements->measureTag, + elements->measureLen + elements->tagsLen); + if (tmp) tinfo = *tmp; } else { - SSmlTableInfo** tmp = (SSmlTableInfo **)taosHashGet(info->childTables, elements->measureTag, - elements->measureLen + elements->tagsLen); - if(tmp) tinfo = *tmp; + SSmlTableInfo **tmp = (SSmlTableInfo **)taosHashGet(info->childTables, elements->measureTag, + elements->measureLen + elements->tagsLen); + if (tmp) tinfo = *tmp; } if (tinfo == NULL) { @@ -1187,6 +1221,8 @@ static int32_t smlParseLineBottom(SSmlHandle *info) { SSmlSTableMeta **tableMeta = (SSmlSTableMeta **)taosHashGet(info->superTables, elements->measure, elements->measureLen); if (tableMeta) { // update meta + uDebug("SML:0x%" PRIx64 " smlParseLineBottom update meta, format:%d, linenum:%d", info->id, info->dataFormat, + info->lineNum); ret = smlUpdateMeta((*tableMeta)->colHash, (*tableMeta)->cols, elements->colArray, false, &info->msgBuf); if (ret == TSDB_CODE_SUCCESS) { ret = smlUpdateMeta((*tableMeta)->tagHash, (*tableMeta)->tags, tinfo->tags, true, &info->msgBuf); @@ -1201,26 +1237,32 @@ static int32_t smlParseLineBottom(SSmlHandle *info) { // uError("SML:0x%" PRIx64 " smlUpdateMeta failed", info->id); // return ret; // } - + uDebug("SML:0x%" PRIx64 " smlParseLineBottom add meta, format:%d, linenum:%d", info->id, info->dataFormat, + info->lineNum); SSmlSTableMeta *meta = smlBuildSTableMeta(info->dataFormat); smlInsertMeta(meta->tagHash, meta->tags, tinfo->tags); - if(terrno == TSDB_CODE_DUP_KEY){return terrno;} + if (terrno == TSDB_CODE_DUP_KEY) { + return terrno; + } smlInsertMeta(meta->colHash, meta->cols, elements->colArray); taosHashPut(info->superTables, elements->measure, elements->measureLen, &meta, POINTER_BYTES); } } + uDebug("SML:0x%" PRIx64 " smlParseLineBottom end, format:%d, linenum:%d", info->id, info->dataFormat, info->lineNum); return TSDB_CODE_SUCCESS; } static int32_t smlInsertData(SSmlHandle *info) { int32_t code = TSDB_CODE_SUCCESS; + uDebug("SML:0x%" PRIx64 " smlInsertData start, format:%d", info->id, info->dataFormat); - if(info->pRequest->dbList == NULL){ + if (info->pRequest->dbList == NULL) { info->pRequest->dbList = taosArrayInit(1, TSDB_DB_FNAME_LEN); } - void* data = taosArrayReserve(info->pRequest->dbList, 1); - memcpy(data, info->pRequest->pDb, TSDB_DB_FNAME_LEN > strlen(info->pRequest->pDb) ? strlen(info->pRequest->pDb) : TSDB_DB_FNAME_LEN); + void *data = taosArrayReserve(info->pRequest->dbList, 1); + memcpy(data, info->pRequest->pDb, + TSDB_DB_FNAME_LEN > strlen(info->pRequest->pDb) ? strlen(info->pRequest->pDb) : TSDB_DB_FNAME_LEN); SSmlTableInfo **oneTable = (SSmlTableInfo **)taosHashIterate(info->childTables, NULL); while (oneTable) { @@ -1230,7 +1272,7 @@ static int32_t smlInsertData(SSmlHandle *info) { tstrncpy(pName.dbname, info->pRequest->pDb, sizeof(pName.dbname)); memcpy(pName.tname, tableData->childTableName, strlen(tableData->childTableName)); - if(info->pRequest->tableList == NULL){ + if (info->pRequest->tableList == NULL) { info->pRequest->tableList = taosArrayInit(1, sizeof(SName)); } taosArrayPush(info->pRequest->tableList, &pName); @@ -1259,6 +1301,8 @@ static int32_t smlInsertData(SSmlHandle *info) { // use tablemeta of stable to save vgid and uid of child table (*pMeta)->tableMeta->vgId = vg.vgId; (*pMeta)->tableMeta->uid = tableData->uid; // one table merge data block together according uid + uDebug("SML:0x%" PRIx64 " smlInsertData table:%s, uid:%" PRIu64 ", format:%d", info->id, pName.tname, + tableData->uid, info->dataFormat); code = smlBindData(info->pQuery, info->dataFormat, tableData->tags, (*pMeta)->cols, tableData->cols, (*pMeta)->tableMeta, tableData->childTableName, tableData->sTableName, tableData->sTableNameLen, @@ -1281,20 +1325,23 @@ static int32_t smlInsertData(SSmlHandle *info) { atomic_add_fetch_64((int64_t *)&pActivity->numOfInsertsReq, 1); launchQueryImpl(info->pRequest, info->pQuery, true, NULL); + uDebug("SML:0x%" PRIx64 " smlInsertData end, format:%d, code:%d,%s", info->id, info->dataFormat, info->pRequest->code, + tstrerror(info->pRequest->code)); + return info->pRequest->code; } static void smlPrintStatisticInfo(SSmlHandle *info) { uDebug( "SML:0x%" PRIx64 - " smlInsertLines result, code:%d,lineNum:%d,stable num:%d,ctable num:%d,create stable num:%d,alter stable tag num:%d,alter stable col num:%d \ + " smlInsertLines result, code:%d, msg:%s, lineNum:%d,stable num:%d,ctable num:%d,create stable num:%d,alter stable tag num:%d,alter stable col num:%d \ parse cost:%" PRId64 ",schema cost:%" PRId64 ",bind cost:%" PRId64 ",rpc cost:%" PRId64 ",total cost:%" PRId64 "", - info->id, info->cost.code, info->cost.lineNum, info->cost.numOfSTables, info->cost.numOfCTables, - info->cost.numOfCreateSTables, info->cost.numOfAlterTagSTables, info->cost.numOfAlterColSTables, - info->cost.schemaTime - info->cost.parseTime, info->cost.insertBindTime - info->cost.schemaTime, - info->cost.insertRpcTime - info->cost.insertBindTime, info->cost.endTime - info->cost.insertRpcTime, - info->cost.endTime - info->cost.parseTime); + info->id, info->cost.code, tstrerror(info->cost.code), info->cost.lineNum, info->cost.numOfSTables, + info->cost.numOfCTables, info->cost.numOfCreateSTables, info->cost.numOfAlterTagSTables, + info->cost.numOfAlterColSTables, info->cost.schemaTime - info->cost.parseTime, + info->cost.insertBindTime - info->cost.schemaTime, info->cost.insertRpcTime - info->cost.insertBindTime, + info->cost.endTime - info->cost.insertRpcTime, info->cost.endTime - info->cost.parseTime); } int32_t smlClearForRerun(SSmlHandle *info) { @@ -1335,6 +1382,7 @@ int32_t smlClearForRerun(SSmlHandle *info) { } static int32_t smlParseLine(SSmlHandle *info, char *lines[], char *rawLine, char *rawLineEnd, int numLines) { + uDebug("SML:0x%" PRIx64 " smlParseLine start", info->id); int32_t code = TSDB_CODE_SUCCESS; if (info->protocol == TSDB_SML_JSON_PROTOCOL) { if (lines) { @@ -1370,8 +1418,17 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char *rawLine, char } } - uDebug("SML:0x%" PRIx64 " smlParseLine israw:%d, len:%d, sql:%s", info->id, info->isRawLine, len, - (info->isRawLine ? "rawdata" : tmp)); + char cTmp = 0; // for print tmp if is raw + if (info->isRawLine) { + cTmp = tmp[len - 1]; + tmp[len - 1] = '\0'; + } + + uDebug("SML:0x%" PRIx64 " smlParseLine israw:%d, numLines:%d, protocol:%d, len:%d, sql:%s", info->id, + info->isRawLine, numLines, info->protocol, len, tmp); + if (info->isRawLine) { + tmp[len - 1] = cTmp; + } if (info->protocol == TSDB_SML_LINE_PROTOCOL) { if (info->dataFormat) { @@ -1396,6 +1453,7 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char *rawLine, char return code; } if (info->reRun) { + uDebug("SML:0x%" PRIx64 " smlParseLine re run", info->id); i = 0; rawLine = oldRaw; code = smlClearForRerun(info); @@ -1406,6 +1464,7 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], char *rawLine, char } i++; } + uDebug("SML:0x%" PRIx64 " smlParseLine end", info->id); return code; } @@ -1436,7 +1495,8 @@ static int smlProcess(SSmlHandle *info, char *lines[], char *rawLine, char *rawL do { code = smlModifyDBSchemas(info); if (code == 0) break; - taosMsleep(200); + taosMsleep(500); + uInfo("SML:0x%" PRIx64 " smlModifyDBSchemas retry code:%s, times:%d", info->id, tstrerror(code), retryNum); } while (retryNum++ < taosHashGetSize(info->superTables) * MAX_RETRY_TIMES); if (code != 0) { @@ -1462,8 +1522,9 @@ TAOS_RES *taos_schemaless_insert_inner(TAOS *taos, char *lines[], char *rawLine, return NULL; } SRequestObj *request = NULL; - SSmlHandle *info = NULL; - while(1){ + SSmlHandle *info = NULL; + int cnt = 0; + while (1) { request = (SRequestObj *)createRequest(*(int64_t *)taos, TSDB_SQL_INSERT, reqid); if (request == NULL) { uError("SML:taos_schemaless_insert error request is null"); @@ -1517,16 +1578,23 @@ TAOS_RES *taos_schemaless_insert_inner(TAOS *taos, char *lines[], char *rawLine, request->code = code; info->cost.endTime = taosGetTimestampUs(); info->cost.code = code; - smlPrintStatisticInfo(info); - if(code == TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER || code == TSDB_CODE_SDB_OBJ_CREATING){ + if (code == TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER || code == TSDB_CODE_SDB_OBJ_CREATING || + code == TSDB_CODE_PAR_VALUE_TOO_LONG || code == TSDB_CODE_MND_TRANS_CONFLICT) { + if (cnt++ >= 10) { + uInfo("SML:%" PRIx64 " retry:%d/10 end code:%d, msg:%s", info->id, cnt, code, tstrerror(code)); + break; + } + taosMsleep(100); refreshMeta(request->pTscObj, request); - uInfo("SML:%"PRIx64" ver is old retry or object is creating code:%d", info->id, code); + uInfo("SML:%" PRIx64 " retry:%d/10,ver is old retry or object is creating code:%d, msg:%s", info->id, cnt, code, + tstrerror(code)); smlDestroyInfo(info); info = NULL; taos_free_result(request); request = NULL; continue; } + smlPrintStatisticInfo(info); break; } diff --git a/source/client/src/clientSmlJson.c b/source/client/src/clientSmlJson.c index 4609dd68b04460e27fb5ff63bd30731ac3dd4227..9fd98e33b7ce8768f530764f0e3b926771f8cea5 100644 --- a/source/client/src/clientSmlJson.c +++ b/source/client/src/clientSmlJson.c @@ -1238,7 +1238,8 @@ int32_t smlParseJSON(SSmlHandle *info, char *payload) { payloadNum = payloadNum << 1; void *tmp = taosMemoryRealloc(info->lines, payloadNum * sizeof(SSmlLineInfo)); if (tmp == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + ret = TSDB_CODE_OUT_OF_MEMORY; + return ret; } info->lines = (SSmlLineInfo *)tmp; memset(info->lines + cnt, 0, (payloadNum - cnt) * sizeof(SSmlLineInfo)); diff --git a/source/client/src/clientSmlLine.c b/source/client/src/clientSmlLine.c index f5ae077b5d030e90e06685d496cc0b35ea6047c1..335e3a1dc76a0b1cfd231f43e3e43632cd4e44ef 100644 --- a/source/client/src/clientSmlLine.c +++ b/source/client/src/clientSmlLine.c @@ -292,6 +292,7 @@ static int32_t smlParseTagKv(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLin info->currSTableMeta->uid = tinfo->uid; tinfo->tableDataCtx = smlInitTableDataCtx(info->pQuery, info->currSTableMeta); if (tinfo->tableDataCtx == NULL) { + smlDestroyTableInfo(info, tinfo); smlBuildInvalidDataMsg(&info->msgBuf, "smlInitTableDataCtx error", NULL); return TSDB_CODE_SML_INVALID_DATA; } @@ -582,12 +583,14 @@ int32_t smlParseInfluxString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLine .i = ts, .length = (size_t)tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes}; if (info->dataFormat) { + uDebug("SML:0x%" PRIx64 " smlParseInfluxString format true, ts:%" PRId64, info->id, ts); ret = smlBuildCol(info->currTableDataCtx, info->currSTableMeta->schema, &kv, 0); if(ret != TSDB_CODE_SUCCESS){return ret;} ret = smlBuildRow(info->currTableDataCtx); if(ret != TSDB_CODE_SUCCESS){return ret;} clearColValArray(info->currTableDataCtx->pValues); } else { + uDebug("SML:0x%" PRIx64 " smlParseInfluxString format false, ts:%" PRId64, info->id, ts); taosArraySet(elements->colArray, 0, &kv); } info->preLine = *elements; diff --git a/source/client/src/clientSmlTelnet.c b/source/client/src/clientSmlTelnet.c index ccf79cfc64f462e1818f58cb96216a6b73ea49f2..036442573dbb7faa2f1989b03162c84ada5390fc 100644 --- a/source/client/src/clientSmlTelnet.c +++ b/source/client/src/clientSmlTelnet.c @@ -292,7 +292,7 @@ int32_t smlParseTelnetString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLine return TSDB_CODE_SUCCESS; } - if (info->dataFormat) { + if (info->dataFormat && info->currSTableMeta != NULL) { if (needConverTime) { kvTs.i = convertTimePrecision(kvTs.i, TSDB_TIME_PRECISION_NANO, info->currSTableMeta->tableInfo.precision); } diff --git a/source/client/src/clientTmq.c b/source/client/src/clientTmq.c index 9f24deff94adf5da052d70987e8b9bc926d3faf0..9e43765b5b93cac7ef90ac6a11684305d9647c19 100644 --- a/source/client/src/clientTmq.c +++ b/source/client/src/clientTmq.c @@ -20,17 +20,14 @@ #include "tdatablock.h" #include "tdef.h" #include "tglobal.h" -#include "tmsgtype.h" #include "tqueue.h" #include "tref.h" #include "ttimer.h" -#if 0 -#undef tsem_post -#define tsem_post(x) \ - tscInfo("call sem post at %s %d", __FUNCTION__, __LINE__); \ - sem_post(x) -#endif +#define EMPTY_BLOCK_POLL_IDLE_DURATION 10 +#define DEFAULT_AUTO_COMMIT_INTERVAL 5000 + +typedef void (*__tmq_askep_fn_t)(tmq_t* pTmq, int32_t code, SDataBuf* pBuf, void* pParam); struct SMqMgmt { int8_t inited; @@ -76,18 +73,16 @@ struct tmq_conf_t { }; struct tmq_t { - int64_t refId; - // conf - char groupId[TSDB_CGROUP_LEN]; - char clientId[256]; - int8_t withTbName; - int8_t useSnapshot; - int8_t autoCommit; - int32_t autoCommitInterval; - int32_t resetOffsetCfg; - uint64_t consumerId; - bool hbBgEnable; - + int64_t refId; + char groupId[TSDB_CGROUP_LEN]; + char clientId[256]; + int8_t withTbName; + int8_t useSnapshot; + int8_t autoCommit; + int32_t autoCommitInterval; + int32_t resetOffsetCfg; + uint64_t consumerId; + bool hbBgEnable; tmq_commit_cb* commitCb; void* commitCbUserParam; @@ -98,27 +93,29 @@ struct tmq_t { int8_t epStatus; int32_t epSkipCnt; #endif + // poll info int64_t pollCnt; + int64_t totalRows; // timer - tmr_h hbLiveTimer; - tmr_h epTimer; - tmr_h reportTimer; - tmr_h commitTimer; - - // connection - STscObj* pTscObj; - - // container - SArray* clientTopics; // SArray - STaosQueue* mqueue; // queue of rsp - STaosQall* qall; - STaosQueue* delayedTask; // delayed task queue for heartbeat and auto commit - - // ctl - tsem_t rspSem; + tmr_h hbLiveTimer; + tmr_h epTimer; + tmr_h reportTimer; + tmr_h commitTimer; + STscObj* pTscObj; // connection + SArray* clientTopics; // SArray + STaosQueue* mqueue; // queue of rsp + STaosQall* qall; + STaosQueue* delayedTask; // delayed task queue for heartbeat and auto commit + TdThreadMutex lock; // used to protect the operation on each topic, when updating the epsets. + tsem_t rspSem; }; +typedef struct SAskEpInfo { + int32_t code; + tsem_t sem; +} SAskEpInfo; + enum { TMQ_VG_STATUS__IDLE = 0, TMQ_VG_STATUS__WAIT, @@ -138,20 +135,18 @@ enum { }; typedef struct { - // statistics - int64_t pollCnt; - // offset + int64_t pollCnt; + int64_t numOfRows; STqOffsetVal committedOffset; STqOffsetVal currentOffset; - // connection info - int32_t vgId; - int32_t vgStatus; - int32_t vgSkipCnt; - SEpSet epSet; + int32_t vgId; + int32_t vgStatus; + int32_t vgSkipCnt; + int64_t emptyBlockReceiveTs; // once empty block is received, idle for ignoreCnt then start to poll data + SEpSet epSet; } SMqClientVg; typedef struct { - // subscribe info char topicName[TSDB_TOPIC_FNAME_LEN]; char db[TSDB_DB_FNAME_LEN]; SArray* vgs; // SArray @@ -160,9 +155,12 @@ typedef struct { typedef struct { int8_t tmqRspType; - int32_t epoch; + int32_t epoch; // epoch can be used to guard the vgHandle + int32_t vgId; SMqClientVg* vgHandle; SMqClientTopic* topicHandle; + uint64_t reqId; + SEpSet* pEpset; union { SMqDataRsp dataRsp; SMqMetaRsp metaRsp; @@ -178,11 +176,10 @@ typedef struct { } SMqSubscribeCbParam; typedef struct { - int64_t refId; - int32_t epoch; - int32_t code; - int32_t async; - tsem_t rspSem; + int64_t refId; + int32_t epoch; + void* pParam; + __tmq_askep_fn_t pUserFn; } SMqAskEpCbParam; typedef struct { @@ -192,33 +189,37 @@ typedef struct { SMqClientTopic* pTopic; int32_t vgId; tsem_t rspSem; - uint64_t requestId; // request id for debug purpose + uint64_t requestId; // request id for debug purpose } SMqPollCbParam; typedef struct { int64_t refId; int32_t epoch; - int8_t automatic; - int8_t async; int32_t waitingRspNum; int32_t totalRspNum; - int32_t rspErr; - tmq_commit_cb* userCb; + int32_t code; + tmq_commit_cb* callbackFn; /*SArray* successfulOffsets;*/ /*SArray* failedOffsets;*/ - void* userParam; - tsem_t rspSem; + void* userParam; } SMqCommitCbParamSet; typedef struct { SMqCommitCbParamSet* params; STqOffset* pOffset; - SMqClientVg* pMqVg; - /*char topicName[TSDB_TOPIC_FNAME_LEN];*/ - /*int32_t vgId;*/ + char topicName[TSDB_TOPIC_FNAME_LEN]; + int32_t vgId; + tmq_t* pTmq; } SMqCommitCbParam; -static int32_t tmqAskEp(tmq_t* tmq, bool async); +static int32_t doAskEp(tmq_t* tmq); +static int32_t makeTopicVgroupKey(char* dst, const char* topicName, int32_t vg); +static int32_t tmqCommitDone(SMqCommitCbParamSet* pParamSet); +static int32_t doSendCommitMsg(tmq_t* tmq, SMqClientVg* pVg, const char* pTopicName, SMqCommitCbParamSet* pParamSet, + int32_t index, int32_t totalVgroups); +static void commitRspCountDown(SMqCommitCbParamSet* pParamSet, int64_t consumerId, const char* pTopic, int32_t vgId); +static void asyncAskEp(tmq_t* pTmq, __tmq_askep_fn_t askEpFn, void* param); +static void addToQueueCallbackFn(tmq_t* pTmq, int32_t code, SDataBuf* pDataBuf, void* param); tmq_conf_t* tmq_conf_new() { tmq_conf_t* conf = taosMemoryCalloc(1, sizeof(tmq_conf_t)); @@ -229,8 +230,8 @@ tmq_conf_t* tmq_conf_new() { conf->withTbName = false; conf->autoCommit = true; - conf->autoCommitInterval = 5000; - conf->resetOffset = TMQ_CONF__RESET_OFFSET__EARLIEAST; + conf->autoCommitInterval = DEFAULT_AUTO_COMMIT_INTERVAL; + conf->resetOffset = TMQ_OFFSET__RESET_EARLIEAST; conf->hbBgEnable = true; return conf; @@ -238,29 +239,35 @@ tmq_conf_t* tmq_conf_new() { void tmq_conf_destroy(tmq_conf_t* conf) { if (conf) { - if (conf->ip) taosMemoryFree(conf->ip); - if (conf->user) taosMemoryFree(conf->user); - if (conf->pass) taosMemoryFree(conf->pass); + if (conf->ip) { + taosMemoryFree(conf->ip); + } + if (conf->user) { + taosMemoryFree(conf->user); + } + if (conf->pass) { + taosMemoryFree(conf->pass); + } taosMemoryFree(conf); } } tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value) { - if (strcmp(key, "group.id") == 0) { + if (strcasecmp(key, "group.id") == 0) { tstrncpy(conf->groupId, value, TSDB_CGROUP_LEN); return TMQ_CONF_OK; } - if (strcmp(key, "client.id") == 0) { + if (strcasecmp(key, "client.id") == 0) { tstrncpy(conf->clientId, value, 256); return TMQ_CONF_OK; } - if (strcmp(key, "enable.auto.commit") == 0) { - if (strcmp(value, "true") == 0) { + if (strcasecmp(key, "enable.auto.commit") == 0) { + if (strcasecmp(value, "true") == 0) { conf->autoCommit = true; return TMQ_CONF_OK; - } else if (strcmp(value, "false") == 0) { + } else if (strcasecmp(value, "false") == 0) { conf->autoCommit = false; return TMQ_CONF_OK; } else { @@ -268,31 +275,31 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value } } - if (strcmp(key, "auto.commit.interval.ms") == 0) { - conf->autoCommitInterval = atoi(value); + if (strcasecmp(key, "auto.commit.interval.ms") == 0) { + conf->autoCommitInterval = taosStr2int64(value); return TMQ_CONF_OK; } - if (strcmp(key, "auto.offset.reset") == 0) { - if (strcmp(value, "none") == 0) { - conf->resetOffset = TMQ_CONF__RESET_OFFSET__NONE; + if (strcasecmp(key, "auto.offset.reset") == 0) { + if (strcasecmp(value, "none") == 0) { + conf->resetOffset = TMQ_OFFSET__RESET_NONE; return TMQ_CONF_OK; - } else if (strcmp(value, "earliest") == 0) { - conf->resetOffset = TMQ_CONF__RESET_OFFSET__EARLIEAST; + } else if (strcasecmp(value, "earliest") == 0) { + conf->resetOffset = TMQ_OFFSET__RESET_EARLIEAST; return TMQ_CONF_OK; - } else if (strcmp(value, "latest") == 0) { - conf->resetOffset = TMQ_CONF__RESET_OFFSET__LATEST; + } else if (strcasecmp(value, "latest") == 0) { + conf->resetOffset = TMQ_OFFSET__RESET_LATEST; return TMQ_CONF_OK; } else { return TMQ_CONF_INVALID; } } - if (strcmp(key, "msg.with.table.name") == 0) { - if (strcmp(value, "true") == 0) { + if (strcasecmp(key, "msg.with.table.name") == 0) { + if (strcasecmp(value, "true") == 0) { conf->withTbName = true; return TMQ_CONF_OK; - } else if (strcmp(value, "false") == 0) { + } else if (strcasecmp(value, "false") == 0) { conf->withTbName = false; return TMQ_CONF_OK; } else { @@ -300,11 +307,11 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value } } - if (strcmp(key, "experimental.snapshot.enable") == 0) { - if (strcmp(value, "true") == 0) { + if (strcasecmp(key, "experimental.snapshot.enable") == 0) { + if (strcasecmp(value, "true") == 0) { conf->snapEnable = true; return TMQ_CONF_OK; - } else if (strcmp(value, "false") == 0) { + } else if (strcasecmp(value, "false") == 0) { conf->snapEnable = false; return TMQ_CONF_OK; } else { @@ -312,52 +319,52 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value } } - if (strcmp(key, "experimental.snapshot.batch.size") == 0) { - conf->snapBatchSize = atoi(value); + if (strcasecmp(key, "experimental.snapshot.batch.size") == 0) { + conf->snapBatchSize = taosStr2int64(value); return TMQ_CONF_OK; } - if (strcmp(key, "enable.heartbeat.background") == 0) { - if (strcmp(value, "true") == 0) { - conf->hbBgEnable = true; - return TMQ_CONF_OK; - } else if (strcmp(value, "false") == 0) { - conf->hbBgEnable = false; - return TMQ_CONF_OK; - } else { - return TMQ_CONF_INVALID; - } - return TMQ_CONF_OK; + if (strcasecmp(key, "enable.heartbeat.background") == 0) { + // if (strcasecmp(value, "true") == 0) { + // conf->hbBgEnable = true; + // return TMQ_CONF_OK; + // } else if (strcasecmp(value, "false") == 0) { + // conf->hbBgEnable = false; + // return TMQ_CONF_OK; + // } else { + tscError("the default value of enable.heartbeat.background is true, can not be seted"); + return TMQ_CONF_INVALID; + // } } - if (strcmp(key, "td.connect.ip") == 0) { + if (strcasecmp(key, "td.connect.ip") == 0) { conf->ip = taosStrdup(value); return TMQ_CONF_OK; } - if (strcmp(key, "td.connect.user") == 0) { + + if (strcasecmp(key, "td.connect.user") == 0) { conf->user = taosStrdup(value); return TMQ_CONF_OK; } - if (strcmp(key, "td.connect.pass") == 0) { + + if (strcasecmp(key, "td.connect.pass") == 0) { conf->pass = taosStrdup(value); return TMQ_CONF_OK; } - if (strcmp(key, "td.connect.port") == 0) { - conf->port = atoi(value); + + if (strcasecmp(key, "td.connect.port") == 0) { + conf->port = taosStr2int64(value); return TMQ_CONF_OK; } - if (strcmp(key, "td.connect.db") == 0) { - /*conf->db = taosStrdup(value);*/ + + if (strcasecmp(key, "td.connect.db") == 0) { return TMQ_CONF_OK; } return TMQ_CONF_UNKNOWN; } -tmq_list_t* tmq_list_new() { - // - return (tmq_list_t*)taosArrayInit(0, sizeof(void*)); -} +tmq_list_t* tmq_list_new() { return (tmq_list_t*)taosArrayInit(0, sizeof(void*)); } int32_t tmq_list_append(tmq_list_t* list, const char* src) { SArray* container = &list->container; @@ -385,88 +392,82 @@ char** tmq_list_to_c_array(const tmq_list_t* list) { return container->pData; } -static int32_t tmqMakeTopicVgKey(char* dst, const char* topicName, int32_t vg) { - return sprintf(dst, "%s:%d", topicName, vg); -} +static SMqClientVg* foundClientVg(SArray* pTopicList, const char* pName, int32_t vgId, int32_t* index, + int32_t* numOfVgroups) { + int32_t numOfTopics = taosArrayGetSize(pTopicList); + *index = -1; + *numOfVgroups = 0; -int32_t tmqCommitDone(SMqCommitCbParamSet* pParamSet) { - tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, pParamSet->refId); - if (tmq == NULL) { - if (!pParamSet->async) { - tsem_destroy(&pParamSet->rspSem); + for (int32_t i = 0; i < numOfTopics; ++i) { + SMqClientTopic* pTopic = taosArrayGet(pTopicList, i); + if (strcmp(pTopic->topicName, pName) != 0) { + continue; } - taosMemoryFree(pParamSet); - terrno = TSDB_CODE_TMQ_CONSUMER_CLOSED; - return -1; - } - // if no more waiting rsp - if (pParamSet->async) { - // call async cb func - if (pParamSet->automatic && tmq->commitCb) { - tmq->commitCb(tmq, pParamSet->rspErr, tmq->commitCbUserParam); - } else if (!pParamSet->automatic && pParamSet->userCb) { - // sem post - pParamSet->userCb(tmq, pParamSet->rspErr, pParamSet->userParam); + *numOfVgroups = taosArrayGetSize(pTopic->vgs); + for (int32_t j = 0; j < (*numOfVgroups); ++j) { + SMqClientVg* pClientVg = taosArrayGet(pTopic->vgs, j); + if (pClientVg->vgId == vgId) { + *index = j; + return pClientVg; + } } - taosMemoryFree(pParamSet); - } else { - tsem_post(&pParamSet->rspSem); } -#if 0 - taosArrayDestroyP(pParamSet->successfulOffsets, taosMemoryFree); - taosArrayDestroyP(pParamSet->failedOffsets, taosMemoryFree); -#endif - return 0; -} - -static void tmqCommitRspCountDown(SMqCommitCbParamSet* pParamSet) { - int32_t waitingRspNum = atomic_sub_fetch_32(&pParamSet->waitingRspNum, 1); - if (waitingRspNum == 0) { - tmqCommitDone(pParamSet); - } + return NULL; } -int32_t tmqCommitCb(void* param, SDataBuf* pBuf, int32_t code) { +// Two problems do not need to be addressed here +// 1. update to of epset. the response of poll request will automatically handle this problem +// 2. commit failure. This one needs to be resolved. +static int32_t tmqCommitCb(void* param, SDataBuf* pBuf, int32_t code) { SMqCommitCbParam* pParam = (SMqCommitCbParam*)param; SMqCommitCbParamSet* pParamSet = (SMqCommitCbParamSet*)pParam->params; - // push into array -#if 0 - if (code == 0) { - taosArrayPush(pParamSet->failedOffsets, &pParam->pOffset); - } else { - taosArrayPush(pParamSet->successfulOffsets, &pParam->pOffset); - } -#endif - - // there may be race condition. fix it - if (pBuf->pEpSet != NULL && pParam->pMqVg != NULL) { - SMqClientVg* pMqVg = pParam->pMqVg; - SEp* pEp = GET_ACTIVE_EP(pBuf->pEpSet); - SEp* pOld = GET_ACTIVE_EP(&(pMqVg->epSet)); - uDebug("subKey:%s update the epset vgId:%d, ep:%s:%d, old ep:%s:%d", pParam->pOffset->subKey, pMqVg->vgId, - pEp->fqdn, pEp->port, pOld->fqdn, pOld->port); - pParam->pMqVg->epSet = *pBuf->pEpSet; - } + // if (code != TSDB_CODE_SUCCESS) { // if commit offset failed, let's try again + // taosThreadMutexLock(&pParam->pTmq->lock); + // int32_t numOfVgroups, index; + // SMqClientVg* pVg = foundClientVg(pParam->pTmq->clientTopics, pParam->topicName, pParam->vgId, &index, + // &numOfVgroups); if (pVg == NULL) { + // tscDebug("consumer:0x%" PRIx64 + // " subKey:%s vgId:%d commit failed, code:%s has been transferred to other consumer, no need retry + // ordinal:%d/%d", pParam->pTmq->consumerId, pParam->pOffset->subKey, pParam->vgId, tstrerror(code), + // index + 1, numOfVgroups); + // } else { // let's retry the commit + // int32_t code1 = doSendCommitMsg(pParam->pTmq, pVg, pParam->topicName, pParamSet, index, numOfVgroups); + // if (code1 != TSDB_CODE_SUCCESS) { // retry failed. + // tscError("consumer:0x%" PRIx64 " topic:%s vgId:%d offset:%" PRId64 + // " retry failed, ignore this commit. code:%s ordinal:%d/%d", + // pParam->pTmq->consumerId, pParam->topicName, pVg->vgId, pVg->committedOffset.version, + // tstrerror(terrno), index + 1, numOfVgroups); + // } + // } + // + // taosThreadMutexUnlock(&pParam->pTmq->lock); + // + // taosMemoryFree(pParam->pOffset); + // taosMemoryFree(pBuf->pData); + // taosMemoryFree(pBuf->pEpSet); + // + // commitRspCountDown(pParamSet, pParam->pTmq->consumerId, pParam->topicName, pParam->vgId); + // return 0; + // } + // + // // todo replace the pTmq with refId taosMemoryFree(pParam->pOffset); taosMemoryFree(pBuf->pData); taosMemoryFree(pBuf->pEpSet); - /*tscDebug("receive offset commit cb of %s on vgId:%d, offset is %" PRId64, pParam->pOffset->subKey, pParam->->vgId, - * pOffset->version);*/ - - tmqCommitRspCountDown(pParamSet); + commitRspCountDown(pParamSet, pParam->pTmq->consumerId, pParam->topicName, pParam->vgId); return 0; } -static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pTopic, SMqCommitCbParamSet* pParamSet) { +static int32_t doSendCommitMsg(tmq_t* tmq, SMqClientVg* pVg, const char* pTopicName, SMqCommitCbParamSet* pParamSet, + int32_t index, int32_t totalVgroups) { STqOffset* pOffset = taosMemoryCalloc(1, sizeof(STqOffset)); if (pOffset == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; + return TSDB_CODE_OUT_OF_MEMORY; } pOffset->val = pVg->currentOffset; @@ -474,19 +475,19 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT int32_t groupLen = strlen(tmq->groupId); memcpy(pOffset->subKey, tmq->groupId, groupLen); pOffset->subKey[groupLen] = TMQ_SEPARATOR; - strcpy(pOffset->subKey + groupLen + 1, pTopic->topicName); + strcpy(pOffset->subKey + groupLen + 1, pTopicName); - int32_t len; - int32_t code; + int32_t len = 0; + int32_t code = 0; tEncodeSize(tEncodeSTqOffset, pOffset, len, code); if (code < 0) { - return -1; + return TSDB_CODE_INVALID_PARA; } void* buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len); if (buf == NULL) { taosMemoryFree(pOffset); - return -1; + return TSDB_CODE_OUT_OF_MEMORY; } ((SMsgHead*)buf)->vgId = htonl(pVg->vgId); @@ -503,12 +504,15 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT if (pParam == NULL) { taosMemoryFree(pOffset); taosMemoryFree(buf); - return -1; + return TSDB_CODE_OUT_OF_MEMORY; } pParam->params = pParamSet; pParam->pOffset = pOffset; - pParam->pMqVg = pVg; // there may be an race condition + pParam->vgId = pVg->vgId; + pParam->pTmq = tmq; + + tstrncpy(pParam->topicName, pTopicName, tListLen(pParam->topicName)); // build send info SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); @@ -516,7 +520,7 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT taosMemoryFree(pOffset); taosMemoryFree(buf); taosMemoryFree(pParam); - return -1; + return TSDB_CODE_OUT_OF_MEMORY; } pMsgSendInfo->msgInfo = (SDataBuf){ @@ -525,130 +529,135 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT .handle = NULL, }; - SEp* pEp = &pVg->epSet.eps[pVg->epSet.inUse]; - tscDebug("consumer:0x%" PRIx64 " topic:%s on vgId:%d offset:%" PRId64 " prev:%" PRId64 ", ep:%s:%d", tmq->consumerId, - pOffset->subKey, pVg->vgId, pOffset->val.version, pVg->committedOffset.version, pEp->fqdn, pEp->port); - - // TODO: put into cb, the commit offset should be move to the callback function - pVg->committedOffset = pVg->currentOffset; - pMsgSendInfo->requestId = generateRequestId(); pMsgSendInfo->requestObjRefId = 0; pMsgSendInfo->param = pParam; pMsgSendInfo->paramFreeFp = taosMemoryFree; pMsgSendInfo->fp = tmqCommitCb; pMsgSendInfo->msgType = TDMT_VND_TMQ_COMMIT_OFFSET; - // send msg atomic_add_fetch_32(&pParamSet->waitingRspNum, 1); atomic_add_fetch_32(&pParamSet->totalRspNum, 1); + SEp* pEp = GET_ACTIVE_EP(&pVg->epSet); + char offsetBuf[80] = {0}; + tFormatOffset(offsetBuf, tListLen(offsetBuf), &pOffset->val); + + char commitBuf[80] = {0}; + tFormatOffset(commitBuf, tListLen(commitBuf), &pVg->committedOffset); + tscDebug("consumer:0x%" PRIx64 " topic:%s on vgId:%d send offset:%s prev:%s, ep:%s:%d, ordinal:%d/%d, req:0x%" PRIx64, + tmq->consumerId, pOffset->subKey, pVg->vgId, offsetBuf, commitBuf, pEp->fqdn, pEp->port, index + 1, + totalVgroups, pMsgSendInfo->requestId); + int64_t transporterId = 0; asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, pMsgSendInfo); - return 0; + + return TSDB_CODE_SUCCESS; } -int32_t tmqCommitMsgImpl(tmq_t* tmq, const TAOS_RES* msg, int8_t async, tmq_commit_cb* userCb, void* userParam) { - char* topic; - int32_t vgId; - if (TD_RES_TMQ(msg)) { - SMqRspObj* pRspObj = (SMqRspObj*)msg; - topic = pRspObj->topic; +static void asyncCommitOffset(tmq_t* tmq, const TAOS_RES* pRes, tmq_commit_cb* pCommitFp, void* userParam) { + char* pTopicName = NULL; + int32_t vgId = 0; + int32_t code = 0; + + if (pRes == NULL || tmq == NULL) { + pCommitFp(tmq, TSDB_CODE_INVALID_PARA, userParam); + return; + } + + if (TD_RES_TMQ(pRes)) { + SMqRspObj* pRspObj = (SMqRspObj*)pRes; + pTopicName = pRspObj->topic; vgId = pRspObj->vgId; - } else if (TD_RES_TMQ_META(msg)) { - SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)msg; - topic = pMetaRspObj->topic; + } else if (TD_RES_TMQ_META(pRes)) { + SMqMetaRspObj* pMetaRspObj = (SMqMetaRspObj*)pRes; + pTopicName = pMetaRspObj->topic; vgId = pMetaRspObj->vgId; - } else if (TD_RES_TMQ_METADATA(msg)) { - SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)msg; - topic = pRspObj->topic; + } else if (TD_RES_TMQ_METADATA(pRes)) { + SMqTaosxRspObj* pRspObj = (SMqTaosxRspObj*)pRes; + pTopicName = pRspObj->topic; vgId = pRspObj->vgId; } else { - return TSDB_CODE_TMQ_INVALID_MSG; + pCommitFp(tmq, TSDB_CODE_TMQ_INVALID_MSG, userParam); + return; } SMqCommitCbParamSet* pParamSet = taosMemoryCalloc(1, sizeof(SMqCommitCbParamSet)); if (pParamSet == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; + pCommitFp(tmq, TSDB_CODE_OUT_OF_MEMORY, userParam); + return; } + pParamSet->refId = tmq->refId; pParamSet->epoch = tmq->epoch; - pParamSet->automatic = 0; - pParamSet->async = async; - pParamSet->userCb = userCb; + pParamSet->callbackFn = pCommitFp; pParamSet->userParam = userParam; - tsem_init(&pParamSet->rspSem, 0, 0); - int32_t code = -1; + int32_t numOfTopics = taosArrayGetSize(tmq->clientTopics); - for (int32_t i = 0; i < taosArrayGetSize(tmq->clientTopics); i++) { - SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); - if (strcmp(pTopic->topicName, topic) != 0) continue; - for (int32_t j = 0; j < taosArrayGetSize(pTopic->vgs); j++) { - SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); - if (pVg->vgId != vgId) continue; + tscDebug("consumer:0x%" PRIx64 " do manual commit offset for %s, vgId:%d", tmq->consumerId, pTopicName, vgId); - if (pVg->currentOffset.type > 0 && !tOffsetEqual(&pVg->currentOffset, &pVg->committedOffset)) { - if (tmqSendCommitReq(tmq, pVg, pTopic, pParamSet) < 0) { - tsem_destroy(&pParamSet->rspSem); - taosMemoryFree(pParamSet); - goto FAIL; - } - goto HANDLE_RSP; - } + int32_t i = 0; + for (; i < numOfTopics; i++) { + SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); + if (strcmp(pTopic->topicName, pTopicName) == 0) { + break; } } -HANDLE_RSP: - if (pParamSet->totalRspNum == 0) { - tsem_destroy(&pParamSet->rspSem); + if (i == numOfTopics) { + tscWarn("consumer:0x%" PRIx64 " failed to find the specified topic:%s, total topics:%d", tmq->consumerId, + pTopicName, numOfTopics); taosMemoryFree(pParamSet); - return 0; + pCommitFp(tmq, TSDB_CODE_SUCCESS, userParam); + return; + } + + SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); + + int32_t j = 0; + int32_t numOfVgroups = taosArrayGetSize(pTopic->vgs); + for (j = 0; j < numOfVgroups; j++) { + SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); + if (pVg->vgId == vgId) { + break; + } } - if (!async) { - tsem_wait(&pParamSet->rspSem); - code = pParamSet->rspErr; - tsem_destroy(&pParamSet->rspSem); + if (j == numOfVgroups) { + tscWarn("consumer:0x%" PRIx64 " failed to find the specified vgId:%d, total Vgs:%d, topic:%s", tmq->consumerId, + vgId, numOfVgroups, pTopicName); taosMemoryFree(pParamSet); - return code; - } else { - code = 0; + pCommitFp(tmq, TSDB_CODE_SUCCESS, userParam); + return; } -FAIL: - if (code != 0 && async) { - userCb(tmq, code, userParam); + SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); + if (pVg->currentOffset.type > 0 && !tOffsetEqual(&pVg->currentOffset, &pVg->committedOffset)) { + code = doSendCommitMsg(tmq, pVg, pTopic->topicName, pParamSet, j, numOfVgroups); + + // failed to commit, callback user function directly. + if (code != TSDB_CODE_SUCCESS) { + taosMemoryFree(pParamSet); + pCommitFp(tmq, code, userParam); + } + } else { // do not perform commit, callback user function directly. + taosMemoryFree(pParamSet); + pCommitFp(tmq, code, userParam); } - return 0; } -static int32_t tmqCommitConsumerImpl(tmq_t* tmq, int8_t automatic, int8_t async, tmq_commit_cb* userCb, - void* userParam) { - int32_t code = -1; - +static void asyncCommitAllOffsets(tmq_t* tmq, tmq_commit_cb* pCommitFp, void* userParam) { SMqCommitCbParamSet* pParamSet = taosMemoryCalloc(1, sizeof(SMqCommitCbParamSet)); if (pParamSet == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - if (async) { - if (automatic) { - tmq->commitCb(tmq, code, tmq->commitCbUserParam); - } else { - userCb(tmq, code, userParam); - } - } - return -1; + pCommitFp(tmq, TSDB_CODE_OUT_OF_MEMORY, userParam); + return; } pParamSet->refId = tmq->refId; pParamSet->epoch = tmq->epoch; - - pParamSet->automatic = automatic; - pParamSet->async = async; - pParamSet->userCb = userCb; + pParamSet->callbackFn = pCommitFp; pParamSet->userParam = userParam; - tsem_init(&pParamSet->rspSem, 0, 0); // init as 1 to prevent concurrency issue pParamSet->waitingRspNum = 1; @@ -658,75 +667,65 @@ static int32_t tmqCommitConsumerImpl(tmq_t* tmq, int8_t automatic, int8_t async, for (int32_t i = 0; i < numOfTopics; i++) { SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); + int32_t numOfVgroups = taosArrayGetSize(pTopic->vgs); - int32_t numOfVgroups = taosArrayGetSize(pTopic->vgs); + tscDebug("consumer:0x%" PRIx64 " commit offset for topics:%s, numOfVgs:%d", tmq->consumerId, pTopic->topicName, + numOfVgroups); for (int32_t j = 0; j < numOfVgroups; j++) { SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); + if (pVg->currentOffset.type > 0 && !tOffsetEqual(&pVg->currentOffset, &pVg->committedOffset)) { - if (tmqSendCommitReq(tmq, pVg, pTopic, pParamSet) < 0) { + int32_t code = doSendCommitMsg(tmq, pVg, pTopic->topicName, pParamSet, j, numOfVgroups); + if (code != TSDB_CODE_SUCCESS) { + tscError("consumer:0x%" PRIx64 " topic:%s vgId:%d offset:%" PRId64 " failed, code:%s ordinal:%d/%d", + tmq->consumerId, pTopic->topicName, pVg->vgId, pVg->committedOffset.version, tstrerror(terrno), + j + 1, numOfVgroups); continue; } + + // update the offset value. + pVg->committedOffset = pVg->currentOffset; } else { - tscDebug("consumer:0x%" PRIx64 " topic:%s vgId:%d, not commit, current:%" PRId64 ", ordinal:%d/%d", + tscDebug("consumer:0x%" PRIx64 " topic:%s vgId:%d, no commit, current:%" PRId64 ", ordinal:%d/%d", tmq->consumerId, pTopic->topicName, pVg->vgId, pVg->currentOffset.version, j + 1, numOfVgroups); } } } + tscDebug("consumer:0x%" PRIx64 " total commit:%d for %d topics", tmq->consumerId, pParamSet->waitingRspNum - 1, + numOfTopics); + // no request is sent if (pParamSet->totalRspNum == 0) { - tsem_destroy(&pParamSet->rspSem); taosMemoryFree(pParamSet); - return 0; + pCommitFp(tmq, TSDB_CODE_SUCCESS, userParam); + return; } // count down since waiting rsp num init as 1 - tmqCommitRspCountDown(pParamSet); - - if (!async) { - tsem_wait(&pParamSet->rspSem); - code = pParamSet->rspErr; - tsem_destroy(&pParamSet->rspSem); - taosMemoryFree(pParamSet); -#if 0 - taosArrayDestroyP(pParamSet->successfulOffsets, taosMemoryFree); - taosArrayDestroyP(pParamSet->failedOffsets, taosMemoryFree); -#endif - } - - return code; -} - -int32_t tmqCommitInner(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_t async, tmq_commit_cb* userCb, - void* userParam) { - if (msg) { - return tmqCommitMsgImpl(tmq, msg, async, userCb, userParam); - } else { - return tmqCommitConsumerImpl(tmq, automatic, async, userCb, userParam); - } + commitRspCountDown(pParamSet, tmq->consumerId, "", 0); } -void tmqAssignAskEpTask(void* param, void* tmrId) { - int64_t refId = *(int64_t*)param; - tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId); +static void generateTimedTask(int64_t refId, int32_t type) { + tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId); if (tmq != NULL) { int8_t* pTaskType = taosAllocateQitem(sizeof(int8_t), DEF_QITEM, 0); - *pTaskType = TMQ_DELAYED_TASK__ASK_EP; + *pTaskType = type; taosWriteQitem(tmq->delayedTask, pTaskType); tsem_post(&tmq->rspSem); } + taosReleaseRef(tmqMgmt.rsetId, refId); +} + +void tmqAssignAskEpTask(void* param, void* tmrId) { + int64_t refId = *(int64_t*)param; + generateTimedTask(refId, TMQ_DELAYED_TASK__ASK_EP); taosMemoryFree(param); } void tmqAssignDelayedCommitTask(void* param, void* tmrId) { int64_t refId = *(int64_t*)param; - tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId); - if (tmq != NULL) { - int8_t* pTaskType = taosAllocateQitem(sizeof(int8_t), DEF_QITEM, 0); - *pTaskType = TMQ_DELAYED_TASK__COMMIT; - taosWriteQitem(tmq->delayedTask, pTaskType); - tsem_post(&tmq->rspSem); - } + generateTimedTask(refId, TMQ_DELAYED_TASK__COMMIT); taosMemoryFree(param); } @@ -739,6 +738,8 @@ void tmqAssignDelayedReportTask(void* param, void* tmrId) { taosWriteQitem(tmq->delayedTask, pTaskType); tsem_post(&tmq->rspSem); } + + taosReleaseRef(tmqMgmt.rsetId, refId); taosMemoryFree(param); } @@ -752,7 +753,8 @@ int32_t tmqHbCb(void* param, SDataBuf* pMsg, int32_t code) { void tmqSendHbReq(void* param, void* tmrId) { int64_t refId = *(int64_t*)param; - tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId); + + tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId); if (tmq == NULL) { taosMemoryFree(param); return; @@ -765,17 +767,19 @@ void tmqSendHbReq(void* param, void* tmrId) { int32_t tlen = tSerializeSMqHbReq(NULL, 0, &req); if (tlen < 0) { tscError("tSerializeSMqHbReq failed"); - return; + goto OVER; } + void* pReq = taosMemoryCalloc(1, tlen); if (tlen < 0) { tscError("failed to malloc MqHbReq msg, size:%d", tlen); - return; + goto OVER; } + if (tSerializeSMqHbReq(pReq, tlen, &req) < 0) { tscError("tSerializeSMqHbReq %d failed", tlen); taosMemoryFree(pReq); - return; + goto OVER; } SMsgSendInfo* sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); @@ -783,6 +787,7 @@ void tmqSendHbReq(void* param, void* tmrId) { taosMemoryFree(pReq); goto OVER; } + sendInfo->msgInfo = (SDataBuf){ .pData = pReq, .len = tlen, @@ -802,6 +807,13 @@ void tmqSendHbReq(void* param, void* tmrId) { OVER: taosTmrReset(tmqSendHbReq, 1000, param, tmqMgmt.timer, &tmq->hbLiveTimer); + taosReleaseRef(tmqMgmt.rsetId, refId); +} + +static void defaultCommitCbFn(tmq_t* pTmq, int32_t code, void* param) { + if (code != 0) { + tscDebug("consumer:0x%" PRIx64 ", failed to commit offset, code:%s", pTmq->consumerId, tstrerror(code)); + } } int32_t tmqHandleAllDelayedTask(tmq_t* pTmq) { @@ -819,7 +831,7 @@ int32_t tmqHandleAllDelayedTask(tmq_t* pTmq) { while (pTaskType != NULL) { if (*pTaskType == TMQ_DELAYED_TASK__ASK_EP) { - tmqAskEp(pTmq, true); + asyncAskEp(pTmq, addToQueueCallbackFn, NULL); int64_t* pRefId = taosMemoryMalloc(sizeof(int64_t)); *pRefId = pTmq->refId; @@ -827,12 +839,13 @@ int32_t tmqHandleAllDelayedTask(tmq_t* pTmq) { tscDebug("consumer:0x%" PRIx64 " retrieve ep from mnode in 1s", pTmq->consumerId); taosTmrReset(tmqAssignAskEpTask, 1000, pRefId, tmqMgmt.timer, &pTmq->epTimer); } else if (*pTaskType == TMQ_DELAYED_TASK__COMMIT) { - tmqCommitInner(pTmq, NULL, 1, 1, pTmq->commitCb, pTmq->commitCbUserParam); + tmq_commit_cb* pCallbackFn = pTmq->commitCb ? pTmq->commitCb : defaultCommitCbFn; + asyncCommitAllOffsets(pTmq, pCallbackFn, pTmq->commitCbUserParam); int64_t* pRefId = taosMemoryMalloc(sizeof(int64_t)); *pRefId = pTmq->refId; - tscDebug("consumer:0x%" PRIx64 " commit to vnode(s) in %.2fs", pTmq->consumerId, + tscDebug("consumer:0x%" PRIx64 " next commit to vnode(s) in %.2fs", pTmq->consumerId, pTmq->autoCommitInterval / 1000.0); taosTmrReset(tmqAssignDelayedCommitTask, pTmq->autoCommitInterval, pRefId, tmqMgmt.timer, &pTmq->commitTimer); } else if (*pTaskType == TMQ_DELAYED_TASK__REPORT) { @@ -846,7 +859,7 @@ int32_t tmqHandleAllDelayedTask(tmq_t* pTmq) { return 0; } -static void tmqFreeRspWrapper(SMqRspWrapper* rspWrapper) { +static void* tmqFreeRspWrapper(SMqRspWrapper* rspWrapper) { if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__END_RSP) { // do nothing } else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__EP_RSP) { @@ -854,15 +867,21 @@ static void tmqFreeRspWrapper(SMqRspWrapper* rspWrapper) { tDeleteSMqAskEpRsp(&pEpRspWrapper->msg); } else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_RSP) { SMqPollRspWrapper* pRsp = (SMqPollRspWrapper*)rspWrapper; + taosMemoryFreeClear(pRsp->pEpset); + taosArrayDestroyP(pRsp->dataRsp.blockData, taosMemoryFree); taosArrayDestroy(pRsp->dataRsp.blockDataLen); taosArrayDestroyP(pRsp->dataRsp.blockTbName, taosMemoryFree); taosArrayDestroyP(pRsp->dataRsp.blockSchema, (FDelete)tDeleteSSchemaWrapper); } else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_META_RSP) { SMqPollRspWrapper* pRsp = (SMqPollRspWrapper*)rspWrapper; + taosMemoryFreeClear(pRsp->pEpset); + taosMemoryFree(pRsp->metaRsp.metaRsp); } else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__TAOSX_RSP) { SMqPollRspWrapper* pRsp = (SMqPollRspWrapper*)rspWrapper; + taosMemoryFreeClear(pRsp->pEpset); + taosArrayDestroyP(pRsp->taosxRsp.blockData, taosMemoryFree); taosArrayDestroy(pRsp->taosxRsp.blockDataLen); taosArrayDestroyP(pRsp->taosxRsp.blockTbName, taosMemoryFree); @@ -871,6 +890,8 @@ static void tmqFreeRspWrapper(SMqRspWrapper* rspWrapper) { taosArrayDestroy(pRsp->taosxRsp.createTableLen); taosArrayDestroyP(pRsp->taosxRsp.createTableReq, taosMemoryFree); } + + return NULL; } void tmqClearUnhandleMsg(tmq_t* tmq) { @@ -936,28 +957,35 @@ int32_t tmq_unsubscribe(tmq_t* tmq) { return rsp; } +static void freeClientVgImpl(void* param) { + SMqClientTopic* pTopic = param; + taosMemoryFreeClear(pTopic->schema.pSchema); + taosArrayDestroy(pTopic->vgs); +} + void tmqFreeImpl(void* handle) { - tmq_t* tmq = (tmq_t*)handle; + tmq_t* tmq = (tmq_t*)handle; + int64_t id = tmq->consumerId; // TODO stop timer if (tmq->mqueue) { tmqClearUnhandleMsg(tmq); taosCloseQueue(tmq->mqueue); } - if (tmq->delayedTask) taosCloseQueue(tmq->delayedTask); - taosFreeQall(tmq->qall); + if (tmq->delayedTask) { + taosCloseQueue(tmq->delayedTask); + } + + taosFreeQall(tmq->qall); tsem_destroy(&tmq->rspSem); + taosThreadMutexDestroy(&tmq->lock); - int32_t sz = taosArrayGetSize(tmq->clientTopics); - for (int32_t i = 0; i < sz; i++) { - SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); - taosMemoryFreeClear(pTopic->schema.pSchema); - taosArrayDestroy(pTopic->vgs); - } - taosArrayDestroy(tmq->clientTopics); + taosArrayDestroyEx(tmq->clientTopics, freeClientVgImpl); taos_close_internal(tmq->pTscObj); taosMemoryFree(tmq); + + tscDebug("consumer:0x%" PRIx64 " closed", id); } static void tmqMgmtInit(void) { @@ -984,7 +1012,7 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) { tmq_t* pTmq = taosMemoryCalloc(1, sizeof(tmq_t)); if (pTmq == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - tscError("failed to create consumer, consumer group %s, code:%s", conf->groupId, terrstr()); + tscError("failed to create consumer, groupId:%s, code:%s", conf->groupId, terrstr()); return NULL; } @@ -993,23 +1021,21 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) { pTmq->clientTopics = taosArrayInit(0, sizeof(SMqClientTopic)); pTmq->mqueue = taosOpenQueue(); - pTmq->qall = taosAllocateQall(); pTmq->delayedTask = taosOpenQueue(); + pTmq->qall = taosAllocateQall(); + taosThreadMutexInit(&pTmq->lock, NULL); if (pTmq->clientTopics == NULL || pTmq->mqueue == NULL || pTmq->qall == NULL || pTmq->delayedTask == NULL || conf->groupId[0] == 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; - tscError("consumer:0x%" PRIx64 " setup failed since %s, consumer group %s", pTmq->consumerId, terrstr(), - pTmq->groupId); - goto FAIL; + tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, terrstr(), pTmq->groupId); + goto _failed; } // init status pTmq->status = TMQ_CONSUMER_STATUS__INIT; pTmq->pollCnt = 0; pTmq->epoch = 0; - /*pTmq->epStatus = 0;*/ - /*pTmq->epSkipCnt = 0;*/ // set conf strcpy(pTmq->clientId, conf->clientId); @@ -1031,22 +1057,20 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) { if (tsem_init(&pTmq->rspSem, 0, 0) != 0) { tscError("consumer:0x %" PRIx64 " setup failed since %s, consumer group %s", pTmq->consumerId, terrstr(), pTmq->groupId); - goto FAIL; + goto _failed; } // init connection pTmq->pTscObj = taos_connect_internal(conf->ip, user, pass, NULL, NULL, conf->port, CONN_TYPE__TMQ); if (pTmq->pTscObj == NULL) { - tscError("consumer:0x %" PRIx64 " setup failed since %s, consumer group %s", pTmq->consumerId, terrstr(), - pTmq->groupId); + tscError("consumer:0x%" PRIx64 " setup failed since %s, groupId:%s", pTmq->consumerId, terrstr(), pTmq->groupId); tsem_destroy(&pTmq->rspSem); - goto FAIL; + goto _failed; } pTmq->refId = taosAddRef(tmqMgmt.rsetId, pTmq); if (pTmq->refId < 0) { - tmqFreeImpl(pTmq); - return NULL; + goto _failed; } if (pTmq->hbBgEnable) { @@ -1055,20 +1079,23 @@ tmq_t* tmq_consumer_new(tmq_conf_t* conf, char* errstr, int32_t errstrLen) { pTmq->hbLiveTimer = taosTmrStart(tmqSendHbReq, 1000, pRefId, tmqMgmt.timer); } - tscInfo("consumer:0x%" PRIx64 " is setup, groupId:%s", pTmq->consumerId, pTmq->groupId); - return pTmq; + char buf[80] = {0}; + STqOffsetVal offset = {.type = pTmq->resetOffsetCfg}; + tFormatOffset(buf, tListLen(buf), &offset); + tscInfo("consumer:0x%" PRIx64 " is setup, refId:%" PRId64 + ", groupId:%s, snapshot:%d, autoCommit:%d, commitInterval:%dms, offset:%s, backgroudHB:%d", + pTmq->consumerId, pTmq->refId, pTmq->groupId, pTmq->useSnapshot, pTmq->autoCommit, pTmq->autoCommitInterval, + buf, pTmq->hbBgEnable); -FAIL: - if (pTmq->clientTopics) taosArrayDestroy(pTmq->clientTopics); - if (pTmq->mqueue) taosCloseQueue(pTmq->mqueue); - if (pTmq->delayedTask) taosCloseQueue(pTmq->delayedTask); - if (pTmq->qall) taosFreeQall(pTmq->qall); - taosMemoryFree(pTmq); + return pTmq; +_failed: + tmqFreeImpl(pTmq); return NULL; } int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) { + const int32_t MAX_RETRY_COUNT = 120 * 2; // let's wait for 2 mins at most const SArray* container = &topic_list->container; int32_t sz = taosArrayGetSize(container); void* buf = NULL; @@ -1161,8 +1188,8 @@ int32_t tmq_subscribe(tmq_t* tmq, const tmq_list_t* topic_list) { } int32_t retryCnt = 0; - while (TSDB_CODE_MND_CONSUMER_NOT_READY == tmqAskEp(tmq, false)) { - if (retryCnt++ > 40) { + while (TSDB_CODE_MND_CONSUMER_NOT_READY == doAskEp(tmq)) { + if (retryCnt++ > MAX_RETRY_COUNT) { goto FAIL; } @@ -1193,17 +1220,18 @@ FAIL: } void tmq_conf_set_auto_commit_cb(tmq_conf_t* conf, tmq_commit_cb* cb, void* param) { - // conf->commitCb = cb; conf->commitCbUserParam = param; } int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { SMqPollCbParam* pParam = (SMqPollCbParam*)param; + + int64_t refId = pParam->refId; SMqClientVg* pVg = pParam->pVg; SMqClientTopic* pTopic = pParam->pTopic; - tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, pParam->refId); + tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId); if (tmq == NULL) { tsem_destroy(&pParam->rspSem); taosMemoryFree(pParam); @@ -1220,8 +1248,8 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { taosMemoryFree(pParam); if (code != 0) { - tscWarn("consumer:0x%"PRIx64" msg from vgId:%d discarded, epoch %d, since %s, reqId:0x%"PRIx64, tmq->consumerId, vgId, - epoch, tstrerror(code), requestId); + tscWarn("consumer:0x%" PRIx64 " msg from vgId:%d discarded, epoch %d, since %s, reqId:0x%" PRIx64, tmq->consumerId, + vgId, epoch, tstrerror(code), requestId); if (pMsg->pData) taosMemoryFree(pMsg->pData); if (pMsg->pEpSet) taosMemoryFree(pMsg->pEpSet); @@ -1230,7 +1258,8 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { if (code == TSDB_CODE_TMQ_CONSUMER_MISMATCH) { taosMsleep(500); atomic_store_8(&tmq->status, TMQ_CONSUMER_STATUS__RECOVER); - tscDebug("consumer:0x%" PRIx64" wait for the re-balance, wait for 500ms and set status to be RECOVER", tmq->consumerId); + tscDebug("consumer:0x%" PRIx64 " wait for the re-balance, wait for 500ms and set status to be RECOVER", + tmq->consumerId); } else if (code == TSDB_CODE_TQ_NO_COMMITTED_OFFSET) { SMqPollRspWrapper* pRspWrapper = taosAllocateQitem(sizeof(SMqPollRspWrapper), DEF_QITEM, 0); if (pRspWrapper == NULL) { @@ -1240,10 +1269,7 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { } pRspWrapper->tmqRspType = TMQ_MSG_TYPE__END_RSP; - /*pRspWrapper->vgHandle = pVg;*/ - /*pRspWrapper->topicHandle = pTopic;*/ taosWriteQitem(tmq->mqueue, pRspWrapper); - tsem_post(&tmq->rspSem); } goto CREATE_MSG_FAIL; @@ -1253,18 +1279,21 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { int32_t tmqEpoch = atomic_load_32(&tmq->epoch); if (msgEpoch < tmqEpoch) { // do not write into queue since updating epoch reset - tscWarn("consumer:0x%" PRIx64 " msg discard from vgId:%d since from earlier epoch, rsp epoch %d, current epoch %d, reqId:0x%"PRIx64, + tscWarn("consumer:0x%" PRIx64 + " msg discard from vgId:%d since from earlier epoch, rsp epoch %d, current epoch %d, reqId:0x%" PRIx64, tmq->consumerId, vgId, msgEpoch, tmqEpoch, requestId); tsem_post(&tmq->rspSem); + taosReleaseRef(tmqMgmt.rsetId, refId); + taosMemoryFree(pMsg->pData); taosMemoryFree(pMsg->pEpSet); return 0; } if (msgEpoch != tmqEpoch) { - tscWarn("consumer:0x%"PRIx64" mismatch rsp from vgId:%d, epoch %d, current epoch %d, reqId:0x%"PRIx64, tmq->consumerId, vgId, - msgEpoch, tmqEpoch, requestId); + tscWarn("consumer:0x%" PRIx64 " mismatch rsp from vgId:%d, epoch %d, current epoch %d, reqId:0x%" PRIx64, + tmq->consumerId, vgId, msgEpoch, tmqEpoch, requestId); } // handle meta rsp @@ -1274,14 +1303,19 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { if (pRspWrapper == NULL) { taosMemoryFree(pMsg->pData); taosMemoryFree(pMsg->pEpSet); - tscWarn("consumer:0x%"PRIx64" msg discard from vgId:%d, epoch %d since out of memory", tmq->consumerId, vgId, epoch); + tscWarn("consumer:0x%" PRIx64 " msg discard from vgId:%d, epoch %d since out of memory", tmq->consumerId, vgId, + epoch); goto CREATE_MSG_FAIL; } pRspWrapper->tmqRspType = rspType; pRspWrapper->vgHandle = pVg; pRspWrapper->topicHandle = pTopic; + pRspWrapper->reqId = requestId; + pRspWrapper->pEpset = pMsg->pEpSet; + pRspWrapper->vgId = pVg->vgId; + pMsg->pEpSet = NULL; if (rspType == TMQ_MSG_TYPE__POLL_RSP) { SDecoder decoder; tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead)); @@ -1289,9 +1323,10 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { tDecoderClear(&decoder); memcpy(&pRspWrapper->dataRsp, pMsg->pData, sizeof(SMqRspHead)); - tscDebug("consumer:0x%" PRIx64 " recv poll rsp, vgId:%d, req offset:%" PRId64 ", rsp offset:%" PRId64 " type %d, reqId:0x%"PRIx64, - tmq->consumerId, pVg->vgId, pRspWrapper->dataRsp.reqOffset.version, pRspWrapper->dataRsp.rspOffset.version, - rspType, requestId); + char buf[80]; + tFormatOffset(buf, 80, &pRspWrapper->dataRsp.rspOffset); + tscDebug("consumer:0x%" PRIx64 " recv poll rsp, vgId:%d, req ver:%" PRId64 ", rsp:%s type %d, reqId:0x%" PRIx64, + tmq->consumerId, vgId, pRspWrapper->dataRsp.reqOffset.version, buf, rspType, requestId); } else if (rspType == TMQ_MSG_TYPE__POLL_META_RSP) { SDecoder decoder; tDecoderInit(&decoder, POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), pMsg->len - sizeof(SMqRspHead)); @@ -1304,16 +1339,18 @@ int32_t tmqPollCb(void* param, SDataBuf* pMsg, int32_t code) { tDecodeSTaosxRsp(&decoder, &pRspWrapper->taosxRsp); tDecoderClear(&decoder); memcpy(&pRspWrapper->taosxRsp, pMsg->pData, sizeof(SMqRspHead)); + } else { // invalid rspType + tscError("consumer:0x%" PRIx64 " invalid rsp msg received, type:%d ignored", tmq->consumerId, rspType); } taosMemoryFree(pMsg->pData); - taosMemoryFree(pMsg->pEpSet); + taosWriteQitem(tmq->mqueue, pRspWrapper); - tscDebug("consumer:0x%" PRIx64 ", put poll res into mqueue, total in queue:%d, reqId:0x%" PRIx64, tmq->consumerId, - tmq->mqueue->numOfItems, requestId); + tscDebug("consumer:0x%" PRIx64 " put poll res into mqueue, type:%d, vgId:%d, total in queue:%d, reqId:0x%" PRIx64, + tmq->consumerId, rspType, vgId, tmq->mqueue->numOfItems, requestId); - taosWriteQitem(tmq->mqueue, pRspWrapper); tsem_post(&tmq->rspSem); + taosReleaseRef(tmqMgmt.rsetId, refId); return 0; @@ -1323,10 +1360,69 @@ CREATE_MSG_FAIL: } tsem_post(&tmq->rspSem); + taosReleaseRef(tmqMgmt.rsetId, refId); + return -1; } -bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) { +typedef struct SVgroupSaveInfo { + STqOffsetVal offset; + int64_t numOfRows; +} SVgroupSaveInfo; + +static void initClientTopicFromRsp(SMqClientTopic* pTopic, SMqSubTopicEp* pTopicEp, SHashObj* pVgOffsetHashMap, + tmq_t* tmq) { + pTopic->schema = pTopicEp->schema; + pTopicEp->schema.nCols = 0; + pTopicEp->schema.pSchema = NULL; + + char vgKey[TSDB_TOPIC_FNAME_LEN + 22]; + int32_t vgNumGet = taosArrayGetSize(pTopicEp->vgs); + + tstrncpy(pTopic->topicName, pTopicEp->topic, TSDB_TOPIC_FNAME_LEN); + tstrncpy(pTopic->db, pTopicEp->db, TSDB_DB_FNAME_LEN); + + tscDebug("consumer:0x%" PRIx64 ", update topic:%s, numOfVgs:%d", tmq->consumerId, pTopic->topicName, vgNumGet); + pTopic->vgs = taosArrayInit(vgNumGet, sizeof(SMqClientVg)); + + for (int32_t j = 0; j < vgNumGet; j++) { + SMqSubVgEp* pVgEp = taosArrayGet(pTopicEp->vgs, j); + + makeTopicVgroupKey(vgKey, pTopic->topicName, pVgEp->vgId); + SVgroupSaveInfo* pInfo = taosHashGet(pVgOffsetHashMap, vgKey, strlen(vgKey)); + + int64_t numOfRows = 0; + STqOffsetVal offsetNew = {.type = tmq->resetOffsetCfg}; + if (pInfo != NULL) { + offsetNew = pInfo->offset; + numOfRows = pInfo->numOfRows; + } + + SMqClientVg clientVg = { + .pollCnt = 0, + .currentOffset = offsetNew, + .vgId = pVgEp->vgId, + .epSet = pVgEp->epSet, + .vgStatus = TMQ_VG_STATUS__IDLE, + .vgSkipCnt = 0, + .emptyBlockReceiveTs = 0, + .numOfRows = numOfRows, + }; + + taosArrayPush(pTopic->vgs, &clientVg); + } +} + +static void freeClientVgInfo(void* param) { + SMqClientTopic* pTopic = param; + if (pTopic->schema.nCols) { + taosMemoryFreeClear(pTopic->schema.pSchema); + } + + taosArrayDestroy(pTopic->vgs); +} + +static bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) { bool set = false; int32_t topicNumCur = taosArrayGetSize(tmq->clientTopics); @@ -1341,12 +1437,13 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) { return false; } - SHashObj* pHash = taosHashInit(64, MurmurHash3_32, false, HASH_NO_LOCK); - if (pHash == NULL) { + SHashObj* pVgOffsetHashMap = taosHashInit(64, MurmurHash3_32, false, HASH_NO_LOCK); + if (pVgOffsetHashMap == NULL) { taosArrayDestroy(newTopics); return false; } + // todo extract method for (int32_t i = 0; i < topicNumCur; i++) { // find old topic SMqClientTopic* pTopicCur = taosArrayGet(tmq->clientTopics, i); @@ -1355,12 +1452,15 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) { tscDebug("consumer:0x%" PRIx64 ", new vg num: %d", tmq->consumerId, vgNumCur); for (int32_t j = 0; j < vgNumCur; j++) { SMqClientVg* pVgCur = taosArrayGet(pTopicCur->vgs, j); - sprintf(vgKey, "%s:%d", pTopicCur->topicName, pVgCur->vgId); + makeTopicVgroupKey(vgKey, pTopicCur->topicName, pVgCur->vgId); + char buf[80]; tFormatOffset(buf, 80, &pVgCur->currentOffset); - tscDebug("consumer:0x%" PRIx64 ", epoch:%d vgId:%d vgKey:%s, offset:%s", tmq->consumerId, epoch, - pVgCur->vgId, vgKey, buf); - taosHashPut(pHash, vgKey, strlen(vgKey), &pVgCur->currentOffset, sizeof(STqOffsetVal)); + tscDebug("consumer:0x%" PRIx64 ", epoch:%d vgId:%d vgKey:%s, offset:%s", tmq->consumerId, epoch, pVgCur->vgId, + vgKey, buf); + + SVgroupSaveInfo info = {.offset = pVgCur->currentOffset, .numOfRows = pVgCur->numOfRows}; + taosHashPut(pVgOffsetHashMap, vgKey, strlen(vgKey), &info, sizeof(SVgroupSaveInfo)); } } } @@ -1368,87 +1468,53 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, const SMqAskEpRsp* pRsp) { for (int32_t i = 0; i < topicNumGet; i++) { SMqClientTopic topic = {0}; SMqSubTopicEp* pTopicEp = taosArrayGet(pRsp->topics, i); - topic.schema = pTopicEp->schema; - pTopicEp->schema.nCols = 0; - pTopicEp->schema.pSchema = NULL; - tstrncpy(topic.topicName, pTopicEp->topic, TSDB_TOPIC_FNAME_LEN); - tstrncpy(topic.db, pTopicEp->db, TSDB_DB_FNAME_LEN); - - tscDebug("consumer:0x%" PRIx64 ", update topic: %s", tmq->consumerId, topic.topicName); - - int32_t vgNumGet = taosArrayGetSize(pTopicEp->vgs); - topic.vgs = taosArrayInit(vgNumGet, sizeof(SMqClientVg)); - for (int32_t j = 0; j < vgNumGet; j++) { - SMqSubVgEp* pVgEp = taosArrayGet(pTopicEp->vgs, j); - sprintf(vgKey, "%s:%d", topic.topicName, pVgEp->vgId); - STqOffsetVal* pOffset = taosHashGet(pHash, vgKey, strlen(vgKey)); - STqOffsetVal offsetNew = {.type = tmq->resetOffsetCfg}; - if (pOffset != NULL) { - offsetNew = *pOffset; - } - - SMqClientVg clientVg = { - .pollCnt = 0, - .currentOffset = offsetNew, - .vgId = pVgEp->vgId, - .epSet = pVgEp->epSet, - .vgStatus = TMQ_VG_STATUS__IDLE, - .vgSkipCnt = 0, - }; - taosArrayPush(topic.vgs, &clientVg); - set = true; - } + initClientTopicFromRsp(&topic, pTopicEp, pVgOffsetHashMap, tmq); taosArrayPush(newTopics, &topic); } + taosHashCleanup(pVgOffsetHashMap); + + taosThreadMutexLock(&tmq->lock); // destroy current buffered existed topics info if (tmq->clientTopics) { - int32_t sz = taosArrayGetSize(tmq->clientTopics); - for (int32_t i = 0; i < sz; i++) { - SMqClientTopic* pTopic = taosArrayGet(tmq->clientTopics, i); - if (pTopic->schema.nCols) taosMemoryFreeClear(pTopic->schema.pSchema); - taosArrayDestroy(pTopic->vgs); - } - - taosArrayDestroy(tmq->clientTopics); + taosArrayDestroyEx(tmq->clientTopics, freeClientVgInfo); } - taosHashCleanup(pHash); tmq->clientTopics = newTopics; + taosThreadMutexUnlock(&tmq->lock); - if (taosArrayGetSize(tmq->clientTopics) == 0) { - atomic_store_8(&tmq->status, TMQ_CONSUMER_STATUS__NO_TOPIC); - } else { - atomic_store_8(&tmq->status, TMQ_CONSUMER_STATUS__READY); - } - + int8_t flag = (topicNumGet == 0) ? TMQ_CONSUMER_STATUS__NO_TOPIC : TMQ_CONSUMER_STATUS__READY; + atomic_store_8(&tmq->status, flag); atomic_store_32(&tmq->epoch, epoch); + tscDebug("consumer:0x%" PRIx64 " update topic info completed", tmq->consumerId); return set; } -int32_t tmqAskEpCb(void* param, SDataBuf* pMsg, int32_t code) { +int32_t askEpCallbackFn(void* param, SDataBuf* pMsg, int32_t code) { SMqAskEpCbParam* pParam = (SMqAskEpCbParam*)param; - int8_t async = pParam->async; tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, pParam->refId); if (tmq == NULL) { - if (!async) { - tsem_destroy(&pParam->rspSem); - } else { - taosMemoryFree(pParam); - } + terrno = TSDB_CODE_TMQ_CONSUMER_CLOSED; + pParam->pUserFn(tmq, terrno, NULL, pParam->pParam); + taosMemoryFree(pMsg->pData); taosMemoryFree(pMsg->pEpSet); - terrno = TSDB_CODE_TMQ_CONSUMER_CLOSED; - return -1; + taosMemoryFree(pParam); + return terrno; } - pParam->code = code; - if (code != 0) { - tscError("consumer:0x%" PRIx64 ", get topic endpoint error, async:%d, code:%s", tmq->consumerId, pParam->async, - tstrerror(code)); - goto END; + if (code != TSDB_CODE_SUCCESS) { + tscError("consumer:0x%" PRIx64 ", get topic endpoint error, code:%s", tmq->consumerId, tstrerror(code)); + pParam->pUserFn(tmq, code, NULL, pParam->pParam); + + taosReleaseRef(tmqMgmt.rsetId, pParam->refId); + + taosMemoryFree(pMsg->pData); + taosMemoryFree(pMsg->pEpSet); + taosMemoryFree(pParam); + return code; } // tmq's epoch is monotonically increase, @@ -1459,132 +1525,26 @@ int32_t tmqAskEpCb(void* param, SDataBuf* pMsg, int32_t code) { if (head->epoch <= epoch) { tscDebug("consumer:0x%" PRIx64 ", recv ep, msg epoch %d, current epoch %d, no need to update local ep", tmq->consumerId, head->epoch, epoch); - goto END; - } - - tscDebug("consumer:0x%" PRIx64 ", recv ep, msg epoch %d, current epoch %d, update local ep", tmq->consumerId, - head->epoch, epoch); - if (!async) { - SMqAskEpRsp rsp; - tDecodeSMqAskEpRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &rsp); - /*printf("rsp epoch %" PRId64 " sz %" PRId64 "\n", rsp.epoch, rsp.topics->size);*/ - /*printf("tmq epoch %" PRId64 " sz %" PRId64 "\n", tmq->epoch, tmq->clientTopics->size);*/ - tmqUpdateEp(tmq, head->epoch, &rsp); - tDeleteSMqAskEpRsp(&rsp); - } else { - SMqAskEpRspWrapper* pWrapper = taosAllocateQitem(sizeof(SMqAskEpRspWrapper), DEF_QITEM, 0); - if (pWrapper == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - code = -1; - goto END; + if (tmq->status == TMQ_CONSUMER_STATUS__RECOVER) { + SMqAskEpRsp rsp; + tDecodeSMqAskEpRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &rsp); + int8_t flag = (taosArrayGetSize(rsp.topics) == 0) ? TMQ_CONSUMER_STATUS__NO_TOPIC : TMQ_CONSUMER_STATUS__READY; + atomic_store_8(&tmq->status, flag); + tDeleteSMqAskEpRsp(&rsp); } - pWrapper->tmqRspType = TMQ_MSG_TYPE__EP_RSP; - pWrapper->epoch = head->epoch; - memcpy(&pWrapper->msg, pMsg->pData, sizeof(SMqRspHead)); - tDecodeSMqAskEpRsp(POINTER_SHIFT(pMsg->pData, sizeof(SMqRspHead)), &pWrapper->msg); - - taosWriteQitem(tmq->mqueue, pWrapper); - tsem_post(&tmq->rspSem); - } - -END: - /*atomic_store_8(&tmq->epStatus, 0);*/ - if (!async) { - tsem_post(&pParam->rspSem); } else { - taosMemoryFree(pParam); + tscDebug("consumer:0x%" PRIx64 ", recv ep, msg epoch %d, current epoch %d, update local ep", tmq->consumerId, + head->epoch, epoch); + pParam->pUserFn(tmq, code, pMsg, pParam->pParam); } + taosReleaseRef(tmqMgmt.rsetId, pParam->refId); + taosMemoryFree(pMsg->pEpSet); taosMemoryFree(pMsg->pData); - return code; -} - -int32_t tmqAskEp(tmq_t* tmq, bool async) { - int32_t code = TSDB_CODE_SUCCESS; -#if 0 - int8_t epStatus = atomic_val_compare_exchange_8(&tmq->epStatus, 0, 1); - if (epStatus == 1) { - int32_t epSkipCnt = atomic_add_fetch_32(&tmq->epSkipCnt, 1); - tscTrace("consumer:0x%" PRIx64 ", skip ask ep cnt %d", tmq->consumerId, epSkipCnt); - if (epSkipCnt < 5000) return 0; - } - atomic_store_32(&tmq->epSkipCnt, 0); -#endif - - SMqAskEpReq req = {0}; - req.consumerId = tmq->consumerId; - req.epoch = tmq->epoch; - strcpy(req.cgroup, tmq->groupId); - - int32_t tlen = tSerializeSMqAskEpReq(NULL, 0, &req); - if (tlen < 0) { - tscError("consumer:0x%" PRIx64 ", tSerializeSMqAskEpReq failed", tmq->consumerId); - return -1; - } - - void* pReq = taosMemoryCalloc(1, tlen); - if (pReq == NULL) { - tscError("consumer:0x%" PRIx64 ", failed to malloc askEpReq msg, size:%d", tmq->consumerId, tlen); - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - - if (tSerializeSMqAskEpReq(pReq, tlen, &req) < 0) { - tscError("consumer:0x%" PRIx64 ", tSerializeSMqAskEpReq %d failed", tmq->consumerId, tlen); - taosMemoryFree(pReq); - return -1; - } - - SMqAskEpCbParam* pParam = taosMemoryCalloc(1, sizeof(SMqAskEpCbParam)); - if (pParam == NULL) { - tscError("consumer:0x%" PRIx64 ", failed to malloc subscribe param", tmq->consumerId); - taosMemoryFree(pReq); - /*atomic_store_8(&tmq->epStatus, 0);*/ - return -1; - } - - pParam->refId = tmq->refId; - pParam->epoch = tmq->epoch; - pParam->async = async; - tsem_init(&pParam->rspSem, 0, 0); - - SMsgSendInfo* sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); - if (sendInfo == NULL) { - tsem_destroy(&pParam->rspSem); - taosMemoryFree(pParam); - taosMemoryFree(pReq); - /*atomic_store_8(&tmq->epStatus, 0);*/ - return -1; - } - - sendInfo->msgInfo = (SDataBuf){ - .pData = pReq, - .len = tlen, - .handle = NULL, - }; - - sendInfo->requestId = generateRequestId(); - sendInfo->requestObjRefId = 0; - sendInfo->param = pParam; - sendInfo->fp = tmqAskEpCb; - sendInfo->msgType = TDMT_MND_TMQ_ASK_EP; - - SEpSet epSet = getEpSet_s(&tmq->pTscObj->pAppInfo->mgmtEp); - tscDebug("consumer:0x%" PRIx64 " ask ep from mnode, async:%d, reqId:0x%" PRIx64, tmq->consumerId, async, - sendInfo->requestId); - - int64_t transporterId = 0; - asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); - - if (!async) { - tsem_wait(&pParam->rspSem); - code = pParam->code; - taosMemoryFree(pParam); - } - + taosMemoryFree(pParam); return code; } @@ -1616,21 +1576,33 @@ SMqMetaRspObj* tmqBuildMetaRspFromWrapper(SMqPollRspWrapper* pWrapper) { return pRspObj; } -SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper) { +SMqRspObj* tmqBuildRspFromWrapper(SMqPollRspWrapper* pWrapper, SMqClientVg* pVg, int64_t* numOfRows) { SMqRspObj* pRspObj = taosMemoryCalloc(1, sizeof(SMqRspObj)); pRspObj->resType = RES_TYPE__TMQ; + + (*numOfRows) = 0; 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; pRspObj->resIter = -1; memcpy(&pRspObj->rsp, &pWrapper->dataRsp, sizeof(SMqDataRsp)); pRspObj->resInfo.totalRows = 0; pRspObj->resInfo.precision = TSDB_TIME_PRECISION_MILLI; + if (!pWrapper->dataRsp.withSchema) { setResSchemaInfo(&pRspObj->resInfo, pWrapper->topicHandle->schema.pSchema, pWrapper->topicHandle->schema.nCols); } + // extract the rows in this data packet + for (int32_t i = 0; i < pRspObj->rsp.blockNum; ++i) { + SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)taosArrayGetP(pRspObj->rsp.blockData, i); + int64_t rows = htobe64(pRetrieve->numOfRows); + pVg->numOfRows += rows; + (*numOfRows) += rows; + } + return pRspObj; } @@ -1713,8 +1685,8 @@ static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* p char offsetFormatBuf[80]; tFormatOffset(offsetFormatBuf, tListLen(offsetFormatBuf), &pVg->currentOffset); - tscDebug("consumer:0x%" PRIx64 " send poll to %s vgId:%d, epoch %d, req:%s, reqId:0x%" PRIx64, - pTmq->consumerId, pTopic->topicName, pVg->vgId, pTmq->epoch, offsetFormatBuf, req.reqId); + tscDebug("consumer:0x%" PRIx64 " send poll to %s vgId:%d, epoch %d, req:%s, reqId:0x%" PRIx64, pTmq->consumerId, + pTopic->topicName, pVg->vgId, pTmq->epoch, offsetFormatBuf, req.reqId); asyncSendMsgToServer(pTmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo); pVg->pollCnt++; @@ -1724,7 +1696,7 @@ static int32_t doTmqPollImpl(tmq_t* pTmq, SMqClientTopic* pTopic, SMqClientVg* p } // broadcast the poll request to all related vnodes -int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) { +static int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) { int32_t numOfTopics = taosArrayGetSize(tmq->clientTopics); tscDebug("consumer:0x%" PRIx64 " start to poll data, numOfTopics:%d", tmq->consumerId, numOfTopics); @@ -1734,7 +1706,13 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) { for (int j = 0; j < numOfVg; j++) { SMqClientVg* pVg = taosArrayGet(pTopic->vgs, j); - int32_t vgStatus = atomic_val_compare_exchange_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE, TMQ_VG_STATUS__WAIT); + if (taosGetTimestampMs() - pVg->emptyBlockReceiveTs < EMPTY_BLOCK_POLL_IDLE_DURATION) { // less than 100ms + tscTrace("consumer:0x%" PRIx64 " epoch %d, vgId:%d idle for 10ms before start next poll", tmq->consumerId, + tmq->epoch, pVg->vgId); + continue; + } + + int32_t vgStatus = atomic_val_compare_exchange_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE, TMQ_VG_STATUS__WAIT); if (vgStatus == TMQ_VG_STATUS__WAIT) { int32_t vgSkipCnt = atomic_add_fetch_32(&pVg->vgSkipCnt, 1); tscTrace("consumer:0x%" PRIx64 " epoch %d wait poll-rsp, skip vgId:%d skip cnt %d", tmq->consumerId, tmq->epoch, @@ -1757,10 +1735,11 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) { } } + tscDebug("consumer:0x%" PRIx64 " end to poll data", tmq->consumerId); return 0; } -int32_t tmqHandleNoPollRsp(tmq_t* tmq, SMqRspWrapper* rspWrapper, bool* pReset) { +static int32_t tmqHandleNoPollRsp(tmq_t* tmq, SMqRspWrapper* rspWrapper, bool* pReset) { if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__EP_RSP) { /*printf("ep %d %d\n", rspMsg->head.epoch, tmq->epoch);*/ if (rspWrapper->epoch > atomic_load_32(&tmq->epoch)) { @@ -1780,69 +1759,84 @@ int32_t tmqHandleNoPollRsp(tmq_t* tmq, SMqRspWrapper* rspWrapper, bool* pReset) return 0; } -void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { +static void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { tscDebug("consumer:0x%" PRIx64 " start to handle the rsp, total:%d", tmq->consumerId, tmq->qall->numOfItems); while (1) { - SMqRspWrapper* rspWrapper = NULL; - taosGetQitem(tmq->qall, (void**)&rspWrapper); + SMqRspWrapper* pRspWrapper = NULL; + taosGetQitem(tmq->qall, (void**)&pRspWrapper); - if (rspWrapper == NULL) { + if (pRspWrapper == NULL) { taosReadAllQitems(tmq->mqueue, tmq->qall); - taosGetQitem(tmq->qall, (void**)&rspWrapper); - - if (rspWrapper == NULL) { + taosGetQitem(tmq->qall, (void**)&pRspWrapper); + if (pRspWrapper == NULL) { return NULL; } } - if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__END_RSP) { - taosFreeQitem(rspWrapper); + tscDebug("consumer:0x%" PRIx64 " handle rsp, type:%d", tmq->consumerId, pRspWrapper->tmqRspType); + + if (pRspWrapper->tmqRspType == TMQ_MSG_TYPE__END_RSP) { + taosFreeQitem(pRspWrapper); terrno = TSDB_CODE_TQ_NO_COMMITTED_OFFSET; tscError("consumer:0x%" PRIx64 " unexpected rsp from poll, code:%s", tmq->consumerId, tstrerror(terrno)); return NULL; - } else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_RSP) { - SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper; + } else if (pRspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_RSP) { + SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)pRspWrapper; + + int32_t consumerEpoch = atomic_load_32(&tmq->epoch); + SMqDataRsp* pDataRsp = &pollRspWrapper->dataRsp; - /*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/ - int32_t consumerEpoch = atomic_load_32(&tmq->epoch); - if (pollRspWrapper->dataRsp.head.epoch == consumerEpoch) { + if (pDataRsp->head.epoch == consumerEpoch) { SMqClientVg* pVg = pollRspWrapper->vgHandle; - pVg->currentOffset = pollRspWrapper->dataRsp.rspOffset; - atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); - if (pollRspWrapper->dataRsp.blockNum == 0) { - tscDebug("consumer:0x%" PRIx64 " empty block received, vgId:%d", tmq->consumerId, pVg->vgId); - taosFreeQitem(pollRspWrapper); - rspWrapper = NULL; - continue; + // update the epset + if (pollRspWrapper->pEpset != NULL) { + SEp* pEp = GET_ACTIVE_EP(pollRspWrapper->pEpset); + SEp* pOld = GET_ACTIVE_EP(&(pVg->epSet)); + tscDebug("consumer:0x%" PRIx64 " update epset vgId:%d, ep:%s:%d, old ep:%s:%d", tmq->consumerId, pVg->vgId, + pEp->fqdn, pEp->port, pOld->fqdn, pOld->port); + pVg->epSet = *pollRspWrapper->pEpset; } - // build rsp - char buf[80]; - tFormatOffset(buf, 80, &pVg->currentOffset); - SMqRspObj* pRsp = tmqBuildRspFromWrapper(pollRspWrapper); - tscDebug("consumer:0x%" PRIx64 " process poll rsp, vgId:%d, offset:%s, blocks:%d", tmq->consumerId, - pVg->vgId, buf, pollRspWrapper->dataRsp.blockNum); + // update the local offset value only for the returned values. + pVg->currentOffset = pDataRsp->rspOffset; + atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); - taosFreeQitem(pollRspWrapper); - return pRsp; + char buf[80]; + tFormatOffset(buf, 80, &pDataRsp->rspOffset); + if (pDataRsp->blockNum == 0) { + tscDebug("consumer:0x%" PRIx64 " empty block received, vgId:%d, offset:%s, vg total:%" PRId64 + " total:%" PRId64 " reqId:0x%" PRIx64, + tmq->consumerId, pVg->vgId, buf, pVg->numOfRows, tmq->totalRows, pollRspWrapper->reqId); + pRspWrapper = tmqFreeRspWrapper(pRspWrapper); + taosFreeQitem(pollRspWrapper); + } else { // build rsp + int64_t numOfRows = 0; + SMqRspObj* pRsp = tmqBuildRspFromWrapper(pollRspWrapper, pVg, &numOfRows); + tmq->totalRows += numOfRows; + + tscDebug("consumer:0x%" PRIx64 " process poll rsp, vgId:%d, offset:%s, blocks:%d, rows:%" PRId64 + " vg total:%" PRId64 " total:%" PRId64 ", reqId:0x%" PRIx64, + tmq->consumerId, pVg->vgId, buf, pDataRsp->blockNum, numOfRows, pVg->numOfRows, tmq->totalRows, + pollRspWrapper->reqId); + taosFreeQitem(pollRspWrapper); + return pRsp; + } } else { - tscDebug("consumer:0x%" PRIx64 " msg discard since epoch mismatch: msg epoch %d, consumer epoch %d", - tmq->consumerId, pollRspWrapper->dataRsp.head.epoch, consumerEpoch); - tmqFreeRspWrapper(rspWrapper); + tscDebug("consumer:0x%" PRIx64 " vgId:%d msg discard since epoch mismatch: msg epoch %d, consumer epoch %d", + tmq->consumerId, pollRspWrapper->vgId, pDataRsp->head.epoch, consumerEpoch); + pRspWrapper = tmqFreeRspWrapper(pRspWrapper); taosFreeQitem(pollRspWrapper); } - } else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_META_RSP) { - SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper; + } else if (pRspWrapper->tmqRspType == TMQ_MSG_TYPE__POLL_META_RSP) { + SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)pRspWrapper; int32_t consumerEpoch = atomic_load_32(&tmq->epoch); tscDebug("consumer:0x%" PRIx64 " process meta rsp", tmq->consumerId); if (pollRspWrapper->metaRsp.head.epoch == consumerEpoch) { SMqClientVg* pVg = pollRspWrapper->vgHandle; - /*printf("vgId:%d, offset %" PRId64 " up to %" PRId64 "\n", pVg->vgId, pVg->currentOffset, - * rspMsg->msg.rspOffset);*/ pVg->currentOffset = pollRspWrapper->metaRsp.rspOffset; atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); // build rsp @@ -1850,62 +1844,78 @@ void* tmqHandleAllRsp(tmq_t* tmq, int64_t timeout, bool pollIfReset) { taosFreeQitem(pollRspWrapper); return pRsp; } else { - tscDebug("consumer:0x%" PRIx64 " msg discard since epoch mismatch: msg epoch %d, consumer epoch %d", - tmq->consumerId, pollRspWrapper->metaRsp.head.epoch, consumerEpoch); - tmqFreeRspWrapper(rspWrapper); + tscDebug("consumer:0x%" PRIx64 " vgId:%d msg discard since epoch mismatch: msg epoch %d, consumer epoch %d", + tmq->consumerId, pollRspWrapper->vgId, pollRspWrapper->metaRsp.head.epoch, consumerEpoch); + pRspWrapper = tmqFreeRspWrapper(pRspWrapper); taosFreeQitem(pollRspWrapper); } - } else if (rspWrapper->tmqRspType == TMQ_MSG_TYPE__TAOSX_RSP) { - SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)rspWrapper; - /*atomic_sub_fetch_32(&tmq->readyRequest, 1);*/ - int32_t consumerEpoch = atomic_load_32(&tmq->epoch); + } else if (pRspWrapper->tmqRspType == TMQ_MSG_TYPE__TAOSX_RSP) { + SMqPollRspWrapper* pollRspWrapper = (SMqPollRspWrapper*)pRspWrapper; + int32_t consumerEpoch = atomic_load_32(&tmq->epoch); + if (pollRspWrapper->taosxRsp.head.epoch == consumerEpoch) { SMqClientVg* pVg = pollRspWrapper->vgHandle; - /*printf("vgId:%d, offset %" PRId64 " up to %" PRId64 "\n", pVg->vgId, pVg->currentOffset, - * rspMsg->msg.rspOffset);*/ pVg->currentOffset = pollRspWrapper->taosxRsp.rspOffset; atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE); + if (pollRspWrapper->taosxRsp.blockNum == 0) { + tscDebug("consumer:0x%" PRIx64 " taosx empty block received, vgId:%d, vg total:%" PRId64 " reqId:0x%" PRIx64, + tmq->consumerId, pVg->vgId, pVg->numOfRows, pollRspWrapper->reqId); + pVg->emptyBlockReceiveTs = taosGetTimestampMs(); + pRspWrapper = tmqFreeRspWrapper(pRspWrapper); taosFreeQitem(pollRspWrapper); - rspWrapper = NULL; continue; + } else { + pVg->emptyBlockReceiveTs = 0; // reset the ts } // build rsp - void* pRsp = NULL; + void* pRsp = NULL; + int64_t numOfRows = 0; if (pollRspWrapper->taosxRsp.createTableNum == 0) { - pRsp = tmqBuildRspFromWrapper(pollRspWrapper); + pRsp = tmqBuildRspFromWrapper(pollRspWrapper, pVg, &numOfRows); } else { pRsp = tmqBuildTaosxRspFromWrapper(pollRspWrapper); } + + tmq->totalRows += numOfRows; + + char buf[80]; + tFormatOffset(buf, 80, &pVg->currentOffset); + tscDebug("consumer:0x%" PRIx64 " process taosx poll rsp, vgId:%d, offset:%s, blocks:%d, rows:%" PRId64 + ", vg total:%" PRId64 " total:%" PRId64 " reqId:0x%" PRIx64, + tmq->consumerId, pVg->vgId, buf, pollRspWrapper->dataRsp.blockNum, numOfRows, pVg->numOfRows, + tmq->totalRows, pollRspWrapper->reqId); + taosFreeQitem(pollRspWrapper); return pRsp; + } else { - tscDebug("consumer:0x%" PRIx64 " msg discard since epoch mismatch: msg epoch %d, consumer epoch %d", - tmq->consumerId, pollRspWrapper->taosxRsp.head.epoch, consumerEpoch); - tmqFreeRspWrapper(rspWrapper); + tscDebug("consumer:0x%" PRIx64 " vgId:%d msg discard since epoch mismatch: msg epoch %d, consumer epoch %d", + tmq->consumerId, pollRspWrapper->vgId, pollRspWrapper->taosxRsp.head.epoch, consumerEpoch); + pRspWrapper = tmqFreeRspWrapper(pRspWrapper); taosFreeQitem(pollRspWrapper); } } else { - /*printf("handle ep rsp %d\n", rspMsg->head.mqMsgType);*/ + tscDebug("consumer:0x%" PRIx64 " not data msg received", tmq->consumerId); + bool reset = false; - tmqHandleNoPollRsp(tmq, rspWrapper, &reset); - taosFreeQitem(rspWrapper); + tmqHandleNoPollRsp(tmq, pRspWrapper, &reset); + taosFreeQitem(pRspWrapper); if (pollIfReset && reset) { tscDebug("consumer:0x%" PRIx64 ", reset and repoll", tmq->consumerId); tmqPollImpl(tmq, timeout); } } } - - tscDebug("consumer:0x%" PRIx64 " handle the rsp completed", tmq->consumerId); } TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) { void* rspObj; int64_t startTime = taosGetTimestampMs(); - tscDebug("consumer:0x%" PRIx64 " start to poll at %" PRId64, tmq->consumerId, startTime); + tscDebug("consumer:0x%" PRIx64 " start to poll at %" PRId64 ", timeout:%" PRId64, tmq->consumerId, startTime, + timeout); #if 0 tmqHandleAllDelayedTask(tmq); @@ -1923,9 +1933,9 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) { return NULL; } - if (atomic_load_8(&tmq->status) == TMQ_CONSUMER_STATUS__RECOVER) { + while (atomic_load_8(&tmq->status) == TMQ_CONSUMER_STATUS__RECOVER) { int32_t retryCnt = 0; - while (TSDB_CODE_MND_CONSUMER_NOT_READY == tmqAskEp(tmq, false)) { + while (TSDB_CODE_MND_CONSUMER_NOT_READY == doAskEp(tmq)) { if (retryCnt++ > 40) { return NULL; } @@ -1940,7 +1950,6 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) { if (tmqPollImpl(tmq, timeout) < 0) { tscDebug("consumer:0x%" PRIx64 " return due to poll error", tmq->consumerId); - /*return NULL;*/ } rspObj = tmqHandleAllRsp(tmq, timeout, false); @@ -1952,7 +1961,7 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) { return NULL; } - if (timeout != -1) { + if (timeout >= 0) { int64_t currentTime = taosGetTimestampMs(); int64_t elapsedTime = currentTime - startTime; if (elapsedTime > timeout) { @@ -1960,9 +1969,6 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) { tmq->consumerId, tmq->epoch, startTime, currentTime); return NULL; } - /*tscInfo("consumer:0x%" PRIx64 ", (epoch %d) wait, start time %" PRId64 ", current time %" PRId64*/ - /*", left time %" PRId64,*/ - /*tmq->consumerId, tmq->epoch, startTime, currentTime, (timeout - elapsedTime));*/ tsem_timewait(&tmq->rspSem, (timeout - elapsedTime)); } else { // use tsem_timewait instead of tsem_wait to avoid unexpected stuck @@ -1971,17 +1977,43 @@ TAOS_RES* tmq_consumer_poll(tmq_t* tmq, int64_t timeout) { } } +static void displayConsumeStatistics(const tmq_t* pTmq) { + int32_t numOfTopics = taosArrayGetSize(pTmq->clientTopics); + tscDebug("consumer:0x%" PRIx64 " closing poll:%" PRId64 " rows:%" PRId64 " topics:%d, final epoch:%d", + pTmq->consumerId, pTmq->pollCnt, pTmq->totalRows, numOfTopics, pTmq->epoch); + + tscDebug("consumer:0x%" PRIx64 " rows dist begin: ", pTmq->consumerId); + for (int32_t i = 0; i < numOfTopics; ++i) { + SMqClientTopic* pTopics = taosArrayGet(pTmq->clientTopics, i); + + tscDebug("consumer:0x%" PRIx64 " topic:%d", pTmq->consumerId, i); + int32_t numOfVgs = taosArrayGetSize(pTopics->vgs); + for (int32_t j = 0; j < numOfVgs; ++j) { + SMqClientVg* pVg = taosArrayGet(pTopics->vgs, j); + tscDebug("topic:%s, %d. vgId:%d rows:%" PRId64, pTopics->topicName, j, pVg->vgId, pVg->numOfRows); + } + } + + tscDebug("consumer:0x%" PRIx64 " rows dist end", pTmq->consumerId); +} + int32_t tmq_consumer_close(tmq_t* tmq) { + tscDebug("consumer:0x%" PRIx64 " start to close consumer, status:%d", tmq->consumerId, tmq->status); + displayConsumeStatistics(tmq); + if (tmq->status == TMQ_CONSUMER_STATUS__READY) { - int32_t rsp = tmq_commit_sync(tmq, NULL); - if (rsp != 0) { - return rsp; + // if auto commit is set, commit before close consumer. Otherwise, do nothing. + if (tmq->autoCommit) { + int32_t rsp = tmq_commit_sync(tmq, NULL); + if (rsp != 0) { + return rsp; + } } int32_t retryCnt = 0; tmq_list_t* lst = tmq_list_new(); while (1) { - rsp = tmq_subscribe(tmq, lst); + int32_t rsp = tmq_subscribe(tmq, lst); if (rsp != TSDB_CODE_MND_CONSUMER_NOT_READY || retryCnt > 5) { break; } else { @@ -1991,7 +2023,10 @@ int32_t tmq_consumer_close(tmq_t* tmq) { } tmq_list_destroy(lst); + } else { + tscWarn("consumer:0x%" PRIx64 " not in ready state, close it directly", tmq->consumerId); } + taosRemoveRef(tmqMgmt.rsetId, tmq->refId); return 0; } @@ -2082,12 +2117,194 @@ const char* tmq_get_table_name(TAOS_RES* res) { return NULL; } -void tmq_commit_async(tmq_t* tmq, const TAOS_RES* msg, tmq_commit_cb* cb, void* param) { - // - tmqCommitInner(tmq, msg, 0, 1, cb, param); +void tmq_commit_async(tmq_t* tmq, const TAOS_RES* pRes, tmq_commit_cb* cb, void* param) { + if (pRes == NULL) { // here needs to commit all offsets. + asyncCommitAllOffsets(tmq, cb, param); + } else { // only commit one offset + asyncCommitOffset(tmq, pRes, cb, param); + } } -int32_t tmq_commit_sync(tmq_t* tmq, const TAOS_RES* msg) { - // - return tmqCommitInner(tmq, msg, 0, 0, NULL, NULL); +typedef struct SSyncCommitInfo { + tsem_t sem; + int32_t code; +} SSyncCommitInfo; + +static void commitCallBackFn(tmq_t* pTmq, int32_t code, void* param) { + SSyncCommitInfo* pInfo = (SSyncCommitInfo*)param; + pInfo->code = code; + tsem_post(&pInfo->sem); +} + +int32_t tmq_commit_sync(tmq_t* tmq, const TAOS_RES* pRes) { + int32_t code = 0; + + SSyncCommitInfo* pInfo = taosMemoryMalloc(sizeof(SSyncCommitInfo)); + tsem_init(&pInfo->sem, 0, 0); + pInfo->code = 0; + + if (pRes == NULL) { + asyncCommitAllOffsets(tmq, commitCallBackFn, pInfo); + } else { + asyncCommitOffset(tmq, pRes, commitCallBackFn, pInfo); + } + + tsem_wait(&pInfo->sem); + code = pInfo->code; + + tsem_destroy(&pInfo->sem); + taosMemoryFree(pInfo); + + tscDebug("consumer:0x%" PRIx64 " sync commit done, code:%s", tmq->consumerId, tstrerror(code)); + return code; +} + +void updateEpCallbackFn(tmq_t* pTmq, int32_t code, SDataBuf* pDataBuf, void* param) { + SAskEpInfo* pInfo = param; + pInfo->code = code; + + if (code == TSDB_CODE_SUCCESS) { + SMqRspHead* head = pDataBuf->pData; + + SMqAskEpRsp rsp; + tDecodeSMqAskEpRsp(POINTER_SHIFT(pDataBuf->pData, sizeof(SMqRspHead)), &rsp); + tmqUpdateEp(pTmq, head->epoch, &rsp); + tDeleteSMqAskEpRsp(&rsp); + } + + tsem_post(&pInfo->sem); +} + +void addToQueueCallbackFn(tmq_t* pTmq, int32_t code, SDataBuf* pDataBuf, void* param) { + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + return; + } + + SMqAskEpRspWrapper* pWrapper = taosAllocateQitem(sizeof(SMqAskEpRspWrapper), DEF_QITEM, 0); + if (pWrapper == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return; + } + + SMqRspHead* head = pDataBuf->pData; + + pWrapper->tmqRspType = TMQ_MSG_TYPE__EP_RSP; + pWrapper->epoch = head->epoch; + memcpy(&pWrapper->msg, pDataBuf->pData, sizeof(SMqRspHead)); + tDecodeSMqAskEpRsp(POINTER_SHIFT(pDataBuf->pData, sizeof(SMqRspHead)), &pWrapper->msg); + + taosWriteQitem(pTmq->mqueue, pWrapper); +} + +int32_t doAskEp(tmq_t* pTmq) { + SAskEpInfo* pInfo = taosMemoryMalloc(sizeof(SAskEpInfo)); + tsem_init(&pInfo->sem, 0, 0); + + asyncAskEp(pTmq, updateEpCallbackFn, pInfo); + tsem_wait(&pInfo->sem); + + int32_t code = pInfo->code; + tsem_destroy(&pInfo->sem); + taosMemoryFree(pInfo); + return code; +} + +void asyncAskEp(tmq_t* pTmq, __tmq_askep_fn_t askEpFn, void* param) { + SMqAskEpReq req = {0}; + req.consumerId = pTmq->consumerId; + req.epoch = pTmq->epoch; + strcpy(req.cgroup, pTmq->groupId); + + int32_t tlen = tSerializeSMqAskEpReq(NULL, 0, &req); + if (tlen < 0) { + tscError("consumer:0x%" PRIx64 ", tSerializeSMqAskEpReq failed", pTmq->consumerId); + askEpFn(pTmq, TSDB_CODE_INVALID_PARA, NULL, param); + return; + } + + void* pReq = taosMemoryCalloc(1, tlen); + if (pReq == NULL) { + tscError("consumer:0x%" PRIx64 ", failed to malloc askEpReq msg, size:%d", pTmq->consumerId, tlen); + askEpFn(pTmq, TSDB_CODE_OUT_OF_MEMORY, NULL, param); + return; + } + + if (tSerializeSMqAskEpReq(pReq, tlen, &req) < 0) { + tscError("consumer:0x%" PRIx64 ", tSerializeSMqAskEpReq %d failed", pTmq->consumerId, tlen); + taosMemoryFree(pReq); + + askEpFn(pTmq, TSDB_CODE_INVALID_PARA, NULL, param); + return; + } + + SMqAskEpCbParam* pParam = taosMemoryCalloc(1, sizeof(SMqAskEpCbParam)); + if (pParam == NULL) { + tscError("consumer:0x%" PRIx64 ", failed to malloc subscribe param", pTmq->consumerId); + taosMemoryFree(pReq); + + askEpFn(pTmq, TSDB_CODE_OUT_OF_MEMORY, NULL, param); + return; + } + + pParam->refId = pTmq->refId; + pParam->epoch = pTmq->epoch; + pParam->pUserFn = askEpFn; + pParam->pParam = param; + + SMsgSendInfo* sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); + if (sendInfo == NULL) { + taosMemoryFree(pParam); + taosMemoryFree(pReq); + askEpFn(pTmq, TSDB_CODE_OUT_OF_MEMORY, NULL, param); + return; + } + + sendInfo->msgInfo = (SDataBuf){.pData = pReq, .len = tlen, .handle = NULL}; + + sendInfo->requestId = generateRequestId(); + sendInfo->requestObjRefId = 0; + sendInfo->param = pParam; + sendInfo->fp = askEpCallbackFn; + sendInfo->msgType = TDMT_MND_TMQ_ASK_EP; + + SEpSet epSet = getEpSet_s(&pTmq->pTscObj->pAppInfo->mgmtEp); + tscDebug("consumer:0x%" PRIx64 " ask ep from mnode, reqId:0x%" PRIx64, pTmq->consumerId, sendInfo->requestId); + + int64_t transporterId = 0; + asyncSendMsgToServer(pTmq->pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); +} + +int32_t makeTopicVgroupKey(char* dst, const char* topicName, int32_t vg) { + return sprintf(dst, "%s:%d", topicName, vg); +} + +int32_t tmqCommitDone(SMqCommitCbParamSet* pParamSet) { + int64_t refId = pParamSet->refId; + + tmq_t* tmq = taosAcquireRef(tmqMgmt.rsetId, refId); + if (tmq == NULL) { + taosMemoryFree(pParamSet); + terrno = TSDB_CODE_TMQ_CONSUMER_CLOSED; + return -1; + } + + // if no more waiting rsp + pParamSet->callbackFn(tmq, pParamSet->code, pParamSet->userParam); + taosMemoryFree(pParamSet); + + taosReleaseRef(tmqMgmt.rsetId, refId); + return 0; +} + +void commitRspCountDown(SMqCommitCbParamSet* pParamSet, int64_t consumerId, const char* pTopic, int32_t vgId) { + int32_t waitingRspNum = atomic_sub_fetch_32(&pParamSet->waitingRspNum, 1); + if (waitingRspNum == 0) { + tscDebug("consumer:0x%" PRIx64 " topic:%s vgId:%d all commit-rsp received, commit completed", consumerId, pTopic, + vgId); + tmqCommitDone(pParamSet); + } else { + tscDebug("consumer:0x%" PRIx64 " topic:%s vgId:%d commit-rsp received, remain:%d", consumerId, pTopic, vgId, + waitingRspNum); + } } diff --git a/source/client/src/clientTmqConnector.c b/source/client/src/clientTmqConnector.c index a8c9f2279d73f2cedf1c698d703c5591885a431e..894c51d13c9dd8e4205763893206de7ef86cdf7c 100644 --- a/source/client/src/clientTmqConnector.c +++ b/source/client/src/clientTmqConnector.c @@ -361,8 +361,8 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_fetchRawBlockImp( TAOS_RES *tres = (TAOS_RES *)res; - void *data; - int32_t numOfRows; + void *data = NULL; + int32_t numOfRows = 0; int error_code = taos_fetch_raw_block(tres, &numOfRows, &data); if (numOfRows == 0) { if (error_code == JNI_SUCCESS) { diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 2f3d60001944365451e312baf48097169f4587bf..517d8e0221136cab9c1075ee06d6e98106b4f7ca 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -52,15 +52,15 @@ void printResult(TAOS_RES* pRes) { int32_t n = 0; char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { -// int32_t* length = taos_fetch_lengths(pRes); -// for(int32_t i = 0; i < numOfFields; ++i) { -// printf("(%d):%d " , i, length[i]); -// } -// printf("\n"); -// -// int32_t code = taos_print_row(str, pRow, pFields, numOfFields); -// printf("%s\n", str); -// memset(str, 0, sizeof(str)); + // int32_t* length = taos_fetch_lengths(pRes); + // for(int32_t i = 0; i < numOfFields; ++i) { + // printf("(%d):%d " , i, length[i]); + // } + // printf("\n"); + // + // int32_t code = taos_print_row(str, pRow, pFields, numOfFields); + // printf("%s\n", str); + // memset(str, 0, sizeof(str)); } } @@ -112,7 +112,7 @@ void createNewTable(TAOS* pConn, int32_t index) { } taos_free_result(pRes); - for(int32_t i = 0; i < 2000; i += 20) { + for (int32_t i = 0; i < 100; i += 20) { char sql[1024] = {0}; sprintf(sql, "insert into tu%d values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)" @@ -131,7 +131,7 @@ void createNewTable(TAOS* pConn, int32_t index) { } } -void *queryThread(void *arg) { +void* queryThread(void* arg) { TAOS* pConn = taos_connect("192.168.0.209", "root", "taosdata", NULL, 0); if (pConn == NULL) { printf("failed to connect to db, reason:%s", taos_errstr(pConn)); @@ -141,9 +141,10 @@ void *queryThread(void *arg) { int64_t el = 0; for (int32_t i = 0; i < 5000000; ++i) { - int64_t st = taosGetTimestampUs(); + int64_t st = taosGetTimestampUs(); TAOS_RES* pRes = taos_query(pConn, - "SELECT _wstart as ts,max(usage_user) FROM benchmarkcpu.host_49 WHERE ts >= 1451618560000 AND ts < 1451622160000 INTERVAL(1m) ;"); + "SELECT _wstart as ts,max(usage_user) FROM benchmarkcpu.host_49 WHERE ts >= " + "1451618560000 AND ts < 1451622160000 INTERVAL(1m) ;"); if (taos_errno(pRes) != 0) { printf("failed, reason:%s\n", taos_errstr(pRes)); } else { @@ -153,7 +154,7 @@ void *queryThread(void *arg) { taos_free_result(pRes); el += (taosGetTimestampUs() - st); if (i % 1000 == 0 && i != 0) { - printf("total:%d, avg time:%.2fms\n", i, el/(double)(i*1000)); + printf("total:%d, avg time:%.2fms\n", i, el / (double)(i * 1000)); } } @@ -163,8 +164,80 @@ void *queryThread(void *arg) { static int32_t numOfThreads = 1; -void tmq_commit_cb_print(tmq_t *pTmq, int32_t code, void *param) { - printf("success, code:%d\n", code); +void tmq_commit_cb_print(tmq_t* pTmq, int32_t code, void* param) { printf("success, code:%d\n", code); } + +void* doConsumeData(void* param) { + TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); + + tmq_conf_t* conf = tmq_conf_new(); + tmq_conf_set(conf, "enable.auto.commit", "true"); + tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); + tmq_conf_set(conf, "group.id", "cgrpName12"); + tmq_conf_set(conf, "td.connect.user", "root"); + tmq_conf_set(conf, "td.connect.pass", "taosdata"); + tmq_conf_set(conf, "auto.offset.reset", "earliest"); + tmq_conf_set(conf, "experimental.snapshot.enable", "true"); + tmq_conf_set(conf, "msg.with.table.name", "true"); + tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); + + tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); + tmq_conf_destroy(conf); + + // 创建订阅 topics 列表 + tmq_list_t* topicList = tmq_list_new(); + tmq_list_append(topicList, "topic_t2"); + + // 启动订阅 + tmq_subscribe(tmq, topicList); + + tmq_list_destroy(topicList); + + TAOS_FIELD* fields = NULL; + int32_t numOfFields = 0; + int32_t precision = 0; + int32_t totalRows = 0; + int32_t msgCnt = 0; + int32_t timeout = 25000; + + int32_t count = 0; + + while (1) { + TAOS_RES* pRes = tmq_consumer_poll(tmq, timeout); + if (pRes) { + char buf[1024]; + + const char* topicName = tmq_get_topic_name(pRes); + const char* dbName = tmq_get_db_name(pRes); + int32_t vgroupId = tmq_get_vgroup_id(pRes); + + printf("topic: %s\n", topicName); + printf("db: %s\n", dbName); + printf("vgroup id: %d\n", vgroupId); + + while (1) { + TAOS_ROW row = taos_fetch_row(pRes); + if (row == NULL) { + break; + } + + fields = taos_fetch_fields(pRes); + numOfFields = taos_field_count(pRes); + precision = taos_result_precision(pRes); + taos_print_row(buf, row, fields, numOfFields); + totalRows += 1; + // printf("precision: %d, row content: %s\n", precision, buf); + } + + taos_free_result(pRes); + } else { + break; + } + } + + tmq_consumer_close(tmq); + taos_close(pConn); + fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); + return NULL; } } // namespace @@ -188,7 +261,6 @@ TEST(clientCase, driverInit_Test) { TEST(clientCase, connect_Test) { taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); - TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); if (pConn == NULL) { printf("failed to connect to server, reason:%s\n", taos_errstr(NULL)); @@ -418,17 +490,17 @@ TEST(clientCase, create_stable_Test) { ASSERT_EQ(numOfFields, 0); taos_free_result(pRes); -// pRes = taos_query(pConn, "create stable if not exists abc1.`123_$^)` (ts timestamp, `abc` int) tags(a int)"); -// if (taos_errno(pRes) != 0) { -// printf("failed to create super table 123_$^), reason:%s\n", taos_errstr(pRes)); -// } -// -// pRes = taos_query(pConn, "use abc1"); -// taos_free_result(pRes); -// pRes = taos_query(pConn, "drop stable `123_$^)`"); -// if (taos_errno(pRes) != 0) { -// printf("failed to drop super table 123_$^), reason:%s\n", taos_errstr(pRes)); -// } + // pRes = taos_query(pConn, "create stable if not exists abc1.`123_$^)` (ts timestamp, `abc` int) tags(a int)"); + // if (taos_errno(pRes) != 0) { + // printf("failed to create super table 123_$^), reason:%s\n", taos_errstr(pRes)); + // } + // + // pRes = taos_query(pConn, "use abc1"); + // taos_free_result(pRes); + // pRes = taos_query(pConn, "drop stable `123_$^)`"); + // if (taos_errno(pRes) != 0) { + // printf("failed to drop super table 123_$^), reason:%s\n", taos_errstr(pRes)); + // } taos_close(pConn); } @@ -593,8 +665,7 @@ TEST(clientCase, create_multiple_tables) { for (int32_t i = 0; i < 500; i += 2) { char sql[512] = {0}; - snprintf(sql, tListLen(sql), - "create table t_x_%d using st1 tags(2) t_x_%d using st1 tags(5)", i, i + 1); + snprintf(sql, tListLen(sql), "create table t_x_%d using st1 tags(2) t_x_%d using st1 tags(5)", i, i + 1); TAOS_RES* pres = taos_query(pConn, sql); if (taos_errno(pres) != 0) { printf("failed to create table %d\n, reason:%s", i, taos_errstr(pres)); @@ -628,7 +699,7 @@ TEST(clientCase, show_table_Test) { int32_t numOfFields = taos_num_fields(pRes); int32_t count = 0; - char str[512] = {0}; + char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t code = taos_print_row(str, pRow, pFields, numOfFields); @@ -639,30 +710,30 @@ TEST(clientCase, show_table_Test) { taos_close(pConn); } -//TEST(clientCase, drop_stable_Test) { -// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); -// assert(pConn != nullptr); +// TEST(clientCase, drop_stable_Test) { +// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); +// assert(pConn != nullptr); // -// TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1"); -// if (taos_errno(pRes) != 0) { -// printf("error in creating db, reason:%s\n", taos_errstr(pRes)); -// } -// taos_free_result(pRes); +// TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1"); +// if (taos_errno(pRes) != 0) { +// printf("error in creating db, reason:%s\n", taos_errstr(pRes)); +// } +// taos_free_result(pRes); // -// pRes = taos_query(pConn, "use abc1"); -// if (taos_errno(pRes) != 0) { -// printf("error in using db, reason:%s\n", taos_errstr(pRes)); -// } -// taos_free_result(pRes); +// pRes = taos_query(pConn, "use abc1"); +// if (taos_errno(pRes) != 0) { +// printf("error in using db, reason:%s\n", taos_errstr(pRes)); +// } +// taos_free_result(pRes); // -// pRes = taos_query(pConn, "drop stable st1"); -// if (taos_errno(pRes) != 0) { -// printf("failed to drop stable, reason:%s\n", taos_errstr(pRes)); -// } +// pRes = taos_query(pConn, "drop stable st1"); +// if (taos_errno(pRes) != 0) { +// printf("failed to drop stable, reason:%s\n", taos_errstr(pRes)); +// } // -// taos_free_result(pRes); -// taos_close(pConn); -//} +// taos_free_result(pRes); +// taos_close(pConn); +// } TEST(clientCase, generated_request_id_test) { SHashObj* phash = taosHashInit(10000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK); @@ -671,7 +742,7 @@ TEST(clientCase, generated_request_id_test) { uint64_t v = generateRequestId(); void* result = taosHashGet(phash, &v, sizeof(v)); if (result != nullptr) { -// printf("0x%llx, index:%d\n", v, i); + // printf("0x%llx, index:%d\n", v, i); } assert(result == nullptr); taosHashPut(phash, &v, sizeof(v), NULL, 0); @@ -708,7 +779,7 @@ TEST(clientCase, projection_query_tables) { // } // taos_free_result(pRes); - TAOS_RES* pRes = taos_query(pConn, "use abc2"); + TAOS_RES* pRes = taos_query(pConn, "use abc1"); taos_free_result(pRes); pRes = taos_query(pConn, "create stable st1 (ts timestamp, k int) tags(a int)"); @@ -730,7 +801,7 @@ TEST(clientCase, projection_query_tables) { } taos_free_result(pRes); - for (int32_t i = 0; i < 2; ++i) { + for (int32_t i = 0; i < 10000; ++i) { printf("create table :%d\n", i); createNewTable(pConn, i); } @@ -759,7 +830,7 @@ TEST(clientCase, projection_query_tables) { TEST(clientCase, tsbs_perf_test) { TdThread qid[20] = {0}; - for(int32_t i = 0; i < numOfThreads; ++i) { + for (int32_t i = 0; i < numOfThreads; ++i) { taosThreadCreate(&qid[i], NULL, queryThread, NULL); } getchar(); @@ -785,8 +856,8 @@ TEST(clientCase, projection_query_stables) { char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { -// int32_t code = taos_print_row(str, pRow, pFields, numOfFields); -// printf("%s\n", str); + // int32_t code = taos_print_row(str, pRow, pFields, numOfFields); + // printf("%s\n", str); } taos_free_result(pRes); @@ -825,7 +896,8 @@ use test; create table m1(ts timestamp, k int) tags(a int); create table tm0 using m1 tags(1); create table tm1 using m1 tags(2); -insert into tm0 values('2021-1-1 1:1:1.120', 1) ('2021-1-1 1:1:2.9', 2) tm1 values('2021-1-1 1:1:1.120', 11) ('2021-1-1 1:1:2.99', 22); +insert into tm0 values('2021-1-1 1:1:1.120', 1) ('2021-1-1 1:1:2.9', 2) tm1 values('2021-1-1 1:1:1.120', 11) ('2021-1-1 +1:1:2.99', 22); */ TEST(clientCase, async_api_test) { @@ -839,7 +911,7 @@ TEST(clientCase, async_api_test) { printf("failed, reason:%s\n", taos_errstr(pRes)); } - int32_t n = 0; + int32_t n = 0; TAOS_ROW pRow = NULL; TAOS_FIELD* pFields = taos_fetch_fields(pRes); int32_t numOfFields = taos_num_fields(pRes); @@ -847,8 +919,8 @@ TEST(clientCase, async_api_test) { char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t* length = taos_fetch_lengths(pRes); - for(int32_t i = 0; i < numOfFields; ++i) { - printf("(%d):%d " , i, length[i]); + for (int32_t i = 0; i < numOfFields; ++i) { + printf("(%d):%d ", i, length[i]); } printf("\n"); @@ -890,15 +962,15 @@ TEST(clientCase, update_test) { taos_free_result(pRes); - char s[256] = {0}; - for(int32_t i = 0; i < 17000; ++i) { + char s[256] = {0}; + for (int32_t i = 0; i < 17000; ++i) { sprintf(s, "insert into tup values(now+%da, %d)", i, i); pRes = taos_query(pConn, s); taos_free_result(pRes); } } -TEST(clientCase, subscription_test) { +TEST(clientCase, sub_db_test) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); @@ -912,7 +984,7 @@ TEST(clientCase, subscription_test) { tmq_conf_t* conf = tmq_conf_new(); tmq_conf_set(conf, "enable.auto.commit", "true"); tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); - tmq_conf_set(conf, "group.id", "cgrpName"); + tmq_conf_set(conf, "group.id", "cgrpNamedb"); tmq_conf_set(conf, "td.connect.user", "root"); tmq_conf_set(conf, "td.connect.pass", "taosdata"); tmq_conf_set(conf, "auto.offset.reset", "earliest"); @@ -925,7 +997,8 @@ TEST(clientCase, subscription_test) { // 创建订阅 topics 列表 tmq_list_t* topicList = tmq_list_new(); -// tmq_list_append(topicList, "topic_t1"); + tmq_list_append(topicList, "topic_t1"); + tmq_list_append(topicList, "topic_s2"); // 启动订阅 tmq_subscribe(tmq, topicList); @@ -954,7 +1027,7 @@ TEST(clientCase, subscription_test) { printf("db: %s\n", dbName); printf("vgroup id: %d\n", vgroupId); - if (count ++ > 20) { + if (count++ > 200) { tmq_unsubscribe(tmq); break; } @@ -970,11 +1043,103 @@ TEST(clientCase, subscription_test) { taos_print_row(buf, row, fields, numOfFields); printf("precision: %d, row content: %s\n", precision, buf); } + taos_free_result(pRes); } -// return rows; } fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); } +TEST(clientCase, sub_tb_test) { + taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); + + TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); + ASSERT_NE(pConn, nullptr); + + tmq_conf_t* conf = tmq_conf_new(); + tmq_conf_set(conf, "enable.auto.commit", "true"); + tmq_conf_set(conf, "auto.commit.interval.ms", "1000"); + tmq_conf_set(conf, "group.id", "cgrpName27"); + tmq_conf_set(conf, "td.connect.user", "root"); + tmq_conf_set(conf, "td.connect.pass", "taosdata"); + tmq_conf_set(conf, "auto.offset.reset", "earliest"); + tmq_conf_set(conf, "experimental.snapshot.enable", "true"); + tmq_conf_set(conf, "msg.with.table.name", "true"); + tmq_conf_set_auto_commit_cb(conf, tmq_commit_cb_print, NULL); + + tmq_t* tmq = tmq_consumer_new(conf, NULL, 0); + tmq_conf_destroy(conf); + + // 创建订阅 topics 列表 + tmq_list_t* topicList = tmq_list_new(); + tmq_list_append(topicList, "topic_t2"); + + // 启动订阅 + tmq_subscribe(tmq, topicList); + + tmq_list_destroy(topicList); + + TAOS_FIELD* fields = NULL; + int32_t numOfFields = 0; + int32_t precision = 0; + int32_t totalRows = 0; + int32_t msgCnt = 0; + int32_t timeout = 25000; + + int32_t count = 0; + + while (1) { + TAOS_RES* pRes = tmq_consumer_poll(tmq, timeout); + if (pRes) { + char buf[1024]; + + const char* topicName = tmq_get_topic_name(pRes); + const char* dbName = tmq_get_db_name(pRes); + int32_t vgroupId = tmq_get_vgroup_id(pRes); + + printf("topic: %s\n", topicName); + printf("db: %s\n", dbName); + printf("vgroup id: %d\n", vgroupId); + + while (1) { + TAOS_ROW row = taos_fetch_row(pRes); + if (row == NULL) { + break; + } + + fields = taos_fetch_fields(pRes); + numOfFields = taos_field_count(pRes); + precision = taos_result_precision(pRes); + taos_print_row(buf, row, fields, numOfFields); + totalRows += 1; + printf("precision: %d, row content: %s\n", precision, buf); + } + + taos_free_result(pRes); + // if ((++count) > 1) { + // break; + // } + } else { + break; + } + } + + tmq_consumer_close(tmq); + taos_close(pConn); + fprintf(stderr, "%d msg consumed, include %d rows\n", msgCnt, totalRows); +} + +TEST(clientCase, sub_tb_mt_test) { + taos_options(TSDB_OPTION_CONFIGDIR, "~/first/cfg"); + TdThread qid[20] = {0}; + + for (int32_t i = 0; i < 1; ++i) { + taosThreadCreate(&qid[i], NULL, doConsumeData, NULL); + } + + for (int32_t i = 0; i < 4; ++i) { + taosThreadJoin(qid[i], NULL); + } +} + #pragma GCC diagnostic pop diff --git a/source/common/src/systable.c b/source/common/src/systable.c index 4aa47a381966c225da16a2f48a555833558522de..228aa40fa9058d749ef3c2a88fef56f073ed07b0 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -114,6 +114,9 @@ static const SSysDbTableSchema userFuncSchema[] = { {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, {.name = "code_len", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, {.name = "bufsize", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, + {.name = "func_language", .bytes = TSDB_TYPE_STR_MAX_LEN - 1 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "func_body", .bytes = TSDB_MAX_BINARY_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "func_version", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, }; static const SSysDbTableSchema userIdxSchema[] = { @@ -233,6 +236,7 @@ static const SSysDbTableSchema vgroupsSchema[] = { {.name = "v4_dnode", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true}, {.name = "v4_status", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, {.name = "cacheload", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, + {.name = "cacheelements", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true}, {.name = "tsma", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true}, // {.name = "compact_start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, }; diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 3c8d394b4396776b03d3557e49aa7d87c29ffccc..e021e655496cd9f94e787ebfcb00a958519fb50c 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -147,9 +147,17 @@ int32_t colDataReserve(SColumnInfoData* pColumnInfoData, size_t newSize) { return TSDB_CODE_SUCCESS; } -static void doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t currentRow, const char* pData, - int32_t itemLen, int32_t numOfRows) { - ASSERT(pColumnInfoData->info.bytes >= itemLen); +static int32_t doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t currentRow, const char* pData, + int32_t itemLen, int32_t numOfRows, bool trimValue) { + if (pColumnInfoData->info.bytes < itemLen) { + uWarn("column/tag actual data len %d is bigger than schema len %d, trim it:%d", itemLen, pColumnInfoData->info.bytes, trimValue); + if (trimValue) { + itemLen = pColumnInfoData->info.bytes; + } else { + return TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER; + } + } + size_t start = 1; // the first item @@ -178,10 +186,12 @@ static void doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t curren pColumnInfoData->varmeta.length += numOfRows * itemLen; } + + return TSDB_CODE_SUCCESS; } int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, - uint32_t numOfRows) { + uint32_t numOfRows, bool trimValue) { int32_t len = pColumnInfoData->info.bytes; if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) { len = varDataTLen(pData); @@ -193,8 +203,7 @@ int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, } } - doCopyNItems(pColumnInfoData, currentRow, pData, len, numOfRows); - return TSDB_CODE_SUCCESS; + return doCopyNItems(pColumnInfoData, currentRow, pData, len, numOfRows, trimValue); } static void doBitmapMerge(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, const SColumnInfoData* pSource, @@ -973,7 +982,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) { taosSort(pColInfoData->pData, pDataBlock->info.rows, pColInfoData->info.bytes, fn); int64_t p1 = taosGetTimestampUs(); - uDebug("blockDataSort easy cost:%" PRId64 ", rows:%d\n", p1 - p0, pDataBlock->info.rows); + uDebug("blockDataSort easy cost:%" PRId64 ", rows:%" PRId64 "\n", p1 - p0, pDataBlock->info.rows); return TSDB_CODE_SUCCESS; } else { // var data type @@ -1026,6 +1035,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo) { return TSDB_CODE_SUCCESS; } +#if 0 typedef struct SHelper { int32_t index; union { @@ -1074,59 +1084,20 @@ SHelper* createTupleIndex_rv(int32_t numOfRows, SArray* pOrderInfo, SSDataBlock* int32_t dataBlockCompar_rv(const void* p1, const void* p2, const void* param) { const SSDataBlockSortHelper* pHelper = (const SSDataBlockSortHelper*)param; - // SSDataBlock* pDataBlock = pHelper->pDataBlock; - SHelper* left = (SHelper*)p1; SHelper* right = (SHelper*)p2; SArray* pInfo = pHelper->orderInfo; int32_t offset = 0; - // for(int32_t i = 0; i < pInfo->size; ++i) { - // SBlockOrderInfo* pOrder = TARRAY_GET_ELEM(pInfo, 0); - // SColumnInfoData* pColInfoData = pOrder->pColData;//TARRAY_GET_ELEM(pDataBlock->pDataBlock, pOrder->colIndex); - - // if (pColInfoData->hasNull) { - // bool leftNull = colDataIsNull(pColInfoData, pDataBlock->info.rows, left, pDataBlock->pBlockAgg); - // bool rightNull = colDataIsNull(pColInfoData, pDataBlock->info.rows, right, pDataBlock->pBlockAgg); - // if (leftNull && rightNull) { - // continue; // continue to next slot - // } - // - // if (rightNull) { - // return pHelper->nullFirst? 1:-1; - // } - // - // if (leftNull) { - // return pHelper->nullFirst? -1:1; - // } - // } - - // void* left1 = colDataGetData(pColInfoData, left); - // void* right1 = colDataGetData(pColInfoData, right); - - // switch(pColInfoData->info.type) { - // case TSDB_DATA_TYPE_INT: { int32_t leftx = *(int32_t*)left->pData; //*(int32_t*)(left->pData + offset); int32_t rightx = *(int32_t*)right->pData; //*(int32_t*)(right->pData + offset); - // offset += pColInfoData->info.bytes; if (leftx == rightx) { - // break; return 0; } else { - // if (pOrder->order == TSDB_ORDER_ASC) { return (leftx < rightx) ? -1 : 1; - // } else { - // return (leftx < rightx)? 1:-1; - // } - } - // } - // default: - // assert(0); - // } - // } - + } return 0; } @@ -1170,6 +1141,7 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF // destroyTupleIndex(index); return 0; } +#endif void blockDataCleanup(SSDataBlock* pDataBlock) { blockDataEmpty(pDataBlock); @@ -1180,7 +1152,7 @@ void blockDataCleanup(SSDataBlock* pDataBlock) { void blockDataEmpty(SSDataBlock* pDataBlock) { SDataBlockInfo* pInfo = &pDataBlock->info; - if (pInfo->capacity == 0 || pInfo->rows > pDataBlock->info.capacity) { + if (pInfo->capacity == 0) { return; } @@ -1739,14 +1711,14 @@ int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) { int64_t tbUid = pBlock->info.id.uid; int16_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); int16_t hasVarCol = pBlock->info.hasVarCol; - int32_t rows = pBlock->info.rows; + int64_t rows = pBlock->info.rows; int32_t sz = taosArrayGetSize(pBlock->pDataBlock); int32_t tlen = 0; tlen += taosEncodeFixedI64(buf, tbUid); tlen += taosEncodeFixedI16(buf, numOfCols); tlen += taosEncodeFixedI16(buf, hasVarCol); - tlen += taosEncodeFixedI32(buf, rows); + tlen += taosEncodeFixedI64(buf, rows); tlen += taosEncodeFixedI32(buf, sz); for (int32_t i = 0; i < sz; i++) { SColumnInfoData* pColData = (SColumnInfoData*)taosArrayGet(pBlock->pDataBlock, i); @@ -1777,7 +1749,7 @@ void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock) { buf = taosDecodeFixedU64(buf, &pBlock->info.id.uid); buf = taosDecodeFixedI16(buf, &numOfCols); buf = taosDecodeFixedI16(buf, &pBlock->info.hasVarCol); - buf = taosDecodeFixedI32(buf, &pBlock->info.rows); + buf = taosDecodeFixedI64(buf, &pBlock->info.rows); buf = taosDecodeFixedI32(buf, &sz); pBlock->pDataBlock = taosArrayInit(sz, sizeof(SColumnInfoData)); for (int32_t i = 0; i < sz; i++) { @@ -1864,7 +1836,9 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) { } } struct tm ptm = {0}; - taosLocalTime(&tt, &ptm); + if (taosLocalTime(&tt, &ptm, buf) == NULL) { + return buf; + } size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", &ptm); if (precision == TSDB_TIME_PRECISION_NANO) { @@ -1878,6 +1852,7 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) { return buf; } +#if 0 void blockDebugShowDataBlock(SSDataBlock* pBlock, const char* flag) { SArray* dataBlocks = taosArrayInit(1, sizeof(SSDataBlock*)); taosArrayPush(dataBlocks, &pBlock); @@ -1970,6 +1945,8 @@ void blockDebugShowDataBlocks(const SArray* dataBlocks, const char* flag) { } } +#endif + // for debug char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf) { int32_t size = 2048; @@ -1981,7 +1958,7 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf) int32_t len = 0; len += snprintf(dumpBuf + len, size - len, "===stream===%s|block type %d|child id %d|group id:%" PRIu64 "|uid:%" PRId64 - "|rows:%d|version:%" PRIu64 "|cal start:%" PRIu64 "|cal end:%" PRIu64 "|tbl:%s\n", + "|rows:%" PRId64 "|version:%" PRIu64 "|cal start:%" PRIu64 "|cal end:%" PRIu64 "|tbl:%s\n", flag, (int32_t)pDataBlock->info.type, pDataBlock->info.childId, pDataBlock->info.id.groupId, pDataBlock->info.id.uid, pDataBlock->info.rows, pDataBlock->info.version, pDataBlock->info.calWin.skey, pDataBlock->info.calWin.ekey, pDataBlock->info.parTbName); diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 2bb870837272a0422de500d56e89c7ca245a7beb..d6ab974c6ced8305ddad0ebc86f072a08bf9c978 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -2439,6 +2439,12 @@ _exit: int32_t tColDataAddValueByDataBlock(SColData *pColData, int8_t type, int32_t bytes, int32_t nRows, char *lengthOrbitmap, char *data) { int32_t code = 0; + if(data == NULL){ + for (int32_t i = 0; i < nRows; ++i) { + code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NONE](pColData, NULL, 0); + } + goto _exit; + } if (IS_VAR_DATA_TYPE(type)) { // var-length data type for (int32_t i = 0; i < nRows; ++i) { @@ -2447,6 +2453,11 @@ int32_t tColDataAddValueByDataBlock(SColData *pColData, int8_t type, int32_t byt code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_NULL](pColData, NULL, 0); if (code) goto _exit; } else { + if(ASSERT(varDataTLen(data + offset) <= bytes)){ + uError("var data length invalid, varDataTLen(data + offset):%d <= bytes:%d", (int)varDataTLen(data + offset), bytes); + code = TSDB_CODE_INVALID_PARA; + goto _exit; + } code = tColDataAppendValueImpl[pColData->flag][CV_FLAG_VALUE](pColData, (uint8_t *)varDataVal(data + offset), varDataLen(data + offset)); } diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index f69a1721b26e2bfe399a6291d5b8a09cc59aae5f..a4ee0624ce9a55f35b2ce98cf99c1158640573f4 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -154,6 +154,7 @@ char tsTagFilterCache = 0; // positive value (in MB) int32_t tsQueryBufferSize = -1; int64_t tsQueryBufferSizeBytes = -1; +int32_t tsCacheLazyLoadThreshold = 500; int32_t tsDiskCfgNum = 0; SDiskCfg tsDiskCfg[TFS_MAX_DISKS] = {0}; @@ -229,7 +230,11 @@ static int32_t taosLoadCfg(SConfig *pCfg, const char **envCmd, const char *input taosExpandDir(inputCfgDir, cfgDir, PATH_MAX); if (taosIsDir(cfgDir)) { +#ifdef CUS_PROMPT + snprintf(cfgFile, sizeof(cfgFile), "%s" TD_DIRSEP "%s.cfg", cfgDir, CUS_PROMPT); +#else snprintf(cfgFile, sizeof(cfgFile), "%s" TD_DIRSEP "taos.cfg", cfgDir); +#endif } else { tstrncpy(cfgFile, cfgDir, sizeof(cfgDir)); } @@ -501,6 +506,8 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddInt64(pCfg, "streamBufferSize", tsStreamBufferSize, 0, INT64_MAX, 0) != 0) return -1; if (cfgAddInt64(pCfg, "checkpointInterval", tsCheckpointInterval, 0, INT64_MAX, 0) != 0) return -1; + if (cfgAddInt32(pCfg, "cacheLazyLoadThreshold", tsCacheLazyLoadThreshold, 0, 100000, 0) != 0) return -1; + GRANT_CFG_ADD; return 0; } @@ -828,6 +835,8 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL; } + tsCacheLazyLoadThreshold = cfgGetItem(pCfg, "cacheLazyLoadThreshold")->i32; + tsDisableStream = cfgGetItem(pCfg, "disableStream")->bval; tsStreamBufferSize = cfgGetItem(pCfg, "streamBufferSize")->i64; tsCheckpointInterval = cfgGetItem(pCfg, "checkpointInterval")->i64; @@ -1239,13 +1248,13 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi } if (taosLoadCfg(pCfg, envCmd, cfgDir, envFile, apolloUrl) != 0) { - uError("failed to load cfg since %s", terrstr()); + printf("failed to load cfg since %s", terrstr()); cfgCleanup(pCfg); return -1; } if (cfgLoadFromArray(pCfg, pArgs) != 0) { - uError("failed to load cfg from array since %s", terrstr()); + printf("failed to load cfg from array since %s", terrstr()); cfgCleanup(pCfg); return -1; } @@ -1261,13 +1270,13 @@ int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDi if (taosMulModeMkDir(tsLogDir, 0777) != 0) { terrno = TAOS_SYSTEM_ERROR(errno); - uError("failed to create dir:%s since %s", tsLogDir, terrstr()); + printf("failed to create dir:%s since %s", tsLogDir, terrstr()); cfgCleanup(pCfg); return -1; } if (taosInitLog(logname, logFileNum) != 0) { - uError("failed to init log file since %s", terrstr()); + printf("failed to init log file since %s", terrstr()); cfgCleanup(pCfg); return -1; } diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 9ad7c72bc0de1d90c16b3a37ef5f5186be46a21d..ac3d4e6a107c77ccdeb3a22835743fc8a567bfb2 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1070,7 +1070,8 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { if (tEncodeI64(&encoder, pload->totalStorage) < 0) return -1; if (tEncodeI64(&encoder, pload->compStorage) < 0) return -1; if (tEncodeI64(&encoder, pload->pointsWritten) < 0) return -1; - if (tEncodeI64(&encoder, reserved) < 0) return -1; + if (tEncodeI32(&encoder, pload->numOfCachedTables) < 0) return -1; + if (tEncodeI32(&encoder, reserved) < 0) return -1; if (tEncodeI64(&encoder, reserved) < 0) return -1; if (tEncodeI64(&encoder, reserved) < 0) return -1; } @@ -1148,7 +1149,8 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) { if (tDecodeI64(&decoder, &vload.totalStorage) < 0) return -1; if (tDecodeI64(&decoder, &vload.compStorage) < 0) return -1; if (tDecodeI64(&decoder, &vload.pointsWritten) < 0) return -1; - if (tDecodeI64(&decoder, &reserved) < 0) return -1; + if (tDecodeI32(&decoder, &vload.numOfCachedTables) < 0) return -1; + if (tDecodeI32(&decoder, (int32_t *)&reserved) < 0) return -1; if (tDecodeI64(&decoder, &reserved) < 0) return -1; if (tDecodeI64(&decoder, &reserved) < 0) return -1; if (taosArrayPush(pReq->pVloads, &vload) == NULL) { @@ -1700,6 +1702,9 @@ int32_t tSerializeSCreateFuncReq(void *buf, int32_t bufLen, SCreateFuncReq *pReq if (tEncodeCStr(&encoder, pReq->pComment) < 0) return -1; } + + if (tEncodeI8(&encoder, pReq->orReplace) < 0) return -1; + tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -1742,6 +1747,13 @@ int32_t tDeserializeSCreateFuncReq(void *buf, int32_t bufLen, SCreateFuncReq *pR if (tDecodeCStrTo(&decoder, pReq->pComment) < 0) return -1; } + + if (!tDecodeIsEnd(&decoder)) { + if (tDecodeI8(&decoder, &pReq->orReplace) < 0) return -1; + } else { + pReq->orReplace = false; + } + tEndDecode(&decoder); tDecoderClear(&decoder); @@ -1853,6 +1865,13 @@ int32_t tSerializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp * } } + if (pRsp->numOfFuncs != (int32_t)taosArrayGetSize(pRsp->pFuncExtraInfos)) return -1; + for (int32_t i = 0; i < pRsp->numOfFuncs; ++i) { + SFuncExtraInfo *extraInfo = taosArrayGet(pRsp->pFuncExtraInfos, i); + if (tEncodeI32(&encoder, extraInfo->funcVersion) < 0) return -1; + if (tEncodeI64(&encoder, extraInfo->funcCreatedTime) < 0) return -1; + } + tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -1900,6 +1919,22 @@ int32_t tDeserializeSRetrieveFuncRsp(void *buf, int32_t bufLen, SRetrieveFuncRsp taosArrayPush(pRsp->pFuncInfos, &fInfo); } + + pRsp->pFuncExtraInfos = taosArrayInit(pRsp->numOfFuncs, sizeof(SFuncExtraInfo)); + if (pRsp->pFuncExtraInfos == NULL) return -1; + if (tDecodeIsEnd(&decoder)) { + for (int32_t i = 0; i < pRsp->numOfFuncs; ++i) { + SFuncExtraInfo extraInfo = { 0 }; + taosArrayPush(pRsp->pFuncExtraInfos, &extraInfo); + } + } else { + for (int32_t i = 0; i < pRsp->numOfFuncs; ++i) { + SFuncExtraInfo extraInfo = { 0 }; + if (tDecodeI32(&decoder, &extraInfo.funcVersion) < 0) return -1; + if (tDecodeI64(&decoder, &extraInfo.funcCreatedTime) < 0) return -1; + taosArrayPush(pRsp->pFuncExtraInfos, &extraInfo); + } + } tEndDecode(&decoder); tDecoderClear(&decoder); @@ -1922,6 +1957,7 @@ void tFreeSRetrieveFuncRsp(SRetrieveFuncRsp *pRsp) { tFreeSFuncInfo(pInfo); } taosArrayDestroy(pRsp->pFuncInfos); + taosArrayDestroy(pRsp->pFuncExtraInfos); } int32_t tSerializeSTableCfgReq(void *buf, int32_t bufLen, STableCfgReq *pReq) { @@ -2222,7 +2258,9 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) { // 1st modification if (tEncodeI32(&encoder, pReq->minRows) < 0) return -1; - + // 2nd modification + if (tEncodeI32(&encoder, pReq->walRetentionPeriod) < 0) return -1; + if (tEncodeI32(&encoder, pReq->walRetentionSize) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -2257,6 +2295,15 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) { } else { pReq->minRows = -1; } + + // 2nd modification + if (!tDecodeIsEnd(&decoder)) { + if (tDecodeI32(&decoder, &pReq->walRetentionPeriod) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->walRetentionSize) < 0) return -1; + } else { + pReq->walRetentionPeriod = -1; + pReq->walRetentionSize = -1; + } tEndDecode(&decoder); tDecoderClear(&decoder); @@ -4187,7 +4234,9 @@ int32_t tSerializeSAlterVnodeConfigReq(void *buf, int32_t bufLen, SAlterVnodeCon // 1st modification if (tEncodeI16(&encoder, pReq->sttTrigger) < 0) return -1; if (tEncodeI32(&encoder, pReq->minRows) < 0) return -1; - + // 2nd modification + if (tEncodeI32(&encoder, pReq->walRetentionPeriod) < 0) return -1; + if (tEncodeI32(&encoder, pReq->walRetentionSize) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -4226,6 +4275,14 @@ int32_t tDeserializeSAlterVnodeConfigReq(void *buf, int32_t bufLen, SAlterVnodeC if (tDecodeI32(&decoder, &pReq->minRows) < 0) return -1; } + // 2n modification + if (tDecodeIsEnd(&decoder)) { + pReq->walRetentionPeriod = -1; + pReq->walRetentionSize = -1; + } else { + if (tDecodeI32(&decoder, &pReq->walRetentionPeriod) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->walRetentionSize) < 0) return -1; + } tEndDecode(&decoder); tDecoderClear(&decoder); return 0; @@ -4438,6 +4495,31 @@ int32_t tDeserializeSBalanceVgroupReq(void *buf, int32_t bufLen, SBalanceVgroupR return 0; } +int32_t tSerializeSBalanceVgroupLeaderReq(void *buf, int32_t bufLen, SBalanceVgroupLeaderReq *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 tDeserializeSBalanceVgroupLeaderReq(void *buf, int32_t bufLen, SBalanceVgroupLeaderReq *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 tSerializeSMergeVgroupReq(void *buf, int32_t bufLen, SMergeVgroupReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); @@ -4521,6 +4603,31 @@ int32_t tDeserializeSSplitVgroupReq(void *buf, int32_t bufLen, SSplitVgroupReq * return 0; } +int32_t tSerializeSForceBecomeFollowerReq(void *buf, int32_t bufLen, SForceBecomeFollowerReq *pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeI32(&encoder, pReq->vgId) < 0) return -1; + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSForceBecomeFollowerReq(void *buf, int32_t bufLen, SForceBecomeFollowerReq *pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeI32(&decoder, &pReq->vgId) < 0) return -1; + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + int32_t tSerializeSDCreateMnodeReq(void *buf, int32_t bufLen, SDCreateMnodeReq *pReq) { SEncoder encoder = {0}; tEncoderInit(&encoder, buf, bufLen); @@ -6637,8 +6744,9 @@ int32_t tFormatOffset(char *buf, int32_t maxLen, const STqOffsetVal *pVal) { } else if (pVal->type == TMQ_OFFSET__SNAPSHOT_DATA || pVal->type == TMQ_OFFSET__SNAPSHOT_META) { snprintf(buf, maxLen, "offset(snapshot) uid:%" PRId64 " ts:%" PRId64, pVal->uid, pVal->ts); } else { - ASSERT(0); + return TSDB_CODE_INVALID_PARA; } + return 0; } @@ -6821,8 +6929,7 @@ int32_t tDecodeSMqDataRsp(SDecoder *pDecoder, SMqDataRsp *pRsp) { } void tDeleteSMqDataRsp(SMqDataRsp *pRsp) { - taosArrayDestroy(pRsp->blockDataLen); - pRsp->blockDataLen = NULL; + pRsp->blockDataLen = taosArrayDestroy(pRsp->blockDataLen); taosArrayDestroyP(pRsp->blockData, (FDelete)taosMemoryFree); pRsp->blockData = NULL; taosArrayDestroyP(pRsp->blockSchema, (FDelete)tDeleteSSchemaWrapper); diff --git a/source/common/src/ttime.c b/source/common/src/ttime.c index 7996498d451f95df794fab75c644eed044d37c4b..dcd539bd91e11c570a9f779f9c1c9a3811765c41 100644 --- a/source/common/src/ttime.c +++ b/source/common/src/ttime.c @@ -727,7 +727,7 @@ int64_t taosTimeAdd(int64_t t, int64_t duration, char unit, int32_t precision) { struct tm tm; time_t tt = (time_t)(t / TSDB_TICK_PER_SECOND(precision)); - taosLocalTime(&tt, &tm); + taosLocalTime(&tt, &tm, NULL); int32_t mon = tm.tm_year * 12 + tm.tm_mon + (int32_t)numOfMonth; tm.tm_year = mon / 12; tm.tm_mon = mon % 12; @@ -750,11 +750,11 @@ int32_t taosTimeCountInterval(int64_t skey, int64_t ekey, int64_t interval, char struct tm tm; time_t t = (time_t)skey; - taosLocalTime(&t, &tm); + taosLocalTime(&t, &tm, NULL); int32_t smon = tm.tm_year * 12 + tm.tm_mon; t = (time_t)ekey; - taosLocalTime(&t, &tm); + taosLocalTime(&t, &tm, NULL); int32_t emon = tm.tm_year * 12 + tm.tm_mon; if (unit == 'y') { @@ -774,7 +774,7 @@ int64_t taosTimeTruncate(int64_t t, const SInterval* pInterval, int32_t precisio start /= (int64_t)(TSDB_TICK_PER_SECOND(precision)); struct tm tm; time_t tt = (time_t)start; - taosLocalTime(&tt, &tm); + taosLocalTime(&tt, &tm, NULL); tm.tm_sec = 0; tm.tm_min = 0; tm.tm_hour = 0; @@ -867,13 +867,17 @@ const char* fmtts(int64_t ts) { if (ts > -62135625943 && ts < 32503651200) { time_t t = (time_t)ts; - taosLocalTime(&t, &tm); + if (taosLocalTime(&t, &tm, buf) == NULL) { + return buf; + } pos += strftime(buf + pos, sizeof(buf), "s=%Y-%m-%d %H:%M:%S", &tm); } if (ts > -62135625943000 && ts < 32503651200000) { time_t t = (time_t)(ts / 1000); - taosLocalTime(&t, &tm); + if (taosLocalTime(&t, &tm, buf) == NULL) { + return buf; + } if (pos > 0) { buf[pos++] = ' '; buf[pos++] = '|'; @@ -885,7 +889,9 @@ const char* fmtts(int64_t ts) { { time_t t = (time_t)(ts / 1000000); - taosLocalTime(&t, &tm); + if (taosLocalTime(&t, &tm, buf) == NULL) { + return buf; + } if (pos > 0) { buf[pos++] = ' '; buf[pos++] = '|'; @@ -937,7 +943,9 @@ void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precision) ASSERT(false); } - taosLocalTime(", &ptm); + if (taosLocalTime(", &ptm, buf) == NULL) { + return; + } int32_t length = (int32_t)strftime(ts, 40, "%Y-%m-%dT%H:%M:%S", &ptm); length += snprintf(ts + length, fractionLen, format, mod); length += (int32_t)strftime(ts + length, 40 - length, "%z", &ptm); diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index d3cffaa185382af4ddfa7db681a1b9357582fb96..f0e020edfed8136e6b7fbfc3a023c1ef2822fd01 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -18,7 +18,23 @@ #include "mnode.h" #include "tconfig.h" #include "tglobal.h" +#include "version.h" +#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL) +#include "cus_name.h" +#else +#ifndef CUS_NAME + #define CUS_NAME "TDengine" +#endif + +#ifndef CUS_PROMPT + #define CUS_PROMPT "taos" +#endif + +#ifndef CUS_EMAIL + #define CUS_EMAIL "" +#endif +#endif // clang-format off #define DM_APOLLO_URL "The apollo string to use when configuring the server, such as: -a 'jsonFile:./tests/cfg.json', cfg.json text can be '{\"fqdn\":\"td1\"}'." #define DM_CFG_DIR "Configuration directory." @@ -76,28 +92,28 @@ void dmLogCrash(int signum, void *sigInfo, void *context) { taosIgnSignal(SIGINT); taosIgnSignal(SIGBREAK); -#ifndef WINDOWS +#ifndef WINDOWS taosIgnSignal(SIGBUS); #endif taosIgnSignal(SIGABRT); taosIgnSignal(SIGFPE); taosIgnSignal(SIGSEGV); - char *pMsg = NULL; + char *pMsg = NULL; const char *flags = "UTL FATAL "; ELogLevel level = DEBUG_FATAL; int32_t dflag = 255; - int64_t msgLen= -1; - + int64_t msgLen = -1; + if (tsEnableCrashReport) { if (taosGenCrashJsonMsg(signum, &pMsg, dmGetClusterId(), global.startTime)) { taosPrintLog(flags, level, dflag, "failed to generate crash json msg"); goto _return; } else { - msgLen = strlen(pMsg); + msgLen = strlen(pMsg); } } - + _return: taosLogCrashInfo("taosd", pMsg, msgLen, signum, sigInfo); @@ -123,7 +139,7 @@ static void dmSetSignalHandle() { #ifndef WINDOWS taosSetSignal(SIGBUS, dmLogCrash); -#endif +#endif taosSetSignal(SIGABRT, dmLogCrash); taosSetSignal(SIGFPE, dmLogCrash); taosSetSignal(SIGSEGV, dmLogCrash); @@ -134,7 +150,7 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) { int32_t cmdEnvIndex = 0; if (argc < 2) return 0; - + global.envCmd = taosMemoryMalloc((argc - 1) * sizeof(char *)); memset(global.envCmd, 0, (argc - 1) * sizeof(char *)); for (int32_t i = 1; i < argc; ++i) { @@ -203,6 +219,9 @@ static void dmPrintVersion() { #endif printf("%s version: %s compatible_version: %s\n", releaseName, version, compatible_version); printf("gitinfo: %s\n", gitinfo); +#ifdef TD_ENTERPRISE + printf("gitinfoOfInternal: %s\n", gitinfoOfInternal); +#endif printf("buildInfo: %s\n", buildinfo); } @@ -228,7 +247,7 @@ static void dmDumpCfg() { } static int32_t dmInitLog() { - return taosCreateLog("taosdlog", 1, configDir, global.envCmd, global.envFile, global.apolloUrl, global.pArgs, 0); + return taosCreateLog(CUS_PROMPT"dlog", 1, configDir, global.envCmd, global.envFile, global.apolloUrl, global.pArgs, 0); } static void taosCleanupArgs() { @@ -284,7 +303,7 @@ int mainWindows(int argc, char **argv) { printf("failed to init memory dbg, error:%s\n", tstrerror(code)); return code; } - tsAsyncLog = false; + tsAsyncLog = false; printf("memory dbg enabled\n"); } #endif diff --git a/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h b/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h index b47742b4ed8db0cf55df46118b20a07bf00bd6bd..24f75e3c8b01dd41f958ec5913352b9baba991b7 100644 --- a/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h +++ b/source/dnode/mgmt/mgmt_mnode/inc/mmInt.h @@ -34,7 +34,7 @@ typedef struct SMnodeMgmt { SSingleWorker readWorker; SSingleWorker writeWorker; SSingleWorker syncWorker; - SSingleWorker syncCtrlWorker; + SSingleWorker syncRdWorker; bool stopped; int32_t refCount; TdThreadRwlock lock; @@ -54,7 +54,7 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt); void mmStopWorker(SMnodeMgmt *pMgmt); int32_t mmPutMsgToWriteQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); -int32_t mmPutMsgToSyncCtrlQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); +int32_t mmPutMsgToSyncRdQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t mmPutMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t mmPutMsgToFetchQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg); diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index fe65c3dde96a0e81ab8211fa87aebc7e92ee0294..76977dd4a8178792f3867b3a615ef552c5449c1d 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -126,6 +126,7 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_MND_MERGE_VGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_SPLIT_VGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_BALANCE_VGROUP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_BALANCE_VGROUP_LEADER, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_FUNC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_FUNC, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_FUNC, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; @@ -188,7 +189,7 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_INDEX_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_DISABLE_WRITE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT_ELECTION, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_BATCH, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; @@ -198,11 +199,15 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_BATCH, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, mmPutMsgToSyncCtrlQueue, 1) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, mmPutMsgToSyncCtrlQueue, 1) == NULL) goto _OVER; + + if (dmSetMgmtHandle(pArray, TDMT_SYNC_FORCE_FOLLOWER_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + + if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, mmPutMsgToSyncRdQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, mmPutMsgToSyncRdQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, mmPutMsgToSyncRdQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, mmPutMsgToSyncRdQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT_REPLY, mmPutMsgToSyncRdQueue, 1) == NULL) goto _OVER; code = 0; diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c index b0810d528f761d6362b27a818636d52e8421429c..0152e5d0b1a02041b2d70961a7bf85e7a516dd82 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmWorker.c @@ -111,8 +111,8 @@ int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { return mmPutMsgToWorker(pMgmt, &pMgmt->syncWorker, pMsg); } -int32_t mmPutMsgToSyncCtrlQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { - return mmPutMsgToWorker(pMgmt, &pMgmt->syncCtrlWorker, pMsg); +int32_t mmPutMsgToSyncRdQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { + return mmPutMsgToWorker(pMgmt, &pMgmt->syncRdWorker, pMsg); } int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) { @@ -151,8 +151,8 @@ int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) { case SYNC_QUEUE: pWorker = &pMgmt->syncWorker; break; - case SYNC_CTRL_QUEUE: - pWorker = &pMgmt->syncCtrlWorker; + case SYNC_RD_QUEUE: + pWorker = &pMgmt->syncRdWorker; break; default: terrno = TSDB_CODE_INVALID_PARA; @@ -238,12 +238,12 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) { SSingleWorkerCfg scCfg = { .min = 1, .max = 1, - .name = "mnode-sync-ctrl", + .name = "mnode-sync-rd", .fp = (FItem)mmProcessSyncMsg, .param = pMgmt, }; - if (tSingleWorkerInit(&pMgmt->syncCtrlWorker, &scCfg) != 0) { - dError("failed to start mnode mnode-sync-ctrl worker since %s", terrstr()); + if (tSingleWorkerInit(&pMgmt->syncRdWorker, &scCfg) != 0) { + dError("failed to start mnode mnode-sync-rd worker since %s", terrstr()); return -1; } @@ -259,6 +259,6 @@ void mmStopWorker(SMnodeMgmt *pMgmt) { tSingleWorkerCleanup(&pMgmt->readWorker); tSingleWorkerCleanup(&pMgmt->writeWorker); tSingleWorkerCleanup(&pMgmt->syncWorker); - tSingleWorkerCleanup(&pMgmt->syncCtrlWorker); + tSingleWorkerCleanup(&pMgmt->syncRdWorker); dDebug("mnode workers are closed"); } diff --git a/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h b/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h index e3fa2964b74b697cd507a9fddcb27a848010e2e1..4374ae363cce8b4138ebb224ddf3528eae2b0784 100644 --- a/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h +++ b/source/dnode/mgmt/mgmt_vnode/inc/vmInt.h @@ -59,7 +59,7 @@ typedef struct { SVnode *pImpl; SMultiWorker pWriteW; SMultiWorker pSyncW; - SMultiWorker pSyncCtrlW; + SMultiWorker pSyncRdW; SMultiWorker pApplyW; STaosQueue *pQueryQ; STaosQueue *pStreamQ; @@ -107,7 +107,7 @@ int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc); int32_t vmPutMsgToWriteQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t vmPutMsgToSyncQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); -int32_t vmPutMsgToSyncCtrlQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); +int32_t vmPutMsgToSyncRdQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t vmPutMsgToQueryQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t vmPutMsgToFetchQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t vmPutMsgToStreamQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index d7f91b74a8d1827f512b85b2a7e91221306172a3..d61eb3ec0390af04e97c2977131d8381c26b351a 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -21,7 +21,7 @@ void vmGetVnodeLoads(SVnodeMgmt *pMgmt, SMonVloadInfo *pInfo, bool isReset) { if (pInfo->pVloads == NULL) return; tfsUpdateSize(pMgmt->pTfs); - + taosThreadRwlockRdlock(&pMgmt->lock); void *pIter = taosHashIterate(pMgmt->hash, NULL); @@ -549,7 +549,7 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_VNODE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_VNODE, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT_ELECTION, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_BATCH, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_CLIENT_REQUEST_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; @@ -559,12 +559,14 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_BATCH, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_APPEND_ENTRIES_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_FORCE_FOLLOWER, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER; - if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, vmPutMsgToSyncRdQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, vmPutMsgToSyncRdQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, vmPutMsgToSyncRdQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, vmPutMsgToSyncRdQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT_REPLY, vmPutMsgToSyncRdQueue, 0) == NULL) goto _OVER; code = 0; diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c index 0524e2713ab4eec96cf4fd5eecf99bfa0968bf4e..4c5b1246e7f21f2a9ca8862e8cc2580407d13264 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmInt.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmInt.c @@ -98,9 +98,9 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode, bool commitAndRemoveWal) pVnode->pSyncW.queue->threadId); tMultiWorkerCleanup(&pVnode->pSyncW); - dInfo("vgId:%d, wait for vnode sync ctrl queue:%p is empty, thread:%08" PRId64, pVnode->vgId, - pVnode->pSyncCtrlW.queue, pVnode->pSyncCtrlW.queue->threadId); - tMultiWorkerCleanup(&pVnode->pSyncCtrlW); + dInfo("vgId:%d, wait for vnode sync rd queue:%p is empty, thread:%08" PRId64, pVnode->vgId, pVnode->pSyncRdW.queue, + pVnode->pSyncRdW.queue->threadId); + tMultiWorkerCleanup(&pVnode->pSyncRdW); dInfo("vgId:%d, wait for vnode apply queue:%p is empty, thread:%08" PRId64, pVnode->vgId, pVnode->pApplyW.queue, pVnode->pApplyW.queue->threadId); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c index 7aa1c9f56acc9e1cec882e6a317e0bc0ed2a5eb1..e4e0d608de4de3ae95786f3b1754b18ca3805cdd 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmWorker.c @@ -216,9 +216,9 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp dGTrace("vgId:%d, msg:%p put into vnode-sync queue", pVnode->vgId, pMsg); taosWriteQitem(pVnode->pSyncW.queue, pMsg); break; - case SYNC_CTRL_QUEUE: - dGTrace("vgId:%d, msg:%p put into vnode-sync-ctrl queue", pVnode->vgId, pMsg); - taosWriteQitem(pVnode->pSyncCtrlW.queue, pMsg); + case SYNC_RD_QUEUE: + dGTrace("vgId:%d, msg:%p put into vnode-sync-rd queue", pVnode->vgId, pMsg); + taosWriteQitem(pVnode->pSyncRdW.queue, pMsg); break; case APPLY_QUEUE: dGTrace("vgId:%d, msg:%p put into vnode-apply queue", pVnode->vgId, pMsg); @@ -234,9 +234,7 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp return code; } -int32_t vmPutMsgToSyncCtrlQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { - return vmPutMsgToQueue(pMgmt, pMsg, SYNC_CTRL_QUEUE); -} +int32_t vmPutMsgToSyncRdQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmPutMsgToQueue(pMgmt, pMsg, SYNC_RD_QUEUE); } int32_t vmPutMsgToSyncQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmPutMsgToQueue(pMgmt, pMsg, SYNC_QUEUE); } @@ -327,18 +325,18 @@ int32_t vmGetQueueSize(SVnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype) { int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) { SMultiWorkerCfg wcfg = {.max = 1, .name = "vnode-write", .fp = (FItems)vnodeProposeWriteMsg, .param = pVnode->pImpl}; SMultiWorkerCfg scfg = {.max = 1, .name = "vnode-sync", .fp = (FItems)vmProcessSyncQueue, .param = pVnode}; - SMultiWorkerCfg sccfg = {.max = 1, .name = "vnode-sync-ctrl", .fp = (FItems)vmProcessSyncQueue, .param = pVnode}; + SMultiWorkerCfg sccfg = {.max = 1, .name = "vnode-sync-rd", .fp = (FItems)vmProcessSyncQueue, .param = pVnode}; SMultiWorkerCfg acfg = {.max = 1, .name = "vnode-apply", .fp = (FItems)vnodeApplyWriteMsg, .param = pVnode->pImpl}; (void)tMultiWorkerInit(&pVnode->pWriteW, &wcfg); (void)tMultiWorkerInit(&pVnode->pSyncW, &scfg); - (void)tMultiWorkerInit(&pVnode->pSyncCtrlW, &sccfg); + (void)tMultiWorkerInit(&pVnode->pSyncRdW, &sccfg); (void)tMultiWorkerInit(&pVnode->pApplyW, &acfg); pVnode->pQueryQ = tQWorkerAllocQueue(&pMgmt->queryPool, pVnode, (FItem)vmProcessQueryQueue); pVnode->pStreamQ = tAutoQWorkerAllocQueue(&pMgmt->streamPool, pVnode, (FItem)vmProcessStreamQueue); pVnode->pFetchQ = tWWorkerAllocQueue(&pMgmt->fetchPool, pVnode, (FItems)vmProcessFetchQueue); - if (pVnode->pWriteW.queue == NULL || pVnode->pSyncW.queue == NULL || pVnode->pSyncCtrlW.queue == NULL || + if (pVnode->pWriteW.queue == NULL || pVnode->pSyncW.queue == NULL || pVnode->pSyncRdW.queue == NULL || pVnode->pApplyW.queue == NULL || pVnode->pQueryQ == NULL || pVnode->pStreamQ == NULL || pVnode->pFetchQ == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; @@ -348,8 +346,8 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) { pVnode->pWriteW.queue->threadId); dInfo("vgId:%d, sync-queue:%p is alloced, thread:%08" PRId64, pVnode->vgId, pVnode->pSyncW.queue, pVnode->pSyncW.queue->threadId); - dInfo("vgId:%d, sync-ctrl-queue:%p is alloced, thread:%08" PRId64, pVnode->vgId, pVnode->pSyncCtrlW.queue, - pVnode->pSyncCtrlW.queue->threadId); + dInfo("vgId:%d, sync-rd-queue:%p is alloced, thread:%08" PRId64, pVnode->vgId, pVnode->pSyncRdW.queue, + pVnode->pSyncRdW.queue->threadId); dInfo("vgId:%d, apply-queue:%p is alloced, thread:%08" PRId64, pVnode->vgId, pVnode->pApplyW.queue, pVnode->pApplyW.queue->threadId); dInfo("vgId:%d, query-queue:%p is alloced", pVnode->vgId, pVnode->pQueryQ); diff --git a/source/dnode/mnode/impl/inc/mndConsumer.h b/source/dnode/mnode/impl/inc/mndConsumer.h index 1176e1af0b8fa09328669f11066235870f39b06a..99b0d06936ec16b59b0abda4bad52748ff9a6e45 100644 --- a/source/dnode/mnode/impl/inc/mndConsumer.h +++ b/source/dnode/mnode/impl/inc/mndConsumer.h @@ -24,10 +24,10 @@ extern "C" { enum { MQ_CONSUMER_STATUS__MODIFY = 1, - MQ_CONSUMER_STATUS__MODIFY_IN_REB, + MQ_CONSUMER_STATUS__MODIFY_IN_REB, // this value is not used anymore MQ_CONSUMER_STATUS__READY, MQ_CONSUMER_STATUS__LOST, - MQ_CONSUMER_STATUS__LOST_IN_REB, + MQ_CONSUMER_STATUS__LOST_IN_REB, // this value is not used anymore MQ_CONSUMER_STATUS__LOST_REBD, MQ_CONSUMER_STATUS__REMOVED, }; diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 1feb292779490363a6245c5079a13d5c44ee41da..710c2c52b202563d391f2e599a99e6fb0e3e716c 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -360,6 +360,7 @@ typedef struct { int8_t replica; SVnodeGid vnodeGid[TSDB_MAX_REPLICA]; void* pTsma; + int32_t numOfCachedTables; } SVgObj; typedef struct { @@ -392,7 +393,7 @@ typedef struct { } SSmaObj; typedef struct { - char name[TSDB_TABLE_FNAME_LEN]; + char name[TSDB_INDEX_FNAME_LEN]; char stb[TSDB_TABLE_FNAME_LEN]; char db[TSDB_DB_FNAME_LEN]; char dstTbName[TSDB_TABLE_FNAME_LEN]; @@ -446,6 +447,8 @@ typedef struct { int32_t codeSize; char* pComment; char* pCode; + int32_t funcVersion; + SRWLatch lock; } SFuncObj; typedef struct { @@ -457,6 +460,7 @@ typedef struct { void* pIter; SMnode* pMnode; STableMetaRsp* pMeta; + bool restore; bool sysDbRsp; char db[TSDB_DB_FNAME_LEN]; char filterTb[TSDB_TABLE_NAME_LEN]; diff --git a/source/dnode/mnode/impl/inc/mndInt.h b/source/dnode/mnode/impl/inc/mndInt.h index 006c74ef3de223a34aaa483346b28102bfdfe54a..ffb2443808b9efdd2e0a3dfbe89662b88962f6be 100644 --- a/source/dnode/mnode/impl/inc/mndInt.h +++ b/source/dnode/mnode/impl/inc/mndInt.h @@ -113,6 +113,7 @@ typedef struct SMnode { bool deploy; char *path; int64_t checkTime; + SyncIndex applied; SSdb *pSdb; SArray *pSteps; SQHandle *pQuery; diff --git a/source/dnode/mnode/impl/inc/mndTopic.h b/source/dnode/mnode/impl/inc/mndTopic.h index 8ed7fc6a11043bddda295759d8ba59e9d26be1f8..b2b86775aba1e59ca7caecc935669eb9c53c4380 100644 --- a/source/dnode/mnode/impl/inc/mndTopic.h +++ b/source/dnode/mnode/impl/inc/mndTopic.h @@ -32,6 +32,7 @@ bool mndTopicExistsForDb(SMnode *pMnode, SDbObj *pDb); const char *mndTopicGetShowName(const char topic[TSDB_TOPIC_FNAME_LEN]); int32_t mndSetTopicCommitLogs(SMnode *pMnode, STrans *pTrans, SMqTopicObj *pTopic); +int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTopics); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index f1ef83aca553d682092fe3a7551c8b40aba48f49..8f1cfbff931d74df3dab3f6f3fb9669894811876 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -77,13 +77,11 @@ void mndCleanupConsumer(SMnode *pMnode) {} bool mndRebTryStart() { int32_t old = atomic_val_compare_exchange_32(&mqRebInExecCnt, 0, 1); - mInfo("tq timer, rebalance counter old val:%d", old); + mDebug("tq timer, rebalance counter old val:%d", old); return old == 0; } -void mndRebEnd() { - mndRebCntDec(); -} +void mndRebEnd() { mndRebCntDec(); } void mndRebCntInc() { int32_t val = atomic_add_fetch_32(&mqRebInExecCnt, 1); @@ -101,7 +99,7 @@ void mndRebCntDec() { int32_t newVal = val - 1; int32_t oldVal = atomic_val_compare_exchange_32(&mqRebInExecCnt, val, newVal); if (oldVal == val) { - mInfo("rebalance trans end, rebalance counter:%d", newVal); + mDebug("rebalance trans end, rebalance counter:%d", newVal); break; } } @@ -247,23 +245,43 @@ static SMqRebInfo *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) { return pRebInfo; } +static void freeRebalanceItem(void *param) { + SMqRebInfo *pInfo = param; + taosArrayDestroy(pInfo->lostConsumers); + taosArrayDestroy(pInfo->newConsumers); + taosArrayDestroy(pInfo->removedConsumers); +} + static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) { SMnode *pMnode = pMsg->info.node; SSdb *pSdb = pMnode->pSdb; SMqConsumerObj *pConsumer; void *pIter = NULL; - mTrace("start to process mq timer"); + mDebug("start to process mq timer"); // rebalance cannot be parallel if (!mndRebTryStart()) { - mInfo("mq rebalance already in progress, do nothing"); + mDebug("mq rebalance already in progress, do nothing"); return 0; } SMqDoRebalanceMsg *pRebMsg = rpcMallocCont(sizeof(SMqDoRebalanceMsg)); + if (pRebMsg == NULL) { + mError("failed to create the rebalance msg, size:%d, quit mq timer", (int32_t)sizeof(SMqDoRebalanceMsg)); + mndRebEnd(); + return TSDB_CODE_OUT_OF_MEMORY; + } + pRebMsg->rebSubHash = taosHashInit(64, MurmurHash3_32, true, HASH_NO_LOCK); - // TODO set cleanfp + if (pRebMsg->rebSubHash == NULL) { + mError("failed to create rebalance hashmap"); + rpcFreeCont(pRebMsg); + mndRebEnd(); + return TSDB_CODE_OUT_OF_MEMORY; + } + + taosHashSetFreeFp(pRebMsg->rebSubHash, freeRebalanceItem); // iterate all consumers, find all modification while (1) { @@ -317,7 +335,7 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) { taosArrayPush(pRebSub->removedConsumers, &pConsumer->consumerId); } taosRUnLockLatch(&pConsumer->lock); - } else if (status == MQ_CONSUMER_STATUS__MODIFY) { + } else if (status == MQ_CONSUMER_STATUS__MODIFY || status == MQ_CONSUMER_STATUS__MODIFY_IN_REB) { taosRLockLatch(&pConsumer->lock); int32_t newTopicNum = taosArrayGetSize(pConsumer->rebNewTopics); @@ -356,7 +374,7 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) { } else { taosHashCleanup(pRebMsg->rebSubHash); rpcFreeCont(pRebMsg); - mInfo("mq rebalance finished, no modification"); + mDebug("mq timer finished, no need to re-balance"); mndRebEnd(); } return 0; @@ -576,7 +594,7 @@ int32_t mndSetConsumerCommitLogs(SMnode *pMnode, STrans *pTrans, SMqConsumerObj return 0; } -static int32_t validateTopics(const SArray* pTopicList, SMnode* pMnode, const char* pUser) { +static int32_t validateTopics(const SArray *pTopicList, SMnode *pMnode, const char *pUser) { int32_t numOfTopics = taosArrayGetSize(pTopicList); for (int32_t i = 0; i < numOfTopics; i++) { @@ -597,8 +615,13 @@ static int32_t validateTopics(const SArray* pTopicList, SMnode* pMnode, const ch return 0; } -static void* topicNameDup(void* p){ - return taosStrdup((char*) p); +static void *topicNameDup(void *p) { return taosStrdup((char *)p); } + +static void freeItem(void *param) { + void *pItem = *(void **)param; + if (pItem != NULL) { + taosMemoryFree(pItem); + } } int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { @@ -616,7 +639,7 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { int32_t code = -1; SArray *pTopicList = subscribe.topicNames; taosArraySort(pTopicList, taosArrayCompareString); - taosArrayRemoveDuplicateP(pTopicList, taosArrayCompareString, taosMemoryFree); + taosArrayRemoveDuplicate(pTopicList, taosArrayCompareString, freeItem); int32_t newTopicNum = taosArrayGetSize(pTopicList); @@ -633,8 +656,8 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { pExistedConsumer = mndAcquireConsumer(pMnode, consumerId); if (pExistedConsumer == NULL) { - mInfo("receive subscribe request from new consumer:0x%" PRIx64" cgroup:%s, numOfTopics:%d", consumerId, - subscribe.cgroup, (int32_t) taosArrayGetSize(pTopicList)); + mInfo("receive subscribe request from new consumer:0x%" PRIx64 " cgroup:%s, numOfTopics:%d", consumerId, + subscribe.cgroup, (int32_t)taosArrayGetSize(pTopicList)); pConsumerNew = tNewSMqConsumerObj(consumerId, cgroup); tstrncpy(pConsumerNew->clientId, subscribe.clientId, tListLen(pConsumerNew->clientId)); @@ -656,8 +679,9 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { /*taosRLockLatch(&pExistedConsumer->lock);*/ int32_t status = atomic_load_32(&pExistedConsumer->status); - mInfo("receive subscribe request from existed consumer:0x%" PRIx64 " cgroup:%s, current status:%d(%s), subscribe topic num: %d", - consumerId, subscribe.cgroup, status,mndConsumerStatusName(status), newTopicNum); + mInfo("receive subscribe request from existed consumer:0x%" PRIx64 + " cgroup:%s, current status:%d(%s), subscribe topic num: %d", + consumerId, subscribe.cgroup, status, mndConsumerStatusName(status), newTopicNum); if (status != MQ_CONSUMER_STATUS__READY) { terrno = TSDB_CODE_MND_CONSUMER_NOT_READY; @@ -674,7 +698,7 @@ int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) { taosArrayDestroy(pConsumerNew->assignedTopics); pConsumerNew->assignedTopics = taosArrayDup(pTopicList, topicNameDup); - int32_t oldTopicNum = (pExistedConsumer->currentTopics)? taosArrayGetSize(pExistedConsumer->currentTopics):0; + int32_t oldTopicNum = (pExistedConsumer->currentTopics) ? taosArrayGetSize(pExistedConsumer->currentTopics) : 0; int32_t i = 0, j = 0; while (i < oldTopicNum || j < newTopicNum) { @@ -839,12 +863,59 @@ static int32_t mndConsumerActionInsert(SSdb *pSdb, SMqConsumerObj *pConsumer) { } static int32_t mndConsumerActionDelete(SSdb *pSdb, SMqConsumerObj *pConsumer) { - mDebug("consumer:0x%" PRIx64 " perform delete action, status:(%d)%s", pConsumer->consumerId, - pConsumer->status, mndConsumerStatusName(pConsumer->status)); + mDebug("consumer:0x%" PRIx64 " perform delete action, status:(%d)%s", pConsumer->consumerId, pConsumer->status, + mndConsumerStatusName(pConsumer->status)); tDeleteSMqConsumerObj(pConsumer); return 0; } +static void updateConsumerStatus(SMqConsumerObj *pConsumer) { + int32_t status = pConsumer->status; + + if (taosArrayGetSize(pConsumer->rebNewTopics) == 0 && taosArrayGetSize(pConsumer->rebRemovedTopics) == 0) { + if (status == MQ_CONSUMER_STATUS__MODIFY || status == MQ_CONSUMER_STATUS__MODIFY_IN_REB) { + pConsumer->status = MQ_CONSUMER_STATUS__READY; + } else if (status == MQ_CONSUMER_STATUS__LOST_IN_REB || status == MQ_CONSUMER_STATUS__LOST) { + pConsumer->status = MQ_CONSUMER_STATUS__LOST_REBD; + } + } else { + if (status == MQ_CONSUMER_STATUS__MODIFY || status == MQ_CONSUMER_STATUS__MODIFY_IN_REB) { + pConsumer->status = MQ_CONSUMER_STATUS__MODIFY; + } else if (status == MQ_CONSUMER_STATUS__LOST || status == MQ_CONSUMER_STATUS__LOST_IN_REB) { + pConsumer->status = MQ_CONSUMER_STATUS__LOST; + } + } +} + +// remove from new topic +static void removeFromNewTopicList(SMqConsumerObj *pConsumer, const char *pTopic) { + int32_t size = taosArrayGetSize(pConsumer->rebNewTopics); + for (int32_t i = 0; i < taosArrayGetSize(pConsumer->rebNewTopics); i++) { + char *p = taosArrayGetP(pConsumer->rebNewTopics, i); + if (strcmp(pTopic, p) == 0) { + taosArrayRemove(pConsumer->rebNewTopics, i); + taosMemoryFree(p); + + mDebug("consumer:0x%" PRIx64 " remove new topic:%s in the topic list, remain newTopics:%d", pConsumer->consumerId, + pTopic, (int)taosArrayGetSize(pConsumer->rebNewTopics)); + break; + } + } +} + +// remove from removed topic +static void removeFromRemoveTopicList(SMqConsumerObj *pConsumer, const char *pTopic) { + int32_t size = taosArrayGetSize(pConsumer->rebRemovedTopics); + for (int32_t i = 0; i < size; i++) { + char *p = taosArrayGetP(pConsumer->rebRemovedTopics, i); + if (strcmp(pTopic, p) == 0) { + taosArrayRemove(pConsumer->rebRemovedTopics, i); + taosMemoryFree(p); + break; + } + } +} + static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, SMqConsumerObj *pNewConsumer) { mDebug("consumer:0x%" PRIx64 " perform update action, update type:%d, subscribe-time:%" PRId64 ", uptime:%" PRId64, pOldConsumer->consumerId, pNewConsumer->updateType, pOldConsumer->subscribeTime, pOldConsumer->upTime); @@ -855,6 +926,7 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, /*A(taosArrayGetSize(pOldConsumer->rebNewTopics) == 0);*/ /*A(taosArrayGetSize(pOldConsumer->rebRemovedTopics) == 0);*/ + // this new consumer has identical topics with one existed consumers. if (taosArrayGetSize(pNewConsumer->rebNewTopics) == 0 && taosArrayGetSize(pNewConsumer->rebRemovedTopics) == 0) { pOldConsumer->status = MQ_CONSUMER_STATUS__READY; } else { @@ -871,7 +943,6 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, pNewConsumer->assignedTopics = tmp; pOldConsumer->subscribeTime = pNewConsumer->upTime; - pOldConsumer->status = MQ_CONSUMER_STATUS__MODIFY; } } else if (pNewConsumer->updateType == CONSUMER_UPDATE__LOST) { @@ -911,71 +982,48 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, pOldConsumer->rebalanceTime = pNewConsumer->upTime; } else if (pNewConsumer->updateType == CONSUMER_UPDATE__ADD) { - /*A(taosArrayGetSize(pNewConsumer->rebNewTopics) == 1);*/ - /*A(taosArrayGetSize(pNewConsumer->rebRemovedTopics) == 0);*/ + ASSERT(taosArrayGetSize(pNewConsumer->rebNewTopics) == 1 && taosArrayGetSize(pNewConsumer->rebRemovedTopics) == 0); + char *pNewTopic = taosStrdup(taosArrayGetP(pNewConsumer->rebNewTopics, 0)); - char *addedTopic = taosStrdup(taosArrayGetP(pNewConsumer->rebNewTopics, 0)); // not exist in current topic - - bool existing = false; -#if 1 + bool existing = false; int32_t numOfExistedTopics = taosArrayGetSize(pOldConsumer->currentTopics); for (int32_t i = 0; i < numOfExistedTopics; i++) { char *topic = taosArrayGetP(pOldConsumer->currentTopics, i); - if (strcmp(topic, addedTopic) == 0) { + if (strcmp(topic, pNewTopic) == 0) { existing = true; } } -#endif - // remove from new topic - for (int32_t i = 0; i < taosArrayGetSize(pOldConsumer->rebNewTopics); i++) { - char *topic = taosArrayGetP(pOldConsumer->rebNewTopics, i); - if (strcmp(addedTopic, topic) == 0) { - taosArrayRemove(pOldConsumer->rebNewTopics, i); - taosMemoryFree(topic); - break; - } - } + removeFromNewTopicList(pOldConsumer, pNewTopic); // add to current topic if (!existing) { - taosArrayPush(pOldConsumer->currentTopics, &addedTopic); + taosArrayPush(pOldConsumer->currentTopics, &pNewTopic); taosArraySort(pOldConsumer->currentTopics, taosArrayCompareString); } else { - taosMemoryFree(addedTopic); + taosMemoryFree(pNewTopic); } // set status int32_t status = pOldConsumer->status; - if (taosArrayGetSize(pOldConsumer->rebNewTopics) == 0 && taosArrayGetSize(pOldConsumer->rebRemovedTopics) == 0) { - if (status == MQ_CONSUMER_STATUS__MODIFY || status == MQ_CONSUMER_STATUS__MODIFY_IN_REB) { - pOldConsumer->status = MQ_CONSUMER_STATUS__READY; - } else if (status == MQ_CONSUMER_STATUS__LOST_IN_REB || status == MQ_CONSUMER_STATUS__LOST) { - pOldConsumer->status = MQ_CONSUMER_STATUS__LOST_REBD; - } - } else { - if (status == MQ_CONSUMER_STATUS__MODIFY || status == MQ_CONSUMER_STATUS__MODIFY_IN_REB) { - pOldConsumer->status = MQ_CONSUMER_STATUS__MODIFY_IN_REB; - } else if (status == MQ_CONSUMER_STATUS__LOST || status == MQ_CONSUMER_STATUS__LOST_IN_REB) { - pOldConsumer->status = MQ_CONSUMER_STATUS__LOST_IN_REB; - } - } + updateConsumerStatus(pOldConsumer); // the re-balance is triggered when the new consumer is launched. pOldConsumer->rebalanceTime = pNewConsumer->upTime; atomic_add_fetch_32(&pOldConsumer->epoch, 1); - mDebug("consumer:0x%" PRIx64 " state (%d)%s -> (%d)%s, new epoch:%d, reb-time:%" PRId64 ", current topics:%d", + mDebug("consumer:0x%" PRIx64 " state (%d)%s -> (%d)%s, new epoch:%d, reb-time:%" PRId64 + ", current topics:%d, newTopics:%d, removeTopics:%d", pOldConsumer->consumerId, status, mndConsumerStatusName(status), pOldConsumer->status, - mndConsumerStatusName(pOldConsumer->status), - pOldConsumer->epoch, pOldConsumer->rebalanceTime, (int)taosArrayGetSize(pOldConsumer->currentTopics)); + mndConsumerStatusName(pOldConsumer->status), pOldConsumer->epoch, pOldConsumer->rebalanceTime, + (int)taosArrayGetSize(pOldConsumer->currentTopics), (int)taosArrayGetSize(pOldConsumer->rebNewTopics), + (int)taosArrayGetSize(pOldConsumer->rebRemovedTopics)); + } else if (pNewConsumer->updateType == CONSUMER_UPDATE__REMOVE) { /*A(taosArrayGetSize(pNewConsumer->rebNewTopics) == 0);*/ /*A(taosArrayGetSize(pNewConsumer->rebRemovedTopics) == 1);*/ char *removedTopic = taosArrayGetP(pNewConsumer->rebRemovedTopics, 0); - - // not exist in new topic #if 0 for (int32_t i = 0; i < taosArrayGetSize(pOldConsumer->rebNewTopics); i++) { char *topic = taosArrayGetP(pOldConsumer->rebNewTopics, i); @@ -984,14 +1032,7 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, #endif // remove from removed topic - for (int32_t i = 0; i < taosArrayGetSize(pOldConsumer->rebRemovedTopics); i++) { - char *topic = taosArrayGetP(pOldConsumer->rebRemovedTopics, i); - if (strcmp(removedTopic, topic) == 0) { - taosArrayRemove(pOldConsumer->rebRemovedTopics, i); - taosMemoryFree(topic); - break; - } - } + removeFromRemoveTopicList(pOldConsumer, removedTopic); // remove from current topic int32_t i = 0; @@ -1004,32 +1045,20 @@ static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, break; } } - // must find the topic - /*A(i < sz);*/ // set status int32_t status = pOldConsumer->status; - if (taosArrayGetSize(pOldConsumer->rebNewTopics) == 0 && taosArrayGetSize(pOldConsumer->rebRemovedTopics) == 0) { - if (status == MQ_CONSUMER_STATUS__MODIFY || status == MQ_CONSUMER_STATUS__MODIFY_IN_REB) { - pOldConsumer->status = MQ_CONSUMER_STATUS__READY; - } else if (status == MQ_CONSUMER_STATUS__LOST_IN_REB || status == MQ_CONSUMER_STATUS__LOST) { - pOldConsumer->status = MQ_CONSUMER_STATUS__LOST_REBD; - } - } else { - if (status == MQ_CONSUMER_STATUS__MODIFY || status == MQ_CONSUMER_STATUS__MODIFY_IN_REB) { - pOldConsumer->status = MQ_CONSUMER_STATUS__MODIFY_IN_REB; - } else if (status == MQ_CONSUMER_STATUS__LOST || status == MQ_CONSUMER_STATUS__LOST_IN_REB) { - pOldConsumer->status = MQ_CONSUMER_STATUS__LOST_IN_REB; - } - } + updateConsumerStatus(pOldConsumer); pOldConsumer->rebalanceTime = pNewConsumer->upTime; atomic_add_fetch_32(&pOldConsumer->epoch, 1); - mDebug("consumer:0x%" PRIx64 " state %d(%s) -> %d(%s), new epoch:%d, reb-time:%" PRId64 ", current topics:%d", + mDebug("consumer:0x%" PRIx64 " state (%d)%s -> (%d)%s, new epoch:%d, reb-time:%" PRId64 + ", current topics:%d, newTopics:%d, removeTopics:%d", pOldConsumer->consumerId, status, mndConsumerStatusName(status), pOldConsumer->status, - mndConsumerStatusName(pOldConsumer->status), - pOldConsumer->epoch, pOldConsumer->rebalanceTime, (int)taosArrayGetSize(pOldConsumer->currentTopics)); + mndConsumerStatusName(pOldConsumer->status), pOldConsumer->epoch, pOldConsumer->rebalanceTime, + (int)taosArrayGetSize(pOldConsumer->currentTopics), (int)taosArrayGetSize(pOldConsumer->rebNewTopics), + (int)taosArrayGetSize(pOldConsumer->rebRemovedTopics)); } taosWUnLockLatch(&pOldConsumer->lock); @@ -1105,8 +1134,8 @@ static int32_t mndRetrieveConsumer(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock * colDataSetVal(pColInfo, numOfRows, (const char *)clientId, false); // status - char status[20 + VARSTR_HEADER_SIZE] = {0}; - const char* pStatusName = mndConsumerStatusName(pConsumer->status); + char status[20 + VARSTR_HEADER_SIZE] = {0}; + const char *pStatusName = mndConsumerStatusName(pConsumer->status); STR_TO_VARSTR(status, pStatusName); pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 8b09c823aba21650be9ef9ba2d7492c156cc5904..df220340688ae7b0230dae3a3242e0fc9ff6d2b9 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -275,10 +275,14 @@ static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOld, SDbObj *pNew) { pOld->cfg.daysToKeep2 = pNew->cfg.daysToKeep2; pOld->cfg.walFsyncPeriod = pNew->cfg.walFsyncPeriod; pOld->cfg.walLevel = pNew->cfg.walLevel; + pOld->cfg.walRetentionPeriod = pNew->cfg.walRetentionPeriod; + pOld->cfg.walRetentionSize = pNew->cfg.walRetentionSize; pOld->cfg.strict = pNew->cfg.strict; pOld->cfg.cacheLast = pNew->cfg.cacheLast; pOld->cfg.replications = pNew->cfg.replications; pOld->cfg.sstTrigger = pNew->cfg.sstTrigger; + pOld->cfg.minRows = pNew->cfg.minRows; + pOld->cfg.maxRows = pNew->cfg.maxRows; pOld->cfg.tsdbPageSize = pNew->cfg.tsdbPageSize; pOld->compactStartTime = pNew->compactStartTime; taosWUnLockLatch(&pOld->lock); @@ -616,13 +620,8 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) { } } else { if (terrno == TSDB_CODE_MND_DB_IN_CREATING) { - if (mndSetRpcInfoForDbTrans(pMnode, pReq, MND_OPER_CREATE_DB, createReq.db) == 0) { - mInfo("db:%s, is creating and createdb response after trans finished", createReq.db); - code = TSDB_CODE_ACTION_IN_PROGRESS; - goto _OVER; - } else { - goto _OVER; - } + code = terrno; + goto _OVER; } else if (terrno == TSDB_CODE_MND_DB_IN_DROPPING) { goto _OVER; } else if (terrno == TSDB_CODE_MND_DB_NOT_EXIST) { @@ -737,6 +736,20 @@ static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) { terrno = 0; } + if (pAlter->walRetentionPeriod > TSDB_DB_MIN_WAL_RETENTION_PERIOD && + pAlter->walRetentionPeriod != pDb->cfg.walRetentionPeriod) { + pDb->cfg.walRetentionPeriod = pAlter->walRetentionPeriod; + pDb->vgVersion++; + terrno = 0; + } + + if (pAlter->walRetentionSize > TSDB_DB_MIN_WAL_RETENTION_SIZE && + pAlter->walRetentionSize != pDb->cfg.walRetentionSize) { + pDb->cfg.walRetentionSize = pAlter->walRetentionSize; + pDb->vgVersion++; + terrno = 0; + } + return terrno; } @@ -833,6 +846,18 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) { goto _OVER; } + int32_t numOfTopics = 0; + if (mndGetNumOfTopics(pMnode, pDb->name, &numOfTopics) != 0) { + goto _OVER; + } + + if (numOfTopics != 0 && alterReq.walRetentionPeriod == 0) { + terrno = TSDB_CODE_MND_DB_RETENTION_PERIOD_ZERO; + mError("db:%s, not allowed to set WAL_RETENTION_PERIOD 0 when there are topics defined. numOfTopics:%d", pDb->name, + numOfTopics); + goto _OVER; + } + memcpy(&dbObj, pDb, sizeof(SDbObj)); if (dbObj.cfg.pRetensions != NULL) { dbObj.cfg.pRetensions = taosArrayDup(pDb->cfg.pRetensions, NULL); @@ -1270,14 +1295,9 @@ static int32_t mndProcessUseDbReq(SRpcMsg *pReq) { usedbRsp.errCode = terrno; if (terrno == TSDB_CODE_MND_DB_IN_CREATING) { - if (mndSetRpcInfoForDbTrans(pMnode, pReq, MND_OPER_CREATE_DB, usedbReq.db) == 0) { - mInfo("db:%s, is creating and usedb response after trans finished", usedbReq.db); - code = TSDB_CODE_ACTION_IN_PROGRESS; - goto _OVER; - } + code = terrno; + goto _OVER; } - - mError("db:%s, failed to process use db req since %s", usedbReq.db, terrstr()); } else { if (mndCheckDbPrivilege(pMnode, pReq->info.conn.user, MND_OPER_USE_DB, pDb) != 0) { goto _OVER; diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index d4a84759c1abbffe248130e11cb649bea825bb82..1f58ae97a3c7034eda9ef8385e1e057cf0c510d2 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -25,6 +25,7 @@ #include "mndUser.h" #include "mndVgroup.h" #include "tmisce.h" +#include "mndCluster.h" #define TSDB_DNODE_VER_NUMBER 1 #define TSDB_DNODE_RESERVE_SIZE 64 @@ -366,6 +367,14 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { goto _OVER; } + int64_t clusterid = mndGetClusterId(pMnode); + if (statusReq.clusterId != 0 && statusReq.clusterId != clusterid) { + code = TSDB_CODE_MND_DNODE_DIFF_CLUSTER; + mWarn("dnode:%d, %s, its clusterid:%" PRId64 " differ from current cluster:%" PRId64 ", code:0x%x", + statusReq.dnodeId, statusReq.dnodeEp, statusReq.clusterId, clusterid, code); + goto _OVER; + } + if (statusReq.dnodeId == 0) { pDnode = mndAcquireDnodeByEp(pMnode, statusReq.dnodeEp); if (pDnode == NULL) { @@ -412,6 +421,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { if (pVgroup != NULL) { if (pVload->syncState == TAOS_SYNC_STATE_LEADER) { pVgroup->cacheUsage = pVload->cacheUsage; + pVgroup->numOfCachedTables = pVload->numOfCachedTables; pVgroup->numOfTables = pVload->numOfTables; pVgroup->numOfTimeSeries = pVload->numOfTimeSeries; pVgroup->totalStorage = pVload->totalStorage; diff --git a/source/dnode/mnode/impl/src/mndFunc.c b/source/dnode/mnode/impl/src/mndFunc.c index 8d006f10296eaf1fc1e90613eebc54cfd7e983c7..51a231daf463c357eb494c87fad4b0187a9c43f6 100644 --- a/source/dnode/mnode/impl/src/mndFunc.c +++ b/source/dnode/mnode/impl/src/mndFunc.c @@ -21,7 +21,7 @@ #include "mndTrans.h" #include "mndUser.h" -#define SDB_FUNC_VER 1 +#define SDB_FUNC_VER 2 #define SDB_FUNC_RESERVE_SIZE 64 static SSdbRaw *mndFuncActionEncode(SFuncObj *pFunc); @@ -83,6 +83,7 @@ static SSdbRaw *mndFuncActionEncode(SFuncObj *pFunc) { SDB_SET_BINARY(pRaw, dataPos, pFunc->pComment, pFunc->commentSize, _OVER) } SDB_SET_BINARY(pRaw, dataPos, pFunc->pCode, pFunc->codeSize, _OVER) + SDB_SET_INT32(pRaw, dataPos, pFunc->funcVersion, _OVER) SDB_SET_RESERVE(pRaw, dataPos, SDB_FUNC_RESERVE_SIZE, _OVER) SDB_SET_DATALEN(pRaw, dataPos, _OVER); @@ -107,7 +108,7 @@ static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) { int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto _OVER; - if (sver != SDB_FUNC_VER) { + if (sver != 1 && sver != 2) { terrno = TSDB_CODE_SDB_INVALID_DATA_VER; goto _OVER; } @@ -144,8 +145,15 @@ static SSdbRow *mndFuncActionDecode(SSdbRaw *pRaw) { goto _OVER; } SDB_GET_BINARY(pRaw, dataPos, pFunc->pCode, pFunc->codeSize, _OVER) + + if (sver >= 2) { + SDB_GET_INT32(pRaw, dataPos, &pFunc->funcVersion, _OVER) + } + SDB_GET_RESERVE(pRaw, dataPos, SDB_FUNC_RESERVE_SIZE, _OVER) + taosInitRWLatch(&pFunc->lock); + terrno = 0; _OVER: @@ -173,6 +181,44 @@ static int32_t mndFuncActionDelete(SSdb *pSdb, SFuncObj *pFunc) { static int32_t mndFuncActionUpdate(SSdb *pSdb, SFuncObj *pOld, SFuncObj *pNew) { mTrace("func:%s, perform update action, old row:%p new row:%p", pOld->name, pOld, pNew); + + taosWLockLatch(&pOld->lock); + + pOld->align = pNew->align; + pOld->bufSize = pNew->bufSize; + pOld->codeSize = pNew->codeSize; + pOld->commentSize = pNew->commentSize; + pOld->createdTime = pNew->createdTime; + pOld->funcType = pNew->funcType; + pOld->funcVersion = pNew->funcVersion; + pOld->outputLen = pNew->outputLen; + pOld->outputType = pNew->outputType; + + if (pOld->pComment != NULL) { + taosMemoryFree(pOld->pComment); + pOld->pComment = NULL; + } + if (pNew->commentSize > 0 && pNew->pComment != NULL) { + pOld->commentSize = pNew->commentSize; + pOld->pComment = taosMemoryMalloc(pOld->commentSize); + memcpy(pOld->pComment, pNew->pComment, pOld->commentSize); + } + + if (pOld->pCode != NULL) { + taosMemoryFree(pOld->pCode); + pOld->pCode = NULL; + } + if (pNew->codeSize > 0 && pNew->pCode != NULL) { + pOld->codeSize = pNew->codeSize; + pOld->pCode = taosMemoryMalloc(pOld->codeSize); + memcpy(pOld->pCode, pNew->pCode, pOld->codeSize); + } + + pOld->scriptType = pNew->scriptType; + pOld->signature = pNew->signature; + + taosWUnLockLatch(&pOld->lock); + return 0; } @@ -225,26 +271,47 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pReq, "create-func"); if (pTrans == NULL) goto _OVER; - mInfo("trans:%d, used to create func:%s", pTrans->id, pCreate->name); - SSdbRaw *pRedoRaw = mndFuncActionEncode(&func); - if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER; - if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING) != 0) goto _OVER; + SFuncObj *oldFunc = mndAcquireFunc(pMnode, pCreate->name); + if (pCreate->orReplace == 1 && oldFunc != NULL) { + func.funcVersion = oldFunc->funcVersion + 1; + func.createdTime = oldFunc->createdTime; + + SSdbRaw *pRedoRaw = mndFuncActionEncode(oldFunc); + if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER; + if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY) != 0) goto _OVER; + + SSdbRaw *pUndoRaw = mndFuncActionEncode(oldFunc); + if (pUndoRaw == NULL || mndTransAppendUndolog(pTrans, pUndoRaw) != 0) goto _OVER; + if (sdbSetRawStatus(pUndoRaw, SDB_STATUS_READY) != 0) goto _OVER; - SSdbRaw *pUndoRaw = mndFuncActionEncode(&func); - if (pUndoRaw == NULL || mndTransAppendUndolog(pTrans, pUndoRaw) != 0) goto _OVER; - if (sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED) != 0) goto _OVER; + SSdbRaw *pCommitRaw = mndFuncActionEncode(&func); + if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto _OVER; + if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) goto _OVER; + } else { + SSdbRaw *pRedoRaw = mndFuncActionEncode(&func); + if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) goto _OVER; + if (sdbSetRawStatus(pRedoRaw, SDB_STATUS_CREATING) != 0) goto _OVER; - SSdbRaw *pCommitRaw = mndFuncActionEncode(&func); - if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto _OVER; - if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) goto _OVER; + SSdbRaw *pUndoRaw = mndFuncActionEncode(&func); + if (pUndoRaw == NULL || mndTransAppendUndolog(pTrans, pUndoRaw) != 0) goto _OVER; + if (sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED) != 0) goto _OVER; + + SSdbRaw *pCommitRaw = mndFuncActionEncode(&func); + if (pCommitRaw == NULL || mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) goto _OVER; + if (sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY) != 0) goto _OVER; + } if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; code = 0; _OVER: + if (oldFunc != NULL) { + mndReleaseFunc(pMnode, oldFunc); + } + taosMemoryFree(func.pCode); taosMemoryFree(func.pComment); mndTransDrop(pTrans); @@ -304,6 +371,9 @@ static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) { mInfo("func:%s, already exist, ignore exist is set", createReq.name); code = 0; goto _OVER; + } else if (createReq.orReplace) { + mInfo("func:%s, replace function is set", createReq.name); + code = 0; } else { terrno = TSDB_CODE_MND_FUNC_ALREADY_EXIST; goto _OVER; @@ -413,6 +483,12 @@ static int32_t mndProcessRetrieveFuncReq(SRpcMsg *pReq) { goto RETRIEVE_FUNC_OVER; } + retrieveRsp.pFuncExtraInfos = taosArrayInit(retrieveReq.numOfFuncs, sizeof(SFuncExtraInfo)); + if (retrieveRsp.pFuncExtraInfos == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto RETRIEVE_FUNC_OVER; + } + for (int32_t i = 0; i < retrieveReq.numOfFuncs; ++i) { char *funcName = taosArrayGet(retrieveReq.pFuncNames, i); @@ -451,6 +527,11 @@ static int32_t mndProcessRetrieveFuncReq(SRpcMsg *pReq) { } } taosArrayPush(retrieveRsp.pFuncInfos, &funcInfo); + SFuncExtraInfo extraInfo = {0}; + extraInfo.funcVersion = pFunc->funcVersion; + extraInfo.funcCreatedTime = pFunc->createdTime; + taosArrayPush(retrieveRsp.pFuncExtraInfos, &extraInfo); + mndReleaseFunc(pMnode, pFunc); } @@ -519,6 +600,7 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataSetVal(pColInfo, numOfRows, (const char *)b2, false); + taosMemoryFree(b2); } else { pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataSetVal(pColInfo, numOfRows, NULL, true); @@ -545,6 +627,31 @@ static int32_t mndRetrieveFuncs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBl pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->bufSize, false); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + char *language = ""; + if (pFunc->scriptType == TSDB_FUNC_SCRIPT_BIN_LIB) { + language = "C"; + } else if (pFunc->scriptType == TSDB_FUNC_SCRIPT_PYTHON) { + language = "Python"; + } + char varLang[TSDB_TYPE_STR_MAX_LEN + 1] = {0}; + varDataSetLen(varLang, strlen(language)); + strcpy(varDataVal(varLang), language); + colDataSetVal(pColInfo, numOfRows, (const char *)varLang, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + int32_t varCodeLen = (pFunc->codeSize + VARSTR_HEADER_SIZE) > TSDB_MAX_BINARY_LEN + ? TSDB_MAX_BINARY_LEN + : pFunc->codeSize + VARSTR_HEADER_SIZE; + char *b4 = taosMemoryMalloc(varCodeLen); + memcpy(varDataVal(b4), pFunc->pCode, varCodeLen - VARSTR_HEADER_SIZE); + varDataSetLen(b4, varCodeLen - VARSTR_HEADER_SIZE); + colDataSetVal(pColInfo, numOfRows, (const char *)b4, false); + taosMemoryFree(b4); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)&pFunc->funcVersion, false); + numOfRows++; sdbRelease(pSdb, pFunc); } diff --git a/source/dnode/mnode/impl/src/mndIndex.c b/source/dnode/mnode/impl/src/mndIndex.c index 8782fd823f36fdfcad114d4cf2f6bbac5d754bad..83172acf641608427a045623b835b9300901ad2c 100644 --- a/source/dnode/mnode/impl/src/mndIndex.c +++ b/source/dnode/mnode/impl/src/mndIndex.c @@ -138,7 +138,7 @@ static void *mndBuildDropIdxReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pStbOb mInfo("idx: %s start to build drop index req", pIdx->name); len = tSerializeSDropIdxReq(NULL, 0, &req); - if (ret < 0) { + if (len < 0) { goto _err; } @@ -672,7 +672,7 @@ _OVER: static int32_t mndAddIndex(SMnode *pMnode, SRpcMsg *pReq, SCreateTagIndexReq *req, SDbObj *pDb, SStbObj *pStb) { int32_t code = -1; SIdxObj idxObj = {0}; - memcpy(idxObj.name, req->idxName, TSDB_TABLE_FNAME_LEN); + memcpy(idxObj.name, req->idxName, TSDB_INDEX_FNAME_LEN); memcpy(idxObj.stb, pStb->name, TSDB_TABLE_FNAME_LEN); memcpy(idxObj.db, pDb->name, TSDB_DB_FNAME_LEN); memcpy(idxObj.colName, req->colName, TSDB_COL_NAME_LEN); diff --git a/source/dnode/mnode/impl/src/mndMain.c b/source/dnode/mnode/impl/src/mndMain.c index d83b969e2debfd3848b39c28ca316e4ef9eb3fc1..5c20887cf5b548fc291d5ae37aac10e9a1f506b1 100644 --- a/source/dnode/mnode/impl/src/mndMain.c +++ b/source/dnode/mnode/impl/src/mndMain.c @@ -380,11 +380,13 @@ static int32_t mndInitSdb(SMnode *pMnode) { } static int32_t mndOpenSdb(SMnode *pMnode) { + int32_t code = 0; if (!pMnode->deploy) { - return sdbReadFile(pMnode->pSdb); - } else { - return 0; + code = sdbReadFile(pMnode->pSdb); } + + atomic_store_64(&pMnode->applied, pMnode->pSdb->commitIndex); + return code; } static void mndCleanupSdb(SMnode *pMnode) { @@ -651,7 +653,7 @@ _OVER: pMsg->msgType == TDMT_MND_TRANS_TIMER || pMsg->msgType == TDMT_MND_TTL_TIMER || pMsg->msgType == TDMT_MND_UPTIME_TIMER) { mTrace("timer not process since mnode restored:%d stopped:%d, sync restored:%d role:%s ", pMnode->restored, - pMnode->stopped, state.restored, syncStr(state.restored)); + pMnode->stopped, state.restored, syncStr(state.state)); return -1; } @@ -759,6 +761,8 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr pClusterInfo->connections_total = mndGetNumOfConnections(pMnode); pClusterInfo->dbs_total = sdbGetSize(pSdb, SDB_DB); pClusterInfo->stbs_total = sdbGetSize(pSdb, SDB_STB); + pClusterInfo->topics_toal = sdbGetSize(pSdb, SDB_TOPIC); + pClusterInfo->streams_total = sdbGetSize(pSdb, SDB_STREAM); void *pIter = NULL; while (1) { @@ -862,7 +866,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr } // grant info - pGrantInfo->expire_time = (pMnode->grant.expireTimeMS - ms) / 86400000.0f; + pGrantInfo->expire_time = (pMnode->grant.expireTimeMS - ms) / 1000; pGrantInfo->timeseries_total = pMnode->grant.timeseriesAllowed; if (pMnode->grant.expireTimeMS == 0) { pGrantInfo->expire_time = INT32_MAX; diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 41dea5073146076e5783f763fbe43c9488c5d12d..50e502f4ab9b240e8518bdb4fe531929149e974d 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -226,7 +226,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) { goto _OVER; } - if ((code = taosCheckVersionCompatibleFromStr(connReq.sVer, version, 2)) != 0) { + if ((code = taosCheckVersionCompatibleFromStr(connReq.sVer, version, 3)) != 0) { terrno = code; goto _OVER; } diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index 7fe08514f62108ae08f75c2d875cb117881b9298..c50b205f37f569fced5a690f329ae3ba26c1ac6a 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -324,7 +324,7 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) { pReq->info.rsp = pRsp; pReq->info.rspLen = size; - if (rowsRead == 0 || rowsRead < rowsToRead) { + if (rowsRead == 0 || ((rowsRead < rowsToRead) && !pShow->restore)) { pRsp->completed = 1; mDebug("show:0x%" PRIx64 ", retrieve completed", pShow->id); mndReleaseShowObj(pShow, true); diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index ac8a35c23766100908ecd1df8284f79d800992a8..b3da66a035e7f071b5245dad4ac8edda9abc1151 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -3114,9 +3114,18 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB char typeName[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; STR_TO_VARSTR(typeName, "SUPER_TABLE"); + bool fetch = pShow->restore ? false : true; + pShow->restore = false; while (numOfRows < rows) { - pShow->pIter = sdbFetch(pSdb, SDB_STB, pShow->pIter, (void **)&pStb); - if (pShow->pIter == NULL) break; + if (fetch) { + pShow->pIter = sdbFetch(pSdb, SDB_STB, pShow->pIter, (void **)&pStb); + if (pShow->pIter == NULL) break; + } else { + fetch = true; + void *pKey = taosHashGetKey(pShow->pIter, NULL); + pStb = sdbAcquire(pSdb, SDB_STB, pKey); + if (!pStb) continue; + } if (pDb != NULL && pStb->dbUid != pDb->uid) { sdbRelease(pSdb, pStb); @@ -3130,6 +3139,17 @@ static int32_t mndRetrieveStbCol(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB sdbRelease(pSdb, pStb); continue; } + + if ((numOfRows + pStb->numOfColumns) > rows) { + pShow->restore = true; + if (numOfRows == 0) { + mError("mndRetrieveStbCol failed to get stable cols since buf:%d less than result:%d, stable name:%s, db:%s", + rows, pStb->numOfColumns, pStb->name, pStb->db); + } + sdbRelease(pSdb, pStb); + break; + } + varDataSetLen(stbName, strlen(&stbName[VARSTR_HEADER_SIZE])); mDebug("mndRetrieveStbCol get stable cols, stable name:%s, db:%s", pStb->name, pStb->db); diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index 4d19110f31ffa9e01a38c4bd60ab375e608a65d4..6a745a0a4f94ff4668e55927b99596bfd705d5ca 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -197,24 +197,20 @@ static SMqRebInfo *mndGetOrCreateRebSub(SHashObj *pHash, const char *key) { return pRebSub; } -static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput) { - int32_t totalVgNum = pOutput->pSub->vgNum; - const char *sub = pOutput->pSub->key; - mInfo("sub:%s mq re-balance %d vgroups", sub, pOutput->pSub->vgNum); - - // 1. build temporary hash(vgId -> SMqRebOutputVg) to store modified vg - SHashObj *pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); +static void doRemoveExistedConsumers(SMqRebOutputObj *pOutput, SHashObj *pHash, const SMqRebInputObj *pInput) { + int32_t numOfRemoved = taosArrayGetSize(pInput->pRebInfo->removedConsumers); + const char *pSubKey = pOutput->pSub->key; - // 2. check and get actual removed consumers, put their vg into hash - int32_t removedNum = taosArrayGetSize(pInput->pRebInfo->removedConsumers); int32_t actualRemoved = 0; - for (int32_t i = 0; i < removedNum; i++) { + for (int32_t i = 0; i < numOfRemoved; i++) { uint64_t consumerId = *(uint64_t *)taosArrayGet(pInput->pRebInfo->removedConsumers, i); SMqConsumerEp *pConsumerEp = taosHashGet(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t)); + // consumer exists till now if (pConsumerEp) { actualRemoved++; + int32_t consumerVgNum = taosArrayGetSize(pConsumerEp->vgs); for (int32_t j = 0; j < consumerVgNum; j++) { SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, j); @@ -223,52 +219,67 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR .newConsumerId = -1, .pVgEp = pVgEp, }; + taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("sub:%s mq re-balance remove vgId:%d from consumer:%" PRIx64, sub, pVgEp->vgId, consumerId); + mInfo("sub:%s mq re-balance remove vgId:%d from consumer:%" PRIx64, pSubKey, pVgEp->vgId, consumerId); } + taosArrayDestroy(pConsumerEp->vgs); taosHashRemove(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t)); + // put into removed taosArrayPush(pOutput->removedConsumers, &consumerId); } } - if (removedNum != actualRemoved) { - mError("sub:%s mq re-balance removedNum:%d not matched with actual:%d", sub, removedNum, actualRemoved); + if (numOfRemoved != actualRemoved) { + mError("sub:%s mq re-balance removedNum:%d not matched with actual:%d", pSubKey, numOfRemoved, actualRemoved); + } else { + mInfo("sub:%s removed %d consumers", pSubKey, numOfRemoved); } +} - // if previously no consumer, there are vgs not assigned - { - int32_t consumerVgNum = taosArrayGetSize(pOutput->pSub->unassignedVgs); - for (int32_t i = 0; i < consumerVgNum; i++) { - SMqVgEp *pVgEp = *(SMqVgEp **)taosArrayPop(pOutput->pSub->unassignedVgs); - SMqRebOutputVg rebOutput = { - .oldConsumerId = -1, - .newConsumerId = -1, - .pVgEp = pVgEp, - }; - taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &rebOutput, sizeof(SMqRebOutputVg)); - mInfo("sub:%s mq re-balance remove vgId:%d from unassigned", sub, pVgEp->vgId); - } +static void doAddNewConsumers(SMqRebOutputObj *pOutput, const SMqRebInputObj *pInput) { + int32_t numOfNewConsumers = taosArrayGetSize(pInput->pRebInfo->newConsumers); + const char *pSubKey = pOutput->pSub->key; + + for (int32_t i = 0; i < numOfNewConsumers; i++) { + int64_t consumerId = *(int64_t *)taosArrayGet(pInput->pRebInfo->newConsumers, i); + + SMqConsumerEp newConsumerEp; + newConsumerEp.consumerId = consumerId; + newConsumerEp.vgs = taosArrayInit(0, sizeof(void *)); + + taosHashPut(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t), &newConsumerEp, sizeof(SMqConsumerEp)); + taosArrayPush(pOutput->newConsumers, &consumerId); + mInfo("sub:%s mq rebalance add new consumer:%" PRIx64, pSubKey, consumerId); } +} - // 3. calc vg number of each consumer - int32_t afterRebConsumerNum = pInput->oldConsumerNum + taosArrayGetSize(pInput->pRebInfo->newConsumers) - - taosArrayGetSize(pInput->pRebInfo->removedConsumers); - int32_t minVgCnt = 0; - int32_t imbConsumerNum = 0; - // calc num - if (afterRebConsumerNum) { - minVgCnt = totalVgNum / afterRebConsumerNum; - imbConsumerNum = totalVgNum % afterRebConsumerNum; +static void addUnassignedVgroups(SMqRebOutputObj *pOutput, SHashObj *pHash) { + const char *pSubKey = pOutput->pSub->key; + int32_t numOfVgroups = taosArrayGetSize(pOutput->pSub->unassignedVgs); + + for (int32_t i = 0; i < numOfVgroups; i++) { + SMqVgEp *pVgEp = *(SMqVgEp **)taosArrayPop(pOutput->pSub->unassignedVgs); + SMqRebOutputVg rebOutput = { + .oldConsumerId = -1, + .newConsumerId = -1, + .pVgEp = pVgEp, + }; + + taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &rebOutput, sizeof(SMqRebOutputVg)); + mInfo("sub:%s mq re-balance remove vgId:%d from unassigned", pSubKey, pVgEp->vgId); } +} - mInfo("sub:%s mq re-balance %d consumers: at least %d vgs each, %d consumers has more vgs", sub, - afterRebConsumerNum, minVgCnt, imbConsumerNum); +static void transferVgroupsForConsumers(SMqRebOutputObj *pOutput, SHashObj *pHash, int32_t minVgCnt, + int32_t imbConsumerNum) { + const char *pSubKey = pOutput->pSub->key; - // 4. first scan: remove consumer more than wanted, put to remove hash int32_t imbCnt = 0; void *pIter = NULL; + while (1) { pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); if (pIter == NULL) { @@ -276,8 +287,8 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR } SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; + int32_t consumerVgNum = taosArrayGetSize(pConsumerEp->vgs); - int32_t consumerVgNum = taosArrayGetSize(pConsumerEp->vgs); // all old consumers still existing are touched // TODO optimize: touch only consumer whose vgs changed taosArrayPush(pOutput->touchedConsumers, &pConsumerEp->consumerId); @@ -296,13 +307,13 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR .pVgEp = pVgEp, }; taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("sub:%s mq rebalance remove vgId:%d from consumer:0x%" PRIx64 ",(first scan)", sub, pVgEp->vgId, + mInfo("sub:%s mq rebalance remove vgId:%d from consumer:0x%" PRIx64 ",(first scan)", pSubKey, pVgEp->vgId, pConsumerEp->consumerId); } imbCnt++; } } else { - // pop until equal minVg + // all the remain consumers should only have the number of vgroups, which is equalled to the value of minVg while (taosArrayGetSize(pConsumerEp->vgs) > minVgCnt) { SMqVgEp *pVgEp = *(SMqVgEp **)taosArrayPop(pConsumerEp->vgs); SMqRebOutputVg outputVg = { @@ -311,36 +322,67 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR .pVgEp = pVgEp, }; taosHashPut(pHash, &pVgEp->vgId, sizeof(int32_t), &outputVg, sizeof(SMqRebOutputVg)); - mInfo("sub:%s mq rebalance remove vgId:%d from consumer:0x%" PRIx64 ",(first scan)", sub, pVgEp->vgId, + mInfo("sub:%s mq rebalance remove vgId:%d from consumer:0x%" PRIx64 ",(first scan)", pSubKey, pVgEp->vgId, pConsumerEp->consumerId); } } } } +} - // 5. add new consumer into sub - { - int32_t consumerNum = taosArrayGetSize(pInput->pRebInfo->newConsumers); - for (int32_t i = 0; i < consumerNum; i++) { - int64_t consumerId = *(int64_t *)taosArrayGet(pInput->pRebInfo->newConsumers, i); - - SMqConsumerEp newConsumerEp; - newConsumerEp.consumerId = consumerId; - newConsumerEp.vgs = taosArrayInit(0, sizeof(void *)); - taosHashPut(pOutput->pSub->consumerHash, &consumerId, sizeof(int64_t), &newConsumerEp, sizeof(SMqConsumerEp)); - taosArrayPush(pOutput->newConsumers, &consumerId); - mInfo("sub:%s mq rebalance add new consumer:%" PRIx64, sub, consumerId); - } +static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqRebOutputObj *pOutput) { + int32_t totalVgNum = pOutput->pSub->vgNum; + const char *pSubKey = pOutput->pSub->key; + + int32_t numOfRemoved = taosArrayGetSize(pInput->pRebInfo->removedConsumers); + int32_t numOfAdded = taosArrayGetSize(pInput->pRebInfo->newConsumers); + mInfo("sub:%s mq re-balance %d vgroups, existed consumers:%d, added:%d, removed:%d", pSubKey, totalVgNum, + pInput->oldConsumerNum, numOfAdded, numOfRemoved); + + // 1. build temporary hash(vgId -> SMqRebOutputVg) to store modified vg + SHashObj *pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + + // 2. check and get actual removed consumers, put their vg into hash + doRemoveExistedConsumers(pOutput, pHash, pInput); + + // 3. if previously no consumer, there are vgs not assigned + addUnassignedVgroups(pOutput, pHash); + + // 4. calc vg number of each consumer + int32_t numOfFinal = pInput->oldConsumerNum + numOfAdded - numOfRemoved; + + int32_t minVgCnt = 0; + int32_t imbConsumerNum = 0; + + // calc num + if (numOfFinal) { + minVgCnt = totalVgNum / numOfFinal; + imbConsumerNum = totalVgNum % numOfFinal; + mInfo("sub:%s mq re-balance %d consumers: at least %d vgs each, %d consumers has 1 more vgroups than avg value", + pSubKey, numOfFinal, minVgCnt, imbConsumerNum); + } else { + mInfo("sub:%s no consumer subscribe this topic", pSubKey); } - // 6. second scan: find consumer do not have enough vg, extract from temporary hash and assign to new consumer. + // 5. first scan: remove vgroups from te consumers, who have more vgroups than the threashold value that is + // minVgCnt, and then put them into the recycled hash list + transferVgroupsForConsumers(pOutput, pHash, minVgCnt, imbConsumerNum); + + // 6. add new consumer into sub + doAddNewConsumers(pOutput, pInput); + + // 7. second scan: find consumer do not have enough vgroups, extract from temporary hash and assign to them // All related vg should be put into rebVgs SMqRebOutputVg *pRebVg = NULL; void *pRemovedIter = NULL; - pIter = NULL; + void *pIter = NULL; + while (1) { pIter = taosHashIterate(pOutput->pSub->consumerHash, pIter); - if (pIter == NULL) break; + if (pIter == NULL) { + break; + } + SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; // push until equal minVg @@ -348,8 +390,8 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR // iter hash and find one vg pRemovedIter = taosHashIterate(pHash, pRemovedIter); if (pRemovedIter == NULL) { - mError("sub:%s removed iter is null", sub); - continue; + mError("sub:%s removed iter is null", pSubKey); + break; } pRebVg = (SMqRebOutputVg *)pRemovedIter; @@ -357,7 +399,7 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp); pRebVg->newConsumerId = pConsumerEp->consumerId; taosArrayPush(pOutput->rebVgs, pRebVg); - mInfo("mq rebalance: add vgId:%d to consumer:%" PRIx64 " (second scan) (not enough)", pRebVg->pVgEp->vgId, + mInfo("mq rebalance: add vgId:%d to consumer:0x%" PRIx64 " (second scan) (not enough)", pRebVg->pVgEp->vgId, pConsumerEp->consumerId); } } @@ -387,12 +429,12 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR taosArrayPush(pConsumerEp->vgs, &pRebVg->pVgEp); pRebVg->newConsumerId = pConsumerEp->consumerId; if (pRebVg->newConsumerId == pRebVg->oldConsumerId) { - mInfo("mq rebalance: skip vg %d for same consumer:%" PRIx64 " (second scan)", pRebVg->pVgEp->vgId, + mInfo("mq rebalance: skip vg %d for same consumer:0x%" PRIx64 " (second scan)", pRebVg->pVgEp->vgId, pConsumerEp->consumerId); continue; } taosArrayPush(pOutput->rebVgs, pRebVg); - mInfo("mq rebalance: add vgId:%d to consumer:%" PRIx64 " (second scan) (unassigned)", pRebVg->pVgEp->vgId, + mInfo("mq rebalance: add vgId:%d to consumer:0x%" PRIx64 " (second scan) (unassigned)", pRebVg->pVgEp->vgId, pConsumerEp->consumerId); } } else { @@ -409,15 +451,15 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR taosArrayPush(pOutput->pSub->unassignedVgs, &pRebOutput->pVgEp); taosArrayPush(pOutput->rebVgs, pRebOutput); - mInfo("sub:%s mq re-balance unassign vgId:%d (second scan)", sub, pRebOutput->pVgEp->vgId); + mInfo("sub:%s mq re-balance unassign vgId:%d (second scan)", pSubKey, pRebOutput->pVgEp->vgId); } } // 8. generate logs - mInfo("sub:%s mq re-balance calculation completed, re-balanced vg", sub); + mInfo("sub:%s mq re-balance calculation completed, re-balanced vg", pSubKey); for (int32_t i = 0; i < taosArrayGetSize(pOutput->rebVgs); i++) { SMqRebOutputVg *pOutputRebVg = taosArrayGet(pOutput->rebVgs, i); - mInfo("sub:%s mq re-balance vgId:%d, moved from consumer:0x%" PRIx64 ", to consumer:0x%" PRIx64, sub, + mInfo("sub:%s mq re-balance vgId:%d, moved from consumer:0x%" PRIx64 ", to consumer:0x%" PRIx64, pSubKey, pOutputRebVg->pVgEp->vgId, pOutputRebVg->oldConsumerId, pOutputRebVg->newConsumerId); } { @@ -427,10 +469,10 @@ static int32_t mndDoRebalance(SMnode *pMnode, const SMqRebInputObj *pInput, SMqR if (pIter == NULL) break; SMqConsumerEp *pConsumerEp = (SMqConsumerEp *)pIter; int32_t sz = taosArrayGetSize(pConsumerEp->vgs); - mInfo("sub:%s mq re-balance final cfg: consumer:0x%" PRIx64 " has %d vg", sub, pConsumerEp->consumerId, sz); + mInfo("sub:%s mq re-balance final cfg: consumer:0x%" PRIx64 " has %d vg", pSubKey, pConsumerEp->consumerId, sz); for (int32_t i = 0; i < sz; i++) { SMqVgEp *pVgEp = taosArrayGetP(pConsumerEp->vgs, i); - mInfo("sub:%s mq re-balance final cfg: vg %d to consumer:0x%" PRIx64, sub, pVgEp->vgId, + mInfo("sub:%s mq re-balance final cfg: vg %d to consumer:0x%" PRIx64, pSubKey, pVgEp->vgId, pConsumerEp->consumerId); } } @@ -555,17 +597,23 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { SMnode *pMnode = pMsg->info.node; SMqDoRebalanceMsg *pReq = pMsg->pCont; void *pIter = NULL; + bool rebalanceOnce = false; // to ensure only once. - mInfo("mq re-balance start"); + mInfo("mq re-balance start, total required re-balanced trans:%d", taosHashGetSize(pReq->rebSubHash)); + // here we only handle one topic rebalance requirement to ensure the atomic execution of this transaction. while (1) { + if (rebalanceOnce) { + break; + } + pIter = taosHashIterate(pReq->rebSubHash, pIter); if (pIter == NULL) { break; } - SMqRebInputObj rebInput = {0}; - + // todo handle the malloc failure + SMqRebInputObj rebInput = {0}; SMqRebOutputObj rebOutput = {0}; rebOutput.newConsumers = taosArrayInit(0, sizeof(int64_t)); rebOutput.removedConsumers = taosArrayInit(0, sizeof(int64_t)); @@ -582,9 +630,10 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { char topic[TSDB_TOPIC_FNAME_LEN]; char cgroup[TSDB_CGROUP_LEN]; mndSplitSubscribeKey(pRebInfo->key, topic, cgroup, true); + SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); if (pTopic == NULL) { - mError("mq re-balance %s ignored since topic %s not exist", pRebInfo->key, topic); + mError("mq re-balance %s ignored since topic %s doesn't exist", pRebInfo->key, topic); continue; } @@ -604,11 +653,13 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { mndReleaseTopic(pMnode, pTopic); rebInput.oldConsumerNum = 0; + mInfo("topic:%s has no consumers sub yet", topic); } else { taosRLockLatch(&pSub->lock); rebInput.oldConsumerNum = taosHashGetSize(pSub->consumerHash); rebOutput.pSub = tCloneSubscribeObj(pSub); taosRUnLockLatch(&pSub->lock); + mInfo("topic:%s has %d consumers sub till now", pRebInfo->key, rebInput.oldConsumerNum); mndReleaseSubscribe(pMnode, pSub); } @@ -623,16 +674,14 @@ static int32_t mndProcessRebalanceReq(SRpcMsg *pMsg) { mError("mq re-balance persist output error, possibly vnode splitted or dropped"); } - taosArrayDestroy(pRebInfo->lostConsumers); - taosArrayDestroy(pRebInfo->newConsumers); - taosArrayDestroy(pRebInfo->removedConsumers); - taosArrayDestroy(rebOutput.newConsumers); taosArrayDestroy(rebOutput.touchedConsumers); taosArrayDestroy(rebOutput.removedConsumers); taosArrayDestroy(rebOutput.rebVgs); tDeleteSubscribeObj(rebOutput.pSub); taosMemoryFree(rebOutput.pSub); + + rebalanceOnce = true; } // reset flag @@ -1019,7 +1068,7 @@ int32_t mndRetrieveSubscribe(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataSetVal(pColInfo, numOfRows, (const char *)&pConsumerEp->consumerId, false); - mDebug("mnd show subscriptions: topic %s, consumer:%" PRIx64 " cgroup %s vgid %d", varDataVal(topic), + mDebug("mnd show subscriptions: topic %s, consumer:0x%" PRIx64 " cgroup %s vgid %d", varDataVal(topic), pConsumerEp->consumerId, varDataVal(cgroup), pVgEp->vgId); // offset diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index f702d8f14858f13525f893737f02cc40beab8355..4965d5c34a2f09b3ce25edf4bc6ed902a2f23a42 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -33,7 +33,7 @@ static int32_t mndSyncEqCtrlMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) { return -1; } - int32_t code = tmsgPutToQueue(msgcb, SYNC_CTRL_QUEUE, pMsg); + int32_t code = tmsgPutToQueue(msgcb, SYNC_RD_QUEUE, pMsg); if (code != 0) { rpcFreeCont(pMsg->pCont); pMsg->pCont = NULL; @@ -129,6 +129,14 @@ int32_t mndProcessWriteMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta int32_t mndSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) { int32_t code = 0; + pMsg->info.conn.applyIndex = pMeta->index; + pMsg->info.conn.applyTerm = pMeta->term; + + if (pMsg->code == 0) { + SMnode *pMnode = pFsm->data; + atomic_store_64(&pMnode->applied, pMsg->info.conn.applyIndex); + } + if (!syncUtilUserCommit(pMsg->msgType)) { goto _out; } @@ -140,6 +148,11 @@ _out: return code; } +SyncIndex mndSyncAppliedIndex(const SSyncFSM *pFSM) { + SMnode *pMnode = pFSM->data; + return atomic_load_64(&pMnode->applied); +} + int32_t mndSyncGetSnapshot(const SSyncFSM *pFsm, SSnapshot *pSnapshot, void *pReaderParam, void **ppReader) { mInfo("start to read snapshot from sdb in atomic way"); SMnode *pMnode = pFsm->data; @@ -153,7 +166,7 @@ static void mndSyncGetSnapshotInfo(const SSyncFSM *pFsm, SSnapshot *pSnapshot) { sdbGetCommitInfo(pMnode->pSdb, &pSnapshot->lastApplyIndex, &pSnapshot->lastApplyTerm, &pSnapshot->lastConfigIndex); } -void mndRestoreFinish(const SSyncFSM *pFsm) { +void mndRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx) { SMnode *pMnode = pFsm->data; if (!pMnode->deploy) { @@ -167,6 +180,8 @@ void mndRestoreFinish(const SSyncFSM *pFsm) { } else { mInfo("vgId:1, sync restore finished"); } + + ASSERT(commitIdx == mndSyncAppliedIndex(pFsm)); } int32_t mndSnapshotStartRead(const SSyncFSM *pFsm, void *pParam, void **ppReader) { @@ -253,6 +268,7 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) { SSyncFSM *pFsm = taosMemoryCalloc(1, sizeof(SSyncFSM)); pFsm->data = pMnode; pFsm->FpCommitCb = mndSyncCommitMsg; + pFsm->FpAppliedIndexCb = mndSyncAppliedIndex; pFsm->FpPreCommitCb = NULL; pFsm->FpRollBackCb = NULL; pFsm->FpRestoreFinishCb = mndRestoreFinish; diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 991f1099a63aee39526b27371d72cd9699ea83fb..f6da3709164158acc008708121873da5bb2b78d1 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -605,6 +605,12 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) { goto _OVER; } + if (pDb->cfg.walRetentionPeriod == 0) { + terrno = TSDB_CODE_MND_DB_RETENTION_PERIOD_ZERO; + mError("db:%s, not allowed to create topic when WAL_RETENTION_PERIOD is zero", pDb->name); + goto _OVER; + } + code = mndCreateTopic(pMnode, pReq, &createTopicReq, pDb, pReq->info.conn.user); if (code == 0) { code = TSDB_CODE_ACTION_IN_PROGRESS; @@ -793,7 +799,7 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) { return TSDB_CODE_ACTION_IN_PROGRESS; } -static int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTopics) { +int32_t mndGetNumOfTopics(SMnode *pMnode, char *dbName, int32_t *pNumOfTopics) { *pNumOfTopics = 0; SSdb *pSdb = pMnode->pSdb; @@ -943,4 +949,4 @@ int32_t mndDropTopicByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) { return code; } -#endif \ No newline at end of file +#endif diff --git a/source/dnode/mnode/impl/src/mndTrans.c b/source/dnode/mnode/impl/src/mndTrans.c index 4aaed29fc350013bba3bc412575a378015f1da84..106eea031384a93641c002200ab0c084f53fc76a 100644 --- a/source/dnode/mnode/impl/src/mndTrans.c +++ b/source/dnode/mnode/impl/src/mndTrans.c @@ -1093,10 +1093,13 @@ int32_t mndTransProcessRsp(SRpcMsg *pRsp) { pAction->msgReceived = 1; pAction->errCode = pRsp->code; pTrans->lastErrorNo = pRsp->code; + + mInfo("trans:%d, %s:%d response is received, code:0x%x, accept:0x%x retry:0x%x", transId, + mndTransStr(pAction->stage), action, pRsp->code, pAction->acceptableCode, pAction->retryCode); + } else { + mInfo("trans:%d, invalid action, index:%d, code:0x%x", transId, action, pRsp->code); } - mInfo("trans:%d, %s:%d response is received, code:0x%x, accept:0x%x retry:0x%x", transId, mndTransStr(pAction->stage), - action, pRsp->code, pAction->acceptableCode, pAction->retryCode); mndTransExecute(pMnode, pTrans, true); _OVER: diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 84e8a9ec4384847173c744a9db8d542702b62306..31924e04717e0bfffb485b7726a533454d718194 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -40,6 +40,7 @@ static void mndCancelGetNextVnode(SMnode *pMnode, void *pIter); static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq); static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq); static int32_t mndProcessBalanceVgroupMsg(SRpcMsg *pReq); +static int32_t mndProcessVgroupBalanceLeaderMsg(SRpcMsg *pReq); int32_t mndInitVgroup(SMnode *pMnode) { SSdbTable table = { @@ -60,10 +61,13 @@ int32_t mndInitVgroup(SMnode *pMnode) { mndSetMsgHandle(pMnode, TDMT_DND_DROP_VNODE_RSP, mndTransProcessRsp); mndSetMsgHandle(pMnode, TDMT_VND_COMPACT_RSP, mndTransProcessRsp); mndSetMsgHandle(pMnode, TDMT_VND_DISABLE_WRITE_RSP, mndTransProcessRsp); + mndSetMsgHandle(pMnode, TDMT_SYNC_FORCE_FOLLOWER_RSP, mndTransProcessRsp); mndSetMsgHandle(pMnode, TDMT_MND_REDISTRIBUTE_VGROUP, mndProcessRedistributeVgroupMsg); mndSetMsgHandle(pMnode, TDMT_MND_SPLIT_VGROUP, mndProcessSplitVgroupMsg); + //mndSetMsgHandle(pMnode, TDMT_MND_BALANCE_VGROUP, mndProcessVgroupBalanceLeaderMsg); mndSetMsgHandle(pMnode, TDMT_MND_BALANCE_VGROUP, mndProcessBalanceVgroupMsg); + mndSetMsgHandle(pMnode, TDMT_MND_BALANCE_VGROUP_LEADER, mndProcessVgroupBalanceLeaderMsg); mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_VGROUP, mndRetrieveVgroups); mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_VGROUP, mndCancelGetNextVgroup); @@ -321,6 +325,8 @@ static void *mndBuildAlterVnodeConfigReq(SMnode *pMnode, SDbObj *pDb, SVgObj *pV alterReq.cacheLast = pDb->cfg.cacheLast; alterReq.sttTrigger = pDb->cfg.sstTrigger; alterReq.minRows = pDb->cfg.minRows; + alterReq.walRetentionPeriod = pDb->cfg.walRetentionPeriod; + alterReq.walRetentionSize = pDb->cfg.walRetentionSize; mInfo("vgId:%d, build alter vnode config req", pVgroup->vgId); int32_t contLen = tSerializeSAlterVnodeConfigReq(NULL, 0, &alterReq); @@ -803,6 +809,9 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p int32_t cacheUsage = (int32_t)pVgroup->cacheUsage; colDataSetVal(pColInfo, numOfRows, (const char *)&cacheUsage, false); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->numOfCachedTables, false); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); colDataSetVal(pColInfo, numOfRows, (const char *)&pVgroup->isTsma, false); @@ -1770,6 +1779,169 @@ _OVER: return code; } +static void *mndBuildSForceBecomeFollowerReq(SMnode *pMnode, SVgObj *pVgroup, int32_t dnodeId, + int32_t *pContLen) { + SForceBecomeFollowerReq balanceReq = { + .vgId = pVgroup->vgId, + }; + + int32_t contLen = tSerializeSForceBecomeFollowerReq(NULL, 0, &balanceReq); + if (contLen < 0) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + contLen += sizeof(SMsgHead); + + void *pReq = taosMemoryMalloc(contLen); + if (pReq == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + + SMsgHead *pHead = pReq; + pHead->contLen = htonl(contLen); + pHead->vgId = htonl(pVgroup->vgId); + + tSerializeSForceBecomeFollowerReq((char *)pReq + sizeof(SMsgHead), contLen, &balanceReq); + *pContLen = contLen; + return pReq; +} + +int32_t mndAddBalanceVgroupLeaderAction(SMnode *pMnode, STrans *pTrans, SVgObj *pVgroup, int32_t dnodeId) { + SDnodeObj *pDnode = mndAcquireDnode(pMnode, dnodeId); + if (pDnode == NULL) return -1; + + STransAction action = {0}; + action.epSet = mndGetDnodeEpset(pDnode); + mndReleaseDnode(pMnode, pDnode); + + int32_t contLen = 0; + void *pReq = mndBuildSForceBecomeFollowerReq(pMnode, pVgroup, dnodeId, &contLen); + if (pReq == NULL) return -1; + + action.pCont = pReq; + action.contLen = contLen; + action.msgType = TDMT_SYNC_FORCE_FOLLOWER; + + if (mndTransAppendRedoAction(pTrans, &action) != 0) { + taosMemoryFree(pReq); + return -1; + } + + return 0; +} + +int32_t mndAddVgroupBalanceToTrans(SMnode *pMnode, SVgObj *pVgroup, STrans *pTrans){ + SSdb *pSdb = pMnode->pSdb; + + int32_t vgid = pVgroup->vgId; + int8_t replica = pVgroup->replica; + + if(pVgroup->replica <= 1) { + mInfo("trans:%d, vgid:%d no need to balance, replica:%d", pTrans->id, vgid, replica); + return -1; + } + + int32_t dnodeId = pVgroup->vnodeGid[0].dnodeId; + + for(int i = 0; i < replica; i++) + { + if(pVgroup->vnodeGid[i].syncState == TAOS_SYNC_STATE_LEADER){ + dnodeId = pVgroup->vnodeGid[i].dnodeId; + break; + } + } + + bool exist = false; + bool online = false; + int64_t curMs = taosGetTimestampMs(); + SDnodeObj *pDnode = mndAcquireDnode(pMnode, dnodeId); + if (pDnode != NULL) { + exist = true; + online = mndIsDnodeOnline(pDnode, curMs); + mndReleaseDnode(pMnode, pDnode); + } + + if(exist && online) + { + mInfo("trans:%d, vgid:%d leader to dnode:%d", pTrans->id, vgid, dnodeId); + + if (mndAddBalanceVgroupLeaderAction(pMnode, pTrans, pVgroup, dnodeId) != 0) { + mError("trans:%d, vgid:%d failed to be balanced to dnode:%d", pTrans->id, vgid, dnodeId); + return -1; + } + + SSdbRaw *pRaw = mndVgroupActionEncode(pVgroup); + if (pRaw == NULL) { + mError("trans:%d, vgid:%d failed to encode action to dnode:%d", pTrans->id, vgid, dnodeId); + return -1; + } + if (mndTransAppendCommitlog(pTrans, pRaw) != 0) { + sdbFreeRaw(pRaw); + mError("trans:%d, vgid:%d failed to append commit log dnode:%d", pTrans->id, vgid, dnodeId); + return -1; + } + (void)sdbSetRawStatus(pRaw, SDB_STATUS_READY); + } + else + { + mInfo("trans:%d, vgid:%d cant be balanced to dnode:%d, exist:%d, online:%d", pTrans->id, vgid, dnodeId, exist, online); + } + + return 0; +} + +int32_t mndProcessVgroupBalanceLeaderMsg(SRpcMsg *pReq) { + int32_t code = -1; + + SBalanceVgroupLeaderReq req = {0}; + if (tDeserializeSBalanceVgroupLeaderReq(pReq->pCont, pReq->contLen, &req) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + return code; + } + + SMnode *pMnode = pReq->info.node; + SSdb *pSdb = pMnode->pSdb; + + int32_t total = sdbGetSize(pSdb, SDB_VGROUP); + if(total <= 0) { + terrno = TSDB_CODE_TSC_INVALID_OPERATION; + return code; + } + + STrans *pTrans = NULL; + pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pReq, "bal-vg-leader"); + if (pTrans == NULL) goto _OVER; + mndTransSetSerial(pTrans); + mInfo("trans:%d, used to balance vgroup leader", pTrans->id); + + void *pIter = NULL; + int32_t count = 0; + while (1) { + SVgObj *pVgroup = NULL; + pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup); + if (pIter == NULL) break; + + if(mndAddVgroupBalanceToTrans(pMnode, pVgroup, pTrans) == 0){ + count++; + } + + sdbRelease(pSdb, pVgroup); + } + + if(count == 0) { + terrno = TSDB_CODE_TSC_INVALID_OPERATION; + goto _OVER; + } + + if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; + code = 0; + +_OVER: + mndTransDrop(pTrans); + return code; +} + static int32_t mndCheckDnodeMemory(SMnode *pMnode, SDbObj *pOldDb, SDbObj *pNewDb, SVgObj *pOldVgroup, SVgObj *pNewVgroup, SArray *pArray) { for (int32_t i = 0; i < (int32_t)taosArrayGetSize(pArray); ++i) { @@ -2267,4 +2439,4 @@ int32_t mndBuildCompactVgroupAction(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, STimeWindow tw) { if (mndAddCompactVnodeAction(pMnode, pTrans, pDb, pVgroup, compactTs, tw) != 0) return -1; 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 df71567d0043e818432e1f3f2ed552d47be58610..acfd181c513d4db5b3950ad1e69f4e656731c2de 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -76,9 +76,7 @@ int32_t sndExpandTask(SSnode *pSnode, SStreamTask *pTask, int64_t ver) { pTask->inputStatus = TASK_INPUT_STATUS__NORMAL; pTask->outputStatus = TASK_OUTPUT_STATUS__NORMAL; - pTask->pMsgCb = &pSnode->msgCb; - pTask->startVer = ver; pTask->pState = streamStateOpen(pSnode->path, pTask, false, -1, -1); @@ -91,11 +89,11 @@ int32_t sndExpandTask(SSnode *pSnode, SStreamTask *pTask, int64_t ver) { .numOfVgroups = (int32_t)taosArrayGetSize(pTask->childEpInfo), .pStateBackend = pTask->pState, }; - pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &mgHandle); + + pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &mgHandle, 0); ASSERT(pTask->exec.executor); streamSetupTrigger(pTask); - return 0; } diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index 566f6d4a9bf690f588b60958c2c53bb8d2277772..7dbfdc5ed281f9bb495225893c449180a3efecff 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -57,7 +57,7 @@ target_sources( # tq "src/tq/tq.c" - "src/tq/tqExec.c" + "src/tq/tqScan.c" "src/tq/tqMeta.c" "src/tq/tqRead.c" "src/tq/tqOffset.c" diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 1d14829891c602587f90f7aa38d1eeefb4b7b875..9636dc2872c82c50a9e501e744a5b8712f5bb0fd 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -157,7 +157,7 @@ typedef struct SMTbCursor SMTbCursor; SMTbCursor *metaOpenTbCursor(SMeta *pMeta); void metaCloseTbCursor(SMTbCursor *pTbCur); int32_t metaTbCursorNext(SMTbCursor *pTbCur, ETableType jumpTableType); -int32_t metaTbCursorPrev(SMTbCursor *pTbCur); +int32_t metaTbCursorPrev(SMTbCursor *pTbCur, ETableType jumpTableType); #endif @@ -178,10 +178,11 @@ typedef struct STsdbReader STsdbReader; int32_t tsdbSetTableList(STsdbReader *pReader, const void *pTableList, int32_t num); int32_t tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, void *pTableList, int32_t numOfTables, - SSDataBlock *pResBlock, STsdbReader **ppReader, const char *idstr); + SSDataBlock *pResBlock, STsdbReader **ppReader, const char *idstr, bool countOnly); +void tsdbReaderSetId(STsdbReader* pReader, const char* idstr); void tsdbReaderClose(STsdbReader *pReader); -bool tsdbNextDataBlock(STsdbReader *pReader); +int32_t tsdbNextDataBlock(STsdbReader *pReader, bool *hasNext); int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SSDataBlock *pDataBlock, bool *allHave); void tsdbReleaseDataBlock(STsdbReader *pReader); SSDataBlock *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList); @@ -198,9 +199,10 @@ int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32 void *tsdbCacherowsReaderClose(void *pReader); int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid); -void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity); -size_t tsdbCacheGetCapacity(SVnode *pVnode); -size_t tsdbCacheGetUsage(SVnode *pVnode); +void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity); +size_t tsdbCacheGetCapacity(SVnode *pVnode); +size_t tsdbCacheGetUsage(SVnode *pVnode); +int32_t tsdbCacheGetElems(SVnode *pVnode); // tq typedef struct SMetaTableInfo { @@ -264,7 +266,7 @@ int32_t tqReaderSetTbUidList(STqReader *pReader, const SArray *tbUidList); int32_t tqReaderAddTbUidList(STqReader *pReader, const SArray *tbUidList); int32_t tqReaderRemoveTbUidList(STqReader *pReader, const SArray *tbUidList); -int32_t tqSeekVer(STqReader *pReader, int64_t ver, const char* id); +int32_t tqSeekVer(STqReader *pReader, int64_t ver, const char *id); int32_t tqNextBlock(STqReader *pReader, SFetchRet *ret); int32_t tqReaderSetSubmitReq2(STqReader *pReader, void *msgStr, int32_t msgLen, int64_t ver); diff --git a/source/dnode/vnode/src/inc/tq.h b/source/dnode/vnode/src/inc/tq.h index 792fed2309e95d89fdf0616cd4f28e9bf58019e6..9037644602034819fd1da260c1cef02b7ae29a97 100644 --- a/source/dnode/vnode/src/inc/tq.h +++ b/source/dnode/vnode/src/inc/tq.h @@ -79,63 +79,48 @@ typedef struct { } STqExecDb; typedef struct { - int8_t subType; - - STqReader* pExecReader; - qTaskInfo_t task; + int8_t subType; + STqReader* pExecReader; + qTaskInfo_t task; union { STqExecCol execCol; STqExecTb execTb; STqExecDb execDb; }; - int32_t numOfCols; // number of out pout column, temporarily used + int32_t numOfCols; // number of out pout column, temporarily used } STqExecHandle; typedef struct { - // info - char subKey[TSDB_SUBSCRIBE_KEY_LEN]; - int64_t consumerId; - int32_t epoch; - int8_t fetchMeta; - - int64_t snapshotVer; - - SWalReader* pWalReader; - - SWalRef* pRef; - - // push - STqPushHandle pushHandle; - - // exec - STqExecHandle execHandle; - + char subKey[TSDB_SUBSCRIBE_KEY_LEN]; + int64_t consumerId; + int32_t epoch; + int8_t fetchMeta; + int64_t snapshotVer; + SWalReader* pWalReader; + SWalRef* pRef; + STqPushHandle pushHandle; // push + STqExecHandle execHandle; // exec } STqHandle; typedef struct { - SMqDataRsp dataRsp; + SMqDataRsp* pDataRsp; char subKey[TSDB_SUBSCRIBE_KEY_LEN]; - SRpcHandleInfo pInfo; + SRpcHandleInfo info; } STqPushEntry; struct STQ { - SVnode* pVnode; - char* path; - int64_t walLogLastVer; - - SRWLatch pushLock; - - SHashObj* pPushMgr; // consumerId -> STqPushEntry - SHashObj* pHandle; // subKey -> STqHandle - SHashObj* pCheckInfo; // topic -> SAlterCheckInfo - + SVnode* pVnode; + char* path; + int64_t walLogLastVer; + SRWLatch lock; + SHashObj* pPushMgr; // consumerId -> STqPushEntry + SHashObj* pHandle; // subKey -> STqHandle + SHashObj* pCheckInfo; // topic -> SAlterCheckInfo STqOffsetStore* pOffsetStore; - - TDB* pMetaDB; - TTB* pExecStore; - TTB* pCheckStore; - - SStreamMeta* pStreamMeta; + TDB* pMetaDB; + TTB* pExecStore; + TTB* pCheckStore; + SStreamMeta* pStreamMeta; }; typedef struct { @@ -151,13 +136,12 @@ int32_t tDecodeSTqHandle(SDecoder* pDecoder, STqHandle* pHandle); // tqRead int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMetaRsp* pMetaRsp, STqOffsetVal* offset); int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* pOffset); -int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** pHeadWithCkSum); +int32_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** pHeadWithCkSum, uint64_t reqId); // tqExec -int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp); -// int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp* pRsp); +int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp, int32_t* totalRows); int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision); -int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp); +int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp, int32_t type); int32_t tqPushDataRsp(STQ* pTq, STqPushEntry* pPushEntry); // tqMeta @@ -174,7 +158,7 @@ typedef struct { int32_t size; } STqOffsetHead; -STqOffsetStore* tqOffsetOpen(); +STqOffsetStore* tqOffsetOpen(STQ* pTq); void tqOffsetClose(STqOffsetStore*); STqOffset* tqOffsetRead(STqOffsetStore* pStore, const char* subscribeKey); int32_t tqOffsetWrite(STqOffsetStore* pStore, const STqOffset* pOffset); diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index b2e1e8ab34f627e17d431e4b0624bfa3166fdd73..0c4ada2cb1306c4c46d37d652e995dd8bf3f3904 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -224,6 +224,8 @@ int32_t tsdbTbDataIterCreate(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, void *tsdbTbDataIterDestroy(STbDataIter *pIter); void tsdbTbDataIterOpen(STbData *pTbData, TSDBKEY *pFrom, int8_t backward, STbDataIter *pIter); bool tsdbTbDataIterNext(STbDataIter *pIter); +void tsdbMemTableCountRows(SMemTable *pMemTable, SHashObj* pTableMap, int64_t *rowsNum); + // STbData int32_t tsdbGetNRowsInTbData(STbData *pTbData); // tsdbFile.c ============================================================================================== @@ -687,6 +689,8 @@ typedef struct SSttBlockLoadInfo { STSchema *pSchema; int16_t *colIds; int32_t numOfCols; + bool checkRemainingRow; + bool isLast; bool sttBlockLoaded; int32_t numOfStt; @@ -706,6 +710,7 @@ typedef struct SMergeTree { bool destroyLoadInfo; SSttBlockLoadInfo *pLoadInfo; const char *idStr; + bool ignoreEarlierTs; } SMergeTree; typedef struct { @@ -748,9 +753,10 @@ struct SDiskDataBuilder { int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFReader, uint64_t suid, uint64_t uid, STimeWindow *pTimeWindow, SVersionRange *pVerRange, SSttBlockLoadInfo *pBlockLoadInfo, - bool destroyLoadInfo, const char *idStr); + bool destroyLoadInfo, const char *idStr, bool strictTimeRange); void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter); bool tMergeTreeNext(SMergeTree *pMTree); +bool tMergeTreeIgnoreEarlierTs(SMergeTree *pMTree); TSDBROW tMergeTreeGetRow(SMergeTree *pMTree); void tMergeTreeClose(SMergeTree *pMTree); diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 0dff2420ec4013c251de993c8195273dc29c91ac..253d5aebcec2353c1e951c5399256a23681f6850 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -187,11 +187,15 @@ int32_t tsdbDeleteTableData(STsdb* pTsdb, int64_t version, tb_uid_t suid, tb_uid int32_t tsdbSetKeepCfg(STsdb* pTsdb, STsdbCfg* pCfg); // tq -int tqInit(); -void tqCleanUp(); -STQ* tqOpen(const char* path, SVnode* pVnode); -void tqClose(STQ*); -int tqPushMsg(STQ*, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver); +int tqInit(); +void tqCleanUp(); +STQ* tqOpen(const char* path, SVnode* pVnode); +void tqClose(STQ*); +int tqPushMsg(STQ*, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver); +int tqRegisterPushEntry(STQ* pTq, void* pHandle, const SMqPollReq* pRequest, SRpcMsg* pRpcMsg, SMqDataRsp* pDataRsp, + int32_t type); +int tqUnregisterPushEntry(STQ* pTq, const char* pKey, int32_t keyLen, uint64_t consumerId, bool rspConsumer); + int tqCommit(STQ*); int32_t tqUpdateTbUidList(STQ* pTq, const SArray* tbUidList, bool isAdd); int32_t tqCheckColModifiable(STQ* pTq, int64_t tbUid, int32_t colId); diff --git a/source/dnode/vnode/src/meta/metaCache.c b/source/dnode/vnode/src/meta/metaCache.c index 05889e47673aa3ed41f5c55693dce0f2d63fa407..9501bf4b8ef6055f2e4f28242f8f259896623725 100644 --- a/source/dnode/vnode/src/meta/metaCache.c +++ b/source/dnode/vnode/src/meta/metaCache.c @@ -14,6 +14,7 @@ */ #include "meta.h" +#define TAG_FILTER_RES_KEY_LEN 32 #define META_CACHE_BASE_BUCKET 1024 #define META_CACHE_STATS_BUCKET 16 @@ -34,7 +35,6 @@ typedef struct SMetaStbStatsEntry { typedef struct STagFilterResEntry { SList list; // the linked list of md5 digest, extracted from the serialized tag query condition uint32_t hitTimes; // queried times for current super table - uint32_t accTime; } STagFilterResEntry; struct SMetaCache { @@ -455,26 +455,37 @@ static int checkAllEntriesInCache(const STagFilterResEntry* pEntry, SArray* pInv return 0; } +static FORCE_INLINE void setMD5DigestInKey(uint64_t* pBuf, const char* key, int32_t keyLen) { +// ASSERT(keyLen == sizeof(int64_t) * 2); + memcpy(&pBuf[2], key, keyLen); +} + +// the format of key: +// hash table address(8bytes) + suid(8bytes) + MD5 digest(16bytes) +static void initCacheKey(uint64_t* buf, const SHashObj* pHashMap, uint64_t suid, const char* key, int32_t keyLen) { + buf[0] = (uint64_t) pHashMap; + buf[1] = suid; + setMD5DigestInKey(buf, key, keyLen); + ASSERT(keyLen == sizeof(uint64_t) * 2); +} + int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pKey, int32_t keyLen, SArray* pList1, bool* acquireRes) { + int32_t vgId = TD_VID(pMeta->pVnode); + // generate the composed key for LRU cache SLRUCache* pCache = pMeta->pCache->sTagFilterResCache.pUidResCache; SHashObj* pTableMap = pMeta->pCache->sTagFilterResCache.pTableEntry; TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock; - uint64_t buf[4]; - *acquireRes = 0; - - buf[0] = (uint64_t)pTableMap; - buf[1] = suid; - memcpy(&buf[2], pKey, keyLen); + uint64_t key[4]; + initCacheKey(key, pTableMap, suid, (const char*)pKey, keyLen); taosThreadMutexLock(pLock); pMeta->pCache->sTagFilterResCache.accTimes += 1; - int32_t len = keyLen + sizeof(uint64_t) * 2; - LRUHandle* pHandle = taosLRUCacheLookup(pCache, buf, len); + LRUHandle* pHandle = taosLRUCacheLookup(pCache, key, TAG_FILTER_RES_KEY_LEN); if (pHandle == NULL) { taosThreadMutexUnlock(pLock); return TSDB_CODE_SUCCESS; @@ -499,7 +510,7 @@ int32_t metaGetCachedTableUidList(SMeta* pMeta, tb_uid_t suid, const uint8_t* pK uint32_t acc = pMeta->pCache->sTagFilterResCache.accTimes; if ((*pEntry)->hitTimes % 5000 == 0 && (*pEntry)->hitTimes > 0) { - metaInfo("cache hit:%d, total acc:%d, rate:%.2f", (*pEntry)->hitTimes, acc, ((double)(*pEntry)->hitTimes) / acc); + metaInfo("vgId:%d cache hit:%d, total acc:%d, rate:%.2f", vgId, (*pEntry)->hitTimes, acc, ((double)(*pEntry)->hitTimes) / acc); } taosLRUCacheRelease(pCache, pHandle, false); @@ -563,10 +574,13 @@ static int32_t addNewEntry(SHashObj* pTableEntry, const void* pKey, int32_t keyL // check both the payload size and selectivity ratio int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int32_t keyLen, void* pPayload, int32_t payloadLen, double selectivityRatio) { + int32_t code = 0; + int32_t vgId = TD_VID(pMeta->pVnode); + if (selectivityRatio > tsSelectivityRatio) { metaDebug("vgId:%d, suid:%" PRIu64 " failed to add to uid list cache, due to selectivity ratio %.2f less than threshold %.2f", - TD_VID(pMeta->pVnode), suid, selectivityRatio, tsSelectivityRatio); + vgId, suid, selectivityRatio, tsSelectivityRatio); taosMemoryFree(pPayload); return TSDB_CODE_SUCCESS; } @@ -574,7 +588,7 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int if (payloadLen > tsTagFilterResCacheSize) { metaDebug("vgId:%d, suid:%" PRIu64 " failed to add to uid list cache, due to payload length %d greater than threshold %d", - TD_VID(pMeta->pVnode), suid, payloadLen, tsTagFilterResCacheSize); + vgId, suid, payloadLen, tsTagFilterResCacheSize); taosMemoryFree(pPayload); return TSDB_CODE_SUCCESS; } @@ -583,26 +597,17 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int SHashObj* pTableEntry = pMeta->pCache->sTagFilterResCache.pTableEntry; TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock; - // the format of key: - // hash table address(8bytes) + suid(8bytes) + MD5 digest(16bytes) - - uint64_t buf[4] = {0}; - buf[0] = (uint64_t)pTableEntry; - buf[1] = suid; - memcpy(&buf[2], pKey, keyLen); - ASSERT(keyLen == 16); + uint64_t key[4] = {0}; + initCacheKey(key, pTableEntry, suid, pKey, keyLen); - int32_t code = 0; taosThreadMutexLock(pLock); - STagFilterResEntry** pEntry = taosHashGet(pTableEntry, &suid, sizeof(uint64_t)); if (pEntry == NULL) { code = addNewEntry(pTableEntry, pKey, keyLen, suid); if (code != TSDB_CODE_SUCCESS) { goto _end; } - } else { - // check if it exists or not + } else { // check if it exists or not size_t size = listNEles(&(*pEntry)->list); if (size == 0) { tdListAppend(&(*pEntry)->list, pKey); @@ -620,12 +625,11 @@ int32_t metaUidFilterCachePut(SMeta* pMeta, uint64_t suid, const void* pKey, int } // add to cache. - taosLRUCacheInsert(pCache, buf, sizeof(uint64_t) * 2 + keyLen, pPayload, payloadLen, freePayload, NULL, + taosLRUCacheInsert(pCache, key, TAG_FILTER_RES_KEY_LEN, pPayload, payloadLen, freePayload, NULL, TAOS_LRU_PRIORITY_LOW); _end: taosThreadMutexUnlock(pLock); - - metaDebug("vgId:%d, suid:%" PRIu64 " list cache added into cache, total:%d, tables:%d", TD_VID(pMeta->pVnode), suid, + metaDebug("vgId:%d, suid:%" PRIu64 " list cache added into cache, total:%d, tables:%d", vgId, suid, (int32_t)taosLRUCacheGetUsage(pCache), taosHashGetSize(pTableEntry)); return code; @@ -633,33 +637,36 @@ _end: // remove the lru cache that are expired due to the tags value update, or creating, or dropping, of child tables int32_t metaUidCacheClear(SMeta* pMeta, uint64_t suid) { - int32_t keyLen = sizeof(uint64_t) * 3; - uint64_t p[4] = {0}; + uint64_t p[4] = {0}; + int32_t vgId = TD_VID(pMeta->pVnode); + SHashObj* pEntryHashMap = pMeta->pCache->sTagFilterResCache.pTableEntry; - p[0] = (uint64_t)pMeta->pCache->sTagFilterResCache.pTableEntry; - p[1] = suid; + uint64_t dummy[2] = {0}; + initCacheKey(p, pEntryHashMap, suid, (char*) &dummy[0], 16); TdThreadMutex* pLock = &pMeta->pCache->sTagFilterResCache.lock; - taosThreadMutexLock(pLock); - STagFilterResEntry** pEntry = taosHashGet(pMeta->pCache->sTagFilterResCache.pTableEntry, &suid, sizeof(uint64_t)); + + STagFilterResEntry** pEntry = taosHashGet(pEntryHashMap, &suid, sizeof(uint64_t)); if (pEntry == NULL || listNEles(&(*pEntry)->list) == 0) { taosThreadMutexUnlock(pLock); return TSDB_CODE_SUCCESS; } + (*pEntry)->hitTimes = 0; + SListIter iter = {0}; tdListInitIter(&(*pEntry)->list, &iter, TD_LIST_FORWARD); SListNode* pNode = NULL; while ((pNode = tdListNext(&iter)) != NULL) { - memcpy(&p[2], pNode->data, 16); - taosLRUCacheErase(pMeta->pCache->sTagFilterResCache.pUidResCache, p, keyLen); + setMD5DigestInKey(p, pNode->data, 2 * sizeof(uint64_t)); + taosLRUCacheErase(pMeta->pCache->sTagFilterResCache.pUidResCache, p, TAG_FILTER_RES_KEY_LEN); } - (*pEntry)->hitTimes = 0; tdListEmpty(&(*pEntry)->list); - taosThreadMutexUnlock(pLock); + + metaDebug("vgId:%d suid:%"PRId64" cached related tag filter uid list cleared", vgId, suid); return TSDB_CODE_SUCCESS; } diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index d3382373144aaef5efb72dce65e8d602e0064317..2359a165b7e131bde308fa1d68c7ba8d1f0c4a87 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -14,6 +14,8 @@ */ #include "meta.h" +#include "osMemory.h" +#include "tencode.h" void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags) { memset(pReader, 0, sizeof(*pReader)); @@ -334,7 +336,7 @@ int32_t metaTbCursorNext(SMTbCursor *pTbCur, ETableType jumpTableType) { return 0; } -int32_t metaTbCursorPrev(SMTbCursor *pTbCur) { +int32_t metaTbCursorPrev(SMTbCursor *pTbCur, ETableType jumpTableType) { int ret; void *pBuf; STbCfg tbCfg; @@ -348,7 +350,7 @@ int32_t metaTbCursorPrev(SMTbCursor *pTbCur) { tDecoderClear(&pTbCur->mr.coder); metaGetTableEntryByVersion(&pTbCur->mr, ((SUidIdxVal *)pTbCur->pVal)[0].version, *(tb_uid_t *)pTbCur->pKey); - if (pTbCur->mr.me.type == TSDB_SUPER_TABLE) { + if (pTbCur->mr.me.type == jumpTableType) { continue; } @@ -1235,9 +1237,14 @@ END: return 0; } int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) { - int32_t ret = 0; - char *buf = NULL; - + SMetaEntry oStbEntry = {0}; + int32_t ret = -1; + char *buf = NULL; + void *pData = NULL; + int nData = 0; + + SDecoder dc = {0}; + STbDbKey tbDbKey = {0}; STagIdxKey *pKey = NULL; int32_t nKey = 0; @@ -1249,8 +1256,34 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) { pCursor->type = param->type; metaRLock(pMeta); + + if (tdbTbGet(pMeta->pUidIdx, ¶m->suid, sizeof(tb_uid_t), &pData, &nData) != 0) { + goto END; + } + tbDbKey.uid = param->suid; + tbDbKey.version = ((SUidIdxVal *)pData)[0].version; + tdbTbGet(pMeta->pTbDb, &tbDbKey, sizeof(tbDbKey), &pData, &nData); + + tDecoderInit(&dc, pData, nData); + ret = metaDecodeEntry(&dc, &oStbEntry); + + if (oStbEntry.stbEntry.schemaTag.pSchema == NULL || oStbEntry.stbEntry.schemaTag.pSchema == NULL) { + ret = -1; + goto END; + } + ret = -1; + for (int i = 0; i < oStbEntry.stbEntry.schemaTag.nCols; i++) { + SSchema *schema = oStbEntry.stbEntry.schemaTag.pSchema + i; + if (schema->colId == param->cid && param->type == schema->type && (IS_IDX_ON(schema) || i == 0)) { + ret = 0; + } + } + if (ret != 0) { + goto END; + } + ret = tdbTbcOpen(pMeta->pTagIdx, &pCursor->pCur, NULL); - if (ret < 0) { + if (ret != 0) { goto END; } @@ -1271,6 +1304,7 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) { maxSize = 4 * nTagData + 1; buf = taosMemoryCalloc(1, maxSize); if (false == taosMbsToUcs4(tagData, nTagData, (TdUcs4 *)buf, maxSize, &maxSize)) { + ret = -1; goto END; } @@ -1288,8 +1322,10 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) { if (ret != 0) { goto END; } + int cmp = 0; - if (tdbTbcMoveTo(pCursor->pCur, pKey, nKey, &cmp) < 0) { + ret = tdbTbcMoveTo(pCursor->pCur, pKey, nKey, &cmp); + if (ret != 0) { goto END; } @@ -1356,6 +1392,10 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) { END: if (pCursor->pMeta) metaULock(pCursor->pMeta); if (pCursor->pCur) tdbTbcClose(pCursor->pCur); + if (oStbEntry.pBuf) taosMemoryFree(oStbEntry.pBuf); + tDecoderClear(&dc); + tdbFree(pData); + taosMemoryFree(buf); taosMemoryFree(pKey); diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 99e171dde1785f7aab55ab0f97b28f248744545d..c75c675ec39946e4f23d005a8050d35b52eca762 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -282,7 +282,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat .initTqReader = 1, .pStateBackend = pStreamState, }; - pRSmaInfo->taskInfo[idx] = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle); + pRSmaInfo->taskInfo[idx] = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle, TD_VID(pVnode)); if (!pRSmaInfo->taskInfo[idx]) { terrno = TSDB_CODE_RSMA_QTASKINFO_CREATE; return TSDB_CODE_FAILED; @@ -669,7 +669,7 @@ static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSma #endif for (int32_t i = 0; i < taosArrayGetSize(pResList); ++i) { SSDataBlock *output = taosArrayGetP(pResList, i); - smaDebug("result block, uid:%" PRIu64 ", groupid:%" PRIu64 ", rows:%d", output->info.id.uid, + smaDebug("result block, uid:%" PRIu64 ", groupid:%" PRIu64 ", rows:%" PRId64, output->info.id.uid, output->info.id.groupId, output->info.rows); STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb[0] : pSma->pRSmaTsdb[1]); @@ -864,7 +864,7 @@ static int32_t tdCloneQTaskInfo(SSma *pSma, qTaskInfo_t dstTaskInfo, qTaskInfo_t TSDB_CHECK_CODE(code, lino, _exit); } - dstTaskInfo = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle); + dstTaskInfo = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle, TD_VID(pVnode)); if (!dstTaskInfo) { code = TSDB_CODE_RSMA_QTASKINFO_CREATE; TSDB_CHECK_CODE(code, lino, _exit); diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index a4d55010faefdaf05f22e5652846244f8e13a0dd..1364a61929be4f37606bb96580cce6fb5d34d0d6 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -55,7 +55,7 @@ void tqCleanUp() { } } -static void destroySTqHandle(void* data) { +static void destroyTqHandle(void* data) { STqHandle* pData = (STqHandle*)data; qDestroyTask(pData->execHandle.task); if (pData->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { @@ -72,7 +72,13 @@ static void destroySTqHandle(void* data) { static void tqPushEntryFree(void* data) { STqPushEntry* p = *(void**)data; - tDeleteSMqDataRsp(&p->dataRsp); + if (p->pDataRsp->head.mqMsgType == TMQ_MSG_TYPE__POLL_RSP) { + tDeleteSMqDataRsp(p->pDataRsp); + } else if (p->pDataRsp->head.mqMsgType == TMQ_MSG_TYPE__TAOSX_RSP) { + tDeleteSTaosxRsp((STaosxRsp*)p->pDataRsp); + } + + taosMemoryFree(p->pDataRsp); taosMemoryFree(p); } @@ -87,9 +93,9 @@ STQ* tqOpen(const char* path, SVnode* pVnode) { pTq->walLogLastVer = pVnode->pWal->vers.lastVer; pTq->pHandle = taosHashInit(64, MurmurHash3_32, true, HASH_ENTRY_LOCK); - taosHashSetFreeFp(pTq->pHandle, destroySTqHandle); + taosHashSetFreeFp(pTq->pHandle, destroyTqHandle); - taosInitRWLatch(&pTq->pushLock); + taosInitRWLatch(&pTq->lock); pTq->pPushMgr = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK); taosHashSetFreeFp(pTq->pPushMgr, tqPushEntryFree); @@ -170,24 +176,16 @@ int32_t tqSendMetaPollRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, return 0; } -int32_t tqPushDataRsp(STQ* pTq, STqPushEntry* pPushEntry) { - SMqDataRsp* pRsp = &pPushEntry->dataRsp; - -#if 0 - A(taosArrayGetSize(pRsp->blockData) == pRsp->blockNum); - A(taosArrayGetSize(pRsp->blockDataLen) == pRsp->blockNum); - - A(!pRsp->withSchema); - A(taosArrayGetSize(pRsp->blockSchema) == 0); - - if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) { - A(pRsp->rspOffset.version > pRsp->reqOffset.version); - } -#endif - +static int32_t doSendDataRsp(const SRpcHandleInfo* pRpcHandleInfo, const SMqDataRsp* pRsp, int32_t epoch, + int64_t consumerId, int32_t type) { int32_t len = 0; int32_t code = 0; - tEncodeSize(tEncodeSMqDataRsp, pRsp, len, code); + + if (type == TMQ_MSG_TYPE__POLL_RSP) { + tEncodeSize(tEncodeSMqDataRsp, pRsp, len, code); + } else if (type == TMQ_MSG_TYPE__TAOSX_RSP) { + tEncodeSize(tEncodeSTaosxRsp, (STaosxRsp*)pRsp, len, code); + } if (code < 0) { return -1; @@ -199,154 +197,69 @@ int32_t tqPushDataRsp(STQ* pTq, STqPushEntry* pPushEntry) { return -1; } - memcpy(buf, &pPushEntry->dataRsp.head, sizeof(SMqRspHead)); + ((SMqRspHead*)buf)->mqMsgType = type; + ((SMqRspHead*)buf)->epoch = epoch; + ((SMqRspHead*)buf)->consumerId = consumerId; void* abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead)); SEncoder encoder = {0}; tEncoderInit(&encoder, abuf, len); - tEncodeSMqDataRsp(&encoder, pRsp); - tEncoderClear(&encoder); - - SRpcMsg rsp = { - .info = pPushEntry->pInfo, - .pCont = buf, - .contLen = tlen, - .code = 0, - }; - - tmsgSendRsp(&rsp); - - if (tqDebugFlag & DEBUG_DEBUG) { - char buf1[80] = {0}; - char buf2[80] = {0}; - tFormatOffset(buf1, tListLen(buf1), &pRsp->reqOffset); - tFormatOffset(buf2, tListLen(buf2), &pRsp->rspOffset); - tqDebug("vgId:%d, from consumer:0x%" PRIx64 " (epoch %d) push rsp, block num: %d, req:%s, rsp:%s", - TD_VID(pTq->pVnode), pRsp->head.consumerId, pRsp->head.epoch, pRsp->blockNum, buf1, buf2); - } - - return 0; -} - -int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp) { -#if 0 - A(taosArrayGetSize(pRsp->blockData) == pRsp->blockNum); - A(taosArrayGetSize(pRsp->blockDataLen) == pRsp->blockNum); - - A(!pRsp->withSchema); - A(taosArrayGetSize(pRsp->blockSchema) == 0); - if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) { - if (pRsp->blockNum > 0) { - A(pRsp->rspOffset.version > pRsp->reqOffset.version); - } else { - A(pRsp->rspOffset.version >= pRsp->reqOffset.version); - } - } -#endif - - int32_t len = 0; - int32_t code = 0; - tEncodeSize(tEncodeSMqDataRsp, pRsp, len, code); - if (code < 0) { - return -1; - } - int32_t tlen = sizeof(SMqRspHead) + len; - void* buf = rpcMallocCont(tlen); - if (buf == NULL) { - return -1; + if (type == TMQ_MSG_TYPE__POLL_RSP) { + tEncodeSMqDataRsp(&encoder, pRsp); + } else if (type == TMQ_MSG_TYPE__TAOSX_RSP) { + tEncodeSTaosxRsp(&encoder, (STaosxRsp*)pRsp); } - ((SMqRspHead*)buf)->mqMsgType = TMQ_MSG_TYPE__POLL_RSP; - ((SMqRspHead*)buf)->epoch = pReq->epoch; - ((SMqRspHead*)buf)->consumerId = pReq->consumerId; - - void* abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead)); - - SEncoder encoder = {0}; - tEncoderInit(&encoder, abuf, len); - tEncodeSMqDataRsp(&encoder, pRsp); tEncoderClear(&encoder); SRpcMsg rsp = { - .info = pMsg->info, + .info = *pRpcHandleInfo, .pCont = buf, .contLen = tlen, .code = 0, }; + tmsgSendRsp(&rsp); + return 0; +} - if (tqDebugFlag & DEBUG_DEBUG) { - char buf1[80] = {0}; - char buf2[80] = {0}; - tFormatOffset(buf1, 80, &pRsp->reqOffset); - tFormatOffset(buf2, 80, &pRsp->rspOffset); - tqDebug("vgId:%d consumer:0x%" PRIx64 " (epoch %d), block num:%d, req:%s, rsp:%s", TD_VID(pTq->pVnode), - pReq->consumerId, pReq->epoch, pRsp->blockNum, buf1, buf2); - } +int32_t tqPushDataRsp(STQ* pTq, STqPushEntry* pPushEntry) { + SMqDataRsp* pRsp = pPushEntry->pDataRsp; + SMqRspHead* pHeader = &pPushEntry->pDataRsp->head; + doSendDataRsp(&pPushEntry->info, pRsp, pHeader->epoch, pHeader->consumerId, pHeader->mqMsgType); + + char buf1[80] = {0}; + char buf2[80] = {0}; + tFormatOffset(buf1, tListLen(buf1), &pRsp->reqOffset); + tFormatOffset(buf2, tListLen(buf2), &pRsp->rspOffset); + tqDebug("vgId:%d, from consumer:0x%" PRIx64 " (epoch %d) push rsp, block num: %d, req:%s, rsp:%s", + TD_VID(pTq->pVnode), pRsp->head.consumerId, pRsp->head.epoch, pRsp->blockNum, buf1, buf2); return 0; } -int32_t tqSendTaosxRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const STaosxRsp* pRsp) { +int32_t tqSendDataRsp(STQ* pTq, const SRpcMsg* pMsg, const SMqPollReq* pReq, const SMqDataRsp* pRsp, int32_t type) { #if 0 A(taosArrayGetSize(pRsp->blockData) == pRsp->blockNum); A(taosArrayGetSize(pRsp->blockDataLen) == pRsp->blockNum); - if (pRsp->withSchema) { - A(taosArrayGetSize(pRsp->blockSchema) == pRsp->blockNum); - } else { - A(taosArrayGetSize(pRsp->blockSchema) == 0); - } + A(!pRsp->withSchema); + A(taosArrayGetSize(pRsp->blockSchema) == 0); if (pRsp->reqOffset.type == TMQ_OFFSET__LOG) { - if (pRsp->blockNum > 0) { - A(pRsp->rspOffset.version > pRsp->reqOffset.version); - } else { - A(pRsp->rspOffset.version >= pRsp->reqOffset.version); - } + A(pRsp->rspOffset.version > pRsp->reqOffset.version); } #endif + doSendDataRsp(&pMsg->info, pRsp, pReq->epoch, pReq->consumerId, type); - int32_t len = 0; - int32_t code = 0; - tEncodeSize(tEncodeSTaosxRsp, pRsp, len, code); - if (code < 0) { - return -1; - } - int32_t tlen = sizeof(SMqRspHead) + len; - void* buf = rpcMallocCont(tlen); - if (buf == NULL) { - return -1; - } - - ((SMqRspHead*)buf)->mqMsgType = TMQ_MSG_TYPE__TAOSX_RSP; - ((SMqRspHead*)buf)->epoch = pReq->epoch; - ((SMqRspHead*)buf)->consumerId = pReq->consumerId; + char buf1[80] = {0}; + char buf2[80] = {0}; + tFormatOffset(buf1, 80, &pRsp->reqOffset); + tFormatOffset(buf2, 80, &pRsp->rspOffset); - void* abuf = POINTER_SHIFT(buf, sizeof(SMqRspHead)); - - SEncoder encoder = {0}; - tEncoderInit(&encoder, abuf, len); - tEncodeSTaosxRsp(&encoder, pRsp); - tEncoderClear(&encoder); - - SRpcMsg rsp = { - .info = pMsg->info, - .pCont = buf, - .contLen = tlen, - .code = 0, - }; - tmsgSendRsp(&rsp); - - if (tqDebugFlag & DEBUG_DEBUG) { - char buf1[80] = {0}; - char buf2[80] = {0}; - tFormatOffset(buf1, 80, &pRsp->reqOffset); - tFormatOffset(buf2, 80, &pRsp->rspOffset); - tqDebug("taosx rsp, vgId:%d, from consumer:0x%" PRIx64 " (epoch %d) send rsp, numOfBlks:%d, req:%s, rsp:%s", - TD_VID(pTq->pVnode), pReq->consumerId, pReq->epoch, pRsp->blockNum, buf1, buf2); - } + tqDebug("vgId:%d consumer:0x%" PRIx64 " (epoch %d) send rsp, block num:%d, req:%s, rsp:%s, reqId:0x%" PRIx64, + TD_VID(pTq->pVnode), pReq->consumerId, pReq->epoch, pRsp->blockNum, buf1, buf2, pReq->reqId); return 0; } @@ -358,6 +271,7 @@ static FORCE_INLINE bool tqOffsetLessOrEqual(const STqOffset* pLeft, const STqOf int32_t tqProcessOffsetCommitReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) { STqOffset offset = {0}; + int32_t vgId = TD_VID(pTq->pVnode); SDecoder decoder; tDecoderInit(&decoder, (uint8_t*)msg, msgLen); @@ -369,10 +283,10 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, int64_t sversion, char* msg, int32_t if (offset.val.type == TMQ_OFFSET__SNAPSHOT_DATA || offset.val.type == TMQ_OFFSET__SNAPSHOT_META) { tqDebug("receive offset commit msg to %s on vgId:%d, offset(type:snapshot) uid:%" PRId64 ", ts:%" PRId64, - offset.subKey, TD_VID(pTq->pVnode), offset.val.uid, offset.val.ts); + offset.subKey, vgId, offset.val.uid, offset.val.ts); } else if (offset.val.type == TMQ_OFFSET__LOG) { - tqDebug("receive offset commit msg to %s on vgId:%d, offset(type:log) version:%" PRId64, offset.subKey, - TD_VID(pTq->pVnode), offset.val.version); + tqDebug("receive offset commit msg to %s on vgId:%d, offset(type:log) version:%" PRId64, offset.subKey, vgId, + offset.val.version); if (offset.val.version + 1 == sversion) { offset.val.version += 1; } @@ -449,9 +363,7 @@ static int32_t tqInitDataRsp(SMqDataRsp* pRsp, const SMqPollReq* pReq, int8_t su } #endif - /*A(subType == TOPIC_SUB_TYPE__COLUMN);*/ pRsp->withSchema = false; - return 0; } @@ -472,260 +384,238 @@ static int32_t tqInitTaosxRsp(STaosxRsp* pRsp, const SMqPollReq* pReq) { return 0; } -int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { - SMqPollReq req = {0}; - int32_t code = 0; - STqOffsetVal fetchOffsetNew; - SWalCkHead* pCkHead = NULL; +static int32_t extractResetOffsetVal(STqOffsetVal* pOffsetVal, STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, + SRpcMsg* pMsg, bool* pBlockReturned) { + uint64_t consumerId = pRequest->consumerId; + STqOffsetVal reqOffset = pRequest->reqOffset; + STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, pRequest->subKey); + int32_t vgId = TD_VID(pTq->pVnode); - if (tDeserializeSMqPollReq(pMsg->pCont, pMsg->contLen, &req) < 0) { - tqError("tDeserializeSMqPollReq %d failed", pMsg->contLen); - return -1; - } + *pBlockReturned = false; - int64_t consumerId = req.consumerId; - int32_t reqEpoch = req.epoch; - STqOffsetVal reqOffset = req.reqOffset; - - // 1. find handle - STqHandle* pHandle = taosHashGet(pTq->pHandle, req.subKey, strlen(req.subKey)); - if (pHandle == NULL) { - tqError("tmq poll: consumer:0x%" PRIx64 " vgId:%d, subkey %s not found", consumerId, TD_VID(pTq->pVnode), - req.subKey); - return -1; - } + // In this vnode, data has been polled by consumer for this topic, so let's continue from the last offset value. + if (pOffset != NULL) { + *pOffsetVal = pOffset->val; - // 2. check rebalance - if (pHandle->consumerId != consumerId) { - tqDebug("ERROR tmq poll: consumer:0x%" PRIx64 " vgId:%d, subkey %s, mismatch for saved handle consumer:0x%" PRIx64, - consumerId, TD_VID(pTq->pVnode), req.subKey, pHandle->consumerId); - terrno = TSDB_CODE_TMQ_CONSUMER_MISMATCH; - return -1; - } - - // update epoch if need - int32_t savedEpoch = atomic_load_32(&pHandle->epoch); - while (savedEpoch < reqEpoch) { - tqDebug("tmq poll: consumer:0x%" PRIx64 " epoch update from %d to %d by poll req", consumerId, savedEpoch, - reqEpoch); - savedEpoch = atomic_val_compare_exchange_32(&pHandle->epoch, savedEpoch, reqEpoch); - } - - char buf[80]; - tFormatOffset(buf, 80, &reqOffset); - tqDebug("tmq poll: consumer:0x%" PRIx64 " (epoch %d), subkey %s, recv poll req vgId:%d, req:%s", consumerId, - req.epoch, pHandle->subKey, TD_VID(pTq->pVnode), buf); - - // 2.reset offset if needed - if (reqOffset.type > 0) { - fetchOffsetNew = reqOffset; + char formatBuf[80]; + tFormatOffset(formatBuf, 80, pOffsetVal); + tqDebug("tmq poll: consumer:0x%" PRIx64 + ", subkey %s, vgId:%d, existed offset found, offset reset to %s and continue. reqId:0x%" PRIx64, + consumerId, pHandle->subKey, vgId, formatBuf, pRequest->reqId); + return 0; } else { - STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, req.subKey); - if (pOffset != NULL) { - fetchOffsetNew = pOffset->val; - char formatBuf[80]; - tFormatOffset(formatBuf, 80, &fetchOffsetNew); - tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vg %d, offset reset to %s", consumerId, pHandle->subKey, - TD_VID(pTq->pVnode), formatBuf); - } else { - if (reqOffset.type == TMQ_OFFSET__RESET_EARLIEAST) { - if (req.useSnapshot) { - if (pHandle->fetchMeta) { - tqOffsetResetToMeta(&fetchOffsetNew, 0); - } else { - tqOffsetResetToData(&fetchOffsetNew, 0, 0); - } + // no poll occurs in this vnode for this topic, let's seek to the right offset value. + if (reqOffset.type == TMQ_OFFSET__RESET_EARLIEAST) { + if (pRequest->useSnapshot) { + tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey:%s, vgId:%d, (earliest) set offset to be snapshot", + consumerId, pHandle->subKey, vgId); + + if (pHandle->fetchMeta) { + tqOffsetResetToMeta(pOffsetVal, 0); } else { - pHandle->pRef = walRefFirstVer(pTq->pVnode->pWal, pHandle->pRef); - if (pHandle->pRef == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return -1; - } - tqOffsetResetToLog(&fetchOffsetNew, pHandle->pRef->refVer - 1); + tqOffsetResetToData(pOffsetVal, 0, 0); } - } else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) { - if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { - SMqDataRsp dataRsp = {0}; - tqInitDataRsp(&dataRsp, &req, pHandle->execHandle.subType); - - tqOffsetResetToLog(&dataRsp.rspOffset, walGetLastVer(pTq->pVnode->pWal)); - tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, offset reset to %" PRId64, consumerId, - pHandle->subKey, TD_VID(pTq->pVnode), dataRsp.rspOffset.version); - if (tqSendDataRsp(pTq, pMsg, &req, &dataRsp) < 0) { - code = -1; - } - tDeleteSMqDataRsp(&dataRsp); - return code; - } else { - STaosxRsp taosxRsp = {0}; - tqInitTaosxRsp(&taosxRsp, &req); - tqOffsetResetToLog(&taosxRsp.rspOffset, walGetLastVer(pTq->pVnode->pWal)); - if (tqSendTaosxRsp(pTq, pMsg, &req, &taosxRsp) < 0) { - code = -1; - } - tDeleteSTaosxRsp(&taosxRsp); - return code; + } else { + pHandle->pRef = walRefFirstVer(pTq->pVnode->pWal, pHandle->pRef); + if (pHandle->pRef == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; } - } else if (reqOffset.type == TMQ_OFFSET__RESET_NONE) { - tqError("tmq poll: subkey %s, no offset committed for consumer:0x%" PRIx64 - " in vg %d, subkey %s, reset none failed", - pHandle->subKey, consumerId, TD_VID(pTq->pVnode), req.subKey); - terrno = TSDB_CODE_TQ_NO_COMMITTED_OFFSET; - return -1; + + tqOffsetResetToLog(pOffsetVal, pHandle->pRef->refVer - 1); } - } - } + } else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) { + if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { + SMqDataRsp dataRsp = {0}; + tqInitDataRsp(&dataRsp, pRequest, pHandle->execHandle.subType); + + tqOffsetResetToLog(&dataRsp.rspOffset, walGetLastVer(pTq->pVnode->pWal)); + tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, (latest) offset reset to %" PRId64, consumerId, + pHandle->subKey, vgId, dataRsp.rspOffset.version); + int32_t code = tqSendDataRsp(pTq, pMsg, pRequest, &dataRsp, TMQ_MSG_TYPE__POLL_RSP); + tDeleteSMqDataRsp(&dataRsp); + + *pBlockReturned = true; + return code; + } else { + STaosxRsp taosxRsp = {0}; + tqInitTaosxRsp(&taosxRsp, pRequest); + tqOffsetResetToLog(&taosxRsp.rspOffset, walGetLastVer(pTq->pVnode->pWal)); + int32_t code = tqSendDataRsp(pTq, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, TMQ_MSG_TYPE__TAOSX_RSP); + tDeleteSTaosxRsp(&taosxRsp); - if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { - SMqDataRsp dataRsp = {0}; - tqInitDataRsp(&dataRsp, &req, pHandle->execHandle.subType); - // lock - taosWLockLatch(&pTq->pushLock); - if (tqScanData(pTq, pHandle, &dataRsp, &fetchOffsetNew) < 0) { + *pBlockReturned = true; + return code; + } + } else if (reqOffset.type == TMQ_OFFSET__RESET_NONE) { + tqError("tmq poll: subkey:%s, no offset committed for consumer:0x%" PRIx64 + " in vg %d, subkey %s, reset none failed", + pHandle->subKey, consumerId, vgId, pRequest->subKey); + terrno = TSDB_CODE_TQ_NO_COMMITTED_OFFSET; return -1; } + } - // till now, all data has been rsp to consumer, new data needs to push client once arrived. - if (dataRsp.blockNum == 0 && dataRsp.reqOffset.type == TMQ_OFFSET__LOG && - dataRsp.reqOffset.version == dataRsp.rspOffset.version) { - STqPushEntry* pPushEntry = taosMemoryCalloc(1, sizeof(STqPushEntry)); - if (pPushEntry != NULL) { - pPushEntry->pInfo = pMsg->info; - memcpy(pPushEntry->subKey, pHandle->subKey, TSDB_SUBSCRIBE_KEY_LEN); - dataRsp.withTbName = 0; - memcpy(&pPushEntry->dataRsp, &dataRsp, sizeof(SMqDataRsp)); - pPushEntry->dataRsp.head.consumerId = consumerId; - pPushEntry->dataRsp.head.epoch = reqEpoch; - pPushEntry->dataRsp.head.mqMsgType = TMQ_MSG_TYPE__POLL_RSP; - taosHashPut(pTq->pPushMgr, pHandle->subKey, strlen(pHandle->subKey) + 1, &pPushEntry, sizeof(void*)); - - tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s offset:%" PRId64 ", vgId:%d save handle to push mgr", - consumerId, pHandle->subKey, dataRsp.reqOffset.version, TD_VID(pTq->pVnode)); - // unlock - taosWUnLockLatch(&pTq->pushLock); - return 0; - } - } - taosWUnLockLatch(&pTq->pushLock); + return 0; +} - if (tqSendDataRsp(pTq, pMsg, &req, &dataRsp) < 0) { - code = -1; - } +#define IS_OFFSET_RESET_TYPE(_t) ((_t) < 0) + +static int32_t extractDataAndRspForNormalSubscribe(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, + SRpcMsg* pMsg, STqOffsetVal* pOffset) { + int32_t code = 0; + uint64_t consumerId = pRequest->consumerId; + int32_t vgId = TD_VID(pTq->pVnode); - tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, rsp block:%d, offset type:%d, uid/version:%" PRId64 - ", ts:%" PRId64 "", - consumerId, pHandle->subKey, TD_VID(pTq->pVnode), dataRsp.blockNum, dataRsp.rspOffset.type, - dataRsp.rspOffset.uid, dataRsp.rspOffset.ts); + SMqDataRsp dataRsp = {0}; + tqInitDataRsp(&dataRsp, pRequest, pHandle->execHandle.subType); + + // lock + taosWLockLatch(&pTq->lock); + + qSetTaskId(pHandle->execHandle.task, consumerId, pRequest->reqId); + code = tqScanData(pTq, pHandle, &dataRsp, pOffset); + if (code != TSDB_CODE_SUCCESS) { + taosWUnLockLatch(&pTq->lock); + return code; + } - tDeleteSMqDataRsp(&dataRsp); + // till now, all data has been transferred to consumer, new data needs to push client once arrived. + if (dataRsp.blockNum == 0 && dataRsp.reqOffset.type == TMQ_OFFSET__LOG && + dataRsp.reqOffset.version == dataRsp.rspOffset.version && pHandle->consumerId == pRequest->consumerId) { + code = tqRegisterPushEntry(pTq, pHandle, pRequest, pMsg, &dataRsp, TMQ_MSG_TYPE__POLL_RSP); + taosWUnLockLatch(&pTq->lock); return code; } + taosWUnLockLatch(&pTq->lock); + code = tqSendDataRsp(pTq, pMsg, pRequest, (SMqDataRsp*)&dataRsp, TMQ_MSG_TYPE__POLL_RSP); + + // NOTE: this pHandle->consumerId may have been changed already. + tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s, vgId:%d, rsp block:%d, offset type:%d, uid/version:%" PRId64 + ", ts:%" PRId64 ", reqId:0x%" PRIx64, + consumerId, pHandle->subKey, vgId, dataRsp.blockNum, dataRsp.rspOffset.type, dataRsp.rspOffset.uid, + dataRsp.rspOffset.ts, pRequest->reqId); + + tDeleteSMqDataRsp(&dataRsp); + return code; +} + +static int32_t doPollDataForMq(STQ* pTq, STqHandle* pHandle, const SMqPollReq* pRequest, SRpcMsg* pMsg) { + int32_t code = -1; + STqOffsetVal offset = {0}; + SWalCkHead* pCkHead = NULL; + int32_t vgId = TD_VID(pTq->pVnode); + + STqOffsetVal reqOffset = pRequest->reqOffset; + uint64_t consumerId = pRequest->consumerId; + + // 1. reset the offset if needed + if (IS_OFFSET_RESET_TYPE(reqOffset.type)) { + // handle the reset offset cases, according to the consumer's choice. + bool blockReturned = false; + code = extractResetOffsetVal(&offset, pTq, pHandle, pRequest, pMsg, &blockReturned); + if (code != 0) { + return code; + } + + // empty block returned, quit + if (blockReturned) { + return 0; + } + } else { // use the consumer specified offset + // the offset value can not be monotonious increase?? + offset = reqOffset; + } + + // this is a normal subscribe requirement + if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { + return extractDataAndRspForNormalSubscribe(pTq, pHandle, pRequest, pMsg, &offset); + } + + // todo handle the case where re-balance occurs. // for taosx SMqMetaRsp metaRsp = {0}; STaosxRsp taosxRsp = {0}; - tqInitTaosxRsp(&taosxRsp, &req); + tqInitTaosxRsp(&taosxRsp, pRequest); - if (fetchOffsetNew.type != TMQ_OFFSET__LOG) { - if (tqScanTaosx(pTq, pHandle, &taosxRsp, &metaRsp, &fetchOffsetNew) < 0) { + if (offset.type != TMQ_OFFSET__LOG) { + if (tqScanTaosx(pTq, pHandle, &taosxRsp, &metaRsp, &offset) < 0) { return -1; } if (metaRsp.metaRspLen > 0) { - if (tqSendMetaPollRsp(pTq, pMsg, &req, &metaRsp) < 0) { - code = -1; - } - tqDebug("tmq poll: consumer:0x%" PRIx64 " subkey %s, vg %d, send meta offset type:%d,uid:%" PRId64 - ",version:%" PRId64, - consumerId, pHandle->subKey, TD_VID(pTq->pVnode), metaRsp.rspOffset.type, metaRsp.rspOffset.uid, - metaRsp.rspOffset.version); + code = tqSendMetaPollRsp(pTq, pMsg, pRequest, &metaRsp); + tqDebug("tmq poll: consumer:0x%" PRIx64 " subkey:%s vgId:%d, send meta offset type:%d,uid:%" PRId64 + ",ts:%" PRId64, + consumerId, pHandle->subKey, vgId, metaRsp.rspOffset.type, metaRsp.rspOffset.uid, metaRsp.rspOffset.ts); taosMemoryFree(metaRsp.metaRsp); tDeleteSTaosxRsp(&taosxRsp); return code; } if (taosxRsp.blockNum > 0) { - if (tqSendTaosxRsp(pTq, pMsg, &req, &taosxRsp) < 0) { - code = -1; - } + code = tqSendDataRsp(pTq, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, TMQ_MSG_TYPE__TAOSX_RSP); tDeleteSTaosxRsp(&taosxRsp); return code; } else { - fetchOffsetNew = taosxRsp.rspOffset; + offset = taosxRsp.rspOffset; } - tqDebug("taosx poll: consumer:0x%" PRIx64 " subkey %s, vg %d, send data blockNum:%d, offset type:%d,uid:%" PRId64 + tqDebug("taosx poll: consumer:0x%" PRIx64 " subkey:%s vgId:%d, send data blockNum:%d, offset type:%d,uid:%" PRId64 ",version:%" PRId64, - consumerId, pHandle->subKey, TD_VID(pTq->pVnode), taosxRsp.blockNum, taosxRsp.rspOffset.type, - taosxRsp.rspOffset.uid, taosxRsp.rspOffset.version); + consumerId, pHandle->subKey, vgId, taosxRsp.blockNum, taosxRsp.rspOffset.type, taosxRsp.rspOffset.uid, + taosxRsp.rspOffset.version); } - if (fetchOffsetNew.type == TMQ_OFFSET__LOG) { - int64_t fetchVer = fetchOffsetNew.version + 1; + if (offset.type == TMQ_OFFSET__LOG) { + int64_t fetchVer = offset.version + 1; pCkHead = taosMemoryMalloc(sizeof(SWalCkHead) + 2048); if (pCkHead == NULL) { tDeleteSTaosxRsp(&taosxRsp); + terrno = TSDB_CODE_OUT_OF_MEMORY; return -1; } - walSetReaderCapacity(pHandle->pWalReader, 2048); - + int totalRows = 0; while (1) { - savedEpoch = atomic_load_32(&pHandle->epoch); - if (savedEpoch > reqEpoch) { - tqWarn("tmq poll: consumer:0x%" PRIx64 " (epoch %d), subkey %s, vg %d offset %" PRId64 + // todo refactor: this is not correct. + int32_t savedEpoch = atomic_load_32(&pHandle->epoch); + if (savedEpoch > pRequest->epoch) { + tqWarn("tmq poll: consumer:0x%" PRIx64 " (epoch %d), subkey:%s vgId:%d offset %" PRId64 ", found new consumer epoch %d, discard req epoch %d", - consumerId, req.epoch, pHandle->subKey, TD_VID(pTq->pVnode), fetchVer, savedEpoch, reqEpoch); + consumerId, pRequest->epoch, pHandle->subKey, vgId, fetchVer, savedEpoch, pRequest->epoch); break; } - if (tqFetchLog(pTq, pHandle, &fetchVer, &pCkHead) < 0) { + if (tqFetchLog(pTq, pHandle, &fetchVer, &pCkHead, pRequest->reqId) < 0) { tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer); - if (tqSendTaosxRsp(pTq, pMsg, &req, &taosxRsp) < 0) { - code = -1; - } + code = tqSendDataRsp(pTq, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, TMQ_MSG_TYPE__TAOSX_RSP); tDeleteSTaosxRsp(&taosxRsp); taosMemoryFreeClear(pCkHead); return code; } SWalCont* pHead = &pCkHead->head; - tqDebug("tmq poll: consumer:0x%" PRIx64 " (epoch %d) iter log, vgId:%d offset %" PRId64 " msgType %d", consumerId, - req.epoch, TD_VID(pTq->pVnode), fetchVer, pHead->msgType); - - if (pHead->msgType == TDMT_VND_SUBMIT) { - SPackedData submit = { - .msgStr = POINTER_SHIFT(pHead->body, sizeof(SSubmitReq2Msg)), - .msgLen = pHead->bodyLen - sizeof(SSubmitReq2Msg), - .ver = pHead->version, - }; - if (tqTaosxScanLog(pTq, pHandle, submit, &taosxRsp) < 0) { - tqError("tmq poll: tqTaosxScanLog error %" PRId64 ", in vgId:%d, subkey %s", consumerId, TD_VID(pTq->pVnode), - req.subKey); - return -1; - } - if (taosxRsp.blockNum > 0 /* threshold */) { - tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer); - if (tqSendTaosxRsp(pTq, pMsg, &req, &taosxRsp) < 0) { - code = -1; - } + pRequest->epoch, vgId, fetchVer, pHead->msgType); + + // process meta + if (pHead->msgType != TDMT_VND_SUBMIT) { + if (totalRows > 0) { + tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer - 1); + code = tqSendDataRsp(pTq, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, TMQ_MSG_TYPE__TAOSX_RSP); tDeleteSTaosxRsp(&taosxRsp); taosMemoryFreeClear(pCkHead); return code; - } else { - fetchVer++; } - } else { - /*A(pHandle->fetchMeta);*/ - /*A(IS_META_MSG(pHead->msgType));*/ tqDebug("fetch meta msg, ver:%" PRId64 ", type:%s", pHead->version, TMSG_INFO(pHead->msgType)); tqOffsetResetToLog(&metaRsp.rspOffset, fetchVer); metaRsp.resMsgType = pHead->msgType; metaRsp.metaRspLen = pHead->bodyLen; metaRsp.metaRsp = pHead->body; - if (tqSendMetaPollRsp(pTq, pMsg, &req, &metaRsp) < 0) { + if (tqSendMetaPollRsp(pTq, pMsg, pRequest, &metaRsp) < 0) { code = -1; taosMemoryFreeClear(pCkHead); tDeleteSTaosxRsp(&taosxRsp); @@ -736,6 +626,31 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { tDeleteSTaosxRsp(&taosxRsp); return code; } + + // process data + SPackedData submit = { + .msgStr = POINTER_SHIFT(pHead->body, sizeof(SSubmitReq2Msg)), + .msgLen = pHead->bodyLen - sizeof(SSubmitReq2Msg), + .ver = pHead->version, + }; + + if (tqTaosxScanLog(pTq, pHandle, submit, &taosxRsp, &totalRows) < 0) { + tqError("tmq poll: tqTaosxScanLog error %" PRId64 ", in vgId:%d, subkey %s", consumerId, vgId, + pRequest->subKey); + taosMemoryFreeClear(pCkHead); + tDeleteSTaosxRsp(&taosxRsp); + return -1; + } + + if (totalRows >= 4096 || taosxRsp.createTableNum > 0) { + tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer); + code = tqSendDataRsp(pTq, pMsg, pRequest, (SMqDataRsp*)&taosxRsp, TMQ_MSG_TYPE__TAOSX_RSP); + tDeleteSTaosxRsp(&taosxRsp); + taosMemoryFreeClear(pCkHead); + return code; + } else { + fetchVer++; + } } } @@ -744,17 +659,67 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { return 0; } +int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) { + SMqPollReq req = {0}; + if (tDeserializeSMqPollReq(pMsg->pCont, pMsg->contLen, &req) < 0) { + tqError("tDeserializeSMqPollReq %d failed", pMsg->contLen); + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + int64_t consumerId = req.consumerId; + int32_t reqEpoch = req.epoch; + STqOffsetVal reqOffset = req.reqOffset; + int32_t vgId = TD_VID(pTq->pVnode); + + // 1. find handle + STqHandle* pHandle = taosHashGet(pTq->pHandle, req.subKey, strlen(req.subKey)); + if (pHandle == NULL) { + tqError("tmq poll: consumer:0x%" PRIx64 " vgId:%d subkey %s not found", consumerId, vgId, req.subKey); + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + // 2. check re-balance status + taosRLockLatch(&pTq->lock); + if (pHandle->consumerId != consumerId) { + tqDebug("ERROR tmq poll: consumer:0x%" PRIx64 " vgId:%d, subkey %s, mismatch for saved handle consumer:0x%" PRIx64, + consumerId, TD_VID(pTq->pVnode), req.subKey, pHandle->consumerId); + terrno = TSDB_CODE_TMQ_CONSUMER_MISMATCH; + taosRUnLockLatch(&pTq->lock); + return -1; + } + taosRUnLockLatch(&pTq->lock); + + // 3. update the epoch value + taosWLockLatch(&pTq->lock); + int32_t savedEpoch = pHandle->epoch; + if (savedEpoch < reqEpoch) { + tqDebug("tmq poll: consumer:0x%" PRIx64 " epoch update from %d to %d by poll req", consumerId, savedEpoch, + reqEpoch); + pHandle->epoch = reqEpoch; + } + taosWUnLockLatch(&pTq->lock); + + char buf[80]; + tFormatOffset(buf, 80, &reqOffset); + tqDebug("tmq poll: consumer:0x%" PRIx64 " (epoch %d), subkey %s, recv poll req vgId:%d, req:%s, reqId:0x%" PRIx64, + consumerId, req.epoch, pHandle->subKey, vgId, buf, req.reqId); + + return doPollDataForMq(pTq, pHandle, &req, pMsg); +} + int32_t tqProcessDeleteSubReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) { SMqVDeleteReq* pReq = (SMqVDeleteReq*)msg; tqDebug("vgId:%d, tq process delete sub req %s", pTq->pVnode->config.vgId, pReq->subKey); - taosWLockLatch(&pTq->pushLock); + taosWLockLatch(&pTq->lock); int32_t code = taosHashRemove(pTq->pPushMgr, pReq->subKey, strlen(pReq->subKey)); if (code != 0) { tqDebug("vgId:%d, tq remove push handle %s", pTq->pVnode->config.vgId, pReq->subKey); } - taosWUnLockLatch(&pTq->pushLock); + taosWUnLockLatch(&pTq->lock); STqHandle* pHandle = taosHashGet(pTq->pHandle, pReq->subKey, strlen(pReq->subKey)); if (pHandle) { @@ -814,24 +779,28 @@ int32_t tqProcessDelCheckInfoReq(STQ* pTq, int64_t sversion, char* msg, int32_t int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msgLen) { SMqRebVgReq req = {0}; tDecodeSMqRebVgReq(msg, &req); - // todo lock - tqDebug("vgId:%d, tq process sub req %s", pTq->pVnode->config.vgId, req.subKey); + SVnode* pVnode = pTq->pVnode; + int32_t vgId = TD_VID(pVnode); + + tqDebug("vgId:%d, tq process sub req:%s, Id:0x%" PRIx64 " -> Id:0x%" PRIx64, pVnode->config.vgId, req.subKey, + req.oldConsumerId, req.newConsumerId); STqHandle* pHandle = taosHashGet(pTq->pHandle, req.subKey, strlen(req.subKey)); if (pHandle == NULL) { if (req.oldConsumerId != -1) { - tqError("vgId:%d, build new consumer handle %s for consumer:0x%" PRIx64 ", but old consumerId is %" PRId64 "", + tqError("vgId:%d, build new consumer handle %s for consumer:0x%" PRIx64 ", but old consumerId:0x%" PRIx64, req.vgId, req.subKey, req.newConsumerId, req.oldConsumerId); } + if (req.newConsumerId == -1) { - tqError("vgId:%d, tq invalid rebalance request, new consumerId %" PRId64 "", req.vgId, req.newConsumerId); + tqError("vgId:%d, tq invalid re-balance request, new consumerId %" PRId64 "", req.vgId, req.newConsumerId); taosMemoryFree(req.qmsg); return 0; } + STqHandle tqHandle = {0}; pHandle = &tqHandle; - /*taosInitRWLatch(&pExec->lock);*/ uint64_t oldConsumerId = pHandle->consumerId; memcpy(pHandle->subKey, req.subKey, TSDB_SUBSCRIBE_KEY_LEN); @@ -842,85 +811,110 @@ int32_t tqProcessSubscribeReq(STQ* pTq, int64_t sversion, char* msg, int32_t msg pHandle->fetchMeta = req.withMeta; // TODO version should be assigned and refed during preprocess - SWalRef* pRef = walRefCommittedVer(pTq->pVnode->pWal); + SWalRef* pRef = walRefCommittedVer(pVnode->pWal); if (pRef == NULL) { + taosMemoryFree(req.qmsg); return -1; } + int64_t ver = pRef->refVer; pHandle->pRef = pRef; SReadHandle handle = { - .meta = pTq->pVnode->pMeta, - .vnode = pTq->pVnode, + .meta = pVnode->pMeta, + .vnode = pVnode, .initTableReader = true, .initTqReader = true, .version = ver, }; + pHandle->snapshotVer = ver; if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { pHandle->execHandle.execCol.qmsg = req.qmsg; req.qmsg = NULL; - pHandle->execHandle.task = - qCreateQueueExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle, &pHandle->execHandle.numOfCols, NULL); + pHandle->execHandle.task = qCreateQueueExecTaskInfo(pHandle->execHandle.execCol.qmsg, &handle, vgId, + &pHandle->execHandle.numOfCols, req.newConsumerId); void* scanner = NULL; qExtractStreamScanner(pHandle->execHandle.task, &scanner); pHandle->execHandle.pExecReader = qExtractReaderFromStreamScanner(scanner); } else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__DB) { - pHandle->pWalReader = walOpenReader(pTq->pVnode->pWal, NULL); - pHandle->execHandle.pExecReader = tqOpenReader(pTq->pVnode); + pHandle->pWalReader = walOpenReader(pVnode->pWal, NULL); + pHandle->execHandle.pExecReader = tqOpenReader(pVnode); + pHandle->execHandle.execDb.pFilterOutTbUid = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); buildSnapContext(handle.meta, handle.version, 0, pHandle->execHandle.subType, pHandle->fetchMeta, (SSnapContext**)(&handle.sContext)); - pHandle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &handle, NULL, NULL); + pHandle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &handle, vgId, NULL, req.newConsumerId); } else if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__TABLE) { - pHandle->pWalReader = walOpenReader(pTq->pVnode->pWal, NULL); - + pHandle->pWalReader = walOpenReader(pVnode->pWal, NULL); pHandle->execHandle.execTb.suid = req.suid; SArray* tbUidList = taosArrayInit(0, sizeof(int64_t)); - vnodeGetCtbIdList(pTq->pVnode, req.suid, tbUidList); - tqDebug("vgId:%d, tq try to get all ctb, suid:%" PRId64, pTq->pVnode->config.vgId, req.suid); + vnodeGetCtbIdList(pVnode, req.suid, tbUidList); + tqDebug("vgId:%d, tq try to get all ctb, suid:%" PRId64, pVnode->config.vgId, req.suid); for (int32_t i = 0; i < taosArrayGetSize(tbUidList); i++) { int64_t tbUid = *(int64_t*)taosArrayGet(tbUidList, i); - tqDebug("vgId:%d, idx %d, uid:%" PRId64, TD_VID(pTq->pVnode), i, tbUid); + tqDebug("vgId:%d, idx %d, uid:%" PRId64, vgId, i, tbUid); } - pHandle->execHandle.pExecReader = tqOpenReader(pTq->pVnode); + pHandle->execHandle.pExecReader = tqOpenReader(pVnode); tqReaderSetTbUidList(pHandle->execHandle.pExecReader, tbUidList); taosArrayDestroy(tbUidList); buildSnapContext(handle.meta, handle.version, req.suid, pHandle->execHandle.subType, pHandle->fetchMeta, (SSnapContext**)(&handle.sContext)); - pHandle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &handle, NULL, NULL); + pHandle->execHandle.task = qCreateQueueExecTaskInfo(NULL, &handle, vgId, NULL, req.newConsumerId); } taosHashPut(pTq->pHandle, req.subKey, strlen(req.subKey), pHandle, sizeof(STqHandle)); tqDebug("try to persist handle %s consumer:0x%" PRIx64 " , old consumer:0x%" PRIx64, req.subKey, pHandle->consumerId, oldConsumerId); if (tqMetaSaveHandle(pTq, req.subKey, pHandle) < 0) { + taosMemoryFree(req.qmsg); return -1; } } else { - // TODO handle qmsg and exec modification - tqInfo("update the consumer info, old consumer id:0x%" PRIx64 ", new Id:0x%" PRIx64, pHandle->consumerId, - req.newConsumerId); - atomic_store_32(&pHandle->epoch, -1); - atomic_store_64(&pHandle->consumerId, req.newConsumerId); - atomic_add_fetch_32(&pHandle->epoch, 1); - taosMemoryFree(req.qmsg); - if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { - qStreamCloseTsdbReader(pHandle->execHandle.task); - } + if (pHandle->consumerId == req.newConsumerId) { // do nothing + tqInfo("vgId:%d consumer:0x%" PRIx64 " remains, no switch occurs", req.vgId, req.newConsumerId); + atomic_store_32(&pHandle->epoch, -1); + atomic_add_fetch_32(&pHandle->epoch, 1); + taosMemoryFree(req.qmsg); + return tqMetaSaveHandle(pTq, req.subKey, pHandle); + } else { + tqInfo("vgId:%d switch consumer from Id:0x%" PRIx64 " to Id:0x%" PRIx64, req.vgId, pHandle->consumerId, + req.newConsumerId); - if (tqMetaSaveHandle(pTq, req.subKey, pHandle) < 0) { - return -1; + // kill executing task + qTaskInfo_t pTaskInfo = pHandle->execHandle.task; + if (pTaskInfo != NULL) { + qKillTask(pTaskInfo, TSDB_CODE_SUCCESS); + } + + taosWLockLatch(&pTq->lock); + atomic_store_32(&pHandle->epoch, -1); + + // remove if it has been register in the push manager, and return one empty block to consumer + tqUnregisterPushEntry(pTq, req.subKey, (int32_t)strlen(req.subKey), pHandle->consumerId, true); + + atomic_store_64(&pHandle->consumerId, req.newConsumerId); + atomic_add_fetch_32(&pHandle->epoch, 1); + + if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { + qStreamCloseTsdbReader(pTaskInfo); + } + + taosWUnLockLatch(&pTq->lock); + if (tqMetaSaveHandle(pTq, req.subKey, pHandle) < 0) { + taosMemoryFree(req.qmsg); + return -1; + } } - // close handle } + taosMemoryFree(req.qmsg); return 0; } @@ -931,6 +925,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver) { } #endif + int32_t vgId = TD_VID(pTq->pVnode); pTask->refCnt = 1; pTask->schedStatus = TASK_SCHED_STATUS__INACTIVE; @@ -943,9 +938,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver) { pTask->inputStatus = TASK_INPUT_STATUS__NORMAL; pTask->outputStatus = TASK_OUTPUT_STATUS__NORMAL; - pTask->pMsgCb = &pTq->pVnode->msgCb; - pTask->startVer = ver; // expand executor @@ -965,7 +958,8 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver) { .initTqReader = 1, .pStateBackend = pTask->pState, }; - pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle); + + pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle, vgId); if (pTask->exec.executor == NULL) { return -1; } @@ -980,7 +974,8 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver) { .numOfVgroups = (int32_t)taosArrayGetSize(pTask->childEpInfo), .pStateBackend = pTask->pState, }; - pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &mgHandle); + + pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &mgHandle, vgId); if (pTask->exec.executor == NULL) { return -1; } @@ -995,22 +990,23 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask, int64_t ver) { pTask->tbSink.vnode = pTq->pVnode; pTask->tbSink.tbSinkFunc = tqSinkToTablePipeline2; - int32_t version = 1; + int32_t ver1 = 1; SMetaInfo info = {0}; int32_t code = metaGetInfo(pTq->pVnode->pMeta, pTask->tbSink.stbUid, &info, NULL); if (code == TSDB_CODE_SUCCESS) { - version = info.skmVer; + ver1 = info.skmVer; } pTask->tbSink.pTSchema = - tBuildTSchema(pTask->tbSink.pSchemaWrapper->pSchema, pTask->tbSink.pSchemaWrapper->nCols, version); - ASSERT(pTask->tbSink.pTSchema); + tBuildTSchema(pTask->tbSink.pSchemaWrapper->pSchema, pTask->tbSink.pSchemaWrapper->nCols, ver1); + if (pTask->tbSink.pTSchema == NULL) { + return -1; + } } streamSetupTrigger(pTask); - - tqInfo("expand stream task on vg %d, task id %d, child id %d, level %d", TD_VID(pTq->pVnode), pTask->taskId, - pTask->selfChildId, pTask->taskLevel); + tqInfo("expand stream task on vg %d, task id %d, child id %d, level %d", vgId, pTask->taskId, pTask->selfChildId, + pTask->taskLevel); return 0; } diff --git a/source/dnode/vnode/src/tq/tqMeta.c b/source/dnode/vnode/src/tq/tqMeta.c index 25ee5637967229b5fb6b5aaa0e7daede6d9283c0..7b0cdab2f8ac7e49ef7f18fc5e971a0399969d65 100644 --- a/source/dnode/vnode/src/tq/tqMeta.c +++ b/source/dnode/vnode/src/tq/tqMeta.c @@ -269,12 +269,13 @@ int32_t tqMetaDeleteHandle(STQ* pTq, const char* key) { } int32_t tqMetaRestoreHandle(STQ* pTq) { - int code = 0; + int code = 0; TBC* pCur = NULL; if (tdbTbcOpen(pTq->pExecStore, &pCur, NULL) < 0) { return -1; } + int32_t vgId = TD_VID(pTq->pVnode); void* pKey = NULL; int kLen = 0; void* pVal = NULL; @@ -284,7 +285,7 @@ int32_t tqMetaRestoreHandle(STQ* pTq) { tdbTbcMoveToFirst(pCur); while (tdbTbcNext(pCur, &pKey, &kLen, &pVal, &vLen) == 0) { - STqHandle handle; + STqHandle handle = {0}; tDecoderInit(&decoder, (uint8_t*)pVal, vLen); tDecodeSTqHandle(&decoder, &handle); tDecoderClear(&decoder); @@ -306,7 +307,7 @@ int32_t tqMetaRestoreHandle(STQ* pTq) { if (handle.execHandle.subType == TOPIC_SUB_TYPE__COLUMN) { handle.execHandle.task = - qCreateQueueExecTaskInfo(handle.execHandle.execCol.qmsg, &reader, &handle.execHandle.numOfCols, NULL); + qCreateQueueExecTaskInfo(handle.execHandle.execCol.qmsg, &reader, vgId, &handle.execHandle.numOfCols, 0); if (handle.execHandle.task == NULL) { tqError("cannot create exec task for %s", handle.subKey); code = -1; @@ -331,7 +332,7 @@ int32_t tqMetaRestoreHandle(STQ* pTq) { buildSnapContext(reader.meta, reader.version, 0, handle.execHandle.subType, handle.fetchMeta, (SSnapContext**)(&reader.sContext)); - handle.execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, NULL, NULL); + handle.execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, vgId, NULL, 0); } else if (handle.execHandle.subType == TOPIC_SUB_TYPE__TABLE) { handle.pWalReader = walOpenReader(pTq->pVnode->pWal, NULL); @@ -340,7 +341,7 @@ int32_t tqMetaRestoreHandle(STQ* pTq) { tqDebug("vgId:%d, tq try to get all ctb, suid:%" PRId64, pTq->pVnode->config.vgId, handle.execHandle.execTb.suid); for (int32_t i = 0; i < taosArrayGetSize(tbUidList); i++) { int64_t tbUid = *(int64_t*)taosArrayGet(tbUidList, i); - tqDebug("vgId:%d, idx %d, uid:%" PRId64, TD_VID(pTq->pVnode), i, tbUid); + tqDebug("vgId:%d, idx %d, uid:%" PRId64, vgId, i, tbUid); } handle.execHandle.pExecReader = tqOpenReader(pTq->pVnode); tqReaderSetTbUidList(handle.execHandle.pExecReader, tbUidList); @@ -348,9 +349,9 @@ int32_t tqMetaRestoreHandle(STQ* pTq) { buildSnapContext(reader.meta, reader.version, handle.execHandle.execTb.suid, handle.execHandle.subType, handle.fetchMeta, (SSnapContext**)(&reader.sContext)); - handle.execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, NULL, NULL); + handle.execHandle.task = qCreateQueueExecTaskInfo(NULL, &reader, vgId, NULL, 0); } - tqDebug("tq restore %s consumer %" PRId64 " vgId:%d", handle.subKey, handle.consumerId, TD_VID(pTq->pVnode)); + tqDebug("tq restore %s consumer %" PRId64 " vgId:%d", handle.subKey, handle.consumerId, vgId); taosHashPut(pTq->pHandle, pKey, kLen, &handle, sizeof(STqHandle)); } diff --git a/source/dnode/vnode/src/tq/tqPush.c b/source/dnode/vnode/src/tq/tqPush.c index 5a25d7e89468b29e6c597c555d27afb259f09b63..d55b533f8a95319e964a2519dacff60a1e5fab42 100644 --- a/source/dnode/vnode/src/tq/tqPush.c +++ b/source/dnode/vnode/src/tq/tqPush.c @@ -206,119 +206,144 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_ } #endif -int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) { +typedef struct { + void* pKey; + int64_t keyLen; +} SItem; + +static void recordPushedEntry(SArray* cachedKey, void* pIter); + +static void freeItem(void* param) { + SItem* p = (SItem*)param; + taosMemoryFree(p->pKey); +} + +static void doRemovePushedEntry(SArray* pCachedKeys, STQ* pTq) { + int32_t vgId = TD_VID(pTq->pVnode); + int32_t numOfKeys = (int32_t)taosArrayGetSize(pCachedKeys); + + for (int32_t i = 0; i < numOfKeys; i++) { + SItem* pItem = taosArrayGet(pCachedKeys, i); + if (taosHashRemove(pTq->pPushMgr, pItem->pKey, pItem->keyLen) != 0) { + tqError("vgId:%d, tq push hash remove key error, key: %s", vgId, (char*)pItem->pKey); + } + } + + if (numOfKeys > 0) { + tqDebug("vgId:%d, pushed %d items and remain:%d", vgId, numOfKeys, (int32_t)taosHashGetSize(pTq->pPushMgr)); + } +} + +static void doPushDataForEntry(void* pIter, STqExecHandle* pExec, STQ* pTq, int64_t ver, int32_t vgId, char* pData, + int32_t dataLen, SArray* pCachedKey) { + STqPushEntry* pPushEntry = *(STqPushEntry**)pIter; + + SMqDataRsp* pRsp = pPushEntry->pDataRsp; + if (pRsp->reqOffset.version >= ver) { + tqDebug("vgId:%d, push entry req version %" PRId64 ", while push version %" PRId64 ", skip", vgId, + pRsp->reqOffset.version, ver); + return; + } + + qTaskInfo_t pTaskInfo = pExec->task; + + // prepare scan mem data + SPackedData submit = {.msgStr = pData, .msgLen = dataLen, .ver = ver}; + + if (qStreamSetScanMemData(pTaskInfo, submit) != 0) { + return; + } + + // here start to scan submit block to extract the subscribed data + int32_t totalRows = 0; + + while (1) { + SSDataBlock* pDataBlock = NULL; + uint64_t ts = 0; + if (qExecTask(pTaskInfo, &pDataBlock, &ts) < 0) { + tqDebug("vgId:%d, tq exec error since %s", vgId, terrstr()); + } + + if (pDataBlock == NULL) { + break; + } + + tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision); + pRsp->blockNum++; + totalRows += pDataBlock->info.rows; + } + + tqDebug("vgId:%d, tq handle push, subkey:%s, block num:%d, rows:%d", vgId, pPushEntry->subKey, pRsp->blockNum, + totalRows); + + if (pRsp->blockNum > 0) { + tqOffsetResetToLog(&pRsp->rspOffset, ver); + tqPushDataRsp(pTq, pPushEntry); + recordPushedEntry(pCachedKey, pIter); + } +} + +int32_t tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) { void* pReq = POINTER_SHIFT(msg, sizeof(SSubmitReq2Msg)); int32_t len = msgLen - sizeof(SSubmitReq2Msg); + int32_t vgId = TD_VID(pTq->pVnode); if (msgType == TDMT_VND_SUBMIT) { // lock push mgr to avoid potential msg lost - taosWLockLatch(&pTq->pushLock); + taosWLockLatch(&pTq->lock); int32_t numOfRegisteredPush = taosHashGetSize(pTq->pPushMgr); if (numOfRegisteredPush > 0) { tqDebug("vgId:%d tq push msg version:%" PRId64 " type:%s, head:%p, body:%p len:%d, numOfPushed consumers:%d", - pTq->pVnode->config.vgId, ver, TMSG_INFO(msgType), msg, pReq, len, numOfRegisteredPush); - - SArray* cachedKeys = taosArrayInit(0, sizeof(void*)); - SArray* cachedKeyLens = taosArrayInit(0, sizeof(size_t)); + vgId, ver, TMSG_INFO(msgType), msg, pReq, len, numOfRegisteredPush); - void* data = taosMemoryMalloc(len); + void* data = taosMemoryMalloc(len); if (data == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; - tqError("failed to copy data for stream since out of memory"); - taosArrayDestroyP(cachedKeys, (FDelete)taosMemoryFree); - taosArrayDestroy(cachedKeyLens); - - // unlock - taosWUnLockLatch(&pTq->pushLock); + tqError("failed to copy data for stream since out of memory, vgId:%d", vgId); + taosWUnLockLatch(&pTq->lock); return -1; } memcpy(data, pReq, len); - void* pIter = NULL; + SArray* cachedKey = taosArrayInit(0, sizeof(SItem)); + void* pIter = NULL; + while (1) { pIter = taosHashIterate(pTq->pPushMgr, pIter); - if (pIter == NULL) break; + if (pIter == NULL) { + break; + } + STqPushEntry* pPushEntry = *(STqPushEntry**)pIter; STqHandle* pHandle = taosHashGet(pTq->pHandle, pPushEntry->subKey, strlen(pPushEntry->subKey)); if (pHandle == NULL) { - tqDebug("vgId:%d, cannot find handle %s", pTq->pVnode->config.vgId, pPushEntry->subKey); - continue; - } - - if (pPushEntry->dataRsp.reqOffset.version >= ver) { - tqDebug("vgId:%d, push entry req version %" PRId64 ", while push version %" PRId64 ", skip", - pTq->pVnode->config.vgId, pPushEntry->dataRsp.reqOffset.version, ver); + tqDebug("vgId:%d, failed to find handle %s in pushing data to consumer, ignore", pTq->pVnode->config.vgId, + pPushEntry->subKey); continue; } STqExecHandle* pExec = &pHandle->execHandle; - qTaskInfo_t task = pExec->task; - - SMqDataRsp* pRsp = &pPushEntry->dataRsp; - - // prepare scan mem data - SPackedData submit = { - .msgStr = data, - .msgLen = len, - .ver = ver, - }; - qStreamSetScanMemData(task, submit); - - // here start to scan submit block to extract the subscribed data - while (1) { - SSDataBlock* pDataBlock = NULL; - uint64_t ts = 0; - if (qExecTask(task, &pDataBlock, &ts) < 0) { - tqDebug("vgId:%d, tq exec error since %s", pTq->pVnode->config.vgId, terrstr()); - } - - if (pDataBlock == NULL) { - break; - } - - tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision); - pRsp->blockNum++; - } - - tqDebug("vgId:%d, tq handle push, subkey:%s, block num:%d", pTq->pVnode->config.vgId, pPushEntry->subKey, - pRsp->blockNum); - if (pRsp->blockNum > 0) { - // set offset - tqOffsetResetToLog(&pRsp->rspOffset, ver); - // remove from hash - size_t kLen; - void* key = taosHashGetKey(pIter, &kLen); - void* keyCopy = taosMemoryCalloc(1, kLen + 1); - memcpy(keyCopy, key, kLen); - - taosArrayPush(cachedKeys, &keyCopy); - taosArrayPush(cachedKeyLens, &kLen); - - tqPushDataRsp(pTq, pPushEntry); - } + doPushDataForEntry(pIter, pExec, pTq, ver, vgId, data, len, cachedKey); } - // delete entry - for (int32_t i = 0; i < taosArrayGetSize(cachedKeys); i++) { - void* key = taosArrayGetP(cachedKeys, i); - size_t kLen = *(size_t*)taosArrayGet(cachedKeyLens, i); - if (taosHashRemove(pTq->pPushMgr, key, kLen) != 0) { - tqError("vgId:%d, tq push hash remove key error, key: %s", pTq->pVnode->config.vgId, (char*)key); - } - } - taosArrayDestroyP(cachedKeys, (FDelete)taosMemoryFree); - taosArrayDestroy(cachedKeyLens); + doRemovePushedEntry(cachedKey, pTq); + taosArrayDestroyEx(cachedKey, freeItem); taosMemoryFree(data); } + // unlock - taosWUnLockLatch(&pTq->pushLock); + taosWUnLockLatch(&pTq->lock); } + // push data for stream processing if (!tsDisableStream && vnodeIsRoleLeader(pTq->pVnode)) { - if (taosHashGetSize(pTq->pStreamMeta->pTasks) == 0) return 0; + if (taosHashGetSize(pTq->pStreamMeta->pTasks) == 0) { + return 0; + } + if (msgType == TDMT_VND_SUBMIT) { void* data = taosMemoryMalloc(len); if (data == NULL) { @@ -326,17 +351,14 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) tqError("failed to copy data for stream since out of memory"); return -1; } + memcpy(data, pReq, len); - SPackedData submit = { - .msgStr = data, - .msgLen = len, - .ver = ver, - }; + SPackedData submit = {.msgStr = data, .msgLen = len, .ver = ver}; tqDebug("tq copy write msg %p %d %" PRId64 " from %p", data, len, ver, pReq); - tqProcessSubmitReq(pTq, submit); } + if (msgType == TDMT_VND_DELETE) { tqProcessDelReq(pTq, POINTER_SHIFT(msg, sizeof(SMsgHead)), msgLen - sizeof(SMsgHead), ver); } @@ -344,3 +366,68 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) return 0; } + +void recordPushedEntry(SArray* cachedKey, void* pIter) { + size_t kLen = 0; + void* key = taosHashGetKey(pIter, &kLen); + SItem item = {.pKey = strndup(key, kLen), .keyLen = kLen}; + taosArrayPush(cachedKey, &item); +} + +int32_t tqRegisterPushEntry(STQ* pTq, void* pHandle, const SMqPollReq* pRequest, SRpcMsg* pRpcMsg, SMqDataRsp* pDataRsp, + int32_t type) { + uint64_t consumerId = pRequest->consumerId; + int32_t vgId = TD_VID(pTq->pVnode); + STqHandle* pTqHandle = pHandle; + + STqPushEntry* pPushEntry = taosMemoryCalloc(1, sizeof(STqPushEntry)); + if (pPushEntry == NULL) { + tqDebug("tmq poll: consumer:0x%" PRIx64 ", vgId:%d failed to malloc, size:%d", consumerId, vgId, + (int32_t)sizeof(STqPushEntry)); + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + pPushEntry->info = pRpcMsg->info; + memcpy(pPushEntry->subKey, pTqHandle->subKey, TSDB_SUBSCRIBE_KEY_LEN); + + if (type == TMQ_MSG_TYPE__TAOSX_RSP) { + pPushEntry->pDataRsp = taosMemoryCalloc(1, sizeof(STaosxRsp)); + memcpy(pPushEntry->pDataRsp, pDataRsp, sizeof(STaosxRsp)); + } else if (type == TMQ_MSG_TYPE__POLL_RSP) { + pPushEntry->pDataRsp = taosMemoryCalloc(1, sizeof(SMqDataRsp)); + memcpy(pPushEntry->pDataRsp, pDataRsp, sizeof(SMqDataRsp)); + } + + SMqRspHead* pHead = &pPushEntry->pDataRsp->head; + pHead->consumerId = consumerId; + pHead->epoch = pRequest->epoch; + pHead->mqMsgType = type; + + taosHashPut(pTq->pPushMgr, pTqHandle->subKey, strlen(pTqHandle->subKey), &pPushEntry, sizeof(void*)); + + tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s offset:%" PRId64 ", vgId:%d save handle to push mgr, total:%d", + consumerId, pTqHandle->subKey, pDataRsp->reqOffset.version, vgId, taosHashGetSize(pTq->pPushMgr)); + return 0; +} + +int32_t tqUnregisterPushEntry(STQ* pTq, const char* pKey, int32_t keyLen, uint64_t consumerId, bool rspConsumer) { + int32_t vgId = TD_VID(pTq->pVnode); + STqPushEntry** pEntry = taosHashGet(pTq->pPushMgr, pKey, keyLen); + + if (pEntry != NULL) { + uint64_t cId = (*pEntry)->pDataRsp->head.consumerId; + ASSERT(consumerId == cId); + + tqDebug("tmq poll: consumer:0x%" PRIx64 ", subkey %s vgId:%d remove from push mgr, remains:%d", consumerId, + (*pEntry)->subKey, vgId, taosHashGetSize(pTq->pPushMgr) - 1); + + if (rspConsumer) { // rsp the old consumer with empty block. + tqPushDataRsp(pTq, *pEntry); + } + + taosHashRemove(pTq->pPushMgr, pKey, keyLen); + } + + return 0; +} diff --git a/source/dnode/vnode/src/tq/tqRead.c b/source/dnode/vnode/src/tq/tqRead.c index bf73cca9252b80dae6bd988ce0d78b88e6eca5c7..90ff1f8a84800eb7c1c857b35e48f3cd34359476 100644 --- a/source/dnode/vnode/src/tq/tqRead.c +++ b/source/dnode/vnode/src/tq/tqRead.c @@ -183,22 +183,24 @@ end: return tbSuid == realTbSuid; } -int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** ppCkHead) { +int32_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHead** ppCkHead, uint64_t reqId) { int32_t code = 0; + int32_t vgId = TD_VID(pTq->pVnode); + taosThreadMutexLock(&pHandle->pWalReader->mutex); int64_t offset = *fetchOffset; while (1) { if (walFetchHead(pHandle->pWalReader, offset, *ppCkHead) < 0) { - tqDebug("tmq poll: consumer:%" PRId64 ", (epoch %d) vgId:%d offset %" PRId64 ", no more log to return", - pHandle->consumerId, pHandle->epoch, TD_VID(pTq->pVnode), offset); + tqDebug("tmq poll: consumer:0x%" PRIx64 ", (epoch %d) vgId:%d offset %" PRId64 ", no more log to return, reqId:0x%"PRIx64, + pHandle->consumerId, pHandle->epoch, vgId, offset, reqId); *fetchOffset = offset - 1; code = -1; goto END; } - tqDebug("vgId:%d, taosx get msg ver %" PRId64 ", type: %s", pTq->pVnode->config.vgId, offset, - TMSG_INFO((*ppCkHead)->head.msgType)); + tqDebug("vgId:%d, consumer:0x%" PRIx64 " taosx get msg ver %" PRId64 ", type: %s, reqId:0x%" PRIx64, vgId, + pHandle->consumerId, offset, TMSG_INFO((*ppCkHead)->head.msgType), reqId); if ((*ppCkHead)->head.msgType == TDMT_VND_SUBMIT) { code = walFetchBody(pHandle->pWalReader, ppCkHead); @@ -241,6 +243,7 @@ int64_t tqFetchLog(STQ* pTq, STqHandle* pHandle, int64_t* fetchOffset, SWalCkHea offset++; } } + END: taosThreadMutexUnlock(&pHandle->pWalReader->mutex); return code; @@ -294,7 +297,7 @@ int32_t tqSeekVer(STqReader* pReader, int64_t ver, const char* id) { // todo set the correct vgId tqDebug("tmq poll: wal seek to version:%"PRId64" %s", ver, id); if (walReadSeekVer(pReader->pWalReader, ver) < 0) { - tqError("tmq poll: wal reader failed to seek to ver:%"PRId64" code:%s, %s", ver, tstrerror(terrno), id); + tqDebug("tmq poll: wal reader failed to seek to ver:%"PRId64" code:%s, %s", ver, tstrerror(terrno), id); return -1; } else { tqDebug("tmq poll: wal reader seek to ver:%"PRId64" %s", ver, id); @@ -337,7 +340,7 @@ int32_t tqNextBlock(STqReader* pReader, SFetchRet* ret) { continue; } ret->fetchType = FETCH_TYPE__DATA; - tqDebug("return data rows %d", ret->data.info.rows); + tqDebug("return data rows %" PRId64, ret->data.info.rows); return 0; } @@ -707,7 +710,10 @@ int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader, SSubmitTbD sourceIdx++; targetIdx++; } else { - ASSERT(0); + for (int32_t i = 0; i < pCol->nVal; i++) { + colDataSetNULL(pColData, i); + } + targetIdx++; } } } else { @@ -749,7 +755,8 @@ int32_t tqRetrieveDataBlock2(SSDataBlock* pBlock, STqReader* pReader, SSubmitTbD sourceIdx++; break; } else { - ASSERT(0); + colDataSetNULL(pColData, i); + break; } } } diff --git a/source/dnode/vnode/src/tq/tqExec.c b/source/dnode/vnode/src/tq/tqScan.c similarity index 82% rename from source/dnode/vnode/src/tq/tqExec.c rename to source/dnode/vnode/src/tq/tqScan.c index f97c5ce93c7b46c74946d87186f405c2b93101e8..6528b7c8d2a82f79f97cd984cb9d918f26dbacc6 100644 --- a/source/dnode/vnode/src/tq/tqExec.c +++ b/source/dnode/vnode/src/tq/tqScan.c @@ -18,7 +18,9 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t numOfCols, int8_t precision) { int32_t dataStrLen = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock); void* buf = taosMemoryCalloc(1, dataStrLen); - if (buf == NULL) return -1; + if (buf == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } SRetrieveTableRsp* pRetrieve = (SRetrieveTableRsp*)buf; pRetrieve->useconds = 0; @@ -31,7 +33,8 @@ int32_t tqAddBlockDataToRsp(const SSDataBlock* pBlock, SMqDataRsp* pRsp, int32_t actualLen += sizeof(SRetrieveTableRsp); taosArrayPush(pRsp->blockDataLen, &actualLen); taosArrayPush(pRsp->blockData, &buf); - return 0; + + return TSDB_CODE_SUCCESS; } static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, STaosxRsp* pRsp) { @@ -46,11 +49,13 @@ static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, STaosxRsp* pRsp static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, STaosxRsp* pRsp, int32_t n) { SMetaReader mr = {0}; metaReaderInit(&mr, pTq->pVnode->pMeta, 0); + // TODO add reference to gurantee success if (metaGetTableEntryByUidCache(&mr, uid) < 0) { metaReaderClear(&mr); return -1; } + for (int32_t i = 0; i < n; i++) { char* tbName = taosStrdup(mr.me.name); taosArrayPush(pRsp->blockTbName, &tbName); @@ -60,61 +65,84 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, STaosxRsp* pRsp, in } int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffsetVal* pOffset) { - const STqExecHandle* pExec = &pHandle->execHandle; + const int32_t MAX_ROWS_TO_RETURN = 4096; + int32_t vgId = TD_VID(pTq->pVnode); + int32_t code = 0; + int32_t totalRows = 0; - qTaskInfo_t task = pExec->task; + const STqExecHandle* pExec = &pHandle->execHandle; + qTaskInfo_t task = pExec->task; if (qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType) < 0) { - tqDebug("prepare scan failed, return"); + tqDebug("prepare scan failed, vgId:%d, consumer:0x%" PRIx64, vgId, pHandle->consumerId); if (pOffset->type == TMQ_OFFSET__LOG) { pRsp->rspOffset = *pOffset; - return 0; + return code; } else { tqOffsetResetToLog(pOffset, pHandle->snapshotVer); if (qStreamPrepareScan(task, pOffset, pHandle->execHandle.subType) < 0) { - tqDebug("prepare scan failed, return"); + tqDebug("prepare scan failed, vgId:%d, consumer:0x%" PRIx64, vgId, pHandle->consumerId); pRsp->rspOffset = *pOffset; - return 0; + return code; } } } - int32_t rowCnt = 0; while (1) { SSDataBlock* pDataBlock = NULL; uint64_t ts = 0; - tqDebug("vgId:%d, tmq task start to execute", pTq->pVnode->config.vgId); - if (qExecTask(task, &pDataBlock, &ts) < 0) { - tqError("vgId:%d, task exec error since %s", pTq->pVnode->config.vgId, terrstr()); - return -1; + + tqDebug("vgId:%d, tmq task start to execute, consumer:0x%" PRIx64, vgId, pHandle->consumerId); + + code = qExecTask(task, &pDataBlock, &ts); + if (code != TSDB_CODE_SUCCESS) { + tqError("vgId:%d, task exec error since %s, consumer:0x%" PRIx64, vgId, terrstr(), pHandle->consumerId); + return code; } - tqDebug("vgId:%d, tmq task executed, get %p", pTq->pVnode->config.vgId, pDataBlock); + // current scan should be stopped ASAP, since the re-balance occurs. if (pDataBlock == NULL) { break; } - tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision); + code = tqAddBlockDataToRsp(pDataBlock, pRsp, pExec->numOfCols, pTq->pVnode->config.tsdbCfg.precision); + if (code != TSDB_CODE_SUCCESS) { + tqError("vgId:%d, failed to add block to rsp msg", vgId); + return code; + } + pRsp->blockNum++; + tqDebug("vgId:%d, consumer:0x%" PRIx64 " tmq task executed, rows:%" PRId64 ", total blocks:%d", vgId, + pHandle->consumerId, pDataBlock->info.rows, pRsp->blockNum); + if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { - rowCnt += pDataBlock->info.rows; - if (rowCnt >= 4096) break; + totalRows += pDataBlock->info.rows; + if (totalRows >= MAX_ROWS_TO_RETURN) { + break; + } } } - if (qStreamExtractOffset(task, &pRsp->rspOffset) < 0) { - return -1; - } + qStreamExtractOffset(task, &pRsp->rspOffset); if (pRsp->rspOffset.type == 0) { - tqError("expected rsp offset: type %d %" PRId64 " %" PRId64 " %" PRId64, pRsp->rspOffset.type, pRsp->rspOffset.ts, - pRsp->rspOffset.uid, pRsp->rspOffset.version); - return -1; + code = TSDB_CODE_INVALID_PARA; + tqError("vgId:%d, expected rsp offset: type %d %" PRId64 " %" PRId64 " %" PRId64, vgId, pRsp->rspOffset.type, + pRsp->rspOffset.ts, pRsp->rspOffset.uid, pRsp->rspOffset.version); + return code; } - ASSERT(!(pRsp->withTbName || pRsp->withSchema)); - return 0; + if (pRsp->withTbName || pRsp->withSchema) { + code = TSDB_CODE_INVALID_PARA; + tqError("vgId:%d, get column should not with meta:%d,%d", vgId, pRsp->withTbName, pRsp->withSchema); + return code; + } + + tqDebug("vgId:%d, consumer:0x%" PRIx64 " tmq task executed, total blocks:%d, rows:%d", vgId, pHandle->consumerId, + pRsp->blockNum, totalRows); + + return code; } int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMetaRsp* pMetaRsp, STqOffsetVal* pOffset) { @@ -220,23 +248,15 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta return 0; } -int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp) { +int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxRsp* pRsp, int32_t* totalRows) { STqExecHandle* pExec = &pHandle->execHandle; - /*A(pExec->subType != TOPIC_SUB_TYPE__COLUMN);*/ - - SArray* pBlocks = taosArrayInit(0, sizeof(SSDataBlock)); - SArray* pSchemas = taosArrayInit(0, sizeof(void*)); + SArray* pBlocks = taosArrayInit(0, sizeof(SSDataBlock)); + SArray* pSchemas = taosArrayInit(0, sizeof(void*)); if (pExec->subType == TOPIC_SUB_TYPE__TABLE) { STqReader* pReader = pExec->pExecReader; - /*tqReaderSetDataMsg(pReader, pReq, 0);*/ tqReaderSetSubmitReq2(pReader, submit.msgStr, submit.msgLen, submit.ver); while (tqNextDataBlock2(pReader)) { - /*SSDataBlock block = {0};*/ - /*if (tqRetrieveDataBlock(&block, pReader) < 0) {*/ - /*if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;*/ - /*}*/ - taosArrayClear(pBlocks); taosArrayClear(pSchemas); SSubmitTbData* pSubmitTbDataRet = NULL; @@ -244,7 +264,6 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue; } if (pRsp->withTbName) { - /*int64_t uid = pExec->pExecReader->msgIter.uid;*/ int64_t uid = pExec->pExecReader->lastBlkUid; if (tqAddTbNameToRsp(pTq, uid, pRsp, taosArrayGetSize(pBlocks)) < 0) { taosArrayDestroyEx(pBlocks, (FDelete)blockDataFreeRes); @@ -266,7 +285,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR if (TSDB_CODE_SUCCESS != code) { continue; } - void* createReq = taosMemoryCalloc(1, len); + void* createReq = taosMemoryCalloc(1, len); SEncoder encoder = {0}; tEncoderInit(&encoder, createReq, len); code = tEncodeSVCreateTbReq(&encoder, pSubmitTbDataRet->pCreateTbReq); @@ -286,6 +305,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR SSDataBlock* pBlock = taosArrayGet(pBlocks, i); tqAddBlockDataToRsp(pBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pBlock->pDataBlock), pTq->pVnode->config.tsdbCfg.precision); + totalRows += pBlock->info.rows; blockDataFreeRes(pBlock); SSchemaWrapper* pSW = taosArrayGetP(pSchemas, i); taosArrayPush(pRsp->blockSchema, &pSW); @@ -294,13 +314,8 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR } } else if (pExec->subType == TOPIC_SUB_TYPE__DB) { STqReader* pReader = pExec->pExecReader; - /*tqReaderSetDataMsg(pReader, pReq, 0);*/ tqReaderSetSubmitReq2(pReader, submit.msgStr, submit.msgLen, submit.ver); while (tqNextDataBlockFilterOut2(pReader, pExec->execDb.pFilterOutTbUid)) { - /*SSDataBlock block = {0};*/ - /*if (tqRetrieveDataBlock(&block, pReader) < 0) {*/ - /*if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;*/ - /*}*/ taosArrayClear(pBlocks); taosArrayClear(pSchemas); SSubmitTbData* pSubmitTbDataRet = NULL; @@ -329,7 +344,7 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR if (TSDB_CODE_SUCCESS != code) { continue; } - void* createReq = taosMemoryCalloc(1, len); + void* createReq = taosMemoryCalloc(1, len); SEncoder encoder = {0}; tEncoderInit(&encoder, createReq, len); code = tEncodeSVCreateTbReq(&encoder, pSubmitTbDataRet->pCreateTbReq); @@ -345,15 +360,11 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR tEncoderClear(&encoder); } - /*tqAddBlockDataToRsp(&block, (SMqDataRsp*)pRsp, taosArrayGetSize(block.pDataBlock),*/ - /*pTq->pVnode->config.tsdbCfg.precision);*/ - /*blockDataFreeRes(&block);*/ - /*tqAddBlockSchemaToRsp(pExec, (SMqDataRsp*)pRsp);*/ - /*pRsp->blockNum++;*/ for (int32_t i = 0; i < taosArrayGetSize(pBlocks); i++) { SSDataBlock* pBlock = taosArrayGet(pBlocks, i); tqAddBlockDataToRsp(pBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pBlock->pDataBlock), pTq->pVnode->config.tsdbCfg.precision); + *totalRows += pBlock->info.rows; blockDataFreeRes(pBlock); SSchemaWrapper* pSW = taosArrayGetP(pSchemas, i); taosArrayPush(pRsp->blockSchema, &pSW); @@ -363,9 +374,5 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SPackedData submit, STaosxR } taosArrayDestroy(pBlocks); taosArrayDestroy(pSchemas); -// if (pRsp->blockNum == 0) { -// return -1; -// } - return 0; } diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index aaf3dc3936164fc927ce02ff986ee5939ca71349..e2ab1e736993d46dda2d4c591fca59bddeed6930 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -333,6 +333,8 @@ void tqSinkToTablePipeline2(SStreamTask* pTask, void* vnode, int64_t ver, void* tTagNew(tagArray, 1, false, &pTag); tagArray = taosArrayDestroy(tagArray); if (pTag == NULL) { + taosMemoryFree(ctbName); + tdDestroySVCreateTbReq(pCreateTbReq); terrno = TSDB_CODE_OUT_OF_MEMORY; taosMemoryFree(ctbName); tdDestroySVCreateTbReq(pCreateTbReq); diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index 58401cdf44cb8a5fd7b741112c3e77c6c8266378..48d33712845503aa8b69911dff837a81968ea319 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -590,15 +590,18 @@ typedef struct { SDataFReader **pDataFReader; TSDBROW row; + bool checkRemainingRow; SMergeTree mergeTree; SMergeTree *pMergeTree; SSttBlockLoadInfo *pLoadInfo; int64_t lastTs; } SFSLastNextRowIter; -static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlierTs) { +static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlierTs, bool isLast, int16_t *aCols, + int nCols) { SFSLastNextRowIter *state = (SFSLastNextRowIter *)iter; int32_t code = 0; + bool checkRemainingRow = true; switch (state->state) { case SFSLASTNEXTROW_FS: @@ -631,29 +634,42 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow, bool *pIgnoreEa if (code) goto _err; } + for (int i = 0; i < state->pLoadInfo->numOfStt; ++i) { + state->pLoadInfo[i].colIds = aCols; + state->pLoadInfo[i].numOfCols = nCols; + state->pLoadInfo[i].isLast = isLast; + } tMergeTreeOpen(&state->mergeTree, 1, *state->pDataFReader, state->suid, state->uid, - &(STimeWindow){.skey = TSKEY_MIN, .ekey = TSKEY_MAX}, - &(SVersionRange){.minVer = 0, .maxVer = UINT64_MAX}, state->pLoadInfo, false, NULL); + &(STimeWindow){.skey = state->lastTs, .ekey = TSKEY_MAX}, + &(SVersionRange){.minVer = 0, .maxVer = UINT64_MAX}, state->pLoadInfo, false, NULL, true); state->pMergeTree = &state->mergeTree; + state->state = SFSLASTNEXTROW_BLOCKROW; + } + case SFSLASTNEXTROW_BLOCKROW: { + if (nCols != state->pLoadInfo->numOfCols) { + for (int i = 0; i < state->pLoadInfo->numOfStt; ++i) { + state->pLoadInfo[i].numOfCols = nCols; + + state->pLoadInfo[i].checkRemainingRow = state->checkRemainingRow; + } + } bool hasVal = tMergeTreeNext(&state->mergeTree); if (!hasVal) { + if (tMergeTreeIgnoreEarlierTs(&state->mergeTree)) { + *pIgnoreEarlierTs = true; + *ppRow = NULL; + return code; + } state->state = SFSLASTNEXTROW_FILESET; goto _next_fileset; } - state->state = SFSLASTNEXTROW_BLOCKROW; - } - case SFSLASTNEXTROW_BLOCKROW: { - bool hasVal = false; - do { - state->row = tMergeTreeGetRow(&state->mergeTree); - *ppRow = &state->row; - hasVal = tMergeTreeNext(&state->mergeTree); - } while (TSDBROW_TS(&state->row) <= state->lastTs && hasVal); + state->row = tMergeTreeGetRow(&state->mergeTree); + *ppRow = &state->row; if (TSDBROW_TS(&state->row) <= state->lastTs) { *pIgnoreEarlierTs = true; - state->state = SFSLASTNEXTROW_FILESET; - goto _next_fileset; + *ppRow = NULL; + return code; } *pIgnoreEarlierTs = false; @@ -661,6 +677,9 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow, bool *pIgnoreEa state->state = SFSLASTNEXTROW_FILESET; } + if (!state->checkRemainingRow) { + state->checkRemainingRow = true; + } return code; } default: @@ -738,9 +757,11 @@ typedef struct SFSNextRowIter { int64_t lastTs; } SFSNextRowIter; -static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlierTs) { +static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlierTs, bool isLast, int16_t *aCols, + int nCols) { SFSNextRowIter *state = (SFSNextRowIter *)iter; int32_t code = 0; + bool checkRemainingRow = true; switch (state->state) { case SFSNEXTROW_FS: @@ -826,8 +847,11 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie } } case SFSNEXTROW_BLOCKDATA: + _next_datablock: if (state->iBlock >= 0) { SDataBlk block = {0}; + bool skipBlock = true; + int inputColIndex = 0; tDataBlkReset(&block); tBlockDataReset(state->pBlockData); @@ -835,23 +859,105 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie tMapDataGetItemByIdx(&state->blockMap, state->iBlock, &block, tGetDataBlk); if (block.maxKey.ts <= state->lastTs) { *pIgnoreEarlierTs = true; - goto _next_fileset; + if (state->pBlockData) { + tBlockDataDestroy(state->pBlockData); + state->pBlockData = NULL; + } + + *ppRow = NULL; + return code; } *pIgnoreEarlierTs = false; tBlockDataReset(state->pBlockData); TABLEID tid = {.suid = state->suid, .uid = state->uid}; - code = tBlockDataInit(state->pBlockData, &tid, state->pTSchema, NULL, 0); + code = tBlockDataInit(state->pBlockData, &tid, state->pTSchema, aCols, nCols); if (code) goto _err; code = tsdbReadDataBlock(*state->pDataFReader, &block, state->pBlockData); if (code) goto _err; + for (int colIndex = 0; colIndex < state->pBlockData->nColData; ++colIndex) { + SColData *pColData = &state->pBlockData->aColData[colIndex]; + + if (isLast && (pColData->flag & HAS_VALUE)) { + skipBlock = false; + break; + } else if (pColData->flag & (HAS_VALUE | HAS_NULL)) { + skipBlock = false; + break; + } + } + + if (skipBlock) { + if (--state->iBlock < 0) { + tsdbDataFReaderClose(state->pDataFReader); + *state->pDataFReader = NULL; + // resetLastBlockLoadInfo(state->pLoadInfo); + + if (state->aBlockIdx) { + // taosArrayDestroy(state->aBlockIdx); + tsdbBICacheRelease(state->pTsdb->biCache, state->aBlockIdxHandle); + + state->aBlockIdxHandle = NULL; + state->aBlockIdx = NULL; + } + + state->state = SFSNEXTROW_FILESET; + goto _next_fileset; + } else { + goto _next_datablock; + } + } + state->nRow = state->blockData.nRow; state->iRow = state->nRow - 1; state->state = SFSNEXTROW_BLOCKROW; + checkRemainingRow = false; } - case SFSNEXTROW_BLOCKROW: + case SFSNEXTROW_BLOCKROW: { + if (checkRemainingRow) { + bool skipBlock = true; + int inputColIndex = 0; + for (int colIndex = 0; colIndex < state->pBlockData->nColData; ++colIndex) { + SColData *pColData = &state->pBlockData->aColData[colIndex]; + int16_t cid = pColData->cid; + + if (inputColIndex < nCols && cid == aCols[inputColIndex]) { + if (isLast && (pColData->flag & HAS_VALUE)) { + skipBlock = false; + break; + } else if (pColData->flag & (HAS_VALUE | HAS_NULL)) { + skipBlock = false; + break; + } + + ++inputColIndex; + } + } + + if (skipBlock) { + if (--state->iBlock < 0) { + tsdbDataFReaderClose(state->pDataFReader); + *state->pDataFReader = NULL; + // resetLastBlockLoadInfo(state->pLoadInfo); + + if (state->aBlockIdx) { + // taosArrayDestroy(state->aBlockIdx); + tsdbBICacheRelease(state->pTsdb->biCache, state->aBlockIdxHandle); + + state->aBlockIdxHandle = NULL; + state->aBlockIdx = NULL; + } + + state->state = SFSNEXTROW_FILESET; + goto _next_fileset; + } else { + goto _next_datablock; + } + } + } + if (state->iRow >= 0) { state->row = tsdbRowFromBlockData(state->pBlockData, state->iRow); *ppRow = &state->row; @@ -877,6 +983,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlie } return code; + } default: ASSERT(0); break; @@ -952,7 +1059,8 @@ typedef struct SMemNextRowIter { // TSDBROW *curRow; } SMemNextRowIter; -static int32_t getNextRowFromMem(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlierTs) { +static int32_t getNextRowFromMem(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlierTs, bool isLast, int16_t *aCols, + int nCols) { SMemNextRowIter *state = (SMemNextRowIter *)iter; int32_t code = 0; *pIgnoreEarlierTs = false; @@ -1064,7 +1172,8 @@ static bool tsdbKeyDeleted(TSDBKEY *key, SArray *pSkyline, int64_t *iSkyline) { return deleted; } -typedef int32_t (*_next_row_fn_t)(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlierTs); +typedef int32_t (*_next_row_fn_t)(void *iter, TSDBROW **ppRow, bool *pIgnoreEarlierTs, bool isLast, int16_t *aCols, + int nCols); typedef int32_t (*_next_row_clear_fn_t)(void *iter); typedef struct { @@ -1214,12 +1323,14 @@ _err: } // iterate next row non deleted backward ts, version (from high to low) -static int32_t nextRowIterGet(CacheNextRowIter *pIter, TSDBROW **ppRow, bool *pIgnoreEarlierTs) { +static int32_t nextRowIterGet(CacheNextRowIter *pIter, TSDBROW **ppRow, bool *pIgnoreEarlierTs, bool isLast, + int16_t *aCols, int nCols) { int code = 0; for (;;) { for (int i = 0; i < 4; ++i) { if (pIter->input[i].next && !pIter->input[i].stop) { - code = pIter->input[i].nextRowFn(pIter->input[i].iter, &pIter->input[i].pRow, &pIter->input[i].ignoreEarlierTs); + code = pIter->input[i].nextRowFn(pIter->input[i].iter, &pIter->input[i].pRow, &pIter->input[i].ignoreEarlierTs, + isLast, aCols, nCols); if (code) goto _err; if (pIter->input[i].pRow == NULL) { @@ -1350,7 +1461,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, SArray **ppCo do { TSDBROW *pRow = NULL; - nextRowIterGet(&iter, &pRow, &ignoreEarlierTs); + nextRowIterGet(&iter, &pRow, &ignoreEarlierTs, false, NULL, 0); if (!pRow) { break; @@ -1480,11 +1591,21 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SCach bool ignoreEarlierTs = false; SArray *pColArray = NULL; SColVal *pColVal = &(SColVal){0}; + int16_t nCols = nLastCol; int32_t code = initLastColArray(pTSchema, &pColArray); if (TSDB_CODE_SUCCESS != code) { return code; } + SArray *aColArray = taosArrayInit(nCols, sizeof(int16_t)); + if (NULL == aColArray) { + taosArrayDestroy(pColArray); + + return TSDB_CODE_OUT_OF_MEMORY; + } + for (int i = 1; i < pTSchema->numOfCols; ++i) { + taosArrayPush(aColArray, &pTSchema->columns[i].colId); + } TSKEY lastRowTs = TSKEY_MAX; @@ -1494,7 +1615,7 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SCach do { TSDBROW *pRow = NULL; - nextRowIterGet(&iter, &pRow, &ignoreEarlierTs); + nextRowIterGet(&iter, &pRow, &ignoreEarlierTs, true, TARRAY_DATA(aColArray), TARRAY_SIZE(aColArray)); if (!pRow) { break; @@ -1539,9 +1660,14 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SCach memcpy(pCol->colVal.value.pData, pColVal->value.pData, pColVal->value.nData); } - if (!COL_VAL_IS_VALUE(pColVal) && !setNoneCol) { - noneCol = iCol; - setNoneCol = true; + if (!COL_VAL_IS_VALUE(pColVal)) { + if (!setNoneCol) { + noneCol = iCol; + setNoneCol = true; + } + } else { + int32_t aColIndex = taosArraySearchIdx(aColArray, &pColVal->cid, compareInt16Val, TD_EQ); + taosArrayRemove(aColArray, aColIndex); } } if (!setNoneCol) { @@ -1582,6 +1708,8 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SCach } taosArraySet(pColArray, iCol, &lastCol); + int32_t aColIndex = taosArraySearchIdx(aColArray, &lastCol.colVal.cid, compareInt16Val, TD_EQ); + taosArrayRemove(aColArray, aColIndex); } else if (!COL_VAL_IS_VALUE(tColVal) && !COL_VAL_IS_VALUE(pColVal) && !setNoneCol) { noneCol = iCol; setNoneCol = true; @@ -1605,6 +1733,7 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray, SCach //} nextRowIterClose(&iter); + taosArrayDestroy(aColArray); // taosMemoryFreeClear(pTSchema); return code; @@ -1613,6 +1742,7 @@ _err: // taosMemoryFreeClear(pTSchema); *ppLastArray = NULL; taosArrayDestroy(pColArray); + taosArrayDestroy(aColArray); return code; } @@ -1724,6 +1854,15 @@ size_t tsdbCacheGetUsage(SVnode *pVnode) { return usage; } +int32_t tsdbCacheGetElems(SVnode *pVnode) { + int32_t elems = 0; + if (pVnode->pTsdb != NULL) { + elems = taosLRUCacheGetElems(pVnode->pTsdb->lruCache); + } + + return elems; +} + static void getBICacheKey(int32_t fid, int64_t commitID, char *key, int *len) { struct { int32_t fid; diff --git a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c index d9259507032894876ca3dad2e04c31da49054d09..95981c2f0888dd4b9b53b8726a2de3563bca79b8 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCacheRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbCacheRead.c @@ -118,7 +118,6 @@ static int32_t setTableSchema(SCacheRowsReader* p, uint64_t suid, const char* id if (suid != 0) { p->pSchema = metaGetTbTSchema(p->pVnode->pMeta, suid, -1, 1); if (p->pSchema == NULL) { - taosMemoryFree(p); tsdbWarn("stable:%" PRIu64 " has been dropped, failed to retrieve cached rows, %s", suid, idstr); return TSDB_CODE_PAR_TABLE_NOT_EXIST; } @@ -135,7 +134,6 @@ static int32_t setTableSchema(SCacheRowsReader* p, uint64_t suid, const char* id // all queried tables have been dropped already, return immediately. if (p->pSchema == NULL) { - taosMemoryFree(p); tsdbWarn("all queried tables has been dropped, try next group, %s", idstr); return TSDB_CODE_PAR_TABLE_NOT_EXIST; } @@ -332,6 +330,8 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32 // retrieve the only one last row of all tables in the uid list. if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_TYPE_SINGLE)) { + int64_t st = taosGetTimestampUs(); + int64_t totalLastTs = INT64_MAX; for (int32_t i = 0; i < pr->numOfTables; ++i) { STableKeyInfo* pKeyInfo = &pr->pTableList[i]; @@ -350,7 +350,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32 { bool hasNotNullRow = true; - int64_t minTs = INT64_MAX; + int64_t singleTableLastTs = INT64_MAX; for (int32_t k = 0; k < pr->numOfCols; ++k) { int32_t slotId = slotIds[k]; @@ -361,7 +361,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32 hasRes = true; p->ts = pCol->ts; p->colVal = pCol->colVal; - minTs = pCol->ts; + singleTableLastTs = pCol->ts; // only set value for last row query if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_LAST_ROW)) { @@ -386,8 +386,8 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32 hasRes = true; p->ts = pColVal->ts; - if (pColVal->ts < minTs && HASTYPE(pr->type, CACHESCAN_RETRIEVE_LAST)) { - minTs = pColVal->ts; + if (pColVal->ts < singleTableLastTs && HASTYPE(pr->type, CACHESCAN_RETRIEVE_LAST)) { + singleTableLastTs = pColVal->ts; } if (!IS_VAR_DATA_TYPE(pColVal->colVal.type)) { @@ -407,7 +407,13 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32 } if (hasNotNullRow) { - pr->lastTs = minTs; + if (INT64_MAX == totalLastTs || (INT64_MAX != singleTableLastTs && totalLastTs < singleTableLastTs)) { + totalLastTs = singleTableLastTs; + } + double cost = (taosGetTimestampUs() - st) / 1000.0; + if (cost > tsCacheLazyLoadThreshold) { + pr->lastTs = totalLastTs; + } } } @@ -417,7 +423,6 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32 if (hasRes) { saveOneRow(pLastCols, pResBlock, pr, slotIds, pRes, pr->idstr); } - } else if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_TYPE_ALL)) { for (int32_t i = pr->tableIndex; i < pr->numOfTables; ++i) { STableKeyInfo* pKeyInfo = &pr->pTableList[i]; diff --git a/source/dnode/vnode/src/tsdb/tsdbFS.c b/source/dnode/vnode/src/tsdb/tsdbFS.c index b85d8d7746978337710dc93f18b758d1493ecd45..5519d43012f46dc2e24ad56083ff421d5fcff1c5 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFS.c +++ b/source/dnode/vnode/src/tsdb/tsdbFS.c @@ -88,98 +88,6 @@ _exit: return code; } -extern int32_t tsdbDelFileToJson(const SDelFile *pDelFile, cJSON *pJson); -extern int32_t tsdbJsonToDelFile(const cJSON *pJson, SDelFile *pDelFile); -extern int32_t tsdbDFileSetToJson(const SDFileSet *pSet, cJSON *pJson); -extern int32_t tsdbJsonToDFileSet(const cJSON *pJson, SDFileSet *pDelFile); - -static int32_t tsdbFSToJsonStr(STsdbFS *pFS, char **ppStr) { - int32_t code = 0; - int32_t lino = 0; - cJSON *pJson; - - ppStr[0] = NULL; - - pJson = cJSON_CreateObject(); - TSDB_CHECK_NULL(pJson, code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - - // format version - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "format", 1), code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - - // SDelFile - if (pFS->pDelFile) { - code = tsdbDelFileToJson(pFS->pDelFile, cJSON_AddObjectToObject(pJson, "del")); - TSDB_CHECK_CODE(code, lino, _exit); - } - - // aDFileSet - cJSON *aSetJson = cJSON_AddArrayToObject(pJson, "file set"); - TSDB_CHECK_NULL(aSetJson, code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - for (int32_t iSet = 0; iSet < taosArrayGetSize(pFS->aDFileSet); iSet++) { - cJSON *pSetJson = cJSON_CreateObject(); - TSDB_CHECK_NULL(pSetJson, code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - - cJSON_AddItemToArray(aSetJson, pSetJson); - - code = tsdbDFileSetToJson(taosArrayGet(pFS->aDFileSet, iSet), pSetJson); - TSDB_CHECK_CODE(code, lino, _exit); - } - - // print - ppStr[0] = cJSON_Print(pJson); - TSDB_CHECK_NULL(ppStr[0], code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - -_exit: - cJSON_Delete(pJson); - if (code) tsdbError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); - return code; -} - -static int32_t tsdbJsonStrToFS(const char *pStr, STsdbFS *pFS) { - int32_t code = 0; - int32_t lino; - - cJSON *pJson = cJSON_Parse(pStr); - TSDB_CHECK(pJson, code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - - const cJSON *pItem; - - // format version - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "format")), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - - // SDelFile - if (cJSON_IsObject(pItem = cJSON_GetObjectItem(pJson, "del"))) { - pFS->pDelFile = (SDelFile *)taosMemoryCalloc(1, sizeof(SDelFile)); - TSDB_CHECK_NULL(pFS->pDelFile, code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - - code = tsdbJsonToDelFile(pItem, pFS->pDelFile); - TSDB_CHECK_CODE(code, lino, _exit); - - pFS->pDelFile->nRef = 1; - } else { - pFS->pDelFile = NULL; - } - - // aDFileSet - taosArrayClear(pFS->aDFileSet); - - const cJSON *pSetJson; - TSDB_CHECK(cJSON_IsArray(pItem = cJSON_GetObjectItem(pJson, "file set")), code, lino, _exit, - TSDB_CODE_FILE_CORRUPTED); - cJSON_ArrayForEach(pSetJson, pItem) { - SDFileSet *pSet = (SDFileSet *)taosArrayReserve(pFS->aDFileSet, 1); - TSDB_CHECK_NULL(pSet, code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - - code = tsdbJsonToDFileSet(pSetJson, pSet); - TSDB_CHECK_CODE(code, lino, _exit); - } - -_exit: - cJSON_Delete(pJson); - if (code) tsdbError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); - return code; -} - static int32_t tsdbSaveFSToFile(STsdbFS *pFS, const char *fname) { int32_t code = 0; int32_t lino = 0; @@ -224,84 +132,6 @@ _exit: return code; } -static int32_t tsdbSaveFSToJsonFile(STsdbFS *pFS, const char *fname) { - int32_t code; - int32_t lino; - char *pData; - - code = tsdbFSToJsonStr(pFS, &pData); - if (code) return code; - - TdFilePtr pFD = taosOpenFile(fname, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC); - if (pFD == NULL) { - code = TAOS_SYSTEM_ERROR(errno); - TSDB_CHECK_CODE(code, lino, _exit); - } - - int64_t n = taosWriteFile(pFD, pData, strlen(pData) + 1); - if (n < 0) { - code = TAOS_SYSTEM_ERROR(errno); - taosCloseFile(&pFD); - TSDB_CHECK_CODE(code, lino, _exit); - } - - if (taosFsyncFile(pFD) < 0) { - code = TAOS_SYSTEM_ERROR(errno); - taosCloseFile(&pFD); - TSDB_CHECK_CODE(code, lino, _exit); - } - - taosCloseFile(&pFD); - -_exit: - taosMemoryFree(pData); - if (code) { - tsdbError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); - } - - return code; -} - -static int32_t tsdbLoadFSFromJsonFile(const char *fname, STsdbFS *pFS) { - int32_t code = 0; - int32_t lino = 0; - char *pData = NULL; - - TdFilePtr pFD = taosOpenFile(fname, TD_FILE_READ); - if (pFD == NULL) { - code = TAOS_SYSTEM_ERROR(errno); - TSDB_CHECK_CODE(code, lino, _exit); - } - - int64_t size; - if (taosFStatFile(pFD, &size, NULL) < 0) { - code = TAOS_SYSTEM_ERROR(errno); - taosCloseFile(&pFD); - TSDB_CHECK_CODE(code, lino, _exit); - } - - if ((pData = taosMemoryMalloc(size)) == NULL) { - code = TSDB_CODE_OUT_OF_MEMORY; - taosCloseFile(&pFD); - TSDB_CHECK_CODE(code, lino, _exit); - } - - if (taosReadFile(pFD, pData, size) < 0) { - code = TAOS_SYSTEM_ERROR(errno); - taosCloseFile(&pFD); - TSDB_CHECK_CODE(code, lino, _exit); - } - - taosCloseFile(&pFD); - - TSDB_CHECK_CODE(code = tsdbJsonStrToFS(pData, pFS), lino, _exit); - -_exit: - if (pData) taosMemoryFree(pData); - if (code) tsdbError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); - return code; -} - int32_t tsdbFSCreate(STsdbFS *pFS) { int32_t code = 0; @@ -439,8 +269,7 @@ int32_t tDFileSetCmprFn(const void *p1, const void *p2) { return 0; } -static void tsdbGetCurrentFName(STsdb *pTsdb, char *current, char *current_t, char *current_json, - char *current_json_t) { +static void tsdbGetCurrentFName(STsdb *pTsdb, char *current, char *current_t) { SVnode *pVnode = pTsdb->pVnode; if (pVnode->pTfs) { if (current) { @@ -451,14 +280,6 @@ static void tsdbGetCurrentFName(STsdb *pTsdb, char *current, char *current_t, ch snprintf(current_t, TSDB_FILENAME_LEN - 1, "%s%s%s%sCURRENT.t", tfsGetPrimaryPath(pTsdb->pVnode->pTfs), TD_DIRSEP, pTsdb->path, TD_DIRSEP); } - if (current_json) { - snprintf(current_json, TSDB_FILENAME_LEN - 1, "%s%s%s%scurrent.json", tfsGetPrimaryPath(pTsdb->pVnode->pTfs), - TD_DIRSEP, pTsdb->path, TD_DIRSEP); - } - if (current_json_t) { - snprintf(current_json_t, TSDB_FILENAME_LEN - 1, "%s%s%s%scurrent.json.t", tfsGetPrimaryPath(pTsdb->pVnode->pTfs), - TD_DIRSEP, pTsdb->path, TD_DIRSEP); - } } else { if (current) { snprintf(current, TSDB_FILENAME_LEN - 1, "%s%sCURRENT", pTsdb->path, TD_DIRSEP); @@ -466,12 +287,6 @@ static void tsdbGetCurrentFName(STsdb *pTsdb, char *current, char *current_t, ch if (current_t) { snprintf(current_t, TSDB_FILENAME_LEN - 1, "%s%sCURRENT.t", pTsdb->path, TD_DIRSEP); } - if (current_json) { - snprintf(current_json, TSDB_FILENAME_LEN - 1, "%s%scurrent.json", pTsdb->path, TD_DIRSEP); - } - if (current_json_t) { - snprintf(current_json_t, TSDB_FILENAME_LEN - 1, "%s%scurrent.json.t", pTsdb->path, TD_DIRSEP); - } } } @@ -887,15 +702,20 @@ _exit: return code; } -static int32_t tsdbFSCommitImpl(STsdb *pTsdb, const char *fname, const char *tfname, bool isJson) { +// EXPOSED APIS ==================================================================================== +int32_t tsdbFSCommit(STsdb *pTsdb) { int32_t code = 0; int32_t lino = 0; STsdbFS fs = {0}; - if (!taosCheckExistFile(tfname)) goto _exit; + char current[TSDB_FILENAME_LEN] = {0}; + char current_t[TSDB_FILENAME_LEN] = {0}; + tsdbGetCurrentFName(pTsdb, current, current_t); + + if (!taosCheckExistFile(current_t)) goto _exit; // rename the file - if (taosRenameFile(tfname, fname) < 0) { + if (taosRenameFile(current_t, current) < 0) { code = TAOS_SYSTEM_ERROR(errno); TSDB_CHECK_CODE(code, lino, _exit); } @@ -904,11 +724,7 @@ static int32_t tsdbFSCommitImpl(STsdb *pTsdb, const char *fname, const char *tfn code = tsdbFSCreate(&fs); TSDB_CHECK_CODE(code, lino, _exit); - if (isJson) { - code = tsdbLoadFSFromJsonFile(fname, &fs); - } else { - code = tsdbLoadFSFromFile(fname, &fs); - } + code = tsdbLoadFSFromFile(current, &fs); TSDB_CHECK_CODE(code, lino, _exit); // apply file change @@ -923,19 +739,18 @@ _exit: return code; } -// EXPOSED APIS ==================================================================================== -int32_t tsdbFSCommit(STsdb *pTsdb) { - char current_json[TSDB_FILENAME_LEN] = {0}; - char current_json_t[TSDB_FILENAME_LEN] = {0}; - tsdbGetCurrentFName(pTsdb, NULL, NULL, current_json, current_json_t); - return tsdbFSCommitImpl(pTsdb, current_json, current_json_t, true); -} - int32_t tsdbFSRollback(STsdb *pTsdb) { int32_t code = 0; - char current_json_t[TSDB_FILENAME_LEN] = {0}; - tsdbGetCurrentFName(pTsdb, NULL, NULL, NULL, current_json_t); - (void)taosRemoveFile(current_json_t); + int32_t lino = 0; + + char current_t[TSDB_FILENAME_LEN] = {0}; + tsdbGetCurrentFName(pTsdb, NULL, current_t); + (void)taosRemoveFile(current_t); + +_exit: + if (code) { + tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pTsdb->pVnode), __func__, lino, tstrerror(errno)); + } return code; } @@ -951,33 +766,13 @@ int32_t tsdbFSOpen(STsdb *pTsdb, int8_t rollback) { // open impl char current[TSDB_FILENAME_LEN] = {0}; char current_t[TSDB_FILENAME_LEN] = {0}; - char current_json[TSDB_FILENAME_LEN] = {0}; - char current_json_t[TSDB_FILENAME_LEN] = {0}; - tsdbGetCurrentFName(pTsdb, current, current_t, current_json, current_json_t); + tsdbGetCurrentFName(pTsdb, current, current_t); if (taosCheckExistFile(current)) { - // CURRENT file exists code = tsdbLoadFSFromFile(current, &pTsdb->fs); TSDB_CHECK_CODE(code, lino, _exit); if (taosCheckExistFile(current_t)) { - if (rollback) { - (void)taosRemoveFile(current_t); - } else { - code = tsdbFSCommitImpl(pTsdb, current, current_t, false); - TSDB_CHECK_CODE(code, lino, _exit); - } - } - - code = tsdbSaveFSToJsonFile(&pTsdb->fs, current_json); - TSDB_CHECK_CODE(code, lino, _exit); - (void)taosRemoveFile(current); - } else if (taosCheckExistFile(current_json)) { - // current.json exists - code = tsdbLoadFSFromJsonFile(current_json, &pTsdb->fs); - TSDB_CHECK_CODE(code, lino, _exit); - - if (taosCheckExistFile(current_json_t)) { if (rollback) { code = tsdbFSRollback(pTsdb); TSDB_CHECK_CODE(code, lino, _exit); @@ -987,10 +782,11 @@ int32_t tsdbFSOpen(STsdb *pTsdb, int8_t rollback) { } } } else { - // empty TSDB - ASSERT(!rollback); - code = tsdbSaveFSToJsonFile(&pTsdb->fs, current_json); + // empty one + code = tsdbSaveFSToFile(&pTsdb->fs, current); TSDB_CHECK_CODE(code, lino, _exit); + + ASSERT(!rollback); } // scan and fix FS @@ -1228,12 +1024,12 @@ _exit: int32_t tsdbFSPrepareCommit(STsdb *pTsdb, STsdbFS *pFSNew) { int32_t code = 0; int32_t lino = 0; - char current_json_t[TSDB_FILENAME_LEN]; + char tfname[TSDB_FILENAME_LEN]; - tsdbGetCurrentFName(pTsdb, NULL, NULL, NULL, current_json_t); + tsdbGetCurrentFName(pTsdb, NULL, tfname); - // generate current.json - code = tsdbSaveFSToJsonFile(pFSNew, current_json_t); + // gnrt CURRENT.t + code = tsdbSaveFSToFile(pFSNew, tfname); TSDB_CHECK_CODE(code, lino, _exit); _exit: diff --git a/source/dnode/vnode/src/tsdb/tsdbFile.c b/source/dnode/vnode/src/tsdb/tsdbFile.c index 8b2b2caec77f829907d3b81cd51d43e35f856f83..d91475376b240812b8942227fa85e37cb5671dec 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile.c +++ b/source/dnode/vnode/src/tsdb/tsdbFile.c @@ -92,11 +92,11 @@ static int32_t tGetSmaFile(uint8_t *p, SSmaFile *pSmaFile) { } // EXPOSED APIS ================================================== -static char *getFileNamePrefix(STsdb *pTsdb, SDiskID did, int32_t fid, uint64_t commitId, char fname[]) { - const char *p1 = tfsGetDiskPath(pTsdb->pVnode->pTfs, did); - int32_t len = strlen(p1); +static char* getFileNamePrefix(STsdb *pTsdb, SDiskID did, int32_t fid, uint64_t commitId, char fname[]) { + const char* p1 = tfsGetDiskPath(pTsdb->pVnode->pTfs, did); + int32_t len = strlen(p1); - char *p = memcpy(fname, p1, len); + char* p = memcpy(fname, p1, len); p += len; *(p++) = TD_DIRSEP[0]; @@ -121,25 +121,25 @@ static char *getFileNamePrefix(STsdb *pTsdb, SDiskID did, int32_t fid, uint64_t } void tsdbHeadFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SHeadFile *pHeadF, char fname[]) { - char *p = getFileNamePrefix(pTsdb, did, fid, pHeadF->commitID, fname); + char* p = getFileNamePrefix(pTsdb, did, fid, pHeadF->commitID, fname); memcpy(p, ".head", 5); p[5] = 0; } void tsdbDataFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SDataFile *pDataF, char fname[]) { - char *p = getFileNamePrefix(pTsdb, did, fid, pDataF->commitID, fname); + char* p = getFileNamePrefix(pTsdb, did, fid, pDataF->commitID, fname); memcpy(p, ".data", 5); p[5] = 0; } void tsdbSttFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSttFile *pSttF, char fname[]) { - char *p = getFileNamePrefix(pTsdb, did, fid, pSttF->commitID, fname); + char* p = getFileNamePrefix(pTsdb, did, fid, pSttF->commitID, fname); memcpy(p, ".stt", 4); p[4] = 0; } void tsdbSmaFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSmaFile *pSmaF, char fname[]) { - char *p = getFileNamePrefix(pTsdb, did, fid, pSmaF->commitID, fname); + char* p = getFileNamePrefix(pTsdb, did, fid, pSmaF->commitID, fname); memcpy(p, ".sma", 4); p[4] = 0; } @@ -280,272 +280,6 @@ int32_t tGetDFileSet(uint8_t *p, SDFileSet *pSet) { return n; } -static int32_t tDiskIdToJson(const SDiskID *pDiskId, cJSON *pJson) { - int32_t code = 0; - int32_t lino; - - if (pJson == NULL) return TSDB_CODE_OUT_OF_MEMORY; - - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "level", pDiskId->level), code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "id", pDiskId->id), code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - -_exit: - return code; -} -static int32_t tJsonToDiskId(const cJSON *pJson, SDiskID *pDiskId) { - int32_t code = 0; - int32_t lino; - - const cJSON *pItem; - - // level - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "level")), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - pDiskId->level = (int32_t)pItem->valuedouble; - - // id - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "id")), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - pDiskId->id = (int32_t)pItem->valuedouble; - -_exit: - return code; -} - -static int32_t tHeadFileToJson(const SHeadFile *pHeadF, cJSON *pJson) { - int32_t code = 0; - int32_t lino; - - if (pJson == NULL) return TSDB_CODE_OUT_OF_MEMORY; - - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "commit id", pHeadF->commitID), code, lino, _exit, - TSDB_CODE_OUT_OF_MEMORY); - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "size", pHeadF->size), code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "offset", pHeadF->offset), code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - -_exit: - return code; -} - -static int32_t tJsonToHeadFile(const cJSON *pJson, SHeadFile *pHeadF) { - int32_t code = 0; - int32_t lino; - - const cJSON *pItem; - - // commit id - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "commit id")), code, lino, _exit, - TSDB_CODE_FILE_CORRUPTED); - pHeadF->commitID = (int64_t)pItem->valuedouble; - - // size - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "size")), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - pHeadF->size = (int64_t)pItem->valuedouble; - - // offset - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "offset")), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - pHeadF->offset = (int64_t)pItem->valuedouble; - -_exit: - return code; -} - -static int32_t tDataFileToJson(const SDataFile *pDataF, cJSON *pJson) { - int32_t code = 0; - int32_t lino; - - if (pJson == NULL) return TSDB_CODE_OUT_OF_MEMORY; - - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "commit id", pDataF->commitID), code, lino, _exit, - TSDB_CODE_OUT_OF_MEMORY); - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "size", pDataF->size), code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - -_exit: - return code; -} - -static int32_t tJsonToDataFile(const cJSON *pJson, SDataFile *pDataF) { - int32_t code = 0; - int32_t lino; - - const cJSON *pItem; - - // commit id - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "commit id")), code, lino, _exit, - TSDB_CODE_FILE_CORRUPTED); - pDataF->commitID = (int64_t)pItem->valuedouble; - - // size - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "size")), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - pDataF->size = (int64_t)pItem->valuedouble; - -_exit: - return code; -} - -static int32_t tSmaFileToJson(const SSmaFile *pSmaF, cJSON *pJson) { - int32_t code = 0; - int32_t lino; - - if (pJson == NULL) return TSDB_CODE_OUT_OF_MEMORY; - - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "commit id", pSmaF->commitID), code, lino, _exit, - TSDB_CODE_OUT_OF_MEMORY); - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "size", pSmaF->size), code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - -_exit: - return code; -} - -static int32_t tJsonToSmaFile(const cJSON *pJson, SSmaFile *pSmaF) { - int32_t code = 0; - int32_t lino; - - // commit id - const cJSON *pItem; - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "commit id")), code, lino, _exit, - TSDB_CODE_FILE_CORRUPTED); - pSmaF->commitID = (int64_t)pItem->valuedouble; - - // size - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "size")), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - pSmaF->size = (int64_t)pItem->valuedouble; - -_exit: - return code; -} - -static int32_t tSttFileToJson(const SSttFile *pSttF, cJSON *pJson) { - int32_t code = 0; - int32_t lino; - - if (pJson == NULL) return TSDB_CODE_OUT_OF_MEMORY; - - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "commit id", pSttF->commitID), code, lino, _exit, - TSDB_CODE_OUT_OF_MEMORY); - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "size", pSttF->size), code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "offset", pSttF->offset), code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - -_exit: - return code; -} - -static int32_t tJsonToSttFile(const cJSON *pJson, SSttFile *pSttF) { - int32_t code = 0; - int32_t lino; - - const cJSON *pItem; - - // commit id - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "commit id")), code, lino, _exit, - TSDB_CODE_FILE_CORRUPTED); - pSttF->commitID = (int64_t)pItem->valuedouble; - - // size - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "size")), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - pSttF->size = (int64_t)pItem->valuedouble; - - // offset - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "offset")), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - pSttF->offset = (int64_t)pItem->valuedouble; - -_exit: - return code; -} - -int32_t tsdbDFileSetToJson(const SDFileSet *pSet, cJSON *pJson) { - int32_t code = 0; - int32_t lino; - - if (pJson == NULL) return TSDB_CODE_OUT_OF_MEMORY; - - code = tDiskIdToJson(&pSet->diskId, cJSON_AddObjectToObject(pJson, "disk id")); - TSDB_CHECK_CODE(code, lino, _exit); - - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "fid", pSet->fid), code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - - // head - code = tHeadFileToJson(pSet->pHeadF, cJSON_AddObjectToObject(pJson, "head")); - TSDB_CHECK_CODE(code, lino, _exit); - - // data - code = tDataFileToJson(pSet->pDataF, cJSON_AddObjectToObject(pJson, "data")); - TSDB_CHECK_CODE(code, lino, _exit); - - // sma - code = tSmaFileToJson(pSet->pSmaF, cJSON_AddObjectToObject(pJson, "sma")); - TSDB_CHECK_CODE(code, lino, _exit); - - // stt array - cJSON *aSttJson = cJSON_AddArrayToObject(pJson, "stt"); - TSDB_CHECK_NULL(aSttJson, code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) { - cJSON *pSttJson = cJSON_CreateObject(); - TSDB_CHECK_NULL(pSttJson, code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - - cJSON_AddItemToArray(aSttJson, pSttJson); - - code = tSttFileToJson(pSet->aSttF[iStt], pSttJson); - TSDB_CHECK_CODE(code, lino, _exit); - } - -_exit: - return code; -} - -int32_t tsdbJsonToDFileSet(const cJSON *pJson, SDFileSet *pSet) { - int32_t code = 0; - int32_t lino; - - const cJSON *pItem; - // disk id - TSDB_CHECK(cJSON_IsObject(pItem = cJSON_GetObjectItem(pJson, "disk id")), code, lino, _exit, - TSDB_CODE_FILE_CORRUPTED); - code = tJsonToDiskId(pItem, &pSet->diskId); - TSDB_CHECK_CODE(code, lino, _exit); - - // fid - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "fid")), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - pSet->fid = (int32_t)pItem->valuedouble; - - // head - TSDB_CHECK(cJSON_IsObject(pItem = cJSON_GetObjectItem(pJson, "head")), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - TSDB_CHECK_NULL(pSet->pHeadF = (SHeadFile *)taosMemoryMalloc(sizeof(SHeadFile)), code, lino, _exit, - TSDB_CODE_OUT_OF_MEMORY); - TSDB_CHECK_CODE(code = tJsonToHeadFile(pItem, pSet->pHeadF), lino, _exit); - pSet->pHeadF->nRef = 1; - - // data - TSDB_CHECK(cJSON_IsObject(pItem = cJSON_GetObjectItem(pJson, "data")), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - TSDB_CHECK_NULL(pSet->pDataF = (SDataFile *)taosMemoryMalloc(sizeof(SDataFile)), code, lino, _exit, - TSDB_CODE_OUT_OF_MEMORY); - TSDB_CHECK_CODE(code = tJsonToDataFile(pItem, pSet->pDataF), lino, _exit); - pSet->pDataF->nRef = 1; - - // sma - TSDB_CHECK(cJSON_IsObject(pItem = cJSON_GetObjectItem(pJson, "sma")), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - TSDB_CHECK_NULL(pSet->pSmaF = (SSmaFile *)taosMemoryMalloc(sizeof(SSmaFile)), code, lino, _exit, - TSDB_CODE_OUT_OF_MEMORY); - TSDB_CHECK_CODE(code = tJsonToSmaFile(pItem, pSet->pSmaF), lino, _exit); - pSet->pSmaF->nRef = 1; - - // stt array - const cJSON *element; - pSet->nSttF = 0; - TSDB_CHECK(cJSON_IsArray(pItem = cJSON_GetObjectItem(pJson, "stt")), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - cJSON_ArrayForEach(element, pItem) { - TSDB_CHECK(cJSON_IsObject(element), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - - pSet->aSttF[pSet->nSttF] = (SSttFile *)taosMemoryMalloc(sizeof(SSttFile)); - TSDB_CHECK_NULL(pSet->aSttF[pSet->nSttF], code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - TSDB_CHECK_CODE(code = tJsonToSttFile(element, pSet->aSttF[pSet->nSttF]), lino, _exit); - pSet->aSttF[pSet->nSttF]->nRef = 1; - pSet->nSttF++; - } - -_exit: - if (code) tsdbError("%s failed at line %d since %s", __func__, lino, tstrerror(code)); - return code; -} - // SDelFile =============================================== void tsdbDelFileName(STsdb *pTsdb, SDelFile *pFile, char fname[]) { snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%dver%" PRId64 "%s", tfsGetPrimaryPath(pTsdb->pVnode->pTfs), @@ -571,42 +305,3 @@ int32_t tGetDelFile(uint8_t *p, SDelFile *pDelFile) { return n; } - -int32_t tsdbDelFileToJson(const SDelFile *pDelFile, cJSON *pJson) { - if (pJson == NULL) return TSDB_CODE_OUT_OF_MEMORY; - - int32_t code = 0; - int32_t lino; - - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "commit id", pDelFile->commitID), code, lino, _exit, - TSDB_CODE_OUT_OF_MEMORY); - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "size", pDelFile->size), code, lino, _exit, TSDB_CODE_OUT_OF_MEMORY); - TSDB_CHECK_NULL(cJSON_AddNumberToObject(pJson, "offset", pDelFile->offset), code, lino, _exit, - TSDB_CODE_OUT_OF_MEMORY); - -_exit: - return code; -} - -int32_t tsdbJsonToDelFile(const cJSON *pJson, SDelFile *pDelFile) { - int32_t code = 0; - int32_t lino; - - const cJSON *pItem; - - // commit id - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "commit id")), code, lino, _exit, - TSDB_CODE_FILE_CORRUPTED); - pDelFile->commitID = cJSON_GetNumberValue(pItem); - - // size - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "size")), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - pDelFile->size = cJSON_GetNumberValue(pItem); - - // offset - TSDB_CHECK(cJSON_IsNumber(pItem = cJSON_GetObjectItem(pJson, "offset")), code, lino, _exit, TSDB_CODE_FILE_CORRUPTED); - pDelFile->offset = cJSON_GetNumberValue(pItem); - -_exit: - return code; -} \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index d34af9acae68b964879cd7ba24491f0ff878e439..d0ff403bf70a96f114b0722bfb13f7ce035edfb4 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -282,6 +282,40 @@ bool tsdbTbDataIterNext(STbDataIter *pIter) { return true; } +int64_t tsdbCountTbDataRows(STbData *pTbData) { + SMemSkipListNode *pNode = pTbData->sl.pHead; + int64_t rowsNum = 0; + + while (NULL != pNode) { + pNode = SL_GET_NODE_FORWARD(pNode, 0); + if (pNode == pTbData->sl.pTail) { + return rowsNum; + } + + rowsNum++; + } + + return rowsNum; +} + +void tsdbMemTableCountRows(SMemTable *pMemTable, SHashObj* pTableMap, int64_t *rowsNum) { + taosRLockLatch(&pMemTable->latch); + for (int32_t i = 0; i < pMemTable->nBucket; ++i) { + STbData *pTbData = pMemTable->aBucket[i]; + while (pTbData) { + void* p = taosHashGet(pTableMap, &pTbData->uid, sizeof(pTbData->uid)); + if (p == NULL) { + pTbData = pTbData->next; + continue; + } + + *rowsNum += tsdbCountTbDataRows(pTbData); + pTbData = pTbData->next; + } + } + taosRUnLockLatch(&pMemTable->latch); +} + static int32_t tsdbMemTableRehash(SMemTable *pMemTable) { int32_t code = 0; @@ -787,4 +821,4 @@ SArray *tsdbMemTableGetTbDataArray(SMemTable *pMemTable) { _exit: return aTbDataP; -} \ No newline at end of file +} diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c index d9d60442ffbfd36dfa9b132b4d5f9c714558de7a..fa8870835c5fc6b914663a2d76c9202e1410e52f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c +++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c @@ -29,9 +29,11 @@ struct SLDataIter { STimeWindow timeWindow; SVersionRange verRange; SSttBlockLoadInfo *pBlockLoadInfo; + bool ignoreEarlierTs; }; -SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList, int32_t numOfCols, int32_t numOfSttTrigger) { +SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList, int32_t numOfCols, + int32_t numOfSttTrigger) { SSttBlockLoadInfo *pLoadInfo = taosMemoryCalloc(numOfSttTrigger, sizeof(SSttBlockLoadInfo)); if (pLoadInfo == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -162,7 +164,8 @@ static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) { pInfo->blockIndex[pInfo->currentLoadBlockIndex] = pIter->iSttBlk; pIter->iRow = (pIter->backward) ? pInfo->blockData[pInfo->currentLoadBlockIndex].nRow : -1; - tsdbDebug("last block index list:%d, %d, rowIndex:%d %s", pInfo->blockIndex[0], pInfo->blockIndex[1], pIter->iRow, idStr); + tsdbDebug("last block index list:%d, %d, rowIndex:%d %s", pInfo->blockIndex[0], pInfo->blockIndex[1], pIter->iRow, + idStr); return &pInfo->blockData[pInfo->currentLoadBlockIndex]; _exit: @@ -263,7 +266,7 @@ static int32_t binarySearchForStartRowIndex(uint64_t *uidList, int32_t num, uint int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t iStt, int8_t backward, uint64_t suid, uint64_t uid, STimeWindow *pTimeWindow, SVersionRange *pRange, SSttBlockLoadInfo *pBlockLoadInfo, - const char *idStr) { + const char *idStr, bool strictTimeRange) { int32_t code = TSDB_CODE_SUCCESS; *pIter = taosMemoryCalloc(1, sizeof(SLDataIter)); @@ -340,6 +343,17 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t if ((*pIter)->iSttBlk != -1) { (*pIter)->pSttBlk = taosArrayGet(pBlockLoadInfo->aSttBlk, (*pIter)->iSttBlk); (*pIter)->iRow = ((*pIter)->backward) ? (*pIter)->pSttBlk->nRow : -1; + + if ((!backward) && ((strictTimeRange && (*pIter)->pSttBlk->minKey >= (*pIter)->timeWindow.ekey) || + (!strictTimeRange && (*pIter)->pSttBlk->minKey > (*pIter)->timeWindow.ekey))) { + (*pIter)->pSttBlk = NULL; + } + + if (backward && ((strictTimeRange && (*pIter)->pSttBlk->maxKey <= (*pIter)->timeWindow.skey) || + (!strictTimeRange && (*pIter)->pSttBlk->maxKey < (*pIter)->timeWindow.skey))) { + (*pIter)->pSttBlk = NULL; + (*pIter)->ignoreEarlierTs = true; + } } return code; @@ -421,7 +435,7 @@ static void findNextValidRow(SLDataIter *pIter, const char *idStr) { pBlockData->aUid != NULL) { i = binarySearchForStartRowIndex((uint64_t *)pBlockData->aUid, pBlockData->nRow, pIter->uid, pIter->backward); if (i == -1) { - tsdbDebug("failed to find the data in pBlockData, uid:%"PRIu64" , %s", pIter->uid, idStr); + tsdbDebug("failed to find the data in pBlockData, uid:%" PRIu64 " , %s", pIter->uid, idStr); pIter->iRow = -1; return; } @@ -490,9 +504,34 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) { pIter->iRow += step; while (1) { + bool skipBlock = false; + findNextValidRow(pIter, idStr); - if (pIter->iRow >= pBlockData->nRow || pIter->iRow < 0) { + if (pIter->pBlockLoadInfo->checkRemainingRow) { + skipBlock = true; + int16_t *aCols = pIter->pBlockLoadInfo->colIds; + int nCols = pIter->pBlockLoadInfo->numOfCols; + bool isLast = pIter->pBlockLoadInfo->isLast; + for (int inputColIndex = 0; inputColIndex < nCols; ++inputColIndex) { + for (int colIndex = 0; colIndex < pBlockData->nColData; ++colIndex) { + SColData *pColData = &pBlockData->aColData[colIndex]; + int16_t cid = pColData->cid; + + if (cid == aCols[inputColIndex]) { + if (isLast && (pColData->flag & HAS_VALUE)) { + skipBlock = false; + break; + } else if (pColData->flag & (HAS_VALUE | HAS_NULL)) { + skipBlock = false; + break; + } + } + } + } + } + + if (skipBlock || pIter->iRow >= pBlockData->nRow || pIter->iRow < 0) { tLDataIterNextBlock(pIter, idStr); if (pIter->pSttBlk == NULL) { // no more data goto _exit; @@ -508,7 +547,7 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) { } // set start row index - pIter->iRow = pIter->backward? pBlockData->nRow-1:0; + pIter->iRow = pIter->backward ? pBlockData->nRow - 1 : 0; } } @@ -551,7 +590,7 @@ static FORCE_INLINE int32_t tLDataIterDescCmprFn(const SRBTreeNode *p1, const SR int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFReader, uint64_t suid, uint64_t uid, STimeWindow *pTimeWindow, SVersionRange *pVerRange, SSttBlockLoadInfo *pBlockLoadInfo, - bool destroyLoadInfo, const char *idStr) { + bool destroyLoadInfo, const char *idStr, bool strictTimeRange) { pMTree->backward = backward; pMTree->pIter = NULL; pMTree->pIterList = taosArrayInit(4, POINTER_BYTES); @@ -569,11 +608,12 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead pMTree->pLoadInfo = pBlockLoadInfo; pMTree->destroyLoadInfo = destroyLoadInfo; + pMTree->ignoreEarlierTs = false; for (int32_t i = 0; i < pFReader->pSet->nSttF; ++i) { // open all last file struct SLDataIter *pIter = NULL; code = tLDataIterOpen(&pIter, pFReader, i, pMTree->backward, suid, uid, pTimeWindow, pVerRange, - &pMTree->pLoadInfo[i], pMTree->idStr); + &pMTree->pLoadInfo[i], pMTree->idStr, strictTimeRange); if (code != TSDB_CODE_SUCCESS) { goto _end; } @@ -583,6 +623,9 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead taosArrayPush(pMTree->pIterList, &pIter); tMergeTreeAddIter(pMTree, pIter); } else { + if (!pMTree->ignoreEarlierTs) { + pMTree->ignoreEarlierTs = pIter->ignoreEarlierTs; + } tLDataIterClose(pIter); } } @@ -596,6 +639,8 @@ _end: void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter) { tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pIter); } +bool tMergeTreeIgnoreEarlierTs(SMergeTree *pMTree) { return pMTree->ignoreEarlierTs; } + bool tMergeTreeNext(SMergeTree *pMTree) { int32_t code = TSDB_CODE_SUCCESS; if (pMTree->pIter) { diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 31153f0832bb83f3b6c68acd0957b4b5171f61da..480ae7ea64153df2a47313fd7bb9b6d208b40dc2 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -15,6 +15,7 @@ #include "osDef.h" #include "tsdb.h" +#include "tsimplehash.h" #define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC) @@ -24,6 +25,11 @@ typedef enum { EXTERNAL_ROWS_NEXT = 0x3, } EContentData; +typedef enum { + READ_MODE_COUNT_ONLY = 0x1, + READ_MODE_ALL, +} EReadMode; + typedef struct { STbDataIter* iter; int32_t index; @@ -167,6 +173,8 @@ struct STsdbReader { uint64_t suid; int16_t order; bool freeBlock; + EReadMode readMode; + uint64_t rowsNum; STimeWindow window; // the primary query time window that applies to all queries SSDataBlock* pResBlock; int32_t capacity; @@ -176,14 +184,15 @@ struct STsdbReader { SBlockLoadSuppInfo suppInfo; STsdbReadSnap* pReadSnap; SIOCostSummary cost; - STSchema* pSchema; // the newest version schema - STSchema* pMemSchema; // the previous schema for in-memory data, to avoid load schema too many times - SDataFReader* pFileReader; // the file reader - SDelFReader* pDelFReader; // the del file reader - SArray* pDelIdx; // del file block index; - SBlockInfoBuf blockInfoBuf; - int32_t step; - STsdbReader* innerReader[2]; + STSchema* pSchema; // the newest version schema + // STSchema* pMemSchema; // the previous schema for in-memory data, to avoid load schema too many times + SSHashObj* pSchemaMap; // keep the retrieved schema info, to avoid the overhead by repeatly load schema + SDataFReader* pFileReader; // the file reader + SDelFReader* pDelFReader; // the del file reader + SArray* pDelIdx; // del file block index; + SBlockInfoBuf blockInfoBuf; + int32_t step; + STsdbReader* innerReader[2]; }; static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter); @@ -390,8 +399,10 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf pUidList->tableUidList = taosMemoryMalloc(numOfTables * sizeof(uint64_t)); if (pUidList->tableUidList == NULL) { + taosHashCleanup(pTableMap); return NULL; } + pUidList->currentIndex = 0; for (int32_t j = 0; j < numOfTables; ++j) { @@ -425,7 +436,7 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf return pTableMap; } -static void resetAllDataBlockScanInfo(SHashObj* pTableMap, int64_t ts) { +static void resetAllDataBlockScanInfo(SHashObj* pTableMap, int64_t ts, int32_t step) { STableBlockScanInfo** p = NULL; while ((p = taosHashIterate(pTableMap, p)) != NULL) { STableBlockScanInfo* pInfo = *(STableBlockScanInfo**)p; @@ -444,6 +455,7 @@ static void resetAllDataBlockScanInfo(SHashObj* pTableMap, int64_t ts) { pInfo->delSkyline = taosArrayDestroy(pInfo->delSkyline); pInfo->lastKey = ts; + pInfo->lastKeyInStt = ts + step; } } @@ -919,10 +931,8 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockN pBlockNum->numOfBlocks += 1; } - if (pScanInfo->pBlockList != NULL) { - if (taosArrayGetSize(pScanInfo->pBlockList) > 0) { - numOfQTable += 1; - } + if (taosArrayGetSize(pScanInfo->pBlockList) > 0) { + numOfQTable += 1; } } @@ -948,14 +958,18 @@ static void setBlockAllDumped(SFileBlockDumpInfo* pDumpInfo, int64_t maxKey, int pDumpInfo->lastKey = maxKey + step; } -static void doCopyColVal(SColumnInfoData* pColInfoData, int32_t rowIndex, int32_t colIndex, SColVal* pColVal, - SBlockLoadSuppInfo* pSup) { +static int32_t doCopyColVal(SColumnInfoData* pColInfoData, int32_t rowIndex, int32_t colIndex, SColVal* pColVal, + SBlockLoadSuppInfo* pSup) { if (IS_VAR_DATA_TYPE(pColVal->type)) { if (!COL_VAL_IS_VALUE(pColVal)) { colDataSetNULL(pColInfoData, rowIndex); } else { varDataSetLen(pSup->buildBuf[colIndex], pColVal->value.nData); - ASSERT(pColVal->value.nData <= pColInfoData->info.bytes); + if (pColVal->value.nData > pColInfoData->info.bytes) { + tsdbWarn("column cid:%d actual data len %d is bigger than schema len %d", pColVal->cid, pColVal->value.nData, + pColInfoData->info.bytes); + return TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER; + } if (pColVal->value.nData > 0) { // pData may be null, if nData is 0 memcpy(varDataVal(pSup->buildBuf[colIndex]), pColVal->value.pData, pColVal->value.nData); } @@ -965,6 +979,8 @@ static void doCopyColVal(SColumnInfoData* pColInfoData, int32_t rowIndex, int32_ } else { colDataSetVal(pColInfoData, rowIndex, (const char*)&pColVal->value, !COL_VAL_IS_VALUE(pColVal)); } + + return TSDB_CODE_SUCCESS; } static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) { @@ -1166,6 +1182,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader) { SDataBlk* pBlock = getCurrentBlock(pBlockIter); SSDataBlock* pResBlock = pReader->pResBlock; int32_t numOfOutputCols = pSupInfo->numOfCols; + int32_t code = TSDB_CODE_SUCCESS; SColVal cv = {0}; int64_t st = taosGetTimestampUs(); @@ -1243,7 +1260,10 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader) { } else { // varchar/nchar type for (int32_t j = pDumpInfo->rowIndex; rowIndex < dumpedRows; j += step) { tColDataGetValue(pData, j, &cv); - doCopyColVal(pColData, rowIndex++, i, &cv, pSupInfo); + code = doCopyColVal(pColData, rowIndex++, i, &cv, pSupInfo); + if (code) { + return code; + } } } } @@ -1765,7 +1785,7 @@ static int32_t buildDataBlockFromBuf(STsdbReader* pReader, STableBlockScanInfo* setComposedBlockFlag(pReader, true); double elapsedTime = (taosGetTimestampUs() - st) / 1000.0; - tsdbDebug("%p build data block from cache completed, elapsed time:%.2f ms, numOfRows:%d, brange:%" PRId64 + tsdbDebug("%p build data block from cache completed, elapsed time:%.2f ms, numOfRows:%" PRId64 ", brange:%" PRId64 " - %" PRId64 ", uid:%" PRIu64 ", %s", pReader, elapsedTime, pBlock->info.rows, pBlock->info.window.skey, pBlock->info.window.ekey, pBlockScanInfo->uid, pReader->idStr); @@ -1775,23 +1795,29 @@ static int32_t buildDataBlockFromBuf(STsdbReader* pReader, STableBlockScanInfo* } static bool tryCopyDistinctRowFromFileBlock(STsdbReader* pReader, SBlockData* pBlockData, int64_t key, - SFileBlockDumpInfo* pDumpInfo) { + SFileBlockDumpInfo* pDumpInfo, bool* copied) { // opt version // 1. it is not a border point // 2. the direct next point is not an duplicated timestamp + int32_t code = TSDB_CODE_SUCCESS; + + *copied = false; bool asc = (pReader->order == TSDB_ORDER_ASC); if ((pDumpInfo->rowIndex < pDumpInfo->totalRows - 1 && asc) || (pDumpInfo->rowIndex > 0 && (!asc))) { int32_t step = pReader->order == TSDB_ORDER_ASC ? 1 : -1; int64_t nextKey = pBlockData->aTSKEY[pDumpInfo->rowIndex + step]; if (nextKey != key) { // merge is not needed - doAppendRowFromFileBlock(pReader->pResBlock, pReader, pBlockData, pDumpInfo->rowIndex); + code = doAppendRowFromFileBlock(pReader->pResBlock, pReader, pBlockData, pDumpInfo->rowIndex); + if (code) { + return code; + } pDumpInfo->rowIndex += step; - return true; + *copied = true; } } - return false; + return code; } static bool nextRowFromLastBlocks(SLastBlockReader* pLastBlockReader, STableBlockScanInfo* pScanInfo, @@ -1818,20 +1844,35 @@ static bool nextRowFromLastBlocks(SLastBlockReader* pLastBlockReader, STableBloc } static bool tryCopyDistinctRowFromSttBlock(TSDBROW* fRow, SLastBlockReader* pLastBlockReader, - STableBlockScanInfo* pScanInfo, int64_t ts, STsdbReader* pReader) { + STableBlockScanInfo* pScanInfo, int64_t ts, STsdbReader* pReader, + bool* copied) { + int32_t code = TSDB_CODE_SUCCESS; + + *copied = false; + bool hasVal = nextRowFromLastBlocks(pLastBlockReader, pScanInfo, &pReader->verRange); if (hasVal) { int64_t next1 = getCurrentKeyInLastBlock(pLastBlockReader); if (next1 != ts) { - doAppendRowFromFileBlock(pReader->pResBlock, pReader, fRow->pBlockData, fRow->iRow); - return true; + code = doAppendRowFromFileBlock(pReader->pResBlock, pReader, fRow->pBlockData, fRow->iRow); + if (code) { + return code; + } + + *copied = true; + return code; } } else { - doAppendRowFromFileBlock(pReader->pResBlock, pReader, fRow->pBlockData, fRow->iRow); - return true; + code = doAppendRowFromFileBlock(pReader->pResBlock, pReader, fRow->pBlockData, fRow->iRow); + if (code) { + return code; + } + + *copied = true; + return code; } - return false; + return code; } static FORCE_INLINE STSchema* getLatestTableSchema(STsdbReader* pReader, uint64_t uid) { @@ -1857,28 +1898,23 @@ static FORCE_INLINE STSchema* doGetSchemaForTSRow(int32_t sversion, STsdbReader* return pReader->pSchema; } - if (pReader->pMemSchema == NULL) { - int32_t code = - metaGetTbTSchemaEx(pReader->pTsdb->pVnode->pMeta, pReader->suid, uid, sversion, &pReader->pMemSchema); - if (code != TSDB_CODE_SUCCESS) { - terrno = code; - return NULL; - } else { - return pReader->pMemSchema; - } + void** p = tSimpleHashGet(pReader->pSchemaMap, &sversion, sizeof(sversion)); + if (p != NULL) { + return *(STSchema**)p; } - if (pReader->pMemSchema->version == sversion) { - return pReader->pMemSchema; - } - - taosMemoryFreeClear(pReader->pMemSchema); - int32_t code = metaGetTbTSchemaEx(pReader->pTsdb->pVnode->pMeta, pReader->suid, uid, sversion, &pReader->pMemSchema); - if (code != TSDB_CODE_SUCCESS || pReader->pMemSchema == NULL) { + STSchema* ptr = NULL; + int32_t code = metaGetTbTSchemaEx(pReader->pTsdb->pVnode->pMeta, pReader->suid, uid, sversion, &ptr); + if (code != TSDB_CODE_SUCCESS) { terrno = code; return NULL; } else { - return pReader->pMemSchema; + code = tSimpleHashPut(pReader->pSchemaMap, &sversion, sizeof(sversion), &ptr, POINTER_BYTES); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + return NULL; + } + return ptr; } } @@ -2021,11 +2057,12 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo* return code; } - doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); + code = doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); taosMemoryFree(pTSRow); tsdbRowMergerClear(&merge); - return TSDB_CODE_SUCCESS; + + return code; } static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader, STsdbReader* pReader, @@ -2033,15 +2070,21 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader, bool mergeBlockData) { SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; int64_t tsLastBlock = getCurrentKeyInLastBlock(pLastBlockReader); - - SRow* pTSRow = NULL; - SRowMerger merge = {0}; - TSDBROW fRow = tMergeTreeGetRow(&pLastBlockReader->mergeTree); + bool copied = false; + int32_t code = TSDB_CODE_SUCCESS; + SRow* pTSRow = NULL; + SRowMerger merge = {0}; + TSDBROW fRow = tMergeTreeGetRow(&pLastBlockReader->mergeTree); tsdbTrace("fRow ptr:%p, %d, uid:%" PRIu64 ", %s", fRow.pBlockData, fRow.iRow, pLastBlockReader->uid, pReader->idStr); // only last block exists if ((!mergeBlockData) || (tsLastBlock != pBlockData->aTSKEY[pDumpInfo->rowIndex])) { - if (tryCopyDistinctRowFromSttBlock(&fRow, pLastBlockReader, pBlockScanInfo, tsLastBlock, pReader)) { + code = tryCopyDistinctRowFromSttBlock(&fRow, pLastBlockReader, pBlockScanInfo, tsLastBlock, pReader, &copied); + if (code) { + return code; + } + + if (copied) { pBlockScanInfo->lastKey = tsLastBlock; return TSDB_CODE_SUCCESS; } else { @@ -2059,10 +2102,14 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader, return code; } - doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); + code = doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); taosMemoryFree(pTSRow); tsdbRowMergerClear(&merge); + + if (code != TSDB_CODE_SUCCESS) { + return code; + } } } else { // not merge block data int32_t code = tsdbRowMergerInit(&merge, &fRow, pReader->pSchema); @@ -2082,10 +2129,14 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader, return code; } - doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); + code = doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); taosMemoryFree(pTSRow); tsdbRowMergerClear(&merge); + + if (code != TSDB_CODE_SUCCESS) { + return code; + } } return TSDB_CODE_SUCCESS; @@ -2130,7 +2181,7 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader return code; } - doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); + code = doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); taosMemoryFree(pTSRow); tsdbRowMergerClear(&merge); @@ -2352,7 +2403,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo* return code; } - doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); + code = doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); taosMemoryFree(pTSRow); tsdbRowMergerClear(&merge); @@ -2471,7 +2522,6 @@ static bool initLastBlockReader(SLastBlockReader* pLBlockReader, STableBlockScan initMemDataIterator(pScanInfo, pReader); pLBlockReader->uid = pScanInfo->uid; - int32_t step = ASCENDING_TRAVERSE(pLBlockReader->order) ? 1 : -1; STimeWindow w = pLBlockReader->window; if (ASCENDING_TRAVERSE(pLBlockReader->order)) { w.skey = pScanInfo->lastKeyInStt; @@ -2483,7 +2533,7 @@ static bool initLastBlockReader(SLastBlockReader* pLBlockReader, STableBlockScan pScanInfo->uid, pReader->idStr); int32_t code = tMergeTreeOpen(&pLBlockReader->mergeTree, (pLBlockReader->order == TSDB_ORDER_DESC), pReader->pFileReader, pReader->suid, pScanInfo->uid, &w, &pLBlockReader->verRange, - pLBlockReader->pInfo, false, pReader->idStr); + pLBlockReader->pInfo, false, pReader->idStr, false); if (code != TSDB_CODE_SUCCESS) { return false; } @@ -2508,7 +2558,13 @@ bool hasDataInFileBlock(const SBlockData* pBlockData, const SFileBlockDumpInfo* int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBlockScanInfo, int64_t key, STsdbReader* pReader) { SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo; - if (tryCopyDistinctRowFromFileBlock(pReader, pBlockData, key, pDumpInfo)) { + bool copied = false; + int32_t code = tryCopyDistinctRowFromFileBlock(pReader, pBlockData, key, pDumpInfo, &copied); + if (code) { + return code; + } + + if (copied) { pBlockScanInfo->lastKey = key; return TSDB_CODE_SUCCESS; } else { @@ -2528,11 +2584,11 @@ int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBloc return code; } - doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); + code = doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo); taosMemoryFree(pTSRow); tsdbRowMergerClear(&merge); - return TSDB_CODE_SUCCESS; + return code; } } @@ -2649,7 +2705,10 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) { if (isCleanFileDataBlock(pReader, pBlockInfo, pBlock, pBlockScanInfo, keyInBuf, pLastBlockReader) && pBlock->nRow <= pReader->capacity) { if (asc || ((!asc) && (!hasDataInLastBlock(pLastBlockReader)))) { - copyBlockDataToSDataBlock(pReader); + code = copyBlockDataToSDataBlock(pReader); + if (code) { + goto _end; + } // record the last key value pBlockScanInfo->lastKey = asc ? pBlock->maxKey.ts : pBlock->minKey.ts; @@ -2696,7 +2755,10 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) { break; } - buildComposedDataBlockImpl(pReader, pBlockScanInfo, pBlockData, pLastBlockReader); + code = buildComposedDataBlockImpl(pReader, pBlockScanInfo, pBlockData, pLastBlockReader); + if (code) { + goto _end; + } // currently loaded file data block is consumed if ((pBlockData->nRow > 0) && (pDumpInfo->rowIndex >= pBlockData->nRow || pDumpInfo->rowIndex < 0)) { @@ -2715,8 +2777,8 @@ _end: updateComposedBlockInfo(pReader, el, pBlockScanInfo); if (pResBlock->info.rows > 0) { - tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64 - " rows:%d, elapsed time:%.2f ms %s", + tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64 " rows:%" PRId64 + ", elapsed time:%.2f ms %s", pReader, pResBlock->info.id.uid, pResBlock->info.window.skey, pResBlock->info.window.ekey, pResBlock->info.rows, el, pReader->idStr); } @@ -2922,6 +2984,7 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) { SReaderStatus* pStatus = &pReader->status; SLastBlockReader* pLastBlockReader = pStatus->fileIter.pLastBlockReader; STableUidList* pUidList = &pStatus->uidList; + int32_t code = TSDB_CODE_SUCCESS; if (taosHashGetSize(pStatus->pTableMap) == 0) { return TSDB_CODE_SUCCESS; @@ -2952,7 +3015,11 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) { break; } - buildComposedDataBlockImpl(pReader, pScanInfo, &pReader->status.fileBlockData, pLastBlockReader); + code = buildComposedDataBlockImpl(pReader, pScanInfo, &pReader->status.fileBlockData, pLastBlockReader); + if (code) { + return code; + } + if (pResBlock->info.rows >= pReader->capacity) { break; } @@ -2962,8 +3029,8 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) { updateComposedBlockInfo(pReader, el, pScanInfo); if (pResBlock->info.rows > 0) { - tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64 - " rows:%d, elapsed time:%.2f ms %s", + tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64 " rows:%" PRId64 + ", elapsed time:%.2f ms %s", pReader, pResBlock->info.id.uid, pResBlock->info.window.skey, pResBlock->info.window.ekey, pResBlock->info.rows, el, pReader->idStr); return TSDB_CODE_SUCCESS; @@ -3032,7 +3099,11 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { break; } - buildComposedDataBlockImpl(pReader, pScanInfo, &pReader->status.fileBlockData, pLastBlockReader); + code = buildComposedDataBlockImpl(pReader, pScanInfo, &pReader->status.fileBlockData, pLastBlockReader); + if (code) { + return code; + } + if (pResBlock->info.rows >= pReader->capacity) { break; } @@ -3042,8 +3113,8 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { updateComposedBlockInfo(pReader, el, pScanInfo); if (pResBlock->info.rows > 0) { - tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64 - " rows:%d, elapsed time:%.2f ms %s", + tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64 " rows:%" PRId64 + ", elapsed time:%.2f ms %s", pReader, pResBlock->info.id.uid, pResBlock->info.window.skey, pResBlock->info.window.ekey, pResBlock->info.rows, el, pReader->idStr); } @@ -3069,6 +3140,148 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) { return code; } +static int32_t doSumFileBlockRows(STsdbReader* pReader, SDataFReader* pFileReader) { + int64_t st = taosGetTimestampUs(); + LRUHandle* handle = NULL; + int32_t code = tsdbCacheGetBlockIdx(pFileReader->pTsdb->biCache, pFileReader, &handle); + if (code != TSDB_CODE_SUCCESS || handle == NULL) { + goto _end; + } + + int32_t numOfTables = taosHashGetSize(pReader->status.pTableMap); + + SArray* aBlockIdx = (SArray*)taosLRUCacheValue(pFileReader->pTsdb->biCache, handle); + size_t num = taosArrayGetSize(aBlockIdx); + if (num == 0) { + tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle); + return TSDB_CODE_SUCCESS; + } + + SBlockIdx* pBlockIdx = NULL; + int32_t i = 0; + for (int32_t i = 0; i < num; ++i) { + pBlockIdx = (SBlockIdx*)taosArrayGet(aBlockIdx, i); + if (pBlockIdx->suid != pReader->suid) { + continue; + } + + STableBlockScanInfo** p = taosHashGet(pReader->status.pTableMap, &pBlockIdx->uid, sizeof(pBlockIdx->uid)); + if (p == NULL) { + continue; + } + + STableBlockScanInfo* pScanInfo = *p; + tMapDataReset(&pScanInfo->mapData); + tsdbReadDataBlk(pReader->pFileReader, pBlockIdx, &pScanInfo->mapData); + + SDataBlk block = {0}; + for (int32_t j = 0; j < pScanInfo->mapData.nItem; ++j) { + tGetDataBlk(pScanInfo->mapData.pData + pScanInfo->mapData.aOffset[j], &block); + pReader->rowsNum += block.nRow; + } + } + +_end: + tsdbBICacheRelease(pFileReader->pTsdb->biCache, handle); + return code; +} + +static int32_t doSumSttBlockRows(STsdbReader* pReader) { + int32_t code = TSDB_CODE_SUCCESS; + SLastBlockReader* pLastBlockReader = pReader->status.fileIter.pLastBlockReader; + SSttBlockLoadInfo* pBlockLoadInfo = NULL; + + for (int32_t i = 0; i < pReader->pFileReader->pSet->nSttF; ++i) { // open all last file + pBlockLoadInfo = &pLastBlockReader->pInfo[i]; + + code = tsdbReadSttBlk(pReader->pFileReader, i, pBlockLoadInfo->aSttBlk); + if (code) { + return code; + } + + size_t size = taosArrayGetSize(pBlockLoadInfo->aSttBlk); + if (size >= 1) { + SSttBlk* pStart = taosArrayGet(pBlockLoadInfo->aSttBlk, 0); + SSttBlk* pEnd = taosArrayGet(pBlockLoadInfo->aSttBlk, size - 1); + + // all identical + if (pStart->suid == pEnd->suid) { + if (pStart->suid != pReader->suid) { + // no qualified stt block existed + taosArrayClear(pBlockLoadInfo->aSttBlk); + continue; + } + for (int32_t i = 0; i < size; ++i) { + SSttBlk* p = taosArrayGet(pBlockLoadInfo->aSttBlk, i); + pReader->rowsNum += p->nRow; + } + } else { + for (int32_t i = 0; i < size; ++i) { + SSttBlk* p = taosArrayGet(pBlockLoadInfo->aSttBlk, i); + uint64_t s = p->suid; + if (s < pReader->suid) { + continue; + } + + if (s == pReader->suid) { + pReader->rowsNum += p->nRow; + } else if (s > pReader->suid) { + break; + } + } + } + } + } + + return code; +} + +static int32_t readRowsCountFromFiles(STsdbReader* pReader) { + int32_t code = TSDB_CODE_SUCCESS; + + while (1) { + bool hasNext = false; + int32_t code = filesetIteratorNext(&pReader->status.fileIter, pReader, &hasNext); + if (code) { + return code; + } + + if (!hasNext) { // no data files on disk + break; + } + + code = doSumFileBlockRows(pReader, pReader->pFileReader); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + code = doSumSttBlockRows(pReader); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + } + + pReader->status.loadFromFile = false; + + return code; +} + +static int32_t readRowsCountFromMem(STsdbReader* pReader) { + int32_t code = TSDB_CODE_SUCCESS; + int64_t memNum = 0, imemNum = 0; + if (pReader->pReadSnap->pMem != NULL) { + tsdbMemTableCountRows(pReader->pReadSnap->pMem, pReader->status.pTableMap, &memNum); + } + + if (pReader->pReadSnap->pIMem != NULL) { + tsdbMemTableCountRows(pReader->pReadSnap->pIMem, pReader->status.pTableMap, &imemNum); + } + + pReader->rowsNum += memNum + imemNum; + + return code; +} + static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) { SReaderStatus* pStatus = &pReader->status; STableUidList* pUidList = &pStatus->uidList; @@ -3677,8 +3890,9 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p if (ASCENDING_TRAVERSE(pReader->order)) { // ascending order imem --> mem STSchema* pSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(pRow), pReader, pBlockScanInfo->uid); + STSchema* piSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(piRow), pReader, pBlockScanInfo->uid); - int32_t code = tsdbRowMergerInit(&merge, piRow, pSchema); + int32_t code = tsdbRowMergerInit2(&merge, pSchema, piRow, piSchema); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -3689,7 +3903,7 @@ int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* p return code; } - tsdbRowMerge(&merge, pRow); + tsdbRowMergerAdd(&merge, pRow, pSchema); code = doMergeRowsInBuf(&pBlockScanInfo->iter, pBlockScanInfo->uid, k.ts, pBlockScanInfo->delSkyline, &merge, pReader); if (code != TSDB_CODE_SUCCESS) { @@ -3784,6 +3998,7 @@ int32_t tsdbGetNextRowInMem(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pR int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, SRow* pTSRow, STableBlockScanInfo* pScanInfo) { int32_t outputRowIndex = pBlock->info.rows; int64_t uid = pScanInfo->uid; + int32_t code = TSDB_CODE_SUCCESS; int32_t numOfCols = (int32_t)taosArrayGetSize(pBlock->pDataBlock); @@ -3806,7 +4021,10 @@ int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, SRow* pT SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pSupInfo->slotId[i]); tRowGet(pTSRow, pSchema, j, &colVal); - doCopyColVal(pColInfoData, outputRowIndex, i, &colVal, pSupInfo); + code = doCopyColVal(pColInfoData, outputRowIndex, i, &colVal, pSupInfo); + if (code) { + return code; + } i += 1; j += 1; } else if (colId < pSchema->columns[j].colId) { @@ -3836,6 +4054,7 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S int32_t rowIndex) { int32_t i = 0, j = 0; int32_t outputRowIndex = pResBlock->info.rows; + int32_t code = TSDB_CODE_SUCCESS; SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo; if (pReader->suppInfo.colId[i] == PRIMARYKEY_TIMESTAMP_COL_ID) { @@ -3858,7 +4077,10 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S SColumnInfoData* pCol = TARRAY_GET_ELEM(pResBlock->pDataBlock, pSupInfo->slotId[i]); if (pData->cid == pSupInfo->colId[i]) { tColDataGetValue(pData, rowIndex, &cv); - doCopyColVal(pCol, outputRowIndex, i, &cv, pSupInfo); + code = doCopyColVal(pCol, outputRowIndex, i, &cv, pSupInfo); + if (code) { + return code; + } j += 1; } else if (pData->cid > pCol->info.colId) { // the specified column does not exist in file block, fill with null data @@ -3882,6 +4104,7 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t endKey, int32_t capacity, STsdbReader* pReader) { SSDataBlock* pBlock = pReader->pResBlock; + int32_t code = TSDB_CODE_SUCCESS; do { // SRow* pTSRow = NULL; @@ -3893,13 +4116,20 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e } if (row.type == TSDBROW_ROW_FMT) { - doAppendRowFromTSRow(pBlock, pReader, row.pTSRow, pBlockScanInfo); + code = doAppendRowFromTSRow(pBlock, pReader, row.pTSRow, pBlockScanInfo); if (freeTSRow) { taosMemoryFree(row.pTSRow); } + + if (code) { + return code; + } } else { - doAppendRowFromFileBlock(pBlock, pReader, row.pBlockData, row.iRow); + code = doAppendRowFromFileBlock(pBlock, pReader, row.pBlockData, row.iRow); + if (code) { + break; + } } // no data in buffer, return immediately @@ -3912,7 +4142,7 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e } } while (1); - return TSDB_CODE_SUCCESS; + return code; } // TODO refactor: with createDataBlockScanInfo @@ -3929,8 +4159,13 @@ int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t n if (code) { return code; } - pReader->status.uidList.tableUidList = - (uint64_t*)taosMemoryRealloc(pReader->status.uidList.tableUidList, sizeof(uint64_t) * num); + + char* p1 = taosMemoryRealloc(pReader->status.uidList.tableUidList, sizeof(uint64_t) * num); + if (p1 == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + pReader->status.uidList.tableUidList = (uint64_t*)p1; } taosHashClear(pReader->status.pTableMap); @@ -3986,6 +4221,8 @@ static int32_t doOpenReaderImpl(STsdbReader* pReader) { int32_t code = TSDB_CODE_SUCCESS; if (pStatus->fileIter.numOfFiles == 0) { pStatus->loadFromFile = false; + } else if (READ_MODE_COUNT_ONLY == pReader->readMode) { + // DO NOTHING } else { code = initForFirstBlockInFile(pReader, pBlockIter); } @@ -3997,14 +4234,15 @@ static int32_t doOpenReaderImpl(STsdbReader* pReader) { return code; } +static void freeSchemaFunc(void* param) { + void* p = *(void**)param; + taosMemoryFree(p); +} + // ====================================== EXPOSED APIs ====================================== int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableList, int32_t numOfTables, - SSDataBlock* pResBlock, STsdbReader** ppReader, const char* idstr) { + SSDataBlock* pResBlock, STsdbReader** ppReader, const char* idstr, bool countOnly) { STimeWindow window = pCond->twindows; - if (pCond->type == TIMEWINDOW_RANGE_EXTERNAL) { - pCond->twindows.skey += 1; - pCond->twindows.ekey -= 1; - } int32_t capacity = pVnode->config.tsdbCfg.maxRows; if (pResBlock != NULL) { @@ -4027,11 +4265,11 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL // update the SQueryTableDataCond to create inner reader int32_t order = pCond->order; if (order == TSDB_ORDER_ASC) { - pCond->twindows.ekey = window.skey; + pCond->twindows.ekey = window.skey - 1; pCond->twindows.skey = INT64_MIN; pCond->order = TSDB_ORDER_DESC; } else { - pCond->twindows.skey = window.ekey; + pCond->twindows.skey = window.ekey + 1; pCond->twindows.ekey = INT64_MAX; pCond->order = TSDB_ORDER_ASC; } @@ -4043,11 +4281,11 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL } if (order == TSDB_ORDER_ASC) { - pCond->twindows.skey = window.ekey; + pCond->twindows.skey = window.ekey + 1; pCond->twindows.ekey = INT64_MAX; } else { pCond->twindows.skey = INT64_MIN; - pCond->twindows.ekey = window.ekey; + pCond->twindows.ekey = window.ekey - 1; } pCond->order = order; @@ -4073,6 +4311,14 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL } } + pReader->pSchemaMap = tSimpleHashInit(8, taosFastHash); + if (pReader->pSchemaMap == NULL) { + tsdbError("failed init schema hash for reader %s", pReader->idStr); + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + + tSimpleHashSetFreeFp(pReader->pSchemaMap, freeSchemaFunc); if (pReader->pSchema != NULL) { code = updateBlockSMAInfo(pReader->pSchema, &pReader->suppInfo); if (code != TSDB_CODE_SUCCESS) { @@ -4091,6 +4337,10 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL pReader->suspended = true; + if (countOnly) { + pReader->readMode = READ_MODE_COUNT_ONLY; + } + tsdbDebug("%p total numOfTable:%d in this query %s", pReader, numOfTables, pReader->idStr); return code; @@ -4115,7 +4365,7 @@ void tsdbReaderClose(STsdbReader* pReader) { p->status.uidList.tableUidList = NULL; p->pReadSnap = NULL; p->pSchema = NULL; - p->pMemSchema = NULL; + p->pSchemaMap = NULL; p = pReader->innerReader[1]; @@ -4123,7 +4373,7 @@ void tsdbReaderClose(STsdbReader* pReader) { p->status.uidList.tableUidList = NULL; p->pReadSnap = NULL; p->pSchema = NULL; - p->pMemSchema = NULL; + p->pSchemaMap = NULL; tsdbReaderClose(pReader->innerReader[0]); tsdbReaderClose(pReader->innerReader[1]); @@ -4203,10 +4453,7 @@ void tsdbReaderClose(STsdbReader* pReader) { taosMemoryFree(pReader->idStr); taosMemoryFree(pReader->pSchema); - if (pReader->pMemSchema != pReader->pSchema) { - taosMemoryFree(pReader->pMemSchema); - } - + tSimpleHashCleanup(pReader->pSchemaMap); taosMemoryFreeClear(pReader); } @@ -4220,12 +4467,8 @@ int32_t tsdbReaderSuspend(STsdbReader* pReader) { if (pStatus->loadFromFile) { SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter); if (pBlockInfo != NULL) { - pBlockScanInfo = - *(STableBlockScanInfo**)taosHashGet(pStatus->pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid)); + pBlockScanInfo = getTableBlockScanInfo(pStatus->pTableMap, pBlockInfo->uid, pReader->idStr); if (pBlockScanInfo == NULL) { - code = TSDB_CODE_INVALID_PARA; - tsdbError("failed to locate the uid:%" PRIu64 " in query table uid list, total tables:%d, %s", pBlockInfo->uid, - taosHashGetSize(pReader->status.pTableMap), pReader->idStr); goto _err; } } else { @@ -4370,14 +4613,14 @@ int32_t tsdbReaderResume(STsdbReader* pReader) { pPrevReader->status.pTableMap = pReader->status.pTableMap; pPrevReader->status.uidList = pReader->status.uidList; pPrevReader->pSchema = pReader->pSchema; - pPrevReader->pMemSchema = pReader->pMemSchema; + pPrevReader->pSchemaMap = pReader->pSchemaMap; pPrevReader->pReadSnap = pReader->pReadSnap; pNextReader->capacity = 1; pNextReader->status.pTableMap = pReader->status.pTableMap; pNextReader->status.uidList = pReader->status.uidList; pNextReader->pSchema = pReader->pSchema; - pNextReader->pMemSchema = pReader->pMemSchema; + pNextReader->pSchemaMap = pReader->pSchemaMap; pNextReader->pReadSnap = pReader->pReadSnap; code = doOpenReaderImpl(pPrevReader); @@ -4398,43 +4641,82 @@ _err: return code; } -static bool doTsdbNextDataBlock(STsdbReader* pReader) { +static bool tsdbReadRowsCountOnly(STsdbReader* pReader) { + int32_t code = TSDB_CODE_SUCCESS; + SSDataBlock* pBlock = pReader->pResBlock; + + if (pReader->status.loadFromFile == false) { + return false; + } + + code = readRowsCountFromFiles(pReader); + if (code != TSDB_CODE_SUCCESS) { + return false; + } + + code = readRowsCountFromMem(pReader); + if (code != TSDB_CODE_SUCCESS) { + return false; + } + + pBlock->info.rows = pReader->rowsNum; + pBlock->info.id.uid = 0; + pBlock->info.dataLoad = 0; + + pReader->rowsNum = 0; + + return pBlock->info.rows > 0; +} + +static int32_t doTsdbNextDataBlock(STsdbReader* pReader, bool* hasNext) { + int32_t code = TSDB_CODE_SUCCESS; + // cleanup the data that belongs to the previous data block SSDataBlock* pBlock = pReader->pResBlock; blockDataCleanup(pBlock); + *hasNext = false; + SReaderStatus* pStatus = &pReader->status; if (taosHashGetSize(pStatus->pTableMap) == 0) { - return false; + return code; + } + + if (READ_MODE_COUNT_ONLY == pReader->readMode) { + return tsdbReadRowsCountOnly(pReader); } if (pStatus->loadFromFile) { - int32_t code = buildBlockFromFiles(pReader); + code = buildBlockFromFiles(pReader); if (code != TSDB_CODE_SUCCESS) { - return false; + return code; } - if (pBlock->info.rows > 0) { - return true; - } else { + if (pBlock->info.rows <= 0) { resetTableListIndex(&pReader->status); - buildBlockFromBufferSequentially(pReader); - return pBlock->info.rows > 0; + code = buildBlockFromBufferSequentially(pReader); } } else { // no data in files, let's try the buffer - buildBlockFromBufferSequentially(pReader); - return pBlock->info.rows > 0; + code = buildBlockFromBufferSequentially(pReader); } + + *hasNext = pBlock->info.rows > 0; + + return code; } -bool tsdbNextDataBlock(STsdbReader* pReader) { +int32_t tsdbNextDataBlock(STsdbReader* pReader, bool* hasNext) { + int32_t code = TSDB_CODE_SUCCESS; + + *hasNext = false; + if (isEmptyQueryTimeWindow(&pReader->window) || pReader->step == EXTERNAL_ROWS_NEXT) { - return false; + return code; } SReaderStatus* pStatus = &pReader->status; - int32_t code = tsdbAcquireReader(pReader); + code = tsdbAcquireReader(pReader); qTrace("tsdb/read: %p, take read mutex, code: %d", pReader, code); if (pReader->suspended) { @@ -4442,23 +4724,29 @@ bool tsdbNextDataBlock(STsdbReader* pReader) { } if (pReader->innerReader[0] != NULL && pReader->step == 0) { - bool ret = doTsdbNextDataBlock(pReader->innerReader[0]); + code = doTsdbNextDataBlock(pReader->innerReader[0], hasNext); + if (code) { + tsdbReleaseReader(pReader); + return code; + } + pReader->step = EXTERNAL_ROWS_PREV; - if (ret) { + if (*hasNext) { pStatus = &pReader->innerReader[0]->status; if (pStatus->composedDataBlock) { qTrace("tsdb/read: %p, unlock read mutex", pReader); tsdbReleaseReader(pReader); } - return ret; + return code; } } if (pReader->step == EXTERNAL_ROWS_PREV) { // prepare for the main scan - int32_t code = doOpenReaderImpl(pReader); - resetAllDataBlockScanInfo(pReader->status.pTableMap, pReader->innerReader[0]->window.ekey); + code = doOpenReaderImpl(pReader); + int32_t step = 1; + resetAllDataBlockScanInfo(pReader->status.pTableMap, pReader->innerReader[0]->window.ekey, step); if (code != TSDB_CODE_SUCCESS) { return code; @@ -4467,41 +4755,52 @@ bool tsdbNextDataBlock(STsdbReader* pReader) { pReader->step = EXTERNAL_ROWS_MAIN; } - bool ret = doTsdbNextDataBlock(pReader); - if (ret) { + code = doTsdbNextDataBlock(pReader, hasNext); + if (code != TSDB_CODE_SUCCESS) { + tsdbReleaseReader(pReader); + return code; + } + + if (*hasNext) { if (pStatus->composedDataBlock) { qTrace("tsdb/read: %p, unlock read mutex", pReader); tsdbReleaseReader(pReader); } - return ret; + return code; } if (pReader->step == EXTERNAL_ROWS_MAIN && pReader->innerReader[1] != NULL) { // prepare for the next row scan - int32_t code = doOpenReaderImpl(pReader->innerReader[1]); - resetAllDataBlockScanInfo(pReader->innerReader[1]->status.pTableMap, pReader->window.ekey); + int32_t step = -1; + code = doOpenReaderImpl(pReader->innerReader[1]); + resetAllDataBlockScanInfo(pReader->innerReader[1]->status.pTableMap, pReader->window.ekey, step); if (code != TSDB_CODE_SUCCESS) { return code; } - ret = doTsdbNextDataBlock(pReader->innerReader[1]); + code = doTsdbNextDataBlock(pReader->innerReader[1], hasNext); + if (code != TSDB_CODE_SUCCESS) { + tsdbReleaseReader(pReader); + return code; + } + pReader->step = EXTERNAL_ROWS_NEXT; - if (ret) { + if (*hasNext) { pStatus = &pReader->innerReader[1]->status; if (pStatus->composedDataBlock) { qTrace("tsdb/read: %p, unlock read mutex", pReader); tsdbReleaseReader(pReader); } - return ret; + return code; } } qTrace("tsdb/read: %p, unlock read mutex", pReader); tsdbReleaseReader(pReader); - return false; + return code; } static void doFillNullColSMA(SBlockLoadSuppInfo* pSup, int32_t numOfRows, int32_t numOfCols, SColumnDataAgg* pTsAgg) { @@ -4509,6 +4808,7 @@ static void doFillNullColSMA(SBlockLoadSuppInfo* pSup, int32_t numOfRows, int32_ int32_t i = 0, j = 0; int32_t size = (int32_t)taosArrayGetSize(pSup->pColAgg); taosArrayInsert(pSup->pColAgg, 0, pTsAgg); + size++; while (j < numOfCols && i < size) { SColumnDataAgg* pAgg = taosArrayGet(pSup->pColAgg, i); @@ -4521,10 +4821,21 @@ static void doFillNullColSMA(SBlockLoadSuppInfo* pSup, int32_t numOfRows, int32_ if (pSup->colId[j] != PRIMARYKEY_TIMESTAMP_COL_ID) { SColumnDataAgg nullColAgg = {.colId = pSup->colId[j], .numOfNull = numOfRows}; taosArrayInsert(pSup->pColAgg, i, &nullColAgg); + i += 1; + size++; } j += 1; } } + + while (j < numOfCols) { + if (pSup->colId[j] != PRIMARYKEY_TIMESTAMP_COL_ID) { + SColumnDataAgg nullColAgg = {.colId = pSup->colId[j], .numOfNull = numOfRows}; + taosArrayInsert(pSup->pColAgg, i, &nullColAgg); + i += 1; + } + j++; + } } int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock, bool* allHave) { @@ -4550,6 +4861,8 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock, return TSDB_CODE_SUCCESS; } + int64_t st = taosGetTimestampUs(); + SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter); if (tDataBlkHasSma(pBlock)) { code = tsdbReadBlockSma(pReader->pFileReader, pBlock, pSup->pColAgg); @@ -4602,8 +4915,8 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock, } else if (pAgg->colId < pSup->colId[j]) { i += 1; } else if (pSup->colId[j] < pAgg->colId) { - // ASSERT(pSup->colId[j] == PRIMARYKEY_TIMESTAMP_COL_ID); - pResBlock->pBlockAgg[pSup->slotId[j]] = &pSup->tsColAgg; + pResBlock->pBlockAgg[pSup->slotId[j]] = NULL; + *allHave = false; j += 1; } } @@ -4611,6 +4924,9 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SSDataBlock* pDataBlock, *pBlockSMA = pResBlock->pBlockAgg; pReader->cost.smaDataLoad += 1; + double elapsedTime = (taosGetTimestampUs() - st) / 1000.0; + pReader->cost.smaLoadTime += elapsedTime; + tsdbDebug("vgId:%d, succeed to load block SMA for uid %" PRIu64 ", %s", 0, pFBlock->uid, pReader->idStr); return code; } @@ -4629,20 +4945,27 @@ STableBlockScanInfo* getTableBlockScanInfo(SHashObj* pTableMap, uint64_t uid, co static SSDataBlock* doRetrieveDataBlock(STsdbReader* pReader) { SReaderStatus* pStatus = &pReader->status; + int32_t code = TSDB_CODE_SUCCESS; SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(&pStatus->blockIter); STableBlockScanInfo* pBlockScanInfo = getTableBlockScanInfo(pStatus->pTableMap, pBlockInfo->uid, pReader->idStr); if (pBlockScanInfo == NULL) { return NULL; } - int32_t code = doLoadFileBlockData(pReader, &pStatus->blockIter, &pStatus->fileBlockData, pBlockScanInfo->uid); + code = doLoadFileBlockData(pReader, &pStatus->blockIter, &pStatus->fileBlockData, pBlockScanInfo->uid); + if (code != TSDB_CODE_SUCCESS) { + tBlockDataDestroy(&pStatus->fileBlockData); + terrno = code; + return NULL; + } + + code = copyBlockDataToSDataBlock(pReader); if (code != TSDB_CODE_SUCCESS) { tBlockDataDestroy(&pStatus->fileBlockData); terrno = code; return NULL; } - copyBlockDataToSDataBlock(pReader); return pReader->pResBlock; } @@ -4678,15 +5001,12 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) { } if (isEmptyQueryTimeWindow(&pReader->window) || pReader->pReadSnap == NULL) { - tsdbDebug("tsdb reader reset return %p", pReader->pReadSnap); - + tsdbDebug("tsdb reader reset return %p, %s", pReader->pReadSnap, pReader->idStr); tsdbReleaseReader(pReader); - return TSDB_CODE_SUCCESS; } - SReaderStatus* pStatus = &pReader->status; - + SReaderStatus* pStatus = &pReader->status; SDataBlockIter* pBlockIter = &pStatus->blockIter; pReader->order = pCond->order; @@ -4707,8 +5027,10 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) { resetDataBlockIterator(pBlockIter, pReader->order); resetTableListIndex(&pReader->status); - int64_t ts = ASCENDING_TRAVERSE(pReader->order) ? pReader->window.skey - 1 : pReader->window.ekey + 1; - resetAllDataBlockScanInfo(pStatus->pTableMap, ts); + bool asc = ASCENDING_TRAVERSE(pReader->order); + int32_t step = asc ? 1 : -1; + int64_t ts = asc ? pReader->window.skey - 1 : pReader->window.ekey + 1; + resetAllDataBlockScanInfo(pStatus->pTableMap, ts, step); int32_t code = 0; @@ -4723,7 +5045,6 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) { numOfTables, pReader->window.skey, pReader->window.ekey, pReader->idStr); tsdbReleaseReader(pReader); - return code; } } @@ -4767,7 +5088,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa pTableBlockInfo->defMinRows = pc->minRows; pTableBlockInfo->defMaxRows = pc->maxRows; - int32_t bucketRange = ceil((pc->maxRows - pc->minRows) / numOfBuckets); + int32_t bucketRange = ceil(((double)(pc->maxRows - pc->minRows)) / numOfBuckets); pTableBlockInfo->numOfFiles += 1; @@ -4992,3 +5313,9 @@ void tsdbUntakeReadSnap(STsdbReader* pReader, STsdbReadSnap* pSnap, bool proacti } tsdbTrace("vgId:%d, untake read snapshot", TD_VID(pTsdb->pVnode)); } + +// if failed, do nothing +void tsdbReaderSetId(STsdbReader* pReader, const char* idstr) { + taosMemoryFreeClear(pReader->idStr); + pReader->idStr = taosStrdup(idstr); +} diff --git a/source/dnode/vnode/src/vnd/vnodeCommit.c b/source/dnode/vnode/src/vnd/vnodeCommit.c index 0779388ba9ca6da06ff0bfe3ce65219904118f0e..09f1ca78776784673a92f2a23d65314bf14b360c 100644 --- a/source/dnode/vnode/src/vnd/vnodeCommit.c +++ b/source/dnode/vnode/src/vnd/vnodeCommit.c @@ -156,13 +156,10 @@ int vnodeShouldCommit(SVnode *pVnode) { bool needCommit = false; taosThreadMutexLock(&pVnode->mutex); - if (!pVnode->inUse || !diskAvail) { - goto _out; + if (pVnode->inUse && diskAvail) { + needCommit = + ((pVnode->inUse->size > pVnode->inUse->node.size) && (pSched->commitMs + SYNC_VND_COMMIT_MIN_MS < nowMs)); } - needCommit = - (((pVnode->inUse->size > pVnode->inUse->node.size) && (pSched->commitMs + SYNC_VND_COMMIT_MIN_MS < nowMs)) || - (pVnode->inUse->size > 0 && pSched->commitMs + pSched->maxWaitMs < nowMs)); -_out: taosThreadMutexUnlock(&pVnode->mutex); return needCommit; } diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index c017266839a872711b5262ee6671d17d3a3a76b6..303d2a9ca449de504a582c8472951a1bf6c6c683 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -382,6 +382,7 @@ int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) { pLoad->syncRestore = state.restored; pLoad->syncCanRead = state.canRead; pLoad->cacheUsage = tsdbCacheGetUsage(pVnode); + pLoad->numOfCachedTables = tsdbCacheGetElems(pVnode); pLoad->numOfTables = metaGetTbNum(pVnode->pMeta); pLoad->numOfTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta); pLoad->totalStorage = (int64_t)3 * 1073741824; diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index 71458acce2cdab30365c452d23efd5841bb9424a..052e4ab2c18e6dad651cf591962bcb4dd49a0a38 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -335,6 +335,7 @@ int32_t vnodeSnapWriterClose(SVSnapWriter *pWriter, int8_t rollback, SSnapshot * // commit json if (!rollback) { + pWriter->info.state.committed = pWriter->ever; pVnode->config = pWriter->info.config; pVnode->state = (SVState){.committed = pWriter->info.state.committed, .applied = pWriter->info.state.committed, diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 45113d55d33621c737639a7bdab3ef60c0879c9b..02d361ccdb0715f539dd2572e730cd1fd89bff81 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -306,13 +306,7 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp void *pReq; int32_t len; int32_t ret; - /* - if (!pVnode->inUse) { - terrno = TSDB_CODE_VND_NO_AVAIL_BUFPOOL; - vError("vgId:%d, not ready to write since %s", TD_VID(pVnode), terrstr()); - return -1; - } - */ + if (version <= pVnode->state.applied) { vError("vgId:%d, duplicate write request. version: %" PRId64 ", applied: %" PRId64 "", TD_VID(pVnode), version, pVnode->state.applied); @@ -326,8 +320,8 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp ASSERT(pVnode->state.applyTerm <= pMsg->info.conn.applyTerm); ASSERT(pVnode->state.applied + 1 == version); - pVnode->state.applied = version; - pVnode->state.applyTerm = pMsg->info.conn.applyTerm; + atomic_store_64(&pVnode->state.applied, version); + atomic_store_64(&pVnode->state.applyTerm, pMsg->info.conn.applyTerm); if (!syncUtilUserCommit(pMsg->msgType)) goto _exit; @@ -516,7 +510,7 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg) { int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) { vTrace("vgId:%d, msg:%p in fetch queue is processing", pVnode->config.vgId, pMsg); if ((pMsg->msgType == TDMT_SCH_FETCH || pMsg->msgType == TDMT_VND_TABLE_META || pMsg->msgType == TDMT_VND_TABLE_CFG || - pMsg->msgType == TDMT_VND_BATCH_META) && + pMsg->msgType == TDMT_VND_BATCH_META || pMsg->msgType == TDMT_VND_TMQ_CONSUME) && !syncIsReadyForRead(pVnode->sync)) { vnodeRedirectRpcMsg(pVnode, pMsg, terrno); return 0; @@ -1477,10 +1471,11 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t version, void } vInfo("vgId:%d, start to alter vnode config, page:%d pageSize:%d buffer:%d szPage:%d szBuf:%" PRIu64 - " cacheLast:%d cacheLastSize:%d days:%d keep0:%d keep1:%d keep2:%d fsync:%d level:%d", + " cacheLast:%d cacheLastSize:%d days:%d keep0:%d keep1:%d keep2:%d fsync:%d level:%d walRetentionPeriod:%d " + "walRetentionSize:%d", TD_VID(pVnode), req.pages, req.pageSize, req.buffer, req.pageSize * 1024, (uint64_t)req.buffer * 1024 * 1024, req.cacheLast, req.cacheLastSize, req.daysPerFile, req.daysToKeep0, req.daysToKeep1, req.daysToKeep2, - req.walFsyncPeriod, req.walLevel); + req.walFsyncPeriod, req.walLevel, req.walRetentionPeriod, req.walRetentionSize); if (pVnode->config.cacheLastSize != req.cacheLastSize) { pVnode->config.cacheLastSize = req.cacheLastSize; @@ -1510,13 +1505,21 @@ static int32_t vnodeProcessAlterConfigReq(SVnode *pVnode, int64_t version, void if (pVnode->config.walCfg.fsyncPeriod != req.walFsyncPeriod) { pVnode->config.walCfg.fsyncPeriod = req.walFsyncPeriod; - walChanged = true; } if (pVnode->config.walCfg.level != req.walLevel) { pVnode->config.walCfg.level = req.walLevel; + walChanged = true; + } + + if (pVnode->config.walCfg.retentionPeriod != req.walRetentionPeriod) { + pVnode->config.walCfg.retentionPeriod = req.walRetentionPeriod; + walChanged = true; + } + if (pVnode->config.walCfg.retentionSize != req.walRetentionSize) { + pVnode->config.walCfg.retentionSize = req.walRetentionSize; walChanged = true; } diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index e71b03d2af86c69ac6437094dfbeffe4a6da4faa..d681f5b65e2228e6d2b16c88688ba672ad26564d 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -378,7 +378,7 @@ static int32_t vnodeSyncEqCtrlMsg(const SMsgCb *msgcb, SRpcMsg *pMsg) { return -1; } - int32_t code = tmsgPutToQueue(msgcb, SYNC_CTRL_QUEUE, pMsg); + int32_t code = tmsgPutToQueue(msgcb, SYNC_RD_QUEUE, pMsg); if (code != 0) { rpcFreeCont(pMsg->pCont); pMsg->pCont = NULL; @@ -433,7 +433,23 @@ static int32_t vnodeSyncApplyMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsm } static int32_t vnodeSyncCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) { - return vnodeSyncApplyMsg(pFsm, pMsg, pMeta); + if (pMsg->code == 0) { + return vnodeSyncApplyMsg(pFsm, pMsg, pMeta); + } + + const STraceId *trace = &pMsg->info.traceId; + SVnode *pVnode = pFsm->data; + vnodePostBlockMsg(pVnode, pMsg); + + SRpcMsg rsp = {.code = pMsg->code, .info = pMsg->info}; + if (rsp.info.handle != NULL) { + tmsgSendRsp(&rsp); + } + + vGTrace("vgId:%d, msg:%p is freed, code:0x%x index:%" PRId64, TD_VID(pVnode), pMsg, rsp.code, pMeta->index); + rpcFreeCont(pMsg->pCont); + pMsg->pCont = NULL; + return 0; } static int32_t vnodeSyncPreCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) { @@ -443,6 +459,11 @@ static int32_t vnodeSyncPreCommitMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const return 0; } +static SyncIndex vnodeSyncAppliedIndex(const SSyncFSM *pFSM) { + SVnode *pVnode = pFSM->data; + return atomic_load_64(&pVnode->state.applied); +} + static void vnodeSyncRollBackMsg(const SSyncFSM *pFsm, SRpcMsg *pMsg, const SFsmCbMeta *pMeta) { SVnode *pVnode = pFsm->data; vTrace("vgId:%d, rollback-cb is excuted, fsm:%p, index:%" PRId64 ", weak:%d, code:%d, state:%d %s, type:%s", @@ -505,21 +526,26 @@ static int32_t vnodeSnapshotDoWrite(const SSyncFSM *pFsm, void *pWriter, void *p return code; } -static void vnodeRestoreFinish(const SSyncFSM *pFsm) { +static void vnodeRestoreFinish(const SSyncFSM *pFsm, const SyncIndex commitIdx) { SVnode *pVnode = pFsm->data; + SyncIndex appliedIdx = -1; do { - int32_t itemSize = tmsgGetQueueSize(&pVnode->msgCb, pVnode->config.vgId, APPLY_QUEUE); - if (itemSize == 0) { - vInfo("vgId:%d, apply queue is empty, restore finish", pVnode->config.vgId); + appliedIdx = vnodeSyncAppliedIndex(pFsm); + ASSERT(appliedIdx <= commitIdx); + if (appliedIdx == commitIdx) { + vInfo("vgId:%d, no items to be applied, restore finish", pVnode->config.vgId); break; } else { - vInfo("vgId:%d, restore not finish since %d items in apply queue", pVnode->config.vgId, itemSize); + vInfo("vgId:%d, restore not finish since %" PRId64 " items to be applied. commit-index:%" PRId64 + ", applied-index:%" PRId64, + pVnode->config.vgId, commitIdx - appliedIdx, commitIdx, appliedIdx); taosMsleep(10); } } while (true); - walApplyVer(pVnode->pWal, pVnode->state.applied); + ASSERT(commitIdx == vnodeSyncAppliedIndex(pFsm)); + walApplyVer(pVnode->pWal, commitIdx); pVnode->restored = true; vInfo("vgId:%d, sync restore finished", pVnode->config.vgId); @@ -569,6 +595,7 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) { SSyncFSM *pFsm = taosMemoryCalloc(1, sizeof(SSyncFSM)); pFsm->data = pVnode; pFsm->FpCommitCb = vnodeSyncCommitMsg; + pFsm->FpAppliedIndexCb = vnodeSyncAppliedIndex; pFsm->FpPreCommitCb = vnodeSyncPreCommitMsg; pFsm->FpRollBackCb = vnodeSyncRollBackMsg; pFsm->FpGetSnapshotInfo = vnodeSyncGetSnapshotInfo; diff --git a/source/libs/catalog/src/ctgDbg.c b/source/libs/catalog/src/ctgDbg.c index b5d587d257a8d084246efa86ed72e77a723de98c..12ff8a7b388a994e8fd0249a557e993768934342 100644 --- a/source/libs/catalog/src/ctgDbg.c +++ b/source/libs/catalog/src/ctgDbg.c @@ -21,6 +21,8 @@ extern SCatalogMgmt gCtgMgmt; SCtgDebug gCTGDebug = {0}; +#if 0 + void ctgdUserCallback(SMetaData *pResult, void *param, int32_t code) { taosMemoryFree(param); @@ -224,6 +226,7 @@ _return: CTG_RET(code); } +#endif int32_t ctgdEnableDebug(char *option, bool enable) { if (0 == strcasecmp(option, "lock")) { diff --git a/source/libs/catalog/src/ctgUtil.c b/source/libs/catalog/src/ctgUtil.c index a2f2a3d556fea5049e643cdbd7be7e753a89e1db..fd6ee6c1b9f36f7fbe8d8e9a6b754957334028e6 100644 --- a/source/libs/catalog/src/ctgUtil.c +++ b/source/libs/catalog/src/ctgUtil.c @@ -865,19 +865,19 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName vgInfo = taosArraySearch(dbInfo->vgArray, &hashValue, ctgHashValueComp, TD_EQ); -/* - void* pIter = taosHashIterate(dbInfo->vgHash, NULL); - while (pIter) { - vgInfo = pIter; - if (hashValue >= vgInfo->hashBegin && hashValue <= vgInfo->hashEnd) { - taosHashCancelIterate(dbInfo->vgHash, pIter); - break; - } + /* + void* pIter = taosHashIterate(dbInfo->vgHash, NULL); + while (pIter) { + vgInfo = pIter; + if (hashValue >= vgInfo->hashBegin && hashValue <= vgInfo->hashEnd) { + taosHashCancelIterate(dbInfo->vgHash, pIter); + break; + } - pIter = taosHashIterate(dbInfo->vgHash, pIter); - vgInfo = NULL; - } -*/ + pIter = taosHashIterate(dbInfo->vgHash, pIter); + vgInfo = NULL; + } + */ if (NULL == vgInfo) { ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, db, @@ -902,7 +902,7 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo* CTG_ERR_RET(ctgMakeVgArray(dbInfo)); - int32_t vgNum = taosArrayGetSize(dbInfo->vgArray); + int32_t vgNum = taosArrayGetSize(dbInfo->vgArray); if (vgNum <= 0) { ctgError("db vgroup cache invalid, db:%s, vgroup number:%d", dbFName, vgNum); CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); @@ -982,43 +982,43 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo* CTG_RET(code); } -int32_t ctgGetVgIdsFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, char* dbFName, const char* pTbs[], int32_t tbNum, int32_t* vgId) { - int32_t code = 0; - CTG_ERR_RET(ctgMakeVgArray(dbInfo)); +int32_t ctgGetVgIdsFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, char* dbFName, const char* pTbs[], int32_t tbNum, + int32_t* vgId) { + int32_t code = 0; + CTG_ERR_RET(ctgMakeVgArray(dbInfo)); + + int32_t vgNum = taosArrayGetSize(dbInfo->vgArray); - int32_t vgNum = taosArrayGetSize(dbInfo->vgArray); + if (vgNum <= 0) { + ctgError("db vgroup cache invalid, db:%s, vgroup number:%d", dbFName, vgNum); + CTG_ERR_RET(TSDB_CODE_TSC_DB_NOT_SELECTED); + } - if (vgNum <= 0) { - ctgError("db vgroup cache invalid, db:%s, vgroup number:%d", dbFName, vgNum); - CTG_ERR_RET(TSDB_CODE_TSC_DB_NOT_SELECTED); - } + SVgroupInfo* vgInfo = NULL; + char tbFullName[TSDB_TABLE_FNAME_LEN]; + snprintf(tbFullName, sizeof(tbFullName), "%s.", dbFName); + int32_t offset = strlen(tbFullName); - SVgroupInfo* vgInfo = NULL; - char tbFullName[TSDB_TABLE_FNAME_LEN]; - snprintf(tbFullName, sizeof(tbFullName), "%s.", dbFName); - int32_t offset = strlen(tbFullName); - - for (int32_t i = 0; i < tbNum; ++i) { - snprintf(tbFullName + offset, sizeof(tbFullName) - offset, "%s", pTbs[i]); - uint32_t hashValue = taosGetTbHashVal(tbFullName, (uint32_t)strlen(tbFullName), dbInfo->hashMethod, - dbInfo->hashPrefix, dbInfo->hashSuffix); + for (int32_t i = 0; i < tbNum; ++i) { + snprintf(tbFullName + offset, sizeof(tbFullName) - offset, "%s", pTbs[i]); + uint32_t hashValue = taosGetTbHashVal(tbFullName, (uint32_t)strlen(tbFullName), dbInfo->hashMethod, + dbInfo->hashPrefix, dbInfo->hashSuffix); - vgInfo = taosArraySearch(dbInfo->vgArray, &hashValue, ctgHashValueComp, TD_EQ); - if (NULL == vgInfo) { - ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, dbFName, - (int32_t)taosArrayGetSize(dbInfo->vgArray)); - CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); - } + vgInfo = taosArraySearch(dbInfo->vgArray, &hashValue, ctgHashValueComp, TD_EQ); + if (NULL == vgInfo) { + ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, dbFName, + (int32_t)taosArrayGetSize(dbInfo->vgArray)); + CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); + } - vgId[i] = vgInfo->vgId; + vgId[i] = vgInfo->vgId; - ctgDebug("Got tb %s vgId:%d", tbFullName, vgInfo->vgId); - } + ctgDebug("Got tb %s vgId:%d", tbFullName, vgInfo->vgId); + } - CTG_RET(code); + CTG_RET(code); } - int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2) { if (*(uint64_t*)key1 < ((SSTableVersion*)key2)->suid) { return -1; @@ -1063,26 +1063,25 @@ int32_t ctgMakeVgArray(SDBVgInfo* dbInfo) { if (NULL == dbInfo) { return TSDB_CODE_SUCCESS; } - + if (dbInfo->vgHash && NULL == dbInfo->vgArray) { dbInfo->vgArray = taosArrayInit(100, sizeof(SVgroupInfo)); if (NULL == dbInfo->vgArray) { CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - - void* pIter = taosHashIterate(dbInfo->vgHash, NULL); + + void* pIter = taosHashIterate(dbInfo->vgHash, NULL); while (pIter) { taosArrayPush(dbInfo->vgArray, pIter); pIter = taosHashIterate(dbInfo->vgHash, pIter); } - + taosArraySort(dbInfo->vgArray, ctgVgInfoComp); } return TSDB_CODE_SUCCESS; } - int32_t ctgCloneVgInfo(SDBVgInfo* src, SDBVgInfo** dst) { CTG_ERR_RET(ctgMakeVgArray(src)); @@ -1326,6 +1325,7 @@ static void* ctgCloneDnodeList(void* pSrc) { return taosArrayDup((const SArray*) static void ctgFreeDnodeList(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); } +#if 0 static int32_t ctgCloneMetaDataArray(SArray* pSrc, __array_item_dup_fn_t copyFunc, SArray** pDst) { if (NULL == pSrc) { return TSDB_CODE_SUCCESS; @@ -1417,21 +1417,22 @@ void catalogFreeMetaData(SMetaData* pData) { taosMemoryFreeClear(pData->pSvrVer); taosMemoryFree(pData); } +#endif void ctgGetClusterCacheStat(SCatalog* pCtg) { for (int32_t i = 0; i < CTG_CI_MAX_VALUE; ++i) { if (0 == (gCtgStatItem[i].flag & CTG_CI_FLAG_LEVEL_DB)) { continue; } - + pCtg->cacheStat.cacheNum[i] = 0; } - - SCtgDBCache *dbCache = NULL; - void *pIter = taosHashIterate(pCtg->dbCache, NULL); + + SCtgDBCache* dbCache = NULL; + void* pIter = taosHashIterate(pCtg->dbCache, NULL); while (pIter) { - dbCache = (SCtgDBCache *)pIter; - + dbCache = (SCtgDBCache*)pIter; + for (int32_t i = 0; i < CTG_CI_MAX_VALUE; ++i) { if (0 == (gCtgStatItem[i].flag & CTG_CI_FLAG_LEVEL_DB)) { continue; @@ -1444,33 +1445,33 @@ void ctgGetClusterCacheStat(SCatalog* pCtg) { } } -void ctgSummaryClusterCacheStat(SCatalog *pCtg) { +void ctgSummaryClusterCacheStat(SCatalog* pCtg) { for (int32_t i = 0; i < CTG_CI_MAX_VALUE; ++i) { if (gCtgStatItem[i].flag & CTG_CI_FLAG_LEVEL_GLOBAL) { continue; } - + gCtgMgmt.statInfo.cache.cacheNum[i] += pCtg->cacheStat.cacheNum[i]; gCtgMgmt.statInfo.cache.cacheHit[i] += pCtg->cacheStat.cacheHit[i]; gCtgMgmt.statInfo.cache.cacheNHit[i] += pCtg->cacheStat.cacheNHit[i]; } } -void ctgGetGlobalCacheStat(SCtgCacheStat *pStat) { +void ctgGetGlobalCacheStat(SCtgCacheStat* pStat) { for (int32_t i = 0; i < CTG_CI_MAX_VALUE; ++i) { if (gCtgStatItem[i].flag & CTG_CI_FLAG_LEVEL_GLOBAL) { continue; } - + gCtgMgmt.statInfo.cache.cacheNum[i] = 0; gCtgMgmt.statInfo.cache.cacheHit[i] = 0; gCtgMgmt.statInfo.cache.cacheNHit[i] = 0; } - - SCatalog *pCtg = NULL; - void *pIter = taosHashIterate(gCtgMgmt.pCluster, NULL); + + SCatalog* pCtg = NULL; + void* pIter = taosHashIterate(gCtgMgmt.pCluster, NULL); while (pIter) { - pCtg = *(SCatalog **)pIter; + pCtg = *(SCatalog**)pIter; if (pCtg) { ctgGetClusterCacheStat(pCtg); @@ -1482,4 +1483,3 @@ void ctgGetGlobalCacheStat(SCtgCacheStat *pStat) { memcpy(pStat, &gCtgMgmt.statInfo.cache, sizeof(gCtgMgmt.statInfo.cache)); } - diff --git a/source/libs/catalog/test/catalogTests.cpp b/source/libs/catalog/test/catalogTests.cpp index 5e543384ac2747005ddb40602ca778253ea1eacd..fd925a8fe549b7b964e57d29ebb76373627b3c04 100644 --- a/source/libs/catalog/test/catalogTests.cpp +++ b/source/libs/catalog/test/catalogTests.cpp @@ -672,12 +672,17 @@ void ctgTestRspUdfInfo(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pR SRetrieveFuncRsp funcRsp = {0}; funcRsp.numOfFuncs = 1; funcRsp.pFuncInfos = taosArrayInit(1, sizeof(SFuncInfo)); + funcRsp.pFuncExtraInfos = taosArrayInit(1, sizeof(SFuncExtraInfo)); SFuncInfo funcInfo = {0}; strcpy(funcInfo.name, "func1"); funcInfo.funcType = ctgTestFuncType; (void)taosArrayPush(funcRsp.pFuncInfos, &funcInfo); - + SFuncExtraInfo extraInfo = {0}; + extraInfo.funcVersion = 0; + extraInfo.funcCreatedTime = taosGetTimestampMs(); + (void)taosArrayPush(funcRsp.pFuncExtraInfos, &extraInfo); + int32_t rspLen = tSerializeSRetrieveFuncRsp(NULL, 0, &funcRsp); void *pReq = rpcMallocCont(rspLen); tSerializeSRetrieveFuncRsp(pReq, rspLen, &funcRsp); diff --git a/source/libs/command/src/command.c b/source/libs/command/src/command.c index c862a75ed3adaaff3ecb759db9c796f51b2473ce..58c43829cfcc8a4978345542d288e96c99793f35 100644 --- a/source/libs/command/src/command.c +++ b/source/libs/command/src/command.c @@ -307,7 +307,7 @@ static void setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName, ch bool existLeaderRole(TAOS_ROW row, TAOS_FIELD* fields, int nFields) { // vgroup_id | db_name | tables | v1_dnode | v1_status | v2_dnode | v2_status | v3_dnode | v3_status | v4_dnode | // v4_status | cacheload | tsma | - if (nFields != 13) { + if (nFields != 14) { return false; } diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index 119ae1eed77d3260d287a771d60386485563b359..de36151af9e3b989c7ae4894587030ff402286c9 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -108,6 +108,7 @@ int32_t tableListGetGroupList(const STableListInfo* pTableList, int32_t uint64_t tableListGetSize(const STableListInfo* pTableList); uint64_t tableListGetSuid(const STableListInfo* pTableList); STableKeyInfo* tableListGetInfo(const STableListInfo* pTableList, int32_t index); +int32_t tableListFind(const STableListInfo* pTableList, uint64_t uid, int32_t startIndex); size_t getResultRowSize(struct SqlFunctionCtx* pCtx, int32_t numOfOutput); void initResultRowInfo(SResultRowInfo* pResultRowInfo); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index cbfd78429ef221d69dba9361a81422f3e674e3ad..38ae0e531c37b14c22832b9d3430b04171b75a28 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -115,6 +115,7 @@ typedef struct STaskIdInfo { uint64_t subplanId; uint64_t templateId; char* str; + int32_t vgId; } STaskIdInfo; enum { @@ -145,6 +146,7 @@ typedef struct { int64_t dataVersion; SStreamState* pState; int64_t checkPointId; + SStreamState* pState; } SStreamTaskInfo; typedef struct { @@ -166,26 +168,25 @@ typedef struct STaskStopInfo { } STaskStopInfo; struct SExecTaskInfo { - STaskIdInfo id; - uint32_t status; - STimeWindow window; - STaskCostInfo cost; - int64_t owner; // if it is in execution - int32_t code; - int32_t qbufQuota; // total available buffer (in KB) during execution query - - int64_t version; // used for stream to record wal version, why not move to sschemainfo + STaskIdInfo id; + uint32_t status; + STimeWindow window; + STaskCostInfo cost; + int64_t owner; // if it is in execution + int32_t code; + int32_t qbufQuota; // total available buffer (in KB) during execution query + int64_t version; // used for stream to record wal version, why not move to sschemainfo SStreamTaskInfo streamInfo; SSchemaInfo schemaInfo; - STableListInfo* pTableInfoList; // this is a table list - const char* sql; // query sql string - jmp_buf env; // jump to this position when error happens. - EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] + const char* sql; // query sql string + jmp_buf env; // jump to this position when error happens. + EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model] SSubplan* pSubplan; struct SOperatorInfo* pRoot; SLocalFetch localFetch; SArray* pResultBlockList; // result block list STaskStopInfo stopInfo; + SRWLatch lock; // secure the access of STableListInfo }; enum { @@ -324,6 +325,8 @@ typedef struct STableScanBase { int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan int32_t dataBlockLoadFlag; SLimitInfo limitInfo; + // there are more than one table list exists in one task, if only one vnode exists. + STableListInfo* pTableListInfo; } STableScanBase; typedef struct STableScanInfo { @@ -337,6 +340,7 @@ typedef struct STableScanInfo { int8_t scanMode; int8_t assignBlockUid; bool hasGroupByTag; + bool countOnly; } STableScanInfo; typedef struct STableMergeScanInfo { @@ -363,11 +367,12 @@ typedef struct STableMergeScanInfo { } STableMergeScanInfo; typedef struct STagScanInfo { - SColumnInfo* pCols; - SSDataBlock* pRes; - SColMatchInfo matchInfo; - int32_t curPos; - SReadHandle readHandle; + SColumnInfo* pCols; + SSDataBlock* pRes; + SColMatchInfo matchInfo; + int32_t curPos; + SReadHandle readHandle; + STableListInfo* pTableListInfo; } STagScanInfo; typedef enum EStreamScanMode { @@ -485,16 +490,11 @@ typedef struct SStreamScanInfo { } SStreamScanInfo; typedef struct { - // int8_t subType; - // bool withMeta; - // int64_t suid; - // int64_t snapVersion; - // void *metaInfo; - // void *dataInfo; - SVnode* vnode; - SSDataBlock pRes; // result SSDataBlock - STsdbReader* dataReader; - SSnapContext* sContext; + SVnode* vnode; + SSDataBlock pRes; // result SSDataBlock + STsdbReader* dataReader; + SSnapContext* sContext; + STableListInfo* pTableListInfo; } SStreamRawScanInfo; typedef struct STableCountScanSupp { @@ -523,6 +523,16 @@ typedef struct SOptrBasicInfo { bool mergeResultBlock; } SOptrBasicInfo; +typedef struct SAggOperatorInfo { + SOptrBasicInfo binfo; + SAggSupporter aggSup; + STableQueryInfo* current; + uint64_t groupId; + SGroupResInfo groupResInfo; + SExprSupp scalarExprSup; + bool groupKeyOptimized; +} SAggOperatorInfo; + typedef struct SIntervalAggOperatorInfo { SOptrBasicInfo binfo; // basic info SAggSupporter aggSup; // aggregate supporter @@ -559,6 +569,7 @@ typedef struct SStreamIntervalOperatorInfo { STimeWindowAggSupp twAggSup; bool invertible; bool ignoreExpiredData; + bool ignoreExpiredDataSaved; SArray* pDelWins; // SWinRes int32_t delIndex; SSDataBlock* pDelRes; @@ -621,6 +632,7 @@ typedef struct SStreamSessionAggOperatorInfo { SPhysiNode* pPhyNode; // create new child bool isFinal; bool ignoreExpiredData; + bool ignoreExpiredDataSaved; SArray* pUpdated; SSHashObj* pStUpdated; int64_t dataVersion; @@ -639,6 +651,7 @@ typedef struct SStreamStateAggOperatorInfo { void* pDelIterator; SArray* pChildren; // cache for children's result; bool ignoreExpiredData; + bool ignoreExpiredDataSaved; SArray* pUpdated; SSHashObj* pSeUpdated; int64_t dataVersion; @@ -693,6 +706,9 @@ typedef struct SStreamFillOperatorInfo { #define OPTR_IS_OPENED(_optr) (((_optr)->status & OP_OPENED) == OP_OPENED) #define OPTR_SET_OPENED(_optr) ((_optr)->status |= OP_OPENED) +SExecTaskInfo* doCreateExecTaskInfo(uint64_t queryId, uint64_t taskId, int32_t vgId, EOPTR_EXEC_MODEL model, + char* dbFName); + SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_reqBuf_fn_t reqBufFn, __optr_explain_fn_t explain); int32_t optrDummyOpenFn(SOperatorInfo* pOperator); @@ -734,8 +750,9 @@ void updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int64_t numOfRows, int3 STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order); -int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scanFlag, bool inheritUsOrder); -int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz); +SOperatorInfo* extractOperatorInTree(SOperatorInfo* pOperator, int32_t type, const char* id); +int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scanFlag, bool inheritUsOrder); +int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz); extern void doDestroyExchangeOperatorInfo(void* param); @@ -751,16 +768,16 @@ void clearResultRowInitFlag(SqlFunctionCtx* pCtx, int32_t numOfOutput); SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, char* pData, int16_t bytes, bool masterscan, uint64_t groupId, SExecTaskInfo* pTaskInfo, - bool isIntervalQuery, SAggSupporter* pSup); + bool isIntervalQuery, SAggSupporter* pSup, bool keepGroup); // operator creater functions // clang-format off SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, STableListInfo* pTableList, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo); SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode* pScanPhyNode, const char* pUser, SExecTaskInfo* pTaskInfo); @@ -776,7 +793,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** dowStreams, size_t numStreams, SMergePhysiNode* pMergePhysiNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pTableScanNode, SReadHandle* readHandle, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pTableScanNode, SReadHandle* readHandle, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo); SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo); @@ -790,9 +807,9 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SSessionW SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode* pAggNode, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDistScanPhysiNode* pBlockScanNode, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDistScanPhysiNode* pBlockScanNode, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SNode* pTagCond, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SNode* pTagCond, STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo); SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, SExecTaskInfo* pTaskInfo); @@ -835,9 +852,14 @@ void setTaskKilled(SExecTaskInfo* pTaskInfo, int32_t rspCode); void doDestroyTask(SExecTaskInfo* pTaskInfo); void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status); -int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, - char* sql, EOPTR_EXEC_MODEL model); -int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle); +char* buildTaskId(uint64_t taskId, uint64_t queryId); + +SArray* getTableListInfo(const SExecTaskInfo* pTaskInfo); + +int32_t createExecTaskInfo(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, + int32_t vgId, char* sql, EOPTR_EXEC_MODEL model); +int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, STableListInfo* pTableListInfo, + SReadHandle* readHandle); int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInfoList); STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval, @@ -851,7 +873,6 @@ bool isInTimeWindow(STimeWindow* pWin, TSKEY ts, int64_t gap); bool functionNeedToExecute(SqlFunctionCtx* pCtx); bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup); bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup); -bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup); bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, SStreamState* pState, STimeWindowAggSupp* pTwSup); void appendOneRowToStreamSpecialBlock(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid, uint64_t* pGp, void* pTbName); diff --git a/source/libs/executor/inc/tfill.h b/source/libs/executor/inc/tfill.h index fad4059515f386ca94ce2c97985184ff4b95f744..5fd75f9b99d004be68b369172668697bfa6fa9a6 100644 --- a/source/libs/executor/inc/tfill.h +++ b/source/libs/executor/inc/tfill.h @@ -30,6 +30,7 @@ extern "C" { struct SSDataBlock; typedef struct SFillColInfo { + int32_t numOfFillExpr; SExprInfo* pExpr; bool notFillCol; // denote if this column needs fill operation SVariant fillVal; @@ -92,8 +93,8 @@ typedef struct SResultRowData { typedef struct SStreamFillLinearInfo { TSKEY nextEnd; - SArray* pDeltaVal; // double. value for Fill(linear). - SArray* pNextDeltaVal; // double. value for Fill(linear). + SArray* pEndPoints; + SArray* pNextEndPoints; int64_t winIndex; bool hasNext; } SStreamFillLinearInfo; diff --git a/source/libs/executor/inc/tsort.h b/source/libs/executor/inc/tsort.h index cff568aebc0c26fb2e9c22c7a027fa9edb4dd81a..d51a24bb43253e09d6ab21e6a1785d6ef6b5e5ff 100644 --- a/source/libs/executor/inc/tsort.h +++ b/source/libs/executor/inc/tsort.h @@ -44,7 +44,8 @@ typedef struct SSortSource { void* param; bool onlyRef; }; - + int64_t fetchUs; + int64_t fetchNum; } SSortSource; typedef struct SMsortComparParam { diff --git a/source/libs/executor/src/aggregateoperator.c b/source/libs/executor/src/aggregateoperator.c new file mode 100644 index 0000000000000000000000000000000000000000..a26e3ace7b5a715cd3bcdda315ae9587c2d033cd --- /dev/null +++ b/source/libs/executor/src/aggregateoperator.c @@ -0,0 +1,563 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "filter.h" +#include "function.h" +#include "functionMgt.h" +#include "os.h" +#include "querynodes.h" +#include "tfill.h" +#include "tname.h" + +#include "tdatablock.h" +#include "tglobal.h" +#include "tmsg.h" +#include "ttime.h" + +#include "executorimpl.h" +#include "index.h" +#include "query.h" +#include "tcompare.h" +#include "thash.h" +#include "ttypes.h" +#include "vnode.h" + +typedef struct { + bool hasAgg; + int32_t numOfRows; + int32_t startOffset; +} SFunctionCtxStatus; + +static void destroyAggOperatorInfo(void* param); +static void setExecutionContext(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId); + +static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBlock** ppBlock); +static void destroyDataBlockForEmptyInput(bool blockAllocated, SSDataBlock** ppBlock); + +static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator); +static int32_t doAggregateImpl(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx); +static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator); + +static int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t keyBufSize, + const char* pKey); + +static int32_t addNewResultRowBuf(SResultRow* pWindowRes, SDiskbasedBuf* pResultBuf, uint32_t size); + +static void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId); + +static void functionCtxSave(SqlFunctionCtx* pCtx, SFunctionCtxStatus* pStatus); +static void functionCtxRestore(SqlFunctionCtx* pCtx, SFunctionCtxStatus* pStatus); + +SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode* pAggNode, + SExecTaskInfo* pTaskInfo) { + SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo)); + SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); + if (pInfo == NULL || pOperator == NULL) { + goto _error; + } + + SSDataBlock* pResBlock = createDataBlockFromDescNode(pAggNode->node.pOutputDataBlockDesc); + initBasicInfo(&pInfo->binfo, pResBlock); + + size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; + initResultSizeInfo(&pOperator->resultInfo, 4096); + + int32_t num = 0; + SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num); + int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str, + pTaskInfo->streamInfo.pState); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + int32_t numOfScalarExpr = 0; + SExprInfo* pScalarExprInfo = NULL; + if (pAggNode->pExprs != NULL) { + pScalarExprInfo = createExprInfo(pAggNode->pExprs, NULL, &numOfScalarExpr); + } + + code = initExprSupp(&pInfo->scalarExprSup, pScalarExprInfo, numOfScalarExpr); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + code = filterInitFromNode((SNode*)pAggNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + pInfo->binfo.mergeResultBlock = pAggNode->mergeDataBlock; + pInfo->groupKeyOptimized = pAggNode->groupKeyOptimized; + pInfo->groupId = UINT64_MAX; + + setOperatorInfo(pOperator, "TableAggregate", QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, true, OP_NOT_OPENED, pInfo, + pTaskInfo); + pOperator->fpSet = createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, destroyAggOperatorInfo, + optrDefaultBufFn, NULL); + + if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) { + STableScanInfo* pTableScanInfo = downstream->info; + pTableScanInfo->base.pdInfo.pExprSup = &pOperator->exprSupp; + pTableScanInfo->base.pdInfo.pAggSup = &pInfo->aggSup; + } + + code = appendDownstream(pOperator, &downstream, 1); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + + return pOperator; + + _error: + if (pInfo != NULL) { + destroyAggOperatorInfo(pInfo); + } + + if (pOperator != NULL) { + cleanupExprSupp(&pOperator->exprSupp); + } + + taosMemoryFreeClear(pOperator); + pTaskInfo->code = code; + return NULL; +} + +void destroyAggOperatorInfo(void* param) { + SAggOperatorInfo* pInfo = (SAggOperatorInfo*)param; + cleanupBasicInfo(&pInfo->binfo); + + cleanupAggSup(&pInfo->aggSup); + cleanupExprSupp(&pInfo->scalarExprSup); + cleanupGroupResInfo(&pInfo->groupResInfo); + taosMemoryFreeClear(param); +} + +// this is a blocking operator +int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { + if (OPTR_IS_OPENED(pOperator)) { + return TSDB_CODE_SUCCESS; + } + + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SAggOperatorInfo* pAggInfo = pOperator->info; + + SExprSupp* pSup = &pOperator->exprSupp; + SOperatorInfo* downstream = pOperator->pDownstream[0]; + + int64_t st = taosGetTimestampUs(); + + int32_t order = TSDB_ORDER_ASC; + int32_t scanFlag = MAIN_SCAN; + + bool hasValidBlock = false; + bool blockAllocated = false; + + while (1) { + SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); + if (pBlock == NULL) { + if (!hasValidBlock) { + createDataBlockForEmptyInput(pOperator, &pBlock); + if (pBlock == NULL) { + break; + } + blockAllocated = true; + } else { + break; + } + } + hasValidBlock = true; + + int32_t code = getTableScanInfo(pOperator, &order, &scanFlag, false); + if (code != TSDB_CODE_SUCCESS) { + destroyDataBlockForEmptyInput(blockAllocated, &pBlock); + T_LONG_JMP(pTaskInfo->env, code); + } + + // there is an scalar expression that needs to be calculated before apply the group aggregation. + if (pAggInfo->scalarExprSup.pExprInfo != NULL && !blockAllocated) { + SExprSupp* pSup1 = &pAggInfo->scalarExprSup; + code = projectApplyFunctions(pSup1->pExprInfo, pBlock, pBlock, pSup1->pCtx, pSup1->numOfExprs, NULL); + if (code != TSDB_CODE_SUCCESS) { + destroyDataBlockForEmptyInput(blockAllocated, &pBlock); + T_LONG_JMP(pTaskInfo->env, code); + } + } + + // the pDataBlock are always the same one, no need to call this again + setExecutionContext(pOperator, pOperator->exprSupp.numOfExprs, pBlock->info.id.groupId); + setInputDataBlock(pSup, pBlock, order, scanFlag, true); + code = doAggregateImpl(pOperator, pSup->pCtx); + if (code != 0) { + destroyDataBlockForEmptyInput(blockAllocated, &pBlock); + T_LONG_JMP(pTaskInfo->env, code); + } + + destroyDataBlockForEmptyInput(blockAllocated, &pBlock); + } + + // the downstream operator may return with error code, so let's check the code before generating results. + if (pTaskInfo->code != TSDB_CODE_SUCCESS) { + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); + } + + initGroupedResultInfo(&pAggInfo->groupResInfo, pAggInfo->aggSup.pResultRowHashTable, 0); + OPTR_SET_OPENED(pOperator); + + pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0; + return pTaskInfo->code; +} + +SSDataBlock* getAggregateResult(SOperatorInfo* pOperator) { + SAggOperatorInfo* pAggInfo = pOperator->info; + SOptrBasicInfo* pInfo = &pAggInfo->binfo; + + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } + + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + pTaskInfo->code = pOperator->fpSet._openFn(pOperator); + if (pTaskInfo->code != TSDB_CODE_SUCCESS) { + setOperatorCompleted(pOperator); + return NULL; + } + + blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity); + while (1) { + doBuildResultDatablock(pOperator, pInfo, &pAggInfo->groupResInfo, pAggInfo->aggSup.pResultBuf); + doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL); + + if (!hasRemainResults(&pAggInfo->groupResInfo)) { + setOperatorCompleted(pOperator); + break; + } + + if (pInfo->pRes->info.rows > 0) { + break; + } + } + + size_t rows = blockDataGetNumOfRows(pInfo->pRes); + pOperator->resultInfo.totalRows += rows; + + return (rows == 0) ? NULL : pInfo->pRes; +} + +int32_t doAggregateImpl(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx) { + for (int32_t k = 0; k < pOperator->exprSupp.numOfExprs; ++k) { + if (functionNeedToExecute(&pCtx[k])) { + // todo add a dummy funtion to avoid process check + if (pCtx[k].fpSet.process == NULL) { + continue; + } + + int32_t code = pCtx[k].fpSet.process(&pCtx[k]); + if (code != TSDB_CODE_SUCCESS) { + qError("%s aggregate function error happens, code: %s", GET_TASKID(pOperator->pTaskInfo), tstrerror(code)); + return code; + } + } + } + + return TSDB_CODE_SUCCESS; +} + +static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBlock** ppBlock) { + if (!tsCountAlwaysReturnValue) { + return TSDB_CODE_SUCCESS; + } + + SAggOperatorInfo* pAggInfo = pOperator->info; + if (pAggInfo->groupKeyOptimized) { + return TSDB_CODE_SUCCESS; + } + + SOperatorInfo* downstream = pOperator->pDownstream[0]; + if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_PARTITION || + (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN && + ((STableScanInfo*)downstream->info)->hasGroupByTag == true)) { + return TSDB_CODE_SUCCESS; + } + + SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx; + bool hasCountFunc = false; + + for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) { + const char* pName = pCtx[i].pExpr->pExpr->_function.functionName; + if ((strcmp(pName, "count") == 0) || (strcmp(pName, "hyperloglog") == 0) || + (strcmp(pName, "_hyperloglog_partial") == 0) || (strcmp(pName, "_hyperloglog_merge") == 0)) { + hasCountFunc = true; + break; + } + } + + if (!hasCountFunc) { + return TSDB_CODE_SUCCESS; + } + + SSDataBlock* pBlock = createDataBlock(); + pBlock->info.rows = 1; + pBlock->info.capacity = 0; + + for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) { + SColumnInfoData colInfo = {0}; + colInfo.hasNull = true; + colInfo.info.type = TSDB_DATA_TYPE_NULL; + colInfo.info.bytes = 1; + + SExprInfo* pOneExpr = &pOperator->exprSupp.pExprInfo[i]; + for (int32_t j = 0; j < pOneExpr->base.numOfParams; ++j) { + SFunctParam* pFuncParam = &pOneExpr->base.pParam[j]; + if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) { + int32_t slotId = pFuncParam->pCol->slotId; + int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); + if (slotId >= numOfCols) { + taosArrayEnsureCap(pBlock->pDataBlock, slotId + 1); + for (int32_t k = numOfCols; k < slotId + 1; ++k) { + taosArrayPush(pBlock->pDataBlock, &colInfo); + } + } + } else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) { + // do nothing + } + } + } + + blockDataEnsureCapacity(pBlock, pBlock->info.rows); + *ppBlock = pBlock; + + return TSDB_CODE_SUCCESS; +} + +void destroyDataBlockForEmptyInput(bool blockAllocated, SSDataBlock** ppBlock) { + if (!blockAllocated) { + return; + } + + blockDataDestroy(*ppBlock); + *ppBlock = NULL; +} + +void setExecutionContext(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId) { + SAggOperatorInfo* pAggInfo = pOperator->info; + if (pAggInfo->groupId != UINT64_MAX && pAggInfo->groupId == groupId) { + return; + } + + doSetTableGroupOutputBuf(pOperator, numOfOutput, groupId); + + // record the current active group id + pAggInfo->groupId = groupId; +} + +void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId) { + // for simple group by query without interval, all the tables belong to one group result. + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SAggOperatorInfo* pAggInfo = pOperator->info; + + SResultRowInfo* pResultRowInfo = &pAggInfo->binfo.resultRowInfo; + SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx; + int32_t* rowEntryInfoOffset = pOperator->exprSupp.rowEntryInfoOffset; + + SResultRow* pResultRow = doSetResultOutBufByKey(pAggInfo->aggSup.pResultBuf, pResultRowInfo, (char*)&groupId, + sizeof(groupId), true, groupId, pTaskInfo, false, &pAggInfo->aggSup, true); + /* + * not assign result buffer yet, add new result buffer + * all group belong to one result set, and each group result has different group id so set the id to be one + */ + if (pResultRow->pageId == -1) { + int32_t ret = addNewResultRowBuf(pResultRow, pAggInfo->aggSup.pResultBuf, pAggInfo->binfo.pRes->info.rowSize); + if (ret != TSDB_CODE_SUCCESS) { + T_LONG_JMP(pTaskInfo->env, terrno); + } + } + + setResultRowInitCtx(pResultRow, pCtx, numOfOutput, rowEntryInfoOffset); +} + +// a new buffer page for each table. Needs to opt this design +int32_t addNewResultRowBuf(SResultRow* pWindowRes, SDiskbasedBuf* pResultBuf, uint32_t size) { + if (pWindowRes->pageId != -1) { + return 0; + } + + SFilePage* pData = NULL; + + // in the first scan, new space needed for results + int32_t pageId = -1; + SArray* list = getDataBufPagesIdList(pResultBuf); + + if (taosArrayGetSize(list) == 0) { + pData = getNewBufPage(pResultBuf, &pageId); + pData->num = sizeof(SFilePage); + } else { + SPageInfo* pi = getLastPageInfo(list); + pData = getBufPage(pResultBuf, getPageId(pi)); + if (pData == NULL) { + qError("failed to get buffer, code:%s", tstrerror(terrno)); + return terrno; + } + + pageId = getPageId(pi); + + if (pData->num + size > getBufPageSize(pResultBuf)) { + // release current page first, and prepare the next one + releaseBufPageInfo(pResultBuf, pi); + + pData = getNewBufPage(pResultBuf, &pageId); + if (pData != NULL) { + pData->num = sizeof(SFilePage); + } + } + } + + if (pData == NULL) { + return -1; + } + + // set the number of rows in current disk page + if (pWindowRes->pageId == -1) { // not allocated yet, allocate new buffer + pWindowRes->pageId = pageId; + pWindowRes->offset = (int32_t)pData->num; + + pData->num += size; + } + + return 0; +} + +int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t keyBufSize, + const char* pKey) { + int32_t code = 0; + // _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); + + pAggSup->currentPageId = -1; + pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput); + pAggSup->keyBuf = taosMemoryCalloc(1, keyBufSize + POINTER_BYTES + sizeof(int64_t)); + pAggSup->pResultRowHashTable = tSimpleHashInit(100, taosFastHash); + + if (pAggSup->keyBuf == NULL || pAggSup->pResultRowHashTable == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + uint32_t defaultPgsz = 0; + uint32_t defaultBufsz = 0; + getBufferPgSize(pAggSup->resultRowSize, &defaultPgsz, &defaultBufsz); + + if (!osTempSpaceAvailable()) { + code = TSDB_CODE_NO_AVAIL_DISK; + qError("Init stream agg supporter failed since %s, %s", terrstr(code), pKey); + return code; + } + + code = createDiskbasedBuf(&pAggSup->pResultBuf, defaultPgsz, defaultBufsz, pKey, tsTempDir); + if (code != TSDB_CODE_SUCCESS) { + qError("Create agg result buf failed since %s, %s", tstrerror(code), pKey); + return code; + } + + return code; +} + +void cleanupAggSup(SAggSupporter* pAggSup) { + taosMemoryFreeClear(pAggSup->keyBuf); + tSimpleHashCleanup(pAggSup->pResultRowHashTable); + destroyDiskbasedBuf(pAggSup->pResultBuf); +} + +int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize, + const char* pkey, void* pState) { + int32_t code = initExprSupp(pSup, pExprInfo, numOfCols); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + code = doInitAggInfoSup(pAggSup, pSup->pCtx, numOfCols, keyBufSize, pkey); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + + for (int32_t i = 0; i < numOfCols; ++i) { + if (pState) { + pSup->pCtx[i].saveHandle.pBuf = NULL; + pSup->pCtx[i].saveHandle.pState = pState; + pSup->pCtx[i].exprIdx = i; + } else { + pSup->pCtx[i].saveHandle.pBuf = pAggSup->pResultBuf; + } + } + + return TSDB_CODE_SUCCESS; +} + +void applyAggFunctionOnPartialTuples(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, SColumnInfoData* pTimeWindowData, + int32_t offset, int32_t forwardStep, int32_t numOfTotal, int32_t numOfOutput) { + for (int32_t k = 0; k < numOfOutput; ++k) { + // keep it temporarily + SFunctionCtxStatus status = {0}; + functionCtxSave(&pCtx[k], &status); + + pCtx[k].input.startRowIndex = offset; + pCtx[k].input.numOfRows = forwardStep; + + // not a whole block involved in query processing, statistics data can not be used + // NOTE: the original value of isSet have been changed here + if (pCtx[k].input.colDataSMAIsSet && forwardStep < numOfTotal) { + pCtx[k].input.colDataSMAIsSet = false; + } + + if (pCtx[k].isPseudoFunc) { + SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(&pCtx[k]); + + char* p = GET_ROWCELL_INTERBUF(pEntryInfo); + + SColumnInfoData idata = {0}; + idata.info.type = TSDB_DATA_TYPE_BIGINT; + idata.info.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; + idata.pData = p; + + SScalarParam out = {.columnData = &idata}; + SScalarParam tw = {.numOfRows = 5, .columnData = pTimeWindowData}; + pCtx[k].sfp.process(&tw, 1, &out); + pEntryInfo->numOfRes = 1; + } else { + int32_t code = TSDB_CODE_SUCCESS; + if (functionNeedToExecute(&pCtx[k]) && pCtx[k].fpSet.process != NULL) { + code = pCtx[k].fpSet.process(&pCtx[k]); + + if (code != TSDB_CODE_SUCCESS) { + qError("%s apply functions error, code: %s", GET_TASKID(taskInfo), tstrerror(code)); + taskInfo->code = code; + T_LONG_JMP(taskInfo->env, code); + } + } + + // restore it + functionCtxRestore(&pCtx[k], &status); + } + } +} + +void functionCtxSave(SqlFunctionCtx* pCtx, SFunctionCtxStatus* pStatus) { + pStatus->hasAgg = pCtx->input.colDataSMAIsSet; + pStatus->numOfRows = pCtx->input.numOfRows; + pStatus->startOffset = pCtx->input.startRowIndex; +} + +void functionCtxRestore(SqlFunctionCtx* pCtx, SFunctionCtxStatus* pStatus) { + pCtx->input.colDataSMAIsSet = pStatus->hasAgg; + pCtx->input.numOfRows = pStatus->numOfRows; + pCtx->input.startRowIndex = pStatus->startOffset; +} \ No newline at end of file diff --git a/source/libs/executor/src/cachescanoperator.c b/source/libs/executor/src/cachescanoperator.c index d42b348fd8c911b3915ad381f1270a290796f5aa..f6fc332b3793ee25830cacf585c4d7d6b698f959 100644 --- a/source/libs/executor/src/cachescanoperator.c +++ b/source/libs/executor/src/cachescanoperator.c @@ -37,6 +37,7 @@ typedef struct SCacheRowsScanInfo { SSDataBlock* pBufferredRes; SArray* pUidList; int32_t indexOfBufferedRes; + STableListInfo* pTableList; } SCacheRowsScanInfo; static SSDataBlock* doScanCache(SOperatorInfo* pOperator); @@ -47,15 +48,17 @@ static int32_t removeRedundantTsCol(SLastRowScanPhysiNode* pScanNode, SColM #define SCAN_ROW_TYPE(_t) ((_t)? CACHESCAN_RETRIEVE_LAST : CACHESCAN_RETRIEVE_LAST_ROW) SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SReadHandle* readHandle, - SExecTaskInfo* pTaskInfo) { + STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) { int32_t code = TSDB_CODE_SUCCESS; SCacheRowsScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SCacheRowsScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; + tableListDestroy(pTableListInfo); goto _error; } + pInfo->pTableList = pTableListInfo; pInfo->readHandle = *readHandle; SDataBlockDescNode* pDescNode = pScanNode->scan.node.pOutputDataBlockDesc; @@ -75,20 +78,18 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe goto _error; } - STableListInfo* pTableList = pTaskInfo->pTableInfoList; - - int32_t totalTables = tableListGetSize(pTableList); + int32_t totalTables = tableListGetSize(pTableListInfo); int32_t capacity = 0; pInfo->pUidList = taosArrayInit(4, sizeof(int64_t)); // partition by tbname - if (oneTableForEachGroup(pTableList) || (totalTables == 1)) { + if (oneTableForEachGroup(pTableListInfo) || (totalTables == 1)) { pInfo->retrieveType = CACHESCAN_RETRIEVE_TYPE_ALL | SCAN_ROW_TYPE(pScanNode->ignoreNull); - STableKeyInfo* pList = tableListGetInfo(pTableList, 0); + STableKeyInfo* pList = tableListGetInfo(pTableListInfo, 0); - uint64_t suid = tableListGetSuid(pTableList); + uint64_t suid = tableListGetSuid(pTableListInfo); code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, totalTables, taosArrayGetSize(pInfo->matchInfo.pList), suid, &pInfo->pLastrowReader, pTaskInfo->id.str); if (code != TSDB_CODE_SUCCESS) { @@ -136,7 +137,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { SCacheRowsScanInfo* pInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - STableListInfo* pTableList = pTaskInfo->pTableInfoList; + STableListInfo* pTableList = pInfo->pTableList; uint64_t suid = tableListGetSuid(pTableList); int32_t size = tableListGetSize(pTableList); @@ -281,6 +282,7 @@ void destroyCacheScanOperator(void* param) { taosMemoryFree(pInfo->pSlotIds); taosArrayDestroy(pInfo->pUidList); taosArrayDestroy(pInfo->matchInfo.pList); + tableListDestroy(pInfo->pTableList); if (pInfo->pLastrowReader != NULL) { pInfo->pLastrowReader = tsdbCacherowsReaderClose(pInfo->pLastrowReader); diff --git a/source/libs/executor/src/exchangeoperator.c b/source/libs/executor/src/exchangeoperator.c index e5089ab4a9b6a6486d86bebbf82bf54c4abd543e..c855a104b2cccdb7ed28fe36e5e9c740ec6f5bd9 100644 --- a/source/libs/executor/src/exchangeoperator.c +++ b/source/libs/executor/src/exchangeoperator.c @@ -70,7 +70,7 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn tsem_wait(&pExchangeInfo->ready); if (isTaskKilled(pTaskInfo)) { - longjmp(pTaskInfo->env, pTaskInfo->code); + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); } for (int32_t i = 0; i < totalSources; ++i) { @@ -212,6 +212,11 @@ static SSDataBlock* loadRemoteData(SOperatorInfo* pOperator) { return NULL; } + doFilter(pBlock, pOperator->exprSupp.pFilterInfo, NULL); + if (blockDataGetNumOfRows(pBlock) == 0) { + continue; + } + SLimitInfo* pLimitInfo = &pExchangeInfo->limitInfo; if (hasLimitOffsetInfo(pLimitInfo)) { int32_t status = handleLimitOffset(pOperator, pLimitInfo, pBlock, false); @@ -303,6 +308,11 @@ SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode pTaskInfo); pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pDummyBlock->pDataBlock); + code = filterInitFromNode((SNode*)pExNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + pOperator->fpSet = createOperatorFpSet(prepareLoadRemoteData, loadRemoteData, NULL, destroyExchangeOperatorInfo, optrDefaultBufFn, NULL); return pOperator; @@ -512,8 +522,6 @@ int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, char* pData, SArray* pCo blockDataDestroy(pBlock); } - // todo move this to time window aggregator, since the primary timestamp may not be known by exchange operator. - blockDataUpdateTsWindow(pRes, 0); return TSDB_CODE_SUCCESS; } @@ -568,7 +576,7 @@ int32_t prepareConcurrentlyLoad(SOperatorInfo* pOperator) { pOperator->status = OP_RES_TO_RETURN; pOperator->cost.openCost = taosGetTimestampUs() - startTs; if (isTaskKilled(pTaskInfo)) { - longjmp(pTaskInfo->env, pTaskInfo->code); + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); } return TSDB_CODE_SUCCESS; @@ -621,7 +629,7 @@ int32_t seqLoadRemoteData(SOperatorInfo* pOperator) { doSendFetchDataRequest(pExchangeInfo, pTaskInfo, pExchangeInfo->current); tsem_wait(&pExchangeInfo->ready); if (isTaskKilled(pTaskInfo)) { - longjmp(pTaskInfo->env, pTaskInfo->code); + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); } SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, pExchangeInfo->current); diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 0ac458af495c8f4c3a3f4fd1ce7d982e5459aaf4..7d318786ba109927035c3b212aafbb85270d14bd 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -17,6 +17,7 @@ #include "functionMgt.h" #include "index.h" #include "os.h" +#include "query.h" #include "tdatablock.h" #include "thash.h" #include "tmsg.h" @@ -33,7 +34,7 @@ struct STableListInfo { int32_t numOfOuputGroups; // the data block will be generated one by one int32_t* groupOffset; // keep the offset value for each group in the tableList SArray* pTableList; - SHashObj* map; // speedup acquire the tableQueryInfo by table uid + SHashObj* map; // speedup acquire the tableQueryInfo by table uid uint64_t suid; }; @@ -570,6 +571,10 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis memcpy(pStart, data, len); pStart += len; } else if (IS_VAR_DATA_TYPE(pValue->info.type)) { + if (varDataTLen(data) > pValue->info.bytes) { + code = TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER; + goto end; + } memcpy(pStart, data, varDataTLen(data)); pStart += varDataTLen(data); } else { @@ -820,6 +825,7 @@ static SSDataBlock* createTagValBlockForFilter(SArray* pColList, int32_t numOfTa int32_t code = blockDataEnsureCapacity(pResBlock, numOfTables); if (code != TSDB_CODE_SUCCESS) { terrno = code; + taosMemoryFree(pResBlock); return NULL; } @@ -1057,10 +1063,10 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, SIndexMetaArg metaArg = { .metaEx = metaHandle, .idx = tsdbGetIdx(metaHandle), .ivtIdx = pIndex, .suid = pScanNode->uid}; - SIdxFltStatus status = SFLT_NOT_INDEX; + status = SFLT_NOT_INDEX; code = doFilterTag(pTagIndexCond, &metaArg, pUidList, &status); if (code != 0 || status == SFLT_NOT_INDEX) { // temporarily disable it for performance sake - // qError("failed to get tableIds from index, reason:%s, suid:%" PRIu64, tstrerror(code), tableUid); + qWarn("failed to get tableIds from index, suid:%" PRIu64, pScanNode->uid); code = TDB_CODE_SUCCESS; } else { qInfo("succ to get filter result, table num: %d", (int)taosArrayGetSize(pUidList)); @@ -1798,6 +1804,21 @@ STableKeyInfo* tableListGetInfo(const STableListInfo* pTableList, int32_t index) return taosArrayGet(pTableList->pTableList, index); } +int32_t tableListFind(const STableListInfo* pTableList, uint64_t uid, int32_t startIndex) { + int32_t numOfTables = taosArrayGetSize(pTableList->pTableList); + if (startIndex >= numOfTables) { + return -1; + } + + for (int32_t i = startIndex; i < numOfTables; ++i) { + STableKeyInfo* p = taosArrayGet(pTableList->pTableList, i); + if (p->uid == uid) { + return i; + } + } + return -1; +} + uint64_t getTableGroupId(const STableListInfo* pTableList, uint64_t tableUid) { int32_t* slot = taosHashGet(pTableList->map, &tableUid, sizeof(tableUid)); ASSERT(pTableList->map != NULL && slot != NULL); @@ -2040,7 +2061,7 @@ int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags void printDataBlock(SSDataBlock* pBlock, const char* flag) { if (!pBlock || pBlock->info.rows == 0) { - qDebug("===stream===printDataBlock: Block is Null or Empty"); + qDebug("===stream===%s: Block is Null or Empty", flag); return; } char* pBuf = NULL; diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c index 55f87162e64a7f1bf9f8f08428e7f6439eacb8f0..feff35e67f94fae25165a56ed715675c1ba9b6b7 100644 --- a/source/libs/executor/src/executor.c +++ b/source/libs/executor/src/executor.c @@ -29,8 +29,8 @@ static void cleanupRefPool() { taosCloseRef(ref); } -static void initRefPool() { - exchangeObjRefPool = taosOpenRef(1024, doDestroyExchangeOperatorInfo); +static void initRefPool() { + exchangeObjRefPool = taosOpenRef(1024, doDestroyExchangeOperatorInfo); atexit(cleanupRefPool); } @@ -159,6 +159,30 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu } } +void doSetTaskId(SOperatorInfo* pOperator) { + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + if (pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { + SStreamScanInfo* pStreamScanInfo = pOperator->info; + STableScanInfo* pScanInfo = pStreamScanInfo->pTableScanOp->info; + if (pScanInfo->base.dataReader != NULL) { + tsdbReaderSetId(pScanInfo->base.dataReader, pTaskInfo->id.str); + } + } else { + doSetTaskId(pOperator->pDownstream[0]); + } +} + +void qSetTaskId(qTaskInfo_t tinfo, uint64_t taskId, uint64_t queryId) { + SExecTaskInfo* pTaskInfo = tinfo; + pTaskInfo->id.queryId = queryId; + + taosMemoryFreeClear(pTaskInfo->id.str); + pTaskInfo->id.str = buildTaskId(taskId, queryId); + + // set the idstr for tsdbReader + doSetTaskId(pTaskInfo->pRoot); +} + int32_t qSetStreamOpOpen(qTaskInfo_t tinfo) { if (tinfo == NULL) { return TSDB_CODE_APP_ERROR; @@ -224,37 +248,35 @@ int32_t qSetSMAInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numOfBlocks, return code; } -qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* numOfCols, SSchemaWrapper** pSchema) { - if (msg == NULL) { - // create raw scan - - SExecTaskInfo* pTaskInfo = taosMemoryCalloc(1, sizeof(SExecTaskInfo)); +qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* pReaderHandle, int32_t vgId, int32_t* numOfCols, + uint64_t id) { + if (msg == NULL) { // create raw scan + SExecTaskInfo* pTaskInfo = doCreateExecTaskInfo(0, id, vgId, OPTR_EXEC_MODEL_QUEUE, ""); if (NULL == pTaskInfo) { terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } - setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED); - - pTaskInfo->cost.created = taosGetTimestampUs(); - pTaskInfo->execModel = OPTR_EXEC_MODEL_QUEUE; - pTaskInfo->pRoot = createRawScanOperatorInfo(readers, pTaskInfo); + pTaskInfo->pRoot = createRawScanOperatorInfo(pReaderHandle, pTaskInfo); if (NULL == pTaskInfo->pRoot) { terrno = TSDB_CODE_OUT_OF_MEMORY; taosMemoryFree(pTaskInfo); return NULL; } + + qDebug("create raw scan task info completed, vgId:%d, %s", vgId, GET_TASKID(pTaskInfo)); return pTaskInfo; } struct SSubplan* pPlan = NULL; - int32_t code = qStringToSubplan(msg, &pPlan); + + int32_t code = qStringToSubplan(msg, &pPlan); if (code != TSDB_CODE_SUCCESS) { terrno = code; return NULL; } qTaskInfo_t pTaskInfo = NULL; - code = qCreateExecTask(readers, 0, 0, pPlan, &pTaskInfo, NULL, NULL, OPTR_EXEC_MODEL_QUEUE); + code = qCreateExecTask(pReaderHandle, vgId, 0, pPlan, &pTaskInfo, NULL, NULL, OPTR_EXEC_MODEL_QUEUE); if (code != TSDB_CODE_SUCCESS) { nodesDestroyNode((SNode*)pPlan); qDestroyTask(pTaskInfo); @@ -274,19 +296,14 @@ qTaskInfo_t qCreateQueueExecTaskInfo(void* msg, SReadHandle* readers, int32_t* n } } - if (pSchema) { - *pSchema = tCloneSSchemaWrapper(((SExecTaskInfo*)pTaskInfo)->schemaInfo.qsw); - } return pTaskInfo; } -qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers) { +qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers, int32_t vgId) { if (msg == NULL) { return NULL; } - /*qDebugL("stream task string %s", (const char*)msg);*/ - struct SSubplan* pPlan = NULL; int32_t code = qStringToSubplan(msg, &pPlan); if (code != TSDB_CODE_SUCCESS) { @@ -295,7 +312,7 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, SReadHandle* readers) { } qTaskInfo_t pTaskInfo = NULL; - code = qCreateExecTask(readers, 0, 0, pPlan, &pTaskInfo, NULL, NULL, OPTR_EXEC_MODEL_STREAM); + code = qCreateExecTask(readers, vgId, 0, pPlan, &pTaskInfo, NULL, NULL, OPTR_EXEC_MODEL_STREAM); if (code != TSDB_CODE_SUCCESS) { nodesDestroyNode((SNode*)pPlan); qDestroyTask(pTaskInfo); @@ -393,7 +410,8 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo } } - STableListInfo* pTableListInfo = pTaskInfo->pTableInfoList; + STableListInfo* pTableListInfo = ((STableScanInfo*)pScanInfo->pTableScanOp->info)->base.pTableListInfo; + taosWLockLatch(&pTaskInfo->lock); for (int32_t i = 0; i < numOfQualifiedTables; ++i) { uint64_t* uid = taosArrayGet(qa, i); @@ -408,6 +426,7 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo if (code != TSDB_CODE_SUCCESS) { taosMemoryFree(keyBuf); taosArrayDestroy(qa); + taosWUnLockLatch(&pTaskInfo->lock); return code; } } @@ -429,6 +448,7 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo tableListAddTableInfo(pTableListInfo, keyInfo.uid, keyInfo.groupId); } + taosWUnLockLatch(&pTaskInfo->lock); if (keyBuf != NULL) { taosMemoryFree(keyBuf); } @@ -436,7 +456,9 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo taosArrayDestroy(qa); } else { // remove the table id in current list qDebug(" %d remove child tables from the stream scanner", (int32_t)taosArrayGetSize(tableIdList)); + taosWLockLatch(&pTaskInfo->lock); code = tqReaderRemoveTbUidList(pScanInfo->tqReader, tableIdList); + taosWUnLockLatch(&pTaskInfo->lock); } return code; @@ -469,16 +491,14 @@ int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* table int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, SSubplan* pSubplan, qTaskInfo_t* pTaskInfo, DataSinkHandle* handle, char* sql, EOPTR_EXEC_MODEL model) { - assert(pSubplan != NULL); SExecTaskInfo** pTask = (SExecTaskInfo**)pTaskInfo; - taosThreadOnce(&initPoolOnce, initRefPool); - qDebug("start to create subplan task, TID:0x%" PRIx64 " QID:0x%" PRIx64, taskId, pSubplan->id.queryId); + qDebug("start to create task, TID:0x%" PRIx64 " QID:0x%" PRIx64 ", vgId:%d", taskId, pSubplan->id.queryId, vgId); - int32_t code = createExecTaskInfoImpl(pSubplan, pTask, readHandle, taskId, sql, model); + int32_t code = createExecTaskInfo(pSubplan, pTask, readHandle, taskId, vgId, sql, model); if (code != TSDB_CODE_SUCCESS) { - qError("failed to createExecTaskInfoImpl, code: %s", tstrerror(code)); + qError("failed to createExecTaskInfo, code: %s", tstrerror(code)); goto _error; } @@ -491,7 +511,12 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId, if (handle) { void* pSinkParam = NULL; - code = createDataSinkParam(pSubplan->pDataSink, &pSinkParam, pTaskInfo, readHandle); + + SArray* pInfoList = getTableListInfo(*pTask); + STableListInfo* pTableListInfo = taosArrayGetP(pInfoList, 0); + taosArrayDestroy(pInfoList); + + code = createDataSinkParam(pSubplan->pDataSink, &pSinkParam, pTableListInfo, readHandle); if (code != TSDB_CODE_SUCCESS) { qError("failed to createDataSinkParam, vgId:%d, code:%s, %s", vgId, tstrerror(code), (*pTask)->id.str); goto _error; @@ -721,7 +746,6 @@ void qStopTaskOperators(SExecTaskInfo* pTaskInfo) { int32_t qAsyncKillTask(qTaskInfo_t qinfo, int32_t rspCode) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)qinfo; - if (pTaskInfo == NULL) { return TSDB_CODE_QRY_INVALID_QHANDLE; } @@ -729,12 +753,28 @@ int32_t qAsyncKillTask(qTaskInfo_t qinfo, int32_t rspCode) { qDebug("%s execTask async killed", GET_TASKID(pTaskInfo)); setTaskKilled(pTaskInfo, rspCode); - qStopTaskOperators(pTaskInfo); return TSDB_CODE_SUCCESS; } +int32_t qKillTask(qTaskInfo_t tinfo, int32_t rspCode) { + SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; + if (pTaskInfo == NULL) { + return TSDB_CODE_QRY_INVALID_QHANDLE; + } + + qDebug("%s sync killed execTask", GET_TASKID(pTaskInfo)); + setTaskKilled(pTaskInfo, TSDB_CODE_TSC_QUERY_KILLED); + + while (qTaskIsExecuting(pTaskInfo)) { + taosMsleep(10); + } + + pTaskInfo->code = rspCode; + return TSDB_CODE_SUCCESS; +} + bool qTaskIsExecuting(qTaskInfo_t qinfo) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)qinfo; if (NULL == pTaskInfo) { @@ -874,7 +914,8 @@ int32_t qStreamSetParamForRecover(qTaskInfo_t tinfo) { pInfo->twAggSup.deleteMarkSaved = pInfo->twAggSup.deleteMark; pInfo->twAggSup.calTrigger = STREAM_TRIGGER_AT_ONCE; pInfo->twAggSup.deleteMark = INT64_MAX; - + pInfo->ignoreExpiredDataSaved = pInfo->ignoreExpiredData; + pInfo->ignoreExpiredData = false; } else if (pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION || pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION || pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION) { @@ -890,6 +931,8 @@ int32_t qStreamSetParamForRecover(qTaskInfo_t tinfo) { pInfo->twAggSup.deleteMarkSaved = pInfo->twAggSup.deleteMark; pInfo->twAggSup.calTrigger = STREAM_TRIGGER_AT_ONCE; pInfo->twAggSup.deleteMark = INT64_MAX; + pInfo->ignoreExpiredDataSaved = pInfo->ignoreExpiredData; + pInfo->ignoreExpiredData = false; } else if (pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE) { SStreamStateAggOperatorInfo* pInfo = pOperator->info; ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE || @@ -903,6 +946,8 @@ int32_t qStreamSetParamForRecover(qTaskInfo_t tinfo) { pInfo->twAggSup.deleteMarkSaved = pInfo->twAggSup.deleteMark; pInfo->twAggSup.calTrigger = STREAM_TRIGGER_AT_ONCE; pInfo->twAggSup.deleteMark = INT64_MAX; + pInfo->ignoreExpiredDataSaved = pInfo->ignoreExpiredData; + pInfo->ignoreExpiredData = false; } // iterate operator tree @@ -930,35 +975,23 @@ int32_t qStreamRestoreParam(qTaskInfo_t tinfo) { pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL || pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL) { SStreamIntervalOperatorInfo* pInfo = pOperator->info; - /*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);*/ - /*ASSERT(pInfo->twAggSup.deleteMark == INT64_MAX);*/ - pInfo->twAggSup.calTrigger = pInfo->twAggSup.calTriggerSaved; pInfo->twAggSup.deleteMark = pInfo->twAggSup.deleteMarkSaved; - /*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE ||*/ - /*pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);*/ + pInfo->ignoreExpiredData = pInfo->ignoreExpiredDataSaved; qInfo("restore stream param for interval: %d, %" PRId64, pInfo->twAggSup.calTrigger, pInfo->twAggSup.deleteMark); } else if (pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION || pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION || pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION) { SStreamSessionAggOperatorInfo* pInfo = pOperator->info; - /*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);*/ - /*ASSERT(pInfo->twAggSup.deleteMark == INT64_MAX);*/ - pInfo->twAggSup.calTrigger = pInfo->twAggSup.calTriggerSaved; pInfo->twAggSup.deleteMark = pInfo->twAggSup.deleteMarkSaved; - /*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE ||*/ - /*pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);*/ + pInfo->ignoreExpiredData = pInfo->ignoreExpiredDataSaved; qInfo("restore stream param for session: %d, %" PRId64, pInfo->twAggSup.calTrigger, pInfo->twAggSup.deleteMark); } else if (pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE) { SStreamStateAggOperatorInfo* pInfo = pOperator->info; - /*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE);*/ - /*ASSERT(pInfo->twAggSup.deleteMark == INT64_MAX);*/ - pInfo->twAggSup.calTrigger = pInfo->twAggSup.calTriggerSaved; pInfo->twAggSup.deleteMark = pInfo->twAggSup.deleteMarkSaved; - /*ASSERT(pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE ||*/ - /*pInfo->twAggSup.calTrigger == STREAM_TRIGGER_WINDOW_CLOSE);*/ + pInfo->ignoreExpiredData = pInfo->ignoreExpiredDataSaved; qInfo("restore stream param for state: %d, %" PRId64, pInfo->twAggSup.calTrigger, pInfo->twAggSup.deleteMark); } @@ -976,6 +1009,7 @@ int32_t qStreamRestoreParam(qTaskInfo_t tinfo) { } return 0; } + bool qStreamRecoverScanFinished(qTaskInfo_t tinfo) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; return pTaskInfo->streamInfo.recoverScanFinished; @@ -998,19 +1032,16 @@ const char* qExtractTbnameFromTask(qTaskInfo_t tinfo) { SMqMetaRsp* qStreamExtractMetaMsg(qTaskInfo_t tinfo) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE); return &pTaskInfo->streamInfo.metaRsp; } int64_t qStreamExtractPrepareUid(qTaskInfo_t tinfo) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE); return pTaskInfo->streamInfo.prepareStatus.uid; } int32_t qStreamExtractOffset(qTaskInfo_t tinfo, STqOffsetVal* pOffset) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE); memcpy(pOffset, &pTaskInfo->streamInfo.lastStatus, sizeof(STqOffsetVal)); return 0; } @@ -1046,20 +1077,12 @@ int32_t initQueryTableDataCondForTmq(SQueryTableDataCond* pCond, SSnapContext* s return TSDB_CODE_SUCCESS; } -#if 0 -int32_t qStreamScanMemData(qTaskInfo_t tinfo, const SSubmitReq* pReq, int64_t scanVer) { - SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE); - ASSERT(pTaskInfo->streamInfo.pReq == NULL); - pTaskInfo->streamInfo.pReq = pReq; - pTaskInfo->streamInfo.scanVer = scanVer; - return 0; -} -#endif - int32_t qStreamSetScanMemData(qTaskInfo_t tinfo, SPackedData submit) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; - ASSERT((pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE )&& (pTaskInfo->streamInfo.submit.msgStr == NULL)); + if ((pTaskInfo->execModel != OPTR_EXEC_MODEL_QUEUE) || (pTaskInfo->streamInfo.submit.msgStr != NULL)) { + qError("qStreamSetScanMemData err:%d,%p", pTaskInfo->execModel, pTaskInfo->streamInfo.submit.msgStr); + return -1; + } qDebug("set the submit block for future scan"); pTaskInfo->streamInfo.submit = submit; @@ -1069,7 +1092,8 @@ int32_t qStreamSetScanMemData(qTaskInfo_t tinfo, SPackedData submit) { int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subType) { SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo; SOperatorInfo* pOperator = pTaskInfo->pRoot; - ASSERT(pTaskInfo->execModel == OPTR_EXEC_MODEL_QUEUE); + const char* id = GET_TASKID(pTaskInfo); + pTaskInfo->streamInfo.prepareStatus = *pOffset; pTaskInfo->streamInfo.returned = 0; @@ -1079,20 +1103,20 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT if (subType == TOPIC_SUB_TYPE__COLUMN) { pOperator->status = OP_OPENED; - - // TODO add more check - if (pOperator->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) { - ASSERT(pOperator->numOfDownstream == 1); - pOperator = pOperator->pDownstream[0]; - } + pOperator = extractOperatorInTree(pOperator, QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, id); SStreamScanInfo* pInfo = pOperator->info; + STableScanInfo* pScanInfo = pInfo->pTableScanOp->info; + STableScanBase* pScanBaseInfo = &pScanInfo->base; + STableListInfo* pTableListInfo = pScanBaseInfo->pTableListInfo; + if (pOffset->type == TMQ_OFFSET__LOG) { - STableScanInfo* pTSInfo = pInfo->pTableScanOp->info; - tsdbReaderClose(pTSInfo->base.dataReader); - pTSInfo->base.dataReader = NULL; + tsdbReaderClose(pScanBaseInfo->dataReader); + pScanBaseInfo->dataReader = NULL; + // let's seek to the next version in wal file if (tqSeekVer(pInfo->tqReader, pOffset->version + 1, pTaskInfo->id.str) < 0) { + qError("tqSeekVer failed ver:%" PRId64 ", %s", pOffset->version + 1, id); return -1; } } else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { @@ -1100,122 +1124,141 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT // those data are from the snapshot in tsdb, besides the data in the wal file. int64_t uid = pOffset->uid; int64_t ts = pOffset->ts; + int32_t index = 0; + + // this value may be changed if new tables are created + taosRLockLatch(&pTaskInfo->lock); + int32_t numOfTables = tableListGetSize(pTableListInfo); if (uid == 0) { - if (tableListGetSize(pTaskInfo->pTableInfoList) != 0) { - STableKeyInfo* pTableInfo = tableListGetInfo(pTaskInfo->pTableInfoList, 0); + if (numOfTables != 0) { + STableKeyInfo* pTableInfo = tableListGetInfo(pTableListInfo, 0); uid = pTableInfo->uid; ts = INT64_MIN; + pScanInfo->currentTable = 0; } else { + taosRUnLockLatch(&pTaskInfo->lock); + qError("no table in table list, %s", id); return -1; } } - /*if (pTaskInfo->streamInfo.lastStatus.type != TMQ_OFFSET__SNAPSHOT_DATA ||*/ - /*pTaskInfo->streamInfo.lastStatus.uid != uid || pTaskInfo->streamInfo.lastStatus.ts != ts) {*/ - STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info; - int32_t numOfTables = tableListGetSize(pTaskInfo->pTableInfoList); - - qDebug("switch to next table %" PRId64 " ts %" PRId64 "% "PRId64 " rows returned", uid, ts, pInfo->pTableScanOp->resultInfo.totalRows); pInfo->pTableScanOp->resultInfo.totalRows = 0; - bool found = false; - for (int32_t i = 0; i < numOfTables; i++) { - STableKeyInfo* pTableInfo = tableListGetInfo(pTaskInfo->pTableInfoList, i); - if (pTableInfo->uid == uid) { - found = true; - pTableScanInfo->currentTable = i; - break; - } + // start from current accessed position + // we cannot start from the pScanInfo->currentTable, since the commit offset may cause the rollback of the start + // position, let's find it from the beginning. + index = tableListFind(pTableListInfo, uid, 0); + taosRUnLockLatch(&pTaskInfo->lock); + + if (index >= 0) { + pScanInfo->currentTable = index; + } else { + qError("vgId:%d uid:%" PRIu64 " not found in table list, total:%d, index:%d %s", pTaskInfo->id.vgId, uid, + numOfTables, pScanInfo->currentTable, id); + return -1; } - // TODO after dropping table, table may not found - ASSERT(found); + STableKeyInfo keyInfo = {.uid = uid}; + int64_t oldSkey = pScanBaseInfo->cond.twindows.skey; - if (pTableScanInfo->base.dataReader == NULL) { - STableKeyInfo* pList = tableListGetInfo(pTaskInfo->pTableInfoList, 0); - int32_t num = tableListGetSize(pTaskInfo->pTableInfoList); + // let's start from the next ts that returned to consumer. + pScanBaseInfo->cond.twindows.skey = ts + 1; + pScanInfo->scanTimes = 0; - if (tsdbReaderOpen(pTableScanInfo->base.readHandle.vnode, &pTableScanInfo->base.cond, pList, num, - pTableScanInfo->pResBlock, &pTableScanInfo->base.dataReader, NULL) < 0 || - pTableScanInfo->base.dataReader == NULL) { - ASSERT(0); + if (pScanBaseInfo->dataReader == NULL) { + int32_t code = tsdbReaderOpen(pScanBaseInfo->readHandle.vnode, &pScanBaseInfo->cond, &keyInfo, 1, + pScanInfo->pResBlock, &pScanBaseInfo->dataReader, id, false); + if (code != TSDB_CODE_SUCCESS) { + qError("prepare read tsdb snapshot failed, uid:%" PRId64 ", code:%s %s", pOffset->uid, tstrerror(code), id); + terrno = code; + return -1; } - } - STableKeyInfo tki = {.uid = uid}; - tsdbSetTableList(pTableScanInfo->base.dataReader, &tki, 1); - int64_t oldSkey = pTableScanInfo->base.cond.twindows.skey; - pTableScanInfo->base.cond.twindows.skey = ts + 1; - tsdbReaderReset(pTableScanInfo->base.dataReader, &pTableScanInfo->base.cond); - pTableScanInfo->base.cond.twindows.skey = oldSkey; - pTableScanInfo->scanTimes = 0; + qDebug("tsdb reader created with offset(snapshot) uid:%" PRId64 " ts:%" PRId64 " table index:%d, total:%d, %s", + uid, pScanBaseInfo->cond.twindows.skey, pScanInfo->currentTable, numOfTables, id); + } else { + tsdbSetTableList(pScanBaseInfo->dataReader, &keyInfo, 1); + tsdbReaderReset(pScanBaseInfo->dataReader, &pScanBaseInfo->cond); + qDebug("tsdb reader offset seek snapshot to uid:%" PRId64 " ts %" PRId64 " table index:%d numOfTable:%d, %s", + uid, pScanBaseInfo->cond.twindows.skey, pScanInfo->currentTable, numOfTables, id); + } - qDebug("tsdb reader offset seek to uid %" PRId64 " ts %" PRId64 ", table cur set to %d , all table num %d", uid, - ts, pTableScanInfo->currentTable, numOfTables); + // restore the key value + pScanBaseInfo->cond.twindows.skey = oldSkey; } else { - ASSERT(0); - } - } else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { - SStreamRawScanInfo* pInfo = pOperator->info; - SSnapContext* sContext = pInfo->sContext; - if (setForSnapShot(sContext, pOffset->uid) != 0) { - qError("setDataForSnapShot error. uid:%" PRIi64, pOffset->uid); + qError("invalid pOffset->type:%d, %s", pOffset->type, id); return -1; } - SMetaTableInfo mtInfo = getUidfromSnapShot(sContext); - tsdbReaderClose(pInfo->dataReader); - pInfo->dataReader = NULL; + } else { // subType == TOPIC_SUB_TYPE__TABLE/TOPIC_SUB_TYPE__DB - cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond); - tableListClear(pTaskInfo->pTableInfoList); + if (pOffset->type == TMQ_OFFSET__SNAPSHOT_DATA) { + SStreamRawScanInfo* pInfo = pOperator->info; + SSnapContext* sContext = pInfo->sContext; - if (mtInfo.uid == 0) { - return 0; // no data - } + SOperatorInfo* p = extractOperatorInTree(pOperator, QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN, id); + STableListInfo* pTableListInfo = ((SStreamRawScanInfo*)(p->info))->pTableListInfo; - initQueryTableDataCondForTmq(&pTaskInfo->streamInfo.tableCond, sContext, &mtInfo); - pTaskInfo->streamInfo.tableCond.twindows.skey = pOffset->ts; + if (setForSnapShot(sContext, pOffset->uid) != 0) { + qError("setDataForSnapShot error. uid:%" PRId64 " , %s", pOffset->uid, id); + return -1; + } - if (pTaskInfo->pTableInfoList == NULL) { - pTaskInfo->pTableInfoList = tableListCreate(); - } + SMetaTableInfo mtInfo = getUidfromSnapShot(sContext); + tsdbReaderClose(pInfo->dataReader); + pInfo->dataReader = NULL; - tableListAddTableInfo(pTaskInfo->pTableInfoList, mtInfo.uid, 0); + cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond); + tableListClear(pTableListInfo); - STableKeyInfo* pList = tableListGetInfo(pTaskInfo->pTableInfoList, 0); - int32_t size = tableListGetSize(pTaskInfo->pTableInfoList); - ASSERT(size == 1); + if (mtInfo.uid == 0) { + return 0; // no data + } - tsdbReaderOpen(pInfo->vnode, &pTaskInfo->streamInfo.tableCond, pList, size, NULL, &pInfo->dataReader, NULL); + initQueryTableDataCondForTmq(&pTaskInfo->streamInfo.tableCond, sContext, &mtInfo); + pTaskInfo->streamInfo.tableCond.twindows.skey = pOffset->ts; - cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond); - strcpy(pTaskInfo->streamInfo.tbName, mtInfo.tbName); - tDeleteSSchemaWrapper(pTaskInfo->streamInfo.schema); - pTaskInfo->streamInfo.schema = mtInfo.schema; + tableListAddTableInfo(pTableListInfo, mtInfo.uid, 0); - qDebug("tmqsnap qStreamPrepareScan snapshot data uid:%" PRId64 " ts %" PRId64, mtInfo.uid, pOffset->ts); - } else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_META) { - SStreamRawScanInfo* pInfo = pOperator->info; - SSnapContext* sContext = pInfo->sContext; - if (setForSnapShot(sContext, pOffset->uid) != 0) { - qError("setForSnapShot error. uid:%" PRIu64 " ,version:%" PRId64, pOffset->uid, pOffset->version); - return -1; + STableKeyInfo* pList = tableListGetInfo(pTableListInfo, 0); + int32_t size = tableListGetSize(pTableListInfo); + + tsdbReaderOpen(pInfo->vnode, &pTaskInfo->streamInfo.tableCond, pList, size, NULL, &pInfo->dataReader, NULL, + false); + + cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond); + strcpy(pTaskInfo->streamInfo.tbName, mtInfo.tbName); + tDeleteSSchemaWrapper(pTaskInfo->streamInfo.schema); + pTaskInfo->streamInfo.schema = mtInfo.schema; + + qDebug("tmqsnap qStreamPrepareScan snapshot data uid:%" PRId64 " ts %" PRId64 " %s", mtInfo.uid, pOffset->ts, id); + } else if (pOffset->type == TMQ_OFFSET__SNAPSHOT_META) { + SStreamRawScanInfo* pInfo = pOperator->info; + SSnapContext* sContext = pInfo->sContext; + if (setForSnapShot(sContext, pOffset->uid) != 0) { + qError("setForSnapShot error. uid:%" PRIu64 " ,version:%" PRId64, pOffset->uid, pOffset->version); + return -1; + } + qDebug("tmqsnap qStreamPrepareScan snapshot meta uid:%" PRId64 " ts %" PRId64 " %s", pOffset->uid, pOffset->ts, + id); + } else if (pOffset->type == TMQ_OFFSET__LOG) { + SStreamRawScanInfo* pInfo = pOperator->info; + tsdbReaderClose(pInfo->dataReader); + pInfo->dataReader = NULL; + qDebug("tmqsnap qStreamPrepareScan snapshot log, %s", id); } - qDebug("tmqsnap qStreamPrepareScan snapshot meta uid:%" PRId64 " ts %" PRId64, pOffset->uid, pOffset->ts); - } else if (pOffset->type == TMQ_OFFSET__LOG) { - SStreamRawScanInfo* pInfo = pOperator->info; - tsdbReaderClose(pInfo->dataReader); - pInfo->dataReader = NULL; - qDebug("tmqsnap qStreamPrepareScan snapshot log"); } + return 0; } void qProcessRspMsg(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { SMsgSendInfo* pSendInfo = (SMsgSendInfo*)pMsg->info.ahandle; - assert(pMsg->info.ahandle != NULL); + if (pMsg->info.ahandle == NULL) { + qError("pMsg->info.ahandle is NULL"); + return; + } SDataBuf buf = {.len = pMsg->contLen, .pData = NULL}; @@ -1233,4 +1276,3 @@ void qProcessRspMsg(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) { rpcFreeCont(pMsg->pCont); destroySendMsgInfo(pSendInfo); } - diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index e41ec5c7c73e1abfc1dbc440f3fd4ab407fc8e0d..da9516be8a056ee2fd7f5ffa2932e3f53ff8aab0 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -34,9 +34,7 @@ #include "ttypes.h" #include "vnode.h" -#define IS_MAIN_SCAN(runtime) ((runtime)->scanFlag == MAIN_SCAN) -#define SET_REVERSE_SCAN_FLAG(runtime) ((runtime)->scanFlag = REVERSE_SCAN) - +#define SET_REVERSE_SCAN_FLAG(runtime) ((runtime)->scanFlag = REVERSE_SCAN) #define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP) #if 0 @@ -73,35 +71,22 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) { #define realloc u_realloc #endif -#define CLEAR_QUERY_STATUS(q, st) ((q)->status &= (~(st))) -#define QUERY_IS_INTERVAL_QUERY(_q) ((_q)->interval.interval > 0) - -typedef struct SAggOperatorInfo { - SOptrBasicInfo binfo; - SAggSupporter aggSup; - STableQueryInfo* current; - uint64_t groupId; - SGroupResInfo groupResInfo; - SExprSupp scalarExprSup; - bool groupKeyOptimized; -} SAggOperatorInfo; +#define CLEAR_QUERY_STATUS(q, st) ((q)->status &= (~(st))) static void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExpr, SSDataBlock* pBlock); static void releaseQueryBuf(size_t numOfTables); -static void destroyAggOperatorInfo(void* param); -static void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size); -static void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId); -static void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag); -static int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t keyBufSize, - const char* pKey); +static void initCtxOutputBuffer(SqlFunctionCtx* pCtx, int32_t size); +static void doApplyScalarCalculation(SOperatorInfo* pOperator, SSDataBlock* pBlock, int32_t order, int32_t scanFlag); + static void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoData* p, bool keep, int32_t status); static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag, bool createDummyCol); static int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup, SDiskbasedBuf* pBuf, SGroupResInfo* pGroupResInfo); +static SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode); void setOperatorCompleted(SOperatorInfo* pOperator) { pOperator->status = OP_EXEC_DONE; @@ -195,8 +180,11 @@ SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, i */ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, char* pData, int16_t bytes, bool masterscan, uint64_t groupId, SExecTaskInfo* pTaskInfo, - bool isIntervalQuery, SAggSupporter* pSup) { + bool isIntervalQuery, SAggSupporter* pSup, bool keepGroup) { SET_RES_WINDOW_KEY(pSup->keyBuf, pData, bytes, groupId); + if (!keepGroup) { + *(uint64_t*)pSup->keyBuf = calcGroupId(pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes)); + } SResultRowPosition* p1 = (SResultRowPosition*)tSimpleHashGet(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes)); @@ -263,57 +251,6 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR return pResult; } -// a new buffer page for each table. Needs to opt this design -static int32_t addNewWindowResultBuf(SResultRow* pWindowRes, SDiskbasedBuf* pResultBuf, uint32_t size) { - if (pWindowRes->pageId != -1) { - return 0; - } - - SFilePage* pData = NULL; - - // in the first scan, new space needed for results - int32_t pageId = -1; - SArray* list = getDataBufPagesIdList(pResultBuf); - - if (taosArrayGetSize(list) == 0) { - pData = getNewBufPage(pResultBuf, &pageId); - pData->num = sizeof(SFilePage); - } else { - SPageInfo* pi = getLastPageInfo(list); - pData = getBufPage(pResultBuf, getPageId(pi)); - if (pData == NULL) { - qError("failed to get buffer, code:%s", tstrerror(terrno)); - return terrno; - } - - pageId = getPageId(pi); - - if (pData->num + size > getBufPageSize(pResultBuf)) { - // release current page first, and prepare the next one - releaseBufPageInfo(pResultBuf, pi); - - pData = getNewBufPage(pResultBuf, &pageId); - if (pData != NULL) { - pData->num = sizeof(SFilePage); - } - } - } - - if (pData == NULL) { - return -1; - } - - // set the number of rows in current disk page - if (pWindowRes->pageId == -1) { // not allocated yet, allocate new buffer - pWindowRes->pageId = pageId; - pWindowRes->offset = (int32_t)pData->num; - - pData->num += size; - } - - return 0; -} - // query_range_start, query_range_end, window_duration, window_start, window_end void initExecTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pQueryWindow) { pColData->info.type = TSDB_DATA_TYPE_TIMESTAMP; @@ -329,72 +266,6 @@ void initExecTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pQueryWindow colDataSetInt64(pColData, 4, &pQueryWindow->ekey); } -typedef struct { - bool hasAgg; - int32_t numOfRows; - int32_t startOffset; -} SFunctionCtxStatus; - -static void functionCtxSave(SqlFunctionCtx* pCtx, SFunctionCtxStatus* pStatus) { - pStatus->hasAgg = pCtx->input.colDataSMAIsSet; - pStatus->numOfRows = pCtx->input.numOfRows; - pStatus->startOffset = pCtx->input.startRowIndex; -} - -static void functionCtxRestore(SqlFunctionCtx* pCtx, SFunctionCtxStatus* pStatus) { - pCtx->input.colDataSMAIsSet = pStatus->hasAgg; - pCtx->input.numOfRows = pStatus->numOfRows; - pCtx->input.startRowIndex = pStatus->startOffset; -} - -void applyAggFunctionOnPartialTuples(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, SColumnInfoData* pTimeWindowData, - int32_t offset, int32_t forwardStep, int32_t numOfTotal, int32_t numOfOutput) { - for (int32_t k = 0; k < numOfOutput; ++k) { - // keep it temporarily - SFunctionCtxStatus status = {0}; - functionCtxSave(&pCtx[k], &status); - - pCtx[k].input.startRowIndex = offset; - pCtx[k].input.numOfRows = forwardStep; - - // not a whole block involved in query processing, statistics data can not be used - // NOTE: the original value of isSet have been changed here - if (pCtx[k].input.colDataSMAIsSet && forwardStep < numOfTotal) { - pCtx[k].input.colDataSMAIsSet = false; - } - - if (pCtx[k].isPseudoFunc) { - SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(&pCtx[k]); - - char* p = GET_ROWCELL_INTERBUF(pEntryInfo); - - SColumnInfoData idata = {0}; - idata.info.type = TSDB_DATA_TYPE_BIGINT; - idata.info.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; - idata.pData = p; - - SScalarParam out = {.columnData = &idata}; - SScalarParam tw = {.numOfRows = 5, .columnData = pTimeWindowData}; - pCtx[k].sfp.process(&tw, 1, &out); - pEntryInfo->numOfRes = 1; - } else { - int32_t code = TSDB_CODE_SUCCESS; - if (functionNeedToExecute(&pCtx[k]) && pCtx[k].fpSet.process != NULL) { - code = pCtx[k].fpSet.process(&pCtx[k]); - - if (code != TSDB_CODE_SUCCESS) { - qError("%s apply functions error, code: %s", GET_TASKID(taskInfo), tstrerror(code)); - taskInfo->code = code; - T_LONG_JMP(taskInfo->env, code); - } - } - - // restore it - functionCtxRestore(&pCtx[k], &status); - } - } -} - static void doSetInputDataBlockInfo(SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t order, int32_t scanFlag) { SqlFunctionCtx* pCtx = pExprSup->pCtx; for (int32_t i = 0; i < pExprSup->numOfExprs; ++i) { @@ -509,25 +380,6 @@ static int32_t doSetInputDataBlock(SExprSupp* pExprSup, SSDataBlock* pBlock, int return code; } -static int32_t doAggregateImpl(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx) { - for (int32_t k = 0; k < pOperator->exprSupp.numOfExprs; ++k) { - if (functionNeedToExecute(&pCtx[k])) { - // todo add a dummy funtion to avoid process check - if (pCtx[k].fpSet.process == NULL) { - continue; - } - - int32_t code = pCtx[k].fpSet.process(&pCtx[k]); - if (code != TSDB_CODE_SUCCESS) { - qError("%s aggregate function error happens, code: %s", GET_TASKID(pOperator->pTaskInfo), tstrerror(code)); - return code; - } - } - } - - return TSDB_CODE_SUCCESS; -} - bool functionNeedToExecute(SqlFunctionCtx* pCtx) { struct SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); @@ -630,7 +482,7 @@ void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock* pB } } -bool isTaskKilled(SExecTaskInfo* pTaskInfo) { return (0 != pTaskInfo->code) ? true : false; } +bool isTaskKilled(SExecTaskInfo* pTaskInfo) { return (0 != pTaskInfo->code); } void setTaskKilled(SExecTaskInfo* pTaskInfo, int32_t rspCode) { pTaskInfo->code = rspCode; } @@ -651,149 +503,6 @@ STimeWindow getAlignQueryTimeWindow(SInterval* pInterval, int32_t precision, int return win; } -int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableScanInfo, SSDataBlock* pBlock, - uint32_t* status) { - *status = BLK_DATA_NOT_LOAD; - - pBlock->pDataBlock = NULL; - pBlock->pBlockAgg = NULL; - - // int64_t groupId = pRuntimeEnv->current->groupIndex; - // bool ascQuery = QUERY_IS_ASC_QUERY(pQueryAttr); - - STaskCostInfo* pCost = &pTaskInfo->cost; - -// pCost->totalBlocks += 1; -// pCost->totalRows += pBlock->info.rows; -#if 0 - // Calculate all time windows that are overlapping or contain current data block. - // If current data block is contained by all possible time window, do not load current data block. - if (/*pQueryAttr->pFilters || */pQueryAttr->groupbyColumn || pQueryAttr->sw.gap > 0 || - (QUERY_IS_INTERVAL_QUERY(pQueryAttr) && overlapWithTimeWindow(pTaskInfo, &pBlock->info))) { - (*status) = BLK_DATA_DATA_LOAD; - } - - // check if this data block is required to load - if ((*status) != BLK_DATA_DATA_LOAD) { - bool needFilter = true; - - // the pCtx[i] result is belonged to previous time window since the outputBuf has not been set yet, - // the filter result may be incorrect. So in case of interval query, we need to set the correct time output buffer - if (QUERY_IS_INTERVAL_QUERY(pQueryAttr)) { - SResultRow* pResult = NULL; - - bool masterScan = IS_MAIN_SCAN(pRuntimeEnv); - TSKEY k = ascQuery? pBlock->info.window.skey : pBlock->info.window.ekey; - - STimeWindow win = getActiveTimeWindow(pTableScanInfo->pResultRowInfo, k, pQueryAttr); - if (pQueryAttr->pointInterpQuery) { - needFilter = chkWindowOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, &win, masterScan, &pResult, groupId, - pTableScanInfo->pCtx, pTableScanInfo->numOfOutput, - pTableScanInfo->rowEntryInfoOffset); - } else { - if (setResultOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pBlock->info.id.uid, &win, masterScan, &pResult, groupId, - pTableScanInfo->pCtx, pTableScanInfo->numOfOutput, - pTableScanInfo->rowEntryInfoOffset) != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pRuntimeEnv->env, TSDB_CODE_OUT_OF_MEMORY); - } - } - } else if (pQueryAttr->stableQuery && (!pQueryAttr->tsCompQuery) && (!pQueryAttr->diffQuery)) { // stable aggregate, not interval aggregate or normal column aggregate - doSetTableGroupOutputBuf(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pTableScanInfo->pCtx, - pTableScanInfo->rowEntryInfoOffset, pTableScanInfo->numOfOutput, - pRuntimeEnv->current->groupIndex); - } - - if (needFilter) { - (*status) = doFilterByBlockTimeWindow(pTableScanInfo, pBlock); - } else { - (*status) = BLK_DATA_DATA_LOAD; - } - } - - SDataBlockInfo* pBlockInfo = &pBlock->info; -// *status = updateBlockLoadStatus(pRuntimeEnv->pQueryAttr, *status); - - if ((*status) == BLK_DATA_NOT_LOAD || (*status) == BLK_DATA_FILTEROUT) { - //qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey, -// pBlockInfo->window.ekey, pBlockInfo->rows); - pCost->skipBlocks += 1; - } else if ((*status) == BLK_DATA_SMA_LOAD) { - // this function never returns error? - pCost->loadBlockStatis += 1; -// tsdbRetrieveDatablockSMA(pTableScanInfo->pTsdbReadHandle, &pBlock->pBlockAgg); - - if (pBlock->pBlockAgg == NULL) { // data block statistics does not exist, load data block -// pBlock->pDataBlock = tsdbRetrieveDataBlock(pTableScanInfo->pTsdbReadHandle, NULL); - pCost->totalCheckedRows += pBlock->info.rows; - } - } else { - assert((*status) == BLK_DATA_DATA_LOAD); - - // load the data block statistics to perform further filter - pCost->loadBlockStatis += 1; -// tsdbRetrieveDatablockSMA(pTableScanInfo->pTsdbReadHandle, &pBlock->pBlockAgg); - - if (pQueryAttr->topBotQuery && pBlock->pBlockAgg != NULL) { - { // set previous window - if (QUERY_IS_INTERVAL_QUERY(pQueryAttr)) { - SResultRow* pResult = NULL; - - bool masterScan = IS_MAIN_SCAN(pRuntimeEnv); - TSKEY k = ascQuery? pBlock->info.window.skey : pBlock->info.window.ekey; - - STimeWindow win = getActiveTimeWindow(pTableScanInfo->pResultRowInfo, k, pQueryAttr); - if (setResultOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pBlock->info.id.uid, &win, masterScan, &pResult, groupId, - pTableScanInfo->pCtx, pTableScanInfo->numOfOutput, - pTableScanInfo->rowEntryInfoOffset) != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pRuntimeEnv->env, TSDB_CODE_OUT_OF_MEMORY); - } - } - } - bool load = false; - for (int32_t i = 0; i < pQueryAttr->numOfOutput; ++i) { - int32_t functionId = pTableScanInfo->pCtx[i].functionId; - if (functionId == FUNCTION_TOP || functionId == FUNCTION_BOTTOM) { -// load = topbot_datablock_filter(&pTableScanInfo->pCtx[i], (char*)&(pBlock->pBlockAgg[i].min), -// (char*)&(pBlock->pBlockAgg[i].max)); - if (!load) { // current block has been discard due to filter applied - pCost->skipBlocks += 1; - //qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, -// pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); - (*status) = BLK_DATA_FILTEROUT; - return TSDB_CODE_SUCCESS; - } - } - } - } - - // current block has been discard due to filter applied -// if (!doFilterByBlockSMA(pRuntimeEnv, pBlock->pBlockAgg, pTableScanInfo->pCtx, pBlockInfo->rows)) { -// pCost->skipBlocks += 1; -// qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey, -// pBlockInfo->window.ekey, pBlockInfo->rows); -// (*status) = BLK_DATA_FILTEROUT; -// return TSDB_CODE_SUCCESS; -// } - - pCost->totalCheckedRows += pBlockInfo->rows; - pCost->loadBlocks += 1; -// pBlock->pDataBlock = tsdbRetrieveDataBlock(pTableScanInfo->pTsdbReadHandle, NULL); -// if (pBlock->pDataBlock == NULL) { -// return terrno; -// } - -// if (pQueryAttr->pFilters != NULL) { -// filterSetColFieldData(pQueryAttr->pFilters, taosArrayGetSize(pBlock->pDataBlock), pBlock->pDataBlock); -// } - -// if (pQueryAttr->pFilters != NULL || pRuntimeEnv->pTsBuf != NULL) { -// filterColRowsInDataBlock(pRuntimeEnv, pBlock, ascQuery); -// } - } -#endif - return TSDB_CODE_SUCCESS; -} - void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status) { if (status == TASK_NOT_COMPLETED) { pTaskInfo->status = status; @@ -1024,43 +733,6 @@ void extractQualifiedTupleByFilterResult(SSDataBlock* pBlock, const SColumnInfoD } } -void doSetTableGroupOutputBuf(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId) { - // for simple group by query without interval, all the tables belong to one group result. - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - SAggOperatorInfo* pAggInfo = pOperator->info; - - SResultRowInfo* pResultRowInfo = &pAggInfo->binfo.resultRowInfo; - SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx; - int32_t* rowEntryInfoOffset = pOperator->exprSupp.rowEntryInfoOffset; - - SResultRow* pResultRow = doSetResultOutBufByKey(pAggInfo->aggSup.pResultBuf, pResultRowInfo, (char*)&groupId, - sizeof(groupId), true, groupId, pTaskInfo, false, &pAggInfo->aggSup); - /* - * not assign result buffer yet, add new result buffer - * all group belong to one result set, and each group result has different group id so set the id to be one - */ - if (pResultRow->pageId == -1) { - int32_t ret = addNewWindowResultBuf(pResultRow, pAggInfo->aggSup.pResultBuf, pAggInfo->binfo.pRes->info.rowSize); - if (ret != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pTaskInfo->env, terrno); - } - } - - setResultRowInitCtx(pResultRow, pCtx, numOfOutput, rowEntryInfoOffset); -} - -static void setExecutionContext(SOperatorInfo* pOperator, int32_t numOfOutput, uint64_t groupId) { - SAggOperatorInfo* pAggInfo = pOperator->info; - if (pAggInfo->groupId != UINT64_MAX && pAggInfo->groupId == groupId) { - return; - } - - doSetTableGroupOutputBuf(pOperator, numOfOutput, groupId); - - // record the current active group id - pAggInfo->groupId = groupId; -} - void doUpdateNumOfRows(SqlFunctionCtx* pCtx, SResultRow* pRow, int32_t numOfExprs, const int32_t* rowEntryOffset) { bool returnNotNull = false; for (int32_t j = 0; j < numOfExprs; ++j) { @@ -1199,7 +871,7 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprS if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) { blockDataEnsureCapacity(pBlock, pBlock->info.rows + pRow->numOfRows); - qDebug("datablock capacity not sufficient, expand to required:%d, current capacity:%d, %s", + qDebug("datablock capacity not sufficient, expand to required:%" PRId64 ", current capacity:%d, %s", (pRow->numOfRows + pBlock->info.rows), pBlock->info.capacity, GET_TASKID(pTaskInfo)); // todo set the pOperator->resultInfo size } @@ -1211,7 +883,7 @@ int32_t doCopyToSDataBlock(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprS pBlock->info.rows += pRow->numOfRows; } - qDebug("%s result generated, rows:%d, groupId:%" PRIu64, GET_TASKID(pTaskInfo), pBlock->info.rows, + qDebug("%s result generated, rows:%" PRId64 ", groupId:%" PRIu64, GET_TASKID(pTaskInfo), pBlock->info.rows, pBlock->info.id.groupId); pBlock->info.dataLoad = 1; blockDataUpdateTsWindow(pBlock, 0); @@ -1251,161 +923,6 @@ void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SG } } -// static TSKEY doSkipIntervalProcess(STaskRuntimeEnv* pRuntimeEnv, STimeWindow* win, SDataBlockInfo* pBlockInfo, -// STableQueryInfo* pTableQueryInfo) { -// STaskAttr *pQueryAttr = pRuntimeEnv->pQueryAttr; -// SResultRowInfo *pWindowResInfo = &pRuntimeEnv->resultRowInfo; -// -// STimeWindow tw = *win; -// getNextTimeWindow(pQueryAttr, &tw); -// -// if ((tw.skey <= pBlockInfo->window.ekey && QUERY_IS_ASC_QUERY(pQueryAttr)) || -// (tw.ekey >= pBlockInfo->window.skey && !QUERY_IS_ASC_QUERY(pQueryAttr))) { -// -// // load the data block and check data remaining in current data block -// // TODO optimize performance -// SArray * pDataBlock = tsdbRetrieveDataBlock(pRuntimeEnv->pTsdbReadHandle, NULL); -// SColumnInfoData *pColInfoData = taosArrayGet(pDataBlock, 0); -// -// tw = *win; -// int32_t startPos = -// getNextQualifiedWindow(pQueryAttr, &tw, pBlockInfo, pColInfoData->pData, binarySearchForKey, -1); -// -// // set the abort info -// pQueryAttr->pos = startPos; -// -// // reset the query start timestamp -// pTableQueryInfo->win.skey = ((TSKEY *)pColInfoData->pData)[startPos]; -// pQueryAttr->window.skey = pTableQueryInfo->win.skey; -// TSKEY key = pTableQueryInfo->win.skey; -// -// pWindowResInfo->prevSKey = tw.skey; -// int32_t index = pRuntimeEnv->resultRowInfo.curIndex; -// -// int32_t numOfRes = tableApplyFunctionsOnBlock(pRuntimeEnv, pBlockInfo, NULL, binarySearchForKey, pDataBlock); -// pRuntimeEnv->resultRowInfo.curIndex = index; // restore the window index -// -// //qDebug("QInfo:0x%"PRIx64" check data block, brange:%" PRId64 "-%" PRId64 ", numOfRows:%d, numOfRes:%d, -// lastKey:%" PRId64, -// GET_TASKID(pRuntimeEnv), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, numOfRes, -// pQueryAttr->current->lastKey); -// -// return key; -// } else { // do nothing -// pQueryAttr->window.skey = tw.skey; -// pWindowResInfo->prevSKey = tw.skey; -// pTableQueryInfo->lastKey = tw.skey; -// -// return tw.skey; -// } -// -// return true; -// } - -// static bool skipTimeInterval(STaskRuntimeEnv *pRuntimeEnv, TSKEY* start) { -// STaskAttr *pQueryAttr = pRuntimeEnv->pQueryAttr; -// -// // if queried with value filter, do NOT forward query start position -// if (pQueryAttr->limit.offset <= 0 || pQueryAttr->numOfFilterCols > 0 || pRuntimeEnv->pTsBuf != NULL || -// pRuntimeEnv->pFillInfo != NULL) { -// return true; -// } -// -// /* -// * 1. for interval without interpolation query we forward pQueryAttr->interval.interval at a time for -// * pQueryAttr->limit.offset times. Since hole exists, pQueryAttr->interval.interval*pQueryAttr->limit.offset -// value is -// * not valid. otherwise, we only forward pQueryAttr->limit.offset number of points -// */ -// STimeWindow w = TSWINDOW_INITIALIZER; -// bool ascQuery = QUERY_IS_ASC_QUERY(pQueryAttr); -// -// SResultRowInfo *pWindowResInfo = &pRuntimeEnv->resultRowInfo; -// STableQueryInfo *pTableQueryInfo = pRuntimeEnv->current; -// -// SDataBlockInfo blockInfo = SDATA_BLOCK_INITIALIZER; -// while (tsdbNextDataBlock(pRuntimeEnv->pTsdbReadHandle)) { -// tsdbRetrieveDataBlockInfo(pRuntimeEnv->pTsdbReadHandle, &blockInfo); -// -// if (QUERY_IS_ASC_QUERY(pQueryAttr)) { -// if (pWindowResInfo->prevSKey == TSKEY_INITIAL_VAL) { -// getAlignQueryTimeWindow(pQueryAttr, blockInfo.window.skey, blockInfo.window.skey, pQueryAttr->window.ekey, -// &w); pWindowResInfo->prevSKey = w.skey; -// } -// } else { -// getAlignQueryTimeWindow(pQueryAttr, blockInfo.window.ekey, pQueryAttr->window.ekey, blockInfo.window.ekey, &w); -// pWindowResInfo->prevSKey = w.skey; -// } -// -// // the first time window -// STimeWindow win = getActiveTimeWindow(pWindowResInfo, pWindowResInfo->prevSKey, pQueryAttr); -// -// while (pQueryAttr->limit.offset > 0) { -// STimeWindow tw = win; -// -// if ((win.ekey <= blockInfo.window.ekey && ascQuery) || (win.ekey >= blockInfo.window.skey && !ascQuery)) { -// pQueryAttr->limit.offset -= 1; -// pWindowResInfo->prevSKey = win.skey; -// -// // current time window is aligned with blockInfo.window.ekey -// // restart it from next data block by set prevSKey to be TSKEY_INITIAL_VAL; -// if ((win.ekey == blockInfo.window.ekey && ascQuery) || (win.ekey == blockInfo.window.skey && !ascQuery)) { -// pWindowResInfo->prevSKey = TSKEY_INITIAL_VAL; -// } -// } -// -// if (pQueryAttr->limit.offset == 0) { -// *start = doSkipIntervalProcess(pRuntimeEnv, &win, &blockInfo, pTableQueryInfo); -// return true; -// } -// -// // current window does not ended in current data block, try next data block -// getNextTimeWindow(pQueryAttr, &tw); -// -// /* -// * If the next time window still starts from current data block, -// * load the primary timestamp column first, and then find the start position for the next queried time window. -// * Note that only the primary timestamp column is required. -// * TODO: Optimize for this cases. All data blocks are not needed to be loaded, only if the first actually -// required -// * time window resides in current data block. -// */ -// if ((tw.skey <= blockInfo.window.ekey && ascQuery) || (tw.ekey >= blockInfo.window.skey && !ascQuery)) { -// -// SArray *pDataBlock = tsdbRetrieveDataBlock(pRuntimeEnv->pTsdbReadHandle, NULL); -// SColumnInfoData *pColInfoData = taosArrayGet(pDataBlock, 0); -// -// if ((win.ekey > blockInfo.window.ekey && ascQuery) || (win.ekey < blockInfo.window.skey && !ascQuery)) { -// pQueryAttr->limit.offset -= 1; -// } -// -// if (pQueryAttr->limit.offset == 0) { -// *start = doSkipIntervalProcess(pRuntimeEnv, &win, &blockInfo, pTableQueryInfo); -// return true; -// } else { -// tw = win; -// int32_t startPos = -// getNextQualifiedWindow(pQueryAttr, &tw, &blockInfo, pColInfoData->pData, binarySearchForKey, -1); -// // set the abort info -// pQueryAttr->pos = startPos; -// pTableQueryInfo->lastKey = ((TSKEY *)pColInfoData->pData)[startPos]; -// pWindowResInfo->prevSKey = tw.skey; -// win = tw; -// } -// } else { -// break; // offset is not 0, and next time window begins or ends in the next block. -// } -// } -// } -// -// // check for error -// if (terrno != TSDB_CODE_SUCCESS) { -// T_LONG_JMP(pRuntimeEnv->env, terrno); -// } -// -// return true; -// } - int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t num) { p->pDownstream = taosMemoryCalloc(1, num * POINTER_BYTES); if (p->pDownstream == NULL) { @@ -1451,191 +968,23 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan } } -static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBlock** ppBlock) { - if (!tsCountAlwaysReturnValue) { - return TSDB_CODE_SUCCESS; - } - - SAggOperatorInfo* pAggInfo = pOperator->info; - if (pAggInfo->groupKeyOptimized) { - return TSDB_CODE_SUCCESS; - } - - SOperatorInfo* downstream = pOperator->pDownstream[0]; - if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_PARTITION || - (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN && - ((STableScanInfo*)downstream->info)->hasGroupByTag == true)) { - return TSDB_CODE_SUCCESS; - } - - SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx; - bool hasCountFunc = false; - - for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) { - const char* pName = pCtx[i].pExpr->pExpr->_function.functionName; - if ((strcmp(pName, "count") == 0) || (strcmp(pName, "hyperloglog") == 0) || - (strcmp(pName, "_hyperloglog_partial") == 0) || (strcmp(pName, "_hyperloglog_merge") == 0)) { - hasCountFunc = true; - break; - } - } - - if (!hasCountFunc) { - return TSDB_CODE_SUCCESS; - } - - SSDataBlock* pBlock = createDataBlock(); - pBlock->info.rows = 1; - pBlock->info.capacity = 0; - - for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) { - SColumnInfoData colInfo = {0}; - colInfo.hasNull = true; - colInfo.info.type = TSDB_DATA_TYPE_NULL; - colInfo.info.bytes = 1; - - SExprInfo* pOneExpr = &pOperator->exprSupp.pExprInfo[i]; - for (int32_t j = 0; j < pOneExpr->base.numOfParams; ++j) { - SFunctParam* pFuncParam = &pOneExpr->base.pParam[j]; - if (pFuncParam->type == FUNC_PARAM_TYPE_COLUMN) { - int32_t slotId = pFuncParam->pCol->slotId; - int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock); - if (slotId >= numOfCols) { - taosArrayEnsureCap(pBlock->pDataBlock, slotId + 1); - for (int32_t k = numOfCols; k < slotId + 1; ++k) { - taosArrayPush(pBlock->pDataBlock, &colInfo); - } - } - } else if (pFuncParam->type == FUNC_PARAM_TYPE_VALUE) { - // do nothing - } - } - } - - blockDataEnsureCapacity(pBlock, pBlock->info.rows); - *ppBlock = pBlock; - - return TSDB_CODE_SUCCESS; -} - -static void destroyDataBlockForEmptyInput(bool blockAllocated, SSDataBlock** ppBlock) { - if (!blockAllocated) { - return; - } - - blockDataDestroy(*ppBlock); - *ppBlock = NULL; -} - -// this is a blocking operator -static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) { - if (OPTR_IS_OPENED(pOperator)) { - return TSDB_CODE_SUCCESS; - } - - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - SAggOperatorInfo* pAggInfo = pOperator->info; - - SExprSupp* pSup = &pOperator->exprSupp; - SOperatorInfo* downstream = pOperator->pDownstream[0]; - - int64_t st = taosGetTimestampUs(); - - int32_t order = TSDB_ORDER_ASC; - int32_t scanFlag = MAIN_SCAN; - - bool hasValidBlock = false; - bool blockAllocated = false; - - while (1) { - SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream); - if (pBlock == NULL) { - if (!hasValidBlock) { - createDataBlockForEmptyInput(pOperator, &pBlock); - if (pBlock == NULL) { - break; - } - blockAllocated = true; - } else { - break; - } - } - hasValidBlock = true; - - int32_t code = getTableScanInfo(pOperator, &order, &scanFlag, false); - if (code != TSDB_CODE_SUCCESS) { - destroyDataBlockForEmptyInput(blockAllocated, &pBlock); - T_LONG_JMP(pTaskInfo->env, code); - } - - // there is an scalar expression that needs to be calculated before apply the group aggregation. - if (pAggInfo->scalarExprSup.pExprInfo != NULL && !blockAllocated) { - SExprSupp* pSup1 = &pAggInfo->scalarExprSup; - code = projectApplyFunctions(pSup1->pExprInfo, pBlock, pBlock, pSup1->pCtx, pSup1->numOfExprs, NULL); - if (code != TSDB_CODE_SUCCESS) { - destroyDataBlockForEmptyInput(blockAllocated, &pBlock); - T_LONG_JMP(pTaskInfo->env, code); - } - } - - // the pDataBlock are always the same one, no need to call this again - setExecutionContext(pOperator, pOperator->exprSupp.numOfExprs, pBlock->info.id.groupId); - setInputDataBlock(pSup, pBlock, order, scanFlag, true); - code = doAggregateImpl(pOperator, pSup->pCtx); - if (code != 0) { - destroyDataBlockForEmptyInput(blockAllocated, &pBlock); - T_LONG_JMP(pTaskInfo->env, code); - } - - destroyDataBlockForEmptyInput(blockAllocated, &pBlock); - } - - // the downstream operator may return with error code, so let's check the code before generating results. - if (pTaskInfo->code != TSDB_CODE_SUCCESS) { - T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); - } - - initGroupedResultInfo(&pAggInfo->groupResInfo, pAggInfo->aggSup.pResultRowHashTable, 0); - OPTR_SET_OPENED(pOperator); - - pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0; - return pTaskInfo->code; -} - -static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator) { - SAggOperatorInfo* pAggInfo = pOperator->info; - SOptrBasicInfo* pInfo = &pAggInfo->binfo; - - if (pOperator->status == OP_EXEC_DONE) { - return NULL; - } - - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - pTaskInfo->code = pOperator->fpSet._openFn(pOperator); - if (pTaskInfo->code != TSDB_CODE_SUCCESS) { - setOperatorCompleted(pOperator); +// QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN +SOperatorInfo* extractOperatorInTree(SOperatorInfo* pOperator, int32_t type, const char* id) { + if (pOperator == NULL) { + qError("invalid operator, failed to find tableScanOperator %s", id); return NULL; } - blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity); - while (1) { - doBuildResultDatablock(pOperator, pInfo, &pAggInfo->groupResInfo, pAggInfo->aggSup.pResultBuf); - doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL); - - if (!hasRemainResults(&pAggInfo->groupResInfo)) { - setOperatorCompleted(pOperator); - break; + if (pOperator->operatorType == type) { + return pOperator; + } else { + if (pOperator->pDownstream == NULL || pOperator->pDownstream[0] == NULL) { + qError("invalid operator, failed to find tableScanOperator %s", id); + return NULL; } - if (pInfo->pRes->info.rows > 0) { - break; - } + return extractOperatorInTree(pOperator->pDownstream[0], type, id); } - - size_t rows = blockDataGetNumOfRows(pInfo->pRes); - pOperator->resultInfo.totalRows += rows; - - return (rows == 0) ? NULL : pInfo->pRes; } void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs) { @@ -1702,70 +1051,6 @@ int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaul return 0; } -int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, size_t keyBufSize, - const char* pKey) { - int32_t code = 0; - // _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); - - pAggSup->currentPageId = -1; - pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput); - pAggSup->keyBuf = taosMemoryCalloc(1, keyBufSize + POINTER_BYTES + sizeof(int64_t)); - pAggSup->pResultRowHashTable = tSimpleHashInit(100, taosFastHash); - - if (pAggSup->keyBuf == NULL || pAggSup->pResultRowHashTable == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - uint32_t defaultPgsz = 0; - uint32_t defaultBufsz = 0; - getBufferPgSize(pAggSup->resultRowSize, &defaultPgsz, &defaultBufsz); - - if (!osTempSpaceAvailable()) { - code = TSDB_CODE_NO_AVAIL_DISK; - qError("Init stream agg supporter failed since %s, %s", terrstr(code), pKey); - return code; - } - - code = createDiskbasedBuf(&pAggSup->pResultBuf, defaultPgsz, defaultBufsz, pKey, tsTempDir); - if (code != TSDB_CODE_SUCCESS) { - qError("Create agg result buf failed since %s, %s", tstrerror(code), pKey); - return code; - } - - return code; -} - -void cleanupAggSup(SAggSupporter* pAggSup) { - taosMemoryFreeClear(pAggSup->keyBuf); - tSimpleHashCleanup(pAggSup->pResultRowHashTable); - destroyDiskbasedBuf(pAggSup->pResultBuf); -} - -int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize, - const char* pkey, void* pState) { - int32_t code = initExprSupp(pSup, pExprInfo, numOfCols); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - code = doInitAggInfoSup(pAggSup, pSup->pCtx, numOfCols, keyBufSize, pkey); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - for (int32_t i = 0; i < numOfCols; ++i) { - if (pState) { - pSup->pCtx[i].saveHandle.pBuf = NULL; - pSup->pCtx[i].saveHandle.pState = pState; - pSup->pCtx[i].exprIdx = i; - } else { - pSup->pCtx[i].saveHandle.pBuf = pAggSup->pResultBuf; - } - } - - return TSDB_CODE_SUCCESS; -} - void initResultSizeInfo(SResultInfo* pResultInfo, int32_t numOfRows) { if (numOfRows == 0) { numOfRows = 4096; @@ -1784,7 +1069,7 @@ void initBasicInfo(SOptrBasicInfo* pInfo, SSDataBlock* pBlock) { initResultRowInfo(&pInfo->resultRowInfo); } -void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput) { +static void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput) { if (pCtx == NULL) { return NULL; } @@ -1836,100 +1121,9 @@ void cleanupExprSupp(SExprSupp* pSupp) { taosMemoryFree(pSupp->rowEntryInfoOffset); } -SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode* pAggNode, - SExecTaskInfo* pTaskInfo) { - SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo)); - SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); - if (pInfo == NULL || pOperator == NULL) { - goto _error; - } - - SSDataBlock* pResBlock = createDataBlockFromDescNode(pAggNode->node.pOutputDataBlockDesc); - initBasicInfo(&pInfo->binfo, pResBlock); - - size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES; - initResultSizeInfo(&pOperator->resultInfo, 4096); - - int32_t num = 0; - SExprInfo* pExprInfo = createExprInfo(pAggNode->pAggFuncs, pAggNode->pGroupKeys, &num); - int32_t code = initAggSup(&pOperator->exprSupp, &pInfo->aggSup, pExprInfo, num, keyBufSize, pTaskInfo->id.str, - pTaskInfo->streamInfo.pState); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - int32_t numOfScalarExpr = 0; - SExprInfo* pScalarExprInfo = NULL; - if (pAggNode->pExprs != NULL) { - pScalarExprInfo = createExprInfo(pAggNode->pExprs, NULL, &numOfScalarExpr); - } - - code = initExprSupp(&pInfo->scalarExprSup, pScalarExprInfo, numOfScalarExpr); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - code = filterInitFromNode((SNode*)pAggNode->node.pConditions, &pOperator->exprSupp.pFilterInfo, 0); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - pInfo->binfo.mergeResultBlock = pAggNode->mergeDataBlock; - pInfo->groupKeyOptimized = pAggNode->groupKeyOptimized; - pInfo->groupId = UINT64_MAX; - - setOperatorInfo(pOperator, "TableAggregate", QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, true, OP_NOT_OPENED, pInfo, - pTaskInfo); - pOperator->fpSet = createOperatorFpSet(doOpenAggregateOptr, getAggregateResult, NULL, destroyAggOperatorInfo, - optrDefaultBufFn, NULL); - - if (downstream->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) { - STableScanInfo* pTableScanInfo = downstream->info; - pTableScanInfo->base.pdInfo.pExprSup = &pOperator->exprSupp; - pTableScanInfo->base.pdInfo.pAggSup = &pInfo->aggSup; - } - - code = appendDownstream(pOperator, &downstream, 1); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - - return pOperator; - -_error: - if (pInfo != NULL) { - destroyAggOperatorInfo(pInfo); - } - - if (pOperator != NULL) { - cleanupExprSupp(&pOperator->exprSupp); - } - - taosMemoryFreeClear(pOperator); - pTaskInfo->code = code; - return NULL; -} - void cleanupBasicInfo(SOptrBasicInfo* pInfo) { pInfo->pRes = blockDataDestroy(pInfo->pRes); } -static void freeItem(void* pItem) { - void** p = pItem; - if (*p != NULL) { - taosMemoryFreeClear(*p); - } -} - -void destroyAggOperatorInfo(void* param) { - SAggOperatorInfo* pInfo = (SAggOperatorInfo*)param; - cleanupBasicInfo(&pInfo->binfo); - - cleanupAggSup(&pInfo->aggSup); - cleanupExprSupp(&pInfo->scalarExprSup); - cleanupGroupResInfo(&pInfo->groupResInfo); - taosMemoryFreeClear(param); -} - -static char* buildTaskId(uint64_t taskId, uint64_t queryId) { +char* buildTaskId(uint64_t taskId, uint64_t queryId) { char* p = taosMemoryMalloc(64); int32_t offset = 6; @@ -1941,11 +1135,11 @@ static char* buildTaskId(uint64_t taskId, uint64_t queryId) { offset += tintToHex(queryId, &p[offset]); p[offset] = 0; - return p; } -static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPTR_EXEC_MODEL model, char* dbFName) { +SExecTaskInfo* doCreateExecTaskInfo(uint64_t queryId, uint64_t taskId, int32_t vgId, EOPTR_EXEC_MODEL model, + char* dbFName) { SExecTaskInfo* pTaskInfo = taosMemoryCalloc(1, sizeof(SExecTaskInfo)); if (pTaskInfo == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -1953,20 +1147,20 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT } setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED); + pTaskInfo->cost.created = taosGetTimestampUs(); pTaskInfo->schemaInfo.dbname = taosStrdup(dbFName); pTaskInfo->execModel = model; - pTaskInfo->pTableInfoList = tableListCreate(); pTaskInfo->stopInfo.pStopInfo = taosArrayInit(4, sizeof(SExchangeOpStopInfo)); pTaskInfo->pResultBlockList = taosArrayInit(128, POINTER_BYTES); + taosInitRWLatch(&pTaskInfo->lock); + pTaskInfo->id.vgId = vgId; pTaskInfo->id.queryId = queryId; pTaskInfo->id.str = buildTaskId(taskId, queryId); return pTaskInfo; } -SSchemaWrapper* extractQueriedColumnSchema(SScanPhysiNode* pScanNode); - int32_t extractTableSchemaInfo(SReadHandle* pHandle, SScanPhysiNode* pScanNode, SExecTaskInfo* pTaskInfo) { SMetaReader mr = {0}; if (pHandle == NULL) { @@ -2073,9 +1267,8 @@ bool groupbyTbname(SNodeList* pGroupList) { SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, SReadHandle* pHandle, SNode* pTagCond, SNode* pTagIndexCond, const char* pUser) { - int32_t type = nodeType(pPhyNode); - STableListInfo* pTableListInfo = pTaskInfo->pTableInfoList; - const char* idstr = GET_TASKID(pTaskInfo); + int32_t type = nodeType(pPhyNode); + const char* idstr = GET_TASKID(pTaskInfo); if (pPhyNode->pChildren == NULL || LIST_LENGTH(pPhyNode->pChildren) == 0) { SOperatorInfo* pOperator = NULL; @@ -2088,11 +1281,13 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pTableScanNode->groupSort = true; } - int32_t code = + STableListInfo* pTableListInfo = tableListCreate(); + int32_t code = createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, pTableScanNode->groupSort, pHandle, pTableListInfo, pTagCond, pTagIndexCond, pTaskInfo); if (code) { pTaskInfo->code = code; + tableListDestroy(pTableListInfo); qError("failed to createScanTableListInfo, code:%s, %s", tstrerror(code), idstr); return NULL; } @@ -2100,10 +1295,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo code = extractTableSchemaInfo(pHandle, &pTableScanNode->scan, pTaskInfo); if (code) { pTaskInfo->code = terrno; + tableListDestroy(pTableListInfo); return NULL; } - pOperator = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo); + pOperator = createTableScanOperatorInfo(pTableScanNode, pHandle, pTableListInfo, pTaskInfo); if (NULL == pOperator) { pTaskInfo->code = terrno; return NULL; @@ -2113,11 +1309,13 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pTaskInfo->cost.pRecoder = &pScanInfo->base.readRecorder; } else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN == type) { STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode; + STableListInfo* pTableListInfo = tableListCreate(); int32_t code = createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, true, pHandle, pTableListInfo, pTagCond, pTagIndexCond, pTaskInfo); if (code) { pTaskInfo->code = code; + tableListDestroy(pTableListInfo); qError("failed to createScanTableListInfo, code: %s", tstrerror(code)); return NULL; } @@ -2125,12 +1323,14 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo code = extractTableSchemaInfo(pHandle, &pTableScanNode->scan, pTaskInfo); if (code) { pTaskInfo->code = terrno; + tableListDestroy(pTableListInfo); return NULL; } - pOperator = createTableMergeScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo); + pOperator = createTableMergeScanOperatorInfo(pTableScanNode, pHandle, pTableListInfo, pTaskInfo); if (NULL == pOperator) { pTaskInfo->code = terrno; + tableListDestroy(pTableListInfo); return NULL; } @@ -2141,29 +1341,22 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN == type) { STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode; + STableListInfo* pTableListInfo = tableListCreate(); + if (pHandle->vnode) { int32_t code = createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, pTableScanNode->groupSort, pHandle, pTableListInfo, pTagCond, pTagIndexCond, pTaskInfo); if (code) { pTaskInfo->code = code; + tableListDestroy(pTableListInfo); qError("failed to createScanTableListInfo, code: %s", tstrerror(code)); return NULL; } - -#ifndef NDEBUG - int32_t sz = tableListGetSize(pTableListInfo); - qDebug("create stream task, total:%d", sz); - - for (int32_t i = 0; i < sz; i++) { - STableKeyInfo* pKeyInfo = tableListGetInfo(pTableListInfo, i); - qDebug("add table uid:%" PRIu64 ", gid:%" PRIu64, pKeyInfo->uid, pKeyInfo->groupId); - } -#endif } pTaskInfo->schemaInfo.qsw = extractQueriedColumnSchema(&pTableScanNode->scan); - pOperator = createStreamScanOperatorInfo(pHandle, pTableScanNode, pTagCond, pTaskInfo); + pOperator = createStreamScanOperatorInfo(pHandle, pTableScanNode, pTagCond, pTableListInfo, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN == type) { SSystemTableScanPhysiNode* pSysScanPhyNode = (SSystemTableScanPhysiNode*)pPhyNode; pOperator = createSysTableScanOperatorInfo(pHandle, pSysScanPhyNode, pUser, pTaskInfo); @@ -2172,18 +1365,19 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pOperator = createTableCountScanOperatorInfo(pHandle, pTblCountScanNode, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN == type) { STagScanPhysiNode* pScanPhyNode = (STagScanPhysiNode*)pPhyNode; - - int32_t code = createScanTableListInfo(pScanPhyNode, NULL, false, pHandle, pTableListInfo, pTagCond, - pTagIndexCond, pTaskInfo); + STableListInfo* pTableListInfo = tableListCreate(); + int32_t code = createScanTableListInfo(pScanPhyNode, NULL, false, pHandle, pTableListInfo, pTagCond, + pTagIndexCond, pTaskInfo); if (code != TSDB_CODE_SUCCESS) { pTaskInfo->code = code; qError("failed to getTableList, code: %s", tstrerror(code)); return NULL; } - pOperator = createTagScanOperatorInfo(pHandle, pScanPhyNode, pTaskInfo); + pOperator = createTagScanOperatorInfo(pHandle, pScanPhyNode, pTableListInfo, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN == type) { SBlockDistScanPhysiNode* pBlockNode = (SBlockDistScanPhysiNode*)pPhyNode; + STableListInfo* pTableListInfo = tableListCreate(); if (pBlockNode->tableType == TSDB_SUPER_TABLE) { SArray* pList = taosArrayInit(4, sizeof(STableKeyInfo)); @@ -2204,9 +1398,10 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo tableListAddTableInfo(pTableListInfo, pBlockNode->uid, 0); } - pOperator = createDataBlockInfoScanOperator(pHandle, pBlockNode, pTaskInfo); + pOperator = createDataBlockInfoScanOperator(pHandle, pBlockNode, pTableListInfo, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN == type) { SLastRowScanPhysiNode* pScanNode = (SLastRowScanPhysiNode*)pPhyNode; + STableListInfo* pTableListInfo = tableListCreate(); int32_t code = createScanTableListInfo(&pScanNode->scan, pScanNode->pGroupTags, true, pHandle, pTableListInfo, pTagCond, pTagIndexCond, pTaskInfo); @@ -2221,7 +1416,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return NULL; } - pOperator = createCacherowsScanOperator(pScanNode, pHandle, pTaskInfo); + pOperator = createCacherowsScanOperator(pScanNode, pHandle, pTableListInfo, pTaskInfo); } else if (QUERY_NODE_PHYSICAL_PLAN_PROJECT == type) { pOperator = createProjectOperatorInfo(NULL, (SProjectPhysiNode*)pPhyNode, pTaskInfo); } else { @@ -2229,7 +1424,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo return NULL; } - if (pOperator != NULL) { + if (pOperator != NULL) { // todo moved away pOperator->resultDataBlockId = pPhyNode->pOutputDataBlockDesc->dataBlockId; } @@ -2319,6 +1514,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo pOptr = createEventwindowOperatorInfo(ops[0], pPhyNode, pTaskInfo); } else { terrno = TSDB_CODE_INVALID_PARA; + taosMemoryFree(ops); return NULL; } @@ -2369,9 +1565,8 @@ int32_t extractTableScanNode(SPhysiNode* pNode, STableScanPhysiNode** ppNode) { return -1; } -int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle) { - SExecTaskInfo* pTask = *(SExecTaskInfo**)pTaskInfo; - +int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, STableListInfo* pTableListInfo, + SReadHandle* readHandle) { switch (pNode->type) { case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT: { SInserterParam* pInserterParam = taosMemoryCalloc(1, sizeof(SInserterParam)); @@ -2388,8 +1583,9 @@ int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pT if (NULL == pDeleterParam) { return TSDB_CODE_OUT_OF_MEMORY; } - int32_t tbNum = tableListGetSize(pTask->pTableInfoList); - pDeleterParam->suid = tableListGetSuid(pTask->pTableInfoList); + + int32_t tbNum = tableListGetSize(pTableListInfo); + pDeleterParam->suid = tableListGetSuid(pTableListInfo); // TODO extract uid list pDeleterParam->pUidList = taosArrayInit(tbNum, sizeof(uint64_t)); @@ -2399,11 +1595,12 @@ int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pT } for (int32_t i = 0; i < tbNum; ++i) { - STableKeyInfo* pTable = tableListGetInfo(pTask->pTableInfoList, i); + STableKeyInfo* pTable = tableListGetInfo(pTableListInfo, i); taosArrayPush(pDeleterParam->pUidList, &pTable->uid); } *pParam = pDeleterParam; + break; } default: @@ -2413,17 +1610,14 @@ int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pT return TSDB_CODE_SUCCESS; } -int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, - char* sql, EOPTR_EXEC_MODEL model) { - uint64_t queryId = pPlan->id.queryId; - - *pTaskInfo = createExecTaskInfo(queryId, taskId, model, pPlan->dbFName); +int32_t createExecTaskInfo(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId, + int32_t vgId, char* sql, EOPTR_EXEC_MODEL model) { + *pTaskInfo = doCreateExecTaskInfo(pPlan->id.queryId, taskId, vgId, model, pPlan->dbFName); if (*pTaskInfo == NULL) { goto _complete; } if (pHandle) { - /*(*pTaskInfo)->streamInfo.fillHistoryVer1 = pHandle->fillHistoryVer1;*/ if (pHandle->pStateBackend) { (*pTaskInfo)->streamInfo.pState = pHandle->pStateBackend; } @@ -2441,7 +1635,6 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead goto _complete; } - (*pTaskInfo)->cost.created = taosGetTimestampUs(); return TSDB_CODE_SUCCESS; _complete: @@ -2457,8 +1650,6 @@ static void freeBlock(void* pParam) { void doDestroyTask(SExecTaskInfo* pTaskInfo) { qDebug("%s execTask is freed", GET_TASKID(pTaskInfo)); - - pTaskInfo->pTableInfoList = tableListDestroy(pTaskInfo->pTableInfoList); destroyOperatorInfo(pTaskInfo->pRoot); cleanupTableSchemaInfo(&pTaskInfo->schemaInfo); cleanupStreamInfo(&pTaskInfo->streamInfo); @@ -2767,11 +1958,17 @@ int32_t buildSessionResultDataBlock(SOperatorInfo* pOperator, SStreamState* pSta } void qStreamCloseTsdbReader(void* task) { - if (task == NULL) return; + if (task == NULL) { + return; + } + SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)task; SOperatorInfo* pOp = pTaskInfo->pRoot; - qDebug("stream close tsdb reader, reset status uid %" PRId64 " ts %" PRId64, pTaskInfo->streamInfo.lastStatus.uid, + + qDebug("stream close tsdb reader, reset status uid:%" PRId64 " ts:%" PRId64, pTaskInfo->streamInfo.lastStatus.uid, pTaskInfo->streamInfo.lastStatus.ts); + + // todo refactor, other thread may already use this read to extract data. pTaskInfo->streamInfo.lastStatus = (STqOffsetVal){0}; while (pOp->numOfDownstream == 1 && pOp->pDownstream[0]) { SOperatorInfo* pDownstreamOp = pOp->pDownstream[0]; @@ -2779,10 +1976,39 @@ void qStreamCloseTsdbReader(void* task) { SStreamScanInfo* pInfo = pDownstreamOp->info; if (pInfo->pTableScanOp) { STableScanInfo* pTSInfo = pInfo->pTableScanOp->info; + + setOperatorCompleted(pInfo->pTableScanOp); + while (pTaskInfo->owner != 0) { + taosMsleep(100); + qDebug("wait for the reader stopping"); + } + tsdbReaderClose(pTSInfo->base.dataReader); pTSInfo->base.dataReader = NULL; + + // restore the status, todo refactor. + pInfo->pTableScanOp->status = OP_OPENED; + pTaskInfo->status = TASK_NOT_COMPLETED; return; } } } } + +static void extractTableList(SArray* pList, const SOperatorInfo* pOperator) { + if (pOperator->operatorType == QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN) { + STableScanInfo* pScanInfo = pOperator->info; + taosArrayPush(pList, &pScanInfo->base.pTableListInfo); + } else { + if (pOperator->pDownstream != NULL && pOperator->pDownstream[0] != NULL) { + extractTableList(pList, pOperator->pDownstream[0]); + } + } +} + +SArray* getTableListInfo(const SExecTaskInfo* pTaskInfo) { + SArray* pArray = taosArrayInit(0, POINTER_BYTES); + SOperatorInfo* pOperator = pTaskInfo->pRoot; + extractTableList(pArray, pOperator); + return pArray; +} \ No newline at end of file diff --git a/source/libs/executor/src/filloperator.c b/source/libs/executor/src/filloperator.c index 0ce5390d50391d447d8260bdb79a219a3c063bf4..0ff0c81f8008ee359070bca3a20ee2bc16cb1d8b 100644 --- a/source/libs/executor/src/filloperator.c +++ b/source/libs/executor/src/filloperator.c @@ -449,9 +449,14 @@ void* destroyStreamFillSupporter(SStreamFillSupporter* pFillSup) { return NULL; } +void destroySPoint(void* ptr) { + SPoint* point = (SPoint*) ptr; + taosMemoryFreeClear(point->val); +} + void* destroyStreamFillLinearInfo(SStreamFillLinearInfo* pFillLinear) { - taosArrayDestroy(pFillLinear->pDeltaVal); - taosArrayDestroy(pFillLinear->pNextDeltaVal); + taosArrayDestroyEx(pFillLinear->pEndPoints, destroySPoint); + taosArrayDestroyEx(pFillLinear->pNextEndPoints, destroySPoint); taosMemoryFree(pFillLinear); return NULL; } @@ -613,19 +618,15 @@ static void calcDeltaData(SSDataBlock* pBlock, int32_t rowId, SResultRowData* pR } } -static void calcRowDeltaData(SResultRowData* pStartRow, SResultRowData* pEndRow, SArray* pDelta, SFillColInfo* pFillCol, - int32_t numOfCol, int32_t winCount) { +static void calcRowDeltaData(SResultRowData* pEndRow, SArray* pEndPoins, SFillColInfo* pFillCol, + int32_t numOfCol) { for (int32_t i = 0; i < numOfCol; i++) { if (!pFillCol[i].notFillCol) { int32_t slotId = GET_DEST_SLOT_ID(pFillCol + i); - SResultCellData* pSCell = getResultCell(pStartRow, slotId); - double start = 0.0; - GET_TYPED_DATA(start, double, pSCell->type, pSCell->pData); SResultCellData* pECell = getResultCell(pEndRow, slotId); - double end = 0.0; - GET_TYPED_DATA(end, double, pECell->type, pECell->pData); - double delta = (end - start) / winCount; - taosArraySet(pDelta, slotId, &delta); + SPoint* pPoint = taosArrayGet(pEndPoins, slotId); + pPoint->key = pEndRow->key; + memcpy(pPoint->val, pECell->pData, pECell->bytes); } } } @@ -676,10 +677,8 @@ void setDeleteFillValueInfo(TSKEY start, TSKEY end, SStreamFillSupporter* pFillS setFillKeyInfo(pFillSup->prev.key, pFillSup->next.key, &pFillSup->interval, pFillInfo); pFillInfo->pLinearInfo->hasNext = false; pFillInfo->pLinearInfo->nextEnd = INT64_MIN; - int32_t numOfWins = taosTimeCountInterval(pFillSup->prev.key, pFillSup->next.key, pFillSup->interval.sliding, - pFillSup->interval.slidingUnit, pFillSup->interval.precision); - calcRowDeltaData(&pFillSup->prev, &pFillSup->next, pFillInfo->pLinearInfo->pDeltaVal, pFillSup->pAllColInfo, - pFillSup->numOfAllCols, numOfWins); + calcRowDeltaData(&pFillSup->next, pFillInfo->pLinearInfo->pEndPoints, pFillSup->pAllColInfo, + pFillSup->numOfAllCols); pFillInfo->pResRow = &pFillSup->prev; pFillInfo->pLinearInfo->winIndex = 0; } break; @@ -782,25 +781,19 @@ void setFillValueInfo(SSDataBlock* pBlock, TSKEY ts, int32_t rowId, SStreamFillS setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); pFillInfo->pos = FILL_POS_MID; pFillInfo->pLinearInfo->nextEnd = nextWKey; - int32_t numOfWins = taosTimeCountInterval(prevWKey, ts, pFillSup->interval.sliding, - pFillSup->interval.slidingUnit, pFillSup->interval.precision); - calcRowDeltaData(&pFillSup->prev, &pFillSup->cur, pFillInfo->pLinearInfo->pDeltaVal, pFillSup->pAllColInfo, - pFillSup->numOfAllCols, numOfWins); + calcRowDeltaData(&pFillSup->cur, pFillInfo->pLinearInfo->pEndPoints, pFillSup->pAllColInfo, + pFillSup->numOfAllCols); pFillInfo->pResRow = &pFillSup->prev; - numOfWins = taosTimeCountInterval(ts, nextWKey, pFillSup->interval.sliding, pFillSup->interval.slidingUnit, - pFillSup->interval.precision); - calcRowDeltaData(&pFillSup->cur, &pFillSup->next, pFillInfo->pLinearInfo->pNextDeltaVal, pFillSup->pAllColInfo, - pFillSup->numOfAllCols, numOfWins); + calcRowDeltaData(&pFillSup->next, pFillInfo->pLinearInfo->pNextEndPoints, pFillSup->pAllColInfo, + pFillSup->numOfAllCols); pFillInfo->pLinearInfo->hasNext = true; } else if (hasPrevWindow(pFillSup)) { setFillKeyInfo(prevWKey, ts, &pFillSup->interval, pFillInfo); pFillInfo->pos = FILL_POS_END; pFillInfo->pLinearInfo->nextEnd = INT64_MIN; - int32_t numOfWins = taosTimeCountInterval(prevWKey, ts, pFillSup->interval.sliding, - pFillSup->interval.slidingUnit, pFillSup->interval.precision); - calcRowDeltaData(&pFillSup->prev, &pFillSup->cur, pFillInfo->pLinearInfo->pDeltaVal, pFillSup->pAllColInfo, - pFillSup->numOfAllCols, numOfWins); + calcRowDeltaData(&pFillSup->cur, pFillInfo->pLinearInfo->pEndPoints, pFillSup->pAllColInfo, + pFillSup->numOfAllCols); pFillInfo->pResRow = &pFillSup->prev; pFillInfo->pLinearInfo->hasNext = false; } else { @@ -808,10 +801,8 @@ void setFillValueInfo(SSDataBlock* pBlock, TSKEY ts, int32_t rowId, SStreamFillS setFillKeyInfo(ts, nextWKey, &pFillSup->interval, pFillInfo); pFillInfo->pos = FILL_POS_START; pFillInfo->pLinearInfo->nextEnd = INT64_MIN; - int32_t numOfWins = taosTimeCountInterval(ts, nextWKey, pFillSup->interval.sliding, - pFillSup->interval.slidingUnit, pFillSup->interval.precision); - calcRowDeltaData(&pFillSup->cur, &pFillSup->next, pFillInfo->pLinearInfo->pDeltaVal, pFillSup->pAllColInfo, - pFillSup->numOfAllCols, numOfWins); + calcRowDeltaData(&pFillSup->next, pFillInfo->pLinearInfo->pEndPoints, pFillSup->pAllColInfo, + pFillSup->numOfAllCols); pFillInfo->pResRow = &pFillSup->cur; pFillInfo->pLinearInfo->hasNext = false; } @@ -908,13 +899,18 @@ static void doStreamFillLinear(SStreamFillSupporter* pFillSup, SStreamFillInfo* colDataSetNULL(pColData, index); continue; } - double* pDelta = taosArrayGet(pFillInfo->pLinearInfo->pDeltaVal, slotId); + SPoint* pEnd = taosArrayGet(pFillInfo->pLinearInfo->pEndPoints, slotId); double vCell = 0; - GET_TYPED_DATA(vCell, double, pCell->type, pCell->pData); - vCell += (*pDelta) * pFillInfo->pLinearInfo->winIndex; - int64_t result = 0; - SET_TYPED_DATA(&result, pCell->type, vCell); - colDataSetVal(pColData, index, (const char*)&result, false); + SPoint start = {0}; + start.key = pFillInfo->pResRow->key; + start.val = pCell->pData; + + SPoint cur = {0}; + cur.key = pFillInfo->current; + cur.val = taosMemoryCalloc(1, pCell->bytes); + taosGetLinearInterpolationVal(&cur, pCell->type, &start, pEnd, pCell->type); + colDataSetVal(pColData, index, (const char*)cur.val, false); + destroySPoint(&cur); } } pFillInfo->current = taosTimeAdd(pFillInfo->current, pFillSup->interval.sliding, pFillSup->interval.slidingUnit, @@ -955,8 +951,7 @@ static void doStreamFillRange(SStreamFillInfo* pFillInfo, SStreamFillSupporter* if (pFillInfo->current > pFillInfo->end && pFillInfo->pLinearInfo->hasNext) { pFillInfo->pLinearInfo->hasNext = false; pFillInfo->pLinearInfo->winIndex = 0; - taosArrayClear(pFillInfo->pLinearInfo->pDeltaVal); - taosArrayAddAll(pFillInfo->pLinearInfo->pDeltaVal, pFillInfo->pLinearInfo->pNextDeltaVal); + taosArraySwap(pFillInfo->pLinearInfo->pEndPoints, pFillInfo->pLinearInfo->pNextEndPoints); pFillInfo->pResRow = &pFillSup->cur; setFillKeyInfo(pFillSup->cur.key, pFillInfo->pLinearInfo->nextEnd, &pFillSup->interval, pFillInfo); doStreamFillLinear(pFillSup, pFillInfo, pRes); @@ -1362,15 +1357,19 @@ SStreamFillInfo* initStreamFillInfo(SStreamFillSupporter* pFillSup, SSDataBlock* pFillInfo->pLinearInfo = taosMemoryCalloc(1, sizeof(SStreamFillLinearInfo)); pFillInfo->pLinearInfo->hasNext = false; pFillInfo->pLinearInfo->nextEnd = INT64_MIN; - pFillInfo->pLinearInfo->pDeltaVal = NULL; - pFillInfo->pLinearInfo->pNextDeltaVal = NULL; + pFillInfo->pLinearInfo->pEndPoints = NULL; + pFillInfo->pLinearInfo->pNextEndPoints = NULL; if (pFillSup->type == TSDB_FILL_LINEAR) { - pFillInfo->pLinearInfo->pDeltaVal = taosArrayInit(pFillSup->numOfAllCols, sizeof(double)); - pFillInfo->pLinearInfo->pNextDeltaVal = taosArrayInit(pFillSup->numOfAllCols, sizeof(double)); + pFillInfo->pLinearInfo->pEndPoints = taosArrayInit(pFillSup->numOfAllCols, sizeof(SPoint)); + pFillInfo->pLinearInfo->pNextEndPoints = taosArrayInit(pFillSup->numOfAllCols, sizeof(SPoint)); for (int32_t i = 0; i < pFillSup->numOfAllCols; i++) { - double value = 0.0; - taosArrayPush(pFillInfo->pLinearInfo->pDeltaVal, &value); - taosArrayPush(pFillInfo->pLinearInfo->pNextDeltaVal, &value); + SColumnInfoData* pColData = taosArrayGet(pRes->pDataBlock, i); + SPoint value = {0}; + value.val = taosMemoryCalloc(1, pColData->info.bytes); + taosArrayPush(pFillInfo->pLinearInfo->pEndPoints, &value); + + value.val = taosMemoryCalloc(1, pColData->info.bytes); + taosArrayPush(pFillInfo->pLinearInfo->pNextEndPoints, &value); } } pFillInfo->pLinearInfo->winIndex = 0; diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c index 9537a76bd679f03f0fa0c675eec9c4e05cb8db22..6546bfff89bd904c5cb342db2875423ad7324f5e 100644 --- a/source/libs/executor/src/groupoperator.c +++ b/source/libs/executor/src/groupoperator.c @@ -173,9 +173,14 @@ static void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSData size_t numOfGroupCols = taosArrayGetSize(pGroupCols); for (int32_t i = 0; i < numOfGroupCols; ++i) { - SColumn* pCol = taosArrayGet(pGroupCols, i); + SColumn* pCol = (SColumn*) taosArrayGet(pGroupCols, i); SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, pCol->slotId); + // valid range check. todo: return error code. + if (pCol->slotId > taosArrayGetSize(pBlock->pDataBlock)) { + continue; + } + if (pBlock->pBlockAgg != NULL) { pColAgg = pBlock->pBlockAgg[pCol->slotId]; // TODO is agg data matched? } @@ -277,6 +282,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) { terrno = TSDB_CODE_SUCCESS; int32_t num = 0; + uint64_t groupId = 0; for (int32_t j = 0; j < pBlock->info.rows; ++j) { // Compare with the previous row of this column, and do not set the output buffer again if they are identical. if (!pInfo->isInit) { @@ -473,6 +479,8 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode* initResultRowInfo(&pInfo->binfo.resultRowInfo); setOperatorInfo(pOperator, "GroupbyAggOperator", 0, true, OP_NOT_OPENED, pInfo, pTaskInfo); + pInfo->binfo.mergeResultBlock = pAggNode->mergeDataBlock; + pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, hashGroupbyAggregate, NULL, destroyGroupOperatorInfo, optrDefaultBufFn, NULL); code = appendDownstream(pOperator, &downstream, 1); @@ -917,7 +925,7 @@ int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx; SResultRow* pResultRow = - doSetResultOutBufByKey(pBuf, pResultRowInfo, (char*)pData, bytes, true, groupId, pTaskInfo, false, pAggSup); + doSetResultOutBufByKey(pBuf, pResultRowInfo, (char*)pData, bytes, true, groupId, pTaskInfo, false, pAggSup, false); assert(pResultRow != NULL); setResultRowInitCtx(pResultRow, pCtx, numOfCols, pOperator->exprSupp.rowEntryInfoOffset); diff --git a/source/libs/executor/src/projectoperator.c b/source/libs/executor/src/projectoperator.c index 49bc5af634b82c410e903d023d8c1e5e62b9d3fd..c943270df9dff636b90c9e955b0030c49eb0a5a2 100644 --- a/source/libs/executor/src/projectoperator.c +++ b/source/libs/executor/src/projectoperator.c @@ -161,10 +161,9 @@ static int32_t discardGroupDataBlock(SSDataBlock* pBlock, SLimitInfo* pLimitInfo if (pLimitInfo->remainGroupOffset > 0) { return PROJECT_RETRIEVE_CONTINUE; } - } - // set current group id of the project operator - pLimitInfo->currentGroupId = pBlock->info.id.groupId; + pLimitInfo->currentGroupId = 0; + } } return PROJECT_RETRIEVE_DONE; @@ -175,19 +174,29 @@ static int32_t setInfoForNewGroup(SSDataBlock* pBlock, SLimitInfo* pLimitInfo, S // here check for a new group data, we need to handle the data of the previous group. ASSERT(pLimitInfo->remainGroupOffset == 0 || pLimitInfo->remainGroupOffset == -1); - if (pLimitInfo->currentGroupId != 0 && pLimitInfo->currentGroupId != pBlock->info.id.groupId) { + bool newGroup = false; + if (0 == pBlock->info.id.groupId) { + pLimitInfo->numOfOutputGroups = 1; + } else if (pLimitInfo->currentGroupId != pBlock->info.id.groupId) { + pLimitInfo->currentGroupId = pBlock->info.id.groupId; pLimitInfo->numOfOutputGroups += 1; - if ((pLimitInfo->slimit.limit > 0) && (pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) { - setOperatorCompleted(pOperator); - return PROJECT_RETRIEVE_DONE; - } + newGroup = true; + } else { + return PROJECT_RETRIEVE_CONTINUE; + } - // reset the value for a new group data - // existing rows that belongs to previous group. - resetLimitInfoForNextGroup(pLimitInfo); + if ((pLimitInfo->slimit.limit >= 0) && (pLimitInfo->slimit.limit < pLimitInfo->numOfOutputGroups)) { + setOperatorCompleted(pOperator); + return PROJECT_RETRIEVE_DONE; } - return PROJECT_RETRIEVE_DONE; + // reset the value for a new group data + // existing rows that belongs to previous group. + if (newGroup) { + resetLimitInfoForNextGroup(pLimitInfo); + } + + return PROJECT_RETRIEVE_CONTINUE; } // todo refactor @@ -199,7 +208,7 @@ static int32_t doIngroupLimitOffset(SLimitInfo* pLimitInfo, uint64_t groupId, SS if (pBlock->info.rows == 0) { return PROJECT_RETRIEVE_CONTINUE; } else { - if (limitReached && (pLimitInfo->slimit.limit > 0 && pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) { + if (limitReached && (pLimitInfo->slimit.limit >= 0 && pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) { setOperatorCompleted(pOperator); } } @@ -262,7 +271,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { return NULL; } } - qDebug("set op close, exec %d, status %d rows %d", pTaskInfo->execModel, pOperator->status, + qDebug("set op close, exec %d, status %d rows %" PRId64 , pTaskInfo->execModel, pOperator->status, pFinalRes->info.rows); setOperatorCompleted(pOperator); break; @@ -328,7 +337,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) { // when apply the limit/offset for each group, pRes->info.rows may be 0, due to limit constraint. if (pFinalRes->info.rows > 0 || (pOperator->status == OP_EXEC_DONE)) { - qDebug("project return %d rows, status %d", pFinalRes->info.rows, pOperator->status); + qDebug("project return %" PRId64 " rows, status %d", pFinalRes->info.rows, pOperator->status); break; } } else { @@ -580,7 +589,7 @@ void setFunctionResultOutput(SOperatorInfo* pOperator, SOptrBasicInfo* pInfo, SA int64_t tid = 0; int64_t groupId = 0; SResultRow* pRow = doSetResultOutBufByKey(pSup->pResultBuf, pResultRowInfo, (char*)&tid, sizeof(tid), true, groupId, - pTaskInfo, false, pSup); + pTaskInfo, false, pSup, true); for (int32_t i = 0; i < numOfExprs; ++i) { struct SResultRowEntryInfo* pEntry = getResultEntryInfo(pRow, i, rowEntryInfoOffset); diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index b8d293bdf62cae1d37de10c40ca5d6ad0f5e1d3d..e1e861c7c8f27629accc4edd5d9b98642b95750c 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -31,6 +31,9 @@ #include "thash.h" #include "ttypes.h" +int32_t scanDebug = 0; + +#define MULTI_READER_MAX_TABLE_NUM 5000 #define SET_REVERSE_SCAN_FLAG(_info) ((_info)->scanFlag = REVERSE_SCAN) #define SWITCH_ORDER(n) (((n) = ((n) == TSDB_ORDER_ASC) ? TSDB_ORDER_DESC : TSDB_ORDER_ASC)) @@ -44,6 +47,8 @@ typedef struct STableMergeScanSortSourceParam { int32_t readerIdx; uint64_t uid; SSDataBlock* inputBlock; + bool multiReader; + STsdbReader* dataReader; } STableMergeScanSortSourceParam; static bool processBlockWithProbability(const SSampleExecInfo* pInfo); @@ -85,7 +90,7 @@ static void getNextTimeWindow(SInterval* pInterval, STimeWindow* tw, int32_t ord struct tm tm; time_t t = (time_t)key; - taosLocalTime(&t, &tm); + taosLocalTime(&t, &tm, NULL); int mon = (int)(tm.tm_year * 12 + tm.tm_mon + interval * factor); tm.tm_year = mon / 12; @@ -305,15 +310,16 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca taosMemoryFreeClear(pBlock->pBlockAgg); if (*status == FUNC_DATA_REQUIRED_FILTEROUT) { - qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), + qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%" PRId64, GET_TASKID(pTaskInfo), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); pCost->filterOutBlocks += 1; pCost->totalRows += pBlock->info.rows; tsdbReleaseDataBlock(pTableScanInfo->dataReader); return TSDB_CODE_SUCCESS; } else if (*status == FUNC_DATA_REQUIRED_NOT_LOAD) { - qDebug("%s data block skipped, brange:%" PRId64 "-%" PRId64 ", rows:%d, uid:%" PRIu64, GET_TASKID(pTaskInfo), - pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, pBlockInfo->id.uid); + qDebug("%s data block skipped, brange:%" PRId64 "-%" PRId64 ", rows:%" PRId64 ", uid:%" PRIu64, + GET_TASKID(pTaskInfo), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, + pBlockInfo->id.uid); doSetTagColumnData(pTableScanInfo, pBlock, pTaskInfo, 1); pCost->skipBlocks += 1; tsdbReleaseDataBlock(pTableScanInfo->dataReader); @@ -323,7 +329,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca loadSMA = true; // mark the operation of load sma; bool success = doLoadBlockSMA(pTableScanInfo, pBlock, pTaskInfo); if (success) { // failed to load the block sma data, data block statistics does not exist, load data block instead - qDebug("%s data block SMA loaded, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), + qDebug("%s data block SMA loaded, brange:%" PRId64 "-%" PRId64 ", rows:%" PRId64, GET_TASKID(pTaskInfo), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); doSetTagColumnData(pTableScanInfo, pBlock, pTaskInfo, 1); tsdbReleaseDataBlock(pTableScanInfo->dataReader); @@ -343,8 +349,8 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca size_t size = taosArrayGetSize(pBlock->pDataBlock); bool keep = doFilterByBlockSMA(pOperator->exprSupp.pFilterInfo, pBlock->pBlockAgg, size, pBlockInfo->rows); if (!keep) { - qDebug("%s data block filter out by block SMA, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), - pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); + qDebug("%s data block filter out by block SMA, brange:%" PRId64 "-%" PRId64 ", rows:%" PRId64, + GET_TASKID(pTaskInfo), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); pCost->filterOutBlocks += 1; (*status) = FUNC_DATA_REQUIRED_FILTEROUT; @@ -360,8 +366,8 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca // try to filter data block according to current results doDynamicPruneDataBlock(pOperator, pBlockInfo, status); if (*status == FUNC_DATA_REQUIRED_NOT_LOAD) { - qDebug("%s data block skipped due to dynamic prune, brange:%" PRId64 "-%" PRId64 ", rows:%d", GET_TASKID(pTaskInfo), - pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); + qDebug("%s data block skipped due to dynamic prune, brange:%" PRId64 "-%" PRId64 ", rows:%" PRId64, + GET_TASKID(pTaskInfo), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows); pCost->skipBlocks += 1; tsdbReleaseDataBlock(pTableScanInfo->dataReader); *status = FUNC_DATA_REQUIRED_FILTEROUT; @@ -391,7 +397,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanBase* pTableSca if (pBlock->info.rows == 0) { pCost->filterOutBlocks += 1; - qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%d, elapsed time:%.2f ms", + qDebug("%s data block filter out, brange:%" PRId64 "-%" PRId64 ", rows:%" PRId64 ", elapsed time:%.2f ms", GET_TASKID(pTaskInfo), pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows, el); } else { qDebug("%s data block filter applied, elapsed time:%.2f ms", GET_TASKID(pTaskInfo), el); @@ -581,10 +587,16 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, const SExprInfo* pExpr, int if (isNullVal) { colDataSetNNULL(pColInfoData, 0, pBlock->info.rows); } else if (pColInfoData->info.type != TSDB_DATA_TYPE_JSON) { - colDataSetNItems(pColInfoData, 0, data, pBlock->info.rows); + code = colDataSetNItems(pColInfoData, 0, data, pBlock->info.rows, false); if (IS_VAR_DATA_TYPE(((const STagVal*)p)->type)) { taosMemoryFree(data); } + if (code) { + if (freeReader) { + metaReaderClear(&mr); + } + return code; + } } else { // todo opt for json tag for (int32_t i = 0; i < pBlock->info.rows; ++i) { colDataSetVal(pColInfoData, i, data, false); @@ -631,10 +643,22 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { STableScanInfo* pTableScanInfo = pOperator->info; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SSDataBlock* pBlock = pTableScanInfo->pResBlock; + bool hasNext = false; + int32_t code = TSDB_CODE_SUCCESS; int64_t st = taosGetTimestampUs(); - while (tsdbNextDataBlock(pTableScanInfo->base.dataReader)) { + while (true) { + code = tsdbNextDataBlock(pTableScanInfo->base.dataReader, &hasNext); + if (code) { + tsdbReleaseDataBlock(pTableScanInfo->base.dataReader); + T_LONG_JMP(pTaskInfo->env, code); + } + + if (!hasNext) { + break; + } + if (isTaskKilled(pTaskInfo)) { tsdbReleaseDataBlock(pTableScanInfo->base.dataReader); T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); @@ -651,8 +675,9 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { continue; } - ASSERT(pBlock->info.id.uid != 0); - pBlock->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBlock->info.id.uid); + if (pBlock->info.id.uid) { + pBlock->info.id.groupId = getTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid); + } uint32_t status = 0; int32_t code = loadDataBlock(pOperator, &pTableScanInfo->base, pBlock, &status); @@ -677,7 +702,6 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) { pTaskInfo->streamInfo.lastStatus.uid = pBlock->info.id.uid; pTaskInfo->streamInfo.lastStatus.ts = pBlock->info.window.ekey; - ASSERT(pBlock->info.id.uid != 0); return pBlock; } return NULL; @@ -747,42 +771,51 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) { // scan table one by one sequentially if (pInfo->scanMode == TABLE_SCAN__TABLE_ORDER) { - int32_t numOfTables = tableListGetSize(pTaskInfo->pTableInfoList); + int32_t numOfTables = 0; // tableListGetSize(pTaskInfo->pTableListInfo); + STableKeyInfo tInfo = {0}; while (1) { SSDataBlock* result = doGroupedTableScan(pOperator); - if (result) { + if (result || (pOperator->status == OP_EXEC_DONE) || isTaskKilled(pTaskInfo)) { return result; } // if no data, switch to next table and continue scan pInfo->currentTable++; + + taosRLockLatch(&pTaskInfo->lock); + numOfTables = tableListGetSize(pInfo->base.pTableListInfo); + if (pInfo->currentTable >= numOfTables) { + qDebug("all table checked in table list, total:%d, return NULL, %s", numOfTables, GET_TASKID(pTaskInfo)); + taosRUnLockLatch(&pTaskInfo->lock); return NULL; } - STableKeyInfo* pTableInfo = tableListGetInfo(pTaskInfo->pTableInfoList, pInfo->currentTable); - tsdbSetTableList(pInfo->base.dataReader, pTableInfo, 1); - qDebug("set uid:%" PRIu64 " into scanner, total tables:%d, index:%d %s", pTableInfo->uid, numOfTables, - pInfo->currentTable, pTaskInfo->id.str); + tInfo = *(STableKeyInfo*)tableListGetInfo(pInfo->base.pTableListInfo, pInfo->currentTable); + taosRUnLockLatch(&pTaskInfo->lock); + + tsdbSetTableList(pInfo->base.dataReader, &tInfo, 1); + qDebug("set uid:%" PRIu64 " into scanner, total tables:%d, index:%d/%d %s", tInfo.uid, numOfTables, + pInfo->currentTable, numOfTables, GET_TASKID(pTaskInfo)); tsdbReaderReset(pInfo->base.dataReader, &pInfo->base.cond); pInfo->scanTimes = 0; } } else { // scan table group by group sequentially if (pInfo->currentGroupId == -1) { - if ((++pInfo->currentGroupId) >= tableListGetOutputGroups(pTaskInfo->pTableInfoList)) { + if ((++pInfo->currentGroupId) >= tableListGetOutputGroups(pInfo->base.pTableListInfo)) { setOperatorCompleted(pOperator); return NULL; } int32_t num = 0; STableKeyInfo* pList = NULL; - tableListGetGroupList(pTaskInfo->pTableInfoList, pInfo->currentGroupId, &pList, &num); + tableListGetGroupList(pInfo->base.pTableListInfo, pInfo->currentGroupId, &pList, &num); ASSERT(pInfo->base.dataReader == NULL); int32_t code = tsdbReaderOpen(pInfo->base.readHandle.vnode, &pInfo->base.cond, pList, num, pInfo->pResBlock, - (STsdbReader**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo)); + (STsdbReader**)&pInfo->base.dataReader, GET_TASKID(pTaskInfo), pInfo->countOnly); if (code != TSDB_CODE_SUCCESS) { T_LONG_JMP(pTaskInfo->env, code); } @@ -794,11 +827,10 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) { SSDataBlock* result = doGroupedTableScan(pOperator); if (result != NULL) { - ASSERT(result->info.id.uid != 0); return result; } - if ((++pInfo->currentGroupId) >= tableListGetOutputGroups(pTaskInfo->pTableInfoList)) { + if ((++pInfo->currentGroupId) >= tableListGetOutputGroups(pInfo->base.pTableListInfo)) { setOperatorCompleted(pOperator); return NULL; } @@ -809,7 +841,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) { int32_t num = 0; STableKeyInfo* pList = NULL; - tableListGetGroupList(pTaskInfo->pTableInfoList, pInfo->currentGroupId, &pList, &num); + tableListGetGroupList(pInfo->base.pTableListInfo, pInfo->currentGroupId, &pList, &num); tsdbSetTableList(pInfo->base.dataReader, pList, num); tsdbReaderReset(pInfo->base.dataReader, &pInfo->base.cond); @@ -834,25 +866,30 @@ static int32_t getTableScannerExecInfo(struct SOperatorInfo* pOptr, void** pOptr return 0; } -static void destroyTableScanOperatorInfo(void* param) { - STableScanInfo* pTableScanInfo = (STableScanInfo*)param; - blockDataDestroy(pTableScanInfo->pResBlock); - cleanupQueryTableDataCond(&pTableScanInfo->base.cond); +static void destroyTableScanBase(STableScanBase* pBase) { + cleanupQueryTableDataCond(&pBase->cond); - tsdbReaderClose(pTableScanInfo->base.dataReader); - pTableScanInfo->base.dataReader = NULL; + tsdbReaderClose(pBase->dataReader); + pBase->dataReader = NULL; - if (pTableScanInfo->base.matchInfo.pList != NULL) { - taosArrayDestroy(pTableScanInfo->base.matchInfo.pList); + if (pBase->matchInfo.pList != NULL) { + taosArrayDestroy(pBase->matchInfo.pList); } - taosLRUCacheCleanup(pTableScanInfo->base.metaCache.pTableMetaEntryCache); - cleanupExprSupp(&pTableScanInfo->base.pseudoSup); + tableListDestroy(pBase->pTableListInfo); + taosLRUCacheCleanup(pBase->metaCache.pTableMetaEntryCache); + cleanupExprSupp(&pBase->pseudoSup); +} + +static void destroyTableScanOperatorInfo(void* param) { + STableScanInfo* pTableScanInfo = (STableScanInfo*)param; + blockDataDestroy(pTableScanInfo->pResBlock); + destroyTableScanBase(&pTableScanInfo->base); taosMemoryFreeClear(param); } SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle, - SExecTaskInfo* pTaskInfo) { + STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) { STableScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -908,12 +945,17 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, pTaskInfo); pOperator->exprSupp.numOfExprs = numOfCols; + pInfo->base.pTableListInfo = pTableListInfo; pInfo->base.metaCache.pTableMetaEntryCache = taosLRUCacheInit(1024 * 128, -1, .5); if (pInfo->base.metaCache.pTableMetaEntryCache == NULL) { code = terrno; goto _error; } + if (scanDebug) { + pInfo->countOnly = true; + } + taosLRUCacheSetStrictCapacity(pInfo->base.metaCache.pTableMetaEntryCache, false); pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, doTableScan, NULL, destroyTableScanOperatorInfo, optrDefaultBufFn, getTableScannerExecInfo); @@ -985,6 +1027,7 @@ void resetTableScanInfo(STableScanInfo* pTableScanInfo, STimeWindow* pWin) { pTableScanInfo->scanTimes = 0; pTableScanInfo->currentGroupId = -1; tsdbReaderClose(pTableScanInfo->base.dataReader); + qDebug("1"); pTableScanInfo->base.dataReader = NULL; } @@ -1004,21 +1047,29 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU SSDataBlock* pBlock = pTableScanInfo->pResBlock; STsdbReader* pReader = NULL; int32_t code = tsdbReaderOpen(pTableScanInfo->base.readHandle.vnode, &cond, &tblInfo, 1, pBlock, - (STsdbReader**)&pReader, GET_TASKID(pTaskInfo)); + (STsdbReader**)&pReader, GET_TASKID(pTaskInfo), false); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + T_LONG_JMP(pTaskInfo->env, code); + return NULL; + } + + bool hasNext = false; + code = tsdbNextDataBlock(pReader, &hasNext); if (code != TSDB_CODE_SUCCESS) { terrno = code; T_LONG_JMP(pTaskInfo->env, code); return NULL; } - if (tsdbNextDataBlock(pReader)) { + if (hasNext) { /*SSDataBlock* p = */ tsdbRetrieveDataBlock(pReader, NULL); doSetTagColumnData(&pTableScanInfo->base, pBlock, pTaskInfo, pBlock->info.rows); - pBlock->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBlock->info.id.uid); + pBlock->info.id.groupId = getTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid); } tsdbReaderClose(pReader); - qDebug("retrieve prev rows:%d, skey:%" PRId64 ", ekey:%" PRId64 " uid:%" PRIu64 ", max ver:%" PRId64 + qDebug("retrieve prev rows:%" PRId64 ", skey:%" PRId64 ", ekey:%" PRId64 " uid:%" PRIu64 ", max ver:%" PRId64 ", suid:%" PRIu64, pBlock->info.rows, startTs, endTs, tbUid, maxVersion, cond.suid); @@ -1035,7 +1086,8 @@ static uint64_t getGroupIdByCol(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, } static uint64_t getGroupIdByUid(SStreamScanInfo* pInfo, uint64_t uid) { - return getTableGroupId(pInfo->pTableScanOp->pTaskInfo->pTableInfoList, uid); + STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info; + return getTableGroupId(pTableScanInfo->base.pTableListInfo, uid); } static uint64_t getGroupIdByData(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion) { @@ -1144,6 +1196,7 @@ static SSDataBlock* doRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pSDB, int32 pInfo->updateWin = (STimeWindow){.skey = INT64_MIN, .ekey = INT64_MAX}; STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info; tsdbReaderClose(pTableScanInfo->base.dataReader); + qDebug("2"); pTableScanInfo->base.dataReader = NULL; return NULL; } @@ -1193,6 +1246,8 @@ static int32_t getPreSessionWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, if (code != TSDB_CODE_SUCCESS) { SET_SESSION_WIN_KEY_INVALID(pKey); } + + taosMemoryFree(pCur); return code; } @@ -1507,7 +1562,8 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock pInfo->pRes->info.type = STREAM_NORMAL; pInfo->pRes->info.version = pBlock->info.version; - pInfo->pRes->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBlock->info.id.uid); + STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info; + pInfo->pRes->info.id.groupId = getTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid); // todo extract method for (int32_t i = 0; i < taosArrayGetSize(pInfo->matchInfo.pList); ++i) { @@ -1563,19 +1619,15 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SStreamScanInfo* pInfo = pOperator->info; + const char* id = GET_TASKID(pTaskInfo); - qDebug("start to exec queue scan"); + qDebug("start to exec queue scan, %s", id); if (pTaskInfo->streamInfo.submit.msgStr != NULL) { if (pInfo->tqReader->msg2.msgStr == NULL) { - /*pInfo->tqReader->pMsg = pTaskInfo->streamInfo.pReq;*/ - - /*const SSubmitReq* pSubmit = pInfo->tqReader->pMsg;*/ - /*if (tqReaderSetDataMsg(pInfo->tqReader, pSubmit, 0) < 0) {*/ - /*void* msgStr = pTaskInfo->streamInfo.*/ SPackedData submit = pTaskInfo->streamInfo.submit; if (tqReaderSetSubmitReq2(pInfo->tqReader, submit.msgStr, submit.msgLen, submit.ver) < 0) { - qError("submit msg messed up when initing stream submit block %p", submit.msgStr); + qError("submit msg messed up when initing stream submit block %p, %s", submit.msgStr, id); pInfo->tqReader->msg2 = (SPackedData){0}; pInfo->tqReader->setMsg = 0; ASSERT(0); @@ -1609,18 +1661,20 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_DATA) { SSDataBlock* pResult = doTableScan(pInfo->pTableScanOp); if (pResult && pResult->info.rows > 0) { - qDebug("queue scan tsdb return %d rows min:%" PRId64 " max:%" PRId64 " wal curVersion:%" PRId64, + qDebug("queue scan tsdb return %" PRId64 " rows min:%" PRId64 " max:%" PRId64 " wal curVersion:%" PRId64 " %s", pResult->info.rows, pResult->info.window.skey, pResult->info.window.ekey, - pInfo->tqReader->pWalReader->curVersion); + pInfo->tqReader->pWalReader->curVersion, id); pTaskInfo->streamInfo.returned = 1; return pResult; } else { + // no data has return already, try to extract data in the WAL if (!pTaskInfo->streamInfo.returned) { STableScanInfo* pTSInfo = pInfo->pTableScanOp->info; tsdbReaderClose(pTSInfo->base.dataReader); pTSInfo->base.dataReader = NULL; tqOffsetResetToLog(&pTaskInfo->streamInfo.prepareStatus, pTaskInfo->streamInfo.snapshotVer); - qDebug("queue scan tsdb over, switch to wal ver %" PRId64 "", pTaskInfo->streamInfo.snapshotVer + 1); + + qDebug("queue scan tsdb over, switch to wal ver:%" PRId64 " %s", pTaskInfo->streamInfo.snapshotVer + 1, id); if (tqSeekVer(pInfo->tqReader, pTaskInfo->streamInfo.snapshotVer + 1, pTaskInfo->id.str) < 0) { tqOffsetResetToLog(&pTaskInfo->streamInfo.lastStatus, pTaskInfo->streamInfo.snapshotVer); return NULL; @@ -1634,10 +1688,12 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__LOG) { while (1) { SFetchRet ret = {0}; + terrno = 0; + if (tqNextBlock(pInfo->tqReader, &ret) < 0) { // if the end is reached, terrno is 0 if (terrno != 0) { - qError("failed to get next log block since %s", terrstr()); + qError("failed to get next log block since %s, %s", terrstr(), id); } } @@ -1646,15 +1702,12 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { setBlockIntoRes(pInfo, &ret.data, true); if (pInfo->pRes->info.rows > 0) { pOperator->status = OP_EXEC_RECV; - qDebug("queue scan log return %d rows", pInfo->pRes->info.rows); + qDebug("queue scan log return %" PRId64 " rows", pInfo->pRes->info.rows); return pInfo->pRes; } } else if (ret.fetchType == FETCH_TYPE__META) { qError("unexpected ret.fetchType:%d", ret.fetchType); continue; - // pTaskInfo->streamInfo.lastStatus = ret.offset; - // pTaskInfo->streamInfo.metaBlk = ret.meta; - // return NULL; } else if (ret.fetchType == FETCH_TYPE__NONE || (ret.fetchType == FETCH_TYPE__SEP && pOperator->status == OP_EXEC_RECV)) { pTaskInfo->streamInfo.lastStatus = ret.offset; @@ -1666,7 +1719,7 @@ static SSDataBlock* doQueueScan(SOperatorInfo* pOperator) { } } } else { - qError("unexpected streamInfo prepare type: %d", pTaskInfo->streamInfo.prepareStatus.type); + qError("unexpected streamInfo prepare type: %d %s", pTaskInfo->streamInfo.prepareStatus.type, id); return NULL; } } @@ -1755,8 +1808,8 @@ void streamScanOperatorDeocde(void* pBuff, int32_t len, SStreamScanInfo* pInfo) return; } - SUpdateInfo *pUpInfo = updateInfoInit(0, TSDB_TIME_PRECISION_MILLI, 0); - int32_t code = updateInfoDeserialize(pBuff, len, pUpInfo); + SUpdateInfo* pUpInfo = updateInfoInit(0, TSDB_TIME_PRECISION_MILLI, 0); + int32_t code = updateInfoDeserialize(pBuff, len, pUpInfo); if (code == TSDB_CODE_SUCCESS) { pInfo->pUpdateInfo = pUpInfo; } @@ -1789,6 +1842,8 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { /*resetTableScanInfo(pTSInfo, pWin);*/ tsdbReaderClose(pTSInfo->base.dataReader); + qDebug("4"); + pTSInfo->base.dataReader = NULL; pInfo->pTableScanOp->status = OP_OPENED; @@ -1815,8 +1870,18 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { generateScanRange(pInfo, pInfo->pUpdateDataRes, pInfo->pUpdateRes); prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex); pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE; + printDataBlock(pInfo->pUpdateRes, "recover update"); return pInfo->pUpdateRes; } break; + case STREAM_SCAN_FROM_DELETE_DATA: { + generateScanRange(pInfo, pInfo->pUpdateDataRes, pInfo->pUpdateRes); + prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex); + pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE; + copyDataBlock(pInfo->pDeleteDataRes, pInfo->pUpdateRes); + pInfo->pDeleteDataRes->info.type = STREAM_DELETE_DATA; + printDataBlock(pInfo->pDeleteDataRes, "recover delete"); + return pInfo->pDeleteDataRes; + } break; case STREAM_SCAN_FROM_DATAREADER_RANGE: { SSDataBlock* pSDB = doRangeScan(pInfo, pInfo->pUpdateRes, pInfo->primaryTsIndex, &pInfo->updateResIndex); if (pSDB) { @@ -1825,7 +1890,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { updateInfoSetScanRange(pInfo->pUpdateInfo, &pTableScanInfo->base.cond.twindows, pInfo->groupId, version); pSDB->info.type = pInfo->scanMode == STREAM_SCAN_FROM_DATAREADER_RANGE ? STREAM_NORMAL : STREAM_PULL_DATA; checkUpdateData(pInfo, true, pSDB, false); - // printDataBlock(pSDB, "stream scan update"); + printDataBlock(pSDB, "scan recover update"); calBlockTbName(pInfo, pSDB); return pSDB; } @@ -1850,15 +1915,18 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) { } if (pInfo->pCreateTbRes->info.rows > 0) { pInfo->scanMode = STREAM_SCAN_FROM_RES; + printDataBlock(pInfo->pCreateTbRes, "recover createTbl"); return pInfo->pCreateTbRes; } - qDebug("stream recover scan get block, rows %d", pInfo->pRecoverRes->info.rows); + qDebug("stream recover scan get block, rows %" PRId64, pInfo->pRecoverRes->info.rows); printDataBlock(pInfo->pRecoverRes, "scan recover"); return pInfo->pRecoverRes; } pTaskInfo->streamInfo.recoverStep = STREAM_RECOVER_STEP__NONE; STableScanInfo* pTSInfo = pInfo->pTableScanOp->info; tsdbReaderClose(pTSInfo->base.dataReader); + qDebug("5"); + pTSInfo->base.dataReader = NULL; pTSInfo->base.cond.startVersion = -1; @@ -2006,6 +2074,7 @@ FETCH_NEXT_BLOCK: copyDataBlock(pInfo->pUpdateRes, pSup->pScanBlock); blockDataCleanup(pSup->pScanBlock); prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex); + pInfo->pUpdateRes->info.type = STREAM_DELETE_DATA; return pInfo->pUpdateRes; } @@ -2022,7 +2091,7 @@ FETCH_NEXT_BLOCK: qDebug("stream scan return empty, consume block %d", totBlockNum); // void* buff = NULL; // int32_t len = streamScanOperatorEncode(pInfo, &buff); - //todo(liuyao) save buff + // todo(liuyao) save buff // taosMemoryFreeClear(buff); return NULL; } @@ -2083,7 +2152,7 @@ FETCH_NEXT_BLOCK: pOperator->resultInfo.totalRows += pBlockInfo->rows; // printDataBlock(pInfo->pRes, "stream scan"); - qDebug("scan rows: %d", pBlockInfo->rows); + qDebug("scan rows: %" PRId64, pBlockInfo->rows); if (pBlockInfo->rows > 0) { return pInfo->pRes; } @@ -2116,20 +2185,30 @@ static SSDataBlock* doRawScan(SOperatorInfo* pOperator) { // NOTE: this operator does never check if current status is done or not SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SStreamRawScanInfo* pInfo = pOperator->info; + int32_t code = TSDB_CODE_SUCCESS; pTaskInfo->streamInfo.metaRsp.metaRspLen = 0; // use metaRspLen !=0 to judge if data is meta pTaskInfo->streamInfo.metaRsp.metaRsp = NULL; qDebug("tmqsnap doRawScan called"); if (pTaskInfo->streamInfo.prepareStatus.type == TMQ_OFFSET__SNAPSHOT_DATA) { - if (pInfo->dataReader && tsdbNextDataBlock(pInfo->dataReader)) { + bool hasNext = false; + if (pInfo->dataReader) { + code = tsdbNextDataBlock(pInfo->dataReader, &hasNext); + if (code) { + tsdbReleaseDataBlock(pInfo->dataReader); + T_LONG_JMP(pTaskInfo->env, code); + } + } + + if (pInfo->dataReader && hasNext) { if (isTaskKilled(pTaskInfo)) { tsdbReleaseDataBlock(pInfo->dataReader); - longjmp(pTaskInfo->env, pTaskInfo->code); + T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); } SSDataBlock* pBlock = tsdbRetrieveDataBlock(pInfo->dataReader, NULL); if (pBlock == NULL) { - longjmp(pTaskInfo->env, terrno); + T_LONG_JMP(pTaskInfo->env, terrno); } qDebug("tmqsnap doRawScan get data uid:%" PRId64 "", pBlock->info.id.uid); @@ -2228,6 +2307,7 @@ static void destroyRawScanOperatorInfo(void* param) { SStreamRawScanInfo* pRawScan = (SStreamRawScanInfo*)param; tsdbReaderClose(pRawScan->dataReader); destroySnapContext(pRawScan->sContext); + tableListDestroy(pRawScan->pTableListInfo); taosMemoryFree(pRawScan); } @@ -2249,6 +2329,7 @@ SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, SExecTaskInfo* pT goto _end; } + pInfo->pTableListInfo = tableListCreate(); pInfo->vnode = pHandle->vnode; pInfo->sContext = pHandle->sContext; @@ -2267,9 +2348,11 @@ _end: static void destroyStreamScanOperatorInfo(void* param) { SStreamScanInfo* pStreamScan = (SStreamScanInfo*)param; + if (pStreamScan->pTableScanOp && pStreamScan->pTableScanOp->info) { destroyOperatorInfo(pStreamScan->pTableScanOp); } + if (pStreamScan->tqReader) { tqCloseReader(pStreamScan->tqReader); } @@ -2296,13 +2379,14 @@ static void destroyStreamScanOperatorInfo(void* param) { } SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhysiNode* pTableScanNode, SNode* pTagCond, - SExecTaskInfo* pTaskInfo) { + STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) { SArray* pColIds = NULL; SStreamScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; + tableListDestroy(pTableListInfo); goto _error; } @@ -2316,6 +2400,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys int32_t code = extractColMatchInfo(pScanPhyNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo); if (code != TSDB_CODE_SUCCESS) { + tableListDestroy(pTableListInfo); goto _error; } @@ -2335,11 +2420,14 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys SExprInfo* pSubTableExpr = taosMemoryCalloc(1, sizeof(SExprInfo)); if (pSubTableExpr == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; + tableListDestroy(pTableListInfo); goto _error; } + pInfo->tbnameCalSup.pExprInfo = pSubTableExpr; createExprFromOneNode(pSubTableExpr, pTableScanNode->pSubtable, 0); if (initExprSupp(&pInfo->tbnameCalSup, pSubTableExpr, 1) != 0) { + tableListDestroy(pTableListInfo); goto _error; } } @@ -2349,10 +2437,12 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys SExprInfo* pTagExpr = createExpr(pTableScanNode->pTags, &numOfTags); if (pTagExpr == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; + tableListDestroy(pTableListInfo); goto _error; } if (initExprSupp(&pInfo->tagCalSup, pTagExpr, numOfTags) != 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; + tableListDestroy(pTableListInfo); goto _error; } } @@ -2360,11 +2450,12 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->pBlockLists = taosArrayInit(4, sizeof(SPackedData)); if (pInfo->pBlockLists == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; + tableListDestroy(pTableListInfo); goto _error; } if (pHandle->vnode) { - SOperatorInfo* pTableScanOp = createTableScanOperatorInfo(pTableScanNode, pHandle, pTaskInfo); + SOperatorInfo* pTableScanOp = createTableScanOperatorInfo(pTableScanNode, pHandle, pTableListInfo, pTaskInfo); STableScanInfo* pTSInfo = (STableScanInfo*)pTableScanOp->info; if (pHandle->version > 0) { pTSInfo->base.cond.endVersion = pHandle->version; @@ -2372,7 +2463,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys STableKeyInfo* pList = NULL; int32_t num = 0; - tableListGetGroupList(pTaskInfo->pTableInfoList, 0, &pList, &num); + tableListGetGroupList(pTableListInfo, 0, &pList, &num); if (pHandle->initTableReader) { pTSInfo->scanMode = TABLE_SCAN__TABLE_ORDER; @@ -2403,16 +2494,18 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys // set the extract column id to streamHandle tqReaderSetColIdList(pInfo->tqReader, pColIds); - SArray* tableIdList = extractTableIdList(pTaskInfo->pTableInfoList); + SArray* tableIdList = extractTableIdList(((STableScanInfo*)(pInfo->pTableScanOp->info))->base.pTableListInfo); code = tqReaderSetTbUidList(pInfo->tqReader, tableIdList); if (code != 0) { taosArrayDestroy(tableIdList); goto _error; } + taosArrayDestroy(tableIdList); memcpy(&pTaskInfo->streamInfo.tableCond, &pTSInfo->base.cond, sizeof(SQueryTableDataCond)); } else { taosArrayDestroy(pColIds); + tableListDestroy(pTableListInfo); pColIds = NULL; } @@ -2443,8 +2536,8 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pInfo->igExpired = pTableScanNode->igExpired; pInfo->twAggSup.maxTs = INT64_MIN; - //todo(liuyao) get buff from rocks db; - void* buff = NULL; + // todo(liuyao) get buff from rocks db; + void* buff = NULL; int32_t len = 0; streamScanOperatorDeocde(buff, len, pInfo); @@ -2452,7 +2545,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys pTaskInfo); pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock); - __optr_fn_t nextFn = pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM ? doStreamScan : doQueueScan; + __optr_fn_t nextFn = (pTaskInfo->execModel == OPTR_EXEC_MODEL_STREAM) ? doStreamScan : doQueueScan; pOperator->fpSet = createOperatorFpSet(optrDummyOpenFn, nextFn, NULL, destroyStreamScanOperatorInfo, optrDefaultBufFn, NULL); @@ -2483,7 +2576,7 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator) { SSDataBlock* pRes = pInfo->pRes; blockDataCleanup(pRes); - int32_t size = tableListGetSize(pTaskInfo->pTableInfoList); + int32_t size = tableListGetSize(pInfo->pTableListInfo); if (size == 0) { setTaskStatus(pTaskInfo, TASK_COMPLETED); return NULL; @@ -2495,7 +2588,7 @@ static SSDataBlock* doTagScan(SOperatorInfo* pOperator) { metaReaderInit(&mr, pInfo->readHandle.meta, 0); while (pInfo->curPos < size && count < pOperator->resultInfo.capacity) { - STableKeyInfo* item = tableListGetInfo(pTaskInfo->pTableInfoList, pInfo->curPos); + STableKeyInfo* item = tableListGetInfo(pInfo->pTableListInfo, pInfo->curPos); int32_t code = metaGetTableEntryByUid(&mr, item->uid); tDecoderClear(&mr.coder); if (code != TSDB_CODE_SUCCESS) { @@ -2556,11 +2649,12 @@ static void destroyTagScanOperatorInfo(void* param) { STagScanInfo* pInfo = (STagScanInfo*)param; pInfo->pRes = blockDataDestroy(pInfo->pRes); taosArrayDestroy(pInfo->matchInfo.pList); + pInfo->pTableListInfo = tableListDestroy(pInfo->pTableListInfo); taosMemoryFreeClear(param); } SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode, - SExecTaskInfo* pTaskInfo) { + STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) { STagScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STagScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -2582,6 +2676,7 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi goto _error; } + pInfo->pTableListInfo = pTableListInfo; pInfo->pRes = createDataBlockFromDescNode(pDescNode); pInfo->readHandle = *pReadHandle; pInfo->curPos = 0; @@ -2610,24 +2705,41 @@ static SSDataBlock* getTableDataBlockImpl(void* param) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; int32_t readIdx = source->readerIdx; SSDataBlock* pBlock = source->inputBlock; + int32_t code = 0; SQueryTableDataCond* pQueryCond = taosArrayGet(pInfo->queryConds, readIdx); int64_t st = taosGetTimestampUs(); - void* p = tableListGetInfo(pTaskInfo->pTableInfoList, readIdx + pInfo->tableStartIndex); + void* p = tableListGetInfo(pInfo->base.pTableListInfo, readIdx + pInfo->tableStartIndex); SReadHandle* pHandle = &pInfo->base.readHandle; - int32_t code = - tsdbReaderOpen(pHandle->vnode, pQueryCond, p, 1, pBlock, &pInfo->base.dataReader, GET_TASKID(pTaskInfo)); - if (code != 0) { - T_LONG_JMP(pTaskInfo->env, code); + if (NULL == source->dataReader || !source->multiReader) { + code = tsdbReaderOpen(pHandle->vnode, pQueryCond, p, 1, pBlock, &source->dataReader, GET_TASKID(pTaskInfo), false); + if (code != 0) { + T_LONG_JMP(pTaskInfo->env, code); + } } + pInfo->base.dataReader = source->dataReader; STsdbReader* reader = pInfo->base.dataReader; + bool hasNext = false; qTrace("tsdb/read-table-data: %p, enter next reader", reader); - while (tsdbNextDataBlock(reader)) { + + while (true) { + code = tsdbNextDataBlock(reader, &hasNext); + if (code != 0) { + tsdbReleaseDataBlock(reader); + pInfo->base.dataReader = NULL; + T_LONG_JMP(pTaskInfo->env, code); + } + + if (!hasNext) { + break; + } + if (isTaskKilled(pTaskInfo)) { tsdbReleaseDataBlock(reader); + pInfo->base.dataReader = NULL; T_LONG_JMP(pTaskInfo->env, pTaskInfo->code); } @@ -2655,18 +2767,24 @@ static SSDataBlock* getTableDataBlockImpl(void* param) { continue; } - pBlock->info.id.groupId = getTableGroupId(pTaskInfo->pTableInfoList, pBlock->info.id.uid); + pBlock->info.id.groupId = getTableGroupId(pInfo->base.pTableListInfo, pBlock->info.id.uid); pOperator->resultInfo.totalRows += pBlock->info.rows; pInfo->base.readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0; qTrace("tsdb/read-table-data: %p, close reader", reader); - tsdbReaderClose(pInfo->base.dataReader); + if (!source->multiReader) { + tsdbReaderClose(pInfo->base.dataReader); + source->dataReader = NULL; + } pInfo->base.dataReader = NULL; return pBlock; } - tsdbReaderClose(pInfo->base.dataReader); + if (!source->multiReader) { + tsdbReaderClose(pInfo->base.dataReader); + source->dataReader = NULL; + } pInfo->base.dataReader = NULL; return NULL; } @@ -2705,10 +2823,10 @@ int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) { SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; { - size_t numOfTables = tableListGetSize(pTaskInfo->pTableInfoList); + size_t numOfTables = tableListGetSize(pInfo->base.pTableListInfo); int32_t i = pInfo->tableStartIndex + 1; for (; i < numOfTables; ++i) { - STableKeyInfo* tableKeyInfo = tableListGetInfo(pTaskInfo->pTableInfoList, i); + STableKeyInfo* tableKeyInfo = tableListGetInfo(pInfo->base.pTableListInfo, i); if (tableKeyInfo->groupId != pInfo->groupId) { break; } @@ -2738,6 +2856,7 @@ int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) { STableMergeScanSortSourceParam param = {0}; param.readerIdx = i; param.pOperator = pOperator; + param.multiReader = (numOfTable <= MULTI_READER_MAX_TABLE_NUM) ? true : false; param.inputBlock = createOneDataBlock(pInfo->pResBlock, false); blockDataEnsureCapacity(param.inputBlock, pOperator->resultInfo.capacity); @@ -2781,6 +2900,8 @@ int32_t stopGroupTableMergeScan(SOperatorInfo* pOperator) { for (int32_t i = 0; i < numOfTable; ++i) { STableMergeScanSortSourceParam* param = taosArrayGet(pInfo->sortSourceParams, i); blockDataDestroy(param->inputBlock); + tsdbReaderClose(param->dataReader); + param->dataReader = NULL; } taosArrayClear(pInfo->sortSourceParams); @@ -2820,12 +2941,9 @@ SSDataBlock* getSortedTableMergeScanBlockData(SSortHandle* pHandle, SSDataBlock* } bool limitReached = applyLimitOffset(&pInfo->limitInfo, pResBlock, pTaskInfo); - qDebug("%s get sorted row block, rows:%d, limit:%" PRId64, GET_TASKID(pTaskInfo), pResBlock->info.rows, + qDebug("%s get sorted row block, rows:%" PRId64 ", limit:%" PRId64, GET_TASKID(pTaskInfo), pResBlock->info.rows, pInfo->limitInfo.numOfOutputRows); - if (limitReached) { - resetLimitInfoForNextGroup(&pInfo->limitInfo); - } return (pResBlock->info.rows > 0) ? pResBlock : NULL; } @@ -2842,7 +2960,7 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) { T_LONG_JMP(pTaskInfo->env, code); } - size_t tableListSize = tableListGetSize(pTaskInfo->pTableInfoList); + size_t tableListSize = tableListGetSize(pInfo->base.pTableListInfo); if (!pInfo->hasGroupId) { pInfo->hasGroupId = true; @@ -2851,7 +2969,7 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) { return NULL; } pInfo->tableStartIndex = 0; - pInfo->groupId = ((STableKeyInfo*)tableListGetInfo(pTaskInfo->pTableInfoList, pInfo->tableStartIndex))->groupId; + pInfo->groupId = ((STableKeyInfo*)tableListGetInfo(pInfo->base.pTableListInfo, pInfo->tableStartIndex))->groupId; startGroupTableMergeScan(pOperator); } @@ -2876,8 +2994,9 @@ SSDataBlock* doTableMergeScan(SOperatorInfo* pOperator) { } pInfo->tableStartIndex = pInfo->tableEndIndex + 1; - pInfo->groupId = tableListGetInfo(pTaskInfo->pTableInfoList, pInfo->tableStartIndex)->groupId; + pInfo->groupId = tableListGetInfo(pInfo->base.pTableListInfo, pInfo->tableStartIndex)->groupId; startGroupTableMergeScan(pOperator); + resetLimitInfoForNextGroup(&pInfo->limitInfo); } } @@ -2893,35 +3012,29 @@ void destroyTableMergeScanOperatorInfo(void* param) { for (int32_t i = 0; i < numOfTable; i++) { STableMergeScanSortSourceParam* p = taosArrayGet(pTableScanInfo->sortSourceParams, i); blockDataDestroy(p->inputBlock); + tsdbReaderClose(p->dataReader); + p->dataReader = NULL; } + tsdbReaderClose(pTableScanInfo->base.dataReader); + pTableScanInfo->base.dataReader = NULL; + taosArrayDestroy(pTableScanInfo->sortSourceParams); tsortDestroySortHandle(pTableScanInfo->pSortHandle); pTableScanInfo->pSortHandle = NULL; - tsdbReaderClose(pTableScanInfo->base.dataReader); - pTableScanInfo->base.dataReader = NULL; - for (int i = 0; i < taosArrayGetSize(pTableScanInfo->queryConds); i++) { SQueryTableDataCond* pCond = taosArrayGet(pTableScanInfo->queryConds, i); taosMemoryFree(pCond->colList); } - taosArrayDestroy(pTableScanInfo->queryConds); - if (pTableScanInfo->base.matchInfo.pList != NULL) { - taosArrayDestroy(pTableScanInfo->base.matchInfo.pList); - } + taosArrayDestroy(pTableScanInfo->queryConds); + destroyTableScanBase(&pTableScanInfo->base); pTableScanInfo->pResBlock = blockDataDestroy(pTableScanInfo->pResBlock); pTableScanInfo->pSortInputBlock = blockDataDestroy(pTableScanInfo->pSortInputBlock); taosArrayDestroy(pTableScanInfo->pSortInfo); - cleanupExprSupp(&pTableScanInfo->base.pseudoSup); - - tsdbReaderClose(pTableScanInfo->base.dataReader); - pTableScanInfo->base.dataReader = NULL; - taosLRUCacheCleanup(pTableScanInfo->base.metaCache.pTableMetaEntryCache); - taosMemoryFreeClear(param); } @@ -2940,7 +3053,7 @@ int32_t getTableMergeScanExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExpla } SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle, - SExecTaskInfo* pTaskInfo) { + STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) { STableMergeScanInfo* pInfo = taosMemoryCalloc(1, sizeof(STableMergeScanInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -2982,6 +3095,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN pInfo->base.limitInfo.limit.limit = -1; pInfo->base.limitInfo.slimit.limit = -1; + pInfo->base.pTableListInfo = pTableListInfo; pInfo->sample.sampleRatio = pTableScanNode->ratio; pInfo->sample.seed = taosGetTimestampSec(); @@ -3211,7 +3325,7 @@ static SSDataBlock* buildSysDbTableCount(SOperatorInfo* pOperator, STableCountSc size_t perfdbTableNum; getPerfDbMeta(NULL, &perfdbTableNum); - if (pSupp->groupByDbName) { + if (pSupp->groupByDbName || pSupp->groupByStbName) { buildSysDbGroupedTableCount(pOperator, pInfo, pSupp, pRes, infodbTableNum, perfdbTableNum); return (pRes->info.rows > 0) ? pRes : NULL; } else { @@ -3236,11 +3350,23 @@ static void buildSysDbGroupedTableCount(SOperatorInfo* pOperator, STableCountSca STableCountScanSupp* pSupp, SSDataBlock* pRes, size_t infodbTableNum, size_t perfdbTableNum) { if (pInfo->currGrpIdx == 0) { - uint64_t groupId = calcGroupId(TSDB_INFORMATION_SCHEMA_DB, strlen(TSDB_INFORMATION_SCHEMA_DB)); + uint64_t groupId = 0; + if (pSupp->groupByDbName) { + groupId = calcGroupId(TSDB_INFORMATION_SCHEMA_DB, strlen(TSDB_INFORMATION_SCHEMA_DB)); + } else { + groupId = calcGroupId("", 0); + } + pRes->info.id.groupId = groupId; fillTableCountScanDataBlock(pSupp, TSDB_INFORMATION_SCHEMA_DB, "", infodbTableNum, pRes); } else if (pInfo->currGrpIdx == 1) { - uint64_t groupId = calcGroupId(TSDB_PERFORMANCE_SCHEMA_DB, strlen(TSDB_PERFORMANCE_SCHEMA_DB)); + uint64_t groupId = 0; + if (pSupp->groupByDbName) { + groupId = calcGroupId(TSDB_PERFORMANCE_SCHEMA_DB, strlen(TSDB_PERFORMANCE_SCHEMA_DB)); + } else { + groupId = calcGroupId("", 0); + } + pRes->info.id.groupId = groupId; fillTableCountScanDataBlock(pSupp, TSDB_PERFORMANCE_SCHEMA_DB, "", perfdbTableNum, pRes); } else { @@ -3278,7 +3404,7 @@ static SSDataBlock* buildVnodeDbTableCount(SOperatorInfo* pOperator, STableCount tNameFromString(&sn, db, T_NAME_ACCT | T_NAME_DB); tNameGetDbName(&sn, dbName); - if (pSupp->groupByDbName) { + if (pSupp->groupByDbName || pSupp->groupByStbName) { buildVnodeGroupedTableCount(pOperator, pInfo, pSupp, pRes, vgId, dbName); } else { buildVnodeFilteredTbCount(pOperator, pInfo, pSupp, pRes, dbName); @@ -3339,7 +3465,10 @@ static void buildVnodeFilteredTbCount(SOperatorInfo* pOperator, STableCountScanO static void buildVnodeGroupedNtbTableCount(STableCountScanOperatorInfo* pInfo, STableCountScanSupp* pSupp, SSDataBlock* pRes, char* dbName) { char fullStbName[TSDB_TABLE_FNAME_LEN] = {0}; - snprintf(fullStbName, TSDB_TABLE_FNAME_LEN, "%s.%s", dbName, ""); + if (pSupp->groupByDbName) { + snprintf(fullStbName, TSDB_TABLE_FNAME_LEN, "%s.%s", dbName, ""); + } + uint64_t groupId = calcGroupId(fullStbName, strlen(fullStbName)); pRes->info.id.groupId = groupId; int64_t ntbNum = metaGetNtbNum(pInfo->readHandle.meta); @@ -3354,7 +3483,12 @@ static void buildVnodeGroupedStbTableCount(STableCountScanOperatorInfo* pInfo, S metaGetTableSzNameByUid(pInfo->readHandle.meta, stbUid, stbName); char fullStbName[TSDB_TABLE_FNAME_LEN] = {0}; - snprintf(fullStbName, TSDB_TABLE_FNAME_LEN, "%s.%s", dbName, stbName); + if (pSupp->groupByDbName) { + snprintf(fullStbName, TSDB_TABLE_FNAME_LEN, "%s.%s", dbName, stbName); + } else { + snprintf(fullStbName, TSDB_TABLE_FNAME_LEN, "%s", stbName); + } + uint64_t groupId = calcGroupId(fullStbName, strlen(fullStbName)); pRes->info.id.groupId = groupId; diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index 90c7fa10ca766c0d3c6ba67115b30070d569b6cd..cb0f1aa06845575e40d69ff4dca2ccaf96809b0a 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -698,7 +698,7 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData pDataBlock->info.dataLoad = 1; } - qDebug("%s get sorted block, groupId:0x%" PRIx64 " rows:%d", GET_TASKID(pTaskInfo), pDataBlock->info.id.groupId, + qDebug("%s get sorted block, groupId:0x%" PRIx64 " rows:%" PRId64 , GET_TASKID(pTaskInfo), pDataBlock->info.id.groupId, pDataBlock->info.rows); return (pDataBlock->info.rows > 0) ? pDataBlock : NULL; diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index 24f42ff178c45660a13f58df2f3c025eb3e78048..1abe678ac6453ed0edacd9012937c8463000ceb3 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -57,9 +57,11 @@ typedef struct SSysTableScanInfo { const char* pUser; bool sysInfo; bool showRewrite; + bool restore; SNode* pCondition; // db_name filter condition, to discard data that are not in current database SMTbCursor* pCur; // cursor for iterate the local table meta store. SSysTableIndex* pIdx; // idx for local table meta + SHashObj* pSchema; SColMatchInfo matchInfo; SName name; SSDataBlock* pRes; @@ -81,10 +83,11 @@ typedef struct MergeIndex { } MergeIndex; typedef struct SBlockDistInfo { - SSDataBlock* pResBlock; - STsdbReader* pHandle; - SReadHandle readHandle; - uint64_t uid; // table uid + SSDataBlock* pResBlock; + STsdbReader* pHandle; + SReadHandle readHandle; + STableListInfo* pTableListInfo; + uint64_t uid; // table uid } SBlockDistInfo; static int32_t sysChkFilter__Comm(SNode* pNode); @@ -514,9 +517,23 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) { pInfo->pCur = metaOpenTbCursor(pInfo->readHandle.meta); } - SHashObj* stableSchema = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); - taosHashSetFreeFp(stableSchema, tDeleteSSchemaWrapperForHash); - while ((ret = metaTbCursorNext(pInfo->pCur, TSDB_TABLE_MAX)) == 0) { + if (pInfo->pSchema == NULL) { + pInfo->pSchema = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK); + taosHashSetFreeFp(pInfo->pSchema, tDeleteSSchemaWrapperForHash); + } + + if (!pInfo->pCur || !pInfo->pSchema) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + qError("sysTableScanUserCols failed since %s", terrstr(terrno)); + blockDataDestroy(dataBlock); + pInfo->loadInfo.totalRows = 0; + return NULL; + } + + int32_t restore = pInfo->restore; + pInfo->restore = false; + while (restore || ((ret = metaTbCursorNext(pInfo->pCur, TSDB_TABLE_MAX)) == 0)) { + if (restore) restore = false; char typeName[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; char tableName[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0}; @@ -524,33 +541,36 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) { if (pInfo->pCur->mr.me.type == TSDB_SUPER_TABLE) { qDebug("sysTableScanUserCols cursor get super table"); - void* schema = taosHashGet(stableSchema, &pInfo->pCur->mr.me.uid, sizeof(int64_t)); + void* schema = taosHashGet(pInfo->pSchema, &pInfo->pCur->mr.me.uid, sizeof(int64_t)); if (schema == NULL) { SSchemaWrapper* schemaWrapper = tCloneSSchemaWrapper(&pInfo->pCur->mr.me.stbEntry.schemaRow); - taosHashPut(stableSchema, &pInfo->pCur->mr.me.uid, sizeof(int64_t), &schemaWrapper, POINTER_BYTES); + taosHashPut(pInfo->pSchema, &pInfo->pCur->mr.me.uid, sizeof(int64_t), &schemaWrapper, POINTER_BYTES); } continue; } else if (pInfo->pCur->mr.me.type == TSDB_CHILD_TABLE) { qDebug("sysTableScanUserCols cursor get child table"); STR_TO_VARSTR(typeName, "CHILD_TABLE"); STR_TO_VARSTR(tableName, pInfo->pCur->mr.me.name); - int64_t suid = pInfo->pCur->mr.me.ctbEntry.suid; - void* schema = taosHashGet(stableSchema, &pInfo->pCur->mr.me.ctbEntry.suid, sizeof(int64_t)); + void* schema = taosHashGet(pInfo->pSchema, &pInfo->pCur->mr.me.ctbEntry.suid, sizeof(int64_t)); if (schema != NULL) { schemaRow = *(SSchemaWrapper**)schema; } else { - tDecoderClear(&pInfo->pCur->mr.coder); - int code = metaGetTableEntryByUid(&pInfo->pCur->mr, suid); + SMetaReader smrSuperTable = {0}; + metaReaderInit(&smrSuperTable, pInfo->readHandle.meta, 0); + int code = metaGetTableEntryByUid(&smrSuperTable, suid); if (code != TSDB_CODE_SUCCESS) { // terrno has been set by metaGetTableEntryByName, therefore, return directly qError("sysTableScanUserCols get meta by suid:%" PRId64 " error, code:%d", suid, code); + metaReaderClear(&smrSuperTable); blockDataDestroy(dataBlock); pInfo->loadInfo.totalRows = 0; - taosHashCleanup(stableSchema); return NULL; } - schemaRow = &pInfo->pCur->mr.me.stbEntry.schemaRow; + SSchemaWrapper* schemaWrapper = tCloneSSchemaWrapper(&smrSuperTable.me.stbEntry.schemaRow); + taosHashPut(pInfo->pSchema, &suid, sizeof(int64_t), &schemaWrapper, POINTER_BYTES); + schemaRow = schemaWrapper; + metaReaderClear(&smrSuperTable); } } else if (pInfo->pCur->mr.me.type == TSDB_NORMAL_TABLE) { qDebug("sysTableScanUserCols cursor get normal table"); @@ -562,20 +582,19 @@ static SSDataBlock* sysTableScanUserCols(SOperatorInfo* pOperator) { continue; } - sysTableUserColsFillOneTableCols(pInfo, dbname, &numOfRows, dataBlock, tableName, schemaRow, typeName); - - if (numOfRows >= pOperator->resultInfo.capacity) { + if ((numOfRows + schemaRow->nCols) > pOperator->resultInfo.capacity) { relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock, pOperator->exprSupp.pFilterInfo); numOfRows = 0; + pInfo->restore = true; if (pInfo->pRes->info.rows > 0) { break; } + } else { + sysTableUserColsFillOneTableCols(pInfo, dbname, &numOfRows, dataBlock, tableName, schemaRow, typeName); } } - taosHashCleanup(stableSchema); - if (numOfRows > 0) { relocateAndFilterSysTagsScanResult(pInfo, numOfRows, dataBlock, pOperator->exprSupp.pFilterInfo); numOfRows = 0; @@ -695,7 +714,7 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { } if ((smrSuperTable.me.stbEntry.schemaTag.nCols + numOfRows) > pOperator->resultInfo.capacity) { - metaTbCursorPrev(pInfo->pCur); + metaTbCursorPrev(pInfo->pCur, TSDB_TABLE_MAX); blockFull = true; } else { sysTableUserTagsFillOneTableTags(pInfo, &smrSuperTable, &pInfo->pCur->mr, dbname, tableName, &numOfRows, @@ -1609,7 +1628,7 @@ static void sysTableScanFillTbName(SOperatorInfo* pOperator, const SSysTableScan char varTbName[TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE] = {0}; STR_TO_VARSTR(varTbName, name); - colDataSetNItems(pColumnInfoData, 0, varTbName, pBlock->info.rows); + colDataSetNItems(pColumnInfoData, 0, varTbName, pBlock->info.rows, true); } doFilter(pBlock, pOperator->exprSupp.pFilterInfo, NULL); @@ -1789,6 +1808,11 @@ void destroySysScanOperator(void* param) { pInfo->pIdx = NULL; } + if(pInfo->pSchema) { + taosHashCleanup(pInfo->pSchema); + pInfo->pSchema = NULL; + } + taosArrayDestroy(pInfo->matchInfo.pList); taosMemoryFreeClear(pInfo->pUser); @@ -2191,6 +2215,7 @@ static void destroyBlockDistScanOperatorInfo(void* param) { SBlockDistInfo* pDistInfo = (SBlockDistInfo*)param; blockDataDestroy(pDistInfo->pResBlock); tsdbReaderClose(pDistInfo->pHandle); + tableListDestroy(pDistInfo->pTableListInfo); taosMemoryFreeClear(param); } @@ -2222,7 +2247,7 @@ static int32_t initTableblockDistQueryCond(uint64_t uid, SQueryTableDataCond* pC } SOperatorInfo* createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDistScanPhysiNode* pBlockScanNode, - SExecTaskInfo* pTaskInfo) { + STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo) { SBlockDistInfo* pInfo = taosMemoryCalloc(1, sizeof(SBlockDistInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -2240,11 +2265,11 @@ SOperatorInfo* createDataBlockInfoScanOperator(SReadHandle* readHandle, SBlockDi goto _error; } - STableListInfo* pTableListInfo = pTaskInfo->pTableInfoList; - size_t num = tableListGetSize(pTableListInfo); - void* pList = tableListGetInfo(pTableListInfo, 0); + pInfo->pTableListInfo = pTableListInfo; + size_t num = tableListGetSize(pTableListInfo); + void* pList = tableListGetInfo(pTableListInfo, 0); - code = tsdbReaderOpen(readHandle->vnode, &cond, pList, num, pInfo->pResBlock, &pInfo->pHandle, pTaskInfo->id.str); + code = tsdbReaderOpen(readHandle->vnode, &cond, pList, num, pInfo->pResBlock, &pInfo->pHandle, pTaskInfo->id.str, false); cleanupQueryTableDataCond(&cond); if (code != 0) { goto _error; diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index f4c8521b941b4e82e22195e2c42098705dacc251..e59ea253ccee8e3badda35445d4f681e76c1542e 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -44,7 +44,7 @@ static void setNotFillColumn(SFillInfo* pFillInfo, SColumnInfoData* pDstColInfo, } else { p = FILL_IS_ASC_FILL(pFillInfo) ? &pFillInfo->prev : &pFillInfo->next; } - + SGroupKeys* pKey = taosArrayGet(p->pRowVal, colIdx); doSetVal(pDstColInfo, rowIndex, pKey); } @@ -578,7 +578,12 @@ int32_t taosGetLinearInterpolationVal(SPoint* point, int32_t outputType, SPoint* GET_TYPED_DATA(v1, double, inputType, point1->val); GET_TYPED_DATA(v2, double, inputType, point2->val); - double r = DO_INTERPOLATION(v1, v2, point1->key, point2->key, point->key); + double r = 0; + if (!IS_BOOLEAN_TYPE(inputType)) { + r = DO_INTERPOLATION(v1, v2, point1->key, point2->key, point->key); + } else { + r = (v1 < 1 || v2 < 1) ? 0 : 1; + } SET_TYPED_DATA(point->val, outputType, r); return TSDB_CODE_SUCCESS; @@ -630,6 +635,7 @@ SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfFillExpr, SExprIn nodesValueNodeToVariant(pv, &pFillCol[i].fillVal); } } + pFillCol->numOfFillExpr = numOfFillExpr; for (int32_t i = 0; i < numOfNoFillExpr; ++i) { SExprInfo* pExprInfo = &pNotFillExpr[i]; diff --git a/source/libs/executor/src/timesliceoperator.c b/source/libs/executor/src/timesliceoperator.c index 911700be8534d7b6b7762854b82bd7ceaad12489..f0e25d8cc5a3786a66720de1e314c406361af11a 100644 --- a/source/libs/executor/src/timesliceoperator.c +++ b/source/libs/executor/src/timesliceoperator.c @@ -156,6 +156,16 @@ static FORCE_INLINE int32_t timeSliceEnsureBlockCapacity(STimeSliceOperatorInfo* return TSDB_CODE_SUCCESS; } +static bool isIrowtsPseudoColumn(SExprInfo* pExprInfo) { + char *name = pExprInfo->pExpr->_function.functionName; + return (IS_TIMESTAMP_TYPE(pExprInfo->base.resSchema.type) && strcasecmp(name, "_irowts") == 0); +} + +static bool isIsfilledPseudoColumn(SExprInfo* pExprInfo) { + char *name = pExprInfo->pExpr->_function.functionName; + return (IS_BOOLEAN_TYPE(pExprInfo->base.resSchema.type) && strcasecmp(name, "_isfilled") == 0); +} + static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp* pExprSup, SSDataBlock* pResBlock, bool beforeTs) { int32_t rows = pResBlock->info.rows; @@ -170,10 +180,10 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp int32_t dstSlot = pExprInfo->base.resSchema.slotId; SColumnInfoData* pDst = taosArrayGet(pResBlock->pDataBlock, dstSlot); - if (IS_TIMESTAMP_TYPE(pExprInfo->base.resSchema.type)) { + if (isIrowtsPseudoColumn(pExprInfo)) { colDataSetVal(pDst, rows, (char*)&pSliceInfo->current, false); continue; - } else if (IS_BOOLEAN_TYPE(pExprInfo->base.resSchema.type)) { + } else if (isIsfilledPseudoColumn(pExprInfo)) { bool isFilled = true; colDataAppend(pDst, pResBlock->info.rows, (char*)&isFilled, false); continue; @@ -203,6 +213,14 @@ static bool genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp int64_t v = 0; GET_TYPED_DATA(v, int64_t, pVar->nType, &pVar->i); colDataSetVal(pDst, rows, (char*)&v, false); + } else if (IS_BOOLEAN_TYPE(pDst->info.type)) { + bool v = false; + if (!IS_VAR_DATA_TYPE(pVar->nType)) { + GET_TYPED_DATA(v, bool, pVar->nType, &pVar->i); + } else { + v = taosStr2Int8(varDataVal(pVar->pz), NULL, 10); + } + colDataSetVal(pDst, rows, (char*)&v, false); } break; } @@ -288,9 +306,9 @@ static void addCurrentRowToResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp* int32_t dstSlot = pExprInfo->base.resSchema.slotId; SColumnInfoData* pDst = taosArrayGet(pResBlock->pDataBlock, dstSlot); - if (IS_TIMESTAMP_TYPE(pExprInfo->base.resSchema.type)) { + if (isIrowtsPseudoColumn(pExprInfo)) { colDataSetVal(pDst, pResBlock->info.rows, (char*)&pSliceInfo->current, false); - } else if (IS_BOOLEAN_TYPE(pExprInfo->base.resSchema.type)) { + } else if (isIsfilledPseudoColumn(pExprInfo)) { bool isFilled = false; colDataSetVal(pDst, pResBlock->info.rows, (char*)&isFilled, false); } else { @@ -643,6 +661,9 @@ void destroyTimeSliceOperatorInfo(void* param) { taosArrayDestroy(pInfo->pLinearInfo); cleanupExprSupp(&pInfo->scalarSup); + for (int32_t i = 0; i < pInfo->pFillColInfo->numOfFillExpr; ++i) { + taosVariantDestroy(&pInfo->pFillColInfo[i].fillVal); + } taosMemoryFree(pInfo->pFillColInfo); taosMemoryFreeClear(param); } diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index d9da8e076c234ad53c9c600f908314c71188565a..b121f38a0f16bf55a72f06052f7e3e733a8c9393 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -80,7 +80,7 @@ static int32_t setTimeWindowOutputBuf(SResultRowInfo* pResultRowInfo, STimeWindo int32_t numOfOutput, int32_t* rowEntryInfoOffset, SAggSupporter* pAggSup, SExecTaskInfo* pTaskInfo) { SResultRow* pResultRow = doSetResultOutBufByKey(pAggSup->pResultBuf, pResultRowInfo, (char*)&win->skey, TSDB_KEYSIZE, - masterscan, tableGroupId, pTaskInfo, true, pAggSup); + masterscan, tableGroupId, pTaskInfo, true, pAggSup, true); if (pResultRow == NULL) { *pResult = NULL; @@ -130,8 +130,9 @@ FORCE_INLINE int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn if (end >= 0) { forwardRows = end; - if (pData[end + pos] == ekey) { + while (pData[end + pos] == ekey) { forwardRows += 1; + ++pos; } } } else { @@ -139,8 +140,9 @@ FORCE_INLINE int32_t getForwardStepsInBlock(int32_t numOfRows, __block_search_fn if (end >= 0) { forwardRows = end; - if (pData[end + pos] == ekey) { + while (pData[end + pos] == ekey) { forwardRows += 1; + ++pos; } } // int32_t end = searchFn((char*)pData, pos + 1, ekey, order); @@ -283,7 +285,7 @@ static void getNextTimeWindow(SInterval* pInterval, int32_t precision, int32_t o struct tm tm; time_t t = (time_t)key; - taosLocalTime(&t, &tm); + taosLocalTime(&t, &tm, NULL); int mon = (int)(tm.tm_year * 12 + tm.tm_mon + interval * factor); tm.tm_year = mon / 12; @@ -925,10 +927,10 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { T_LONG_JMP(pTaskInfo->env, TSDB_CODE_OUT_OF_MEMORY); } + TSKEY ekey = ascScan ? win.ekey : win.skey; int32_t forwardRows = getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->inputOrder); - ASSERT(forwardRows > 0); // prev time window not interpolation yet. if (pInfo->timeWindowInterpo) { @@ -2079,10 +2081,12 @@ void compactFunctions(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx, int3 } else if (functionNeedToExecute(&pDestCtx[k]) && pDestCtx[k].fpSet.combine != NULL) { int32_t code = pDestCtx[k].fpSet.combine(&pDestCtx[k], &pSourceCtx[k]); if (code != TSDB_CODE_SUCCESS) { - qError("%s apply functions error, code: %s", GET_TASKID(pTaskInfo), tstrerror(code)); - pTaskInfo->code = code; - T_LONG_JMP(pTaskInfo->env, code); + qError("%s apply combine functions error, code: %s", GET_TASKID(pTaskInfo), tstrerror(code)); } + } else if (pDestCtx[k].fpSet.combine == NULL) { + char* funName = fmGetFuncName(pDestCtx[k].functionId); + qError("%s error, combine funcion for %s is not implemented", GET_TASKID(pTaskInfo), funName); + taosMemoryFreeClear(funName); } } } @@ -2164,13 +2168,6 @@ static void rebuildIntervalWindow(SOperatorInfo* pOperator, SArray* pWinArray, S } } -bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup) { - SET_RES_WINDOW_KEY(pSup->keyBuf, &pWin->skey, sizeof(int64_t), groupId); - SResultRowPosition* p1 = (SResultRowPosition*)tSimpleHashGet(pSup->pResultRowHashTable, pSup->keyBuf, - GET_RES_WINDOW_KEY_LEN(sizeof(int64_t))); - return p1 == NULL; -} - bool isDeletedStreamWindow(STimeWindow* pWin, uint64_t groupId, SStreamState* pState, STimeWindowAggSupp* pTwSup) { if (pWin->ekey < pTwSup->maxTs - pTwSup->deleteMark) { SWinKey key = {.ts = pWin->skey, .groupId = groupId}; @@ -2882,6 +2879,7 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, pInfo->pPullDataMap = taosHashInit(64, hashFn, false, HASH_NO_LOCK); pInfo->pPullDataRes = createSpecialDataBlock(STREAM_RETRIEVE); pInfo->ignoreExpiredData = pIntervalPhyNode->window.igExpired; + pInfo->ignoreExpiredDataSaved = false; pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT); pInfo->delIndex = 0; pInfo->pDelWins = taosArrayInit(4, sizeof(SWinKey)); @@ -3705,6 +3703,7 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh pInfo->isFinal = false; pInfo->pPhyNode = pPhyNode; pInfo->ignoreExpiredData = pSessionNode->window.igExpired; + pInfo->ignoreExpiredDataSaved = false; pInfo->pUpdated = NULL; pInfo->pStUpdated = NULL; pInfo->dataVersion = 0; @@ -4033,7 +4032,7 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl blockDataEnsureCapacity(pAggSup->pScanBlock, rows); SColumnInfoData* pKeyColInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->stateCol.slotId); for (int32_t i = 0; i < rows; i += winRows) { - if (pInfo->ignoreExpiredData && isOverdue(tsCols[i], &pInfo->twAggSup)) { + if (pInfo->ignoreExpiredData && isOverdue(tsCols[i], &pInfo->twAggSup) || colDataIsNull_s(pKeyColInfo, i)) { i++; continue; } @@ -4234,6 +4233,7 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT); pInfo->pChildren = NULL; pInfo->ignoreExpiredData = pStateNode->window.igExpired; + pInfo->ignoreExpiredDataSaved = false; pInfo->pUpdated = NULL; pInfo->pSeUpdated = NULL; pInfo->dataVersion = 0; @@ -5011,6 +5011,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys pOperator->pTaskInfo = pTaskInfo; pInfo->ignoreExpiredData = pIntervalPhyNode->window.igExpired; + pInfo->ignoreExpiredDataSaved = false; pInfo->isFinal = false; SExprSupp* pSup = &pOperator->exprSupp; diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 6d734901ab3e43a165bdba05690abd222ff96385..6c8e581b3fe837aa1bf101bf8cf6748a2cac5f4d 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -108,12 +108,18 @@ static int32_t sortComparCleanup(SMsortComparParam* cmpParam) { return TSDB_CODE_SUCCESS; } -void tsortClearOrderdSource(SArray* pOrderedSource) { +void tsortClearOrderdSource(SArray* pOrderedSource, int64_t *fetchUs, int64_t *fetchNum) { for (size_t i = 0; i < taosArrayGetSize(pOrderedSource); i++) { SSortSource** pSource = taosArrayGet(pOrderedSource, i); if (NULL == *pSource) { continue; } + + if (fetchUs) { + *fetchUs += (*pSource)->fetchUs; + *fetchNum += (*pSource)->fetchNum; + } + // release pageIdList if ((*pSource)->pageIdList) { taosArrayDestroy((*pSource)->pageIdList); @@ -147,7 +153,10 @@ void tsortDestroySortHandle(SSortHandle* pSortHandle) { taosMemoryFreeClear(pSortHandle->idStr); blockDataDestroy(pSortHandle->pDataBlock); - tsortClearOrderdSource(pSortHandle->pOrderedSource); + int64_t fetchUs = 0, fetchNum = 0; + tsortClearOrderdSource(pSortHandle->pOrderedSource, &fetchUs, &fetchNum); + qError("all source fetch time: %" PRId64 "us num:%" PRId64 " %s", fetchUs, fetchNum, pSortHandle->idStr); + taosArrayDestroy(pSortHandle->pOrderedSource); taosMemoryFreeClear(pSortHandle); } @@ -214,7 +223,6 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) { if (pPage == NULL) { taosArrayDestroy(pPageIdList); blockDataDestroy(p); - taosArrayDestroy(pPageIdList); return terrno; } @@ -308,7 +316,7 @@ static int32_t sortComparInit(SMsortComparParam* pParam, SArray* pSources, int32 } int64_t et = taosGetTimestampUs(); - qDebug("init for merge sort completed, elapsed time:%.2f ms, %s", (et - st) / 1000.0, pHandle->idStr); + qError("init for merge sort completed, elapsed time:%.2f ms, %s", (et - st) / 1000.0, pHandle->idStr); } return code; @@ -366,7 +374,10 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource* pSource, SMultiwayMergeT releaseBufPage(pHandle->pBuf, pPage); } } else { + int64_t st = taosGetTimestampUs(); pSource->src.pBlock = pHandle->fetchfp(((SSortSource*)pSource)->param); + pSource->fetchUs += taosGetTimestampUs() - st; + pSource->fetchNum++; if (pSource->src.pBlock == NULL) { (*numOfCompleted) += 1; pSource->src.rowIndex = -1; @@ -603,7 +614,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { } } - tsortClearOrderdSource(pHandle->pOrderedSource); + tsortClearOrderdSource(pHandle->pOrderedSource, NULL, NULL); taosArrayAddAll(pHandle->pOrderedSource, pResList); taosArrayDestroy(pResList); @@ -645,7 +656,7 @@ static int32_t createInitialSources(SSortHandle* pHandle) { SSortSource* source = *pSource; *pSource = NULL; - tsortClearOrderdSource(pHandle->pOrderedSource); + tsortClearOrderdSource(pHandle->pOrderedSource, NULL, NULL); while (1) { SSDataBlock* pBlock = pHandle->fetchfp(source->param); diff --git a/source/libs/function/inc/builtinsimpl.h b/source/libs/function/inc/builtinsimpl.h index dc884a058193e0abbefa04cff086788733f59a87..c3afc30a7b203469b0da23244dc281e64f32bd69 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -235,6 +235,7 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); bool getGroupKeyFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv); int32_t groupKeyFunction(SqlFunctionCtx* pCtx); int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); +int32_t groupKeyCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); #ifdef __cplusplus } diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 0257b3d5e6c2e0062b00b79dab221f4ddb606d4a..69951f680e745a47c6c7e31947f27f67cb37f97c 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -213,8 +213,9 @@ static int32_t addTimezoneParam(SNodeList* pList) { char buf[6] = {0}; time_t t = taosTime(NULL); struct tm tmInfo; - taosLocalTime(&t, &tmInfo); - strftime(buf, sizeof(buf), "%z", &tmInfo); + if (taosLocalTime(&t, &tmInfo, buf) != NULL) { + strftime(buf, sizeof(buf), "%z", &tmInfo); + } int32_t len = (int32_t)strlen(buf); SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); @@ -480,14 +481,16 @@ static int32_t translateNowToday(SFunctionNode* pFunc, char* pErrBuf, int32_t le return code; } - pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP}; + pFunc->node.resType = + (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP}; return TSDB_CODE_SUCCESS; } static int32_t translateTimePseudoColumn(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { // pseudo column do not need to check parameters - pFunc->node.resType = (SDataType){.bytes =tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP}; + pFunc->node.resType = + (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_TIMESTAMP].bytes, .type = TSDB_DATA_TYPE_TIMESTAMP}; return TSDB_CODE_SUCCESS; } @@ -509,13 +512,11 @@ static int32_t translatePercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); } - uint8_t para1Type = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; if (!IS_NUMERIC_TYPE(para1Type)) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } - for (int32_t i = 1; i < numOfParams; ++i) { SValueNode* pValue = (SValueNode*)nodesListGetNode(pFunc->pParameterList, i); pValue->notReserved = true; @@ -1574,7 +1575,7 @@ static int32_t translateInterp(SFunctionNode* pFunc, char* pErrBuf, int32_t len) uint8_t nodeType = nodeType(nodesListGetNode(pFunc->pParameterList, 0)); uint8_t paraType = ((SExprNode*)nodesListGetNode(pFunc->pParameterList, 0))->resType.type; - if (!IS_NUMERIC_TYPE(paraType) || QUERY_NODE_VALUE == nodeType) { + if ((!IS_NUMERIC_TYPE(paraType) && !IS_BOOLEAN_TYPE(paraType))|| QUERY_NODE_VALUE == nodeType) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } @@ -2375,7 +2376,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "spread", .type = FUNCTION_TYPE_SPREAD, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED, .translateFunc = translateSpread, .dataRequiredFunc = statisDataRequired, .getEnvFunc = getSpreadFuncEnv, @@ -2417,7 +2418,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "elapsed", .type = FUNCTION_TYPE_ELAPSED, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_INTERVAL_INTERPO_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_INTERVAL_INTERPO_FUNC | FUNC_MGT_FORBID_STREAM_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED, .dataRequiredFunc = statisDataRequired, .translateFunc = translateElapsed, .getEnvFunc = getElapsedFuncEnv, @@ -2457,7 +2458,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "interp", .type = FUNCTION_TYPE_INTERP, .classification = FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_INTERVAL_INTERPO_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | - FUNC_MGT_FORBID_STREAM_FUNC, + FUNC_MGT_FORBID_STREAM_FUNC|FUNC_MGT_KEEP_ORDER_FUNC, .translateFunc = translateInterp, .getEnvFunc = getSelectivityFuncEnv, .initFunc = functionSetup, @@ -2480,7 +2481,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "irate", .type = FUNCTION_TYPE_IRATE, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TIMELINE_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateIrate, .getEnvFunc = getIrateFuncEnv, .initFunc = irateFuncSetup, @@ -2491,7 +2492,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "last_row", .type = FUNCTION_TYPE_LAST_ROW, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | FUNC_MGT_KEEP_ORDER_FUNC, .translateFunc = translateFirstLast, .dynDataRequiredFunc = lastDynDataReq, .getEnvFunc = getFirstLastFuncEnv, @@ -2500,7 +2501,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .sprocessFunc = firstLastScalarFunction, .pPartialFunc = "_last_row_partial", .pMergeFunc = "_last_row_merge", - .finalizeFunc = firstLastFinalize + .finalizeFunc = firstLastFinalize, + .combineFunc = lastCombine }, { .name = "_cache_last_row", @@ -2809,7 +2811,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "mode", .type = FUNCTION_TYPE_MODE, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateMode, .getEnvFunc = getModeFuncEnv, .initFunc = modeFunctionSetup, @@ -3212,7 +3214,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_block_dist", .type = FUNCTION_TYPE_BLOCK_DIST, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_FORBID_STREAM_FUNC, .translateFunc = translateBlockDistFunc, .getEnvFunc = getBlockDistFuncEnv, .initFunc = blockDistSetup, @@ -3234,6 +3236,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .initFunc = functionSetup, .processFunc = groupKeyFunction, .finalizeFunc = groupKeyFinalize, + .combineFunc = groupKeyCombine, .pPartialFunc = "_group_key", .pMergeFunc = "_group_key" }, @@ -3276,7 +3279,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "_irowts", .type = FUNCTION_TYPE_IROWTS, - .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_INTERP_PC_FUNC, + .classification = FUNC_MGT_PSEUDO_COLUMN_FUNC | FUNC_MGT_INTERP_PC_FUNC|FUNC_MGT_KEEP_ORDER_FUNC, .translateFunc = translateTimePseudoColumn, .getEnvFunc = getTimePseudoFuncEnv, .initFunc = NULL, diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index ba8acef7864aa9ddc4b79a22aa26a3fe18998f01..0d2ae4bd744b296b2dc7551ebac69416043274f9 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -32,9 +32,6 @@ #define TAIL_MAX_POINTS_NUM 100 #define TAIL_MAX_OFFSET 100 -#define UNIQUE_MAX_RESULT_SIZE (1024 * 1024 * 10) -#define MODE_MAX_RESULT_SIZE UNIQUE_MAX_RESULT_SIZE - #define HLL_BUCKET_BITS 14 // The bits of the bucket #define HLL_DATA_BITS (64 - HLL_BUCKET_BITS) #define HLL_BUCKETS (1 << HLL_BUCKET_BITS) @@ -244,12 +241,11 @@ typedef struct SUniqueInfo { typedef struct SModeItem { int64_t count; + STuplePos dataPos; STuplePos tuplePos; - char data[]; } SModeItem; typedef struct SModeInfo { - int32_t numOfPoints; uint8_t colType; int16_t colBytes; SHashObj* pHash; @@ -257,7 +253,7 @@ typedef struct SModeInfo { STuplePos nullTuplePos; bool nullTupleSaved; - char pItems[]; + char* buf; // serialize data buffer } SModeInfo; typedef struct SDerivInfo { @@ -494,8 +490,8 @@ bool getCountFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { return true; } -static int32_t getNumOfElems(SqlFunctionCtx* pCtx) { - int32_t numOfElem = 0; +static int64_t getNumOfElems(SqlFunctionCtx* pCtx) { + int64_t numOfElem = 0; /* * 1. column data missing (schema modified) causes pInputCol->hasNull == true. pInput->colDataSMAIsSet == true; @@ -528,7 +524,7 @@ static int32_t getNumOfElems(SqlFunctionCtx* pCtx) { * count function does not use the pCtx->interResBuf to keep the intermediate buffer */ int32_t countFunction(SqlFunctionCtx* pCtx) { - int32_t numOfElem = 0; + int64_t numOfElem = 0; SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); SInputColumnInfoData* pInput = &pCtx->input; @@ -555,7 +551,7 @@ int32_t countFunction(SqlFunctionCtx* pCtx) { } int32_t countInvertFunction(SqlFunctionCtx* pCtx) { - int32_t numOfElem = getNumOfElems(pCtx); + int64_t numOfElem = getNumOfElems(pCtx); SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); char* buf = GET_ROWCELL_INTERBUF(pResInfo); @@ -871,6 +867,12 @@ int32_t setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STu SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j]; int32_t dstSlotId = pc->pExpr->base.resSchema.slotId; + // group_key function has its own process function + // do not process there + if (fmIsGroupKeyFunc(pc->functionId)) { + continue; + } + SColumnInfoData* pDstCol = taosArrayGet(pBlock->pDataBlock, dstSlotId); if (nullList[j]) { colDataSetNULL(pDstCol, rowIndex); @@ -1929,7 +1931,7 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) { SAPercentileInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); - qDebug("%s total %d rows will merge, %p", __FUNCTION__, pInput->numOfRows, pInfo->pHisto); + qDebug("%s total %" PRId64 " rows will merge, %p", __FUNCTION__, pInput->numOfRows, pInfo->pHisto); int32_t start = pInput->startRowIndex; for (int32_t i = start; i < start + pInput->numOfRows; ++i) { @@ -3091,6 +3093,12 @@ void* serializeTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SSubsid for (int32_t i = 0; i < pSubsidiaryies->num; ++i) { SqlFunctionCtx* pc = pSubsidiaryies->pCtx[i]; + // group_key function has its own process function + // do not process there + if (fmIsGroupKeyFunc(pc->functionId)) { + continue; + } + SFunctParam* pFuncParam = &pc->pExpr->base.pParam[0]; int32_t srcSlotId = pFuncParam->pCol->slotId; @@ -3113,7 +3121,7 @@ void* serializeTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SSubsid return buf; } -static int32_t doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length, STupleKey key, +static int32_t doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length, STupleKey* key, STuplePos* pPos) { STuplePos p = {0}; if (pHandle->pBuf != NULL) { @@ -3149,8 +3157,8 @@ static int32_t doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf, releaseBufPage(pHandle->pBuf, pPage); } else { // other tuple save policy - if (streamStateFuncPut(pHandle->pState, &key, pBuf, length) >= 0) { - p.streamTupleKey = key; + if (streamStateFuncPut(pHandle->pState, key, pBuf, length) >= 0) { + p.streamTupleKey = *key; } } @@ -3174,7 +3182,7 @@ int32_t saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* } char* buf = serializeTupleData(pSrcBlock, rowIndex, &pCtx->subsidiaries, pCtx->subsidiaries.buf); - return doSaveTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, key, pPos); + return doSaveTupleData(&pCtx->saveHandle, buf, pCtx->subsidiaries.rowLen, &key, pPos); } static int32_t doUpdateTupleData(SSerializeDataHandle* pHandle, const void* pBuf, size_t length, STuplePos* pPos) { @@ -4949,7 +4957,7 @@ int32_t uniqueFunction(SqlFunctionCtx* pCtx) { } bool getModeFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) { - pEnv->calcMemSize = sizeof(SModeInfo) + MODE_MAX_RESULT_SIZE; + pEnv->calcMemSize = sizeof(SModeInfo); return true; } @@ -4959,7 +4967,6 @@ bool modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) { } SModeInfo* pInfo = GET_ROWCELL_INTERBUF(pResInfo); - pInfo->numOfPoints = 0; pInfo->colType = pCtx->resDataInfo.type; pInfo->colBytes = pCtx->resDataInfo.bytes; if (pInfo->pHash != NULL) { @@ -4970,38 +4977,60 @@ bool modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) { pInfo->nullTupleSaved = false; pInfo->nullTuplePos.pageId = -1; + pInfo->buf = taosMemoryMalloc(pInfo->colBytes); + return true; } +static void modeFunctionCleanup(SModeInfo * pInfo) { + taosHashCleanup(pInfo->pHash); + taosMemoryFreeClear(pInfo->buf); +} + +static int32_t saveModeTupleData(SqlFunctionCtx* pCtx, char* data, SModeInfo *pInfo, STuplePos* pPos) { + if (IS_VAR_DATA_TYPE(pInfo->colType)) { + memcpy(pInfo->buf, data, varDataTLen(data)); + } else { + memcpy(pInfo->buf, data, pInfo->colBytes); + } + + return doSaveTupleData(&pCtx->saveHandle, pInfo->buf, pInfo->colBytes, NULL, pPos); +} + static int32_t doModeAdd(SModeInfo* pInfo, int32_t rowIndex, SqlFunctionCtx* pCtx, char* data) { - int32_t hashKeyBytes = IS_STR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes; - SModeItem** pHashItem = taosHashGet(pInfo->pHash, data, hashKeyBytes); + int32_t code = TSDB_CODE_SUCCESS; + int32_t hashKeyBytes = IS_STR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes; + + SModeItem* pHashItem = (SModeItem *)taosHashGet(pInfo->pHash, data, hashKeyBytes); if (pHashItem == NULL) { - int32_t size = sizeof(SModeItem) + pInfo->colBytes; - SModeItem* pItem = (SModeItem*)(pInfo->pItems + pInfo->numOfPoints * size); - memcpy(pItem->data, data, hashKeyBytes); - pItem->count += 1; + int32_t size = sizeof(SModeItem); + SModeItem item = {0}; + + item.count += 1; + code = saveModeTupleData(pCtx, data, pInfo, &item.dataPos); + if (code != TSDB_CODE_SUCCESS) { + return code; + } if (pCtx->subsidiaries.num > 0) { - int32_t code = saveTupleData(pCtx, rowIndex, pCtx->pSrcBlock, &pItem->tuplePos); + code = saveTupleData(pCtx, rowIndex, pCtx->pSrcBlock, &item.tuplePos); if (code != TSDB_CODE_SUCCESS) { return code; } } - taosHashPut(pInfo->pHash, data, hashKeyBytes, &pItem, sizeof(SModeItem*)); - pInfo->numOfPoints++; + taosHashPut(pInfo->pHash, data, hashKeyBytes, &item, sizeof(SModeItem)); } else { - (*pHashItem)->count += 1; + pHashItem->count += 1; if (pCtx->subsidiaries.num > 0) { - int32_t code = updateTupleData(pCtx, rowIndex, pCtx->pSrcBlock, &((*pHashItem)->tuplePos)); + int32_t code = updateTupleData(pCtx, rowIndex, pCtx->pSrcBlock, &pHashItem->tuplePos); if (code != TSDB_CODE_SUCCESS) { return code; } } } - return TSDB_CODE_SUCCESS; + return code; } int32_t modeFunction(SqlFunctionCtx* pCtx) { @@ -5024,18 +5053,15 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) { char* data = colDataGetData(pInputCol, i); int32_t code = doModeAdd(pInfo, i, pCtx, data); if (code != TSDB_CODE_SUCCESS) { + modeFunctionCleanup(pInfo); return code; } - - if (sizeof(SModeInfo) + pInfo->numOfPoints * (sizeof(SModeItem) + pInfo->colBytes) >= MODE_MAX_RESULT_SIZE) { - taosHashCleanup(pInfo->pHash); - return TSDB_CODE_OUT_OF_MEMORY; - } } if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pInfo->nullTupleSaved) { int32_t code = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock, &pInfo->nullTuplePos); if (code != TSDB_CODE_SUCCESS) { + modeFunctionCleanup(pInfo); return code; } pInfo->nullTupleSaved = true; @@ -5054,26 +5080,37 @@ int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, slotId); int32_t currentRow = pBlock->info.rows; - int32_t resIndex = -1; + STuplePos resDataPos, resTuplePos; int32_t maxCount = 0; - for (int32_t i = 0; i < pInfo->numOfPoints; ++i) { - SModeItem* pItem = (SModeItem*)(pInfo->pItems + i * (sizeof(SModeItem) + pInfo->colBytes)); + + void *pIter = taosHashIterate(pInfo->pHash, NULL); + while (pIter != NULL) { + SModeItem *pItem = (SModeItem *)pIter; if (pItem->count >= maxCount) { maxCount = pItem->count; - resIndex = i; + resDataPos = pItem->dataPos; + resTuplePos = pItem->tuplePos; } + + pIter = taosHashIterate(pInfo->pHash, pIter); } if (maxCount != 0) { - SModeItem* pResItem = (SModeItem*)(pInfo->pItems + resIndex * (sizeof(SModeItem) + pInfo->colBytes)); - colDataSetVal(pCol, currentRow, pResItem->data, false); - code = setSelectivityValue(pCtx, pBlock, &pResItem->tuplePos, currentRow); + const char* pData = loadTupleData(pCtx, &resDataPos); + if (pData == NULL) { + code = TSDB_CODE_NO_AVAIL_DISK; + modeFunctionCleanup(pInfo); + return code; + } + + colDataSetVal(pCol, currentRow, pData, false); + code = setSelectivityValue(pCtx, pBlock, &resTuplePos, currentRow); } else { colDataSetNULL(pCol, currentRow); code = setSelectivityValue(pCtx, pBlock, &pInfo->nullTuplePos, currentRow); } - taosHashCleanup(pInfo->pHash); + modeFunctionCleanup(pInfo); return code; } @@ -5900,6 +5937,39 @@ int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) { return pResInfo->numOfRes; } +int32_t groupKeyCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx) { + SResultRowEntryInfo* pDResInfo = GET_RES_INFO(pDestCtx); + SGroupKeyInfo* pDBuf = GET_ROWCELL_INTERBUF(pDResInfo); + + SResultRowEntryInfo* pSResInfo = GET_RES_INFO(pSourceCtx); + SGroupKeyInfo* pSBuf = GET_ROWCELL_INTERBUF(pSResInfo); + + // escape rest of data blocks to avoid first entry to be overwritten. + if (pDBuf->hasResult) { + goto _group_key_over; + } + + if (pSBuf->isNull) { + pDBuf->isNull = true; + pDBuf->hasResult = true; + goto _group_key_over; + } + + if (IS_VAR_DATA_TYPE(pSourceCtx->resDataInfo.type)) { + memcpy(pDBuf->data, pSBuf->data, + (pSourceCtx->resDataInfo.type == TSDB_DATA_TYPE_JSON) ? getJsonValueLen(pSBuf->data) : varDataTLen(pSBuf->data)); + } else { + memcpy(pDBuf->data, pSBuf->data, pSourceCtx->resDataInfo.bytes); + } + + pDBuf->hasResult = true; + +_group_key_over: + + SET_VAL(pDResInfo, 1, 1); + return TSDB_CODE_SUCCESS; +} + int32_t cachedLastRowFunction(SqlFunctionCtx* pCtx) { int32_t numOfElems = 0; diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index e3127fcd7ba233d478c58cc16b7543587b5eaf90..94ab616dda984f8ebb87c4a8d709851292cd2881 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -447,3 +447,10 @@ int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc return code; } + +char* fmGetFuncName(int32_t funcId) { + if (fmIsUserDefinedFunc(funcId) || funcId < 0 || funcId >= funcMgtBuiltinsNum) { + return taosStrdup("invalid function"); + } + return taosStrdup(funcMgtBuiltins[funcId].name); +} diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index 78c2d4bde7bec82e910834c1b81ef881bdfc4ea0..2269ad7f6a8d5e5d1c67b70be661168907820797 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -1070,8 +1070,15 @@ int32_t callUdfScalarFunc(char *udfName, SScalarParam *input, int32_t numOfCols, if (code != 0) { return code; } + SUdfcUvSession *session = handle; code = doCallUdfScalarFunc(handle, input, numOfCols, output); + if (code != TSDB_CODE_SUCCESS) { + fnError("udfc scalar function execution failure"); + releaseUdfFuncHandle(udfName); + return code; + } + if (output->columnData == NULL) { fnError("udfc scalar function calculate error. no column data"); code = TSDB_CODE_UDF_INVALID_OUTPUT_TYPE; @@ -1210,14 +1217,19 @@ int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock *pBlock) { fnError("udfAggFinalize error. doCallUdfAggFinalize step. udf code:%d", udfCallCode); GET_RES_INFO(pCtx)->numOfRes = 0; } else { - if (resultBuf.bufLen <= session->bytes) { - memcpy(udfRes->finalResBuf, resultBuf.buf, resultBuf.bufLen); - udfRes->finalResNum = resultBuf.numOfResult; - GET_RES_INFO(pCtx)->numOfRes = udfRes->finalResNum; - } else { - fnError("udfc inter buf size %d is greater than function output size %d", resultBuf.bufLen, session->bytes); + if (resultBuf.numOfResult == 0) { + udfRes->finalResNum = 0; GET_RES_INFO(pCtx)->numOfRes = 0; - udfCallCode = TSDB_CODE_UDF_INVALID_OUTPUT_TYPE; + } else { + if (resultBuf.bufLen <= session->bytes) { + memcpy(udfRes->finalResBuf, resultBuf.buf, resultBuf.bufLen); + udfRes->finalResNum = resultBuf.numOfResult; + GET_RES_INFO(pCtx)->numOfRes = udfRes->finalResNum; + } else { + fnError("udfc inter buf size %d is greater than function output size %d", resultBuf.bufLen, session->bytes); + GET_RES_INFO(pCtx)->numOfRes = 0; + udfCallCode = TSDB_CODE_UDF_INVALID_OUTPUT_TYPE; + } } } @@ -1388,8 +1400,9 @@ void udfcUvHandleError(SClientUvConn *conn) { QUEUE_REMOVE(&task->procTaskQueue); uv_sem_post(&task->taskSem); } - - uv_close((uv_handle_t *)conn->pipe, onUdfcPipeClose); + if (!uv_is_closing((uv_handle_t *)conn->pipe)) { + uv_close((uv_handle_t *)conn->pipe, onUdfcPipeClose); + } } void onUdfcPipeRead(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf) { @@ -1541,7 +1554,9 @@ int32_t udfcStartUvTask(SClientUvTaskNode *uvTask) { } else { SClientUvConn *conn = pipe->data; QUEUE_INSERT_TAIL(&conn->taskQueue, &uvTask->connTaskQueue); - uv_close((uv_handle_t *)uvTask->pipe, onUdfcPipeClose); + if (!uv_is_closing((uv_handle_t *)uvTask->pipe)) { + uv_close((uv_handle_t *)uvTask->pipe, onUdfcPipeClose); + } code = 0; } break; diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index f67b352cc0945005ee6f9e07de4156decde6c2d4..aa72309c62f7008c1191b2640444af5f51f0cd7c 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -21,6 +21,7 @@ #include "tudf.h" #include "tudfInt.h" +#include "version.h" #include "tdatablock.h" #include "tdataformat.h" @@ -52,6 +53,45 @@ int32_t udfdCPluginOpen(SScriptUdfEnvItem *items, int numItems) { return 0; } int32_t udfdCPluginClose() { return 0; } +const char *udfdCPluginUdfInitLoadInitDestoryFuncs(SUdfCPluginCtx *udfCtx, const char *udfName) { + char initFuncName[TSDB_FUNC_NAME_LEN + 5] = {0}; + char *initSuffix = "_init"; + strcpy(initFuncName, udfName); + strncat(initFuncName, initSuffix, strlen(initSuffix)); + uv_dlsym(&udfCtx->lib, initFuncName, (void **)(&udfCtx->initFunc)); + + char destroyFuncName[TSDB_FUNC_NAME_LEN + 5] = {0}; + char *destroySuffix = "_destroy"; + strcpy(destroyFuncName, udfName); + strncat(destroyFuncName, destroySuffix, strlen(destroySuffix)); + uv_dlsym(&udfCtx->lib, destroyFuncName, (void **)(&udfCtx->destroyFunc)); + return udfName; +} + +void udfdCPluginUdfInitLoadAggFuncs(SUdfCPluginCtx *udfCtx, const char *udfName) { + char processFuncName[TSDB_FUNC_NAME_LEN] = {0}; + strcpy(processFuncName, udfName); + uv_dlsym(&udfCtx->lib, processFuncName, (void **)(&udfCtx->aggProcFunc)); + + char startFuncName[TSDB_FUNC_NAME_LEN + 6] = {0}; + char *startSuffix = "_start"; + strncpy(startFuncName, processFuncName, sizeof(startFuncName)); + strncat(startFuncName, startSuffix, strlen(startSuffix)); + uv_dlsym(&udfCtx->lib, startFuncName, (void **)(&udfCtx->aggStartFunc)); + + char finishFuncName[TSDB_FUNC_NAME_LEN + 7] = {0}; + char *finishSuffix = "_finish"; + strncpy(finishFuncName, processFuncName, sizeof(finishFuncName)); + strncat(finishFuncName, finishSuffix, strlen(finishSuffix)); + uv_dlsym(&udfCtx->lib, finishFuncName, (void **)(&udfCtx->aggFinishFunc)); + + char mergeFuncName[TSDB_FUNC_NAME_LEN + 6] = {0}; + char *mergeSuffix = "_merge"; + strncpy(mergeFuncName, processFuncName, sizeof(mergeFuncName)); + strncat(mergeFuncName, mergeSuffix, strlen(mergeSuffix)); + uv_dlsym(&udfCtx->lib, mergeFuncName, (void **)(&udfCtx->aggMergeFunc)); +} + int32_t udfdCPluginUdfInit(SScriptUdfInfo *udf, void **pUdfCtx) { int32_t err = 0; SUdfCPluginCtx *udfCtx = taosMemoryCalloc(1, sizeof(SUdfCPluginCtx)); @@ -61,45 +101,19 @@ int32_t udfdCPluginUdfInit(SScriptUdfInfo *udf, void **pUdfCtx) { return TSDB_CODE_UDF_LOAD_UDF_FAILURE; } const char *udfName = udf->name; - char initFuncName[TSDB_FUNC_NAME_LEN + 5] = {0}; - char *initSuffix = "_init"; - strcpy(initFuncName, udfName); - strncat(initFuncName, initSuffix, strlen(initSuffix)); - uv_dlsym(&udfCtx->lib, initFuncName, (void **)(&udfCtx->initFunc)); - char destroyFuncName[TSDB_FUNC_NAME_LEN + 5] = {0}; - char *destroySuffix = "_destroy"; - strcpy(destroyFuncName, udfName); - strncat(destroyFuncName, destroySuffix, strlen(destroySuffix)); - uv_dlsym(&udfCtx->lib, destroyFuncName, (void **)(&udfCtx->destroyFunc)); + udfdCPluginUdfInitLoadInitDestoryFuncs(udfCtx, udfName); if (udf->funcType == UDF_FUNC_TYPE_SCALAR) { char processFuncName[TSDB_FUNC_NAME_LEN] = {0}; strcpy(processFuncName, udfName); uv_dlsym(&udfCtx->lib, processFuncName, (void **)(&udfCtx->scalarProcFunc)); } else if (udf->funcType == UDF_FUNC_TYPE_AGG) { - char processFuncName[TSDB_FUNC_NAME_LEN] = {0}; - strcpy(processFuncName, udfName); - uv_dlsym(&udfCtx->lib, processFuncName, (void **)(&udfCtx->aggProcFunc)); - char startFuncName[TSDB_FUNC_NAME_LEN + 6] = {0}; - char *startSuffix = "_start"; - strncpy(startFuncName, processFuncName, sizeof(startFuncName)); - strncat(startFuncName, startSuffix, strlen(startSuffix)); - uv_dlsym(&udfCtx->lib, startFuncName, (void **)(&udfCtx->aggStartFunc)); - char finishFuncName[TSDB_FUNC_NAME_LEN + 7] = {0}; - char *finishSuffix = "_finish"; - strncpy(finishFuncName, processFuncName, sizeof(finishFuncName)); - strncat(finishFuncName, finishSuffix, strlen(finishSuffix)); - uv_dlsym(&udfCtx->lib, finishFuncName, (void **)(&udfCtx->aggFinishFunc)); - char mergeFuncName[TSDB_FUNC_NAME_LEN + 6] = {0}; - char *mergeSuffix = "_merge"; - strncpy(mergeFuncName, processFuncName, sizeof(mergeFuncName)); - strncat(mergeFuncName, mergeSuffix, strlen(mergeSuffix)); - uv_dlsym(&udfCtx->lib, mergeFuncName, (void **)(&udfCtx->aggMergeFunc)); + udfdCPluginUdfInitLoadAggFuncs(udfCtx, udfName); } + int32_t code = 0; if (udfCtx->initFunc) { - // TODO: handle init call return error code = (udfCtx->initFunc)(); if (code != 0) { uv_dlclose(&udfCtx->lib); @@ -215,6 +229,7 @@ typedef struct SUdfdContext { SArray *residentFuncs; + char udfDataDir[PATH_MAX]; bool printVersion; } SUdfdContext; @@ -241,10 +256,12 @@ typedef struct SUvUdfWork { struct SUvUdfWork *pWorkNext; } SUvUdfWork; -typedef enum { UDF_STATE_INIT = 0, UDF_STATE_LOADING, UDF_STATE_READY} EUdfState; +typedef enum { UDF_STATE_INIT = 0, UDF_STATE_LOADING, UDF_STATE_READY } EUdfState; typedef struct SUdf { - char name[TSDB_FUNC_NAME_LEN + 1]; + char name[TSDB_FUNC_NAME_LEN + 1]; + int32_t version; + int64_t createdTime; int8_t funcType; int8_t scriptType; @@ -262,9 +279,11 @@ typedef struct SUdf { SUdfScriptPlugin *scriptPlugin; void *scriptUdfCtx; + + int64_t lastFetchTime; // last fetch time in milliseconds + bool expired; } SUdf; -// TODO: add private udf structure. typedef struct SUdfcFuncHandle { SUdf *udf; } SUdfcFuncHandle; @@ -317,6 +336,9 @@ static void udfdCloseWalkCb(uv_handle_t *handle, void *arg); static int32_t udfdRun(); static void udfdConnectMnodeThreadFunc(void *args); +SUdf *udfdNewUdf(const char *udfName); +void udfdGetFuncBodyPath(const SUdf *udf, char *path); + void udfdInitializeCPlugin(SUdfScriptPlugin *plugin) { plugin->scriptType = TSDB_FUNC_SCRIPT_BIN_LIB; plugin->openFunc = udfdCPluginOpen; @@ -369,12 +391,13 @@ int32_t udfdInitializePythonPlugin(SUdfScriptPlugin *plugin) { } if (plugin->openFunc) { - int16_t lenPythonPath = strlen(tsUdfdLdLibPath) + strlen(tsTempDir) + 1 + 1; // tsTempDir:tsUdfdLdLibPath - char *pythonPath = taosMemoryMalloc(lenPythonPath); + int16_t lenPythonPath = + strlen(tsUdfdLdLibPath) + strlen(global.udfDataDir) + 1 + 1; // global.udfDataDir:tsUdfdLdLibPath + char *pythonPath = taosMemoryMalloc(lenPythonPath); #ifdef WINDOWS - snprintf(pythonPath, lenPythonPath, "%s;%s", tsTempDir, tsUdfdLdLibPath); + snprintf(pythonPath, lenPythonPath, "%s;%s", global.udfDataDir, tsUdfdLdLibPath); #else - snprintf(pythonPath, lenPythonPath, "%s:%s", tsTempDir, tsUdfdLdLibPath); + snprintf(pythonPath, lenPythonPath, "%s:%s", global.udfDataDir, tsUdfdLdLibPath); #endif SScriptUdfEnvItem items[] = {{"PYTHONPATH", pythonPath}, {"LOGDIR", tsLogDir}}; err = plugin->openFunc(items, 2); @@ -439,7 +462,7 @@ int32_t udfdInitScriptPlugin(int8_t scriptType) { return err; } break; - } + } default: fnError("udf script type %d not supported", scriptType); taosMemoryFree(plugin); @@ -499,28 +522,14 @@ void convertUdf2UdfInfo(SUdf *udf, SScriptUdfInfo *udfInfo) { udfInfo->funcType = UDF_FUNC_TYPE_SCALAR; } udfInfo->name = udf->name; + udfInfo->version = udf->version; + udfInfo->createdTime = udf->createdTime; udfInfo->outputLen = udf->outputLen; udfInfo->outputType = udf->outputType; udfInfo->path = udf->path; udfInfo->scriptType = udf->scriptType; } -int32_t udfdRenameUdfFile(SUdf *udf) { - char newPath[PATH_MAX]; - if (udf->scriptType == TSDB_FUNC_SCRIPT_BIN_LIB) { - snprintf(newPath, PATH_MAX, "%s/lib%s.so", tsTempDir, udf->name); - taosRenameFile(udf->path, newPath); - sprintf(udf->path, "%s", newPath); - } else if (udf->scriptType == TSDB_FUNC_SCRIPT_PYTHON) { - snprintf(newPath, PATH_MAX, "%s/%s.py", tsTempDir, udf->name); - taosRenameFile(udf->path, newPath); - sprintf(udf->path, "%s", newPath); - } else { - return TSDB_CODE_UDF_SCRIPT_NOT_SUPPORTED; - } - return 0; -} - int32_t udfdInitUdf(char *udfName, SUdf *udf) { int32_t err = 0; err = udfdFillUdfInfoFromMNode(global.clientRpc, udfName, udf); @@ -545,8 +554,6 @@ int32_t udfdInitUdf(char *udfName, SUdf *udf) { uv_mutex_unlock(&global.scriptPluginsMutex); udf->scriptPlugin = global.scriptPlugins[udf->scriptType]; - udfdRenameUdfFile(udf); - SScriptUdfInfo info = {0}; convertUdf2UdfInfo(udf, &info); err = udf->scriptPlugin->udfInitFunc(&info, &udf->scriptUdfCtx); @@ -554,39 +561,61 @@ int32_t udfdInitUdf(char *udfName, SUdf *udf) { fnError("udf name %s init failed. error %d", udfName, err); return err; } + + fnInfo("udf init succeeded. name %s type %d context %p", udf->name, udf->scriptType, (void *)udf->scriptUdfCtx); return 0; } +SUdf *udfdNewUdf(const char *udfName) { + SUdf *udfNew = taosMemoryCalloc(1, sizeof(SUdf)); + udfNew->refCount = 1; + udfNew->lastFetchTime = taosGetTimestampMs(); + strncpy(udfNew->name, udfName, TSDB_FUNC_NAME_LEN); + + udfNew->state = UDF_STATE_INIT; + uv_mutex_init(&udfNew->lock); + uv_cond_init(&udfNew->condReady); + + udfNew->resident = false; + udfNew->expired = false; + for (int32_t i = 0; i < taosArrayGetSize(global.residentFuncs); ++i) { + char *funcName = taosArrayGet(global.residentFuncs, i); + if (strcmp(udfName, funcName) == 0) { + udfNew->resident = true; + break; + } + } + return udfNew; +} + SUdf *udfdGetOrCreateUdf(const char *udfName) { - SUdf *udf = NULL; uv_mutex_lock(&global.udfsMutex); - SUdf **udfInHash = taosHashGet(global.udfsHash, udfName, strlen(udfName)); - if (udfInHash) { - ++(*udfInHash)->refCount; - udf = *udfInHash; - uv_mutex_unlock(&global.udfsMutex); - } else { - SUdf *udfNew = taosMemoryCalloc(1, sizeof(SUdf)); - udfNew->refCount = 1; - strncpy(udfNew->name, udfName, TSDB_FUNC_NAME_LEN); - - udfNew->state = UDF_STATE_INIT; - uv_mutex_init(&udfNew->lock); - uv_cond_init(&udfNew->condReady); - - udf = udfNew; - udf->resident = false; - for (int32_t i = 0; i < taosArrayGetSize(global.residentFuncs); ++i) { - char *funcName = taosArrayGet(global.residentFuncs, i); - if (strcmp(udfName, funcName) == 0) { - udf->resident = true; - break; - } + SUdf **pUdfHash = taosHashGet(global.udfsHash, udfName, strlen(udfName)); + int64_t currTime = taosGetTimestampSec(); + bool expired = false; + if (pUdfHash) { + expired = currTime - (*pUdfHash)->lastFetchTime > 10 * 1000; // 10s + if (!expired) { + ++(*pUdfHash)->refCount; + SUdf *udf = *pUdfHash; + uv_mutex_unlock(&global.udfsMutex); + fnInfo("udfd reuse existing udf. udf %s udf version %d, udf created time %" PRIx64, udf->name, udf->version, + udf->createdTime); + return udf; + } else { + (*pUdfHash)->expired = true; + taosHashRemove(global.udfsHash, udfName, strlen(udfName)); + fnInfo("udfd expired, check for new version. existing udf %s udf version %d, udf created time %" PRIx64, + (*pUdfHash)->name, (*pUdfHash)->version, (*pUdfHash)->createdTime); } - SUdf **pUdf = &udf; - taosHashPut(global.udfsHash, udfName, strlen(udfName), pUdf, POINTER_BYTES); - uv_mutex_unlock(&global.udfsMutex); } + + SUdf *udf = udfdNewUdf(udfName); + + SUdf **pUdf = &udf; + taosHashPut(global.udfsHash, udfName, strlen(udfName), pUdf, POINTER_BYTES); + uv_mutex_unlock(&global.udfsMutex); + return udf; } @@ -757,12 +786,13 @@ void udfdProcessTeardownRequest(SUvUdfWork *uvUdf, SUdfRequest *request) { uv_mutex_lock(&global.udfsMutex); udf->refCount--; - if (udf->refCount == 0 && !udf->resident) { + if (udf->refCount == 0 && (!udf->resident || udf->expired)) { unloadUdf = true; taosHashRemove(global.udfsHash, udf->name, strlen(udf->name)); } uv_mutex_unlock(&global.udfsMutex); if (unloadUdf) { + fnInfo("udf teardown. udf name: %s type %d: context %p", udf->name, udf->scriptType, (void *)(udf->scriptUdfCtx)); uv_cond_destroy(&udf->condReady); uv_mutex_destroy(&udf->lock); code = udf->scriptPlugin->udfDestroyFunc(udf->scriptUdfCtx); @@ -787,6 +817,61 @@ void udfdProcessTeardownRequest(SUvUdfWork *uvUdf, SUdfRequest *request) { return; } +void udfdGetFuncBodyPath(const SUdf *udf, char *path) { + if (udf->scriptType == TSDB_FUNC_SCRIPT_BIN_LIB) { +#ifdef WINDOWS + snprintf(path, PATH_MAX, "%s%s_%d_%" PRIx64 ".dll", global.udfDataDir, udf->name, udf->version, udf->createdTime); +#else + snprintf(path, PATH_MAX, "%s/lib%s_%d_%" PRIx64 ".so", global.udfDataDir, udf->name, udf->version, + udf->createdTime); +#endif + } else if (udf->scriptType == TSDB_FUNC_SCRIPT_PYTHON) { +#ifdef WINDOWS + snprintf(path, PATH_MAX, "%s%s_%d_%" PRIx64 ".py", global.udfDataDir, udf->name, udf->version, udf->createdTime); +#else + snprintf(path, PATH_MAX, "%s/%s_%d_%" PRIx64 ".py", global.udfDataDir, udf->name, udf->version, udf->createdTime); +#endif + } else { +#ifdef WINDOWS + snprintf(path, PATH_MAX, "%s%s_%d_%" PRIx64, global.udfDataDir, udf->name, udf->version, udf->createdTime); +#else + snprintf(path, PATH_MAX, "%s/lib%s_%d_%" PRIx64, global.udfDataDir, udf->name, udf->version, udf->createdTime); +#endif + } +} + +int32_t udfdSaveFuncBodyToFile(SFuncInfo *pFuncInfo, SUdf *udf) { + if (!osDataSpaceAvailable()) { + terrno = TSDB_CODE_NO_AVAIL_DISK; + fnError("udfd create shared library failed since %s", terrstr(terrno)); + return terrno; + } + + char path[PATH_MAX] = {0}; + udfdGetFuncBodyPath(udf, path); + bool fileExist = !(taosStatFile(path, NULL, NULL) < 0); + if (fileExist) { + strncpy(udf->path, path, PATH_MAX); + fnInfo("udfd func body file. reuse existing file %s", path); + return TSDB_CODE_SUCCESS; + } + + TdFilePtr file = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC); + if (file == NULL) { + fnError("udfd write udf shared library: %s failed, error: %d %s", path, errno, strerror(errno)); + return TSDB_CODE_FILE_CORRUPTED; + } + int64_t count = taosWriteFile(file, pFuncInfo->pCode, pFuncInfo->codeSize); + if (count != pFuncInfo->codeSize) { + fnError("udfd write udf shared library failed"); + return TSDB_CODE_FILE_CORRUPTED; + } + taosCloseFile(&file); + + strncpy(udf->path, path, PATH_MAX); + return TSDB_CODE_SUCCESS; +} + void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { SUdfdRpcSendRecvInfo *msgInfo = (SUdfdRpcSendRecvInfo *)pMsg->info.ahandle; @@ -825,49 +910,25 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { } else if (msgInfo->rpcType == UDFD_RPC_RETRIVE_FUNC) { SRetrieveFuncRsp retrieveRsp = {0}; tDeserializeSRetrieveFuncRsp(pMsg->pCont, pMsg->contLen, &retrieveRsp); - if (retrieveRsp.pFuncInfos == NULL) { - goto _return; - } + SFuncInfo *pFuncInfo = (SFuncInfo *)taosArrayGet(retrieveRsp.pFuncInfos, 0); - // SUdf *udf = msgInfo->param; - SUdf *udf = msgInfo->param; + SUdf *udf = msgInfo->param; udf->funcType = pFuncInfo->funcType; udf->scriptType = pFuncInfo->scriptType; udf->outputType = pFuncInfo->outputType; udf->outputLen = pFuncInfo->outputLen; udf->bufSize = pFuncInfo->bufSize; - if (!osTempSpaceAvailable()) { - terrno = TSDB_CODE_NO_AVAIL_DISK; - msgInfo->code = terrno; - fnError("udfd create shared library failed since %s", terrstr(terrno)); - goto _return; - } - - char path[PATH_MAX] = {0}; -#ifdef WINDOWS - snprintf(path, sizeof(path), "%s%s", tsTempDir, pFuncInfo->name); -#else - snprintf(path, sizeof(path), "%s/%s", tsTempDir, pFuncInfo->name); -#endif - TdFilePtr file = taosOpenFile(path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC); - if (file == NULL) { - fnError("udfd write udf shared library: %s failed, error: %d %s", path, errno, strerror(errno)); - msgInfo->code = TSDB_CODE_FILE_CORRUPTED; - goto _return; - } - - int64_t count = taosWriteFile(file, pFuncInfo->pCode, pFuncInfo->codeSize); - if (count != pFuncInfo->codeSize) { - fnError("udfd write udf shared library failed"); - msgInfo->code = TSDB_CODE_FILE_CORRUPTED; - goto _return; + SFuncExtraInfo *pFuncExtraInfo = (SFuncExtraInfo *)taosArrayGet(retrieveRsp.pFuncExtraInfos, 0); + udf->version = pFuncExtraInfo->funcVersion; + udf->createdTime = pFuncExtraInfo->funcCreatedTime; + msgInfo->code = udfdSaveFuncBodyToFile(pFuncInfo, udf); + if (msgInfo->code != 0) { + udf->lastFetchTime = 0; } - taosCloseFile(&file); - strncpy(udf->path, path, PATH_MAX); tFreeSFuncInfo(pFuncInfo); taosArrayDestroy(retrieveRsp.pFuncInfos); - msgInfo->code = 0; + taosArrayDestroy(retrieveRsp.pFuncExtraInfos); } _return: @@ -916,6 +977,7 @@ int32_t udfdConnectToMnode() { tstrncpy(connReq.passwd, pass, sizeof(connReq.passwd)); connReq.pid = taosGetPId(); connReq.startTime = taosGetTimestampMs(); + strcpy(connReq.sVer, version); int32_t contLen = tSerializeSConnectReq(NULL, 0, &connReq); void *pReq = rpcMallocCont(contLen); @@ -1358,7 +1420,7 @@ int32_t udfdDeinitResidentFuncs() { char *funcName = taosArrayGet(global.residentFuncs, i); SUdf **udfInHash = taosHashGet(global.udfsHash, funcName, strlen(funcName)); if (udfInHash) { - SUdf *udf = *udfInHash; + SUdf *udf = *udfInHash; int32_t code = udf->scriptPlugin->udfDestroyFunc(udf->scriptUdfCtx); fnDebug("udfd destroy function returns %d", code); taosHashRemove(global.udfsHash, funcName, strlen(funcName)); @@ -1375,6 +1437,24 @@ int32_t udfdCleanup() { return 0; } +int32_t udfdCreateUdfSourceDir() { + snprintf(global.udfDataDir, PATH_MAX, "%s/.udf", tsDataDir); + int32_t code = taosMkDir(global.udfDataDir); + if (code != TSDB_CODE_SUCCESS) { + snprintf(global.udfDataDir, PATH_MAX, "%s/.udf", tsTempDir); + code = taosMkDir(global.udfDataDir); + } + fnInfo("udfd create udf source directory %s. result: %s", global.udfDataDir, tstrerror(code)); + + return code; +} + +int32_t udfdDestroyUdfSourceDir() { + fnInfo("destory udf source directory %s", global.udfDataDir); + taosRemoveDir(global.udfDataDir); + return 0; +} + int main(int argc, char *argv[]) { if (!taosCheckSystemIsLittleEnd()) { printf("failed to start since on non-little-end machines\n"); @@ -1403,10 +1483,15 @@ int main(int argc, char *argv[]) { initEpSetFromCfg(tsFirst, tsSecond, &global.mgmtEp); if (udfdOpenClientRpc() != 0) { - fnError("open rpc connection to mnode failure"); + fnError("open rpc connection to mnode failed"); return -3; } + if (udfdCreateUdfSourceDir() != 0) { + fnError("create udf source directory failed"); + return -4; + } + if (udfdUvInit() != 0) { fnError("uv init failure"); return -5; @@ -1420,6 +1505,7 @@ int main(int argc, char *argv[]) { udfdRun(); removeListeningPipe(); + udfdDestroyUdfSourceDir(); udfdCloseClientRpc(); udfdDeinitResidentFuncs(); diff --git a/source/libs/index/src/indexFilter.c b/source/libs/index/src/indexFilter.c index 0d13db2f358587c349ef79b7411e8ac45810b883..ec5fc5ad2a50c07d1c4784911d7c39f0fedce9fb 100644 --- a/source/libs/index/src/indexFilter.c +++ b/source/libs/index/src/indexFilter.c @@ -634,7 +634,7 @@ static FORCE_INLINE int32_t sifGetOperFn(int32_t funcId, sif_func_t *func, SIdxF } static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) { - int32_t code = 0; + int32_t code = -1; if (sifValidOp(node->opType) < 0) { code = TSDB_CODE_QRY_INVALID_INPUT; ctx->code = code; @@ -654,7 +654,7 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) { SIFParam *params = NULL; SIF_ERR_RET(sifInitOperParams(¶ms, node, ctx)); - if (params[0].status == SFLT_NOT_INDEX && (nParam > 1 && params[1].status == SFLT_NOT_INDEX)) { + if (params[0].status == SFLT_NOT_INDEX || (nParam > 1 && params[1].status == SFLT_NOT_INDEX)) { output->status = SFLT_NOT_INDEX; goto _return; } @@ -664,6 +664,7 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) { sif_func_t operFn = sifNullFunc; if (!ctx->noExec) { + code = 0; SIF_ERR_JRET(sifGetOperFn(node->opType, &operFn, &output->status)); SIF_ERR_JRET(operFn(¶ms[0], nParam > 1 ? ¶ms[1] : NULL, output)); } else { @@ -672,11 +673,17 @@ static int32_t sifExecOper(SOperatorNode *node, SIFCtx *ctx, SIFParam *output) { output->status = SFLT_NOT_INDEX; goto _return; } + code = 0; SIF_ERR_JRET(sifGetOperFn(node->opType, &operFn, &output->status)); } _return: for (int i = 0; i < nParam; i++) sifFreeParam(¶ms[i]); taosMemoryFree(params); + if (code != 0) { + output->status = SFLT_NOT_INDEX; + } else { + output->status = SFLT_COARSE_INDEX; + } return code; } @@ -717,7 +724,7 @@ _return: static EDealRes sifWalkFunction(SNode *pNode, void *context) { SFunctionNode *node = (SFunctionNode *)pNode; - SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t))}; + SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t)), .status = SFLT_COARSE_INDEX}; SIFCtx *ctx = context; ctx->code = sifExecFunction(node, ctx, &output); @@ -735,7 +742,7 @@ static EDealRes sifWalkFunction(SNode *pNode, void *context) { static EDealRes sifWalkLogic(SNode *pNode, void *context) { SLogicConditionNode *node = (SLogicConditionNode *)pNode; - SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t))}; + SIFParam output = {.result = taosArrayInit(8, sizeof(uint64_t)), .status = SFLT_COARSE_INDEX}; SIFCtx *ctx = context; ctx->code = sifExecLogic(node, ctx, &output); @@ -831,6 +838,7 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) { if (res->result != NULL) { taosArrayAddAll(pDst->result, res->result); } + pDst->status = res->status; sifFreeParam(res); taosHashRemove(ctx.pRes, (void *)&pNode, POINTER_BYTES); @@ -887,16 +895,20 @@ int32_t doFilterTag(SNode *pFilterNode, SIndexMetaArg *metaArg, SArray *result, SFilterInfo *filter = NULL; SArray *output = taosArrayInit(8, sizeof(uint64_t)); - SIFParam param = {.arg = *metaArg, .result = output}; + SIFParam param = {.arg = *metaArg, .result = output, .status = SFLT_NOT_INDEX}; int32_t code = sifCalculate((SNode *)pFilterNode, ¶m); if (code != 0) { sifFreeParam(¶m); return code; } + if (param.status == SFLT_NOT_INDEX) { + *status = param.status; + } else { + *status = st; + } taosArrayAddAll(result, param.result); sifFreeParam(¶m); - *status = st; return TSDB_CODE_SUCCESS; } diff --git a/source/libs/index/src/indexFstFile.c b/source/libs/index/src/indexFstFile.c index 40c50ed9cb97fd0ea64eb8d50bcf04801a24a89b..9e7ed5210425520f7b7c02a7f9b2edc6d98756ed 100644 --- a/source/libs/index/src/indexFstFile.c +++ b/source/libs/index/src/indexFstFile.c @@ -127,8 +127,6 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of blk->blockId = blkId; blk->nread = taosPReadFile(ctx->file.pFile, blk->buf, kBlockSize, blkId * kBlockSize); ASSERTS(blk->nread <= kBlockSize, "index read incomplete data"); - if (blk->nread > kBlockSize) break; - if (blk->nread < kBlockSize && blk->nread < len) { taosMemoryFree(blk); break; diff --git a/source/libs/monitor/src/monMain.c b/source/libs/monitor/src/monMain.c index b23a36d4df3acaef40116b2fd66559a661e3f8c1..949e91198adcb69301fbc177b721289d6d736651 100644 --- a/source/libs/monitor/src/monMain.c +++ b/source/libs/monitor/src/monMain.c @@ -210,6 +210,8 @@ static void monGenClusterJson(SMonInfo *pMonitor) { tjsonAddDoubleToObject(pJson, "vnodes_total", pInfo->vnodes_total); tjsonAddDoubleToObject(pJson, "vnodes_alive", pInfo->vnodes_alive); tjsonAddDoubleToObject(pJson, "connections_total", pInfo->connections_total); + tjsonAddDoubleToObject(pJson, "topics_total", pInfo->topics_toal); + tjsonAddDoubleToObject(pJson, "streams_total", pInfo->streams_total); SJson *pDnodesJson = tjsonAddArrayToObject(pJson, "dnodes"); if (pDnodesJson == NULL) return; diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index e18de1c1d2fd6215f81bd08178a81400dadb4932..0aeb83ce0812cf52bd3add4b2b0276fe051d00f3 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -173,6 +173,8 @@ const char* nodesNodeName(ENodeType type) { return "DropStreamStmt"; case QUERY_NODE_BALANCE_VGROUP_STMT: return "BalanceVgroupStmt"; + case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT: + return "BalanceVgroupLeaderStmt"; case QUERY_NODE_MERGE_VGROUP_STMT: return "MergeVgroupStmt"; case QUERY_NODE_SHOW_DB_ALIVE_STMT: @@ -6433,6 +6435,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { return dropStreamStmtToJson(pObj, pJson); case QUERY_NODE_BALANCE_VGROUP_STMT: return TSDB_CODE_SUCCESS; // SBalanceVgroupStmt has no fields to serialize. + case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT: + return TSDB_CODE_SUCCESS; // SBalanceVgroupLeaderStmt has no fields to serialize. case QUERY_NODE_MERGE_VGROUP_STMT: return mergeVgroupStmtToJson(pObj, pJson); case QUERY_NODE_REDISTRIBUTE_VGROUP_STMT: @@ -6741,6 +6745,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { return jsonToDropStreamStmt(pJson, pObj); case QUERY_NODE_BALANCE_VGROUP_STMT: return TSDB_CODE_SUCCESS; // SBalanceVgroupStmt has no fields to deserialize. + case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT: + return TSDB_CODE_SUCCESS; // SBalanceVgroupLeaderStmt has no fields to deserialize. case QUERY_NODE_MERGE_VGROUP_STMT: return jsonToMergeVgroupStmt(pJson, pObj); case QUERY_NODE_REDISTRIBUTE_VGROUP_STMT: diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 8d6c3288b907e0ee8678f1d6970410bec351b758..4180ba1d6c6879a5589f532784f711a28e740d3d 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -386,6 +386,8 @@ SNode* nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SDropStreamStmt)); case QUERY_NODE_BALANCE_VGROUP_STMT: return makeNode(type, sizeof(SBalanceVgroupStmt)); + case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT: + return makeNode(type, sizeof(SBalanceVgroupLeaderStmt)); case QUERY_NODE_MERGE_VGROUP_STMT: return makeNode(type, sizeof(SMergeVgroupStmt)); case QUERY_NODE_REDISTRIBUTE_VGROUP_STMT: @@ -923,9 +925,14 @@ void nodesDestroyNode(SNode* pNode) { taosMemoryFree(((SDescribeStmt*)pNode)->pMeta); break; case QUERY_NODE_RESET_QUERY_CACHE_STMT: // no pointer field - case QUERY_NODE_COMPACT_DATABASE_STMT: // no pointer field - case QUERY_NODE_CREATE_FUNCTION_STMT: // no pointer field - case QUERY_NODE_DROP_FUNCTION_STMT: // no pointer field + case QUERY_NODE_COMPACT_DATABASE_STMT: { + SCompactDatabaseStmt* pStmt = (SCompactDatabaseStmt*)pNode; + nodesDestroyNode(pStmt->pStart); + nodesDestroyNode(pStmt->pEnd); + break; + } + case QUERY_NODE_CREATE_FUNCTION_STMT: // no pointer field + case QUERY_NODE_DROP_FUNCTION_STMT: // no pointer field break; case QUERY_NODE_CREATE_STREAM_STMT: { SCreateStreamStmt* pStmt = (SCreateStreamStmt*)pNode; @@ -937,6 +944,7 @@ void nodesDestroyNode(SNode* pNode) { } case QUERY_NODE_DROP_STREAM_STMT: // no pointer field case QUERY_NODE_BALANCE_VGROUP_STMT: // no pointer field + case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT: // no pointer field case QUERY_NODE_MERGE_VGROUP_STMT: // no pointer field break; case QUERY_NODE_REDISTRIBUTE_VGROUP_STMT: diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 10d4adf17db22e4a8068a9c702cd1fda933ec6b3..69043e8915b3526548cf7976b4faea0ee3e8b986 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -212,7 +212,8 @@ SNode* createExplainStmt(SAstCreateContext* pCxt, bool analyze, SNode* pOptions, SNode* createDescribeStmt(SAstCreateContext* pCxt, SNode* pRealTable); SNode* createResetQueryCacheStmt(SAstCreateContext* pCxt); SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool aggFunc, const SToken* pFuncName, - const SToken* pLibPath, SDataType dataType, int32_t bufSize, const SToken* pLanguage); + const SToken* pLibPath, SDataType dataType, int32_t bufSize, const SToken* pLanguage, + bool orReplace); SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pFuncName); SNode* createStreamOptions(SAstCreateContext* pCxt); SNode* setStreamOptions(SAstCreateContext* pCxt, SNode* pOptions, EStreamOptionsSetFlag setflag, SToken* pToken, @@ -223,6 +224,7 @@ SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToke SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId); SNode* createKillQueryStmt(SAstCreateContext* pCxt, const SToken* pQueryId); SNode* createBalanceVgroupStmt(SAstCreateContext* pCxt); +SNode* createBalanceVgroupLeaderStmt(SAstCreateContext* pCxt); SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, const SToken* pVgId2); SNode* createRedistributeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId, SNodeList* pDnodes); SNode* createSplitVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 72a0a70e36da076de10c0939c5560a68c7f9cbdd..ebd8f51f900ad6b244cd9c66894f91ff20c7d266 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -237,6 +237,18 @@ alter_db_option(A) ::= REPLICA NK_INTEGER(B). alter_db_option(A) ::= WAL_LEVEL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; } alter_db_option(A) ::= STT_TRIGGER NK_INTEGER(B). { A.type = DB_OPTION_STT_TRIGGER; A.val = B; } alter_db_option(A) ::= MINROWS NK_INTEGER(B). { A.type = DB_OPTION_MINROWS; A.val = B; } +alter_db_option(A) ::= WAL_RETENTION_PERIOD NK_INTEGER(B). { A.type = DB_OPTION_WAL_RETENTION_PERIOD; A.val = B; } +alter_db_option(A) ::= WAL_RETENTION_PERIOD NK_MINUS(B) NK_INTEGER(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A.type = DB_OPTION_WAL_RETENTION_PERIOD; A.val = t; + } +alter_db_option(A) ::= WAL_RETENTION_SIZE NK_INTEGER(B). { A.type = DB_OPTION_WAL_RETENTION_SIZE; A.val = B; } +alter_db_option(A) ::= WAL_RETENTION_SIZE NK_MINUS(B) NK_INTEGER(C). { + SToken t = B; + t.n = (C.z + C.n) - B.z; + A.type = DB_OPTION_WAL_RETENTION_SIZE; A.val = t; + } %type integer_list { SNodeList* } %destructor integer_list { nodesDestroyList($$); } @@ -541,8 +553,9 @@ explain_options(A) ::= explain_options(B) VERBOSE NK_BOOL(C). explain_options(A) ::= explain_options(B) RATIO NK_FLOAT(C). { A = setExplainRatio(pCxt, B, &C); } /************************************************ create/drop function ************************************************/ -cmd ::= CREATE agg_func_opt(A) FUNCTION not_exists_opt(F) function_name(B) - AS NK_STRING(C) OUTPUTTYPE type_name(D) bufsize_opt(E) language_opt(G). { pCxt->pRootNode = createCreateFunctionStmt(pCxt, F, A, &B, &C, D, E, &G); } +cmd ::= CREATE or_replace_opt(H) agg_func_opt(A) FUNCTION not_exists_opt(F) + function_name(B) AS NK_STRING(C) OUTPUTTYPE type_name(D) bufsize_opt(E) + language_opt(G). { pCxt->pRootNode = createCreateFunctionStmt(pCxt, F, A, &B, &C, D, E, &G, H); } cmd ::= DROP FUNCTION exists_opt(B) function_name(A). { pCxt->pRootNode = createDropFunctionStmt(pCxt, B, &A); } %type agg_func_opt { bool } @@ -560,6 +573,11 @@ bufsize_opt(A) ::= BUFSIZE NK_INTEGER(B). language_opt(A) ::= . { A = nil_token; } language_opt(A) ::= LANGUAGE NK_STRING(B). { A = B; } +%type or_replace_opt { bool } +%destructor or_replace_opt { } +or_replace_opt(A) ::= . { A = false; } +or_replace_opt(A) ::= OR REPLACE. { A = true; } + /************************************************ create/drop stream **************************************************/ cmd ::= CREATE STREAM not_exists_opt(E) stream_name(A) stream_options(B) INTO full_table_name(C) col_list_opt(H) tag_def_or_ref_opt(F) subtable_opt(G) @@ -597,6 +615,7 @@ cmd ::= KILL TRANSACTION NK_INTEGER(A). /************************************************ merge/redistribute/ vgroup ******************************************/ cmd ::= BALANCE VGROUP. { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } +cmd ::= BALANCE VGROUP LEADER. { pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt); } cmd ::= MERGE VGROUP NK_INTEGER(A) NK_INTEGER(B). { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &A, &B); } cmd ::= REDISTRIBUTE VGROUP NK_INTEGER(A) dnode_list(B). { pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &A, B); } cmd ::= SPLIT VGROUP NK_INTEGER(A). { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &A); } @@ -1123,5 +1142,5 @@ null_ordering_opt(A) ::= NULLS FIRST. null_ordering_opt(A) ::= NULLS LAST. { A = NULL_ORDER_LAST; } %fallback ABORT AFTER ATTACH BEFORE BEGIN BITAND BITNOT BITOR BLOCKS CHANGE COMMA CONCAT CONFLICT COPY DEFERRED DELIMITERS DETACH DIVIDE DOT EACH END FAIL - FILE FOR GLOB ID IMMEDIATE IMPORT INITIALLY INSTEAD ISNULL KEY MODULES NK_BITNOT NK_SEMI NOTNULL OF PLUS PRIVILEGE RAISE REPLACE RESTRICT ROW SEMI STAR STATEMENT + FILE FOR GLOB ID IMMEDIATE IMPORT INITIALLY INSTEAD ISNULL KEY MODULES NK_BITNOT NK_SEMI NOTNULL OF PLUS PRIVILEGE RAISE RESTRICT ROW SEMI STAR STATEMENT STRICT STRING TIMES VALUES VARIABLE VIEW WAL. diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index a761b7a7b08decfefd3c2bfd6c8c974afce0945c..2ec942d890f5c865f8a0cda0f8077fdb954c78f8 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -925,8 +925,8 @@ SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) { pOptions->numOfVgroups = -1; pOptions->singleStable = -1; pOptions->schemaless = -1; - pOptions->walRetentionPeriod = -1; - pOptions->walRetentionSize = -1; + pOptions->walRetentionPeriod = -2; // -1 is a valid value + pOptions->walRetentionSize = -2; // -1 is a valid value pOptions->walRollPeriod = -1; pOptions->walSegmentSize = -1; pOptions->sstTrigger = -1; @@ -935,7 +935,8 @@ SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) { return (SNode*)pOptions; } -SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, void* pVal) { +static SNode* setDatabaseOptionImpl(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, void* pVal, + bool alter) { CHECK_PARSER_STATUS(pCxt); SDatabaseOptions* pDbOptions = (SDatabaseOptions*)pOptions; switch (type) { @@ -986,7 +987,9 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti break; case DB_OPTION_REPLICA: pDbOptions->replica = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); - updateWalOptionsDefault(pDbOptions); + if (!alter) { + updateWalOptionsDefault(pDbOptions); + } break; case DB_OPTION_STRICT: COPY_STRING_FORM_STR_TOKEN(pDbOptions->strictStr, (SToken*)pVal); @@ -1033,16 +1036,20 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti return pOptions; } +SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, void* pVal) { + return setDatabaseOptionImpl(pCxt, pOptions, type, pVal, false); +} + SNode* setAlterDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOption* pAlterOption) { CHECK_PARSER_STATUS(pCxt); switch (pAlterOption->type) { case DB_OPTION_KEEP: case DB_OPTION_RETENTIONS: - return setDatabaseOption(pCxt, pOptions, pAlterOption->type, pAlterOption->pList); + return setDatabaseOptionImpl(pCxt, pOptions, pAlterOption->type, pAlterOption->pList, true); default: break; } - return setDatabaseOption(pCxt, pOptions, pAlterOption->type, &pAlterOption->val); + return setDatabaseOptionImpl(pCxt, pOptions, pAlterOption->type, &pAlterOption->val, true); } SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken* pDbName, SNode* pOptions) { @@ -1794,7 +1801,8 @@ static int32_t convertUdfLanguageType(SAstCreateContext* pCxt, const SToken* pLa } SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool aggFunc, const SToken* pFuncName, - const SToken* pLibPath, SDataType dataType, int32_t bufSize, const SToken* pLanguage) { + const SToken* pLibPath, SDataType dataType, int32_t bufSize, const SToken* pLanguage, + bool orReplace) { CHECK_PARSER_STATUS(pCxt); if (pLibPath->n <= 2) { pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR; @@ -1806,6 +1814,7 @@ SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool } SCreateFunctionStmt* pStmt = (SCreateFunctionStmt*)nodesMakeNode(QUERY_NODE_CREATE_FUNCTION_STMT); CHECK_OUT_OF_MEM(pStmt); + pStmt->orReplace = orReplace; pStmt->ignoreExists = ignoreExists; COPY_STRING_FORM_ID_TOKEN(pStmt->funcName, pFuncName); pStmt->isAgg = aggFunc; @@ -1945,6 +1954,13 @@ SNode* createBalanceVgroupStmt(SAstCreateContext* pCxt) { return (SNode*)pStmt; } +SNode* createBalanceVgroupLeaderStmt(SAstCreateContext* pCxt) { + CHECK_PARSER_STATUS(pCxt); + SBalanceVgroupLeaderStmt* pStmt = (SBalanceVgroupLeaderStmt*)nodesMakeNode(QUERY_NODE_BALANCE_VGROUP_LEADER_STMT); + CHECK_OUT_OF_MEM(pStmt); + return (SNode*)pStmt; +} + SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, const SToken* pVgId2) { CHECK_PARSER_STATUS(pCxt); SMergeVgroupStmt* pStmt = (SMergeVgroupStmt*)nodesMakeNode(QUERY_NODE_MERGE_VGROUP_STMT); diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index b2fc88add1506336869dce1c33c19ff9e077a4d2..c25d0e7036aef4d979069976e6f0e221c2b84615 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -183,16 +183,18 @@ static int32_t calcConstProject(SNode* pProject, bool dual, SNode** pNew) { } else { code = scalarCalculateConstants(pProject, pNew); } - if (TSDB_CODE_SUCCESS == code && QUERY_NODE_VALUE == nodeType(*pNew) && NULL != pAssociation) { + if (TSDB_CODE_SUCCESS == code) { strcpy(((SExprNode*)*pNew)->aliasName, aliasName); - int32_t size = taosArrayGetSize(pAssociation); - for (int32_t i = 0; i < size; ++i) { - SNode** pCol = taosArrayGetP(pAssociation, i); - nodesDestroyNode(*pCol); - *pCol = nodesCloneNode(*pNew); - if (NULL == *pCol) { - code = TSDB_CODE_OUT_OF_MEMORY; - break; + if (QUERY_NODE_VALUE == nodeType(*pNew) && NULL != pAssociation) { + int32_t size = taosArrayGetSize(pAssociation); + for (int32_t i = 0; i < size; ++i) { + SNode** pCol = taosArrayGetP(pAssociation, i); + nodesDestroyNode(*pCol); + *pCol = nodesCloneNode(*pNew); + if (NULL == *pCol) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } } } } @@ -335,8 +337,14 @@ static SNodeList* getChildProjection(SNode* pStmt) { static void eraseSetOpChildProjection(SSetOperator* pSetOp, int32_t index) { SNodeList* pLeftProjs = getChildProjection(pSetOp->pLeft); nodesListErase(pLeftProjs, nodesListGetCell(pLeftProjs, index)); + if (QUERY_NODE_SET_OPERATOR == nodeType(pSetOp->pLeft)) { + eraseSetOpChildProjection((SSetOperator*)pSetOp->pLeft, index); + } SNodeList* pRightProjs = getChildProjection(pSetOp->pRight); nodesListErase(pRightProjs, nodesListGetCell(pRightProjs, index)); + if (QUERY_NODE_SET_OPERATOR == nodeType(pSetOp->pRight)) { + eraseSetOpChildProjection((SSetOperator*)pSetOp->pRight, index); + } } typedef struct SNotRefByOrderByCxt { @@ -361,11 +369,30 @@ static bool notRefByOrderBy(SColumnNode* pCol, SNodeList* pOrderByList) { return !cxt.hasThisCol; } +static bool isSetUselessCol(SSetOperator* pSetOp, int32_t index, SExprNode* pProj) { + if (!isUselessCol(pProj)) { + return false; + } + + SNodeList* pLeftProjs = getChildProjection(pSetOp->pLeft); + if (!isUselessCol((SExprNode*)nodesListGetNode(pLeftProjs, index))) { + return false; + } + + SNodeList* pRightProjs = getChildProjection(pSetOp->pRight); + if (!isUselessCol((SExprNode*)nodesListGetNode(pRightProjs, index))) { + return false; + } + + return true; +} + static int32_t calcConstSetOpProjections(SCalcConstContext* pCxt, SSetOperator* pSetOp, bool subquery) { int32_t index = 0; SNode* pProj = NULL; WHERE_EACH(pProj, pSetOp->pProjectionList) { - if (subquery && notRefByOrderBy((SColumnNode*)pProj, pSetOp->pOrderByList) && isUselessCol((SExprNode*)pProj)) { + if (subquery && notRefByOrderBy((SColumnNode*)pProj, pSetOp->pOrderByList) && + isSetUselessCol(pSetOp, index, (SExprNode*)pProj)) { ERASE_NODE(pSetOp->pProjectionList); eraseSetOpChildProjection(pSetOp, index); continue; diff --git a/source/libs/parser/src/parInsertSml.c b/source/libs/parser/src/parInsertSml.c index d6c107266950f0c21885f66f3ba4267c191b14f1..0bcd777d2a4bd332a146e6cceb1bb464cdbbe573 100644 --- a/source/libs/parser/src/parInsertSml.c +++ b/source/libs/parser/src/parInsertSml.c @@ -25,6 +25,8 @@ static void clearColValArray(SArray* pCols) { if (TSDB_DATA_TYPE_NCHAR == pCol->type) { taosMemoryFreeClear(pCol->value.pData); } + pCol->flag = CV_FLAG_NONE; + pCol->value.val = 0; } } @@ -70,7 +72,7 @@ static int32_t smlBoundColumnData(SArray* cols, SBoundColInfo* pBoundInfo, SSche SToken sToken = {.n = kv->keyLen, .z = (char*)kv->key}; col_id_t t = lastColIdx + 1; col_id_t index = ((t == 0 && !isTag) ? 0 : insFindCol(&sToken, t, pBoundInfo->numOfCols, pSchema)); - uDebug("SML, index:%d, t:%d, ncols:%d", index, t, pBoundInfo->numOfCols); + uTrace("SML, index:%d, t:%d, ncols:%d", index, t, pBoundInfo->numOfCols); if (index < 0 && t > 0) { index = insFindCol(&sToken, 0, t, pSchema); } @@ -345,6 +347,7 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc } if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)pUcs4, pColSchema->bytes - VARSTR_HEADER_SIZE, &len)) { if (errno == E2BIG) { + uError("sml bind taosMbsToUcs4 error, kv length:%d, bytes:%d, kv->value:%s", (int)kv->length, pColSchema->bytes, kv->value); buildInvalidOperationMsg(&pBuf, "value too long"); ret = TSDB_CODE_PAR_VALUE_TOO_LONG; goto end; diff --git a/source/libs/parser/src/parInsertSql.c b/source/libs/parser/src/parInsertSql.c index 3fbe23592a8ed2344b4df8898cec9f80c5dc906d..18d65dd47711e445633a4b2969decfab5f5dd07e 100644 --- a/source/libs/parser/src/parInsertSql.c +++ b/source/libs/parser/src/parInsertSql.c @@ -1492,6 +1492,7 @@ static void resetEnvPreTable(SInsertParseContext* pCxt, SVnodeModifyOpStmt* pStm pStmt->pBoundCols = NULL; pStmt->usingTableProcessing = false; pStmt->fileProcessing = false; + pStmt->usingTableName.type = 0; } // input pStmt->pSql: [(field1_name, ...)] [ USING ... ] VALUES ... | FILE ... @@ -1539,6 +1540,10 @@ static int32_t checkTableClauseFirstToken(SInsertParseContext* pCxt, SVnodeModif } } + if (TK_NK_ID != pTbName->type && TK_NK_STRING != pTbName->type && TK_NK_QUESTION != pTbName->type) { + return buildSyntaxErrMsg(&pCxt->msg, "table_name is expected", pTbName->z); + } + *pHasData = true; return TSDB_CODE_SUCCESS; } diff --git a/source/libs/parser/src/parInsertUtil.c b/source/libs/parser/src/parInsertUtil.c index 52d3569dcd15be1370ee2930796e1bd126efc09a..132a3b26187a833b5eeb3bd23ab8642331478635 100644 --- a/source/libs/parser/src/parInsertUtil.c +++ b/source/libs/parser/src/parInsertUtil.c @@ -404,6 +404,7 @@ static int32_t createVgroupDataCxt(STableDataCxt* pTableCxt, SHashObj* pVgroupHa int32_t code = taosHashPut(pVgroupHash, &pVgCxt->vgId, sizeof(pVgCxt->vgId), &pVgCxt, POINTER_BYTES); if (TSDB_CODE_SUCCESS == code) { taosArrayPush(pVgroupList, &pVgCxt); +// uDebug("td23101 2vgId:%d, uid:%" PRIu64, pVgCxt->vgId, pTableCxt->pMeta->uid); *pOutput = pVgCxt; } else { insDestroyVgroupDataCxt(pVgCxt); @@ -546,6 +547,7 @@ int32_t insBuildVgDataBlocks(SHashObj* pVgroupsHashObj, SArray* pVgDataCxtList, if (TSDB_CODE_SUCCESS == code) { dst->numOfTables = taosArrayGetSize(src->pData->aSubmitTbData); code = taosHashGetDup(pVgroupsHashObj, (const char*)&src->vgId, sizeof(src->vgId), &dst->vg); +// uError("td23101 3vgId:%d, numEps:%d", src->vgId, dst->vg.epSet.numOfEps); } if (TSDB_CODE_SUCCESS == code) { code = buildSubmitReq(src->vgId, src->pData, &dst->pData, &dst->size); @@ -564,53 +566,19 @@ int32_t insBuildVgDataBlocks(SHashObj* pVgroupsHashObj, SArray* pVgDataCxtList, return code; } -static int bindFileds(SBoundColInfo* pBoundInfo, SSchema* pSchema, TAOS_FIELD* fields, int numFields) { - bool* pUseCols = taosMemoryCalloc(pBoundInfo->numOfCols, sizeof(bool)); - if (NULL == pUseCols) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - pBoundInfo->numOfBound = 0; - - int16_t lastColIdx = -1; // last column found - int32_t code = TSDB_CODE_SUCCESS; +static bool findFileds(SSchema* pSchema, TAOS_FIELD* fields, int numFields) { for (int i = 0; i < numFields; i++) { - SToken token; - token.z = fields[i].name; - token.n = strlen(fields[i].name); - - int16_t t = lastColIdx + 1; - int16_t index = insFindCol(&token, t, pBoundInfo->numOfCols, pSchema); - if (index < 0 && t > 0) { - index = insFindCol(&token, 0, t, pSchema); - } - if (index < 0) { - uError("can not find column name:%s", token.z); - code = TSDB_CODE_PAR_INVALID_COLUMN; - break; - } else if (pUseCols[index]) { - code = TSDB_CODE_PAR_INVALID_COLUMN; - uError("duplicated column name:%s", token.z); - break; - } else { - lastColIdx = index; - pUseCols[index] = true; - pBoundInfo->pColIndex[pBoundInfo->numOfBound] = index; - ++pBoundInfo->numOfBound; + if(strcmp(pSchema->name, fields[i].name) == 0){ + return true; } } - if (TSDB_CODE_SUCCESS == code && !pUseCols[0]) { - uError("primary timestamp column can not be null:"); - code = TSDB_CODE_PAR_INVALID_COLUMN; - } - - taosMemoryFree(pUseCols); - return code; + return false; } int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreateTbReq* pCreateTb, TAOS_FIELD* tFields, int numFields, bool needChangeLength) { + void* tmp = taosHashGet(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid, sizeof(pTableMeta->uid)); STableDataCxt* pTableCxt = NULL; int ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid, sizeof(pTableMeta->uid), pTableMeta, &pCreateTb, &pTableCxt, true); @@ -618,19 +586,14 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate uError("insGetTableDataCxt error"); goto end; } - if (tFields != NULL) { - ret = bindFileds(&pTableCxt->boundColsInfo, getTableColumnSchema(pTableMeta), tFields, numFields); + + if(tmp == NULL){ + ret = initTableColSubmitData(pTableCxt); if (ret != TSDB_CODE_SUCCESS) { - uError("bindFileds error"); + uError("initTableColSubmitData error"); goto end; } } - // no need to bind, because select * get all fields - ret = initTableColSubmitData(pTableCxt); - if (ret != TSDB_CODE_SUCCESS) { - uError("initTableColSubmitData error"); - goto end; - } char* p = (char*)data; // | version | total length | total rows | total columns | flag seg| block group id | column schema | each column @@ -658,35 +621,83 @@ int rawBlockBindData(SQuery* query, STableMeta* pTableMeta, void* data, SVCreate SSchema* pSchema = getTableColumnSchema(pTableCxt->pMeta); SBoundColInfo* boundInfo = &pTableCxt->boundColsInfo; - if (boundInfo->numOfBound != numOfCols) { - uError("boundInfo->numOfBound:%d != numOfCols:%d", boundInfo->numOfBound, numOfCols); + if (tFields != NULL && numFields != numOfCols) { + uError("numFields:%d != numOfCols:%d", numFields, numOfCols); ret = TSDB_CODE_INVALID_PARA; goto end; } - for (int c = 0; c < boundInfo->numOfBound; ++c) { - SSchema* pColSchema = &pSchema[boundInfo->pColIndex[c]]; - SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, c); + if (tFields != NULL && numFields > boundInfo->numOfBound) { + uError("numFields:%d > boundInfo->numOfBound:%d", numFields, boundInfo->numOfBound); + ret = TSDB_CODE_INVALID_PARA; + goto end; + } + if(tFields == NULL){ + for (int j = 0; j < boundInfo->numOfBound; j++){ + SSchema* pColSchema = &pSchema[j]; + SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, j); + if (*fields != pColSchema->type && *(int32_t*)(fields + sizeof(int8_t)) != pColSchema->bytes) { + uError("type or bytes not equal"); + ret = TSDB_CODE_INVALID_PARA; + goto end; + } - if (*fields != pColSchema->type && *(int32_t*)(fields + sizeof(int8_t)) != pColSchema->bytes) { - uError("type or bytes not equal"); - ret = TSDB_CODE_INVALID_PARA; - goto end; + int8_t* offset = pStart; + if (IS_VAR_DATA_TYPE(pColSchema->type)) { + pStart += numOfRows * sizeof(int32_t); + } else { + pStart += BitmapLen(numOfRows); + } + char* pData = pStart; + + tColDataAddValueByDataBlock(pCol, pColSchema->type, pColSchema->bytes, numOfRows, offset, pData); + fields += sizeof(int8_t) + sizeof(int32_t); + if (needChangeLength) { + pStart += htonl(colLength[j]); + } else { + pStart += colLength[j]; + } } + }else{ + for (int i = 0; i < numFields; i++) { + for (int j = 0; j < boundInfo->numOfBound; j++){ + SSchema* pColSchema = &pSchema[j]; + if(strcmp(pColSchema->name, tFields[i].name) == 0){ + if (*fields != pColSchema->type && *(int32_t*)(fields + sizeof(int8_t)) != pColSchema->bytes) { + uError("type or bytes not equal"); + ret = TSDB_CODE_INVALID_PARA; + goto end; + } + + int8_t* offset = pStart; + if (IS_VAR_DATA_TYPE(pColSchema->type)) { + pStart += numOfRows * sizeof(int32_t); + } else { + pStart += BitmapLen(numOfRows); + } + char* pData = pStart; + + SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, j); + tColDataAddValueByDataBlock(pCol, pColSchema->type, pColSchema->bytes, numOfRows, offset, pData); + fields += sizeof(int8_t) + sizeof(int32_t); + if (needChangeLength) { + pStart += htonl(colLength[i]); + } else { + pStart += colLength[i]; + } + boundInfo->pColIndex[j] = -1; + break; + } + } - int8_t* offset = pStart; - if (IS_VAR_DATA_TYPE(pColSchema->type)) { - pStart += numOfRows * sizeof(int32_t); - } else { - pStart += BitmapLen(numOfRows); } - char* pData = pStart; - tColDataAddValueByDataBlock(pCol, pColSchema->type, pColSchema->bytes, numOfRows, offset, pData); - fields += sizeof(int8_t) + sizeof(int32_t); - if (needChangeLength) { - pStart += htonl(colLength[c]); - } else { - pStart += colLength[c]; + for (int c = 0; c < boundInfo->numOfBound; ++c) { + if( boundInfo->pColIndex[c] != -1){ + SColData* pCol = taosArrayGet(pTableCxt->pData->aCol, c); + tColDataAddValueByDataBlock(pCol, 0, 0, numOfRows, NULL, NULL); + }else{ + boundInfo->pColIndex[c] = c; // restore for next block + } } } diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 366831ee1af056e09ed17f9fec0e5975322c059e..312584994fe593085a83dca11e763b9ef4d4410b 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -127,6 +127,7 @@ static SKeyword keywordTable[] = { {"LANGUAGE", TK_LANGUAGE}, {"LAST", TK_LAST}, {"LAST_ROW", TK_LAST_ROW}, + {"LEADER", TK_LEADER}, {"LICENCES", TK_LICENCES}, {"LIKE", TK_LIKE}, {"LIMIT", TK_LIMIT}, @@ -177,6 +178,7 @@ static SKeyword keywordTable[] = { {"READ", TK_READ}, {"REDISTRIBUTE", TK_REDISTRIBUTE}, {"RENAME", TK_RENAME}, + {"REPLACE", TK_REPLACE}, {"REPLICA", TK_REPLICA}, {"RESET", TK_RESET}, {"RETENTIONS", TK_RETENTIONS}, @@ -237,7 +239,7 @@ static SKeyword keywordTable[] = { {"TTL", TK_TTL}, {"UNION", TK_UNION}, {"UNSIGNED", TK_UNSIGNED}, - {"UPDATE", TK_UPDATE}, + {"UPDATE", TK_UPDATE}, {"USE", TK_USE}, {"USER", TK_USER}, {"USERS", TK_USERS}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 74b32c638dded2135e7eff8ff0527801ac8934a8..78fc097f6f5024e8a1932217ba2440cb342ec3e7 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -755,9 +755,11 @@ static bool isPrimaryKeyImpl(SNode* pExpr) { } else if (QUERY_NODE_FUNCTION == nodeType(pExpr)) { SFunctionNode* pFunc = (SFunctionNode*)pExpr; if (FUNCTION_TYPE_SELECT_VALUE == pFunc->funcType || FUNCTION_TYPE_GROUP_KEY == pFunc->funcType || - FUNCTION_TYPE_FIRST == pFunc->funcType || FUNCTION_TYPE_LAST == pFunc->funcType) { + FUNCTION_TYPE_FIRST == pFunc->funcType || FUNCTION_TYPE_LAST == pFunc->funcType || + FUNCTION_TYPE_LAST_ROW == pFunc->funcType) { return isPrimaryKeyImpl(nodesListGetNode(pFunc->pParameterList, 0)); - } else if (FUNCTION_TYPE_WSTART == pFunc->funcType || FUNCTION_TYPE_WEND == pFunc->funcType) { + } else if (FUNCTION_TYPE_WSTART == pFunc->funcType || FUNCTION_TYPE_WEND == pFunc->funcType || + FUNCTION_TYPE_IROWTS == pFunc->funcType) { return true; } } @@ -1331,6 +1333,32 @@ static int32_t rewriteCountStar(STranslateContext* pCxt, SFunctionNode* pCount) return code; } +static bool isCountNotNullValue(SFunctionNode* pFunc) { + if (FUNCTION_TYPE_COUNT != pFunc->funcType || 1 != LIST_LENGTH(pFunc->pParameterList)) { + return false; + } + SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); + return (QUERY_NODE_VALUE == nodeType(pPara) && !((SValueNode*)pPara)->isNull); +} + +// count(1) is rewritten as count(ts) for scannning optimization +static int32_t rewriteCountNotNullValue(STranslateContext* pCxt, SFunctionNode* pCount) { + SValueNode* pValue = (SValueNode*)nodesListGetNode(pCount->pParameterList, 0); + STableNode* pTable = NULL; + int32_t code = findTable(pCxt, NULL, &pTable); + if (TSDB_CODE_SUCCESS == code && QUERY_NODE_REAL_TABLE == nodeType(pTable)) { + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); + if (NULL == pCol) { + code = TSDB_CODE_OUT_OF_MEMORY; + } else { + setColumnInfoBySchema((SRealTableNode*)pTable, ((SRealTableNode*)pTable)->pMeta->schema, -1, pCol); + NODES_DESTORY_LIST(pCount->pParameterList); + code = nodesListMakeAppend(&pCount->pParameterList, (SNode*)pCol); + } + } + return code; +} + static bool isCountTbname(SFunctionNode* pFunc) { if (FUNCTION_TYPE_COUNT != pFunc->funcType || 1 != LIST_LENGTH(pFunc->pParameterList)) { return false; @@ -1396,6 +1424,9 @@ static int32_t translateAggFunc(STranslateContext* pCxt, SFunctionNode* pFunc) { if (isCountStar(pFunc)) { return rewriteCountStar(pCxt, pFunc); } + if (isCountNotNullValue(pFunc)) { + return rewriteCountNotNullValue(pCxt, pFunc); + } if (isCountTbname(pFunc)) { return rewriteCountTbname(pCxt, pFunc); } @@ -1605,13 +1636,15 @@ static bool isTableStar(SNode* pNode) { (0 == strcmp(((SColumnNode*)pNode)->colName, "*")); } +static bool isStarParam(SNode* pNode) { return isStar(pNode) || isTableStar(pNode); } + static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFunc) { if (!fmIsMultiResFunc(pFunc->funcId)) { return TSDB_CODE_SUCCESS; } if (SQL_CLAUSE_SELECT != pCxt->currClause) { SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); - if (isStar(pPara) || isTableStar(pPara)) { + if (isStarParam(pPara)) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC, "%s(*) is only supported in SELECTed list", pFunc->functionName); } @@ -1625,7 +1658,7 @@ static int32_t translateMultiResFunc(STranslateContext* pCxt, SFunctionNode* pFu static int32_t getMultiResFuncNum(SNodeList* pParameterList) { if (1 == LIST_LENGTH(pParameterList)) { - return isStar(nodesListGetNode(pParameterList, 0)) ? 2 : 1; + return isStarParam(nodesListGetNode(pParameterList, 0)) ? 2 : 1; } return LIST_LENGTH(pParameterList); } @@ -2041,7 +2074,7 @@ static int32_t getGroupByErrorCode(STranslateContext* pCxt) { if (isSelectStmt(pCxt->pCurrStmt) && NULL != ((SSelectStmt*)pCxt->pCurrStmt)->pGroupByList) { return TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION; } - return TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN; + return TSDB_CODE_PAR_INVALID_OPTR_USAGE; } static EDealRes rewriteColToSelectValFunc(STranslateContext* pCxt, SNode** pNode) { @@ -2114,13 +2147,13 @@ static EDealRes doCheckExprForGroupBy(SNode** pNode, void* pContext) { } if (isScanPseudoColumnFunc(*pNode) || QUERY_NODE_COLUMN == nodeType(*pNode)) { if (pSelect->selectFuncNum > 1 || pSelect->hasOtherVectorFunc || !pSelect->hasSelectFunc) { - return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt)); + return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt), ((SExprNode*)(*pNode))->userAlias); } else { return rewriteColToSelectValFunc(pCxt, pNode); } } if (isVectorFunc(*pNode) && isDistinctOrderBy(pCxt)) { - return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt)); + return generateDealNodeErrMsg(pCxt, getGroupByErrorCode(pCxt), ((SExprNode*)(*pNode))->userAlias); } return DEAL_RES_CONTINUE; } @@ -3088,6 +3121,19 @@ static const char* getPrecisionStr(uint8_t precision) { return "unknown"; } +static void convertVarDuration(SValueNode* pOffset, uint8_t precision) { + const int64_t factors[3] = {NANOSECOND_PER_MSEC, NANOSECOND_PER_USEC, 1}; + const int8_t units[3] = {TIME_UNIT_MILLISECOND, TIME_UNIT_MICROSECOND, TIME_UNIT_NANOSECOND}; + + if (pOffset->unit == 'n') { + pOffset->datum.i = pOffset->datum.i * 31 * (NANOSECOND_PER_DAY / factors[precision]); + } else { + pOffset->datum.i = pOffset->datum.i * 365 * (NANOSECOND_PER_DAY / factors[precision]); + } + + pOffset->unit = units[precision]; +} + static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* pInterval) { uint8_t precision = ((SColumnNode*)pInterval->pCol)->node.resType.precision; @@ -3112,6 +3158,10 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* getMonthsFromTimeVal(pInter->datum.i, precision, pInter->unit))) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_OFFSET_TOO_BIG); } + + if (pOffset->unit == 'n' || pOffset->unit == 'y') { + convertVarDuration(pOffset, precision); + } } if (NULL != pInterval->pSliding) { @@ -3372,8 +3422,8 @@ static int32_t checkLimit(STranslateContext* pCxt, SSelectStmt* pSelect) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_OFFSET_LESS_ZERO); } - if (NULL != pSelect->pSlimit && NULL == pSelect->pPartitionByList) { - return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_BY); + if (NULL != pSelect->pSlimit && (NULL == pSelect->pPartitionByList && NULL == pSelect->pGroupByList)) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_GROUP_BY); } return TSDB_CODE_SUCCESS; @@ -4254,6 +4304,8 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt, pReq->replications = pStmt->pOptions->replica; pReq->sstTrigger = pStmt->pOptions->sstTrigger; pReq->minRows = pStmt->pOptions->minRowsPerBlock; + pReq->walRetentionPeriod = pStmt->pOptions->walRetentionPeriod; + pReq->walRetentionSize = pStmt->pOptions->walRetentionSize; return; } @@ -5894,11 +5946,15 @@ static int32_t addSubtableInfoToCreateStreamQuery(STranslateContext* pCxt, STabl return code; } +static bool isEventWindowQuery(SSelectStmt* pSelect) { + return NULL != pSelect->pWindow && QUERY_NODE_EVENT_WINDOW == nodeType(pSelect->pWindow); +} + static int32_t checkStreamQuery(STranslateContext* pCxt, SCreateStreamStmt* pStmt) { SSelectStmt* pSelect = (SSelectStmt*)pStmt->pQuery; if (TSDB_DATA_TYPE_TIMESTAMP != ((SExprNode*)nodesListGetNode(pSelect->pProjectionList, 0))->resType.type || !pSelect->isTimeLineResult || crossTableWithoutAggOper(pSelect) || NULL != pSelect->pOrderByList || - crossTableWithUdaf(pSelect)) { + crossTableWithUdaf(pSelect) || isEventWindowQuery(pSelect)) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_STREAM_QUERY, "Unsupported stream query"); } if (NULL != pSelect->pSubtable && TSDB_DATA_TYPE_VARCHAR != ((SExprNode*)pSelect->pSubtable)->resType.type) { @@ -6393,8 +6449,20 @@ static int32_t translateCreateFunction(STranslateContext* pCxt, SCreateFunctionS if (fmIsBuiltinFunc(pStmt->funcName)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_FUNCTION_NAME); } + + if (TSDB_DATA_TYPE_JSON == pStmt->outputDt.type || TSDB_DATA_TYPE_VARBINARY == pStmt->outputDt.type || + TSDB_DATA_TYPE_DECIMAL == pStmt->outputDt.type || TSDB_DATA_TYPE_BLOB == pStmt->outputDt.type || + TSDB_DATA_TYPE_MEDIUMBLOB == pStmt->outputDt.type) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, "Unsupported output type for UDF"); + } + + if (!pStmt->isAgg && pStmt->bufSize > 0) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, "BUFSIZE can only be used with UDAF"); + } + SCreateFuncReq req = {0}; strcpy(req.name, pStmt->funcName); + req.orReplace = pStmt->orReplace; req.igExists = pStmt->ignoreExists; req.funcType = pStmt->isAgg ? TSDB_FUNC_TYPE_AGGREGATE : TSDB_FUNC_TYPE_SCALAR; req.scriptType = pStmt->language; @@ -6458,6 +6526,11 @@ static int32_t translateBalanceVgroup(STranslateContext* pCxt, SBalanceVgroupStm return buildCmdMsg(pCxt, TDMT_MND_BALANCE_VGROUP, (FSerializeFunc)tSerializeSBalanceVgroupReq, &req); } +static int32_t translateBalanceVgroupLeader(STranslateContext* pCxt, SBalanceVgroupLeaderStmt* pStmt) { + SBalanceVgroupLeaderReq req = {0}; + return buildCmdMsg(pCxt, TDMT_MND_BALANCE_VGROUP_LEADER, (FSerializeFunc)tSerializeSBalanceVgroupLeaderReq, &req); +} + static int32_t translateMergeVgroup(STranslateContext* pCxt, SMergeVgroupStmt* pStmt) { SMergeVgroupReq req = {.vgId1 = pStmt->vgId1, .vgId2 = pStmt->vgId2}; return buildCmdMsg(pCxt, TDMT_MND_MERGE_VGROUP, (FSerializeFunc)tSerializeSMergeVgroupReq, &req); @@ -6669,6 +6742,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_BALANCE_VGROUP_STMT: code = translateBalanceVgroup(pCxt, (SBalanceVgroupStmt*)pNode); break; + case QUERY_NODE_BALANCE_VGROUP_LEADER_STMT: + code = translateBalanceVgroupLeader(pCxt, (SBalanceVgroupLeaderStmt*)pNode); + break; case QUERY_NODE_MERGE_VGROUP_STMT: code = translateMergeVgroup(pCxt, (SMergeVgroupStmt*)pNode); break; diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 89a42cb03c29fcc97570610d52b5bc15a663fc9b..563bc5e7800ddbb8752b4070bd203ad3410bd5c1 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -103,8 +103,8 @@ static char* getSyntaxErrFormat(int32_t errCode) { return "Incorrect TIMESTAMP value: %s"; case TSDB_CODE_PAR_OFFSET_LESS_ZERO: return "soffset/offset can not be less than 0"; - case TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_BY: - return "slimit/soffset only available for PARTITION BY query"; + case TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_GROUP_BY: + return "slimit/soffset only available for PARTITION/GROUP BY query"; case TSDB_CODE_PAR_INVALID_TOPIC_QUERY: return "Invalid topic query"; case TSDB_CODE_PAR_INVALID_DROP_STABLE: @@ -174,6 +174,8 @@ static char* getSyntaxErrFormat(int32_t errCode) { return "Invalid usage of RANGE clause, EVERY clause or FILL clause"; case TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN: return "No valid function in window query"; + case TSDB_CODE_PAR_INVALID_OPTR_USAGE: + return "Invalid usage of expr: %s"; case TSDB_CODE_OUT_OF_MEMORY: return "Out of memory"; default: @@ -442,7 +444,7 @@ static int32_t getInsTagsTableTargetNameFromOp(int32_t acctId, SOperatorNode* pO } else if (QUERY_NODE_VALUE == nodeType(pOper->pRight)) { pVal = (SValueNode*)pOper->pRight; } - if (NULL == pCol || NULL == pVal) { + if (NULL == pCol || NULL == pVal || NULL == pVal->literal || 0 == strcmp(pVal->literal, "")) { return TSDB_CODE_SUCCESS; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 457083358d551fa7a1afd777baa585e8a40c0e30..b1437bbb6bba7de0aadaa3b0a4c8950865fa731d 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -104,26 +104,26 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 473 +#define YYNOCODE 475 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EOperatorType yy62; - SToken yy63; - EOrder yy158; - SNodeList* yy222; - SAlterOption yy233; - int32_t yy332; - int64_t yy393; - EJoinType yy574; - bool yy669; - ENullOrder yy675; - SDataType yy686; - int8_t yy707; - EFillMode yy822; - SNode* yy828; + EOrder yy88; + EFillMode yy94; + SToken yy129; + SDataType yy184; + SNodeList* yy274; + int32_t yy310; + bool yy337; + int8_t yy353; + int64_t yy359; + EOperatorType yy440; + SAlterOption yy595; + SNode* yy712; + ENullOrder yy907; + EJoinType yy912; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -139,17 +139,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 754 -#define YYNRULE 574 -#define YYNTOKEN 329 -#define YY_MAX_SHIFT 753 -#define YY_MIN_SHIFTREDUCE 1121 -#define YY_MAX_SHIFTREDUCE 1694 -#define YY_ERROR_ACTION 1695 -#define YY_ACCEPT_ACTION 1696 -#define YY_NO_ACTION 1697 -#define YY_MIN_REDUCE 1698 -#define YY_MAX_REDUCE 2271 +#define YYNSTATE 761 +#define YYNRULE 581 +#define YYNTOKEN 330 +#define YY_MAX_SHIFT 760 +#define YY_MIN_SHIFTREDUCE 1133 +#define YY_MAX_SHIFTREDUCE 1713 +#define YY_ERROR_ACTION 1714 +#define YY_ACCEPT_ACTION 1715 +#define YY_NO_ACTION 1716 +#define YY_MIN_REDUCE 1717 +#define YY_MAX_REDUCE 2297 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -216,773 +216,827 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2833) +#define YY_ACTTAB_COUNT (3096) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 2069, 2247, 1980, 166, 2083, 2242, 491, 2101, 492, 1734, - /* 10 */ 1806, 2065, 45, 43, 1622, 600, 1980, 1978, 630, 2069, - /* 20 */ 385, 2246, 1471, 618, 1496, 2243, 2245, 2083, 376, 2186, - /* 30 */ 2065, 1977, 630, 1552, 2019, 1469, 1837, 2101, 44, 42, - /* 40 */ 41, 40, 39, 430, 642, 621, 2061, 2067, 366, 1173, - /* 50 */ 2051, 1172, 659, 629, 643, 2183, 139, 653, 1547, 2247, - /* 60 */ 2101, 599, 1914, 2242, 18, 2061, 2067, 367, 660, 350, - /* 70 */ 132, 1477, 167, 2051, 1710, 659, 653, 530, 1912, 2246, - /* 80 */ 1174, 240, 2082, 2243, 2244, 333, 2118, 1861, 642, 109, - /* 90 */ 2084, 663, 2086, 2087, 658, 2069, 653, 750, 65, 697, - /* 100 */ 14, 179, 507, 2171, 1973, 2082, 2065, 379, 2167, 2118, - /* 110 */ 45, 43, 168, 2084, 663, 2086, 2087, 658, 385, 653, - /* 120 */ 1471, 184, 270, 2179, 617, 1721, 133, 616, 73, 2197, - /* 130 */ 2242, 1552, 1173, 1469, 1172, 390, 1554, 1555, 1907, 1909, - /* 140 */ 606, 2061, 2067, 380, 2242, 605, 182, 222, 35, 291, - /* 150 */ 2243, 607, 653, 582, 2208, 273, 1547, 1838, 628, 605, - /* 160 */ 182, 642, 18, 1174, 2243, 607, 1527, 1537, 48, 1477, - /* 170 */ 1764, 2051, 1553, 1556, 38, 37, 178, 81, 44, 42, - /* 180 */ 41, 40, 39, 546, 545, 544, 1472, 509, 1470, 1901, - /* 190 */ 536, 136, 540, 176, 61, 750, 539, 61, 14, 92, - /* 200 */ 497, 538, 543, 61, 38, 37, 493, 537, 44, 42, - /* 210 */ 41, 40, 39, 1475, 1476, 1964, 1526, 1529, 1530, 1531, - /* 220 */ 1532, 1533, 1534, 1535, 1536, 655, 651, 1545, 1546, 1548, - /* 230 */ 1549, 1550, 1551, 2, 1554, 1555, 727, 726, 725, 724, - /* 240 */ 395, 48, 723, 722, 143, 717, 716, 715, 714, 713, - /* 250 */ 712, 711, 156, 707, 706, 705, 394, 393, 702, 701, - /* 260 */ 700, 699, 698, 601, 1527, 1537, 596, 1661, 580, 695, - /* 270 */ 1553, 1556, 122, 1583, 1242, 121, 120, 119, 118, 117, - /* 280 */ 116, 115, 114, 113, 1472, 695, 1470, 154, 153, 692, - /* 290 */ 691, 690, 151, 38, 37, 697, 1154, 44, 42, 41, - /* 300 */ 40, 39, 1959, 154, 153, 692, 691, 690, 151, 1696, - /* 310 */ 1244, 1475, 1476, 190, 1526, 1529, 1530, 1531, 1532, 1533, - /* 320 */ 1534, 1535, 1536, 655, 651, 1545, 1546, 1548, 1549, 1550, - /* 330 */ 1551, 2, 11, 45, 43, 1156, 1839, 1159, 1160, 1496, - /* 340 */ 52, 385, 1299, 1471, 185, 32, 1959, 185, 1496, 345, - /* 350 */ 602, 597, 590, 185, 1552, 1588, 1469, 192, 1290, 685, - /* 360 */ 684, 683, 1294, 682, 1296, 1297, 681, 678, 86, 1305, - /* 370 */ 675, 1307, 1308, 672, 669, 1699, 31, 398, 2083, 1547, - /* 380 */ 147, 397, 38, 37, 354, 18, 44, 42, 41, 40, - /* 390 */ 39, 185, 1477, 1856, 1581, 500, 122, 492, 1734, 121, - /* 400 */ 120, 119, 118, 117, 116, 115, 114, 113, 38, 37, - /* 410 */ 629, 2101, 44, 42, 41, 40, 39, 377, 750, 657, - /* 420 */ 1499, 14, 468, 581, 2051, 164, 659, 2242, 61, 388, - /* 430 */ 1495, 45, 43, 1557, 1863, 282, 283, 161, 1959, 385, - /* 440 */ 281, 1471, 2248, 182, 364, 1497, 1863, 2243, 607, 196, - /* 450 */ 1582, 238, 1552, 1912, 1469, 237, 2082, 1554, 1555, 627, - /* 460 */ 2118, 1973, 569, 327, 2084, 663, 2086, 2087, 658, 656, - /* 470 */ 653, 644, 2136, 1698, 38, 37, 11, 1547, 44, 42, - /* 480 */ 41, 40, 39, 198, 197, 1388, 1389, 1527, 1537, 100, - /* 490 */ 1477, 1767, 490, 1553, 1556, 495, 1740, 131, 130, 129, - /* 500 */ 128, 127, 126, 125, 124, 123, 467, 1472, 499, 1470, - /* 510 */ 27, 495, 1740, 1854, 89, 340, 750, 424, 362, 46, - /* 520 */ 562, 423, 34, 383, 1576, 1577, 1578, 1579, 1580, 1584, - /* 530 */ 1585, 1586, 1587, 1720, 1475, 1476, 576, 1526, 1529, 1530, - /* 540 */ 1531, 1532, 1533, 1534, 1535, 1536, 655, 651, 1545, 1546, - /* 550 */ 1548, 1549, 1550, 1551, 2, 1554, 1555, 546, 545, 544, - /* 560 */ 1477, 1333, 1334, 581, 536, 136, 540, 2242, 250, 49, - /* 570 */ 539, 1908, 1909, 1852, 106, 538, 543, 709, 185, 2051, - /* 580 */ 2083, 537, 2248, 182, 2065, 1527, 1537, 2243, 607, 33, - /* 590 */ 140, 1553, 1556, 13, 12, 38, 37, 1836, 1853, 44, - /* 600 */ 42, 41, 40, 39, 688, 1472, 2247, 1470, 542, 541, - /* 610 */ 38, 37, 560, 2101, 44, 42, 41, 40, 39, 2061, - /* 620 */ 2067, 660, 618, 1498, 1944, 558, 2051, 556, 659, 11, - /* 630 */ 653, 9, 1475, 1476, 86, 1526, 1529, 1530, 1531, 1532, - /* 640 */ 1533, 1534, 1535, 1536, 655, 651, 1545, 1546, 1548, 1549, - /* 650 */ 1550, 1551, 2, 45, 43, 139, 248, 2083, 2082, 1857, - /* 660 */ 2070, 385, 2118, 1471, 643, 109, 2084, 663, 2086, 2087, - /* 670 */ 658, 2065, 653, 1497, 1552, 142, 1469, 149, 2142, 2171, - /* 680 */ 187, 38, 37, 379, 2167, 44, 42, 41, 40, 39, - /* 690 */ 2101, 1719, 176, 1595, 1498, 1914, 1754, 1861, 660, 1547, - /* 700 */ 90, 618, 363, 2051, 1684, 659, 2061, 2067, 1718, 695, - /* 710 */ 624, 1912, 1477, 352, 1963, 1650, 357, 653, 547, 185, - /* 720 */ 620, 180, 2179, 2180, 643, 137, 2184, 154, 153, 692, - /* 730 */ 691, 690, 151, 141, 139, 2082, 2142, 2051, 750, 2118, - /* 740 */ 54, 46, 169, 2084, 663, 2086, 2087, 658, 2246, 653, - /* 750 */ 1717, 45, 43, 643, 2051, 689, 581, 1861, 1905, 385, - /* 760 */ 2242, 1471, 593, 592, 1648, 1649, 1651, 1652, 1653, 428, - /* 770 */ 163, 272, 1552, 1850, 1469, 2248, 182, 1554, 1555, 448, - /* 780 */ 2243, 607, 358, 2186, 356, 355, 1861, 532, 447, 1405, - /* 790 */ 1406, 534, 629, 1846, 608, 2263, 2051, 1547, 1848, 2083, - /* 800 */ 181, 2179, 2180, 1716, 137, 2184, 1499, 1527, 1537, 2182, - /* 810 */ 1477, 1844, 533, 1553, 1556, 643, 38, 37, 2186, 643, - /* 820 */ 44, 42, 41, 40, 39, 1404, 1407, 1472, 687, 1470, - /* 830 */ 1914, 132, 2101, 1715, 2037, 429, 750, 373, 535, 14, - /* 840 */ 660, 638, 272, 1973, 2181, 2051, 1912, 659, 1861, 2051, - /* 850 */ 2044, 1691, 1861, 194, 1475, 1476, 1714, 1526, 1529, 1530, - /* 860 */ 1531, 1532, 1533, 1534, 1535, 1536, 655, 651, 1545, 1546, - /* 870 */ 1548, 1549, 1550, 1551, 2, 1554, 1555, 2082, 245, 2051, - /* 880 */ 2045, 2118, 405, 1914, 110, 2084, 663, 2086, 2087, 658, - /* 890 */ 378, 653, 693, 388, 83, 1905, 581, 82, 2171, 1912, - /* 900 */ 2242, 164, 2051, 2168, 606, 1527, 1537, 1496, 2242, 1638, - /* 910 */ 1863, 1553, 1556, 721, 719, 2248, 182, 417, 61, 8, - /* 920 */ 2243, 607, 1253, 605, 182, 1472, 581, 1470, 2243, 607, - /* 930 */ 2242, 1914, 645, 1626, 2143, 1252, 1562, 654, 389, 1496, - /* 940 */ 419, 415, 1496, 1159, 1160, 2248, 182, 1912, 1690, 610, - /* 950 */ 2243, 607, 1475, 1476, 191, 1526, 1529, 1530, 1531, 1532, - /* 960 */ 1533, 1534, 1535, 1536, 655, 651, 1545, 1546, 1548, 1549, - /* 970 */ 1550, 1551, 2, 1499, 336, 165, 1494, 643, 382, 381, - /* 980 */ 311, 567, 647, 461, 2143, 551, 475, 2083, 1485, 474, - /* 990 */ 41, 40, 39, 438, 309, 72, 1619, 477, 71, 1552, - /* 1000 */ 561, 1478, 1711, 422, 444, 421, 476, 2211, 694, 446, - /* 1010 */ 1861, 1905, 1471, 164, 236, 609, 205, 487, 485, 482, - /* 1020 */ 2101, 152, 1864, 618, 1547, 1469, 643, 581, 660, 554, - /* 1030 */ 420, 2242, 391, 2051, 548, 659, 1713, 1477, 643, 235, - /* 1040 */ 164, 534, 453, 1712, 2191, 1615, 2248, 182, 643, 1863, - /* 1050 */ 1914, 2243, 607, 1528, 454, 353, 139, 61, 710, 1861, - /* 1060 */ 1823, 1477, 533, 649, 508, 2082, 1913, 434, 185, 2118, - /* 1070 */ 1807, 1861, 109, 2084, 663, 2086, 2087, 658, 53, 653, - /* 1080 */ 69, 1861, 2051, 68, 2146, 1528, 2171, 750, 1528, 2051, - /* 1090 */ 379, 2167, 1709, 1708, 1480, 108, 472, 1707, 1747, 466, - /* 1100 */ 465, 464, 463, 460, 459, 458, 457, 456, 452, 451, - /* 1110 */ 450, 449, 335, 441, 440, 439, 643, 436, 435, 351, - /* 1120 */ 549, 249, 183, 2179, 2180, 613, 137, 2184, 643, 1615, - /* 1130 */ 305, 643, 1858, 1891, 152, 80, 79, 427, 2051, 2051, - /* 1140 */ 189, 2083, 643, 2051, 241, 239, 1257, 577, 51, 1861, - /* 1150 */ 3, 145, 1486, 134, 1481, 643, 1706, 643, 622, 1256, - /* 1160 */ 334, 1861, 1479, 413, 1861, 411, 407, 403, 400, 420, - /* 1170 */ 1705, 626, 2083, 286, 2101, 1861, 1472, 611, 1470, 1489, - /* 1180 */ 1491, 267, 621, 228, 643, 650, 226, 2051, 1861, 659, - /* 1190 */ 1861, 1440, 651, 1545, 1546, 1548, 1549, 1550, 1551, 643, - /* 1200 */ 640, 431, 2051, 1475, 1476, 2101, 1704, 185, 643, 643, - /* 1210 */ 1703, 1445, 1446, 660, 432, 641, 2051, 1861, 2051, 2082, - /* 1220 */ 659, 479, 2083, 2118, 292, 392, 109, 2084, 663, 2086, - /* 1230 */ 2087, 658, 1861, 653, 230, 1702, 1701, 229, 179, 2083, - /* 1240 */ 2171, 1861, 1861, 1618, 379, 2167, 232, 1483, 234, 231, - /* 1250 */ 2082, 233, 2051, 594, 2118, 2101, 2051, 109, 2084, 663, - /* 1260 */ 2086, 2087, 658, 660, 653, 152, 2198, 1745, 2051, 2262, - /* 1270 */ 659, 2171, 2101, 63, 221, 379, 2167, 564, 63, 563, - /* 1280 */ 660, 2051, 2051, 261, 254, 2051, 2205, 659, 105, 552, - /* 1290 */ 1693, 1694, 2102, 152, 396, 13, 12, 47, 102, 2083, - /* 1300 */ 2082, 279, 70, 2072, 2118, 150, 152, 168, 2084, 663, - /* 1310 */ 2086, 2087, 658, 63, 653, 1482, 1968, 2082, 1735, 2083, - /* 1320 */ 1902, 2118, 1443, 47, 109, 2084, 663, 2086, 2087, 658, - /* 1330 */ 1647, 653, 2101, 2201, 1573, 1646, 2262, 753, 2171, 703, - /* 1340 */ 660, 256, 379, 2167, 619, 2051, 1741, 659, 269, 2209, - /* 1350 */ 625, 298, 2101, 2218, 1402, 614, 2074, 47, 284, 635, - /* 1360 */ 660, 1222, 288, 1283, 667, 2051, 175, 659, 150, 152, - /* 1370 */ 1589, 704, 743, 739, 735, 731, 296, 2082, 266, 135, - /* 1380 */ 1538, 2118, 150, 1203, 109, 2084, 663, 2086, 2087, 658, - /* 1390 */ 1, 653, 4, 1220, 399, 745, 2262, 2082, 2171, 404, - /* 1400 */ 349, 2118, 379, 2167, 109, 2084, 663, 2086, 2087, 658, - /* 1410 */ 1425, 653, 299, 588, 304, 195, 2262, 107, 2171, 1204, - /* 1420 */ 289, 1311, 379, 2167, 433, 1315, 1322, 1499, 2083, 1969, - /* 1430 */ 437, 470, 442, 2236, 1494, 223, 1320, 455, 462, 155, - /* 1440 */ 1961, 469, 480, 471, 481, 478, 483, 200, 2083, 484, - /* 1450 */ 171, 199, 639, 202, 486, 488, 526, 522, 518, 514, - /* 1460 */ 220, 2101, 1500, 489, 1502, 498, 501, 1497, 208, 660, - /* 1470 */ 1501, 502, 210, 503, 2051, 1503, 659, 506, 504, 213, - /* 1480 */ 215, 2101, 1176, 84, 85, 510, 527, 276, 531, 660, - /* 1490 */ 529, 528, 275, 219, 2051, 111, 659, 2028, 2025, 339, - /* 1500 */ 1851, 87, 566, 2024, 218, 88, 2082, 571, 1432, 300, - /* 1510 */ 2118, 243, 568, 109, 2084, 663, 2086, 2087, 658, 148, - /* 1520 */ 653, 242, 2083, 225, 1847, 2262, 2082, 2171, 227, 157, - /* 1530 */ 2118, 379, 2167, 109, 2084, 663, 2086, 2087, 658, 158, - /* 1540 */ 653, 1849, 2190, 1845, 570, 2144, 2083, 2171, 159, 160, - /* 1550 */ 572, 379, 2167, 244, 246, 2101, 578, 2202, 2212, 585, - /* 1560 */ 575, 595, 633, 660, 2217, 252, 255, 591, 2051, 368, - /* 1570 */ 659, 217, 211, 598, 7, 604, 216, 586, 505, 2101, - /* 1580 */ 584, 2216, 583, 265, 615, 369, 1615, 660, 612, 2265, - /* 1590 */ 138, 262, 2051, 1498, 659, 209, 2083, 2193, 2187, 623, - /* 1600 */ 2082, 372, 172, 263, 2118, 1504, 260, 109, 2084, 663, - /* 1610 */ 2086, 2087, 658, 2083, 653, 274, 264, 95, 268, 646, - /* 1620 */ 301, 2171, 1974, 2241, 2082, 379, 2167, 636, 2118, 2101, - /* 1630 */ 631, 110, 2084, 663, 2086, 2087, 658, 660, 653, 302, - /* 1640 */ 637, 632, 2051, 1988, 659, 2171, 2101, 97, 1987, 2170, - /* 1650 */ 2167, 303, 1986, 375, 660, 1862, 60, 2152, 99, 2051, - /* 1660 */ 101, 659, 665, 1906, 746, 1824, 295, 306, 747, 310, - /* 1670 */ 749, 341, 50, 2083, 2082, 315, 2043, 308, 2118, 2042, - /* 1680 */ 342, 321, 2084, 663, 2086, 2087, 658, 329, 653, 330, - /* 1690 */ 319, 2082, 2041, 2083, 77, 2118, 2038, 401, 110, 2084, - /* 1700 */ 663, 2086, 2087, 658, 402, 653, 2101, 1462, 1463, 188, - /* 1710 */ 406, 2036, 2171, 408, 660, 409, 648, 2167, 410, 2051, - /* 1720 */ 2035, 659, 412, 2034, 414, 603, 2101, 2033, 416, 2032, - /* 1730 */ 418, 78, 1428, 1427, 660, 2000, 1999, 1998, 426, 2051, - /* 1740 */ 425, 659, 1997, 1996, 1379, 1952, 1951, 1949, 1948, 144, - /* 1750 */ 1947, 661, 1950, 1946, 1945, 2118, 2083, 1943, 110, 2084, - /* 1760 */ 663, 2086, 2087, 658, 1942, 653, 1941, 193, 443, 1940, - /* 1770 */ 445, 2082, 2171, 1954, 1939, 2118, 344, 2167, 169, 2084, - /* 1780 */ 663, 2086, 2087, 658, 1381, 653, 1938, 1937, 1936, 2101, - /* 1790 */ 1935, 1934, 1933, 1932, 374, 1931, 1930, 660, 1929, 1928, - /* 1800 */ 1927, 1926, 2051, 1925, 659, 146, 1924, 1923, 1922, 1953, - /* 1810 */ 1921, 1920, 1919, 1918, 2083, 1917, 473, 1916, 1915, 1254, - /* 1820 */ 337, 338, 1770, 201, 1258, 1769, 203, 1768, 204, 1250, - /* 1830 */ 1766, 2264, 1730, 177, 2082, 1162, 1729, 1161, 2118, 2083, - /* 1840 */ 2015, 328, 2084, 663, 2086, 2087, 658, 2101, 653, 2007, - /* 1850 */ 1995, 2071, 494, 1994, 1972, 657, 206, 1840, 75, 76, - /* 1860 */ 2051, 214, 659, 496, 207, 212, 1765, 1763, 511, 1761, - /* 1870 */ 515, 1759, 2101, 513, 519, 1757, 517, 384, 1744, 512, - /* 1880 */ 660, 523, 521, 525, 1743, 2051, 516, 659, 1726, 520, - /* 1890 */ 1842, 62, 2082, 1196, 1327, 524, 2118, 1841, 1326, 327, - /* 1900 */ 2084, 663, 2086, 2087, 658, 1241, 653, 1240, 2137, 1239, - /* 1910 */ 1755, 1232, 2083, 1748, 1238, 1237, 1234, 2082, 1233, 1746, - /* 1920 */ 1231, 2118, 359, 360, 328, 2084, 663, 2086, 2087, 658, - /* 1930 */ 718, 653, 550, 2083, 361, 720, 224, 553, 1725, 555, - /* 1940 */ 1724, 557, 1723, 559, 112, 2101, 1450, 2014, 26, 1452, - /* 1950 */ 386, 1449, 1454, 660, 1436, 66, 2006, 573, 2051, 1993, - /* 1960 */ 659, 1434, 2083, 1991, 162, 2247, 2101, 19, 16, 1663, - /* 1970 */ 20, 58, 59, 28, 660, 258, 259, 251, 30, 2051, - /* 1980 */ 64, 659, 17, 2083, 2072, 587, 1678, 21, 5, 6, - /* 1990 */ 2082, 589, 1677, 370, 2118, 2101, 253, 328, 2084, 663, - /* 2000 */ 2086, 2087, 658, 660, 653, 1682, 1645, 170, 2051, 257, - /* 2010 */ 659, 565, 271, 55, 1681, 2118, 2101, 29, 323, 2084, - /* 2020 */ 663, 2086, 2087, 658, 660, 653, 574, 579, 371, 2051, - /* 2030 */ 247, 659, 365, 2083, 1637, 57, 91, 173, 1992, 1990, - /* 2040 */ 2082, 1989, 1683, 1971, 2118, 1684, 1612, 312, 2084, 663, - /* 2050 */ 2086, 2087, 658, 1611, 653, 93, 94, 277, 2083, 96, - /* 2060 */ 22, 2082, 278, 1970, 280, 2118, 2101, 1643, 313, 2084, - /* 2070 */ 663, 2086, 2087, 658, 660, 653, 285, 287, 67, 2051, - /* 2080 */ 290, 659, 98, 102, 23, 1564, 634, 1563, 12, 1487, - /* 2090 */ 1519, 2101, 2121, 2083, 174, 1542, 1540, 652, 10, 660, - /* 2100 */ 36, 186, 1539, 15, 2051, 24, 659, 1574, 1511, 25, - /* 2110 */ 56, 2082, 1312, 662, 666, 2118, 2083, 664, 314, 2084, - /* 2120 */ 663, 2086, 2087, 658, 387, 653, 2101, 668, 670, 1309, - /* 2130 */ 671, 673, 1306, 1300, 660, 674, 2082, 676, 1298, 2051, - /* 2140 */ 2118, 659, 677, 320, 2084, 663, 2086, 2087, 658, 2101, - /* 2150 */ 653, 679, 680, 1289, 293, 103, 104, 660, 1321, 1304, - /* 2160 */ 686, 74, 2051, 1317, 659, 1194, 1248, 1303, 1302, 1301, - /* 2170 */ 696, 2082, 1228, 1227, 2083, 2118, 708, 1226, 324, 2084, - /* 2180 */ 663, 2086, 2087, 658, 1225, 653, 1224, 1223, 1221, 1219, - /* 2190 */ 1218, 1217, 294, 2083, 2082, 1215, 1214, 1213, 2118, 1212, - /* 2200 */ 1211, 316, 2084, 663, 2086, 2087, 658, 2101, 653, 1210, - /* 2210 */ 1245, 1209, 1200, 1243, 1206, 660, 1205, 1202, 1201, 1199, - /* 2220 */ 2051, 1762, 659, 728, 730, 1760, 2101, 732, 729, 1758, - /* 2230 */ 734, 736, 738, 1756, 660, 733, 740, 737, 742, 2051, - /* 2240 */ 1742, 659, 741, 744, 1151, 1722, 297, 748, 1697, 1473, - /* 2250 */ 307, 751, 2082, 1697, 2083, 1697, 2118, 752, 1697, 325, - /* 2260 */ 2084, 663, 2086, 2087, 658, 1697, 653, 1697, 1697, 1697, - /* 2270 */ 1697, 2082, 1697, 1697, 1697, 2118, 1697, 1697, 317, 2084, - /* 2280 */ 663, 2086, 2087, 658, 1697, 653, 1697, 2101, 1697, 1697, - /* 2290 */ 1697, 1697, 1697, 1697, 1697, 660, 1697, 1697, 1697, 1697, - /* 2300 */ 2051, 1697, 659, 1697, 1697, 1697, 1697, 1697, 1697, 1697, - /* 2310 */ 1697, 1697, 2083, 1697, 1697, 1697, 1697, 1697, 1697, 1697, - /* 2320 */ 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 2083, 1697, - /* 2330 */ 1697, 1697, 2082, 1697, 1697, 1697, 2118, 1697, 1697, 326, - /* 2340 */ 2084, 663, 2086, 2087, 658, 2101, 653, 1697, 1697, 1697, - /* 2350 */ 1697, 1697, 1697, 660, 1697, 1697, 1697, 1697, 2051, 1697, - /* 2360 */ 659, 2101, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 660, - /* 2370 */ 1697, 1697, 1697, 1697, 2051, 1697, 659, 1697, 1697, 1697, - /* 2380 */ 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, - /* 2390 */ 2082, 2083, 1697, 1697, 2118, 1697, 1697, 318, 2084, 663, - /* 2400 */ 2086, 2087, 658, 1697, 653, 1697, 2082, 2083, 1697, 1697, - /* 2410 */ 2118, 1697, 1697, 331, 2084, 663, 2086, 2087, 658, 1697, - /* 2420 */ 653, 1697, 1697, 1697, 2101, 1697, 2083, 1697, 1697, 1697, - /* 2430 */ 1697, 1697, 660, 1697, 1697, 1697, 1697, 2051, 1697, 659, - /* 2440 */ 2101, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 660, 1697, - /* 2450 */ 1697, 1697, 1697, 2051, 1697, 659, 1697, 1697, 1697, 2101, - /* 2460 */ 1697, 1697, 1697, 1697, 1697, 1697, 1697, 660, 1697, 2082, - /* 2470 */ 1697, 1697, 2051, 2118, 659, 1697, 332, 2084, 663, 2086, - /* 2480 */ 2087, 658, 1697, 653, 1697, 2082, 1697, 1697, 1697, 2118, - /* 2490 */ 2083, 1697, 2095, 2084, 663, 2086, 2087, 658, 1697, 653, - /* 2500 */ 1697, 1697, 1697, 1697, 2082, 1697, 1697, 2083, 2118, 1697, - /* 2510 */ 1697, 2094, 2084, 663, 2086, 2087, 658, 1697, 653, 1697, - /* 2520 */ 1697, 1697, 1697, 2101, 1697, 1697, 1697, 1697, 1697, 1697, - /* 2530 */ 1697, 660, 1697, 1697, 1697, 1697, 2051, 1697, 659, 1697, - /* 2540 */ 2101, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 660, 1697, - /* 2550 */ 1697, 1697, 1697, 2051, 1697, 659, 1697, 1697, 1697, 1697, - /* 2560 */ 1697, 1697, 1697, 1697, 1697, 1697, 1697, 2083, 2082, 1697, - /* 2570 */ 1697, 1697, 2118, 1697, 1697, 2093, 2084, 663, 2086, 2087, - /* 2580 */ 658, 1697, 653, 1697, 1697, 2082, 1697, 2083, 1697, 2118, - /* 2590 */ 1697, 1697, 346, 2084, 663, 2086, 2087, 658, 1697, 653, - /* 2600 */ 2101, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 660, 1697, - /* 2610 */ 1697, 1697, 1697, 2051, 1697, 659, 1697, 1697, 1697, 1697, - /* 2620 */ 2101, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 660, 1697, - /* 2630 */ 1697, 1697, 1697, 2051, 1697, 659, 1697, 1697, 1697, 1697, - /* 2640 */ 1697, 1697, 1697, 1697, 1697, 2082, 1697, 1697, 1697, 2118, - /* 2650 */ 1697, 1697, 347, 2084, 663, 2086, 2087, 658, 1697, 653, - /* 2660 */ 1697, 2083, 1697, 1697, 1697, 2082, 1697, 1697, 1697, 2118, - /* 2670 */ 1697, 1697, 343, 2084, 663, 2086, 2087, 658, 2083, 653, - /* 2680 */ 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, - /* 2690 */ 1697, 1697, 1697, 1697, 2101, 1697, 1697, 1697, 1697, 1697, - /* 2700 */ 1697, 1697, 660, 1697, 1697, 1697, 1697, 2051, 1697, 659, - /* 2710 */ 1697, 2101, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 660, - /* 2720 */ 1697, 1697, 1697, 1697, 2051, 1697, 659, 1697, 1697, 1697, - /* 2730 */ 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 2082, - /* 2740 */ 2083, 1697, 1697, 2118, 1697, 1697, 348, 2084, 663, 2086, - /* 2750 */ 2087, 658, 1697, 653, 1697, 1697, 661, 1697, 1697, 1697, - /* 2760 */ 2118, 1697, 1697, 323, 2084, 663, 2086, 2087, 658, 1697, - /* 2770 */ 653, 1697, 1697, 2101, 1697, 1697, 1697, 1697, 1697, 1697, - /* 2780 */ 1697, 660, 1697, 1697, 1697, 1697, 2051, 1697, 659, 1697, - /* 2790 */ 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, - /* 2800 */ 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, - /* 2810 */ 1697, 1697, 1697, 1697, 1697, 1697, 1697, 1697, 2082, 1697, - /* 2820 */ 1697, 1697, 2118, 1697, 1697, 322, 2084, 663, 2086, 2087, - /* 2830 */ 658, 1697, 653, + /* 0 */ 1873, 2109, 2003, 428, 1875, 1869, 631, 427, 2096, 167, + /* 10 */ 650, 1729, 45, 43, 1641, 2091, 176, 2001, 637, 2091, + /* 20 */ 389, 613, 1490, 38, 37, 2268, 187, 44, 42, 41, + /* 30 */ 40, 39, 1937, 1571, 2127, 1488, 1783, 354, 1986, 367, + /* 40 */ 612, 182, 664, 1884, 106, 2269, 614, 2077, 1935, 666, + /* 50 */ 588, 2087, 2093, 588, 2268, 2087, 2093, 2268, 1566, 1517, + /* 60 */ 140, 2273, 660, 178, 18, 2268, 660, 2003, 1876, 2274, + /* 70 */ 182, 1496, 2274, 182, 2269, 614, 1924, 2269, 614, 380, + /* 80 */ 2108, 2272, 2000, 637, 2144, 2269, 2271, 328, 2110, 670, + /* 90 */ 2112, 2113, 665, 663, 660, 651, 2162, 757, 1258, 649, + /* 100 */ 14, 501, 734, 733, 732, 731, 399, 497, 730, 729, + /* 110 */ 143, 724, 723, 722, 721, 720, 719, 718, 156, 714, + /* 120 */ 713, 712, 398, 397, 709, 708, 707, 706, 705, 1515, + /* 130 */ 495, 1315, 496, 1753, 1260, 122, 1573, 1574, 121, 120, + /* 140 */ 119, 118, 117, 116, 115, 114, 113, 1306, 692, 691, + /* 150 */ 690, 1310, 689, 1312, 1313, 688, 685, 649, 1321, 682, + /* 160 */ 1323, 1324, 679, 676, 650, 61, 1546, 1556, 2273, 649, + /* 170 */ 38, 37, 1572, 1575, 44, 42, 41, 40, 39, 48, + /* 180 */ 132, 504, 1937, 496, 1753, 1517, 1491, 534, 1489, 352, + /* 190 */ 1515, 35, 292, 1710, 635, 38, 37, 1884, 1935, 44, + /* 200 */ 42, 41, 40, 39, 238, 38, 37, 273, 237, 44, + /* 210 */ 42, 41, 40, 39, 2109, 1494, 1495, 1518, 1545, 1548, + /* 220 */ 1549, 1550, 1551, 1552, 1553, 1554, 1555, 662, 658, 1564, + /* 230 */ 1565, 1567, 1568, 1569, 1570, 2, 45, 43, 166, 513, + /* 240 */ 636, 337, 625, 1513, 389, 1825, 1490, 2127, 1740, 48, + /* 250 */ 465, 346, 1739, 479, 625, 628, 478, 1571, 2044, 1488, + /* 260 */ 2077, 613, 666, 1680, 2070, 2268, 1703, 49, 89, 341, + /* 270 */ 61, 448, 366, 480, 568, 139, 450, 1516, 434, 2095, + /* 280 */ 612, 182, 1566, 13, 12, 2269, 614, 139, 18, 511, + /* 290 */ 2091, 1996, 1709, 2108, 2077, 1496, 1600, 2144, 2077, 608, + /* 300 */ 109, 2110, 670, 2112, 2113, 665, 240, 660, 1185, 274, + /* 310 */ 1184, 588, 179, 86, 2197, 2268, 2109, 185, 383, 2193, + /* 320 */ 334, 757, 355, 222, 14, 86, 2087, 2093, 370, 356, + /* 330 */ 2274, 182, 184, 273, 438, 2269, 614, 660, 1879, 1186, + /* 340 */ 2223, 627, 180, 2205, 2206, 1862, 137, 2210, 1516, 2127, + /* 350 */ 1880, 61, 1601, 92, 181, 2205, 2206, 667, 137, 2210, + /* 360 */ 1573, 1574, 2077, 476, 666, 251, 470, 469, 468, 467, + /* 370 */ 464, 463, 462, 461, 460, 456, 455, 454, 453, 336, + /* 380 */ 445, 444, 443, 1614, 440, 439, 353, 1931, 1932, 147, + /* 390 */ 1546, 1556, 1738, 1349, 1350, 2108, 1572, 1575, 566, 2144, + /* 400 */ 392, 185, 109, 2110, 670, 2112, 2113, 665, 161, 660, + /* 410 */ 1491, 564, 1489, 562, 2172, 368, 2197, 1886, 603, 185, + /* 420 */ 383, 2193, 185, 652, 1935, 2169, 34, 387, 1595, 1596, + /* 430 */ 1597, 1598, 1599, 1603, 1604, 1605, 1606, 625, 2077, 1494, + /* 440 */ 1495, 704, 1545, 1548, 1549, 1550, 1551, 1552, 1553, 1554, + /* 450 */ 1555, 662, 658, 1564, 1565, 1567, 1568, 1569, 1570, 2, + /* 460 */ 11, 45, 43, 394, 1421, 1422, 1930, 1932, 1514, 389, + /* 470 */ 139, 1490, 552, 551, 550, 1669, 548, 547, 1982, 542, + /* 480 */ 136, 546, 1571, 239, 1488, 545, 1737, 223, 2109, 190, + /* 490 */ 544, 549, 362, 361, 494, 1515, 543, 499, 1759, 1967, + /* 500 */ 1420, 1423, 171, 185, 609, 604, 597, 1566, 530, 526, + /* 510 */ 522, 518, 220, 18, 44, 42, 41, 40, 39, 650, + /* 520 */ 1496, 2127, 600, 599, 1667, 1668, 1670, 1671, 1672, 667, + /* 530 */ 100, 636, 2077, 65, 2077, 54, 666, 271, 2205, 624, + /* 540 */ 503, 133, 623, 499, 1759, 2268, 757, 61, 1937, 14, + /* 550 */ 1463, 1464, 1884, 87, 1877, 377, 218, 1645, 728, 726, + /* 560 */ 612, 182, 2127, 1515, 1935, 2269, 614, 2108, 165, 1718, + /* 570 */ 607, 2144, 1786, 312, 169, 2110, 670, 2112, 2113, 665, + /* 580 */ 634, 660, 1996, 2272, 702, 1573, 1574, 310, 72, 421, + /* 590 */ 122, 71, 1861, 121, 120, 119, 118, 117, 116, 115, + /* 600 */ 114, 113, 154, 153, 699, 698, 697, 151, 575, 205, + /* 610 */ 491, 489, 486, 423, 419, 1546, 1556, 606, 41, 40, + /* 620 */ 39, 1572, 1575, 217, 211, 11, 615, 2289, 216, 61, + /* 630 */ 509, 538, 426, 176, 425, 1491, 381, 1489, 552, 551, + /* 640 */ 550, 1404, 1405, 636, 164, 542, 136, 546, 209, 2095, + /* 650 */ 61, 545, 537, 1886, 452, 1987, 544, 549, 362, 361, + /* 660 */ 2091, 424, 543, 451, 1494, 1495, 1496, 1545, 1548, 1549, + /* 670 */ 1550, 1551, 1552, 1553, 1554, 1555, 662, 658, 1564, 1565, + /* 680 */ 1567, 1568, 1569, 1570, 2, 45, 43, 1576, 108, 1717, + /* 690 */ 1736, 1735, 645, 389, 1996, 1490, 2087, 2093, 371, 185, + /* 700 */ 11, 2109, 9, 1715, 702, 1871, 1571, 660, 1488, 1547, + /* 710 */ 1185, 1166, 1184, 131, 130, 129, 128, 127, 126, 125, + /* 720 */ 124, 123, 154, 153, 699, 698, 697, 151, 80, 79, + /* 730 */ 431, 1566, 650, 189, 2127, 650, 2077, 2077, 1171, 1172, + /* 740 */ 1734, 1186, 667, 650, 1496, 695, 472, 2077, 132, 666, + /* 750 */ 1168, 432, 1171, 1172, 335, 539, 1269, 417, 716, 433, + /* 760 */ 415, 411, 407, 404, 424, 1884, 2095, 1937, 1884, 1268, + /* 770 */ 757, 402, 1490, 46, 382, 401, 1884, 2091, 1860, 2109, + /* 780 */ 2108, 185, 2098, 1935, 2144, 1488, 2077, 109, 2110, 670, + /* 790 */ 2112, 2113, 665, 654, 660, 2169, 1867, 142, 1581, 149, + /* 800 */ 2168, 2197, 185, 650, 1515, 383, 2193, 198, 197, 1573, + /* 810 */ 1574, 625, 2127, 2087, 2093, 384, 1937, 164, 588, 442, + /* 820 */ 667, 1496, 2268, 393, 660, 2077, 1887, 666, 283, 284, + /* 830 */ 471, 481, 1935, 282, 194, 2100, 1884, 2274, 182, 1546, + /* 840 */ 1556, 704, 2269, 614, 139, 1572, 1575, 757, 650, 38, + /* 850 */ 37, 1518, 616, 44, 42, 41, 40, 39, 2108, 1491, + /* 860 */ 1273, 1489, 2144, 392, 457, 109, 2110, 670, 2112, 2113, + /* 870 */ 665, 164, 660, 1272, 1733, 83, 1515, 2170, 82, 2197, + /* 880 */ 1886, 1884, 1732, 383, 2193, 27, 2071, 1602, 1494, 1495, + /* 890 */ 1638, 1545, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, + /* 900 */ 662, 658, 1564, 1565, 1567, 1568, 1569, 1570, 2, 45, + /* 910 */ 43, 183, 2205, 2206, 395, 137, 2210, 389, 650, 1490, + /* 920 */ 2077, 2109, 164, 248, 2217, 1634, 650, 1731, 2077, 73, + /* 930 */ 1571, 1886, 1488, 588, 458, 483, 1491, 2268, 1489, 38, + /* 940 */ 37, 557, 512, 44, 42, 41, 40, 39, 2212, 694, + /* 950 */ 1547, 1884, 2274, 182, 2127, 1566, 567, 2269, 614, 1884, + /* 960 */ 1728, 32, 628, 2212, 2060, 1494, 1495, 2077, 1496, 666, + /* 970 */ 236, 1607, 1727, 2077, 2209, 38, 37, 1982, 81, 44, + /* 980 */ 42, 41, 40, 39, 717, 560, 1846, 650, 192, 2208, + /* 990 */ 554, 1726, 8, 152, 757, 235, 1725, 46, 1724, 191, + /* 1000 */ 2108, 1518, 1723, 1881, 2144, 2109, 2077, 109, 2110, 670, + /* 1010 */ 2112, 2113, 665, 1722, 660, 1721, 1720, 31, 2077, 179, + /* 1020 */ 1884, 2197, 1547, 38, 37, 383, 2193, 44, 42, 41, + /* 1030 */ 40, 39, 1657, 1573, 1574, 1859, 69, 2077, 2127, 68, + /* 1040 */ 141, 650, 2077, 2168, 2077, 1982, 667, 2224, 2077, 650, + /* 1050 */ 53, 2077, 1937, 666, 435, 2212, 196, 241, 51, 2077, + /* 1060 */ 3, 2077, 2077, 1546, 1556, 584, 33, 436, 1936, 1572, + /* 1070 */ 1575, 650, 38, 37, 1884, 617, 44, 42, 41, 40, + /* 1080 */ 39, 2207, 1884, 1491, 2108, 1489, 696, 629, 2144, 1928, + /* 1090 */ 2063, 109, 2110, 670, 2112, 2113, 665, 700, 660, 701, + /* 1100 */ 1928, 620, 1928, 653, 1884, 2197, 152, 2109, 306, 383, + /* 1110 */ 2193, 1914, 1494, 1495, 540, 1545, 1548, 1549, 1550, 1551, + /* 1120 */ 1552, 1553, 1554, 1555, 662, 658, 1564, 1565, 1567, 1568, + /* 1130 */ 1569, 1570, 2, 45, 43, 163, 1256, 587, 409, 1637, + /* 1140 */ 2127, 389, 650, 1490, 570, 650, 569, 702, 667, 250, + /* 1150 */ 145, 152, 134, 2077, 1571, 666, 1488, 228, 633, 573, + /* 1160 */ 226, 287, 245, 1458, 661, 154, 153, 699, 698, 697, + /* 1170 */ 151, 230, 359, 416, 229, 1884, 38, 37, 1884, 1566, + /* 1180 */ 44, 42, 41, 40, 39, 232, 2108, 650, 231, 249, + /* 1190 */ 2144, 63, 1496, 109, 2110, 670, 2112, 2113, 665, 650, + /* 1200 */ 660, 650, 1826, 647, 1634, 2288, 588, 2197, 1461, 52, + /* 1210 */ 2268, 383, 2193, 2109, 1499, 648, 63, 293, 757, 650, + /* 1220 */ 1884, 14, 2231, 1773, 234, 2274, 182, 233, 1766, 255, + /* 1230 */ 2269, 614, 1884, 90, 1884, 396, 2109, 1498, 360, 105, + /* 1240 */ 358, 357, 1764, 536, 541, 553, 2127, 538, 1666, 102, + /* 1250 */ 555, 2273, 1884, 152, 667, 2268, 1730, 1573, 1574, 2077, + /* 1260 */ 2237, 666, 1712, 1713, 558, 268, 1254, 710, 537, 2127, + /* 1270 */ 601, 2272, 657, 1665, 47, 2269, 2270, 667, 280, 13, + /* 1280 */ 12, 70, 2077, 221, 666, 262, 257, 1546, 1556, 1234, + /* 1290 */ 2128, 400, 2108, 1572, 1575, 1991, 2144, 1754, 1215, 110, + /* 1300 */ 2110, 670, 2112, 2113, 665, 618, 660, 1491, 150, 1489, + /* 1310 */ 632, 152, 1925, 2197, 63, 2108, 47, 2196, 2193, 2144, + /* 1320 */ 47, 674, 168, 2110, 670, 2112, 2113, 665, 2109, 660, + /* 1330 */ 2227, 1418, 150, 621, 1216, 285, 1494, 1495, 642, 1545, + /* 1340 */ 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 662, 658, + /* 1350 */ 1564, 1565, 1567, 1568, 1569, 1570, 2, 711, 626, 270, + /* 1360 */ 267, 2127, 1, 589, 2234, 289, 4, 1502, 1299, 667, + /* 1370 */ 152, 1608, 135, 1557, 2077, 403, 666, 305, 1327, 1232, + /* 1380 */ 150, 1760, 408, 350, 1441, 300, 437, 195, 1518, 1331, + /* 1390 */ 1501, 1992, 441, 446, 474, 459, 1513, 1984, 2109, 466, + /* 1400 */ 484, 473, 475, 485, 482, 199, 487, 2108, 488, 200, + /* 1410 */ 202, 2144, 490, 492, 109, 2110, 670, 2112, 2113, 665, + /* 1420 */ 1519, 660, 493, 1592, 502, 1521, 2288, 1338, 2197, 1336, + /* 1430 */ 752, 2127, 383, 2193, 505, 208, 1516, 155, 210, 667, + /* 1440 */ 1520, 506, 507, 2244, 2077, 1522, 666, 508, 510, 2109, + /* 1450 */ 213, 215, 84, 1188, 514, 531, 85, 219, 532, 533, + /* 1460 */ 535, 1874, 225, 1870, 227, 157, 111, 340, 158, 572, + /* 1470 */ 88, 2053, 2050, 578, 574, 148, 579, 2108, 242, 244, + /* 1480 */ 301, 2144, 2127, 1872, 109, 2110, 670, 2112, 2113, 665, + /* 1490 */ 667, 660, 577, 1868, 159, 2077, 2288, 666, 2197, 386, + /* 1500 */ 385, 2049, 383, 2193, 160, 246, 1448, 585, 2228, 1504, + /* 1510 */ 582, 602, 2238, 595, 7, 592, 2243, 640, 611, 583, + /* 1520 */ 1571, 598, 1497, 372, 2109, 605, 593, 373, 2108, 591, + /* 1530 */ 2242, 253, 2144, 261, 256, 109, 2110, 670, 2112, 2113, + /* 1540 */ 665, 2219, 660, 622, 590, 1566, 2267, 2288, 619, 2197, + /* 1550 */ 1634, 2291, 269, 383, 2193, 138, 1517, 2127, 1496, 266, + /* 1560 */ 630, 2213, 376, 275, 2262, 667, 95, 1523, 1997, 302, + /* 1570 */ 2077, 638, 666, 172, 639, 2011, 2010, 2009, 303, 643, + /* 1580 */ 379, 644, 60, 264, 656, 97, 304, 1885, 263, 99, + /* 1590 */ 2178, 1929, 101, 265, 1847, 672, 296, 307, 753, 342, + /* 1600 */ 50, 754, 331, 2108, 756, 343, 316, 2144, 330, 576, + /* 1610 */ 109, 2110, 670, 2112, 2113, 665, 311, 660, 320, 309, + /* 1620 */ 2069, 2068, 2288, 2067, 2197, 77, 2064, 760, 383, 2193, + /* 1630 */ 405, 406, 1481, 1482, 188, 410, 2062, 412, 413, 2216, + /* 1640 */ 414, 299, 2061, 2109, 351, 2059, 418, 2058, 2057, 420, + /* 1650 */ 422, 78, 1444, 1443, 2023, 2022, 175, 2021, 429, 430, + /* 1660 */ 2020, 2019, 750, 746, 742, 738, 297, 1975, 1974, 1395, + /* 1670 */ 1972, 144, 1971, 1505, 1970, 1500, 2127, 193, 447, 1963, + /* 1680 */ 449, 1977, 1962, 1961, 667, 1973, 1969, 1968, 1966, 2077, + /* 1690 */ 1965, 666, 1964, 1960, 1959, 1958, 1957, 1956, 1955, 1954, + /* 1700 */ 1953, 1952, 1508, 1510, 1951, 1950, 1949, 107, 2109, 1948, + /* 1710 */ 290, 146, 1947, 1946, 1945, 658, 1564, 1565, 1567, 1568, + /* 1720 */ 1569, 1570, 2108, 1976, 1944, 1943, 2144, 1942, 1941, 110, + /* 1730 */ 2110, 670, 2112, 2113, 665, 1940, 660, 1397, 1939, 477, + /* 1740 */ 1938, 2127, 646, 2197, 1270, 338, 339, 655, 2193, 667, + /* 1750 */ 1789, 1274, 1266, 1788, 2077, 1787, 666, 1785, 1749, 75, + /* 1760 */ 201, 206, 177, 2097, 1748, 203, 204, 2040, 1174, 76, + /* 1770 */ 1173, 2030, 2018, 2109, 207, 212, 2017, 277, 498, 500, + /* 1780 */ 1995, 1863, 276, 214, 1784, 1782, 1208, 668, 517, 516, + /* 1790 */ 1780, 2144, 520, 1778, 110, 2110, 670, 2112, 2113, 665, + /* 1800 */ 515, 660, 243, 519, 523, 521, 2127, 524, 2197, 525, + /* 1810 */ 1776, 528, 345, 2193, 667, 1763, 529, 527, 1762, 2077, + /* 1820 */ 1745, 666, 1865, 1343, 2109, 1342, 1864, 1257, 1244, 1255, + /* 1830 */ 725, 1253, 1252, 1251, 1250, 62, 1249, 1246, 1774, 1245, + /* 1840 */ 224, 363, 1243, 2109, 727, 1767, 364, 1765, 559, 365, + /* 1850 */ 1744, 561, 2108, 1743, 1742, 556, 2144, 2127, 563, 110, + /* 1860 */ 2110, 670, 2112, 2113, 665, 667, 660, 1468, 565, 112, + /* 1870 */ 2077, 1470, 666, 2197, 1467, 26, 2127, 2039, 2194, 1472, + /* 1880 */ 1452, 2029, 1454, 66, 667, 580, 1450, 2016, 2014, 2077, + /* 1890 */ 16, 666, 2273, 20, 64, 17, 19, 2015, 2013, 162, + /* 1900 */ 58, 59, 1697, 2108, 596, 55, 259, 2144, 28, 247, + /* 1910 */ 168, 2110, 670, 2112, 2113, 665, 581, 660, 2109, 369, + /* 1920 */ 586, 252, 2108, 260, 5, 2098, 2144, 594, 30, 322, + /* 1930 */ 2110, 670, 2112, 2113, 665, 1682, 660, 2109, 6, 21, + /* 1940 */ 1696, 254, 1664, 170, 258, 374, 1701, 1700, 29, 375, + /* 1950 */ 272, 2127, 2235, 57, 173, 2012, 1656, 1994, 641, 667, + /* 1960 */ 91, 56, 1702, 94, 2077, 1703, 666, 1631, 278, 1630, + /* 1970 */ 2127, 93, 22, 610, 279, 378, 1662, 1993, 667, 281, + /* 1980 */ 286, 96, 67, 2077, 102, 666, 288, 291, 23, 10, + /* 1990 */ 12, 1583, 98, 1506, 1582, 1561, 174, 2108, 186, 2147, + /* 2000 */ 659, 2144, 1559, 1558, 169, 2110, 670, 2112, 2113, 665, + /* 2010 */ 2109, 660, 1538, 36, 673, 15, 2108, 24, 391, 1530, + /* 2020 */ 2144, 677, 25, 329, 2110, 670, 2112, 2113, 665, 1593, + /* 2030 */ 660, 671, 1328, 675, 680, 1325, 2109, 678, 683, 1322, + /* 2040 */ 1316, 681, 686, 2127, 1314, 684, 687, 669, 1320, 1319, + /* 2050 */ 1318, 664, 1317, 1305, 103, 294, 2077, 2290, 666, 693, + /* 2060 */ 104, 1337, 74, 1333, 1240, 1206, 703, 1239, 1238, 2127, + /* 2070 */ 1237, 1236, 1264, 1235, 388, 1233, 1224, 667, 1231, 1230, + /* 2080 */ 1229, 1227, 2077, 295, 666, 715, 1226, 1225, 1223, 2108, + /* 2090 */ 1222, 1221, 1261, 2144, 1259, 1218, 328, 2110, 670, 2112, + /* 2100 */ 2113, 665, 1217, 660, 1214, 2163, 1213, 2109, 1212, 1211, + /* 2110 */ 1781, 735, 736, 1779, 737, 2108, 739, 741, 740, 2144, + /* 2120 */ 1777, 744, 329, 2110, 670, 2112, 2113, 665, 2109, 660, + /* 2130 */ 743, 745, 1775, 748, 747, 749, 1761, 751, 1163, 1741, + /* 2140 */ 2127, 298, 755, 759, 1492, 390, 308, 758, 667, 1716, + /* 2150 */ 1716, 1716, 1716, 2077, 1716, 666, 1716, 1716, 2109, 1716, + /* 2160 */ 1716, 2127, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 667, + /* 2170 */ 1716, 1716, 1716, 1716, 2077, 1716, 666, 1716, 1716, 1716, + /* 2180 */ 1716, 1716, 1716, 1716, 1716, 1716, 2108, 1716, 1716, 1716, + /* 2190 */ 2144, 2127, 1716, 329, 2110, 670, 2112, 2113, 665, 667, + /* 2200 */ 660, 1716, 1716, 1716, 2077, 1716, 666, 571, 1716, 1716, + /* 2210 */ 1716, 2144, 1716, 1716, 324, 2110, 670, 2112, 2113, 665, + /* 2220 */ 1716, 660, 1716, 2109, 1716, 1716, 1716, 1716, 1716, 1716, + /* 2230 */ 1716, 1716, 1716, 1716, 1716, 1716, 1716, 2108, 1716, 1716, + /* 2240 */ 1716, 2144, 1716, 1716, 313, 2110, 670, 2112, 2113, 665, + /* 2250 */ 1716, 660, 2109, 1716, 1716, 1716, 2127, 1716, 1716, 1716, + /* 2260 */ 1716, 1716, 1716, 1716, 667, 1716, 1716, 1716, 1716, 2077, + /* 2270 */ 1716, 666, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, + /* 2280 */ 1716, 1716, 1716, 1716, 1716, 2127, 2109, 1716, 1716, 1716, + /* 2290 */ 1716, 1716, 1716, 667, 1716, 1716, 1716, 1716, 2077, 1716, + /* 2300 */ 666, 1716, 2108, 1716, 1716, 1716, 2144, 1716, 1716, 314, + /* 2310 */ 2110, 670, 2112, 2113, 665, 1716, 660, 1716, 1716, 2127, + /* 2320 */ 1716, 1716, 1716, 1716, 1716, 1716, 1716, 667, 1716, 1716, + /* 2330 */ 1716, 2108, 2077, 1716, 666, 2144, 1716, 1716, 315, 2110, + /* 2340 */ 670, 2112, 2113, 665, 1716, 660, 1716, 1716, 1716, 1716, + /* 2350 */ 2109, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, + /* 2360 */ 1716, 1716, 1716, 1716, 1716, 2108, 1716, 1716, 1716, 2144, + /* 2370 */ 2109, 1716, 321, 2110, 670, 2112, 2113, 665, 1716, 660, + /* 2380 */ 1716, 1716, 1716, 2127, 1716, 1716, 1716, 1716, 1716, 1716, + /* 2390 */ 1716, 667, 1716, 1716, 1716, 1716, 2077, 1716, 666, 1716, + /* 2400 */ 1716, 1716, 1716, 2127, 1716, 1716, 1716, 1716, 1716, 1716, + /* 2410 */ 1716, 667, 1716, 1716, 1716, 1716, 2077, 1716, 666, 1716, + /* 2420 */ 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 2108, + /* 2430 */ 1716, 2109, 1716, 2144, 1716, 1716, 325, 2110, 670, 2112, + /* 2440 */ 2113, 665, 1716, 660, 1716, 1716, 1716, 1716, 1716, 2108, + /* 2450 */ 1716, 1716, 1716, 2144, 1716, 1716, 317, 2110, 670, 2112, + /* 2460 */ 2113, 665, 1716, 660, 2127, 1716, 1716, 1716, 1716, 1716, + /* 2470 */ 1716, 1716, 667, 1716, 1716, 1716, 1716, 2077, 1716, 666, + /* 2480 */ 1716, 1716, 2109, 1716, 1716, 1716, 1716, 1716, 1716, 1716, + /* 2490 */ 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, + /* 2500 */ 1716, 1716, 1716, 2109, 1716, 1716, 1716, 1716, 1716, 1716, + /* 2510 */ 2108, 1716, 1716, 1716, 2144, 2127, 1716, 326, 2110, 670, + /* 2520 */ 2112, 2113, 665, 667, 660, 1716, 1716, 1716, 2077, 1716, + /* 2530 */ 666, 1716, 1716, 2109, 1716, 1716, 2127, 1716, 1716, 1716, + /* 2540 */ 1716, 1716, 1716, 1716, 667, 1716, 1716, 1716, 1716, 2077, + /* 2550 */ 1716, 666, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, + /* 2560 */ 1716, 2108, 1716, 1716, 1716, 2144, 2127, 1716, 318, 2110, + /* 2570 */ 670, 2112, 2113, 665, 667, 660, 1716, 1716, 1716, 2077, + /* 2580 */ 1716, 666, 2108, 1716, 1716, 1716, 2144, 1716, 1716, 327, + /* 2590 */ 2110, 670, 2112, 2113, 665, 1716, 660, 1716, 2109, 1716, + /* 2600 */ 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, + /* 2610 */ 1716, 1716, 2108, 1716, 1716, 1716, 2144, 1716, 1716, 319, + /* 2620 */ 2110, 670, 2112, 2113, 665, 1716, 660, 2109, 1716, 1716, + /* 2630 */ 1716, 2127, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 667, + /* 2640 */ 1716, 1716, 1716, 1716, 2077, 1716, 666, 1716, 1716, 1716, + /* 2650 */ 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, + /* 2660 */ 2127, 2109, 1716, 1716, 1716, 1716, 1716, 1716, 667, 1716, + /* 2670 */ 1716, 1716, 1716, 2077, 1716, 666, 1716, 2108, 1716, 1716, + /* 2680 */ 1716, 2144, 1716, 1716, 332, 2110, 670, 2112, 2113, 665, + /* 2690 */ 1716, 660, 1716, 1716, 2127, 1716, 1716, 1716, 1716, 1716, + /* 2700 */ 1716, 1716, 667, 1716, 1716, 1716, 2108, 2077, 1716, 666, + /* 2710 */ 2144, 1716, 1716, 333, 2110, 670, 2112, 2113, 665, 1716, + /* 2720 */ 660, 1716, 1716, 1716, 1716, 2109, 1716, 1716, 1716, 1716, + /* 2730 */ 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, + /* 2740 */ 2108, 1716, 1716, 1716, 2144, 2109, 1716, 2121, 2110, 670, + /* 2750 */ 2112, 2113, 665, 1716, 660, 1716, 1716, 1716, 2127, 1716, + /* 2760 */ 1716, 1716, 1716, 1716, 1716, 1716, 667, 1716, 1716, 1716, + /* 2770 */ 1716, 2077, 1716, 666, 1716, 1716, 1716, 1716, 2127, 1716, + /* 2780 */ 1716, 1716, 1716, 1716, 1716, 1716, 667, 1716, 1716, 1716, + /* 2790 */ 1716, 2077, 1716, 666, 1716, 1716, 1716, 1716, 1716, 1716, + /* 2800 */ 1716, 1716, 1716, 1716, 2108, 1716, 2109, 1716, 2144, 1716, + /* 2810 */ 1716, 2120, 2110, 670, 2112, 2113, 665, 1716, 660, 1716, + /* 2820 */ 1716, 1716, 1716, 1716, 2108, 1716, 1716, 1716, 2144, 1716, + /* 2830 */ 1716, 2119, 2110, 670, 2112, 2113, 665, 1716, 660, 2127, + /* 2840 */ 1716, 1716, 1716, 1716, 1716, 1716, 1716, 667, 1716, 1716, + /* 2850 */ 1716, 1716, 2077, 1716, 666, 1716, 1716, 2109, 1716, 1716, + /* 2860 */ 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, + /* 2870 */ 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 2109, 1716, + /* 2880 */ 1716, 1716, 1716, 1716, 1716, 2108, 1716, 1716, 1716, 2144, + /* 2890 */ 2127, 1716, 347, 2110, 670, 2112, 2113, 665, 667, 660, + /* 2900 */ 1716, 1716, 1716, 2077, 1716, 666, 1716, 1716, 2109, 1716, + /* 2910 */ 1716, 2127, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 667, + /* 2920 */ 1716, 1716, 1716, 1716, 2077, 1716, 666, 1716, 1716, 1716, + /* 2930 */ 1716, 1716, 1716, 1716, 1716, 1716, 2108, 1716, 1716, 1716, + /* 2940 */ 2144, 2127, 1716, 348, 2110, 670, 2112, 2113, 665, 667, + /* 2950 */ 660, 1716, 1716, 1716, 2077, 1716, 666, 2108, 1716, 1716, + /* 2960 */ 1716, 2144, 1716, 1716, 344, 2110, 670, 2112, 2113, 665, + /* 2970 */ 1716, 660, 1716, 2109, 1716, 1716, 1716, 1716, 1716, 1716, + /* 2980 */ 1716, 1716, 1716, 1716, 1716, 1716, 1716, 2108, 1716, 1716, + /* 2990 */ 1716, 2144, 1716, 1716, 349, 2110, 670, 2112, 2113, 665, + /* 3000 */ 1716, 660, 2109, 1716, 1716, 1716, 2127, 1716, 1716, 1716, + /* 3010 */ 1716, 1716, 1716, 1716, 667, 1716, 1716, 1716, 1716, 2077, + /* 3020 */ 1716, 666, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, + /* 3030 */ 1716, 1716, 1716, 1716, 1716, 2127, 1716, 1716, 1716, 1716, + /* 3040 */ 1716, 1716, 1716, 667, 1716, 1716, 1716, 1716, 2077, 1716, + /* 3050 */ 666, 1716, 668, 1716, 1716, 1716, 2144, 1716, 1716, 324, + /* 3060 */ 2110, 670, 2112, 2113, 665, 1716, 660, 1716, 1716, 1716, + /* 3070 */ 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, 1716, + /* 3080 */ 1716, 2108, 1716, 1716, 1716, 2144, 1716, 1716, 323, 2110, + /* 3090 */ 670, 2112, 2113, 665, 1716, 660, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 367, 443, 380, 347, 332, 447, 336, 365, 338, 339, - /* 10 */ 354, 378, 12, 13, 14, 373, 380, 395, 396, 367, - /* 20 */ 20, 463, 22, 340, 20, 467, 468, 332, 392, 416, - /* 30 */ 378, 395, 396, 33, 361, 35, 0, 365, 12, 13, - /* 40 */ 14, 15, 16, 340, 20, 373, 413, 414, 415, 20, - /* 50 */ 378, 22, 380, 340, 340, 442, 373, 424, 58, 443, - /* 60 */ 365, 419, 365, 447, 64, 413, 414, 415, 373, 372, - /* 70 */ 356, 71, 331, 378, 333, 380, 424, 363, 381, 463, - /* 80 */ 51, 408, 410, 467, 468, 382, 414, 373, 20, 417, - /* 90 */ 418, 419, 420, 421, 422, 367, 424, 97, 4, 63, - /* 100 */ 100, 429, 389, 431, 391, 410, 378, 435, 436, 414, - /* 110 */ 12, 13, 417, 418, 419, 420, 421, 422, 20, 424, - /* 120 */ 22, 449, 439, 440, 441, 332, 443, 444, 111, 457, - /* 130 */ 447, 33, 20, 35, 22, 376, 136, 137, 379, 380, - /* 140 */ 443, 413, 414, 415, 447, 462, 463, 35, 432, 433, - /* 150 */ 467, 468, 424, 458, 459, 58, 58, 0, 20, 462, - /* 160 */ 463, 20, 64, 51, 467, 468, 166, 167, 100, 71, - /* 170 */ 0, 378, 172, 173, 8, 9, 364, 160, 12, 13, - /* 180 */ 14, 15, 16, 66, 67, 68, 186, 63, 188, 377, - /* 190 */ 73, 74, 75, 365, 100, 97, 79, 100, 100, 102, - /* 200 */ 14, 84, 85, 100, 8, 9, 20, 90, 12, 13, - /* 210 */ 14, 15, 16, 213, 214, 387, 216, 217, 218, 219, + /* 0 */ 367, 333, 381, 398, 368, 367, 398, 402, 368, 332, + /* 10 */ 341, 334, 12, 13, 14, 379, 366, 396, 397, 379, + /* 20 */ 20, 445, 22, 8, 9, 449, 357, 12, 13, 14, + /* 30 */ 15, 16, 366, 33, 366, 35, 0, 387, 388, 373, + /* 40 */ 464, 465, 374, 374, 345, 469, 470, 379, 382, 381, + /* 50 */ 445, 415, 416, 445, 449, 415, 416, 449, 58, 20, + /* 60 */ 361, 445, 426, 365, 64, 449, 426, 381, 369, 464, + /* 70 */ 465, 71, 464, 465, 469, 470, 378, 469, 470, 393, + /* 80 */ 412, 465, 396, 397, 416, 469, 470, 419, 420, 421, + /* 90 */ 422, 423, 424, 425, 426, 427, 428, 97, 35, 20, + /* 100 */ 100, 14, 66, 67, 68, 69, 70, 20, 72, 73, + /* 110 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, + /* 120 */ 84, 85, 86, 87, 88, 89, 90, 91, 92, 20, + /* 130 */ 337, 97, 339, 340, 71, 21, 136, 137, 24, 25, + /* 140 */ 26, 27, 28, 29, 30, 31, 32, 113, 114, 115, + /* 150 */ 116, 117, 118, 119, 120, 121, 122, 20, 124, 125, + /* 160 */ 126, 127, 128, 129, 341, 100, 166, 167, 3, 20, + /* 170 */ 8, 9, 172, 173, 12, 13, 14, 15, 16, 100, + /* 180 */ 357, 337, 366, 339, 340, 20, 186, 364, 188, 373, + /* 190 */ 20, 434, 435, 178, 20, 8, 9, 374, 382, 12, + /* 200 */ 13, 14, 15, 16, 131, 8, 9, 168, 135, 12, + /* 210 */ 13, 14, 15, 16, 333, 215, 216, 20, 218, 219, /* 220 */ 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, - /* 230 */ 230, 231, 232, 233, 136, 137, 66, 67, 68, 69, - /* 240 */ 70, 100, 72, 73, 74, 75, 76, 77, 78, 79, - /* 250 */ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, - /* 260 */ 90, 91, 92, 20, 166, 167, 171, 101, 96, 112, - /* 270 */ 172, 173, 21, 165, 35, 24, 25, 26, 27, 28, - /* 280 */ 29, 30, 31, 32, 186, 112, 188, 130, 131, 132, - /* 290 */ 133, 134, 135, 8, 9, 63, 4, 12, 13, 14, - /* 300 */ 15, 16, 373, 130, 131, 132, 133, 134, 135, 329, - /* 310 */ 71, 213, 214, 384, 216, 217, 218, 219, 220, 221, - /* 320 */ 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, - /* 330 */ 232, 233, 234, 12, 13, 43, 0, 45, 46, 20, - /* 340 */ 168, 20, 97, 22, 250, 237, 373, 250, 20, 64, - /* 350 */ 255, 256, 257, 250, 33, 247, 35, 384, 113, 114, - /* 360 */ 115, 116, 117, 118, 119, 120, 121, 122, 346, 124, - /* 370 */ 125, 126, 127, 128, 129, 0, 2, 397, 332, 58, - /* 380 */ 44, 401, 8, 9, 362, 64, 12, 13, 14, 15, - /* 390 */ 16, 250, 71, 371, 109, 336, 21, 338, 339, 24, - /* 400 */ 25, 26, 27, 28, 29, 30, 31, 32, 8, 9, - /* 410 */ 340, 365, 12, 13, 14, 15, 16, 357, 97, 373, - /* 420 */ 20, 100, 80, 443, 378, 365, 380, 447, 100, 357, - /* 430 */ 20, 12, 13, 14, 374, 130, 131, 365, 373, 20, - /* 440 */ 135, 22, 462, 463, 372, 20, 374, 467, 468, 384, - /* 450 */ 165, 131, 33, 381, 35, 135, 410, 136, 137, 389, - /* 460 */ 414, 391, 111, 417, 418, 419, 420, 421, 422, 423, - /* 470 */ 424, 425, 426, 0, 8, 9, 234, 58, 12, 13, - /* 480 */ 14, 15, 16, 141, 142, 166, 167, 166, 167, 344, - /* 490 */ 71, 0, 337, 172, 173, 340, 341, 24, 25, 26, - /* 500 */ 27, 28, 29, 30, 31, 32, 164, 186, 337, 188, - /* 510 */ 44, 340, 341, 368, 194, 195, 97, 397, 198, 100, - /* 520 */ 200, 401, 237, 238, 239, 240, 241, 242, 243, 244, - /* 530 */ 245, 246, 247, 332, 213, 214, 402, 216, 217, 218, - /* 540 */ 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, - /* 550 */ 229, 230, 231, 232, 233, 136, 137, 66, 67, 68, - /* 560 */ 71, 136, 137, 443, 73, 74, 75, 447, 168, 100, - /* 570 */ 79, 379, 380, 367, 344, 84, 85, 71, 250, 378, - /* 580 */ 332, 90, 462, 463, 378, 166, 167, 467, 468, 2, - /* 590 */ 360, 172, 173, 1, 2, 8, 9, 0, 368, 12, - /* 600 */ 13, 14, 15, 16, 111, 186, 3, 188, 351, 352, - /* 610 */ 8, 9, 21, 365, 12, 13, 14, 15, 16, 413, - /* 620 */ 414, 373, 340, 20, 0, 34, 378, 36, 380, 234, - /* 630 */ 424, 236, 213, 214, 346, 216, 217, 218, 219, 220, - /* 640 */ 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, - /* 650 */ 231, 232, 233, 12, 13, 373, 58, 332, 410, 371, - /* 660 */ 367, 20, 414, 22, 340, 417, 418, 419, 420, 421, - /* 670 */ 422, 378, 424, 20, 33, 427, 35, 429, 430, 431, - /* 680 */ 356, 8, 9, 435, 436, 12, 13, 14, 15, 16, - /* 690 */ 365, 332, 365, 101, 20, 365, 0, 373, 373, 58, - /* 700 */ 102, 340, 372, 378, 101, 380, 413, 414, 332, 112, - /* 710 */ 397, 381, 71, 386, 387, 213, 37, 424, 22, 250, - /* 720 */ 438, 439, 440, 441, 340, 443, 444, 130, 131, 132, - /* 730 */ 133, 134, 135, 427, 373, 410, 430, 378, 97, 414, - /* 740 */ 356, 100, 417, 418, 419, 420, 421, 422, 3, 424, - /* 750 */ 332, 12, 13, 340, 378, 375, 443, 373, 378, 20, - /* 760 */ 447, 22, 260, 261, 262, 263, 264, 265, 266, 356, - /* 770 */ 168, 168, 33, 366, 35, 462, 463, 136, 137, 155, - /* 780 */ 467, 468, 103, 416, 105, 106, 373, 108, 164, 136, - /* 790 */ 137, 112, 340, 366, 469, 470, 378, 58, 366, 332, - /* 800 */ 439, 440, 441, 332, 443, 444, 20, 166, 167, 442, - /* 810 */ 71, 366, 133, 172, 173, 340, 8, 9, 416, 340, - /* 820 */ 12, 13, 14, 15, 16, 172, 173, 186, 366, 188, - /* 830 */ 365, 356, 365, 332, 0, 356, 97, 372, 363, 100, - /* 840 */ 373, 389, 168, 391, 442, 378, 381, 380, 373, 378, - /* 850 */ 397, 178, 373, 58, 213, 214, 332, 216, 217, 218, - /* 860 */ 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, - /* 870 */ 229, 230, 231, 232, 233, 136, 137, 410, 366, 378, - /* 880 */ 397, 414, 48, 365, 417, 418, 419, 420, 421, 422, - /* 890 */ 372, 424, 375, 357, 99, 378, 443, 102, 431, 381, - /* 900 */ 447, 365, 378, 436, 443, 166, 167, 20, 447, 101, - /* 910 */ 374, 172, 173, 351, 352, 462, 463, 181, 100, 39, - /* 920 */ 467, 468, 22, 462, 463, 186, 443, 188, 467, 468, - /* 930 */ 447, 365, 428, 14, 430, 35, 14, 366, 372, 20, - /* 940 */ 204, 205, 20, 45, 46, 462, 463, 381, 275, 44, - /* 950 */ 467, 468, 213, 214, 168, 216, 217, 218, 219, 220, - /* 960 */ 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, - /* 970 */ 231, 232, 233, 20, 18, 18, 20, 340, 12, 13, - /* 980 */ 23, 397, 428, 27, 430, 4, 30, 332, 22, 33, - /* 990 */ 14, 15, 16, 356, 37, 38, 4, 97, 41, 33, - /* 1000 */ 19, 35, 333, 185, 48, 187, 50, 388, 375, 53, - /* 1010 */ 373, 378, 22, 365, 33, 270, 59, 60, 61, 62, - /* 1020 */ 365, 44, 374, 340, 58, 35, 340, 443, 373, 48, - /* 1030 */ 212, 447, 357, 378, 53, 380, 332, 71, 340, 58, - /* 1040 */ 365, 112, 356, 332, 248, 249, 462, 463, 340, 374, - /* 1050 */ 365, 467, 468, 166, 356, 99, 373, 100, 353, 373, - /* 1060 */ 355, 71, 133, 97, 356, 410, 381, 111, 250, 414, - /* 1070 */ 354, 373, 417, 418, 419, 420, 421, 422, 101, 424, - /* 1080 */ 99, 373, 378, 102, 429, 166, 431, 97, 166, 378, - /* 1090 */ 435, 436, 332, 332, 35, 138, 140, 332, 0, 143, - /* 1100 */ 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, - /* 1110 */ 154, 155, 156, 157, 158, 159, 340, 161, 162, 163, - /* 1120 */ 22, 168, 439, 440, 441, 44, 443, 444, 340, 249, - /* 1130 */ 358, 340, 356, 361, 44, 178, 179, 180, 378, 378, - /* 1140 */ 183, 332, 340, 378, 356, 130, 22, 356, 42, 373, - /* 1150 */ 44, 42, 186, 44, 188, 340, 332, 340, 356, 35, - /* 1160 */ 203, 373, 35, 206, 373, 208, 209, 210, 211, 212, - /* 1170 */ 332, 356, 332, 356, 365, 373, 186, 272, 188, 213, - /* 1180 */ 214, 471, 373, 104, 340, 64, 107, 378, 373, 380, - /* 1190 */ 373, 101, 226, 227, 228, 229, 230, 231, 232, 340, - /* 1200 */ 356, 22, 378, 213, 214, 365, 332, 250, 340, 340, - /* 1210 */ 332, 196, 197, 373, 35, 356, 378, 373, 378, 410, - /* 1220 */ 380, 97, 332, 414, 356, 356, 417, 418, 419, 420, - /* 1230 */ 421, 422, 373, 424, 104, 332, 332, 107, 429, 332, - /* 1240 */ 431, 373, 373, 251, 435, 436, 104, 188, 104, 107, - /* 1250 */ 410, 107, 378, 460, 414, 365, 378, 417, 418, 419, - /* 1260 */ 420, 421, 422, 373, 424, 44, 457, 0, 378, 429, - /* 1270 */ 380, 431, 365, 44, 342, 435, 436, 199, 44, 201, - /* 1280 */ 373, 378, 378, 454, 44, 378, 446, 380, 100, 22, - /* 1290 */ 136, 137, 365, 44, 342, 1, 2, 44, 110, 332, - /* 1300 */ 410, 44, 44, 47, 414, 44, 44, 417, 418, 419, - /* 1310 */ 420, 421, 422, 44, 424, 188, 388, 410, 339, 332, - /* 1320 */ 377, 414, 101, 44, 417, 418, 419, 420, 421, 422, - /* 1330 */ 101, 424, 365, 388, 213, 101, 429, 19, 431, 13, - /* 1340 */ 373, 101, 435, 436, 445, 378, 0, 380, 464, 459, - /* 1350 */ 101, 33, 365, 446, 101, 274, 100, 44, 101, 101, - /* 1360 */ 373, 35, 101, 101, 44, 378, 48, 380, 44, 44, - /* 1370 */ 101, 13, 54, 55, 56, 57, 58, 410, 437, 44, - /* 1380 */ 101, 414, 44, 35, 417, 418, 419, 420, 421, 422, - /* 1390 */ 448, 424, 252, 35, 412, 49, 429, 410, 431, 48, - /* 1400 */ 411, 414, 435, 436, 417, 418, 419, 420, 421, 422, - /* 1410 */ 184, 424, 399, 446, 101, 42, 429, 99, 431, 71, - /* 1420 */ 102, 101, 435, 436, 385, 101, 101, 20, 332, 388, - /* 1430 */ 385, 165, 383, 446, 20, 33, 101, 340, 385, 101, - /* 1440 */ 340, 383, 98, 383, 350, 95, 94, 340, 332, 348, - /* 1450 */ 48, 349, 134, 340, 340, 340, 54, 55, 56, 57, - /* 1460 */ 58, 365, 20, 334, 20, 334, 405, 20, 346, 373, - /* 1470 */ 20, 380, 346, 341, 378, 20, 380, 341, 398, 346, - /* 1480 */ 346, 365, 52, 346, 346, 340, 343, 169, 365, 373, - /* 1490 */ 334, 343, 174, 346, 378, 340, 380, 378, 378, 334, - /* 1500 */ 365, 99, 202, 378, 102, 100, 410, 192, 190, 405, - /* 1510 */ 414, 193, 409, 417, 418, 419, 420, 421, 422, 407, - /* 1520 */ 424, 344, 332, 365, 365, 429, 410, 431, 365, 365, - /* 1530 */ 414, 435, 436, 417, 418, 419, 420, 421, 422, 365, - /* 1540 */ 424, 365, 446, 365, 191, 429, 332, 431, 365, 365, - /* 1550 */ 404, 435, 436, 403, 344, 365, 340, 388, 388, 378, - /* 1560 */ 380, 259, 258, 373, 453, 393, 393, 378, 378, 378, - /* 1570 */ 380, 169, 170, 378, 267, 177, 174, 269, 176, 365, - /* 1580 */ 268, 453, 253, 412, 273, 276, 249, 373, 271, 472, - /* 1590 */ 373, 452, 378, 20, 380, 193, 332, 456, 416, 340, - /* 1600 */ 410, 341, 453, 451, 414, 20, 455, 417, 418, 419, - /* 1610 */ 420, 421, 422, 332, 424, 344, 450, 344, 465, 429, - /* 1620 */ 393, 431, 391, 466, 410, 435, 436, 170, 414, 365, - /* 1630 */ 378, 417, 418, 419, 420, 421, 422, 373, 424, 393, - /* 1640 */ 390, 378, 378, 378, 380, 431, 365, 344, 378, 435, - /* 1650 */ 436, 361, 378, 378, 373, 373, 100, 434, 344, 378, - /* 1660 */ 100, 380, 369, 378, 36, 355, 344, 340, 335, 330, - /* 1670 */ 334, 394, 400, 332, 410, 359, 0, 345, 414, 0, - /* 1680 */ 394, 417, 418, 419, 420, 421, 422, 359, 424, 406, - /* 1690 */ 359, 410, 0, 332, 42, 414, 0, 35, 417, 418, - /* 1700 */ 419, 420, 421, 422, 207, 424, 365, 35, 35, 35, - /* 1710 */ 207, 0, 431, 35, 373, 35, 435, 436, 207, 378, - /* 1720 */ 0, 380, 207, 0, 35, 461, 365, 0, 22, 0, - /* 1730 */ 35, 194, 188, 186, 373, 0, 0, 0, 181, 378, - /* 1740 */ 182, 380, 0, 0, 47, 0, 0, 0, 0, 42, - /* 1750 */ 0, 410, 0, 0, 0, 414, 332, 0, 417, 418, - /* 1760 */ 419, 420, 421, 422, 0, 424, 0, 155, 35, 0, - /* 1770 */ 155, 410, 431, 0, 0, 414, 435, 436, 417, 418, - /* 1780 */ 419, 420, 421, 422, 22, 424, 0, 0, 0, 365, - /* 1790 */ 0, 0, 0, 0, 370, 0, 0, 373, 0, 0, - /* 1800 */ 0, 0, 378, 0, 380, 42, 0, 0, 0, 0, - /* 1810 */ 0, 0, 0, 0, 332, 0, 139, 0, 0, 22, - /* 1820 */ 96, 96, 0, 58, 22, 0, 58, 0, 58, 35, - /* 1830 */ 0, 470, 0, 44, 410, 14, 0, 14, 414, 332, - /* 1840 */ 0, 417, 418, 419, 420, 421, 422, 365, 424, 0, - /* 1850 */ 0, 47, 47, 0, 0, 373, 42, 0, 39, 39, - /* 1860 */ 378, 177, 380, 47, 40, 39, 0, 0, 35, 0, - /* 1870 */ 35, 0, 365, 39, 35, 0, 39, 370, 0, 48, - /* 1880 */ 373, 35, 39, 39, 0, 378, 48, 380, 0, 48, - /* 1890 */ 0, 109, 410, 65, 35, 48, 414, 0, 22, 417, - /* 1900 */ 418, 419, 420, 421, 422, 35, 424, 35, 426, 35, - /* 1910 */ 0, 22, 332, 0, 35, 35, 35, 410, 35, 0, - /* 1920 */ 35, 414, 22, 22, 417, 418, 419, 420, 421, 422, - /* 1930 */ 44, 424, 50, 332, 22, 44, 107, 35, 0, 35, - /* 1940 */ 0, 35, 0, 22, 20, 365, 35, 0, 100, 35, - /* 1950 */ 370, 35, 101, 373, 22, 100, 0, 22, 378, 0, - /* 1960 */ 380, 35, 332, 0, 189, 3, 365, 44, 254, 101, - /* 1970 */ 254, 44, 44, 100, 373, 44, 47, 100, 44, 378, - /* 1980 */ 3, 380, 254, 332, 47, 98, 35, 44, 96, 96, - /* 1990 */ 410, 95, 35, 35, 414, 365, 101, 417, 418, 419, - /* 2000 */ 420, 421, 422, 373, 424, 35, 101, 100, 378, 100, - /* 2010 */ 380, 410, 47, 168, 35, 414, 365, 100, 417, 418, - /* 2020 */ 419, 420, 421, 422, 373, 424, 168, 175, 35, 378, - /* 2030 */ 170, 380, 168, 332, 101, 44, 100, 47, 0, 0, - /* 2040 */ 410, 0, 101, 0, 414, 101, 101, 417, 418, 419, - /* 2050 */ 420, 421, 422, 101, 424, 100, 39, 47, 332, 39, - /* 2060 */ 100, 410, 101, 0, 100, 414, 365, 101, 417, 418, - /* 2070 */ 419, 420, 421, 422, 373, 424, 100, 169, 100, 378, - /* 2080 */ 47, 380, 100, 110, 44, 98, 171, 98, 2, 22, - /* 2090 */ 22, 365, 100, 332, 47, 101, 101, 100, 235, 373, - /* 2100 */ 100, 47, 101, 100, 378, 100, 380, 213, 101, 100, - /* 2110 */ 248, 410, 101, 215, 35, 414, 332, 111, 417, 418, - /* 2120 */ 419, 420, 421, 422, 35, 424, 365, 100, 35, 101, - /* 2130 */ 100, 35, 101, 101, 373, 100, 410, 35, 101, 378, - /* 2140 */ 414, 380, 100, 417, 418, 419, 420, 421, 422, 365, - /* 2150 */ 424, 35, 100, 22, 44, 100, 100, 373, 35, 123, - /* 2160 */ 112, 100, 378, 22, 380, 65, 71, 123, 123, 123, - /* 2170 */ 64, 410, 35, 35, 332, 414, 93, 35, 417, 418, - /* 2180 */ 419, 420, 421, 422, 35, 424, 35, 35, 35, 35, - /* 2190 */ 35, 35, 44, 332, 410, 35, 35, 35, 414, 22, - /* 2200 */ 35, 417, 418, 419, 420, 421, 422, 365, 424, 35, - /* 2210 */ 71, 35, 22, 35, 35, 373, 35, 35, 35, 35, - /* 2220 */ 378, 0, 380, 35, 39, 0, 365, 35, 48, 0, - /* 2230 */ 39, 35, 39, 0, 373, 48, 35, 48, 39, 378, - /* 2240 */ 0, 380, 48, 35, 35, 0, 22, 21, 473, 22, - /* 2250 */ 22, 21, 410, 473, 332, 473, 414, 20, 473, 417, - /* 2260 */ 418, 419, 420, 421, 422, 473, 424, 473, 473, 473, - /* 2270 */ 473, 410, 473, 473, 473, 414, 473, 473, 417, 418, - /* 2280 */ 419, 420, 421, 422, 473, 424, 473, 365, 473, 473, - /* 2290 */ 473, 473, 473, 473, 473, 373, 473, 473, 473, 473, - /* 2300 */ 378, 473, 380, 473, 473, 473, 473, 473, 473, 473, - /* 2310 */ 473, 473, 332, 473, 473, 473, 473, 473, 473, 473, - /* 2320 */ 473, 473, 473, 473, 473, 473, 473, 473, 332, 473, - /* 2330 */ 473, 473, 410, 473, 473, 473, 414, 473, 473, 417, - /* 2340 */ 418, 419, 420, 421, 422, 365, 424, 473, 473, 473, - /* 2350 */ 473, 473, 473, 373, 473, 473, 473, 473, 378, 473, - /* 2360 */ 380, 365, 473, 473, 473, 473, 473, 473, 473, 373, - /* 2370 */ 473, 473, 473, 473, 378, 473, 380, 473, 473, 473, - /* 2380 */ 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - /* 2390 */ 410, 332, 473, 473, 414, 473, 473, 417, 418, 419, - /* 2400 */ 420, 421, 422, 473, 424, 473, 410, 332, 473, 473, - /* 2410 */ 414, 473, 473, 417, 418, 419, 420, 421, 422, 473, - /* 2420 */ 424, 473, 473, 473, 365, 473, 332, 473, 473, 473, - /* 2430 */ 473, 473, 373, 473, 473, 473, 473, 378, 473, 380, - /* 2440 */ 365, 473, 473, 473, 473, 473, 473, 473, 373, 473, - /* 2450 */ 473, 473, 473, 378, 473, 380, 473, 473, 473, 365, - /* 2460 */ 473, 473, 473, 473, 473, 473, 473, 373, 473, 410, - /* 2470 */ 473, 473, 378, 414, 380, 473, 417, 418, 419, 420, - /* 2480 */ 421, 422, 473, 424, 473, 410, 473, 473, 473, 414, - /* 2490 */ 332, 473, 417, 418, 419, 420, 421, 422, 473, 424, - /* 2500 */ 473, 473, 473, 473, 410, 473, 473, 332, 414, 473, - /* 2510 */ 473, 417, 418, 419, 420, 421, 422, 473, 424, 473, - /* 2520 */ 473, 473, 473, 365, 473, 473, 473, 473, 473, 473, - /* 2530 */ 473, 373, 473, 473, 473, 473, 378, 473, 380, 473, - /* 2540 */ 365, 473, 473, 473, 473, 473, 473, 473, 373, 473, - /* 2550 */ 473, 473, 473, 378, 473, 380, 473, 473, 473, 473, - /* 2560 */ 473, 473, 473, 473, 473, 473, 473, 332, 410, 473, - /* 2570 */ 473, 473, 414, 473, 473, 417, 418, 419, 420, 421, - /* 2580 */ 422, 473, 424, 473, 473, 410, 473, 332, 473, 414, - /* 2590 */ 473, 473, 417, 418, 419, 420, 421, 422, 473, 424, - /* 2600 */ 365, 473, 473, 473, 473, 473, 473, 473, 373, 473, - /* 2610 */ 473, 473, 473, 378, 473, 380, 473, 473, 473, 473, - /* 2620 */ 365, 473, 473, 473, 473, 473, 473, 473, 373, 473, - /* 2630 */ 473, 473, 473, 378, 473, 380, 473, 473, 473, 473, - /* 2640 */ 473, 473, 473, 473, 473, 410, 473, 473, 473, 414, - /* 2650 */ 473, 473, 417, 418, 419, 420, 421, 422, 473, 424, - /* 2660 */ 473, 332, 473, 473, 473, 410, 473, 473, 473, 414, - /* 2670 */ 473, 473, 417, 418, 419, 420, 421, 422, 332, 424, - /* 2680 */ 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - /* 2690 */ 473, 473, 473, 473, 365, 473, 473, 473, 473, 473, - /* 2700 */ 473, 473, 373, 473, 473, 473, 473, 378, 473, 380, - /* 2710 */ 473, 365, 473, 473, 473, 473, 473, 473, 473, 373, - /* 2720 */ 473, 473, 473, 473, 378, 473, 380, 473, 473, 473, - /* 2730 */ 473, 473, 473, 473, 473, 473, 473, 473, 473, 410, - /* 2740 */ 332, 473, 473, 414, 473, 473, 417, 418, 419, 420, - /* 2750 */ 421, 422, 473, 424, 473, 473, 410, 473, 473, 473, - /* 2760 */ 414, 473, 473, 417, 418, 419, 420, 421, 422, 473, - /* 2770 */ 424, 473, 473, 365, 473, 473, 473, 473, 473, 473, - /* 2780 */ 473, 373, 473, 473, 473, 473, 378, 473, 380, 473, - /* 2790 */ 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - /* 2800 */ 473, 473, 473, 473, 473, 473, 473, 473, 473, 473, - /* 2810 */ 473, 473, 473, 473, 473, 473, 473, 473, 410, 473, - /* 2820 */ 473, 473, 414, 473, 473, 417, 418, 419, 420, 421, - /* 2830 */ 422, 473, 424, + /* 230 */ 230, 231, 232, 233, 234, 235, 12, 13, 348, 63, + /* 240 */ 341, 18, 341, 20, 20, 355, 22, 366, 333, 100, + /* 250 */ 27, 64, 333, 30, 341, 374, 33, 33, 362, 35, + /* 260 */ 379, 445, 381, 101, 398, 449, 101, 100, 195, 196, + /* 270 */ 100, 48, 199, 50, 201, 374, 53, 20, 341, 368, + /* 280 */ 464, 465, 58, 1, 2, 469, 470, 374, 64, 390, + /* 290 */ 379, 392, 277, 412, 379, 71, 109, 416, 379, 20, + /* 300 */ 419, 420, 421, 422, 423, 424, 410, 426, 20, 58, + /* 310 */ 22, 445, 431, 347, 433, 449, 333, 252, 437, 438, + /* 320 */ 383, 97, 99, 35, 100, 347, 415, 416, 417, 363, + /* 330 */ 464, 465, 451, 168, 111, 469, 470, 426, 372, 51, + /* 340 */ 459, 440, 441, 442, 443, 0, 445, 446, 20, 366, + /* 350 */ 372, 100, 165, 102, 441, 442, 443, 374, 445, 446, + /* 360 */ 136, 137, 379, 140, 381, 168, 143, 144, 145, 146, + /* 370 */ 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, + /* 380 */ 157, 158, 159, 101, 161, 162, 163, 380, 381, 44, + /* 390 */ 166, 167, 333, 136, 137, 412, 172, 173, 21, 416, + /* 400 */ 358, 252, 419, 420, 421, 422, 423, 424, 366, 426, + /* 410 */ 186, 34, 188, 36, 431, 373, 433, 375, 171, 252, + /* 420 */ 437, 438, 252, 430, 382, 432, 239, 240, 241, 242, + /* 430 */ 243, 244, 245, 246, 247, 248, 249, 341, 379, 215, + /* 440 */ 216, 63, 218, 219, 220, 221, 222, 223, 224, 225, + /* 450 */ 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, + /* 460 */ 236, 12, 13, 377, 136, 137, 380, 381, 20, 20, + /* 470 */ 374, 22, 66, 67, 68, 215, 352, 353, 374, 73, + /* 480 */ 74, 75, 33, 130, 35, 79, 333, 33, 333, 385, + /* 490 */ 84, 85, 86, 87, 338, 20, 90, 341, 342, 0, + /* 500 */ 172, 173, 48, 252, 257, 258, 259, 58, 54, 55, + /* 510 */ 56, 57, 58, 64, 12, 13, 14, 15, 16, 341, + /* 520 */ 71, 366, 262, 263, 264, 265, 266, 267, 268, 374, + /* 530 */ 345, 341, 379, 4, 379, 357, 381, 441, 442, 443, + /* 540 */ 338, 445, 446, 341, 342, 449, 97, 100, 366, 100, + /* 550 */ 197, 198, 374, 99, 369, 373, 102, 14, 352, 353, + /* 560 */ 464, 465, 366, 20, 382, 469, 470, 412, 18, 0, + /* 570 */ 374, 416, 0, 23, 419, 420, 421, 422, 423, 424, + /* 580 */ 390, 426, 392, 3, 112, 136, 137, 37, 38, 181, + /* 590 */ 21, 41, 0, 24, 25, 26, 27, 28, 29, 30, + /* 600 */ 31, 32, 130, 131, 132, 133, 134, 135, 111, 59, + /* 610 */ 60, 61, 62, 205, 206, 166, 167, 421, 14, 15, + /* 620 */ 16, 172, 173, 169, 170, 236, 471, 472, 174, 100, + /* 630 */ 176, 112, 185, 366, 187, 186, 358, 188, 66, 67, + /* 640 */ 68, 166, 167, 341, 366, 73, 74, 75, 194, 368, + /* 650 */ 100, 79, 133, 375, 155, 388, 84, 85, 86, 87, + /* 660 */ 379, 214, 90, 164, 215, 216, 71, 218, 219, 220, + /* 670 */ 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, + /* 680 */ 231, 232, 233, 234, 235, 12, 13, 14, 138, 0, + /* 690 */ 333, 333, 390, 20, 392, 22, 415, 416, 417, 252, + /* 700 */ 236, 333, 238, 330, 112, 367, 33, 426, 35, 166, + /* 710 */ 20, 4, 22, 24, 25, 26, 27, 28, 29, 30, + /* 720 */ 31, 32, 130, 131, 132, 133, 134, 135, 178, 179, + /* 730 */ 180, 58, 341, 183, 366, 341, 379, 379, 45, 46, + /* 740 */ 333, 51, 374, 341, 71, 111, 80, 379, 357, 381, + /* 750 */ 43, 357, 45, 46, 204, 364, 22, 207, 71, 357, + /* 760 */ 210, 211, 212, 213, 214, 374, 368, 366, 374, 35, + /* 770 */ 97, 398, 22, 100, 373, 402, 374, 379, 0, 333, + /* 780 */ 412, 252, 47, 382, 416, 35, 379, 419, 420, 421, + /* 790 */ 422, 423, 424, 430, 426, 432, 367, 429, 14, 431, + /* 800 */ 432, 433, 252, 341, 20, 437, 438, 141, 142, 136, + /* 810 */ 137, 341, 366, 415, 416, 417, 366, 366, 445, 357, + /* 820 */ 374, 71, 449, 373, 426, 379, 375, 381, 130, 131, + /* 830 */ 164, 97, 382, 135, 58, 100, 374, 464, 465, 166, + /* 840 */ 167, 63, 469, 470, 374, 172, 173, 97, 341, 8, + /* 850 */ 9, 20, 272, 12, 13, 14, 15, 16, 412, 186, + /* 860 */ 22, 188, 416, 358, 357, 419, 420, 421, 422, 423, + /* 870 */ 424, 366, 426, 35, 333, 99, 20, 431, 102, 433, + /* 880 */ 375, 374, 333, 437, 438, 44, 398, 165, 215, 216, + /* 890 */ 4, 218, 219, 220, 221, 222, 223, 224, 225, 226, + /* 900 */ 227, 228, 229, 230, 231, 232, 233, 234, 235, 12, + /* 910 */ 13, 441, 442, 443, 358, 445, 446, 20, 341, 22, + /* 920 */ 379, 333, 366, 403, 250, 251, 341, 333, 379, 111, + /* 930 */ 33, 375, 35, 445, 357, 97, 186, 449, 188, 8, + /* 940 */ 9, 4, 357, 12, 13, 14, 15, 16, 418, 367, + /* 950 */ 166, 374, 464, 465, 366, 58, 19, 469, 470, 374, + /* 960 */ 333, 239, 374, 418, 0, 215, 216, 379, 71, 381, + /* 970 */ 33, 249, 333, 379, 444, 8, 9, 374, 160, 12, + /* 980 */ 13, 14, 15, 16, 354, 48, 356, 341, 385, 444, + /* 990 */ 53, 333, 39, 44, 97, 58, 333, 100, 333, 168, + /* 1000 */ 412, 20, 333, 357, 416, 333, 379, 419, 420, 421, + /* 1010 */ 422, 423, 424, 333, 426, 333, 333, 2, 379, 431, + /* 1020 */ 374, 433, 166, 8, 9, 437, 438, 12, 13, 14, + /* 1030 */ 15, 16, 101, 136, 137, 0, 99, 379, 366, 102, + /* 1040 */ 429, 341, 379, 432, 379, 374, 374, 459, 379, 341, + /* 1050 */ 101, 379, 366, 381, 22, 418, 385, 357, 42, 379, + /* 1060 */ 44, 379, 379, 166, 167, 357, 2, 35, 382, 172, + /* 1070 */ 173, 341, 8, 9, 374, 44, 12, 13, 14, 15, + /* 1080 */ 16, 444, 374, 186, 412, 188, 376, 357, 416, 379, + /* 1090 */ 0, 419, 420, 421, 422, 423, 424, 376, 426, 376, + /* 1100 */ 379, 44, 379, 431, 374, 433, 44, 333, 359, 437, + /* 1110 */ 438, 362, 215, 216, 13, 218, 219, 220, 221, 222, + /* 1120 */ 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, + /* 1130 */ 233, 234, 235, 12, 13, 168, 35, 96, 48, 253, + /* 1140 */ 366, 20, 341, 22, 200, 341, 202, 112, 374, 168, + /* 1150 */ 42, 44, 44, 379, 33, 381, 35, 104, 357, 398, + /* 1160 */ 107, 357, 367, 101, 367, 130, 131, 132, 133, 134, + /* 1170 */ 135, 104, 37, 209, 107, 374, 8, 9, 374, 58, + /* 1180 */ 12, 13, 14, 15, 16, 104, 412, 341, 107, 58, + /* 1190 */ 416, 44, 71, 419, 420, 421, 422, 423, 424, 341, + /* 1200 */ 426, 341, 355, 357, 251, 431, 445, 433, 101, 168, + /* 1210 */ 449, 437, 438, 333, 35, 357, 44, 357, 97, 341, + /* 1220 */ 374, 100, 448, 0, 104, 464, 465, 107, 0, 44, + /* 1230 */ 469, 470, 374, 102, 374, 357, 333, 35, 103, 100, + /* 1240 */ 105, 106, 0, 108, 13, 22, 366, 112, 101, 110, + /* 1250 */ 22, 445, 374, 44, 374, 449, 334, 136, 137, 379, + /* 1260 */ 389, 381, 136, 137, 22, 473, 35, 13, 133, 366, + /* 1270 */ 462, 465, 64, 101, 44, 469, 470, 374, 44, 1, + /* 1280 */ 2, 44, 379, 343, 381, 456, 101, 166, 167, 35, + /* 1290 */ 366, 343, 412, 172, 173, 389, 416, 340, 35, 419, + /* 1300 */ 420, 421, 422, 423, 424, 274, 426, 186, 44, 188, + /* 1310 */ 101, 44, 378, 433, 44, 412, 44, 437, 438, 416, + /* 1320 */ 44, 44, 419, 420, 421, 422, 423, 424, 333, 426, + /* 1330 */ 389, 101, 44, 276, 71, 101, 215, 216, 101, 218, + /* 1340 */ 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, + /* 1350 */ 229, 230, 231, 232, 233, 234, 235, 13, 447, 466, + /* 1360 */ 439, 366, 450, 460, 461, 101, 254, 188, 101, 374, + /* 1370 */ 44, 101, 44, 101, 379, 414, 381, 101, 101, 35, + /* 1380 */ 44, 0, 48, 413, 184, 400, 386, 42, 20, 101, + /* 1390 */ 188, 389, 386, 384, 165, 341, 20, 341, 333, 386, + /* 1400 */ 98, 384, 384, 351, 95, 350, 94, 412, 349, 341, + /* 1410 */ 341, 416, 341, 341, 419, 420, 421, 422, 423, 424, + /* 1420 */ 20, 426, 335, 215, 335, 20, 431, 101, 433, 101, + /* 1430 */ 49, 366, 437, 438, 407, 347, 20, 101, 347, 374, + /* 1440 */ 20, 381, 342, 448, 379, 20, 381, 399, 342, 333, + /* 1450 */ 347, 347, 347, 52, 341, 344, 347, 347, 344, 335, + /* 1460 */ 366, 366, 366, 366, 366, 366, 341, 335, 366, 203, + /* 1470 */ 100, 379, 379, 192, 411, 409, 406, 412, 345, 405, + /* 1480 */ 407, 416, 366, 366, 419, 420, 421, 422, 423, 424, + /* 1490 */ 374, 426, 191, 366, 366, 379, 431, 381, 433, 12, + /* 1500 */ 13, 379, 437, 438, 366, 345, 190, 341, 389, 22, + /* 1510 */ 381, 261, 389, 448, 269, 379, 455, 260, 177, 404, + /* 1520 */ 33, 379, 35, 379, 333, 379, 271, 278, 412, 270, + /* 1530 */ 455, 394, 416, 457, 394, 419, 420, 421, 422, 423, + /* 1540 */ 424, 458, 426, 275, 255, 58, 468, 431, 273, 433, + /* 1550 */ 251, 474, 467, 437, 438, 374, 20, 366, 71, 414, + /* 1560 */ 341, 418, 342, 345, 448, 374, 345, 20, 392, 394, + /* 1570 */ 379, 379, 381, 455, 379, 379, 379, 379, 394, 170, + /* 1580 */ 379, 391, 100, 453, 97, 345, 362, 374, 454, 345, + /* 1590 */ 436, 379, 100, 452, 356, 370, 345, 341, 36, 395, + /* 1600 */ 401, 336, 408, 412, 335, 395, 360, 416, 360, 1, + /* 1610 */ 419, 420, 421, 422, 423, 424, 331, 426, 360, 346, + /* 1620 */ 0, 0, 431, 0, 433, 42, 0, 19, 437, 438, + /* 1630 */ 35, 208, 35, 35, 35, 208, 0, 35, 35, 448, + /* 1640 */ 208, 33, 0, 333, 208, 0, 35, 0, 0, 22, + /* 1650 */ 35, 195, 188, 186, 0, 0, 48, 0, 182, 181, + /* 1660 */ 0, 0, 54, 55, 56, 57, 58, 0, 0, 47, + /* 1670 */ 0, 42, 0, 186, 0, 188, 366, 155, 35, 0, + /* 1680 */ 155, 0, 0, 0, 374, 0, 0, 0, 0, 379, + /* 1690 */ 0, 381, 0, 0, 0, 0, 0, 0, 0, 0, + /* 1700 */ 0, 0, 215, 216, 0, 0, 0, 99, 333, 0, + /* 1710 */ 102, 42, 0, 0, 0, 228, 229, 230, 231, 232, + /* 1720 */ 233, 234, 412, 0, 0, 0, 416, 0, 0, 419, + /* 1730 */ 420, 421, 422, 423, 424, 0, 426, 22, 0, 139, + /* 1740 */ 0, 366, 134, 433, 22, 96, 96, 437, 438, 374, + /* 1750 */ 0, 22, 35, 0, 379, 0, 381, 0, 0, 39, + /* 1760 */ 58, 42, 44, 47, 0, 58, 58, 0, 14, 39, + /* 1770 */ 14, 0, 0, 333, 40, 39, 0, 169, 47, 47, + /* 1780 */ 0, 0, 174, 177, 0, 0, 65, 412, 39, 48, + /* 1790 */ 0, 416, 48, 0, 419, 420, 421, 422, 423, 424, + /* 1800 */ 35, 426, 194, 35, 35, 39, 366, 48, 433, 39, + /* 1810 */ 0, 48, 437, 438, 374, 0, 39, 35, 0, 379, + /* 1820 */ 0, 381, 0, 35, 333, 22, 0, 35, 22, 35, + /* 1830 */ 44, 35, 35, 35, 35, 109, 35, 35, 0, 35, + /* 1840 */ 107, 22, 35, 333, 44, 0, 22, 0, 35, 22, + /* 1850 */ 0, 35, 412, 0, 0, 50, 416, 366, 35, 419, + /* 1860 */ 420, 421, 422, 423, 424, 374, 426, 35, 22, 20, + /* 1870 */ 379, 35, 381, 433, 35, 100, 366, 0, 438, 101, + /* 1880 */ 22, 0, 193, 100, 374, 22, 35, 0, 0, 379, + /* 1890 */ 256, 381, 3, 256, 3, 256, 44, 0, 0, 189, + /* 1900 */ 44, 44, 35, 412, 95, 168, 44, 416, 100, 170, + /* 1910 */ 419, 420, 421, 422, 423, 424, 168, 426, 333, 168, + /* 1920 */ 175, 100, 412, 47, 96, 47, 416, 98, 44, 419, + /* 1930 */ 420, 421, 422, 423, 424, 101, 426, 333, 96, 44, + /* 1940 */ 35, 101, 101, 100, 100, 35, 35, 35, 100, 35, + /* 1950 */ 47, 366, 461, 44, 47, 0, 101, 0, 171, 374, + /* 1960 */ 100, 250, 101, 39, 379, 101, 381, 101, 47, 101, + /* 1970 */ 366, 100, 100, 463, 101, 371, 101, 0, 374, 100, + /* 1980 */ 100, 39, 100, 379, 110, 381, 169, 47, 44, 237, + /* 1990 */ 2, 98, 100, 22, 98, 101, 47, 412, 47, 100, + /* 2000 */ 100, 416, 101, 101, 419, 420, 421, 422, 423, 424, + /* 2010 */ 333, 426, 22, 100, 35, 100, 412, 100, 35, 101, + /* 2020 */ 416, 35, 100, 419, 420, 421, 422, 423, 424, 215, + /* 2030 */ 426, 111, 101, 100, 35, 101, 333, 100, 35, 101, + /* 2040 */ 101, 100, 35, 366, 101, 100, 100, 217, 123, 123, + /* 2050 */ 123, 374, 123, 22, 100, 44, 379, 472, 381, 112, + /* 2060 */ 100, 35, 100, 22, 35, 65, 64, 35, 35, 366, + /* 2070 */ 35, 35, 71, 35, 371, 35, 22, 374, 35, 35, + /* 2080 */ 35, 35, 379, 44, 381, 93, 35, 35, 35, 412, + /* 2090 */ 35, 35, 71, 416, 35, 35, 419, 420, 421, 422, + /* 2100 */ 423, 424, 35, 426, 35, 428, 35, 333, 22, 35, + /* 2110 */ 0, 35, 48, 0, 39, 412, 35, 39, 48, 416, + /* 2120 */ 0, 48, 419, 420, 421, 422, 423, 424, 333, 426, + /* 2130 */ 35, 39, 0, 48, 35, 39, 0, 35, 35, 0, + /* 2140 */ 366, 22, 21, 20, 22, 371, 22, 21, 374, 475, + /* 2150 */ 475, 475, 475, 379, 475, 381, 475, 475, 333, 475, + /* 2160 */ 475, 366, 475, 475, 475, 475, 475, 475, 475, 374, + /* 2170 */ 475, 475, 475, 475, 379, 475, 381, 475, 475, 475, + /* 2180 */ 475, 475, 475, 475, 475, 475, 412, 475, 475, 475, + /* 2190 */ 416, 366, 475, 419, 420, 421, 422, 423, 424, 374, + /* 2200 */ 426, 475, 475, 475, 379, 475, 381, 412, 475, 475, + /* 2210 */ 475, 416, 475, 475, 419, 420, 421, 422, 423, 424, + /* 2220 */ 475, 426, 475, 333, 475, 475, 475, 475, 475, 475, + /* 2230 */ 475, 475, 475, 475, 475, 475, 475, 412, 475, 475, + /* 2240 */ 475, 416, 475, 475, 419, 420, 421, 422, 423, 424, + /* 2250 */ 475, 426, 333, 475, 475, 475, 366, 475, 475, 475, + /* 2260 */ 475, 475, 475, 475, 374, 475, 475, 475, 475, 379, + /* 2270 */ 475, 381, 475, 475, 475, 475, 475, 475, 475, 475, + /* 2280 */ 475, 475, 475, 475, 475, 366, 333, 475, 475, 475, + /* 2290 */ 475, 475, 475, 374, 475, 475, 475, 475, 379, 475, + /* 2300 */ 381, 475, 412, 475, 475, 475, 416, 475, 475, 419, + /* 2310 */ 420, 421, 422, 423, 424, 475, 426, 475, 475, 366, + /* 2320 */ 475, 475, 475, 475, 475, 475, 475, 374, 475, 475, + /* 2330 */ 475, 412, 379, 475, 381, 416, 475, 475, 419, 420, + /* 2340 */ 421, 422, 423, 424, 475, 426, 475, 475, 475, 475, + /* 2350 */ 333, 475, 475, 475, 475, 475, 475, 475, 475, 475, + /* 2360 */ 475, 475, 475, 475, 475, 412, 475, 475, 475, 416, + /* 2370 */ 333, 475, 419, 420, 421, 422, 423, 424, 475, 426, + /* 2380 */ 475, 475, 475, 366, 475, 475, 475, 475, 475, 475, + /* 2390 */ 475, 374, 475, 475, 475, 475, 379, 475, 381, 475, + /* 2400 */ 475, 475, 475, 366, 475, 475, 475, 475, 475, 475, + /* 2410 */ 475, 374, 475, 475, 475, 475, 379, 475, 381, 475, + /* 2420 */ 475, 475, 475, 475, 475, 475, 475, 475, 475, 412, + /* 2430 */ 475, 333, 475, 416, 475, 475, 419, 420, 421, 422, + /* 2440 */ 423, 424, 475, 426, 475, 475, 475, 475, 475, 412, + /* 2450 */ 475, 475, 475, 416, 475, 475, 419, 420, 421, 422, + /* 2460 */ 423, 424, 475, 426, 366, 475, 475, 475, 475, 475, + /* 2470 */ 475, 475, 374, 475, 475, 475, 475, 379, 475, 381, + /* 2480 */ 475, 475, 333, 475, 475, 475, 475, 475, 475, 475, + /* 2490 */ 475, 475, 475, 475, 475, 475, 475, 475, 475, 475, + /* 2500 */ 475, 475, 475, 333, 475, 475, 475, 475, 475, 475, + /* 2510 */ 412, 475, 475, 475, 416, 366, 475, 419, 420, 421, + /* 2520 */ 422, 423, 424, 374, 426, 475, 475, 475, 379, 475, + /* 2530 */ 381, 475, 475, 333, 475, 475, 366, 475, 475, 475, + /* 2540 */ 475, 475, 475, 475, 374, 475, 475, 475, 475, 379, + /* 2550 */ 475, 381, 475, 475, 475, 475, 475, 475, 475, 475, + /* 2560 */ 475, 412, 475, 475, 475, 416, 366, 475, 419, 420, + /* 2570 */ 421, 422, 423, 424, 374, 426, 475, 475, 475, 379, + /* 2580 */ 475, 381, 412, 475, 475, 475, 416, 475, 475, 419, + /* 2590 */ 420, 421, 422, 423, 424, 475, 426, 475, 333, 475, + /* 2600 */ 475, 475, 475, 475, 475, 475, 475, 475, 475, 475, + /* 2610 */ 475, 475, 412, 475, 475, 475, 416, 475, 475, 419, + /* 2620 */ 420, 421, 422, 423, 424, 475, 426, 333, 475, 475, + /* 2630 */ 475, 366, 475, 475, 475, 475, 475, 475, 475, 374, + /* 2640 */ 475, 475, 475, 475, 379, 475, 381, 475, 475, 475, + /* 2650 */ 475, 475, 475, 475, 475, 475, 475, 475, 475, 475, + /* 2660 */ 366, 333, 475, 475, 475, 475, 475, 475, 374, 475, + /* 2670 */ 475, 475, 475, 379, 475, 381, 475, 412, 475, 475, + /* 2680 */ 475, 416, 475, 475, 419, 420, 421, 422, 423, 424, + /* 2690 */ 475, 426, 475, 475, 366, 475, 475, 475, 475, 475, + /* 2700 */ 475, 475, 374, 475, 475, 475, 412, 379, 475, 381, + /* 2710 */ 416, 475, 475, 419, 420, 421, 422, 423, 424, 475, + /* 2720 */ 426, 475, 475, 475, 475, 333, 475, 475, 475, 475, + /* 2730 */ 475, 475, 475, 475, 475, 475, 475, 475, 475, 475, + /* 2740 */ 412, 475, 475, 475, 416, 333, 475, 419, 420, 421, + /* 2750 */ 422, 423, 424, 475, 426, 475, 475, 475, 366, 475, + /* 2760 */ 475, 475, 475, 475, 475, 475, 374, 475, 475, 475, + /* 2770 */ 475, 379, 475, 381, 475, 475, 475, 475, 366, 475, + /* 2780 */ 475, 475, 475, 475, 475, 475, 374, 475, 475, 475, + /* 2790 */ 475, 379, 475, 381, 475, 475, 475, 475, 475, 475, + /* 2800 */ 475, 475, 475, 475, 412, 475, 333, 475, 416, 475, + /* 2810 */ 475, 419, 420, 421, 422, 423, 424, 475, 426, 475, + /* 2820 */ 475, 475, 475, 475, 412, 475, 475, 475, 416, 475, + /* 2830 */ 475, 419, 420, 421, 422, 423, 424, 475, 426, 366, + /* 2840 */ 475, 475, 475, 475, 475, 475, 475, 374, 475, 475, + /* 2850 */ 475, 475, 379, 475, 381, 475, 475, 333, 475, 475, + /* 2860 */ 475, 475, 475, 475, 475, 475, 475, 475, 475, 475, + /* 2870 */ 475, 475, 475, 475, 475, 475, 475, 475, 333, 475, + /* 2880 */ 475, 475, 475, 475, 475, 412, 475, 475, 475, 416, + /* 2890 */ 366, 475, 419, 420, 421, 422, 423, 424, 374, 426, + /* 2900 */ 475, 475, 475, 379, 475, 381, 475, 475, 333, 475, + /* 2910 */ 475, 366, 475, 475, 475, 475, 475, 475, 475, 374, + /* 2920 */ 475, 475, 475, 475, 379, 475, 381, 475, 475, 475, + /* 2930 */ 475, 475, 475, 475, 475, 475, 412, 475, 475, 475, + /* 2940 */ 416, 366, 475, 419, 420, 421, 422, 423, 424, 374, + /* 2950 */ 426, 475, 475, 475, 379, 475, 381, 412, 475, 475, + /* 2960 */ 475, 416, 475, 475, 419, 420, 421, 422, 423, 424, + /* 2970 */ 475, 426, 475, 333, 475, 475, 475, 475, 475, 475, + /* 2980 */ 475, 475, 475, 475, 475, 475, 475, 412, 475, 475, + /* 2990 */ 475, 416, 475, 475, 419, 420, 421, 422, 423, 424, + /* 3000 */ 475, 426, 333, 475, 475, 475, 366, 475, 475, 475, + /* 3010 */ 475, 475, 475, 475, 374, 475, 475, 475, 475, 379, + /* 3020 */ 475, 381, 475, 475, 475, 475, 475, 475, 475, 475, + /* 3030 */ 475, 475, 475, 475, 475, 366, 475, 475, 475, 475, + /* 3040 */ 475, 475, 475, 374, 475, 475, 475, 475, 379, 475, + /* 3050 */ 381, 475, 412, 475, 475, 475, 416, 475, 475, 419, + /* 3060 */ 420, 421, 422, 423, 424, 475, 426, 475, 475, 475, + /* 3070 */ 475, 475, 475, 475, 475, 475, 475, 475, 475, 475, + /* 3080 */ 475, 412, 475, 475, 475, 416, 475, 475, 419, 420, + /* 3090 */ 421, 422, 423, 424, 475, 426, }; -#define YY_SHIFT_COUNT (753) +#define YY_SHIFT_COUNT (760) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2245) +#define YY_SHIFT_MAX (2139) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 957, 0, 98, 0, 321, 321, 321, 321, 321, 321, - /* 10 */ 321, 321, 321, 321, 321, 419, 641, 641, 739, 641, - /* 20 */ 641, 641, 641, 641, 641, 641, 641, 641, 641, 641, - /* 30 */ 641, 641, 641, 641, 641, 641, 641, 641, 641, 641, - /* 40 */ 641, 641, 641, 641, 641, 641, 641, 641, 141, 328, - /* 50 */ 818, 68, 97, 103, 469, 103, 68, 68, 966, 966, - /* 60 */ 966, 103, 966, 966, 94, 103, 4, 653, 24, 24, - /* 70 */ 653, 292, 292, 319, 425, 186, 186, 24, 24, 24, - /* 80 */ 24, 24, 24, 24, 138, 24, 24, 124, 4, 24, - /* 90 */ 24, 243, 24, 4, 24, 138, 24, 138, 4, 24, - /* 100 */ 24, 4, 24, 4, 4, 4, 24, 232, 956, 285, - /* 110 */ 285, 117, 251, 990, 990, 990, 990, 990, 990, 990, - /* 120 */ 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, - /* 130 */ 990, 990, 679, 603, 319, 425, 239, 674, 674, 674, - /* 140 */ 36, 395, 395, 239, 410, 410, 410, 124, 351, 242, - /* 150 */ 4, 489, 4, 489, 489, 493, 506, 245, 245, 245, - /* 160 */ 245, 245, 245, 245, 245, 1318, 491, 375, 400, 673, - /* 170 */ 502, 112, 95, 919, 922, 29, 786, 898, 929, 953, - /* 180 */ 796, 880, 745, 796, 1106, 992, 887, 1140, 1351, 1226, - /* 190 */ 1373, 1407, 1373, 1266, 1414, 1414, 1373, 1266, 1266, 1344, - /* 200 */ 1350, 1414, 1352, 1414, 1414, 1414, 1442, 1442, 1444, 124, - /* 210 */ 1447, 124, 1450, 1455, 124, 1450, 124, 124, 124, 1414, - /* 220 */ 124, 1430, 1430, 1442, 4, 4, 4, 4, 4, 4, - /* 230 */ 4, 4, 4, 4, 4, 1414, 1442, 489, 489, 489, - /* 240 */ 1300, 1405, 1444, 232, 1315, 1353, 1447, 232, 1414, 1407, - /* 250 */ 1407, 489, 1302, 1304, 489, 1302, 1304, 489, 489, 4, - /* 260 */ 1307, 1398, 1302, 1308, 1312, 1329, 1140, 1309, 1311, 1317, - /* 270 */ 1337, 410, 1573, 1414, 1450, 232, 232, 1585, 1304, 489, - /* 280 */ 489, 489, 489, 489, 1304, 489, 1457, 232, 493, 232, - /* 290 */ 410, 1556, 1560, 489, 506, 1414, 232, 1628, 1442, 2833, - /* 300 */ 2833, 2833, 2833, 2833, 2833, 2833, 2833, 2833, 170, 1402, - /* 310 */ 473, 981, 166, 466, 808, 157, 374, 587, 602, 597, - /* 320 */ 196, 196, 196, 196, 196, 196, 196, 196, 196, 173, - /* 330 */ 320, 26, 26, 342, 736, 624, 795, 900, 1124, 591, - /* 340 */ 1015, 305, 305, 976, 592, 108, 976, 976, 976, 834, - /* 350 */ 977, 1179, 1109, 17, 336, 1079, 1130, 1142, 1144, 696, - /* 360 */ 1098, 1267, 1078, 1090, 1221, 598, 1229, 1234, 1240, 1154, - /* 370 */ 905, 1081, 172, 1249, 1253, 1257, 1258, 1261, 1262, 1294, - /* 380 */ 1269, 1059, 1127, 1121, 1279, 1256, 1313, 1320, 1324, 1325, - /* 390 */ 1335, 1338, 1188, 1326, 1358, 1348, 1346, 1676, 1679, 1692, - /* 400 */ 1652, 1696, 1662, 1497, 1672, 1673, 1674, 1503, 1711, 1678, - /* 410 */ 1680, 1511, 1720, 1515, 1723, 1689, 1727, 1706, 1729, 1695, - /* 420 */ 1537, 1544, 1547, 1735, 1736, 1737, 1558, 1557, 1742, 1743, - /* 430 */ 1697, 1745, 1746, 1747, 1707, 1748, 1750, 1752, 1753, 1754, - /* 440 */ 1757, 1764, 1766, 1612, 1733, 1769, 1615, 1773, 1774, 1786, - /* 450 */ 1787, 1788, 1790, 1791, 1792, 1793, 1795, 1796, 1798, 1799, - /* 460 */ 1800, 1801, 1803, 1763, 1806, 1807, 1808, 1809, 1810, 1811, - /* 470 */ 1762, 1812, 1813, 1815, 1677, 1817, 1818, 1797, 1724, 1802, - /* 480 */ 1725, 1822, 1765, 1794, 1825, 1768, 1827, 1770, 1830, 1832, - /* 490 */ 1814, 1819, 1789, 1804, 1821, 1805, 1823, 1816, 1836, 1824, - /* 500 */ 1820, 1840, 1849, 1850, 1826, 1684, 1853, 1854, 1857, 1828, - /* 510 */ 1866, 1867, 1833, 1831, 1834, 1869, 1835, 1838, 1837, 1871, - /* 520 */ 1839, 1841, 1843, 1875, 1846, 1847, 1844, 1878, 1884, 1888, - /* 530 */ 1890, 1782, 1829, 1859, 1876, 1897, 1870, 1872, 1874, 1879, - /* 540 */ 1880, 1886, 1891, 1881, 1883, 1889, 1885, 1910, 1900, 1913, - /* 550 */ 1901, 1882, 1919, 1912, 1902, 1938, 1904, 1940, 1906, 1942, - /* 560 */ 1921, 1924, 1911, 1914, 1916, 1851, 1848, 1947, 1845, 1855, - /* 570 */ 1926, 1932, 1956, 1775, 1935, 1858, 1860, 1959, 1963, 1864, - /* 580 */ 1852, 1962, 1923, 1714, 1873, 1868, 1877, 1892, 1887, 1893, - /* 590 */ 1896, 1895, 1927, 1928, 1905, 1907, 1909, 1917, 1933, 1931, - /* 600 */ 1929, 1937, 1936, 1934, 1716, 1941, 1944, 1977, 1943, 1728, - /* 610 */ 1951, 1957, 1958, 1970, 1979, 1993, 1945, 1952, 1965, 1862, - /* 620 */ 1991, 1990, 2038, 2039, 2041, 2043, 1955, 2017, 1804, 2010, - /* 630 */ 1960, 1961, 1966, 1964, 1976, 1915, 1978, 2063, 2020, 1908, - /* 640 */ 1982, 1973, 1804, 2033, 2040, 1987, 1863, 1989, 2086, 2067, - /* 650 */ 1894, 1992, 1994, 1997, 1995, 2000, 2001, 2047, 2003, 2005, - /* 660 */ 2054, 2007, 2068, 1898, 2009, 2006, 2011, 2079, 2089, 2027, - /* 670 */ 2028, 2093, 2030, 2031, 2096, 2035, 2032, 2102, 2042, 2037, - /* 680 */ 2116, 2052, 2036, 2044, 2045, 2046, 2131, 2048, 2055, 2110, - /* 690 */ 2056, 2123, 2061, 2110, 2110, 2141, 2100, 2106, 2137, 2138, - /* 700 */ 2142, 2149, 2151, 2152, 2153, 2154, 2155, 2156, 2095, 2083, - /* 710 */ 2148, 2160, 2161, 2162, 2177, 2165, 2174, 2176, 2139, 1886, - /* 720 */ 2178, 1891, 2179, 2181, 2182, 2183, 2190, 2184, 2221, 2188, - /* 730 */ 2180, 2185, 2225, 2192, 2187, 2191, 2229, 2196, 2189, 2193, - /* 740 */ 2233, 2201, 2194, 2199, 2240, 2208, 2209, 2245, 2224, 2226, - /* 750 */ 2227, 2228, 2230, 2237, + /* 0 */ 550, 0, 224, 0, 449, 449, 449, 449, 449, 449, + /* 10 */ 449, 449, 449, 449, 449, 673, 897, 897, 1121, 897, + /* 20 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 897, + /* 30 */ 897, 897, 897, 897, 897, 897, 897, 897, 897, 897, + /* 40 */ 897, 897, 897, 897, 897, 897, 897, 897, 149, 170, + /* 50 */ 447, 79, 251, 65, 167, 65, 79, 79, 1487, 1487, + /* 60 */ 1487, 65, 1487, 1487, 529, 65, 109, 328, 137, 137, + /* 70 */ 328, 707, 707, 475, 257, 87, 87, 137, 137, 137, + /* 80 */ 137, 137, 137, 137, 174, 137, 137, 176, 109, 137, + /* 90 */ 137, 279, 137, 109, 137, 174, 137, 174, 109, 137, + /* 100 */ 137, 109, 137, 109, 109, 109, 137, 378, 223, 187, + /* 110 */ 187, 406, 114, 750, 750, 750, 750, 750, 750, 750, + /* 120 */ 750, 750, 750, 750, 750, 750, 750, 750, 750, 750, + /* 130 */ 750, 750, 1135, 165, 475, 257, 63, 39, 39, 39, + /* 140 */ 778, 464, 464, 63, 448, 448, 448, 176, 497, 389, + /* 150 */ 109, 595, 109, 595, 595, 634, 687, 34, 34, 34, + /* 160 */ 34, 34, 34, 34, 34, 1608, 572, 569, 197, 15, + /* 170 */ 260, 288, 247, 543, 784, 690, 831, 693, 519, 981, + /* 180 */ 674, 953, 580, 674, 1016, 886, 856, 1112, 1334, 1200, + /* 190 */ 1345, 1368, 1345, 1229, 1376, 1376, 1345, 1229, 1229, 1302, + /* 200 */ 1309, 1376, 1312, 1376, 1376, 1376, 1400, 1400, 1405, 176, + /* 210 */ 1416, 176, 1420, 1425, 176, 1420, 176, 176, 176, 1376, + /* 220 */ 176, 1401, 1401, 1400, 109, 109, 109, 109, 109, 109, + /* 230 */ 109, 109, 109, 109, 109, 1376, 1400, 595, 595, 595, + /* 240 */ 1266, 1370, 1405, 378, 1281, 1301, 1416, 378, 1316, 1376, + /* 250 */ 1368, 1368, 595, 1250, 1257, 595, 1250, 1257, 595, 595, + /* 260 */ 109, 1245, 1341, 1250, 1255, 1259, 1289, 1112, 1249, 1268, + /* 270 */ 1275, 1299, 448, 1536, 1376, 1420, 378, 378, 1547, 1257, + /* 280 */ 595, 595, 595, 595, 595, 1257, 595, 1409, 378, 634, + /* 290 */ 378, 448, 1482, 1492, 595, 687, 1376, 378, 1562, 1400, + /* 300 */ 3096, 3096, 3096, 3096, 3096, 3096, 3096, 3096, 3096, 36, + /* 310 */ 454, 689, 937, 162, 841, 931, 592, 1015, 1064, 967, + /* 320 */ 1035, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, 1168, + /* 330 */ 472, 73, 502, 502, 666, 408, 499, 776, 734, 838, + /* 340 */ 377, 353, 698, 698, 604, 282, 722, 604, 604, 604, + /* 350 */ 1090, 964, 949, 1032, 1108, 818, 345, 1053, 1067, 1081, + /* 360 */ 1120, 1101, 1231, 1223, 1228, 1242, 944, 1062, 1107, 1131, + /* 370 */ 1147, 1172, 1185, 1126, 1031, 1057, 1041, 1209, 1230, 1234, + /* 380 */ 1237, 1264, 1267, 1278, 1270, 1179, 1202, 1208, 1272, 735, + /* 390 */ 1276, 1277, 1288, 1326, 1328, 1336, 1139, 1254, 1344, 1263, + /* 400 */ 1381, 1620, 1621, 1623, 1583, 1626, 1595, 1423, 1597, 1598, + /* 410 */ 1599, 1427, 1636, 1602, 1603, 1432, 1642, 1436, 1645, 1611, + /* 420 */ 1647, 1627, 1648, 1615, 1456, 1464, 1467, 1654, 1655, 1657, + /* 430 */ 1476, 1478, 1660, 1661, 1622, 1667, 1668, 1670, 1629, 1672, + /* 440 */ 1674, 1685, 1686, 1687, 1688, 1690, 1692, 1522, 1643, 1679, + /* 450 */ 1525, 1681, 1682, 1683, 1693, 1694, 1695, 1696, 1697, 1698, + /* 460 */ 1699, 1700, 1701, 1704, 1705, 1706, 1709, 1669, 1712, 1713, + /* 470 */ 1714, 1723, 1724, 1725, 1715, 1727, 1728, 1735, 1600, 1738, + /* 480 */ 1740, 1722, 1649, 1729, 1650, 1750, 1702, 1717, 1753, 1707, + /* 490 */ 1755, 1708, 1757, 1758, 1719, 1720, 1718, 1716, 1754, 1731, + /* 500 */ 1756, 1732, 1764, 1734, 1730, 1767, 1771, 1772, 1736, 1606, + /* 510 */ 1776, 1780, 1781, 1721, 1784, 1785, 1765, 1741, 1749, 1790, + /* 520 */ 1768, 1744, 1766, 1793, 1769, 1759, 1770, 1810, 1782, 1763, + /* 530 */ 1777, 1815, 1818, 1820, 1822, 1726, 1733, 1788, 1803, 1826, + /* 540 */ 1792, 1794, 1796, 1797, 1798, 1799, 1801, 1786, 1800, 1802, + /* 550 */ 1804, 1806, 1807, 1838, 1819, 1845, 1824, 1805, 1847, 1827, + /* 560 */ 1813, 1850, 1816, 1853, 1823, 1854, 1846, 1849, 1832, 1836, + /* 570 */ 1839, 1778, 1775, 1877, 1737, 1783, 1689, 1851, 1858, 1881, + /* 580 */ 1710, 1863, 1748, 1739, 1887, 1888, 1751, 1745, 1889, 1852, + /* 590 */ 1634, 1808, 1834, 1821, 1828, 1829, 1842, 1809, 1840, 1856, + /* 600 */ 1857, 1841, 1843, 1844, 1848, 1855, 1862, 1876, 1878, 1860, + /* 610 */ 1884, 1637, 1861, 1864, 1891, 1895, 1639, 1867, 1905, 1910, + /* 620 */ 1911, 1912, 1914, 1866, 1868, 1903, 1711, 1909, 1907, 1897, + /* 630 */ 1898, 1955, 1957, 1871, 1924, 1716, 1921, 1872, 1873, 1875, + /* 640 */ 1879, 1880, 1787, 1882, 1977, 1942, 1817, 1892, 1874, 1716, + /* 650 */ 1940, 1944, 1893, 1752, 1896, 1988, 1971, 1814, 1899, 1894, + /* 660 */ 1900, 1901, 1913, 1902, 1949, 1915, 1917, 1951, 1918, 1990, + /* 670 */ 1830, 1922, 1920, 1931, 1979, 1983, 1933, 1934, 1986, 1937, + /* 680 */ 1938, 1999, 1941, 1939, 2003, 1945, 1943, 2007, 1946, 1925, + /* 690 */ 1926, 1927, 1929, 2031, 1947, 1954, 2011, 1960, 2026, 1962, + /* 700 */ 2011, 2011, 2041, 2000, 2002, 2029, 2032, 2033, 2035, 2036, + /* 710 */ 2038, 2040, 2043, 2044, 2045, 2001, 1992, 2039, 2046, 2051, + /* 720 */ 2052, 2054, 2053, 2055, 2056, 2021, 1786, 2059, 1800, 2060, + /* 730 */ 2067, 2069, 2071, 2086, 2074, 2110, 2076, 2064, 2075, 2113, + /* 740 */ 2081, 2070, 2078, 2120, 2095, 2073, 2092, 2132, 2099, 2085, + /* 750 */ 2096, 2136, 2102, 2103, 2139, 2119, 2121, 2122, 2124, 2126, + /* 760 */ 2123, }; -#define YY_REDUCE_COUNT (307) -#define YY_REDUCE_MIN (-442) -#define YY_REDUCE_MAX (2408) +#define YY_REDUCE_COUNT (308) +#define YY_REDUCE_MIN (-424) +#define YY_REDUCE_MAX (2669) static const short yy_reduce_ofst[] = { - /* 0 */ -20, -328, 248, 809, 840, 907, 967, 987, 1096, 655, - /* 10 */ 1116, 1190, 1214, 1281, 1341, 46, -305, 325, 467, 890, - /* 20 */ 1264, 1361, 1424, 1482, 1507, 1580, 1601, 1630, 1651, 1701, - /* 30 */ 1726, 1761, 1784, 1842, 1861, 1922, 1980, 1996, 2059, 2075, - /* 40 */ 2094, 2158, 2175, 2235, 2255, 2329, 2346, 2408, -317, -303, - /* 50 */ 120, 282, 313, 453, 483, 584, 361, 683, -367, -348, - /* 60 */ -272, 461, 206, 293, -442, -384, 72, -364, -286, 475, - /* 70 */ -378, -330, 59, 327, -241, 155, 171, 324, 384, 413, - /* 80 */ 479, 637, 686, 698, -287, 708, 776, 22, 330, 788, - /* 90 */ 791, -358, 802, 465, 815, 70, 817, 452, 60, 844, - /* 100 */ 859, 518, 868, 536, 566, 675, 869, 230, -297, -284, - /* 110 */ -284, -344, -259, -207, 201, 359, 376, 418, 471, 501, - /* 120 */ 524, 704, 711, 760, 761, 765, 824, 838, 874, 878, - /* 130 */ 903, 904, -188, -387, -172, 192, 257, -387, 367, 402, - /* 140 */ 145, 504, 554, 562, -71, -27, 65, 288, -327, 306, - /* 150 */ 648, 380, 685, 517, 633, 772, 705, 407, 427, 432, - /* 160 */ 445, 462, 512, 571, 462, 134, 716, 669, 619, 710, - /* 170 */ 793, 932, 829, 927, 927, 952, 928, 979, 943, 945, - /* 180 */ 899, 899, 884, 899, 941, 942, 927, 982, 989, 1013, - /* 190 */ 1039, 1041, 1045, 1049, 1097, 1100, 1053, 1058, 1060, 1094, - /* 200 */ 1102, 1107, 1101, 1113, 1114, 1115, 1129, 1131, 1061, 1122, - /* 210 */ 1091, 1126, 1132, 1080, 1133, 1136, 1134, 1137, 1138, 1145, - /* 220 */ 1147, 1143, 1148, 1156, 1123, 1135, 1158, 1159, 1163, 1164, - /* 230 */ 1174, 1176, 1178, 1183, 1184, 1155, 1165, 1119, 1120, 1125, - /* 240 */ 1103, 1112, 1104, 1177, 1146, 1150, 1180, 1210, 1216, 1169, - /* 250 */ 1170, 1181, 1111, 1172, 1189, 1128, 1173, 1191, 1195, 927, - /* 260 */ 1141, 1151, 1149, 1139, 1152, 1166, 1171, 1117, 1157, 1153, - /* 270 */ 899, 1217, 1182, 1259, 1260, 1271, 1273, 1231, 1227, 1252, - /* 280 */ 1263, 1265, 1270, 1274, 1246, 1275, 1250, 1303, 1290, 1314, - /* 290 */ 1282, 1223, 1293, 1285, 1310, 1327, 1322, 1333, 1336, 1272, - /* 300 */ 1283, 1277, 1286, 1316, 1328, 1331, 1332, 1339, + /* 0 */ 373, -119, 368, 588, 774, 995, 1065, 1116, 1191, -17, + /* 10 */ 446, 672, 880, 1310, 1375, -332, 903, 155, 1440, 1491, + /* 20 */ 1510, 1585, 1604, 1677, 1703, 1774, 1795, 1825, 1890, 1919, + /* 30 */ 1953, 2017, 2037, 2098, 2149, 2170, 2200, 2265, 2294, 2328, + /* 40 */ 2392, 2412, 2473, 2524, 2545, 2575, 2640, 2669, 96, -184, + /* 50 */ -395, -99, -392, -134, 488, 761, -87, 470, -89, 281, + /* 60 */ 398, -424, -364, -360, -384, 806, 42, -314, -177, 391, + /* 70 */ -379, -207, -156, -350, 86, 156, 202, -331, 178, 394, + /* 80 */ 402, 462, 507, 577, -101, 585, 646, -34, -334, 700, + /* 90 */ 708, 196, 730, 182, 801, 190, 804, 302, 278, 846, + /* 100 */ 858, 401, 860, 505, 450, 556, 878, -301, -63, -243, + /* 110 */ -243, -110, -323, -85, -81, 59, 153, 357, 358, 407, + /* 120 */ 541, 549, 594, 627, 639, 658, 663, 665, 669, 680, + /* 130 */ 682, 683, -302, 530, 267, 7, 124, 530, 545, 637, + /* 140 */ 185, -7, 363, 206, 104, 603, 671, -22, -104, 611, + /* 150 */ 451, 710, 686, 721, 723, 749, 630, -367, -362, 338, + /* 160 */ 429, 582, 795, 797, 582, 520, 847, 922, 871, 792, + /* 170 */ 808, 940, 829, 924, 924, 948, 906, 957, 934, 941, + /* 180 */ 911, 911, 893, 911, 921, 912, 924, 961, 970, 985, + /* 190 */ 1000, 1002, 1006, 1009, 1054, 1056, 1013, 1017, 1018, 1052, + /* 200 */ 1055, 1068, 1059, 1069, 1071, 1072, 1087, 1089, 1027, 1088, + /* 210 */ 1060, 1091, 1100, 1048, 1103, 1106, 1104, 1105, 1109, 1113, + /* 220 */ 1110, 1111, 1114, 1124, 1094, 1095, 1096, 1097, 1098, 1099, + /* 230 */ 1102, 1117, 1127, 1128, 1138, 1125, 1132, 1092, 1093, 1122, + /* 240 */ 1063, 1066, 1073, 1133, 1070, 1074, 1129, 1160, 1115, 1166, + /* 250 */ 1119, 1123, 1136, 1061, 1137, 1142, 1075, 1140, 1144, 1146, + /* 260 */ 924, 1083, 1076, 1118, 1134, 1130, 1141, 1145, 1077, 1078, + /* 270 */ 1085, 911, 1181, 1143, 1219, 1220, 1218, 1221, 1176, 1175, + /* 280 */ 1192, 1195, 1196, 1197, 1198, 1184, 1201, 1190, 1240, 1224, + /* 290 */ 1244, 1213, 1154, 1225, 1212, 1238, 1256, 1251, 1265, 1269, + /* 300 */ 1199, 1194, 1204, 1210, 1246, 1248, 1258, 1273, 1285, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 10 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 20 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 30 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 40 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 50 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 60 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 70 */ 1695, 1695, 1695, 1962, 1695, 1695, 1695, 1695, 1695, 1695, - /* 80 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1774, 1695, 1695, - /* 90 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 100 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1772, 1955, 2173, - /* 110 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 120 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 130 */ 1695, 1695, 1695, 2185, 1695, 1695, 1695, 2185, 2185, 2185, - /* 140 */ 1772, 2145, 2145, 1695, 1695, 1695, 1695, 1774, 2018, 1695, - /* 150 */ 1695, 1695, 1695, 1695, 1695, 1890, 1695, 1695, 1695, 1695, - /* 160 */ 1695, 1914, 1695, 1695, 1695, 2008, 1695, 1695, 2210, 2266, - /* 170 */ 1695, 1695, 2213, 1695, 1695, 1695, 1967, 1695, 1843, 2200, - /* 180 */ 2177, 2191, 2250, 2178, 2175, 2194, 1695, 2204, 1695, 2001, - /* 190 */ 1960, 1695, 1960, 1957, 1695, 1695, 1960, 1957, 1957, 1832, - /* 200 */ 1828, 1695, 1826, 1695, 1695, 1695, 1695, 1695, 1695, 1774, - /* 210 */ 1695, 1774, 1695, 1695, 1774, 1695, 1774, 1774, 1774, 1695, - /* 220 */ 1774, 1752, 1752, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 230 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 240 */ 2030, 2016, 1695, 1772, 2012, 2010, 1695, 1772, 1695, 1695, - /* 250 */ 1695, 1695, 2221, 2219, 1695, 2221, 2219, 1695, 1695, 1695, - /* 260 */ 2235, 2231, 2221, 2239, 2237, 2206, 2204, 2269, 2256, 2252, - /* 270 */ 2191, 1695, 1695, 1695, 1695, 1772, 1772, 1695, 2219, 1695, - /* 280 */ 1695, 1695, 1695, 1695, 2219, 1695, 1695, 1772, 1695, 1772, - /* 290 */ 1695, 1695, 1859, 1695, 1695, 1695, 1772, 1727, 1695, 2003, - /* 300 */ 2021, 1985, 1985, 1893, 1893, 1893, 1775, 1700, 1695, 1695, - /* 310 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 320 */ 2234, 2233, 2100, 1695, 2149, 2148, 2147, 2138, 2099, 1855, - /* 330 */ 1695, 2098, 2097, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 340 */ 1695, 1976, 1975, 2091, 1695, 1695, 2092, 2090, 2089, 1695, - /* 350 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 360 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 370 */ 2253, 2257, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 2174, - /* 380 */ 1695, 1695, 1695, 1695, 1695, 2073, 1695, 1695, 1695, 1695, - /* 390 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 400 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 410 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 420 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 430 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 440 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 450 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 460 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 470 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 480 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 490 */ 1695, 1695, 1732, 2078, 1695, 1695, 1695, 1695, 1695, 1695, - /* 500 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 510 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 520 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 530 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 540 */ 1695, 1813, 1812, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 550 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 560 */ 1695, 1695, 1695, 1695, 1695, 2082, 1695, 1695, 1695, 1695, - /* 570 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 580 */ 1695, 2249, 2207, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 590 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 600 */ 1695, 2073, 1695, 2232, 1695, 1695, 2247, 1695, 2251, 1695, - /* 610 */ 1695, 1695, 1695, 1695, 1695, 1695, 2184, 2180, 1695, 1695, - /* 620 */ 2176, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 2081, 1695, - /* 630 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 640 */ 1695, 1695, 2072, 1695, 2135, 1695, 1695, 1695, 2169, 1695, - /* 650 */ 1695, 2120, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 660 */ 1695, 2082, 1695, 2085, 1695, 1695, 1695, 1695, 1695, 1887, - /* 670 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 680 */ 1695, 1695, 1872, 1870, 1869, 1868, 1695, 1865, 1695, 1900, - /* 690 */ 1695, 1695, 1695, 1896, 1895, 1695, 1695, 1695, 1695, 1695, - /* 700 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 710 */ 1793, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1785, - /* 720 */ 1695, 1784, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 730 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 740 */ 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, 1695, - /* 750 */ 1695, 1695, 1695, 1695, + /* 0 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 10 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 20 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 30 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 40 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 50 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 60 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 70 */ 1714, 1714, 1714, 1985, 1714, 1714, 1714, 1714, 1714, 1714, + /* 80 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1793, 1714, 1714, + /* 90 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 100 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1791, 1978, 2199, + /* 110 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 120 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 130 */ 1714, 1714, 1714, 2211, 1714, 1714, 1714, 2211, 2211, 2211, + /* 140 */ 1791, 2171, 2171, 1714, 1714, 1714, 1714, 1793, 2043, 1714, + /* 150 */ 1714, 1714, 1714, 1714, 1714, 1913, 1714, 1714, 1714, 1714, + /* 160 */ 1714, 1937, 1714, 1714, 1714, 2037, 1714, 1714, 2236, 2292, + /* 170 */ 1714, 1714, 2239, 1714, 1714, 1714, 1990, 1714, 1866, 2226, + /* 180 */ 2203, 2217, 2276, 2204, 2201, 2220, 1714, 2230, 1714, 2024, + /* 190 */ 1983, 1714, 1983, 1980, 1714, 1714, 1983, 1980, 1980, 1855, + /* 200 */ 1851, 1714, 1849, 1714, 1714, 1714, 1714, 1714, 1714, 1793, + /* 210 */ 1714, 1793, 1714, 1714, 1793, 1714, 1793, 1793, 1793, 1714, + /* 220 */ 1793, 1771, 1771, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 230 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 240 */ 2055, 2041, 1714, 1791, 2035, 2033, 1714, 1791, 2031, 1714, + /* 250 */ 1714, 1714, 1714, 2247, 2245, 1714, 2247, 2245, 1714, 1714, + /* 260 */ 1714, 2261, 2257, 2247, 2265, 2263, 2232, 2230, 2295, 2282, + /* 270 */ 2278, 2217, 1714, 1714, 1714, 1714, 1791, 1791, 1714, 2245, + /* 280 */ 1714, 1714, 1714, 1714, 1714, 2245, 1714, 1714, 1791, 1714, + /* 290 */ 1791, 1714, 1714, 1882, 1714, 1714, 1714, 1791, 1746, 1714, + /* 300 */ 2026, 2046, 2008, 2008, 1916, 1916, 1916, 1794, 1719, 1714, + /* 310 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 320 */ 1714, 2260, 2259, 2126, 1714, 2175, 2174, 2173, 2164, 2125, + /* 330 */ 1878, 1714, 2124, 2123, 1714, 1714, 1714, 1714, 1714, 1714, + /* 340 */ 1714, 1714, 1999, 1998, 2117, 1714, 1714, 2118, 2116, 2115, + /* 350 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 360 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 370 */ 1714, 1714, 1714, 1714, 2279, 2283, 1714, 1714, 1714, 1714, + /* 380 */ 1714, 1714, 1714, 2200, 1714, 1714, 1714, 1714, 1714, 2099, + /* 390 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 400 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 410 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 420 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 430 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 440 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 450 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 460 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 470 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 480 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 490 */ 1714, 1714, 1714, 1714, 1714, 1714, 1751, 2104, 1714, 1714, + /* 500 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 510 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 520 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 530 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 540 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1832, 1831, 1714, + /* 550 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 560 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 570 */ 1714, 2108, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 580 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 2275, 2233, + /* 590 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 600 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 2099, 1714, + /* 610 */ 2258, 1714, 1714, 2273, 1714, 2277, 1714, 1714, 1714, 1714, + /* 620 */ 1714, 1714, 1714, 2210, 2206, 1714, 1714, 2202, 1714, 1714, + /* 630 */ 1714, 1714, 1714, 1714, 1714, 2107, 1714, 1714, 1714, 1714, + /* 640 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 2098, + /* 650 */ 1714, 2161, 1714, 1714, 1714, 2195, 1714, 1714, 2146, 1714, + /* 660 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 2108, 1714, + /* 670 */ 2111, 1714, 1714, 1714, 1714, 1714, 1910, 1714, 1714, 1714, + /* 680 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1895, + /* 690 */ 1893, 1892, 1891, 1714, 1888, 1714, 1923, 1714, 1714, 1714, + /* 700 */ 1919, 1918, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 710 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1812, 1714, 1714, + /* 720 */ 1714, 1714, 1714, 1714, 1714, 1714, 1804, 1714, 1803, 1714, + /* 730 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 740 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 750 */ 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, 1714, + /* 760 */ 1714, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1100,7 +1154,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* START => nothing */ 0, /* WITH => nothing */ 0, /* TIMESTAMP => nothing */ - 277, /* END => ABORT */ + 279, /* END => ABORT */ 0, /* TABLE => nothing */ 0, /* NK_LP => nothing */ 0, /* NK_RP => nothing */ @@ -1195,6 +1249,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* AGGREGATE => nothing */ 0, /* BUFSIZE => nothing */ 0, /* LANGUAGE => nothing */ + 0, /* REPLACE => nothing */ 0, /* STREAM => nothing */ 0, /* INTO => nothing */ 0, /* TRIGGER => nothing */ @@ -1210,6 +1265,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* TRANSACTION => nothing */ 0, /* BALANCE => nothing */ 0, /* VGROUP => nothing */ + 0, /* LEADER => nothing */ 0, /* MERGE => nothing */ 0, /* REDISTRIBUTE => nothing */ 0, /* SPLIT => nothing */ @@ -1280,57 +1336,56 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ABORT => nothing */ - 277, /* AFTER => ABORT */ - 277, /* ATTACH => ABORT */ - 277, /* BEFORE => ABORT */ - 277, /* BEGIN => ABORT */ - 277, /* BITAND => ABORT */ - 277, /* BITNOT => ABORT */ - 277, /* BITOR => ABORT */ - 277, /* BLOCKS => ABORT */ - 277, /* CHANGE => ABORT */ - 277, /* COMMA => ABORT */ - 277, /* CONCAT => ABORT */ - 277, /* CONFLICT => ABORT */ - 277, /* COPY => ABORT */ - 277, /* DEFERRED => ABORT */ - 277, /* DELIMITERS => ABORT */ - 277, /* DETACH => ABORT */ - 277, /* DIVIDE => ABORT */ - 277, /* DOT => ABORT */ - 277, /* EACH => ABORT */ - 277, /* FAIL => ABORT */ - 277, /* FILE => ABORT */ - 277, /* FOR => ABORT */ - 277, /* GLOB => ABORT */ - 277, /* ID => ABORT */ - 277, /* IMMEDIATE => ABORT */ - 277, /* IMPORT => ABORT */ - 277, /* INITIALLY => ABORT */ - 277, /* INSTEAD => ABORT */ - 277, /* ISNULL => ABORT */ - 277, /* KEY => ABORT */ - 277, /* MODULES => ABORT */ - 277, /* NK_BITNOT => ABORT */ - 277, /* NK_SEMI => ABORT */ - 277, /* NOTNULL => ABORT */ - 277, /* OF => ABORT */ - 277, /* PLUS => ABORT */ - 277, /* PRIVILEGE => ABORT */ - 277, /* RAISE => ABORT */ - 277, /* REPLACE => ABORT */ - 277, /* RESTRICT => ABORT */ - 277, /* ROW => ABORT */ - 277, /* SEMI => ABORT */ - 277, /* STAR => ABORT */ - 277, /* STATEMENT => ABORT */ - 277, /* STRICT => ABORT */ - 277, /* STRING => ABORT */ - 277, /* TIMES => ABORT */ - 277, /* VALUES => ABORT */ - 277, /* VARIABLE => ABORT */ - 277, /* VIEW => ABORT */ - 277, /* WAL => ABORT */ + 279, /* AFTER => ABORT */ + 279, /* ATTACH => ABORT */ + 279, /* BEFORE => ABORT */ + 279, /* BEGIN => ABORT */ + 279, /* BITAND => ABORT */ + 279, /* BITNOT => ABORT */ + 279, /* BITOR => ABORT */ + 279, /* BLOCKS => ABORT */ + 279, /* CHANGE => ABORT */ + 279, /* COMMA => ABORT */ + 279, /* CONCAT => ABORT */ + 279, /* CONFLICT => ABORT */ + 279, /* COPY => ABORT */ + 279, /* DEFERRED => ABORT */ + 279, /* DELIMITERS => ABORT */ + 279, /* DETACH => ABORT */ + 279, /* DIVIDE => ABORT */ + 279, /* DOT => ABORT */ + 279, /* EACH => ABORT */ + 279, /* FAIL => ABORT */ + 279, /* FILE => ABORT */ + 279, /* FOR => ABORT */ + 279, /* GLOB => ABORT */ + 279, /* ID => ABORT */ + 279, /* IMMEDIATE => ABORT */ + 279, /* IMPORT => ABORT */ + 279, /* INITIALLY => ABORT */ + 279, /* INSTEAD => ABORT */ + 279, /* ISNULL => ABORT */ + 279, /* KEY => ABORT */ + 279, /* MODULES => ABORT */ + 279, /* NK_BITNOT => ABORT */ + 279, /* NK_SEMI => ABORT */ + 279, /* NOTNULL => ABORT */ + 279, /* OF => ABORT */ + 279, /* PLUS => ABORT */ + 279, /* PRIVILEGE => ABORT */ + 279, /* RAISE => ABORT */ + 279, /* RESTRICT => ABORT */ + 279, /* ROW => ABORT */ + 279, /* SEMI => ABORT */ + 279, /* STAR => ABORT */ + 279, /* STATEMENT => ABORT */ + 279, /* STRICT => ABORT */ + 279, /* STRING => ABORT */ + 279, /* TIMES => ABORT */ + 279, /* VALUES => ABORT */ + 279, /* VARIABLE => ABORT */ + 279, /* VIEW => ABORT */ + 279, /* WAL => ABORT */ }; #endif /* YYFALLBACK */ @@ -1611,286 +1666,288 @@ static const char *const yyTokenName[] = { /* 190 */ "AGGREGATE", /* 191 */ "BUFSIZE", /* 192 */ "LANGUAGE", - /* 193 */ "STREAM", - /* 194 */ "INTO", - /* 195 */ "TRIGGER", - /* 196 */ "AT_ONCE", - /* 197 */ "WINDOW_CLOSE", - /* 198 */ "IGNORE", - /* 199 */ "EXPIRED", - /* 200 */ "FILL_HISTORY", - /* 201 */ "UPDATE", - /* 202 */ "SUBTABLE", - /* 203 */ "KILL", - /* 204 */ "CONNECTION", - /* 205 */ "TRANSACTION", - /* 206 */ "BALANCE", - /* 207 */ "VGROUP", - /* 208 */ "MERGE", - /* 209 */ "REDISTRIBUTE", - /* 210 */ "SPLIT", - /* 211 */ "DELETE", - /* 212 */ "INSERT", - /* 213 */ "NULL", - /* 214 */ "NK_QUESTION", - /* 215 */ "NK_ARROW", - /* 216 */ "ROWTS", - /* 217 */ "QSTART", - /* 218 */ "QEND", - /* 219 */ "QDURATION", - /* 220 */ "WSTART", - /* 221 */ "WEND", - /* 222 */ "WDURATION", - /* 223 */ "IROWTS", - /* 224 */ "ISFILLED", - /* 225 */ "CAST", - /* 226 */ "NOW", - /* 227 */ "TODAY", - /* 228 */ "TIMEZONE", - /* 229 */ "CLIENT_VERSION", - /* 230 */ "SERVER_VERSION", - /* 231 */ "SERVER_STATUS", - /* 232 */ "CURRENT_USER", - /* 233 */ "CASE", - /* 234 */ "WHEN", - /* 235 */ "THEN", - /* 236 */ "ELSE", - /* 237 */ "BETWEEN", - /* 238 */ "IS", - /* 239 */ "NK_LT", - /* 240 */ "NK_GT", - /* 241 */ "NK_LE", - /* 242 */ "NK_GE", - /* 243 */ "NK_NE", - /* 244 */ "MATCH", - /* 245 */ "NMATCH", - /* 246 */ "CONTAINS", - /* 247 */ "IN", - /* 248 */ "JOIN", - /* 249 */ "INNER", - /* 250 */ "SELECT", - /* 251 */ "DISTINCT", - /* 252 */ "WHERE", - /* 253 */ "PARTITION", - /* 254 */ "BY", - /* 255 */ "SESSION", - /* 256 */ "STATE_WINDOW", - /* 257 */ "EVENT_WINDOW", - /* 258 */ "SLIDING", - /* 259 */ "FILL", - /* 260 */ "VALUE", - /* 261 */ "VALUE_F", - /* 262 */ "NONE", - /* 263 */ "PREV", - /* 264 */ "NULL_F", - /* 265 */ "LINEAR", - /* 266 */ "NEXT", - /* 267 */ "HAVING", - /* 268 */ "RANGE", - /* 269 */ "EVERY", - /* 270 */ "ORDER", - /* 271 */ "SLIMIT", - /* 272 */ "SOFFSET", - /* 273 */ "LIMIT", - /* 274 */ "OFFSET", - /* 275 */ "ASC", - /* 276 */ "NULLS", - /* 277 */ "ABORT", - /* 278 */ "AFTER", - /* 279 */ "ATTACH", - /* 280 */ "BEFORE", - /* 281 */ "BEGIN", - /* 282 */ "BITAND", - /* 283 */ "BITNOT", - /* 284 */ "BITOR", - /* 285 */ "BLOCKS", - /* 286 */ "CHANGE", - /* 287 */ "COMMA", - /* 288 */ "CONCAT", - /* 289 */ "CONFLICT", - /* 290 */ "COPY", - /* 291 */ "DEFERRED", - /* 292 */ "DELIMITERS", - /* 293 */ "DETACH", - /* 294 */ "DIVIDE", - /* 295 */ "DOT", - /* 296 */ "EACH", - /* 297 */ "FAIL", - /* 298 */ "FILE", - /* 299 */ "FOR", - /* 300 */ "GLOB", - /* 301 */ "ID", - /* 302 */ "IMMEDIATE", - /* 303 */ "IMPORT", - /* 304 */ "INITIALLY", - /* 305 */ "INSTEAD", - /* 306 */ "ISNULL", - /* 307 */ "KEY", - /* 308 */ "MODULES", - /* 309 */ "NK_BITNOT", - /* 310 */ "NK_SEMI", - /* 311 */ "NOTNULL", - /* 312 */ "OF", - /* 313 */ "PLUS", - /* 314 */ "PRIVILEGE", - /* 315 */ "RAISE", - /* 316 */ "REPLACE", - /* 317 */ "RESTRICT", - /* 318 */ "ROW", - /* 319 */ "SEMI", - /* 320 */ "STAR", - /* 321 */ "STATEMENT", - /* 322 */ "STRICT", - /* 323 */ "STRING", - /* 324 */ "TIMES", - /* 325 */ "VALUES", - /* 326 */ "VARIABLE", - /* 327 */ "VIEW", - /* 328 */ "WAL", - /* 329 */ "cmd", - /* 330 */ "account_options", - /* 331 */ "alter_account_options", - /* 332 */ "literal", - /* 333 */ "alter_account_option", - /* 334 */ "user_name", - /* 335 */ "sysinfo_opt", - /* 336 */ "privileges", - /* 337 */ "priv_level", - /* 338 */ "priv_type_list", - /* 339 */ "priv_type", - /* 340 */ "db_name", - /* 341 */ "topic_name", - /* 342 */ "dnode_endpoint", - /* 343 */ "force_opt", - /* 344 */ "not_exists_opt", - /* 345 */ "db_options", - /* 346 */ "exists_opt", - /* 347 */ "alter_db_options", - /* 348 */ "speed_opt", - /* 349 */ "start_opt", - /* 350 */ "end_opt", - /* 351 */ "integer_list", - /* 352 */ "variable_list", - /* 353 */ "retention_list", - /* 354 */ "alter_db_option", - /* 355 */ "retention", - /* 356 */ "full_table_name", - /* 357 */ "column_def_list", - /* 358 */ "tags_def_opt", - /* 359 */ "table_options", - /* 360 */ "multi_create_clause", - /* 361 */ "tags_def", - /* 362 */ "multi_drop_clause", - /* 363 */ "alter_table_clause", - /* 364 */ "alter_table_options", - /* 365 */ "column_name", - /* 366 */ "type_name", - /* 367 */ "signed_literal", - /* 368 */ "create_subtable_clause", - /* 369 */ "specific_cols_opt", - /* 370 */ "expression_list", - /* 371 */ "drop_table_clause", - /* 372 */ "col_name_list", - /* 373 */ "table_name", - /* 374 */ "column_def", - /* 375 */ "duration_list", - /* 376 */ "rollup_func_list", - /* 377 */ "alter_table_option", - /* 378 */ "duration_literal", - /* 379 */ "rollup_func_name", - /* 380 */ "function_name", - /* 381 */ "col_name", - /* 382 */ "db_name_cond_opt", - /* 383 */ "like_pattern_opt", - /* 384 */ "table_name_cond", - /* 385 */ "from_db_opt", - /* 386 */ "tag_list_opt", - /* 387 */ "tag_item", - /* 388 */ "column_alias", - /* 389 */ "full_index_name", - /* 390 */ "index_options", - /* 391 */ "index_name", - /* 392 */ "func_list", - /* 393 */ "sliding_opt", - /* 394 */ "sma_stream_opt", - /* 395 */ "func", - /* 396 */ "sma_func_name", - /* 397 */ "query_or_subquery", - /* 398 */ "cgroup_name", - /* 399 */ "analyze_opt", - /* 400 */ "explain_options", - /* 401 */ "insert_query", - /* 402 */ "agg_func_opt", - /* 403 */ "bufsize_opt", - /* 404 */ "language_opt", - /* 405 */ "stream_name", - /* 406 */ "stream_options", - /* 407 */ "col_list_opt", - /* 408 */ "tag_def_or_ref_opt", - /* 409 */ "subtable_opt", - /* 410 */ "expression", - /* 411 */ "dnode_list", - /* 412 */ "where_clause_opt", - /* 413 */ "signed", - /* 414 */ "literal_func", - /* 415 */ "literal_list", - /* 416 */ "table_alias", - /* 417 */ "expr_or_subquery", - /* 418 */ "pseudo_column", - /* 419 */ "column_reference", - /* 420 */ "function_expression", - /* 421 */ "case_when_expression", - /* 422 */ "star_func", - /* 423 */ "star_func_para_list", - /* 424 */ "noarg_func", - /* 425 */ "other_para_list", - /* 426 */ "star_func_para", - /* 427 */ "when_then_list", - /* 428 */ "case_when_else_opt", - /* 429 */ "common_expression", - /* 430 */ "when_then_expr", - /* 431 */ "predicate", - /* 432 */ "compare_op", - /* 433 */ "in_op", - /* 434 */ "in_predicate_value", - /* 435 */ "boolean_value_expression", - /* 436 */ "boolean_primary", - /* 437 */ "from_clause_opt", - /* 438 */ "table_reference_list", - /* 439 */ "table_reference", - /* 440 */ "table_primary", - /* 441 */ "joined_table", - /* 442 */ "alias_opt", - /* 443 */ "subquery", - /* 444 */ "parenthesized_joined_table", - /* 445 */ "join_type", - /* 446 */ "search_condition", - /* 447 */ "query_specification", - /* 448 */ "set_quantifier_opt", - /* 449 */ "select_list", - /* 450 */ "partition_by_clause_opt", - /* 451 */ "range_opt", - /* 452 */ "every_opt", - /* 453 */ "fill_opt", - /* 454 */ "twindow_clause_opt", - /* 455 */ "group_by_clause_opt", - /* 456 */ "having_clause_opt", - /* 457 */ "select_item", - /* 458 */ "partition_list", - /* 459 */ "partition_item", - /* 460 */ "fill_mode", - /* 461 */ "group_by_list", - /* 462 */ "query_expression", - /* 463 */ "query_simple", - /* 464 */ "order_by_clause_opt", - /* 465 */ "slimit_clause_opt", - /* 466 */ "limit_clause_opt", - /* 467 */ "union_query_expression", - /* 468 */ "query_simple_or_subquery", - /* 469 */ "sort_specification_list", - /* 470 */ "sort_specification", - /* 471 */ "ordering_specification_opt", - /* 472 */ "null_ordering_opt", + /* 193 */ "REPLACE", + /* 194 */ "STREAM", + /* 195 */ "INTO", + /* 196 */ "TRIGGER", + /* 197 */ "AT_ONCE", + /* 198 */ "WINDOW_CLOSE", + /* 199 */ "IGNORE", + /* 200 */ "EXPIRED", + /* 201 */ "FILL_HISTORY", + /* 202 */ "UPDATE", + /* 203 */ "SUBTABLE", + /* 204 */ "KILL", + /* 205 */ "CONNECTION", + /* 206 */ "TRANSACTION", + /* 207 */ "BALANCE", + /* 208 */ "VGROUP", + /* 209 */ "LEADER", + /* 210 */ "MERGE", + /* 211 */ "REDISTRIBUTE", + /* 212 */ "SPLIT", + /* 213 */ "DELETE", + /* 214 */ "INSERT", + /* 215 */ "NULL", + /* 216 */ "NK_QUESTION", + /* 217 */ "NK_ARROW", + /* 218 */ "ROWTS", + /* 219 */ "QSTART", + /* 220 */ "QEND", + /* 221 */ "QDURATION", + /* 222 */ "WSTART", + /* 223 */ "WEND", + /* 224 */ "WDURATION", + /* 225 */ "IROWTS", + /* 226 */ "ISFILLED", + /* 227 */ "CAST", + /* 228 */ "NOW", + /* 229 */ "TODAY", + /* 230 */ "TIMEZONE", + /* 231 */ "CLIENT_VERSION", + /* 232 */ "SERVER_VERSION", + /* 233 */ "SERVER_STATUS", + /* 234 */ "CURRENT_USER", + /* 235 */ "CASE", + /* 236 */ "WHEN", + /* 237 */ "THEN", + /* 238 */ "ELSE", + /* 239 */ "BETWEEN", + /* 240 */ "IS", + /* 241 */ "NK_LT", + /* 242 */ "NK_GT", + /* 243 */ "NK_LE", + /* 244 */ "NK_GE", + /* 245 */ "NK_NE", + /* 246 */ "MATCH", + /* 247 */ "NMATCH", + /* 248 */ "CONTAINS", + /* 249 */ "IN", + /* 250 */ "JOIN", + /* 251 */ "INNER", + /* 252 */ "SELECT", + /* 253 */ "DISTINCT", + /* 254 */ "WHERE", + /* 255 */ "PARTITION", + /* 256 */ "BY", + /* 257 */ "SESSION", + /* 258 */ "STATE_WINDOW", + /* 259 */ "EVENT_WINDOW", + /* 260 */ "SLIDING", + /* 261 */ "FILL", + /* 262 */ "VALUE", + /* 263 */ "VALUE_F", + /* 264 */ "NONE", + /* 265 */ "PREV", + /* 266 */ "NULL_F", + /* 267 */ "LINEAR", + /* 268 */ "NEXT", + /* 269 */ "HAVING", + /* 270 */ "RANGE", + /* 271 */ "EVERY", + /* 272 */ "ORDER", + /* 273 */ "SLIMIT", + /* 274 */ "SOFFSET", + /* 275 */ "LIMIT", + /* 276 */ "OFFSET", + /* 277 */ "ASC", + /* 278 */ "NULLS", + /* 279 */ "ABORT", + /* 280 */ "AFTER", + /* 281 */ "ATTACH", + /* 282 */ "BEFORE", + /* 283 */ "BEGIN", + /* 284 */ "BITAND", + /* 285 */ "BITNOT", + /* 286 */ "BITOR", + /* 287 */ "BLOCKS", + /* 288 */ "CHANGE", + /* 289 */ "COMMA", + /* 290 */ "CONCAT", + /* 291 */ "CONFLICT", + /* 292 */ "COPY", + /* 293 */ "DEFERRED", + /* 294 */ "DELIMITERS", + /* 295 */ "DETACH", + /* 296 */ "DIVIDE", + /* 297 */ "DOT", + /* 298 */ "EACH", + /* 299 */ "FAIL", + /* 300 */ "FILE", + /* 301 */ "FOR", + /* 302 */ "GLOB", + /* 303 */ "ID", + /* 304 */ "IMMEDIATE", + /* 305 */ "IMPORT", + /* 306 */ "INITIALLY", + /* 307 */ "INSTEAD", + /* 308 */ "ISNULL", + /* 309 */ "KEY", + /* 310 */ "MODULES", + /* 311 */ "NK_BITNOT", + /* 312 */ "NK_SEMI", + /* 313 */ "NOTNULL", + /* 314 */ "OF", + /* 315 */ "PLUS", + /* 316 */ "PRIVILEGE", + /* 317 */ "RAISE", + /* 318 */ "RESTRICT", + /* 319 */ "ROW", + /* 320 */ "SEMI", + /* 321 */ "STAR", + /* 322 */ "STATEMENT", + /* 323 */ "STRICT", + /* 324 */ "STRING", + /* 325 */ "TIMES", + /* 326 */ "VALUES", + /* 327 */ "VARIABLE", + /* 328 */ "VIEW", + /* 329 */ "WAL", + /* 330 */ "cmd", + /* 331 */ "account_options", + /* 332 */ "alter_account_options", + /* 333 */ "literal", + /* 334 */ "alter_account_option", + /* 335 */ "user_name", + /* 336 */ "sysinfo_opt", + /* 337 */ "privileges", + /* 338 */ "priv_level", + /* 339 */ "priv_type_list", + /* 340 */ "priv_type", + /* 341 */ "db_name", + /* 342 */ "topic_name", + /* 343 */ "dnode_endpoint", + /* 344 */ "force_opt", + /* 345 */ "not_exists_opt", + /* 346 */ "db_options", + /* 347 */ "exists_opt", + /* 348 */ "alter_db_options", + /* 349 */ "speed_opt", + /* 350 */ "start_opt", + /* 351 */ "end_opt", + /* 352 */ "integer_list", + /* 353 */ "variable_list", + /* 354 */ "retention_list", + /* 355 */ "alter_db_option", + /* 356 */ "retention", + /* 357 */ "full_table_name", + /* 358 */ "column_def_list", + /* 359 */ "tags_def_opt", + /* 360 */ "table_options", + /* 361 */ "multi_create_clause", + /* 362 */ "tags_def", + /* 363 */ "multi_drop_clause", + /* 364 */ "alter_table_clause", + /* 365 */ "alter_table_options", + /* 366 */ "column_name", + /* 367 */ "type_name", + /* 368 */ "signed_literal", + /* 369 */ "create_subtable_clause", + /* 370 */ "specific_cols_opt", + /* 371 */ "expression_list", + /* 372 */ "drop_table_clause", + /* 373 */ "col_name_list", + /* 374 */ "table_name", + /* 375 */ "column_def", + /* 376 */ "duration_list", + /* 377 */ "rollup_func_list", + /* 378 */ "alter_table_option", + /* 379 */ "duration_literal", + /* 380 */ "rollup_func_name", + /* 381 */ "function_name", + /* 382 */ "col_name", + /* 383 */ "db_name_cond_opt", + /* 384 */ "like_pattern_opt", + /* 385 */ "table_name_cond", + /* 386 */ "from_db_opt", + /* 387 */ "tag_list_opt", + /* 388 */ "tag_item", + /* 389 */ "column_alias", + /* 390 */ "full_index_name", + /* 391 */ "index_options", + /* 392 */ "index_name", + /* 393 */ "func_list", + /* 394 */ "sliding_opt", + /* 395 */ "sma_stream_opt", + /* 396 */ "func", + /* 397 */ "sma_func_name", + /* 398 */ "query_or_subquery", + /* 399 */ "cgroup_name", + /* 400 */ "analyze_opt", + /* 401 */ "explain_options", + /* 402 */ "insert_query", + /* 403 */ "or_replace_opt", + /* 404 */ "agg_func_opt", + /* 405 */ "bufsize_opt", + /* 406 */ "language_opt", + /* 407 */ "stream_name", + /* 408 */ "stream_options", + /* 409 */ "col_list_opt", + /* 410 */ "tag_def_or_ref_opt", + /* 411 */ "subtable_opt", + /* 412 */ "expression", + /* 413 */ "dnode_list", + /* 414 */ "where_clause_opt", + /* 415 */ "signed", + /* 416 */ "literal_func", + /* 417 */ "literal_list", + /* 418 */ "table_alias", + /* 419 */ "expr_or_subquery", + /* 420 */ "pseudo_column", + /* 421 */ "column_reference", + /* 422 */ "function_expression", + /* 423 */ "case_when_expression", + /* 424 */ "star_func", + /* 425 */ "star_func_para_list", + /* 426 */ "noarg_func", + /* 427 */ "other_para_list", + /* 428 */ "star_func_para", + /* 429 */ "when_then_list", + /* 430 */ "case_when_else_opt", + /* 431 */ "common_expression", + /* 432 */ "when_then_expr", + /* 433 */ "predicate", + /* 434 */ "compare_op", + /* 435 */ "in_op", + /* 436 */ "in_predicate_value", + /* 437 */ "boolean_value_expression", + /* 438 */ "boolean_primary", + /* 439 */ "from_clause_opt", + /* 440 */ "table_reference_list", + /* 441 */ "table_reference", + /* 442 */ "table_primary", + /* 443 */ "joined_table", + /* 444 */ "alias_opt", + /* 445 */ "subquery", + /* 446 */ "parenthesized_joined_table", + /* 447 */ "join_type", + /* 448 */ "search_condition", + /* 449 */ "query_specification", + /* 450 */ "set_quantifier_opt", + /* 451 */ "select_list", + /* 452 */ "partition_by_clause_opt", + /* 453 */ "range_opt", + /* 454 */ "every_opt", + /* 455 */ "fill_opt", + /* 456 */ "twindow_clause_opt", + /* 457 */ "group_by_clause_opt", + /* 458 */ "having_clause_opt", + /* 459 */ "select_item", + /* 460 */ "partition_list", + /* 461 */ "partition_item", + /* 462 */ "fill_mode", + /* 463 */ "group_by_list", + /* 464 */ "query_expression", + /* 465 */ "query_simple", + /* 466 */ "order_by_clause_opt", + /* 467 */ "slimit_clause_opt", + /* 468 */ "limit_clause_opt", + /* 469 */ "union_query_expression", + /* 470 */ "query_simple_or_subquery", + /* 471 */ "sort_specification_list", + /* 472 */ "sort_specification", + /* 473 */ "ordering_specification_opt", + /* 474 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -2019,459 +2076,466 @@ static const char *const yyRuleName[] = { /* 118 */ "alter_db_option ::= WAL_LEVEL NK_INTEGER", /* 119 */ "alter_db_option ::= STT_TRIGGER NK_INTEGER", /* 120 */ "alter_db_option ::= MINROWS NK_INTEGER", - /* 121 */ "integer_list ::= NK_INTEGER", - /* 122 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", - /* 123 */ "variable_list ::= NK_VARIABLE", - /* 124 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", - /* 125 */ "retention_list ::= retention", - /* 126 */ "retention_list ::= retention_list NK_COMMA retention", - /* 127 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", - /* 128 */ "speed_opt ::=", - /* 129 */ "speed_opt ::= MAX_SPEED NK_INTEGER", - /* 130 */ "start_opt ::=", - /* 131 */ "start_opt ::= START WITH NK_INTEGER", - /* 132 */ "start_opt ::= START WITH NK_STRING", - /* 133 */ "start_opt ::= START WITH TIMESTAMP NK_STRING", - /* 134 */ "end_opt ::=", - /* 135 */ "end_opt ::= END WITH NK_INTEGER", - /* 136 */ "end_opt ::= END WITH NK_STRING", - /* 137 */ "end_opt ::= END WITH TIMESTAMP NK_STRING", - /* 138 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 139 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 140 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 141 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 142 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 143 */ "cmd ::= ALTER TABLE alter_table_clause", - /* 144 */ "cmd ::= ALTER STABLE alter_table_clause", - /* 145 */ "alter_table_clause ::= full_table_name alter_table_options", - /* 146 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", - /* 147 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", - /* 148 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", - /* 149 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", - /* 150 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", - /* 151 */ "alter_table_clause ::= full_table_name DROP TAG column_name", - /* 152 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", - /* 153 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 154 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", - /* 155 */ "multi_create_clause ::= create_subtable_clause", - /* 156 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 157 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options", - /* 158 */ "multi_drop_clause ::= drop_table_clause", - /* 159 */ "multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause", - /* 160 */ "drop_table_clause ::= exists_opt full_table_name", - /* 161 */ "specific_cols_opt ::=", - /* 162 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", - /* 163 */ "full_table_name ::= table_name", - /* 164 */ "full_table_name ::= db_name NK_DOT table_name", - /* 165 */ "column_def_list ::= column_def", - /* 166 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 167 */ "column_def ::= column_name type_name", - /* 168 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 169 */ "type_name ::= BOOL", - /* 170 */ "type_name ::= TINYINT", - /* 171 */ "type_name ::= SMALLINT", - /* 172 */ "type_name ::= INT", - /* 173 */ "type_name ::= INTEGER", - /* 174 */ "type_name ::= BIGINT", - /* 175 */ "type_name ::= FLOAT", - /* 176 */ "type_name ::= DOUBLE", - /* 177 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 178 */ "type_name ::= TIMESTAMP", - /* 179 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 180 */ "type_name ::= TINYINT UNSIGNED", - /* 181 */ "type_name ::= SMALLINT UNSIGNED", - /* 182 */ "type_name ::= INT UNSIGNED", - /* 183 */ "type_name ::= BIGINT UNSIGNED", - /* 184 */ "type_name ::= JSON", - /* 185 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 186 */ "type_name ::= MEDIUMBLOB", - /* 187 */ "type_name ::= BLOB", - /* 188 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 189 */ "type_name ::= DECIMAL", - /* 190 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 191 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 192 */ "tags_def_opt ::=", - /* 193 */ "tags_def_opt ::= tags_def", - /* 194 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 195 */ "table_options ::=", - /* 196 */ "table_options ::= table_options COMMENT NK_STRING", - /* 197 */ "table_options ::= table_options MAX_DELAY duration_list", - /* 198 */ "table_options ::= table_options WATERMARK duration_list", - /* 199 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", - /* 200 */ "table_options ::= table_options TTL NK_INTEGER", - /* 201 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 202 */ "table_options ::= table_options DELETE_MARK duration_list", - /* 203 */ "alter_table_options ::= alter_table_option", - /* 204 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 205 */ "alter_table_option ::= COMMENT NK_STRING", - /* 206 */ "alter_table_option ::= TTL NK_INTEGER", - /* 207 */ "duration_list ::= duration_literal", - /* 208 */ "duration_list ::= duration_list NK_COMMA duration_literal", - /* 209 */ "rollup_func_list ::= rollup_func_name", - /* 210 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", - /* 211 */ "rollup_func_name ::= function_name", - /* 212 */ "rollup_func_name ::= FIRST", - /* 213 */ "rollup_func_name ::= LAST", - /* 214 */ "col_name_list ::= col_name", - /* 215 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 216 */ "col_name ::= column_name", - /* 217 */ "cmd ::= SHOW DNODES", - /* 218 */ "cmd ::= SHOW USERS", - /* 219 */ "cmd ::= SHOW USER PRIVILEGES", - /* 220 */ "cmd ::= SHOW DATABASES", - /* 221 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", - /* 222 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 223 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 224 */ "cmd ::= SHOW MNODES", - /* 225 */ "cmd ::= SHOW QNODES", - /* 226 */ "cmd ::= SHOW FUNCTIONS", - /* 227 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 228 */ "cmd ::= SHOW STREAMS", - /* 229 */ "cmd ::= SHOW ACCOUNTS", - /* 230 */ "cmd ::= SHOW APPS", - /* 231 */ "cmd ::= SHOW CONNECTIONS", - /* 232 */ "cmd ::= SHOW LICENCES", - /* 233 */ "cmd ::= SHOW GRANTS", - /* 234 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 235 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 236 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 237 */ "cmd ::= SHOW QUERIES", - /* 238 */ "cmd ::= SHOW SCORES", - /* 239 */ "cmd ::= SHOW TOPICS", - /* 240 */ "cmd ::= SHOW VARIABLES", - /* 241 */ "cmd ::= SHOW CLUSTER VARIABLES", - /* 242 */ "cmd ::= SHOW LOCAL VARIABLES", - /* 243 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt", - /* 244 */ "cmd ::= SHOW BNODES", - /* 245 */ "cmd ::= SHOW SNODES", - /* 246 */ "cmd ::= SHOW CLUSTER", - /* 247 */ "cmd ::= SHOW TRANSACTIONS", - /* 248 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", - /* 249 */ "cmd ::= SHOW CONSUMERS", - /* 250 */ "cmd ::= SHOW SUBSCRIPTIONS", - /* 251 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", - /* 252 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", - /* 253 */ "cmd ::= SHOW VNODES NK_INTEGER", - /* 254 */ "cmd ::= SHOW VNODES NK_STRING", - /* 255 */ "cmd ::= SHOW db_name_cond_opt ALIVE", - /* 256 */ "cmd ::= SHOW CLUSTER ALIVE", - /* 257 */ "db_name_cond_opt ::=", - /* 258 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 259 */ "like_pattern_opt ::=", - /* 260 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 261 */ "table_name_cond ::= table_name", - /* 262 */ "from_db_opt ::=", - /* 263 */ "from_db_opt ::= FROM db_name", - /* 264 */ "tag_list_opt ::=", - /* 265 */ "tag_list_opt ::= tag_item", - /* 266 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", - /* 267 */ "tag_item ::= TBNAME", - /* 268 */ "tag_item ::= QTAGS", - /* 269 */ "tag_item ::= column_name", - /* 270 */ "tag_item ::= column_name column_alias", - /* 271 */ "tag_item ::= column_name AS column_alias", - /* 272 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options", - /* 273 */ "cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP", - /* 274 */ "cmd ::= DROP INDEX exists_opt full_index_name", - /* 275 */ "full_index_name ::= index_name", - /* 276 */ "full_index_name ::= db_name NK_DOT index_name", - /* 277 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 278 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt", - /* 279 */ "func_list ::= func", - /* 280 */ "func_list ::= func_list NK_COMMA func", - /* 281 */ "func ::= sma_func_name NK_LP expression_list NK_RP", - /* 282 */ "sma_func_name ::= function_name", - /* 283 */ "sma_func_name ::= COUNT", - /* 284 */ "sma_func_name ::= FIRST", - /* 285 */ "sma_func_name ::= LAST", - /* 286 */ "sma_func_name ::= LAST_ROW", - /* 287 */ "sma_stream_opt ::=", - /* 288 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", - /* 289 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", - /* 290 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", - /* 291 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", - /* 292 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", - /* 293 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", - /* 294 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", - /* 295 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", - /* 296 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 297 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 298 */ "cmd ::= DESC full_table_name", - /* 299 */ "cmd ::= DESCRIBE full_table_name", - /* 300 */ "cmd ::= RESET QUERY CACHE", - /* 301 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", - /* 302 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", - /* 303 */ "analyze_opt ::=", - /* 304 */ "analyze_opt ::= ANALYZE", - /* 305 */ "explain_options ::=", - /* 306 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 307 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 308 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt", - /* 309 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 310 */ "agg_func_opt ::=", - /* 311 */ "agg_func_opt ::= AGGREGATE", - /* 312 */ "bufsize_opt ::=", - /* 313 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 314 */ "language_opt ::=", - /* 315 */ "language_opt ::= LANGUAGE NK_STRING", - /* 316 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery", - /* 317 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 318 */ "col_list_opt ::=", - /* 319 */ "col_list_opt ::= NK_LP col_name_list NK_RP", - /* 320 */ "tag_def_or_ref_opt ::=", - /* 321 */ "tag_def_or_ref_opt ::= tags_def", - /* 322 */ "tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP", - /* 323 */ "stream_options ::=", - /* 324 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 325 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 326 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 327 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 328 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 329 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", - /* 330 */ "stream_options ::= stream_options DELETE_MARK duration_literal", - /* 331 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", - /* 332 */ "subtable_opt ::=", - /* 333 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 334 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 335 */ "cmd ::= KILL QUERY NK_STRING", - /* 336 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 337 */ "cmd ::= BALANCE VGROUP", - /* 338 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 339 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 340 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 341 */ "dnode_list ::= DNODE NK_INTEGER", - /* 342 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 343 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 344 */ "cmd ::= query_or_subquery", - /* 345 */ "cmd ::= insert_query", - /* 346 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 347 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", - /* 348 */ "literal ::= NK_INTEGER", - /* 349 */ "literal ::= NK_FLOAT", - /* 350 */ "literal ::= NK_STRING", - /* 351 */ "literal ::= NK_BOOL", - /* 352 */ "literal ::= TIMESTAMP NK_STRING", - /* 353 */ "literal ::= duration_literal", - /* 354 */ "literal ::= NULL", - /* 355 */ "literal ::= NK_QUESTION", - /* 356 */ "duration_literal ::= NK_VARIABLE", - /* 357 */ "signed ::= NK_INTEGER", - /* 358 */ "signed ::= NK_PLUS NK_INTEGER", - /* 359 */ "signed ::= NK_MINUS NK_INTEGER", - /* 360 */ "signed ::= NK_FLOAT", - /* 361 */ "signed ::= NK_PLUS NK_FLOAT", - /* 362 */ "signed ::= NK_MINUS NK_FLOAT", - /* 363 */ "signed_literal ::= signed", - /* 364 */ "signed_literal ::= NK_STRING", - /* 365 */ "signed_literal ::= NK_BOOL", - /* 366 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 367 */ "signed_literal ::= duration_literal", - /* 368 */ "signed_literal ::= NULL", - /* 369 */ "signed_literal ::= literal_func", - /* 370 */ "signed_literal ::= NK_QUESTION", - /* 371 */ "literal_list ::= signed_literal", - /* 372 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 373 */ "db_name ::= NK_ID", - /* 374 */ "table_name ::= NK_ID", - /* 375 */ "column_name ::= NK_ID", - /* 376 */ "function_name ::= NK_ID", - /* 377 */ "table_alias ::= NK_ID", - /* 378 */ "column_alias ::= NK_ID", - /* 379 */ "user_name ::= NK_ID", - /* 380 */ "topic_name ::= NK_ID", - /* 381 */ "stream_name ::= NK_ID", - /* 382 */ "cgroup_name ::= NK_ID", - /* 383 */ "index_name ::= NK_ID", - /* 384 */ "expr_or_subquery ::= expression", - /* 385 */ "expression ::= literal", - /* 386 */ "expression ::= pseudo_column", - /* 387 */ "expression ::= column_reference", - /* 388 */ "expression ::= function_expression", - /* 389 */ "expression ::= case_when_expression", - /* 390 */ "expression ::= NK_LP expression NK_RP", - /* 391 */ "expression ::= NK_PLUS expr_or_subquery", - /* 392 */ "expression ::= NK_MINUS expr_or_subquery", - /* 393 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 394 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 395 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 396 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 397 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 398 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 399 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 400 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 401 */ "expression_list ::= expr_or_subquery", - /* 402 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 403 */ "column_reference ::= column_name", - /* 404 */ "column_reference ::= table_name NK_DOT column_name", - /* 405 */ "pseudo_column ::= ROWTS", - /* 406 */ "pseudo_column ::= TBNAME", - /* 407 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 408 */ "pseudo_column ::= QSTART", - /* 409 */ "pseudo_column ::= QEND", - /* 410 */ "pseudo_column ::= QDURATION", - /* 411 */ "pseudo_column ::= WSTART", - /* 412 */ "pseudo_column ::= WEND", - /* 413 */ "pseudo_column ::= WDURATION", - /* 414 */ "pseudo_column ::= IROWTS", - /* 415 */ "pseudo_column ::= ISFILLED", - /* 416 */ "pseudo_column ::= QTAGS", - /* 417 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 418 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 419 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 420 */ "function_expression ::= literal_func", - /* 421 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 422 */ "literal_func ::= NOW", - /* 423 */ "noarg_func ::= NOW", - /* 424 */ "noarg_func ::= TODAY", - /* 425 */ "noarg_func ::= TIMEZONE", - /* 426 */ "noarg_func ::= DATABASE", - /* 427 */ "noarg_func ::= CLIENT_VERSION", - /* 428 */ "noarg_func ::= SERVER_VERSION", - /* 429 */ "noarg_func ::= SERVER_STATUS", - /* 430 */ "noarg_func ::= CURRENT_USER", - /* 431 */ "noarg_func ::= USER", - /* 432 */ "star_func ::= COUNT", - /* 433 */ "star_func ::= FIRST", - /* 434 */ "star_func ::= LAST", - /* 435 */ "star_func ::= LAST_ROW", - /* 436 */ "star_func_para_list ::= NK_STAR", - /* 437 */ "star_func_para_list ::= other_para_list", - /* 438 */ "other_para_list ::= star_func_para", - /* 439 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 440 */ "star_func_para ::= expr_or_subquery", - /* 441 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 442 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 443 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 444 */ "when_then_list ::= when_then_expr", - /* 445 */ "when_then_list ::= when_then_list when_then_expr", - /* 446 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 447 */ "case_when_else_opt ::=", - /* 448 */ "case_when_else_opt ::= ELSE common_expression", - /* 449 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 450 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 451 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 452 */ "predicate ::= expr_or_subquery IS NULL", - /* 453 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 454 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 455 */ "compare_op ::= NK_LT", - /* 456 */ "compare_op ::= NK_GT", - /* 457 */ "compare_op ::= NK_LE", - /* 458 */ "compare_op ::= NK_GE", - /* 459 */ "compare_op ::= NK_NE", - /* 460 */ "compare_op ::= NK_EQ", - /* 461 */ "compare_op ::= LIKE", - /* 462 */ "compare_op ::= NOT LIKE", - /* 463 */ "compare_op ::= MATCH", - /* 464 */ "compare_op ::= NMATCH", - /* 465 */ "compare_op ::= CONTAINS", - /* 466 */ "in_op ::= IN", - /* 467 */ "in_op ::= NOT IN", - /* 468 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 469 */ "boolean_value_expression ::= boolean_primary", - /* 470 */ "boolean_value_expression ::= NOT boolean_primary", - /* 471 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 472 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 473 */ "boolean_primary ::= predicate", - /* 474 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 475 */ "common_expression ::= expr_or_subquery", - /* 476 */ "common_expression ::= boolean_value_expression", - /* 477 */ "from_clause_opt ::=", - /* 478 */ "from_clause_opt ::= FROM table_reference_list", - /* 479 */ "table_reference_list ::= table_reference", - /* 480 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 481 */ "table_reference ::= table_primary", - /* 482 */ "table_reference ::= joined_table", - /* 483 */ "table_primary ::= table_name alias_opt", - /* 484 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 485 */ "table_primary ::= subquery alias_opt", - /* 486 */ "table_primary ::= parenthesized_joined_table", - /* 487 */ "alias_opt ::=", - /* 488 */ "alias_opt ::= table_alias", - /* 489 */ "alias_opt ::= AS table_alias", - /* 490 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 491 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 492 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 493 */ "join_type ::=", - /* 494 */ "join_type ::= INNER", - /* 495 */ "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", - /* 496 */ "set_quantifier_opt ::=", - /* 497 */ "set_quantifier_opt ::= DISTINCT", - /* 498 */ "set_quantifier_opt ::= ALL", - /* 499 */ "select_list ::= select_item", - /* 500 */ "select_list ::= select_list NK_COMMA select_item", - /* 501 */ "select_item ::= NK_STAR", - /* 502 */ "select_item ::= common_expression", - /* 503 */ "select_item ::= common_expression column_alias", - /* 504 */ "select_item ::= common_expression AS column_alias", - /* 505 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 506 */ "where_clause_opt ::=", - /* 507 */ "where_clause_opt ::= WHERE search_condition", - /* 508 */ "partition_by_clause_opt ::=", - /* 509 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 510 */ "partition_list ::= partition_item", - /* 511 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 512 */ "partition_item ::= expr_or_subquery", - /* 513 */ "partition_item ::= expr_or_subquery column_alias", - /* 514 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 515 */ "twindow_clause_opt ::=", - /* 516 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 517 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 518 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 519 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 520 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", - /* 521 */ "sliding_opt ::=", - /* 522 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 523 */ "fill_opt ::=", - /* 524 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 525 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 526 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP", - /* 527 */ "fill_mode ::= NONE", - /* 528 */ "fill_mode ::= PREV", - /* 529 */ "fill_mode ::= NULL", - /* 530 */ "fill_mode ::= NULL_F", - /* 531 */ "fill_mode ::= LINEAR", - /* 532 */ "fill_mode ::= NEXT", - /* 533 */ "group_by_clause_opt ::=", - /* 534 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 535 */ "group_by_list ::= expr_or_subquery", - /* 536 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 537 */ "having_clause_opt ::=", - /* 538 */ "having_clause_opt ::= HAVING search_condition", - /* 539 */ "range_opt ::=", - /* 540 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 541 */ "every_opt ::=", - /* 542 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 543 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 544 */ "query_simple ::= query_specification", - /* 545 */ "query_simple ::= union_query_expression", - /* 546 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 547 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 548 */ "query_simple_or_subquery ::= query_simple", - /* 549 */ "query_simple_or_subquery ::= subquery", - /* 550 */ "query_or_subquery ::= query_expression", - /* 551 */ "query_or_subquery ::= subquery", - /* 552 */ "order_by_clause_opt ::=", - /* 553 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 554 */ "slimit_clause_opt ::=", - /* 555 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 556 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 557 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 558 */ "limit_clause_opt ::=", - /* 559 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 560 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 561 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 562 */ "subquery ::= NK_LP query_expression NK_RP", - /* 563 */ "subquery ::= NK_LP subquery NK_RP", - /* 564 */ "search_condition ::= common_expression", - /* 565 */ "sort_specification_list ::= sort_specification", - /* 566 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 567 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 568 */ "ordering_specification_opt ::=", - /* 569 */ "ordering_specification_opt ::= ASC", - /* 570 */ "ordering_specification_opt ::= DESC", - /* 571 */ "null_ordering_opt ::=", - /* 572 */ "null_ordering_opt ::= NULLS FIRST", - /* 573 */ "null_ordering_opt ::= NULLS LAST", + /* 121 */ "alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER", + /* 122 */ "alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER", + /* 123 */ "alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER", + /* 124 */ "alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER", + /* 125 */ "integer_list ::= NK_INTEGER", + /* 126 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", + /* 127 */ "variable_list ::= NK_VARIABLE", + /* 128 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", + /* 129 */ "retention_list ::= retention", + /* 130 */ "retention_list ::= retention_list NK_COMMA retention", + /* 131 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", + /* 132 */ "speed_opt ::=", + /* 133 */ "speed_opt ::= MAX_SPEED NK_INTEGER", + /* 134 */ "start_opt ::=", + /* 135 */ "start_opt ::= START WITH NK_INTEGER", + /* 136 */ "start_opt ::= START WITH NK_STRING", + /* 137 */ "start_opt ::= START WITH TIMESTAMP NK_STRING", + /* 138 */ "end_opt ::=", + /* 139 */ "end_opt ::= END WITH NK_INTEGER", + /* 140 */ "end_opt ::= END WITH NK_STRING", + /* 141 */ "end_opt ::= END WITH TIMESTAMP NK_STRING", + /* 142 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 143 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 144 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 145 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 146 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 147 */ "cmd ::= ALTER TABLE alter_table_clause", + /* 148 */ "cmd ::= ALTER STABLE alter_table_clause", + /* 149 */ "alter_table_clause ::= full_table_name alter_table_options", + /* 150 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", + /* 151 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", + /* 152 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", + /* 153 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", + /* 154 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", + /* 155 */ "alter_table_clause ::= full_table_name DROP TAG column_name", + /* 156 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", + /* 157 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", + /* 158 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", + /* 159 */ "multi_create_clause ::= create_subtable_clause", + /* 160 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 161 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options", + /* 162 */ "multi_drop_clause ::= drop_table_clause", + /* 163 */ "multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause", + /* 164 */ "drop_table_clause ::= exists_opt full_table_name", + /* 165 */ "specific_cols_opt ::=", + /* 166 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP", + /* 167 */ "full_table_name ::= table_name", + /* 168 */ "full_table_name ::= db_name NK_DOT table_name", + /* 169 */ "column_def_list ::= column_def", + /* 170 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 171 */ "column_def ::= column_name type_name", + /* 172 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 173 */ "type_name ::= BOOL", + /* 174 */ "type_name ::= TINYINT", + /* 175 */ "type_name ::= SMALLINT", + /* 176 */ "type_name ::= INT", + /* 177 */ "type_name ::= INTEGER", + /* 178 */ "type_name ::= BIGINT", + /* 179 */ "type_name ::= FLOAT", + /* 180 */ "type_name ::= DOUBLE", + /* 181 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 182 */ "type_name ::= TIMESTAMP", + /* 183 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 184 */ "type_name ::= TINYINT UNSIGNED", + /* 185 */ "type_name ::= SMALLINT UNSIGNED", + /* 186 */ "type_name ::= INT UNSIGNED", + /* 187 */ "type_name ::= BIGINT UNSIGNED", + /* 188 */ "type_name ::= JSON", + /* 189 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 190 */ "type_name ::= MEDIUMBLOB", + /* 191 */ "type_name ::= BLOB", + /* 192 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 193 */ "type_name ::= DECIMAL", + /* 194 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 195 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 196 */ "tags_def_opt ::=", + /* 197 */ "tags_def_opt ::= tags_def", + /* 198 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 199 */ "table_options ::=", + /* 200 */ "table_options ::= table_options COMMENT NK_STRING", + /* 201 */ "table_options ::= table_options MAX_DELAY duration_list", + /* 202 */ "table_options ::= table_options WATERMARK duration_list", + /* 203 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP", + /* 204 */ "table_options ::= table_options TTL NK_INTEGER", + /* 205 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 206 */ "table_options ::= table_options DELETE_MARK duration_list", + /* 207 */ "alter_table_options ::= alter_table_option", + /* 208 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 209 */ "alter_table_option ::= COMMENT NK_STRING", + /* 210 */ "alter_table_option ::= TTL NK_INTEGER", + /* 211 */ "duration_list ::= duration_literal", + /* 212 */ "duration_list ::= duration_list NK_COMMA duration_literal", + /* 213 */ "rollup_func_list ::= rollup_func_name", + /* 214 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name", + /* 215 */ "rollup_func_name ::= function_name", + /* 216 */ "rollup_func_name ::= FIRST", + /* 217 */ "rollup_func_name ::= LAST", + /* 218 */ "col_name_list ::= col_name", + /* 219 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 220 */ "col_name ::= column_name", + /* 221 */ "cmd ::= SHOW DNODES", + /* 222 */ "cmd ::= SHOW USERS", + /* 223 */ "cmd ::= SHOW USER PRIVILEGES", + /* 224 */ "cmd ::= SHOW DATABASES", + /* 225 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", + /* 226 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", + /* 227 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", + /* 228 */ "cmd ::= SHOW MNODES", + /* 229 */ "cmd ::= SHOW QNODES", + /* 230 */ "cmd ::= SHOW FUNCTIONS", + /* 231 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 232 */ "cmd ::= SHOW STREAMS", + /* 233 */ "cmd ::= SHOW ACCOUNTS", + /* 234 */ "cmd ::= SHOW APPS", + /* 235 */ "cmd ::= SHOW CONNECTIONS", + /* 236 */ "cmd ::= SHOW LICENCES", + /* 237 */ "cmd ::= SHOW GRANTS", + /* 238 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 239 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 240 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 241 */ "cmd ::= SHOW QUERIES", + /* 242 */ "cmd ::= SHOW SCORES", + /* 243 */ "cmd ::= SHOW TOPICS", + /* 244 */ "cmd ::= SHOW VARIABLES", + /* 245 */ "cmd ::= SHOW CLUSTER VARIABLES", + /* 246 */ "cmd ::= SHOW LOCAL VARIABLES", + /* 247 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt", + /* 248 */ "cmd ::= SHOW BNODES", + /* 249 */ "cmd ::= SHOW SNODES", + /* 250 */ "cmd ::= SHOW CLUSTER", + /* 251 */ "cmd ::= SHOW TRANSACTIONS", + /* 252 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", + /* 253 */ "cmd ::= SHOW CONSUMERS", + /* 254 */ "cmd ::= SHOW SUBSCRIPTIONS", + /* 255 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", + /* 256 */ "cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt", + /* 257 */ "cmd ::= SHOW VNODES NK_INTEGER", + /* 258 */ "cmd ::= SHOW VNODES NK_STRING", + /* 259 */ "cmd ::= SHOW db_name_cond_opt ALIVE", + /* 260 */ "cmd ::= SHOW CLUSTER ALIVE", + /* 261 */ "db_name_cond_opt ::=", + /* 262 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 263 */ "like_pattern_opt ::=", + /* 264 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 265 */ "table_name_cond ::= table_name", + /* 266 */ "from_db_opt ::=", + /* 267 */ "from_db_opt ::= FROM db_name", + /* 268 */ "tag_list_opt ::=", + /* 269 */ "tag_list_opt ::= tag_item", + /* 270 */ "tag_list_opt ::= tag_list_opt NK_COMMA tag_item", + /* 271 */ "tag_item ::= TBNAME", + /* 272 */ "tag_item ::= QTAGS", + /* 273 */ "tag_item ::= column_name", + /* 274 */ "tag_item ::= column_name column_alias", + /* 275 */ "tag_item ::= column_name AS column_alias", + /* 276 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options", + /* 277 */ "cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP", + /* 278 */ "cmd ::= DROP INDEX exists_opt full_index_name", + /* 279 */ "full_index_name ::= index_name", + /* 280 */ "full_index_name ::= db_name NK_DOT index_name", + /* 281 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 282 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt", + /* 283 */ "func_list ::= func", + /* 284 */ "func_list ::= func_list NK_COMMA func", + /* 285 */ "func ::= sma_func_name NK_LP expression_list NK_RP", + /* 286 */ "sma_func_name ::= function_name", + /* 287 */ "sma_func_name ::= COUNT", + /* 288 */ "sma_func_name ::= FIRST", + /* 289 */ "sma_func_name ::= LAST", + /* 290 */ "sma_func_name ::= LAST_ROW", + /* 291 */ "sma_stream_opt ::=", + /* 292 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", + /* 293 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", + /* 294 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", + /* 295 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", + /* 296 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", + /* 297 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", + /* 298 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", + /* 299 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", + /* 300 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 301 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 302 */ "cmd ::= DESC full_table_name", + /* 303 */ "cmd ::= DESCRIBE full_table_name", + /* 304 */ "cmd ::= RESET QUERY CACHE", + /* 305 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", + /* 306 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", + /* 307 */ "analyze_opt ::=", + /* 308 */ "analyze_opt ::= ANALYZE", + /* 309 */ "explain_options ::=", + /* 310 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 311 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 312 */ "cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt", + /* 313 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 314 */ "agg_func_opt ::=", + /* 315 */ "agg_func_opt ::= AGGREGATE", + /* 316 */ "bufsize_opt ::=", + /* 317 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 318 */ "language_opt ::=", + /* 319 */ "language_opt ::= LANGUAGE NK_STRING", + /* 320 */ "or_replace_opt ::=", + /* 321 */ "or_replace_opt ::= OR REPLACE", + /* 322 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery", + /* 323 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 324 */ "col_list_opt ::=", + /* 325 */ "col_list_opt ::= NK_LP col_name_list NK_RP", + /* 326 */ "tag_def_or_ref_opt ::=", + /* 327 */ "tag_def_or_ref_opt ::= tags_def", + /* 328 */ "tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP", + /* 329 */ "stream_options ::=", + /* 330 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 331 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 332 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 333 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 334 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", + /* 335 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", + /* 336 */ "stream_options ::= stream_options DELETE_MARK duration_literal", + /* 337 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", + /* 338 */ "subtable_opt ::=", + /* 339 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 340 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 341 */ "cmd ::= KILL QUERY NK_STRING", + /* 342 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 343 */ "cmd ::= BALANCE VGROUP", + /* 344 */ "cmd ::= BALANCE VGROUP LEADER", + /* 345 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 346 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 347 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 348 */ "dnode_list ::= DNODE NK_INTEGER", + /* 349 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 350 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 351 */ "cmd ::= query_or_subquery", + /* 352 */ "cmd ::= insert_query", + /* 353 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 354 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", + /* 355 */ "literal ::= NK_INTEGER", + /* 356 */ "literal ::= NK_FLOAT", + /* 357 */ "literal ::= NK_STRING", + /* 358 */ "literal ::= NK_BOOL", + /* 359 */ "literal ::= TIMESTAMP NK_STRING", + /* 360 */ "literal ::= duration_literal", + /* 361 */ "literal ::= NULL", + /* 362 */ "literal ::= NK_QUESTION", + /* 363 */ "duration_literal ::= NK_VARIABLE", + /* 364 */ "signed ::= NK_INTEGER", + /* 365 */ "signed ::= NK_PLUS NK_INTEGER", + /* 366 */ "signed ::= NK_MINUS NK_INTEGER", + /* 367 */ "signed ::= NK_FLOAT", + /* 368 */ "signed ::= NK_PLUS NK_FLOAT", + /* 369 */ "signed ::= NK_MINUS NK_FLOAT", + /* 370 */ "signed_literal ::= signed", + /* 371 */ "signed_literal ::= NK_STRING", + /* 372 */ "signed_literal ::= NK_BOOL", + /* 373 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 374 */ "signed_literal ::= duration_literal", + /* 375 */ "signed_literal ::= NULL", + /* 376 */ "signed_literal ::= literal_func", + /* 377 */ "signed_literal ::= NK_QUESTION", + /* 378 */ "literal_list ::= signed_literal", + /* 379 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 380 */ "db_name ::= NK_ID", + /* 381 */ "table_name ::= NK_ID", + /* 382 */ "column_name ::= NK_ID", + /* 383 */ "function_name ::= NK_ID", + /* 384 */ "table_alias ::= NK_ID", + /* 385 */ "column_alias ::= NK_ID", + /* 386 */ "user_name ::= NK_ID", + /* 387 */ "topic_name ::= NK_ID", + /* 388 */ "stream_name ::= NK_ID", + /* 389 */ "cgroup_name ::= NK_ID", + /* 390 */ "index_name ::= NK_ID", + /* 391 */ "expr_or_subquery ::= expression", + /* 392 */ "expression ::= literal", + /* 393 */ "expression ::= pseudo_column", + /* 394 */ "expression ::= column_reference", + /* 395 */ "expression ::= function_expression", + /* 396 */ "expression ::= case_when_expression", + /* 397 */ "expression ::= NK_LP expression NK_RP", + /* 398 */ "expression ::= NK_PLUS expr_or_subquery", + /* 399 */ "expression ::= NK_MINUS expr_or_subquery", + /* 400 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 401 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 402 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 403 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 404 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 405 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 406 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 407 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 408 */ "expression_list ::= expr_or_subquery", + /* 409 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 410 */ "column_reference ::= column_name", + /* 411 */ "column_reference ::= table_name NK_DOT column_name", + /* 412 */ "pseudo_column ::= ROWTS", + /* 413 */ "pseudo_column ::= TBNAME", + /* 414 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 415 */ "pseudo_column ::= QSTART", + /* 416 */ "pseudo_column ::= QEND", + /* 417 */ "pseudo_column ::= QDURATION", + /* 418 */ "pseudo_column ::= WSTART", + /* 419 */ "pseudo_column ::= WEND", + /* 420 */ "pseudo_column ::= WDURATION", + /* 421 */ "pseudo_column ::= IROWTS", + /* 422 */ "pseudo_column ::= ISFILLED", + /* 423 */ "pseudo_column ::= QTAGS", + /* 424 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 425 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 426 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 427 */ "function_expression ::= literal_func", + /* 428 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 429 */ "literal_func ::= NOW", + /* 430 */ "noarg_func ::= NOW", + /* 431 */ "noarg_func ::= TODAY", + /* 432 */ "noarg_func ::= TIMEZONE", + /* 433 */ "noarg_func ::= DATABASE", + /* 434 */ "noarg_func ::= CLIENT_VERSION", + /* 435 */ "noarg_func ::= SERVER_VERSION", + /* 436 */ "noarg_func ::= SERVER_STATUS", + /* 437 */ "noarg_func ::= CURRENT_USER", + /* 438 */ "noarg_func ::= USER", + /* 439 */ "star_func ::= COUNT", + /* 440 */ "star_func ::= FIRST", + /* 441 */ "star_func ::= LAST", + /* 442 */ "star_func ::= LAST_ROW", + /* 443 */ "star_func_para_list ::= NK_STAR", + /* 444 */ "star_func_para_list ::= other_para_list", + /* 445 */ "other_para_list ::= star_func_para", + /* 446 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 447 */ "star_func_para ::= expr_or_subquery", + /* 448 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 449 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 450 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 451 */ "when_then_list ::= when_then_expr", + /* 452 */ "when_then_list ::= when_then_list when_then_expr", + /* 453 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 454 */ "case_when_else_opt ::=", + /* 455 */ "case_when_else_opt ::= ELSE common_expression", + /* 456 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 457 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 458 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 459 */ "predicate ::= expr_or_subquery IS NULL", + /* 460 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 461 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 462 */ "compare_op ::= NK_LT", + /* 463 */ "compare_op ::= NK_GT", + /* 464 */ "compare_op ::= NK_LE", + /* 465 */ "compare_op ::= NK_GE", + /* 466 */ "compare_op ::= NK_NE", + /* 467 */ "compare_op ::= NK_EQ", + /* 468 */ "compare_op ::= LIKE", + /* 469 */ "compare_op ::= NOT LIKE", + /* 470 */ "compare_op ::= MATCH", + /* 471 */ "compare_op ::= NMATCH", + /* 472 */ "compare_op ::= CONTAINS", + /* 473 */ "in_op ::= IN", + /* 474 */ "in_op ::= NOT IN", + /* 475 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 476 */ "boolean_value_expression ::= boolean_primary", + /* 477 */ "boolean_value_expression ::= NOT boolean_primary", + /* 478 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 479 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 480 */ "boolean_primary ::= predicate", + /* 481 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 482 */ "common_expression ::= expr_or_subquery", + /* 483 */ "common_expression ::= boolean_value_expression", + /* 484 */ "from_clause_opt ::=", + /* 485 */ "from_clause_opt ::= FROM table_reference_list", + /* 486 */ "table_reference_list ::= table_reference", + /* 487 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 488 */ "table_reference ::= table_primary", + /* 489 */ "table_reference ::= joined_table", + /* 490 */ "table_primary ::= table_name alias_opt", + /* 491 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 492 */ "table_primary ::= subquery alias_opt", + /* 493 */ "table_primary ::= parenthesized_joined_table", + /* 494 */ "alias_opt ::=", + /* 495 */ "alias_opt ::= table_alias", + /* 496 */ "alias_opt ::= AS table_alias", + /* 497 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 498 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 499 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 500 */ "join_type ::=", + /* 501 */ "join_type ::= INNER", + /* 502 */ "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", + /* 503 */ "set_quantifier_opt ::=", + /* 504 */ "set_quantifier_opt ::= DISTINCT", + /* 505 */ "set_quantifier_opt ::= ALL", + /* 506 */ "select_list ::= select_item", + /* 507 */ "select_list ::= select_list NK_COMMA select_item", + /* 508 */ "select_item ::= NK_STAR", + /* 509 */ "select_item ::= common_expression", + /* 510 */ "select_item ::= common_expression column_alias", + /* 511 */ "select_item ::= common_expression AS column_alias", + /* 512 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 513 */ "where_clause_opt ::=", + /* 514 */ "where_clause_opt ::= WHERE search_condition", + /* 515 */ "partition_by_clause_opt ::=", + /* 516 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 517 */ "partition_list ::= partition_item", + /* 518 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 519 */ "partition_item ::= expr_or_subquery", + /* 520 */ "partition_item ::= expr_or_subquery column_alias", + /* 521 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 522 */ "twindow_clause_opt ::=", + /* 523 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 524 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 525 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 526 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 527 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", + /* 528 */ "sliding_opt ::=", + /* 529 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 530 */ "fill_opt ::=", + /* 531 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 532 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 533 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP", + /* 534 */ "fill_mode ::= NONE", + /* 535 */ "fill_mode ::= PREV", + /* 536 */ "fill_mode ::= NULL", + /* 537 */ "fill_mode ::= NULL_F", + /* 538 */ "fill_mode ::= LINEAR", + /* 539 */ "fill_mode ::= NEXT", + /* 540 */ "group_by_clause_opt ::=", + /* 541 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 542 */ "group_by_list ::= expr_or_subquery", + /* 543 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 544 */ "having_clause_opt ::=", + /* 545 */ "having_clause_opt ::= HAVING search_condition", + /* 546 */ "range_opt ::=", + /* 547 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 548 */ "every_opt ::=", + /* 549 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 550 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 551 */ "query_simple ::= query_specification", + /* 552 */ "query_simple ::= union_query_expression", + /* 553 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 554 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 555 */ "query_simple_or_subquery ::= query_simple", + /* 556 */ "query_simple_or_subquery ::= subquery", + /* 557 */ "query_or_subquery ::= query_expression", + /* 558 */ "query_or_subquery ::= subquery", + /* 559 */ "order_by_clause_opt ::=", + /* 560 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 561 */ "slimit_clause_opt ::=", + /* 562 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 563 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 564 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 565 */ "limit_clause_opt ::=", + /* 566 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 567 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 568 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 569 */ "subquery ::= NK_LP query_expression NK_RP", + /* 570 */ "subquery ::= NK_LP subquery NK_RP", + /* 571 */ "search_condition ::= common_expression", + /* 572 */ "sort_specification_list ::= sort_specification", + /* 573 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 574 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 575 */ "ordering_specification_opt ::=", + /* 576 */ "ordering_specification_opt ::= ASC", + /* 577 */ "ordering_specification_opt ::= DESC", + /* 578 */ "null_ordering_opt ::=", + /* 579 */ "null_ordering_opt ::= NULLS FIRST", + /* 580 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2598,202 +2662,203 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 329: /* cmd */ - case 332: /* literal */ - case 345: /* db_options */ - case 347: /* alter_db_options */ - case 349: /* start_opt */ - case 350: /* end_opt */ - case 355: /* retention */ - case 356: /* full_table_name */ - case 359: /* table_options */ - case 363: /* alter_table_clause */ - case 364: /* alter_table_options */ - case 367: /* signed_literal */ - case 368: /* create_subtable_clause */ - case 371: /* drop_table_clause */ - case 374: /* column_def */ - case 378: /* duration_literal */ - case 379: /* rollup_func_name */ - case 381: /* col_name */ - case 382: /* db_name_cond_opt */ - case 383: /* like_pattern_opt */ - case 384: /* table_name_cond */ - case 385: /* from_db_opt */ - case 387: /* tag_item */ - case 389: /* full_index_name */ - case 390: /* index_options */ - case 393: /* sliding_opt */ - case 394: /* sma_stream_opt */ - case 395: /* func */ - case 397: /* query_or_subquery */ - case 400: /* explain_options */ - case 401: /* insert_query */ - case 406: /* stream_options */ - case 409: /* subtable_opt */ - case 410: /* expression */ - case 412: /* where_clause_opt */ - case 413: /* signed */ - case 414: /* literal_func */ - case 417: /* expr_or_subquery */ - case 418: /* pseudo_column */ - case 419: /* column_reference */ - case 420: /* function_expression */ - case 421: /* case_when_expression */ - case 426: /* star_func_para */ - case 428: /* case_when_else_opt */ - case 429: /* common_expression */ - case 430: /* when_then_expr */ - case 431: /* predicate */ - case 434: /* in_predicate_value */ - case 435: /* boolean_value_expression */ - case 436: /* boolean_primary */ - case 437: /* from_clause_opt */ - case 438: /* table_reference_list */ - case 439: /* table_reference */ - case 440: /* table_primary */ - case 441: /* joined_table */ - case 443: /* subquery */ - case 444: /* parenthesized_joined_table */ - case 446: /* search_condition */ - case 447: /* query_specification */ - case 451: /* range_opt */ - case 452: /* every_opt */ - case 453: /* fill_opt */ - case 454: /* twindow_clause_opt */ - case 456: /* having_clause_opt */ - case 457: /* select_item */ - case 459: /* partition_item */ - case 462: /* query_expression */ - case 463: /* query_simple */ - case 465: /* slimit_clause_opt */ - case 466: /* limit_clause_opt */ - case 467: /* union_query_expression */ - case 468: /* query_simple_or_subquery */ - case 470: /* sort_specification */ + case 330: /* cmd */ + case 333: /* literal */ + case 346: /* db_options */ + case 348: /* alter_db_options */ + case 350: /* start_opt */ + case 351: /* end_opt */ + case 356: /* retention */ + case 357: /* full_table_name */ + case 360: /* table_options */ + case 364: /* alter_table_clause */ + case 365: /* alter_table_options */ + case 368: /* signed_literal */ + case 369: /* create_subtable_clause */ + case 372: /* drop_table_clause */ + case 375: /* column_def */ + case 379: /* duration_literal */ + case 380: /* rollup_func_name */ + case 382: /* col_name */ + case 383: /* db_name_cond_opt */ + case 384: /* like_pattern_opt */ + case 385: /* table_name_cond */ + case 386: /* from_db_opt */ + case 388: /* tag_item */ + case 390: /* full_index_name */ + case 391: /* index_options */ + case 394: /* sliding_opt */ + case 395: /* sma_stream_opt */ + case 396: /* func */ + case 398: /* query_or_subquery */ + case 401: /* explain_options */ + case 402: /* insert_query */ + case 408: /* stream_options */ + case 411: /* subtable_opt */ + case 412: /* expression */ + case 414: /* where_clause_opt */ + case 415: /* signed */ + case 416: /* literal_func */ + case 419: /* expr_or_subquery */ + case 420: /* pseudo_column */ + case 421: /* column_reference */ + case 422: /* function_expression */ + case 423: /* case_when_expression */ + case 428: /* star_func_para */ + case 430: /* case_when_else_opt */ + case 431: /* common_expression */ + case 432: /* when_then_expr */ + case 433: /* predicate */ + case 436: /* in_predicate_value */ + case 437: /* boolean_value_expression */ + case 438: /* boolean_primary */ + case 439: /* from_clause_opt */ + case 440: /* table_reference_list */ + case 441: /* table_reference */ + case 442: /* table_primary */ + case 443: /* joined_table */ + case 445: /* subquery */ + case 446: /* parenthesized_joined_table */ + case 448: /* search_condition */ + case 449: /* query_specification */ + case 453: /* range_opt */ + case 454: /* every_opt */ + case 455: /* fill_opt */ + case 456: /* twindow_clause_opt */ + case 458: /* having_clause_opt */ + case 459: /* select_item */ + case 461: /* partition_item */ + case 464: /* query_expression */ + case 465: /* query_simple */ + case 467: /* slimit_clause_opt */ + case 468: /* limit_clause_opt */ + case 469: /* union_query_expression */ + case 470: /* query_simple_or_subquery */ + case 472: /* sort_specification */ { - nodesDestroyNode((yypminor->yy828)); + nodesDestroyNode((yypminor->yy712)); } break; - case 330: /* account_options */ - case 331: /* alter_account_options */ - case 333: /* alter_account_option */ - case 348: /* speed_opt */ - case 403: /* bufsize_opt */ + case 331: /* account_options */ + case 332: /* alter_account_options */ + case 334: /* alter_account_option */ + case 349: /* speed_opt */ + case 405: /* bufsize_opt */ { } break; - case 334: /* user_name */ - case 337: /* priv_level */ - case 340: /* db_name */ - case 341: /* topic_name */ - case 342: /* dnode_endpoint */ - case 365: /* column_name */ - case 373: /* table_name */ - case 380: /* function_name */ - case 388: /* column_alias */ - case 391: /* index_name */ - case 396: /* sma_func_name */ - case 398: /* cgroup_name */ - case 404: /* language_opt */ - case 405: /* stream_name */ - case 416: /* table_alias */ - case 422: /* star_func */ - case 424: /* noarg_func */ - case 442: /* alias_opt */ + case 335: /* user_name */ + case 338: /* priv_level */ + case 341: /* db_name */ + case 342: /* topic_name */ + case 343: /* dnode_endpoint */ + case 366: /* column_name */ + case 374: /* table_name */ + case 381: /* function_name */ + case 389: /* column_alias */ + case 392: /* index_name */ + case 397: /* sma_func_name */ + case 399: /* cgroup_name */ + case 406: /* language_opt */ + case 407: /* stream_name */ + case 418: /* table_alias */ + case 424: /* star_func */ + case 426: /* noarg_func */ + case 444: /* alias_opt */ { } break; - case 335: /* sysinfo_opt */ + case 336: /* sysinfo_opt */ { } break; - case 336: /* privileges */ - case 338: /* priv_type_list */ - case 339: /* priv_type */ + case 337: /* privileges */ + case 339: /* priv_type_list */ + case 340: /* priv_type */ { } break; - case 343: /* force_opt */ - case 344: /* not_exists_opt */ - case 346: /* exists_opt */ - case 399: /* analyze_opt */ - case 402: /* agg_func_opt */ - case 448: /* set_quantifier_opt */ + case 344: /* force_opt */ + case 345: /* not_exists_opt */ + case 347: /* exists_opt */ + case 400: /* analyze_opt */ + case 403: /* or_replace_opt */ + case 404: /* agg_func_opt */ + case 450: /* set_quantifier_opt */ { } break; - case 351: /* integer_list */ - case 352: /* variable_list */ - case 353: /* retention_list */ - case 357: /* column_def_list */ - case 358: /* tags_def_opt */ - case 360: /* multi_create_clause */ - case 361: /* tags_def */ - case 362: /* multi_drop_clause */ - case 369: /* specific_cols_opt */ - case 370: /* expression_list */ - case 372: /* col_name_list */ - case 375: /* duration_list */ - case 376: /* rollup_func_list */ - case 386: /* tag_list_opt */ - case 392: /* func_list */ - case 407: /* col_list_opt */ - case 408: /* tag_def_or_ref_opt */ - case 411: /* dnode_list */ - case 415: /* literal_list */ - case 423: /* star_func_para_list */ - case 425: /* other_para_list */ - case 427: /* when_then_list */ - case 449: /* select_list */ - case 450: /* partition_by_clause_opt */ - case 455: /* group_by_clause_opt */ - case 458: /* partition_list */ - case 461: /* group_by_list */ - case 464: /* order_by_clause_opt */ - case 469: /* sort_specification_list */ + case 352: /* integer_list */ + case 353: /* variable_list */ + case 354: /* retention_list */ + case 358: /* column_def_list */ + case 359: /* tags_def_opt */ + case 361: /* multi_create_clause */ + case 362: /* tags_def */ + case 363: /* multi_drop_clause */ + case 370: /* specific_cols_opt */ + case 371: /* expression_list */ + case 373: /* col_name_list */ + case 376: /* duration_list */ + case 377: /* rollup_func_list */ + case 387: /* tag_list_opt */ + case 393: /* func_list */ + case 409: /* col_list_opt */ + case 410: /* tag_def_or_ref_opt */ + case 413: /* dnode_list */ + case 417: /* literal_list */ + case 425: /* star_func_para_list */ + case 427: /* other_para_list */ + case 429: /* when_then_list */ + case 451: /* select_list */ + case 452: /* partition_by_clause_opt */ + case 457: /* group_by_clause_opt */ + case 460: /* partition_list */ + case 463: /* group_by_list */ + case 466: /* order_by_clause_opt */ + case 471: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy222)); + nodesDestroyList((yypminor->yy274)); } break; - case 354: /* alter_db_option */ - case 377: /* alter_table_option */ + case 355: /* alter_db_option */ + case 378: /* alter_table_option */ { } break; - case 366: /* type_name */ + case 367: /* type_name */ { } break; - case 432: /* compare_op */ - case 433: /* in_op */ + case 434: /* compare_op */ + case 435: /* in_op */ { } break; - case 445: /* join_type */ + case 447: /* join_type */ { } break; - case 460: /* fill_mode */ + case 462: /* fill_mode */ { } break; - case 471: /* ordering_specification_opt */ + case 473: /* ordering_specification_opt */ { } break; - case 472: /* null_ordering_opt */ + case 474: /* null_ordering_opt */ { } @@ -3092,580 +3157,587 @@ 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[] = { - { 329, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 329, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 330, 0 }, /* (2) account_options ::= */ - { 330, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 330, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 330, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 330, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 330, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 330, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 330, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 330, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 330, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 331, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 331, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 333, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 333, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 333, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 333, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 333, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 333, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 333, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 333, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 333, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 333, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 329, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ - { 329, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 329, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - { 329, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - { 329, -3 }, /* (28) cmd ::= DROP USER user_name */ - { 335, 0 }, /* (29) sysinfo_opt ::= */ - { 335, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ - { 329, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 329, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 336, -1 }, /* (33) privileges ::= ALL */ - { 336, -1 }, /* (34) privileges ::= priv_type_list */ - { 336, -1 }, /* (35) privileges ::= SUBSCRIBE */ - { 338, -1 }, /* (36) priv_type_list ::= priv_type */ - { 338, -3 }, /* (37) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 339, -1 }, /* (38) priv_type ::= READ */ - { 339, -1 }, /* (39) priv_type ::= WRITE */ - { 337, -3 }, /* (40) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 337, -3 }, /* (41) priv_level ::= db_name NK_DOT NK_STAR */ - { 337, -1 }, /* (42) priv_level ::= topic_name */ - { 329, -3 }, /* (43) cmd ::= CREATE DNODE dnode_endpoint */ - { 329, -5 }, /* (44) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - { 329, -4 }, /* (45) cmd ::= DROP DNODE NK_INTEGER force_opt */ - { 329, -4 }, /* (46) cmd ::= DROP DNODE dnode_endpoint force_opt */ - { 329, -4 }, /* (47) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 329, -5 }, /* (48) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 329, -4 }, /* (49) cmd ::= ALTER ALL DNODES NK_STRING */ - { 329, -5 }, /* (50) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 342, -1 }, /* (51) dnode_endpoint ::= NK_STRING */ - { 342, -1 }, /* (52) dnode_endpoint ::= NK_ID */ - { 342, -1 }, /* (53) dnode_endpoint ::= NK_IPTOKEN */ - { 343, 0 }, /* (54) force_opt ::= */ - { 343, -1 }, /* (55) force_opt ::= FORCE */ - { 329, -3 }, /* (56) cmd ::= ALTER LOCAL NK_STRING */ - { 329, -4 }, /* (57) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 329, -5 }, /* (58) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 329, -5 }, /* (59) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 329, -5 }, /* (60) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 329, -5 }, /* (61) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 329, -5 }, /* (62) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 329, -5 }, /* (63) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 329, -5 }, /* (64) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 329, -5 }, /* (65) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 329, -5 }, /* (66) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 329, -4 }, /* (67) cmd ::= DROP DATABASE exists_opt db_name */ - { 329, -2 }, /* (68) cmd ::= USE db_name */ - { 329, -4 }, /* (69) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 329, -3 }, /* (70) cmd ::= FLUSH DATABASE db_name */ - { 329, -4 }, /* (71) cmd ::= TRIM DATABASE db_name speed_opt */ - { 329, -5 }, /* (72) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ - { 344, -3 }, /* (73) not_exists_opt ::= IF NOT EXISTS */ - { 344, 0 }, /* (74) not_exists_opt ::= */ - { 346, -2 }, /* (75) exists_opt ::= IF EXISTS */ - { 346, 0 }, /* (76) exists_opt ::= */ - { 345, 0 }, /* (77) db_options ::= */ - { 345, -3 }, /* (78) db_options ::= db_options BUFFER NK_INTEGER */ - { 345, -3 }, /* (79) db_options ::= db_options CACHEMODEL NK_STRING */ - { 345, -3 }, /* (80) db_options ::= db_options CACHESIZE NK_INTEGER */ - { 345, -3 }, /* (81) db_options ::= db_options COMP NK_INTEGER */ - { 345, -3 }, /* (82) db_options ::= db_options DURATION NK_INTEGER */ - { 345, -3 }, /* (83) db_options ::= db_options DURATION NK_VARIABLE */ - { 345, -3 }, /* (84) db_options ::= db_options MAXROWS NK_INTEGER */ - { 345, -3 }, /* (85) db_options ::= db_options MINROWS NK_INTEGER */ - { 345, -3 }, /* (86) db_options ::= db_options KEEP integer_list */ - { 345, -3 }, /* (87) db_options ::= db_options KEEP variable_list */ - { 345, -3 }, /* (88) db_options ::= db_options PAGES NK_INTEGER */ - { 345, -3 }, /* (89) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 345, -3 }, /* (90) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ - { 345, -3 }, /* (91) db_options ::= db_options PRECISION NK_STRING */ - { 345, -3 }, /* (92) db_options ::= db_options REPLICA NK_INTEGER */ - { 345, -3 }, /* (93) db_options ::= db_options VGROUPS NK_INTEGER */ - { 345, -3 }, /* (94) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 345, -3 }, /* (95) db_options ::= db_options RETENTIONS retention_list */ - { 345, -3 }, /* (96) db_options ::= db_options SCHEMALESS NK_INTEGER */ - { 345, -3 }, /* (97) db_options ::= db_options WAL_LEVEL NK_INTEGER */ - { 345, -3 }, /* (98) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ - { 345, -3 }, /* (99) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ - { 345, -4 }, /* (100) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - { 345, -3 }, /* (101) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ - { 345, -4 }, /* (102) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - { 345, -3 }, /* (103) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ - { 345, -3 }, /* (104) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ - { 345, -3 }, /* (105) db_options ::= db_options STT_TRIGGER NK_INTEGER */ - { 345, -3 }, /* (106) db_options ::= db_options TABLE_PREFIX NK_INTEGER */ - { 345, -3 }, /* (107) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ - { 347, -1 }, /* (108) alter_db_options ::= alter_db_option */ - { 347, -2 }, /* (109) alter_db_options ::= alter_db_options alter_db_option */ - { 354, -2 }, /* (110) alter_db_option ::= BUFFER NK_INTEGER */ - { 354, -2 }, /* (111) alter_db_option ::= CACHEMODEL NK_STRING */ - { 354, -2 }, /* (112) alter_db_option ::= CACHESIZE NK_INTEGER */ - { 354, -2 }, /* (113) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ - { 354, -2 }, /* (114) alter_db_option ::= KEEP integer_list */ - { 354, -2 }, /* (115) alter_db_option ::= KEEP variable_list */ - { 354, -2 }, /* (116) alter_db_option ::= PAGES NK_INTEGER */ - { 354, -2 }, /* (117) alter_db_option ::= REPLICA NK_INTEGER */ - { 354, -2 }, /* (118) alter_db_option ::= WAL_LEVEL NK_INTEGER */ - { 354, -2 }, /* (119) alter_db_option ::= STT_TRIGGER NK_INTEGER */ - { 354, -2 }, /* (120) alter_db_option ::= MINROWS NK_INTEGER */ - { 351, -1 }, /* (121) integer_list ::= NK_INTEGER */ - { 351, -3 }, /* (122) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 352, -1 }, /* (123) variable_list ::= NK_VARIABLE */ - { 352, -3 }, /* (124) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 353, -1 }, /* (125) retention_list ::= retention */ - { 353, -3 }, /* (126) retention_list ::= retention_list NK_COMMA retention */ - { 355, -3 }, /* (127) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 348, 0 }, /* (128) speed_opt ::= */ - { 348, -2 }, /* (129) speed_opt ::= MAX_SPEED NK_INTEGER */ - { 349, 0 }, /* (130) start_opt ::= */ - { 349, -3 }, /* (131) start_opt ::= START WITH NK_INTEGER */ - { 349, -3 }, /* (132) start_opt ::= START WITH NK_STRING */ - { 349, -4 }, /* (133) start_opt ::= START WITH TIMESTAMP NK_STRING */ - { 350, 0 }, /* (134) end_opt ::= */ - { 350, -3 }, /* (135) end_opt ::= END WITH NK_INTEGER */ - { 350, -3 }, /* (136) end_opt ::= END WITH NK_STRING */ - { 350, -4 }, /* (137) end_opt ::= END WITH TIMESTAMP NK_STRING */ - { 329, -9 }, /* (138) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 329, -3 }, /* (139) cmd ::= CREATE TABLE multi_create_clause */ - { 329, -9 }, /* (140) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 329, -3 }, /* (141) cmd ::= DROP TABLE multi_drop_clause */ - { 329, -4 }, /* (142) cmd ::= DROP STABLE exists_opt full_table_name */ - { 329, -3 }, /* (143) cmd ::= ALTER TABLE alter_table_clause */ - { 329, -3 }, /* (144) cmd ::= ALTER STABLE alter_table_clause */ - { 363, -2 }, /* (145) alter_table_clause ::= full_table_name alter_table_options */ - { 363, -5 }, /* (146) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 363, -4 }, /* (147) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 363, -5 }, /* (148) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 363, -5 }, /* (149) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 363, -5 }, /* (150) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 363, -4 }, /* (151) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 363, -5 }, /* (152) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 363, -5 }, /* (153) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 363, -6 }, /* (154) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 360, -1 }, /* (155) multi_create_clause ::= create_subtable_clause */ - { 360, -2 }, /* (156) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 368, -10 }, /* (157) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ - { 362, -1 }, /* (158) multi_drop_clause ::= drop_table_clause */ - { 362, -3 }, /* (159) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ - { 371, -2 }, /* (160) drop_table_clause ::= exists_opt full_table_name */ - { 369, 0 }, /* (161) specific_cols_opt ::= */ - { 369, -3 }, /* (162) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - { 356, -1 }, /* (163) full_table_name ::= table_name */ - { 356, -3 }, /* (164) full_table_name ::= db_name NK_DOT table_name */ - { 357, -1 }, /* (165) column_def_list ::= column_def */ - { 357, -3 }, /* (166) column_def_list ::= column_def_list NK_COMMA column_def */ - { 374, -2 }, /* (167) column_def ::= column_name type_name */ - { 374, -4 }, /* (168) column_def ::= column_name type_name COMMENT NK_STRING */ - { 366, -1 }, /* (169) type_name ::= BOOL */ - { 366, -1 }, /* (170) type_name ::= TINYINT */ - { 366, -1 }, /* (171) type_name ::= SMALLINT */ - { 366, -1 }, /* (172) type_name ::= INT */ - { 366, -1 }, /* (173) type_name ::= INTEGER */ - { 366, -1 }, /* (174) type_name ::= BIGINT */ - { 366, -1 }, /* (175) type_name ::= FLOAT */ - { 366, -1 }, /* (176) type_name ::= DOUBLE */ - { 366, -4 }, /* (177) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 366, -1 }, /* (178) type_name ::= TIMESTAMP */ - { 366, -4 }, /* (179) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 366, -2 }, /* (180) type_name ::= TINYINT UNSIGNED */ - { 366, -2 }, /* (181) type_name ::= SMALLINT UNSIGNED */ - { 366, -2 }, /* (182) type_name ::= INT UNSIGNED */ - { 366, -2 }, /* (183) type_name ::= BIGINT UNSIGNED */ - { 366, -1 }, /* (184) type_name ::= JSON */ - { 366, -4 }, /* (185) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 366, -1 }, /* (186) type_name ::= MEDIUMBLOB */ - { 366, -1 }, /* (187) type_name ::= BLOB */ - { 366, -4 }, /* (188) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 366, -1 }, /* (189) type_name ::= DECIMAL */ - { 366, -4 }, /* (190) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 366, -6 }, /* (191) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 358, 0 }, /* (192) tags_def_opt ::= */ - { 358, -1 }, /* (193) tags_def_opt ::= tags_def */ - { 361, -4 }, /* (194) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 359, 0 }, /* (195) table_options ::= */ - { 359, -3 }, /* (196) table_options ::= table_options COMMENT NK_STRING */ - { 359, -3 }, /* (197) table_options ::= table_options MAX_DELAY duration_list */ - { 359, -3 }, /* (198) table_options ::= table_options WATERMARK duration_list */ - { 359, -5 }, /* (199) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - { 359, -3 }, /* (200) table_options ::= table_options TTL NK_INTEGER */ - { 359, -5 }, /* (201) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 359, -3 }, /* (202) table_options ::= table_options DELETE_MARK duration_list */ - { 364, -1 }, /* (203) alter_table_options ::= alter_table_option */ - { 364, -2 }, /* (204) alter_table_options ::= alter_table_options alter_table_option */ - { 377, -2 }, /* (205) alter_table_option ::= COMMENT NK_STRING */ - { 377, -2 }, /* (206) alter_table_option ::= TTL NK_INTEGER */ - { 375, -1 }, /* (207) duration_list ::= duration_literal */ - { 375, -3 }, /* (208) duration_list ::= duration_list NK_COMMA duration_literal */ - { 376, -1 }, /* (209) rollup_func_list ::= rollup_func_name */ - { 376, -3 }, /* (210) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - { 379, -1 }, /* (211) rollup_func_name ::= function_name */ - { 379, -1 }, /* (212) rollup_func_name ::= FIRST */ - { 379, -1 }, /* (213) rollup_func_name ::= LAST */ - { 372, -1 }, /* (214) col_name_list ::= col_name */ - { 372, -3 }, /* (215) col_name_list ::= col_name_list NK_COMMA col_name */ - { 381, -1 }, /* (216) col_name ::= column_name */ - { 329, -2 }, /* (217) cmd ::= SHOW DNODES */ - { 329, -2 }, /* (218) cmd ::= SHOW USERS */ - { 329, -3 }, /* (219) cmd ::= SHOW USER PRIVILEGES */ - { 329, -2 }, /* (220) cmd ::= SHOW DATABASES */ - { 329, -4 }, /* (221) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 329, -4 }, /* (222) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 329, -3 }, /* (223) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 329, -2 }, /* (224) cmd ::= SHOW MNODES */ - { 329, -2 }, /* (225) cmd ::= SHOW QNODES */ - { 329, -2 }, /* (226) cmd ::= SHOW FUNCTIONS */ - { 329, -5 }, /* (227) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 329, -2 }, /* (228) cmd ::= SHOW STREAMS */ - { 329, -2 }, /* (229) cmd ::= SHOW ACCOUNTS */ - { 329, -2 }, /* (230) cmd ::= SHOW APPS */ - { 329, -2 }, /* (231) cmd ::= SHOW CONNECTIONS */ - { 329, -2 }, /* (232) cmd ::= SHOW LICENCES */ - { 329, -2 }, /* (233) cmd ::= SHOW GRANTS */ - { 329, -4 }, /* (234) cmd ::= SHOW CREATE DATABASE db_name */ - { 329, -4 }, /* (235) cmd ::= SHOW CREATE TABLE full_table_name */ - { 329, -4 }, /* (236) cmd ::= SHOW CREATE STABLE full_table_name */ - { 329, -2 }, /* (237) cmd ::= SHOW QUERIES */ - { 329, -2 }, /* (238) cmd ::= SHOW SCORES */ - { 329, -2 }, /* (239) cmd ::= SHOW TOPICS */ - { 329, -2 }, /* (240) cmd ::= SHOW VARIABLES */ - { 329, -3 }, /* (241) cmd ::= SHOW CLUSTER VARIABLES */ - { 329, -3 }, /* (242) cmd ::= SHOW LOCAL VARIABLES */ - { 329, -5 }, /* (243) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ - { 329, -2 }, /* (244) cmd ::= SHOW BNODES */ - { 329, -2 }, /* (245) cmd ::= SHOW SNODES */ - { 329, -2 }, /* (246) cmd ::= SHOW CLUSTER */ - { 329, -2 }, /* (247) cmd ::= SHOW TRANSACTIONS */ - { 329, -4 }, /* (248) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - { 329, -2 }, /* (249) cmd ::= SHOW CONSUMERS */ - { 329, -2 }, /* (250) cmd ::= SHOW SUBSCRIPTIONS */ - { 329, -5 }, /* (251) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - { 329, -7 }, /* (252) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ - { 329, -3 }, /* (253) cmd ::= SHOW VNODES NK_INTEGER */ - { 329, -3 }, /* (254) cmd ::= SHOW VNODES NK_STRING */ - { 329, -3 }, /* (255) cmd ::= SHOW db_name_cond_opt ALIVE */ - { 329, -3 }, /* (256) cmd ::= SHOW CLUSTER ALIVE */ - { 382, 0 }, /* (257) db_name_cond_opt ::= */ - { 382, -2 }, /* (258) db_name_cond_opt ::= db_name NK_DOT */ - { 383, 0 }, /* (259) like_pattern_opt ::= */ - { 383, -2 }, /* (260) like_pattern_opt ::= LIKE NK_STRING */ - { 384, -1 }, /* (261) table_name_cond ::= table_name */ - { 385, 0 }, /* (262) from_db_opt ::= */ - { 385, -2 }, /* (263) from_db_opt ::= FROM db_name */ - { 386, 0 }, /* (264) tag_list_opt ::= */ - { 386, -1 }, /* (265) tag_list_opt ::= tag_item */ - { 386, -3 }, /* (266) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ - { 387, -1 }, /* (267) tag_item ::= TBNAME */ - { 387, -1 }, /* (268) tag_item ::= QTAGS */ - { 387, -1 }, /* (269) tag_item ::= column_name */ - { 387, -2 }, /* (270) tag_item ::= column_name column_alias */ - { 387, -3 }, /* (271) tag_item ::= column_name AS column_alias */ - { 329, -8 }, /* (272) cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */ - { 329, -9 }, /* (273) cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP */ - { 329, -4 }, /* (274) cmd ::= DROP INDEX exists_opt full_index_name */ - { 389, -1 }, /* (275) full_index_name ::= index_name */ - { 389, -3 }, /* (276) full_index_name ::= db_name NK_DOT index_name */ - { 390, -10 }, /* (277) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - { 390, -12 }, /* (278) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ - { 392, -1 }, /* (279) func_list ::= func */ - { 392, -3 }, /* (280) func_list ::= func_list NK_COMMA func */ - { 395, -4 }, /* (281) func ::= sma_func_name NK_LP expression_list NK_RP */ - { 396, -1 }, /* (282) sma_func_name ::= function_name */ - { 396, -1 }, /* (283) sma_func_name ::= COUNT */ - { 396, -1 }, /* (284) sma_func_name ::= FIRST */ - { 396, -1 }, /* (285) sma_func_name ::= LAST */ - { 396, -1 }, /* (286) sma_func_name ::= LAST_ROW */ - { 394, 0 }, /* (287) sma_stream_opt ::= */ - { 394, -3 }, /* (288) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - { 394, -3 }, /* (289) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - { 394, -3 }, /* (290) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - { 329, -6 }, /* (291) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - { 329, -7 }, /* (292) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 329, -9 }, /* (293) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ - { 329, -7 }, /* (294) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 329, -9 }, /* (295) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ - { 329, -4 }, /* (296) cmd ::= DROP TOPIC exists_opt topic_name */ - { 329, -7 }, /* (297) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 329, -2 }, /* (298) cmd ::= DESC full_table_name */ - { 329, -2 }, /* (299) cmd ::= DESCRIBE full_table_name */ - { 329, -3 }, /* (300) cmd ::= RESET QUERY CACHE */ - { 329, -4 }, /* (301) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - { 329, -4 }, /* (302) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ - { 399, 0 }, /* (303) analyze_opt ::= */ - { 399, -1 }, /* (304) analyze_opt ::= ANALYZE */ - { 400, 0 }, /* (305) explain_options ::= */ - { 400, -3 }, /* (306) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 400, -3 }, /* (307) explain_options ::= explain_options RATIO NK_FLOAT */ - { 329, -11 }, /* (308) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ - { 329, -4 }, /* (309) cmd ::= DROP FUNCTION exists_opt function_name */ - { 402, 0 }, /* (310) agg_func_opt ::= */ - { 402, -1 }, /* (311) agg_func_opt ::= AGGREGATE */ - { 403, 0 }, /* (312) bufsize_opt ::= */ - { 403, -2 }, /* (313) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 404, 0 }, /* (314) language_opt ::= */ - { 404, -2 }, /* (315) language_opt ::= LANGUAGE NK_STRING */ - { 329, -12 }, /* (316) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ - { 329, -4 }, /* (317) cmd ::= DROP STREAM exists_opt stream_name */ - { 407, 0 }, /* (318) col_list_opt ::= */ - { 407, -3 }, /* (319) col_list_opt ::= NK_LP col_name_list NK_RP */ - { 408, 0 }, /* (320) tag_def_or_ref_opt ::= */ - { 408, -1 }, /* (321) tag_def_or_ref_opt ::= tags_def */ - { 408, -4 }, /* (322) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ - { 406, 0 }, /* (323) stream_options ::= */ - { 406, -3 }, /* (324) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 406, -3 }, /* (325) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 406, -4 }, /* (326) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 406, -3 }, /* (327) stream_options ::= stream_options WATERMARK duration_literal */ - { 406, -4 }, /* (328) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - { 406, -3 }, /* (329) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - { 406, -3 }, /* (330) stream_options ::= stream_options DELETE_MARK duration_literal */ - { 406, -4 }, /* (331) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ - { 409, 0 }, /* (332) subtable_opt ::= */ - { 409, -4 }, /* (333) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - { 329, -3 }, /* (334) cmd ::= KILL CONNECTION NK_INTEGER */ - { 329, -3 }, /* (335) cmd ::= KILL QUERY NK_STRING */ - { 329, -3 }, /* (336) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 329, -2 }, /* (337) cmd ::= BALANCE VGROUP */ - { 329, -4 }, /* (338) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 329, -4 }, /* (339) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 329, -3 }, /* (340) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 411, -2 }, /* (341) dnode_list ::= DNODE NK_INTEGER */ - { 411, -3 }, /* (342) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 329, -4 }, /* (343) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 329, -1 }, /* (344) cmd ::= query_or_subquery */ - { 329, -1 }, /* (345) cmd ::= insert_query */ - { 401, -7 }, /* (346) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - { 401, -4 }, /* (347) insert_query ::= INSERT INTO full_table_name query_or_subquery */ - { 332, -1 }, /* (348) literal ::= NK_INTEGER */ - { 332, -1 }, /* (349) literal ::= NK_FLOAT */ - { 332, -1 }, /* (350) literal ::= NK_STRING */ - { 332, -1 }, /* (351) literal ::= NK_BOOL */ - { 332, -2 }, /* (352) literal ::= TIMESTAMP NK_STRING */ - { 332, -1 }, /* (353) literal ::= duration_literal */ - { 332, -1 }, /* (354) literal ::= NULL */ - { 332, -1 }, /* (355) literal ::= NK_QUESTION */ - { 378, -1 }, /* (356) duration_literal ::= NK_VARIABLE */ - { 413, -1 }, /* (357) signed ::= NK_INTEGER */ - { 413, -2 }, /* (358) signed ::= NK_PLUS NK_INTEGER */ - { 413, -2 }, /* (359) signed ::= NK_MINUS NK_INTEGER */ - { 413, -1 }, /* (360) signed ::= NK_FLOAT */ - { 413, -2 }, /* (361) signed ::= NK_PLUS NK_FLOAT */ - { 413, -2 }, /* (362) signed ::= NK_MINUS NK_FLOAT */ - { 367, -1 }, /* (363) signed_literal ::= signed */ - { 367, -1 }, /* (364) signed_literal ::= NK_STRING */ - { 367, -1 }, /* (365) signed_literal ::= NK_BOOL */ - { 367, -2 }, /* (366) signed_literal ::= TIMESTAMP NK_STRING */ - { 367, -1 }, /* (367) signed_literal ::= duration_literal */ - { 367, -1 }, /* (368) signed_literal ::= NULL */ - { 367, -1 }, /* (369) signed_literal ::= literal_func */ - { 367, -1 }, /* (370) signed_literal ::= NK_QUESTION */ - { 415, -1 }, /* (371) literal_list ::= signed_literal */ - { 415, -3 }, /* (372) literal_list ::= literal_list NK_COMMA signed_literal */ - { 340, -1 }, /* (373) db_name ::= NK_ID */ - { 373, -1 }, /* (374) table_name ::= NK_ID */ - { 365, -1 }, /* (375) column_name ::= NK_ID */ - { 380, -1 }, /* (376) function_name ::= NK_ID */ - { 416, -1 }, /* (377) table_alias ::= NK_ID */ - { 388, -1 }, /* (378) column_alias ::= NK_ID */ - { 334, -1 }, /* (379) user_name ::= NK_ID */ - { 341, -1 }, /* (380) topic_name ::= NK_ID */ - { 405, -1 }, /* (381) stream_name ::= NK_ID */ - { 398, -1 }, /* (382) cgroup_name ::= NK_ID */ - { 391, -1 }, /* (383) index_name ::= NK_ID */ - { 417, -1 }, /* (384) expr_or_subquery ::= expression */ - { 410, -1 }, /* (385) expression ::= literal */ - { 410, -1 }, /* (386) expression ::= pseudo_column */ - { 410, -1 }, /* (387) expression ::= column_reference */ - { 410, -1 }, /* (388) expression ::= function_expression */ - { 410, -1 }, /* (389) expression ::= case_when_expression */ - { 410, -3 }, /* (390) expression ::= NK_LP expression NK_RP */ - { 410, -2 }, /* (391) expression ::= NK_PLUS expr_or_subquery */ - { 410, -2 }, /* (392) expression ::= NK_MINUS expr_or_subquery */ - { 410, -3 }, /* (393) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - { 410, -3 }, /* (394) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - { 410, -3 }, /* (395) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - { 410, -3 }, /* (396) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - { 410, -3 }, /* (397) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - { 410, -3 }, /* (398) expression ::= column_reference NK_ARROW NK_STRING */ - { 410, -3 }, /* (399) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - { 410, -3 }, /* (400) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - { 370, -1 }, /* (401) expression_list ::= expr_or_subquery */ - { 370, -3 }, /* (402) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - { 419, -1 }, /* (403) column_reference ::= column_name */ - { 419, -3 }, /* (404) column_reference ::= table_name NK_DOT column_name */ - { 418, -1 }, /* (405) pseudo_column ::= ROWTS */ - { 418, -1 }, /* (406) pseudo_column ::= TBNAME */ - { 418, -3 }, /* (407) pseudo_column ::= table_name NK_DOT TBNAME */ - { 418, -1 }, /* (408) pseudo_column ::= QSTART */ - { 418, -1 }, /* (409) pseudo_column ::= QEND */ - { 418, -1 }, /* (410) pseudo_column ::= QDURATION */ - { 418, -1 }, /* (411) pseudo_column ::= WSTART */ - { 418, -1 }, /* (412) pseudo_column ::= WEND */ - { 418, -1 }, /* (413) pseudo_column ::= WDURATION */ - { 418, -1 }, /* (414) pseudo_column ::= IROWTS */ - { 418, -1 }, /* (415) pseudo_column ::= ISFILLED */ - { 418, -1 }, /* (416) pseudo_column ::= QTAGS */ - { 420, -4 }, /* (417) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 420, -4 }, /* (418) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 420, -6 }, /* (419) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - { 420, -1 }, /* (420) function_expression ::= literal_func */ - { 414, -3 }, /* (421) literal_func ::= noarg_func NK_LP NK_RP */ - { 414, -1 }, /* (422) literal_func ::= NOW */ - { 424, -1 }, /* (423) noarg_func ::= NOW */ - { 424, -1 }, /* (424) noarg_func ::= TODAY */ - { 424, -1 }, /* (425) noarg_func ::= TIMEZONE */ - { 424, -1 }, /* (426) noarg_func ::= DATABASE */ - { 424, -1 }, /* (427) noarg_func ::= CLIENT_VERSION */ - { 424, -1 }, /* (428) noarg_func ::= SERVER_VERSION */ - { 424, -1 }, /* (429) noarg_func ::= SERVER_STATUS */ - { 424, -1 }, /* (430) noarg_func ::= CURRENT_USER */ - { 424, -1 }, /* (431) noarg_func ::= USER */ - { 422, -1 }, /* (432) star_func ::= COUNT */ - { 422, -1 }, /* (433) star_func ::= FIRST */ - { 422, -1 }, /* (434) star_func ::= LAST */ - { 422, -1 }, /* (435) star_func ::= LAST_ROW */ - { 423, -1 }, /* (436) star_func_para_list ::= NK_STAR */ - { 423, -1 }, /* (437) star_func_para_list ::= other_para_list */ - { 425, -1 }, /* (438) other_para_list ::= star_func_para */ - { 425, -3 }, /* (439) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 426, -1 }, /* (440) star_func_para ::= expr_or_subquery */ - { 426, -3 }, /* (441) star_func_para ::= table_name NK_DOT NK_STAR */ - { 421, -4 }, /* (442) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - { 421, -5 }, /* (443) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - { 427, -1 }, /* (444) when_then_list ::= when_then_expr */ - { 427, -2 }, /* (445) when_then_list ::= when_then_list when_then_expr */ - { 430, -4 }, /* (446) when_then_expr ::= WHEN common_expression THEN common_expression */ - { 428, 0 }, /* (447) case_when_else_opt ::= */ - { 428, -2 }, /* (448) case_when_else_opt ::= ELSE common_expression */ - { 431, -3 }, /* (449) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - { 431, -5 }, /* (450) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - { 431, -6 }, /* (451) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - { 431, -3 }, /* (452) predicate ::= expr_or_subquery IS NULL */ - { 431, -4 }, /* (453) predicate ::= expr_or_subquery IS NOT NULL */ - { 431, -3 }, /* (454) predicate ::= expr_or_subquery in_op in_predicate_value */ - { 432, -1 }, /* (455) compare_op ::= NK_LT */ - { 432, -1 }, /* (456) compare_op ::= NK_GT */ - { 432, -1 }, /* (457) compare_op ::= NK_LE */ - { 432, -1 }, /* (458) compare_op ::= NK_GE */ - { 432, -1 }, /* (459) compare_op ::= NK_NE */ - { 432, -1 }, /* (460) compare_op ::= NK_EQ */ - { 432, -1 }, /* (461) compare_op ::= LIKE */ - { 432, -2 }, /* (462) compare_op ::= NOT LIKE */ - { 432, -1 }, /* (463) compare_op ::= MATCH */ - { 432, -1 }, /* (464) compare_op ::= NMATCH */ - { 432, -1 }, /* (465) compare_op ::= CONTAINS */ - { 433, -1 }, /* (466) in_op ::= IN */ - { 433, -2 }, /* (467) in_op ::= NOT IN */ - { 434, -3 }, /* (468) in_predicate_value ::= NK_LP literal_list NK_RP */ - { 435, -1 }, /* (469) boolean_value_expression ::= boolean_primary */ - { 435, -2 }, /* (470) boolean_value_expression ::= NOT boolean_primary */ - { 435, -3 }, /* (471) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 435, -3 }, /* (472) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 436, -1 }, /* (473) boolean_primary ::= predicate */ - { 436, -3 }, /* (474) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 429, -1 }, /* (475) common_expression ::= expr_or_subquery */ - { 429, -1 }, /* (476) common_expression ::= boolean_value_expression */ - { 437, 0 }, /* (477) from_clause_opt ::= */ - { 437, -2 }, /* (478) from_clause_opt ::= FROM table_reference_list */ - { 438, -1 }, /* (479) table_reference_list ::= table_reference */ - { 438, -3 }, /* (480) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 439, -1 }, /* (481) table_reference ::= table_primary */ - { 439, -1 }, /* (482) table_reference ::= joined_table */ - { 440, -2 }, /* (483) table_primary ::= table_name alias_opt */ - { 440, -4 }, /* (484) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 440, -2 }, /* (485) table_primary ::= subquery alias_opt */ - { 440, -1 }, /* (486) table_primary ::= parenthesized_joined_table */ - { 442, 0 }, /* (487) alias_opt ::= */ - { 442, -1 }, /* (488) alias_opt ::= table_alias */ - { 442, -2 }, /* (489) alias_opt ::= AS table_alias */ - { 444, -3 }, /* (490) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 444, -3 }, /* (491) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 441, -6 }, /* (492) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 445, 0 }, /* (493) join_type ::= */ - { 445, -1 }, /* (494) join_type ::= INNER */ - { 447, -12 }, /* (495) 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 */ - { 448, 0 }, /* (496) set_quantifier_opt ::= */ - { 448, -1 }, /* (497) set_quantifier_opt ::= DISTINCT */ - { 448, -1 }, /* (498) set_quantifier_opt ::= ALL */ - { 449, -1 }, /* (499) select_list ::= select_item */ - { 449, -3 }, /* (500) select_list ::= select_list NK_COMMA select_item */ - { 457, -1 }, /* (501) select_item ::= NK_STAR */ - { 457, -1 }, /* (502) select_item ::= common_expression */ - { 457, -2 }, /* (503) select_item ::= common_expression column_alias */ - { 457, -3 }, /* (504) select_item ::= common_expression AS column_alias */ - { 457, -3 }, /* (505) select_item ::= table_name NK_DOT NK_STAR */ - { 412, 0 }, /* (506) where_clause_opt ::= */ - { 412, -2 }, /* (507) where_clause_opt ::= WHERE search_condition */ - { 450, 0 }, /* (508) partition_by_clause_opt ::= */ - { 450, -3 }, /* (509) partition_by_clause_opt ::= PARTITION BY partition_list */ - { 458, -1 }, /* (510) partition_list ::= partition_item */ - { 458, -3 }, /* (511) partition_list ::= partition_list NK_COMMA partition_item */ - { 459, -1 }, /* (512) partition_item ::= expr_or_subquery */ - { 459, -2 }, /* (513) partition_item ::= expr_or_subquery column_alias */ - { 459, -3 }, /* (514) partition_item ::= expr_or_subquery AS column_alias */ - { 454, 0 }, /* (515) twindow_clause_opt ::= */ - { 454, -6 }, /* (516) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 454, -4 }, /* (517) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - { 454, -6 }, /* (518) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 454, -8 }, /* (519) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 454, -7 }, /* (520) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ - { 393, 0 }, /* (521) sliding_opt ::= */ - { 393, -4 }, /* (522) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 453, 0 }, /* (523) fill_opt ::= */ - { 453, -4 }, /* (524) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 453, -6 }, /* (525) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 453, -6 }, /* (526) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP */ - { 460, -1 }, /* (527) fill_mode ::= NONE */ - { 460, -1 }, /* (528) fill_mode ::= PREV */ - { 460, -1 }, /* (529) fill_mode ::= NULL */ - { 460, -1 }, /* (530) fill_mode ::= NULL_F */ - { 460, -1 }, /* (531) fill_mode ::= LINEAR */ - { 460, -1 }, /* (532) fill_mode ::= NEXT */ - { 455, 0 }, /* (533) group_by_clause_opt ::= */ - { 455, -3 }, /* (534) group_by_clause_opt ::= GROUP BY group_by_list */ - { 461, -1 }, /* (535) group_by_list ::= expr_or_subquery */ - { 461, -3 }, /* (536) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - { 456, 0 }, /* (537) having_clause_opt ::= */ - { 456, -2 }, /* (538) having_clause_opt ::= HAVING search_condition */ - { 451, 0 }, /* (539) range_opt ::= */ - { 451, -6 }, /* (540) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - { 452, 0 }, /* (541) every_opt ::= */ - { 452, -4 }, /* (542) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 462, -4 }, /* (543) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 463, -1 }, /* (544) query_simple ::= query_specification */ - { 463, -1 }, /* (545) query_simple ::= union_query_expression */ - { 467, -4 }, /* (546) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - { 467, -3 }, /* (547) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - { 468, -1 }, /* (548) query_simple_or_subquery ::= query_simple */ - { 468, -1 }, /* (549) query_simple_or_subquery ::= subquery */ - { 397, -1 }, /* (550) query_or_subquery ::= query_expression */ - { 397, -1 }, /* (551) query_or_subquery ::= subquery */ - { 464, 0 }, /* (552) order_by_clause_opt ::= */ - { 464, -3 }, /* (553) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 465, 0 }, /* (554) slimit_clause_opt ::= */ - { 465, -2 }, /* (555) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 465, -4 }, /* (556) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 465, -4 }, /* (557) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 466, 0 }, /* (558) limit_clause_opt ::= */ - { 466, -2 }, /* (559) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 466, -4 }, /* (560) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 466, -4 }, /* (561) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 443, -3 }, /* (562) subquery ::= NK_LP query_expression NK_RP */ - { 443, -3 }, /* (563) subquery ::= NK_LP subquery NK_RP */ - { 446, -1 }, /* (564) search_condition ::= common_expression */ - { 469, -1 }, /* (565) sort_specification_list ::= sort_specification */ - { 469, -3 }, /* (566) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 470, -3 }, /* (567) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - { 471, 0 }, /* (568) ordering_specification_opt ::= */ - { 471, -1 }, /* (569) ordering_specification_opt ::= ASC */ - { 471, -1 }, /* (570) ordering_specification_opt ::= DESC */ - { 472, 0 }, /* (571) null_ordering_opt ::= */ - { 472, -2 }, /* (572) null_ordering_opt ::= NULLS FIRST */ - { 472, -2 }, /* (573) null_ordering_opt ::= NULLS LAST */ + { 330, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 330, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 331, 0 }, /* (2) account_options ::= */ + { 331, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 331, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 331, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 331, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 331, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 331, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 331, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 331, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 331, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 332, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 332, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 334, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 334, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 334, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 334, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 334, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 334, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 334, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 334, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 334, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 334, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 330, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ + { 330, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 330, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + { 330, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + { 330, -3 }, /* (28) cmd ::= DROP USER user_name */ + { 336, 0 }, /* (29) sysinfo_opt ::= */ + { 336, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */ + { 330, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 330, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 337, -1 }, /* (33) privileges ::= ALL */ + { 337, -1 }, /* (34) privileges ::= priv_type_list */ + { 337, -1 }, /* (35) privileges ::= SUBSCRIBE */ + { 339, -1 }, /* (36) priv_type_list ::= priv_type */ + { 339, -3 }, /* (37) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 340, -1 }, /* (38) priv_type ::= READ */ + { 340, -1 }, /* (39) priv_type ::= WRITE */ + { 338, -3 }, /* (40) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 338, -3 }, /* (41) priv_level ::= db_name NK_DOT NK_STAR */ + { 338, -1 }, /* (42) priv_level ::= topic_name */ + { 330, -3 }, /* (43) cmd ::= CREATE DNODE dnode_endpoint */ + { 330, -5 }, /* (44) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + { 330, -4 }, /* (45) cmd ::= DROP DNODE NK_INTEGER force_opt */ + { 330, -4 }, /* (46) cmd ::= DROP DNODE dnode_endpoint force_opt */ + { 330, -4 }, /* (47) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 330, -5 }, /* (48) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 330, -4 }, /* (49) cmd ::= ALTER ALL DNODES NK_STRING */ + { 330, -5 }, /* (50) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 343, -1 }, /* (51) dnode_endpoint ::= NK_STRING */ + { 343, -1 }, /* (52) dnode_endpoint ::= NK_ID */ + { 343, -1 }, /* (53) dnode_endpoint ::= NK_IPTOKEN */ + { 344, 0 }, /* (54) force_opt ::= */ + { 344, -1 }, /* (55) force_opt ::= FORCE */ + { 330, -3 }, /* (56) cmd ::= ALTER LOCAL NK_STRING */ + { 330, -4 }, /* (57) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 330, -5 }, /* (58) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 330, -5 }, /* (59) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 330, -5 }, /* (60) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 330, -5 }, /* (61) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 330, -5 }, /* (62) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 330, -5 }, /* (63) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 330, -5 }, /* (64) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 330, -5 }, /* (65) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 330, -5 }, /* (66) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 330, -4 }, /* (67) cmd ::= DROP DATABASE exists_opt db_name */ + { 330, -2 }, /* (68) cmd ::= USE db_name */ + { 330, -4 }, /* (69) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 330, -3 }, /* (70) cmd ::= FLUSH DATABASE db_name */ + { 330, -4 }, /* (71) cmd ::= TRIM DATABASE db_name speed_opt */ + { 330, -5 }, /* (72) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ + { 345, -3 }, /* (73) not_exists_opt ::= IF NOT EXISTS */ + { 345, 0 }, /* (74) not_exists_opt ::= */ + { 347, -2 }, /* (75) exists_opt ::= IF EXISTS */ + { 347, 0 }, /* (76) exists_opt ::= */ + { 346, 0 }, /* (77) db_options ::= */ + { 346, -3 }, /* (78) db_options ::= db_options BUFFER NK_INTEGER */ + { 346, -3 }, /* (79) db_options ::= db_options CACHEMODEL NK_STRING */ + { 346, -3 }, /* (80) db_options ::= db_options CACHESIZE NK_INTEGER */ + { 346, -3 }, /* (81) db_options ::= db_options COMP NK_INTEGER */ + { 346, -3 }, /* (82) db_options ::= db_options DURATION NK_INTEGER */ + { 346, -3 }, /* (83) db_options ::= db_options DURATION NK_VARIABLE */ + { 346, -3 }, /* (84) db_options ::= db_options MAXROWS NK_INTEGER */ + { 346, -3 }, /* (85) db_options ::= db_options MINROWS NK_INTEGER */ + { 346, -3 }, /* (86) db_options ::= db_options KEEP integer_list */ + { 346, -3 }, /* (87) db_options ::= db_options KEEP variable_list */ + { 346, -3 }, /* (88) db_options ::= db_options PAGES NK_INTEGER */ + { 346, -3 }, /* (89) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 346, -3 }, /* (90) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ + { 346, -3 }, /* (91) db_options ::= db_options PRECISION NK_STRING */ + { 346, -3 }, /* (92) db_options ::= db_options REPLICA NK_INTEGER */ + { 346, -3 }, /* (93) db_options ::= db_options VGROUPS NK_INTEGER */ + { 346, -3 }, /* (94) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 346, -3 }, /* (95) db_options ::= db_options RETENTIONS retention_list */ + { 346, -3 }, /* (96) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 346, -3 }, /* (97) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + { 346, -3 }, /* (98) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + { 346, -3 }, /* (99) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + { 346, -4 }, /* (100) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + { 346, -3 }, /* (101) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + { 346, -4 }, /* (102) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + { 346, -3 }, /* (103) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + { 346, -3 }, /* (104) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + { 346, -3 }, /* (105) db_options ::= db_options STT_TRIGGER NK_INTEGER */ + { 346, -3 }, /* (106) db_options ::= db_options TABLE_PREFIX NK_INTEGER */ + { 346, -3 }, /* (107) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ + { 348, -1 }, /* (108) alter_db_options ::= alter_db_option */ + { 348, -2 }, /* (109) alter_db_options ::= alter_db_options alter_db_option */ + { 355, -2 }, /* (110) alter_db_option ::= BUFFER NK_INTEGER */ + { 355, -2 }, /* (111) alter_db_option ::= CACHEMODEL NK_STRING */ + { 355, -2 }, /* (112) alter_db_option ::= CACHESIZE NK_INTEGER */ + { 355, -2 }, /* (113) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + { 355, -2 }, /* (114) alter_db_option ::= KEEP integer_list */ + { 355, -2 }, /* (115) alter_db_option ::= KEEP variable_list */ + { 355, -2 }, /* (116) alter_db_option ::= PAGES NK_INTEGER */ + { 355, -2 }, /* (117) alter_db_option ::= REPLICA NK_INTEGER */ + { 355, -2 }, /* (118) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + { 355, -2 }, /* (119) alter_db_option ::= STT_TRIGGER NK_INTEGER */ + { 355, -2 }, /* (120) alter_db_option ::= MINROWS NK_INTEGER */ + { 355, -2 }, /* (121) alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ + { 355, -3 }, /* (122) alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + { 355, -2 }, /* (123) alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ + { 355, -3 }, /* (124) alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + { 352, -1 }, /* (125) integer_list ::= NK_INTEGER */ + { 352, -3 }, /* (126) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 353, -1 }, /* (127) variable_list ::= NK_VARIABLE */ + { 353, -3 }, /* (128) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 354, -1 }, /* (129) retention_list ::= retention */ + { 354, -3 }, /* (130) retention_list ::= retention_list NK_COMMA retention */ + { 356, -3 }, /* (131) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 349, 0 }, /* (132) speed_opt ::= */ + { 349, -2 }, /* (133) speed_opt ::= MAX_SPEED NK_INTEGER */ + { 350, 0 }, /* (134) start_opt ::= */ + { 350, -3 }, /* (135) start_opt ::= START WITH NK_INTEGER */ + { 350, -3 }, /* (136) start_opt ::= START WITH NK_STRING */ + { 350, -4 }, /* (137) start_opt ::= START WITH TIMESTAMP NK_STRING */ + { 351, 0 }, /* (138) end_opt ::= */ + { 351, -3 }, /* (139) end_opt ::= END WITH NK_INTEGER */ + { 351, -3 }, /* (140) end_opt ::= END WITH NK_STRING */ + { 351, -4 }, /* (141) end_opt ::= END WITH TIMESTAMP NK_STRING */ + { 330, -9 }, /* (142) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 330, -3 }, /* (143) cmd ::= CREATE TABLE multi_create_clause */ + { 330, -9 }, /* (144) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 330, -3 }, /* (145) cmd ::= DROP TABLE multi_drop_clause */ + { 330, -4 }, /* (146) cmd ::= DROP STABLE exists_opt full_table_name */ + { 330, -3 }, /* (147) cmd ::= ALTER TABLE alter_table_clause */ + { 330, -3 }, /* (148) cmd ::= ALTER STABLE alter_table_clause */ + { 364, -2 }, /* (149) alter_table_clause ::= full_table_name alter_table_options */ + { 364, -5 }, /* (150) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 364, -4 }, /* (151) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 364, -5 }, /* (152) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 364, -5 }, /* (153) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 364, -5 }, /* (154) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 364, -4 }, /* (155) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 364, -5 }, /* (156) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 364, -5 }, /* (157) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 364, -6 }, /* (158) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 361, -1 }, /* (159) multi_create_clause ::= create_subtable_clause */ + { 361, -2 }, /* (160) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 369, -10 }, /* (161) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ + { 363, -1 }, /* (162) multi_drop_clause ::= drop_table_clause */ + { 363, -3 }, /* (163) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ + { 372, -2 }, /* (164) drop_table_clause ::= exists_opt full_table_name */ + { 370, 0 }, /* (165) specific_cols_opt ::= */ + { 370, -3 }, /* (166) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + { 357, -1 }, /* (167) full_table_name ::= table_name */ + { 357, -3 }, /* (168) full_table_name ::= db_name NK_DOT table_name */ + { 358, -1 }, /* (169) column_def_list ::= column_def */ + { 358, -3 }, /* (170) column_def_list ::= column_def_list NK_COMMA column_def */ + { 375, -2 }, /* (171) column_def ::= column_name type_name */ + { 375, -4 }, /* (172) column_def ::= column_name type_name COMMENT NK_STRING */ + { 367, -1 }, /* (173) type_name ::= BOOL */ + { 367, -1 }, /* (174) type_name ::= TINYINT */ + { 367, -1 }, /* (175) type_name ::= SMALLINT */ + { 367, -1 }, /* (176) type_name ::= INT */ + { 367, -1 }, /* (177) type_name ::= INTEGER */ + { 367, -1 }, /* (178) type_name ::= BIGINT */ + { 367, -1 }, /* (179) type_name ::= FLOAT */ + { 367, -1 }, /* (180) type_name ::= DOUBLE */ + { 367, -4 }, /* (181) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 367, -1 }, /* (182) type_name ::= TIMESTAMP */ + { 367, -4 }, /* (183) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 367, -2 }, /* (184) type_name ::= TINYINT UNSIGNED */ + { 367, -2 }, /* (185) type_name ::= SMALLINT UNSIGNED */ + { 367, -2 }, /* (186) type_name ::= INT UNSIGNED */ + { 367, -2 }, /* (187) type_name ::= BIGINT UNSIGNED */ + { 367, -1 }, /* (188) type_name ::= JSON */ + { 367, -4 }, /* (189) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 367, -1 }, /* (190) type_name ::= MEDIUMBLOB */ + { 367, -1 }, /* (191) type_name ::= BLOB */ + { 367, -4 }, /* (192) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 367, -1 }, /* (193) type_name ::= DECIMAL */ + { 367, -4 }, /* (194) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 367, -6 }, /* (195) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 359, 0 }, /* (196) tags_def_opt ::= */ + { 359, -1 }, /* (197) tags_def_opt ::= tags_def */ + { 362, -4 }, /* (198) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 360, 0 }, /* (199) table_options ::= */ + { 360, -3 }, /* (200) table_options ::= table_options COMMENT NK_STRING */ + { 360, -3 }, /* (201) table_options ::= table_options MAX_DELAY duration_list */ + { 360, -3 }, /* (202) table_options ::= table_options WATERMARK duration_list */ + { 360, -5 }, /* (203) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + { 360, -3 }, /* (204) table_options ::= table_options TTL NK_INTEGER */ + { 360, -5 }, /* (205) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 360, -3 }, /* (206) table_options ::= table_options DELETE_MARK duration_list */ + { 365, -1 }, /* (207) alter_table_options ::= alter_table_option */ + { 365, -2 }, /* (208) alter_table_options ::= alter_table_options alter_table_option */ + { 378, -2 }, /* (209) alter_table_option ::= COMMENT NK_STRING */ + { 378, -2 }, /* (210) alter_table_option ::= TTL NK_INTEGER */ + { 376, -1 }, /* (211) duration_list ::= duration_literal */ + { 376, -3 }, /* (212) duration_list ::= duration_list NK_COMMA duration_literal */ + { 377, -1 }, /* (213) rollup_func_list ::= rollup_func_name */ + { 377, -3 }, /* (214) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + { 380, -1 }, /* (215) rollup_func_name ::= function_name */ + { 380, -1 }, /* (216) rollup_func_name ::= FIRST */ + { 380, -1 }, /* (217) rollup_func_name ::= LAST */ + { 373, -1 }, /* (218) col_name_list ::= col_name */ + { 373, -3 }, /* (219) col_name_list ::= col_name_list NK_COMMA col_name */ + { 382, -1 }, /* (220) col_name ::= column_name */ + { 330, -2 }, /* (221) cmd ::= SHOW DNODES */ + { 330, -2 }, /* (222) cmd ::= SHOW USERS */ + { 330, -3 }, /* (223) cmd ::= SHOW USER PRIVILEGES */ + { 330, -2 }, /* (224) cmd ::= SHOW DATABASES */ + { 330, -4 }, /* (225) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 330, -4 }, /* (226) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 330, -3 }, /* (227) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 330, -2 }, /* (228) cmd ::= SHOW MNODES */ + { 330, -2 }, /* (229) cmd ::= SHOW QNODES */ + { 330, -2 }, /* (230) cmd ::= SHOW FUNCTIONS */ + { 330, -5 }, /* (231) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 330, -2 }, /* (232) cmd ::= SHOW STREAMS */ + { 330, -2 }, /* (233) cmd ::= SHOW ACCOUNTS */ + { 330, -2 }, /* (234) cmd ::= SHOW APPS */ + { 330, -2 }, /* (235) cmd ::= SHOW CONNECTIONS */ + { 330, -2 }, /* (236) cmd ::= SHOW LICENCES */ + { 330, -2 }, /* (237) cmd ::= SHOW GRANTS */ + { 330, -4 }, /* (238) cmd ::= SHOW CREATE DATABASE db_name */ + { 330, -4 }, /* (239) cmd ::= SHOW CREATE TABLE full_table_name */ + { 330, -4 }, /* (240) cmd ::= SHOW CREATE STABLE full_table_name */ + { 330, -2 }, /* (241) cmd ::= SHOW QUERIES */ + { 330, -2 }, /* (242) cmd ::= SHOW SCORES */ + { 330, -2 }, /* (243) cmd ::= SHOW TOPICS */ + { 330, -2 }, /* (244) cmd ::= SHOW VARIABLES */ + { 330, -3 }, /* (245) cmd ::= SHOW CLUSTER VARIABLES */ + { 330, -3 }, /* (246) cmd ::= SHOW LOCAL VARIABLES */ + { 330, -5 }, /* (247) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ + { 330, -2 }, /* (248) cmd ::= SHOW BNODES */ + { 330, -2 }, /* (249) cmd ::= SHOW SNODES */ + { 330, -2 }, /* (250) cmd ::= SHOW CLUSTER */ + { 330, -2 }, /* (251) cmd ::= SHOW TRANSACTIONS */ + { 330, -4 }, /* (252) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 330, -2 }, /* (253) cmd ::= SHOW CONSUMERS */ + { 330, -2 }, /* (254) cmd ::= SHOW SUBSCRIPTIONS */ + { 330, -5 }, /* (255) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + { 330, -7 }, /* (256) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ + { 330, -3 }, /* (257) cmd ::= SHOW VNODES NK_INTEGER */ + { 330, -3 }, /* (258) cmd ::= SHOW VNODES NK_STRING */ + { 330, -3 }, /* (259) cmd ::= SHOW db_name_cond_opt ALIVE */ + { 330, -3 }, /* (260) cmd ::= SHOW CLUSTER ALIVE */ + { 383, 0 }, /* (261) db_name_cond_opt ::= */ + { 383, -2 }, /* (262) db_name_cond_opt ::= db_name NK_DOT */ + { 384, 0 }, /* (263) like_pattern_opt ::= */ + { 384, -2 }, /* (264) like_pattern_opt ::= LIKE NK_STRING */ + { 385, -1 }, /* (265) table_name_cond ::= table_name */ + { 386, 0 }, /* (266) from_db_opt ::= */ + { 386, -2 }, /* (267) from_db_opt ::= FROM db_name */ + { 387, 0 }, /* (268) tag_list_opt ::= */ + { 387, -1 }, /* (269) tag_list_opt ::= tag_item */ + { 387, -3 }, /* (270) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ + { 388, -1 }, /* (271) tag_item ::= TBNAME */ + { 388, -1 }, /* (272) tag_item ::= QTAGS */ + { 388, -1 }, /* (273) tag_item ::= column_name */ + { 388, -2 }, /* (274) tag_item ::= column_name column_alias */ + { 388, -3 }, /* (275) tag_item ::= column_name AS column_alias */ + { 330, -8 }, /* (276) cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */ + { 330, -9 }, /* (277) cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP */ + { 330, -4 }, /* (278) cmd ::= DROP INDEX exists_opt full_index_name */ + { 390, -1 }, /* (279) full_index_name ::= index_name */ + { 390, -3 }, /* (280) full_index_name ::= db_name NK_DOT index_name */ + { 391, -10 }, /* (281) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + { 391, -12 }, /* (282) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ + { 393, -1 }, /* (283) func_list ::= func */ + { 393, -3 }, /* (284) func_list ::= func_list NK_COMMA func */ + { 396, -4 }, /* (285) func ::= sma_func_name NK_LP expression_list NK_RP */ + { 397, -1 }, /* (286) sma_func_name ::= function_name */ + { 397, -1 }, /* (287) sma_func_name ::= COUNT */ + { 397, -1 }, /* (288) sma_func_name ::= FIRST */ + { 397, -1 }, /* (289) sma_func_name ::= LAST */ + { 397, -1 }, /* (290) sma_func_name ::= LAST_ROW */ + { 395, 0 }, /* (291) sma_stream_opt ::= */ + { 395, -3 }, /* (292) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + { 395, -3 }, /* (293) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + { 395, -3 }, /* (294) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + { 330, -6 }, /* (295) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + { 330, -7 }, /* (296) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 330, -9 }, /* (297) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 330, -7 }, /* (298) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 330, -9 }, /* (299) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 330, -4 }, /* (300) cmd ::= DROP TOPIC exists_opt topic_name */ + { 330, -7 }, /* (301) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 330, -2 }, /* (302) cmd ::= DESC full_table_name */ + { 330, -2 }, /* (303) cmd ::= DESCRIBE full_table_name */ + { 330, -3 }, /* (304) cmd ::= RESET QUERY CACHE */ + { 330, -4 }, /* (305) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + { 330, -4 }, /* (306) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ + { 400, 0 }, /* (307) analyze_opt ::= */ + { 400, -1 }, /* (308) analyze_opt ::= ANALYZE */ + { 401, 0 }, /* (309) explain_options ::= */ + { 401, -3 }, /* (310) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 401, -3 }, /* (311) explain_options ::= explain_options RATIO NK_FLOAT */ + { 330, -12 }, /* (312) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ + { 330, -4 }, /* (313) cmd ::= DROP FUNCTION exists_opt function_name */ + { 404, 0 }, /* (314) agg_func_opt ::= */ + { 404, -1 }, /* (315) agg_func_opt ::= AGGREGATE */ + { 405, 0 }, /* (316) bufsize_opt ::= */ + { 405, -2 }, /* (317) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 406, 0 }, /* (318) language_opt ::= */ + { 406, -2 }, /* (319) language_opt ::= LANGUAGE NK_STRING */ + { 403, 0 }, /* (320) or_replace_opt ::= */ + { 403, -2 }, /* (321) or_replace_opt ::= OR REPLACE */ + { 330, -12 }, /* (322) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ + { 330, -4 }, /* (323) cmd ::= DROP STREAM exists_opt stream_name */ + { 409, 0 }, /* (324) col_list_opt ::= */ + { 409, -3 }, /* (325) col_list_opt ::= NK_LP col_name_list NK_RP */ + { 410, 0 }, /* (326) tag_def_or_ref_opt ::= */ + { 410, -1 }, /* (327) tag_def_or_ref_opt ::= tags_def */ + { 410, -4 }, /* (328) tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ + { 408, 0 }, /* (329) stream_options ::= */ + { 408, -3 }, /* (330) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 408, -3 }, /* (331) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 408, -4 }, /* (332) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 408, -3 }, /* (333) stream_options ::= stream_options WATERMARK duration_literal */ + { 408, -4 }, /* (334) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + { 408, -3 }, /* (335) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + { 408, -3 }, /* (336) stream_options ::= stream_options DELETE_MARK duration_literal */ + { 408, -4 }, /* (337) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + { 411, 0 }, /* (338) subtable_opt ::= */ + { 411, -4 }, /* (339) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + { 330, -3 }, /* (340) cmd ::= KILL CONNECTION NK_INTEGER */ + { 330, -3 }, /* (341) cmd ::= KILL QUERY NK_STRING */ + { 330, -3 }, /* (342) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 330, -2 }, /* (343) cmd ::= BALANCE VGROUP */ + { 330, -3 }, /* (344) cmd ::= BALANCE VGROUP LEADER */ + { 330, -4 }, /* (345) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 330, -4 }, /* (346) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 330, -3 }, /* (347) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 413, -2 }, /* (348) dnode_list ::= DNODE NK_INTEGER */ + { 413, -3 }, /* (349) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 330, -4 }, /* (350) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 330, -1 }, /* (351) cmd ::= query_or_subquery */ + { 330, -1 }, /* (352) cmd ::= insert_query */ + { 402, -7 }, /* (353) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + { 402, -4 }, /* (354) insert_query ::= INSERT INTO full_table_name query_or_subquery */ + { 333, -1 }, /* (355) literal ::= NK_INTEGER */ + { 333, -1 }, /* (356) literal ::= NK_FLOAT */ + { 333, -1 }, /* (357) literal ::= NK_STRING */ + { 333, -1 }, /* (358) literal ::= NK_BOOL */ + { 333, -2 }, /* (359) literal ::= TIMESTAMP NK_STRING */ + { 333, -1 }, /* (360) literal ::= duration_literal */ + { 333, -1 }, /* (361) literal ::= NULL */ + { 333, -1 }, /* (362) literal ::= NK_QUESTION */ + { 379, -1 }, /* (363) duration_literal ::= NK_VARIABLE */ + { 415, -1 }, /* (364) signed ::= NK_INTEGER */ + { 415, -2 }, /* (365) signed ::= NK_PLUS NK_INTEGER */ + { 415, -2 }, /* (366) signed ::= NK_MINUS NK_INTEGER */ + { 415, -1 }, /* (367) signed ::= NK_FLOAT */ + { 415, -2 }, /* (368) signed ::= NK_PLUS NK_FLOAT */ + { 415, -2 }, /* (369) signed ::= NK_MINUS NK_FLOAT */ + { 368, -1 }, /* (370) signed_literal ::= signed */ + { 368, -1 }, /* (371) signed_literal ::= NK_STRING */ + { 368, -1 }, /* (372) signed_literal ::= NK_BOOL */ + { 368, -2 }, /* (373) signed_literal ::= TIMESTAMP NK_STRING */ + { 368, -1 }, /* (374) signed_literal ::= duration_literal */ + { 368, -1 }, /* (375) signed_literal ::= NULL */ + { 368, -1 }, /* (376) signed_literal ::= literal_func */ + { 368, -1 }, /* (377) signed_literal ::= NK_QUESTION */ + { 417, -1 }, /* (378) literal_list ::= signed_literal */ + { 417, -3 }, /* (379) literal_list ::= literal_list NK_COMMA signed_literal */ + { 341, -1 }, /* (380) db_name ::= NK_ID */ + { 374, -1 }, /* (381) table_name ::= NK_ID */ + { 366, -1 }, /* (382) column_name ::= NK_ID */ + { 381, -1 }, /* (383) function_name ::= NK_ID */ + { 418, -1 }, /* (384) table_alias ::= NK_ID */ + { 389, -1 }, /* (385) column_alias ::= NK_ID */ + { 335, -1 }, /* (386) user_name ::= NK_ID */ + { 342, -1 }, /* (387) topic_name ::= NK_ID */ + { 407, -1 }, /* (388) stream_name ::= NK_ID */ + { 399, -1 }, /* (389) cgroup_name ::= NK_ID */ + { 392, -1 }, /* (390) index_name ::= NK_ID */ + { 419, -1 }, /* (391) expr_or_subquery ::= expression */ + { 412, -1 }, /* (392) expression ::= literal */ + { 412, -1 }, /* (393) expression ::= pseudo_column */ + { 412, -1 }, /* (394) expression ::= column_reference */ + { 412, -1 }, /* (395) expression ::= function_expression */ + { 412, -1 }, /* (396) expression ::= case_when_expression */ + { 412, -3 }, /* (397) expression ::= NK_LP expression NK_RP */ + { 412, -2 }, /* (398) expression ::= NK_PLUS expr_or_subquery */ + { 412, -2 }, /* (399) expression ::= NK_MINUS expr_or_subquery */ + { 412, -3 }, /* (400) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + { 412, -3 }, /* (401) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + { 412, -3 }, /* (402) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + { 412, -3 }, /* (403) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + { 412, -3 }, /* (404) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + { 412, -3 }, /* (405) expression ::= column_reference NK_ARROW NK_STRING */ + { 412, -3 }, /* (406) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + { 412, -3 }, /* (407) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + { 371, -1 }, /* (408) expression_list ::= expr_or_subquery */ + { 371, -3 }, /* (409) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + { 421, -1 }, /* (410) column_reference ::= column_name */ + { 421, -3 }, /* (411) column_reference ::= table_name NK_DOT column_name */ + { 420, -1 }, /* (412) pseudo_column ::= ROWTS */ + { 420, -1 }, /* (413) pseudo_column ::= TBNAME */ + { 420, -3 }, /* (414) pseudo_column ::= table_name NK_DOT TBNAME */ + { 420, -1 }, /* (415) pseudo_column ::= QSTART */ + { 420, -1 }, /* (416) pseudo_column ::= QEND */ + { 420, -1 }, /* (417) pseudo_column ::= QDURATION */ + { 420, -1 }, /* (418) pseudo_column ::= WSTART */ + { 420, -1 }, /* (419) pseudo_column ::= WEND */ + { 420, -1 }, /* (420) pseudo_column ::= WDURATION */ + { 420, -1 }, /* (421) pseudo_column ::= IROWTS */ + { 420, -1 }, /* (422) pseudo_column ::= ISFILLED */ + { 420, -1 }, /* (423) pseudo_column ::= QTAGS */ + { 422, -4 }, /* (424) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 422, -4 }, /* (425) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 422, -6 }, /* (426) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + { 422, -1 }, /* (427) function_expression ::= literal_func */ + { 416, -3 }, /* (428) literal_func ::= noarg_func NK_LP NK_RP */ + { 416, -1 }, /* (429) literal_func ::= NOW */ + { 426, -1 }, /* (430) noarg_func ::= NOW */ + { 426, -1 }, /* (431) noarg_func ::= TODAY */ + { 426, -1 }, /* (432) noarg_func ::= TIMEZONE */ + { 426, -1 }, /* (433) noarg_func ::= DATABASE */ + { 426, -1 }, /* (434) noarg_func ::= CLIENT_VERSION */ + { 426, -1 }, /* (435) noarg_func ::= SERVER_VERSION */ + { 426, -1 }, /* (436) noarg_func ::= SERVER_STATUS */ + { 426, -1 }, /* (437) noarg_func ::= CURRENT_USER */ + { 426, -1 }, /* (438) noarg_func ::= USER */ + { 424, -1 }, /* (439) star_func ::= COUNT */ + { 424, -1 }, /* (440) star_func ::= FIRST */ + { 424, -1 }, /* (441) star_func ::= LAST */ + { 424, -1 }, /* (442) star_func ::= LAST_ROW */ + { 425, -1 }, /* (443) star_func_para_list ::= NK_STAR */ + { 425, -1 }, /* (444) star_func_para_list ::= other_para_list */ + { 427, -1 }, /* (445) other_para_list ::= star_func_para */ + { 427, -3 }, /* (446) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 428, -1 }, /* (447) star_func_para ::= expr_or_subquery */ + { 428, -3 }, /* (448) star_func_para ::= table_name NK_DOT NK_STAR */ + { 423, -4 }, /* (449) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + { 423, -5 }, /* (450) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + { 429, -1 }, /* (451) when_then_list ::= when_then_expr */ + { 429, -2 }, /* (452) when_then_list ::= when_then_list when_then_expr */ + { 432, -4 }, /* (453) when_then_expr ::= WHEN common_expression THEN common_expression */ + { 430, 0 }, /* (454) case_when_else_opt ::= */ + { 430, -2 }, /* (455) case_when_else_opt ::= ELSE common_expression */ + { 433, -3 }, /* (456) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + { 433, -5 }, /* (457) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + { 433, -6 }, /* (458) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + { 433, -3 }, /* (459) predicate ::= expr_or_subquery IS NULL */ + { 433, -4 }, /* (460) predicate ::= expr_or_subquery IS NOT NULL */ + { 433, -3 }, /* (461) predicate ::= expr_or_subquery in_op in_predicate_value */ + { 434, -1 }, /* (462) compare_op ::= NK_LT */ + { 434, -1 }, /* (463) compare_op ::= NK_GT */ + { 434, -1 }, /* (464) compare_op ::= NK_LE */ + { 434, -1 }, /* (465) compare_op ::= NK_GE */ + { 434, -1 }, /* (466) compare_op ::= NK_NE */ + { 434, -1 }, /* (467) compare_op ::= NK_EQ */ + { 434, -1 }, /* (468) compare_op ::= LIKE */ + { 434, -2 }, /* (469) compare_op ::= NOT LIKE */ + { 434, -1 }, /* (470) compare_op ::= MATCH */ + { 434, -1 }, /* (471) compare_op ::= NMATCH */ + { 434, -1 }, /* (472) compare_op ::= CONTAINS */ + { 435, -1 }, /* (473) in_op ::= IN */ + { 435, -2 }, /* (474) in_op ::= NOT IN */ + { 436, -3 }, /* (475) in_predicate_value ::= NK_LP literal_list NK_RP */ + { 437, -1 }, /* (476) boolean_value_expression ::= boolean_primary */ + { 437, -2 }, /* (477) boolean_value_expression ::= NOT boolean_primary */ + { 437, -3 }, /* (478) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 437, -3 }, /* (479) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 438, -1 }, /* (480) boolean_primary ::= predicate */ + { 438, -3 }, /* (481) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 431, -1 }, /* (482) common_expression ::= expr_or_subquery */ + { 431, -1 }, /* (483) common_expression ::= boolean_value_expression */ + { 439, 0 }, /* (484) from_clause_opt ::= */ + { 439, -2 }, /* (485) from_clause_opt ::= FROM table_reference_list */ + { 440, -1 }, /* (486) table_reference_list ::= table_reference */ + { 440, -3 }, /* (487) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 441, -1 }, /* (488) table_reference ::= table_primary */ + { 441, -1 }, /* (489) table_reference ::= joined_table */ + { 442, -2 }, /* (490) table_primary ::= table_name alias_opt */ + { 442, -4 }, /* (491) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 442, -2 }, /* (492) table_primary ::= subquery alias_opt */ + { 442, -1 }, /* (493) table_primary ::= parenthesized_joined_table */ + { 444, 0 }, /* (494) alias_opt ::= */ + { 444, -1 }, /* (495) alias_opt ::= table_alias */ + { 444, -2 }, /* (496) alias_opt ::= AS table_alias */ + { 446, -3 }, /* (497) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 446, -3 }, /* (498) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 443, -6 }, /* (499) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 447, 0 }, /* (500) join_type ::= */ + { 447, -1 }, /* (501) join_type ::= INNER */ + { 449, -12 }, /* (502) 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 */ + { 450, 0 }, /* (503) set_quantifier_opt ::= */ + { 450, -1 }, /* (504) set_quantifier_opt ::= DISTINCT */ + { 450, -1 }, /* (505) set_quantifier_opt ::= ALL */ + { 451, -1 }, /* (506) select_list ::= select_item */ + { 451, -3 }, /* (507) select_list ::= select_list NK_COMMA select_item */ + { 459, -1 }, /* (508) select_item ::= NK_STAR */ + { 459, -1 }, /* (509) select_item ::= common_expression */ + { 459, -2 }, /* (510) select_item ::= common_expression column_alias */ + { 459, -3 }, /* (511) select_item ::= common_expression AS column_alias */ + { 459, -3 }, /* (512) select_item ::= table_name NK_DOT NK_STAR */ + { 414, 0 }, /* (513) where_clause_opt ::= */ + { 414, -2 }, /* (514) where_clause_opt ::= WHERE search_condition */ + { 452, 0 }, /* (515) partition_by_clause_opt ::= */ + { 452, -3 }, /* (516) partition_by_clause_opt ::= PARTITION BY partition_list */ + { 460, -1 }, /* (517) partition_list ::= partition_item */ + { 460, -3 }, /* (518) partition_list ::= partition_list NK_COMMA partition_item */ + { 461, -1 }, /* (519) partition_item ::= expr_or_subquery */ + { 461, -2 }, /* (520) partition_item ::= expr_or_subquery column_alias */ + { 461, -3 }, /* (521) partition_item ::= expr_or_subquery AS column_alias */ + { 456, 0 }, /* (522) twindow_clause_opt ::= */ + { 456, -6 }, /* (523) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 456, -4 }, /* (524) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + { 456, -6 }, /* (525) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 456, -8 }, /* (526) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 456, -7 }, /* (527) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ + { 394, 0 }, /* (528) sliding_opt ::= */ + { 394, -4 }, /* (529) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 455, 0 }, /* (530) fill_opt ::= */ + { 455, -4 }, /* (531) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 455, -6 }, /* (532) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 455, -6 }, /* (533) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP */ + { 462, -1 }, /* (534) fill_mode ::= NONE */ + { 462, -1 }, /* (535) fill_mode ::= PREV */ + { 462, -1 }, /* (536) fill_mode ::= NULL */ + { 462, -1 }, /* (537) fill_mode ::= NULL_F */ + { 462, -1 }, /* (538) fill_mode ::= LINEAR */ + { 462, -1 }, /* (539) fill_mode ::= NEXT */ + { 457, 0 }, /* (540) group_by_clause_opt ::= */ + { 457, -3 }, /* (541) group_by_clause_opt ::= GROUP BY group_by_list */ + { 463, -1 }, /* (542) group_by_list ::= expr_or_subquery */ + { 463, -3 }, /* (543) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + { 458, 0 }, /* (544) having_clause_opt ::= */ + { 458, -2 }, /* (545) having_clause_opt ::= HAVING search_condition */ + { 453, 0 }, /* (546) range_opt ::= */ + { 453, -6 }, /* (547) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + { 454, 0 }, /* (548) every_opt ::= */ + { 454, -4 }, /* (549) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 464, -4 }, /* (550) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 465, -1 }, /* (551) query_simple ::= query_specification */ + { 465, -1 }, /* (552) query_simple ::= union_query_expression */ + { 469, -4 }, /* (553) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + { 469, -3 }, /* (554) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + { 470, -1 }, /* (555) query_simple_or_subquery ::= query_simple */ + { 470, -1 }, /* (556) query_simple_or_subquery ::= subquery */ + { 398, -1 }, /* (557) query_or_subquery ::= query_expression */ + { 398, -1 }, /* (558) query_or_subquery ::= subquery */ + { 466, 0 }, /* (559) order_by_clause_opt ::= */ + { 466, -3 }, /* (560) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 467, 0 }, /* (561) slimit_clause_opt ::= */ + { 467, -2 }, /* (562) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 467, -4 }, /* (563) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 467, -4 }, /* (564) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 468, 0 }, /* (565) limit_clause_opt ::= */ + { 468, -2 }, /* (566) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 468, -4 }, /* (567) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 468, -4 }, /* (568) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 445, -3 }, /* (569) subquery ::= NK_LP query_expression NK_RP */ + { 445, -3 }, /* (570) subquery ::= NK_LP subquery NK_RP */ + { 448, -1 }, /* (571) search_condition ::= common_expression */ + { 471, -1 }, /* (572) sort_specification_list ::= sort_specification */ + { 471, -3 }, /* (573) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 472, -3 }, /* (574) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + { 473, 0 }, /* (575) ordering_specification_opt ::= */ + { 473, -1 }, /* (576) ordering_specification_opt ::= ASC */ + { 473, -1 }, /* (577) ordering_specification_opt ::= DESC */ + { 474, 0 }, /* (578) null_ordering_opt ::= */ + { 474, -2 }, /* (579) null_ordering_opt ::= NULLS FIRST */ + { 474, -2 }, /* (580) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3754,11 +3826,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,330,&yymsp[0].minor); + yy_destructor(yypParser,331,&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,331,&yymsp[0].minor); + yy_destructor(yypParser,332,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3772,20 +3844,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,330,&yymsp[-2].minor); +{ yy_destructor(yypParser,331,&yymsp[-2].minor); { } - yy_destructor(yypParser,332,&yymsp[0].minor); + yy_destructor(yypParser,333,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,333,&yymsp[0].minor); +{ yy_destructor(yypParser,334,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,331,&yymsp[-1].minor); +{ yy_destructor(yypParser,332,&yymsp[-1].minor); { } - yy_destructor(yypParser,333,&yymsp[0].minor); + yy_destructor(yypParser,334,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3799,81 +3871,81 @@ 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,332,&yymsp[0].minor); + yy_destructor(yypParser,333,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy63, &yymsp[-1].minor.yy0, yymsp[0].minor.yy707); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy0, yymsp[0].minor.yy353); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy63, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy129, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy63, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy129, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy63, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy129, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } break; case 28: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy63); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy129); } break; case 29: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy707 = 1; } +{ yymsp[1].minor.yy353 = 1; } break; case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy707 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy353 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } break; case 31: /* cmd ::= GRANT privileges ON priv_level TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy393, &yymsp[-2].minor.yy63, &yymsp[0].minor.yy63); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy359, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129); } break; case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy393, &yymsp[-2].minor.yy63, &yymsp[0].minor.yy63); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy359, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129); } break; case 33: /* privileges ::= ALL */ -{ yymsp[0].minor.yy393 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy359 = PRIVILEGE_TYPE_ALL; } break; case 34: /* privileges ::= priv_type_list */ case 36: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==36); -{ yylhsminor.yy393 = yymsp[0].minor.yy393; } - yymsp[0].minor.yy393 = yylhsminor.yy393; +{ yylhsminor.yy359 = yymsp[0].minor.yy359; } + yymsp[0].minor.yy359 = yylhsminor.yy359; break; case 35: /* privileges ::= SUBSCRIBE */ -{ yymsp[0].minor.yy393 = PRIVILEGE_TYPE_SUBSCRIBE; } +{ yymsp[0].minor.yy359 = PRIVILEGE_TYPE_SUBSCRIBE; } break; case 37: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy393 = yymsp[-2].minor.yy393 | yymsp[0].minor.yy393; } - yymsp[-2].minor.yy393 = yylhsminor.yy393; +{ yylhsminor.yy359 = yymsp[-2].minor.yy359 | yymsp[0].minor.yy359; } + yymsp[-2].minor.yy359 = yylhsminor.yy359; break; case 38: /* priv_type ::= READ */ -{ yymsp[0].minor.yy393 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy359 = PRIVILEGE_TYPE_READ; } break; case 39: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy393 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy359 = PRIVILEGE_TYPE_WRITE; } break; case 40: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy63 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy63 = yylhsminor.yy63; +{ yylhsminor.yy129 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy129 = yylhsminor.yy129; break; case 41: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy63 = yymsp[-2].minor.yy63; } - yymsp[-2].minor.yy63 = yylhsminor.yy63; +{ yylhsminor.yy129 = yymsp[-2].minor.yy129; } + yymsp[-2].minor.yy129 = yylhsminor.yy129; break; case 42: /* priv_level ::= topic_name */ - case 282: /* sma_func_name ::= function_name */ yytestcase(yyruleno==282); - case 488: /* alias_opt ::= table_alias */ yytestcase(yyruleno==488); -{ yylhsminor.yy63 = yymsp[0].minor.yy63; } - yymsp[0].minor.yy63 = yylhsminor.yy63; + case 286: /* sma_func_name ::= function_name */ yytestcase(yyruleno==286); + case 495: /* alias_opt ::= table_alias */ yytestcase(yyruleno==495); +{ yylhsminor.yy129 = yymsp[0].minor.yy129; } + yymsp[0].minor.yy129 = yylhsminor.yy129; break; case 43: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy63, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy129, NULL); } break; case 44: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy63, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } break; case 45: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy669); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy337); } break; case 46: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy63, yymsp[0].minor.yy669); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy337); } break; case 47: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3890,50 +3962,51 @@ static YYACTIONTYPE yy_reduce( case 51: /* dnode_endpoint ::= NK_STRING */ case 52: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==52); case 53: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==53); - case 283: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==283); - case 284: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==284); - case 285: /* sma_func_name ::= LAST */ yytestcase(yyruleno==285); - case 286: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==286); - case 373: /* db_name ::= NK_ID */ yytestcase(yyruleno==373); - case 374: /* table_name ::= NK_ID */ yytestcase(yyruleno==374); - case 375: /* column_name ::= NK_ID */ yytestcase(yyruleno==375); - case 376: /* function_name ::= NK_ID */ yytestcase(yyruleno==376); - case 377: /* table_alias ::= NK_ID */ yytestcase(yyruleno==377); - case 378: /* column_alias ::= NK_ID */ yytestcase(yyruleno==378); - case 379: /* user_name ::= NK_ID */ yytestcase(yyruleno==379); - case 380: /* topic_name ::= NK_ID */ yytestcase(yyruleno==380); - case 381: /* stream_name ::= NK_ID */ yytestcase(yyruleno==381); - case 382: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==382); - case 383: /* index_name ::= NK_ID */ yytestcase(yyruleno==383); - case 423: /* noarg_func ::= NOW */ yytestcase(yyruleno==423); - case 424: /* noarg_func ::= TODAY */ yytestcase(yyruleno==424); - case 425: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==425); - case 426: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==426); - case 427: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==427); - case 428: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==428); - case 429: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==429); - case 430: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==430); - case 431: /* noarg_func ::= USER */ yytestcase(yyruleno==431); - case 432: /* star_func ::= COUNT */ yytestcase(yyruleno==432); - case 433: /* star_func ::= FIRST */ yytestcase(yyruleno==433); - case 434: /* star_func ::= LAST */ yytestcase(yyruleno==434); - case 435: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==435); -{ yylhsminor.yy63 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy63 = yylhsminor.yy63; + case 287: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==287); + case 288: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==288); + case 289: /* sma_func_name ::= LAST */ yytestcase(yyruleno==289); + case 290: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==290); + case 380: /* db_name ::= NK_ID */ yytestcase(yyruleno==380); + case 381: /* table_name ::= NK_ID */ yytestcase(yyruleno==381); + case 382: /* column_name ::= NK_ID */ yytestcase(yyruleno==382); + case 383: /* function_name ::= NK_ID */ yytestcase(yyruleno==383); + case 384: /* table_alias ::= NK_ID */ yytestcase(yyruleno==384); + case 385: /* column_alias ::= NK_ID */ yytestcase(yyruleno==385); + case 386: /* user_name ::= NK_ID */ yytestcase(yyruleno==386); + case 387: /* topic_name ::= NK_ID */ yytestcase(yyruleno==387); + case 388: /* stream_name ::= NK_ID */ yytestcase(yyruleno==388); + case 389: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==389); + case 390: /* index_name ::= NK_ID */ yytestcase(yyruleno==390); + case 430: /* noarg_func ::= NOW */ yytestcase(yyruleno==430); + case 431: /* noarg_func ::= TODAY */ yytestcase(yyruleno==431); + case 432: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==432); + case 433: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==433); + case 434: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==434); + case 435: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==435); + case 436: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==436); + case 437: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==437); + case 438: /* noarg_func ::= USER */ yytestcase(yyruleno==438); + case 439: /* star_func ::= COUNT */ yytestcase(yyruleno==439); + case 440: /* star_func ::= FIRST */ yytestcase(yyruleno==440); + case 441: /* star_func ::= LAST */ yytestcase(yyruleno==441); + case 442: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==442); +{ yylhsminor.yy129 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy129 = yylhsminor.yy129; break; case 54: /* force_opt ::= */ case 74: /* not_exists_opt ::= */ yytestcase(yyruleno==74); case 76: /* exists_opt ::= */ yytestcase(yyruleno==76); - case 303: /* analyze_opt ::= */ yytestcase(yyruleno==303); - case 310: /* agg_func_opt ::= */ yytestcase(yyruleno==310); - case 496: /* set_quantifier_opt ::= */ yytestcase(yyruleno==496); -{ yymsp[1].minor.yy669 = false; } + case 307: /* analyze_opt ::= */ yytestcase(yyruleno==307); + case 314: /* agg_func_opt ::= */ yytestcase(yyruleno==314); + case 320: /* or_replace_opt ::= */ yytestcase(yyruleno==320); + case 503: /* set_quantifier_opt ::= */ yytestcase(yyruleno==503); +{ yymsp[1].minor.yy337 = false; } break; case 55: /* force_opt ::= FORCE */ - case 304: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==304); - case 311: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==311); - case 497: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==497); -{ yymsp[0].minor.yy669 = true; } + case 308: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==308); + case 315: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==315); + case 504: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==504); +{ yymsp[0].minor.yy337 = true; } break; case 56: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3966,1403 +4039,1427 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 66: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy669, &yymsp[-1].minor.yy63, yymsp[0].minor.yy828); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy337, &yymsp[-1].minor.yy129, yymsp[0].minor.yy712); } break; case 67: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy669, &yymsp[0].minor.yy63); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy337, &yymsp[0].minor.yy129); } break; case 68: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy63); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy129); } break; case 69: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy63, yymsp[0].minor.yy828); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy712); } break; case 70: /* cmd ::= FLUSH DATABASE db_name */ -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy63); } +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy129); } break; case 71: /* cmd ::= TRIM DATABASE db_name speed_opt */ -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy63, yymsp[0].minor.yy332); } +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy310); } break; case 72: /* cmd ::= COMPACT DATABASE db_name start_opt end_opt */ -{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy63, yymsp[-1].minor.yy828, yymsp[0].minor.yy828); } +{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy129, yymsp[-1].minor.yy712, yymsp[0].minor.yy712); } break; case 73: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy669 = true; } +{ yymsp[-2].minor.yy337 = true; } break; case 75: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy669 = true; } + case 321: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==321); +{ yymsp[-1].minor.yy337 = true; } break; case 77: /* db_options ::= */ -{ yymsp[1].minor.yy828 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy712 = createDefaultDatabaseOptions(pCxt); } break; case 78: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 79: /* db_options ::= db_options CACHEMODEL NK_STRING */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 80: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 81: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 82: /* db_options ::= db_options DURATION NK_INTEGER */ case 83: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==83); -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 84: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 85: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 86: /* db_options ::= db_options KEEP integer_list */ case 87: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==87); -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_KEEP, yymsp[0].minor.yy222); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_KEEP, yymsp[0].minor.yy274); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 88: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 89: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 90: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 91: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 92: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 93: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 94: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 95: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_RETENTIONS, yymsp[0].minor.yy222); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_RETENTIONS, yymsp[0].minor.yy274); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 96: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 97: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 98: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 99: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 100: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-3].minor.yy828, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-3].minor.yy712, DB_OPTION_WAL_RETENTION_PERIOD, &t); } - yymsp[-3].minor.yy828 = yylhsminor.yy828; + yymsp[-3].minor.yy712 = yylhsminor.yy712; break; case 101: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 102: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-3].minor.yy828, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-3].minor.yy712, DB_OPTION_WAL_RETENTION_SIZE, &t); } - yymsp[-3].minor.yy828 = yylhsminor.yy828; + yymsp[-3].minor.yy712 = yylhsminor.yy712; break; case 103: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 104: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 105: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 106: /* db_options ::= db_options TABLE_PREFIX NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 107: /* db_options ::= db_options TABLE_SUFFIX NK_INTEGER */ -{ yylhsminor.yy828 = setDatabaseOption(pCxt, yymsp[-2].minor.yy828, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setDatabaseOption(pCxt, yymsp[-2].minor.yy712, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; case 108: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy828 = createAlterDatabaseOptions(pCxt); yylhsminor.yy828 = setAlterDatabaseOption(pCxt, yylhsminor.yy828, &yymsp[0].minor.yy233); } - yymsp[0].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = createAlterDatabaseOptions(pCxt); yylhsminor.yy712 = setAlterDatabaseOption(pCxt, yylhsminor.yy712, &yymsp[0].minor.yy595); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; case 109: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy828 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy828, &yymsp[0].minor.yy233); } - yymsp[-1].minor.yy828 = yylhsminor.yy828; +{ yylhsminor.yy712 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy712, &yymsp[0].minor.yy595); } + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; case 110: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy595.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy595.val = yymsp[0].minor.yy0; } break; case 111: /* alter_db_option ::= CACHEMODEL NK_STRING */ -{ yymsp[-1].minor.yy233.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy595.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy595.val = yymsp[0].minor.yy0; } break; case 112: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy595.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy595.val = yymsp[0].minor.yy0; } break; case 113: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy595.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy595.val = yymsp[0].minor.yy0; } break; case 114: /* alter_db_option ::= KEEP integer_list */ case 115: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==115); -{ yymsp[-1].minor.yy233.type = DB_OPTION_KEEP; yymsp[-1].minor.yy233.pList = yymsp[0].minor.yy222; } +{ yymsp[-1].minor.yy595.type = DB_OPTION_KEEP; yymsp[-1].minor.yy595.pList = yymsp[0].minor.yy274; } break; case 116: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = DB_OPTION_PAGES; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy595.type = DB_OPTION_PAGES; yymsp[-1].minor.yy595.val = yymsp[0].minor.yy0; } break; case 117: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy595.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy595.val = yymsp[0].minor.yy0; } break; case 118: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = DB_OPTION_WAL; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy595.type = DB_OPTION_WAL; yymsp[-1].minor.yy595.val = yymsp[0].minor.yy0; } break; case 119: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy595.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy595.val = yymsp[0].minor.yy0; } break; case 120: /* alter_db_option ::= MINROWS NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } - break; - case 121: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy222 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy222 = yylhsminor.yy222; - break; - case 122: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 342: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==342); -{ yylhsminor.yy222 = addNodeToList(pCxt, yymsp[-2].minor.yy222, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy222 = yylhsminor.yy222; - break; - case 123: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy222 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy222 = yylhsminor.yy222; - break; - case 124: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy222 = addNodeToList(pCxt, yymsp[-2].minor.yy222, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy222 = yylhsminor.yy222; - break; - case 125: /* retention_list ::= retention */ - case 155: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==155); - case 158: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==158); - case 165: /* column_def_list ::= column_def */ yytestcase(yyruleno==165); - case 209: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==209); - case 214: /* col_name_list ::= col_name */ yytestcase(yyruleno==214); - case 265: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==265); - case 279: /* func_list ::= func */ yytestcase(yyruleno==279); - case 371: /* literal_list ::= signed_literal */ yytestcase(yyruleno==371); - case 438: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==438); - case 444: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==444); - case 499: /* select_list ::= select_item */ yytestcase(yyruleno==499); - case 510: /* partition_list ::= partition_item */ yytestcase(yyruleno==510); - case 565: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==565); -{ yylhsminor.yy222 = createNodeList(pCxt, yymsp[0].minor.yy828); } - yymsp[0].minor.yy222 = yylhsminor.yy222; - break; - case 126: /* retention_list ::= retention_list NK_COMMA retention */ - case 159: /* multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ yytestcase(yyruleno==159); - case 166: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==166); - case 210: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==210); - case 215: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==215); - case 266: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==266); - case 280: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==280); - case 372: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==372); - case 439: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==439); - case 500: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==500); - case 511: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==511); - case 566: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==566); -{ yylhsminor.yy222 = addNodeToList(pCxt, yymsp[-2].minor.yy222, yymsp[0].minor.yy828); } - yymsp[-2].minor.yy222 = yylhsminor.yy222; - break; - case 127: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy828 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; - break; - case 128: /* speed_opt ::= */ - case 312: /* bufsize_opt ::= */ yytestcase(yyruleno==312); -{ yymsp[1].minor.yy332 = 0; } - break; - case 129: /* speed_opt ::= MAX_SPEED NK_INTEGER */ - case 313: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==313); -{ yymsp[-1].minor.yy332 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } - break; - case 130: /* start_opt ::= */ - case 134: /* end_opt ::= */ yytestcase(yyruleno==134); - case 259: /* like_pattern_opt ::= */ yytestcase(yyruleno==259); - case 332: /* subtable_opt ::= */ yytestcase(yyruleno==332); - case 447: /* case_when_else_opt ::= */ yytestcase(yyruleno==447); - case 477: /* from_clause_opt ::= */ yytestcase(yyruleno==477); - case 506: /* where_clause_opt ::= */ yytestcase(yyruleno==506); - case 515: /* twindow_clause_opt ::= */ yytestcase(yyruleno==515); - case 521: /* sliding_opt ::= */ yytestcase(yyruleno==521); - case 523: /* fill_opt ::= */ yytestcase(yyruleno==523); - case 537: /* having_clause_opt ::= */ yytestcase(yyruleno==537); - case 539: /* range_opt ::= */ yytestcase(yyruleno==539); - case 541: /* every_opt ::= */ yytestcase(yyruleno==541); - case 554: /* slimit_clause_opt ::= */ yytestcase(yyruleno==554); - case 558: /* limit_clause_opt ::= */ yytestcase(yyruleno==558); -{ yymsp[1].minor.yy828 = NULL; } - break; - case 131: /* start_opt ::= START WITH NK_INTEGER */ - case 135: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==135); -{ yymsp[-2].minor.yy828 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - break; - case 132: /* start_opt ::= START WITH NK_STRING */ - case 136: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==136); -{ yymsp[-2].minor.yy828 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } - break; - case 133: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ - case 137: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==137); -{ yymsp[-3].minor.yy828 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } - break; - case 138: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 140: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==140); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy669, yymsp[-5].minor.yy828, yymsp[-3].minor.yy222, yymsp[-1].minor.yy222, yymsp[0].minor.yy828); } - break; - case 139: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy222); } - break; - case 141: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy222); } - break; - case 142: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy669, yymsp[0].minor.yy828); } - break; - case 143: /* cmd ::= ALTER TABLE alter_table_clause */ - case 344: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==344); - case 345: /* cmd ::= insert_query */ yytestcase(yyruleno==345); -{ pCxt->pRootNode = yymsp[0].minor.yy828; } - break; - case 144: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy828); } - break; - case 145: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy828 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy828, yymsp[0].minor.yy828); } - yymsp[-1].minor.yy828 = yylhsminor.yy828; - break; - case 146: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy828 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy828, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy63, yymsp[0].minor.yy686); } - yymsp[-4].minor.yy828 = yylhsminor.yy828; - break; - case 147: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy828 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy828, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy63); } - yymsp[-3].minor.yy828 = yylhsminor.yy828; - break; - case 148: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy828 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy828, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy63, yymsp[0].minor.yy686); } - yymsp[-4].minor.yy828 = yylhsminor.yy828; - break; - case 149: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy828 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy828, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy63, &yymsp[0].minor.yy63); } - yymsp[-4].minor.yy828 = yylhsminor.yy828; - break; - case 150: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy828 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy828, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy63, yymsp[0].minor.yy686); } - yymsp[-4].minor.yy828 = yylhsminor.yy828; - break; - case 151: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy828 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy828, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy63); } - yymsp[-3].minor.yy828 = yylhsminor.yy828; - break; - case 152: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy828 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy828, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy63, yymsp[0].minor.yy686); } - yymsp[-4].minor.yy828 = yylhsminor.yy828; - break; - case 153: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy828 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy828, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy63, &yymsp[0].minor.yy63); } - yymsp[-4].minor.yy828 = yylhsminor.yy828; +{ yymsp[-1].minor.yy595.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy595.val = yymsp[0].minor.yy0; } + break; + case 121: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ +{ yymsp[-1].minor.yy595.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy595.val = yymsp[0].minor.yy0; } + break; + case 122: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ +{ + SToken t = yymsp[-1].minor.yy0; + t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; + yymsp[-2].minor.yy595.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy595.val = t; + } break; - case 154: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy828 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy828, &yymsp[-2].minor.yy63, yymsp[0].minor.yy828); } - yymsp[-5].minor.yy828 = yylhsminor.yy828; + case 123: /* alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ +{ yymsp[-1].minor.yy595.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy595.val = yymsp[0].minor.yy0; } break; - case 156: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 445: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==445); -{ yylhsminor.yy222 = addNodeToList(pCxt, yymsp[-1].minor.yy222, yymsp[0].minor.yy828); } - yymsp[-1].minor.yy222 = yylhsminor.yy222; + case 124: /* alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ +{ + SToken t = yymsp[-1].minor.yy0; + t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; + yymsp[-2].minor.yy595.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy595.val = t; + } + break; + case 125: /* integer_list ::= NK_INTEGER */ +{ yylhsminor.yy274 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy274 = yylhsminor.yy274; + break; + case 126: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ + case 349: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==349); +{ yylhsminor.yy274 = addNodeToList(pCxt, yymsp[-2].minor.yy274, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy274 = yylhsminor.yy274; + break; + case 127: /* variable_list ::= NK_VARIABLE */ +{ yylhsminor.yy274 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy274 = yylhsminor.yy274; + break; + case 128: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ +{ yylhsminor.yy274 = addNodeToList(pCxt, yymsp[-2].minor.yy274, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy274 = yylhsminor.yy274; + break; + case 129: /* retention_list ::= retention */ + case 159: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==159); + case 162: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==162); + case 169: /* column_def_list ::= column_def */ yytestcase(yyruleno==169); + case 213: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==213); + case 218: /* col_name_list ::= col_name */ yytestcase(yyruleno==218); + case 269: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==269); + case 283: /* func_list ::= func */ yytestcase(yyruleno==283); + case 378: /* literal_list ::= signed_literal */ yytestcase(yyruleno==378); + case 445: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==445); + case 451: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==451); + case 506: /* select_list ::= select_item */ yytestcase(yyruleno==506); + case 517: /* partition_list ::= partition_item */ yytestcase(yyruleno==517); + case 572: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==572); +{ yylhsminor.yy274 = createNodeList(pCxt, yymsp[0].minor.yy712); } + yymsp[0].minor.yy274 = yylhsminor.yy274; + break; + case 130: /* retention_list ::= retention_list NK_COMMA retention */ + case 163: /* multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ yytestcase(yyruleno==163); + case 170: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==170); + case 214: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==214); + case 219: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==219); + case 270: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==270); + case 284: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==284); + case 379: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==379); + case 446: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==446); + case 507: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==507); + case 518: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==518); + case 573: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==573); +{ yylhsminor.yy274 = addNodeToList(pCxt, yymsp[-2].minor.yy274, yymsp[0].minor.yy712); } + yymsp[-2].minor.yy274 = yylhsminor.yy274; + break; + case 131: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ +{ yylhsminor.yy712 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 132: /* speed_opt ::= */ + case 316: /* bufsize_opt ::= */ yytestcase(yyruleno==316); +{ yymsp[1].minor.yy310 = 0; } + break; + case 133: /* speed_opt ::= MAX_SPEED NK_INTEGER */ + case 317: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==317); +{ yymsp[-1].minor.yy310 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + break; + case 134: /* start_opt ::= */ + case 138: /* end_opt ::= */ yytestcase(yyruleno==138); + case 263: /* like_pattern_opt ::= */ yytestcase(yyruleno==263); + case 338: /* subtable_opt ::= */ yytestcase(yyruleno==338); + case 454: /* case_when_else_opt ::= */ yytestcase(yyruleno==454); + case 484: /* from_clause_opt ::= */ yytestcase(yyruleno==484); + case 513: /* where_clause_opt ::= */ yytestcase(yyruleno==513); + case 522: /* twindow_clause_opt ::= */ yytestcase(yyruleno==522); + case 528: /* sliding_opt ::= */ yytestcase(yyruleno==528); + case 530: /* fill_opt ::= */ yytestcase(yyruleno==530); + case 544: /* having_clause_opt ::= */ yytestcase(yyruleno==544); + case 546: /* range_opt ::= */ yytestcase(yyruleno==546); + case 548: /* every_opt ::= */ yytestcase(yyruleno==548); + case 561: /* slimit_clause_opt ::= */ yytestcase(yyruleno==561); + case 565: /* limit_clause_opt ::= */ yytestcase(yyruleno==565); +{ yymsp[1].minor.yy712 = NULL; } + break; + case 135: /* start_opt ::= START WITH NK_INTEGER */ + case 139: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==139); +{ yymsp[-2].minor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + break; + case 136: /* start_opt ::= START WITH NK_STRING */ + case 140: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==140); +{ yymsp[-2].minor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + break; + case 137: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ + case 141: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==141); +{ yymsp[-3].minor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + break; + case 142: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 144: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==144); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy337, yymsp[-5].minor.yy712, yymsp[-3].minor.yy274, yymsp[-1].minor.yy274, yymsp[0].minor.yy712); } + break; + case 143: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy274); } + break; + case 145: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy274); } + break; + case 146: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy337, yymsp[0].minor.yy712); } + break; + case 147: /* cmd ::= ALTER TABLE alter_table_clause */ + case 351: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==351); + case 352: /* cmd ::= insert_query */ yytestcase(yyruleno==352); +{ pCxt->pRootNode = yymsp[0].minor.yy712; } + break; + case 148: /* cmd ::= ALTER STABLE alter_table_clause */ +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy712); } + break; + case 149: /* alter_table_clause ::= full_table_name alter_table_options */ +{ yylhsminor.yy712 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy712, yymsp[0].minor.yy712); } + yymsp[-1].minor.yy712 = yylhsminor.yy712; + break; + case 150: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ +{ yylhsminor.yy712 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy712, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy129, yymsp[0].minor.yy184); } + yymsp[-4].minor.yy712 = yylhsminor.yy712; + break; + case 151: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ +{ yylhsminor.yy712 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy712, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy129); } + yymsp[-3].minor.yy712 = yylhsminor.yy712; + break; + case 152: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ +{ yylhsminor.yy712 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy712, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy129, yymsp[0].minor.yy184); } + yymsp[-4].minor.yy712 = yylhsminor.yy712; + break; + case 153: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ +{ yylhsminor.yy712 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy712, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } + yymsp[-4].minor.yy712 = yylhsminor.yy712; + break; + case 154: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ +{ yylhsminor.yy712 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy712, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy129, yymsp[0].minor.yy184); } + yymsp[-4].minor.yy712 = yylhsminor.yy712; + break; + case 155: /* alter_table_clause ::= full_table_name DROP TAG column_name */ +{ yylhsminor.yy712 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy712, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy129); } + yymsp[-3].minor.yy712 = yylhsminor.yy712; + break; + case 156: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ +{ yylhsminor.yy712 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy712, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy129, yymsp[0].minor.yy184); } + yymsp[-4].minor.yy712 = yylhsminor.yy712; + break; + case 157: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ +{ yylhsminor.yy712 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy712, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } + yymsp[-4].minor.yy712 = yylhsminor.yy712; + break; + case 158: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ +{ yylhsminor.yy712 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy712, &yymsp[-2].minor.yy129, yymsp[0].minor.yy712); } + yymsp[-5].minor.yy712 = yylhsminor.yy712; break; - case 157: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ -{ yylhsminor.yy828 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy669, yymsp[-8].minor.yy828, yymsp[-6].minor.yy828, yymsp[-5].minor.yy222, yymsp[-2].minor.yy222, yymsp[0].minor.yy828); } - yymsp[-9].minor.yy828 = yylhsminor.yy828; + case 160: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 452: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==452); +{ yylhsminor.yy274 = addNodeToList(pCxt, yymsp[-1].minor.yy274, yymsp[0].minor.yy712); } + yymsp[-1].minor.yy274 = yylhsminor.yy274; break; - case 160: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy828 = createDropTableClause(pCxt, yymsp[-1].minor.yy669, yymsp[0].minor.yy828); } - yymsp[-1].minor.yy828 = yylhsminor.yy828; + case 161: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */ +{ yylhsminor.yy712 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy337, yymsp[-8].minor.yy712, yymsp[-6].minor.yy712, yymsp[-5].minor.yy274, yymsp[-2].minor.yy274, yymsp[0].minor.yy712); } + yymsp[-9].minor.yy712 = yylhsminor.yy712; break; - case 161: /* specific_cols_opt ::= */ - case 192: /* tags_def_opt ::= */ yytestcase(yyruleno==192); - case 264: /* tag_list_opt ::= */ yytestcase(yyruleno==264); - case 318: /* col_list_opt ::= */ yytestcase(yyruleno==318); - case 320: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==320); - case 508: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==508); - case 533: /* group_by_clause_opt ::= */ yytestcase(yyruleno==533); - case 552: /* order_by_clause_opt ::= */ yytestcase(yyruleno==552); -{ yymsp[1].minor.yy222 = NULL; } + case 164: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy712 = createDropTableClause(pCxt, yymsp[-1].minor.yy337, yymsp[0].minor.yy712); } + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 162: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ - case 319: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==319); -{ yymsp[-2].minor.yy222 = yymsp[-1].minor.yy222; } + case 165: /* specific_cols_opt ::= */ + case 196: /* tags_def_opt ::= */ yytestcase(yyruleno==196); + case 268: /* tag_list_opt ::= */ yytestcase(yyruleno==268); + case 324: /* col_list_opt ::= */ yytestcase(yyruleno==324); + case 326: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==326); + case 515: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==515); + case 540: /* group_by_clause_opt ::= */ yytestcase(yyruleno==540); + case 559: /* order_by_clause_opt ::= */ yytestcase(yyruleno==559); +{ yymsp[1].minor.yy274 = NULL; } break; - case 163: /* full_table_name ::= table_name */ -{ yylhsminor.yy828 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy63, NULL); } - yymsp[0].minor.yy828 = yylhsminor.yy828; + case 166: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ + case 325: /* col_list_opt ::= NK_LP col_name_list NK_RP */ yytestcase(yyruleno==325); +{ yymsp[-2].minor.yy274 = yymsp[-1].minor.yy274; } break; - case 164: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy828 = createRealTableNode(pCxt, &yymsp[-2].minor.yy63, &yymsp[0].minor.yy63, NULL); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 167: /* full_table_name ::= table_name */ +{ yylhsminor.yy712 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy129, NULL); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 167: /* column_def ::= column_name type_name */ -{ yylhsminor.yy828 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy63, yymsp[0].minor.yy686, NULL); } - yymsp[-1].minor.yy828 = yylhsminor.yy828; + case 168: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy712 = createRealTableNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, NULL); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 168: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy828 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy63, yymsp[-2].minor.yy686, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy828 = yylhsminor.yy828; + case 171: /* column_def ::= column_name type_name */ +{ yylhsminor.yy712 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy184, NULL); } + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 169: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy686 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 172: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy712 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-2].minor.yy184, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy712 = yylhsminor.yy712; break; - case 170: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy686 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 173: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 171: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy686 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 174: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 172: /* type_name ::= INT */ - case 173: /* type_name ::= INTEGER */ yytestcase(yyruleno==173); -{ yymsp[0].minor.yy686 = createDataType(TSDB_DATA_TYPE_INT); } + case 175: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 174: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy686 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 176: /* type_name ::= INT */ + case 177: /* type_name ::= INTEGER */ yytestcase(yyruleno==177); +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 175: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy686 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 178: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 176: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy686 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 179: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 177: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy686 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 180: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 178: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy686 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 181: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy184 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 179: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy686 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 182: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 180: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy686 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 183: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy184 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 181: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy686 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 184: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy184 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 182: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy686 = createDataType(TSDB_DATA_TYPE_UINT); } + case 185: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy184 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 183: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy686 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 186: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy184 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 184: /* type_name ::= JSON */ -{ yymsp[0].minor.yy686 = createDataType(TSDB_DATA_TYPE_JSON); } + case 187: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy184 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 185: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy686 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 188: /* type_name ::= JSON */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 186: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy686 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 189: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy184 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 187: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy686 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 190: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 188: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy686 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 191: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 189: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy686 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 192: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy184 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 190: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy686 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 193: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy184 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 191: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy686 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 194: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy184 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 193: /* tags_def_opt ::= tags_def */ - case 321: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==321); - case 437: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==437); -{ yylhsminor.yy222 = yymsp[0].minor.yy222; } - yymsp[0].minor.yy222 = yylhsminor.yy222; + case 195: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy184 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 194: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ - case 322: /* tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ yytestcase(yyruleno==322); -{ yymsp[-3].minor.yy222 = yymsp[-1].minor.yy222; } + case 197: /* tags_def_opt ::= tags_def */ + case 327: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==327); + case 444: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==444); +{ yylhsminor.yy274 = yymsp[0].minor.yy274; } + yymsp[0].minor.yy274 = yylhsminor.yy274; break; - case 195: /* table_options ::= */ -{ yymsp[1].minor.yy828 = createDefaultTableOptions(pCxt); } + case 198: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ + case 328: /* tag_def_or_ref_opt ::= TAGS NK_LP col_name_list NK_RP */ yytestcase(yyruleno==328); +{ yymsp[-3].minor.yy274 = yymsp[-1].minor.yy274; } break; - case 196: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy828 = setTableOption(pCxt, yymsp[-2].minor.yy828, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 199: /* table_options ::= */ +{ yymsp[1].minor.yy712 = createDefaultTableOptions(pCxt); } break; - case 197: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy828 = setTableOption(pCxt, yymsp[-2].minor.yy828, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy222); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 200: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy712 = setTableOption(pCxt, yymsp[-2].minor.yy712, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 198: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy828 = setTableOption(pCxt, yymsp[-2].minor.yy828, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy222); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 201: /* table_options ::= table_options MAX_DELAY duration_list */ +{ yylhsminor.yy712 = setTableOption(pCxt, yymsp[-2].minor.yy712, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy274); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 199: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy828 = setTableOption(pCxt, yymsp[-4].minor.yy828, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy222); } - yymsp[-4].minor.yy828 = yylhsminor.yy828; + case 202: /* table_options ::= table_options WATERMARK duration_list */ +{ yylhsminor.yy712 = setTableOption(pCxt, yymsp[-2].minor.yy712, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy274); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 200: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy828 = setTableOption(pCxt, yymsp[-2].minor.yy828, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 203: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ +{ yylhsminor.yy712 = setTableOption(pCxt, yymsp[-4].minor.yy712, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy274); } + yymsp[-4].minor.yy712 = yylhsminor.yy712; break; - case 201: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy828 = setTableOption(pCxt, yymsp[-4].minor.yy828, TABLE_OPTION_SMA, yymsp[-1].minor.yy222); } - yymsp[-4].minor.yy828 = yylhsminor.yy828; + case 204: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy712 = setTableOption(pCxt, yymsp[-2].minor.yy712, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 202: /* table_options ::= table_options DELETE_MARK duration_list */ -{ yylhsminor.yy828 = setTableOption(pCxt, yymsp[-2].minor.yy828, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy222); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 205: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy712 = setTableOption(pCxt, yymsp[-4].minor.yy712, TABLE_OPTION_SMA, yymsp[-1].minor.yy274); } + yymsp[-4].minor.yy712 = yylhsminor.yy712; break; - case 203: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy828 = createAlterTableOptions(pCxt); yylhsminor.yy828 = setTableOption(pCxt, yylhsminor.yy828, yymsp[0].minor.yy233.type, &yymsp[0].minor.yy233.val); } - yymsp[0].minor.yy828 = yylhsminor.yy828; + case 206: /* table_options ::= table_options DELETE_MARK duration_list */ +{ yylhsminor.yy712 = setTableOption(pCxt, yymsp[-2].minor.yy712, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy274); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 204: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy828 = setTableOption(pCxt, yymsp[-1].minor.yy828, yymsp[0].minor.yy233.type, &yymsp[0].minor.yy233.val); } - yymsp[-1].minor.yy828 = yylhsminor.yy828; + case 207: /* alter_table_options ::= alter_table_option */ +{ yylhsminor.yy712 = createAlterTableOptions(pCxt); yylhsminor.yy712 = setTableOption(pCxt, yylhsminor.yy712, yymsp[0].minor.yy595.type, &yymsp[0].minor.yy595.val); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 205: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy233.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } + case 208: /* alter_table_options ::= alter_table_options alter_table_option */ +{ yylhsminor.yy712 = setTableOption(pCxt, yymsp[-1].minor.yy712, yymsp[0].minor.yy595.type, &yymsp[0].minor.yy595.val); } + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 206: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy233.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy233.val = yymsp[0].minor.yy0; } + case 209: /* alter_table_option ::= COMMENT NK_STRING */ +{ yymsp[-1].minor.yy595.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy595.val = yymsp[0].minor.yy0; } break; - case 207: /* duration_list ::= duration_literal */ - case 401: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==401); -{ yylhsminor.yy222 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy828)); } - yymsp[0].minor.yy222 = yylhsminor.yy222; + case 210: /* alter_table_option ::= TTL NK_INTEGER */ +{ yymsp[-1].minor.yy595.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy595.val = yymsp[0].minor.yy0; } break; - case 208: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 402: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==402); -{ yylhsminor.yy222 = addNodeToList(pCxt, yymsp[-2].minor.yy222, releaseRawExprNode(pCxt, yymsp[0].minor.yy828)); } - yymsp[-2].minor.yy222 = yylhsminor.yy222; + case 211: /* duration_list ::= duration_literal */ + case 408: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==408); +{ yylhsminor.yy274 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy712)); } + yymsp[0].minor.yy274 = yylhsminor.yy274; break; - case 211: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy828 = createFunctionNode(pCxt, &yymsp[0].minor.yy63, NULL); } - yymsp[0].minor.yy828 = yylhsminor.yy828; + case 212: /* duration_list ::= duration_list NK_COMMA duration_literal */ + case 409: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==409); +{ yylhsminor.yy274 = addNodeToList(pCxt, yymsp[-2].minor.yy274, releaseRawExprNode(pCxt, yymsp[0].minor.yy712)); } + yymsp[-2].minor.yy274 = yylhsminor.yy274; break; - case 212: /* rollup_func_name ::= FIRST */ - case 213: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==213); - case 268: /* tag_item ::= QTAGS */ yytestcase(yyruleno==268); -{ yylhsminor.yy828 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy828 = yylhsminor.yy828; + case 215: /* rollup_func_name ::= function_name */ +{ yylhsminor.yy712 = createFunctionNode(pCxt, &yymsp[0].minor.yy129, NULL); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 216: /* col_name ::= column_name */ - case 269: /* tag_item ::= column_name */ yytestcase(yyruleno==269); -{ yylhsminor.yy828 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy63); } - yymsp[0].minor.yy828 = yylhsminor.yy828; + case 216: /* rollup_func_name ::= FIRST */ + case 217: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==217); + case 272: /* tag_item ::= QTAGS */ yytestcase(yyruleno==272); +{ yylhsminor.yy712 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 217: /* cmd ::= SHOW DNODES */ + case 220: /* col_name ::= column_name */ + case 273: /* tag_item ::= column_name */ yytestcase(yyruleno==273); +{ yylhsminor.yy712 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 221: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } break; - case 218: /* cmd ::= SHOW USERS */ + case 222: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } break; - case 219: /* cmd ::= SHOW USER PRIVILEGES */ + case 223: /* cmd ::= SHOW USER PRIVILEGES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); } break; - case 220: /* cmd ::= SHOW DATABASES */ + case 224: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); } break; - case 221: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy828, yymsp[0].minor.yy828, OP_TYPE_LIKE); } + case 225: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy712, yymsp[0].minor.yy712, OP_TYPE_LIKE); } break; - case 222: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy828, yymsp[0].minor.yy828, OP_TYPE_LIKE); } + case 226: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy712, yymsp[0].minor.yy712, OP_TYPE_LIKE); } break; - case 223: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy828, NULL, OP_TYPE_LIKE); } + case 227: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy712, NULL, OP_TYPE_LIKE); } break; - case 224: /* cmd ::= SHOW MNODES */ + case 228: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } break; - case 225: /* cmd ::= SHOW QNODES */ + case 229: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } break; - case 226: /* cmd ::= SHOW FUNCTIONS */ + case 230: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; - case 227: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy828, yymsp[-1].minor.yy828, OP_TYPE_EQUAL); } + case 231: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy712, yymsp[-1].minor.yy712, OP_TYPE_EQUAL); } break; - case 228: /* cmd ::= SHOW STREAMS */ + case 232: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } break; - case 229: /* cmd ::= SHOW ACCOUNTS */ + case 233: /* cmd ::= SHOW ACCOUNTS */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } break; - case 230: /* cmd ::= SHOW APPS */ + case 234: /* cmd ::= SHOW APPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } break; - case 231: /* cmd ::= SHOW CONNECTIONS */ + case 235: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } break; - case 232: /* cmd ::= SHOW LICENCES */ - case 233: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==233); + case 236: /* cmd ::= SHOW LICENCES */ + case 237: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==237); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } break; - case 234: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy63); } + case 238: /* cmd ::= SHOW CREATE DATABASE db_name */ +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy129); } break; - case 235: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy828); } + case 239: /* cmd ::= SHOW CREATE TABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy712); } break; - case 236: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy828); } + case 240: /* cmd ::= SHOW CREATE STABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy712); } break; - case 237: /* cmd ::= SHOW QUERIES */ + case 241: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } break; - case 238: /* cmd ::= SHOW SCORES */ + case 242: /* cmd ::= SHOW SCORES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } break; - case 239: /* cmd ::= SHOW TOPICS */ + case 243: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } break; - case 240: /* cmd ::= SHOW VARIABLES */ - case 241: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==241); + case 244: /* cmd ::= SHOW VARIABLES */ + case 245: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==245); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } break; - case 242: /* cmd ::= SHOW LOCAL VARIABLES */ + case 246: /* cmd ::= SHOW LOCAL VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } break; - case 243: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy828); } + case 247: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy712); } break; - case 244: /* cmd ::= SHOW BNODES */ + case 248: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } break; - case 245: /* cmd ::= SHOW SNODES */ + case 249: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } break; - case 246: /* cmd ::= SHOW CLUSTER */ + case 250: /* cmd ::= SHOW CLUSTER */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } break; - case 247: /* cmd ::= SHOW TRANSACTIONS */ + case 251: /* cmd ::= SHOW TRANSACTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; - case 248: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy828); } + case 252: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy712); } break; - case 249: /* cmd ::= SHOW CONSUMERS */ + case 253: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } break; - case 250: /* cmd ::= SHOW SUBSCRIPTIONS */ + case 254: /* cmd ::= SHOW SUBSCRIPTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; - case 251: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy828, yymsp[-1].minor.yy828, OP_TYPE_EQUAL); } + case 255: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy712, yymsp[-1].minor.yy712, OP_TYPE_EQUAL); } break; - case 252: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy828, yymsp[0].minor.yy828, yymsp[-3].minor.yy222); } + case 256: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy712, yymsp[0].minor.yy712, yymsp[-3].minor.yy274); } break; - case 253: /* cmd ::= SHOW VNODES NK_INTEGER */ + case 257: /* cmd ::= SHOW VNODES NK_INTEGER */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } break; - case 254: /* cmd ::= SHOW VNODES NK_STRING */ + case 258: /* cmd ::= SHOW VNODES NK_STRING */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, createValueNode(pCxt, TSDB_DATA_TYPE_VARCHAR, &yymsp[0].minor.yy0)); } break; - case 255: /* cmd ::= SHOW db_name_cond_opt ALIVE */ -{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy828, QUERY_NODE_SHOW_DB_ALIVE_STMT); } + case 259: /* cmd ::= SHOW db_name_cond_opt ALIVE */ +{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy712, QUERY_NODE_SHOW_DB_ALIVE_STMT); } break; - case 256: /* cmd ::= SHOW CLUSTER ALIVE */ + case 260: /* cmd ::= SHOW CLUSTER ALIVE */ { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } break; - case 257: /* db_name_cond_opt ::= */ - case 262: /* from_db_opt ::= */ yytestcase(yyruleno==262); -{ yymsp[1].minor.yy828 = createDefaultDatabaseCondValue(pCxt); } + case 261: /* db_name_cond_opt ::= */ + case 266: /* from_db_opt ::= */ yytestcase(yyruleno==266); +{ yymsp[1].minor.yy712 = createDefaultDatabaseCondValue(pCxt); } break; - case 258: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy828 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy63); } - yymsp[-1].minor.yy828 = yylhsminor.yy828; + case 262: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy712 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy129); } + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 260: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy828 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 264: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 261: /* table_name_cond ::= table_name */ -{ yylhsminor.yy828 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy63); } - yymsp[0].minor.yy828 = yylhsminor.yy828; + case 265: /* table_name_cond ::= table_name */ +{ yylhsminor.yy712 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy129); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 263: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy828 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy63); } + case 267: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy712 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy129); } break; - case 267: /* tag_item ::= TBNAME */ -{ yylhsminor.yy828 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } - yymsp[0].minor.yy828 = yylhsminor.yy828; + case 271: /* tag_item ::= TBNAME */ +{ yylhsminor.yy712 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 270: /* tag_item ::= column_name column_alias */ -{ yylhsminor.yy828 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy63), &yymsp[0].minor.yy63); } - yymsp[-1].minor.yy828 = yylhsminor.yy828; + case 274: /* tag_item ::= column_name column_alias */ +{ yylhsminor.yy712 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy129), &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 271: /* tag_item ::= column_name AS column_alias */ -{ yylhsminor.yy828 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy63), &yymsp[0].minor.yy63); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 275: /* tag_item ::= column_name AS column_alias */ +{ yylhsminor.yy712 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy129), &yymsp[0].minor.yy129); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 272: /* cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy669, yymsp[-3].minor.yy828, yymsp[-1].minor.yy828, NULL, yymsp[0].minor.yy828); } + case 276: /* cmd ::= CREATE SMA INDEX not_exists_opt full_index_name ON full_table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy337, yymsp[-3].minor.yy712, yymsp[-1].minor.yy712, NULL, yymsp[0].minor.yy712); } break; - case 273: /* cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy669, yymsp[-5].minor.yy828, yymsp[-3].minor.yy828, yymsp[-1].minor.yy222, NULL); } + case 277: /* cmd ::= CREATE INDEX not_exists_opt full_index_name ON full_table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy337, yymsp[-5].minor.yy712, yymsp[-3].minor.yy712, yymsp[-1].minor.yy274, NULL); } break; - case 274: /* cmd ::= DROP INDEX exists_opt full_index_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy669, yymsp[0].minor.yy828); } + case 278: /* cmd ::= DROP INDEX exists_opt full_index_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy337, yymsp[0].minor.yy712); } break; - case 275: /* full_index_name ::= index_name */ -{ yylhsminor.yy828 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy63); } - yymsp[0].minor.yy828 = yylhsminor.yy828; + case 279: /* full_index_name ::= index_name */ +{ yylhsminor.yy712 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy129); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 276: /* full_index_name ::= db_name NK_DOT index_name */ -{ yylhsminor.yy828 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy63, &yymsp[0].minor.yy63); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 280: /* full_index_name ::= db_name NK_DOT index_name */ +{ yylhsminor.yy712 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 277: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy828 = createIndexOption(pCxt, yymsp[-7].minor.yy222, releaseRawExprNode(pCxt, yymsp[-3].minor.yy828), NULL, yymsp[-1].minor.yy828, yymsp[0].minor.yy828); } + case 281: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-9].minor.yy712 = createIndexOption(pCxt, yymsp[-7].minor.yy274, releaseRawExprNode(pCxt, yymsp[-3].minor.yy712), NULL, yymsp[-1].minor.yy712, yymsp[0].minor.yy712); } break; - case 278: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-11].minor.yy828 = createIndexOption(pCxt, yymsp[-9].minor.yy222, releaseRawExprNode(pCxt, yymsp[-5].minor.yy828), releaseRawExprNode(pCxt, yymsp[-3].minor.yy828), yymsp[-1].minor.yy828, yymsp[0].minor.yy828); } + case 282: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ +{ yymsp[-11].minor.yy712 = createIndexOption(pCxt, yymsp[-9].minor.yy274, releaseRawExprNode(pCxt, yymsp[-5].minor.yy712), releaseRawExprNode(pCxt, yymsp[-3].minor.yy712), yymsp[-1].minor.yy712, yymsp[0].minor.yy712); } break; - case 281: /* func ::= sma_func_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy828 = createFunctionNode(pCxt, &yymsp[-3].minor.yy63, yymsp[-1].minor.yy222); } - yymsp[-3].minor.yy828 = yylhsminor.yy828; + case 285: /* func ::= sma_func_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy712 = createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy274); } + yymsp[-3].minor.yy712 = yylhsminor.yy712; break; - case 287: /* sma_stream_opt ::= */ - case 323: /* stream_options ::= */ yytestcase(yyruleno==323); -{ yymsp[1].minor.yy828 = createStreamOptions(pCxt); } + case 291: /* sma_stream_opt ::= */ + case 329: /* stream_options ::= */ yytestcase(yyruleno==329); +{ yymsp[1].minor.yy712 = createStreamOptions(pCxt); } break; - case 288: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy828)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy828); yylhsminor.yy828 = yymsp[-2].minor.yy828; } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 292: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy712)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy712); yylhsminor.yy712 = yymsp[-2].minor.yy712; } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 289: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy828)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy828); yylhsminor.yy828 = yymsp[-2].minor.yy828; } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 293: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy712)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy712); yylhsminor.yy712 = yymsp[-2].minor.yy712; } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 290: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy828)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy828); yylhsminor.yy828 = yymsp[-2].minor.yy828; } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 294: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy712)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy712); yylhsminor.yy712 = yymsp[-2].minor.yy712; } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 291: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy669, &yymsp[-2].minor.yy63, yymsp[0].minor.yy828); } + case 295: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy337, &yymsp[-2].minor.yy129, yymsp[0].minor.yy712); } break; - case 292: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy669, &yymsp[-3].minor.yy63, &yymsp[0].minor.yy63, false); } + case 296: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy337, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy129, false); } break; - case 293: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy669, &yymsp[-5].minor.yy63, &yymsp[0].minor.yy63, true); } + case 297: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy337, &yymsp[-5].minor.yy129, &yymsp[0].minor.yy129, true); } break; - case 294: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy669, &yymsp[-3].minor.yy63, yymsp[0].minor.yy828, false); } + case 298: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy337, &yymsp[-3].minor.yy129, yymsp[0].minor.yy712, false); } break; - case 295: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy669, &yymsp[-5].minor.yy63, yymsp[0].minor.yy828, true); } + case 299: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy337, &yymsp[-5].minor.yy129, yymsp[0].minor.yy712, true); } break; - case 296: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy669, &yymsp[0].minor.yy63); } + case 300: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy337, &yymsp[0].minor.yy129); } break; - case 297: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy669, &yymsp[-2].minor.yy63, &yymsp[0].minor.yy63); } + case 301: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy337, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129); } break; - case 298: /* cmd ::= DESC full_table_name */ - case 299: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==299); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy828); } + case 302: /* cmd ::= DESC full_table_name */ + case 303: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==303); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy712); } break; - case 300: /* cmd ::= RESET QUERY CACHE */ + case 304: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 301: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - case 302: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==302); -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy669, yymsp[-1].minor.yy828, yymsp[0].minor.yy828); } + case 305: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + case 306: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==306); +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy337, yymsp[-1].minor.yy712, yymsp[0].minor.yy712); } break; - case 305: /* explain_options ::= */ -{ yymsp[1].minor.yy828 = createDefaultExplainOptions(pCxt); } + case 309: /* explain_options ::= */ +{ yymsp[1].minor.yy712 = createDefaultExplainOptions(pCxt); } break; - case 306: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy828 = setExplainVerbose(pCxt, yymsp[-2].minor.yy828, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 310: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy712 = setExplainVerbose(pCxt, yymsp[-2].minor.yy712, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 307: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy828 = setExplainRatio(pCxt, yymsp[-2].minor.yy828, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 311: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy712 = setExplainRatio(pCxt, yymsp[-2].minor.yy712, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 308: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy669, yymsp[-9].minor.yy669, &yymsp[-6].minor.yy63, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy686, yymsp[-1].minor.yy332, &yymsp[0].minor.yy63); } + case 312: /* cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy337, yymsp[-9].minor.yy337, &yymsp[-6].minor.yy129, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy184, yymsp[-1].minor.yy310, &yymsp[0].minor.yy129, yymsp[-10].minor.yy337); } break; - case 309: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy669, &yymsp[0].minor.yy63); } + case 313: /* cmd ::= DROP FUNCTION exists_opt function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy337, &yymsp[0].minor.yy129); } break; - case 314: /* language_opt ::= */ -{ yymsp[1].minor.yy63 = nil_token; } + case 318: /* language_opt ::= */ +{ yymsp[1].minor.yy129 = nil_token; } break; - case 315: /* language_opt ::= LANGUAGE NK_STRING */ -{ yymsp[-1].minor.yy63 = yymsp[0].minor.yy0; } + case 319: /* language_opt ::= LANGUAGE NK_STRING */ +{ yymsp[-1].minor.yy129 = yymsp[0].minor.yy0; } break; - case 316: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy669, &yymsp[-8].minor.yy63, yymsp[-5].minor.yy828, yymsp[-7].minor.yy828, yymsp[-3].minor.yy222, yymsp[-2].minor.yy828, yymsp[0].minor.yy828, yymsp[-4].minor.yy222); } + case 322: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy337, &yymsp[-8].minor.yy129, yymsp[-5].minor.yy712, yymsp[-7].minor.yy712, yymsp[-3].minor.yy274, yymsp[-2].minor.yy712, yymsp[0].minor.yy712, yymsp[-4].minor.yy274); } break; - case 317: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy669, &yymsp[0].minor.yy63); } + case 323: /* cmd ::= DROP STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy337, &yymsp[0].minor.yy129); } break; - case 324: /* stream_options ::= stream_options TRIGGER AT_ONCE */ - case 325: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==325); -{ yylhsminor.yy828 = setStreamOptions(pCxt, yymsp[-2].minor.yy828, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 330: /* stream_options ::= stream_options TRIGGER AT_ONCE */ + case 331: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==331); +{ yylhsminor.yy712 = setStreamOptions(pCxt, yymsp[-2].minor.yy712, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 326: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ yylhsminor.yy828 = setStreamOptions(pCxt, yymsp[-3].minor.yy828, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy828)); } - yymsp[-3].minor.yy828 = yylhsminor.yy828; + case 332: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +{ yylhsminor.yy712 = setStreamOptions(pCxt, yymsp[-3].minor.yy712, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy712)); } + yymsp[-3].minor.yy712 = yylhsminor.yy712; break; - case 327: /* stream_options ::= stream_options WATERMARK duration_literal */ -{ yylhsminor.yy828 = setStreamOptions(pCxt, yymsp[-2].minor.yy828, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy828)); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 333: /* stream_options ::= stream_options WATERMARK duration_literal */ +{ yylhsminor.yy712 = setStreamOptions(pCxt, yymsp[-2].minor.yy712, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy712)); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 328: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -{ yylhsminor.yy828 = setStreamOptions(pCxt, yymsp[-3].minor.yy828, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-3].minor.yy828 = yylhsminor.yy828; + case 334: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ +{ yylhsminor.yy712 = setStreamOptions(pCxt, yymsp[-3].minor.yy712, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-3].minor.yy712 = yylhsminor.yy712; break; - case 329: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ -{ yylhsminor.yy828 = setStreamOptions(pCxt, yymsp[-2].minor.yy828, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 335: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ +{ yylhsminor.yy712 = setStreamOptions(pCxt, yymsp[-2].minor.yy712, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 330: /* stream_options ::= stream_options DELETE_MARK duration_literal */ -{ yylhsminor.yy828 = setStreamOptions(pCxt, yymsp[-2].minor.yy828, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy828)); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 336: /* stream_options ::= stream_options DELETE_MARK duration_literal */ +{ yylhsminor.yy712 = setStreamOptions(pCxt, yymsp[-2].minor.yy712, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy712)); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 331: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ -{ yylhsminor.yy828 = setStreamOptions(pCxt, yymsp[-3].minor.yy828, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-3].minor.yy828 = yylhsminor.yy828; + case 337: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ +{ yylhsminor.yy712 = setStreamOptions(pCxt, yymsp[-3].minor.yy712, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } + yymsp[-3].minor.yy712 = yylhsminor.yy712; break; - case 333: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 522: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==522); - case 542: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==542); -{ yymsp[-3].minor.yy828 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy828); } + case 339: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 529: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==529); + case 549: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==549); +{ yymsp[-3].minor.yy712 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy712); } break; - case 334: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 340: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 335: /* cmd ::= KILL QUERY NK_STRING */ + case 341: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 336: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 342: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 337: /* cmd ::= BALANCE VGROUP */ + case 343: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 338: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 344: /* cmd ::= BALANCE VGROUP LEADER */ +{ pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt); } + break; + case 345: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 339: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy222); } + case 346: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy274); } break; - case 340: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 347: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 341: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy222 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - break; - case 343: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy828, yymsp[0].minor.yy828); } - break; - case 346: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -{ yymsp[-6].minor.yy828 = createInsertStmt(pCxt, yymsp[-4].minor.yy828, yymsp[-2].minor.yy222, yymsp[0].minor.yy828); } - break; - case 347: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ -{ yymsp[-3].minor.yy828 = createInsertStmt(pCxt, yymsp[-1].minor.yy828, NULL, yymsp[0].minor.yy828); } - break; - case 348: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy828 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy828 = yylhsminor.yy828; - break; - case 349: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy828 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy828 = yylhsminor.yy828; - break; - case 350: /* literal ::= NK_STRING */ -{ yylhsminor.yy828 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy828 = yylhsminor.yy828; - break; - case 351: /* literal ::= NK_BOOL */ -{ yylhsminor.yy828 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy828 = yylhsminor.yy828; - break; - case 352: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy828 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy828 = yylhsminor.yy828; - break; - case 353: /* literal ::= duration_literal */ - case 363: /* signed_literal ::= signed */ yytestcase(yyruleno==363); - case 384: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==384); - case 385: /* expression ::= literal */ yytestcase(yyruleno==385); - case 386: /* expression ::= pseudo_column */ yytestcase(yyruleno==386); - case 387: /* expression ::= column_reference */ yytestcase(yyruleno==387); - case 388: /* expression ::= function_expression */ yytestcase(yyruleno==388); - case 389: /* expression ::= case_when_expression */ yytestcase(yyruleno==389); - case 420: /* function_expression ::= literal_func */ yytestcase(yyruleno==420); - case 469: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==469); - case 473: /* boolean_primary ::= predicate */ yytestcase(yyruleno==473); - case 475: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==475); - case 476: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==476); - case 479: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==479); - case 481: /* table_reference ::= table_primary */ yytestcase(yyruleno==481); - case 482: /* table_reference ::= joined_table */ yytestcase(yyruleno==482); - case 486: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==486); - case 544: /* query_simple ::= query_specification */ yytestcase(yyruleno==544); - case 545: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==545); - case 548: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==548); - case 550: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==550); -{ yylhsminor.yy828 = yymsp[0].minor.yy828; } - yymsp[0].minor.yy828 = yylhsminor.yy828; - break; - case 354: /* literal ::= NULL */ -{ yylhsminor.yy828 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy828 = yylhsminor.yy828; - break; - case 355: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy828 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy828 = yylhsminor.yy828; - break; - case 356: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy828 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy828 = yylhsminor.yy828; - break; - case 357: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy828 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy828 = yylhsminor.yy828; - break; - case 358: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy828 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - break; - case 359: /* signed ::= NK_MINUS NK_INTEGER */ + case 348: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy274 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + break; + case 350: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy712, yymsp[0].minor.yy712); } + break; + case 353: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ +{ yymsp[-6].minor.yy712 = createInsertStmt(pCxt, yymsp[-4].minor.yy712, yymsp[-2].minor.yy274, yymsp[0].minor.yy712); } + break; + case 354: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ +{ yymsp[-3].minor.yy712 = createInsertStmt(pCxt, yymsp[-1].minor.yy712, NULL, yymsp[0].minor.yy712); } + break; + case 355: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy712 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 356: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy712 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 357: /* literal ::= NK_STRING */ +{ yylhsminor.yy712 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 358: /* literal ::= NK_BOOL */ +{ yylhsminor.yy712 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 359: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy712 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy712 = yylhsminor.yy712; + break; + case 360: /* literal ::= duration_literal */ + case 370: /* signed_literal ::= signed */ yytestcase(yyruleno==370); + case 391: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==391); + case 392: /* expression ::= literal */ yytestcase(yyruleno==392); + case 393: /* expression ::= pseudo_column */ yytestcase(yyruleno==393); + case 394: /* expression ::= column_reference */ yytestcase(yyruleno==394); + case 395: /* expression ::= function_expression */ yytestcase(yyruleno==395); + case 396: /* expression ::= case_when_expression */ yytestcase(yyruleno==396); + case 427: /* function_expression ::= literal_func */ yytestcase(yyruleno==427); + case 476: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==476); + case 480: /* boolean_primary ::= predicate */ yytestcase(yyruleno==480); + case 482: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==482); + case 483: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==483); + case 486: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==486); + case 488: /* table_reference ::= table_primary */ yytestcase(yyruleno==488); + case 489: /* table_reference ::= joined_table */ yytestcase(yyruleno==489); + case 493: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==493); + case 551: /* query_simple ::= query_specification */ yytestcase(yyruleno==551); + case 552: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==552); + case 555: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==555); + case 557: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==557); +{ yylhsminor.yy712 = yymsp[0].minor.yy712; } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 361: /* literal ::= NULL */ +{ yylhsminor.yy712 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 362: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy712 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 363: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy712 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 364: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 365: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + break; + case 366: /* 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.yy828 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy828 = yylhsminor.yy828; + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 360: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy828 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy828 = yylhsminor.yy828; + case 367: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 361: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy828 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 368: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 362: /* signed ::= NK_MINUS NK_FLOAT */ + case 369: /* 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.yy828 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy828 = yylhsminor.yy828; - break; - case 364: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy828 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy828 = yylhsminor.yy828; - break; - case 365: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy828 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy828 = yylhsminor.yy828; - break; - case 366: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy828 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } - break; - case 367: /* signed_literal ::= duration_literal */ - case 369: /* signed_literal ::= literal_func */ yytestcase(yyruleno==369); - case 440: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==440); - case 502: /* select_item ::= common_expression */ yytestcase(yyruleno==502); - case 512: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==512); - case 549: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==549); - case 551: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==551); - case 564: /* search_condition ::= common_expression */ yytestcase(yyruleno==564); -{ yylhsminor.yy828 = releaseRawExprNode(pCxt, yymsp[0].minor.yy828); } - yymsp[0].minor.yy828 = yylhsminor.yy828; - break; - case 368: /* signed_literal ::= NULL */ -{ yylhsminor.yy828 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy828 = yylhsminor.yy828; - break; - case 370: /* signed_literal ::= NK_QUESTION */ -{ yylhsminor.yy828 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy828 = yylhsminor.yy828; - break; - case 390: /* expression ::= NK_LP expression NK_RP */ - case 474: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==474); - case 563: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==563); -{ yylhsminor.yy828 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy828)); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; - break; - case 391: /* expression ::= NK_PLUS expr_or_subquery */ + yymsp[-1].minor.yy712 = yylhsminor.yy712; + break; + case 371: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 372: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 373: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + break; + case 374: /* signed_literal ::= duration_literal */ + case 376: /* signed_literal ::= literal_func */ yytestcase(yyruleno==376); + case 447: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==447); + case 509: /* select_item ::= common_expression */ yytestcase(yyruleno==509); + case 519: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==519); + case 556: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==556); + case 558: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==558); + case 571: /* search_condition ::= common_expression */ yytestcase(yyruleno==571); +{ yylhsminor.yy712 = releaseRawExprNode(pCxt, yymsp[0].minor.yy712); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 375: /* signed_literal ::= NULL */ +{ yylhsminor.yy712 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 377: /* signed_literal ::= NK_QUESTION */ +{ yylhsminor.yy712 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 397: /* expression ::= NK_LP expression NK_RP */ + case 481: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==481); + case 570: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==570); +{ yylhsminor.yy712 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy712)); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 398: /* expression ::= NK_PLUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy828)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy712)); } - yymsp[-1].minor.yy828 = yylhsminor.yy828; + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 392: /* expression ::= NK_MINUS expr_or_subquery */ + case 399: /* expression ::= NK_MINUS expr_or_subquery */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy828), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy712), NULL)); } - yymsp[-1].minor.yy828 = yylhsminor.yy828; + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 393: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + case 400: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy828); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), releaseRawExprNode(pCxt, yymsp[0].minor.yy828))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy712); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 394: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + case 401: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy828); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), releaseRawExprNode(pCxt, yymsp[0].minor.yy828))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy712); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 395: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + case 402: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy828); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), releaseRawExprNode(pCxt, yymsp[0].minor.yy828))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy712); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 396: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + case 403: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy828); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), releaseRawExprNode(pCxt, yymsp[0].minor.yy828))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy712); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 397: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ + case 404: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy828); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), releaseRawExprNode(pCxt, yymsp[0].minor.yy828))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy712); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 398: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 405: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 399: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + case 406: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy828); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), releaseRawExprNode(pCxt, yymsp[0].minor.yy828))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy712); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 400: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + case 407: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy828); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), releaseRawExprNode(pCxt, yymsp[0].minor.yy828))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy712); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; - break; - case 403: /* column_reference ::= column_name */ -{ yylhsminor.yy828 = createRawExprNode(pCxt, &yymsp[0].minor.yy63, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy63)); } - yymsp[0].minor.yy828 = yylhsminor.yy828; - break; - case 404: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy828 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy63, &yymsp[0].minor.yy63, createColumnNode(pCxt, &yymsp[-2].minor.yy63, &yymsp[0].minor.yy63)); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; - break; - case 405: /* pseudo_column ::= ROWTS */ - case 406: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==406); - case 408: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==408); - case 409: /* pseudo_column ::= QEND */ yytestcase(yyruleno==409); - case 410: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==410); - case 411: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==411); - case 412: /* pseudo_column ::= WEND */ yytestcase(yyruleno==412); - case 413: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==413); - case 414: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==414); - case 415: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==415); - case 416: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==416); - case 422: /* literal_func ::= NOW */ yytestcase(yyruleno==422); -{ yylhsminor.yy828 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy828 = yylhsminor.yy828; - break; - case 407: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy828 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy63, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy63)))); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; - break; - case 417: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 418: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==418); -{ yylhsminor.yy828 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy63, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy63, yymsp[-1].minor.yy222)); } - yymsp[-3].minor.yy828 = yylhsminor.yy828; - break; - case 419: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ -{ yylhsminor.yy828 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy828), yymsp[-1].minor.yy686)); } - yymsp[-5].minor.yy828 = yylhsminor.yy828; - break; - case 421: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy828 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy63, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy63, NULL)); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; - break; - case 436: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy222 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy222 = yylhsminor.yy222; - break; - case 441: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 505: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==505); -{ yylhsminor.yy828 = createColumnNode(pCxt, &yymsp[-2].minor.yy63, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; - break; - case 442: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -{ yylhsminor.yy828 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy222, yymsp[-1].minor.yy828)); } - yymsp[-3].minor.yy828 = yylhsminor.yy828; - break; - case 443: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -{ yylhsminor.yy828 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy828), yymsp[-2].minor.yy222, yymsp[-1].minor.yy828)); } - yymsp[-4].minor.yy828 = yylhsminor.yy828; - break; - case 446: /* when_then_expr ::= WHEN common_expression THEN common_expression */ -{ yymsp[-3].minor.yy828 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), releaseRawExprNode(pCxt, yymsp[0].minor.yy828)); } - break; - case 448: /* case_when_else_opt ::= ELSE common_expression */ -{ yymsp[-1].minor.yy828 = releaseRawExprNode(pCxt, yymsp[0].minor.yy828); } - break; - case 449: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 454: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==454); + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 410: /* column_reference ::= column_name */ +{ yylhsminor.yy712 = createRawExprNode(pCxt, &yymsp[0].minor.yy129, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129)); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 411: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy712 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129)); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 412: /* pseudo_column ::= ROWTS */ + case 413: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==413); + case 415: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==415); + case 416: /* pseudo_column ::= QEND */ yytestcase(yyruleno==416); + case 417: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==417); + case 418: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==418); + case 419: /* pseudo_column ::= WEND */ yytestcase(yyruleno==419); + case 420: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==420); + case 421: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==421); + case 422: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==422); + case 423: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==423); + case 429: /* literal_func ::= NOW */ yytestcase(yyruleno==429); +{ yylhsminor.yy712 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy712 = yylhsminor.yy712; + break; + case 414: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy712 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy129)))); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 424: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 425: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==425); +{ yylhsminor.yy712 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy274)); } + yymsp[-3].minor.yy712 = yylhsminor.yy712; + break; + case 426: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ +{ yylhsminor.yy712 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy712), yymsp[-1].minor.yy184)); } + yymsp[-5].minor.yy712 = yylhsminor.yy712; + break; + case 428: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy712 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy129, NULL)); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 443: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy274 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy274 = yylhsminor.yy274; + break; + case 448: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 512: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==512); +{ yylhsminor.yy712 = createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; + break; + case 449: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ +{ yylhsminor.yy712 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy274, yymsp[-1].minor.yy712)); } + yymsp[-3].minor.yy712 = yylhsminor.yy712; + break; + case 450: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ +{ yylhsminor.yy712 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy712), yymsp[-2].minor.yy274, yymsp[-1].minor.yy712)); } + yymsp[-4].minor.yy712 = yylhsminor.yy712; + break; + case 453: /* when_then_expr ::= WHEN common_expression THEN common_expression */ +{ yymsp[-3].minor.yy712 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), releaseRawExprNode(pCxt, yymsp[0].minor.yy712)); } + break; + case 455: /* case_when_else_opt ::= ELSE common_expression */ +{ yymsp[-1].minor.yy712 = releaseRawExprNode(pCxt, yymsp[0].minor.yy712); } + break; + case 456: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 461: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==461); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy828); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy62, releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), releaseRawExprNode(pCxt, yymsp[0].minor.yy828))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy712); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy440, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 450: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + case 457: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy828); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy828), releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), releaseRawExprNode(pCxt, yymsp[0].minor.yy828))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy712); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy712), releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } - yymsp[-4].minor.yy828 = yylhsminor.yy828; + yymsp[-4].minor.yy712 = yylhsminor.yy712; break; - case 451: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + case 458: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy828); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy828), releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), releaseRawExprNode(pCxt, yymsp[0].minor.yy828))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy712); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy712), releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } - yymsp[-5].minor.yy828 = yylhsminor.yy828; + yymsp[-5].minor.yy712 = yylhsminor.yy712; break; - case 452: /* predicate ::= expr_or_subquery IS NULL */ + case 459: /* predicate ::= expr_or_subquery IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), NULL)); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 453: /* predicate ::= expr_or_subquery IS NOT NULL */ + case 460: /* predicate ::= expr_or_subquery IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy828), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy712), NULL)); } - yymsp[-3].minor.yy828 = yylhsminor.yy828; + yymsp[-3].minor.yy712 = yylhsminor.yy712; break; - case 455: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy62 = OP_TYPE_LOWER_THAN; } + case 462: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy440 = OP_TYPE_LOWER_THAN; } break; - case 456: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy62 = OP_TYPE_GREATER_THAN; } + case 463: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy440 = OP_TYPE_GREATER_THAN; } break; - case 457: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy62 = OP_TYPE_LOWER_EQUAL; } + case 464: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy440 = OP_TYPE_LOWER_EQUAL; } break; - case 458: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy62 = OP_TYPE_GREATER_EQUAL; } + case 465: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy440 = OP_TYPE_GREATER_EQUAL; } break; - case 459: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy62 = OP_TYPE_NOT_EQUAL; } + case 466: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy440 = OP_TYPE_NOT_EQUAL; } break; - case 460: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy62 = OP_TYPE_EQUAL; } + case 467: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy440 = OP_TYPE_EQUAL; } break; - case 461: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy62 = OP_TYPE_LIKE; } + case 468: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy440 = OP_TYPE_LIKE; } break; - case 462: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy62 = OP_TYPE_NOT_LIKE; } + case 469: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy440 = OP_TYPE_NOT_LIKE; } break; - case 463: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy62 = OP_TYPE_MATCH; } + case 470: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy440 = OP_TYPE_MATCH; } break; - case 464: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy62 = OP_TYPE_NMATCH; } + case 471: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy440 = OP_TYPE_NMATCH; } break; - case 465: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy62 = OP_TYPE_JSON_CONTAINS; } + case 472: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy440 = OP_TYPE_JSON_CONTAINS; } break; - case 466: /* in_op ::= IN */ -{ yymsp[0].minor.yy62 = OP_TYPE_IN; } + case 473: /* in_op ::= IN */ +{ yymsp[0].minor.yy440 = OP_TYPE_IN; } break; - case 467: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy62 = OP_TYPE_NOT_IN; } + case 474: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy440 = OP_TYPE_NOT_IN; } break; - case 468: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -{ yylhsminor.yy828 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy222)); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 475: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +{ yylhsminor.yy712 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy274)); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 470: /* boolean_value_expression ::= NOT boolean_primary */ + case 477: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy828), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy712), NULL)); } - yymsp[-1].minor.yy828 = yylhsminor.yy828; + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 471: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 478: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy828); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), releaseRawExprNode(pCxt, yymsp[0].minor.yy828))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy712); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 472: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 479: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy828); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy828); - yylhsminor.yy828 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), releaseRawExprNode(pCxt, yymsp[0].minor.yy828))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy712); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy712); + yylhsminor.yy712 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 478: /* from_clause_opt ::= FROM table_reference_list */ - case 507: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==507); - case 538: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==538); -{ yymsp[-1].minor.yy828 = yymsp[0].minor.yy828; } + case 485: /* from_clause_opt ::= FROM table_reference_list */ + case 514: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==514); + case 545: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==545); +{ yymsp[-1].minor.yy712 = yymsp[0].minor.yy712; } break; - case 480: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy828 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy828, yymsp[0].minor.yy828, NULL); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 487: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy712 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy712, yymsp[0].minor.yy712, NULL); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 483: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy828 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy63, &yymsp[0].minor.yy63); } - yymsp[-1].minor.yy828 = yylhsminor.yy828; + case 490: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy712 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 484: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy828 = createRealTableNode(pCxt, &yymsp[-3].minor.yy63, &yymsp[-1].minor.yy63, &yymsp[0].minor.yy63); } - yymsp[-3].minor.yy828 = yylhsminor.yy828; + case 491: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy712 = createRealTableNode(pCxt, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } + yymsp[-3].minor.yy712 = yylhsminor.yy712; break; - case 485: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy828 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy828), &yymsp[0].minor.yy63); } - yymsp[-1].minor.yy828 = yylhsminor.yy828; + case 492: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy712 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy712), &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 487: /* alias_opt ::= */ -{ yymsp[1].minor.yy63 = nil_token; } + case 494: /* alias_opt ::= */ +{ yymsp[1].minor.yy129 = nil_token; } break; - case 489: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy63 = yymsp[0].minor.yy63; } + case 496: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy129 = yymsp[0].minor.yy129; } break; - case 490: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 491: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==491); -{ yymsp[-2].minor.yy828 = yymsp[-1].minor.yy828; } + case 497: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 498: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==498); +{ yymsp[-2].minor.yy712 = yymsp[-1].minor.yy712; } break; - case 492: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy828 = createJoinTableNode(pCxt, yymsp[-4].minor.yy574, yymsp[-5].minor.yy828, yymsp[-2].minor.yy828, yymsp[0].minor.yy828); } - yymsp[-5].minor.yy828 = yylhsminor.yy828; + case 499: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy712 = createJoinTableNode(pCxt, yymsp[-4].minor.yy912, yymsp[-5].minor.yy712, yymsp[-2].minor.yy712, yymsp[0].minor.yy712); } + yymsp[-5].minor.yy712 = yylhsminor.yy712; break; - case 493: /* join_type ::= */ -{ yymsp[1].minor.yy574 = JOIN_TYPE_INNER; } + case 500: /* join_type ::= */ +{ yymsp[1].minor.yy912 = JOIN_TYPE_INNER; } break; - case 494: /* join_type ::= INNER */ -{ yymsp[0].minor.yy574 = JOIN_TYPE_INNER; } + case 501: /* join_type ::= INNER */ +{ yymsp[0].minor.yy912 = JOIN_TYPE_INNER; } break; - case 495: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 502: /* 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.yy828 = createSelectStmt(pCxt, yymsp[-10].minor.yy669, yymsp[-9].minor.yy222, yymsp[-8].minor.yy828); - yymsp[-11].minor.yy828 = addWhereClause(pCxt, yymsp[-11].minor.yy828, yymsp[-7].minor.yy828); - yymsp[-11].minor.yy828 = addPartitionByClause(pCxt, yymsp[-11].minor.yy828, yymsp[-6].minor.yy222); - yymsp[-11].minor.yy828 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy828, yymsp[-2].minor.yy828); - yymsp[-11].minor.yy828 = addGroupByClause(pCxt, yymsp[-11].minor.yy828, yymsp[-1].minor.yy222); - yymsp[-11].minor.yy828 = addHavingClause(pCxt, yymsp[-11].minor.yy828, yymsp[0].minor.yy828); - yymsp[-11].minor.yy828 = addRangeClause(pCxt, yymsp[-11].minor.yy828, yymsp[-5].minor.yy828); - yymsp[-11].minor.yy828 = addEveryClause(pCxt, yymsp[-11].minor.yy828, yymsp[-4].minor.yy828); - yymsp[-11].minor.yy828 = addFillClause(pCxt, yymsp[-11].minor.yy828, yymsp[-3].minor.yy828); + yymsp[-11].minor.yy712 = createSelectStmt(pCxt, yymsp[-10].minor.yy337, yymsp[-9].minor.yy274, yymsp[-8].minor.yy712); + yymsp[-11].minor.yy712 = addWhereClause(pCxt, yymsp[-11].minor.yy712, yymsp[-7].minor.yy712); + yymsp[-11].minor.yy712 = addPartitionByClause(pCxt, yymsp[-11].minor.yy712, yymsp[-6].minor.yy274); + yymsp[-11].minor.yy712 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy712, yymsp[-2].minor.yy712); + yymsp[-11].minor.yy712 = addGroupByClause(pCxt, yymsp[-11].minor.yy712, yymsp[-1].minor.yy274); + yymsp[-11].minor.yy712 = addHavingClause(pCxt, yymsp[-11].minor.yy712, yymsp[0].minor.yy712); + yymsp[-11].minor.yy712 = addRangeClause(pCxt, yymsp[-11].minor.yy712, yymsp[-5].minor.yy712); + yymsp[-11].minor.yy712 = addEveryClause(pCxt, yymsp[-11].minor.yy712, yymsp[-4].minor.yy712); + yymsp[-11].minor.yy712 = addFillClause(pCxt, yymsp[-11].minor.yy712, yymsp[-3].minor.yy712); } break; - case 498: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy669 = false; } + case 505: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy337 = false; } break; - case 501: /* select_item ::= NK_STAR */ -{ yylhsminor.yy828 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy828 = yylhsminor.yy828; + case 508: /* select_item ::= NK_STAR */ +{ yylhsminor.yy712 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy712 = yylhsminor.yy712; break; - case 503: /* select_item ::= common_expression column_alias */ - case 513: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==513); -{ yylhsminor.yy828 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy828), &yymsp[0].minor.yy63); } - yymsp[-1].minor.yy828 = yylhsminor.yy828; + case 510: /* select_item ::= common_expression column_alias */ + case 520: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==520); +{ yylhsminor.yy712 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy712), &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy712 = yylhsminor.yy712; break; - case 504: /* select_item ::= common_expression AS column_alias */ - case 514: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==514); -{ yylhsminor.yy828 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), &yymsp[0].minor.yy63); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 511: /* select_item ::= common_expression AS column_alias */ + case 521: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==521); +{ yylhsminor.yy712 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), &yymsp[0].minor.yy129); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 509: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 534: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==534); - case 553: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==553); -{ yymsp[-2].minor.yy222 = yymsp[0].minor.yy222; } + case 516: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 541: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==541); + case 560: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==560); +{ yymsp[-2].minor.yy274 = yymsp[0].minor.yy274; } break; - case 516: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy828 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy828), releaseRawExprNode(pCxt, yymsp[-1].minor.yy828)); } + case 523: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy712 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy712), releaseRawExprNode(pCxt, yymsp[-1].minor.yy712)); } break; - case 517: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy828 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy828)); } + case 524: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ +{ yymsp[-3].minor.yy712 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy712)); } break; - case 518: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy828 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy828), NULL, yymsp[-1].minor.yy828, yymsp[0].minor.yy828); } + case 525: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy712 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy712), NULL, yymsp[-1].minor.yy712, yymsp[0].minor.yy712); } break; - case 519: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy828 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy828), releaseRawExprNode(pCxt, yymsp[-3].minor.yy828), yymsp[-1].minor.yy828, yymsp[0].minor.yy828); } + case 526: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy712 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy712), releaseRawExprNode(pCxt, yymsp[-3].minor.yy712), yymsp[-1].minor.yy712, yymsp[0].minor.yy712); } break; - case 520: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ -{ yymsp[-6].minor.yy828 = createEventWindowNode(pCxt, yymsp[-3].minor.yy828, yymsp[0].minor.yy828); } + case 527: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ +{ yymsp[-6].minor.yy712 = createEventWindowNode(pCxt, yymsp[-3].minor.yy712, yymsp[0].minor.yy712); } break; - case 524: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy828 = createFillNode(pCxt, yymsp[-1].minor.yy822, NULL); } + case 531: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy712 = createFillNode(pCxt, yymsp[-1].minor.yy94, NULL); } break; - case 525: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy828 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy222)); } + case 532: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy712 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy274)); } break; - case 526: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy828 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy222)); } + case 533: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy712 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy274)); } break; - case 527: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy822 = FILL_MODE_NONE; } + case 534: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy94 = FILL_MODE_NONE; } break; - case 528: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy822 = FILL_MODE_PREV; } + case 535: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy94 = FILL_MODE_PREV; } break; - case 529: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy822 = FILL_MODE_NULL; } + case 536: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy94 = FILL_MODE_NULL; } break; - case 530: /* fill_mode ::= NULL_F */ -{ yymsp[0].minor.yy822 = FILL_MODE_NULL_F; } + case 537: /* fill_mode ::= NULL_F */ +{ yymsp[0].minor.yy94 = FILL_MODE_NULL_F; } break; - case 531: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy822 = FILL_MODE_LINEAR; } + case 538: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy94 = FILL_MODE_LINEAR; } break; - case 532: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy822 = FILL_MODE_NEXT; } + case 539: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy94 = FILL_MODE_NEXT; } break; - case 535: /* group_by_list ::= expr_or_subquery */ -{ yylhsminor.yy222 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy828))); } - yymsp[0].minor.yy222 = yylhsminor.yy222; + case 542: /* group_by_list ::= expr_or_subquery */ +{ yylhsminor.yy274 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } + yymsp[0].minor.yy274 = yylhsminor.yy274; break; - case 536: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -{ yylhsminor.yy222 = addNodeToList(pCxt, yymsp[-2].minor.yy222, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy828))); } - yymsp[-2].minor.yy222 = yylhsminor.yy222; + case 543: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ +{ yylhsminor.yy274 = addNodeToList(pCxt, yymsp[-2].minor.yy274, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy712))); } + yymsp[-2].minor.yy274 = yylhsminor.yy274; break; - case 540: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -{ yymsp[-5].minor.yy828 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy828), releaseRawExprNode(pCxt, yymsp[-1].minor.yy828)); } + case 547: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +{ yymsp[-5].minor.yy712 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy712), releaseRawExprNode(pCxt, yymsp[-1].minor.yy712)); } break; - case 543: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 550: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy828 = addOrderByClause(pCxt, yymsp[-3].minor.yy828, yymsp[-2].minor.yy222); - yylhsminor.yy828 = addSlimitClause(pCxt, yylhsminor.yy828, yymsp[-1].minor.yy828); - yylhsminor.yy828 = addLimitClause(pCxt, yylhsminor.yy828, yymsp[0].minor.yy828); + yylhsminor.yy712 = addOrderByClause(pCxt, yymsp[-3].minor.yy712, yymsp[-2].minor.yy274); + yylhsminor.yy712 = addSlimitClause(pCxt, yylhsminor.yy712, yymsp[-1].minor.yy712); + yylhsminor.yy712 = addLimitClause(pCxt, yylhsminor.yy712, yymsp[0].minor.yy712); } - yymsp[-3].minor.yy828 = yylhsminor.yy828; + yymsp[-3].minor.yy712 = yylhsminor.yy712; break; - case 546: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -{ yylhsminor.yy828 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy828, yymsp[0].minor.yy828); } - yymsp[-3].minor.yy828 = yylhsminor.yy828; + case 553: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +{ yylhsminor.yy712 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy712, yymsp[0].minor.yy712); } + yymsp[-3].minor.yy712 = yylhsminor.yy712; break; - case 547: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -{ yylhsminor.yy828 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy828, yymsp[0].minor.yy828); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 554: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +{ yylhsminor.yy712 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy712, yymsp[0].minor.yy712); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 555: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 559: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==559); -{ yymsp[-1].minor.yy828 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 562: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 566: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==566); +{ yymsp[-1].minor.yy712 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 556: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 560: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==560); -{ yymsp[-3].minor.yy828 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 563: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 567: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==567); +{ yymsp[-3].minor.yy712 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 557: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 561: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==561); -{ yymsp[-3].minor.yy828 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 564: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 568: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==568); +{ yymsp[-3].minor.yy712 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 562: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy828 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy828); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 569: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy712 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy712); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 567: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy828 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy828), yymsp[-1].minor.yy158, yymsp[0].minor.yy675); } - yymsp[-2].minor.yy828 = yylhsminor.yy828; + case 574: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy712 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy712), yymsp[-1].minor.yy88, yymsp[0].minor.yy907); } + yymsp[-2].minor.yy712 = yylhsminor.yy712; break; - case 568: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy158 = ORDER_ASC; } + case 575: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy88 = ORDER_ASC; } break; - case 569: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy158 = ORDER_ASC; } + case 576: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy88 = ORDER_ASC; } break; - case 570: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy158 = ORDER_DESC; } + case 577: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy88 = ORDER_DESC; } break; - case 571: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy675 = NULL_ORDER_DEFAULT; } + case 578: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy907 = NULL_ORDER_DEFAULT; } break; - case 572: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy675 = NULL_ORDER_FIRST; } + case 579: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy907 = NULL_ORDER_FIRST; } break; - case 573: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy675 = NULL_ORDER_LAST; } + case 580: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy907 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parAlterToBalanceTest.cpp b/source/libs/parser/test/parAlterToBalanceTest.cpp index 4cccfd449c1b33410be910a44ab7f3071839f26f..db74e66d2bb06b1de08a187583ee9fadfe72e8b4 100644 --- a/source/libs/parser/test/parAlterToBalanceTest.cpp +++ b/source/libs/parser/test/parAlterToBalanceTest.cpp @@ -109,7 +109,8 @@ TEST_F(ParserInitialATest, alterDnode) { * | WAL_LEVEL int_value -- enum 1, 2, default 1 * | STT_TRIGGER int_value -- rang [1, 16], default 8 * | MINROWS int_value -- rang [10, 1000], default 100 - * } + * | WAL_RETENTION_PERIOD int_value -- rang [-1, INT32_MAX], default 0 + * | WAL_RETENTION_SIZE int_value -- rang [-1, INT32_MAX], default 0 */ TEST_F(ParserInitialATest, alterDatabase) { useDb("root", "test"); @@ -135,6 +136,8 @@ TEST_F(ParserInitialATest, alterDatabase) { expect.replications = -1; expect.sstTrigger = -1; expect.minRows = -1; + expect.walRetentionPeriod = -2; + expect.walRetentionSize = -2; }; auto setAlterDbBuffer = [&](int32_t buffer) { expect.buffer = buffer; }; auto setAlterDbPageSize = [&](int32_t pageSize) { expect.pageSize = pageSize; }; @@ -153,6 +156,10 @@ TEST_F(ParserInitialATest, alterDatabase) { auto setAlterDbReplica = [&](int8_t replications) { expect.replications = replications; }; auto setAlterDbSttTrigger = [&](int8_t sstTrigger) { expect.sstTrigger = sstTrigger; }; auto setAlterDbMinRows = [&](int32_t minRows) { expect.minRows = minRows; }; + auto setAlterDbWalRetentionPeriod = [&](int32_t walRetentionPeriod) { + expect.walRetentionPeriod = walRetentionPeriod; + }; + auto setAlterDbWalRetentionSize = [&](int32_t walRetentionSize) { expect.walRetentionSize = walRetentionSize; }; setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_ALTER_DATABASE_STMT); @@ -174,6 +181,8 @@ TEST_F(ParserInitialATest, alterDatabase) { ASSERT_EQ(req.replications, expect.replications); ASSERT_EQ(req.sstTrigger, expect.sstTrigger); ASSERT_EQ(req.minRows, expect.minRows); + ASSERT_EQ(req.walRetentionPeriod, expect.walRetentionPeriod); + ASSERT_EQ(req.walRetentionSize, expect.walRetentionSize); }); const int32_t MINUTE_PER_DAY = MILLISECOND_PER_DAY / MILLISECOND_PER_MINUTE; @@ -189,8 +198,10 @@ TEST_F(ParserInitialATest, alterDatabase) { setAlterDbBuffer(16); setAlterDbPages(128); setAlterDbReplica(3); + setAlterDbWalRetentionPeriod(10); + setAlterDbWalRetentionSize(20); run("ALTER DATABASE test BUFFER 16 CACHEMODEL 'last_row' CACHESIZE 32 WAL_FSYNC_PERIOD 200 KEEP 10 PAGES 128 " - "REPLICA 3 WAL_LEVEL 1 STT_TRIGGER 16"); + "REPLICA 3 WAL_LEVEL 1 STT_TRIGGER 16 WAL_RETENTION_PERIOD 10 WAL_RETENTION_SIZE 20"); clearAlterDbReq(); initAlterDb("test"); @@ -290,6 +301,20 @@ TEST_F(ParserInitialATest, alterDatabase) { setAlterDbMinRows(1000); run("ALTER DATABASE test MINROWS 1000"); clearAlterDbReq(); + + initAlterDb("test"); + setAlterDbWalRetentionPeriod(-1); + run("ALTER DATABASE test WAL_RETENTION_PERIOD -1"); + setAlterDbWalRetentionPeriod(50); + run("ALTER DATABASE test WAL_RETENTION_PERIOD 50"); + clearAlterDbReq(); + + initAlterDb("test"); + setAlterDbWalRetentionSize(-1); + run("ALTER DATABASE test WAL_RETENTION_SIZE -1"); + setAlterDbWalRetentionSize(50); + run("ALTER DATABASE test WAL_RETENTION_SIZE 50"); + clearAlterDbReq(); } TEST_F(ParserInitialATest, alterDatabaseSemanticCheck) { @@ -612,7 +637,9 @@ TEST_F(ParserInitialATest, alterTable) { } ASSERT_EQ(req.isNull, expect.isNull); ASSERT_EQ(req.nTagVal, expect.nTagVal); - ASSERT_EQ(memcmp(req.pTagVal, expect.pTagVal, expect.nTagVal), 0); + if (nullptr != req.pTagVal) { + ASSERT_EQ(memcmp(req.pTagVal, expect.pTagVal, expect.nTagVal), 0); + } ASSERT_EQ(req.updateTTL, expect.updateTTL); ASSERT_EQ(req.newTTL, expect.newTTL); if (nullptr != expect.newComment) { @@ -831,4 +858,21 @@ TEST_F(ParserInitialATest, balanceVgroup) { run("BALANCE VGROUP"); } +/* + * BALANCE VGROUP LEADER + */ +TEST_F(ParserInitialATest, balanceVgroupLeader) { + useDb("root", "test"); + + setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { + ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_BALANCE_VGROUP_LEADER_STMT); + ASSERT_EQ(pQuery->pCmdMsg->msgType, TDMT_MND_BALANCE_VGROUP_LEADER); + SBalanceVgroupLeaderReq req = {0}; + ASSERT_EQ(tDeserializeSBalanceVgroupLeaderReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req), + TSDB_CODE_SUCCESS); + }); + + run("BALANCE VGROUP LEADER"); +} + } // namespace ParserTest \ No newline at end of file diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp index 2dffdae934453bb8f5284c0d3f8972887e898584..88e66997eb85ff6a65595b7749a38a69762e5239 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -398,7 +398,7 @@ TEST_F(ParserInitialCTest, createDnode) { } /* - * CREATE [AGGREGATE] FUNCTION [IF NOT EXISTS] func_name + * CREATE [OR REPLACE] [AGGREGATE] FUNCTION [IF NOT EXISTS] func_name * AS library_path OUTPUTTYPE type_name [BUFSIZE value] [LANGUAGE value] */ TEST_F(ParserInitialCTest, createFunction) { @@ -408,9 +408,10 @@ TEST_F(ParserInitialCTest, createFunction) { auto setCreateFuncReq = [&](const char* pUdfName, int8_t outputType, int32_t outputBytes = 0, int8_t funcType = TSDB_FUNC_TYPE_SCALAR, int8_t igExists = 0, int32_t bufSize = 0, - int8_t language = TSDB_FUNC_SCRIPT_BIN_LIB) { + int8_t language = TSDB_FUNC_SCRIPT_BIN_LIB, int8_t orReplace = 0) { memset(&expect, 0, sizeof(SCreateFuncReq)); strcpy(expect.name, pUdfName); + expect.orReplace = orReplace; expect.igExists = igExists; expect.funcType = funcType; expect.scriptType = language; @@ -425,6 +426,7 @@ TEST_F(ParserInitialCTest, createFunction) { ASSERT_TRUE(TSDB_CODE_SUCCESS == tDeserializeSCreateFuncReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req)); ASSERT_EQ(std::string(req.name), std::string(expect.name)); + ASSERT_EQ(req.orReplace, expect.orReplace); ASSERT_EQ(req.igExists, expect.igExists); ASSERT_EQ(req.funcType, expect.funcType); ASSERT_EQ(req.scriptType, expect.scriptType); @@ -448,8 +450,8 @@ TEST_F(ParserInitialCTest, createFunction) { setCreateFuncReq("udf1", TSDB_DATA_TYPE_INT); run("CREATE FUNCTION udf1 AS 'udf' OUTPUTTYPE INT"); - setCreateFuncReq("udf2", TSDB_DATA_TYPE_DOUBLE, 0, TSDB_FUNC_TYPE_AGGREGATE, 1, 8, TSDB_FUNC_SCRIPT_PYTHON); - run("CREATE AGGREGATE FUNCTION IF NOT EXISTS udf2 AS 'udf' OUTPUTTYPE DOUBLE BUFSIZE 8 LANGUAGE 'python'"); + setCreateFuncReq("udf2", TSDB_DATA_TYPE_DOUBLE, 0, TSDB_FUNC_TYPE_AGGREGATE, 1, 8, TSDB_FUNC_SCRIPT_PYTHON, 1); + run("CREATE OR REPLACE AGGREGATE FUNCTION IF NOT EXISTS udf2 AS 'udf' OUTPUTTYPE DOUBLE BUFSIZE 8 LANGUAGE 'python'"); } /* diff --git a/source/libs/parser/test/parSelectTest.cpp b/source/libs/parser/test/parSelectTest.cpp index fcd8dd1f2635040f7f4b7e59f07302246f0a7630..ec6c69ea8ded78443ba9803c7099faafaaf8765a 100644 --- a/source/libs/parser/test/parSelectTest.cpp +++ b/source/libs/parser/test/parSelectTest.cpp @@ -286,7 +286,7 @@ TEST_F(ParserSelectTest, interval) { TEST_F(ParserSelectTest, intervalSemanticCheck) { useDb("root", "test"); - run("SELECT c1 FROM t1 INTERVAL(10s)", TSDB_CODE_PAR_NO_VALID_FUNC_IN_WIN); + run("SELECT c1 FROM t1 INTERVAL(10s)", TSDB_CODE_PAR_INVALID_OPTR_USAGE); run("SELECT DISTINCT c1, c2 FROM t1 WHERE c1 > 3 INTERVAL(1d) FILL(NEXT)", TSDB_CODE_PAR_INVALID_FILL_TIME_RANGE); run("SELECT HISTOGRAM(c1, 'log_bin', '{\"start\": -33,\"factor\": 55,\"count\": 5,\"infinity\": false}', 1) FROM t1 " "WHERE ts > TIMESTAMP '2022-04-01 00:00:00' and ts < TIMESTAMP '2022-04-30 23:59:59' INTERVAL(10s) FILL(NULL)", diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 16a5ef7bae1e7aeaa4c0521022bd96913b9c222a..8fee17d96811227d7831b20c629999d3428074e7 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -2279,7 +2279,7 @@ static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogic if (NULL != cxt.pLastCols) { cxt.doAgg = false; lastRowScanOptSetLastTargets(pScan->pScanCols, cxt.pLastCols); - nodesWalkExprs(pScan->pScanPseudoCols, lastRowScanOptSetColDataType, &cxt); + NODES_DESTORY_LIST(pScan->pScanPseudoCols); lastRowScanOptSetLastTargets(pScan->node.pTargets, cxt.pLastCols); nodesClearList(cxt.pLastCols); } diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index e9a2efaac79fe237c8e4e93a91cf79f397d27f33..e2c2e4c65563e3b4a49add42d73c004f1ea39bb7 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1089,9 +1089,15 @@ static int32_t doCreateExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogic pExchange->srcStartGroupId = pExchangeLogicNode->srcStartGroupId; pExchange->srcEndGroupId = pExchangeLogicNode->srcEndGroupId; pExchange->seqRecvData = pExchangeLogicNode->seqRecvData; - *pPhyNode = (SPhysiNode*)pExchange; - return TSDB_CODE_SUCCESS; + int32_t code = setConditionsSlotId(pCxt, (const SLogicNode*)pExchangeLogicNode, (SPhysiNode*)pExchange); + if (TSDB_CODE_SUCCESS == code) { + *pPhyNode = (SPhysiNode*)pExchange; + } else { + nodesDestroyNode((SNode*)pExchange); + } + + return code; } static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExchangeLogicNode* pExchangeLogicNode, @@ -1119,6 +1125,9 @@ static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExc if (TSDB_CODE_SUCCESS == code) { code = addDataBlockSlots(pCxt, pScan->pScanCols, pScan->node.pOutputDataBlockDesc); } + if (TSDB_CODE_SUCCESS == code) { + code = setConditionsSlotId(pCxt, (const SLogicNode*)pExchangeLogicNode, (SPhysiNode*)pScan); + } if (TSDB_CODE_SUCCESS == code) { *pPhyNode = (SPhysiNode*)pScan; diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 361cf33d58bffb63523156d6fab555b8ccb5d5d4..fd77261818702defef8aa928e10a73cb66e28b20 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -1365,7 +1365,8 @@ static int32_t unAllSplCreateExchangeNode(SSplitContext* pCxt, int32_t startGrou pExchange->srcEndGroupId = pCxt->groupId - 1; pExchange->node.precision = pProject->node.precision; pExchange->node.pTargets = nodesCloneList(pProject->node.pTargets); - if (NULL == pExchange->node.pTargets) { + pExchange->node.pConditions = nodesCloneNode(pProject->node.pConditions); + if (NULL == pExchange->node.pTargets || (NULL != pProject->node.pConditions && NULL == pExchange->node.pConditions)) { return TSDB_CODE_OUT_OF_MEMORY; } TSWAP(pExchange->node.pLimit, pProject->node.pLimit); diff --git a/source/libs/qcom/src/queryUtil.c b/source/libs/qcom/src/queryUtil.c index c68a08682c57886b407dcb9f6ab7c6245ddf61a2..9d8c17000345a7aa73761c1e3f9af5ae4a4a3363 100644 --- a/source/libs/qcom/src/queryUtil.c +++ b/source/libs/qcom/src/queryUtil.c @@ -194,6 +194,8 @@ char* jobTaskStatusStr(int32_t status) { return "EXECUTING"; case JOB_TASK_STATUS_PART_SUCC: return "PARTIAL_SUCCEED"; + case JOB_TASK_STATUS_FETCH: + return "FETCHING"; case JOB_TASK_STATUS_SUCC: return "SUCCEED"; case JOB_TASK_STATUS_FAIL: diff --git a/source/libs/qcom/src/querymsg.c b/source/libs/qcom/src/querymsg.c index d2934e1ff86d964cc80e391e53052c25900b0d4a..b62a3e49326181ba6d32b07f307e1e18f5fbc76f 100644 --- a/source/libs/qcom/src/querymsg.c +++ b/source/libs/qcom/src/querymsg.c @@ -587,7 +587,8 @@ int32_t queryProcessRetrieveFuncRsp(void *output, char *msg, int32_t msgSize) { memcpy(output, funcInfo, sizeof(*funcInfo)); taosArrayDestroy(out.pFuncInfos); - + taosArrayDestroy(out.pFuncExtraInfos); + return TSDB_CODE_SUCCESS; } diff --git a/source/libs/qworker/src/qwDbg.c b/source/libs/qworker/src/qwDbg.c index 0ab501ddd5abe806f62ef611900df1455b716e9f..59e63e9eae2636ae1676ac612083e3857e3a7510 100644 --- a/source/libs/qworker/src/qwDbg.c +++ b/source/libs/qworker/src/qwDbg.c @@ -259,19 +259,30 @@ void qwDbgSimulateDead(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *rsped) { static int32_t ignoreTime = 0; if (++ignoreTime > 10 && 0 == taosRand() % 9) { + if (ctx->msgType == TDMT_SCH_FETCH) { + qwBuildAndSendErrorRsp(TDMT_SCH_LINK_BROKEN, &ctx->ctrlConnInfo, TSDB_CODE_RPC_BROKEN_LINK); + qwBuildAndSendErrorRsp(ctx->msgType + 1, &ctx->dataConnInfo, TSDB_CODE_QRY_TASK_CTX_NOT_EXIST); + *rsped = true; + + taosSsleep(3); + return; + } + +#if 0 SRpcHandleInfo *pConn = ((ctx->msgType == TDMT_SCH_FETCH || ctx->msgType == TDMT_SCH_MERGE_FETCH) ? &ctx->dataConnInfo - : &ctx->ctrlConnInfo); + : &ctx->ctrlConnInfo); qwBuildAndSendErrorRsp(ctx->msgType + 1, pConn, TSDB_CODE_RPC_BROKEN_LINK); - + qwBuildAndSendDropMsg(QW_FPARAMS(), pConn); *rsped = true; - + return; +#endif } } -int32_t qwDbgEnableDebug(char *option) { +int32_t qWorkerDbgEnableDebug(char *option) { if (0 == strcasecmp(option, "lock")) { gQWDebug.lockEnable = true; qError("qw lock debug enabled"); diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index ec4049a3eb45c2c274a58837e9f06b1af940e631..92c7852dbca5ba9bd2bf0542e31e7b63b15aa632 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -199,7 +199,7 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryStop) { QW_ERR_JRET(code); } - QW_TASK_DLOG("data put into sink, rows:%d, continueExecTask:%d", pRes->info.rows, qcontinue); + QW_TASK_DLOG("data put into sink, rows:%" PRId64 ", continueExecTask:%d", pRes->info.rows, qcontinue); } if (numOfResBlock == 0 || (hasMore == false)) { diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 195a08525c3d502e9cae6ab49c23658bda9f2f24..24b25cec80ce58390b7a83d71a607bbaba18fe50 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1067,9 +1067,15 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam * } struct tm tmInfo; - taosLocalTime((const time_t *)&timeVal, &tmInfo); + int32_t len = 0; + + if (taosLocalTime((const time_t *)&timeVal, &tmInfo, buf) == NULL) { + len = (int32_t)strlen(buf); + goto _end; + } + strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", &tmInfo); - int32_t len = (int32_t)strlen(buf); + len = (int32_t)strlen(buf); // add timezone string if (tzLen > 0) { @@ -1103,6 +1109,7 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam * len += fracLen; } +_end: memmove(buf + VARSTR_HEADER_SIZE, buf, len); varDataSetLen(buf, len); @@ -1755,7 +1762,11 @@ int32_t winEndTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p int32_t qTbnameFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { char* p = colDataGetVarData(pInput->columnData, 0); - colDataSetNItems(pOutput->columnData, pOutput->numOfRows, p, pInput->numOfRows); + int32_t code = colDataSetNItems(pOutput->columnData, pOutput->numOfRows, p, pInput->numOfRows, true); + if (code) { + return code; + } + pOutput->numOfRows += pInput->numOfRows; return TSDB_CODE_SUCCESS; } diff --git a/source/libs/scheduler/inc/schInt.h b/source/libs/scheduler/inc/schInt.h index 85b952937fbc356879adc1b53a059767b9164e5f..d002b5dfa96f182d343d85390f32263fcd4912a8 100644 --- a/source/libs/scheduler/inc/schInt.h +++ b/source/libs/scheduler/inc/schInt.h @@ -193,7 +193,7 @@ typedef struct SSchLevel { int32_t taskSucceed; int32_t taskNum; int32_t taskLaunchedNum; - int32_t taskDoneNum; + int32_t taskExecDoneNum; SArray *subTasks; // Element is SSchTask } SSchLevel; @@ -299,6 +299,7 @@ typedef struct SSchJob { SExecResult execRes; void *fetchRes; // TODO free it or not bool fetched; + bool noMoreRetry; int64_t resNumOfRows; // from int32_t to int64_t SSchResInfo userRes; char *sql; @@ -333,13 +334,16 @@ extern SSchedulerMgmt schMgmt; ((_job)->attr.localExec && SCH_IS_QUERY_JOB(_job) && (!SCH_IS_INSERT_JOB(_job)) && \ (!SCH_IS_DATA_BIND_QRY_TASK(_task))) -#define SCH_UPDATE_REDICT_CODE(job, _code) atomic_val_compare_exchange_32(&((job)->redirectCode), 0, _code) -#define SCH_GET_REDICT_CODE(job, _code) (((!NO_RET_REDIRECT_ERROR(_code)) || (job)->redirectCode == 0) ? (_code) : (job)->redirectCode) +#define SCH_UPDATE_REDIRECT_CODE(job, _code) atomic_val_compare_exchange_32(&((job)->redirectCode), 0, _code) +#define SCH_GET_REDIRECT_CODE(job, _code) (((!NO_RET_REDIRECT_ERROR(_code)) || (job)->redirectCode == 0) ? (_code) : (job)->redirectCode) #define SCH_SET_TASK_STATUS(task, st) atomic_store_8(&(task)->status, st) #define SCH_GET_TASK_STATUS(task) atomic_load_8(&(task)->status) #define SCH_GET_TASK_STATUS_STR(task) jobTaskStatusStr(SCH_GET_TASK_STATUS(task)) +#define SCH_TASK_ALREADY_LAUNCHED(task) (SCH_GET_TASK_STATUS(task) >= JOB_TASK_STATUS_EXEC) +#define SCH_TASK_EXEC_DONE(task) (SCH_GET_TASK_STATUS(task) >= JOB_TASK_STATUS_PART_SUCC) + #define SCH_GET_TASK_HANDLE(_task) ((_task) ? (_task)->handle : NULL) #define SCH_SET_TASK_HANDLE(_task, _handle) ((_task)->handle = (_handle)) @@ -361,6 +365,7 @@ extern SSchedulerMgmt schMgmt; (SCH_IS_DATA_BIND_QRY_TASK(_task) && SCH_JOB_NEED_FLOW_CTRL(_job) && SCH_IS_LEVEL_UNFINISHED((_task)->level)) #define SCH_FETCH_TYPE(_pSrcTask) (SCH_IS_DATA_BIND_QRY_TASK(_pSrcTask) ? TDMT_SCH_FETCH : TDMT_SCH_MERGE_FETCH) #define SCH_TASK_NEED_FETCH(_task) ((_task)->plan->subplanType != SUBPLAN_TYPE_MODIFY) +#define SCH_MULTI_LEVEL_LAUNCHED(_job) ((_job)->levelIdx != ((_job)->levelNum - 1)) #define SCH_SET_JOB_TYPE(_job, type) \ do { \ @@ -377,16 +382,24 @@ extern SSchedulerMgmt schMgmt; #define SCH_JOB_NEED_DROP(_job) (SCH_IS_QUERY_JOB(_job)) #define SCH_IS_EXPLAIN_JOB(_job) (EXPLAIN_MODE_ANALYZE == (_job)->attr.explainMode) #define SCH_NETWORK_ERR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || (_code) == TSDB_CODE_RPC_SOMENODE_NOT_CONNECTED) -#define SCH_MERGE_TASK_NETWORK_ERR(_task, _code, _len) \ - (SCH_NETWORK_ERR(_code) && (((_len) > 0) || (!SCH_IS_DATA_BIND_TASK(_task)) || (_task)->redirectCtx.inRedirect)) #define SCH_REDIRECT_MSGTYPE(_msgType) \ ((_msgType) == TDMT_SCH_LINK_BROKEN || (_msgType) == TDMT_SCH_QUERY || (_msgType) == TDMT_SCH_MERGE_QUERY || \ (_msgType) == TDMT_SCH_FETCH || (_msgType) == TDMT_SCH_MERGE_FETCH) -#define SCH_TASK_NEED_REDIRECT(_task, _msgType, _code, _rspLen) \ - (SCH_REDIRECT_MSGTYPE(_msgType) && \ - (NEED_SCHEDULER_REDIRECT_ERROR(_code) || SCH_MERGE_TASK_NETWORK_ERR((_task), (_code), (_rspLen)))) -#define SCH_NEED_RETRY(_msgType, _code) \ - ((SCH_NETWORK_ERR(_code) && SCH_REDIRECT_MSGTYPE(_msgType)) || (_code) == TSDB_CODE_SCH_TIMEOUT_ERROR) +#define SCH_LOW_LEVEL_NETWORK_ERR(_job, _task, _code) \ + (SCH_NETWORK_ERR(_code) && ((_task)->level->level == (_job)->levelIdx)) +#define SCH_TOP_LEVEL_NETWORK_ERR(_job, _task, _code) \ + (SCH_NETWORK_ERR(_code) && ((_task)->level->level > (_job)->levelIdx)) +#define SCH_TASK_RETRY_NETWORK_ERR(_task, _code) \ + (SCH_NETWORK_ERR(_code) && (_task)->redirectCtx.inRedirect) + +#define SCH_JOB_NEED_RETRY(_job, _task, _msgType, _code) \ + (SCH_REDIRECT_MSGTYPE(_msgType) && SCH_TOP_LEVEL_NETWORK_ERR(_job, _task, _code)) +#define SCH_TASKSET_NEED_RETRY(_job, _task, _msgType, _code) \ + (SCH_REDIRECT_MSGTYPE(_msgType) && \ + (NEED_SCHEDULER_REDIRECT_ERROR(_code) || SCH_LOW_LEVEL_NETWORK_ERR((_job), (_task), (_code)) || SCH_TASK_RETRY_NETWORK_ERR((_task), (_code)))) +#define SCH_TASK_NEED_RETRY(_msgType, _code) \ + ((SCH_REDIRECT_MSGTYPE(_msgType) && SCH_NETWORK_ERR(_code)) || (_code) == TSDB_CODE_SCH_TIMEOUT_ERROR) + #define SCH_IS_LEVEL_UNFINISHED(_level) ((_level)->taskLaunchedNum < (_level)->taskNum) #define SCH_GET_CUR_EP(_addr) (&(_addr)->epSet.eps[(_addr)->epSet.inUse]) @@ -510,6 +523,11 @@ extern SSchedulerMgmt schMgmt; } \ } while (0) +#define SCH_RESET_JOB_LEVEL_IDX(_job) do { \ + (_job)->levelIdx = (_job)->levelNum - 1; \ + SCH_JOB_DLOG("set job levelIdx to %d", (_job)->levelIdx); \ +} while (0) + void schDeregisterTaskHb(SSchJob *pJob, SSchTask *pTask); void schCleanClusterHb(void *pTrans); int32_t schLaunchTask(SSchJob *job, SSchTask *task); @@ -562,7 +580,7 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq); int32_t schExecJob(SSchJob *pJob, SSchedulerReq *pReq); int32_t schDumpJobExecRes(SSchJob *pJob, SExecResult *pRes); int32_t schUpdateTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask, SEpSet *pEpSet); -int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode); +int32_t schHandleTaskSetRetry(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode); void schProcessOnOpEnd(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq *pReq, int32_t errCode); int32_t schProcessOnOpBegin(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq *pReq); void schProcessOnCbEnd(SSchJob *pJob, SSchTask *pTask, int32_t errCode); @@ -591,6 +609,10 @@ int32_t schHandleJobDrop(SSchJob *pJob, int32_t errCode); bool schChkCurrentOp(SSchJob *pJob, int32_t op, int8_t sync); int32_t schProcessFetchRsp(SSchJob *pJob, SSchTask *pTask, char *msg, int32_t rspCode); int32_t schProcessExplainRsp(SSchJob *pJob, SSchTask *pTask, SExplainRsp *rsp); +int32_t schHandleJobRetry(SSchJob *pJob, SSchTask *pTask, SDataBuf *pMsg, int32_t rspCode); +int32_t schChkResetJobRetry(SSchJob *pJob, int32_t rspCode); +void schResetTaskForRetry(SSchJob *pJob, SSchTask *pTask); +int32_t schChkUpdateRedirectCtx(SSchJob *pJob, SSchTask *pTask, SEpSet *pEpSet, int32_t rspCode); extern SSchDebug gSCHDebug; diff --git a/source/libs/scheduler/src/schFlowCtrl.c b/source/libs/scheduler/src/schFlowCtrl.c index 5e4fe4b8a1f2795cfbd4dff838304fe0e36343ff..9cb95a6bbe7aad0bf9a6576dac13db3114d1559d 100644 --- a/source/libs/scheduler/src/schFlowCtrl.c +++ b/source/libs/scheduler/src/schFlowCtrl.c @@ -282,7 +282,6 @@ int32_t schLaunchTasksInFlowCtrlList(SSchJob *pJob, SSchTask *pTask) { } int32_t code = schLaunchTasksInFlowCtrlListImpl(pJob, ctrl); - ; SCH_ERR_RET(code); return code; // to avoid compiler error diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index 980a8ac6a193e32c38e64f0b323c5311ddacef55..e7bfe95795f44f61ee4d1cc02873a21b80438369 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -83,6 +83,10 @@ int32_t schUpdateJobStatus(SSchJob *pJob, int8_t newStatus) { oriStatus = SCH_GET_JOB_STATUS(pJob); if (oriStatus == newStatus) { + if (JOB_TASK_STATUS_FETCH == newStatus) { + return code; + } + SCH_ERR_JRET(TSDB_CODE_SCH_IGNORE_ERROR); } @@ -108,10 +112,19 @@ int32_t schUpdateJobStatus(SSchJob *pJob, int8_t newStatus) { break; case JOB_TASK_STATUS_PART_SUCC: if (newStatus != JOB_TASK_STATUS_FAIL && newStatus != JOB_TASK_STATUS_SUCC && - newStatus != JOB_TASK_STATUS_DROP && newStatus != JOB_TASK_STATUS_EXEC) { + newStatus != JOB_TASK_STATUS_DROP && newStatus != JOB_TASK_STATUS_EXEC && + newStatus != JOB_TASK_STATUS_FETCH) { SCH_ERR_JRET(TSDB_CODE_APP_ERROR); } + break; + case JOB_TASK_STATUS_FETCH: + if (newStatus != JOB_TASK_STATUS_FAIL && newStatus != JOB_TASK_STATUS_SUCC && + newStatus != JOB_TASK_STATUS_DROP && newStatus != JOB_TASK_STATUS_EXEC && + newStatus != JOB_TASK_STATUS_FETCH) { + SCH_ERR_JRET(TSDB_CODE_APP_ERROR); + } + break; case JOB_TASK_STATUS_SUCC: case JOB_TASK_STATUS_FAIL: @@ -288,7 +301,7 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { } pJob->levelNum = levelNum; - pJob->levelIdx = levelNum - 1; + SCH_RESET_JOB_LEVEL_IDX(pJob); SSchLevel level = {0}; SNodeListNode *plans = NULL; @@ -550,9 +563,9 @@ int32_t schLaunchJobLowerLevel(SSchJob *pJob, SSchTask *pTask) { } SSchLevel *pLevel = pTask->level; - int32_t doneNum = atomic_add_fetch_32(&pLevel->taskDoneNum, 1); + int32_t doneNum = atomic_add_fetch_32(&pLevel->taskExecDoneNum, 1); if (doneNum == pLevel->taskNum) { - pJob->levelIdx--; + atomic_sub_fetch_32(&pJob->levelIdx, 1); pLevel = taosArrayGet(pJob->levels, pJob->levelIdx); for (int32_t i = 0; i < pLevel->taskNum; ++i) { @@ -562,6 +575,10 @@ int32_t schLaunchJobLowerLevel(SSchJob *pJob, SSchTask *pTask) { continue; } + if (SCH_TASK_ALREADY_LAUNCHED(pTask)) { + continue; + } + SCH_ERR_RET(schLaunchTask(pJob, pTask)); } } @@ -811,6 +828,75 @@ void schDirectPostJobRes(SSchedulerReq *pReq, int32_t errCode) { } } +int32_t schChkResetJobRetry(SSchJob *pJob, int32_t rspCode) { + if (pJob->status >= JOB_TASK_STATUS_PART_SUCC) { + SCH_LOCK(SCH_WRITE, &pJob->resLock); + if (pJob->fetched) { + SCH_UNLOCK(SCH_WRITE, &pJob->resLock); + pJob->noMoreRetry = true; + SCH_JOB_ELOG("already fetched while got error %s", tstrerror(rspCode)); + SCH_ERR_RET(rspCode); + } + SCH_UNLOCK(SCH_WRITE, &pJob->resLock); + + schUpdateJobStatus(pJob, JOB_TASK_STATUS_EXEC); + } + + return TSDB_CODE_SUCCESS; +} + +int32_t schResetJobForRetry(SSchJob *pJob, int32_t rspCode) { + SCH_ERR_RET(schChkResetJobRetry(pJob, rspCode)); + + int32_t numOfLevels = taosArrayGetSize(pJob->levels); + for (int32_t i = 0; i < numOfLevels; ++i) { + SSchLevel *pLevel = taosArrayGet(pJob->levels, i); + + pLevel->taskExecDoneNum = 0; + pLevel->taskLaunchedNum = 0; + + int32_t numOfTasks = taosArrayGetSize(pLevel->subTasks); + for (int32_t j = 0; j < numOfTasks; ++j) { + SSchTask *pTask = taosArrayGet(pLevel->subTasks, j); + SCH_LOCK_TASK(pTask); + SCH_ERR_RET(schChkUpdateRedirectCtx(pJob, pTask, NULL, rspCode)); + qClearSubplanExecutionNode(pTask->plan); + schResetTaskForRetry(pJob, pTask); + SCH_UNLOCK_TASK(pTask); + } + } + + SCH_RESET_JOB_LEVEL_IDX(pJob); + + return TSDB_CODE_SUCCESS; +} + + +int32_t schHandleJobRetry(SSchJob *pJob, SSchTask *pTask, SDataBuf *pMsg, int32_t rspCode) { + int32_t code = 0; + + taosMemoryFreeClear(pMsg->pData); + taosMemoryFreeClear(pMsg->pEpSet); + + SCH_UNLOCK_TASK(pTask); + + SCH_TASK_DLOG("start to redirect all job tasks cause of error: %s", tstrerror(rspCode)); + + SCH_ERR_JRET(schResetJobForRetry(pJob, rspCode)); + + SCH_ERR_JRET(schLaunchJob(pJob)); + + SCH_LOCK_TASK(pTask); + + SCH_RET(code); + +_return: + + SCH_LOCK_TASK(pTask); + + SCH_RET(schProcessOnTaskFailure(pJob, pTask, code)); +} + bool schChkCurrentOp(SSchJob *pJob, int32_t op, int8_t sync) { bool r = false; SCH_LOCK(SCH_READ, &pJob->opStatus.lock); @@ -907,7 +993,7 @@ int32_t schProcessOnOpBegin(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq *pReq SCH_ERR_RET(TSDB_CODE_APP_ERROR); } - if (status != JOB_TASK_STATUS_PART_SUCC) { + if (status != JOB_TASK_STATUS_PART_SUCC && status != JOB_TASK_STATUS_FETCH) { SCH_JOB_ELOG("job status error for fetch, status:%s", jobTaskStatusStr(status)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index 6f4130fd9ffe2814f0dd30655a58aefc92801a13..80fdc7594cc63b8e893de9e4e7cf193592deb885 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -36,7 +36,7 @@ int32_t schValidateRspMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgType) { TMSG_INFO(msgType)); SCH_ERR_RET(TSDB_CODE_QW_MSG_ERROR); } - if (taskStatus != JOB_TASK_STATUS_PART_SUCC) { + if (taskStatus != JOB_TASK_STATUS_FETCH) { SCH_TASK_ELOG("rsp msg conflicted with task status, status:%s, rspType:%s", jobTaskStatusStr(taskStatus), TMSG_INFO(msgType)); SCH_ERR_RET(TSDB_CODE_QW_MSG_ERROR); @@ -137,25 +137,12 @@ int32_t schProcessExplainRsp(SSchJob *pJob, SSchTask *pTask, SExplainRsp *rsp) { return TSDB_CODE_SUCCESS; } -// Note: no more task error processing, handled in function internal -int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDataBuf *pMsg, int32_t rspCode) { +int32_t schProcessResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDataBuf *pMsg, int32_t rspCode) { int32_t code = 0; char *msg = pMsg->pData; int32_t msgSize = pMsg->len; int32_t msgType = pMsg->msgType; - bool dropExecNode = (msgType == TDMT_SCH_LINK_BROKEN || SCH_NETWORK_ERR(rspCode)); - if (SCH_IS_QUERY_JOB(pJob)) { - SCH_ERR_JRET(schUpdateTaskHandle(pJob, pTask, dropExecNode, pMsg->handle, execId)); - } - - SCH_ERR_JRET(schValidateRspMsgType(pJob, pTask, msgType)); - - int32_t reqType = IsReq(pMsg) ? pMsg->msgType : (pMsg->msgType - 1); - if (SCH_TASK_NEED_REDIRECT(pTask, reqType, rspCode, pMsg->len)) { - SCH_RET(schHandleRedirect(pJob, pTask, (SDataBuf *)pMsg, rspCode)); - } - pTask->redirectCtx.inRedirect = false; switch (msgType) { @@ -423,6 +410,38 @@ _return: SCH_RET(schProcessOnTaskFailure(pJob, pTask, code)); } + + +// Note: no more task error processing, handled in function internal +int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDataBuf *pMsg, int32_t rspCode) { + int32_t code = 0; + int32_t msgType = pMsg->msgType; + char *msg = pMsg->pData; + + bool dropExecNode = (msgType == TDMT_SCH_LINK_BROKEN || SCH_NETWORK_ERR(rspCode)); + if (SCH_IS_QUERY_JOB(pJob)) { + SCH_ERR_JRET(schUpdateTaskHandle(pJob, pTask, dropExecNode, pMsg->handle, execId)); + } + + SCH_ERR_JRET(schValidateRspMsgType(pJob, pTask, msgType)); + + int32_t reqType = IsReq(pMsg) ? pMsg->msgType : (pMsg->msgType - 1); + if (SCH_JOB_NEED_RETRY(pJob, pTask, reqType, rspCode)) { + SCH_RET(schHandleJobRetry(pJob, pTask, (SDataBuf *)pMsg, rspCode)); + } else if (SCH_TASKSET_NEED_RETRY(pJob, pTask, reqType, rspCode)) { + SCH_RET(schHandleTaskSetRetry(pJob, pTask, (SDataBuf *)pMsg, rspCode)); + } + + pTask->redirectCtx.inRedirect = false; + + SCH_RET(schProcessResponseMsg(pJob, pTask, execId, pMsg, rspCode)); + +_return: + + taosMemoryFreeClear(msg); + + SCH_RET(schProcessOnTaskFailure(pJob, pTask, code)); +} int32_t schHandleCallback(void *param, SDataBuf *pMsg, int32_t rspCode) { int32_t code = 0; SSchTaskCallbackParam *pParam = (SSchTaskCallbackParam *)param; diff --git a/source/libs/scheduler/src/schStatus.c b/source/libs/scheduler/src/schStatus.c index 4c16a81a05003166978dd9ee0f96b2c876f6fefd..9d0ad30e2a47de92136ec1f25bffa6f761ea7725 100644 --- a/source/libs/scheduler/src/schStatus.c +++ b/source/libs/scheduler/src/schStatus.c @@ -34,6 +34,9 @@ int32_t schSwitchJobStatus(SSchJob* pJob, int32_t status, void* param) { case JOB_TASK_STATUS_PART_SUCC: SCH_ERR_JRET(schProcessOnJobPartialSuccess(pJob)); break; + case JOB_TASK_STATUS_FETCH: + SCH_ERR_JRET(schJobFetchRows(pJob)); + break; case JOB_TASK_STATUS_SUCC: break; case JOB_TASK_STATUS_FAIL: diff --git a/source/libs/scheduler/src/schTask.c b/source/libs/scheduler/src/schTask.c index bdab7393277617afa8dbd183700d54efa2caf4a7..207753ae2571fe292ca009cb6af51030bf0667f0 100644 --- a/source/libs/scheduler/src/schTask.c +++ b/source/libs/scheduler/src/schTask.c @@ -378,7 +378,8 @@ int32_t schChkUpdateRedirectCtx(SSchJob *pJob, SSchTask *pTask, SEpSet *pEpSet, if (lastTime > tsMaxRetryWaitTime) { SCH_TASK_DLOG("task no more redirect retry since timeout, now:%" PRId64 ", start:%" PRId64 ", max:%d, total:%d", nowTs, pCtx->startTs, tsMaxRetryWaitTime, pCtx->totalTimes); - SCH_ERR_RET(SCH_GET_REDICT_CODE(pJob, rspCode)); + pJob->noMoreRetry = true; + SCH_ERR_RET(SCH_GET_REDIRECT_CODE(pJob, rspCode)); } pCtx->periodMs *= tsRedirectFactor; @@ -404,32 +405,35 @@ _return: return TSDB_CODE_SUCCESS; } -int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode) { - int32_t code = 0; - - SCH_TASK_DLOG("task will be redirected now, status:%s, code:%s", SCH_GET_TASK_STATUS_STR(pTask), tstrerror(rspCode)); - - if (NULL == pData) { - pTask->retryTimes = 0; - } - - if (!NO_RET_REDIRECT_ERROR(rspCode)) { - SCH_UPDATE_REDICT_CODE(pJob, rspCode); - } - - SCH_ERR_JRET(schChkUpdateRedirectCtx(pJob, pTask, pData ? pData->pEpSet : NULL, rspCode)); - +void schResetTaskForRetry(SSchJob *pJob, SSchTask *pTask) { pTask->waitRetry = true; schDropTaskOnExecNode(pJob, pTask); + if (pTask->delayTimer) { + taosTmrStopA(&pTask->delayTimer); + } taosHashClear(pTask->execNodes); schRemoveTaskFromExecList(pJob, pTask); schDeregisterTaskHb(pJob, pTask); - atomic_sub_fetch_32(&pTask->level->taskLaunchedNum, 1); taosMemoryFreeClear(pTask->msg); pTask->msgLen = 0; pTask->lastMsgType = 0; + pTask->childReady = 0; memset(&pTask->succeedAddr, 0, sizeof(pTask->succeedAddr)); +} + +int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode) { + int32_t code = 0; + + SCH_TASK_DLOG("task will be redirected now, status:%s, code:%s", SCH_GET_TASK_STATUS_STR(pTask), tstrerror(rspCode)); + + if (!NO_RET_REDIRECT_ERROR(rspCode)) { + SCH_UPDATE_REDIRECT_CODE(pJob, rspCode); + } + + SCH_ERR_JRET(schChkUpdateRedirectCtx(pJob, pTask, pData ? pData->pEpSet : NULL, rspCode)); + + schResetTaskForRetry(pJob, pTask); if (SCH_IS_DATA_BIND_TASK(pTask)) { if (pData && pData->pEpSet) { @@ -445,12 +449,6 @@ int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32 SCH_TASK_DLOG("switch task target node %d epset to %d/%d", addr->nodeId, addr->epSet.inUse, addr->epSet.numOfEps); } - if (SCH_TASK_NEED_FLOW_CTRL(pJob, pTask)) { - if (JOB_TASK_STATUS_EXEC == SCH_GET_TASK_STATUS(pTask)) { - SCH_ERR_JRET(schLaunchTasksInFlowCtrlList(pJob, pTask)); - } - } - SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_INIT); SCH_ERR_JRET(schDelayLaunchTask(pJob, pTask)); @@ -486,20 +484,10 @@ _return: SCH_RET(schProcessOnTaskFailure(pJob, pTask, code)); } -int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode) { +int32_t schHandleTaskSetRetry(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode) { int32_t code = 0; - if (JOB_TASK_STATUS_PART_SUCC == pJob->status) { - SCH_LOCK(SCH_WRITE, &pJob->resLock); - if (pJob->fetched) { - SCH_UNLOCK(SCH_WRITE, &pJob->resLock); - SCH_TASK_ELOG("already fetched while got error %s", tstrerror(rspCode)); - SCH_ERR_JRET(rspCode); - } - SCH_UNLOCK(SCH_WRITE, &pJob->resLock); - - schUpdateJobStatus(pJob, JOB_TASK_STATUS_EXEC); - } + SCH_ERR_JRET(schChkResetJobRetry(pJob, rspCode)); if (SYNC_OTHER_LEADER_REDIRECT_ERROR(rspCode)) { if (NULL == pData->pEpSet) { @@ -509,7 +497,19 @@ int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32 } } + SCH_TASK_DLOG("start to redirect current task set cause of error: %s", tstrerror(rspCode)); + + for (int32_t i = 0; i < pJob->levelNum; ++i) { + SSchLevel *pLevel = taosArrayGet(pJob->levels, i); + + pLevel->taskExecDoneNum = 0; + pLevel->taskLaunchedNum = 0; + } + + SCH_RESET_JOB_LEVEL_IDX(pJob); + code = schDoTaskRedirect(pJob, pTask, pData, rspCode); + taosMemoryFreeClear(pData->pData); taosMemoryFreeClear(pData->pEpSet); @@ -621,6 +621,13 @@ int32_t schMoveTaskToExecList(SSchJob *pJob, SSchTask *pTask, bool *moved) { */ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bool *needRetry) { + if (pJob->noMoreRetry) { + *needRetry = false; + SCH_TASK_DLOG("task no more retry since job no more retry, retryTimes:%d/%d", pTask->retryTimes, + pTask->maxRetryTimes); + return TSDB_CODE_SUCCESS; + } + if (TSDB_CODE_SCH_TIMEOUT_ERROR == errCode) { pTask->maxExecTimes++; pTask->maxRetryTimes++; @@ -645,7 +652,7 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo return TSDB_CODE_SUCCESS; } - if (!SCH_NEED_RETRY(pTask->lastMsgType, errCode)) { + if (!SCH_TASK_NEED_RETRY(pTask->lastMsgType, errCode)) { *needRetry = false; SCH_TASK_DLOG("task no more retry cause of errCode, errCode:%x - %s", errCode, tstrerror(errCode)); return TSDB_CODE_SUCCESS; @@ -1067,7 +1074,6 @@ int32_t schLaunchTaskImpl(void *param) { SCH_ERR_JRET(TSDB_CODE_SCH_IGNORE_ERROR); } - // NOTE: race condition: the task should be put into the hash table before send msg to server if (SCH_GET_TASK_STATUS(pTask) != JOB_TASK_STATUS_EXEC) { SCH_ERR_JRET(schPushTaskToExecList(pJob, pTask)); SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_EXEC); @@ -1272,6 +1278,8 @@ int32_t schLaunchFetchTask(SSchJob *pJob) { return TSDB_CODE_SUCCESS; } + SCH_SET_TASK_STATUS(pJob->fetchTask, JOB_TASK_STATUS_FETCH); + if (SCH_IS_LOCAL_EXEC_TASK(pJob, pJob->fetchTask)) { SCH_ERR_JRET(schExecLocalFetch(pJob, pJob->fetchTask)); } else { diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 7cd5e957b6b8d47871274f80632a65ec11485753..2b46a4710e24215e9b32009f4fb97c8204963fe6 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -91,7 +91,7 @@ int32_t schedulerFetchRows(int64_t jobId, SSchedulerReq *pReq) { SCH_ERR_JRET(schHandleOpBeginEvent(jobId, &pJob, SCH_OP_FETCH, pReq)); - SCH_ERR_JRET(schJobFetchRows(pJob)); + SCH_ERR_JRET(schSwitchJobStatus(pJob, JOB_TASK_STATUS_FETCH, pReq)); _return: diff --git a/source/libs/stream/src/stream.c b/source/libs/stream/src/stream.c index 649e31be7708750d68db87a38dd374effef9cf58..bd23dc23126c4a69223bfd77be9a4616dc995bd4 100644 --- a/source/libs/stream/src/stream.c +++ b/source/libs/stream/src/stream.c @@ -279,7 +279,7 @@ int32_t streamProcessRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* pReq, S return 0; } -int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp) { - // - return 0; -} +// int32_t streamProcessRetrieveRsp(SStreamTask* pTask, SStreamRetrieveRsp* pRsp) { +// // +// return 0; +// } diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index 207be792ed7d235341cab6141ecc97ec7604f1ea..fd186a3feec3627bf6999f67988c9fa2e7f8eb65 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -20,7 +20,7 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, const void* data, SArray* pRes) { int32_t code; void* exec = pTask->exec.executor; - while (atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) { + while (pTask->taskLevel == TASK_LEVEL__SOURCE && atomic_load_8(&pTask->taskStatus) != TASK_STATUS__NORMAL) { qError("stream task wait for the end of fill history"); taosMsleep(2); continue; @@ -153,8 +153,14 @@ int32_t streamScanExec(SStreamTask* pTask, int32_t batchSz) { if (batchCnt >= batchSz) break; } if (taosArrayGetSize(pRes) == 0) { - taosArrayDestroy(pRes); - break; + if (finished) { + taosArrayDestroy(pRes); + qDebug("task %d finish recover exec task ", pTask->taskId); + break; + } else { + qDebug("task %d continue recover exec task ", pTask->taskId); + continue; + } } SStreamDataBlock* qRes = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM, 0); if (qRes == NULL) { diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c index 537ebb31d727cb1dc143021ede51d9eeee9e8672..cee72002daed01ddc71aae2a034b3f4b020f5995 100644 --- a/source/libs/stream/src/streamState.c +++ b/source/libs/stream/src/streamState.c @@ -144,21 +144,25 @@ SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int char cfgPath[1030]; sprintf(cfgPath, "%s/cfg", statePath); + szPage = szPage < 0 ? 4096 : szPage; + pages = pages < 0 ? 256 : pages; char cfg[1024]; memset(cfg, 0, 1024); TdFilePtr pCfgFile = taosOpenFile(cfgPath, TD_FILE_READ); if (pCfgFile != NULL) { - int64_t size; + int64_t size = 0; taosFStatFile(pCfgFile, &size, NULL); - taosReadFile(pCfgFile, cfg, size); - sscanf(cfg, "%d\n%d\n", &szPage, &pages); + if (size > 0) { + taosReadFile(pCfgFile, cfg, size); + sscanf(cfg, "%d\n%d\n", &szPage, &pages); + } } else { - taosMulModeMkDir(statePath, 0755); - pCfgFile = taosOpenFile(cfgPath, TD_FILE_WRITE | TD_FILE_CREATE); - szPage = szPage < 0 ? 4096 : szPage; - pages = pages < 0 ? 256 : pages; - sprintf(cfg, "%d\n%d\n", szPage, pages); - taosWriteFile(pCfgFile, cfg, strlen(cfg)); + int32_t code = taosMulModeMkDir(statePath, 0755); + if (code == 0) { + pCfgFile = taosOpenFile(cfgPath, TD_FILE_WRITE | TD_FILE_CREATE); + sprintf(cfg, "%d\n%d\n", szPage, pages); + taosWriteFile(pCfgFile, cfg, strlen(cfg)); + } } taosCloseFile(&pCfgFile); diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index bd1dae54d956a9a722d70eac30c596989d117cf3..9ab545075cfc38281358e8847447f821a00393aa 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -105,6 +105,7 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) { SRpcMsg rpcRsp = {0}; bool accepted = false; SSyncRaftEntry* pEntry = NULL; + bool resetElect = false; // if already drop replica, do not process if (!syncNodeInRaftGroup(ths, &(pMsg->srcId))) { @@ -137,7 +138,7 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) { } syncNodeStepDown(ths, pMsg->term); - syncNodeResetElectTimer(ths); + resetElect = true; if (pMsg->dataLen < sizeof(SSyncRaftEntry)) { sError("vgId:%d, incomplete append entries received. prev index:%" PRId64 ", term:%" PRId64 ", datalen:%d", @@ -184,10 +185,9 @@ _SEND_RESPONSE: // commit index, i.e. leader notice me if (syncLogBufferCommit(ths->pLogBuf, ths, ths->commitIndex) < 0) { sError("vgId:%d, failed to commit raft fsm log since %s.", ths->vgId, terrstr()); - goto _out; } -_out: + if (resetElect) syncNodeResetElectTimer(ths); return 0; _IGNORE: diff --git a/source/libs/sync/src/syncElection.c b/source/libs/sync/src/syncElection.c index e53b8ade1ca71281f4ec2536195456def7882781..3699efbc594c812c798c0c4b6aa38a6ae001edc5 100644 --- a/source/libs/sync/src/syncElection.c +++ b/source/libs/sync/src/syncElection.c @@ -115,6 +115,5 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) { ASSERT(ret == 0); syncNodeResetElectTimer(pSyncNode); - return ret; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 90f79fd93c7d2371fcafe83ab57ab42deb53e765..524daee7cf2e0ece65ba6ffac02ecaf9c9d2117f 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -37,6 +37,7 @@ #include "syncVoteMgr.h" #include "tglobal.h" #include "tref.h" +#include "syncUtil.h" static void syncNodeEqPingTimer(void* param, void* tmrId); static void syncNodeEqElectTimer(void* param, void* tmrId); @@ -182,6 +183,9 @@ int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg) { case TDMT_SYNC_TIMEOUT: code = syncNodeOnTimeout(pSyncNode, pMsg); break; + case TDMT_SYNC_TIMEOUT_ELECTION: + code = syncNodeOnTimeout(pSyncNode, pMsg); + break; case TDMT_SYNC_CLIENT_REQUEST: code = syncNodeOnClientRequest(pSyncNode, pMsg, NULL); break; @@ -206,6 +210,9 @@ int32_t syncProcessMsg(int64_t rid, SRpcMsg* pMsg) { case TDMT_SYNC_LOCAL_CMD: code = syncNodeOnLocalCmd(pSyncNode, pMsg); break; + case TDMT_SYNC_FORCE_FOLLOWER: + code = syncForceBecomeFollower(pSyncNode, pMsg); + break; default: terrno = TSDB_CODE_MSG_NOT_PROCESSED; code = -1; @@ -228,6 +235,20 @@ int32_t syncLeaderTransfer(int64_t rid) { return ret; } +int32_t syncForceBecomeFollower(SSyncNode* ths, const SRpcMsg* pRpcMsg) { + syncNodeBecomeFollower(ths, "force election"); + + SRpcMsg rsp = { + .code = 0, + .pCont = pRpcMsg->info.rsp, + .contLen = pRpcMsg->info.rspLen, + .info = pRpcMsg->info, + }; + tmsgSendRsp(&rsp); + + return 0; +} + int32_t syncSendTimeoutRsp(int64_t rid, int64_t seq) { SSyncNode* pNode = syncNodeAcquire(rid); if (pNode == NULL) return -1; @@ -1593,8 +1614,8 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) { pSyncNode->state = TAOS_SYNC_STATE_FOLLOWER; syncNodeStopHeartbeatTimer(pSyncNode); - // reset elect timer - syncNodeResetElectTimer(pSyncNode); + // trace log + sNTrace(pSyncNode, "become follower %s", debugStr); // send rsp to client syncNodeLeaderChangeRsp(pSyncNode); @@ -1610,8 +1631,8 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode, const char* debugStr) { // reset log buffer syncLogBufferReset(pSyncNode->pLogBuf, pSyncNode); - // trace log - sNTrace(pSyncNode, "become follower %s", debugStr); + // reset elect timer + syncNodeResetElectTimer(pSyncNode); } // TLA+ Spec @@ -2160,8 +2181,8 @@ int32_t syncNodeAppend(SSyncNode* ths, SSyncRaftEntry* pEntry) { // append to log buffer if (syncLogBufferAppend(ths->pLogBuf, ths, pEntry) < 0) { sError("vgId:%d, failed to enqueue sync log buffer, index:%" PRId64, ths->vgId, pEntry->index); - terrno = TSDB_CODE_SYN_BUFFER_FULL; - (void)syncLogFsmExecute(ths, ths->pFsm, ths->state, raftStoreGetTerm(ths), pEntry, TSDB_CODE_SYN_BUFFER_FULL); + ASSERT(terrno != 0); + (void)syncLogFsmExecute(ths, ths->pFsm, ths->state, raftStoreGetTerm(ths), pEntry, terrno); syncEntryDestroy(pEntry); return -1; } @@ -2277,6 +2298,7 @@ static int32_t syncNodeAppendNoopOld(SSyncNode* ths) { int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { SyncHeartbeat* pMsg = pRpcMsg->pCont; + bool resetElect = false; const STraceId* trace = &pRpcMsg->info.traceId; char tbuf[40] = {0}; @@ -2286,6 +2308,14 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { int64_t timeDiff = tsMs - pMsg->timeStamp; syncLogRecvHeartbeat(ths, pMsg, timeDiff, tbuf); + if (!syncNodeInRaftGroup(ths, &pMsg->srcId)) { + sWarn( + "vgId:%d, drop heartbeat msg from dnode:%d, because it come from another cluster:%d, differ from current " + "cluster:%d", + ths->vgId, DID(&(pMsg->srcId)), CID(&(pMsg->srcId)), CID(&(ths->myRaftId))); + return 0; + } + SRpcMsg rpcMsg = {0}; (void)syncBuildHeartbeatReply(&rpcMsg, ths->vgId); SyncTerm currentTerm = raftStoreGetTerm(ths); @@ -2300,12 +2330,11 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { if (pMsg->term == currentTerm && ths->state != TAOS_SYNC_STATE_LEADER) { syncIndexMgrSetRecvTime(ths->pNextIndex, &(pMsg->srcId), tsMs); + resetElect = true; - syncNodeResetElectTimer(ths); ths->minMatchIndex = pMsg->minMatchIndex; if (ths->state == TAOS_SYNC_STATE_FOLLOWER) { - // syncNodeFollowerCommit(ths, pMsg->commitIndex); SRpcMsg rpcMsgLocalCmd = {0}; (void)syncBuildLocalCmd(&rpcMsgLocalCmd, ths->vgId); @@ -2328,7 +2357,6 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { } if (pMsg->term >= currentTerm && ths->state != TAOS_SYNC_STATE_FOLLOWER) { - // syncNodeStepDown(ths, pMsg->term); SRpcMsg rpcMsgLocalCmd = {0}; (void)syncBuildLocalCmd(&rpcMsgLocalCmd, ths->vgId); @@ -2348,15 +2376,10 @@ int32_t syncNodeOnHeartbeat(SSyncNode* ths, const SRpcMsg* pRpcMsg) { } } - /* - // htonl - SMsgHead* pHead = rpcMsg.pCont; - pHead->contLen = htonl(pHead->contLen); - pHead->vgId = htonl(pHead->vgId); - */ - // reply syncNodeSendMsgById(&pMsgReply->destId, ths, &rpcMsg); + + if (resetElect) syncNodeResetElectTimer(ths); return 0; } diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c index 2a44588eefc2287bce3cfc310907c081f32338fb..72c8887803c778e0cd8a82b4b11273ad2b1df5f2 100644 --- a/source/libs/sync/src/syncMessage.c +++ b/source/libs/sync/src/syncMessage.c @@ -22,7 +22,7 @@ int32_t syncBuildTimeout(SRpcMsg* pMsg, ESyncTimeoutType timeoutType, uint64_t l SSyncNode* pNode) { int32_t bytes = sizeof(SyncTimeout); pMsg->pCont = rpcMallocCont(bytes); - pMsg->msgType = TDMT_SYNC_TIMEOUT; + pMsg->msgType = (timeoutType == SYNC_TIMEOUT_ELECTION) ? TDMT_SYNC_TIMEOUT_ELECTION : TDMT_SYNC_TIMEOUT; pMsg->contLen = bytes; if (pMsg->pCont == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -31,7 +31,7 @@ int32_t syncBuildTimeout(SRpcMsg* pMsg, ESyncTimeoutType timeoutType, uint64_t l SyncTimeout* pTimeout = pMsg->pCont; pTimeout->bytes = bytes; - pTimeout->msgType = TDMT_SYNC_TIMEOUT; + pTimeout->msgType = pMsg->msgType; pTimeout->vgId = pNode->vgId; pTimeout->timeoutType = timeoutType; pTimeout->logicClock = logicClock; diff --git a/source/libs/sync/src/syncPipeline.c b/source/libs/sync/src/syncPipeline.c index cc1a40a430f4698b18bed863fee5253030308b86..6600b505c18405c40abe262655898d20c078fd60 100644 --- a/source/libs/sync/src/syncPipeline.c +++ b/source/libs/sync/src/syncPipeline.c @@ -48,7 +48,16 @@ int32_t syncLogBufferAppend(SSyncLogBuffer* pBuf, SSyncNode* pNode, SSyncRaftEnt SyncIndex index = pEntry->index; if (index - pBuf->startIndex >= pBuf->size) { - sError("vgId:%d, failed to append due to sync log buffer full. index:%" PRId64 "", pNode->vgId, index); + terrno = TSDB_CODE_SYN_BUFFER_FULL; + sError("vgId:%d, failed to append since %s. index:%" PRId64 "", pNode->vgId, terrstr(), index); + goto _err; + } + + SyncIndex appliedIndex = pNode->pFsm->FpAppliedIndexCb(pNode->pFsm); + if (pNode->restoreFinish && pBuf->commitIndex - appliedIndex >= pBuf->size) { + terrno = TSDB_CODE_SYN_WRITE_STALL; + sError("vgId:%d, failed to append since %s. index:%" PRId64 ", commit-index:%" PRId64 ", applied-index:%" PRId64, + pNode->vgId, terrstr(), index, pBuf->commitIndex, appliedIndex); goto _err; } @@ -475,7 +484,7 @@ _out: int32_t syncLogFsmExecute(SSyncNode* pNode, SSyncFSM* pFsm, ESyncState role, SyncTerm term, SSyncRaftEntry* pEntry, int32_t applyCode) { - if ((pNode->replicaNum == 1) && pNode->restoreFinish && pNode->vgId != 1) { + if (pNode->replicaNum == 1 && pNode->restoreFinish && pNode->vgId != 1) { return 0; } @@ -587,10 +596,10 @@ _out: // mark as restored if needed if (!pNode->restoreFinish && pBuf->commitIndex >= pNode->commitIndex && pEntry != NULL && currentTerm <= pEntry->term) { - pNode->pFsm->FpRestoreFinishCb(pNode->pFsm); + pNode->pFsm->FpRestoreFinishCb(pNode->pFsm, pBuf->commitIndex); pNode->restoreFinish = true; - sInfo("vgId:%d, restore finished. log buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", pNode->vgId, - pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); + sInfo("vgId:%d, restore finished. term:%" PRId64 ", log buffer: [%" PRId64 " %" PRId64 " %" PRId64 ", %" PRId64 ")", + pNode->vgId, currentTerm, pBuf->startIndex, pBuf->commitIndex, pBuf->matchIndex, pBuf->endIndex); } if (!inBuf) { diff --git a/source/libs/sync/src/syncRequestVote.c b/source/libs/sync/src/syncRequestVote.c index 2fda2a19b8dad08a49d35e8d0492f7e3259fbffe..77e5498127ecea7bcead68d83876b5334f551567 100644 --- a/source/libs/sync/src/syncRequestVote.c +++ b/source/libs/sync/src/syncRequestVote.c @@ -20,6 +20,7 @@ #include "syncRaftStore.h" #include "syncUtil.h" #include "syncVoteMgr.h" +#include "syncUtil.h" // TLA+ Spec // HandleRequestVoteRequest(i, j, m) == @@ -89,6 +90,7 @@ static bool syncNodeOnRequestVoteLogOK(SSyncNode* ths, SyncRequestVote* pMsg) { int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) { int32_t ret = 0; SyncRequestVote* pMsg = pRpcMsg->pCont; + bool resetElect = false; // if already drop replica, do not process if (!syncNodeInRaftGroup(ths, &pMsg->srcId)) { @@ -115,7 +117,7 @@ int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) { syncNodeStepDown(ths, currentTerm); // forbid elect for this round - syncNodeResetElectTimer(ths); + resetElect = true; } // send msg @@ -134,5 +136,7 @@ int32_t syncNodeOnRequestVote(SSyncNode* ths, const SRpcMsg* pRpcMsg) { syncLogRecvRequestVote(ths, pMsg, pReply->voteGranted, ""); syncLogSendRequestVoteReply(ths, pReply, ""); syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); + + if (resetElect) syncNodeResetElectTimer(ths); return 0; } diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 413d6adf057ca5447ae31ef07398a9cf24d2a796..a9d0ddad17d99f929c51ef60e313d2df463377e3 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -798,7 +798,6 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { if (pMsg->term > raftStoreGetTerm(pSyncNode)) { syncNodeStepDown(pSyncNode, pMsg->term); } - syncNodeResetElectTimer(pSyncNode); // state, term, seq/ack int32_t code = 0; @@ -840,6 +839,7 @@ int32_t syncNodeOnSnapshot(SSyncNode *pSyncNode, const SRpcMsg *pRpcMsg) { code = -1; } + syncNodeResetElectTimer(pSyncNode); return code; } diff --git a/source/libs/sync/src/syncTimeout.c b/source/libs/sync/src/syncTimeout.c index 859183db9529ace6bf914fafbc381ca388880dea..a27be2853e512d73ada59bc224ce028ae208e0cb 100644 --- a/source/libs/sync/src/syncTimeout.c +++ b/source/libs/sync/src/syncTimeout.c @@ -120,9 +120,6 @@ int32_t syncNodeOnTimeout(SSyncNode* ths, const SRpcMsg* pRpc) { if (atomic_load_64(&ths->pingTimerLogicClockUser) <= pMsg->logicClock) { ++(ths->pingTimerCounter); - // syncNodePingAll(ths); - // syncNodePingPeers(ths); - syncNodeTimerRoutine(ths); } @@ -138,8 +135,6 @@ int32_t syncNodeOnTimeout(SSyncNode* ths, const SRpcMsg* pRpc) { ++(ths->heartbeatTimerCounter); sTrace("vgId:%d, sync timer, type:replicate count:%" PRIu64 ", lc-user:%" PRIu64, ths->vgId, ths->heartbeatTimerCounter, ths->heartbeatTimerLogicClockUser); - - // syncNodeReplicate(ths, true); } } else { diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index 29b7fa740c85e9ea74def8e53d47edd69c76b743..5ea9be63dbf7bb9415668d232324ca1272b49db6 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -947,6 +947,12 @@ static int tdbPagerRestore(SPager *pPager, const char *jFileName) { return 0; } +static int32_t txnIdCompareDesc(const void *pLeft, const void *pRight) { + int64_t lhs = *(int64_t *)pLeft; + int64_t rhs = *(int64_t *)pRight; + return lhs > rhs ? -1 : 1; +} + int tdbPagerRestoreJournals(SPager *pPager) { tdbDirEntryPtr pDirEntry; tdbDirPtr pDir = taosOpenDir(pPager->pEnv->dbName); @@ -955,23 +961,33 @@ int tdbPagerRestoreJournals(SPager *pPager) { return -1; } + SArray *pTxnList = taosArrayInit(16, sizeof(int64_t)); + while ((pDirEntry = tdbReadDir(pDir)) != NULL) { char *name = tdbDirEntryBaseName(tdbGetDirEntryName(pDirEntry)); if (strncmp(TDB_MAINDB_NAME "-journal", name, 16) == 0) { - char jname[TD_PATH_MAX] = {0}; - int dirLen = strlen(pPager->pEnv->dbName); - memcpy(jname, pPager->pEnv->dbName, dirLen); - jname[dirLen] = '/'; - memcpy(jname + dirLen + 1, name, strlen(name)); - if (tdbPagerRestore(pPager, jname) < 0) { - tdbCloseDir(&pDir); - - tdbError("failed to restore file due to %s. jFileName:%s", strerror(errno), name); - return -1; - } + int64_t txnId = -1; + sscanf(name, TDB_MAINDB_NAME "-journal.%" PRId64, &txnId); + taosArrayPush(pTxnList, &txnId); + } + } + taosArraySort(pTxnList, txnIdCompareDesc); + for (int i = 0; i < TARRAY_SIZE(pTxnList); ++i) { + int64_t *pTxnId = taosArrayGet(pTxnList, i); + char jname[TD_PATH_MAX] = {0}; + int dirLen = strlen(pPager->pEnv->dbName); + memcpy(jname, pPager->pEnv->dbName, dirLen); + jname[dirLen] = '/'; + sprintf(jname + dirLen + 1, TDB_MAINDB_NAME "-journal.%" PRId64, *pTxnId); + if (tdbPagerRestore(pPager, jname) < 0) { + tdbCloseDir(&pDir); + + tdbError("failed to restore file due to %s. jFileName:%s", strerror(errno), jname); + return -1; } } + taosArrayDestroy(pTxnList); tdbCloseDir(&pDir); return 0; diff --git a/source/libs/wal/src/walMgmt.c b/source/libs/wal/src/walMgmt.c index 702d05f57696c55e88b94d2d335674bd8f262c49..54e6abd85a50a5367bcac9c1c42d910df15d6b06 100644 --- a/source/libs/wal/src/walMgmt.c +++ b/source/libs/wal/src/walMgmt.c @@ -179,17 +179,23 @@ _err: int32_t walAlter(SWal *pWal, SWalCfg *pCfg) { if (pWal == NULL) return TSDB_CODE_APP_ERROR; - if (pWal->cfg.level == pCfg->level && pWal->cfg.fsyncPeriod == pCfg->fsyncPeriod) { - wDebug("vgId:%d, old walLevel:%d fsync:%d, new walLevel:%d fsync:%d not change", pWal->cfg.vgId, pWal->cfg.level, - pWal->cfg.fsyncPeriod, pCfg->level, pCfg->fsyncPeriod); + if (pWal->cfg.level == pCfg->level && pWal->cfg.fsyncPeriod == pCfg->fsyncPeriod && + pWal->cfg.retentionPeriod == pCfg->retentionPeriod && pWal->cfg.retentionSize == pCfg->retentionSize) { + wDebug("vgId:%d, walLevel:%d fsync:%d walRetentionPeriod:%d walRetentionSize:%" PRId64 " not change", + pWal->cfg.vgId, pWal->cfg.level, pWal->cfg.fsyncPeriod, pWal->cfg.retentionPeriod, pWal->cfg.retentionSize); return 0; } - wInfo("vgId:%d, change old walLevel:%d fsync:%d, new walLevel:%d fsync:%d", pWal->cfg.vgId, pWal->cfg.level, - pWal->cfg.fsyncPeriod, pCfg->level, pCfg->fsyncPeriod); + wInfo("vgId:%d, change old walLevel:%d fsync:%d walRetentionPeriod:%d walRetentionSize:%" PRId64 + ", new walLevel:%d fsync:%d walRetentionPeriod:%d walRetentionSize:%" PRId64, + pWal->cfg.vgId, pWal->cfg.level, pWal->cfg.fsyncPeriod, pWal->cfg.retentionPeriod, pWal->cfg.retentionSize, + pCfg->level, pCfg->fsyncPeriod, pCfg->retentionPeriod, pCfg->retentionSize); pWal->cfg.level = pCfg->level; pWal->cfg.fsyncPeriod = pCfg->fsyncPeriod; + pWal->cfg.retentionPeriod = pCfg->retentionPeriod; + pWal->cfg.retentionSize = pCfg->retentionSize; + pWal->fsyncSeq = pCfg->fsyncPeriod / 1000; if (pWal->fsyncSeq <= 0) pWal->fsyncSeq = 1; diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index 00ad7a3d67ea6118a0ed9d2fe8bd10b988bdd350..848de4f36da4db57e881df4977b4f2399314a68f 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -290,14 +290,22 @@ int32_t walEndSnapshot(SWal *pWal) { int ts = taosGetTimestampSec(); ver = TMAX(ver - pWal->vers.logRetention, pWal->vers.firstVer - 1); + + bool hasTopic = false; + int64_t refVer = ver; void *pIter = NULL; while (1) { pIter = taosHashIterate(pWal->pRefHash, pIter); if (pIter == NULL) break; SWalRef *pRef = *(SWalRef **)pIter; if (pRef->refVer == -1) continue; - ver = TMIN(ver, pRef->refVer - 1); + refVer = TMIN(refVer, pRef->refVer - 1); wDebug("vgId:%d, wal found ref %" PRId64 ", refId %" PRId64, pWal->cfg.vgId, pRef->refVer, pRef->refId); + hasTopic = true; + } + // compatible mode + if (pWal->cfg.retentionPeriod == 0 && hasTopic) { + ver = TMIN(ver, refVer); } int deleteCnt = 0; @@ -327,7 +335,7 @@ int32_t walEndSnapshot(SWal *pWal) { wDebug("vgId:%d, wal check remove file %" PRId64 "(file size %" PRId64 " close ts %" PRId64 "), new tot size %" PRId64, pWal->cfg.vgId, iter->firstVer, iter->fileSize, iter->closeTs, newTotSize); - if (((pWal->cfg.retentionSize == 0) || (pWal->cfg.retentionSize != -1 && newTotSize > pWal->cfg.retentionSize)) || + if ((pWal->cfg.retentionSize != -1 && pWal->cfg.retentionSize != 0 && newTotSize > pWal->cfg.retentionSize) || ((pWal->cfg.retentionPeriod == 0) || (pWal->cfg.retentionPeriod != -1 && iter->closeTs != -1 && iter->closeTs + pWal->cfg.retentionPeriod < ts))) { // delete according to file size or close time diff --git a/source/os/src/osSysinfo.c b/source/os/src/osSysinfo.c index 52309a7b35cbdad87baf87ab10fae2bf42c1e335..84004ed3c18d1bb4baa218d450e7c825d25cd385 100644 --- a/source/os/src/osSysinfo.c +++ b/source/os/src/osSysinfo.c @@ -17,6 +17,10 @@ #include "os.h" #include "taoserror.h" +#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL) +#include "cus_name.h" +#endif + #define PROCESS_ITEM 12 #define UUIDLEN37 37 @@ -252,7 +256,11 @@ int32_t taosGetEmail(char *email, int32_t maxLen) { #ifdef WINDOWS // ASSERT(0); #elif defined(_TD_DARWIN_64) +#ifdef CUS_PROMPT + const char *filepath = "/usr/local/"CUS_PROMPT"/email"; +#else const char *filepath = "/usr/local/taos/email"; +#endif // CUS_PROMPT TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_READ); if (pFile == NULL) return false; @@ -264,8 +272,12 @@ int32_t taosGetEmail(char *email, int32_t maxLen) { taosCloseFile(&pFile); return 0; +#else +#ifdef CUS_PROMPT + const char *filepath = "/usr/local/"CUS_PROMPT"/email"; #else const char *filepath = "/usr/local/taos/email"; +#endif // CUS_PROMPT TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_READ); if (pFile == NULL) return false; diff --git a/source/os/src/osTime.c b/source/os/src/osTime.c index 685693a709f4dd14efc3ffd5f277946a3293b38a..39d1de043713b83301c8f15a4030345d00536658 100644 --- a/source/os/src/osTime.c +++ b/source/os/src/osTime.c @@ -37,6 +37,9 @@ // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC) // until 00:00:00 January 1, 1970 static const uint64_t TIMEEPOCH = ((uint64_t)116444736000000000ULL); +// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC) +// until 00:00:00 January 1, 1900 +static const uint64_t TIMEEPOCH1900 = ((uint64_t)116445024000000000ULL); /* * We do not implement alternate representations. However, we always @@ -407,29 +410,39 @@ time_t taosMktime(struct tm *timep) { #endif } -struct tm *taosLocalTime(const time_t *timep, struct tm *result) { +struct tm *taosLocalTime(const time_t *timep, struct tm *result, char *buf) { + struct tm *res = NULL; + if (timep == NULL) { + return NULL; + } if (result == NULL) { - return localtime(timep); + res = localtime(timep); + if (res == NULL && buf != NULL) { + sprintf(buf, "NaN"); + } + return res; } #ifdef WINDOWS if (*timep < 0) { - SYSTEMTIME ss, s; - FILETIME ff, f; + if (*timep < -2208988800LL) { + if (buf != NULL) { + sprintf(buf, "NaN"); + } + return NULL; + } + + SYSTEMTIME s; + FILETIME f; LARGE_INTEGER offset; struct tm tm1; time_t tt = 0; - localtime_s(&tm1, &tt); - ss.wYear = tm1.tm_year + 1900; - ss.wMonth = tm1.tm_mon + 1; - ss.wDay = tm1.tm_mday; - ss.wHour = tm1.tm_hour; - ss.wMinute = tm1.tm_min; - ss.wSecond = tm1.tm_sec; - ss.wMilliseconds = 0; - SystemTimeToFileTime(&ss, &ff); - offset.QuadPart = ff.dwHighDateTime; - offset.QuadPart <<= 32; - offset.QuadPart |= ff.dwLowDateTime; + if (localtime_s(&tm1, &tt) != 0 ) { + if (buf != NULL) { + sprintf(buf, "NaN"); + } + return NULL; + } + offset.QuadPart = TIMEEPOCH1900; offset.QuadPart += *timep * 10000000; f.dwLowDateTime = offset.QuadPart & 0xffffffff; f.dwHighDateTime = (offset.QuadPart >> 32) & 0xffffffff; @@ -444,10 +457,18 @@ struct tm *taosLocalTime(const time_t *timep, struct tm *result) { result->tm_yday = 0; result->tm_isdst = 0; } else { - localtime_s(result, timep); + if (localtime_s(result, timep) != 0) { + if (buf != NULL) { + sprintf(buf, "NaN"); + } + return NULL; + } } #else - localtime_r(timep, result); + res = localtime_r(timep, result); + if (res == NULL && buf != NULL) { + sprintf(buf, "NaN"); + } #endif return result; } @@ -469,12 +490,16 @@ struct tm *taosLocalTimeNolock(struct tm *result, const time_t *timep, int dst) } #ifdef WINDOWS if (*timep < 0) { + return NULL; + // TODO: bugs in following code SYSTEMTIME ss, s; FILETIME ff, f; LARGE_INTEGER offset; struct tm tm1; time_t tt = 0; - localtime_s(&tm1, &tt); + if (localtime_s(&tm1, &tt) != 0) { + return NULL; + } ss.wYear = tm1.tm_year + 1900; ss.wMonth = tm1.tm_mon + 1; ss.wDay = tm1.tm_mday; @@ -500,7 +525,9 @@ struct tm *taosLocalTimeNolock(struct tm *result, const time_t *timep, int dst) result->tm_yday = 0; result->tm_isdst = 0; } else { - localtime_s(result, timep); + if (localtime_s(result, timep) != 0) { + return NULL; + } } #elif defined(LINUX) time_t secsMin = 60, secsHour = 3600, secsDay = 3600 * 24; diff --git a/source/os/src/osTimezone.c b/source/os/src/osTimezone.c index ad223bff27de80a454d09215926dcdf44e95c23c..cd6ad7cdb5b45c35bae19093a2a97b0c0d8e9bdf 100644 --- a/source/os/src/osTimezone.c +++ b/source/os/src/osTimezone.c @@ -893,7 +893,7 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { */ time_t tx1 = taosGetTimestampSec(); struct tm tm1; - taosLocalTime(&tx1, &tm1); + taosLocalTime(&tx1, &tm1, NULL); daylight = tm1.tm_isdst; /* @@ -921,7 +921,7 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { */ time_t tx1 = taosGetTimestampSec(); struct tm tm1; - taosLocalTime(&tx1, &tm1); + taosLocalTime(&tx1, &tm1, NULL); /* load time zone string from /etc/timezone */ // FILE *f = fopen("/etc/timezone", "r"); errno = 0; @@ -1008,7 +1008,7 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { */ time_t tx1 = taosGetTimestampSec(); struct tm tm1; - taosLocalTime(&tx1, &tm1); + taosLocalTime(&tx1, &tm1, NULL); /* * format example: diff --git a/source/os/test/osTimeTests.cpp b/source/os/test/osTimeTests.cpp index 366c3fc720f7c1543d1d11bdd69f1d2ae085eb38..5dd15db4ab929edb0a200e28b2fe1b2d230642ca 100644 --- a/source/os/test/osTimeTests.cpp +++ b/source/os/test/osTimeTests.cpp @@ -46,3 +46,80 @@ TEST(osTimeTests, taosLocalTimeNolock) { EXPECT_EQ(expectedTime.tm_yday, result->tm_yday); EXPECT_EQ(expectedTime.tm_isdst, result->tm_isdst); } + + +TEST(osTimeTests, taosLocalTime) { + // Test 1: Test when both timep and result are not NULL + time_t timep = 1617531000; // 2021-04-04 18:10:00 + struct tm result; + struct tm* local_time = taosLocalTime(&timep, &result, NULL); + ASSERT_NE(local_time, nullptr); + ASSERT_EQ(local_time->tm_year, 121); + ASSERT_EQ(local_time->tm_mon, 3); + ASSERT_EQ(local_time->tm_mday, 4); + ASSERT_EQ(local_time->tm_hour, 18); + ASSERT_EQ(local_time->tm_min, 10); + ASSERT_EQ(local_time->tm_sec, 00); + + // Test 2: Test when timep is NULL + local_time = taosLocalTime(NULL, &result, NULL); + ASSERT_EQ(local_time, nullptr); + + // Test 3: Test when result is NULL + local_time = taosLocalTime(&timep, NULL, NULL); + ASSERT_NE(local_time, nullptr); + ASSERT_EQ(local_time->tm_year, 121); + ASSERT_EQ(local_time->tm_mon, 3); + ASSERT_EQ(local_time->tm_mday, 4); + + // Test 4: Test when timep is negative on Windows +#ifdef WINDOWS + time_t pos_timep = 1609459200; // 2021-01-01 08:00:00 + local_time = taosLocalTime(&pos_timep, &result, NULL); + ASSERT_NE(local_time, nullptr); + ASSERT_EQ(local_time->tm_year, 121); + ASSERT_EQ(local_time->tm_mon, 0); + ASSERT_EQ(local_time->tm_mday, 1); + ASSERT_EQ(local_time->tm_hour, 8); + ASSERT_EQ(local_time->tm_min, 0); + ASSERT_EQ(local_time->tm_sec, 0); + + time_t neg_timep = -1617531000; // 1918-09-29 21:50:00 + local_time = taosLocalTime(&neg_timep, &result, NULL); + ASSERT_NE(local_time, nullptr); + ASSERT_EQ(local_time->tm_year, 18); + ASSERT_EQ(local_time->tm_mon, 8); + ASSERT_EQ(local_time->tm_mday, 29); + ASSERT_EQ(local_time->tm_hour, 21); + ASSERT_EQ(local_time->tm_min, 50); + ASSERT_EQ(local_time->tm_sec, 0); + + time_t neg_timep2 = -315619200; // 1960-01-01 08:00:00 + local_time = taosLocalTime(&neg_timep2, &result, NULL); + ASSERT_NE(local_time, nullptr); + ASSERT_EQ(local_time->tm_year, 60); + ASSERT_EQ(local_time->tm_mon, 0); + ASSERT_EQ(local_time->tm_mday, 1); + ASSERT_EQ(local_time->tm_hour, 8); + ASSERT_EQ(local_time->tm_min, 0); + ASSERT_EQ(local_time->tm_sec, 0); + + time_t zero_timep = 0; // 1970-01-01 08:00:00 + local_time = taosLocalTime(&zero_timep, &result, NULL); + ASSERT_NE(local_time, nullptr); + ASSERT_EQ(local_time->tm_year, 70); + ASSERT_EQ(local_time->tm_mon, 0); + ASSERT_EQ(local_time->tm_mday, 1); + ASSERT_EQ(local_time->tm_hour, 8); + ASSERT_EQ(local_time->tm_min, 0); + ASSERT_EQ(local_time->tm_sec, 0); + + time_t over_timep = 6406301441633558; + local_time = taosLocalTime(&over_timep, &result, NULL); + ASSERT_EQ(local_time, nullptr); + + time_t neg_timep3 = -78115158887; + local_time = taosLocalTime(&neg_timep3, &result, NULL); + ASSERT_EQ(local_time, nullptr); +#endif +} \ No newline at end of file diff --git a/source/util/src/tarray.c b/source/util/src/tarray.c index 7467fa29481d932632b612fc44550fd024542fc3..b15bb519e7344a9ccc6469b8f06570fba242af5a 100644 --- a/source/util/src/tarray.c +++ b/source/util/src/tarray.c @@ -140,46 +140,7 @@ void taosArrayRemoveDuplicate(SArray* pArray, __compar_fn_t comparFn, void (*fp) taosArraySet(pArray, pos + 1, p2); memset(TARRAY_GET_ELEM(pArray, i), 0, pArray->elemSize); - pos += 1; - } else { pos += 1; - } - } - } - - if (fp != NULL) { - for (int32_t i = pos + 1; i < pArray->size; ++i) { - void* p = taosArrayGet(pArray, i); - fp(p); - } - } - - pArray->size = pos + 1; -} - -void taosArrayRemoveDuplicateP(SArray* pArray, __compar_fn_t comparFn, void (*fp)(void*)) { - size_t size = pArray->size; - if (size <= 1) { - return; - } - - int32_t pos = 0; - for (int32_t i = 1; i < size; ++i) { - char* p1 = taosArrayGet(pArray, pos); - char* p2 = taosArrayGet(pArray, i); - - if (comparFn(p1, p2) == 0) { - // do nothing - } else { - if (pos + 1 != i) { - void* p = taosArrayGetP(pArray, pos + 1); - if (fp != NULL) { - fp(p); - } - - taosArraySet(pArray, pos + 1, p2); - memset(TARRAY_GET_ELEM(pArray, i), 0, pArray->elemSize); - pos += 1; } else { pos += 1; } @@ -188,7 +149,7 @@ void taosArrayRemoveDuplicateP(SArray* pArray, __compar_fn_t comparFn, void (*fp if (fp != NULL) { for (int32_t i = pos + 1; i < pArray->size; ++i) { - void* p = taosArrayGetP(pArray, i); + void* p = taosArrayGet(pArray, i); fp(p); } } @@ -392,20 +353,6 @@ void taosArrayClearEx(SArray* pArray, void (*fp)(void*)) { pArray->size = 0; } -void taosArrayClearP(SArray* pArray, FDelete fp) { - if (pArray == NULL) return; - if (fp == NULL) { - pArray->size = 0; - return; - } - - for (int32_t i = 0; i < pArray->size; ++i) { - fp(*(void**)TARRAY_GET_ELEM(pArray, i)); - } - - pArray->size = 0; -} - void* taosArrayDestroy(SArray* pArray) { if (pArray) { taosMemoryFree(pArray->pData); @@ -495,6 +442,7 @@ static void taosArrayInsertSort(SArray* pArray, __ext_compar_fn_t fn, const void if (pArray->size <= 1) { return; } + for (int32_t i = 1; i <= pArray->size - 1; ++i) { for (int32_t j = i; j > 0; --j) { if (fn(taosArrayGetP(pArray, j), taosArrayGetP(pArray, j - 1), param) == -1) { @@ -507,7 +455,6 @@ static void taosArrayInsertSort(SArray* pArray, __ext_compar_fn_t fn, const void } } } - return; } int32_t taosEncodeArray(void** buf, const SArray* pArray, FEncode encode) { @@ -556,4 +503,4 @@ void taosArraySwap(SArray* a, SArray* b) { void* data = a->pData; a->pData = b->pData; b->pData = data; -} +} \ No newline at end of file diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index c15bd96903c901ea9f0c7dd6aae317926c2b8ac9..f811d2f20316e2aab87cea030ead08613b19d77c 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -637,6 +637,8 @@ int32_t cfgLoadFromEnvVar(SConfig *pConfig) { int32_t code = 0; char **pEnv = environ; line[1023] = 0; + + if (pEnv == NULL) return 0; while (*pEnv != NULL) { name = value = value2 = value3 = NULL; olen = vlen = vlen2 = vlen3 = 0; diff --git a/source/util/src/terror.c b/source/util/src/terror.c index fb8493dfa44ca3462ac3ea9476c255cd57b0e4b9..af85201e0a5d420c97c250457d9ee6df22d1f5d3 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -224,6 +224,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DB, "Invalid database name TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_DATABASES, "Too many databases for account") TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_IN_DROPPING, "Database in dropping status") TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_NOT_EXIST, "Database not exist") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_RETENTION_PERIOD_ZERO, "WAL retention period is zero") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DB_ACCT, "Invalid database account") TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_OPTION_UNCHANGED, "Database options not changed") TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_INDEX_NOT_EXIST, "Index not exist") @@ -412,7 +413,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_GRANT_TABLE_LIMITED, "Table creation limite // sync TAOS_DEFINE_ERROR(TSDB_CODE_SYN_TIMEOUT, "Sync timeout") TAOS_DEFINE_ERROR(TSDB_CODE_SYN_IS_LEADER, "Sync is leader") -TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NOT_LEADER, "Sync not leader") +TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NOT_LEADER, "Sync leader is unreachable") TAOS_DEFINE_ERROR(TSDB_CODE_SYN_ONE_REPLICA, "Sync one replica") TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NOT_IN_NEW_CONFIG, "Sync not in new config") TAOS_DEFINE_ERROR(TSDB_CODE_SYN_NEW_CONFIG_ERROR, "Sync new config error") @@ -420,9 +421,10 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_RECONFIG_NOT_READY, "Sync not ready for re TAOS_DEFINE_ERROR(TSDB_CODE_SYN_PROPOSE_NOT_READY, "Sync not ready for propose") TAOS_DEFINE_ERROR(TSDB_CODE_SYN_STANDBY_NOT_READY, "Sync not ready for standby") TAOS_DEFINE_ERROR(TSDB_CODE_SYN_BATCH_ERROR, "Sync batch error") -TAOS_DEFINE_ERROR(TSDB_CODE_SYN_RESTORING, "Sync is restoring") +TAOS_DEFINE_ERROR(TSDB_CODE_SYN_RESTORING, "Sync leader is restoring") TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_SNAPSHOT_MSG, "Sync invalid snapshot msg") TAOS_DEFINE_ERROR(TSDB_CODE_SYN_BUFFER_FULL, "Sync buffer is full") +TAOS_DEFINE_ERROR(TSDB_CODE_SYN_WRITE_STALL, "Sync write stall") TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INTERNAL_ERROR, "Sync internal error") //tq @@ -515,7 +517,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_PAR_ONLY_ONE_JSON_TAG, "Only one tag if ther TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INCORRECT_NUM_OF_COL, "Query block has incorrect number of result columns") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INCORRECT_TIMESTAMP_VAL, "Incorrect TIMESTAMP value") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_OFFSET_LESS_ZERO, "soffset/offset can not be less than 0") -TAOS_DEFINE_ERROR(TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_BY, "slimit/soffset only available for PARTITION BY query") +TAOS_DEFINE_ERROR(TSDB_CODE_PAR_SLIMIT_LEAK_PARTITION_GROUP_BY, "slimit/soffset only available for PARTITION/GROUP BY query") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_TOPIC_QUERY, "Invalid topic query") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_DROP_STABLE, "Cannot drop super table in batch") TAOS_DEFINE_ERROR(TSDB_CODE_PAR_INVALID_FILL_TIME_RANGE, "Start(end) time of query range required or time range too large") diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index 89dd51a8924b3a24e70a665a3ae76e14541f6081..a3d3c399abcd6040cf042dec045024549e2d3179 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -21,7 +21,7 @@ #include "tjson.h" #include "tglobal.h" -#define LOG_MAX_LINE_SIZE (1024) +#define LOG_MAX_LINE_SIZE (10024) #define LOG_MAX_LINE_BUFFER_SIZE (LOG_MAX_LINE_SIZE + 3) #define LOG_MAX_LINE_DUMP_SIZE (1024 * 1024) #define LOG_MAX_LINE_DUMP_BUFFER_SIZE (LOG_MAX_LINE_DUMP_SIZE + 3) @@ -121,7 +121,7 @@ static FORCE_INLINE void taosUpdateDaylight() { struct timeval timeSecs; taosGetTimeOfDay(&timeSecs); time_t curTime = timeSecs.tv_sec; - ptm = taosLocalTime(&curTime, &Tm); + ptm = taosLocalTime(&curTime, &Tm, NULL); tsDaylightActive = ptm->tm_isdst; } static FORCE_INLINE int32_t taosGetDaylight() { return tsDaylightActive; } @@ -437,7 +437,7 @@ static inline int32_t taosBuildLogHead(char *buffer, const char *flags) { taosGetTimeOfDay(&timeSecs); time_t curTime = timeSecs.tv_sec; - ptm = taosLocalTime(&curTime, &Tm); + ptm = taosLocalTime(&curTime, &Tm, NULL); return sprintf(buffer, "%02d/%02d %02d:%02d:%02d.%06d %08" PRId64 " %s", ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec, (int32_t)timeSecs.tv_usec, taosGetSelfPthreadId(), flags); diff --git a/source/util/src/tlrucache.c b/source/util/src/tlrucache.c index 264883be4e71c99f1f3f3a1fbc872bf0c522728e..f4172fbb4427463f8a6cf8f937eac1df7eae2ce6 100644 --- a/source/util/src/tlrucache.c +++ b/source/util/src/tlrucache.c @@ -580,6 +580,16 @@ static size_t taosLRUCacheShardGetUsage(SLRUCacheShard *shard) { return usage; } +static int32_t taosLRUCacheShardGetElems(SLRUCacheShard *shard) { + int32_t elems = 0; + + taosThreadMutexLock(&shard->mutex); + elems = shard->table.elems; + taosThreadMutexUnlock(&shard->mutex); + + return elems; +} + static size_t taosLRUCacheShardGetPinnedUsage(SLRUCacheShard *shard) { size_t usage = 0; @@ -755,6 +765,16 @@ size_t taosLRUCacheGetUsage(SLRUCache *cache) { return usage; } +int32_t taosLRUCacheGetElems(SLRUCache *cache) { + int32_t elems = 0; + + for (int i = 0; i < cache->numShards; ++i) { + elems += taosLRUCacheShardGetElems(&cache->shards[i]); + } + + return elems; +} + size_t taosLRUCacheGetPinnedUsage(SLRUCache *cache) { size_t usage = 0; diff --git a/source/util/src/tsimplehash.c b/source/util/src/tsimplehash.c index 70acffed5d62fb0b13fd02ff719b0aab577ae76c..ec1991923fa5caf6f05fe441c386c015b3b22972 100644 --- a/source/util/src/tsimplehash.c +++ b/source/util/src/tsimplehash.c @@ -28,19 +28,23 @@ #define HASH_INDEX(v, c) ((v) & ((c)-1)) -#define FREE_HASH_NODE(_n) \ - do { \ - taosMemoryFreeClear(_n); \ +#define FREE_HASH_NODE(_n, fp) \ + do { \ + if (fp) { \ + fp((_n)->data); \ + } \ + taosMemoryFreeClear(_n); \ } while (0); struct SSHashObj { - SHNode **hashList; - size_t capacity; // number of slots - int64_t size; // number of elements in hash table - _hash_fn_t hashFp; // hash function - _equal_fn_t equalFp; // equal function - SArray* pHashNodeBuf;// hash node allocation buffer, 1k size of each page by default - int32_t offset; // allocation offset in current page + SHNode **hashList; + size_t capacity; // number of slots + int64_t size; // number of elements in hash table + _hash_fn_t hashFp; // hash function + _equal_fn_t equalFp; // equal function + _hash_free_fn_t freeFp; // free function + SArray *pHashNodeBuf; // hash node allocation buffer, 1k size of each page by default + int32_t offset; // allocation offset in current page }; static FORCE_INLINE int32_t taosHashCapacity(int32_t length) { @@ -71,7 +75,7 @@ SSHashObj *tSimpleHashInit(size_t capacity, _hash_fn_t fn) { pHashObj->capacity = taosHashCapacity((int32_t)capacity); pHashObj->equalFp = memcmp; - pHashObj->pHashNodeBuf = taosArrayInit(10, sizeof(void*)); + pHashObj->freeFp = NULL; pHashObj->offset = 0; pHashObj->size = 0; @@ -92,6 +96,10 @@ int32_t tSimpleHashGetSize(const SSHashObj *pHashObj) { return (int32_t) pHashObj->size; } +void tSimpleHashSetFreeFp(SSHashObj* pHashObj, _hash_free_fn_t freeFp) { + pHashObj->freeFp = freeFp; +} + static void* doInternalAlloc(SSHashObj* pHashObj, int32_t size) { #if 0 void** p = taosArrayGetLast(pHashObj->pHashNodeBuf); @@ -306,7 +314,8 @@ int32_t tSimpleHashRemove(SSHashObj *pHashObj, const void *key, size_t keyLen) { } else { pPrev->next = pNode->next; } - FREE_HASH_NODE(pNode); + + FREE_HASH_NODE(pNode, pHashObj->freeFp); pHashObj->size -= 1; code = TSDB_CODE_SUCCESS; break; @@ -341,7 +350,7 @@ int32_t tSimpleHashIterateRemove(SSHashObj *pHashObj, const void *key, size_t ke *pIter = pPrev ? GET_SHASH_NODE_DATA(pPrev) : NULL; } - FREE_HASH_NODE(pNode); + FREE_HASH_NODE(pNode, pHashObj->freeFp); pHashObj->size -= 1; break; } @@ -370,14 +379,13 @@ void tSimpleHashClear(SSHashObj *pHashObj) { while (pNode) { pNext = pNode->next; - FREE_HASH_NODE(pNode); + FREE_HASH_NODE(pNode, pHashObj->freeFp); pNode = pNext; } pHashObj->hashList[i] = NULL; } - taosArrayClearEx(pHashObj->pHashNodeBuf, destroyItems); pHashObj->offset = 0; pHashObj->size = 0; } @@ -388,7 +396,6 @@ void tSimpleHashCleanup(SSHashObj *pHashObj) { } tSimpleHashClear(pHashObj); - taosArrayDestroy(pHashObj->pHashNodeBuf); taosMemoryFreeClear(pHashObj->hashList); taosMemoryFree(pHashObj); } diff --git a/source/util/src/tversion.c b/source/util/src/tversion.c index dc357c61a10df4294f2bc78bcebe514a11aa0879..0f84f6bafa99464f98fea3e064ac9fb94076ffc0 100644 --- a/source/util/src/tversion.c +++ b/source/util/src/tversion.c @@ -26,8 +26,9 @@ int32_t taosVersionStrToInt(const char *vstr, int32_t *vint) { int32_t vnum[4] = {0}; int32_t len = strlen(vstr); char tmp[16] = {0}; + int32_t vpos = 0; - for (int32_t spos = 0, tpos = 0, vpos = 0; spos < len && vpos < 4; ++spos) { + for (int32_t spos = 0, tpos = 0; spos < len && vpos < 4; ++spos) { if (vstr[spos] != '.') { tmp[spos - tpos] = vstr[spos]; } else { @@ -38,6 +39,10 @@ int32_t taosVersionStrToInt(const char *vstr, int32_t *vint) { } } + if ('\0' != tmp[0] && vpos < 4) { + vnum[vpos] = atoi(tmp); + } + if (vnum[0] <= 0) { terrno = TSDB_CODE_INVALID_VERSION_STRING; return -1; @@ -66,16 +71,16 @@ int32_t taosCheckVersionCompatible(int32_t clientVer, int32_t serverVer, int32_t case 4: break; case 3: - clientVer %= 100; - serverVer %= 100; + clientVer /= 100; + serverVer /= 100; break; case 2: - clientVer %= 10000; - serverVer %= 10000; + clientVer /= 10000; + serverVer /= 10000; break; case 1: - clientVer %= 1000000; - serverVer %= 1000000; + clientVer /= 1000000; + serverVer /= 1000000; break; default: terrno = TSDB_CODE_INVALID_VERSION_NUMBER; diff --git a/source/util/src/version.c.in b/source/util/src/version.c.in index cb307b57fce37ba4243aea83995e66612f3c4371..71998e3321e79c08e0885ac09463c0ef05b4a6fa 100644 --- a/source/util/src/version.c.in +++ b/source/util/src/version.c.in @@ -1,6 +1,7 @@ char version[64] = "${TD_VER_NUMBER}"; char compatible_version[12] = "${TD_VER_COMPATIBLE}"; char gitinfo[48] = "${TD_VER_GIT}"; +char gitinfoOfInternal[48] = "${TD_VER_GIT_INTERNAL}"; char buildinfo[64] = "Built at ${TD_VER_DATE}"; void libtaos_${TD_LIB_VER_NUMBER}_${TD_VER_OSTYPE}_${TD_VER_CPUTYPE}_${TD_VER_VERTYPE}() {}; diff --git a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_telnet_tcp.json b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_telnet_tcp.json index 9e1241397fe13eced0000c600ad76971a30227ca..e609fcfebdf3cfb30a88b4e86d59f6b38ce4535b 100644 --- a/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_telnet_tcp.json +++ b/tests/develop-test/5-taos-tools/taosbenchmark/json/sml_telnet_tcp.json @@ -16,7 +16,7 @@ "num_of_records_per_req": 10, "databases": [{ "dbinfo": { - "name": "db", + "name": "opentsdb_telnet", "drop": "yes" }, "super_tables": [{ diff --git a/tests/docs-examples-test/python.sh b/tests/docs-examples-test/python.sh index a7501b54ed56b64121ee13913f8abd52bba9e381..2a44ee75528ed462460cc6783a2cca62f3a022ef 100644 --- a/tests/docs-examples-test/python.sh +++ b/tests/docs-examples-test/python.sh @@ -52,7 +52,7 @@ python3 conn_rest_pandas.py taos -s "drop database if exists power" # 11 -taos -s "create database if not exists test" +taos -s "create database if not exists test wal_retention_period 3600" python3 connect_native_reference.py # 12 diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 141ff2ef8ea4d8c7e0d18a44bf5dfdc447f7e687..f7910e1ab274499d068ce55442436b6932b0c095 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -415,6 +415,109 @@ ,,y,script,./test.sh -f tmp/monitor.sim #system test +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_26.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_26.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/columnLenUpdated.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/columnLenUpdated.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/columnLenUpdated.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/columnLenUpdated.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_26.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqShow.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropStb.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeStb0.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeStb1.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeStb2.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeStb3.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb0.py -N 3 -n 3 + + +,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/delete_stable.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_null_none.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_null_none.py -R +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_null_none.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_null_none.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_null_none.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/database_pre_suf.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/concat.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_26.py -Q 3 + +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/create_wrong_topic.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dropDbR3ConflictTransaction.py -N 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/basic5.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb.py -N 3 -n 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb1.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb2.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb3.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb4.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeStb.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeStb4.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/db.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqError.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/schema.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/stbFilter.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqCheckData.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqCheckData1.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsumerGroup.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqAlterSchema.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb.py -N 3 -n 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1.py -N 3 -n 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb-1ctb.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-1ctb.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqAutoCreateTbl.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDnodeRestart.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDnodeRestart1.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdate-1ctb.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdateWithConsume.py -N 3 -n 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdate-multiCtb-snapshot0.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdate-multiCtb-snapshot1.py +# ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDelete-1ctb.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDelete-multiCtb.py -N 3 -n 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropStbCtb.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropNtb-snapshot0.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropNtb-snapshot1.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUdf.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUdf-multCtb-snapshot0.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUdf-multCtb-snapshot1.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/stbTagFilter-1ctb.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dataFromTsdbNWal.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dataFromTsdbNWal-multiCtb.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_taosx.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/raw_block_interface_test.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/stbTagFilter-multiCtb.py +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqSubscribeStb-r3.py -N 5 +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 6 -M 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 6 -M 3 -n 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-19201.py +,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py + ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/balance_vgroups_r1.py -N 6 ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShell.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/taosShellError.py @@ -435,6 +538,8 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/fsync.py ,,n,system-test,python3 ./test.py -f 0-others/compatibility.py ,,n,system-test,python3 ./test.py -f 0-others/tag_index_basic.py +,,n,system-test,python3 ./test.py -f 0-others/udfpy_main.py +,,n,system-test,python3 ./test.py -N 3 -f 0-others/walRetention.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/alter_database.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/influxdb_line_taosc_insert.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/opentsdb_telnet_line_taosc_insert.py @@ -454,8 +559,8 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/table_param_ttl.py -R ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/update_data_muti_rows.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/db_tb_name_check.py -,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/database_pre_suf.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/InsertFuturets.py +,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/insert_wide_column.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/show.py ,,y,system-test,./pytest.sh python3 ./test.py -f 0-others/information_schema.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/abs.py @@ -560,6 +665,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_partition.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_partition.py -R ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_last_interval.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last_row_interval.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max.py -R ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/min.py @@ -638,7 +744,6 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/projectionDesc.py -R ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/update_data.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/tb_100w_data_order.py -,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/delete_stable.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/delete_childtable.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/delete_normaltable.py ,,y,system-test,./pytest.sh python3 ./test.py -f 1-insert/keep_expired.py @@ -648,11 +753,8 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/union1.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/concat2.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/json_tag.py -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQueryInterval.py -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py + ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity_1.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/elapsed.py @@ -700,68 +802,6 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas.py -N 4 -M 1 ,,y,system-test,./pytest.sh python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_insertdatas_querys.py -N 4 -M 1 ,,y,system-test,./pytest.sh python3 ./test.py -f 6-cluster/vnode/4dnode1mnode_basic_replica3_vgroups.py -N 4 -M 1 -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/create_wrong_topic.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dropDbR3ConflictTransaction.py -N 3 -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/basic5.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb.py -N 3 -n 3 -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb0.py -N 3 -n 3 -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb1.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb2.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb3.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeDb4.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeStb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeStb0.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeStb1.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeStb2.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeStb3.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeStb4.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/db.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqError.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/schema.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/stbFilter.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqCheckData.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqCheckData1.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsumerGroup.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqShow.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqAlterSchema.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb.py -N 3 -n 3 -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1.py -N 3 -n 3 -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb-1ctb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-1ctb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqAutoCreateTbl.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDnodeRestart.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDnodeRestart1.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdate-1ctb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdateWithConsume.py -N 3 -n 3 -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdate-multiCtb-snapshot0.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUpdate-multiCtb-snapshot1.py -# ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDelete-1ctb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDelete-multiCtb.py -N 3 -n 3 -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropStb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropStbCtb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropNtb-snapshot0.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropNtb-snapshot1.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUdf.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUdf-multCtb-snapshot0.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqUdf-multCtb-snapshot1.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/stbTagFilter-1ctb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dataFromTsdbNWal.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/dataFromTsdbNWal-multiCtb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq_taosx.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/stbTagFilter-multiCtb.py -,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-19201.py -,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqSubscribeStb-r3.py -N 5 -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 6 -M 3 -,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmq3mnodeSwitch.py -N 6 -M 3 -n 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/between.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/distinct.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/varchar.py -Q 2 @@ -821,11 +861,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/arctan.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/interp.py -Q 2 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQueryInterval.py -Q 2 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -Q 2 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 2 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity_1.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/avg.py -Q 2 @@ -854,6 +890,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count_partition.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_partition.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_last_interval.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last_row_interval.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last_row.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tsbsQuery.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/sml.py -Q 2 @@ -861,6 +898,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/blockSMA.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/projectionDesc.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py -Q 2 + ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/between.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/distinct.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/varchar.py -Q 3 @@ -876,7 +914,6 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/substr.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/union.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/union1.py -Q 3 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/concat.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/concat2.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/concat_ws.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/concat_ws2.py -Q 3 @@ -919,11 +956,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/arccos.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/arctan.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 3 -#,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQueryInterval.py -Q 3 -#,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -Q 3 -#,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 3 -#,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity_1.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/avg.py -Q 3 @@ -952,6 +985,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count_partition.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_partition.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_last_interval.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last_row_interval.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last_row.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tsbsQuery.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/sml.py -Q 3 @@ -1017,13 +1051,9 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/arccos.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/arctan.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 4 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQueryInterval.py -Q 4 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_str.py -Q 4 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_math.py -Q 4 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/nestedQuery_time.py -Q 4 -#,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity.py -Q 4 -#,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity_1.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/stablity_1.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/avg.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/elapsed.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/csum.py -Q 4 @@ -1051,6 +1081,7 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/count_partition.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_partition.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_last_interval.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last_row_interval.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/last_row.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tsbsQuery.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/sml.py -Q 4 @@ -1061,27 +1092,427 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_select.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_select.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_select.py -Q 4 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_null_none.py -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_null_none.py -R -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_null_none.py -Q 2 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_null_none.py -Q 3 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/insert_null_none.py -Q 4 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py -R -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py -Q 2 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py -Q 3 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/out_of_order.py -Q 4 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_data.py -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_data.py -R -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_data.py -Q 2 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_data.py -Q 3 -,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/max_min_data.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/blockSMA.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/projectionDesc.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/odbc.py ,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-21561.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 99-TDcase/TD-20582.py +#tsim test +,,y,script,./test.sh -f tsim/tmq/basic2Of2ConsOverlap.sim +,,y,script,./test.sh -f tsim/parser/where.sim +,,y,script,./test.sh -f tsim/parser/join_manyblocks.sim +,,y,script,./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim +,,y,script,./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v1_follower.sim +,,y,script,./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v2.sim +,,y,script,./test.sh -f tsim/dnode/redistribute_vgroup_replica3_v3.sim +,,y,script,./test.sh -f tsim/parser/limit1.sim +,,y,script,./test.sh -f tsim/parser/union.sim +,,y,script,./test.sh -f tsim/parser/commit.sim +,,y,script,./test.sh -f tsim/parser/nestquery.sim +,,n,script,./test.sh -f tsim/valgrind/checkError7.sim +,,y,script,./test.sh -f tsim/parser/groupby.sim +,,y,script,./test.sh -f tsim/parser/sliding.sim +,,y,script,./test.sh -f tsim/dnode/balance2.sim +,,y,script,./test.sh -f tsim/vnode/replica3_repeat.sim +,,y,script,./test.sh -f tsim/parser/col_arithmetic_operation.sim +,,y,script,./test.sh -f tsim/trans/create_db.sim +,,y,script,./test.sh -f tsim/dnode/balance3.sim +,,y,script,./test.sh -f tsim/vnode/replica3_many.sim +,,y,script,./test.sh -f tsim/stable/metrics_idx.sim +,,y,script,./test.sh -f tsim/db/alter_replica_13.sim +,,y,script,./test.sh -f tsim/sync/3Replica1VgElect.sim +,,y,script,./test.sh -f tsim/sync/3Replica5VgElect.sim +,,n,script,./test.sh -f tsim/valgrind/checkError6.sim + +,,y,script,./test.sh -f tsim/user/basic.sim +,,y,script,./test.sh -f tsim/user/password.sim +,,y,script,./test.sh -f tsim/user/privilege_db.sim +,,y,script,./test.sh -f tsim/user/privilege_sysinfo.sim +,,y,script,./test.sh -f tsim/user/privilege_topic.sim +,,y,script,./test.sh -f tsim/db/alter_option.sim +,,y,script,./test.sh -f tsim/db/alter_replica_31.sim +,,y,script,./test.sh -f tsim/db/basic1.sim +,,y,script,./test.sh -f tsim/db/basic2.sim +,,y,script,./test.sh -f tsim/db/basic3.sim +,,y,script,./test.sh -f tsim/db/basic4.sim +,,y,script,./test.sh -f tsim/db/basic5.sim +,,y,script,./test.sh -f tsim/db/basic6.sim +,,y,script,./test.sh -f tsim/db/commit.sim +,,y,script,./test.sh -f tsim/db/create_all_options.sim +,,y,script,./test.sh -f tsim/db/delete_reuse1.sim +,,y,script,./test.sh -f tsim/db/delete_reuse2.sim +,,y,script,./test.sh -f tsim/db/delete_reusevnode.sim +,,y,script,./test.sh -f tsim/db/delete_reusevnode2.sim +,,y,script,./test.sh -f tsim/db/delete_writing1.sim +,,y,script,./test.sh -f tsim/db/delete_writing2.sim +,,y,script,./test.sh -f tsim/db/error1.sim +,,y,script,./test.sh -f tsim/db/keep.sim +,,y,script,./test.sh -f tsim/db/len.sim +,,y,script,./test.sh -f tsim/db/repeat.sim +,,y,script,./test.sh -f tsim/db/show_create_db.sim +,,y,script,./test.sh -f tsim/db/show_create_table.sim +,,y,script,./test.sh -f tsim/db/tables.sim +,,y,script,./test.sh -f tsim/db/taosdlog.sim +,,y,script,./test.sh -f tsim/dnode/balance_replica1.sim +,,y,script,./test.sh -f tsim/dnode/balance_replica3.sim +,,y,script,./test.sh -f tsim/dnode/balance1.sim +,,y,script,./test.sh -f tsim/dnode/balancex.sim +,,y,script,./test.sh -f tsim/dnode/create_dnode.sim +,,y,script,./test.sh -f tsim/dnode/drop_dnode_has_mnode.sim +,,y,script,./test.sh -f tsim/dnode/drop_dnode_has_qnode_snode.sim +,,y,script,./test.sh -f tsim/dnode/drop_dnode_has_vnode_replica1.sim +,,y,script,./test.sh -f tsim/dnode/drop_dnode_has_vnode_replica3.sim +,,y,script,./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica1.sim +,,y,script,./test.sh -f tsim/dnode/drop_dnode_has_multi_vnode_replica3.sim +,,y,script,./test.sh -f tsim/dnode/drop_dnode_force.sim +,,y,script,./test.sh -f tsim/dnode/offline_reason.sim +,,y,script,./test.sh -f tsim/dnode/redistribute_vgroup_replica1.sim +,,y,script,./test.sh -f tsim/dnode/vnode_clean.sim +,,y,script,./test.sh -f tsim/dnode/use_dropped_dnode.sim +,,y,script,./test.sh -f tsim/dnode/split_vgroup_replica1.sim +,,y,script,./test.sh -f tsim/dnode/split_vgroup_replica3.sim +,,y,script,./test.sh -f tsim/import/basic.sim +,,y,script,./test.sh -f tsim/import/commit.sim +,,y,script,./test.sh -f tsim/import/large.sim +,,y,script,./test.sh -f tsim/import/replica1.sim +,,y,script,./test.sh -f tsim/insert/backquote.sim +,,y,script,./test.sh -f tsim/insert/basic.sim +,,y,script,./test.sh -f tsim/insert/basic0.sim +,,y,script,./test.sh -f tsim/insert/basic1.sim +,,y,script,./test.sh -f tsim/insert/basic2.sim +,,y,script,./test.sh -f tsim/insert/commit-merge0.sim +,,y,script,./test.sh -f tsim/insert/insert_drop.sim +,,y,script,./test.sh -f tsim/insert/insert_select.sim +,,y,script,./test.sh -f tsim/insert/null.sim +,,y,script,./test.sh -f tsim/insert/query_block1_file.sim +,,y,script,./test.sh -f tsim/insert/query_block1_memory.sim +,,y,script,./test.sh -f tsim/insert/query_block2_file.sim +,,y,script,./test.sh -f tsim/insert/query_block2_memory.sim +,,y,script,./test.sh -f tsim/insert/query_file_memory.sim +,,y,script,./test.sh -f tsim/insert/query_multi_file.sim +,,y,script,./test.sh -f tsim/insert/tcp.sim +,,y,script,./test.sh -f tsim/insert/update0.sim +,,y,script,./test.sh -f tsim/insert/update1_sort_merge.sim +,,y,script,./test.sh -f tsim/insert/update2.sim +,,y,script,./test.sh -f tsim/parser/alter__for_community_version.sim +,,y,script,./test.sh -f tsim/parser/alter_column.sim +,,y,script,./test.sh -f tsim/parser/alter_stable.sim +,,y,script,./test.sh -f tsim/parser/alter.sim +,,y,script,./test.sh -f tsim/parser/alter1.sim +,,y,script,./test.sh -f tsim/parser/auto_create_tb_drop_tb.sim +,,y,script,./test.sh -f tsim/parser/auto_create_tb.sim +,,y,script,./test.sh -f tsim/parser/between_and.sim +,,y,script,./test.sh -f tsim/parser/binary_escapeCharacter.sim +,,y,script,./test.sh -f tsim/parser/columnValue_bigint.sim +,,y,script,./test.sh -f tsim/parser/columnValue_bool.sim +,,y,script,./test.sh -f tsim/parser/columnValue_double.sim +,,y,script,./test.sh -f tsim/parser/columnValue_float.sim +,,y,script,./test.sh -f tsim/parser/columnValue_int.sim +,,y,script,./test.sh -f tsim/parser/columnValue_smallint.sim +,,y,script,./test.sh -f tsim/parser/columnValue_tinyint.sim +,,y,script,./test.sh -f tsim/parser/columnValue_unsign.sim +,,y,script,./test.sh -f tsim/parser/condition.sim +,,y,script,./test.sh -f tsim/parser/constCol.sim +,,y,script,./test.sh -f tsim/parser/create_db.sim +,,y,script,./test.sh -f tsim/parser/create_mt.sim +,,y,script,./test.sh -f tsim/parser/create_tb_with_tag_name.sim +,,y,script,./test.sh -f tsim/parser/create_tb.sim +,,y,script,./test.sh -f tsim/parser/dbtbnameValidate.sim +,,y,script,./test.sh -f tsim/parser/distinct.sim +,,y,script,./test.sh -f tsim/parser/fill_us.sim +,,y,script,./test.sh -f tsim/parser/fill.sim +,,y,script,./test.sh -f tsim/parser/first_last.sim +,,y,script,./test.sh -f tsim/parser/fill_stb.sim +,,y,script,./test.sh -f tsim/parser/interp.sim +,,y,script,./test.sh -f tsim/parser/fourArithmetic-basic.sim +,,y,script,./test.sh -f tsim/parser/function.sim +,,y,script,./test.sh -f tsim/parser/groupby-basic.sim +,,y,script,./test.sh -f tsim/parser/having_child.sim +,,y,script,./test.sh -f tsim/parser/having.sim +,,y,script,./test.sh -f tsim/parser/import_commit1.sim +,,y,script,./test.sh -f tsim/parser/import_commit2.sim +,,y,script,./test.sh -f tsim/parser/import_commit3.sim +,,y,script,./test.sh -f tsim/parser/import_file.sim +,,y,script,./test.sh -f tsim/parser/import.sim +,,y,script,./test.sh -f tsim/parser/insert_multiTbl.sim +,,y,script,./test.sh -f tsim/parser/insert_tb.sim +,,y,script,./test.sh -f tsim/parser/join_multitables.sim +,,y,script,./test.sh -f tsim/parser/join_multivnode.sim +,,y,script,./test.sh -f tsim/parser/join.sim +,,y,script,./test.sh -f tsim/parser/last_cache.sim +,,y,script,./test.sh -f tsim/parser/last_groupby.sim +,,y,script,./test.sh -f tsim/parser/lastrow.sim +,,y,script,./test.sh -f tsim/parser/lastrow2.sim +,,y,script,./test.sh -f tsim/parser/like.sim +,,y,script,./test.sh -f tsim/parser/limit.sim +,,y,script,./test.sh -f tsim/parser/mixed_blocks.sim +,,y,script,./test.sh -f tsim/parser/nchar.sim +,,y,script,./test.sh -f tsim/parser/null_char.sim +,,y,script,./test.sh -f tsim/parser/precision_ns.sim +,,y,script,./test.sh -f tsim/parser/projection_limit_offset.sim +,,y,script,./test.sh -f tsim/parser/regex.sim +,,y,script,./test.sh -f tsim/parser/regressiontest.sim +,,y,script,./test.sh -f tsim/parser/select_across_vnodes.sim +,,y,script,./test.sh -f tsim/parser/select_distinct_tag.sim +,,y,script,./test.sh -f tsim/parser/select_from_cache_disk.sim +,,y,script,./test.sh -f tsim/parser/select_with_tags.sim +,,y,script,./test.sh -f tsim/parser/selectResNum.sim +,,y,script,./test.sh -f tsim/parser/set_tag_vals.sim +,,y,script,./test.sh -f tsim/parser/single_row_in_tb.sim +,,y,script,./test.sh -f tsim/parser/slimit_alter_tags.sim +,,y,script,./test.sh -f tsim/parser/slimit.sim +,,y,script,./test.sh -f tsim/parser/slimit1.sim +,,y,script,./test.sh -f tsim/parser/stableOp.sim +,,y,script,./test.sh -f tsim/parser/tags_dynamically_specifiy.sim +,,y,script,./test.sh -f tsim/parser/tags_filter.sim +,,y,script,./test.sh -f tsim/parser/tbnameIn.sim +,,y,script,./test.sh -f tsim/parser/timestamp.sim +,,y,script,./test.sh -f tsim/parser/top_groupby.sim +,,y,script,./test.sh -f tsim/parser/topbot.sim +,,y,script,./test.sh -f tsim/parser/union_sysinfo.sim +,,y,script,./test.sh -f tsim/parser/slimit_limit.sim +,,y,script,./test.sh -f tsim/parser/table_merge_limit.sim +,,y,script,./test.sh -f tsim/query/tagLikeFilter.sim +,,y,script,./test.sh -f tsim/query/charScalarFunction.sim +,,y,script,./test.sh -f tsim/query/explain.sim +,,y,script,./test.sh -f tsim/query/interval-offset.sim +,,y,script,./test.sh -f tsim/query/interval.sim +,,y,script,./test.sh -f tsim/query/scalarFunction.sim +,,y,script,./test.sh -f tsim/query/scalarNull.sim +,,y,script,./test.sh -f tsim/query/session.sim +,,y,script,./test.sh -f tsim/query/udf.sim +,,n,script,./test.sh -f tsim/query/udfpy.sim +,,y,script,./test.sh -f tsim/query/udf_with_const.sim +,,y,script,./test.sh -f tsim/query/join_interval.sim +,,y,script,./test.sh -f tsim/query/unionall_as_table.sim +,,y,script,./test.sh -f tsim/query/sys_tbname.sim +,,y,script,./test.sh -f tsim/query/groupby.sim +,,y,script,./test.sh -f tsim/query/event.sim +,,y,script,./test.sh -f tsim/query/forceFill.sim +,,y,script,./test.sh -f tsim/query/emptyTsRange.sim +,,y,script,./test.sh -f tsim/query/partitionby.sim +,,y,script,./test.sh -f tsim/query/tableCount.sim +,,y,script,./test.sh -f tsim/query/nullColSma.sim +,,y,script,./test.sh -f tsim/qnode/basic1.sim +,,y,script,./test.sh -f tsim/snode/basic1.sim +,,y,script,./test.sh -f tsim/mnode/basic1.sim +,,y,script,./test.sh -f tsim/mnode/basic2.sim +,,y,script,./test.sh -f tsim/mnode/basic3.sim +,,y,script,./test.sh -f tsim/mnode/basic4.sim +,,y,script,./test.sh -f tsim/mnode/basic5.sim +,,y,script,./test.sh -f tsim/show/basic.sim +,,y,script,./test.sh -f tsim/table/autocreate.sim +,,y,script,./test.sh -f tsim/table/basic1.sim +,,y,script,./test.sh -f tsim/table/basic2.sim +,,y,script,./test.sh -f tsim/table/basic3.sim +,,y,script,./test.sh -f tsim/table/bigint.sim +,,y,script,./test.sh -f tsim/table/binary.sim +,,y,script,./test.sh -f tsim/table/bool.sim +,,y,script,./test.sh -f tsim/table/column_name.sim +,,y,script,./test.sh -f tsim/table/column_num.sim +,,y,script,./test.sh -f tsim/table/column_value.sim +,,y,script,./test.sh -f tsim/table/column2.sim +,,y,script,./test.sh -f tsim/table/createmulti.sim +,,y,script,./test.sh -f tsim/table/date.sim +,,y,script,./test.sh -f tsim/table/db.table.sim +,,y,script,./test.sh -f tsim/table/delete_reuse1.sim +,,y,script,./test.sh -f tsim/table/delete_reuse2.sim +,,y,script,./test.sh -f tsim/table/delete_writing.sim +,,y,script,./test.sh -f tsim/table/describe.sim +,,y,script,./test.sh -f tsim/table/double.sim +,,y,script,./test.sh -f tsim/table/float.sim +,,y,script,./test.sh -f tsim/table/hash.sim +,,y,script,./test.sh -f tsim/table/int.sim +,,y,script,./test.sh -f tsim/table/limit.sim +,,y,script,./test.sh -f tsim/table/smallint.sim +,,y,script,./test.sh -f tsim/table/table_len.sim +,,y,script,./test.sh -f tsim/table/table.sim +,,y,script,./test.sh -f tsim/table/tinyint.sim +,,y,script,./test.sh -f tsim/table/vgroup.sim +,,n,script,./test.sh -f tsim/stream/basic0.sim -g +,,y,script,./test.sh -f tsim/stream/basic1.sim +,,y,script,./test.sh -f tsim/stream/basic2.sim +,,y,script,./test.sh -f tsim/stream/drop_stream.sim +,,y,script,./test.sh -f tsim/stream/fillHistoryBasic1.sim +,,y,script,./test.sh -f tsim/stream/fillHistoryBasic2.sim +,,y,script,./test.sh -f tsim/stream/fillHistoryBasic3.sim +,,y,script,./test.sh -f tsim/stream/distributeInterval0.sim +,,y,script,./test.sh -f tsim/stream/distributeIntervalRetrive0.sim +,,y,script,./test.sh -f tsim/stream/distributeSession0.sim +,,y,script,./test.sh -f tsim/stream/session0.sim +,,y,script,./test.sh -f tsim/stream/session1.sim +,,y,script,./test.sh -f tsim/stream/state0.sim +,,y,script,./test.sh -f tsim/stream/triggerInterval0.sim +,,y,script,./test.sh -f tsim/stream/triggerSession0.sim +,,y,script,./test.sh -f tsim/stream/partitionby.sim +,,y,script,./test.sh -f tsim/stream/partitionby1.sim +,,y,script,./test.sh -f tsim/stream/schedSnode.sim +,,y,script,./test.sh -f tsim/stream/windowClose.sim +,,y,script,./test.sh -f tsim/stream/ignoreExpiredData.sim +,,y,script,./test.sh -f tsim/stream/sliding.sim +,,y,script,./test.sh -f tsim/stream/partitionbyColumnInterval.sim +,,y,script,./test.sh -f tsim/stream/partitionbyColumnSession.sim +,,y,script,./test.sh -f tsim/stream/partitionbyColumnState.sim +,,y,script,./test.sh -f tsim/stream/deleteInterval.sim +,,y,script,./test.sh -f tsim/stream/deleteSession.sim +,,y,script,./test.sh -f tsim/stream/deleteState.sim +,,y,script,./test.sh -f tsim/stream/fillIntervalDelete0.sim +,,y,script,./test.sh -f tsim/stream/fillIntervalDelete1.sim +,,y,script,./test.sh -f tsim/stream/fillIntervalLinear.sim +,,y,script,./test.sh -f tsim/stream/fillIntervalPartitionBy.sim +,,y,script,./test.sh -f tsim/stream/fillIntervalPrevNext.sim +,,y,script,./test.sh -f tsim/stream/fillIntervalValue.sim +,,y,script,./test.sh -f tsim/stream/udTableAndTag0.sim +,,y,script,./test.sh -f tsim/stream/udTableAndTag1.sim +,,y,script,./test.sh -f tsim/trans/lossdata1.sim +,,y,script,./test.sh -f tsim/tmq/basic1.sim +,,y,script,./test.sh -f tsim/tmq/basic2.sim +,,y,script,./test.sh -f tsim/tmq/basic3.sim +,,y,script,./test.sh -f tsim/tmq/basic4.sim +,,y,script,./test.sh -f tsim/tmq/basic1Of2Cons.sim +,,y,script,./test.sh -f tsim/tmq/basic2Of2Cons.sim +,,y,script,./test.sh -f tsim/tmq/basic3Of2Cons.sim +,,y,script,./test.sh -f tsim/tmq/basic4Of2Cons.sim +,,y,script,./test.sh -f tsim/tmq/topic.sim +,,y,script,./test.sh -f tsim/tmq/snapshot.sim +,,y,script,./test.sh -f tsim/tmq/snapshot1.sim +,,y,script,./test.sh -f tsim/stable/alter_comment.sim +,,y,script,./test.sh -f tsim/stable/alter_count.sim +,,y,script,./test.sh -f tsim/stable/alter_import.sim +,,y,script,./test.sh -f tsim/stable/alter_insert1.sim +,,y,script,./test.sh -f tsim/stable/alter_insert2.sim +,,y,script,./test.sh -f tsim/stable/alter_metrics.sim +,,y,script,./test.sh -f tsim/stable/column_add.sim +,,y,script,./test.sh -f tsim/stable/column_drop.sim +,,y,script,./test.sh -f tsim/stable/column_modify.sim +,,y,script,./test.sh -f tsim/stable/disk.sim +,,y,script,./test.sh -f tsim/stable/dnode3.sim +,,y,script,./test.sh -f tsim/stable/metrics.sim +,,y,script,./test.sh -f tsim/stable/refcount.sim +,,y,script,./test.sh -f tsim/stable/tag_add.sim +,,y,script,./test.sh -f tsim/stable/tag_drop.sim +,,y,script,./test.sh -f tsim/stable/tag_filter.sim +,,y,script,./test.sh -f tsim/stable/tag_modify.sim +,,y,script,./test.sh -f tsim/stable/tag_rename.sim +,,y,script,./test.sh -f tsim/stable/values.sim +,,y,script,./test.sh -f tsim/stable/vnode3.sim +,,n,script,./test.sh -f tsim/sma/drop_sma.sim +,,y,script,./test.sh -f tsim/sma/sma_leak.sim +,,y,script,./test.sh -f tsim/sma/tsmaCreateInsertQuery.sim +,,y,script,./test.sh -f tsim/sma/rsmaCreateInsertQuery.sim +,,y,script,./test.sh -f tsim/sma/rsmaPersistenceRecovery.sim +,,n,script,./test.sh -f tsim/valgrind/checkError1.sim +,,n,script,./test.sh -f tsim/valgrind/checkError2.sim +,,n,script,./test.sh -f tsim/valgrind/checkError3.sim +,,n,script,./test.sh -f tsim/valgrind/checkError4.sim +,,n,script,./test.sh -f tsim/valgrind/checkError5.sim +,,n,script,./test.sh -f tsim/valgrind/checkError8.sim +,,n,script,./test.sh -f tsim/valgrind/checkUdf.sim +,,y,script,./test.sh -f tsim/vnode/replica3_basic.sim +,,y,script,./test.sh -f tsim/vnode/replica3_vgroup.sim +,,y,script,./test.sh -f tsim/vnode/replica3_import.sim +,,y,script,./test.sh -f tsim/vnode/stable_balance_replica1.sim +,,y,script,./test.sh -f tsim/vnode/stable_dnode2_stop.sim +,,y,script,./test.sh -f tsim/vnode/stable_dnode2.sim +,,y,script,./test.sh -f tsim/vnode/stable_dnode3.sim +,,y,script,./test.sh -f tsim/vnode/stable_replica3_dnode6.sim +,,y,script,./test.sh -f tsim/vnode/stable_replica3_vnode3.sim +,,y,script,./test.sh -f tsim/sync/oneReplica1VgElect.sim +,,y,script,./test.sh -f tsim/sync/oneReplica5VgElect.sim +,,y,script,./test.sh -f tsim/catalog/alterInCurrent.sim +,,y,script,./test.sh -f tsim/scalar/in.sim +,,y,script,./test.sh -f tsim/scalar/scalar.sim +,,y,script,./test.sh -f tsim/scalar/filter.sim +,,y,script,./test.sh -f tsim/scalar/caseWhen.sim +,,y,script,./test.sh -f tsim/scalar/tsConvert.sim +,,y,script,./test.sh -f tsim/alter/cached_schema_after_alter.sim +,,y,script,./test.sh -f tsim/alter/dnode.sim +,,y,script,./test.sh -f tsim/alter/table.sim +,,y,script,./test.sh -f tsim/cache/new_metrics.sim +,,y,script,./test.sh -f tsim/cache/restart_table.sim +,,y,script,./test.sh -f tsim/cache/restart_metrics.sim +,,y,script,./test.sh -f tsim/column/commit.sim +,,y,script,./test.sh -f tsim/column/metrics.sim +,,y,script,./test.sh -f tsim/column/table.sim +,,y,script,./test.sh -f tsim/compress/commitlog.sim +,,y,script,./test.sh -f tsim/compress/compress2.sim +,,y,script,./test.sh -f tsim/compress/compress.sim +,,y,script,./test.sh -f tsim/compress/uncompress.sim +,,y,script,./test.sh -f tsim/compute/avg.sim +,,y,script,./test.sh -f tsim/compute/block_dist.sim +,,y,script,./test.sh -f tsim/compute/bottom.sim +,,y,script,./test.sh -f tsim/compute/count.sim +,,y,script,./test.sh -f tsim/compute/diff.sim +,,y,script,./test.sh -f tsim/compute/diff2.sim +,,y,script,./test.sh -f tsim/compute/first.sim +,,y,script,./test.sh -f tsim/compute/interval.sim +,,y,script,./test.sh -f tsim/compute/last_row.sim +,,y,script,./test.sh -f tsim/compute/last.sim +,,y,script,./test.sh -f tsim/compute/leastsquare.sim +,,y,script,./test.sh -f tsim/compute/max.sim +,,y,script,./test.sh -f tsim/compute/min.sim +,,y,script,./test.sh -f tsim/compute/null.sim +,,y,script,./test.sh -f tsim/compute/percentile.sim +,,y,script,./test.sh -f tsim/compute/stddev.sim +,,y,script,./test.sh -f tsim/compute/sum.sim +,,y,script,./test.sh -f tsim/compute/top.sim +,,y,script,./test.sh -f tsim/field/2.sim +,,y,script,./test.sh -f tsim/field/3.sim +,,y,script,./test.sh -f tsim/field/4.sim +,,y,script,./test.sh -f tsim/field/5.sim +,,y,script,./test.sh -f tsim/field/6.sim +,,y,script,./test.sh -f tsim/field/binary.sim +,,y,script,./test.sh -f tsim/field/bigint.sim +,,y,script,./test.sh -f tsim/field/bool.sim +,,y,script,./test.sh -f tsim/field/double.sim +,,y,script,./test.sh -f tsim/field/float.sim +,,y,script,./test.sh -f tsim/field/int.sim +,,y,script,./test.sh -f tsim/field/single.sim +,,y,script,./test.sh -f tsim/field/smallint.sim +,,y,script,./test.sh -f tsim/field/tinyint.sim +,,y,script,./test.sh -f tsim/field/unsigined_bigint.sim +,,y,script,./test.sh -f tsim/vector/metrics_field.sim +,,y,script,./test.sh -f tsim/vector/metrics_mix.sim +,,y,script,./test.sh -f tsim/vector/metrics_query.sim +,,y,script,./test.sh -f tsim/vector/metrics_tag.sim +,,y,script,./test.sh -f tsim/vector/metrics_time.sim +,,y,script,./test.sh -f tsim/vector/multi.sim +,,y,script,./test.sh -f tsim/vector/single.sim +,,y,script,./test.sh -f tsim/vector/table_field.sim +,,y,script,./test.sh -f tsim/vector/table_mix.sim +,,y,script,./test.sh -f tsim/vector/table_query.sim +,,y,script,./test.sh -f tsim/vector/table_time.sim +,,y,script,./test.sh -f tsim/wal/kill.sim +,,y,script,./test.sh -f tsim/tag/3.sim +,,y,script,./test.sh -f tsim/tag/4.sim +,,y,script,./test.sh -f tsim/tag/5.sim +,,y,script,./test.sh -f tsim/tag/6.sim +,,y,script,./test.sh -f tsim/tag/add.sim +,,y,script,./test.sh -f tsim/tag/bigint.sim +,,y,script,./test.sh -f tsim/tag/binary_binary.sim +,,y,script,./test.sh -f tsim/tag/binary.sim +,,y,script,./test.sh -f tsim/tag/bool_binary.sim +,,y,script,./test.sh -f tsim/tag/bool_int.sim +,,y,script,./test.sh -f tsim/tag/bool.sim +,,y,script,./test.sh -f tsim/tag/change.sim +,,y,script,./test.sh -f tsim/tag/column.sim +,,y,script,./test.sh -f tsim/tag/commit.sim +,,y,script,./test.sh -f tsim/tag/create.sim +,,y,script,./test.sh -f tsim/tag/delete.sim +,,y,script,./test.sh -f tsim/tag/double.sim +,,y,script,./test.sh -f tsim/tag/filter.sim +,,y,script,./test.sh -f tsim/tag/float.sim +,,y,script,./test.sh -f tsim/tag/int_binary.sim +,,y,script,./test.sh -f tsim/tag/int_float.sim +,,y,script,./test.sh -f tsim/tag/int.sim +,,y,script,./test.sh -f tsim/tag/set.sim +,,y,script,./test.sh -f tsim/tag/smallint.sim +,,y,script,./test.sh -f tsim/tag/tinyint.sim +,,y,script,./test.sh -f tsim/tag/drop_tag.sim +,,y,script,./test.sh -f tsim/tag/tbNameIn.sim +,,y,script,./test.sh -f tmp/monitor.sim #develop test ,,n,develop-test,python3 ./test.py -f 2-query/table_count_scan.py ,,n,develop-test,python3 ./test.py -f 2-query/show_create_db.py @@ -1094,7 +1525,7 @@ ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/json_tag.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/query_json.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/sample_csv_json.py -#,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/sml_json_alltypes.py +,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/sml_json_alltypes.py ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/taosdemoTestQueryWithJson.py -R ,,n,develop-test,python3 ./test.py -f 5-taos-tools/taosbenchmark/telnet_tcp.py -R diff --git a/tests/parallel_test/container_build.sh b/tests/parallel_test/container_build.sh index edb9b4ab3cae80af399f3ed3b22d4416bf1902d8..80236cf604d63e4d9c8fdddfa81aeaf16fb64944 100755 --- a/tests/parallel_test/container_build.sh +++ b/tests/parallel_test/container_build.sh @@ -68,8 +68,8 @@ docker run \ -v ${REP_REAL_PATH}/community/contrib/libuv/:${REP_DIR}/community/contrib/libuv \ -v ${REP_REAL_PATH}/community/contrib/lz4/:${REP_DIR}/community/contrib/lz4 \ -v ${REP_REAL_PATH}/community/contrib/zlib/:${REP_DIR}/community/contrib/zlib \ - -v ${REP_REAL_PATH}/community/contrib/jemalloc/:${REP_DIR}/community/contrib/jemalloc \ - --rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_TAOSX=true;make -j || exit 1" + --rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_TAOSX=true -DJEMALLOC_ENABLED=true;make -j || exit 1" + # -v ${REP_REAL_PATH}/community/contrib/jemalloc/:${REP_DIR}/community/contrib/jemalloc \ if [[ -d ${WORKDIR}/debugNoSan ]] ;then echo "delete ${WORKDIR}/debugNoSan" @@ -97,7 +97,7 @@ docker run \ -v ${REP_REAL_PATH}/community/contrib/lz4/:${REP_DIR}/community/contrib/lz4 \ -v ${REP_REAL_PATH}/community/contrib/zlib/:${REP_DIR}/community/contrib/zlib \ -v ${REP_REAL_PATH}/community/contrib/jemalloc/:${REP_DIR}/community/contrib/jemalloc \ - --rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_SANITIZER=1 -DTOOLS_SANITIZE=true -DTOOLS_BUILD_TYPE=Debug -DBUILD_TAOSX=true;make -j || exit 1 " + --rm --ulimit core=-1 taos_test:v1.0 sh -c "pip uninstall taospy -y;pip3 install taospy==2.7.2;cd $REP_DIR;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true -DBUILD_TEST=true -DWEBSOCKET=true -DBUILD_SANITIZER=1 -DTOOLS_SANITIZE=true -DTOOLS_BUILD_TYPE=Debug -DBUILD_TAOSX=true -DJEMALLOC_ENABLED=true;make -j || exit 1 " mv ${REP_REAL_PATH}/debug ${WORKDIR}/debugSan diff --git a/tests/parallel_test/run.sh b/tests/parallel_test/run.sh index 43533d4f3688922d0f7670e5a74218a606c11f12..de343752c69801c76d1296f0e81685af591e046c 100755 --- a/tests/parallel_test/run.sh +++ b/tests/parallel_test/run.sh @@ -167,8 +167,10 @@ function run_thread() { local case_build_san=`echo "$line"|cut -d, -f3` if [ "${case_build_san}" == "y" ]; then case_build_san="y" + DEBUGPATH="debugSan" elif [[ "${case_build_san}" == "n" ]] || [[ "${case_build_san}" == "" ]]; then case_build_san="n" + DEBUGPATH="debugNoSan" else usage exit 1 @@ -274,6 +276,7 @@ function run_thread() { # echo "$thread_no ${line} DONE" if [ $ret -eq 0 ]; then echo -e "$case_index \e[34m DONE <<<<< \e[0m ${case_info} \e[34m[${total_time}s]\e[0m \e[32m success\e[0m" + flock -x $lock_file -c "echo \"${case_info}|success|${total_time}\" >>${success_case_file}" else if [ ! -z ${web_server} ]; then flock -x $lock_file -c "echo -e \"${hosts[index]} ret:${ret} ${line}\n ${web_server}/$test_log_dir/${case_file}.txt\" >>${failed_case_file}" @@ -300,10 +303,10 @@ function run_thread() { if [ ! -z "$corefile" ]; then echo -e "\e[34m corefiles: $corefile \e[0m" local build_dir=$log_dir/build_${hosts[index]} - local remote_build_dir="${workdirs[index]}/TDengine/debug/build" - if [ $ent -ne 0 ]; then - remote_build_dir="${workdirs[index]}/TDinternal/debug/build" - fi + local remote_build_dir="${workdirs[index]}/{DEBUGPATH}/build" + # if [ $ent -ne 0 ]; then + # remote_build_dir="${workdirs[index]}/{DEBUGPATH}/build" + # fi mkdir $build_dir 2>/dev/null if [ $? -eq 0 ]; then # scp build binary @@ -365,6 +368,8 @@ lock_file=$log_dir/$$.lock index_file=$log_dir/case_index.txt stat_file=$log_dir/stat.txt failed_case_file=$log_dir/failed.txt +success_case_file=$log_dir/success.txt + echo "0" >$index_file i=0 diff --git a/tests/parallel_test/run_case.sh b/tests/parallel_test/run_case.sh index e00e59f46b00dd9425fa393fb6a1b9918079d1ba..ffc23ba6d2baa83b534532d1eac9cb154d007ecb 100755 --- a/tests/parallel_test/run_case.sh +++ b/tests/parallel_test/run_case.sh @@ -51,6 +51,9 @@ if [ $ent -eq 0 ]; then ln -s /home/TDengine/debug/build/lib/libtaos.so /usr/lib/libtaos.so 2>/dev/null ln -s /home/TDengine/debug/build/lib/libtaos.so /usr/lib/libtaos.so.1 2>/dev/null ln -s /home/TDengine/include/client/taos.h /usr/include/taos.h 2>/dev/null + ln -s /home/TDengine/include/common/taosdef.h /usr/include/taosdef.h 2>/dev/null + ln -s /home/TDengine/include/util/taoserror.h /usr/include/taoserror.h 2>/dev/null + ln -s /home/TDengine/include/libs/function/taosudf.h /usr/include/taosudf.h 2>/dev/null CONTAINER_TESTDIR=/home/TDengine else export PATH=$PATH:/home/TDinternal/debug/build/bin @@ -58,6 +61,9 @@ else ln -s /home/TDinternal/debug/build/lib/libtaos.so /usr/lib/libtaos.so 2>/dev/null ln -s /home/TDinternal/debug/build/lib/libtaos.so /usr/lib/libtaos.so.1 2>/dev/null ln -s /home/TDinternal/community/include/client/taos.h /usr/include/taos.h 2>/dev/null + ln -s /home/TDinternal/community/include/common/taosdef.h /usr/include/taosdef.h 2>/dev/null + ln -s /home/TDinternal/community/include/util/taoserror.h /usr/include/taoserror.h 2>/dev/null + ln -s /home/TDinternal/community/include/libs/function/taosudf.h /usr/include/taosudf.h 2>/dev/null CONTAINER_TESTDIR=/home/TDinternal/community fi mkdir -p /var/lib/taos/subscribe diff --git a/tests/pytest/util/autogen.py b/tests/pytest/util/autogen.py new file mode 100644 index 0000000000000000000000000000000000000000..b85348d0ba36a026e9400ece76e18de54185aeee --- /dev/null +++ b/tests/pytest/util/autogen.py @@ -0,0 +1,165 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +import threading +import random +import string +import time + + +# +# Auto Gen class +# +class AutoGen: + def __init__(self): + self.ts = 1600000000000 + self.batch_size = 100 + seed = time.clock_gettime(time.CLOCK_REALTIME) + random.seed(seed) + + # set start ts + def set_start_ts(self, ts): + self.ts = ts + + # set batch size + def set_batch_size(self, batch_size): + self.batch_size = batch_size + + # _columns_sql + def gen_columns_sql(self, pre, cnt, binary_len, nchar_len): + types = [ + 'timestamp', + 'tinyint', + 'smallint', + 'tinyint unsigned', + 'smallint unsigned', + 'int', + 'bigint', + 'int unsigned', + 'bigint unsigned', + 'float', + 'double', + 'bool', + f'varchar({binary_len})', + f'nchar({nchar_len})' + ] + + sqls = "" + metas = [] + for i in range(cnt): + colname = f"{pre}{i}" + sel = len(types) % len(types) + coltype = types[sel] + sql = f"{colname} {coltype}" + if sqls != "": + sqls += "," + sqls += sql + metas.append(sel) + + return metas, sqls; + + # gen tags data + def gen_data(self, i, marr): + datas = "" + for c in marr: + data = "" + if c == 0 : # timestamp + data = "%d" % (self.ts + i) + elif c <= 4 : # small + data = "%d"%(i%128) + elif c <= 8 : # int + data = f"{i}" + elif c <= 10 : # float + data = "%f"%(i+i/1000) + elif c <= 11 : # bool + data = "%d"%(i%2) + elif c == 12 : # binary + data = '"' + self.random_string(self.bin_len) + '"' + elif c == 13 : # binary + data = '"' + self.random_string(self.nch_len) + '"' + + if datas != "": + datas += "," + datas += data + + return datas + + # generate specail wide random string + def random_string(self, count): + letters = string.ascii_letters + return ''.join(random.choice(letters) for i in range(count)) + + # create db + def create_db(self, dbname): + self.dbname = dbname + tdSql.execute(f'create database {dbname}') + tdSql.execute(f'use {dbname}') + + # create table or stable + def create_stable(self, stbname, tag_cnt, column_cnt, binary_len, nchar_len): + self.bin_len = binary_len + self.nch_len = nchar_len + self.stbname = stbname + self.mtags, tags = self.gen_columns_sql("t", tag_cnt, binary_len, nchar_len) + self.mcols, cols = self.gen_columns_sql("c", column_cnt - 1, binary_len, nchar_len) + + sql = f"create table {stbname} (ts timestamp, {cols}) tags({tags})" + tdSql.execute(sql) + + # create child table + def create_child(self, stbname, prename, cnt): + self.child_cnt = cnt + self.child_name = prename + for i in range(cnt): + tags_data = self.gen_data(i, self.mtags) + sql = f"create table {prename}{i} using {stbname} tags({tags_data})" + tdSql.execute(sql) + + tdLog.info(f"create child tables {cnt} ok") + + def insert_data_child(self, child_name, cnt, batch_size, step): + values = "" + print("insert child data") + ts = self.ts + + # loop do + for i in range(cnt): + value = self.gen_data(i, self.mcols) + ts += step + values += f"({ts},{value}) " + if batch_size == 1 or (i > 0 and i % batch_size == 0) : + sql = f"insert into {child_name} values {values}" + tdSql.execute(sql) + if batch_size > 40: + tdLog.info(f" insert data i={i}") + values = "" + + # end batch + if values != "": + sql = f"insert into {child_name} values {values}" + tdSql.execute(sql) + tdLog.info(f" insert data i={i}") + values = "" + + tdLog.info(f" insert child data {child_name} finished, insert rows={cnt}") + + # insert data + def insert_data(self, cnt): + for i in range(self.child_cnt): + name = f"{self.child_name}{i}" + self.insert_data_child(name, cnt, self.batch_size, 1) + + tdLog.info(f" insert data ok, child table={self.child_cnt} insert rows={cnt}") + + # insert same timestamp to all childs + def insert_samets(self, cnt): + for i in range(self.child_cnt): + name = f"{self.child_name}{i}" + self.insert_data_child(name, cnt, self.batch_size, 0) + + tdLog.info(f" insert same timestamp ok, child table={self.child_cnt} insert rows={cnt}") + + diff --git a/tests/pytest/util/cases.py b/tests/pytest/util/cases.py index 4830d2f8b09e2364388f2c3ae1ad24a740de5390..536b8f30d3582875e85d1260861d6839f8503f6f 100644 --- a/tests/pytest/util/cases.py +++ b/tests/pytest/util/cases.py @@ -17,6 +17,7 @@ import time import datetime import inspect import importlib +import traceback from util.log import * @@ -75,6 +76,7 @@ class TDCases: case.run() except Exception as e: tdLog.notice(repr(e)) + traceback.print_exc() tdLog.exit("%s failed" % (fileName)) case.stop() runNum += 1 diff --git a/tests/pytest/util/common.py b/tests/pytest/util/common.py index 5b73989d6f22b25c056cba802328d8e3d583ef87..6d813a416644661bf83881b753afe0d55d97d5f2 100644 --- a/tests/pytest/util/common.py +++ b/tests/pytest/util/common.py @@ -739,6 +739,11 @@ class TDCom: else: os.system("unset LD_PRELOAD; pkill %s " % processorName) + def gen_tag_col_str(self, gen_type, data_type, count): + """ + gen multi tags or cols by gen_type + """ + return ','.join(map(lambda i: f'{gen_type}{i} {data_type}', range(count))) def is_json(msg): if isinstance(msg, str): @@ -775,4 +780,5 @@ def dict2toml(in_dict: dict, file:str): with open(file, 'w') as f: toml.dump(in_dict, f) + tdCom = TDCom() diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index bdf3f20e1546e029dfbf7b41b280e857fb732020..783ee476cb5d3b34ffc4461e336412b0259dc975 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -23,6 +23,15 @@ import pandas as pd from util.log import * from util.constant import * +# from datetime import timezone +import time + +def _parse_ns_timestamp(timestr): + dt_obj = datetime.datetime.strptime(timestr[:len(timestr)-3], "%Y-%m-%d %H:%M:%S.%f") + tz = int(int((dt_obj-datetime.datetime.fromtimestamp(0,dt_obj.tzinfo)).total_seconds())*1e9) + int(dt_obj.microsecond * 1000) + int(timestr[-3:]) + return tz + + def _parse_datetime(timestr): try: return datetime.datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S.%f') @@ -227,28 +236,102 @@ class TDSql: self.checkRowCol(row, col) return self.cursor.istype(col, dataType) + def checkData(self, row, col, data): + if row >= self.queryRows: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row+1, self.queryRows) + tdLog.exit("%s(%d) failed: sql:%s, row:%d is larger than queryRows:%d" % args) + if col >= self.queryCols: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, col+1, self.queryCols) + tdLog.exit("%s(%d) failed: sql:%s, col:%d is larger than queryCols:%d" % args) + self.checkRowCol(row, col) + if self.queryResult[row][col] != data: if self.cursor.istype(col, "TIMESTAMP"): - # suppose user want to check nanosecond timestamp if a longer data passed - if (len(data) >= 28): - if pd.to_datetime(self.queryResult[row][col]) == pd.to_datetime(data): - tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") + # suppose user want to check nanosecond timestamp if a longer data passed`` + if isinstance(data,str) : + if (len(data) >= 28): + if self.queryResult[row][col] == _parse_ns_timestamp(data): + # tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{pd.to_datetime(resultData)} == expect:{data}") + tdLog.info("check successfully") + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + else: + if self.queryResult[row][col].astimezone(datetime.timezone.utc) == _parse_datetime(data).astimezone(datetime.timezone.utc): + # tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") + tdLog.info("check successfully") + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + return + elif isinstance(data,int): + if len(str(data)) == 16: + precision = 'us' + elif len(str(data)) == 13: + precision = 'ms' + elif len(str(data)) == 19: + precision = 'ns' + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + return + success = False + if precision == 'ms': + dt_obj = self.queryResult[row][col] + ts = int(int((dt_obj-datetime.datetime.fromtimestamp(0,dt_obj.tzinfo)).total_seconds())*1000) + int(dt_obj.microsecond/1000) + if ts == data: + success = True + elif precision == 'us': + dt_obj = self.queryResult[row][col] + ts = int(int((dt_obj-datetime.datetime.fromtimestamp(0,dt_obj.tzinfo)).total_seconds())*1e6) + int(dt_obj.microsecond) + if ts == data: + success = True + elif precision == 'ns': + if data == self.queryResult[row][col]: + success = True + if success: + tdLog.info("check successfully") + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + return + elif isinstance(data,datetime.datetime): + dt_obj = self.queryResult[row][col] + delt_data = data-datetime.datetime.fromtimestamp(0,data.tzinfo) + delt_result = self.queryResult[row][col] - datetime.datetime.fromtimestamp(0,self.queryResult[row][col].tzinfo) + if delt_data == delt_result: + tdLog.info("check successfully") + else: + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) + return else: - if self.queryResult[row][col] == _parse_datetime(data): - tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") - return + caller = inspect.getframeinfo(inspect.stack()[1][0]) + args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) + tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) if str(self.queryResult[row][col]) == str(data): - tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") + # tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") + tdLog.info("check successfully") return elif isinstance(data, float): if abs(data) >= 1 and abs((self.queryResult[row][col] - data) / data) <= 0.000001: - tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") + # tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") + tdLog.info("check successfully") elif abs(data) < 1 and abs(self.queryResult[row][col] - data) <= 0.000001: - tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") + # tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") + tdLog.info("check successfully") + else: caller = inspect.getframeinfo(inspect.stack()[1][0]) args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) @@ -258,8 +341,7 @@ class TDSql: caller = inspect.getframeinfo(inspect.stack()[1][0]) args = (caller.filename, caller.lineno, self.sql, row, col, self.queryResult[row][col], data) tdLog.exit("%s(%d) failed: sql:%s row:%d col:%d data:%s != expect:%s" % args) - - tdLog.info(f"sql:{self.sql}, row:{row} col:{col} data:{self.queryResult[row][col]} == expect:{data}") + tdLog.info("check successfully") # return true or false replace exit, no print out def checkRowColNoExit(self, row, col): diff --git a/tests/requirements.txt b/tests/requirements.txt index c6e27fd3be6b35c268c8f7b7b97da048224561e3..5cdd9e02beed40b73a083041e1b4d043dcd48adb 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -8,3 +8,4 @@ distro requests pexpect faker +pyopenssl diff --git a/tests/script/coverage_test.sh b/tests/script/coverage_test.sh index a74e6dae737722f04a38f11b3e7c244b57a34441..535b6802f25c1a94549ae9ea5fbb67f08601f258 100755 --- a/tests/script/coverage_test.sh +++ b/tests/script/coverage_test.sh @@ -12,6 +12,7 @@ fi today=`date +"%Y%m%d"` TDENGINE_DIR=/root/TDengine JDBC_DIR=/root/taos-connector-jdbc +TAOSKEEPER_DIR=/root/taoskeeper TDENGINE_COVERAGE_REPORT=$TDENGINE_DIR/tests/coverage-report-$today.log # Color setting @@ -184,6 +185,24 @@ function runJDBCCases() { echo -e "### JDBC test result: $summary ###" | tee -a $TDENGINE_COVERAGE_REPORT } +function runTaosKeeperCases() { + echo "=== Run taoskeeper cases ===" + + cd $TAOSKEEPER_DIR + git checkout -- . + git reset --hard HEAD + git checkout master + git pull + + stopTaosd + stopTaosadapter + + taosd -c /etc/taos >> /dev/null 2>&1 & + taosadapter >> /dev/null 2>&1 & + + go mod tidy && go test -v ./... +} + function runTest() { echo "run Test" @@ -195,6 +214,7 @@ function runTest() { runSimCases runPythonCases runJDBCCases + runTaosKeeperCases stopTaosd cd $TDENGINE_DIR/tests/script @@ -212,7 +232,7 @@ function lcovFunc { lcov -d . --capture --rc lcov_branch_coverage=1 --rc genhtml_branch_coverage=1 --no-external -b $TDENGINE_DIR -o coverage.info # remove exclude paths - if [ "$branch" == "3.0" ]; then + if [ "$branch" == "main" ] ; then lcov --remove coverage.info \ '*/contrib/*' '*/tests/*' '*/test/*' '*/tools/*' '*/libs/sync/*'\ '*/AccessBridgeCalls.c' '*/ttszip.c' '*/dataInserter.c' '*/tlinearhash.c' '*/tsimplehash.c' '*/tsdbDiskData.c'\ @@ -222,6 +242,8 @@ function lcovFunc { '*/tthread.c' '*/tversion.c' '*/ctgDbg.c' '*/schDbg.c' '*/qwDbg.c' '*/tencode.h' '*/catalog.c'\ '*/tqSnapshot.c' '*/tsdbSnapshot.c''*/metaSnapshot.c' '*/smaSnapshot.c' '*/tqOffsetSnapshot.c'\ '*/vnodeSnapshot.c' '*/metaSnapshot.c' '*/tsdbSnapshot.c' '*/mndGrant.c' '*/mndSnode.c' '*/streamRecover.c'\ + '*/osAtomic.c' '*/osDir.c' '*/osFile.c' '*/osMath.c' '*/osSignal.c' '*/osSleep.c' '*/osString.c' '*/osSystem.c'\ + '*/osThread.c' '*/osTime.c' '*/osTimezone.c' \ --rc lcov_branch_coverage=1 -o coverage.info else lcov --remove coverage.info \ diff --git a/tests/script/sh/bit_and.c b/tests/script/sh/bit_and.c index 2f2e48fdb0882db2a40c9aae019402e031343d13..f3bf71ce946b5b5d62ac6d63de4c2532a799721e 100644 --- a/tests/script/sh/bit_and.c +++ b/tests/script/sh/bit_and.c @@ -1,61 +1,47 @@ -#include -#include #include +#include +#include #include "taosudf.h" +DLL_EXPORT int32_t bit_and_init() { return 0; } -DLL_EXPORT int32_t bit_and_init() { - return 0; -} - -DLL_EXPORT int32_t bit_and_destroy() { - return 0; -} - -DLL_EXPORT int32_t bit_and(SUdfDataBlock* block, SUdfColumn *resultCol) { +DLL_EXPORT int32_t bit_and_destroy() { return 0; } - if (block->numOfCols < 2) { - return TSDB_CODE_UDF_INVALID_INPUT; - } +DLL_EXPORT int32_t bit_and(SUdfDataBlock* block, SUdfColumn* resultCol) { + if (block->numOfCols < 2) { + return TSDB_CODE_UDF_INVALID_INPUT; + } - for (int32_t i = 0; i < block->numOfCols; ++i) { - SUdfColumn* col = block->udfCols[i]; - if (!(col->colMeta.type == TSDB_DATA_TYPE_INT)) { - return TSDB_CODE_UDF_INVALID_INPUT; - } + for (int32_t i = 0; i < block->numOfCols; ++i) { + SUdfColumn* col = block->udfCols[i]; + if (!(col->colMeta.type == TSDB_DATA_TYPE_INT)) { + return TSDB_CODE_UDF_INVALID_INPUT; } + } - SUdfColumnMeta *meta = &resultCol->colMeta; - meta->bytes = 4; - meta->type = TSDB_DATA_TYPE_INT; - meta->scale = 0; - meta->precision = 0; - - - SUdfColumnData *resultData = &resultCol->colData; - - resultData->numOfRows = block->numOfRows; - - for (int32_t i = 0; i < resultData->numOfRows; ++i) { - if (udfColDataIsNull(block->udfCols[0], i)) { - udfColDataSetNull(resultCol, i); - continue; - } - int32_t result = *(int32_t*)udfColDataGetData(block->udfCols[0], i); - int j = 1; - for (; j < block->numOfCols; ++j) { - if (udfColDataIsNull(block->udfCols[j], i)) { - udfColDataSetNull(resultCol, i); - break; - } - - char* colData = udfColDataGetData(block->udfCols[j], i); - result &= *(int32_t*)colData; - } - if (j == block->numOfCols) { - udfColDataSet(resultCol, i, (char*)&result, false); - } + SUdfColumnData* resultData = &resultCol->colData; + for (int32_t i = 0; i < block->numOfRows; ++i) { + if (udfColDataIsNull(block->udfCols[0], i)) { + udfColDataSetNull(resultCol, i); + continue; } - return TSDB_CODE_SUCCESS; + int32_t result = *(int32_t*)udfColDataGetData(block->udfCols[0], i); + int j = 1; + for (; j < block->numOfCols; ++j) { + if (udfColDataIsNull(block->udfCols[j], i)) { + udfColDataSetNull(resultCol, i); + break; + } + + char* colData = udfColDataGetData(block->udfCols[j], i); + result &= *(int32_t*)colData; + } + if (j == block->numOfCols) { + udfColDataSet(resultCol, i, (char*)&result, false); + } + } + resultData->numOfRows = block->numOfRows; + + return TSDB_CODE_SUCCESS; } diff --git a/tests/script/sh/l2norm.c b/tests/script/sh/l2norm.c index 8ccdffb8d69d1ba27410ad61a74ee3d7ca156be2..0b7f5bf7f6756c11331cae3140a9bf6b5cba024b 100644 --- a/tests/script/sh/l2norm.c +++ b/tests/script/sh/l2norm.c @@ -16,7 +16,7 @@ DLL_EXPORT int32_t l2norm_destroy() { DLL_EXPORT int32_t l2norm_start(SUdfInterBuf *buf) { *(int64_t*)(buf->buf) = 0; buf->bufLen = sizeof(double); - buf->numOfResult = 0; + buf->numOfResult = 1; return 0; } @@ -58,20 +58,11 @@ DLL_EXPORT int32_t l2norm(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInte *(double*)(newInterBuf->buf) = sumSquares; newInterBuf->bufLen = sizeof(double); - - if (interBuf->numOfResult == 0 && numNotNull == 0) { - newInterBuf->numOfResult = 0; - } else { - newInterBuf->numOfResult = 1; - } + newInterBuf->numOfResult = 1; return 0; } DLL_EXPORT int32_t l2norm_finish(SUdfInterBuf* buf, SUdfInterBuf *resultData) { - if (buf->numOfResult == 0) { - resultData->numOfResult = 0; - return 0; - } double sumSquares = *(double*)(buf->buf); *(double*)(resultData->buf) = sqrt(sumSquares); resultData->bufLen = sizeof(double); diff --git a/tests/script/sh/prepare_pyudf.sh b/tests/script/sh/prepare_pyudf.sh new file mode 100755 index 0000000000000000000000000000000000000000..b72f8c9f77f94cf35a6bf1daef93ee773e53acfe --- /dev/null +++ b/tests/script/sh/prepare_pyudf.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set +e + +FILE=/usr/local/lib/libtaospyudf.so +if [ ! -f "$FILE" ]; then + echo "$FILE does not exist." + apt install -y python3 python3-dev python3-venv + /usr/bin/python3 -m venv /udfenv + source /udfenv/bin/activate + pip3 install taospyudf + ldconfig + deactivate +else + echo "show dependencies of $FILE" + ldd $FILE +fi diff --git a/tests/script/sh/pybitand.py b/tests/script/sh/pybitand.py new file mode 100644 index 0000000000000000000000000000000000000000..1df724794ec20c6a133f3800046c897c722a173e --- /dev/null +++ b/tests/script/sh/pybitand.py @@ -0,0 +1,21 @@ +def init(): + pass + +def process(block): + (rows, cols) = block.shape() + result = [] + for i in range(rows): + r = 2 ** 32 - 1 + for j in range(cols): + cell = block.data(i,j) + if cell is None: + result.append(None) + break + else: + r = r & cell + else: + result.append(r) + return result + +def destroy(): + pass diff --git a/tests/script/sh/pyl2norm.py b/tests/script/sh/pyl2norm.py new file mode 100644 index 0000000000000000000000000000000000000000..105f546b7d186f466f4fcad5eca38ecf5ff7b5e1 --- /dev/null +++ b/tests/script/sh/pyl2norm.py @@ -0,0 +1,27 @@ +import json +import math + +def init(): + pass + +def destroy(): + pass + +def start(): + return json.dumps(0.0).encode('utf-8') + +def finish(buf): + sum_squares = json.loads(buf) + result = math.sqrt(sum_squares) + return result + +def reduce(datablock, buf): + (rows, cols) = datablock.shape() + sum_squares = json.loads(buf) + + for i in range(rows): + for j in range(cols): + cell = datablock.data(i,j) + if cell is not None: + sum_squares += cell * cell + return json.dumps(sum_squares).encode('utf-8') diff --git a/tests/script/tsim/db/alter_option.sim b/tests/script/tsim/db/alter_option.sim index 6f568ecdb15aec72415e83d881fb69bbe0fc948a..f20f861bd0d40df47ab9c6e1792651410678f515 100644 --- a/tests/script/tsim/db/alter_option.sim +++ b/tests/script/tsim/db/alter_option.sim @@ -285,12 +285,12 @@ sql_error alter database db keep -1 print ============== modify minrows sql_error alter database db minrows 8 -sql_error alter database db minrows 8000 -sql_error alter database db minrows 8001 +sql_error alter database db minrows 8000000 +sql_error alter database db minrows 8001000 print ============== modify maxrows -sql_error alter database db maxrows 1000 -sql_error alter database db maxrows 2000 +sql_error alter database db maxrows 10000001 +sql_error alter database db maxrows 20000000 sql_error alter database db maxrows 11 # equal minrows sql_error alter database db maxrows 10 # little than minrows diff --git a/tests/script/tsim/db/create_all_options.sim b/tests/script/tsim/db/create_all_options.sim index 382cc986e241d3108268491ae1b0ca9ef1c51bdb..abba824e827eace92d8e2c84685e07fdfbaa4b8d 100644 --- a/tests/script/tsim/db/create_all_options.sim +++ b/tests/script/tsim/db/create_all_options.sim @@ -298,11 +298,11 @@ sql drop database db sql_error create database db MAXROWS -1 sql_error create database db MAXROWS 0 sql_error create database db MAXROWS 199 -sql_error create database db MAXROWS 10001 +sql_error create database db MAXROWS 10000001 sql_error create database db MINROWS -1 sql_error create database db MINROWS 0 sql_error create database db MINROWS 9 -sql_error create database db MINROWS 1001 +sql_error create database db MINROWS 1000001 sql_error create database db MAXROWS 500 MINROWS 1000 print ====> PRECISION ['ms' | 'us' | 'ns', default: ms] diff --git a/tests/script/tsim/parser/col_arithmetic_operation.sim b/tests/script/tsim/parser/col_arithmetic_operation.sim index 9a2ba34c85e552585770bb42913b8c83ddd58131..a11b99d3d60329f33bd5e191d32ce1af4be772b8 100644 --- a/tests/script/tsim/parser/col_arithmetic_operation.sim +++ b/tests/script/tsim/parser/col_arithmetic_operation.sim @@ -9,7 +9,7 @@ $dbPrefix = ca_db $tbPrefix = ca_tb $stbPrefix = ca_stb $tbNum = 10 -$rowNum = 10000 +$rowNum = 1000 $totalNum = $tbNum * $rowNum $ts0 = 1537146000000 $delta = 600000 @@ -18,6 +18,7 @@ $i = 0 $db = $dbPrefix . $i $stb = $stbPrefix . $i +print drop database $db -x step1 sql drop database $db -x step1 step1: sql create database $db diff --git a/tests/script/tsim/parser/col_arithmetic_query.sim b/tests/script/tsim/parser/col_arithmetic_query.sim index b77dcbe4982744a59b61687f70d5a650229361e4..1537db9a8365b0eb104f62ae74367d53bf9a10bd 100644 --- a/tests/script/tsim/parser/col_arithmetic_query.sim +++ b/tests/script/tsim/parser/col_arithmetic_query.sim @@ -4,7 +4,7 @@ $dbPrefix = ca_db $tbPrefix = ca_tb $stbPrefix = ca_stb -$rowNum = 10000 +$rowNum = 1000 $i = 0 $db = $dbPrefix . $i @@ -33,7 +33,7 @@ endi # asc/desc order [d.2] ====================================================== sql select c1 *( 2 / 3 ), c1/c1 from $tb order by ts asc; -if $rows != 10000 then +if $rows != 1000 then return -1 endi if $data00 != 0.000000000 then @@ -57,7 +57,7 @@ if $data91 != 1.000000000 then endi sql select (c1 * 2) % 7.9, c1*1, c1*1*1, c1*c1, c1*c1*c1 from $tb order by ts desc; -if $rows != 10000 then +if $rows != 1000 then return -1 endi if $data00 != 2.200000000 then @@ -151,7 +151,7 @@ sql select top(c1,1) - 88 from $tb # all data types [d.6] ================================================================ sql select c2-c1*1.1, c3/c2, c4*c3, c5%c4, (c6+c4)%22, c2-c2 from $tb -if $rows != 10000 then +if $rows != 1000 then return -1 endi if $data00 != 0.000000000 then @@ -221,7 +221,7 @@ if $data90 != 76.000000000 then return -1 endi -sql select c4 / 99.123 from $tb limit 10 offset 9999; +sql select c4 / 99.123 from $tb limit 10 offset 999; if $rows != 1 then return -1 endi @@ -237,7 +237,7 @@ sql_error select c2-c2, c3-c4, c5%c3 from $tb fill(value, 12); # constant column. [d.13]============================================================== sql select c1, c2+c6, 12.9876545678, 1, 1.1 from $tb -if $rows != 10000 then +if $rows != 1000 then return -1 endi if $data00 != 0 then @@ -261,7 +261,7 @@ endi # column value filter [d.14]=========================================================== sql select c1, c2+c6, 12.9876545678, 1, 1.1 from $tb where c1<2 -if $rows != 2000 then +if $rows != 200 then return -1 endi if $data00 != 0 then @@ -338,13 +338,14 @@ sql select (count(c1) * 2) % 7.9, (count(c1) * 2), ( count(1)*2) from $stb if $rows != 1 then return -1 endi -if $data00 != 1.800000000 then +print $data00 +if $data00 != 6.500000000 then return -1 endi -if $data01 != 100000.000000000 then +if $data01 != 10000.000000000 then return -1 endi -if $data02 != 200000.000000000 then +if $data02 != 20000.000000000 then return -1 endi @@ -371,7 +372,7 @@ endi if $data00 != 0.000000000 then return -1 endi -if $data01 != 225000.000000000 then +if $data01 != 22500.000000000 then return -1 endi if $data02 != 8.077777778 then @@ -383,7 +384,7 @@ endi if $data04 != 0.444444444 then return -1 endi -if $data05 != 450000.000000000 then +if $data05 != 45000.000000000 then return -1 endi @@ -484,10 +485,10 @@ endi if $data10 != 0.000000000 then return -1 endi -if $data20 != 0.997600000 then +if $data20 != 0.976000000 then return -1 endi -if $data90 != 7.980800000 then +if $data90 != 7.808000000 then return -1 endi @@ -496,7 +497,7 @@ sql select first(c6) - sum(c6) + 12 from $stb limit 12 offset 0; if $rows != 1 then return -1 endi -if $data00 != -449988.000000000 then +if $data00 != -44988.000000000 then return -1 endi @@ -546,7 +547,7 @@ endi # interval query [d.17]=============================================================== sql select avg(c2)*count(c2), sum(c3)-first(c3), last(c4)+9 from ca_stb0 interval(1s) -if $rows != 10000 then +if $rows != 1000 then return -1 endi diff --git a/tests/script/tsim/parser/commit.sim b/tests/script/tsim/parser/commit.sim index a9bf8b26ebda178ed789f3119eac7203a6889f9b..84610ad379e614bb50aefb90691fc10e287d8ba2 100644 --- a/tests/script/tsim/parser/commit.sim +++ b/tests/script/tsim/parser/commit.sim @@ -7,7 +7,7 @@ $dbPrefix = sc_db $tbPrefix = sc_tb $stbPrefix = sc_stb $tbNum = 10 -$rowNum = 10000 +$rowNum = 1000 $totalNum = $tbNum * $rowNum $loops = 5 $log = 1 diff --git a/tests/script/tsim/parser/groupby.sim b/tests/script/tsim/parser/groupby.sim index 4ee9c530a79c72ccac12a99922af1eeefc7485ed..637b7553fd741d8bf89fce3baf67d817391ea0e5 100644 --- a/tests/script/tsim/parser/groupby.sim +++ b/tests/script/tsim/parser/groupby.sim @@ -7,7 +7,7 @@ $dbPrefix = group_db $tbPrefix = group_tb $mtPrefix = group_mt $tbNum = 8 -$rowNum = 10000 +$rowNum = 1000 $totalNum = $tbNum * $rowNum print =============== groupby.sim @@ -88,7 +88,7 @@ if $row != 20 then return -1 endi -if $data00 != 100 then +if $data00 != 10 then return -1 endi @@ -96,7 +96,7 @@ if $data01 != 0 then return -1 endi -if $data10 != 100 then +if $data10 != 10 then return -1 endi @@ -186,7 +186,7 @@ if $data04 != 0.00000 then return -1 endi -if $data10 != 100 then +if $data10 != 10 then return -1 endi @@ -227,7 +227,7 @@ if $row != 20 then return -1 endi -if $data00 != 800 then +if $data00 != 80 then return -1 endi @@ -235,7 +235,7 @@ if $data01 != 0 then return -1 endi -if $data10 != 800 then +if $data10 != 80 then return -1 endi @@ -243,7 +243,7 @@ if $data11 != 1 then return -1 endi -if $data90 != 800 then +if $data90 != 80 then return -1 endi @@ -297,7 +297,7 @@ if $data00 != $data03 then return -1 endi -if $data01 != @70-01-01 08:01:49.900@ then +if $data01 != @70-01-01 08:01:40.900@ then return -1 endi @@ -305,7 +305,7 @@ if $data02 != @70-01-01 08:01:40.000@ then return -1 endi -if $data07 != 800 then +if $data07 != 80 then return -1 endi @@ -313,7 +313,7 @@ if $data10 != $data13 then return -1 endi -if $data11 != @70-01-01 08:01:49.901@ then +if $data11 != @70-01-01 08:01:40.901@ then return -1 endi @@ -321,7 +321,7 @@ if $data12 != @70-01-01 08:01:40.001@ then return -1 endi -if $data17 != 800 then +if $data17 != 80 then return -1 endi @@ -329,7 +329,7 @@ if $data90 != $data93 then return -1 endi -if $data91 != @70-01-01 08:01:49.909@ then +if $data91 != @70-01-01 08:01:40.909@ then return -1 endi @@ -337,11 +337,11 @@ if $data92 != @70-01-01 08:01:40.009@ then return -1 endi -if $data97 != 800 then +if $data97 != 80 then return -1 endi -if $data95 != 7200 then +if $data95 != 720 then return -1 endi @@ -358,7 +358,7 @@ if $data00 != 0 then return -1 endi -if $data11 != 800 then +if $data11 != 80 then return -1 endi @@ -372,7 +372,7 @@ if $data00 != 0 then return -1 endi -if $data01 != @70-01-01 08:01:49.900@ then +if $data01 != @70-01-01 08:01:40.900@ then return -1 endi @@ -389,13 +389,13 @@ if $data04 != 0 then return -1 endi -if $data06 != 100 then +if $data06 != 10 then return -1 endi sql select count(*),first(ts),last(ts),min(c3) from group_tb1 group by c4 order by c4; -if $rows != 10000 then +if $rows != 1000 then return -1 endi @@ -415,18 +415,18 @@ if $data03 != 0 then return -1 endi -sql select count(*),first(ts),last(ts),min(c3) from group_tb1 group by c4 limit 1; +sql select count(*),first(ts),last(ts),min(c3) from group_tb1 group by c4 slimit 1; if $rows != 1 then return -1 endi -sql select count(*),first(ts),last(ts),min(c3) from group_tb1 group by c4 limit 20 offset 9990; +sql select count(*),first(ts),last(ts),min(c3) from group_tb1 group by c4 slimit 20 soffset 990; if $rows != 10 then return -1 endi sql select count(*),first(ts),last(ts),min(c3),max(c3),sum(c3),avg(c3),sum(c4)/count(c4) from group_tb1 group by c4; -if $rows != 10000 then +if $rows != 1000 then return -1 endi @@ -441,32 +441,32 @@ if $rows != 100 then return -1 endi -if $data00 != 100 then +if $data00 != 10 then return -1 endi -if $data01 != 495000 then +if $data01 != 4500 then return -1 endi -if $data02 != 100 then +if $data02 != 10 then return -1 endi -if $data03 != 4950.000000000 then - print expect 4950.000000000 , acutal $data03 +if $data03 != 450.000000000 then + print expect 450.000000000 , acutal $data03 return -1 endi -if $data10 != 100 then +if $data10 != 10 then return -1 endi -if $data11 != 495100 then +if $data11 != 4510 then return -1 endi -if $data13 != 4951.000000000 then +if $data13 != 451.000000000 then return -1 endi @@ -481,19 +481,19 @@ if $rows != 1 then return -1 endi -#if $data00 != 79200.000000000 then +#if $data00 != 2160.000000000 then # return -1 #endi -#if $data01 != @binary99@ then +#if $data01 != @binary27@ then # return -1 #endi -#if $data02 != 99.000000000 then +#if $data02 != 27.000000000 then # return -1 #endi -#if $data03 != 99.000000000 then +#if $data03 != 27.000000000 then # return -1 #endi @@ -503,7 +503,7 @@ if $rows != 100 then return -1 endi -if $data00 != 4851.000000000 then +if $data00 != 441.000000000 then return -1 endi @@ -511,19 +511,19 @@ if $data01 != 0 then return -1 endi -if $data02 != 9900 then +if $data02 != 900 then return -1 endi -if $data03 != 4950.000000000 then +if $data03 != 450.000000000 then return -1 endi -if $data04 != 2886.607004772 then +if $data04 != 287.228132327 then return -1 endi -if $data10 != 4852.000000000 then +if $data10 != 442.000000000 then return -1 endi @@ -531,15 +531,15 @@ if $data11 != 1 then return -1 endi -if $data12 != 9901 then +if $data12 != 901 then return -1 endi -if $data13 != 4951.000000000 then +if $data13 != 451.000000000 then return -1 endi -if $data14 != 2886.607004772 then +if $data14 != 287.228132327 then return -1 endi diff --git a/tests/script/tsim/parser/interp.sim b/tests/script/tsim/parser/interp.sim index e6512a22d79da5ca5970665f08e369e582eed361..f74a2dc6243ad6d2bf7acf3a5f57d80df3d53cbb 100644 --- a/tests/script/tsim/parser/interp.sim +++ b/tests/script/tsim/parser/interp.sim @@ -7,7 +7,7 @@ $dbPrefix = intp_db $tbPrefix = intp_tb $stbPrefix = intp_stb $tbNum = 4 -$rowNum = 10000 +$rowNum = 1000 $totalNum = $tbNum * $rowNum $ts0 = 1537146000000 $delta = 600000 diff --git a/tests/script/tsim/parser/join_manyblocks.sim b/tests/script/tsim/parser/join_manyblocks.sim index 154316a03f694d7ea375f1cc7d3cc4ad903cd9b9..a40a75f50c54cb9ffdfed24edd2a7e03e0c13e5c 100644 --- a/tests/script/tsim/parser/join_manyblocks.sim +++ b/tests/script/tsim/parser/join_manyblocks.sim @@ -7,7 +7,7 @@ $dbPrefix = join_m_db $tbPrefix = join_tb $mtPrefix = join_mt $tbNum = 3 -$rowNum = 20000 +$rowNum = 2000 $totalNum = $tbNum * $rowNum print =============== join_manyBlocks.sim @@ -78,8 +78,8 @@ print ==============> td-3313 sql select join_mt0.ts,join_mt0.ts,join_mt0.t1 from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t1=join_mt1.t1; print $row -if $row != 60000 then - print expect 60000, actual: $row +if $row != 6000 then + print expect 6000, actual: $row return -1 endi diff --git a/tests/script/tsim/parser/limit1.sim b/tests/script/tsim/parser/limit1.sim index c35617fc4fc64cedbe667a4153bac1a9064f4a91..d1a75f3ba9603ff2d97a029258dc91f0fa097d43 100644 --- a/tests/script/tsim/parser/limit1.sim +++ b/tests/script/tsim/parser/limit1.sim @@ -7,7 +7,7 @@ $dbPrefix = lm1_db $tbPrefix = lm1_tb $stbPrefix = lm1_stb $tbNum = 10 -$rowNum = 10000 +$rowNum = 1000 $totalNum = $tbNum * $rowNum $ts0 = 1537146000000 $delta = 600000 diff --git a/tests/script/tsim/parser/limit1_stb.sim b/tests/script/tsim/parser/limit1_stb.sim index be0963c0fdf3b15750512715b8fa752184436df6..731a218de5d11f11b623a8348344597fb84f78b8 100644 --- a/tests/script/tsim/parser/limit1_stb.sim +++ b/tests/script/tsim/parser/limit1_stb.sim @@ -4,7 +4,7 @@ $dbPrefix = lm1_db $tbPrefix = lm1_tb $stbPrefix = lm1_stb $tbNum = 10 -$rowNum = 10000 +$rowNum = 1000 $totalNum = $tbNum * $rowNum $ts0 = 1537146000000 $delta = 600000 @@ -453,13 +453,14 @@ endi ### [TBASE-361] $offset = $rowNum / 2 $offset = $offset + 1 +print === select _wstart, max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit $offset offset $offset sql select _wstart, max(c1), min(c2), avg(c3), count(c4), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit $offset offset $offset $val = $rowNum - $offset if $rows != $val then print expect $val, actual:$rows return -1 endi -if $data00 != @18-10-22 02:30:00.000@ then +if $data00 != @18-09-20 20:30:00.000@ then return -1 endi if $data01 != 1 then @@ -483,6 +484,7 @@ if $rows != 2 then return -1 endi +print === select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) limit 1 offset 0 sql select max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) limit 1 offset 0 if $rows != 3 then return -1 diff --git a/tests/script/tsim/parser/limit1_tb.sim b/tests/script/tsim/parser/limit1_tb.sim index 0ba82654187ab773dd0d84d488e3e1b2e5f50381..e6407e3024e4747f591570689e2ce77c031158df 100644 --- a/tests/script/tsim/parser/limit1_tb.sim +++ b/tests/script/tsim/parser/limit1_tb.sim @@ -4,7 +4,7 @@ $dbPrefix = lm1_db $tbPrefix = lm1_tb $stbPrefix = lm1_stb $tbNum = 10 -$rowNum = 10000 +$rowNum = 1000 $totalNum = $tbNum * $rowNum $ts0 = 1537146000000 $delta = 600000 @@ -13,7 +13,7 @@ $i = 0 $db = $dbPrefix . $i $stb = $stbPrefix . $i -print ====== use db +print ====== use $db sql use $db ##### select from table @@ -664,9 +664,9 @@ endi if $data21 != 4.027681991 then return -1 endi - +print select _wstart, count(c1), count(c2), count(c3), count(c4), count(c5), count(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(27m) sql select _wstart, count(c1), count(c2), count(c3), count(c4), count(c5), count(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(27m) -if $rows != 3704 then +if $rows != 371 then return -1 endi if $data01 != 2 then @@ -994,11 +994,14 @@ endi $offset = $rowNum / 10 $offset = $offset * 3 $offset = $offset - 1 + +print === select * from $tb where c1 < 5 and c1 > 1 order by ts asc limit 3 offset $offset sql select * from $tb where c1 < 5 and c1 > 1 order by ts asc limit 3 offset $offset if $rows != 1 then return -1 endi -if $data00 != @18-11-25 18:40:00.000@ then +print $data00 +if $data00 != @18-09-24 06:40:00.000@ then return -1 endi if $data01 != 4 then @@ -1012,19 +1015,19 @@ sql select * from $tb order by ts desc limit 5 if $rows != 5 then return -1 endi -if $data00 != @18-11-25 19:30:00.000@ then +if $data00 != @18-09-24 07:30:00.000@ then return -1 endi if $data01 != 9 then return -1 endi -if $data10 != @18-11-25 19:20:00.000@ then +if $data10 != @18-09-24 07:20:00.000@ then return -1 endi if $data12 != 8 then return -1 endi -if $data20 != @18-11-25 19:10:00.000@ then +if $data20 != @18-09-24 07:10:00.000@ then return -1 endi if $data23 != 7.00000 then @@ -1048,7 +1051,7 @@ endi if $data39 != nchar6 then return -1 endi -if $data40 != @18-11-25 18:50:00.000@ then +if $data40 != @18-09-24 06:50:00.000@ then return -1 endi @@ -1056,19 +1059,19 @@ sql select * from $tb order by ts desc limit 5 offset 1 if $rows != 5 then return -1 endi -if $data00 != @18-11-25 19:20:00.000@ then +if $data00 != @18-09-24 07:20:00.000@ then return -1 endi if $data01 != 8 then return -1 endi -if $data10 != @18-11-25 19:10:00.000@ then +if $data10 != @18-09-24 07:10:00.000@ then return -1 endi if $data12 != 7 then return -1 endi -if $data20 != @18-11-25 19:00:00.000@ then +if $data20 != @18-09-24 07:00:00.000@ then return -1 endi if $data23 != 6.00000 then @@ -1092,12 +1095,13 @@ endi if $data39 != nchar5 then return -1 endi -if $data40 != @18-11-25 18:40:00.000@ then +if $data40 != @18-09-24 06:40:00.000@ then return -1 endi $offset = $rowNum $offset = $offset - 2 +print ==== select * from $tb order by ts desc limit 5 offset $offset sql select * from $tb order by ts desc limit 5 offset $offset if $rows != 2 then return -1 @@ -1119,16 +1123,16 @@ sql select * from $tb where c1 < 8 order by ts desc limit 3 offset 2 if $rows != 3 then return -1 endi -if $data00 != @18-11-25 18:50:00.000@ then +if $data00 != @18-09-24 06:50:00.000@ then return -1 endi if $data01 != 5 then return -1 endi -if $data10 != @18-11-25 18:40:00.000@ then +if $data10 != @18-09-24 06:40:00.000@ then return -1 endi -if $data20 != @18-11-25 18:30:00.000@ then +if $data20 != @18-09-24 06:30:00.000@ then return -1 endi if $data12 != 4 then diff --git a/tests/script/tsim/parser/nestquery.sim b/tests/script/tsim/parser/nestquery.sim index 2a363de43df0f774cbbd6b163c3bfd550f10ea1d..c2189d0bddbe91d001ccca378214935df317f2a8 100644 --- a/tests/script/tsim/parser/nestquery.sim +++ b/tests/script/tsim/parser/nestquery.sim @@ -8,7 +8,7 @@ print ======================== dnode1 start $dbPrefix = nest_db $tbPrefix = nest_tb $mtPrefix = nest_mt -$tbNum = 10 +$tbNum = 3 $rowNum = 10000 $totalNum = $tbNum * $rowNum @@ -23,7 +23,7 @@ sql create database if not exists $db sql use $db sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int) -$half = $tbNum / 2 +$half = 2 $i = 0 while $i < $half @@ -69,7 +69,7 @@ sql select count(*) from (select count(*) from nest_mt0 group by tbname) if $rows != 1 then return -1 endi -if $data00 != 10 then +if $data00 != 4 then return -1 endi @@ -77,7 +77,7 @@ sql select count(*) from (select count(*) from nest_mt0 partition by tbname inte if $rows != 1 then return -1 endi -if $data00 != 170 then +if $data00 != 68 then return -1 endi @@ -85,7 +85,7 @@ sql select sum(a) from (select count(*) a from nest_mt0 partition by tbname inte if $rows != 1 then return -1 endi -if $data00 != 100000 then +if $data00 != 40000 then return -1 endi diff --git a/tests/script/tsim/parser/projection_limit_offset.sim b/tests/script/tsim/parser/projection_limit_offset.sim index 669ff3a179c67bce6970868b1fac1bbefccc9d0f..2d99b0a296621ca0b29f908dba8714afde47076c 100644 --- a/tests/script/tsim/parser/projection_limit_offset.sim +++ b/tests/script/tsim/parser/projection_limit_offset.sim @@ -7,7 +7,7 @@ $dbPrefix = group_db $tbPrefix = group_tb $mtPrefix = group_mt $tbNum = 8 -$rowNum = 10000 +$rowNum = 1000 $totalNum = $tbNum * $rowNum print =============== projection_limit_offset.sim @@ -81,199 +81,199 @@ $ts2 = $tb2 . .ts sql select ts from group_mt0 print $rows -sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 0; +sql select ts from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.500' limit 8000 offset 0; if $rows != 4008 then print expect 4008, actual:$rows return -1 endi -sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 1; +sql select ts from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.500' limit 8000 offset 1; if $rows != 4007 then return -1 endi -sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 101; +sql select ts from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.500' limit 8000 offset 101; print $rows if $rows != 3907 then return -1 endi -if $data00 != @70-01-01 08:01:43.101@ then +if $data00 != @70-01-01 08:01:40.101@ then return -1 endi -sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 902; +sql select ts from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.500' limit 8000 offset 902; if $rows != 3106 then return -1 endi -sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 400; +sql select ts from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.500' limit 8000 offset 400; if $rows != 3608 then return -1 endi -sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 8000 offset 4007; +sql select ts from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.500' limit 8000 offset 4007; if $rows != 1 then return -1 endi -sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' limit 2000 offset 4008; +sql select ts from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.500' limit 2000 offset 4008; if $rows != 0 then return -1 endi #==================================order by desc, multi vnode, limit/offset=================================== -sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 0; +sql select ts from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.500' order by ts desc limit 8000 offset 0; if $rows != 4008 then return -1 endi -if $data00 != @70-01-01 08:01:43.500@ then +if $data00 != @70-01-01 08:01:40.500@ then return -1 endi -sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 1; +sql select ts from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.500' order by ts desc limit 8000 offset 1; if $rows != 4007 then return -1 endi -if $data00 != @70-01-01 08:01:43.500@ then +if $data00 != @70-01-01 08:01:40.500@ then return -1 endi -sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 101; +sql select ts from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.500' order by ts desc limit 8000 offset 101; print $rows if $rows != 3907 then return -1 endi -if $data00 != @70-01-01 08:01:43.488@ then +if $data00 != @70-01-01 08:01:40.488@ then return -1 endi -sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 902; +sql select ts from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.500' order by ts desc limit 8000 offset 902; if $rows != 3106 then return -1 endi -if $data00 != @70-01-01 08:01:43.388@ then +if $data00 != @70-01-01 08:01:40.388@ then return -1 endi -sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 400; +sql select ts from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.500' order by ts desc limit 8000 offset 400; if $rows != 3608 then return -1 endi -if $data00 != @70-01-01 08:01:43.450@ then +if $data00 != @70-01-01 08:01:40.450@ then return -1 endi -sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 8000 offset 4007; +sql select ts from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.500' order by ts desc limit 8000 offset 4007; if $rows != 1 then return -1 endi -if $data00 != @70-01-01 08:01:43.000@ then +if $data00 != @70-01-01 08:01:40.000@ then return -1 endi -sql select ts from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.500' order by ts desc limit 2000 offset 4008; +sql select ts from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.500' order by ts desc limit 2000 offset 4008; if $rows != 0 then return -1 endi #=================================single value filter====================================== -sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 0; +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.00' order by ts asc limit 10 offset 0; if $row != 8 then return -1 endi -if $data00 != @70-01-01 08:01:43.000@ then +if $data00 != @70-01-01 08:01:40.000@ then return -1 endi -sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 1; +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.00' order by ts asc limit 10 offset 1; if $row != 7 then return -1 endi -sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 2; +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.00' order by ts asc limit 10 offset 2; if $row != 6 then return -1 endi -sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 4; +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.00' order by ts asc limit 10 offset 4; if $row != 4 then return -1 endi -sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 7; +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.00' order by ts asc limit 10 offset 7; if $row != 1 then return -1 endi -sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 8; +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.00' order by ts asc limit 10 offset 8; if $row != 0 then return -1 endi -sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts asc limit 10 offset 9; +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.00' order by ts asc limit 10 offset 9; if $row != 0 then return -1 endi #===============================single value filter, order by desc============================ -sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 0; +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.00' order by ts desc limit 10 offset 0; if $row != 8 then return -1 endi -if $data00 != @70-01-01 08:01:43.000@ then +if $data00 != @70-01-01 08:01:40.000@ then return -1 endi -sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 1; +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.00' order by ts desc limit 10 offset 1; if $row != 7 then return -1 endi -sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 2; +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.00' order by ts desc limit 10 offset 2; if $row != 6 then return -1 endi -sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 4; +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.00' order by ts desc limit 10 offset 4; if $row != 4 then return -1 endi -sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 7; +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.00' order by ts desc limit 10 offset 7; if $row != 1 then return -1 endi -if $data00 != @70-01-01 08:01:43.000@ then +if $data00 != @70-01-01 08:01:40.000@ then return -1 endi -sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 8; +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.00' order by ts desc limit 10 offset 8; if $row != 0 then return -1 endi -sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:43' and ts<='1970-1-1 8:1:43.00' order by ts desc limit 10 offset 9; +sql select ts,tbname from group_mt0 where ts>='1970-1-1 8:1:40' and ts<='1970-1-1 8:1:40.00' order by ts desc limit 10 offset 9; if $row != 0 then return -1 endi #[tbase-695] -sql select ts,tbname from group_mt0 where ts>='1970-01-01 8:1:40' and ts<'1970-1-1 8:1:45' and c1<99999999 limit 100000 offset 5000 +sql select ts,tbname from group_mt0 where ts>='1970-01-01 8:1:40' and ts<'1970-1-1 8:1:40.500' and c1<99999999 limit 10000 offset 500 print ===> $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 print ===> $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 print ===> $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 print ===> $data30 $data31 $data32 $data33 $data34 $data35 $data36 $data37 $data38 $data39 -if $row != 35000 then +if $row != 3500 then return -1 endi @@ -301,7 +301,7 @@ print tbase-722 sql select spread(ts) from group_tb0; print $data00 -if $data00 != 9999.000000000 then +if $data00 != 999.000000000 then return -1 endi diff --git a/tests/script/tsim/parser/selectResNum.sim b/tests/script/tsim/parser/selectResNum.sim index 43365b2af2c8fe52a3ce3e36d057ba9dcdc25a5d..11310782402b8e98fadcbaa9bf740c806c52443a 100644 --- a/tests/script/tsim/parser/selectResNum.sim +++ b/tests/script/tsim/parser/selectResNum.sim @@ -7,10 +7,10 @@ $dbPrefix = sc_db $tbPrefix = sc_tb $stbPrefix = sc_stb $tbNum = 10 -$rowNum = 10000 +$rowNum = 1000 $totalNum = $tbNum * $rowNum $loops = 200000 -$log = 10000 +$log = 1000 $ts0 = 1537146000000 $delta = 600000 print ========== selectResNum.sim diff --git a/tests/script/tsim/parser/sliding.sim b/tests/script/tsim/parser/sliding.sim index 45a49fbc4e28662499ef71bcb1de9859e944b57d..1cb4cb5340f993ee25b4f73e8b076375ea28a445 100644 --- a/tests/script/tsim/parser/sliding.sim +++ b/tests/script/tsim/parser/sliding.sim @@ -7,7 +7,7 @@ $dbPrefix = sliding_db $tbPrefix = sliding_tb $mtPrefix = sliding_mt $tbNum = 8 -$rowNum = 10000 +$rowNum = 1000 $totalNum = $tbNum * $rowNum print =============== sliding.sim @@ -88,25 +88,25 @@ $ts1 = $tb1 . .ts $ts2 = $tb2 . .ts print ===============================interval_sliding query -sql select _wstart, count(*) from sliding_tb0 interval(30s) sliding(30s); +sql select _wstart, count(*) from sliding_tb0 interval(3s) sliding(3s); if $row != 10 then return -1 endi if $data00 != @00-01-01 00:00:00.000@ then return -1 endi -if $data01 != 1000 then +if $data01 != 100 then return -1 endi -if $data10 != @00-01-01 00:00:30.000@ then +if $data10 != @00-01-01 00:00:03.000@ then return -1 endi -if $data11 != 1000 then +if $data11 != 100 then return -1 endi sql select _wstart, stddev(c1) from sliding_tb0 interval(10a) sliding(10a); -if $row != 10000 then +if $row != 1000 then return -1 endi if $data00 != @00-01-01 00:00:00.000@ then @@ -123,10 +123,10 @@ if $data91 != 0.000000000 then endi sql select _wstart, stddev(c1),count(c2),first(c3),last(c4) from sliding_tb0 interval(10a) sliding(10a) order by _wstart desc; -if $row != 10000 then +if $row != 1000 then return -1 endi -if $data00 != @00-01-01 00:04:59.970@ then +if $data00 != @00-01-01 00:00:29.970@ then return -1 endi if $data01 != 0.000000000 then @@ -141,7 +141,7 @@ endi if $data04 != 99 then return -1 endi -if $data90 != @00-01-01 00:04:59.700@ then +if $data90 != @00-01-01 00:00:29.700@ then return -1 endi if $data91 != 0.000000000 then @@ -157,41 +157,41 @@ if $data94 != 90 then return -1 endi -sql select _wstart, count(c2),last(c4) from sliding_tb0 interval(30s) sliding(10s) order by _wstart asc; +sql select _wstart, count(c2),last(c4) from sliding_tb0 interval(3s) sliding(1s) order by _wstart asc; if $row != 32 then return -1 endi -if $data00 != @99-12-31 23:59:40.000@ then - print expect 12-31 23:59:40.000, actual: $data00 +if $data00 != @99-12-31 23:59:58.000@ then + print expect 12-31 23:59:58.000, actual: $data00 return -1 endi -if $data01 != 334 then +if $data01 != 34 then return -1 endi if $data02 != 33 then return -1 endi -sql select _wstart, count(c2),stddev(c3),first(c4),last(c4) from sliding_tb0 where ts>'2000-01-01 0:0:0' and ts<'2000-1-1 0:0:31' interval(30s) sliding(30s) order by _wstart asc; +sql select _wstart, count(c2),stddev(c3),first(c4),last(c4) from sliding_tb0 where ts>'2000-01-01 0:0:0' and ts<'2000-1-1 0:0:4' interval(3s) sliding(3s) order by _wstart asc; if $row != 2 then return -1 endi if $data04 != 99 then return -1 endi -if $data01 != 999 then +if $data01 != 99 then return -1 endi -if $data02 != 28.837977152 then +if $data02 != 28.577380332 then return -1 endi #interval offset + limit -sql select _wstart, count(c2), first(c3),stddev(c4) from sliding_tb0 interval(10a) sliding(10a) order by _wstart desc limit 10 offset 990; +sql select _wstart, count(c2), first(c3),stddev(c4) from sliding_tb0 interval(10a) sliding(10a) order by _wstart desc limit 10 offset 90; if $row != 10 then return -1 endi -if $data00 != @00-01-01 00:04:30.270@ then +if $data00 != @00-01-01 00:00:27.270@ then return -1 endi if $data01 != 1 then @@ -203,7 +203,7 @@ endi if $data03 != 0.000000000 then return -1 endi -if $data90 != @00-01-01 00:04:30.000@ then +if $data90 != @00-01-01 00:00:27.000@ then return -1 endi if $data91 != 1 then @@ -217,43 +217,43 @@ if $data93 != 0.000000000 then endi #interval offset test -sql select _wstart, count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(30s) order by _wstart asc limit 1000 offset 1; +sql select _wstart, count(c2),last(c4),stddev(c3) from sliding_tb0 interval(3s) sliding(3s) order by _wstart asc limit 100 offset 1; if $row != 9 then return -1 endi -if $data00 != @00-01-01 00:00:30.000@ then +if $data00 != @00-01-01 00:00:03.000@ then return -1 endi -if $data01 != 1000 then +if $data01 != 100 then return -1 endi if $data02 != 99 then return -1 endi -if $data80 != @00-01-01 00:04:30.000@ then +if $data80 != @00-01-01 00:00:27.000@ then return -1 endi -if $data81 != 1000 then +if $data81 != 100 then return -1 endi -sql select _wstart, count(c2),last(c4),stddev(c3) from sliding_tb0 where ts>'2000-1-1 0:0:0' and ts<'2000-1-1 0:0:31' interval(30s) sliding(30s) order by _wstart asc limit 1000 offset 0; +sql select _wstart, count(c2),last(c4),stddev(c3) from sliding_tb0 where ts>'2000-1-1 0:0:0' and ts<'2000-1-1 0:0:4' interval(3s) sliding(3s) order by _wstart asc limit 100 offset 0; if $row != 2 then return -1 endi if $data00 != @00-01-01 00:00:00.000@ then return -1 endi -if $data01 != 999 then +if $data01 != 99 then return -1 endi if $data02 != 99 then return -1 endi -if $data03 != 28.837977152 then +if $data03 != 28.577380332 then return -1 endi -if $data10 != @00-01-01 00:00:30.000@ then +if $data10 != @00-01-01 00:00:03.000@ then return -1 endi if $data11 != 34 then @@ -266,14 +266,14 @@ if $data13 != 9.810708435 then return -1 endi -sql select _wstart, count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by _wstart asc limit 100 offset 1; +sql select _wstart, count(c2),last(c4),stddev(c3) from sliding_tb0 interval(3s) sliding(2s) order by _wstart asc limit 100 offset 1; if $row != 15 then return -1 endi if $data00 != @00-01-01 00:00:00.000@ then return -1 endi -if $data01 != 1000 then +if $data01 != 100 then return -1 endi if $data02 != 99 then @@ -282,85 +282,85 @@ endi if $data03 != 28.866070048 then return -1 endi -if $data90 != @00-01-01 00:03:00.000@ then +if $data90 != @00-01-01 00:00:18.000@ then return -1 endi -if $data91 != 1000 then +if $data91 != 100 then return -1 endi if $data92 != 99 then return -1 endi -sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by _wstart asc limit 100 offset 5; +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(3s) sliding(2s) order by _wstart asc limit 100 offset 5; if $row != 11 then return -1 endi -sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by _wstart asc limit 100 offset 6; +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(3s) sliding(2s) order by _wstart asc limit 100 offset 6; if $row != 10 then return -1 endi -sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by _wstart asc limit 100 offset 7; +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(3s) sliding(2s) order by _wstart asc limit 100 offset 7; if $row != 9 then return -1 endi -sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by _wstart asc limit 100 offset 8; +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(3s) sliding(2s) order by _wstart asc limit 100 offset 8; if $row != 8 then return -1 endi -sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by _wstart asc limit 100 offset 9; +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(3s) sliding(2s) order by _wstart asc limit 100 offset 9; if $row != 7 then return -1 endi -sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by _wstart asc limit 100 offset 10; +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(3s) sliding(2s) order by _wstart asc limit 100 offset 10; if $row != 6 then return -1 endi -sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by _wstart asc limit 100 offset 11; +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(3s) sliding(2s) order by _wstart asc limit 100 offset 11; if $row != 5 then return -1 endi -sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by _wstart asc limit 100 offset 12; +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(3s) sliding(2s) order by _wstart asc limit 100 offset 12; if $row != 4 then return -1 endi -sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by _wstart asc limit 100 offset 13; +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(3s) sliding(2s) order by _wstart asc limit 100 offset 13; if $row != 3 then return -1 endi -sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by _wstart asc limit 100 offset 14; +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(3s) sliding(2s) order by _wstart asc limit 100 offset 14; if $row != 2 then return -1 endi -sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by _wstart asc limit 100 offset 15; +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(3s) sliding(2s) order by _wstart asc limit 100 offset 15; if $row != 1 then return -1 endi -sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(30s) sliding(20s) order by _wstart asc limit 100 offset 16; +sql select count(c2),last(c4),stddev(c3) from sliding_tb0 interval(3s) sliding(2s) order by _wstart asc limit 100 offset 16; if $row != 0 then return -1 endi -sql select _wstart, count(c2),last(c4),stddev(c3),spread(c3) from sliding_tb0 where c2 = 0 interval(30s) order by _wstart desc; +sql select _wstart, count(c2),last(c4),stddev(c3),spread(c3) from sliding_tb0 where c2 = 0 interval(3s) order by _wstart desc; if $row != 10 then return -1 endi -#00-01-01 00:04:30.000| 10| 0| 0.000000000| 0.000000000| -if $data00 != @00-01-01 00:04:30.000@ then +#00-01-01 00:00:27.000 | 1 | 0 | 0.000000000 | 0.000000000 | +if $data00 != @00-01-01 00:00:27.000@ then return -1 endi -if $data01 != 10 then +if $data01 != 1 then return -1 endi if $data02 != 0 then @@ -370,18 +370,18 @@ if $data03 != 0.000000000 then return -1 endi -sql select count(c2),last(c4),stddev(c3),spread(c3) from sliding_tb0 where c2 = 0 interval(30s) sliding(20s) order by _wstart desc limit 1 offset 15; +sql select count(c2),last(c4),stddev(c3),spread(c3) from sliding_tb0 where c2 = 0 interval(3s) sliding(2s) order by _wstart desc limit 1 offset 14; if $row != 1 then return -1 endi -sql select count(c2),last(c4),stddev(c3),spread(c3) from sliding_tb0 where c2 = 0 interval(30s) sliding(20s) order by _wstart desc limit 1 offset 16; +sql select count(c2),last(c4),stddev(c3),spread(c3) from sliding_tb0 where c2 = 0 interval(3s) sliding(2s) order by _wstart desc limit 1 offset 15; if $row != 0 then return -1 endi sql select _wstart, count(c2), first(c3),stddev(c4) from sliding_tb0 interval(10a) order by _wstart desc limit 10 offset 2; -if $data00 != @00-01-01 00:04:59.910@ then +if $data00 != @00-01-01 00:00:29.910@ then return -1 endi diff --git a/tests/script/tsim/parser/slimit1_query.sim b/tests/script/tsim/parser/slimit1_query.sim index 9a27d5523b04c3466e2a6223dd10695f05e9662a..1167fe0b3dba3d25349fdd2401ece10f0ea09afa 100644 --- a/tests/script/tsim/parser/slimit1_query.sim +++ b/tests/script/tsim/parser/slimit1_query.sim @@ -70,7 +70,7 @@ endi ### empty result set sql select count(*) from stb partition by t2,t1 order by t2 asc slimit 0 soffset 0 -if $rows != 9 then +if $rows != 0 then return -1 endi diff --git a/tests/script/tsim/parser/slimit_limit.sim b/tests/script/tsim/parser/slimit_limit.sim new file mode 100644 index 0000000000000000000000000000000000000000..546ef576871b00c14e7a90d7244c2a4f40dc70c7 --- /dev/null +++ b/tests/script/tsim/parser/slimit_limit.sim @@ -0,0 +1,113 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql drop database if exists db1; +sql create database db1 vgroups 1; +sql use db1; +sql create stable sta (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int); +sql create table tba1 using sta tags(1, 1, 1); +sql create table tba2 using sta tags(2, 2, 2); +sql create table tba3 using sta tags(3, 3, 3); +sql create table tba4 using sta tags(4, 4, 4); +sql create table tba5 using sta tags(5, 5, 5); +sql create table tba6 using sta tags(6, 6, 6); +sql create table tba7 using sta tags(7, 7, 7); +sql create table tba8 using sta tags(8, 8, 8); +sql create index index1 on sta (t2); +sql insert into tba1 values ('2022-04-26 15:15:01', 1, "a"); +sql insert into tba1 values ('2022-04-26 15:15:02', 11, "a"); +sql insert into tba2 values ('2022-04-26 15:15:01', 2, "a"); +sql insert into tba2 values ('2022-04-26 15:15:02', 22, "a"); +sql insert into tba3 values ('2022-04-26 15:15:01', 3, "a"); +sql insert into tba4 values ('2022-04-26 15:15:01', 4, "a"); +sql insert into tba5 values ('2022-04-26 15:15:01', 5, "a"); +sql insert into tba6 values ('2022-04-26 15:15:01', 6, "a"); +sql insert into tba7 values ('2022-04-26 15:15:01', 7, "a"); +sql insert into tba8 values ('2022-04-26 15:15:01', 8, "a"); + +sql select t1,count(*) from sta group by t1 limit 1; +if $rows != 8 then + return -1 +endi +sql select t1,count(*) from sta group by t1 slimit 1; +if $rows != 1 then + return -1 +endi +sql select f1,count(*) from sta group by f1 limit 1; +if $rows != 10 then + return -1 +endi +sql select f1,count(*) from sta group by f1 slimit 1; +if $rows != 1 then + return -1 +endi +sql select t1,f1,count(*) from sta group by t1, f1 limit 1; +if $rows != 10 then + return -1 +endi +sql select t1,f1,count(*) from sta group by t1, f1 slimit 1; +if $rows != 1 then + return -1 +endi +sql select t1,f1,count(*) from sta group by f1, t1 limit 1; +if $rows != 10 then + return -1 +endi +sql select t1,f1,count(*) from sta group by f1, t1 slimit 1; +if $rows != 1 then + return -1 +endi + +sql select t1,count(*) from sta group by t1 order by t1 limit 1; +if $rows != 1 then + return -1 +endi +sql select t1,count(*) from sta group by t1 order by t1 slimit 1; +if $rows != 8 then + return -1 +endi +sql select f1,count(*) from sta group by f1 order by f1 limit 1; +if $rows != 1 then + return -1 +endi +sql select f1,count(*) from sta group by f1 order by f1 slimit 1; +if $rows != 10 then + return -1 +endi +sql select t1,f1,count(*) from sta group by t1, f1 order by t1,f1 limit 1; +if $rows != 1 then + return -1 +endi +sql select t1,f1,count(*) from sta group by t1, f1 order by t1,f1 slimit 1; +if $rows != 10 then + return -1 +endi +sql select t1,f1,count(*) from sta group by f1, t1 order by f1,t1 limit 1; +if $rows != 1 then + return -1 +endi +sql select t1,f1,count(*) from sta group by f1, t1 order by f1,t1 slimit 1; +if $rows != 10 then + return -1 +endi + +sql select t1,count(*) from sta group by t1 slimit 1 limit 1; +if $rows != 1 then + return -1 +endi +sql select f1,count(*) from sta group by f1 slimit 1 limit 1; +if $rows != 1 then + return -1 +endi +sql select t1,f1,count(*) from sta group by t1, f1 slimit 1 limit 1; +if $rows != 1 then + return -1 +endi +sql select t1,f1,count(*) from sta group by f1, t1 slimit 1 limit 1; +if $rows != 1 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/table_merge_limit.sim b/tests/script/tsim/parser/table_merge_limit.sim new file mode 100644 index 0000000000000000000000000000000000000000..7d67b6d3a270c8587c85123963b564c82ea18762 --- /dev/null +++ b/tests/script/tsim/parser/table_merge_limit.sim @@ -0,0 +1,47 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +$dbPrefix = m_fl_db +$tbPrefix = m_fl_tb +$mtPrefix = m_fl_mt +$tbNum = 2 +$rowNum = 513 +$totalNum = $tbNum * $rowNum +$ts0 = 1537146000000 +$delta = 600000 +print ========== fill.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db vgroups 1 +sql use $db +sql create table $mt (ts timestamp, c1 int) tags(tgcol int) + +$i = 0 +$ts = $ts0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $xs = $x * $delta + $ts = $ts0 + $xs + sql insert into $tb values ( $ts , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +sql select * from $mt order by ts limit 10 +if $rows != 10 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/union.sim b/tests/script/tsim/parser/union.sim index 9e7c6f77cc90f9612e9d258880322c218892c828..dee5da96e8488a14cc615d7ab3944ccf6558f93e 100644 --- a/tests/script/tsim/parser/union.sim +++ b/tests/script/tsim/parser/union.sim @@ -8,7 +8,7 @@ $tbPrefix = union_tb $tbPrefix1 = union_tb_ $mtPrefix = union_mt $tbNum = 10 -$rowNum = 10000 +$rowNum = 1000 $totalNum = $tbNum * $rowNum print =============== union.sim @@ -65,7 +65,7 @@ sql create table $mt1 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c $j = 0 $t = 1578203484000 -$rowNum = 1000 +$rowNum = 100 $tbNum = 5 $i = 0 @@ -117,7 +117,7 @@ sql_error (select c1 from union_tb0 limit 1 union all select c1 from union_tb1 l # sql with parenthese sql (select c1 from union_tb0) -if $rows != 10000 then +if $rows != 1000 then return -1 endi if $data00 != 0 then @@ -187,7 +187,7 @@ endi if $data10 != 1 then return -1 endi -if $data20 != 4950000 then +if $data20 != 495000 then return -1 endi @@ -202,7 +202,7 @@ endi if $data10 != 1 then return -1 endi -if $data20 != 495000 then +if $data20 != 49500 then return -1 endi @@ -211,7 +211,7 @@ sql (select count(*) as c from union_tb0, union_tb1 where union_tb0.ts=union_tb1 if $rows != 11 then return -1 endi -if $data00 != 10000 then +if $data00 != 1000 then return -1 endi if $data10 != 9 then @@ -227,7 +227,7 @@ endi print ===========================================tags union # two super table tag union, limit is not active during retrieve tags query sql (select t1 from union_mt0) union all (select t1 from union_mt0) -if $rows != 200000 then +if $rows != 20000 then return -1 endi @@ -248,7 +248,7 @@ sql (select count(*) as c from union_tb0 where ts > now + 3650d) union all (sele if $rows != 2 then return -1 endi -#if $data00 != 495000 then +#if $data00 != 49500 then # return -1 #endi @@ -272,7 +272,7 @@ endi # multi-vnode projection query sql (select c1 from union_mt0) union all select c1 from union_mt0; -if $rows != 200000 then +if $rows != 20000 then return -1 endi @@ -330,10 +330,10 @@ sql (select sum(c1) as a from union_tb0 limit 1) union all (select sum(c3) as a if $rows != 2 then return -1 endi -if $data00 != 495000 then +if $data00 != 49500 then return -1 endi -if $data10 != 495000 then +if $data10 != 49500 then return -1 endi diff --git a/tests/script/tsim/parser/where.sim b/tests/script/tsim/parser/where.sim index c1660883b6189a74c38b59b95c4c4fc1fcad8a90..8ab47dacafe9ae39f49db82d045574b2a3448884 100644 --- a/tests/script/tsim/parser/where.sim +++ b/tests/script/tsim/parser/where.sim @@ -7,7 +7,7 @@ $dbPrefix = wh_db $tbPrefix = wh_tb $mtPrefix = wh_mt $tbNum = 10 -$rowNum = 10000 +$rowNum = 1000 $totalNum = $tbNum * $rowNum print =============== where.sim @@ -62,7 +62,7 @@ sql select count(*) from $tb where c1<10 and c1<>2 if $rows != 1 then return -1 endi -if $data00 != 900 then +if $data00 != 90 then return -1 endi @@ -308,9 +308,9 @@ if $row != 0 then endi sql select * from wh_mt0 where c3 = 1; -print $rows -> 1000 +print $rows -> 100 print $data00 $data01 $data02 -if $row != 1000 then +if $row != 100 then return -1 endi diff --git a/tests/script/tsim/query/explain.sim b/tests/script/tsim/query/explain.sim index eb6b102bd9a8d85352dc1312d906fcbabb22b960..2a8f07178804a166fc9e4c0e2163840825bd4459 100644 --- a/tests/script/tsim/query/explain.sim +++ b/tests/script/tsim/query/explain.sim @@ -4,7 +4,7 @@ system sh/exec.sh -n dnode1 -s start sql connect print ======== step1 -sql create database db1 vgroups 3; +sql create database db1 vgroups 3 cachesize 10 cachemodel 'both'; sql use db1; sql select * from information_schema.ins_databases; sql create stable st1 (ts timestamp, f1 int, f2 binary(200)) tags(t1 int); @@ -60,6 +60,15 @@ sql explain verbose true select * from information_schema.ins_stables where db_n sql explain verbose true select st1.f1 from st1 join st2 on st1.ts=st2.ts and st1.f1 > 0; sql explain verbose true insert into t1(ts) select st1.f1 from st1 join st2 on st1.ts=st2.ts and st1.f1 > 0; sql explain verbose true insert into t1(ts, t1) select _wstart, count(*) from st1 interval(10s); +sql explain verbose true select distinct tbname, table_name from information_schema.ins_tables; +sql explain verbose true select diff(f1) as f11 from tb1 order by f11; +sql explain verbose true select count(*) from st1 where ts > now - 3m and ts < now interval(10s) fill(linear); +sql explain verbose true select count(*) from st1 partition by tbname; +sql explain verbose true select count(*) from information_schema.ins_tables group by stable_name; +sql explain verbose true select last(*) from st1; +sql explain verbose true select last_row(*) from st1; +sql explain verbose true select interp(f1) from tb1 where ts > now - 3m and ts < now range(now-3m,now) every(1m) fill(prev); +sql explain verbose true select _wstart, _wend, count(*) from tb1 EVENT_WINDOW start with f1 > 0 end with f1 < 10; print ======== step4 sql explain analyze select ts from st1 where -2; @@ -96,6 +105,13 @@ sql explain analyze verbose true select * from information_schema.ins_stables wh sql explain analyze verbose true select * from (select min(f1),count(*) a from st1 where f1 > 0) where a < 0; sql explain analyze verbose true select count(f1) from st1 group by tbname; sql explain analyze verbose true select st1.f1 from st1 join st2 on st1.ts=st2.ts and st1.f1 > 0; +sql explain analyze verbose true select diff(f1) as f11 from tb1 order by f11; +sql explain analyze verbose true select count(*) from st1 where ts > now - 3m and ts < now interval(10s) fill(linear); +sql explain analyze verbose true select count(*) from information_schema.ins_tables group by stable_name; +sql explain analyze verbose true select last(*) from st1; +sql explain analyze verbose true select last_row(*) from st1; +sql explain analyze verbose true select interp(f1) from tb1 where ts > now - 3m and ts < now range(now-3m,now) every(1m) fill(prev); +sql explain analyze verbose true select _wstart, _wend, count(*) from tb1 EVENT_WINDOW start with f1 > 0 end with f1 < 10; #not pass case #sql explain verbose true select count(*),sum(f1) as aa from tb1 where (f1 > 0 or f1 < -1) and ts > '2020-10-31 00:00:00' and ts < '2021-10-31 00:00:00' order by aa; diff --git a/tests/script/tsim/query/interval-offset.sim b/tests/script/tsim/query/interval-offset.sim index f4d95df083ca9f80ad5ed68d71992689aa7f66be..0d796af0a0ed1d154667c0d647131829625b34d3 100644 --- a/tests/script/tsim/query/interval-offset.sim +++ b/tests/script/tsim/query/interval-offset.sim @@ -212,10 +212,10 @@ print ===> rows2: $data20 $data21 $data22 $data23 $data24 if $rows != 3 then return -1 endi -if $data01 != 2 then +if $data01 != 4 then return -1 endi -if $data04 != 2 then +if $data04 != 4 then return -1 endi diff --git a/tests/script/tsim/query/join_interval.sim b/tests/script/tsim/query/join_interval.sim new file mode 100644 index 0000000000000000000000000000000000000000..14994a5cc1b77909ebcc40fae93880f9fda065f0 --- /dev/null +++ b/tests/script/tsim/query/join_interval.sim @@ -0,0 +1,42 @@ + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c udf -v 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ======== step create databases +sql create database d1 +sql create database d2 +sql create table d1.t1(ts timestamp, i int) tags(t int); +sql create table d2.t1(ts timestamp, i int); +sql insert into d1.t11 using d1.t1 tags(1) values(1500000000000, 0)(1500000000001, 1)(1500000000002,2)(1500000000003,3)(1500000000004,4) +sql insert into d1.t12 using d1.t1 tags(2) values(1500000000000, 0)(1500000000001, 1)(1500000000002,2)(1500000000003,3)(1500000000004,4) +sql insert into d1.t13 using d1.t1 tags(3) values(1500000000000, 0)(1500000000001, 1)(1500000000002,2)(1500000000003,3)(1500000000004,4) + +sql insert into d2.t1 values(1500000000000,0)(1500000000001,1)(1500000000002,2) + +sql select _wstart,_wend,count((a.ts)),count(b.ts) from d1.t1 a, d2.t1 b where a.ts is not null and a.ts = b.ts interval(1a) ; +if $data02 != 3 then + return -1 +endi + +if $data03 != 3 then + return -1 +endi + +if $data12 != 3 then + return -1 +endi + +if $data13 != 3 then + return -1 +endi +if $data22 != 3 then + return -1 +endi + +if $data23 != 3 then + return -1 +endi +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/query/nullColSma.sim b/tests/script/tsim/query/nullColSma.sim new file mode 100644 index 0000000000000000000000000000000000000000..886274e7e59ca22a557a8ed861585592d5402fbb --- /dev/null +++ b/tests/script/tsim/query/nullColSma.sim @@ -0,0 +1,139 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +$dbPrefix = m_in_db +$tbPrefix = m_in_tb +$mtPrefix = m_in_mt +$tbNum = 1 +$rowNum = 200 +$totalNum = 400 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database if exists $db +sql create database $db vgroups 1 maxrows 200 minrows 10; +sql use $db +sql create table $mt (ts timestamp, f1 int, f2 float) TAGS(tgcol int) + +print ====== start create child tables and insert data +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 1 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , NULL , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +$i = 1 +$tb = $tbPrefix . $i +sql create table $tb using $mt tags( $i ) + +$x = 0 +while $x < $rowNum + $cc = $x * 1 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x , NULL ) + $x = $x + 1 +endw + +sql flush database $db + +print =============== step2 +$i = 0 +$tb = $tbPrefix . $i +sql select max(f1) from $tb +if $rows != 1 then + return -1 +endi +if $data00 != NULL then + return -1 +endi + +$i = 1 +$tb = $tbPrefix . $i +sql select max(f2) from $tb +if $rows != 1 then + return -1 +endi +if $data00 != NULL then + return -1 +endi + +$rowNum = 10 + +print ====== insert more data +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + + $x = 0 + while $x < $rowNum + $cc = $x * 1 + $ms = 1601481700000 + $cc + + sql insert into $tb values ($ms , $x , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +$i = 1 +$tb = $tbPrefix . $i +$x = 0 +while $x < $rowNum + $cc = $x * 1 + $ms = 1601481700000 + $cc + + sql insert into $tb values ($ms , $x , $x ) + $x = $x + 1 +endw + +sql flush database $db + +print =============== step3 +$i = 0 +$tb = $tbPrefix . $i +sql select max(f1) from $tb +if $rows != 1 then + return -1 +endi +if $data00 != 9 then + return -1 +endi + +$i = 1 +$tb = $tbPrefix . $i +sql select max(f2) from $tb +if $rows != 1 then + return -1 +endi +if $data00 != 9.00000 then + print $data00 + return -1 +endi + + +print =============== clear +#sql drop database $db +#sql select * from information_schema.ins_databases +#if $rows != 0 then +# return -1 +#endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/query/sys_tbname.sim b/tests/script/tsim/query/sys_tbname.sim index 7b3953129a81d6fa56b093c8b048b2071b6fbe70..c676f2b1e0b7168c5e83e9b5d2c9b07a1164effb 100644 --- a/tests/script/tsim/query/sys_tbname.sim +++ b/tests/script/tsim/query/sys_tbname.sim @@ -51,6 +51,11 @@ if $data00 != @ins_stables@ then return -1 endi +sql select * from information_schema.ins_tables where table_name=''; +if $rows != 0 then + return -1 +endi + sql select tbname from information_schema.ins_tables; print $rows $data00 if $rows != 33 then diff --git a/tests/script/tsim/query/tableCount.sim b/tests/script/tsim/query/tableCount.sim new file mode 100644 index 0000000000000000000000000000000000000000..d8d9bb9b03e227ce3e54d0d1c84071268b768774 --- /dev/null +++ b/tests/script/tsim/query/tableCount.sim @@ -0,0 +1,107 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql drop database if exists db1; +sql create database db1 vgroups 3; +sql create database db1; +sql use db1; +sql create stable sta (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int); +sql create stable stb (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int); +sql create table tba1 using sta tags(1, 1, 1); +sql create table tba2 using sta tags(2, 2, 2); +sql create table tba3 using sta tags(3, 3, 3); +sql create table tba4 using sta tags(3, 3, 3); +sql create table tba5 using sta tags(3, 3, 3); +sql create table tba6 using sta tags(3, 3, 3); +sql create table tba7 using sta tags(3, 3, 3); +sql create table tba8 using sta tags(3, 3, 3); +sql create table tbb1 using stb tags(4, 4, 4); +sql create table tbb2 using stb tags(5, 5, 5); +sql create table tbb3 using stb tags(6, 6, 6); +sql create table tbb4 using stb tags(4, 4, 4); +sql create table tbb5 using stb tags(5, 5, 5); +sql create table tbb6 using stb tags(6, 6, 6); +sql create table tbb7 using stb tags(7, 7, 7); +sql create table tbb8 using stb tags(8, 8, 8); +sql create table tbn1 (ts timestamp, f1 int); +sql create database db2 vgroups 3; +sql create database db2; +sql use db2; +sql create stable sta (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int); +sql create stable stb (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int); +sql create table tba1 using sta tags(1, 1, 1); +sql create table tba2 using sta tags(2, 2, 2); +sql create table tbb1 using stb tags(4, 4, 4); +sql create table tbb2 using stb tags(5, 5, 5); +sql create table tbb3 using stb tags(6, 6, 6); + +sql select count(table_name) from information_schema.ins_tables group by stable_name; +if $rows != 3 then + return -1 +endi +sql select count(table_name) from information_schema.ins_tables group by db_name; +if $rows != 4 then + return -1 +endi +sql select count(table_name) from information_schema.ins_tables group by db_name, stable_name; +if $rows != 7 then + return -1 +endi +sql select stable_name,count(table_name) from information_schema.ins_tables group by stable_name order by stable_name; +if $rows != 3 then + return -1 +endi +if $data01 != 30 then + return -1 +endi +if $data11 != 10 then + return -1 +endi +if $data21 != 11 then + return -1 +endi +sql select db_name,count(table_name) from information_schema.ins_tables group by db_name order by db_name; +if $rows != 4 then + return -1 +endi +if $data01 != 17 then + return -1 +endi +if $data11 != 5 then + return -1 +endi +if $data21 != 24 then + return -1 +endi +if $data31 != 5 then + return -1 +endi +sql select db_name,stable_name,count(table_name) from information_schema.ins_tables group by db_name, stable_name order by db_name, stable_name; +if $rows != 7 then + return -1 +endi +if $data02 != 1 then + return -1 +endi +if $data12 != 8 then + return -1 +endi +if $data22 != 8 then + return -1 +endi +if $data32 != 2 then + return -1 +endi +if $data42 != 3 then + return -1 +endi +if $data52 != 24 then + return -1 +endi +if $data62 != 5 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/query/udf.sim b/tests/script/tsim/query/udf.sim index 0b48a815e21900c4a80e3ea883e6b95f26bcf695..e539f115317abcd2b64279ec476f8f3464a559d5 100644 --- a/tests/script/tsim/query/udf.sim +++ b/tests/script/tsim/query/udf.sim @@ -23,12 +23,15 @@ if $system_content == Windows_NT then return 0; endi if $system_content == Windows_NT then - sql create function bit_and as 'C:\\Windows\\Temp\\bitand.dll' outputtype int bufSize 8; + sql create function bit_and as 'C:\\Windows\\Temp\\bitand.dll' outputtype int; sql create aggregate function l2norm as 'C:\\Windows\\Temp\\l2norm.dll' outputtype double bufSize 8; else - sql create function bit_and as '/tmp/udf/libbitand.so' outputtype int bufSize 8; + sql create function bit_and as '/tmp/udf/libbitand.so' outputtype int; sql create aggregate function l2norm as '/tmp/udf/libl2norm.so' outputtype double bufSize 8; endi + +sql_error create function bit_and as '/tmp/udf/libbitand.so' oputtype json; + sql show functions; if $rows != 2 then return -1 diff --git a/tests/script/tsim/query/udf_with_const.sim b/tests/script/tsim/query/udf_with_const.sim index 7a2a3389bd155e1c384823ce94c3fdd96b14139e..4a12dd68682a1afe39bf31be1b5b249d2433ee72 100644 --- a/tests/script/tsim/query/udf_with_const.sim +++ b/tests/script/tsim/query/udf_with_const.sim @@ -23,9 +23,9 @@ if $system_content == Windows_NT then endi if $system_content == Windows_NT then - sql create function gpd as 'C:\\Windows\\Temp\\gpd.dll' outputtype int bufSize 8; + sql create function gpd as 'C:\\Windows\\Temp\\gpd.dll' outputtype int; else - sql create function gpd as '/tmp/udf/libgpd.so' outputtype int bufSize 8; + sql create function gpd as '/tmp/udf/libgpd.so' outputtype int; endi sql show functions; if $rows != 1 then diff --git a/tests/script/tsim/query/udfpy.sim b/tests/script/tsim/query/udfpy.sim new file mode 100644 index 0000000000000000000000000000000000000000..9e0492ffd95e3baed20a77ddf3423a1e8872c1d0 --- /dev/null +++ b/tests/script/tsim/query/udfpy.sim @@ -0,0 +1,328 @@ +system_content printf %OS% +if $system_content == Windows_NT then + return 0; +endi + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c udf -v 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +print ======== step1 udf +system sh/compile_udf.sh +system sh/prepare_pyudf.sh +system mkdir -p /tmp/pyudf +system cp sh/pybitand.py /tmp/pyudf/ +system cp sh/pyl2norm.py /tmp/pyudf/ +system ls /tmp/pyudf + +sql create database udf vgroups 3; +sql use udf; +sql select * from information_schema.ins_databases; + +sql create table t (ts timestamp, f int); +sql insert into t values(now, 1)(now+1s, 2); + +system_content printf %OS% +if $system_content == Windows_NT then + return 0; +endi +if $system_content == Windows_NT then + sql create function bit_and as 'C:\\Windows\\Temp\\bitand.dll' outputtype int; + sql create aggregate function l2norm as 'C:\\Windows\\Temp\\l2norm.dll' outputtype double bufSize 8; +else + sql create function bit_and as '/tmp/udf/libbitand.so' outputtype int; + sql create aggregate function l2norm as '/tmp/udf/libl2norm.so' outputtype double bufSize 8; +endi +sql create function pybitand as '/tmp/pyudf/pybitand.py' outputtype int language 'python'; +sql create aggregate function pyl2norm as '/tmp/pyudf/pyl2norm.py' outputtype double bufSize 128 language 'python'; + +sql show functions; +if $rows != 4 then + return -1 +endi + +sql select func_language, func_body,name from information_schema.ins_functions order by name +if $rows != 4 then + return -1 +endi + +if $data00 != @C@ then + return -1 +endi +if $data10 != @C@ then + return -1 +endi +if $data20 != @Python@ then + return -1 +endi +if $data30 != @Python@ then + return -1 +endi + +sql select bit_and(f, f) from t; +if $rows != 2 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi + +sql select pybitand(f, f) from t; +if $rows != 2 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi + +sql select l2norm(f) from t; +if $rows != 1 then + print expect 1, actual $rows + return -1 +endi +if $data00 != 2.236067977 then + return -1 +endi + +sql select pyl2norm(f) from t; +if $rows != 1 then + print expect 1, actual $rows + return -1 +endi +if $data00 != 2.236067977 then + return -1 +endi + +sql create table t2 (ts timestamp, f1 int, f2 int); +sql insert into t2 values(now, 0, 0)(now+1s, 1, 1); +sql select bit_and(f1, f2) from t2; +if $rows != 2 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 1 then + return -1 +endi + +sql select l2norm(f1, f2) from t2; +if $rows != 1 then + return -1 +endi +if $data00 != 1.414213562 then + return -1 +endi + +sql select pybitand(f1, f2) from t2; +if $rows != 2 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 1 then + return -1 +endi + +sql select pyl2norm(f1, f2) from t2; +if $rows != 1 then + return -1 +endi +if $data00 != 1.414213562 then + return -1 +endi + +sql insert into t2 values(now+2s, 1, null)(now+3s, null, 2); +sql select bit_and(f1, f2) from t2; +print $rows , $data00 , $data10 , $data20 , $data30 +if $rows != 4 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 1 then + return -1 +endi + +if $data20 != NULL then + return -1 +endi + +if $data30 != NULL then + return -1 +endi + +sql select l2norm(f1, f2) from t2; +print $rows, $data00 +if $rows != 1 then + return -1 +endi +if $data00 != 2.645751311 then + return -1 +endi + +sql select pybitand(f1, f2) from t2; +print $rows , $data00 , $data10 , $data20 , $data30 +if $rows != 4 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 1 then + return -1 +endi + +if $data20 != NULL then + return -1 +endi + +if $data30 != NULL then + return -1 +endi + +sql select pyl2norm(f1, f2) from t2; +print $rows, $data00 +if $rows != 1 then + return -1 +endi +if $data00 != 2.645751311 then + return -1 +endi + + +sql insert into t2 values(now+4s, 4, 8)(now+5s, 5, 9); +sql select l2norm(f1-f2), l2norm(f1+f2) from t2; +print $rows , $data00 , $data01 +if $rows != 1 then + return -1; +endi +if $data00 != 5.656854249 then + return -1 +endi +if $data01 != 18.547236991 then + return -1 +endi + +sql select l2norm(bit_and(f2, f1)), l2norm(bit_and(f1, f2)) from t2; +print $rows , $data00 , $data01 +if $rows != 1 then + return -1 +endi +if $data00 != 1.414213562 then + return -1 +endi +if $data01 != 1.414213562 then + return -1 +endi + +sql select l2norm(f2) from udf.t2 group by 1-bit_and(f1, f2) order by 1-bit_and(f1,f2); +print $rows , $data00 , $data10 , $data20 +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data10 != 9.055385138 then + return -1 +endi +if $data20 != 8.000000000 then + return -1 +endi + +sql select pyl2norm(f1-f2), pyl2norm(f1+f2) from t2; +print $rows , $data00 , $data01 +if $rows != 1 then + return -1; +endi +if $data00 != 5.656854249 then + return -1 +endi +if $data01 != 18.547236991 then + return -1 +endi + +sql select pyl2norm(pybitand(f2, f1)), pyl2norm(pybitand(f1, f2)) from t2; +print $rows , $data00 , $data01 +if $rows != 1 then + return -1 +endi +if $data00 != 1.414213562 then + return -1 +endi +if $data01 != 1.414213562 then + return -1 +endi + +sql select pyl2norm(f2) from udf.t2 group by 1-pybitand(f1, f2) order by 1-pybitand(f1,f2); +print $rows , $data00 , $data10 , $data20 +if $rows != 3 then + return -1 +endi +if $data00 != 2.000000000 then + return -1 +endi +if $data10 != 9.055385138 then + return -1 +endi +if $data20 != 8.000000000 then + return -1 +endi + +sql create or replace function bit_and as '/tmp/udf/libbitand.so' outputtype int +sql select func_version from information_schema.ins_functions where name='bit_and' +if $data00 != 1 then + return -1 +endi +sql select bit_and(f1, f2) from t2; +print $rows , $data00 , $data10 , $data20 , $data30 , $data40 , $data50 +if $rows != 6 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 1 then + return -1 +endi + +if $data20 != NULL then + return -1 +endi + +if $data30 != NULL then + return -1 +endi + +if $data40 != 0 then + return -1 +endi +if $data50 != 1 then + return -1 +endi +#sql drop function bit_and; +#sql show functions; +#if $rows != 1 then +# return -1 +#endi +#if $data00 != @l2norm@ then +# return -1 +# endi +#sql drop function l2norm; +#sql show functions; +#if $rows != 0 then +# return -1 +#endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/query/unionall_as_table.sim b/tests/script/tsim/query/unionall_as_table.sim new file mode 100644 index 0000000000000000000000000000000000000000..dc3d2cbec4e7677e98a1a038fc9b57b9f371d2ff --- /dev/null +++ b/tests/script/tsim/query/unionall_as_table.sim @@ -0,0 +1,28 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql create database test; +sql use test; +sql CREATE STABLE bw_yc_h_substation_mea (ts TIMESTAMP, create_date VARCHAR(50), create_time VARCHAR(30), load_time TIMESTAMP, sum_p_value FLOAT, sum_sz_value FLOAT, sum_gl_ys FLOAT, sum_g_value FLOAT) TAGS (id VARCHAR(50), name NCHAR(200), datasource VARCHAR(50), sys_flag VARCHAR(50)); +sql CREATE STABLE aw_yc_h_substation_mea (ts TIMESTAMP, create_date VARCHAR(50), create_time VARCHAR(30), load_time TIMESTAMP, sum_p_value FLOAT, sum_sz_value FLOAT, sum_gl_ys FLOAT, sum_g_value FLOAT) TAGS (id VARCHAR(50), name NCHAR(200), datasource VARCHAR(50), sys_flag VARCHAR(50)); +sql CREATE STABLE dw_yc_h_substation_mea (ts TIMESTAMP, create_date VARCHAR(50), create_time VARCHAR(30), load_time TIMESTAMP, sum_p_value FLOAT, sum_sz_value FLOAT, sum_gl_ys FLOAT, sum_g_value FLOAT) TAGS (id VARCHAR(50), name NCHAR(200), datasource VARCHAR(50), sys_flag VARCHAR(50)); +sql insert into t1 using dw_yc_h_substation_mea tags('1234567890','testa','0021001','abc01') values(now,'2023-03-27','00:01:00',now,2.3,3.3,4.4,5.5); +sql insert into t2 using dw_yc_h_substation_mea tags('2234567890','testb','0022001','abc02') values(now,'2023-03-27','00:01:00',now,2.3,2.3,2.4,2.5); +sql insert into t3 using aw_yc_h_substation_mea tags('2234567890','testc','0023001','abc03') values(now,'2023-03-27','00:15:00',now,2.3,2.3,2.4,2.5); +sql insert into t4 using bw_yc_h_substation_mea tags('4234567890','testd','0021001','abc03') values(now,'2023-03-27','00:45:00',now,2.3,2.3,2.4,2.5); +sql insert into t5 using bw_yc_h_substation_mea tags('5234567890','testd','0021001','abc03') values(now,'2023-03-27','00:00:00',now,2.3,2.3,2.4,2.5); +sql select t.ts,t.id,t.name,t.create_date,t.create_time,t.datasource,t.sum_p_value from (select ts,id,name,create_date,create_time,datasource,sum_p_value from bw_yc_h_substation_mea where create_date='2023-03-27' and substr(create_time,4,2) in ('00','15','30','45') union all select ts,id,name,create_date,create_time,datasource,sum_p_value from aw_yc_h_substation_mea where create_date='2023-03-27' and substr(create_time,4,2) in ('00','15','30','45') union all select ts,id,name,create_date,create_time,datasource,sum_p_value from dw_yc_h_substation_mea where create_date='2023-03-27' and substr(create_time,4,2) in ('00','15','30','45')) t where t.datasource='0021001' and t.id='4234567890' order by t.create_time; + +if $rows != 1 then + return -1 +endi +if $data01 != @4234567890@ then + return -1 +endi +if $data05 != @0021001@ then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/show/basic.sim b/tests/script/tsim/show/basic.sim index cae7a66589bac72c352ed855902f3b23bb798046..8990e492fa9aa3805cc8427827484958a7fc4aaf 100644 --- a/tests/script/tsim/show/basic.sim +++ b/tests/script/tsim/show/basic.sim @@ -244,5 +244,15 @@ if $rows <= 0 then return -1 endi +sql show cluster alive; +if $rows <= 0 then + return -1 +endi + +sql show db.alive; +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/stream/deleteState.sim b/tests/script/tsim/stream/deleteState.sim index dd74b73dcefc76f69a19b424b5f544cbf0232559..c84e52067cade9cf9df2452d73a5d41260bfc3a9 100644 --- a/tests/script/tsim/stream/deleteState.sim +++ b/tests/script/tsim/stream/deleteState.sim @@ -51,13 +51,8 @@ if $loop_count == 10 then return -1 endi -if $data01 != 1 then - print =====data01=$data01 - goto loop1 -endi - -if $data02 != NULL then - print =====data02=$data02 +if $rows != 0 then + print =====rows=$rows goto loop1 endi diff --git a/tests/script/tsim/stream/distributeInterval0.sim b/tests/script/tsim/stream/distributeInterval0.sim index 1d58922928c7313aa97bff2ed29e26e9e1035952..1559d3d32b5752ce9ec3be66117daeab354ca1ca 100644 --- a/tests/script/tsim/stream/distributeInterval0.sim +++ b/tests/script/tsim/stream/distributeInterval0.sim @@ -272,4 +272,122 @@ if $data12 != 2 then goto loop3 endi +print ===== step3 + +sql drop database if exists test4; +sql create database test4 vgroups 10; +sql use test4; +sql create stable st(ts timestamp,a int,b int,c varchar(250) ) tags(ta int,tb int,tc int); +sql create table aaa using st tags(1,1,1); +sql create table bbb using st tags(2,2,2); +sql create table ccc using st tags(3,2,2); +sql create table ddd using st tags(4,2,2); + + +sql create stream streams1 ignore expired 0 fill_history 0 watermark 3s into streamst subtable(c) as select _wstart, c , count(*) c1, last_row(b) c2 from st partition by c interval(1s) ; + +sql insert into aaa values(1648791221001,2,2,"/a1/aa/aa"); +sql insert into bbb values(1648791221001,2,2,"/a1/aa/aa"); +sql insert into ccc values(1648791221001,2,2,"/a1/aa/aa"); +sql insert into ddd values(1648791221001,2,2,"/a1/aa/aa"); + +sql insert into aaa values(1648791222002,2,2,"/a2/aa/aa"); +sql insert into bbb values(1648791222002,2,2,"/a2/aa/aa"); +sql insert into ccc values(1648791222002,2,2,"/a2/aa/aa"); +sql insert into ddd values(1648791222002,2,2,"/a2/aa/aa"); + +sql insert into aaa values(1648791223003,2,2,"/a3/aa/aa"); +sql insert into bbb values(1648791223003,2,2,"/a3/aa/aa"); +sql insert into ccc values(1648791223003,2,2,"/a3/aa/aa"); +sql insert into ddd values(1648791223003,2,2,"/a3/aa/aa"); + +sql insert into aaa values(1648791224003,2,2,"/a4/aa/aa"); +sql insert into bbb values(1648791224003,2,2,"/a4/aa/aa"); +sql insert into ccc values(1648791224003,2,2,"/a4/aa/aa"); +sql insert into ddd values(1648791224003,2,2,"/a4/aa/aa"); + + +sql insert into aaa values(1648791225003,2,2,"/a5/aa/aa"); +sql insert into bbb values(1648791225003,2,2,"/a5/aa/aa"); +sql insert into ccc values(1648791225003,2,2,"/a5/aa/aa"); +sql insert into ddd values(1648791225003,2,2,"/a5/aa/aa"); + +sql insert into aaa values(1648791226003,2,2,"/a6/aa/aa"); +sql insert into bbb values(1648791226003,2,2,"/a6/aa/aa"); +sql insert into ccc values(1648791226003,2,2,"/a6/aa/aa"); +sql insert into ddd values(1648791226003,2,2,"/a6/aa/aa"); + +$loop_count = 0 + +loop4: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +sql select * from streamst; + +if $rows == 0 then + goto loop4 +endi + +sql delete from aaa where ts = 1648791223003 ; + +$loop_count = 0 + +loop5: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +sql select * from streamst; + +if $rows == 0 then + goto loop5 +endi + + +sql delete from ccc; + +$loop_count = 0 + +loop6: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +sql select * from streamst; + +if $rows == 0 then + goto loop6 +endi + +sql delete from ddd; + +$loop_count = 0 + +loop7: +sleep 200 + +$loop_count = $loop_count + 1 +if $loop_count == 20 then + return -1 +endi + +sql select * from streamst; + +if $rows == 0 then + goto loop7 +endi + +print ===== over + system sh/stop_dnodes.sh diff --git a/tests/script/tsim/stream/distributeIntervalRetrive0.sim b/tests/script/tsim/stream/distributeIntervalRetrive0.sim index 5b8f4e50e855c424614b20d5fe6fcf89c236a20e..0d797ac59336751d4a5fd1148ecaf08f53a742f9 100644 --- a/tests/script/tsim/stream/distributeIntervalRetrive0.sim +++ b/tests/script/tsim/stream/distributeIntervalRetrive0.sim @@ -11,7 +11,6 @@ sql connect sql create dnode $hostname2 port 7200 system sh/exec.sh -n dnode2 -s start -#==system sh/exec.sh -n dnode2 -s start -v print ===== step1 $x = 0 @@ -37,14 +36,14 @@ endi print ===== step2 -sql create database test vgroups 4; +sql create database test vgroups 10; sql use test; sql create stable st(ts timestamp, a int, b int , c int, d double) tags(ta int,tb int,tc int); sql create table ts1 using st tags(1,1,1); sql create table ts2 using st tags(2,2,2); sql create table ts3 using st tags(3,2,2); sql create table ts4 using st tags(4,2,2); -sql create stream stream_t1 trigger at_once IGNORE EXPIRED 0 into streamtST1 as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s); +sql create stream stream_t1 trigger at_once IGNORE EXPIRED 0 delete_mark 10s into streamtST1 as select _wstart, count(*) c1, sum(a) c3 , max(b) c4, min(c) c5 from st interval(10s); sleep 1000 @@ -235,6 +234,29 @@ endi print loop3 over +sql insert into ts1 values(1648791200001,1,12,3,1.0); +sql insert into ts2 values(1648791200001,1,12,3,1.0); +sql insert into ts3 values(1648791200001,1,12,3,1.0); +sql insert into ts4 values(1648791200001,1,12,3,1.0); + +$loop_count = 0 +loop31: +sleep 1000 + +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamtST1; + +if $rows <= 4 then + print =====rows=$rows + goto loop31 +endi + +print loop31 over + sql drop stream if exists streams1; sql drop database if exists test1; @@ -243,7 +265,7 @@ sql use test1; sql create stable st(ts timestamp,a int,b int,c int) tags(ta int,tb int,tc int); sql create table t1 using st tags(1,1,1); sql create table t2 using st tags(2,2,2); -sql create stream streams1 trigger at_once IGNORE EXPIRED 0 into streamt1 as select _wstart as c0, count(*) c1, count(a) c2 from st interval(10s) ; +sql create stream streams1 trigger at_once IGNORE EXPIRED 0 delete_mark 20s into streamt1 as select _wstart as c0, count(*) c1, count(a) c2 from st interval(10s) ; sql insert into t1 values(1648791211000,1,2,3); diff --git a/tests/script/tsim/stream/partitionbyColumnState.sim b/tests/script/tsim/stream/partitionbyColumnState.sim index 62262a490ce739a463142d2b91a5ffecb1fe8f26..b69ab2df52f6a43ffc36a7dbc91c853d4902c00b 100644 --- a/tests/script/tsim/stream/partitionbyColumnState.sim +++ b/tests/script/tsim/stream/partitionbyColumnState.sim @@ -27,13 +27,8 @@ if $loop_count == 10 then return -1 endi -if $data01 != 1 then - print =====data01=$data01 - goto loop0 -endi - -if $data02 != NULL then - print =====data02=$data02 +if $rows != 0 then + print =====rows=$rows goto loop0 endi diff --git a/tests/script/tsim/stream/state1.sim b/tests/script/tsim/stream/state1.sim new file mode 100644 index 0000000000000000000000000000000000000000..67e02c0890821dc2a57776e64faa95ee9a89c997 --- /dev/null +++ b/tests/script/tsim/stream/state1.sim @@ -0,0 +1,157 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +print step 1 +print =============== create database +sql create database test vgroups 4; +sql select * from information_schema.ins_databases; +if $rows != 3 then + return -1 +endi + +print $data00 $data01 $data02 + +sql use test; + +sql create table t1(ts timestamp, a int, b int , c int, d double, id int); + +print create stream streams1 trigger at_once IGNORE EXPIRED 0 into streamt1 as select _wstart, count(*) c1 from t1 state_window(a); + +sql create stream streams1 trigger at_once IGNORE EXPIRED 0 into streamt1 as select _wstart, count(*) c1 from t1 state_window(a); + +sql insert into t1(ts) values(1648791213000); + +$loop_count = 0 +loop0: + +sleep 300 +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt1; +print $data00 $data01 +print $data10 $data11 + +if $rows != 0 then + print =====rows=$rows + goto loop0 +endi + +sql insert into t1 values(1648791214000,1,2,3,1.0,3); +$loop_count = 0 +loop1: + +sleep 300 +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt1; +print $data00 $data01 +print $data10 $data11 + +if $rows != 1 then + print =====rows=$rows + goto loop1 +endi + +sql insert into t1 values(1648791215000,2,2,3,1.0,4); + +$loop_count = 0 +loop2: + +sleep 300 +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt1; + +if $rows != 2 then + print =====rows=$rows + goto loop2 +endi + +sql insert into t1(ts) values(1648791216000); + +$loop_count = 0 +loop3: + +sleep 300 +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt1; +if $rows != 2 then + print =====rows=$rows + goto loop3 +endi + +print step 1 over +print step 2 + +sql create database test2 vgroups 1; +sql use test2; +sql create table t1(ts timestamp, a int, b int , c int, d double); +print create stream streams2 trigger at_once watermark 1000s into streamt2 as select _wstart, count(*) c1, count(d) c2 from t1 partition by b state_window(a) +sql create stream streams2 trigger at_once watermark 1000s into streamt2 as select _wstart, count(*) c1, count(d) c2 from t1 partition by b state_window(a); + +sql insert into t1 values(1648791213000,1,2,3,1.0); +sql insert into t1 values(1648791213010,1,2,3,1.1); + +$loop_count = 0 +loop4: + +sleep 300 +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +sql select * from streamt2; +print $data00 $data01 +print $data10 $data11 + +if $rows != 1 then + print =====rows=$rows + goto loop4 +endi + +print insert into t1 values(1648791213005,2,2,3,1.1) +sql insert into t1 values(1648791213005,2,2,3,1.1); + +$loop_count = 0 +loop5: + +sleep 300 +$loop_count = $loop_count + 1 +if $loop_count == 10 then + return -1 +endi + +print select * from streamt2 +sql select * from streamt2; +print $data00 $data01 +print $data10 $data11 +print $data20 $data21 +print $data30 $data31 + +if $rows != 3 then + print =====rows=$rows + goto loop5 +endi + +print step 2 over + +print state1 end + +system sh/stop_dnodes.sh diff --git a/tests/script/tsim/tmq/basic1.sim b/tests/script/tsim/tmq/basic1.sim index 6880f290f5fda796cbf5b90f98cf5d40c1976eff..b296290214d223a54153e27ee6e1386fc7722541 100644 --- a/tests/script/tsim/tmq/basic1.sim +++ b/tests/script/tsim/tmq/basic1.sim @@ -34,6 +34,9 @@ $showRow = 0 sql connect sql use $dbName +print == alter database +sql alter database $dbName wal_retention_period 3600 + print == create topics from super table sql create topic topic_stb_column as select ts, c3 from stb sql create topic topic_stb_all as select ts, c1, c2, c3 from stb @@ -83,6 +86,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) @@ -155,6 +161,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) @@ -226,6 +235,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) diff --git a/tests/script/tsim/tmq/basic1Of2Cons.sim b/tests/script/tsim/tmq/basic1Of2Cons.sim index 11b645c4d1a008dc82af07999b86ce32c5484947..4c966c370e9bc57c4eb453f72234d027de972576 100644 --- a/tests/script/tsim/tmq/basic1Of2Cons.sim +++ b/tests/script/tsim/tmq/basic1Of2Cons.sim @@ -34,6 +34,9 @@ $showRow = 0 sql connect sql use $dbName +print == alter database +sql alter database $dbName wal_retention_period 3600 + print == create topics from super table sql create topic topic_stb_column as select ts, c3 from stb sql create topic topic_stb_all as select ts, c1, c2, c3 from stb @@ -83,6 +86,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table for stb sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) @@ -186,6 +192,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table for ctb sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) @@ -288,6 +297,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table for ntb sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) diff --git a/tests/script/tsim/tmq/basic2.sim b/tests/script/tsim/tmq/basic2.sim index dce73be592e459264916f67b4390141115c05bc8..6d49b46c854678930a30e88a23720faa2e6c1844 100644 --- a/tests/script/tsim/tmq/basic2.sim +++ b/tests/script/tsim/tmq/basic2.sim @@ -34,6 +34,9 @@ $showRow = 0 sql connect sql use $dbName +print == alter database +sql alter database $dbName wal_retention_period 3600 + print == create topics from super table sql create topic topic_stb_column as select ts, c3 from stb sql create topic topic_stb_all as select ts, c1, c2, c3 from stb @@ -118,6 +121,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) @@ -175,6 +181,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) diff --git a/tests/script/tsim/tmq/basic2Of2Cons.sim b/tests/script/tsim/tmq/basic2Of2Cons.sim index 87559305ba19cb30b7c8f7928a1437f3246cc139..db660a0c93be23b2b42fc118f522b7944b5f4649 100644 --- a/tests/script/tsim/tmq/basic2Of2Cons.sim +++ b/tests/script/tsim/tmq/basic2Of2Cons.sim @@ -34,6 +34,9 @@ $showRow = 0 sql connect sql use $dbName +print == alter database +sql alter database $dbName wal_retention_period 3600 + print == create topics from super table sql create topic topic_stb_column as select ts, c3 from stb sql create topic topic_stb_all as select ts, c1, c2, c3 from stb @@ -147,6 +150,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table for ctb sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) @@ -234,6 +240,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table for ntb sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) diff --git a/tests/script/tsim/tmq/basic2Of2ConsOverlap.sim b/tests/script/tsim/tmq/basic2Of2ConsOverlap.sim index dda5e0059e5c760925e7944b13089b1d3897c0f8..54e10126f1bd2827ce219a7f8d5cfc1511b6ed88 100644 --- a/tests/script/tsim/tmq/basic2Of2ConsOverlap.sim +++ b/tests/script/tsim/tmq/basic2Of2ConsOverlap.sim @@ -34,6 +34,9 @@ $showRow = 0 sql connect sql use $dbName +print == alter database +sql alter database $dbName wal_retention_period 3600 + print == create topics from super table sql create topic topic_stb_column as select ts, c3 from stb sql create topic topic_stb_all as select ts, c1, c2, c3 from stb @@ -168,6 +171,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table for ctb sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) @@ -259,6 +265,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table for ntb sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) diff --git a/tests/script/tsim/tmq/basic3.sim b/tests/script/tsim/tmq/basic3.sim index 8d677766d74371209e53bab94b62a524318146ee..1e95fa90a5bf603a2afc1f2fd90ee9e3f6dacdfd 100644 --- a/tests/script/tsim/tmq/basic3.sim +++ b/tests/script/tsim/tmq/basic3.sim @@ -34,6 +34,9 @@ $showRow = 0 sql connect sql use $dbName +print == alter database +sql alter database $dbName wal_retention_period 3600 + print == create topics from super table sql create topic topic_stb_column as select ts, c3 from stb sql create topic topic_stb_all as select ts, c1, c2, c3 from stb @@ -83,6 +86,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) @@ -154,6 +160,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) @@ -225,6 +234,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) diff --git a/tests/script/tsim/tmq/basic3Of2Cons.sim b/tests/script/tsim/tmq/basic3Of2Cons.sim index 4921c86c4574174b06af4d906b9a3e74e8ee9c3c..be0292c57b23be1bf2342f50229076c90ebc4ead 100644 --- a/tests/script/tsim/tmq/basic3Of2Cons.sim +++ b/tests/script/tsim/tmq/basic3Of2Cons.sim @@ -34,6 +34,9 @@ $showRow = 0 sql connect sql use $dbName +print == alter database +sql alter database $dbName wal_retention_period 3600 + print == create topics from super table sql create topic topic_stb_column as select ts, c3 from stb sql create topic topic_stb_all as select ts, c1, c2, c3 from stb @@ -82,6 +85,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) @@ -197,6 +203,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) @@ -299,6 +308,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) diff --git a/tests/script/tsim/tmq/basic4.sim b/tests/script/tsim/tmq/basic4.sim index 9b418f12f2b95410994cf52fd4e140a8dcc73889..33a66628d0b3871740754d15225477015eb8e055 100644 --- a/tests/script/tsim/tmq/basic4.sim +++ b/tests/script/tsim/tmq/basic4.sim @@ -34,6 +34,9 @@ $showRow = 0 sql connect sql use $dbName +print == alter database +sql alter database $dbName wal_retention_period 3600 + print == create topics from super table sql create topic topic_stb_column as select ts, c3 from stb sql create topic topic_stb_all as select ts, c1, c2, c3 from stb @@ -115,6 +118,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) @@ -172,6 +178,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) diff --git a/tests/script/tsim/tmq/basic4Of2Cons.sim b/tests/script/tsim/tmq/basic4Of2Cons.sim index f1755f732baa365689653d83e117d2780c40f621..fdee3f633e0a887c650f5ee67ae699c8642b537d 100644 --- a/tests/script/tsim/tmq/basic4Of2Cons.sim +++ b/tests/script/tsim/tmq/basic4Of2Cons.sim @@ -34,6 +34,9 @@ $showRow = 0 sql connect sql use $dbName +print == alter database +sql alter database $dbName wal_retention_period 3600 + print == create topics from super table sql create topic topic_stb_column as select ts, c3 from stb sql create topic topic_stb_all as select ts, c1, c2, c3 from stb @@ -156,6 +159,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) @@ -244,6 +250,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) diff --git a/tests/script/tsim/tmq/snapshot.sim b/tests/script/tsim/tmq/snapshot.sim index de0468e6f26871cc4b5118889a0fcd1262c291e4..81fff3522499ff99ccfa9a92be5483ea42d775ba 100644 --- a/tests/script/tsim/tmq/snapshot.sim +++ b/tests/script/tsim/tmq/snapshot.sim @@ -34,6 +34,9 @@ $showRow = 0 sql connect sql use $dbName +print == alter database +sql alter database $dbName wal_retention_period 3600 + print == create topics from super table sql create topic topic_stb_column as select ts, c3 from stb sql create topic topic_stb_all as select ts, c1, c2, c3 from stb @@ -83,6 +86,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) @@ -152,6 +158,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) @@ -223,6 +232,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) diff --git a/tests/script/tsim/tmq/snapshot1.sim b/tests/script/tsim/tmq/snapshot1.sim index e586719db2fa7646d487658d09e71693ff557c7a..c79892ae1d943a071c58fe2236eb90ef9a5e10d4 100644 --- a/tests/script/tsim/tmq/snapshot1.sim +++ b/tests/script/tsim/tmq/snapshot1.sim @@ -34,6 +34,9 @@ $showRow = 0 sql connect sql use $dbName +print == alter database +sql alter database $dbName wal_retention_period 3600 + print == create topics from super table sql create topic topic_stb_column as select ts, c3 from stb sql create topic topic_stb_all as select ts, c1, c2, c3 from stb @@ -147,6 +150,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table for ctb sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) @@ -224,6 +230,9 @@ sql create database $cdbName vgroups 1 sleep 500 sql use $cdbName +print == alter database +sql alter database $cdbName wal_retention_period 3600 + print == create consume info table and consume result table for ntb sql create table consumeinfo (ts timestamp, consumerid int, topiclist binary(1024), keylist binary(1024), expectmsgcnt bigint, ifcheckdata int, ifmanualcommit int) sql create table consumeresult (ts timestamp, consumerid int, consummsgcnt bigint, consumrowcnt bigint, checkresult int) diff --git a/tests/script/tsim/tmq/topic.sim b/tests/script/tsim/tmq/topic.sim index cb1e74798ea072a03d2ea2570a5a245222b5c8c5..0bf0873e9f0513b08b6868bed220c5e3d74072f9 100644 --- a/tests/script/tsim/tmq/topic.sim +++ b/tests/script/tsim/tmq/topic.sim @@ -39,6 +39,8 @@ endi sql use $dbName +print == alter database +sql alter database $dbName wal_retention_period 3600 print == create super table sql create table $stbPrefix (ts timestamp, c1 int, c2 float, c3 binary(16)) tags (t1 int) diff --git a/tests/script/tsim/user/privilege_db.sim b/tests/script/tsim/user/privilege_db.sim index b708fdab64c1931d6a86c67a8f3ec86cb880677a..50eaa1210866dcfb98f0c889a5eef9960d2faf81 100644 --- a/tests/script/tsim/user/privilege_db.sim +++ b/tests/script/tsim/user/privilege_db.sim @@ -4,13 +4,13 @@ system sh/exec.sh -n dnode1 -s start sql connect print =============== create db -sql create database d1 vgroups 1; +sql create database d1 vgroups 1 wal_retention_period 3600; sql use d1 sql create table d1_stb (ts timestamp, i int) tags (j int) sql create topic d1_topic_1 as select ts, i from d1_stb -sql create database d2 vgroups 1; -sql create database d3 vgroups 1; +sql create database d2 vgroups 1 wal_retention_period 3600; +sql create database d3 vgroups 1 wal_retention_period 3600; sql select * from information_schema.ins_databases if $rows != 5 then return -1 diff --git a/tests/script/tsim/user/privilege_topic.sim b/tests/script/tsim/user/privilege_topic.sim index 9ce5bebec3d68761fb5364896f81e4a5e1428878..9d096a97807a70dfe34297c7fac688502b236a5a 100644 --- a/tests/script/tsim/user/privilege_topic.sim +++ b/tests/script/tsim/user/privilege_topic.sim @@ -4,9 +4,9 @@ system sh/exec.sh -n dnode1 -s start sql connect print =============== create db -sql create database root_d1 vgroups 1; -sql create database root_d2 vgroups 1; -sql create database root_d3 vgroups 1; +sql create database root_d1 vgroups 1 wal_retention_period 3600; +sql create database root_d2 vgroups 1 wal_retention_period 3600; +sql create database root_d3 vgroups 1 wal_retention_period 3600; sql show user privileges if $rows != 1 then diff --git a/tests/script/tsim/valgrind/checkError7.sim b/tests/script/tsim/valgrind/checkError7.sim index af42d1e76b50bc07e9c7a484bd24c9544517f980..edfe8816c9d0e83f705032c64da2dd5ccd7034f2 100644 --- a/tests/script/tsim/valgrind/checkError7.sim +++ b/tests/script/tsim/valgrind/checkError7.sim @@ -8,8 +8,9 @@ sql create database d1 sql use d1 $x = 0 -while $x < 128 +while $x < 5 $tb = d1.s . $x + print create table $tb (ts timestamp, i int) tags (j int) sql create table $tb (ts timestamp, i int) tags (j int) $x = $x + 1 endw @@ -17,7 +18,7 @@ endw print ======================== describe stables # TODO : create stable error $m = 0 -while $m < 128 +while $m < 5 $tb = s . $m $filter = ' . $tb $filter = $filter . ' @@ -36,15 +37,16 @@ print ======================== show stables sql show d1.stables print num of stables is $rows -if $rows != 128 then +if $rows != 5 then return -1 endi print ======================== create table $x = 0 -while $x < 424 +while $x < 42 $tb = d1.t . $x + print create table $tb using d1.s0 tags( $x ) sql create table $tb using d1.s0 tags( $x ) $x = $x + 1 endw @@ -54,7 +56,7 @@ print ======================== show stables sql show d1.tables print num of tables is $rows -if $rows != 424 then +if $rows != 42 then return -1 endi diff --git a/tests/script/tsim/valgrind/checkUdf.sim b/tests/script/tsim/valgrind/checkUdf.sim index caf316bd868a057cd8a161817c85d8664a9db82e..dc703e155d3bacf2ed17648c0020192f5bf77eab 100644 --- a/tests/script/tsim/valgrind/checkUdf.sim +++ b/tests/script/tsim/valgrind/checkUdf.sim @@ -15,10 +15,10 @@ sql insert into t values(now, 1)(now+1s, 2); system_content printf %OS% if $system_content == Windows_NT then - sql create function udf1 as 'C:\\Windows\\Temp\\udf1.dll' outputtype int bufSize 8; + sql create function udf1 as 'C:\\Windows\\Temp\\udf1.dll' outputtype int; sql create aggregate function udf2 as 'C:\\Windows\\Temp\\udf2.dll' outputtype double bufSize 8; else - sql create function udf1 as '/tmp/udf/libudf1.so' outputtype int bufSize 8; + sql create function udf1 as '/tmp/udf/libudf1.so' outputtype int; sql create aggregate function udf2 as '/tmp/udf/libudf2.so' outputtype double bufSize 8; endi sql show functions; diff --git a/tests/system-test/0-others/backquote_check.py b/tests/system-test/0-others/backquote_check.py index 33577232538074953457830934fa853ba81aec6a..be8590f913f110e0156d71fa81560fc99fa39132 100644 --- a/tests/system-test/0-others/backquote_check.py +++ b/tests/system-test/0-others/backquote_check.py @@ -29,7 +29,7 @@ class TDTestCase: self.streamname = 'stm' self.streamtb = 'stm_stb' def topic_name_check(self): - tdSql.execute(f'create database if not exists {self.dbname}') + tdSql.execute(f'create database if not exists {self.dbname} wal_retention_period 3600') tdSql.execute(f'use {self.dbname}') tdSql.execute(f'create stable {self.stbname} (ts timestamp,c0 int) tags(t0 int)') for name in [self.dbname,self.stbname]: @@ -56,12 +56,12 @@ class TDTestCase: tdSql.execute(f'drop topic `{name}`') def db_name_check(self): - tdSql.execute(f'create database if not exists `{self.dbname}`') + tdSql.execute(f'create database if not exists `{self.dbname}` wal_retention_period 3600') tdSql.execute(f'use `{self.dbname}`') tdSql.execute(f'drop database {self.dbname}') def stream_name_check(self): - tdSql.execute(f'create database if not exists {self.dbname}') + tdSql.execute(f'create database if not exists {self.dbname} wal_retention_period 3600') tdSql.execute(f'use {self.dbname}') tdSql.execute(f'create stable {self.stbname} (ts timestamp,c0 int) tags(t0 int)') tdSql.execute(f'create stream `{self.streamname}` into `{self.streamtb}` as select count(*) from {self.stbname} interval(10s);') @@ -84,4 +84,4 @@ class TDTestCase: tdLog.success("%s successfully executed" % __file__) tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/0-others/check_assert.py b/tests/system-test/0-others/check_assert.py new file mode 100644 index 0000000000000000000000000000000000000000..ff69b9eeec02caddfe989eacfe3a4a16a5e6d656 --- /dev/null +++ b/tests/system-test/0-others/check_assert.py @@ -0,0 +1,219 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +''' +from util.log import * +from util.cases import * +from util.sql import * +from util.common import * +from util.sqlset import * + +''' + +import sys +import random +import os + +#define code +NO_FOUND = 0 # not found assert or ASSERT +FOUND_OK = 1 # found ASSERT and valid usage +FOUND_NOIF = 2 # found ASSERT but no if like ASSERT(...) +FOUND_LOWER = 3 # found assert write with system assert +FOUND_HAVENOT = 4 # found ASSERT have if but have not like if(!ASSERT) + +code_strs = ["not found", "valid", "found but no if", "system assert","found but have not"] + + +# +# check assert +# +class CheckAssert: + def __init__(self): + self.files = 0 + self.total = [0,0,0,0,0] + + def wholeMatched(self, line, pos, n): + before = False + after = False + if pos != -1: + if pos == 0 or line[pos-1] == ' ' or line[pos-1] == '!' or line[pos-1] == '(': + before = True + if n > pos + 6 + 1: + last = line[pos+6] + if last == ' ' or last == '(': + after = True + + if before and after: + return True + else: + return False + + + def parseLine(self, line): + + # see FOUND_xxx define below + code = 0 + + n = len(line) + if(n < 7): + return NO_FOUND + s1 = line.find("//") # commit line + + # assert + pos = line.find("assert") + if pos != -1: + if self.wholeMatched(line, pos, n): + # comment line check + if not (s1 != -1 and s1 < pos): + return FOUND_LOWER + + # ASSERT + pos = 0 + while pos < n: + pos = line.find("ASSERT", pos) + #print(f" pos={pos} {line}") + if pos == -1: + return NO_FOUND + if self.wholeMatched(line, pos, n): + break + # next + pos += 6 + + # + # found + # + + # comment line + if s1 != -1 and s1 < pos: + return NO_FOUND + # check if + s2 = line.find("if") + if s2 == -1 or s2 > pos or pos - s2 > 5: + return FOUND_NOIF + s3 = line.find("!") + # if(!ASSERT + if s3 > s2 and s3 < pos: + return FOUND_HAVENOT + + return FOUND_OK + + + def checkFile(self, pathfile): + # check .h .c + ext = pathfile[-2:].lower() + if ext != ".h" and ext != ".c": + return + + print(" check file %s"%pathfile) + self.files += 1 + err = 0 + ok = 0 + i = 0 + + # read file context + with open(pathfile, "r") as fp: + lines = fp.readlines() + for line in lines: + i += 1 + code = self.parseLine(line) + self.total[code] += 1 + if code == FOUND_OK: + ok += 1 + if code != NO_FOUND and code != FOUND_OK: + err += 1 + if code != NO_FOUND: + print(f" line: {i} code: {code} {line}") + + # parse end output total + if err > 0 or ok > 0: + print(f" found problem: {err} \n") + + + def scanPath(self, path): + #print(" check path %s"%path) + + ignores = ["/test/"] + for ignore in ignores: + if ignore in path: + print(f" ignore {path} keyword: {ignore}") + return + + with os.scandir(path) as childs: + for child in childs: + if child.is_file(): + self.checkFile(os.path.join(path, child.name)) + elif child.is_dir(): + self.scanPath(child.path) + + + def doCheck(self, path): + print(f" start check path:{path}") + self.scanPath(path) + + # print total + print("\n") + print(f" --------------- total ({self.files} files)--------------") + for i in range(5): + print(f" code : {i} num: {self.total[i]} ({code_strs[i]})") + print(" --------------- end ----------------") + print(f"\n") + +# +# main function +# + +if __name__ == "__main__": + print(" hello, welcome to use check assert tools 1.0.") + path = os.path.dirname(os.path.realpath(__file__)) + label = "TDengine" + pos = path.find(label) + if pos != -1: + pos += len(label) + 1 + src = path[0:pos] + "source" + else: + src = path + + checker = CheckAssert() + checker.doCheck(src) + print(" check assert finished") + + + +''' +class TDTestCase: + def init(self, conn, logSql, replicaVar=1): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + self.checker = CheckAssert() + + # run + def run(self): + # calc + selfPath = os.path.dirname(os.path.realpath(__file__)) + projPath = "" + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + src = self.projPath + "src/" + self.checker.checkAssert(src) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) + +''' \ No newline at end of file diff --git a/tests/system-test/0-others/compatibility.py b/tests/system-test/0-others/compatibility.py index d7dd4e20c02e61a4bc1c9ef5bf2ea4327650dcf8..1922ebfb2f9d6c48c911214b3fe13d68a77e5d26 100644 --- a/tests/system-test/0-others/compatibility.py +++ b/tests/system-test/0-others/compatibility.py @@ -98,7 +98,7 @@ class TDTestCase: def buildTaosd(self,bPath): # os.system(f"mv {bPath}/build_bak {bPath}/build ") - os.system(f" cd {bPath} && make install ") + os.system(f" cd {bPath} ") def run(self): @@ -146,6 +146,10 @@ class TDTestCase: tdLog.info(" LD_LIBRARY_PATH=/usr/lib taosBenchmark -f 0-others/compa4096.json -y ") os.system("LD_LIBRARY_PATH=/usr/lib taosBenchmark -f 0-others/compa4096.json -y") os.system("LD_LIBRARY_PATH=/usr/lib taos -s 'flush database db4096 '") + cmd = f" LD_LIBRARY_PATH={bPath}/build/lib {bPath}/build/bin/taos -h localhost ;" + if os.system(cmd) == 0: + raise Exception("failed to execute system command. cmd: %s" % cmd) + os.system("pkill taosd") # make sure all the data are saved in disk. self.checkProcessPid("taosd") @@ -156,8 +160,10 @@ class TDTestCase: sleep(1) tdsql=tdCom.newTdSql() print(tdsql) - - + cmd = f" LD_LIBRARY_PATH=/usr/lib taos -h localhost ;" + if os.system(cmd) == 0: + raise Exception("failed to execute system command. cmd: %s" % cmd) + tdsql.query(f"SELECT SERVER_VERSION();") nowServerVersion=tdsql.queryResult[0][0] tdLog.info(f"New server version is {nowServerVersion}") @@ -181,6 +187,7 @@ class TDTestCase: tdsql.execute("drop database if exists db") tdsql.execute("create database db") tdsql.execute("use db") + tdsql.execute("alter database db wal_retention_period 3600") tdsql.execute("create stable db.stb1 (ts timestamp, c1 int) tags (t1 int);") tdsql.execute("insert into db.ct1 using db.stb1 TAGS(1) values(now(),11);") tdsql.error(" insert into `db.ct2` using db.stb1 TAGS(9) values(now(),11);") diff --git a/tests/system-test/0-others/information_schema.py b/tests/system-test/0-others/information_schema.py index 720eab74c42eba2dad40500c673d6a7427d3324b..3c4a71c3e4e47baf7c6503f77ea9b588eaebec83 100644 --- a/tests/system-test/0-others/information_schema.py +++ b/tests/system-test/0-others/information_schema.py @@ -93,7 +93,6 @@ class TDTestCase: tdSql.checkEqual(i[2],len(self.perf_list)) tdSql.execute('create table db1.ntb (ts timestamp,c0 int)') tdSql.query(f'select db_name, count(*) from information_schema.ins_tables group by db_name') - print(tdSql.queryResult) for i in tdSql.queryResult: if i[0].lower() == 'information_schema': tdSql.checkEqual(i[1],len(self.ins_list)) @@ -101,9 +100,77 @@ class TDTestCase: tdSql.checkEqual(i[1],len(self.perf_list)) elif i[0].lower() == self.dbname: tdSql.checkEqual(i[1],self.tbnum+1) + + + + def ins_col_check_4096(self): + tdSql.execute('create database db3 vgroups 2 replica 1') + col_str = tdCom.gen_tag_col_str("col", "int",4094) + tdSql.execute(f'create stable if not exists db3.stb (col_ts timestamp, {col_str}) tags (t1 int)') + for i in range(100): + tdLog.info(f"create table db3.ctb{i} using db3.stb tags({i})") + tdSql.execute(f"create table db3.ctb{i} using db3.stb tags({i})") + col_value_str = '1, ' * 4093 + '1' + tdSql.execute(f"insert into db3.ctb{i} values(now,{col_value_str})(now+1s,{col_value_str})(now+2s,{col_value_str})(now+3s,{col_value_str})") + tdSql.query("select * from information_schema.ins_columns") + + tdSql.execute('drop database db3') + def ins_stable_check(self): + tdSql.execute('create database db3 vgroups 2 replica 1') + tbnum = 10 + ctbnum = 10 + for i in range(tbnum): + tdSql.execute(f'create stable db3.stb_{i} (ts timestamp,c0 int) tags(t0 int)') + tdSql.execute(f'create table db3.ntb_{i} (ts timestamp,c0 int)') + for j in range(ctbnum): + tdSql.execute(f"create table db3.ctb_{i}_{j} using db3.stb_{i} tags({j})") + tdSql.query("select stable_name,count(table_name) from information_schema.ins_tables where db_name = 'db3' group by stable_name order by stable_name") + result = tdSql.queryResult + for i in range(len(result)): + if result[i][0] == None: + tdSql.checkEqual(result[0][1],tbnum) + else: + tdSql.checkEqual(result[i][0],f'stb_{i-1}') + tdSql.checkEqual(result[i][1],ctbnum) + + + + def ins_columns_check(self): + tdSql.execute('drop database if exists db2') + tdSql.execute('create database if not exists db2 vgroups 1 replica 1') + for i in range (5): + self.stb4096 = 'create table db2.stb%d (ts timestamp' % (i) + for j in range (4094 - i): + self.stb4096 += ', c%d int' % (j) + self.stb4096 += ') tags (t1 int)' + tdSql.execute(self.stb4096) + for k in range(10): + tdSql.execute("create table db2.ctb_%d_%dc using db2.stb%d tags(%d)" %(i,k,i,k)) + for t in range (2): + tdSql.query(f'select * from information_schema.ins_columns where db_name="db2" and table_type=="SUPER_TABLE"') + tdSql.checkEqual(20465,len(tdSql.queryResult)) + for t in range (2): + tdSql.query(f'select * from information_schema.ins_columns where db_name="db2" and table_type=="CHILD_TABLE"') + tdSql.checkEqual(204650,len(tdSql.queryResult)) + + for i in range (5): + self.ntb4096 = 'create table db2.ntb%d (ts timestamp' % (i) + for j in range (4095 - i): + self.ntb4096 += ', c%d binary(10)' % (j) + self.ntb4096 += ')' + tdSql.execute(self.ntb4096) + for t in range (2): + tdSql.query(f'select * from information_schema.ins_columns where db_name="db2" and table_type=="NORMAL_TABLE"') + tdSql.checkEqual(20470,len(tdSql.queryResult)) + + def run(self): self.prepare_data() self.count_check() + self.ins_columns_check() + # self.ins_col_check_4096() + self.ins_stable_check() + def stop(self): tdSql.close() diff --git a/tests/system-test/0-others/performance_schema.py b/tests/system-test/0-others/performance_schema.py index 70e86009a67fb0fdd3c04e0e98b89539c4ed8ad0..9d2a362254714a2daefc98787a3c1ec236c3e80c 100755 --- a/tests/system-test/0-others/performance_schema.py +++ b/tests/system-test/0-others/performance_schema.py @@ -75,7 +75,7 @@ class TDTestCase: def prepare_data(self): tdSql.execute(f"create database if not exists {self.dbname} vgroups 2") #1 query tdSql.execute(f'use {self.dbname}') #1 query - + tdsql.execute(f"alter database {self.dbname} wal_retention_period 3600") tdSql.execute(self.setsql.set_create_stable_sql(self.stbname,self.column_dict,self.tag_dict)) #1 query for i in range(self.tbnum): #self.tbnum query @@ -92,12 +92,12 @@ class TDTestCase: def run(self): tdSqlTran = TDSql() tdSqlTran.init(self.obj.conn.cursor()) - tdSqlTran.execute(f"create database if not exists %s vgroups 20"%(self.obj.transTestDBName)) + tdSqlTran.execute(f"create database if not exists %s vgroups 20 wal_retention_period 3600"%(self.obj.transTestDBName)) tdSqlTran.execute(f"DROP DATABASE %s"%(self.obj.transTestDBName)) def init_tmq_env(self, db, topic): self.conn.execute("drop topic if exists {}".format(topic)) - self.conn.execute("create database if not exists {}".format(db)) + self.conn.execute("create database if not exists {} wal_retention_period 3600".format(db)) self.conn.select_db(db) self.conn.execute( "create stable if not exists stb_sub (ts timestamp, c1 int, c2 float, c3 varchar(16)) tags(t1 int, t3 varchar(16))") @@ -211,4 +211,4 @@ class TDTestCase: tdLog.success("%s successfully executed" % __file__) tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/0-others/show.py b/tests/system-test/0-others/show.py index 3e176fe25162b2053f5d86d83b97bc61e6a354d8..b284605a0e8dc619c5ab004d4a65d022b0eb8946 100644 --- a/tests/system-test/0-others/show.py +++ b/tests/system-test/0-others/show.py @@ -28,7 +28,7 @@ class TDTestCase: self.perf_param = ['apps','connections','consumers','queries','transactions'] self.perf_param_list = ['apps','connections','consumers','queries','trans'] self.dbname = "db" - self.vgroups = 10 + self.vgroups = 4 self.stbname = f'`{tdCom.getLongName(5)}`' self.tbname = f'`{tdCom.getLongName(3)}`' self.db_param = { diff --git a/tests/system-test/0-others/tag_index_advance.py b/tests/system-test/0-others/tag_index_advance.py index a8d6cde85a7a67f1b1e23ef06d5b30d7908b02ea..cc942bbf03da12e2c74885577ed9418086795745 100644 --- a/tests/system-test/0-others/tag_index_advance.py +++ b/tests/system-test/0-others/tag_index_advance.py @@ -11,45 +11,42 @@ # -*- coding: utf-8 -*- -from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE -import taos -import sys -import time import os -import socket -import subprocess import random +import socket import string -import random - +import subprocess +import sys +import time +from ssl import ALERT_DESCRIPTION_CERTIFICATE_UNOBTAINABLE -from util.log import * -from util.sql import * +import taos from util.cases import * from util.common import * +from util.dnodes import * +from util.dnodes import TDDnode, TDDnodes +from util.log import * +from util.sql import * from util.sqlset import * -from util.dnodes import * -from util.dnodes import TDDnodes -from util.dnodes import TDDnode # # -------------- util -------------------------- # def pathSize(path): - + total_size = 0 for dirpath, dirnames, filenames in os.walk(path): for i in filenames: - #use join to concatenate all the components of path + # use join to concatenate all the components of path f = os.path.join(dirpath, i) - #use getsize to generate size in bytes and add it to the total size + # use getsize to generate size in bytes and add it to the total size total_size += os.path.getsize(f) - #print(dirpath) + # print(dirpath) - print(" %s %.02f MB"%(path, total_size/1024/1024)) + print(" %s %.02f MB" % (path, total_size/1024/1024)) return total_size - + ''' total = 0 with os.scandir(path) as it: @@ -67,24 +64,27 @@ def pathSize(path): # --------------- cluster ------------------------ # + class MyDnodes(TDDnodes): - def __init__(self ,dnodes_lists): - super(MyDnodes,self).__init__() + def __init__(self, dnodes_lists): + super(MyDnodes, self).__init__() self.dnodes = dnodes_lists # dnode must be TDDnode instance self.simDeployed = False + class TagCluster: noConn = True + def init(self, conn, logSql, replicaVar=1): tdLog.debug(f"start to excute {__file__}") self.TDDnodes = None self.depoly_cluster(5) 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) + 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__)) @@ -101,8 +101,7 @@ class TagCluster: break return buildPath - - def depoly_cluster(self ,dnodes_nums): + def depoly_cluster(self, dnodes_nums): testCluster = False valgrind = 0 @@ -126,7 +125,7 @@ class TagCluster: self.TDDnodes.setAsan(tdDnodes.getAsan()) self.TDDnodes.stopAll() for dnode in self.TDDnodes.dnodes: - self.TDDnodes.deploy(dnode.index,{}) + self.TDDnodes.deploy(dnode.index, {}) for dnode in self.TDDnodes.dnodes: self.TDDnodes.starttaosd(dnode.index) @@ -136,7 +135,8 @@ class TagCluster: sql = "" for dnode in self.TDDnodes.dnodes[1:]: # print(dnode.cfgDict) - dnode_id = dnode.cfgDict["fqdn"] + ":" +dnode.cfgDict["serverPort"] + dnode_id = dnode.cfgDict["fqdn"] + \ + ":" + dnode.cfgDict["serverPort"] if dnode_first_host == "": dnode_first_host = dnode.cfgDict["firstEp"].split(":")[0] dnode_first_port = dnode.cfgDict["firstEp"].split(":")[-1] @@ -145,18 +145,17 @@ class TagCluster: cmd = f"{self.getBuildPath()}/build/bin/taos -h {dnode_first_host} -P {dnode_first_port} -s " cmd += f'"{sql}"' print(cmd) - os.system(cmd) + os.system(cmd) time.sleep(2) tdLog.info(" create cluster done! ") - 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.info(" create cluster ok.") @@ -168,22 +167,22 @@ class TagCluster: class PerfDB: def __init__(self): self.sqls = [] - self.spends= [] - + self.spends = [] + # execute def execute(self, sql): - print(f" perfdb execute {sql}") + print(f" perfdb execute {sql}") stime = time.time() ret = tdSql.execute(sql, 1) spend = time.time() - stime - + self.sqls.append(sql) self.spends.append(spend) return ret # query def query(self, sql): - print(f" perfdb query {sql}") + print(f" perfdb query {sql}") start = time.time() ret = tdSql.query(sql, None, 1) spend = time.time() - start @@ -203,9 +202,9 @@ class TDTestCase: self.tagCluster = TagCluster() self.tagCluster.init(conn, logSql, replicaVar) self.lenBinary = 64 - self.lenNchar = 32 - - # column + self.lenNchar = 32 + + # column self.column_dict = { 'ts': 'timestamp', 'col1': 'tinyint', @@ -252,14 +251,14 @@ class TDTestCase: # query def query(self, sql): - return self.dbs[self.cur].query(sql) - - def set_stb_sql(self,stbname,column_dict,tag_dict): + return self.dbs[self.cur].query(sql) + + def set_stb_sql(self, stbname, column_dict, tag_dict): column_sql = '' tag_sql = '' - for k,v in column_dict.items(): + for k, v in column_dict.items(): column_sql += f"{k} {v}, " - for k,v in tag_dict.items(): + for k, v in tag_dict.items(): tag_sql += f"{k} {v}, " create_stb_sql = f'create stable {stbname} ({column_sql[:-2]}) tags ({tag_sql[:-2]})' return create_stb_sql @@ -268,37 +267,41 @@ class TDTestCase: def create_database(self, dbname, vgroups, replica): sql = f'create database {dbname} vgroups {vgroups} replica {replica}' tdSql.execute(sql) - #tdSql.execute(sql) + # tdSql.execute(sql) tdSql.execute(f'use {dbname}') - + # create stable and child tables def create_table(self, stbname, tbname, count): # create stable - create_table_sql = self.set_stb_sql(stbname, self.column_dict, self.tag_dict) + create_table_sql = self.set_stb_sql( + stbname, self.column_dict, self.tag_dict) tdSql.execute(create_table_sql) # create child table tdLog.info(f" start create {count} child tables.") - for i in range(count): - ti = i % 128 - binTxt = self.random_string(self.lenBinary) - tags = f'{ti},{ti},{i},{i},{ti},{ti},{i},{i},{i}.000{i},{i}.000{i},true,"{binTxt}","nch{i}",now' - sql = f'create table {tbname}{i} using {stbname} tags({tags})' - tdSql.execute(sql) - if i > 0 and i % 1000 == 0: - tdLog.info(f" child table count = {i}") + batchSql = "" + batchSize = 5000 + for i in range(int(count/batchSize)): + batchSql = "create table" + for j in range(batchSize): + ti = (i * batchSize + j) % 128 + binTxt = self.random_string(self.lenBinary) + idx = i * batchSize + j + tags = f'{ti},{ti},{idx},{idx},{ti},{ti},{idx},{idx},{idx}.000{idx},{idx}.000{idx},true,"{binTxt}","nch{idx}",now' + sql = f'{tbname}{idx} using {stbname} tags({tags})' + batchSql = batchSql + " " + sql + tdSql.execute(batchSql) + tdLog.info(f" child table count = {i * batchSize}") - tdLog.info(f" end create {count} child tables.") - - # create stable and child tables + def create_tagidx(self, stbname): cnt = -1 for key in self.tag_dict.keys(): # first tag have default index, so skip if cnt == -1: cnt = 0 - continue; + continue sql = f'create index idx_{key} on {stbname} ({key})' tdLog.info(f" sql={sql}") tdSql.execute(sql) @@ -309,11 +312,11 @@ class TDTestCase: def insert_data(self, tbname): # d1 insert 3 rows for i in range(3): - sql = f'insert into {tbname}1(ts,col1) values(now+{i}s,{i});' + sql = f'insert into {tbname}1(ts,col1) values(now+{i}s,{i});' tdSql.execute(sql) # d20 insert 4 for i in range(4): - sql = f'insert into {tbname}20(ts,col1) values(now+{i}s,{i});' + sql = f'insert into {tbname}20(ts,col1) values(now+{i}s,{i});' tdSql.execute(sql) # check show indexs @@ -376,17 +379,17 @@ class TDTestCase: self.query(sql) tdSql.checkRows(4) - # drop child table + def drop_tables(self, tbname, count): # table d1 and d20 have verify data , so can not drop start = random.randint(21, count/2) - end = random.randint(count/2 + 1, count - 1) + end = random.randint(count/2 + 1, count - 1) for i in range(start, end): sql = f'drop table {tbname}{i}' tdSql.execute(sql) - cnt = end - start + 1 - tdLog.info(f' drop table from {start} to {end} count={cnt}') + cnt = end - start + 1 + tdLog.info(f' drop table from {start} to {end} count={cnt}') # drop tag index def drop_tagidx(self, dbname, stbname): @@ -396,11 +399,11 @@ class TDTestCase: # first tag have default index, so skip if cnt == -1: cnt = 0 - continue; + continue sql = f'drop index idx_{key}' tdSql.execute(sql) cnt += 1 - + # check idx result is 0 sql = f'select index_name,column_name from information_schema.ins_indexes where db_name="{dbname}"' tdSql.query(sql) @@ -408,17 +411,19 @@ class TDTestCase: tdLog.info(f' drop {cnt} tag indexs ok.') # show performance - def show_performance(self, count) : - db = self.dbs[0] + def show_performance(self, count): + db = self.dbs[0] db1 = self.dbs[1] cnt = len(db.sqls) cnt1 = len(db1.sqls) - if cnt != len(db1.sqls): - tdLog.info(f" datebase sql count not equal. cnt={cnt} cnt1={cnt1}\n") + if cnt != len(db1.sqls): + tdLog.info( + f" datebase sql count not equal. cnt={cnt} cnt1={cnt1}\n") return False tdLog.info(f" database sql cnt ={cnt}") - print(f" ----------------- performance (child tables = {count})--------------------") + print( + f" ----------------- performance (child tables = {count})--------------------") print(" No time(index) time(no-index) diff(col3-col2) rate(col2/col3) sql") for i in range(cnt): key = db.sqls[i] @@ -427,12 +432,13 @@ class TDTestCase: value1 = db1.spends[i] diff = value1 - value rate = value/value1*100 - print(" %d %.3fs %.3fs %.3fs %d%% %s"%(i+1, value, value1, diff, rate, key)) + print(" %d %.3fs %.3fs %.3fs %d%% %s" % ( + i+1, value, value1, diff, rate, key)) print(" --------------------- end ------------------------") - return True - + return True + def show_diskspace(self): - #calc + # calc selfPath = os.path.dirname(os.path.realpath(__file__)) projPath = "" if ("community" in selfPath): @@ -451,43 +457,41 @@ class TDTestCase: idx_size = vnode2_size + vnode3_size noidx_size = vnode4_size + vnode5_size - print(" index = %.02f M"%(idx_size/1024/1024)) - print(" no-index = %.02f M"%(noidx_size/1024/1024)) - print(" index/no-index = %.2f multiple"%(idx_size/noidx_size)) + print(" index = %.02f M" % (idx_size/1024/1024)) + print(" no-index = %.02f M" % (noidx_size/1024/1024)) + print(" index/no-index = %.2f multiple" % (idx_size/noidx_size)) print(" -------------------- end ------------------------") - - - # main + def testdb(self, dbname, stable, tbname, count, createidx): # cur if createidx: self.cur = 0 - else : + else: self.cur = 1 - # do + # do self.create_database(dbname, 2, 1) self.create_table(stable, tbname, count) - if(createidx): - self.create_tagidx(stable) + if (createidx): + self.create_tagidx(stable) self.insert_data(tbname) - if(createidx): - self.show_tagidx(dbname,stable) + if (createidx): + self.show_tagidx(dbname, stable) self.query_tagidx(stable) - #self.drop_tables(tbname, count) - #if(createidx): + # self.drop_tables(tbname, count) + # if(createidx): # self.drop_tagidx(dbname, stable) # query after delete , expect no crash - #self.query_tagidx(stable) + # self.query_tagidx(stable) tdSql.execute(f'flush database {dbname}') # run def run(self): self.tagCluster.run() - + # var dbname = "tagindex" dbname1 = dbname + "1" @@ -511,10 +515,10 @@ class TDTestCase: self.show_diskspace() - def stop(self): self.tagCluster.stop() tdLog.success("%s successfully executed" % __file__) + tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/0-others/tag_index_basic.py b/tests/system-test/0-others/tag_index_basic.py index 96c3dca016df5c9f7bc995951bff0d01cbadd23f..72ed559ffd94f808a906d0547c8b10f2ea6f1500 100644 --- a/tests/system-test/0-others/tag_index_basic.py +++ b/tests/system-test/0-others/tag_index_basic.py @@ -24,7 +24,7 @@ class TDTestCase: def init(self, conn, logSql, replicaVar=1): self.replicaVar = int(replicaVar) tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor()) + tdSql.init(conn.cursor(), True) self.setsql = TDSetSql() self.column_dict = { 'ts': 'timestamp', diff --git a/tests/system-test/0-others/taosdMonitor.py b/tests/system-test/0-others/taosdMonitor.py index 944ff52d5bacf386369c80b8561229f48d554008..8094c4e0f555dcd7a5a7340c439a0a34948b212d 100644 --- a/tests/system-test/0-others/taosdMonitor.py +++ b/tests/system-test/0-others/taosdMonitor.py @@ -292,7 +292,7 @@ class TDTestCase: def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() # time.sleep(2) - vgroups = "30" + vgroups = "4" sql = "create database db3 vgroups " + vgroups tdSql.query(sql) sql = "create table db3.stb (ts timestamp, f int) tags (t int)" diff --git a/tests/system-test/0-others/taosdShell.py b/tests/system-test/0-others/taosdShell.py index ce049b851527d5b99e17390083e141c87b8633a9..3b9eb66705407e80a9e130680675a618283679e0 100644 --- a/tests/system-test/0-others/taosdShell.py +++ b/tests/system-test/0-others/taosdShell.py @@ -129,7 +129,7 @@ class TDTestCase: # database\stb\tb\chiild-tb\rows\topics tdSql.execute("create user testpy pass 'testpy'") tdSql.execute("drop database if exists db0;") - tdSql.execute("create database db0;") + tdSql.execute("create database db0 wal_retention_period 3600;") tdSql.execute("use db0;") tdSql.execute("create table if not exists db0.stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned);") tdSql.execute("create table db0.ct1 using db0.stb tags(1000);") @@ -145,7 +145,7 @@ class TDTestCase: #stream tdSql.execute("drop database if exists source_db;") - tdSql.query("create database source_db vgroups 3;") + tdSql.query("create database source_db vgroups 3 wal_retention_period 3600;") tdSql.query("use source_db") tdSql.query("create table if not exists source_db.stb (ts timestamp, k int) tags (a int);") tdSql.query("create table source_db.ct1 using source_db.stb tags(1000);create table source_db.ct2 using source_db.stb tags(2000);create table source_db.ct3 using source_db.stb tags(3000);") diff --git a/tests/system-test/0-others/telemetry.py b/tests/system-test/0-others/telemetry.py index bc5d276faa92e2ec6226a7b36c4ac5b0b3d46420..3b6cb105099dfacebc705d347b320005e4b3d109 100644 --- a/tests/system-test/0-others/telemetry.py +++ b/tests/system-test/0-others/telemetry.py @@ -181,7 +181,7 @@ class TDTestCase: def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring tdSql.prepare() # time.sleep(2) - vgroups = "30" + vgroups = "4" sql = "create database db3 vgroups " + vgroups tdSql.query(sql) diff --git a/tests/system-test/0-others/testRoll.py b/tests/system-test/0-others/testRoll.py index 56e5b3630afe9c875be74dcbbdce52d024c9a22e..c5489146dc4edff7c77a6e2888925bb284dd3fc3 100644 --- a/tests/system-test/0-others/testRoll.py +++ b/tests/system-test/0-others/testRoll.py @@ -13,7 +13,7 @@ def init_tmq_env(db, topic): conn.execute("drop topic if exists {}".format(topic)) conn.execute("drop database if exists {}".format(db)) - conn.execute("create database if not exists {} replica 1 ".format(db)) + conn.execute("create database if not exists {} replica 1 wal_retention_period 3600".format(db)) conn.select_db(db) conn.execute( "create stable if not exists stb1 (ts timestamp, c1 int, c2 float, c3 varchar(16)) tags(t1 int, t3 varchar(16))") @@ -37,7 +37,7 @@ def init_tmq_rest_env(db, topic): conn.execute("drop topic if exists {}".format(topic)) conn.execute("drop database if exists {}".format(db)) - conn.execute("create database if not exists {} replica 3 ".format(db)) + conn.execute("create database if not exists {} replica 3 wal_retention_period 3600".format(db)) conn.select_db(db) conn.execute( "create stable if not exists stb1 (ts timestamp, c1 int, c2 float, c3 varchar(16)) tags(t1 int, t3 varchar(16))") @@ -80,4 +80,4 @@ if __name__ == '__main__': val = res.value() for block in val: - print(block.fetchall()) \ No newline at end of file + print(block.fetchall()) diff --git a/tests/system-test/0-others/tmqBasic.json b/tests/system-test/0-others/tmqBasic.json index 24e815708aeefcb18452cfd20670aba2e185e589..d716bff3ac254c3d1106c25bd0a45ce8f43603d4 100644 --- a/tests/system-test/0-others/tmqBasic.json +++ b/tests/system-test/0-others/tmqBasic.json @@ -14,7 +14,6 @@ "auto.offset.reset": "earliest", "enable.auto.commit": "true", "auto.commit.interval.ms": 1000, - "enable.heartbeat.background": "true", "experimental.snapshot.enable": "true", "msg.with.table.name": "false", "topic_list": [ diff --git a/tests/system-test/0-others/udfTest.py b/tests/system-test/0-others/udfTest.py index 15253df0c4eda40378ed2c875f01a8448f73003d..da77078208d5f54eb8b4d09ab5e489bb9eb2f1ff 100644 --- a/tests/system-test/0-others/udfTest.py +++ b/tests/system-test/0-others/udfTest.py @@ -146,7 +146,7 @@ class TDTestCase: for i in range(5): # create scalar functions - tdSql.execute("create function udf1 as '%s' outputtype int bufSize 8;"%self.libudf1) + tdSql.execute("create function udf1 as '%s' outputtype int;"%self.libudf1) # create aggregate functions @@ -171,7 +171,7 @@ class TDTestCase: tdLog.info("drop two udf functions success ") # create scalar functions - tdSql.execute("create function udf1 as '%s' outputtype int bufSize 8;"%self.libudf1) + tdSql.execute("create function udf1 as '%s' outputtype int;"%self.libudf1) # create aggregate functions @@ -562,7 +562,7 @@ class TDTestCase: # create function without buffer tdSql.execute("create aggregate function udf1 as '%s' outputtype int bufSize 8 "%self.libudf1) - tdSql.execute("create function udf2 as '%s' outputtype double bufSize 8"%self.libudf2) + tdSql.execute("create function udf2 as '%s' outputtype double"%self.libudf2) udf1_sqls ,udf2_sqls = self.try_query_sql() for scalar_sql in udf1_sqls: @@ -570,7 +570,7 @@ class TDTestCase: for aggregate_sql in udf2_sqls: tdSql.error(aggregate_sql) - tdSql.execute(" create function db as '%s' outputtype int bufSize 8 "%self.libudf1) + tdSql.execute(" create function db as '%s' outputtype int "%self.libudf1) tdSql.execute(" create aggregate function test as '%s' outputtype int bufSize 8 "%self.libudf1) tdSql.error(" select db(c1) from stb1 ") tdSql.error(" select db(c1,c6), db(c6) from stb1 ") @@ -619,9 +619,9 @@ class TDTestCase: tdLog.info(" create function name is not build_in functions ") tdSql.execute(" drop function udf1 ") tdSql.execute(" drop function udf2 ") - tdSql.error("create function max as '%s' outputtype int bufSize 8"%self.libudf1) + tdSql.error("create function max as '%s' outputtype int "%self.libudf1) tdSql.error("create aggregate function sum as '%s' outputtype double bufSize 8"%self.libudf2) - tdSql.error("create function max as '%s' outputtype int bufSize 8"%self.libudf1) + tdSql.error("create function max as '%s' outputtype int "%self.libudf1) tdSql.error("create aggregate function sum as '%s' outputtype double bufSize 8"%self.libudf2) tdSql.error("create aggregate function tbname as '%s' outputtype double bufSize 8"%self.libudf2) tdSql.error("create aggregate function function as '%s' outputtype double bufSize 8"%self.libudf2) diff --git a/tests/system-test/0-others/udf_cfg1.py b/tests/system-test/0-others/udf_cfg1.py index 35d43ea9b73eedc7b9432cf0590d90927ad2932c..913e5fcca14283579f6d2cc72d9674b448fc0c2b 100644 --- a/tests/system-test/0-others/udf_cfg1.py +++ b/tests/system-test/0-others/udf_cfg1.py @@ -148,7 +148,7 @@ class TDTestCase: for i in range(5): # create scalar functions - tdSql.execute("create function udf1 as '%s' outputtype int bufSize 8;"%self.libudf1) + tdSql.execute("create function udf1 as '%s' outputtype int;"%self.libudf1) # create aggregate functions @@ -173,7 +173,7 @@ class TDTestCase: tdLog.info("drop two udf functions success ") # create scalar functions - tdSql.execute("create function udf1 as '%s' outputtype int bufSize 8;"%self.libudf1) + tdSql.execute("create function udf1 as '%s' outputtype int;"%self.libudf1) # create aggregate functions diff --git a/tests/system-test/0-others/udf_cfg2.py b/tests/system-test/0-others/udf_cfg2.py index 869cb098e2e0415acf931179dc4e6887aa781f4a..cc6da81847126d91e2aed8c14f11ebfbc0729b01 100644 --- a/tests/system-test/0-others/udf_cfg2.py +++ b/tests/system-test/0-others/udf_cfg2.py @@ -148,7 +148,7 @@ class TDTestCase: for i in range(5): # create scalar functions - tdSql.execute("create function udf1 as '%s' outputtype int bufSize 8;"%self.libudf1) + tdSql.execute("create function udf1 as '%s' outputtype int;"%self.libudf1) # create aggregate functions @@ -173,7 +173,7 @@ class TDTestCase: tdLog.info("drop two udf functions success ") # create scalar functions - tdSql.execute("create function udf1 as '%s' outputtype int bufSize 8;"%self.libudf1) + tdSql.execute("create function udf1 as '%s' outputtype int;"%self.libudf1) # create aggregate functions @@ -564,7 +564,7 @@ class TDTestCase: # create function without buffer tdSql.execute("create aggregate function udf1 as '%s' outputtype int bufSize 8 "%self.libudf1) - tdSql.execute("create function udf2 as '%s' outputtype double bufSize 8"%self.libudf2) + tdSql.execute("create function udf2 as '%s' outputtype double"%self.libudf2) udf1_sqls ,udf2_sqls = self.try_query_sql() for scalar_sql in udf1_sqls: @@ -572,7 +572,7 @@ class TDTestCase: for aggregate_sql in udf2_sqls: tdSql.error(aggregate_sql) - tdSql.execute(" create function db as '%s' outputtype int bufSize 8 "%self.libudf1) + tdSql.execute(" create function db as '%s' outputtype int "%self.libudf1) tdSql.execute(" create aggregate function test as '%s' outputtype int bufSize 8 "%self.libudf1) tdSql.error(" select db(c1) from stb1 ") tdSql.error(" select db(c1,c6), db(c6) from stb1 ") @@ -621,9 +621,9 @@ class TDTestCase: tdLog.info(" create function name is not build_in functions ") tdSql.execute(" drop function udf1 ") tdSql.execute(" drop function udf2 ") - tdSql.error("create function max as '%s' outputtype int bufSize 8"%self.libudf1) + tdSql.error("create function max as '%s' outputtype int"%self.libudf1) tdSql.error("create aggregate function sum as '%s' outputtype double bufSize 8"%self.libudf2) - tdSql.error("create function max as '%s' outputtype int bufSize 8"%self.libudf1) + tdSql.error("create function max as '%s' outputtype int"%self.libudf1) tdSql.error("create aggregate function sum as '%s' outputtype double bufSize 8"%self.libudf2) tdSql.error("create aggregate function tbname as '%s' outputtype double bufSize 8"%self.libudf2) tdSql.error("create aggregate function function as '%s' outputtype double bufSize 8"%self.libudf2) diff --git a/tests/system-test/0-others/udf_create.py b/tests/system-test/0-others/udf_create.py index 65dad6400041e8c52d39d0ff4e484bdc29099894..d35688c8dae3c419084e2f0414c5fb9031a4bea3 100644 --- a/tests/system-test/0-others/udf_create.py +++ b/tests/system-test/0-others/udf_create.py @@ -148,7 +148,7 @@ class TDTestCase: for i in range(5): # create scalar functions - tdSql.execute("create function udf1 as '%s' outputtype int bufSize 8;"%self.libudf1) + tdSql.execute("create function udf1 as '%s' outputtype int;"%self.libudf1) # create aggregate functions @@ -173,7 +173,7 @@ class TDTestCase: tdLog.info("drop two udf functions success ") # create scalar functions - tdSql.execute("create function udf1 as '%s' outputtype int bufSize 8;"%self.libudf1) + tdSql.execute("create function udf1 as '%s' outputtype int;"%self.libudf1) # create aggregate functions @@ -574,7 +574,7 @@ class TDTestCase: # create function without buffer tdSql.execute("create aggregate function udf1 as '%s' outputtype int bufSize 8 "%self.libudf1) - tdSql.execute("create function udf2 as '%s' outputtype double bufSize 8"%self.libudf2) + tdSql.execute("create function udf2 as '%s' outputtype double "%self.libudf2) udf1_sqls ,udf2_sqls = self.try_query_sql() for scalar_sql in udf1_sqls: @@ -582,7 +582,7 @@ class TDTestCase: for aggregate_sql in udf2_sqls: tdSql.error(aggregate_sql) - tdSql.execute(" create function db as '%s' outputtype int bufSize 8 "%self.libudf1) + tdSql.execute(" create function db as '%s' outputtype int "%self.libudf1) tdSql.execute(" create aggregate function test as '%s' outputtype int bufSize 8 "%self.libudf1) tdSql.error(" select db(c1) from stb1 ") tdSql.error(" select db(c1,c6), db(c6) from stb1 ") @@ -631,9 +631,9 @@ class TDTestCase: tdLog.info(" create function name is not build_in functions ") tdSql.execute(" drop function udf1 ") tdSql.execute(" drop function udf2 ") - tdSql.error("create function max as '%s' outputtype int bufSize 8"%self.libudf1) + tdSql.error("create function max as '%s' outputtype int"%self.libudf1) tdSql.error("create aggregate function sum as '%s' outputtype double bufSize 8"%self.libudf2) - tdSql.error("create function max as '%s' outputtype int bufSize 8"%self.libudf1) + tdSql.error("create function max as '%s' outputtype int"%self.libudf1) tdSql.error("create aggregate function sum as '%s' outputtype double bufSize 8"%self.libudf2) tdSql.error("create aggregate function tbname as '%s' outputtype double bufSize 8"%self.libudf2) tdSql.error("create aggregate function function as '%s' outputtype double bufSize 8"%self.libudf2) diff --git a/tests/system-test/0-others/udf_restart_taosd.py b/tests/system-test/0-others/udf_restart_taosd.py index dae707520f55e2e2c6b02c60e5d9015f8c613d3d..a0f70ccd49be9884ad1c0eeb5b7ee91c67ea4bee 100644 --- a/tests/system-test/0-others/udf_restart_taosd.py +++ b/tests/system-test/0-others/udf_restart_taosd.py @@ -145,7 +145,7 @@ class TDTestCase: for i in range(5): # create scalar functions - tdSql.execute("create function udf1 as '%s' outputtype int bufSize 8;"%self.libudf1) + tdSql.execute("create function udf1 as '%s' outputtype int;"%self.libudf1) # create aggregate functions @@ -170,7 +170,7 @@ class TDTestCase: tdLog.info("drop two udf functions success ") # create scalar functions - tdSql.execute("create function udf1 as '%s' outputtype int bufSize 8;"%self.libudf1) + tdSql.execute("create function udf1 as '%s' outputtype int;"%self.libudf1) # create aggregate functions @@ -561,7 +561,7 @@ class TDTestCase: # create function without buffer tdSql.execute("create aggregate function udf1 as '%s' outputtype int bufSize 8 "%self.libudf1) - tdSql.execute("create function udf2 as '%s' outputtype double bufSize 8"%self.libudf2) + tdSql.execute("create function udf2 as '%s' outputtype double"%self.libudf2) udf1_sqls ,udf2_sqls = self.try_query_sql() for scalar_sql in udf1_sqls: @@ -569,7 +569,7 @@ class TDTestCase: for aggregate_sql in udf2_sqls: tdSql.error(aggregate_sql) - tdSql.execute(" create function db as '%s' outputtype int bufSize 8 "%self.libudf1) + tdSql.execute(" create function db as '%s' outputtype int "%self.libudf1) tdSql.execute(" create aggregate function test as '%s' outputtype int bufSize 8 "%self.libudf1) tdSql.error(" select db(c1) from stb1 ") tdSql.error(" select db(c1,c6), db(c6) from stb1 ") @@ -618,9 +618,9 @@ class TDTestCase: tdLog.info(" create function name is not build_in functions ") tdSql.execute(" drop function udf1 ") tdSql.execute(" drop function udf2 ") - tdSql.error("create function max as '%s' outputtype int bufSize 8"%self.libudf1) + tdSql.error("create function max as '%s' outputtype int"%self.libudf1) tdSql.error("create aggregate function sum as '%s' outputtype double bufSize 8"%self.libudf2) - tdSql.error("create function max as '%s' outputtype int bufSize 8"%self.libudf1) + tdSql.error("create function max as '%s' outputtype int"%self.libudf1) tdSql.error("create aggregate function sum as '%s' outputtype double bufSize 8"%self.libudf2) tdSql.error("create aggregate function tbname as '%s' outputtype double bufSize 8"%self.libudf2) tdSql.error("create aggregate function function as '%s' outputtype double bufSize 8"%self.libudf2) diff --git a/tests/system-test/0-others/udfpy/af_count.py b/tests/system-test/0-others/udfpy/af_count.py new file mode 100644 index 0000000000000000000000000000000000000000..ce29abca13866f9f311d1e868a5df68c71c5f735 --- /dev/null +++ b/tests/system-test/0-others/udfpy/af_count.py @@ -0,0 +1,23 @@ +import pickle + +def init(): + pass + +def destroy(): + pass + +def start(): + return pickle.dumps(0) + +def finish(buf): + count = pickle.loads(buf) + return count + +def reduce(datablock, buf): + (rows, cols) = datablock.shape() + count = pickle.loads(buf) + for i in range(rows): + val = datablock.data(i, 0) + if val is not None: + count += 1 + return pickle.dumps(count) \ No newline at end of file diff --git a/tests/system-test/0-others/udfpy/af_min.py b/tests/system-test/0-others/udfpy/af_min.py new file mode 100644 index 0000000000000000000000000000000000000000..9f1aadf4145c7bb585040d1f05640c913aab2aee --- /dev/null +++ b/tests/system-test/0-others/udfpy/af_min.py @@ -0,0 +1,30 @@ +import pickle + +def init(): + pass + +def destroy(): + pass + +def start(): + return pickle.dumps([]) + +def finish(buf): + mins = pickle.loads(buf) + min_val = None + for min in mins: + if min_val is None or (min is not None and min < min_val): + min_val = min + return min_val + +def reduce(datablock, buf): + (rows, cols) = datablock.shape() + mins = pickle.loads(buf) + min = None + for i in range(rows): + val = datablock.data(i, 0) + if min is None or (val is not None and val < min) : + min = val + if min is not None: + mins.append(min) + return pickle.dumps(mins) diff --git a/tests/system-test/0-others/udfpy/af_null.py b/tests/system-test/0-others/udfpy/af_null.py new file mode 100644 index 0000000000000000000000000000000000000000..230eac6888245444a4f902274a83bb5671626515 --- /dev/null +++ b/tests/system-test/0-others/udfpy/af_null.py @@ -0,0 +1,19 @@ +import pickle + +def init(): + pass + +def destroy(): + pass + +def start(): + return pickle.dumps([]) + +def finish(buf): + return None + +def reduce(datablock, buf): + (rows, cols) = datablock.shape() + mins = pickle.loads(buf) + mins.append(None) + return pickle.dumps(mins) diff --git a/tests/system-test/0-others/udfpy/af_sum.py b/tests/system-test/0-others/udfpy/af_sum.py new file mode 100644 index 0000000000000000000000000000000000000000..8b88aba56ca08f64249f85a4df596d9fd204b05a --- /dev/null +++ b/tests/system-test/0-others/udfpy/af_sum.py @@ -0,0 +1,26 @@ +import pickle + +def init(): + pass + +def destroy(): + pass + +def start(): + return pickle.dumps(None) + +def finish(buf): + sum = pickle.loads(buf) + return sum + +def reduce(datablock, buf): + (rows, cols) = datablock.shape() + sum = pickle.loads(buf) + for i in range(rows): + val = datablock.data(i, 0) + if val is not None: + if sum is None: + sum = val + else: + sum += val + return pickle.dumps(sum) diff --git a/tests/system-test/0-others/udfpy/sf_concat_nch.py b/tests/system-test/0-others/udfpy/sf_concat_nch.py new file mode 100644 index 0000000000000000000000000000000000000000..84d8eb2c961c11282784f81b6206a36fba0f2edc --- /dev/null +++ b/tests/system-test/0-others/udfpy/sf_concat_nch.py @@ -0,0 +1,27 @@ +# init +def init(): + pass + +# destroy +def destroy(): + pass + +def process(block): + (nrows, ncols) = block.shape() + results = [] + for i in range(nrows): + row = [] + for j in range(ncols): + val = block.data(i, j) + if val is None: + row = None + break + row.append(val.decode('utf_32_le')) + if row is None: + results.append(None) + else: + row_str = ''.join(row) + results.append(row_str.encode('utf_32_le')) + return results + + diff --git a/tests/system-test/0-others/udfpy/sf_concat_var.py b/tests/system-test/0-others/udfpy/sf_concat_var.py new file mode 100644 index 0000000000000000000000000000000000000000..fc8292c718d5c8def7cebc87ee7938b2c7bd3849 --- /dev/null +++ b/tests/system-test/0-others/udfpy/sf_concat_var.py @@ -0,0 +1,26 @@ +# init +def init(): + pass + +# destroy +def destroy(): + pass + +def process(block): + (nrows, ncols) = block.shape() + results = [] + for i in range(nrows): + row = [] + for j in range(ncols): + val = block.data(i, j) + if val is None: + row = None + break + row.append(val.decode('utf-8')) + if row is None: + results.append(None) + else: + results.append(''.join(row)) + return results + + diff --git a/tests/system-test/0-others/udfpy/sf_multi_args.py b/tests/system-test/0-others/udfpy/sf_multi_args.py new file mode 100644 index 0000000000000000000000000000000000000000..1026661d8d127eeb52b6b79f9b81dd29ccc24ba5 --- /dev/null +++ b/tests/system-test/0-others/udfpy/sf_multi_args.py @@ -0,0 +1,23 @@ +# init +def init(): + pass + +# destroy +def destroy(): + pass + +# return origin column one value +def process(block): + (nrows, ncols) = block.shape() + results = [] + for i in range(nrows): + rows = [] + for j in range(ncols): + val = block.data(i, j) + if type(val) is bytes: + rows.append(val.decode('utf-8')) + else: + rows.append(repr(val)) + results.append(','.join(rows)) + return results + diff --git a/tests/system-test/0-others/udfpy/sf_null.py b/tests/system-test/0-others/udfpy/sf_null.py new file mode 100644 index 0000000000000000000000000000000000000000..c22ca95b19f93d2d494a4890154923626a6a445a --- /dev/null +++ b/tests/system-test/0-others/udfpy/sf_null.py @@ -0,0 +1,16 @@ + +# init +def init(): + pass + +# destroy +def destroy(): + pass + +# return origin column one value +def process(block): + (rows, cols) = block.shape() + results = [] + for i in range(rows): + results.append(None) + return results \ No newline at end of file diff --git a/tests/system-test/0-others/udfpy/sf_origin.py b/tests/system-test/0-others/udfpy/sf_origin.py new file mode 100644 index 0000000000000000000000000000000000000000..9158e044d2defb118683f56b889bf95bb7d04ee6 --- /dev/null +++ b/tests/system-test/0-others/udfpy/sf_origin.py @@ -0,0 +1,15 @@ +# init +def init(): + pass + +# destroy +def destroy(): + pass + +# return origin column one value +def process(block): + (rows, cols) = block.shape() + results = [] + for i in range(rows): + results.append(block.data(i,0)) + return results diff --git a/tests/system-test/0-others/udfpy_main.py b/tests/system-test/0-others/udfpy_main.py new file mode 100644 index 0000000000000000000000000000000000000000..916b032edbde72a4ddc011608b924f95bb035c58 --- /dev/null +++ b/tests/system-test/0-others/udfpy_main.py @@ -0,0 +1,464 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + + +from util.log import * +from util.cases import * +from util.sql import * +from util.common import * +from util.sqlset import * + +import random +import os +import subprocess + + +class PerfDB: + def __init__(self): + self.sqls = [] + self.spends = [] + + # execute + def execute(self, sql): + print(f" perfdb execute {sql}") + stime = time.time() + ret = tdSql.execute(sql, 1) + spend = time.time() - stime + + self.sqls.append(sql) + self.spends.append(spend) + return ret + + # query + def query(self, sql): + print(f" perfdb query {sql}") + start = time.time() + ret = tdSql.query(sql, None, 1) + spend = time.time() - start + self.sqls.append(sql) + self.spends.append(spend) + return ret + + +class TDTestCase: + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + self.setsql = TDSetSql() + + # udf path + self.udf_path = os.path.dirname(os.path.realpath(__file__)) + "/udfpy" + + + 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': 'varchar(120)', + 'col13': 'nchar(100)', + } + self.tag_dict = { + 't1': 'tinyint', + 't2': 'smallint', + 't3': 'int', + 't4': 'bigint', + 't5': 'tinyint unsigned', + 't6': 'smallint unsigned', + 't7': 'int unsigned', + 't8': 'bigint unsigned', + 't9': 'float', + 't10': 'double', + 't11': 'bool', + 't12': 'varchar(120)', + 't13': 'nchar(100)', + } + + def set_stb_sql(self,stbname,column_dict,tag_dict): + 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 stable {stbname} ({column_sql[:-2]}) tags ({tag_sql[:-2]})' + return create_stb_sql + + # create stable and child tables + def create_table(self, stbname, tbname, count): + tdSql.execute("create database db wal_retention_period 4") + tdSql.execute('use db') + self.child_count = count + self.stbname = stbname + self.tbname = tbname + + # create stable + create_table_sql = self.set_stb_sql(stbname, self.column_dict, self.tag_dict) + tdSql.execute(create_table_sql) + + batch_size = 1000 + # create child table + for i in range(count): + ti = i % 128 + tags = f'{ti},{ti},{i},{i},{ti},{ti},{i},{i},{i}.000{i},{i}.000{i},true,"var{i}","nch{i}"' + sql = f'create table {tbname}{i} using {stbname} tags({tags});' + tdSql.execute(sql) + if i % batch_size == 0: + tdLog.info(f" create child table {i} ...") + + tdLog.info(f" create {count} child tables ok.") + + # create with dicts + def create_sf_dicts(self, dicts, filename): + for fun_name, out_type in dicts.items(): + sql = f' create function {fun_name} as "{self.udf_path}/{filename}" outputtype {out_type} language "Python" ' + tdSql.execute(sql) + tdLog.info(sql) + + # create_udfpy_function + def create_scalar_udfpy(self): + # scalar funciton + self.scalar_funs = { + 'sf0': 'timestamp', + 'sf1': 'tinyint', + 'sf2': 'smallint', + 'sf3': 'int', + 'sf4': 'bigint', + 'sf5': 'tinyint unsigned', + 'sf6': 'smallint unsigned', + 'sf7': 'int unsigned', + 'sf8': 'bigint unsigned', + 'sf9': 'float', + 'sf10': 'double', + 'sf11': 'bool', + 'sf12': 'varchar(120)', + 'sf13': 'nchar(100)' + } + # agg function + self.agg_funs = { + 'af1': 'tinyint', + 'af2': 'smallint', + 'af3': 'int', + 'af4': 'bigint', + 'af5': 'tinyint unsigned', + 'af6': 'smallint unsigned', + 'af7': 'int unsigned', + 'af8': 'bigint unsigned', + 'af9': 'float', + 'af10': 'double', + 'af11': 'bool', + 'af12': 'varchar(120)', + 'af13': 'nchar(100)', + 'af14': 'timestamp' + } + + # multi_args + self.create_sf_dicts(self.scalar_funs, "sf_origin.py") + fun_name = "sf_multi_args" + self.create_udf_sf(fun_name, f'{fun_name}.py', "binary(1024)") + + # all type check null + for col_name, col_type in self.column_dict.items(): + self.create_udf_sf(f"sf_null_{col_name}", "sf_null.py", col_type) + + # concat + fun_name = "sf_concat_var" + self.create_udf_sf(fun_name, f'{fun_name}.py', "varchar(1024)") + fun_name = "sf_concat_nch" + self.create_udf_sf(fun_name, f'{fun_name}.py', "nchar(1024)") + + + # fun_name == fun_name.py + def create_udf_sf(self, fun_name, file_name, out_type): + sql = f'create function {fun_name} as "{self.udf_path}/{file_name}" outputtype {out_type} language "Python" ' + tdSql.execute(sql) + tdLog.info(sql) + + def create_udf_af(self, fun_name, file_name, out_type, bufsize): + sql = f'create aggregate function {fun_name} as "{self.udf_path}/{file_name}" outputtype {out_type} bufsize {bufsize} language "Python" ' + tdSql.execute(sql) + tdLog.info(sql) + + + # sql1 query result eual with sql2 + def verify_same_result(self, sql1, sql2): + # query + result1 = tdSql.getResult(sql1) + tdSql.query(sql2) + + for i, row in enumerate(result1): + for j , val in enumerate(row): + tdSql.checkData(i, j, result1[i][j]) + + # same value like select col1, udf_fun1(col1) from st + def verify_same_value(self, sql, col=0): + tdSql.query(sql) + nrows = tdSql.getRows() + for i in range(nrows): + val = tdSql.getData(i, col) + tdSql.checkData(i, col + 1, val) + + # verify multi values + def verify_same_multi_values(self, sql): + tdSql.query(sql) + nrows = tdSql.getRows() + for i in range(nrows): + udf_val = tdSql.getData(i, 0) + vals = udf_val.split(',') + for j,val in enumerate(vals, 1): + tdSql.checkData(i, j, val) + + # query multi-args + def query_multi_args(self): + cols = list(self.column_dict.keys()) + list(self.tag_dict.keys()) + cols.remove("col13") + cols.remove("t13") + cols.remove("ts") + ncols = len(cols) + print(cols) + for i in range(2, ncols): + sample = random.sample(cols, i) + print(sample) + cols_name = ','.join(sample) + sql = f'select sf_multi_args({cols_name}),{cols_name} from {self.stbname} limit 10' + self.verify_same_multi_values(sql) + tdLog.info(sql) + + + # query_udfpy + def query_scalar_udfpy(self): + # col + for col_name, col_type in self.column_dict.items(): + for fun_name, out_type in self.scalar_funs.items(): + if col_type == out_type : + sql = f'select {col_name}, {fun_name}({col_name}) from {self.stbname} limit 10' + tdLog.info(sql) + self.verify_same_value(sql) + sql = f'select * from (select {col_name} as a, {fun_name}({col_name}) as b from {self.stbname} limit 100) order by b,a desc' + tdLog.info(sql) + self.verify_same_value(sql) + + # multi-args + self.query_multi_args() + + # all type check null + for col_name, col_type in self.column_dict.items(): + fun_name = f"sf_null_{col_name}" + sql = f'select {fun_name}({col_name}) from {self.stbname}' + tdSql.query(sql) + if col_type != "timestamp": + tdSql.checkData(0, 0, "None") + else: + val = tdSql.getData(0, 0) + if val is not None: + tdLog.exit(f" check {sql} not expect None.") + + # concat + sql = f'select sf_concat_var(col12, t12), concat(col12, t12) from {self.stbname} limit 1000' + self.verify_same_value(sql) + sql = f'select sf_concat_nch(col13, t13), concat(col13, t13) from {self.stbname} limit 1000' + self.verify_same_value(sql) + + # create aggregate + def create_aggr_udfpy(self): + + bufsize = 200 * 1024 + # all type check null + for col_name, col_type in self.column_dict.items(): + self.create_udf_af(f"af_null_{col_name}", "af_null.py", col_type, bufsize) + + # min + file_name = "af_min.py" + fun_name = "af_min_float" + self.create_udf_af(fun_name, file_name, f"float", bufsize) + fun_name = "af_min_int" + self.create_udf_af(fun_name, file_name, f"int", bufsize) + + # sum + file_name = "af_sum.py" + fun_name = "af_sum_float" + self.create_udf_af(fun_name, file_name, f"float", bufsize) + fun_name = "af_sum_int" + self.create_udf_af(fun_name, file_name, f"int", bufsize) + fun_name = "af_sum_bigint" + self.create_udf_af(fun_name, file_name, f"bigint", bufsize) + + # count + file_name = "af_count.py" + fun_name = "af_count_float" + self.create_udf_af(fun_name, file_name, f"float", bufsize) + fun_name = "af_count_int" + self.create_udf_af(fun_name, file_name, f"int", bufsize) + fun_name = "af_count_bigint" + self.create_udf_af(fun_name, file_name, f"bigint", bufsize) + + + # query aggregate + def query_aggr_udfpy(self) : + # all type check null + for col_name, col_type in self.column_dict.items(): + fun_name = f"af_null_{col_name}" + sql = f'select {fun_name}({col_name}) from {self.stbname}' + tdSql.query(sql) + if col_type != "timestamp": + tdSql.checkData(0, 0, "None") + else: + val = tdSql.getData(0, 0) + if val is not None: + tdLog.exit(f" check {sql} not expect None.") + + # min + sql = f'select min(col3), af_min_int(col3) from {self.stbname}' + self.verify_same_value(sql) + sql = f'select min(col7), af_min_int(col7) from {self.stbname}' + self.verify_same_value(sql) + sql = f'select min(col9), af_min_float(col9) from {self.stbname}' + self.verify_same_value(sql) + + # sum + sql = f'select sum(col1), af_sum_int(col1) from d0' + self.verify_same_value(sql) + sql = f'select sum(col3), af_sum_bigint(col3) from {self.stbname}' + self.verify_same_value(sql) + sql = f'select sum(col9), af_sum_float(col9) from {self.stbname}' + self.verify_same_value(sql) + + # count + sql = f'select count(col1), af_count_int(col1) from {self.stbname}' + self.verify_same_value(sql) + sql = f'select count(col7), af_count_bigint(col7) from {self.stbname}' + self.verify_same_value(sql) + sql = f'select count(col8), af_count_float(col8) from {self.stbname}' + self.verify_same_value(sql) + + # nest + sql = f'select a+1000,b+1000 from (select count(col8) as a, af_count_float(col8) as b from {self.stbname})' + self.verify_same_value(sql) + # group by + sql = f'select a+1000,b+1000 from (select count(col8) as a, af_count_float(col8) as b from {self.stbname} group by tbname)' + self.verify_same_value(sql) + # two filed expr + sql = f'select sum(col1+col2),af_sum_float(col1+col2) from {self.stbname};' + self.verify_same_value(sql) + # interval + sql = f'select af_sum_float(col2+col3),sum(col3+col2) from {self.stbname} interval(1s)' + self.verify_same_value(sql) + + + # insert to child table d1 data + def insert_data(self, tbname, rows): + ts = 1670000000000 + values = "" + batch_size = 500 + child_name = "" + for i in range(self.child_count): + for j in range(rows): + tj = j % 128 + cols = f'{tj},{tj},{j},{j},{tj},{tj},{j},{j},{j}.000{j},{j}.000{j},true,"var{j}","nch{j}涛思数据codepage is utf_32_le"' + value = f'({ts+j},{cols})' + if values == "": + values = value + else: + values += f",{value}" + if j % batch_size == 0 or j + 1 == rows: + sql = f'insert into {tbname}{i} values {values};' + tdSql.execute(sql) + tdLog.info(f" child table={i} rows={j} insert data.") + values = "" + + # partial columns upate + sql = f'insert into {tbname}0(ts, col1, col9, col11) values(now, 100, 200, 0)' + tdSql.execute(sql) + sql = f'insert into {tbname}0(ts, col2, col5, col8) values(now, 100, 200, 300)' + tdSql.execute(sql) + sql = f'insert into {tbname}0(ts, col3, col7, col13) values(now, null, null, null)' + tdSql.execute(sql) + sql = f'insert into {tbname}0(ts) values(now)' + tdSql.execute(sql) + tdLog.info(f" insert {rows} to child table {self.child_count} .") + + + # create stream + def create_stream(self): + sql = f"create stream ma into sta subtable(concat('sta_',tbname)) \ + as select _wstart,count(col1),af_count_bigint(col1) from {self.stbname} partition by tbname interval(1s);" + tdSql.execute(sql) + tdLog.info(sql) + + # query stream + def verify_stream(self): + sql = f"select * from sta limit 10" + self.verify_same_value(sql, 1) + + # create tmq + def create_tmq(self): + sql = f"create topic topa as select concat(col12,t12),sf_concat_var(col12,t12) from {self.stbname};" + tdSql.execute(sql) + tdLog.info(sql) + + def install_taospy(self): + tdLog.info("install taospyudf...") + packs = ["taospyudf"] + for pack in packs: + subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-i', 'https://pypi.org/simple', '-U', pack]) + tdLog.info("call ldconfig...") + os.system("ldconfig") + tdLog.info("install taospyudf successfully.") + + # run + def run(self): + self.install_taospy() + + # var + stable = "meters" + tbname = "d" + count = 10 + rows = 5000 + # do + self.create_table(stable, tbname, count) + + # create + self.create_scalar_udfpy() + self.create_aggr_udfpy() + + # create stream + self.create_stream() + + # create tmq + self.create_tmq() + + # insert data + self.insert_data(tbname, rows) + + # query + self.query_scalar_udfpy() + self.query_aggr_udfpy() + + # show performance + + + 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/0-others/user_manage.py b/tests/system-test/0-others/user_manage.py index 6f90a2873afa4e08c1ec4b72457b6cba9f232d48..1e33d4bb1c628bd43569b68d8f7fc07e68f2bec8 100644 --- a/tests/system-test/0-others/user_manage.py +++ b/tests/system-test/0-others/user_manage.py @@ -115,6 +115,7 @@ class TDTestCase: jiacy0_read_conn = taos.connect(user='jiacy0_read', password='123') jiacy0_write_conn = taos.connect(user='jiacy0_write', password='123') jiacy0_none_conn = taos.connect(user='jiacy0_none', password='123') + tdSql.execute('alter database db wal_retention_period 3600') tdSql.execute('create topic root_db as select * from db.stb') for user in [jiacy1_all_conn, jiacy1_read_conn, jiacy0_all_conn, jiacy0_read_conn]: user.execute(f'create topic db_jiacy as select * from db.stb') diff --git a/tests/system-test/0-others/walFileIdex.py b/tests/system-test/0-others/walFileIdex.py index cd34c7e5e30315df92b0f0aa4c0dda7c460b450a..f8309519cd77a63d863105a8a1cd2227021a4ff4 100644 --- a/tests/system-test/0-others/walFileIdex.py +++ b/tests/system-test/0-others/walFileIdex.py @@ -58,7 +58,7 @@ class TDTestCase: #stream tdSql.execute("drop database if exists source_db;") - tdSql.query("create database source_db vgroups 3;") + tdSql.query("create database source_db vgroups 3 wal_retention_period 3600;") tdSql.query("use source_db") tdSql.query("create table if not exists source_db.stb (ts timestamp, k int) tags (a int);") tdSql.query("create table source_db.ct1 using source_db.stb tags(1000);create table source_db.ct2 using source_db.stb tags(2000);create table source_db.ct3 using source_db.stb tags(3000);") diff --git a/tests/system-test/0-others/walRetention.py b/tests/system-test/0-others/walRetention.py new file mode 100644 index 0000000000000000000000000000000000000000..2b340b79697f874a1e300970fac74f90529f0cc9 --- /dev/null +++ b/tests/system-test/0-others/walRetention.py @@ -0,0 +1,472 @@ +################################################################### +# 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 -*- + +# +# The option for wal_retetion_period and wal_retention_size is work well +# + +import taos +from taos.tmq import Consumer + +from util.log import * +from util.cases import * +from util.sql import * +from util.common import * +from util.sqlset import * + + +import os +import threading +import json +import time +from datetime import date +from datetime import datetime +from datetime import timedelta +from os import path + + +# +# -------------- util -------------------------- +# +def pathSize(path): + + total_size = 0 + for dirpath, dirnames, filenames in os.walk(path): + for i in filenames: + # use join to concatenate all the components of path + f = os.path.join(dirpath, i) + # use getsize to generate size in bytes and add it to the total size + total_size += os.path.getsize(f) + # print(dirpath) + + print(" %s %.02f MB" % (path, total_size/1024/1024)) + return total_size + + +# load json from file +def jsonFromFile(jsonFile): + fp = open(jsonFile) + return json.load(fp) + + +# +# ----------------- class ------------------ +# + +# wal file object +class WalFile: + def __init__(self, pathFile, fileName): + self.mtime = os.path.getmtime(pathFile) + self.startVer = int(fileName) + self.fsize = os.path.getsize(pathFile) + self.endVer = -1 + self.pathFile = pathFile + + def needDelete(self, delTsLine): + return True + +# VNode object +class VNode : + # init + def __init__(self, dnodeId, path, walPeriod, walSize, walStayRange): + self.path = path + self.dnodeId = dnodeId + self.vgId = 0 + self.snapVer = 0 + self.firstVer = 0 + self.lastVer = -1 + self.walPeriod = walPeriod + self.walSize = walSize + self.walStayRange = walStayRange + self.walFiles = [] + self.load(path) + + # load + def load(self, path): + # load wal + walPath = os.path.join(path, "wal") + metaFile = "" + with os.scandir(walPath) as items: + for item in items: + if item.is_file(): + fileName, fileExt = os.path.splitext(item.name) + pathFile = os.path.join(walPath, item) + if fileExt == ".log": + self.walFiles.append(WalFile(pathFile, fileName)) + elif fileExt == "": + if fileName[:8] == "meta-ver": + metaFile = pathFile + # load config + tdLog.info(f' meta-ver file={metaFile}') + if metaFile != "": + jsonVer = jsonFromFile(metaFile) + metaNode = jsonVer["meta"] + self.snapVer = int(metaNode["snapshotVer"]) + self.firstVer = int(metaNode["firstVer"]) + self.lastVer = int(metaNode["lastVer"]) + + # sort with startVer + self.walFiles = sorted(self.walFiles, key=lambda x : x.startVer, reverse=True) + # set endVer + startVer = -1 + for walFile in self.walFiles: + if startVer == -1: + startVer = walFile.startVer + continue + walFile.endVer = startVer - 1 + startVer = walFile.startVer + + # print total + tdLog.info(f" ---- dnode{self.dnodeId} snapVer={self.snapVer} firstVer={self.firstVer} lastVer={self.lastVer} {self.path} --------") + for walFile in self.walFiles: + mt = datetime.fromtimestamp(walFile.mtime) + tdLog.info(f" {walFile.pathFile} {mt} startVer={walFile.startVer} endVer={walFile.endVer}") + + # snapVer compare + def canDelete(self, walFile): + if walFile.endVer == -1: + # end file + return False + + # check snapVer + ret = False + if self.snapVer > walFile.endVer: + ret = True + + # check stayRange + if self.lastVer != -1 and ret: + # first wal file ignore + if walFile.startVer == self.firstVer: + tdLog.info(f" {walFile.pathFile} can del, but is first. snapVer={self.snapVer} firstVer={self.firstVer}") + return False + + # ver in stay range + smallVer = self.snapVer - self.walStayRange -1 + if walFile.startVer >= smallVer: + tdLog.info(f" {walFile.pathFile} can del, but range not arrived. snapVer={self.snapVer} smallVer={smallVer}") + return False + + return ret + + # get log size + def getWalsSize(self): + size = 0 + for walFile in self.walFiles: + size += walFile.fsize + + return size + + # vnode + def check_retention(self): + # + # check period + # + delta = self.walPeriod + if self.walPeriod == 0: + delta += 1 * 60 # delete after 1 minutes + elif self.walPeriod < 3600: + delta += 3 * 60 # 5 minutes + else: + delta += 5 * 60 # 10 minutes + + delTsLine = datetime.now() - timedelta(seconds = delta) + delTs = delTsLine.timestamp() + for walFile in self.walFiles: + mt = datetime.fromtimestamp(walFile.mtime) + info = f" {walFile.pathFile} mt={mt} line={delTsLine} start={walFile.startVer} snap={self.snapVer} end= {walFile.endVer}" + tdLog.info(info) + if walFile.mtime < delTs and self.canDelete(walFile): + # wait a moment then check file exist + time.sleep(1) + if os.path.exists(walFile.pathFile): + #report error + tdLog.exit(f" wal file expired need delete. \n {walFile.pathFile} \n modify time={mt} \n delTsLine={delTsLine}\n start={walFile.startVer} snap={self.snapVer} end= {walFile.endVer}") + return False + + # + # check size + # + if self.walSize == 0: + return True + + vnodeSize = self.getWalsSize() + if vnodeSize < self.walSize: + tdLog.info(f" wal size valid. {self.path} real = {vnodeSize} set = {self.walSize} ") + return True + + # check valid + tdLog.info(f" wal size over set. {self.path} real = {vnodeSize} set = {self.walSize} ") + for walFile in self.walFiles: + if self.canDelete(walFile): + # wait a moment then check file exist + time.sleep(1) + if os.path.exists(walFile.pathFile): + tdLog.exit(f" wal file size over .\ + \n wal file = {walFile.pathFile}\ + \n snapVer = {self.snapVer}\ + \n real = {vnodeSize} bytes\ + \n set = {self.walSize} bytes") + return False + return True + + +# insert by async +def thread_insert(testCase, tbname, rows): + print(f"start thread... {tbname} - {rows} \n") + new_conn = testCase.new_connect() + testCase.insert_data(tbname, rows, new_conn) + new_conn.close() + print("end thread\n") + +# case +class TDTestCase: + def init(self, conn, logSql, replicaVar=1): + self.ts = 1670000000000 + self.replicaVar = int(replicaVar) + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor()) + self.setsql = TDSetSql() + self.conn = conn + + # init cluster path + selfPath = os.path.dirname(os.path.realpath(__file__)) + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + self.projDir = f"{projPath}sim/" + tdLog.info(f" init projPath={self.projDir}") + + 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': 'varchar(120)', + 'col13': 'nchar(100)', + } + self.tag_dict = { + 't1': 'tinyint', + 't2': 'smallint', + 't3': 'int', + 't4': 'bigint', + 't5': 'tinyint unsigned', + 't6': 'smallint unsigned', + 't7': 'int unsigned', + 't8': 'bigint unsigned', + 't9': 'float', + 't10': 'double', + 't11': 'bool', + 't12': 'varchar(120)', + 't13': 'nchar(100)', + } + + # malloc new connect + def new_connect(self): + return taos.connect(host = self.conn._host, + user = self.conn._user, + password = self.conn._password, + database = self.dbname, + port = self.conn._port, + config = self.conn._config) + + def set_stb_sql(self,stbname,column_dict,tag_dict): + 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 stable {stbname} ({column_sql[:-2]}) tags ({tag_sql[:-2]})' + return create_stb_sql + + def create_database(self, dbname, wal_period, wal_size_kb, vgroups): + self.wal_period = wal_period + self.wal_size = wal_size_kb * 1024 + self.vgroups = vgroups + self.dbname = dbname + tdSql.execute(f"create database {dbname} wal_retention_period {wal_period} wal_retention_size {wal_size_kb} vgroups {vgroups} replica 3") + tdSql.execute(f'use {dbname}') + + # create stable and child tables + def create_table(self, stbname, tbname, count): + self.child_count = count + self.stbname = stbname + self.tbname = tbname + + # create stable + create_table_sql = self.set_stb_sql(stbname, self.column_dict, self.tag_dict) + tdSql.execute(create_table_sql) + + batch_size = 1000 + # create child table + for i in range(count): + ti = i % 128 + tags = f'{ti},{ti},{i},{i},{ti},{ti},{i},{i},{i}.000{i},{i}.000{i},true,"var{i}","nch{i}"' + sql = f'create table {tbname}{i} using {stbname} tags({tags});' + tdSql.execute(sql) + if i % batch_size == 0: + tdLog.info(f" create child table {i} ...") + + tdLog.info(f" create {count} child tables ok.") + + + # insert to child table d1 data + def insert_data(self, tbname, insertTime): + start = time.time() + values = "" + child_name = "" + cnt = 0 + rows = 10000000000 + for j in range(rows): + for i in range(self.child_count): + tj = j % 128 + cols = f'{tj},{tj},{j},{j},{tj},{tj},{j},{j},{j}.000{j},{j}.000{j},true,"var{j}","nch{j}涛思数据codepage is utf_32_le"' + sql = f'insert into {tbname}{i} values ({self.ts},{cols});' + tdSql.execute(sql) + self.ts += 1 + #tdLog.info(f" child table={i} rows={j} insert data.") + cost = time.time() - start + if j % 100 == 0: + tdSql.execute(f"flush database {self.dbname}") + tdLog.info(" insert row cost time = %ds rows = %d"%(cost, j)) + self.consume_topic("topic1", 5) + + if cost > insertTime and j > 100: + tdLog.info(" insert finished. cost time = %ds rows = %d"%(cost, j)) + return + + # create tmq + def create_tmq(self): + sql = f"create topic topic1 as select ts, col1, concat(col12,t12) from {self.stbname};" + tdSql.execute(sql) + sql = f"create topic topic2 as select * from {self.stbname};" + tdSql.execute(sql) + #tdLog.info(sql) + + def check_retention(self, walStayRange): + # flash database + tdSql.execute(f"flush database {self.dbname}") + time.sleep(0.5) + + vnodes = [] + # put all vnode to list + for dnode in os.listdir(self.projDir): + vnodeDir = self.projDir + f"{dnode}/data/vnode/" + print(f"vnodeDir={vnodeDir}") + if os.path.isdir(vnodeDir) == False or dnode[:5] != "dnode": + continue + # enum all vnode + for entry in os.listdir(vnodeDir): + entryPath = path.join(vnodeDir, entry) + + if os.path.isdir(entryPath): + if path.exists(path.join(entryPath, "vnode.json")): + vnode = VNode(int(dnode[5:]), entryPath, self.wal_period, self.wal_size, walStayRange) + vnodes.append(vnode) + + # do check + for vnode in vnodes: + vnode.check_retention() + + # consume topic + def consume_topic(self, topic_name, consume_cnt): + print("start consume...") + consumer = Consumer( + { + "group.id": "tg2", + "td.connect.user": "root", + "td.connect.pass": "taosdata", + "enable.auto.commit": "true", + } + ) + print("start subscrite...") + consumer.subscribe([topic_name]) + + cnt = 0 + try: + while True and cnt < consume_cnt: + res = consumer.poll(1) + if not res: + break + err = res.error() + if err is not None: + raise err + val = res.value() + cnt += 1 + print(f" consume {cnt} ") + for block in val: + print(block.fetchall()) + finally: + consumer.unsubscribe() + consumer.close() + + + # test db1 + def test_db(self, dbname, checkTime ,wal_period, wal_size_kb): + # var + stable = "meters" + tbname = "d" + vgroups = 6 + count = 10 + + # do + self.create_database(dbname, wal_period, wal_size_kb, vgroups) + self.create_table(stable, tbname, count) + + # create tmq + self.create_tmq() + + # insert data + self.insert_data(tbname, checkTime) + + #stopInsert = False + #tobj = threading.Thread(target = thread_insert, args=(self, tbname, rows)) + #tobj.start() + + # check retention + tdLog.info(f" -------------- do check retention ---------------") + self.check_retention(walStayRange = 256) + + + # stop insert and wait exit + tdLog.info(f" {dbname} stop insert ...") + tdLog.info(f" {dbname} test_db end.") + + + # run + def run(self): + # period + #self.test_db("db1", 10, 60, 0) + # size + #self.test_db("db2", 5, 10*24*3600, 2*1024) # 2M size + + # period + size + self.test_db("db", checkTime = 5*60, wal_period = 60, wal_size_kb=10) + #self.test_db("db", checkTime = 3*60, wal_period = 0, wal_size_kb=0) + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/1-insert/drop.py b/tests/system-test/1-insert/drop.py index a8bfea27415a2b89d230e14d95d2c8a2871ade29..9954b3557e23df193a4c4f84c819fc508c39f5bb 100644 --- a/tests/system-test/1-insert/drop.py +++ b/tests/system-test/1-insert/drop.py @@ -54,7 +54,7 @@ class TDTestCase: insert_list = [] self.setsql.insert_values(column_dict,i,insert_sql,insert_list,self.ts) def drop_ntb_check(self): - tdSql.execute(f'create database if not exists {self.dbname} replica {self.replicaVar}') + tdSql.execute(f'create database if not exists {self.dbname} replica {self.replicaVar} wal_retention_period 3600') tdSql.execute(f'use {self.dbname}') tdSql.execute(self.setsql.set_create_normaltable_sql(self.ntbname,self.column_dict)) self.insert_data(self.column_dict,self.ntbname,self.rowNum) @@ -80,7 +80,7 @@ class TDTestCase: tag_values = [ f'1' ] - tdSql.execute(f"create database if not exists {self.dbname} replica {self.replicaVar}") + tdSql.execute(f"create database if not exists {self.dbname} replica {self.replicaVar} wal_retention_period 3600") tdSql.execute(f'use {self.dbname}') tdSql.execute(self.setsql.set_create_stable_sql(stbname,self.column_dict,tag_dict)) for i in range(self.tbnum): @@ -116,7 +116,7 @@ class TDTestCase: tdSql.checkRows(self.tbnum) tdSql.execute(f'drop database {self.dbname}') def drop_topic_check(self): - tdSql.execute(f'create database {self.dbname} replica {self.replicaVar}') + tdSql.execute(f'create database {self.dbname} replica {self.replicaVar} wal_retention_period 3600') tdSql.execute(f'use {self.dbname}') stbname = tdCom.getLongName(5,"letters") topic_name = tdCom.getLongName(5,"letters") @@ -132,7 +132,7 @@ class TDTestCase: tdSql.execute(f'drop database {self.dbname}') def drop_stream_check(self): - tdSql.execute(f'create database {self.dbname} replica 1') + tdSql.execute(f'create database {self.dbname} replica 1 wal_retention_period 3600') tdSql.execute(f'use {self.dbname}') stbname = tdCom.getLongName(5,"letters") stream_name = tdCom.getLongName(5,"letters") diff --git a/tests/system-test/1-insert/insert_wide_column.py b/tests/system-test/1-insert/insert_wide_column.py new file mode 100644 index 0000000000000000000000000000000000000000..e383675a41dbc63c320f58fe9fe60938f81c5a84 --- /dev/null +++ b/tests/system-test/1-insert/insert_wide_column.py @@ -0,0 +1,87 @@ +################################################################### +# 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 -*- + +import sys +import threading +import random +import string +import time + +from util.log import * +from util.cases import * +from util.sql import * +from util.autogen import * + + +# +# Test Main class +# + +class TDTestCase: + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + self.autoGen = AutoGen() + + def query_test(self, stbname): + sql = f"select count(*) from {stbname}" + tdSql.execute(sql) + sql = f"select * from {stbname} order by ts desc;" + tdSql.execute(sql) + sql = f"select * from (select * from {stbname} where c1=c2 or c3=c4 or c5=c6) order by ts desc;" + tdSql.execute(sql) + + tdLog.info(" test query ok!") + + + def test_db(self, dbname, stbname, childname, tag_cnt, column_cnt, child_cnt, insert_rows, binary_len, nchar_len): + self.autoGen.create_db(dbname) + self.autoGen.create_stable(stbname, tag_cnt, column_cnt, binary_len, nchar_len) + self.autoGen.create_child(stbname, childname, child_cnt) + self.autoGen.insert_data(insert_rows) + self.autoGen.insert_samets(insert_rows) + self.query_test(stbname) + + def run(self): + dbname = "test" + stbname = "st" + childname = "d" + child_cnt = 2 + insert_rows = 10 + tag_cnt = 15 + column_cnt = 20 + binary_len = 10240 + nchar_len = 1025 + self.autoGen.set_batch_size(1) + + # normal + self.test_db(dbname, stbname, childname, tag_cnt, column_cnt, child_cnt, insert_rows, binary_len, nchar_len) + + # max + dbname = "test_max_col" + child_cnt = 3 + insert_rows = 50 + tag_cnt = 128 + binary_len = 3 + nchar_len = 4 + column_cnt = 4096 - tag_cnt + self.autoGen.set_batch_size(1) + self.test_db(dbname, stbname, childname, tag_cnt, column_cnt, child_cnt, insert_rows, binary_len, nchar_len) + + 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/Today.py b/tests/system-test/2-query/Today.py index 08f6ba6bafa8029a20ef3b5e80fc6e9e90ea68b7..77e6bd8cb6dfe94eaaeeb6c455a3a8e6784784bc 100644 --- a/tests/system-test/2-query/Today.py +++ b/tests/system-test/2-query/Today.py @@ -16,6 +16,7 @@ class TDTestCase: tdSql.init(conn.cursor()) self.today_date = datetime.datetime.strptime(datetime.datetime.now().strftime("%Y-%m-%d"), "%Y-%m-%d") self.today_ts = datetime.datetime.strptime(datetime.datetime.now().strftime("%Y-%m-%d"), "%Y-%m-%d").timestamp() + self.today_ts_ns = 0 self.time_unit = ['b','u','a','s','m','h','d','w'] self.error_param = ['1.5','abc','!@#','"abc"','today()'] self.arithmetic_operators = ['+','-','*','/'] @@ -74,8 +75,10 @@ class TDTestCase: num_same = 0 if v.lower() == 'timestamp': tdSql.query(f'select {k} from {tbname}') + for i in tdSql.queryResult: if precision == 'ms': + self.today_ts_trans = int(self.today_ts)*1000 if int(i[0].timestamp())*1000 > int(self.today_ts)*1000: num_up += 1 elif int(i[0].timestamp())*1000 == int(self.today_ts)*1000: @@ -83,6 +86,7 @@ class TDTestCase: elif int(i[0].timestamp())*1000 < int(self.today_ts)*1000: num_down += 1 elif precision == 'us': + self.today_ts_trans = int(self.today_ts)*1000000 if int(i[0].timestamp())*1000000 > int(self.today_ts)*1000000: num_up += 1 elif int(i[0].timestamp())*1000000 == int(self.today_ts)*1000000: @@ -90,6 +94,7 @@ class TDTestCase: elif int(i[0].timestamp())*1000000 < int(self.today_ts)*1000000: num_down += 1 elif precision == 'ns': + self.today_ts_trans = int(self.today_ts)*1000000000 if i[0] > int(self.today_ts)*1000000000: num_up += 1 elif i[0] == int(self.today_ts)*1000000000: @@ -97,8 +102,9 @@ class TDTestCase: elif i[0] < int(self.today_ts)*1000000000: num_down += 1 tdSql.query(f"select today() from {tbname}") - tdSql.checkRows(len(values_list)*tb_num) - tdSql.checkData(0, 0, str(self.today_date)) + tdSql.checkRows(len(values_list)*tb_num) + print(self.today_ts_trans,self.today_ts,precision,num_up,num_down,i[0]) + tdSql.checkData(0, 0, self.today_ts_trans) tdSql.query(f"select * from {tbname} where {k}=today()") if tb == 'tb': tdSql.checkRows(num_same*tb_num) @@ -149,11 +155,12 @@ class TDTestCase: if tb == 'tb': tdSql.checkRows(num_same*tb_num) for i in range(num_same*tb_num): - tdSql.checkData(i, 0, str(self.today_date)) + print(self.today_ts_trans,precision,num_up,num_down) + tdSql.checkData(i, 0, self.today_ts_trans) elif tb == 'stb': tdSql.checkRows(num_same) for i in range(num_same): - tdSql.checkData(i, 0, str(self.today_date)) + tdSql.checkData(i, 0, self.today_ts_trans) def today_check_ntb(self): for time_unit in self.db_percision: diff --git a/tests/system-test/2-query/cast.py b/tests/system-test/2-query/cast.py index 2cc7e6a447da2901e6b818c2f9b50195438ce1d5..ede1f28324dd768a40d7ae98d140c40570e7bb88 100644 --- a/tests/system-test/2-query/cast.py +++ b/tests/system-test/2-query/cast.py @@ -38,11 +38,8 @@ class TDTestCase: if data_tb_col[i] is None: tdSql.checkData( i, 0 , None ) if col_name not in ["c2", "double"] or tbname != f"{self.dbname}.t1" or i != 10: - utc_zone = datetime.timezone.utc - utc_8 = datetime.timezone(datetime.timedelta(hours=8)) - date_init_stamp = datetime.datetime.utcfromtimestamp(data_tb_col[i]/1000) - date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f") - tdSql.checkData( i, 0, date_data) + date_init_stamp = datetime.datetime.fromtimestamp(data_tb_col[i]/1000) + tdSql.checkData( i, 0, date_init_stamp) def __range_to_timestamp(self, cols, tables): for col in cols: @@ -60,12 +57,11 @@ class TDTestCase: self.__range_to_timestamp(cols=__col_list, tables=__table_list) def all_test(self): - + _datetime_epoch = datetime.datetime.fromtimestamp(0) tdSql.query(f"select c1 from {self.dbname}.ct4") data_ct4_c1 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)] tdSql.query(f"select c1 from {self.dbname}.t1") data_t1_c1 = [tdSql.getData(i,0) for i in range(tdSql.queryRows)] - tdLog.printNoPrefix("==========step2: cast int to bigint, expect no changes") tdSql.query(f"select cast(c1 as bigint) as b from {self.dbname}.ct4") @@ -100,22 +96,16 @@ class TDTestCase: if data_ct4_c1[i] is None: tdSql.checkData( i, 0 , None ) else: - utc_zone = datetime.timezone.utc - utc_8 = datetime.timezone(datetime.timedelta(hours=8)) - date_init_stamp = datetime.datetime.utcfromtimestamp(data_ct4_c1[i]/1000) - date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f") - tdSql.checkData( i, 0, date_data) + date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_ct4_c1[i]) / 1000.0) + tdSql.checkData( i, 0, date_init_stamp) tdSql.query(f"select cast(c1 as timestamp) as b from {self.dbname}.t1") for i in range(len(data_t1_c1)): - if data_ct4_c1[i] is None: + if data_t1_c1[i] is None: tdSql.checkData( i, 0 , None ) else: - utc_zone = datetime.timezone.utc - utc_8 = datetime.timezone(datetime.timedelta(hours=8)) - date_init_stamp = datetime.datetime.utcfromtimestamp(data_ct4_c1[i]/1000) - date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f") - tdSql.checkData( i, 0, date_data) + date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_t1_c1[i]) / 1000.0) + tdSql.checkData( i, 0, date_init_stamp) tdLog.printNoPrefix("==========step8: cast bigint to bigint, expect no changes") @@ -157,11 +147,8 @@ class TDTestCase: if data_ct4_c2[i] is None: tdSql.checkData( i, 0 , None ) else: - utc_zone = datetime.timezone.utc - utc_8 = datetime.timezone(datetime.timedelta(hours=8)) - date_init_stamp = datetime.datetime.utcfromtimestamp(data_ct4_c2[i]/1000) - date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f") - tdSql.checkData( i, 0, date_data) + date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_ct4_c2[i]) / 1000.0) + tdSql.checkData( i, 0, date_init_stamp) tdSql.query(f"select cast(c2 as timestamp) as b from {self.dbname}.t1") @@ -171,11 +158,8 @@ class TDTestCase: elif i == 10: continue else: - utc_zone = datetime.timezone.utc - utc_8 = datetime.timezone(datetime.timedelta(hours=8)) - date_init_stamp = datetime.datetime.utcfromtimestamp(data_t1_c2[i]/1000) - date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f") - tdSql.checkData( i, 0, date_data) + date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_t1_c2[i]) / 1000.0) + tdSql.checkData( i, 0, date_init_stamp) tdLog.printNoPrefix("==========step12: cast smallint to bigint, expect no changes") @@ -217,22 +201,16 @@ class TDTestCase: if data_ct4_c3[i] is None: tdSql.checkData( i, 0 , None ) else: - utc_zone = datetime.timezone.utc - utc_8 = datetime.timezone(datetime.timedelta(hours=8)) - date_init_stamp = datetime.datetime.utcfromtimestamp(data_ct4_c3[i]/1000) - date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f") - tdSql.checkData( i, 0, date_data) + date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_ct4_c3[i]) / 1000.0) + tdSql.checkData( i, 0, date_init_stamp) tdSql.query(f"select cast(c3 as timestamp) as b from {self.dbname}.t1") for i in range(len(data_t1_c3)): - if data_ct4_c3[i] is None: + if data_t1_c3[i] is None: tdSql.checkData( i, 0 , None ) else: - utc_zone = datetime.timezone.utc - utc_8 = datetime.timezone(datetime.timedelta(hours=8)) - date_init_stamp = datetime.datetime.utcfromtimestamp(data_ct4_c3[i]/1000) - date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f") - tdSql.checkData( i, 0, date_data) + date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_t1_c3[i]) / 1000.0) + tdSql.checkData( i, 0, date_init_stamp) tdLog.printNoPrefix("==========step16: cast tinyint to bigint, expect no changes") @@ -274,22 +252,16 @@ class TDTestCase: if data_ct4_c4[i] is None: tdSql.checkData( i, 0 , None ) else: - utc_zone = datetime.timezone.utc - utc_8 = datetime.timezone(datetime.timedelta(hours=8)) - date_init_stamp = datetime.datetime.utcfromtimestamp(data_ct4_c4[i]/1000) - date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f") - tdSql.checkData( i, 0, date_data) + date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_ct4_c4[i]) / 1000.0) + tdSql.checkData( i, 0, date_init_stamp) tdSql.query(f"select cast(c4 as timestamp) as b from {self.dbname}.t1") for i in range(len(data_t1_c4)): - if data_ct4_c4[i] is None: + if data_t1_c4[i] is None: tdSql.checkData( i, 0 , None ) else: - utc_zone = datetime.timezone.utc - utc_8 = datetime.timezone(datetime.timedelta(hours=8)) - date_init_stamp = datetime.datetime.utcfromtimestamp(data_ct4_c4[i]/1000) - date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f") - tdSql.checkData( i, 0, date_data) + date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_t1_c4[i]) / 1000.0) + tdSql.checkData( i, 0, date_init_stamp) tdLog.printNoPrefix("==========step20: cast float to bigint, expect no changes") @@ -327,21 +299,15 @@ class TDTestCase: if data_ct4_c5[i] is None: tdSql.checkData( i, 0 , None ) else: - utc_zone = datetime.timezone.utc - utc_8 = datetime.timezone(datetime.timedelta(hours=8)) - date_init_stamp = datetime.datetime.utcfromtimestamp(int(data_ct4_c5[i]/1000)) - date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f") - tdSql.checkData( i, 0, date_data) + date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_ct4_c5[i]) / 1000.0) + tdSql.checkData( i, 0, date_init_stamp) tdSql.query(f"select cast(c5 as timestamp) as b from {self.dbname}.t1") for i in range(len(data_t1_c5)): if data_t1_c5[i] is None: tdSql.checkData( i, 0 , None ) else: - utc_zone = datetime.timezone.utc - utc_8 = datetime.timezone(datetime.timedelta(hours=8)) - date_init_stamp = datetime.datetime.utcfromtimestamp(int(data_t1_c5[i]/1000)) - date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f") - tdSql.checkData( i, 0, date_data) + date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_t1_c5[i]) / 1000.0) + tdSql.checkData( i, 0, date_init_stamp) tdLog.printNoPrefix("==========step24: cast double to bigint, expect no changes") tdSql.query(f"select c6 from {self.dbname}.ct4") @@ -383,11 +349,8 @@ class TDTestCase: if data_ct4_c6[i] is None: tdSql.checkData( i, 0 , None ) else: - utc_zone = datetime.timezone.utc - utc_8 = datetime.timezone(datetime.timedelta(hours=8)) - date_init_stamp = datetime.datetime.utcfromtimestamp(int(data_ct4_c6[i]/1000)) - date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f") - tdSql.checkData( i, 0, date_data) + date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_ct4_c6[i]) / 1000.0) + tdSql.checkData( i, 0, date_init_stamp) tdSql.query(f"select cast(c6 as timestamp) as b from {self.dbname}.t1") for i in range(len(data_t1_c6)): @@ -396,11 +359,8 @@ class TDTestCase: elif i == 10: continue else: - utc_zone = datetime.timezone.utc - utc_8 = datetime.timezone(datetime.timedelta(hours=8)) - date_init_stamp = datetime.datetime.utcfromtimestamp(int(data_t1_c6[i]/1000)) - date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f") - tdSql.checkData( i, 0, date_data) + date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_t1_c6[i]) / 1000.0) + tdSql.checkData( i, 0, date_init_stamp) tdLog.printNoPrefix("==========step28: cast bool to bigint, expect no changes") tdSql.query(f"select c7 from {self.dbname}.ct4") @@ -437,21 +397,15 @@ class TDTestCase: if data_ct4_c7[i] is None: tdSql.checkData( i, 0 , None ) else: - utc_zone = datetime.timezone.utc - utc_8 = datetime.timezone(datetime.timedelta(hours=8)) - date_init_stamp = datetime.datetime.utcfromtimestamp(int(data_ct4_c7[i]/1000)) - date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f") - tdSql.checkData( i, 0, date_data) + date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_ct4_c7[i]) / 1000.0) + tdSql.checkData( i, 0, date_init_stamp) tdSql.query(f"select cast(c7 as timestamp) as b from {self.dbname}.t1") for i in range(len(data_t1_c7)): if data_t1_c7[i] is None: tdSql.checkData( i, 0 , None ) else: - utc_zone = datetime.timezone.utc - utc_8 = datetime.timezone(datetime.timedelta(hours=8)) - date_init_stamp = datetime.datetime.utcfromtimestamp(int(data_t1_c7[i]/1000)) - date_data = date_init_stamp.replace(tzinfo=utc_zone).astimezone(utc_8).strftime("%Y-%m-%d %H:%M:%S.%f") - tdSql.checkData( i, 0, date_data) + date_init_stamp = _datetime_epoch+datetime.timedelta(seconds=int(data_t1_c7[i]) / 1000.0) + tdSql.checkData( i, 0, date_init_stamp) tdSql.query(f"select c8 from {self.dbname}.ct4") @@ -695,7 +649,7 @@ class TDTestCase: tdSql.query(f"select cast('123' as tinyint unsigned) as b from {self.dbname}.stb1 partition by tbname") # uion with cast and common cols - + tdSql.query(f"select cast(c2 as int) as b from {self.dbname}.stb1 union all select c1 from {self.dbname}.stb1 ") tdSql.query(f"select cast(c3 as bool) as b from {self.dbname}.stb1 union all select c7 from {self.dbname}.ct1 ") tdSql.query(f"select cast(c4 as tinyint) as b from {self.dbname}.stb1 union all select c4 from {self.dbname}.stb1") diff --git a/tests/system-test/2-query/columnLenUpdated.py b/tests/system-test/2-query/columnLenUpdated.py new file mode 100644 index 0000000000000000000000000000000000000000..e43b32a716017702382ce0384bb377d692e64684 --- /dev/null +++ b/tests/system-test/2-query/columnLenUpdated.py @@ -0,0 +1,215 @@ + +import taos +import sys +import time +import socket +import os +import platform +if platform.system().lower() == 'windows': + import wexpect as taosExpect +else: + import pexpect as taosExpect + +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * + +def taos_command (buildPath, key, value, expectString, sqlString=''): + if len(key) == 0: + tdLog.exit("taos test key is null!") + + if platform.system().lower() == 'windows': + taosCmd = buildPath + '\\build\\bin\\taos.exe ' + taosCmd = taosCmd.replace('\\','\\\\') + else: + taosCmd = buildPath + '/build/bin/taos ' + + cfgPath = buildPath + "/../sim/psim/cfg" + taosCmd = taosCmd + ' -c' + cfgPath + ' -' + key + if len(value) != 0: + taosCmd = taosCmd + ' ' + value + + tdLog.info ("taos cmd: %s" % taosCmd) + + child = taosExpect.spawn(taosCmd, timeout=20) + #output = child.readline() + #print (output.decode()) + if len(expectString) != 0: + i = child.expect([expectString, taosExpect.TIMEOUT, taosExpect.EOF], timeout=20) + else: + i = child.expect([taosExpect.TIMEOUT, taosExpect.EOF], timeout=20) + + if platform.system().lower() == 'windows': + retResult = child.before + else: + retResult = child.before.decode() + print(retResult) + #print(child.after.decode()) + if i == 0: + print ('taos login success! Here can run sql, taos> ') + return "TAOS_OK" + else: + return "TAOS_FAIL" + +class TDTestCase: + #updatecfgDict = {'clientCfg': {'serverPort': 7080, 'firstEp': 'trd02:7080', 'secondEp':'trd02:7080'},\ + # 'serverPort': 7080, 'firstEp': 'trd02:7080'} + hostname = socket.gethostname() + if (platform.system().lower() == 'windows' and not tdDnodes.dnodes[0].remoteIP == ""): + try: + config = eval(tdDnodes.dnodes[0].remoteIP) + hostname = config["host"] + except Exception: + hostname = tdDnodes.dnodes[0].remoteIP + serverPort = '7080' + rpcDebugFlagVal = '143' + clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''} + clientCfgDict["serverPort"] = serverPort + clientCfgDict["firstEp"] = hostname + ':' + serverPort + clientCfgDict["secondEp"] = hostname + ':' + serverPort + clientCfgDict["rpcDebugFlag"] = rpcDebugFlagVal + clientCfgDict["fqdn"] = hostname + + updatecfgDict = {'clientCfg': {}, 'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''} + updatecfgDict["clientCfg"] = clientCfgDict + updatecfgDict["serverPort"] = serverPort + updatecfgDict["firstEp"] = hostname + ':' + serverPort + updatecfgDict["secondEp"] = hostname + ':' + serverPort + updatecfgDict["fqdn"] = hostname + + print ("===================: ", updatecfgDict) + + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), True) + + def getBuildPath(self): + selfPath = os.path.dirname(os.path.realpath(__file__)) + + if ("community" in selfPath): + projPath = selfPath[:selfPath.find("community")] + else: + projPath = selfPath[:selfPath.find("tests")] + + for root, dirs, files in os.walk(projPath): + if ("taosd" in files or "taosd.exe" in files): + rootRealPath = os.path.dirname(os.path.realpath(root)) + if ("packaging" not in rootRealPath): + buildPath = root[:len(root) - len("/build/bin")] + break + return buildPath + + def run(self): # sourcery skip: extract-duplicate-method, remove-redundant-fstring + tdSql.prepare() + # time.sleep(2) + tdSql.query("create user testpy pass 'testpy'") + + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + cfgPath = buildPath + "/../sim/psim/cfg" + tdLog.info("cfgPath: %s" % cfgPath) + + checkNetworkStatus = ['0: unavailable', '1: network ok', '2: service ok', '3: service degraded', '4: exiting'] + netrole = ['client', 'server'] + + keyDict = {'h':'', 'P':'6030', 'p':'testpy', 'u':'testpy', 'a':'', 'A':'', 'c':'', 'C':'', 's':'', 'r':'', 'f':'', \ + 'k':'', 't':'', 'n':'', 'l':'1024', 'N':'100', 'V':'', 'd':'db', 'w':'30', '-help':'', '-usage':'', '?':''} + + keyDict['h'] = self.hostname + keyDict['c'] = cfgPath + keyDict['P'] = self.serverPort + + tdSql.query("drop database if exists db1") + tdSql.query("create database if not exists db1 vgroups 1") + tdSql.query("use db1") + tdSql.query("create table tba (ts timestamp, f1 binary(2))") + tdSql.query("insert into tba values (now, '22')") + tdSql.query("select * from tba") + tdSql.checkData(0, 1, '22') + + keyDict['s'] = "\"alter table db1.tba modify column f1 binary(5) \"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + keyDict['s'] = "\"insert into db1.tba values (now, '55555')\"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Insert OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + tdSql.query("select * from tba order by ts") + tdSql.checkData(0, 1, '22') + tdSql.checkData(1, 1, '55555') + + + + keyDict['s'] = "\"alter table db1.tba add column f2 binary(5) \"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + tdSql.query("select * from tba order by ts") + tdSql.query("select * from tba order by ts") + tdSql.checkData(0, 2, None) + tdSql.checkData(1, 2, None) + + + + + keyDict['s'] = "\"alter table db1.tba add column f3 binary(5) \"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + tdSql.query("select f3 from tba order by ts") + tdSql.checkData(0, 0, None) + tdSql.checkData(1, 0, None) + + + tdSql.query("create table stb (ts timestamp, f1 int, f2 binary(2)) tags (tg1 binary(2))") + tdSql.query("create table tb1 using stb tags('bb')") + tdSql.query("insert into tb1 values (now, 2,'22')") + tdSql.query("select count(*) from stb group by tg1") + tdSql.checkData(0, 0, 1) + + keyDict['s'] = "\"alter table db1.stb modify tag tg1 binary(5) \"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + keyDict['s'] = "\"create table db1.tb2 using db1.stb tags('bbbbb')\"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Create OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + keyDict['s'] = "\"insert into db1.tb2 values (now, 2,'22')\"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Insert OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + keyDict['s'] = "\"alter table db1.stb modify column f2 binary(5) \"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Query OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + keyDict['s'] = "\"insert into db1.tb2 values (now, 3,'55555')\"" + retCode = taos_command(buildPath, "s", keyDict['s'], "Insert OK", '') + if retCode != "TAOS_OK": + tdLog.exit("taos -s fail") + + tdSql.query("select count(*) from stb group by tg1") + tdSql.checkData(0, 0, 2) + tdSql.checkData(1, 0, 1) + + + 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/interp.py b/tests/system-test/2-query/interp.py index d7344c631f5a150d3b9bac907b263bb2d41ec91e..51d907b13aac767eda077b1e39c17bf32e8bb7bf 100644 --- a/tests/system-test/2-query/interp.py +++ b/tests/system-test/2-query/interp.py @@ -19,6 +19,7 @@ class TDTestCase: dbname = "db" tbname = "tb" tbname1 = "tb1" + tbname2 = "tb2" stbname = "stb" ctbname1 = "ctb1" ctbname2 = "ctb2" @@ -1948,6 +1949,7 @@ class TDTestCase: tdSql.checkData(59, 1, 60) tdSql.checkData(60, 1, 60) # + tdLog.printNoPrefix("==========step11:test multi-interp cases") tdSql.query(f"select interp(c0),interp(c1),interp(c2),interp(c3) from {dbname}.{tbname} range('2020-02-09 00:00:05', '2020-02-13 00:00:05') every(1d) fill(null)") tdSql.checkRows(5) @@ -2002,7 +2004,362 @@ class TDTestCase: for i in range (tdSql.queryCols): tdSql.checkData(0, i, 13) - tdLog.printNoPrefix("==========step12:test error cases") + tdLog.printNoPrefix("==========step12:test interp with boolean type") + tdSql.execute( + f'''create table if not exists {dbname}.{tbname2} + (ts timestamp, c0 bool) + ''' + ) + + + tdSql.execute(f"insert into {dbname}.{tbname2} values ('2020-02-02 00:00:01', false)") + tdSql.execute(f"insert into {dbname}.{tbname2} values ('2020-02-02 00:00:03', true)") + tdSql.execute(f"insert into {dbname}.{tbname2} values ('2020-02-02 00:00:05', false)") + tdSql.execute(f"insert into {dbname}.{tbname2} values ('2020-02-02 00:00:07', true)") + tdSql.execute(f"insert into {dbname}.{tbname2} values ('2020-02-02 00:00:09', true)") + tdSql.execute(f"insert into {dbname}.{tbname2} values ('2020-02-02 00:00:11', false)") + tdSql.execute(f"insert into {dbname}.{tbname2} values ('2020-02-02 00:00:13', false)") + tdSql.execute(f"insert into {dbname}.{tbname2} values ('2020-02-02 00:00:15', NULL)") + tdSql.execute(f"insert into {dbname}.{tbname2} values ('2020-02-02 00:00:17', NULL)") + + # test fill null + tdSql.query(f"select _irowts,_isfilled,interp(c0) from {dbname}.{tbname2} range('2020-02-02 00:00:00', '2020-02-02 00:00:18') every(1s) fill(NULL)") + tdSql.checkRows(19) + tdSql.checkCols(3) + + tdSql.checkData(0, 0, '2020-02-02 00:00:00.000') + + tdSql.checkData(0, 2, None) + tdSql.checkData(1, 2, False) + tdSql.checkData(2, 2, None) + tdSql.checkData(3, 2, True) + tdSql.checkData(4, 2, None) + tdSql.checkData(5, 2, False) + tdSql.checkData(6, 2, None) + tdSql.checkData(7, 2, True) + tdSql.checkData(8, 2, None) + tdSql.checkData(9, 2, True) + tdSql.checkData(10, 2, None) + tdSql.checkData(11, 2, False) + tdSql.checkData(12, 2, None) + tdSql.checkData(13, 2, False) + tdSql.checkData(14, 2, None) + tdSql.checkData(15, 2, None) + tdSql.checkData(16, 2, None) + tdSql.checkData(17, 2, None) + tdSql.checkData(18, 2, None) + + tdSql.checkData(18, 0, '2020-02-02 00:00:18.000') + + # test fill prev + tdSql.query(f"select _irowts,_isfilled,interp(c0) from {dbname}.{tbname2} range('2020-02-02 00:00:00', '2020-02-02 00:00:18') every(1s) fill(prev)") + tdSql.checkRows(18) + tdSql.checkCols(3) + + tdSql.checkData(0, 0, '2020-02-02 00:00:01.000') + + tdSql.checkData(0, 2, False) + tdSql.checkData(1, 2, False) + tdSql.checkData(2, 2, True) + tdSql.checkData(3, 2, True) + tdSql.checkData(4, 2, False) + tdSql.checkData(5, 2, False) + tdSql.checkData(6, 2, True) + tdSql.checkData(7, 2, True) + tdSql.checkData(8, 2, True) + tdSql.checkData(9, 2, True) + tdSql.checkData(10, 2, False) + tdSql.checkData(11, 2, False) + tdSql.checkData(12, 2, False) + tdSql.checkData(13, 2, False) + tdSql.checkData(14, 2, None) + tdSql.checkData(15, 2, None) + tdSql.checkData(16, 2, None) + tdSql.checkData(17, 2, None) + + tdSql.checkData(17, 0, '2020-02-02 00:00:18.000') + + # test fill next + tdSql.query(f"select _irowts,_isfilled,interp(c0) from {dbname}.{tbname2} range('2020-02-02 00:00:00', '2020-02-02 00:00:18') every(1s) fill(next)") + tdSql.checkRows(18) + tdSql.checkCols(3) + + tdSql.checkData(0, 0, '2020-02-02 00:00:00.000') + + tdSql.checkData(0, 2, False) + tdSql.checkData(1, 2, False) + tdSql.checkData(2, 2, True) + tdSql.checkData(3, 2, True) + tdSql.checkData(4, 2, False) + tdSql.checkData(5, 2, False) + tdSql.checkData(6, 2, True) + tdSql.checkData(7, 2, True) + tdSql.checkData(8, 2, True) + tdSql.checkData(9, 2, True) + tdSql.checkData(10, 2, False) + tdSql.checkData(11, 2, False) + tdSql.checkData(12, 2, False) + tdSql.checkData(13, 2, False) + tdSql.checkData(14, 2, None) + tdSql.checkData(15, 2, None) + tdSql.checkData(16, 2, None) + tdSql.checkData(17, 2, None) + + tdSql.checkData(17, 0, '2020-02-02 00:00:17.000') + + # test fill value + tdSql.query(f"select _irowts,_isfilled,interp(c0) from {dbname}.{tbname2} range('2020-02-02 00:00:00', '2020-02-02 00:00:18') every(1s) fill(value, 0)") + tdSql.checkRows(19) + tdSql.checkCols(3) + + tdSql.checkData(0, 0, '2020-02-02 00:00:00.000') + + tdSql.checkData(0, 2, False) + tdSql.checkData(1, 2, False) + tdSql.checkData(2, 2, False) + tdSql.checkData(3, 2, True) + tdSql.checkData(4, 2, False) + tdSql.checkData(5, 2, False) + tdSql.checkData(6, 2, False) + tdSql.checkData(7, 2, True) + tdSql.checkData(8, 2, False) + tdSql.checkData(9, 2, True) + tdSql.checkData(10, 2, False) + tdSql.checkData(11, 2, False) + tdSql.checkData(12, 2, False) + tdSql.checkData(13, 2, False) + tdSql.checkData(14, 2, False) + tdSql.checkData(15, 2, None) + tdSql.checkData(16, 2, False) + tdSql.checkData(17, 2, None) + tdSql.checkData(18, 2, False) + + tdSql.checkData(18, 0, '2020-02-02 00:00:18.000') + + tdSql.query(f"select _irowts,_isfilled,interp(c0) from {dbname}.{tbname2} range('2020-02-02 00:00:00', '2020-02-02 00:00:18') every(1s) fill(value, 1234)") + tdSql.checkRows(19) + tdSql.checkCols(3) + + tdSql.checkData(0, 0, '2020-02-02 00:00:00.000') + + tdSql.checkData(0, 2, True) + tdSql.checkData(1, 2, False) + tdSql.checkData(2, 2, True) + tdSql.checkData(3, 2, True) + tdSql.checkData(4, 2, True) + tdSql.checkData(5, 2, False) + tdSql.checkData(6, 2, True) + tdSql.checkData(7, 2, True) + tdSql.checkData(8, 2, True) + tdSql.checkData(9, 2, True) + tdSql.checkData(10, 2, True) + tdSql.checkData(11, 2, False) + tdSql.checkData(12, 2, True) + tdSql.checkData(13, 2, False) + tdSql.checkData(14, 2, True) + tdSql.checkData(15, 2, None) + tdSql.checkData(16, 2, True) + tdSql.checkData(17, 2, None) + tdSql.checkData(18, 2, True) + + tdSql.checkData(18, 0, '2020-02-02 00:00:18.000') + + tdSql.query(f"select _irowts,_isfilled,interp(c0) from {dbname}.{tbname2} range('2020-02-02 00:00:00', '2020-02-02 00:00:18') every(1s) fill(value, false)") + tdSql.checkRows(19) + tdSql.checkCols(3) + + tdSql.checkData(0, 0, '2020-02-02 00:00:00.000') + + tdSql.checkData(0, 2, False) + tdSql.checkData(1, 2, False) + tdSql.checkData(2, 2, False) + tdSql.checkData(3, 2, True) + tdSql.checkData(4, 2, False) + tdSql.checkData(5, 2, False) + tdSql.checkData(6, 2, False) + tdSql.checkData(7, 2, True) + tdSql.checkData(8, 2, False) + tdSql.checkData(9, 2, True) + tdSql.checkData(10, 2, False) + tdSql.checkData(11, 2, False) + tdSql.checkData(12, 2, False) + tdSql.checkData(13, 2, False) + tdSql.checkData(14, 2, False) + tdSql.checkData(15, 2, None) + tdSql.checkData(16, 2, False) + tdSql.checkData(17, 2, None) + tdSql.checkData(18, 2, False) + + tdSql.checkData(18, 0, '2020-02-02 00:00:18.000') + + tdSql.query(f"select _irowts,_isfilled,interp(c0) from {dbname}.{tbname2} range('2020-02-02 00:00:00', '2020-02-02 00:00:18') every(1s) fill(value, true)") + tdSql.checkRows(19) + tdSql.checkCols(3) + + tdSql.checkData(0, 0, '2020-02-02 00:00:00.000') + + tdSql.checkData(0, 2, True) + tdSql.checkData(1, 2, False) + tdSql.checkData(2, 2, True) + tdSql.checkData(3, 2, True) + tdSql.checkData(4, 2, True) + tdSql.checkData(5, 2, False) + tdSql.checkData(6, 2, True) + tdSql.checkData(7, 2, True) + tdSql.checkData(8, 2, True) + tdSql.checkData(9, 2, True) + tdSql.checkData(10, 2, True) + tdSql.checkData(11, 2, False) + tdSql.checkData(12, 2, True) + tdSql.checkData(13, 2, False) + tdSql.checkData(14, 2, True) + tdSql.checkData(15, 2, None) + tdSql.checkData(16, 2, True) + tdSql.checkData(17, 2, None) + tdSql.checkData(18, 2, True) + + tdSql.checkData(18, 0, '2020-02-02 00:00:18.000') + + tdSql.query(f"select _irowts,_isfilled,interp(c0) from {dbname}.{tbname2} range('2020-02-02 00:00:00', '2020-02-02 00:00:18') every(1s) fill(value, '0')") + tdSql.checkRows(19) + tdSql.checkCols(3) + + tdSql.checkData(0, 0, '2020-02-02 00:00:00.000') + + tdSql.checkData(0, 2, False) + tdSql.checkData(1, 2, False) + tdSql.checkData(2, 2, False) + tdSql.checkData(3, 2, True) + tdSql.checkData(4, 2, False) + tdSql.checkData(5, 2, False) + tdSql.checkData(6, 2, False) + tdSql.checkData(7, 2, True) + tdSql.checkData(8, 2, False) + tdSql.checkData(9, 2, True) + tdSql.checkData(10, 2, False) + tdSql.checkData(11, 2, False) + tdSql.checkData(12, 2, False) + tdSql.checkData(13, 2, False) + tdSql.checkData(14, 2, False) + tdSql.checkData(15, 2, None) + tdSql.checkData(16, 2, False) + tdSql.checkData(17, 2, None) + tdSql.checkData(18, 2, False) + + tdSql.checkData(18, 0, '2020-02-02 00:00:18.000') + + tdSql.query(f"select _irowts,_isfilled,interp(c0) from {dbname}.{tbname2} range('2020-02-02 00:00:00', '2020-02-02 00:00:18') every(1s) fill(value, '123')") + tdSql.checkRows(19) + tdSql.checkCols(3) + + tdSql.checkData(0, 0, '2020-02-02 00:00:00.000') + + tdSql.checkData(0, 2, True) + tdSql.checkData(1, 2, False) + tdSql.checkData(2, 2, True) + tdSql.checkData(3, 2, True) + tdSql.checkData(4, 2, True) + tdSql.checkData(5, 2, False) + tdSql.checkData(6, 2, True) + tdSql.checkData(7, 2, True) + tdSql.checkData(8, 2, True) + tdSql.checkData(9, 2, True) + tdSql.checkData(10, 2, True) + tdSql.checkData(11, 2, False) + tdSql.checkData(12, 2, True) + tdSql.checkData(13, 2, False) + tdSql.checkData(14, 2, True) + tdSql.checkData(15, 2, None) + tdSql.checkData(16, 2, True) + tdSql.checkData(17, 2, None) + tdSql.checkData(18, 2, True) + + tdSql.checkData(18, 0, '2020-02-02 00:00:18.000') + + tdSql.query(f"select _irowts,_isfilled,interp(c0) from {dbname}.{tbname2} range('2020-02-02 00:00:00', '2020-02-02 00:00:18') every(1s) fill(value, 'abc')") + tdSql.checkRows(19) + tdSql.checkCols(3) + + tdSql.checkData(0, 0, '2020-02-02 00:00:00.000') + + tdSql.checkData(0, 2, False) + tdSql.checkData(1, 2, False) + tdSql.checkData(2, 2, False) + tdSql.checkData(3, 2, True) + tdSql.checkData(4, 2, False) + tdSql.checkData(5, 2, False) + tdSql.checkData(6, 2, False) + tdSql.checkData(7, 2, True) + tdSql.checkData(8, 2, False) + tdSql.checkData(9, 2, True) + tdSql.checkData(10, 2, False) + tdSql.checkData(11, 2, False) + tdSql.checkData(12, 2, False) + tdSql.checkData(13, 2, False) + tdSql.checkData(14, 2, False) + tdSql.checkData(15, 2, None) + tdSql.checkData(16, 2, False) + tdSql.checkData(17, 2, None) + tdSql.checkData(18, 2, False) + + tdSql.checkData(18, 0, '2020-02-02 00:00:18.000') + + tdSql.query(f"select _irowts,_isfilled,interp(c0) from {dbname}.{tbname2} range('2020-02-02 00:00:00', '2020-02-02 00:00:18') every(1s) fill(value, NULL)") + tdSql.checkRows(19) + tdSql.checkCols(3) + + tdSql.checkData(0, 0, '2020-02-02 00:00:00.000') + + tdSql.checkData(0, 2, False) + tdSql.checkData(1, 2, False) + tdSql.checkData(2, 2, False) + tdSql.checkData(3, 2, True) + tdSql.checkData(4, 2, False) + tdSql.checkData(5, 2, False) + tdSql.checkData(6, 2, False) + tdSql.checkData(7, 2, True) + tdSql.checkData(8, 2, False) + tdSql.checkData(9, 2, True) + tdSql.checkData(10, 2, False) + tdSql.checkData(11, 2, False) + tdSql.checkData(12, 2, False) + tdSql.checkData(13, 2, False) + tdSql.checkData(14, 2, False) + tdSql.checkData(15, 2, None) + tdSql.checkData(16, 2, False) + tdSql.checkData(17, 2, None) + tdSql.checkData(18, 2, False) + + tdSql.checkData(18, 0, '2020-02-02 00:00:18.000') + + # test fill linear + tdSql.query(f"select _irowts,_isfilled,interp(c0) from {dbname}.{tbname2} range('2020-02-02 00:00:00', '2020-02-02 00:00:18') every(1s) fill(linear)") + tdSql.checkRows(17) + tdSql.checkCols(3) + + tdSql.checkData(0, 0, '2020-02-02 00:00:01.000') + + tdSql.checkData(0, 2, False) + tdSql.checkData(1, 2, False) + tdSql.checkData(2, 2, True) + tdSql.checkData(3, 2, False) + tdSql.checkData(4, 2, False) + tdSql.checkData(5, 2, False) + tdSql.checkData(6, 2, True) + tdSql.checkData(7, 2, True) + tdSql.checkData(8, 2, True) + tdSql.checkData(9, 2, False) + tdSql.checkData(10, 2, False) + tdSql.checkData(11, 2, False) + tdSql.checkData(12, 2, False) + tdSql.checkData(13, 2, None) + tdSql.checkData(14, 2, None) + tdSql.checkData(15, 2, None) + tdSql.checkData(16, 2, None) + + tdSql.checkData(16, 0, '2020-02-02 00:00:17.000') + + tdLog.printNoPrefix("==========step13:test error cases") tdSql.error(f"select interp(c0) from {dbname}.{tbname}") tdSql.error(f"select interp(c0) from {dbname}.{tbname} range('2020-02-10 00:00:05', '2020-02-15 00:00:05')") @@ -2013,7 +2370,7 @@ class TDTestCase: # input can only be numerical types tdSql.error(f"select interp(ts) from {dbname}.{tbname} range('2020-02-10 00:00:05', '2020-02-15 00:00:05') every(1d) fill(null)") - tdSql.error(f"select interp(c6) from {dbname}.{tbname} range('2020-02-10 00:00:05', '2020-02-15 00:00:05') every(1d) fill(null)") + #tdSql.error(f"select interp(c6) from {dbname}.{tbname} range('2020-02-10 00:00:05', '2020-02-15 00:00:05') every(1d) fill(null)") tdSql.error(f"select interp(c7) from {dbname}.{tbname} range('2020-02-10 00:00:05', '2020-02-15 00:00:05') every(1d) fill(null)") tdSql.error(f"select interp(c8) from {dbname}.{tbname} range('2020-02-10 00:00:05', '2020-02-15 00:00:05') every(1d) fill(null)") diff --git a/tests/system-test/2-query/json_tag.py b/tests/system-test/2-query/json_tag.py index df460df5c387acf863e1a7aab3b2de67ef040abe..ebd580efd4fbd7a4ab71e5c06da1f83c99e9da97 100644 --- a/tests/system-test/2-query/json_tag.py +++ b/tests/system-test/2-query/json_tag.py @@ -301,7 +301,7 @@ class TDTestCase: # where json value is not exist tdSql.query(f"select * from {dbname}.jsons1 where jtag->'tag1' is null") - tdSql.checkData(0, 0, 'jsons1_9') + # tdSql.checkData(0, 0, 'jsons1_9') tdSql.checkRows(2) tdSql.query(f"select * from {dbname}.jsons1 where jtag->'tag4' is null") tdSql.checkRows(9) diff --git a/tests/system-test/2-query/last_row_interval.py b/tests/system-test/2-query/last_row_interval.py new file mode 100644 index 0000000000000000000000000000000000000000..ca3946af8874c59f41b27313942b464c80ad29ae --- /dev/null +++ b/tests/system-test/2-query/last_row_interval.py @@ -0,0 +1,789 @@ +# author : wenzhouwww +from util.log import * +from util.sql import * +from util.cases import * + +class TDTestCase: + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), True) + + def prepare_data(self): + + tdSql.execute(f'''drop database if exists table_lastrow_2_2;''') + tdSql.execute(f'''create database if not exists table_lastrow_2_2 keep 36500 ;''') + tdSql.execute(f'''use table_lastrow_2_2;''') + tdSql.execute(f'''create stable stable_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') + tdSql.execute(f'''create stable stable_2 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') + tdSql.execute(f'''create stable stable_null_data (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') + tdSql.execute(f'''create stable stable_null_childtable (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') + tdSql.execute(f'''create stable stable_null_data_insert_data (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) tags(loc nchar(100) , t_int int , t_bigint bigint , t_smallint smallint , t_tinyint tinyint, t_bool bool , t_binary binary(100) , t_nchar nchar(100) ,t_float float , t_double double , t_ts timestamp);''') + tdSql.execute(f'''create table stable_1_1 using stable_1 tags('stable_1_1', '-1018336694' , '1595508332262302224', '28072' , '-35' , 0 , 'binary1.MWLRCtBHUaCUgFSTdtBk' , 'nchar1.dALWGgKyWCbOuxCUbzKr' , '-5.335609', '48773689935.563004' ,'0') ;''') + tdSql.execute(f'''create table stable_1_2 using stable_1 tags('stable_1_2', '785397064' , '-6316393479307224208', '-12059' , '-20' , 1 , 'binary1.laHjdQwAnHfxLDvYcBRX' , 'nchar1.xylcIZwLgJewVUUBDjkc' , '353778266298.739014', '-994383623.121693' , '1999-09-09 09:09:09.090') ;''') + tdSql.execute(f'''create table stable_1_3 using stable_1 tags('stable_1_3', '-2147483647' , '-9223372036854775807' , '-32767' , '-127' , false , 'binary3' , 'nchar3nchar3' , '-3.3' , '-33.33' , '2099-09-09 09:09:09.090') ;''') + tdSql.execute(f'''create table stable_1_4 using stable_1 tags('stable_1_4', '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0') ;''') + tdSql.execute(f'''create table stable_1_5 using stable_1 tags('stable_1_5', '2129429608' , '2307167663134055915', '-30801' , '97' , 1 , 'binary1.xxBwoDsTKoIfHezkMCMK' , 'nchar1.IyVWFtMtpqxfvpJpbgQe' , '-0.988745', '804627.676066' ,'-811294702') ;''') + tdSql.execute(f'''create table stable_1_6 using stable_1 tags('stable_1_6', '-418554527' , '7121649991943388108', '-17673' , '-32' , 1 , 'binary1.nqevHWrcyyicEQwayBtK' , 'nchar1.UzlaWBQIwovvojtniExg' , '63206.472351', '66.580164' ,'-2011047779') ;''') + tdSql.execute(f'''create table stable_2_1 using stable_2 tags('stable_2_1', '-650310817' , '-6448202879686146556', '-4887' , '-49' , 1 , 'binary2.vxWkNcASTlgvrLxckVzo' , 'nchar2.IkwxYduQGOkmMYozJsGu' , '-5503502270.709900', '-193919.697976' ,'0') ;''') + tdSql.execute(f'''create table stable_2_2 using stable_2 tags('stable_2_2' , '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0') ;''') + tdSql.execute(f'''create table stable_2_3 using stable_2 tags('stable_2_3', '844729931' , '3743631577053724543', '-29079' , '-68' , 1 , 'binary2.zemsTeoWSPFIVFIJVgqg' , 'nchar2.zbPxIWIIvmmnSsdjdUgv' , '18949277.377942', '-160343395.575977' ,'2055943475') ;''') + tdSql.execute(f'''create table stable_2_4 using stable_2 tags('stable_2_4', '630274019' , '4517699459805299748', '-10047' , '-66' , 1 , 'binary2.QAecEuLSbznsyExjWhWQ' , 'nchar2.KiKzPupgeBsBQCFpGMjf' , '93521718623175.000000', '5981.851300' ,'-1323235531') ;''') + tdSql.execute(f'''create table stable_2_5 using stable_2 tags('stable_2_5', '-1888888729' , '-4964455964757350108', '21832' , '-102' , 1 , 'binary2.IYBWfiyETfYXlLmoHvCL' , 'nchar2.VNSfIvIrgAZQsYfrvGuW' , '-7938.194391', '8946996355046.539062' ,'-1075201653') ;''') + tdSql.execute(f'''create table stable_2_6 using stable_2 tags('stable_2_6', '221977162' , '-4074099363599643838', '-15384' , '93' , 1 , 'binary2.IixhuAsSrChdQTizyBRi' , 'nchar2.XAECwFPOVvqbfAQnXFll' , '112970.139491', '-86723.729566' ,'124866521') ;''') + tdSql.execute(f'''create table stable_null_data_1 using stable_null_data tags('stable_null_data_1', '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0') ;''') + tdSql.execute(f'''create table stable_null_data_insert_data_1 using stable_null_data_insert_data tags('stable_null_data_insert_data_1', '0' , '0' , '0' , '0' , 0 , '0' , '0' , '0' , '0' ,'0') ;''') + tdSql.execute(f'''create table regular_table_1 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') + tdSql.execute(f'''create table regular_table_2 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') + tdSql.execute(f'''create table regular_table_3 (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') + tdSql.execute(f'''create table regular_table_null (ts timestamp , q_int int , q_bigint bigint , q_smallint smallint , q_tinyint tinyint , q_float float , q_double double , q_bool bool , q_binary binary(100) , q_nchar nchar(100) , q_ts timestamp , q_int_null int , q_bigint_null bigint , q_smallint_null smallint , q_tinyint_null tinyint, q_float_null float , q_double_null double , q_bool_null bool , q_binary_null binary(20) , q_nchar_null nchar(20) , q_ts_null timestamp) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630000000000, -618707591, -8247775922836565826, -5478, 118, 5.414333, 75.304275, 0, 'binary.mjCkHlPgXnuCpAFOIRiI', 'nchar.陕西省长春县涪城赵街S座 993438', 1630000000000) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630000000000, -679041833, 6481912273446973866, 7785, 25, 253.538943, -12801.160677, 0, 'binary.OIaLSSdTkyeghECZRlly', 'nchar.四川省长春县萧山黄街m座 950751', 1630000000000) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1629999999999, 1000633087, 4246783346267002529, 32349, 56, -38524798468.228600, 677.696961, 1, 'binary.tfdGRAJloMWlejFCvXGH', 'nchar.新疆维吾尔自治区彬县浔阳深圳路k座 106151', 1630000000000) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630000000000, 1519095863, 3730763636688762973, 32328, 18, 13261.792805, -23310331001.143700, 1, 'binary.YuznyMmpNmIBujYOnfBj', 'nchar.湖南省银川市蓟州沈阳街f座 828894', 1630000000000) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630000000001, -1721664965, -3230247488973407828, -22534, -78, -4615440117998.759766, 128542619.774818, 1, 'binary.VkIjDmJdfYRXCGOcoaUw', 'nchar.湖北省拉萨县吉区银川街p座 684472', 1630000000001) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630000000001, -457200104, -5211291163024696467, -16773, -94, -6983919702730.200195, -67714706.233835, 1, 'binary.LTmCJTcqnzIfNQYoRTPC', 'nchar.黑龙江省西宁市江北王路P座 603299', 1630000000001) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630000000000, 913998061, -3881184424925998682, 29221, -118, -7492895.381435, -119177303.116243, 0, 'binary.oryFxMGKONJblKZWJxLF', 'nchar.广东省荣市上街钟路A座 708810', 1630000000000) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630015000000, -1004099631, -2329741298995361936, -17228, 92, -7786612568.749220, 63297.402773, 0, 'binary.oIlAieuDxUnJAznSxgDa', 'nchar.陕西省呼和浩特县华龙马鞍山路B座 509550', 1630000000001) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630015000000, 1984250107, -733051146694989614, 25996, 7, 32391348.640906, 30496.996911, 0, 'binary.SjSkhuLmeqJhgvToyskb', 'nchar.广西壮族自治区武汉县梁平兰州街z座 108560', 1630000000001) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630014999999, 1167978495, 168911323243208687, 25054, 105, 9.297430, -74362.658908, 1, 'binary.gjlULgjKtTQMRsgDIVbu', 'nchar.陕西省合山市友好哈尔滨路y座 906640', 1630000000001) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630015000000, 2124176615, 3367944756720448423, 31669, 74, -40.578216, 3714810365386.549805, 1, 'binary.xzMdipXOFEkZkaqAnulR', 'nchar.台湾省洁市门头沟惠州街T座 814575', 1630000000001) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630015000001, -800594954, -6220928593410477008, -6436, -107, -379445813485.830017, 1817959.681926, 1, 'binary.fgQqvhJhqEAyqYcYCzop', 'nchar.江西省六安县蓟州长沙路K座 686835', 1630000000002) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630015000001, -1398934219, -5088222972686572580, -11996, -93, 737.964702, -702597046.276900, 1, 'binary.WqJNWJTeOypOEILqFfFM', 'nchar.福建省哈尔滨市合川李街A座 990061', 1630000000002) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630015000000, -1491848052, -3232978461444804772, 28885, 110, 68028.289282, -0.612906, 0, 'binary.qfQwRgWfrgQLefodbKQE', 'nchar.海南省汕尾市普陀刘街x座 901815', 1630000000001) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630030000000, -554992634, -8694605272129245647, -19744, -34, 371492.822008, 97594901899.304092, 0, 'binary.vATatWJTwyzWNENoWGqm', 'nchar.黑龙江省兴安盟市友好李路X座 412206', 1630000000002) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630030000000, 230798367, 4276367516153106032, 23696, -34, -2149198212.254210, 722029.566814, 0, 'binary.EZDyNTgJgCCPGkPuTwyr', 'nchar.辽宁省石家庄市高港广州路V座 518042', 1630000000002) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630029999999, 2093449032, 3029533084633134124, 17333, 74, 179560.971309, 5.196993, 1, 'binary.JYigiQaVrKTPLzQHXeDp', 'nchar.湖北省南昌县金平合山街g座 418389', 1630000000002) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630030000000, 2099331457, 3609885272656270889, 31314, 60, -8489143.581025, -214298.108651, 1, 'binary.ltSDheslsSNwSxfYxIwt', 'nchar.辽宁省深圳县翔安石家庄街c座 827189', 1630000000002) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630030000001, -1245000234, -1838653281383479618, -13572, -101, -20.386729, 41392371.908604, 1, 'binary.nqjueffbFvZcGQexkMuc', 'nchar.重庆市淮安市上街福州街F座 236907', 1630000000003) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630030000001, -1000510248, -8459051266344969043, -8477, -86, -6923089039562.599609, 7.587889, 1, 'binary.egZiyotIUjvmyEeabqWD', 'nchar.宁夏回族自治区银川县淄川辽阳路F座 365611', 1630000000003) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630030000000, 1641358132, 5291198999362916313, 1219, 43, 13391898193591.400391, -253345.858194, 0, 'binary.zowdfNbqLIBOvTqQmqVq', 'nchar.辽宁省大冶县永川济南街Z座 410021', 1630000000002) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630045000000, 1273633633, -7910396749266717868, -2883, -35, -88018.597889, 331.964131, 0, 'binary.HLOtPGQtEAfRTTNAVbnF', 'nchar.福建省桂珍县翔安周路s座 201916', 1630000000003) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630045000000, -292105648, -9216209950218616247, 17873, -40, 510.442902, 4914.654078, 0, 'binary.FZYRLYLrlaZdIBnbOvWI', 'nchar.安徽省北京县平山郑州路p座 162038', 1630000000003) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630044999999, 1985684265, 7812482934230300604, 10735, 2, 39668.546371, 3772288865301.229980, 1, 'binary.DQDjLSXXpYjXDnGzrDiB', 'nchar.福建省丽丽市大东石家庄路O座 638078', 1630000000003) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630045000000, 273025537, 6201710872284300698, 24247, 122, 34.519692, 3678779922.134800, 1, 'binary.kbpPYOgvAQcOBLFcuuZj', 'nchar.浙江省莹县吉区岳街N座 997620', 1630000000003) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630045000001, -755554172, -5922209280465971373, -16931, -1, -738590.998999, -213684725.699882, 1, 'binary.gGZITsRKKtOkkAZpwqFk', 'nchar.河南省石家庄市西夏施街d座 887826', 1630000000004) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630045000001, -1614464307, -1951583711943603971, -6, -26, 46698502859495.796875, -66331370.539177, 1, 'binary.anFFtpnYqkllelsTzUXp', 'nchar.重庆市长沙县丰都郑街v座 632337', 1630000000004) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630045000000, 1066735810, -1572767557463382095, -24233, -99, -8059716.727903, -44065130.621251, 0, 'binary.EHRUdvBpXXdxSfkPbHPY', 'nchar.贵州省桂兰市高坪广州街K座 807922', 1630000000003) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630060000000, 436440993, 4582366906832569569, 19691, -104, -770862234.875283, 67327.464546, 0, 'binary.rGBrQBwSJziIwOmEMtJD', 'nchar.黑龙江省通辽市高明张路I座 703149', 1630000000004) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630060000000, -875710377, -5188572182276438044, -19951, 75, -2.627015, -71356793.343289, 0, 'binary.xoMabkxpBOQvAWZlTVMz', 'nchar.贵州省汕尾县静安黄街M座 165440', 1630000000004) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630059999999, 1129217878, 8833855448102017424, 3948, 86, 1462546878675.199951, -9256879605.926800, 1, 'binary.pCnFTHmykgTwspRMSMDk', 'nchar.云南省西宁县合川苏街h座 357731', 1630000000004) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630060000000, 2091037114, 6355755798403937517, 32527, 22, 2.418504, 74.778674, 1, 'binary.yoobwWUyBSZuRZmlcWTL', 'nchar.天津市萍市大东姚街w座 255499', 1630000000004) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630060000001, -647490375, -2905281875821917763, -16147, -57, -8479790.621940, 5694596048115.910156, 1, 'binary.gqtxAiHhIoGKdGJgNhat', 'nchar.云南省齐齐哈尔市新城翟路J座 336359', 1630000000005) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630060000001, -1939480852, -8924947224421059592, -29393, -89, 4457679028853.139648, 3390867.192607, 1, 'binary.biEBPzDOrLOGitUZfDIy', 'nchar.新疆维吾尔自治区彬市南溪黄街i座 106358', 1630000000005) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630060000000, 760109584, 2794056460189383180, -17287, -72, -99807343228.163803, 1373392779.173220, 0, 'binary.xABwARkXCmOteoVJInrZ', 'nchar.吉林省芳县安次荆门路K座 396431', 1630000000004) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630075000000, -1866923177, -2210826056783865816, -26481, 25, -60150089285.989502, 7628.542314, 0, 'binary.rTYYBufHDmHMtGoZQOTT', 'nchar.宁夏回族自治区兵市孝南陈路x座 334815', 1630000000005) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630075000000, 2038781133, -328945288212162680, -28897, 95, 5608233.583575, -69.542113, 0, 'binary.JwNUFBltIXQKAdjZpTIn', 'nchar.河南省娟县南长吴路f座 790249', 1630000000005) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630074999999, 1145437501, 7925745151626620680, 4822, 91, -59887158.500668, -47581275646365.203125, 1, 'binary.DrUaLRxoRNzyNzXYUlRE', 'nchar.甘肃省南京市大东大冶街D座 872025', 1630000000005) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630075000000, 1789577030, 3132818518285337526, 26070, 65, 8974955.481672, 25.499355, 1, 'binary.VRegnoPEWKPRFsoYVtYC', 'nchar.贵州省东市东丽上海路s座 272562', 1630000000005) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630075000001, -1373109267, -5826806756838814238, -16841, -28, 51.267264, 48701588356.369003, 1, 'binary.WqMufKnCjgUuLBrWIgRT', 'nchar.安徽省玲市西夏海口街o座 109427', 1630000000006) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630075000001, -813108784, -1617673275161393067, -1248, -69, -972415684.192217, -1.653864, 1, 'binary.kmjtLhPVdLESTsOjNOxB', 'nchar.台湾省潮州市孝南廖街t座 266427', 1630000000006) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630075000000, -1223568312, -8946838664732429923, -4198, -109, 62156997799.337097, 5905968167.585610, 0, 'binary.gPXEGOdtZVrGqPNRAInE', 'nchar.西藏自治区齐齐哈尔市清城郑州街w座 590784', 1630000000005) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630090000000, -884439870, 1248874482756813386, -11000, 61, 80395.998486, -719886040980.203003, 0, 'binary.MUrOdVZgtgPWPXbIcstW', 'nchar.江苏省天津县龙潭贵阳路s座 612000', 1630000000006) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630090000000, 22358632, 696083452197273333, -13257, -41, 56423240.636894, 67488.334223, 0, 'binary.HEsJVMnaOFobHNDaoRtn', 'nchar.贵州省杭州县沈河陆路s座 645540', 1630000000006) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630089999999, 1652733516, 2575789832408445556, 16457, 72, -9677288.455314, -634151591.251647, 1, 'binary.kcMLZfZtpBrgBBeZWbaO', 'nchar.青海省汕尾市长寿周街N座 774464', 1630000000006) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630090000000, 1670284035, 7846771393632678538, 24419, 81, 256.686378, -932250077361.723022, 1, 'binary.dcqObzxzMWdcGMorJEdo', 'nchar.浙江省荣县平山王路W座 892684', 1630000000006) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630090000001, -1239207401, -2017719648880935228, -9628, -15, -77811.715389, -347.862346, 1, 'binary.arpuZMBhyXPuWeNDqoQg', 'nchar.上海市武汉县朝阳佛山街r座 687990', 1630000000007) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630090000001, -429906324, -294441740565391101, -18570, -27, -91849065.920391, -9504277.384224, 1, 'binary.YzliXowrLkmoHdpasClN', 'nchar.广东省静县新城王街H座 307037', 1630000000007) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630090000000, 1647824018, -1290146600224131452, -26320, -17, -97472611955.200394, 623.599606, 0, 'binary.eIXSvTrGfgIWKUgEQIKK', 'nchar.山西省俊县新城许路L座 732295', 1630000000006) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630105000000, 897426731, -6157764764029970873, 13753, 53, -76610.177184, 784852116.102444, 0, 'binary.oThZwmCKADWhpHiBQMEB', 'nchar.安徽省雷县高明六盘水街s座 104130', 1630000000007) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630105000000, 1727787759, 3219114917075431149, -30010, 105, -29098130696901.199219, 2716.301364, 0, 'binary.KpchCpVHGKjREJMxRCYb', 'nchar.河北省辽阳市南长岑街l座 554159', 1630000000007) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630104999999, 964911890, 9104291220948875270, 2620, 93, 6348.912976, -5.436949, 1, 'binary.enOSjjsQzNbvDdFfEKhA', 'nchar.西藏自治区桂芝县山亭刘路N座 825972', 1630000000007) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630105000000, 1265975391, 1097514590897652008, 30907, 127, 6962290728.631910, 4234.969142, 1, 'binary.IDDEVFUXulGKPGUxgwoa', 'nchar.贵州省龙市友好哈尔滨街V座 614938', 1630000000007) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630105000001, -997687142, -3588569170127119022, -31895, -11, 681764.467420, -927.233192, 1, 'binary.qAYrbGModOeljwoNdOSK', 'nchar.内蒙古自治区桂英县清城何街e座 656693', 1630000000008) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630105000001, -1838171592, -2931035207249690385, -27947, -4, -0.864426, -31972996.517570, 1, 'binary.xmGbCIlRspBnDeHNjzGO', 'nchar.香港特别行政区辽阳县朝阳黄路J座 742465', 1630000000008) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630105000000, -463217897, -8041553223283381090, -9791, 67, -69685155628.862000, 251717731390.667999, 0, 'binary.RvKNPCRWhwpJzghpxMnY', 'nchar.山东省宁县大兴王街f座 954429', 1630000000007) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630120000000, -54069770, 3955990383518016848, 8494, 120, 51149.933011, 1349638022797.659912, 0, 'binary.ctqJUvXzcLsBTGXFePLO', 'nchar.辽宁省超市六枝特马鞍山街F座 798879', 1630000000008) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630120000000, -403363944, -2394897603233419155, 16427, 48, 74402.339292, -52.539883, 0, 'binary.kobpHICjpqBLcDIEHpts', 'nchar.海南省琳县高明沈阳路e座 854884', 1630000000008) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630119999999, 806349342, 8818007624619329018, 11587, 27, 24820988.463016, -1.378348, 1, 'binary.SPIvOBZxamwoTLUyeDec', 'nchar.上海市玉梅县六枝特王路F座 154214', 1630000000008) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630120000000, 1843801013, 8068282721613219948, 23265, 89, 20575797079906.000000, 7.906923, 1, 'binary.smCqwmyottgAmLVxlXfX', 'nchar.内蒙古自治区杭州县南湖上海街P座 763569', 1630000000008) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630120000001, -1431341222, -5831324648859520070, -8527, -66, 507444690740.578003, 943376.611667, 1, 'binary.nZHlAmwbcUYtOTsAxArC', 'nchar.广西壮族自治区武汉市海陵施路Z座 727105', 1630000000009) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630120000001, -781555629, -3682028760781093775, -1217, -88, 967.988362, -998747442791.562012, 1, 'binary.CMDWBFfYnlYEdTeiqtsW', 'nchar.云南省敏县白云柳州路Z座 839560', 1630000000009) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630120000000, -1229205179, 1269213658170093198, 15696, -110, 8232823752181.839844, 36569.580002, 0, 'binary.voGRWKSImlHklgUXdYMu', 'nchar.新疆维吾尔自治区红霞市南湖成都路L座 163545', 1630000000008) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630135000000, 801515319, -3418248827901909079, 26288, 51, -534837.671505, 15.631926, 0, 'binary.DnbpUExxknvANXEEsaWR', 'nchar.重庆市旭市清浦冯路W座 960766', 1630000000009) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630135000000, 1651702520, 7472881261358437437, 27039, 39, -901147931976.785034, -21.400440, 0, 'binary.PDCCWnKlBJjPqTBmUhYK', 'nchar.广西壮族自治区秀英县秀英惠州路c座 534464', 1630000000009) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630134999999, 1705176915, 3853689828781845374, 27488, 40, 8339786734.762860, 74741492928.878296, 1, 'binary.jUuMQjVuORGeBYLOtCvN', 'nchar.四川省飞县海陵林路s座 610723', 1630000000009) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630135000000, 1401375995, 4401644438738533904, 10408, 76, -65049698292.958000, 762130648498.933960, 1, 'binary.NgPdruMUwoLdCxyEbNqw', 'nchar.甘肃省长春市南溪张街Q座 680073', 1630000000009) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630135000001, -2067806949, -5140997933871627569, -3032, -3, -771419731758.264038, 30386355.304924, 1, 'binary.XlCFISTlcLIRsxjboWHn', 'nchar.台湾省六盘水县清浦成都街a座 796270', 1630000000010) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630135000001, -1774018458, -2530948670547381542, -23399, -94, -495376178.216937, 151170.247760, 1, 'binary.TnrFRvylqBaNDthXRBAm', 'nchar.山西省帆县清浦昆明街Q座 225961', 1630000000010) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630135000000, -1363931402, 5604209803537258593, -18300, -23, 790034130.791400, 9237371157.649290, 0, 'binary.gyQzvuCzIfMlTIPPFNsH', 'nchar.广西壮族自治区淑珍市徐汇包路e座 156670', 1630000000009) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630150000000, -1894195697, -5734755902035702132, -15870, 111, -2670.233773, -4237.280417, 0, 'binary.UorBnZYRMylozHQezSJY', 'nchar.北京市英市清河张街N座 217253', 1630000000010) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630150000000, 745446575, -9002015868827109100, 7664, 112, -360706186.393129, 47605535552382.398438, 0, 'binary.FZNKeCfgQVTcZyqRNJuK', 'nchar.贵州省桂芳县怀柔天津街b座 347544', 1630000000010) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630149999999, 672434773, 9109650904011996741, 14686, 14, -85079.408071, 86.251927, 1, 'binary.XKWsToLeAsNVsIygACBb', 'nchar.贵州省广州市海港长沙街d座 904810', 1630000000010) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630150000000, 1515726636, 8521257827234172880, 11241, 103, -10.526128, -45196916520756.703125, 1, 'binary.zcHOLLudfLMvmIiXrANq', 'nchar.青海省六安市新城哈尔滨路Z座 312342', 1630000000010) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630150000001, -1923997635, -1295412466812568520, -20900, -107, 86532721.258284, 65558167665.583397, 1, 'binary.zNkNRRNyFRDVubonqLSh', 'nchar.广东省艳市东丽东莞路X座 591920', 1630000000011) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630150000001, -1357505482, -7556497983653555349, -27964, -5, 254673.529731, -273710012885.143005, 1, 'binary.oDZRgFAkFNMiHLGdpWcM', 'nchar.内蒙古自治区太原县秀英吴街F座 707601', 1630000000011) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630150000000, 720531993, -6639843123954951373, 1904, 87, 90228483.253351, 671689.823567, 0, 'binary.pbWPxvdZNrUoUOjzRJiX', 'nchar.湖北省柳市合川台北街k座 351073', 1630000000010) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630165000000, -1222920932, 8032055023952251119, -10742, -10, -567677.518580, -365410143.799096, 0, 'binary.gSPyErqDINWrLLVhCvup', 'nchar.辽宁省慧县牧野沈阳路d座 158793', 1630000000011) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630165000000, 414746648, 5927295586580216537, 31761, -42, 29.776511, -773061167437.739990, 0, 'binary.clWyILBusmbzejzbBoFT', 'nchar.福建省雷县东城曾路t座 587170', 1630000000011) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630164999999, 824419604, 891106057873489263, 23278, 95, 407384.105632, -35575.873087, 1, 'binary.MNQmhqizvbnJgkkIQqJe', 'nchar.广东省郑州市江北王路P座 783592', 1630000000011) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630165000000, 1281221057, 7024877965980246423, 27117, 31, -310144.477215, 7651054.553459, 1, 'binary.glajyvvlfYaEeVkkGCkB', 'nchar.西藏自治区博县黄浦沈阳街J座 833215', 1630000000011) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630165000001, -1830990548, -4649870365451699133, -7796, -55, -7445.199016, 5969245.537249, 1, 'binary.acIrBxurCVUcZrlhKNWy', 'nchar.北京市雪市城北佛山街L座 344309', 1630000000012) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630165000001, -156703760, -5651707522314260232, -20357, -53, -48419.774656, -412073702153.369995, 1, 'binary.RalpwNQKJazBBUIsHJxe', 'nchar.辽宁省阜新市大东郑州街k座 364193', 1630000000012) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630165000000, 862504464, -5500398940730781742, -14444, -90, 83.855205, -42218010095700.703125, 0, 'binary.TDihZaaECjQhZSuXOJkw', 'nchar.台湾省香港县滨城丁路O座 978512', 1630000000011) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630180000000, 667837391, -3891675097346789325, -27238, -120, 1.955652, 9.112019, 0, 'binary.JzwDaPxfqmOCGLPvyrjl', 'nchar.湖北省合肥市朝阳贵阳路w座 542472', 1630000000012) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630180000000, -1060826174, 4656485123040609725, -2306, -49, -31070344.608357, 32855.487468, 0, 'binary.HuQooyRdCtqfxpfenEKD', 'nchar.福建省沈阳县门头沟合山街M座 860092', 1630000000012) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630179999999, 95309922, 7708532961668715531, 4871, 87, -2493.696406, -305230557.440988, 1, 'binary.sDzjVbzXXlrItKczJmNd', 'nchar.四川省彬市高明潜江街t座 525852', 1630000000012) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630180000000, 1834883689, 9087266843320529269, 10482, 90, 7620830515.391810, -42.560665, 1, 'binary.UNyjzeJnXfRpfYwqnoiq', 'nchar.宁夏回族自治区天津县门头沟韩街T座 460087', 1630000000012) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630180000001, -426435327, -3062037029747393786, -9095, -58, 3445.234181, -558141651179.500000, 1, 'binary.PPFhdHAqUnaKoAEmHsdU', 'nchar.湖南省霞市南湖石家庄街t座 857415', 1630000000013) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630180000001, -1181075026, -3180887222641598399, -31207, -111, -1782467190.826900, 5.516558, 1, 'binary.TGHKOSbljBlliohlXOWY', 'nchar.北京市华县南溪兰州路S座 340198', 1630000000013) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630180000000, -1179373775, -2798016462115894947, 13261, 81, -6.728964, -772564358011.891968, 0, 'binary.YugzktgmcxvJhQUFlTJx', 'nchar.重庆市大冶县新城蔡街a座 475876', 1630000000012) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630195000000, -1753829875, 9153441825434214315, 27033, 122, -736.689121, -92.766550, 0, 'binary.pUBZlnzauIFGdWqodaie', 'nchar.新疆维吾尔自治区海燕市高港刘路a座 320202', 1630000000013) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630195000000, 209604377, -5203497748513382294, 11811, 104, 6261702331.471590, 912558484347.494019, 0, 'binary.wZJaPJrGTgLaarzVLUSN', 'nchar.香港特别行政区武汉市海港长沙路y座 885641', 1630000000013) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630194999999, 927761777, 2507975814406403776, 19213, 90, -7617794.842135, -454202300.875154, 1, 'binary.icqbMuuToUNxqWXUeRPk', 'nchar.广东省西宁市丰都李路q座 597739', 1630000000013) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630195000000, 25571599, 9030074847417015485, 31156, 118, -75.396818, 48452341.676426, 1, 'binary.NqBtvtMnkQndvuYapikY', 'nchar.香港特别行政区南宁市长寿甘路u座 453721', 1630000000013) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630195000001, -428129781, -5700535713003042271, -10481, -28, 23726711.628846, -28428638085.690300, 1, 'binary.pCEqFOIEkNkTyynifvvP', 'nchar.西藏自治区张家港市上街阜新街O座 871243', 1630000000014) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630195000001, -848598147, -5339257050356453975, -18995, -126, -97029.616600, -142.756397, 1, 'binary.fnhJdkzuvTlaKyHNNFax', 'nchar.陕西省桂芝市永川马鞍山街k座 606648', 1630000000014) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630195000000, -1235643681, 7084534800526629066, -24801, 79, -145779524595.869995, 94.711588, 0, 'binary.zGptPlBGCsdKPNcWBTWB', 'nchar.湖南省莉市璧山王街S座 444986', 1630000000013) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630210000000, -257925835, 4113510788745659274, -7451, 82, -73680370.344940, 3976133.807981, 0, 'binary.RMHnWOvHGDkBnmnhajqK', 'nchar.甘肃省昆明县锡山东莞路f座 143739', 1630000000014) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630210000000, -441472850, 6731053996474537256, 25225, 88, 40422214874.591599, 23965.803627, 0, 'binary.EHzCItPZeIiFrqnZlZFx', 'nchar.广西壮族自治区丹丹市蓟州李街A座 716733', 1630000000014) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630209999999, 2038647205, 1189537624585781694, 7402, 77, -25786637314.127998, -8273884501116.790039, 1, 'binary.lQDfBPFCwRhZWQDOueFe', 'nchar.四川省南京县大东济南路X座 802062', 1630000000014) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630210000000, 479757528, 6749026723270202494, 13649, 38, -11785225102.777700, 474555902413.706970, 1, 'binary.gZeGdOiDSRQDrrutAJpP', 'nchar.吉林省桂英县门头沟巢湖路W座 373162', 1630000000014) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630210000001, -973859244, -7125967416228878252, -23978, -103, 9.174338, -9074.207791, 1, 'binary.spVrNBOtDUJKWtVfGkIs', 'nchar.云南省重庆县秀英张街w座 814757', 1630000000015) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630210000001, -1099659644, -5069485856549254463, -7663, -21, -77435917488084.906250, 6157980965629.839844, 1, 'binary.neMplXKNDoTZmfaWuQIv', 'nchar.海南省嘉禾县翔安上海街P座 777755', 1630000000015) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630210000000, 1262139840, -4971682912616802373, 32119, 52, -763639.969220, 4466.886880, 0, 'binary.BedkvagFaejmBsJjHkQk', 'nchar.上海市玉英县东丽辽阳街q座 311759', 1630000000014) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630225000000, 722222291, 150763568244594756, -22749, -105, 69152723689.975998, -5072701672145.320312, 0, 'binary.ZIoGBLOEmmhXJZvIxuMC', 'nchar.陕西省博市永川西安街H座 219040', 1630000000015) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630225000000, 591411352, 513820708206298423, -29944, 120, -7450006471858.410156, 28263898844.649300, 0, 'binary.OOYGFQjeyKSgnzgKjpfl', 'nchar.甘肃省南昌县龙潭张街q座 299631', 1630000000015) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630224999999, 1729527872, 858836292464061984, 26768, 61, 8045315.625506, 463874.574633, 1, 'binary.qPTkezKHzqZjenBLvfin', 'nchar.新疆维吾尔自治区汕尾市海陵齐齐哈尔街e座 364606', 1630000000015) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630225000000, 1643785412, 3613608845439721039, 2830, 6, 20141358.132227, -10515528.243744, 1, 'binary.OHifAxUhqgMCYnGFqNtd', 'nchar.福建省惠州县秀英胡路z座 617394', 1630000000015) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630225000001, -1458828697, -6767897245471753991, -5337, -110, 26.347447, -2088415765277.760010, 1, 'binary.nKdzFeMTCkibzMHIBYWp', 'nchar.北京市武汉县海陵沈阳街j座 275130', 1630000000016) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630225000001, -847285817, -4303648033804475519, -29035, -126, 46793.514585, -1507581042167.719971, 1, 'binary.xMmlUvSqOUKadNTjwVbR', 'nchar.湖南省琳市沙湾张路b座 512648', 1630000000016) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630225000000, -978219428, -2955103196936757566, 30178, 32, 1631732545944.110107, -393.171524, 0, 'binary.seXNZyWFCBIKtovhPcPH', 'nchar.江苏省慧县上街宜都路e座 880474', 1630000000015) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630240000000, -1972126026, -7574542606285760315, 28119, 80, -529670.435949, -24383.929895, 0, 'binary.xhubWGtXmHdWMLKNToaW', 'nchar.甘肃省桂英县萧山邱街M座 532318', 1630000000016) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630240000000, -1796898694, -764951623915204003, -15993, 27, 4657602445.591260, 4586648.134693, 0, 'binary.TEhGCTdxkZNmFnzFtObM', 'nchar.甘肃省东县徐汇昆明街P座 260669', 1630000000016) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630239999999, 357526998, 1276204587787008311, 29238, 42, -5156150330.293080, 978546.269907, 1, 'binary.cTaghgmdTbnmdzLMfprn', 'nchar.青海省齐齐哈尔市海港汕尾街S座 223338', 1630000000016) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630240000000, 719321885, 6211071132372294861, 26203, 4, 97973007280575.000000, 4917172790.726020, 1, 'binary.UrLJfXtkYMRsRzBKupLN', 'nchar.安徽省永安市城东六盘水街x座 616834', 1630000000016) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630240000001, -131148573, -7418806044708315561, -24075, -95, -939211006187.709961, -62673687782.380798, 1, 'binary.ioRcxRqlBPWWUslmpXot', 'nchar.河南省瑞市崇文北京路v座 915899', 1630000000017) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630240000001, -926921347, -7119582382885284043, -22204, -33, -843815.847483, -733624.538013, 1, 'binary.CDgPdtLeDlVKfKVxhxpv', 'nchar.浙江省磊县城东阜新路q座 382954', 1630000000017) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630240000000, -256678368, -5278293054518319714, -19250, 63, 76804691.667068, 56757245265557.898438, 0, 'binary.mWDyzgzWsYmwcclLnyKM', 'nchar.新疆维吾尔自治区宁德县平山武路C座 669860', 1630000000016) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630255000000, 105950788, 478455145201382299, 21202, 49, -492280820.857835, -59846.285166, 0, 'binary.bHXHFuvyzSODEypLHuvb', 'nchar.天津市惠州县兴山贵阳路q座 575823', 1630000000017) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630255000000, -1188272652, 3059329495007474279, 15772, 52, 97.388100, -179.239522, 0, 'binary.NcbSJdYAICljVIDdqLDs', 'nchar.河北省凤英市东丽曹路x座 451405', 1630000000017) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630254999999, 1374178023, 3719932182860509152, 15558, 26, -48778273445.594002, -4313900.906134, 1, 'binary.xrqMfwkMMYQAjZjHywqq', 'nchar.江西省广州市南湖汕尾街p座 889246', 1630000000017) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630255000000, 1682040807, 8317842464181056096, 1900, 87, 415547443.281930, 6910478.101601, 1, 'binary.CgZXfDNNfsnrMNDLhaFk', 'nchar.河南省海口县沈河长沙街D座 269675', 1630000000017) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630255000001, -1655416898, -6254408814439814177, -32731, -80, -926982830.629323, -59.656488, 1, 'binary.oerLzcmyCiDByTBvtqJC', 'nchar.贵州省关岭县涪城侯路y座 962245', 1630000000018) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630255000001, -1635083194, -8974109706346763955, -2735, -50, 3293.363373, 18681627453476.000000, 1, 'binary.GSVbHmgpelzbMoHbLPcC', 'nchar.内蒙古自治区晶县清城拉萨路X座 358275', 1630000000018) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630255000000, 1313669852, 6945103232995327793, 30581, 16, 85564937456162.203125, -77542.918719, 0, 'binary.XFHqNNaMVizYnZQgNXPC', 'nchar.新疆维吾尔自治区贵阳市崇文宁德街i座 343604', 1630000000017) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630270000000, 917363192, -2865889321649137964, 23695, 91, 5280836.562854, -3783947630346.270020, 0, 'binary.MNMoJuMUQGuncloQVsno', 'nchar.陕西省福州市吉区苏路s座 468218', 1630000000018) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630270000000, -2122120908, -2872995800597882541, 31983, 71, 6875560.276574, 5.493633, 0, 'binary.EPzGVtLuyIzhTxgbjEWF', 'nchar.山西省哈尔滨县浔阳蒲街L座 163917', 1630000000018) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630269999999, 795882903, 3280694140326918125, 20811, 108, 49.168498, 7651.321312, 1, 'binary.UikJWqrxtOeMoYKjVtNm', 'nchar.广东省桂芳县安次嘉禾街r座 604207', 1630000000018) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630270000000, 2120566264, 4722887562205021135, 28462, 1, 129.403026, 81642332991.346405, 1, 'binary.rFxHYhBonyaZGENLSiup', 'nchar.新疆维吾尔自治区建军市龙潭陈路N座 391792', 1630000000018) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630270000001, -426986357, -7028311428629812651, -4827, -64, -7.591949, -8288.667569, 1, 'binary.MTcHiKSZLMGfDPYnynMD', 'nchar.山东省辛集县东城汕尾路Y座 327226', 1630000000019) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630270000001, -1319979040, -1611680110566277558, -12591, -102, -0.766067, -9.985580, 1, 'binary.aSzFqnlqfbvcqqslssAX', 'nchar.北京市关岭县南长王路s座 855187', 1630000000019) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630270000000, -655731150, 952225036593449539, -12275, 62, 988070261.618785, 110828.718042, 0, 'binary.pwXbqQpeGiCAxVQjBByd', 'nchar.陕西省长沙县江北汕尾路F座 416889', 1630000000018) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630285000000, 1662865387, 6549115606741837921, 31658, -40, 6050748.290946, 850563444268.306030, 0, 'binary.PqxloDzsqJMLqHZQWCjg', 'nchar.上海市兰英市南湖乌鲁木齐路K座 550844', 1630000000019) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630285000000, 1925250353, -2675198429577937161, -954, 26, 42621483170.815201, -2.407178, 0, 'binary.UQoLagBLIXklApVNNHjj', 'nchar.福建省超县淄川大冶街R座 827801', 1630000000019) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630284999999, 1995360198, 5210480004052888682, 18624, 3, 97472570479742.500000, 1260.797791, 1, 'binary.ItgagWrnvwaUBcGaMaeN', 'nchar.广西壮族自治区重庆县平山香港路V座 260105', 1630000000019) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630285000000, 1294452263, 5523637851428821304, 15478, 5, 9507059.611693, 71182.768111, 1, 'binary.zGOYZBGdKbprwpIBOAyf', 'nchar.吉林省静县房山太原街o座 903227', 1630000000019) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630285000001, -1089491236, -4124928499125874309, -26711, -91, 102.262755, -86354.456039, 1, 'binary.wIAlEZNaSWVRvmnECAvO', 'nchar.浙江省梅县孝南广州街r座 602833', 1630000000020) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630285000001, -1857132633, -3826380662652726191, -2637, -78, -5244683893811.500000, 28720333520.104401, 1, 'binary.aCSuXOyNceiyMGbrnKiN', 'nchar.辽宁省海口市城东谌街E座 102059', 1630000000020) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630285000000, 1378099044, 2585214152437420786, 15693, -37, 9876.538042, -735632586.279405, 0, 'binary.SafiqluCtQtykHfilDhK', 'nchar.北京市雪市黄浦王路x座 719370', 1630000000019) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630300000000, 1474375413, 5114018721557230309, 17508, -51, 19062832.997828, -2871763657.353070, 0, 'binary.tQXLaCZMUMopSlkQosvw', 'nchar.甘肃省齐齐哈尔市花溪合山路F座 429081', 1630000000020) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630300000000, -388377907, -3327065272167311555, -118, 78, 891.667968, -939976.640106, 0, 'binary.vDLERQspegLuLpwaUwzM', 'nchar.安徽省潜江市南溪王街H座 114897', 1630000000020) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630299999999, 1778777098, 1247965499115398806, 31082, 36, -34708.444580, -9074056.186352, 1, 'binary.sSRJTkOuBEsIDUBYnvLI', 'nchar.重庆市倩市沈北新拉萨街s座 784670', 1630000000020) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630300000000, 1445490460, 8880599911239061729, 24463, 25, -3.382105, -1781392.553877, 1, 'binary.aoTqpxHvRtaSZcskkkvh', 'nchar.天津市北镇市牧野徐路j座 335208', 1630000000020) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630300000001, -414780851, -3272216576746070612, -22655, -77, 60986281647372.203125, 8206.582673, 1, 'binary.BYPTbfwFwATchckdDRGY', 'nchar.澳门特别行政区瑞市白云沈阳街D座 317572', 1630000000021) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630300000001, -1100845103, -4359114771451299690, -19221, -72, -454991497.458531, 66488519526.609200, 1, 'binary.IAUPjYJLQVMOrfjNhEGW', 'nchar.贵州省柳市丰都合山路I座 879430', 1630000000021) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630300000000, -1344260637, -2327749124997496795, 8396, 9, 53600362.915844, 39096334.438932, 0, 'binary.MCcnFYqPmshweRolVKXy', 'nchar.福建省辽阳市黄浦武汉路Z座 588915', 1630000000020) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630315000000, -355362703, -1297695182610353342, -9770, -89, 952785.346586, -74060980932193.796875, 0, 'binary.oxSCvbpFwbexlztlNbov', 'nchar.江西省阳县徐汇孙街A座 417152', 1630000000021) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630315000000, -1228614638, -3900819433463392818, -17590, -11, 8486255712070.299805, 776309237079.099976, 0, 'binary.lCmzbzWrnzVGWTlKKcLz', 'nchar.江西省健市花溪齐齐哈尔路s座 401365', 1630000000021) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630314999999, 2119897062, 705747859773422308, 11407, 81, -7145565.865688, -262229423.217684, 1, 'binary.eEvZPvUuQslbYxeHtVwF', 'nchar.山西省马鞍山县兴山台北街K座 317962', 1630000000021) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630315000000, 1675027583, 7700778986059081977, 16174, 9, -665864335638.520020, 71582.521862, 1, 'binary.tKmhWfIgqpVzDnSlVNyX', 'nchar.澳门特别行政区银川县高港侯路B座 867370', 1630000000021) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630315000001, -63872001, -6930483055721144761, -55, -27, -647803039.367343, 2303820.355916, 1, 'binary.cMZeLPHbvchDdpONluWD', 'nchar.海南省长沙县浔阳俞路y座 710843', 1630000000022) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630315000001, -550949355, -2196304875670875984, -11885, -39, -6711213741.192790, 743976.503579, 1, 'binary.ZjvtDrDegMEemNdVPYWI', 'nchar.江苏省丽华市东丽林路c座 701423', 1630000000022) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630315000000, -638988531, -238160149511091433, 5704, -64, -8.456931, 122326752.221053, 0, 'binary.bOAzwJsCnDilLpivHhcE', 'nchar.福建省台北县新城佛山街W座 190141', 1630000000021) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630330000000, -626643923, -2019791703137966083, 32109, -84, 3416720.968494, 9357038.426241, 0, 'binary.BaFBcjklAnYcYwGxAqoq', 'nchar.吉林省武汉县朝阳宜都街u座 246031', 1630000000022) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630330000000, 1744535925, -781319618567345160, 25699, 25, 5357.659882, -618.983367, 0, 'binary.VPobijbSHTufuAsIpKoJ', 'nchar.吉林省建华市城北刘路m座 189127', 1630000000022) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630329999999, 880112073, 3294754321072095965, 6900, 77, -89650901.379152, -40.193724, 1, 'binary.slgqehRyEWrrSqbAYVJh', 'nchar.甘肃省佛山县吉区吴路i座 371158', 1630000000022) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630330000000, 185074156, 4989180079312042024, 29358, 109, 553959035.299975, -336.524434, 1, 'binary.gsSAVskcQYNhhgdMqRao', 'nchar.内蒙古自治区海门市新城许路M座 262464', 1630000000022) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630330000001, -1466263570, -2228588793836525866, -21221, -43, -87005519974.974106, -660.194761, 1, 'binary.bxpguIjMdJUkxwsOGQEq', 'nchar.新疆维吾尔自治区杨县徐汇福州街W座 871563', 1630000000023) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630330000001, -1645451433, -4401356942676794117, -28334, -111, 279.991987, 22516.349037, 1, 'binary.dfdHQJlJuaDksxoabJoB', 'nchar.西藏自治区太原县涪城哈尔滨街p座 883295', 1630000000023) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630330000000, 2032301580, 4408736721579229542, -1683, -10, -14742.318595, -7092296.586329, 0, 'binary.GExwHTtWGjhZjTEeFYiG', 'nchar.江苏省大冶市闵行高街t座 870548', 1630000000022) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630345000000, -2137144022, 4079790010886186881, 25710, 117, -4064381240984.290039, 7015370675970.000000, 0, 'binary.CVqxsKDzVLudZenizkMH', 'nchar.澳门特别行政区广州县牧野北京街x座 612318', 1630000000023) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630345000000, 933500773, -9037818060698530179, -29395, 110, -635450613.922866, -7403.402429, 0, 'binary.BAfDibZjCIxGGNhZPzdE', 'nchar.天津市玉梅市六枝特曹街z座 306379', 1630000000023) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630344999999, 1707978124, 7108213046724490283, 23442, 53, -1690092798852.899902, -77.732195, 1, 'binary.CjoXkwnzCpbREZGghsfa', 'nchar.天津市俊市南长成都街Z座 386069', 1630000000023) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630345000000, 638219332, 7562431303377412667, 16354, 108, -1426154.974943, -5203.623256, 1, 'binary.YWcLHHceXXwuYatdWqpB', 'nchar.海南省武汉市闵行佛山路i座 350356', 1630000000023) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630345000001, -694792584, -5451159991441438649, -27358, -63, -421814477.346397, 658.908206, 1, 'binary.RjeNtbCwKmVzuSEznMIP', 'nchar.青海省兴城县双滦嘉禾街J座 854125', 1630000000024) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630345000001, -1486705498, -4529672645278837682, -21086, -87, 0.969525, -88911627001.666107, 1, 'binary.lFWwkNVbMUovcuYFIddp', 'nchar.澳门特别行政区拉萨市和平合山街j座 616189', 1630000000024) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630345000000, 1470276506, -7928540339509515647, -16251, -106, -75636523821237.203125, 1951788289389.639893, 0, 'binary.gAaAcTqtqUaUtILxCARx', 'nchar.广东省嘉禾县清河六盘水街k座 243900', 1630000000023) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630360000000, 1152276268, -8156217200537467815, 19660, 12, 28355311.730820, 6713567748470.700195, 0, 'binary.bmGZNDQVyGtLdMWCUUPh', 'nchar.云南省杰县南长兴城街P座 252275', 1630000000024) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630360000000, -504752588, 1971807127747770396, 27445, 121, -8539663.125419, 54448077.614627, 0, 'binary.cuEEkfEDPsfuHYlKnDOH', 'nchar.西藏自治区坤县金平澳门路Y座 688701', 1630000000024) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630359999999, 855880887, 4257747801443019050, 4002, 59, -651877334084.171021, -40661.869299, 1, 'binary.ZOOiXFRmbNwocDEGjyPI', 'nchar.山西省香港县沈河汕尾街w座 530063', 1630000000024) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630360000000, 24228908, 7366685839096261214, 24706, 108, -2895.104902, -690789994021.112061, 1, 'binary.WoiDFgqNXTSOSSqvghbK', 'nchar.香港特别行政区哈尔滨县萧山重庆路S座 626140', 1630000000024) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630360000001, -1979347419, -8086150063002929949, -31773, -59, -6758.131288, 67.389494, 1, 'binary.BdPhqWnyifozXNBeGuOa', 'nchar.吉林省重庆县东丽齐齐哈尔路T座 928550', 1630000000025) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630360000001, -796374629, -6586675874501163952, -28989, -41, 64993999.806191, -8554109097.403460, 1, 'binary.AjiqARctYieemihXJRgw', 'nchar.广东省嘉禾县房山李街d座 910194', 1630000000025) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630360000000, -2078983709, -5723824485424673203, -23688, -93, 7495606593.360470, 264203417504.108002, 0, 'binary.LvbrLfgWtSAHPeWnNyif', 'nchar.重庆市峰县华龙廉街i座 702040', 1630000000024) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630375000000, -2135854035, 3495311946004641041, -8066, -32, 794122420146.477051, 54762.831473, 0, 'binary.iKNdSNvujYgDbKTFUoWj', 'nchar.湖北省秀珍市东丽佛山街a座 727430', 1630000000025) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630375000000, 195905849, -4893460212808423867, 27472, -20, -60.648891, 9236.500458, 0, 'binary.fxBWbjZbbgBzyftfClnE', 'nchar.云南省春梅市普陀合山街d座 593581', 1630000000025) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630374999999, 1222537098, 2598300007761422980, 13555, 60, -21237649962112.101562, 56425481952996.296875, 1, 'binary.nljxYbIMonhZyPfyRWYU', 'nchar.河北省澳门市大兴贵阳街U座 357038', 1630000000025) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630375000000, 1255129224, 3767117331869115149, 20415, 43, -96039955.962346, -3228760442.535840, 1, 'binary.VjBuTRZJfGBAsllbmlCm', 'nchar.上海市潮州县长寿大冶街V座 568435', 1630000000025) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630375000001, -451008604, -9013008932944649264, -4123, -55, -858251929.793158, 54.556567, 1, 'binary.CGijFVktOvKYBbslrFnW', 'nchar.甘肃省丹市牧野刘街b座 221301', 1630000000026) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630375000001, -994075958, -3836907429942473253, -15968, -12, 4.809100, 97814318457.744095, 1, 'binary.ZkpIzssjZLBfwxySZcqJ', 'nchar.吉林省惠州市兴山辛路i座 132947', 1630000000026) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630375000000, -316707220, -6874259000415830359, -14656, -107, 9783647610530.900391, 6.913912, 0, 'binary.stonHOVphDrwzsFtAuEM', 'nchar.吉林省杭州县秀英任街B座 197635', 1630000000025) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630390000000, 1162924990, -5170396701176744771, 20522, -92, -96439892251.988800, 27285284869935.500000, 0, 'binary.VaAkDRQGuwRsRuHuWTBT', 'nchar.安徽省刚市璧山严路e座 453358', 1630000000026) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630390000000, -1787695146, -7200438941294278654, -1976, -22, -19864559903432.601562, -81662701579034.406250, 0, 'binary.cmeIZxizSzJowehZeTgi', 'nchar.甘肃省萍县吉区雷路Q座 278197', 1630000000026) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630389999999, 1569291471, 7500808657751046307, 17406, 11, 187598077622.457001, 9402508122.216591, 1, 'binary.rGPAUjewRUiNxuGlPQSI', 'nchar.湖北省宁德县永川邓街N座 873981', 1630000000026) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630390000000, 379511627, 959739624838461444, 32645, 40, 27073116046.845501, 9680357.747312, 1, 'binary.EnkonjEPYvAZMcbrIDhm', 'nchar.安徽省宇县南湖拉萨路l座 319850', 1630000000026) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630390000001, -367057952, -5935523220947872265, -31354, -124, 60936491.153154, -7459361.174603, 1, 'binary.ehReUikosMxxEsGOsivE', 'nchar.河北省宁德市六枝特武汉路j座 479101', 1630000000027) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630390000001, -1204076280, -9028857053490170794, -4305, -36, -4299.875188, 8440721199484.889648, 1, 'binary.LDFNunrLqdOUVBNKOEgL', 'nchar.湖北省西安县六枝特淮安街d座 633128', 1630000000027) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630390000000, -1734305566, 9014243322464991494, 2526, -91, 46980567127.508904, 2736.398653, 0, 'binary.kCqLuZWcVXncorOcRLOX', 'nchar.吉林省秀英市永川姜路P座 763227', 1630000000026) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630405000000, 493810102, 750963322474159528, -23750, -17, -22892331.104465, 24868217245883.800781, 0, 'binary.CFELPsklozusjREurYzN', 'nchar.浙江省云市吉区丁路H座 432525', 1630000000027) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630405000000, 1463044753, -1849311824110235905, 30811, -7, -17541415231.352200, 4359875.313503, 0, 'binary.XztqpyyklxsOpFMGQpdQ', 'nchar.内蒙古自治区兴城市和平李路f座 695390', 1630000000027) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630404999999, 1007184435, 7016082283155873873, 18680, 114, 921004.858357, -3749822553130.689941, 1, 'binary.nPsHiYGSrumTPlRhGlGo', 'nchar.内蒙古自治区长沙市海陵六盘水街Z座 569551', 1630000000027) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630405000000, 2001976992, 6444735120490802040, 10757, 75, 3812894583.717430, -70452173102543.796875, 1, 'binary.MPllmpddghzaoIRJmAJs', 'nchar.河南省西安县崇文李街d座 986692', 1630000000027) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630405000001, -1748589793, -7997812859393713894, -9028, -46, -35.226372, -6653121231.857540, 1, 'binary.eVMhMPninMDMThzngiZC', 'nchar.江苏省鹏县长寿深圳街V座 475898', 1630000000028) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630405000001, -952046898, -1003514831999138377, -10475, -121, 583096872.778729, 750.380516, 1, 'binary.NhUrjkWQZoYMHNgZcAur', 'nchar.辽宁省畅县南溪陈街Q座 816736', 1630000000028) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630405000000, 1203696901, 5857368026922559698, 26958, 20, 7943395.425475, 3479394471444.229980, 0, 'binary.EWZLkQdNEMzlxMRcWPIF', 'nchar.河北省凤兰市秀英王街h座 943022', 1630000000027) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630420000000, -1140109939, -7140478781384267748, 23888, -102, -463251528.501850, 58.564400, 0, 'binary.wBOWZRMsrPHnjovxpVtM', 'nchar.福建省桂香市魏都张街s座 891983', 1630000000028) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630420000000, 1596211207, -6399610783775225615, -6948, 18, 5279544962.478530, -3254512966322.680176, 0, 'binary.pkLdHCSKTBJtvlkQZFel', 'nchar.宁夏回族自治区志强市沈北新哈尔滨街V座 984662', 1630000000028) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630419999999, 1987333617, 2406177688984023332, 5515, 81, 93334135.435757, 15200180248105.500000, 1, 'binary.zunblBzpjKjvAprKttjO', 'nchar.陕西省娜市六枝特长春路u座 734021', 1630000000028) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630420000000, 1816593353, 6144436182936056183, 11139, 111, -5111160.608439, 3134629841.427010, 1, 'binary.SvSSddOyqqrLVbTuqmWK', 'nchar.黑龙江省北京市沙湾天津路l座 864505', 1630000000028) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630420000001, -1092293083, -6497162148443342823, -12861, -33, 7333968.460815, -786239055.465100, 1, 'binary.abpCKdOYaAAPNEGSEKTl', 'nchar.重庆市通辽市白云席路d座 390244', 1630000000029) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630420000001, -672330807, -1416095251335444839, -31617, -20, -268.247197, -187856842551.350006, 1, 'binary.ayrYptkczwLwwHSlrotJ', 'nchar.安徽省莹市崇文卓路D座 742319', 1630000000029) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630420000000, 1541531440, -8276464445557829911, -32389, 41, -205002775.660640, 773381214983.128052, 0, 'binary.DfbOMiMBChkQyxVRkVrV', 'nchar.江西省重庆县东城嘉禾路z座 664431', 1630000000028) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630435000000, 511355972, -4607655896423993759, -17667, -115, -72721.674990, -0.210169, 0, 'binary.TzInKrTBzLfzhusnMyJt', 'nchar.西藏自治区大冶县黄浦夏路c座 672141', 1630000000029) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630435000000, -794567134, -2235695034213568259, -18310, -76, 80256151932.389999, -0.448521, 0, 'binary.rSBKSseTjokrDbbUwbdS', 'nchar.新疆维吾尔自治区南宁市璧山王街D座 205832', 1630000000029) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630434999999, 1590979273, 8094673699827428920, 1803, 48, -6923.890078, -97907136406253.203125, 1, 'binary.GnrqLzMLFlinSCSmzsTt', 'nchar.辽宁省荆门县六枝特邯郸街p座 507994', 1630000000029) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630435000000, 1132029984, 2532896687056073497, 20663, 78, 72584604.270350, -52558156996.426201, 1, 'binary.hUBVgUHTpsSwyjcCwqYn', 'nchar.四川省邯郸县南湖张家港路V座 697294', 1630000000029) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630435000001, -214047405, -8929808789293020890, -14561, -75, 57922.963900, 629338050.201999, 1, 'binary.rUFdjCoxExrGdHJRdNrS', 'nchar.香港特别行政区艳市魏都香港街w座 547058', 1630000000030) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630435000001, -1769159233, -2980306744069119372, -24737, -85, 95463.992658, -3290730049210.250000, 1, 'binary.bcUBXvglPoTsHoRWOtZB', 'nchar.青海省建国市蓟州罗街V座 702124', 1630000000030) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630435000000, -787830057, 3539391148256582010, 8967, -84, -3405.578845, 6448387382.497230, 0, 'binary.nXPgVFiqtkagYaeMiBqc', 'nchar.宁夏回族自治区兴安盟县梁平沈阳街J座 590779', 1630000000029) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630450000000, 1186123659, -7951052163704337820, -29743, -14, -83621685835717.906250, 73159143.385460, 0, 'binary.VKjqDeckRehqfqnstQEu', 'nchar.河北省上海市门头沟梧州路n座 288381', 1630000000030) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630450000000, 1878200309, 7041626075528835244, -32078, -31, 37394.924981, -492.884685, 0, 'binary.tSYeYbpjVnhDUVatIqqr', 'nchar.云南省齐齐哈尔市朝阳王街j座 235227', 1630000000030) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630449999999, 1216265979, 1946865098328593924, 13349, 71, -8448.993057, -74684363814152.500000, 1, 'binary.HIQrJxrPESpsHxBeQTJr', 'nchar.香港特别行政区关岭县魏都呼和浩特路i座 304697', 1630000000030) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630450000000, 1436995521, 3840076561934756705, 24645, 53, 3385565140.362020, -18217011452.326302, 1, 'binary.RBEtocJRHaAIuNaYJMhP', 'nchar.辽宁省重庆市江北张路g座 561300', 1630000000030) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630450000001, -704813545, -8641984224483414170, -32490, -72, 305492940.896881, -3375029817498.339844, 1, 'binary.MUkAAGQFoHZIrYzgZIkn', 'nchar.甘肃省佛山市六枝特梧州街p座 155461', 1630000000031) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630450000001, -222045952, -7186471281941680094, -4325, -12, -4.504288, -107.133595, 1, 'binary.rYHScGxtnPQZbrvqmGLs', 'nchar.浙江省斌县西夏宁街i座 817397', 1630000000031) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630450000000, 1430474057, 6099257513015763510, -25953, -124, -4692.193024, 4.787536, 0, 'binary.ECCSIBNtxKQLYBfOfsJg', 'nchar.天津市西宁县璧山曾街N座 665290', 1630000000030) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630465000000, -1933715256, 1674195434522463261, 18595, -62, -2.112704, -1.361571, 0, 'binary.WFmGDlZbQZbxQoPTeYYD', 'nchar.江西省帅市秀英罗路i座 713857', 1630000000031) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630465000000, -1427366603, 348136735706226150, 11786, 45, 998.343140, -9.796246, 0, 'binary.mfnVlbsKfzjjqorEhocA', 'nchar.西藏自治区玉市安次成都街E座 433538', 1630000000031) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630464999999, 1659717258, 7758886491614905150, 8304, 125, 6399945699.318400, 86010265260.434601, 1, 'binary.PFttwdRtnOphOvIvENNh', 'nchar.山东省欣市沙湾孙路R座 922051', 1630000000031) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630465000000, 2080213156, 8048809385397600433, 18758, 65, -544332786.800377, 2865457.223765, 1, 'binary.oElRbKMuPpzhWDlPDXtl', 'nchar.北京市淑华县江北李路F座 469619', 1630000000031) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630465000001, -1260757693, -7052648703184778467, -19691, -58, 263396039624.993988, 4278958.521790, 1, 'binary.CZUckqTDCqkrcZvnYVOg', 'nchar.广东省秀珍市清城谢街t座 351701', 1630000000032) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630465000001, -716674007, -2090666240981221473, -8986, -13, 40900.288977, -311075618204.403015, 1, 'binary.svGVeKCsLqnIefICQikd', 'nchar.宁夏回族自治区哈尔滨市南湖梁路v座 181451', 1630000000032) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630465000000, -1114362408, 5527740642432952035, -26428, 12, -21611.508885, -307.575004, 0, 'binary.UdnFsgeAgiPHPPgFGuCS', 'nchar.天津市成市朝阳沈阳街c座 871777', 1630000000031) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630480000000, 572636870, -1348714871953192727, 11880, -9, 78191326.534929, 5.863674, 0, 'binary.ELYllxOgSmXkAHYWCKeC', 'nchar.河南省六安县和平惠州路b座 192567', 1630000000032) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630480000000, -1554586734, -5797603791431465981, 19152, -58, 376.263188, -9117680341029.800781, 0, 'binary.ItnjMhkccvDshKoJDFBL', 'nchar.广西壮族自治区上海县高明潜江街i座 632153', 1630000000032) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630479999999, 1889928969, 2650453196149359117, 1531, 101, 221512.929316, -89455817137.120804, 1, 'binary.JuOPYpivSOrAxirELGaK', 'nchar.云南省广州县清浦潜江路y座 321604', 1630000000032) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630480000000, 123268180, 7324096614566287829, 18716, 12, 727218062004.973999, 656857194.138679, 1, 'binary.LzrEjFPpRgwZHAABcyJl', 'nchar.宁夏回族自治区兴城县沈河济南路A座 434702', 1630000000032) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630480000001, -739224311, -3272068915371457037, -11723, -49, 952488.600157, -831167.359733, 1, 'binary.KMwlcGqAhCieyQLGVtBU', 'nchar.河北省玉梅县徐汇张街u座 155803', 1630000000033) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630480000001, -1363430935, -5467097084273074766, -2392, -77, -2426746190.920940, -72743043.214903, 1, 'binary.FYLJECmRlLXbWxOIZbkA', 'nchar.新疆维吾尔自治区荆门市沈河丁街Q座 909413', 1630000000033) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630480000000, -1790122655, -8076464905134511680, -30494, 39, -300117474923.549988, 64738074469674.398438, 0, 'binary.sleyeDsmwcqZzCKoASFB', 'nchar.江西省香港市西夏沈阳街A座 666990', 1630000000032) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630495000000, 500469874, -345787852149044362, 31942, 66, 218.280717, 7741245996.308220, 0, 'binary.WbODLLMuYAWsCiVGykXg', 'nchar.甘肃省哈尔滨市萧山邯郸路M座 577140', 1630000000033) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630495000000, 1790655569, -8921791989390937548, -7521, -10, 21190031.941426, 372852.384613, 0, 'binary.pvccoVhryCwBmdnzLuTc', 'nchar.云南省潮州市沈北新吴路C座 166459', 1630000000033) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630494999999, 175625025, 4866859483197899046, 22179, 83, -52019.335200, -315117.422010, 1, 'binary.EPoDgXsUUMvKeLUulmOd', 'nchar.上海市呼和浩特县孝南淮安街D座 688832', 1630000000033) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630495000000, 531699098, 9087043167036546370, 10882, 69, -343189.459391, 211280.823556, 1, 'binary.gZdLTctTatBiWQSJIJOv', 'nchar.黑龙江省鑫县友好石家庄路G座 894253', 1630000000033) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630495000001, -128692601, -3691685846078930525, -2891, -13, -473237.431473, 6.861402, 1, 'binary.PevuHflVwLyOeexwpRis', 'nchar.广西壮族自治区桂花县和平石家庄街b座 197395', 1630000000034) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630495000001, -1382111225, -8179715729898925736, -27170, -65, 94.689652, -9.323222, 1, 'binary.dQukgnOBymmhDJsngvdP', 'nchar.河北省西宁县六枝特谢街w座 636313', 1630000000034) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630495000000, -1067182718, 4525978413594477317, -15988, -12, 9592970.107203, -5857432670.557230, 0, 'binary.KmUaBLARuhpFnBlZhhjz', 'nchar.广西壮族自治区玲县丰都伍街N座 160120', 1630000000033) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630510000000, 834635110, 7524163623717860346, -32317, -74, -15228783.766541, 189210.220590, 0, 'binary.EMKiAeOicxSQHtyaVgJp', 'nchar.广西壮族自治区洋县沙湾太原街b座 616020', 1630000000034) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630510000000, 969850854, 946247056457664769, 21254, -118, -665960476591.563965, -26272792213245.500000, 0, 'binary.AmemAqKVRuTlgnqegQTU', 'nchar.四川省海门县牧野潜江路x座 318206', 1630000000034) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630509999999, 1292293650, 4182146421220552346, 9438, 26, 6515565137650.730469, 4326564.636935, 1, 'binary.sjAdlJbnpCLUoyTzXGLz', 'nchar.山东省杨市南湖刘街Y座 225115', 1630000000034) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630510000000, 122648893, 3568976233348927576, 4722, 101, 3692.808659, 8.426917, 1, 'binary.idKTOjMQWLcoovoLZCRY', 'nchar.天津市关岭市锡山蔡街f座 426508', 1630000000034) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630510000001, -103653848, -6515029160766267522, -13842, -21, 461152.967231, -451711.406503, 1, 'binary.axaNePeGlnNRTVkjQgqj', 'nchar.黑龙江省芳县海陵贺路c座 606589', 1630000000035) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630510000001, -1047587411, -3104445727812638863, -8586, -20, 551018.785658, -69672859.800138, 1, 'binary.rrQrHCANqfAEkPaQtSxY', 'nchar.江西省辛集市平山南京街X座 619416', 1630000000035) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630510000000, 849850958, 4247759734843437140, 25856, 61, 216972633.179206, -688453.180700, 0, 'binary.HFGqhFMKQtiuVGsRfHzo', 'nchar.台湾省柳县清浦长春街g座 249559', 1630000000034) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630525000000, -1263472959, -6789381028960214442, -24794, 114, -380257099.745964, -4055421597.527550, 0, 'binary.vYeuboTOIvXZsvEDJLRp', 'nchar.云南省淮安县浔阳南宁街s座 962460', 1630000000035) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630525000000, -912546236, -763230547896477749, -22937, -100, -61226717.838399, 59403.615805, 0, 'binary.RfopmCaAJeNFUhoHdGfp', 'nchar.北京市嘉禾市海港梧州路Y座 185275', 1630000000035) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630524999999, 1491974080, 3628020701059333562, 19419, 61, 87024838.439295, 563459.869036, 1, 'binary.MGCglbwygRPypvScTmBl', 'nchar.山东省霞市吉区哈尔滨路U座 372048', 1630000000035) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630525000000, 1133422966, 4026166323599059583, 27738, 105, -67481518.148927, -5675366548881.980469, 1, 'binary.LFpWlYqzLoxtHDCeMOWl', 'nchar.黑龙江省北京市沈河王街n座 817738', 1630000000035) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630525000001, -104646696, -5475621281854878817, -8285, -77, -25646075.949196, -671.169300, 1, 'binary.nEdnhlzGKPxpfWnmznnT', 'nchar.辽宁省凤兰市上街李路t座 977250', 1630000000036) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630525000001, -62177409, -7664099839058566322, -13160, -111, 2741718151170.200195, -3.737565, 1, 'binary.kkhcrwzjebqpTkpaFkPz', 'nchar.山东省淑华县六枝特长春街L座 836041', 1630000000036) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630525000000, 1330077191, -57050396993719408, -17322, -114, -17573257017538.599609, 131480451841.740005, 0, 'binary.nBjEjjCxPpyJZZokLLYj', 'nchar.辽宁省拉萨县普陀香港路u座 175740', 1630000000035) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630540000000, 1361888973, -4754878850289093930, -8386, -123, -73755105134.646896, 593521593.672730, 0, 'binary.aaJdLDhVgqXgbzOLtgEC', 'nchar.陕西省玉兰市城东东莞路y座 735950', 1630000000036) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630540000000, -2023047539, 207198366842950509, -16454, -51, -5064990.460660, -1880.742682, 0, 'binary.pgtomoahTdklLDwxLWlX', 'nchar.天津市哈尔滨市普陀赵路a座 285719', 1630000000036) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630539999999, 1161599505, 3137635940724704617, 16998, 16, 341287.343410, 3260540.642346, 1, 'binary.VpvoOstBpXhXgCFmTNbu', 'nchar.江西省坤县沙湾拉萨街f座 882807', 1630000000036) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630540000000, 927677922, 1982533905502059580, 28136, 88, -554.710032, 860334626423.604004, 1, 'binary.xigdKxGBhwDummTjgWpP', 'nchar.甘肃省兴安盟市大兴李街R座 743679', 1630000000036) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630540000001, -1715472820, -1384061899373736161, -15979, -21, -144230.332607, 3166307136.273820, 1, 'binary.keFGWYyGPVWHcgVZNKld', 'nchar.江苏省莉县沈河王街j座 843427', 1630000000037) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630540000001, -1691042073, -7186599605570808771, -14609, -94, -20270760488095.101562, -479065667910.349976, 1, 'binary.qNCwJqmtvmXEEJXuqVcD', 'nchar.安徽省鑫县西峰香港街Q座 197792', 1630000000037) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630540000000, 1494052790, -8128813094838655682, 26938, 0, -5026361458.157280, 48738437612.827003, 0, 'binary.beRVwfLpgmeKWVAywXMR', 'nchar.重庆市西宁县沙市南京路l座 534992', 1630000000036) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630555000000, 611413897, 4152857341280270300, -8759, -18, 2060373600.882190, 661904.107513, 0, 'binary.VNQYBgSikmUjTzZJlnVf', 'nchar.台湾省潮州县永川莫路h座 405659', 1630000000037) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630555000000, -2011948818, 7185570718886510818, -23571, 37, 224031795.273930, 529323.833439, 0, 'binary.gdqheapFdDFaeWrvvlFQ', 'nchar.黑龙江省丹市孝南白路Y座 681449', 1630000000037) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630554999999, 654809776, 1038278314990977803, 21715, 111, 9233.222241, 875.958899, 1, 'binary.zeHdYSkOUqnFvykwmfjx', 'nchar.山西省飞县淄川大冶路o座 582862', 1630000000037) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630555000000, 1280839364, 1109786269551140763, 28107, 83, -7163.528250, -98949521955313.296875, 1, 'binary.GPZyYjBdWvtWXNqtBBAi', 'nchar.吉林省秀云市浔阳石路k座 906496', 1630000000037) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630555000001, -1722544909, -25495015738455645, -17889, -9, 8051193952.303000, -0.243396, 1, 'binary.NUGayWaiLgkIttYyWPen', 'nchar.江苏省帅县合川嘉禾路d座 756609', 1630000000038) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630555000001, -712202888, -3214543942801667949, -11436, -24, -4230794569.824540, 541.605598, 1, 'binary.NPvfKAwLNUBrUsbNQBjL', 'nchar.青海省晨市长寿深圳街y座 565486', 1630000000038) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630555000000, 238745662, 5355356224239767868, -31138, 41, 22.830003, 4601.537342, 0, 'binary.PeqIYBTzojcHPPpbASyS', 'nchar.台湾省邯郸市六枝特海口路s座 355514', 1630000000037) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630570000000, 745693189, 4651138598564121948, -3614, -40, -41.868811, 96833493.796392, 0, 'binary.MRNQDZhMkAPOMwRDPLza', 'nchar.新疆维吾尔自治区坤市南湖蒙路z座 268958', 1630000000038) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630570000000, -2145996442, -3433600130799541776, -10809, -63, 855480.426782, 668870.374284, 0, 'binary.FlljuYVtUMddfJeXCePu', 'nchar.上海市林县永川深圳路h座 254543', 1630000000038) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630569999999, 1261953798, 314028281416970194, 7113, 92, 57276757.143326, 9980201888194.929688, 1, 'binary.CWKxzlTunbzsSgrpGTXp', 'nchar.河北省淑英县南湖武汉路Z座 875483', 1630000000038) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630570000000, 1435842767, 6578024513554467170, 17462, 68, 3980927396.535860, -442434194.149287, 1, 'binary.VGfEsMVqNVUjawdSRhQz', 'nchar.重庆市深圳市西夏刘路N座 212798', 1630000000038) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630570000001, -1529141111, -2552308375560945509, -3088, -52, 65625.681921, -544.669991, 1, 'binary.bfdhAjhpOMjvNqKKrBns', 'nchar.西藏自治区杨县崇文永安街j座 354402', 1630000000039) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630570000001, -541899245, -5991226110563542766, -707, -107, 35892171731.112297, 385.252012, 1, 'binary.TbAKAMxnTbMsqbiNmVzL', 'nchar.香港特别行政区南京市兴山广州街t座 824478', 1630000000039) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630570000000, 101231908, -1793754924693109102, 28121, 5, -27297115.590120, 235254039.488185, 0, 'binary.viiOyqfWQeKCCeqjJSna', 'nchar.台湾省秀华县沙湾辛集路L座 217819', 1630000000038) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630585000000, -979159064, -4405552399360058755, 29025, -61, -213.670605, 43.565732, 0, 'binary.VTPMgOjAfDTIkXvCBRvm', 'nchar.北京市莹县崇文万街c座 320902', 1630000000039) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630585000000, -732603316, 3291957888362983413, -27560, -5, 19536.856481, 81.835797, 0, 'binary.XyZczHSyVrPUQdbZGVqI', 'nchar.河南省香港市蓟州蔡街Y座 824988', 1630000000039) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630584999999, 1148581502, 1746383234690030123, 6204, 56, -838550587.270660, -7435199862.146900, 1, 'binary.jcVlbATHJidNqVsLaIMo', 'nchar.河北省关岭市浔阳任街A座 776594', 1630000000039) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630585000000, 1999818388, 7210586798654528078, 1630, 18, 6208.528721, -335.584522, 1, 'binary.aoQUSVWoTxqKJPqRozVe', 'nchar.河南省平县滨城兰州路a座 637800', 1630000000039) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630585000001, -884290007, -4556726278944994370, -16568, -42, 3252403692312.240234, 6802621362.778860, 1, 'binary.ppFYTcNMeEFxKGYyuqxK', 'nchar.江西省淮安市城东潘路U座 501030', 1630000000040) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630585000001, -1116869032, -271141834781987082, -15740, -33, -9594782340313.500000, -19702686640.119999, 1, 'binary.ptSTibfgYgBqxXBcljXJ', 'nchar.上海市乌鲁木齐县上街吴路k座 975956', 1630000000040) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630585000000, -435132639, -8699906763762846441, -23184, -19, -4717893819233.429688, 8709722.643050, 0, 'binary.RcLPKAxeNyCrFVgZBWDc', 'nchar.贵州省婷婷市永川香港路M座 438076', 1630000000039) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630600000000, 995611137, -3751963808881697081, -16228, -21, -96744.522458, -531.564886, 0, 'binary.uctNWRFZwpiODjjBdURc', 'nchar.江苏省琳县双滦乌鲁木齐街W座 315778', 1630000000040) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630600000000, -701305447, 7350533321420278894, 12461, -14, 637529643632.400024, -37006.524818, 0, 'binary.nBvNWvoxhJhaxlrXNwSq', 'nchar.河南省澳门市海港骆路d座 670505', 1630000000040) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630599999999, 2038087184, 3229395695102168112, 32164, 120, -60786248.451037, -66349595222.869400, 1, 'binary.jnEtTqkFChOMBYyRcHDQ', 'nchar.陕西省桂珍市秀英徐路N座 443126', 1630000000040) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630600000000, 2133331669, 3831296733741228684, 640, 101, -22204789596077.000000, 12726162933.525200, 1, 'binary.uKmymrIXqCovPNkWAJLg', 'nchar.广西壮族自治区瑞县龙潭深圳路g座 407714', 1630000000040) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630600000001, -1455494423, -4099795228613872218, -24485, -97, -42580895412.277603, 438688.561578, 1, 'binary.GqYiJMfzdIKHFsKfxVpu', 'nchar.贵州省建国县海港陆街z座 539355', 1630000000041) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630600000001, -743807783, -2365949684422468696, -5832, -55, 152697699639.433990, -847.354407, 1, 'binary.TEyMfkklGoyQyuhoMfGa', 'nchar.江西省秀华市黄浦刘路o座 900428', 1630000000041) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630600000000, 1164985515, -1528321163891719683, -5017, 59, -4685058576109.339844, 573635.987915, 0, 'binary.YRSxugbLdtCzYDQuPHiO', 'nchar.青海省刚市吉区成都路D座 183949', 1630000000040) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630615000000, 1552612066, 2109390087439052468, -31070, -121, 8636.758774, 54571.528229, 0, 'binary.xlsMBheXDBRIbHzbgzdk', 'nchar.河北省兴城市东城西宁路M座 385581', 1630000000041) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630615000000, 686960603, -6424166539989529553, 24333, 44, 8214.897773, -47431121552021.000000, 0, 'binary.RWvwTVykxTTNOYllQrFG', 'nchar.湖南省鹏县清河徐路D座 553544', 1630000000041) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630614999999, 68548265, 4587156226014614794, 16331, 57, 154895.265334, -2787.111072, 1, 'binary.ixnKFyhNgVkQywiDtpSq', 'nchar.广东省海燕市白云兴城路u座 101958', 1630000000041) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630615000000, 2266587, 2581645298895273135, 22522, 42, 3276944.200912, 911196.685350, 1, 'binary.rAZwQmSTbVawENHakqoC', 'nchar.北京市玉英市西夏台北路Z座 806985', 1630000000041) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630615000001, -982806837, -8813143395330268157, -9811, -65, 4240824286.641320, -949974.279935, 1, 'binary.IhdGdIOduEtBfgveDAUU', 'nchar.广西壮族自治区佳县怀柔西安街o座 181079', 1630000000042) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630615000001, -680593150, -6347717442100280854, -12839, -105, -3011259806.223000, -99641241686.436996, 1, 'binary.BZPuOZNfEoXwZqhyVXdb', 'nchar.内蒙古自治区南宁县丰都支路Y座 726362', 1630000000042) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630615000000, -417426465, -3607718287738436914, 28714, 52, -972051082.524374, -9817388374.836500, 0, 'binary.cWDUQzDHybUekMyDXMXD', 'nchar.四川省帅市黄浦荆门路A座 476400', 1630000000041) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630630000000, 1094499153, -8105793501718430866, 3482, -67, -190.752084, -5267142.925286, 0, 'binary.uxspDdfsvojZAgyJTRsp', 'nchar.贵州省香港县徐汇合山街F座 623037', 1630000000042) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630630000000, -1816628643, -2390834298866111036, -25491, 93, 421896.632317, 21603.217576, 0, 'binary.hrCIGqyoKXyOENntzjcy', 'nchar.湖南省广州市怀柔六安街a座 810265', 1630000000042) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630629999999, 237543427, 5776314153706817860, 8994, 66, 3092.121681, 4306303.541656, 1, 'binary.utVrWGltqteXbNHvQIuO', 'nchar.香港特别行政区建军市长寿刘街N座 294264', 1630000000042) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630630000000, 726605466, 7765148407017524476, 9380, 66, -725.184771, 4.785127, 1, 'binary.eCvUodgIQEPGQAlVRXHW', 'nchar.湖南省石家庄市海港林路K座 736274', 1630000000042) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630630000001, -2034983874, -1663495204537070761, -3507, -95, -26436104.684611, 3096688941.682010, 1, 'binary.buRNGkuUJrPnERgeimCX', 'nchar.湖南省海口市门头沟贵阳街c座 812797', 1630000000043) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630630000001, -1349842048, -6086664054622894661, -26154, -20, 9.257350, 73467.254310, 1, 'binary.VLQrxUICLTloHhOcsChH', 'nchar.福建省超市崇文通辽路p座 610024', 1630000000043) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630630000000, -1077532579, -4438737277090132487, -4021, -89, -1603199944.809290, 972619729.980217, 0, 'binary.bmvtStTuvDxOdnRZezwW', 'nchar.海南省成县闵行康街q座 877974', 1630000000042) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630645000000, 667040085, 5063347356651668746, -6033, 123, 372331463.295536, -1199.428365, 0, 'binary.yILHXSyMobxUzhCNgPvB', 'nchar.陕西省冬梅县高港谢路R座 540642', 1630000000043) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630645000000, 1643497791, -7930526570990406176, 31172, 28, -53.309129, -52475027161.967003, 0, 'binary.lznIQgSqYtbfWrGxFBvU', 'nchar.山西省南昌市翔安李街Z座 864233', 1630000000043) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630644999999, 1757612759, 453614548545492325, 5562, 26, -42197958317985.296875, -395.764533, 1, 'binary.gZRMNooJsuQCqUkKgObf', 'nchar.浙江省呼和浩特县闵行张路Y座 696051', 1630000000043) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630645000000, 716946034, 8100574991162286831, 8901, 92, 390.851634, -9995.448678, 1, 'binary.WChvjMXwNeLmicQzcpDK', 'nchar.湖南省丽华市江北张家港路O座 383877', 1630000000043) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630645000001, -1691922856, -2342118046897302678, -23270, -66, -172559.465035, 3039868.728966, 1, 'binary.RimPMjXlEtpLazOlwnuv', 'nchar.安徽省玉华市合川黄街F座 509787', 1630000000044) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630645000001, -1339923814, -5560716090143693393, -6671, -10, -84330915414.755005, -2113273814915.989990, 1, 'binary.YGgXnRFnSbGpfKSYyKgV', 'nchar.内蒙古自治区荣县永川朱路u座 853226', 1630000000044) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630645000000, 1122107930, -8861294204430315415, -1044, -23, -3031.346285, 18.218107, 0, 'binary.lUwNsZlGQGhpLpDYqvtB', 'nchar.广东省兴安盟市合川拉萨路K座 345819', 1630000000043) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630660000000, 815803254, -3671302785504904803, -3291, -47, 736.989253, -48462175883.852402, 0, 'binary.PcSjPekpFeCmxcWwgQcF', 'nchar.青海省深圳市黄浦淮安路P座 492194', 1630000000044) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630660000000, 484949428, -5416390991488308737, -14887, 67, 2398644.783561, 8171275.544491, 0, 'binary.BizAmDZxfvTsgphmgDgO', 'nchar.新疆维吾尔自治区齐齐哈尔市秀英杜路h座 144209', 1630000000044) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630659999999, 1440457969, 8606030504343208767, 24314, 96, 92496.379572, 0.813941, 1, 'binary.xAmVpiYdockKtVmdHSIc', 'nchar.河南省平市海港龚路P座 644038', 1630000000044) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630660000000, 1069631125, 7783641181026641655, 29140, 58, 69214.199993, 158732124515.929993, 1, 'binary.SBJQcfJBwhXLUJwatImS', 'nchar.广东省强市怀柔哈尔滨街L座 103945', 1630000000044) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630660000001, -899220871, -9196200436704202533, -27771, -90, -73.878944, -8912.628710, 1, 'binary.VQcAzgArqSQQZnbSiMNU', 'nchar.天津市沈阳市东丽西安街g座 810520', 1630000000045) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630660000001, -1450060823, -615484698684325866, -16629, -4, -8.793729, -23575246237039.601562, 1, 'binary.AESWGdfihvaPnTfmDemj', 'nchar.宁夏回族自治区帆县江北石家庄街M座 983792', 1630000000045) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630660000000, 1278398866, 5363278013106925425, 29093, -83, -70828.447306, -526391.541525, 0, 'binary.iFAFqKguHdrdQhGoCpuS', 'nchar.江苏省刚市江北东莞路b座 826956', 1630000000044) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630675000000, -1081748955, 720719842133998595, -22633, 24, -73662437394.636200, -2235207.112560, 0, 'binary.CdInxRzeRZrFBbTOVcoH', 'nchar.台湾省六盘水县兴山石家庄街l座 541218', 1630000000045) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630675000000, -1665303728, -6208374964158196325, -17938, -26, -12.743038, -6410996304252.719727, 0, 'binary.ESErZzoVFrwLvZLjvszF', 'nchar.宁夏回族自治区兵市南长沈阳路A座 196143', 1630000000045) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630674999999, 1830689374, 6847266081436213038, 27195, 56, -98.825225, -11.841657, 1, 'binary.bKBmkbDmVObIaINgcUkt', 'nchar.宁夏回族自治区六安县东丽黎路Z座 360011', 1630000000045) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630675000000, 905604744, 5992591234700515548, 30228, 29, -771431291465.423950, -75930131567683.500000, 1, 'binary.uJqjLxypwZAqCJHRMkKo', 'nchar.吉林省艳县城北贾街Y座 511120', 1630000000045) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630675000001, -1874157012, -4583327710928801759, -27522, -76, 53914287540.938499, -9385422.995425, 1, 'binary.wycnNJGrIpmtWWvFxuJY', 'nchar.宁夏回族自治区云市孝南江路A座 778572', 1630000000046) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630675000001, -1498560711, -9199781197179273356, -25882, -75, 4614968554.698110, -96421428706.153503, 1, 'binary.OOYjhYdCGZQViNShXiSg', 'nchar.吉林省惠州市江北关岭街W座 967516', 1630000000046) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630675000000, -596563585, -8961615493016741888, -10813, 102, 75.123805, 6555481001.569020, 0, 'binary.DVXQBGshLAcqMWMMeiDT', 'nchar.山西省桂兰市涪城佛山路C座 407229', 1630000000045) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630690000000, 81214187, -3182813081122938906, 4960, -50, 518940275802.109985, -7999305661.759080, 0, 'binary.fkEdEbNuIkBTKcrHnEjx', 'nchar.新疆维吾尔自治区佛山市怀柔呼和浩特街P座 745345', 1630000000046) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630690000000, -1132347210, -6643466065281753528, -27772, -3, 8162664758739.139648, -13662048540.698799, 0, 'binary.KmKfzpIUppEqzuPvExem', 'nchar.四川省莹市牧野哈尔滨路j座 521095', 1630000000046) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630689999999, 1019010549, 6975314636031351786, 28464, 43, -465.888140, 8910415.572030, 1, 'binary.rBiBGLvfQWmnGDquOTbn', 'nchar.广东省雷县南溪宋路F座 681268', 1630000000046) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630690000000, 378275737, 876425613508142928, 15367, 120, -49.379488, 7567.687919, 1, 'binary.BTwfiAxrnagWWuCCCSZQ', 'nchar.北京市南昌市南长香港街i座 314362', 1630000000046) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630690000001, -533673302, -4156210237594471836, -17141, -10, -931105.914523, 799382106.862106, 1, 'binary.NqTaorSXMNHGbcIiftLN', 'nchar.香港特别行政区淮安市牧野石家庄街R座 897882', 1630000000047) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630690000001, -1935282932, -2743254909741386818, -6325, -67, 25114142.334721, 78.857657, 1, 'binary.hLaIbMlaSZIaojoxNNAG', 'nchar.湖南省邯郸县新城重庆路W座 451361', 1630000000047) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630690000000, 693093205, 1731593666471158488, 32616, -34, 944511.517342, -3.585256, 0, 'binary.JGrrPFPHkdvblDPQLBzo', 'nchar.安徽省艳市龙潭陈街I座 824093', 1630000000046) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630705000000, 1768911737, 5728476461209604096, -29190, 66, -6177089795.760590, -21430.400483, 0, 'binary.KANmXakVbwmKTQEcoIkv', 'nchar.吉林省帆市静安福州路e座 331035', 1630000000047) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630705000000, -248617365, -4341045528963124184, 31755, -98, 124670342.644870, -654637491670.374023, 0, 'binary.IzfBodxsdDxJktqQeDDU', 'nchar.浙江省秀芳县黄浦郑州路L座 115314', 1630000000047) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630704999999, 27001027, 339256900217870846, 11700, 1, -1455323856048.100098, 447841.805243, 1, 'binary.tMfHAqfBuEMKIckNFKLY', 'nchar.内蒙古自治区亮县清城陈街k座 990698', 1630000000047) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630705000000, 1581778818, 8464425008394999321, 20061, 5, -5247104654.611190, -568125.266376, 1, 'binary.JAXQCWWoDrpJuxVSlCNu', 'nchar.宁夏回族自治区萍市安次六安街H座 295531', 1630000000047) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630705000001, -732869228, -2906753353691356694, -5441, -3, -109283.289234, 9159375.165842, 1, 'binary.VYdDCHOMFAhsntioQInn', 'nchar.澳门特别行政区璐县西夏海门街A座 607065', 1630000000048) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630705000001, -18474510, -5999800564410930013, -6311, -2, -398057879.913052, 8761.567919, 1, 'binary.fIJqDAvfpidoaJSJkpnq', 'nchar.安徽省宁德市浔阳长春街U座 799007', 1630000000048) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630705000000, 850296579, 8875126379280838717, 10524, 108, -2975287.612558, 0.445600, 0, 'binary.eoLmnRFaXvklftfvhFCU', 'nchar.四川省亮县东城南京路E座 405800', 1630000000047) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630720000000, -239418734, -7503726504441061411, -31831, 84, 69021572289.137802, -86475940923.449203, 0, 'binary.ApWGXJYAZWgkReWPsvDb', 'nchar.湖北省磊市璧山武汉路O座 323410', 1630000000048) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630720000000, -943706680, -214023538774872985, -12169, 127, 948155.120585, -65149.125324, 0, 'binary.sujGooIQzKvLdzqRekyb', 'nchar.河南省丽娟县华龙哈尔滨街l座 264772', 1630000000048) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630719999999, 1251825975, 5053354830656579627, 14919, 60, -7531018879634.370117, 310964263643.562988, 1, 'binary.RfrhrTWzkzBvUvupCUaE', 'nchar.海南省阳市平山马鞍山路I座 852814', 1630000000048) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630720000000, 1115544686, 4049894819935008122, 30814, 12, -75.765668, 1187804567.210350, 1, 'binary.hYtJJtMEzEnmlYixUssL', 'nchar.河南省哈尔滨县魏都杭州路z座 972095', 1630000000048) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630720000001, -1724765969, -736233583823352610, -6737, -57, 893.536927, -7421.472515, 1, 'binary.RsUbHbctLoVkgmtdCxjM', 'nchar.黑龙江省马鞍山市山亭孙街b座 213806', 1630000000049) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630720000001, -1986547513, -6324903826238608678, -14843, -46, 309302.506851, -614273917609.833008, 1, 'binary.vnLJpYckYTAcDOpDNuWh', 'nchar.天津市亮市南溪陈路q座 364119', 1630000000049) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630720000000, -1284939264, -9095077298976089415, -19239, -92, 31.280584, 7379.657977, 0, 'binary.knKChKaZsyhUfkgmgzph', 'nchar.贵州省兴安盟市淄川郭路G座 242776', 1630000000048) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630735000000, -762937350, 8729420312334257343, 27701, -108, -6.651477, -29.713736, 0, 'binary.fpjgqsvwAKHintMJaYER', 'nchar.黑龙江省淑华市花溪宁路W座 152088', 1630000000049) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630735000000, 1144380216, 5276665732684544642, -11205, -89, 8215.254115, -99811752553.775497, 0, 'binary.FflDToYYzhVTnyRGzKGA', 'nchar.江西省南京县金平孙街c座 254949', 1630000000049) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630734999999, 1075377727, 9020113518015848371, 11084, 28, 307417.308042, -87.561190, 1, 'binary.kEOyxbKVdHlFqhZZzYwq', 'nchar.青海省佛山市安次深圳街Z座 504751', 1630000000049) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630735000000, 582692563, 4638155561099114479, 23761, 48, -29824236570673.398438, -10200.908461, 1, 'binary.XziirLIHCuFKtpiXVrTy', 'nchar.广东省帅市西峰张街h座 174088', 1630000000049) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630735000001, -1716643044, -8326169264977759340, -4200, -30, -2.318414, -726141333.615880, 1, 'binary.FZBESQUiuERkOgEMEfQR', 'nchar.广西壮族自治区英市海港汪路W座 657875', 1630000000050) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630735000001, -686568708, -4371717027180867061, -6734, -88, -578830467.970145, 9456.996341, 1, 'binary.ybxyxSLSKWvhXIhIuTZo', 'nchar.西藏自治区鹏县华龙邯郸路K座 280464', 1630000000050) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630735000000, -463229385, 8322975415402188951, 7658, 81, 48067565948.430801, 1684.497042, 0, 'binary.VCPIPiYLkNeWVJRVYdAa', 'nchar.江苏省伟县新城杭州路U座 135067', 1630000000049) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630750000000, 229305482, -8755922362006582494, 15607, 16, 433186324.150179, -9760091.526296, 0, 'binary.vzKjmFtaWUQJWUmLYsoF', 'nchar.广西壮族自治区潮州县璧山深圳街u座 513872', 1630000000050) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630750000000, 887769742, 8828265476094538774, 15810, 6, -52009423024.988998, 457109451.488690, 0, 'binary.lFOSpWYYjCkwLqOGSclj', 'nchar.广西壮族自治区伟市大兴李街A座 575739', 1630000000050) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630749999999, 806743984, 7134986215003200921, 17680, 41, 80628998.429324, -398852949.893027, 1, 'binary.KNgNzEsWMMOErSdhZARB', 'nchar.台湾省大冶县西夏辛集路B座 294228', 1630000000050) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630750000000, 1218616066, 4338651506702922568, 20337, 121, 607218.969786, 29540695532115.398438, 1, 'binary.hXxPnZwhSlMFInaNEPGO', 'nchar.上海市桂兰市金平刘路x座 286919', 1630000000050) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630750000001, -592467708, -3107486233936469903, -26640, -37, -77805664.682649, -1730.324950, 1, 'binary.fpSPyrjwsVtXzEHRGCaS', 'nchar.福建省沈阳市东城张路k座 869492', 1630000000051) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630750000001, -547550314, -5200749799296792327, -27549, -59, 2034147.803264, 96891027.798801, 1, 'binary.cyVZnAOokBmkMGIbacqs', 'nchar.江西省宇市蓟州唐路K座 406871', 1630000000051) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630750000000, 756019639, -653863967829096798, -30967, 59, 68379.967777, -1154096688678.510010, 0, 'binary.fHCaNBTuAEHvVNpuNcxn', 'nchar.安徽省宁县永川东莞路X座 798708', 1630000000050) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630765000000, -1406057540, 1446134498171766899, 30680, 68, -9307952080739.890625, -1153314466.810470, 0, 'binary.aDuEaSxjYaNCTgFqMHlC', 'nchar.西藏自治区红县静安黎路I座 596984', 1630000000051) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630765000000, 133613101, -1336954935529805727, 585, 116, 30.398745, -613552078.887368, 0, 'binary.NgMivPQObBgUbKnAwWEj', 'nchar.湖北省金凤县门头沟刘街f座 712446', 1630000000051) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630764999999, 656042024, 1646194287674616827, 26191, 10, 6678822.415847, -95361406615.342804, 1, 'binary.LZeGatPnXBHGNQggCUgW', 'nchar.澳门特别行政区西安市清城汤路p座 810444', 1630000000051) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630765000000, 1983919127, 7730061788745380233, 12586, 75, 10716267.549970, 7.199934, 1, 'binary.rnitdHGQBawBYXtOfvDJ', 'nchar.北京市玉兰市清河海口街u座 800278', 1630000000051) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630765000001, -1382937017, -109262277060062044, -24986, -53, -431535423232.208008, 34209788.409645, 1, 'binary.WSTgldQbIqYUaOeVUhSk', 'nchar.云南省秀英市涪城张路H座 199974', 1630000000052) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630765000001, -1301473352, -6756208355269860322, -17139, -45, -689118.755923, -3373577.841810, 1, 'binary.rcYvJxobOrraprgqcGvR', 'nchar.台湾省洋市花溪宜都路I座 962472', 1630000000052) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630765000000, -691470080, 1659254673769147544, -23790, -47, -429810768489.799988, 93436.707719, 0, 'binary.SxTTHFObymUpnuAfgYSQ', 'nchar.贵州省海门县西夏海门街a座 133401', 1630000000051) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630780000000, 921298258, 8536844726148128680, 3660, 26, -34185874.434563, -26620.589344, 0, 'binary.xevnfxQByaOjIEnqHaqe', 'nchar.重庆市华县山亭赵路b座 801493', 1630000000052) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630780000000, 1233028572, -8019335724423257023, 31663, -58, 14.142909, -50404.483362, 0, 'binary.MgKDUmZIKAlVhLpazpsJ', 'nchar.青海省永安市清浦彭路P座 393906', 1630000000052) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630779999999, 1876585459, 2853158241768185532, 24232, 50, -38916414122.860901, 6486812.485190, 1, 'binary.fafedlhFPmPAyJJGuMuZ', 'nchar.青海省潜江市秀英沈阳路X座 835387', 1630000000052) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630780000000, 1194165890, 7697386066201959752, 12368, 15, -7467278746696.700195, -979006.127435, 1, 'binary.sEHpIDvtRWaxcUbqPHAn', 'nchar.新疆维吾尔自治区大冶县高明项街d座 680148', 1630000000052) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630780000001, -1899593535, -1379716049261187467, -26105, -97, -17.445226, -149.378109, 1, 'binary.sHyQLVjnSTQSXpcWxHjq', 'nchar.安徽省杭州市城东郑州街M座 499265', 1630000000053) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630780000001, -1856641529, -4102589906454836588, -24873, -61, 97710303188.778000, 9646.234878, 1, 'binary.fKSswvhHhMTcaIjfaUUk', 'nchar.安徽省建县牧野杨街U座 584763', 1630000000053) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630780000000, 542554488, -3045723568122762779, 18580, 33, 95242718247053.500000, -50170311.264161, 0, 'binary.PUzrCqSyZiemQmkCCdGz', 'nchar.重庆市玉兰县永川汪路N座 270623', 1630000000052) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630795000000, 1864777486, 9048501077169003317, 32497, 90, -21112693476.624199, 960.488977, 0, 'binary.EEwLsBOCVnXbQbGiHwjl', 'nchar.河北省天津市魏都徐街V座 183214', 1630000000053) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630795000000, -1607594419, 3244019062872113101, -3112, -38, 4371695.605750, -76333.232422, 0, 'binary.FoXqOarMdnRuIkzdWEfn', 'nchar.安徽省石家庄市上街李街j座 287811', 1630000000053) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630794999999, 173077592, 5900121444981917372, 31259, 47, -9.692719, -36537321184.241699, 1, 'binary.hAZkGTgZudTvNdAfGCrG', 'nchar.黑龙江省林县长寿长春街H座 568159', 1630000000053) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630795000000, 1357591704, 8166773293007138161, 11502, 15, 9824768605988.179688, 899.269307, 1, 'binary.ORKiLvVsgwUaMmmVzXYK', 'nchar.浙江省西安县海港关岭路w座 192982', 1630000000053) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630795000001, -1842197906, -1075636322848135854, -11343, -9, 9085057779.572281, -9427483311859.769531, 1, 'binary.urBDWyTekFLJVKfewubE', 'nchar.江西省静县高港辽阳街W座 980270', 1630000000054) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630795000001, -1534128171, -4579657021740144805, -28105, -23, -265482542779.970001, 74780.975545, 1, 'binary.sEpkrqnSpFfYKIgeSBvK', 'nchar.澳门特别行政区西宁市龙潭六安路X座 127241', 1630000000054) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630795000000, -760013920, -8462295357527459170, -31765, 11, -433.960695, 264.431691, 0, 'binary.DroLRaBIftSwkoEbBZUl', 'nchar.山东省丽丽县黄浦谢路f座 644732', 1630000000053) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630810000000, -1675325589, -360996985377003606, -2347, 24, -470.741524, -887230390.331345, 0, 'binary.udlpjXsecEvxMZCZyvrV', 'nchar.江苏省银川市山亭太原路J座 723211', 1630000000054) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630810000000, 1632642973, 7850590523192382300, 13631, 45, -47687.239109, -81863875.566057, 0, 'binary.jmfRTYATfWhgLdSwABgZ', 'nchar.新疆维吾尔自治区长春市龙潭刘路m座 413049', 1630000000054) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630809999999, 1959334832, 4568407287596246175, 27961, 84, -665950847.396483, -29596243749715.199219, 1, 'binary.JOlrzeKxQTwVbozdztiV', 'nchar.山东省广州县高明张街C座 757018', 1630000000054) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630810000000, 1375371462, 4011481089622391741, 11886, 126, 4.397144, 4202513.398747, 1, 'binary.EblbpxwjuFqWmvABRtpz', 'nchar.香港特别行政区坤县南长王路W座 576754', 1630000000054) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630810000001, -1132521267, -4710706752937901089, -27234, -102, -277590425.724995, 292916.997240, 1, 'binary.DaNIAqljzrMdiAdtjNrB', 'nchar.江苏省畅市梁平秦路K座 961783', 1630000000055) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630810000001, -394127423, -4195198128268963203, -5174, -112, -37786616.462910, -750832.942933, 1, 'binary.rDUuOHQMIpSTjzaBeDKl', 'nchar.青海省亮市城东惠州路R座 997920', 1630000000055) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630810000000, 415436252, 7840392447567623067, 18496, -2, -20101885975.533798, 789.450282, 0, 'binary.CIlEgPRwfDUmqTEAjBrU', 'nchar.山西省桂花市高港张家港路B座 439810', 1630000000054) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630825000000, 1382842369, -3387166153829557613, 5113, 67, -14533655399834.400391, -47045088950.955902, 0, 'binary.fdwVbTqALVxEKqxPmklJ', 'nchar.香港特别行政区桂芝县沙市桂路K座 439607', 1630000000055) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630825000000, 122830188, 5944964533814104404, -4275, -2, 503740.982450, -2713577716.766000, 0, 'binary.KnHTmENdKEWNLWdfvFxb', 'nchar.内蒙古自治区婷婷市大兴乔街a座 468770', 1630000000055) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630824999999, 609279903, 9143142539302518131, 18578, 58, 6.776714, 7355.869852, 1, 'binary.PsdCUwiiFfTfBdYWgMIf', 'nchar.广东省巢湖市高坪关岭街z座 165945', 1630000000055) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630825000000, 1229687800, 6229049320529684281, 13288, 61, 1136575.519568, -474.263794, 1, 'binary.UtlqumZjObldYJWTCHVF', 'nchar.上海市玉梅市城东陈街K座 187484', 1630000000055) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630825000001, -902381702, -6581003712798510587, -16241, -42, -136567151.288395, -81351450.825485, 1, 'binary.vZnItDAvBlQXFtrMrdAk', 'nchar.广东省合肥市闵行南昌路a座 421030', 1630000000056) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630825000001, -1633588040, -9147247193490618424, -16771, -115, -2.864546, -4.968001, 1, 'binary.OChQYNfkTrcSaZTJGfhO', 'nchar.云南省淑兰县牧野农街t座 752385', 1630000000056) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630825000000, -997989279, 7637562832426174518, -5, 72, 1838649266.575190, -32247151699394.300781, 0, 'binary.fLcdsxEDyCdsbzARmlzG', 'nchar.吉林省娟市秀英潘街u座 599699', 1630000000055) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630840000000, -1691466505, 3835361758424457104, -21465, 99, 17.423367, -927580467091.141968, 0, 'binary.ExYLmKXMaFjayqkBEWqC', 'nchar.浙江省乌鲁木齐市东丽康路s座 780818', 1630000000056) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630840000000, 990486101, -6476848417158885996, -6947, 34, -91088473.667455, 443265343.199751, 0, 'binary.dyTxrTzimrnLgwtLehEp', 'nchar.海南省帅市金平兴城街F座 303386', 1630000000056) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630839999999, 1355859529, 2260526383089822706, 30660, 63, -672086975563.209961, 9219879.518002, 1, 'binary.EEjtfcofhSPxOuFgMlug', 'nchar.山西省凤英市长寿胡路d座 722345', 1630000000056) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630840000000, 720225284, 8056479222648510406, 7870, 107, 3.205667, -15331943645.198200, 1, 'binary.qBFljuOsopeYwpczltun', 'nchar.海南省杭州市锡山杭州街Y座 563787', 1630000000056) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630840000001, -1666639404, -1502779151523040369, -32737, -27, -720231064.559860, 9483852418979.500000, 1, 'binary.sDGclxLTrGjIYGBWUzox', 'nchar.江苏省颖县华龙奚路M座 347083', 1630000000057) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630840000001, -513166008, -1798257110690905490, -17212, -65, -6875665232.854830, 1.501719, 1, 'binary.JioYSyYNMAmHQGKIwFpt', 'nchar.澳门特别行政区畅县永川淮安街i座 315960', 1630000000057) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630840000000, -784030741, -771760196117941650, 5269, -23, 488442494858.158997, 142.977034, 0, 'binary.RyfovtjrYYDbDQEVcHoA', 'nchar.福建省帅市兴山合山街z座 360892', 1630000000056) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630855000000, -759466985, 3260110813666913849, -21345, -118, 6001735483.766000, 811956391.434487, 0, 'binary.FgtcgDCGdWGhileXYeVC', 'nchar.辽宁省敏市城东潜江街t座 539658', 1630000000057) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630855000000, 1791483134, 1877345879709438108, 7122, 108, 649645.697610, -3.176571, 0, 'binary.VOAUXbpzoEXTfEombqFu', 'nchar.湖北省建国县双滦昆明街k座 555641', 1630000000057) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630854999999, 819862528, 8086075097163190658, 28478, 59, -8892423630966.660156, 927321477.432369, 1, 'binary.gEIBgRUfuMarfhivmcmN', 'nchar.海南省海门市沈河季街o座 938191', 1630000000057) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630855000000, 575972371, 8165684898549408541, 26532, 30, 2158.716179, 6332790959904.230469, 1, 'binary.RzgEyNIsdJwDbkhjuZhn', 'nchar.广西壮族自治区哈尔滨市双滦薛路M座 750545', 1630000000057) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630855000001, -568694685, -6156824576786534987, -5004, -80, -8796651.346065, 4.370643, 1, 'binary.vDKHYEXPpBzKIFbWrBHH', 'nchar.四川省春梅县永川董路R座 716271', 1630000000058) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630855000001, -202484706, -7242157303332761279, -5895, -39, 1369656077.152570, 45024.146483, 1, 'binary.UTIcQraFLhrzeKZQNGad', 'nchar.陕西省大冶市大东陈路V座 230063', 1630000000058) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630855000000, 968718547, -7083502452755942963, 30186, 34, -808.116870, -355374.445932, 0, 'binary.FIxenkYBuIDmoaBpvKJr', 'nchar.内蒙古自治区想市闵行合肥街m座 213729', 1630000000057) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630870000000, 259545745, 6793904417678601057, 29752, -91, 35083182.940608, 4579746.564176, 0, 'binary.wmnksDymOwGQownBXGRS', 'nchar.湖南省上海市淄川陈路f座 699980', 1630000000058) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630870000000, -798452451, -1421146164509922388, -30643, -44, -532.819299, 864903894.997066, 0, 'binary.FofIkZDYExLKhITHZjpy', 'nchar.北京市静县长寿刘路V座 929762', 1630000000058) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630869999999, 810375591, 6862940885997459592, 12888, 67, 1.743840, 42697.428148, 1, 'binary.OrGwClCMpfhfshmaeYAS', 'nchar.安徽省坤市长寿许街s座 864780', 1630000000058) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630870000000, 2141142518, 330171567484187630, 5038, 87, 73252.885684, 88624.734440, 1, 'binary.cdSnMdwrroFKtbPAJSbg', 'nchar.安徽省沈阳市清浦汕尾路C座 749970', 1630000000058) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630870000001, -702799898, -322816941471556942, -1394, -123, 9456805.646888, 2105.641243, 1, 'binary.rTaTBdXbBszZjTTwracU', 'nchar.四川省玉市海港大冶路h座 545972', 1630000000059) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630870000001, -706124307, -5958027025637340951, -30853, -27, -7966.705252, 2.270573, 1, 'binary.eOyuShSfdOAmaSNhUZUv', 'nchar.河南省长沙县萧山毛路H座 196587', 1630000000059) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630870000000, -486193469, 7258930411934958638, 23283, -84, -6.193098, 11.792424, 0, 'binary.KGiDWTZdgHETHLJePGIT', 'nchar.陕西省丽市白云兰州路x座 161175', 1630000000058) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630885000000, -282533404, 7684010141772871588, -23850, 17, -2997190086014.000000, 931579019.615816, 0, 'binary.kZsMznDmRkjSoUQCWmtw', 'nchar.宁夏回族自治区汕尾市清城北京街c座 432095', 1630000000059) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630885000000, 1596401672, -5390915537011895583, -19578, 118, -9665.572275, -7154265.495520, 0, 'binary.JkHelKKoDnnJzPHiEROB', 'nchar.西藏自治区晶市梁平梧州路b座 369190', 1630000000059) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630884999999, 1840788362, 568759292490183791, 18205, 21, 16.931152, 17691.251149, 1, 'binary.EDicJkxTXgqUtLXKDjKy', 'nchar.新疆维吾尔自治区勇县蓟州沈阳路U座 172773', 1630000000059) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630885000000, 365787442, 1666872794496374179, 13837, 37, 193390765070.401001, 546707.447097, 1, 'binary.lmEGkvWshsqnAktNzJbB', 'nchar.重庆市桂花县南湖巢湖街U座 689551', 1630000000059) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630885000001, -745755820, -8898782181578548041, -7682, -15, -443.639102, -255152262.128928, 1, 'binary.MWmdVCjrANIfsdHAAVmb', 'nchar.河北省淑珍县长寿谢街k座 131370', 1630000000060) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630885000001, -2029500216, -7380552851400848492, -3516, -8, 8.915821, -51.793696, 1, 'binary.vQnridOAWDVWkJYYdTtF', 'nchar.云南省六安县海陵宁德街t座 241913', 1630000000060) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630885000000, 1648193924, -5763807398275594930, 27798, -65, -3.657749, 9559111883869.490234, 0, 'binary.VLogQYbaHPpPpmgyuzos', 'nchar.台湾省志强县和平刘路a座 827192', 1630000000059) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630900000000, -997698344, -4360698110328218759, 31934, -79, 8770449833.941080, -71856107060.251297, 0, 'binary.trhWcwdEKeoGUcQdImgV', 'nchar.天津市西安市牧野天津街q座 880750', 1630000000060) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630900000000, -492616894, -7002758781471003065, 28164, -11, 4740658.868259, -5320539.530775, 0, 'binary.TzdNtGFTXZWMADJaayqx', 'nchar.西藏自治区西宁市秀英杨街A座 353774', 1630000000060) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630899999999, 1825013146, 1744104394556381743, 31778, 117, 908811698547.689941, 42.982948, 1, 'binary.FtOgWPVAvygSIYsTWnHX', 'nchar.澳门特别行政区梧州县海港六安路D座 341014', 1630000000060) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630900000000, 2076832076, 3306826763175476238, 29009, 65, 654125.128750, 23.786689, 1, 'binary.yRAQxkeArOAnSkFHvhjQ', 'nchar.青海省南昌县清河澳门街f座 357735', 1630000000060) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630900000001, -364752002, -5092648072975157908, -23087, -39, 9.504646, 93358807.508628, 1, 'binary.sFAvwLkiYcepPputybEK', 'nchar.四川省文县萧山惠州街i座 903240', 1630000000061) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630900000001, -1784446385, -2802855779017240513, -5552, -54, -860449735702.189941, -703215980204.104980, 1, 'binary.RtSNrxogNuhOoRhEPrMJ', 'nchar.青海省静市孝南李路H座 399925', 1630000000061) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630900000000, 1445349008, 992848000519415190, -17518, 28, 4014000610.625470, 592.602654, 0, 'binary.IFSsgUZILZuPRwXTuFEw', 'nchar.海南省沈阳市六枝特长春路n座 155408', 1630000000060) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630915000000, -134082975, 4026898983947505460, 20740, -64, 24146076.871632, -207518516.166626, 0, 'binary.irWEJqxWnIlrKDExOAvg', 'nchar.天津市太原县吉区拉萨路D座 176064', 1630000000061) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630915000000, 1299050318, 3065792171140876784, -12329, -3, 74005.658734, -418157994.246836, 0, 'binary.sqAYHZcIIihZMMauybjG', 'nchar.内蒙古自治区桂花市城北阜新街y座 784832', 1630000000061) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630914999999, 711052785, 2718796412708678637, 32243, 69, 4069895314.170900, 38406.385424, 1, 'binary.UgajoEPkcVXcWkUCGwkP', 'nchar.安徽省桂花县房山傅路O座 240748', 1630000000061) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630915000000, 2140137646, 1082661109056257532, 23250, 103, -44495004919076.296875, -7284.922434, 1, 'binary.ryfAsYaeEOkhesQMRitO', 'nchar.台湾省玉华县徐汇杨街C座 637917', 1630000000061) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630915000001, -1403755208, -3324715225642465377, -15193, -53, -3142.782618, 1794554.528658, 1, 'binary.aOAYKsmWzKDqjOpbOYrJ', 'nchar.河北省倩市清河黄路t座 205485', 1630000000062) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630915000001, -361144599, -8536611280568601202, -8124, -93, -13513340.923311, -20153.231767, 1, 'binary.XgncJmqFHazSpRWcMVeT', 'nchar.澳门特别行政区帅县清城深圳街j座 501390', 1630000000062) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630915000000, 929886382, 6830786048646808920, -26587, -84, 201249126.540132, -33020.844039, 0, 'binary.kUqBGPosKRCkaijDufGt', 'nchar.陕西省澳门市蓟州祁路C座 345922', 1630000000061) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630930000000, 1849726714, -3222927126454669927, 21701, 35, -764955573301.579956, -677588544809.604004, 0, 'binary.mXWIcnTunwqEKbKnJsRO', 'nchar.青海省云县南湖张路t座 577114', 1630000000062) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630930000000, 1948380077, 1829472867218108411, -2841, 62, -585408.996552, -8.398878, 0, 'binary.fZDJrrryXodeitdEZiDN', 'nchar.天津市辽阳市平山深圳街O座 892463', 1630000000062) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630929999999, 215833483, 6741487167704692542, 24982, 99, 7.720103, -4484984.118093, 1, 'binary.PUhvTciOFJERTXpNFDMf', 'nchar.海南省雪梅县萧山夏路s座 884246', 1630000000062) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630930000000, 283066224, 1560470331627072050, 2152, 14, 23735906455.603001, 977.642371, 1, 'binary.LQZzMIDAEVyjgirFHORu', 'nchar.河南省秀梅县房山黄街D座 578931', 1630000000062) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630930000001, -1383444081, -404967010555838935, -20478, -67, -29413948653.431301, 2289249875341.339844, 1, 'binary.gGaUfmagkabfKeDUnCCo', 'nchar.江苏省冬梅县六枝特张路g座 635526', 1630000000063) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630930000001, -821980909, -1357071288288006358, -23706, -57, 6152.175178, -26066560.757762, 1, 'binary.kmxekdKOIgvNnCSEZlwN', 'nchar.上海市宜都县双滦王路P座 262541', 1630000000063) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630930000000, 713911469, -6504806039884313820, -32386, 118, 431693877138.190002, 7127294.830732, 0, 'binary.FArXPzfLVQjsNuWiHLrQ', 'nchar.宁夏回族自治区秀华县长寿钟路t座 443656', 1630000000062) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630945000000, 1000635145, -6949456453535507535, -32142, 99, -7613228535871.339844, 5.367833, 0, 'binary.yafjOZqJhdMZFCxrvkjO', 'nchar.天津市志强县上街陈路g座 745449', 1630000000063) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630945000000, 2094975637, -590793247049504295, 92, 70, -846255.238019, 37.423177, 0, 'binary.IBHCEHNtLvmkpSCmVjQg', 'nchar.台湾省桂芝县华龙合肥路b座 733142', 1630000000063) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630944999999, 792673522, 2133996305758691365, 11545, 90, 8043187112236.719727, -328687222.743009, 1, 'binary.ZJIzomZBnRwLgnTtcylc', 'nchar.安徽省波市清河卢路e座 142743', 1630000000063) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630945000000, 1815853908, 1589355425036470987, 22184, 52, 8.753561, -0.772172, 1, 'binary.eqnhiDmrJHLxSTqywNzp', 'nchar.广东省合山市朝阳佛山街y座 254118', 1630000000063) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630945000001, -1908151355, -8449086371025617726, -31176, -107, -226488394.744318, 522688593.135097, 1, 'binary.mOQahkNsfbxPPiCysDOX', 'nchar.新疆维吾尔自治区潜江县魏都昆明路q座 187031', 1630000000064) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630945000001, -177205853, -5927588760169982955, -1616, -89, -3.764988, 22268450673521.398438, 1, 'binary.dIMAiZxTGtcVSpGTvrOy', 'nchar.重庆市南昌市房山上海街U座 493109', 1630000000064) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630945000000, -271977227, -4833640128107527469, -29661, -35, -25823270909397.800781, -215115.472476, 0, 'binary.FJHanbZZKKPTINTvFuJu', 'nchar.山西省太原县普陀海口路z座 522140', 1630000000063) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630960000000, -1061924199, 80315342405283554, -5983, -53, -35303358.173361, 823245211.259967, 0, 'binary.DHcLdCgRElelyoEjXxxo', 'nchar.云南省辽阳县兴山许街Q座 204291', 1630000000064) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630960000000, -2008448047, -2507465824745412203, 5703, 39, 3073425.192830, -4127246.560225, 0, 'binary.PGGakvXluJKSczwfkbFA', 'nchar.内蒙古自治区深圳市涪城韦路L座 184789', 1630000000064) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630959999999, 1731746435, 8656881002710317018, 24493, 42, -51366300790725.398438, 7057719908.426410, 1, 'binary.GcyDiiYlodcmmVYJcfsy', 'nchar.澳门特别行政区萍县长寿淮安路X座 216888', 1630000000064) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630960000000, 1535163067, 199892343902462919, 8312, 26, -5886360.892067, 99168508385732.296875, 1, 'binary.NajqJanSydLerCaBsTFl', 'nchar.西藏自治区六安县魏都邹路E座 600769', 1630000000064) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630960000001, -1744206201, -5989201622885398375, -9394, -16, -22156768397.647999, -313965437.622286, 1, 'binary.ljgVmLXQbdPjEOYMKEmN', 'nchar.辽宁省玉兰市新城邵街T座 422511', 1630000000065) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630960000001, -416139810, -6604173252994763764, -6397, -53, 826553399123.199951, 28094588.168751, 1, 'binary.hcinwRrwHHsWiQqvAaPk', 'nchar.山西省兰州县永川张家港路l座 400205', 1630000000065) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630960000000, 1411363822, -5559490192650806316, -24296, -124, -84520160618.765900, 48233.620153, 0, 'binary.duMCmTwWDPUzYzHdZrXk', 'nchar.海南省建国市萧山朱街m座 337644', 1630000000064) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630975000000, 63717118, -1781107297269354794, 14103, -107, 4455585.961990, -65419.341974, 0, 'binary.BlHycIqcHPSyynpSsDHt', 'nchar.广西壮族自治区桂芝市西峰史路K座 709908', 1630000000065) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630975000000, -108473967, 5316060064111515170, 7075, -74, 673543603.332905, 8011713.391465, 0, 'binary.ZsNVSCEilaFozvIMOgVn', 'nchar.山西省秀兰县萧山惠州街s座 291738', 1630000000065) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630974999999, 1701097332, 6995506575159608552, 22867, 47, 4495217807.100080, 38.526985, 1, 'binary.VTDyicwtvKBaCCmjUaDu', 'nchar.吉林省天津县长寿宜都路k座 930822', 1630000000065) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630975000000, 257457420, 8835364401886927960, 21297, 21, 0.844779, 716050955.344671, 1, 'binary.TCUqNtJoXousOXFzOaFV', 'nchar.湖北省旭县花溪宋街n座 825626', 1630000000065) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630975000001, -622389272, -4556948567877249858, -30519, -93, 3.569778, -2781.981860, 1, 'binary.SSnWtedSkSpZxzvsXKty', 'nchar.西藏自治区兴安盟县静安哈尔滨街c座 120405', 1630000000066) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630975000001, -84782654, -8863584638236264237, -5954, -44, -220.796336, 81484582682754.296875, 1, 'binary.tQzwvVqEIsBAxnymBEia', 'nchar.甘肃省永安市江北南昌街u座 555029', 1630000000066) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630975000000, -7406744, 4193139347325385474, -9523, 51, 96.656028, -858851298.663605, 0, 'binary.QfqialqEnUJEPhCtbzcy', 'nchar.青海省敏县淄川卢路v座 513752', 1630000000065) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1630990000000, 1127802865, 3673503514622188410, -1852, -113, -34837378.663679, -77832209110.181000, 0, 'binary.rdtbEFZKYFDDJcbwZQUI', 'nchar.上海市潮州县友好辽阳街J座 716345', 1630000000066) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630990000000, 222250382, 7102048992271642834, 30230, 0, -27475250902790.601562, -7.875430, 0, 'binary.okaTayFnJLFHVPbosPMw', 'nchar.湖北省娟县六枝特郑州街o座 923846', 1630000000066) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630989999999, 997138993, 291600547682899796, 8706, 49, 527231819.674759, -76.470030, 1, 'binary.gSCVCKyayTuQHeyozlnD', 'nchar.澳门特别行政区太原县江北六盘水路E座 813817', 1630000000066) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630990000000, 1527492158, 8131177329340856446, 16932, 24, -485902.216583, 47420.341433, 1, 'binary.xIJLktMoyieUcwAitKAf', 'nchar.广西壮族自治区丽娟县永川钱路D座 710055', 1630000000066) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630990000001, -1186362057, -8101517704046664109, -8133, 0, 15457163.632735, 790549863.502675, 1, 'binary.domgcCyjkvkGvnfhJchV', 'nchar.安徽省台北县蓟州张路V座 853541', 1630000000067) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630990000001, -2038096305, -9196878310965066696, -9437, -7, -8043032690399.879883, -3.291758, 1, 'binary.OXzBvNftjfwTqreAuCzo', 'nchar.台湾省西安市西夏贵阳路b座 196727', 1630000000067) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1630990000000, 22826804, -2627900666391071715, -20499, 51, 21.403443, -394389822812.973999, 0, 'binary.abnUGmLKuAKIaCxUeyBU', 'nchar.海南省玉珍县房山罗街t座 776991', 1630000000066) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631005000000, 808597268, 2078929531741697152, -30212, 18, -94851063704.977005, -73674.167661, 0, 'binary.hsfTIdNWdxTPvUwMVrpW', 'nchar.江西省桂荣市清河通辽路U座 806067', 1630000000067) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631005000000, -915524872, -8857255033160626964, 266, 91, 11153.892476, -331797474.177709, 0, 'binary.KRBAAEghraBqMLVZKLxR', 'nchar.河南省成都县浔阳傅路o座 233168', 1630000000067) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631004999999, 2045109124, 8620061599081376707, 21842, 65, -577475988406.473022, -230.252609, 1, 'binary.BdfsaHZLBvLoViCnpcaf', 'nchar.重庆市敏市涪城张街Y座 339115', 1630000000067) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631005000000, 667151973, 2042134679839477524, 30807, 18, 410455086008.659973, -111467516118.406006, 1, 'binary.MRXRSCLnwHZQLMuEpxxc', 'nchar.上海市秀英县南长南京街E座 857787', 1630000000067) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631005000001, -1754458857, -2336346102444691323, -21518, -78, -35328084917.622902, 6799588.766270, 1, 'binary.XKvGUqmEfwrFunqrTSnZ', 'nchar.广东省广州县西夏梁路f座 812202', 1630000000068) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631005000001, -1198184531, -2273612721150875492, -27273, -110, -5590.967174, -36.872012, 1, 'binary.mVuGzysfOhHacpboXfya', 'nchar.澳门特别行政区合肥市怀柔淮安路Q座 830162', 1630000000068) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631005000000, -806268791, 6849292639236533681, -6170, -10, 67.282833, 189646569.949903, 0, 'binary.TDFoHEPsCyCFagPtryZJ', 'nchar.云南省彬县淄川潮州路h座 848046', 1630000000067) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631020000000, -1073614153, 298267925059640970, -26581, 48, -95632.677072, -4.716783, 0, 'binary.VHldMJRfKiPhYVUwVuHn', 'nchar.黑龙江省南宁县清城曾街M座 383184', 1630000000068) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631020000000, 199565482, -5346899860399957284, -803, 119, 641654.245772, 6.968944, 0, 'binary.CdEpJsyAmonutUDWmrxV', 'nchar.山西省龙市新城任路n座 477007', 1630000000068) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631019999999, 117798603, 420439377677612553, 9253, 22, -1137.400660, -4635970947.218740, 1, 'binary.NJEFxITOCrCDbopXNjvy', 'nchar.广西壮族自治区通辽市华龙柳州路J座 634352', 1630000000068) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631020000000, 1124688237, 3000258188050272185, 14502, 16, -74396554878085.203125, -9.906537, 1, 'binary.sIxumMWCehMDSrpZPLqj', 'nchar.上海市峰县双滦荆门街i座 639698', 1630000000068) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631020000001, -1012596446, -5485827047721236689, -13273, -79, -85711452679.407806, -9188.884106, 1, 'binary.vCyjrKXeBvkNVeElgyZi', 'nchar.湖北省明县沙市武汉街E座 620206', 1630000000069) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631020000001, -460195462, -2468912047516302638, -8474, -48, 1519432858382.800049, 17871.504434, 1, 'binary.dixQMmtXAeagNODPIEEv', 'nchar.上海市阳市平山龚街J座 946821', 1630000000069) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631020000000, 1852200026, -6007978387233236224, 8798, -115, 421576343321.414001, 19100383480.317001, 0, 'binary.iRZrrVUoaDQXPuJZnyDI', 'nchar.贵州省南昌县合川成都路a座 820810', 1630000000068) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631035000000, -1253564785, 9123919785095917881, -15701, 31, -186733280.924988, -61.177294, 0, 'binary.NgOZqYryGuLTQMouuNHu', 'nchar.天津市鹏市沙湾兰州街O座 549919', 1630000000069) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631035000000, -1657246812, -4709259982252400503, -17351, -53, 81659768.995530, -7671201354.697040, 0, 'binary.nzcJiagtuSvVewKFNcaK', 'nchar.上海市天津市城北福州路U座 681143', 1630000000069) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631034999999, 1413434601, 2190691240505370364, 11770, 93, 3703815955153.799805, 8268264767.279480, 1, 'binary.oIubCOjKHdxCpeWbqIpp', 'nchar.陕西省秀华市徐汇合肥街s座 902856', 1630000000069) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631035000000, 1217613348, 7975114090727787456, 13738, 43, 355726833911.968994, -438162359629.995972, 1, 'binary.uLWXXVcGhcuWJiRaByBZ', 'nchar.河南省福州市东丽徐路w座 747585', 1630000000069) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631035000001, -2146084891, -23804698624528061, -29407, -115, 3824609640014.350098, -67783404809047.703125, 1, 'binary.RnZVUuAxugAtOZSTEkkn', 'nchar.青海省北京市门头沟陈路Q座 257513', 1630000000070) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631035000001, -1123855083, -2174482244567720750, -12610, -101, -13889290720.493999, -44730168.376831, 1, 'binary.bKiOAOxQmTuUxvfbdpdl', 'nchar.宁夏回族自治区坤市锡山宁德路j座 838367', 1630000000070) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631035000000, -1406844909, 6947966913619883113, -6412, -80, -5.700965, -15608.263924, 0, 'binary.ShuwgacOGYsjNECdcUUt', 'nchar.河北省婷市浔阳南宁路D座 449083', 1630000000069) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631050000000, 1665571243, 5875622308303693056, 26189, -3, 9184334500122.300781, 692.411491, 0, 'binary.mkdoDznGUjHxCWsEReic', 'nchar.天津市明市翔安王街K座 149828', 1630000000070) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631050000000, -866699485, 5150552413312365721, -26931, -72, 304388231344.469971, 1887123.429534, 0, 'binary.gXoNDsUhSIxwTtChSVKC', 'nchar.广东省阜新市牧野何街b座 893235', 1630000000070) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631049999999, 1647088140, 6276524783005291573, 18506, 126, 520220.525305, -11656506505.388300, 1, 'binary.uFvJUrDBxvRNfycpsATy', 'nchar.广西壮族自治区春梅县新城梧州街p座 914349', 1630000000070) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631050000000, 110172144, 3880079542176303291, 7450, 60, -70101821.922084, -766086105.175900, 1, 'binary.sGupuerrJMrewABhIOQF', 'nchar.重庆市永安市孝南东莞街p座 524436', 1630000000070) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631050000001, -2334950, -9174808951498480949, -25376, -56, -706896093828.322021, -7054905528.909860, 1, 'binary.eAsXnsSVfXpwSeWxjIep', 'nchar.新疆维吾尔自治区婷县清城李路R座 863352', 1630000000071) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631050000001, -1709242287, -1024364150913211829, -18517, -95, 612563.744410, 71675616881.702698, 1, 'binary.xwUGLqzyDiIWFYjQChPb', 'nchar.澳门特别行政区建国市东城汕尾街H座 310414', 1630000000071) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631050000000, -1438324283, -2616966529186093777, -15740, 119, -7052.121172, 6.860693, 0, 'binary.gwSKZcnvepcSGvGhQIhU', 'nchar.江苏省娜县安次长春街b座 373327', 1630000000070) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631065000000, 1572844268, 7954082573907623254, 28743, -77, 526200414.754712, -610.377887, 0, 'binary.dhmqewaCwxuZgymXkJYg', 'nchar.甘肃省六盘水市高坪刘街K座 997983', 1630000000071) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631065000000, -1997711328, -8305458100196327173, 15855, 65, -1.591103, 978771.885779, 0, 'binary.ErzqbmUDFqGBseJATzNB', 'nchar.福建省邯郸市龙潭天津路S座 700145', 1630000000071) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631064999999, 118186835, 7105850083426581209, 23043, 123, -294186.598870, 631977325.777490, 1, 'binary.jZYzFZwYbBOMfCYxLkEu', 'nchar.北京市宜都县山亭福州街B座 229199', 1630000000071) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631065000000, 84760302, 4023057210065827734, 20658, 50, -374538737.396905, 2.546280, 1, 'binary.GrfdYDSeONBkUWnVxrIE', 'nchar.重庆市关岭县兴山荆门街i座 354010', 1630000000071) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631065000001, -31117145, -6368825817854208301, -4679, -13, -193.784819, 9941696226439.189453, 1, 'binary.DtkHUqQYbIbRkWfoerGJ', 'nchar.湖南省建国市六枝特广州路d座 104163', 1630000000072) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631065000001, -1214911170, -3868394291968674672, -20441, -79, 567.284011, -99982135106.938004, 1, 'binary.LThAPucPiLueKWedudxF', 'nchar.青海省海门市牧野淮安街D座 825707', 1630000000072) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631065000000, 1697187351, 530203760413095118, -17911, -116, -501.905581, 98.459334, 0, 'binary.mEMXftUdsHdFpIbnKRsd', 'nchar.宁夏回族自治区峰市平山王街M座 201716', 1630000000071) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631080000000, 1610525794, -5290794365132208573, -15731, 123, -335854906.304436, -24139226804197.199219, 0, 'binary.daKMhFVbQQZKGiTKOlls', 'nchar.新疆维吾尔自治区坤市牧野武汉路f座 977660', 1630000000072) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631080000000, 1087333161, 2572492011929726786, 25923, -25, -4763484.301768, -5226373.298693, 0, 'binary.mmMznhJKAQPTjucpnZSc', 'nchar.澳门特别行政区杭州市南湖大冶街g座 395605', 1630000000072) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631079999999, 579193173, 5793829126142110648, 4490, 80, 78951.390551, 19287929360.243801, 1, 'binary.MUCIKFgmyfodWgXzBwpA', 'nchar.台湾省淮安市上街海门街G座 209332', 1630000000072) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631080000000, 1885599296, 5754849838280444727, 16958, 107, -53.481198, -9.937711, 1, 'binary.BrUGLflxCuUJqYeSVVsN', 'nchar.吉林省刚市高明夏路B座 373737', 1630000000072) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631080000001, -718949368, -4253205043582583806, -12561, -68, -134568795933.429993, -71046052762709.500000, 1, 'binary.gOwViQPVHLSImYonXzkV', 'nchar.台湾省红市永川六盘水路m座 707904', 1630000000073) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631080000001, -1419546071, -5628013404742242442, -19653, -61, 4641210572.820400, -516.363302, 1, 'binary.OhALrYMiHXSjCpcdfoPs', 'nchar.甘肃省玉华县高坪长沙路K座 553129', 1630000000073) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631080000000, 1801658141, 3654105358778411870, 18529, -80, 8.652081, -1554626.681517, 0, 'binary.GyuqMCRbacNJHUbGmkXh', 'nchar.台湾省芳市安次薛街o座 207547', 1630000000072) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631095000000, 2136843976, -1210226910088276755, 20600, 23, 539871237741.179993, 49233075000.644600, 0, 'binary.CoZYsjGjLcrAfxoNvULS', 'nchar.山东省嘉禾县平山呼和浩特街F座 641469', 1630000000073) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631095000000, 486220117, 2599712669438010104, -6519, 47, -0.673515, 55.218328, 0, 'binary.hUsJbjOwNFjCpNXnLWPF', 'nchar.广东省六安县秀英上海路E座 148463', 1630000000073) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631094999999, 17707398, 8375178158416972213, 1322, 112, -62111552150188.000000, -3.488348, 1, 'binary.iibUAdMnGmuQRjnCboca', 'nchar.海南省澳门市萧山冯路k座 476673', 1630000000073) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631095000000, 1540458244, 8608337136208602956, 13530, 122, -258.798333, -18390773070513.101562, 1, 'binary.dKifdiuRtzPzgDOgwskf', 'nchar.西藏自治区成市江北丁路k座 811706', 1630000000073) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631095000001, -295978274, -3611928104731611403, -928, -29, -349214171411.169983, 627603759.980824, 1, 'binary.tPAAsLZTOrrgDWhhbvPA', 'nchar.河北省深圳市和平李街k座 107359', 1630000000074) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631095000001, -1110370293, -2926428742790858456, -4685, -42, 594526965.911060, 979845489.815900, 1, 'binary.KCwadhHtPeNvxeOTurpC', 'nchar.四川省桂香市城北张路Z座 135595', 1630000000074) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631095000000, 1016372608, -248268842333445258, -24994, -40, -855742777.413557, 412898933.803171, 0, 'binary.oektpgoczIFkPkMZhePp', 'nchar.四川省楠市锡山王街T座 347259', 1630000000073) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631110000000, 1618012586, -4877738856165917254, -14321, -36, -2.446783, -8386.899686, 0, 'binary.cGuZNtDbGSgYATZIfhUQ', 'nchar.湖南省军县闵行沈街e座 942969', 1630000000074) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631110000000, 336517476, -2851549763879094055, 24260, 42, -284453185.760948, -82312598023267.500000, 0, 'binary.nNUcWFSnghHEXoJZyLSZ', 'nchar.台湾省玉英市海陵广州街D座 932017', 1630000000074) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631109999999, 325913454, 4965185676452141874, 1927, 45, 928.161230, 5002796.693905, 1, 'binary.KPSdukhCAQdFSCjoAXyb', 'nchar.天津市嘉禾市和平王街Y座 800951', 1630000000074) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631110000000, 2115611339, 5603712632691054487, 2040, 92, -88631.744485, -33319292708726.398438, 1, 'binary.nDvmXubKLBkwjQvBrowE', 'nchar.广西壮族自治区合山市大兴邯郸街C座 120130', 1630000000074) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631110000001, -416517208, -3563087064047686173, -32590, -97, 804.877418, -8174392626838.679688, 1, 'binary.yJGXGtGzgxaoyzDFNKzn', 'nchar.新疆维吾尔自治区建平市龙潭曹街X座 409242', 1630000000075) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631110000001, -1502953470, -2238010217654677886, -11068, -38, 69129137.954435, 599892.899153, 1, 'binary.OdnrQcfrzxIUYGMYkhgP', 'nchar.上海市霞县南溪曾路b座 536348', 1630000000075) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631110000000, 451771496, -7517497607249821959, -32099, -92, -213627.556542, -8726497.619554, 0, 'binary.DhxlHgZRZtmSyyhkGtuW', 'nchar.云南省洁县滨城梁路p座 996135', 1630000000074) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631125000000, 32878642, 8801402285444036889, 21539, 48, -596417925905.134033, 373248896.126035, 0, 'binary.RjzhwvLAyYAYYCfkjFJj', 'nchar.重庆市超县梁平温街z座 283315', 1630000000075) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631125000000, 71147814, -5159443215460099961, -15082, 102, 5968659.321019, -26592.753571, 0, 'binary.CljlscxcGjjciERgOxKg', 'nchar.宁夏回族自治区玉梅县吉区海口路d座 230176', 1630000000075) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631124999999, 1015662815, 4795567142964951653, 7167, 1, 325791556.701457, -143633938642.838013, 1, 'binary.JHrHPuhooNwLgDYQlFil', 'nchar.上海市玉华市门头沟长春街L座 619720', 1630000000075) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631125000000, 785489232, 7788643811202703115, 31943, 105, -9652684.346045, -250.125950, 1, 'binary.FkrDvYiLeZOqRVvYQpJr', 'nchar.贵州省璐市永川长沙街K座 573245', 1630000000075) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631125000001, -370350844, -2328721985404462718, -8114, -97, -65.996745, -23054596683.701000, 1, 'binary.YpDtIgmdxGtGOlkpYQbb', 'nchar.吉林省潜江市普陀哈尔滨街G座 354284', 1630000000076) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631125000001, -1104506218, -4613678193581849079, -1965, -116, 67350915247071.203125, -124.355022, 1, 'binary.cGsEpboYJbYsTSnKYKUz', 'nchar.宁夏回族自治区贵阳市永川刘街l座 557372', 1630000000076) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631125000000, -1975758915, -7017697117625132855, -2347, -78, 13301869.493635, 734276825210.396973, 0, 'binary.JMTLLJHKsHvKhVKhxUdD', 'nchar.湖北省淑华县上街郑路d座 249081', 1630000000075) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631140000000, -638220498, 7787936362129921947, 2622, -93, 80359528.879084, -6439.177632, 0, 'binary.KYZqgXaxguXpZiDTipOe', 'nchar.云南省台北县翔安淮安路T座 548657', 1630000000076) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631140000000, 1695929408, 6613622196219250257, -19521, 126, -294182.533903, 872281666.129710, 0, 'binary.bxqGrgGKqftbTFsJVxse', 'nchar.陕西省长春县梁平重庆街f座 969435', 1630000000076) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631139999999, 910799127, 3748990393909505200, 19872, 110, -1.774037, 962.107067, 1, 'binary.SMVCQwJbrLKRzlPTMAle', 'nchar.广东省淮安县南长陈路r座 442094', 1630000000076) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631140000000, 82578099, 1083300683395237822, 14840, 49, -2897441254294.259766, 78241.170285, 1, 'binary.zRnJDsiOdVdrjyezgNqk', 'nchar.新疆维吾尔自治区欣县上街郑州路T座 334404', 1630000000076) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631140000001, -1933040168, -8697939131006546022, -21092, -35, -3404654038.996900, 64905.498178, 1, 'binary.VlVdAdmtswNJQrRzSAPQ', 'nchar.河南省辽阳县长寿兴安盟路C座 114674', 1630000000077) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631140000001, -472785311, -4446555925790326535, -23024, -3, 430107081.785272, -5.140820, 1, 'binary.NUAVJEKQvBvlnJToDnoJ', 'nchar.河北省金凤县双滦石家庄街D座 264667', 1630000000077) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631140000000, -1325721293, 1101829200999493900, 13912, 72, 151194.856760, 931990832.169087, 0, 'binary.siTpYJVsmIUfmSUiacBG', 'nchar.海南省六盘水市房山重庆街R座 786868', 1630000000076) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631155000000, -622133611, 4304164307993590613, -1028, -75, -794.965943, 7129885424.126380, 0, 'binary.PxLiilJCeaWfrPEPswvJ', 'nchar.辽宁省齐齐哈尔县秀英王街V座 753913', 1630000000077) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631155000000, 601975873, -8460674145788246343, 26537, -18, -117.582363, 4.278494, 0, 'binary.DIEUsVGrYCIYpOHOMbYp', 'nchar.青海省玉市高港六安路n座 697115', 1630000000077) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631154999999, 794346686, 2813747690977192290, 19623, 118, -592938779870.880981, -691339105509.250000, 1, 'binary.IkXhYGsGOuGyQXxMcENO', 'nchar.新疆维吾尔自治区兴城市白云海门街z座 410778', 1630000000077) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631155000000, 2077153378, 6007901518953365006, 32590, 25, 8269699092873.599609, -3523058497792.450195, 1, 'binary.zDNlRsoVabJhMNFJfTBy', 'nchar.江西省冬梅县永川王路R座 198556', 1630000000077) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631155000001, -969135765, -1764680015243416710, -27020, -59, -8.491632, -14661.965520, 1, 'binary.jnObVGyDvkIgXvnFpKMn', 'nchar.广东省南宁县涪城沈阳路O座 754414', 1630000000078) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631155000001, -1576113711, -3627767440156041231, -18534, -66, 495.121273, 53596032.859107, 1, 'binary.lOIexILoDTNYoRmKXkCf', 'nchar.西藏自治区瑜县海港史路q座 848639', 1630000000078) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631155000000, -1548677743, -6457865964462190618, 21103, -53, -421862729108.307983, -2360116167608.370117, 0, 'binary.ZmmTgtzFlywNsFIAjzDE', 'nchar.台湾省秀荣市高港高街E座 134599', 1630000000077) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631170000000, 749993747, 3019243752157013695, -17619, 43, -1469831614725.439941, -6462342550.269600, 0, 'binary.PTOhqXMEYVQUAwAPztJg', 'nchar.广东省哈尔滨市花溪深圳街S座 621146', 1630000000078) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631170000000, 256334370, -4650384778595555945, -7069, 22, 596577877.192931, -70129653418.844894, 0, 'binary.zWNroTXoIVAfFKMCHdqU', 'nchar.广西壮族自治区梧州县崇文张路j座 870677', 1630000000078) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631169999999, 366270121, 4191114768474723941, 28897, 88, 36764251.456900, -819995344305.519043, 1, 'binary.KMQKIVvLXKZtzgvGXoZV', 'nchar.上海市深圳市朝阳王路c座 308052', 1630000000078) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631170000000, 904819741, 5165411582118084217, 22379, 49, 5.680573, -23448296491.688702, 1, 'binary.RksynZHDBofeCbnNeueF', 'nchar.西藏自治区秀兰县永川武汉街f座 720233', 1630000000078) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631170000001, -406248475, -3565233828007899422, -28694, -119, 6468114.299821, -9139.276334, 1, 'binary.yDkbSjlEhWxgIdEKjdyw', 'nchar.陕西省明市东丽郭街X座 797325', 1630000000079) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631170000001, -110865946, -7795005438146655234, -26791, -6, 614284367.384455, 50856740.580794, 1, 'binary.tpgIuOiJsKacrUZBOcHs', 'nchar.北京市太原县大兴高路N座 354025', 1630000000079) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631170000000, 1503400003, -80780332688017476, 31847, -84, -1188729980516.979980, 2115639995.697030, 0, 'binary.zMhdERtluQHYrYkarBsp', 'nchar.西藏自治区沈阳市沈河兰路O座 514687', 1630000000078) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631185000000, -703829541, -3015290584870545849, -26195, 25, 65051636.569539, -1355107949.868670, 0, 'binary.pFxWRymlGotRbPxBaKqU', 'nchar.重庆市拉萨县孝南刘路P座 393437', 1630000000079) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631185000000, 322375238, -6241662551377872210, 7578, -41, 9181.469818, 58823.373155, 0, 'binary.yeTYMVojTpBxHFVbiTVH', 'nchar.贵州省天津市吉区潜江街E座 745985', 1630000000079) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631184999999, 901680081, 2918745868131285426, 1954, 123, 799091.717635, 19529.323662, 1, 'binary.HriCdYQCgMqDJrsEPvId', 'nchar.香港特别行政区伟市蓟州崔路h座 182270', 1630000000079) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631185000000, 959830805, 8687660735074694942, 30908, 121, -56072935323.713600, -66360254180.759499, 1, 'binary.hnKLmxkdGfJPtsNffUnx', 'nchar.重庆市云市孝南深圳街D座 180484', 1630000000079) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631185000001, -88966985, -1936037048857392721, -18099, 0, -824204261009.363037, 1697.886509, 1, 'binary.pfXnsxKPgpyOLUjhDIlh', 'nchar.青海省辛集县东丽拉萨街Q座 914524', 1630000000080) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631185000001, -156903452, -7204919546158466118, -26775, -7, 3343624886104.990234, 25.895039, 1, 'binary.DVJPFxpqidEqIbsMkqvk', 'nchar.河南省桂香县普陀合山街y座 473206', 1630000000080) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631185000000, 242951644, -6425706509022302444, -115, -95, -7428172351326.129883, -243792.108001, 0, 'binary.XYfDpoamFuPazIzqqvyQ', 'nchar.江苏省六安县沙湾沈阳路D座 111215', 1630000000079) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631200000000, 917616213, -6105526769675738367, 16833, -4, -912283922.301867, -626.880806, 0, 'binary.UJhwYiRGgenyykMzvCIG', 'nchar.陕西省慧市沈北新台北街V座 622592', 1630000000080) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631200000000, -1010524677, -2564524247724824015, -31994, -48, 478258495629.161011, -2756525.506410, 0, 'binary.JqnispIFJYlFtxhJzBtt', 'nchar.贵州省梅市上街福州路U座 843893', 1630000000080) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631199999999, 1676885574, 5801667850572164138, 9268, 5, 81943569878020.000000, -2651878397664.700195, 1, 'binary.tJnMwFImycFDwadSKvfB', 'nchar.西藏自治区邯郸市东城刘路G座 620688', 1630000000080) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631200000000, 202560740, 8585057740824701967, 2754, 102, 4256312.669784, 2841641554.533030, 1, 'binary.iZuBXyHivNVGIECkZpgp', 'nchar.青海省北镇市永川广州路t座 650954', 1630000000080) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631200000001, -1469589614, -6328986345920555773, -13057, -114, 7124.472347, 1922792124.232900, 1, 'binary.IttYeshrxTWRQzrMpNEl', 'nchar.江苏省呼和浩特市大东钟路V座 373715', 1630000000081) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631200000001, -635536894, -7540406212992578302, -356, -42, 7506079.766892, -846620.925646, 1, 'binary.FBEKhNRXwVaIefMjxKLw', 'nchar.重庆市马鞍山市金平孔路A座 105425', 1630000000081) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631200000000, -1786041154, -5812150165598736743, 31691, -112, -99.932548, -78491263.832105, 0, 'binary.EeccUPRfABMAdtMqrUTP', 'nchar.海南省鑫市西夏兴城街R座 301651', 1630000000080) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631215000000, -1625191731, 6167214474139728168, 11139, 121, -94335581842.567902, 3059478274.613470, 0, 'binary.ZxUIonzZMsBhCCWqYrmZ', 'nchar.天津市拉萨县萧山上海路d座 252099', 1630000000081) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631215000000, -47135681, -6436433940308594642, -21351, 98, -8067393645072.580078, -55.209057, 0, 'binary.wklKlUzIzCbSAlTVhPtf', 'nchar.江西省通辽市西夏曾街D座 770856', 1630000000081) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631214999999, 1572527931, 6199432476029588286, 15047, 53, -329811.437951, -690962.952604, 1, 'binary.VQbrSGdoLASviEaZfVKb', 'nchar.河南省磊市城东曹路Y座 412471', 1630000000081) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631215000000, 1025618009, 8668297953739699167, 6895, 36, 809883.310963, -1830.234393, 1, 'binary.bSASugSRycgShDfZVaRz', 'nchar.天津市亮县江北潜江街S座 540483', 1630000000081) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631215000001, -256464376, -896102382541120115, -19194, -122, 4123590577424.399902, 2656422.305476, 1, 'binary.CyxinbAlvUlbbQCMCmuX', 'nchar.青海省东莞市蓟州叶路g座 257461', 1630000000082) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631215000001, -425746119, -8056851883105951074, -32462, -51, -590076.331164, 324718675328.812988, 1, 'binary.MqmXkQoSJpKeTWWfLSjQ', 'nchar.青海省宁市高坪何街L座 312122', 1630000000082) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631215000000, -1005159716, 5814777795009857976, -20922, -120, -5.121036, 72269204554.118393, 0, 'binary.krPFwdRphWiLhiLWffGj', 'nchar.云南省太原市翔安叶街s座 968090', 1630000000081) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631230000000, 300807334, -1393720031020538944, -10631, 114, -7497311.501447, -7843875.126062, 0, 'binary.gUfZXmtuaUyEMqvzCGVT', 'nchar.甘肃省潮州市海陵张路j座 111530', 1630000000082) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631230000000, -61728336, -6277168556471947655, -14631, 121, 108260.570588, -6225158.445263, 0, 'binary.wjIFBHVvPkzNnyfFqcez', 'nchar.内蒙古自治区小红县锡山张路q座 451673', 1630000000082) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631229999999, 456695922, 6065595906254092225, 13855, 95, -9.750988, 52263.948430, 1, 'binary.HpsqFduULuvFgUNWLaIS', 'nchar.上海市辽阳市友好宜都街J座 260640', 1630000000082) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631230000000, 1314422800, 2343245198878315836, 4530, 110, 5.523721, 52.963146, 1, 'binary.BqILcPWCGdFitnkIUITX', 'nchar.黑龙江省萍市兴山香港街w座 689416', 1630000000082) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631230000001, -1404438854, -6648294746644259055, -29920, -45, -4879.347387, -397204029.641602, 1, 'binary.hWYLNHYZihIwrBwiQKLu', 'nchar.内蒙古自治区大冶县上街谢街p座 354579', 1630000000083) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631230000001, -1560018283, -8582655292633538077, -7916, -9, -813743561.246321, 180605419479.515991, 1, 'binary.rBKhOAPgsFlVbktylkBZ', 'nchar.海南省贵阳县新城张家港路o座 184911', 1630000000083) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631230000000, -1185224620, 3781565114446947943, -32425, -124, -966176.836584, -6194.817285, 0, 'binary.MAHjOJrSnXwRnDjhjhgs', 'nchar.湖北省哈尔滨县璧山嘉禾路W座 107867', 1630000000082) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631245000000, -629005742, 2962477037931783881, 30753, -22, 97626628.877839, -55509075810587.898438, 0, 'binary.bHeXAGMGzghlOuWCGmyS', 'nchar.内蒙古自治区荆门市上街王路f座 313159', 1630000000083) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631245000000, 1289038189, 208643021208222754, 24329, -84, 528626.682214, 4631263449.782700, 0, 'binary.VBcGIQKGeBlgodeKkqIO', 'nchar.天津市梅县孝南许街M座 955579', 1630000000083) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631244999999, 1089857524, 8092714018391461421, 30637, 62, 822.840197, 86578529728.784698, 1, 'binary.ReHWrHhhULYKBWJbDHAl', 'nchar.安徽省合肥县大兴太原街z座 183173', 1630000000083) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631245000000, 1508646219, 5498801626248258629, 6153, 2, -6981.974013, -1.262354, 1, 'binary.rKJJrwLYFsmeLilRmdII', 'nchar.云南省秀英市静安罗路N座 799241', 1630000000083) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631245000001, -1072147772, -6285554104164008129, -13029, -38, 399653108.497808, 9.954981, 1, 'binary.CrzTcvxjDbWSNGHlnGgZ', 'nchar.福建省文市沙市聂路v座 919011', 1630000000084) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631245000001, -1744587122, -4289304118779607521, -3261, -49, 578908.973758, -3283275.161042, 1, 'binary.hnKdQBaXRtRTvdBMxxki', 'nchar.四川省秀荣市江北韩路N座 794727', 1630000000084) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631245000000, -1768419964, 6812389139494481536, -22315, 57, -3991350668.256720, 272847.980876, 0, 'binary.eaKoadYSnHxIAwGvMADW', 'nchar.内蒙古自治区颖市城北呼和浩特路M座 270782', 1630000000083) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631260000000, 62032825, 2419036897017949691, -18301, 34, -34067326787.909401, -4490033.331223, 0, 'binary.vcjOGKOcKjTDVUVgwDDP', 'nchar.福建省太原县上街宁街J座 989695', 1630000000084) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631260000000, -955905466, 8811462063140315136, -25829, 76, 4112554.855015, -353081090.814735, 0, 'binary.sjVkMmweDnQHqIahYBJg', 'nchar.宁夏回族自治区佛山市清浦陈街C座 507576', 1630000000084) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631259999999, 1740302532, 7618062051313344766, 24234, 108, 19.258022, -481986511.838220, 1, 'binary.FHckvgRsNysvnrkBnxPi', 'nchar.河北省丽华市朝阳龚路E座 249405', 1630000000084) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631260000000, 25207874, 8557074180207725958, 5121, 76, -27.837670, 7472.845942, 1, 'binary.yuETGYVvdZgoTrKTDVlM', 'nchar.甘肃省红霞市牧野关岭街C座 146380', 1630000000084) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631260000001, -368156241, -8290129222861749037, -32369, -87, 8778614.707332, -8.396911, 1, 'binary.oTlXrpmNqzuPQFtdJXAL', 'nchar.广东省淑珍市东丽周街e座 132961', 1630000000085) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631260000001, -1391854623, -5255734908673798063, -25898, -63, 6.380914, -981.272293, 1, 'binary.fRTcoeHlACSZuECHxLsF', 'nchar.西藏自治区兴城市东丽惠州街w座 939232', 1630000000085) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631260000000, -1478713358, -7256379885586266224, 7456, -127, 39.210475, -37429036261.203003, 0, 'binary.iLHDKCeEycRrHQjdctpP', 'nchar.贵州省琴市锡山嘉禾街V座 586837', 1630000000084) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631275000000, 1637182628, -7252330432834078022, -13577, -34, -21982.383242, 851033.725636, 0, 'binary.qbwfbTcZcBXRYDFLPsYc', 'nchar.西藏自治区香港县门头沟袁路c座 659900', 1630000000085) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631275000000, -226012380, 714907917095146625, 26998, 45, -378863.223518, 63837840.367547, 0, 'binary.wLhqoOhYDhOLDWgTquSO', 'nchar.广东省淮安县城东惠州街H座 226497', 1630000000085) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631274999999, 1196830217, 7803469523299853932, 4057, 68, -72455041894.121094, 31008329.254161, 1, 'binary.tnTDmSbUwexajzyGQKbU', 'nchar.天津市桂香市海港邱路v座 930985', 1630000000085) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631275000000, 1896164509, 1992693218102163749, 20742, 127, 3279876658623.740234, 97971293613823.203125, 1, 'binary.EwwiwjOJeqmxqOmBSCvF', 'nchar.宁夏回族自治区秀英县高坪银川街T座 599205', 1630000000085) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631275000001, -238216455, -6595002088264755363, -17352, -35, 30291122943460.601562, -523766877.255375, 1, 'binary.JiuAgoqIJOWzLvLnmvBq', 'nchar.四川省六盘水市梁平佛山街Y座 160978', 1630000000086) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631275000001, -1959680714, -5838771977352828969, -30312, -80, -40302216017.319298, 65262645551.558701, 1, 'binary.kKcTvQecUQcVNHCxdbMq', 'nchar.吉林省亮市海陵汕尾街y座 455171', 1630000000086) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631275000000, -1454514443, 2104326254606882084, -3977, 31, -10.683775, 8146970744.319100, 0, 'binary.baHWrZaiEoVOFqPQVViT', 'nchar.上海市明市锡山台北街g座 112480', 1630000000085) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631290000000, 202676239, -997640316674086097, -22675, 17, -597819.667252, -989103790.253560, 0, 'binary.rdoqbRUQFOZbxDrDpEXv', 'nchar.福建省斌市清河刘路r座 438569', 1630000000086) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631290000000, 274493417, -5455741168804436813, -27247, -111, 9288775.263537, -3826.901732, 0, 'binary.eWJNzFpYfQFYqDTlVEuS', 'nchar.广西壮族自治区深圳市海陵邓路e座 598287', 1630000000086) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631289999999, 995318978, 44640273583296417, 14989, 72, 86411387362.516006, -21052069.696864, 1, 'binary.WhVBrissKQCBrAUpwRHT', 'nchar.陕西省桂香市清浦米街p座 269494', 1630000000086) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631290000000, 2136730540, 5315445691851854143, 14450, 103, -6335650603.174980, 501305134.199676, 1, 'binary.zljXuXtZduZhLQoCTEYI', 'nchar.辽宁省凯县西夏太原街R座 148010', 1630000000086) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631290000001, -1917806640, -4720258233332513149, -31214, -45, -8113.185976, -82050.442684, 1, 'binary.dwHmbtStCEgnJspmTqwD', 'nchar.新疆维吾尔自治区桂芝县长寿巢湖路A座 782531', 1630000000087) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631290000001, -981665942, -278699770296496646, -13050, -47, -41130.414162, 453641642.546780, 1, 'binary.BkkbbPyxvTkDiTzQpRiV', 'nchar.浙江省合肥市东城成都路c座 895347', 1630000000087) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631290000000, -834112430, -6635305571569691219, -19258, 73, 919646.148350, 321.289191, 0, 'binary.XzCcSXArLMKFLjFRyHJe', 'nchar.上海市阳县崇文丁路I座 548147', 1630000000086) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631305000000, -568876147, 4115921496929882007, 21876, 118, -766463785.889029, -63.898006, 0, 'binary.WPbsfDfyJKEoZCpyfhuq', 'nchar.青海省贵阳市大兴彭街W座 571855', 1630000000087) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631305000000, -1963919658, -7528759656724736232, -15462, -49, 82.771605, 228.648728, 0, 'binary.gvsIwjOVqnvwPYubIriV', 'nchar.浙江省合肥县蓟州蒋路s座 450606', 1630000000087) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631304999999, 862001048, 8289879675128879554, 10897, 54, -31560046.871248, -2510800476075.919922, 1, 'binary.ZakYSeKJSEQfAnbEPpdl', 'nchar.湖南省秀华市锡山牟街K座 639697', 1630000000087) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631305000000, 1928593809, 5104651015083770612, 32255, 58, 804488379.612065, 9429749762380.500000, 1, 'binary.wgTbKbFYQRosfKvUQSkH', 'nchar.重庆市桂珍市梁平乌鲁木齐街N座 153448', 1630000000087) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631305000001, -1547198379, -350643391542151214, -13828, -103, 64477812.167046, -2903.526723, 1, 'binary.vJieiALrJbMqqRhnMbqe', 'nchar.澳门特别行政区丹丹市丰都南宁街Q座 989300', 1630000000088) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631305000001, -134242385, -3869570405276188197, -32581, -104, 43107832.702441, 44056.657014, 1, 'binary.IkbIEnMQPVXBWOjcanNo', 'nchar.香港特别行政区东莞县丰都朱路U座 249243', 1630000000088) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631305000000, -597984033, -3361517834367129147, 75, -104, -7409.500037, -91.360942, 0, 'binary.TNnOUCoNllHJVskqaqWO', 'nchar.上海市玉梅市和平李街k座 583138', 1630000000087) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631320000000, 904033245, 1599598424557218108, -30005, -24, 4541.289136, -54.239926, 0, 'binary.iEBPEAmKXlpBUXwoALUt', 'nchar.吉林省刚县璧山刘路g座 682546', 1630000000088) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631320000000, -2079364817, -654287221384079565, 15782, -26, 748.766841, -4.965685, 0, 'binary.WEJkxJeFLZZByzCPoRdY', 'nchar.福建省太原县永川兴城街w座 961260', 1630000000088) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631319999999, 526847966, 5775445950760637967, 14304, 60, 81172141354.356293, 870255843.925099, 1, 'binary.MdntNFfvvyCStMNHBKIQ', 'nchar.广西壮族自治区合肥县西夏刘路q座 990741', 1630000000088) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631320000000, 537739308, 5090468389474927294, 22579, 33, 3433128.844123, 3872298849645.379883, 1, 'binary.abGKYFWBPWLVPYEvggCd', 'nchar.陕西省马鞍山市海港韩路B座 339379', 1630000000088) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631320000001, -795092969, -3711201539316715587, -11107, -98, -286579.413055, -3.739221, 1, 'binary.thHeWmYWAcgObBqqwqqB', 'nchar.四川省成县大东张街u座 740678', 1630000000089) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631320000001, -1559644142, -9027525835433685991, -2711, 0, 5557460.651989, -40007573640075.203125, 1, 'binary.NglLAfkhOUvNACXvlutl', 'nchar.西藏自治区丽市兴山萧路O座 326707', 1630000000089) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631320000000, -1107831086, -1823478878718094475, -27832, -90, 99212399503.662796, -74696134214106.500000, 0, 'binary.drlMMrbdDWnwUwkvFszC', 'nchar.青海省利市西夏辛集街A座 820543', 1630000000088) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631335000000, -1747665689, -3268703357637921126, -3204, 118, -7.843951, 5236837072088.639648, 0, 'binary.fKLvQiBIrygGolyqKaVe', 'nchar.福建省淮安县金平海口街k座 430777', 1630000000089) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631335000000, -828294034, 2657326032914454094, 21837, 8, -69702504398061.000000, -4450579.238900, 0, 'binary.esplmUmrLBFMyAKMDAzP', 'nchar.福建省北镇市兴山长沙路D座 908303', 1630000000089) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631334999999, 1804609738, 6857866489996684420, 32112, 37, -2477401204.802390, -3021.525948, 1, 'binary.DCLURcwhhaDhNKDcTLYq', 'nchar.安徽省西宁县江北郑州路R座 729863', 1630000000089) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631335000000, 437917493, 1733585568524751775, 14155, 38, 3358226.279225, -1184.537102, 1, 'binary.KYgSrTTQzSmndNwhbsxY', 'nchar.黑龙江省丽丽县双滦包路i座 494311', 1630000000089) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631335000001, -1727537263, -5460926119155540560, -9690, -95, 9289065.542646, 7.188845, 1, 'binary.yMKTfSNsTiIkXhhIQCtC', 'nchar.新疆维吾尔自治区柳州县东丽高街d座 298894', 1630000000090) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631335000001, -2120093363, -4777070161903130182, -8197, -30, -383000.885433, 9678.947342, 1, 'binary.xYtVuqPnZXiCBdRdskEu', 'nchar.海南省沈阳市大兴邓街P座 552544', 1630000000090) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631335000000, 1750088050, 3697839127781862571, -675, -53, -99724.435061, -28255356.108959, 0, 'binary.ZoJveGLeqQgcoitfoHqY', 'nchar.广东省丽丽市城北呼和浩特路P座 380188', 1630000000089) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631350000000, 1880035325, -4802629856794707608, 22068, 100, 718062376.187030, -506130.634445, 0, 'binary.CfGiHufKQulMxwAItOfy', 'nchar.山西省想市黄浦邯郸路X座 818941', 1630000000090) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631350000000, 165546984, -6984734151301447256, -16166, 96, -1236884449.480500, -639029206.988874, 0, 'binary.AvOGTRfAVrYaxEAHhJKk', 'nchar.四川省坤市清河文街M座 728309', 1630000000090) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631349999999, 1514387404, 2958688219263646841, 21127, 20, -46918158932248.000000, 2353213017.825450, 1, 'binary.bfrSvHvqHlFluwivEgxS', 'nchar.山西省玉市白云马街p座 592361', 1630000000090) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631350000000, 697337569, 7135356390013225753, 32569, 116, -6611897.211005, -1.935866, 1, 'binary.ETaNjgpPPzwvOkzPbLMs', 'nchar.台湾省敏市朝阳余路L座 739835', 1630000000090) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631350000001, -1737290956, -4744278138504720755, -23704, -13, -20682554.975530, -5505407.317856, 1, 'binary.lqhFKjcHzvbkdWVoYtwW', 'nchar.河南省兰英县朝阳天津街A座 102658', 1630000000091) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631350000001, -1792783313, -6546177515445472740, -17996, -82, -2785.518995, 406175.862275, 1, 'binary.ZSgzqADQgOFLGnOSTTgl', 'nchar.云南省丽华县浔阳黄街u座 463279', 1630000000091) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631350000000, 1675171705, 4482392883505129283, 3877, 60, -529410318.578000, 87242703.165205, 0, 'binary.pPrjATzIWSjGnAQlByfg', 'nchar.澳门特别行政区玉珍县南溪刘路J座 234624', 1630000000090) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631365000000, -120996932, 7464290233605180116, -21030, 89, -7265.737889, 38451.519083, 0, 'binary.NdYvAIsMTcBJbRZBuEMZ', 'nchar.四川省成都县六枝特武汉路u座 796761', 1630000000091) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631365000000, 1626331139, -3444691871293469179, 1200, 69, -2719528.747073, 35.186089, 0, 'binary.SfqGXOabBHmYWmwbjAmD', 'nchar.江西省彬县清浦丁街f座 768134', 1630000000091) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631364999999, 1201642931, 3048123187871650645, 5183, 51, 5407076381615.250000, -94.505271, 1, 'binary.pCxeaejTSQlmBlttHhTg', 'nchar.江苏省六盘水市兴山宋街z座 229812', 1630000000091) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631365000000, 606859861, 3791676681420995058, 12977, 20, -11.820203, -60910962808.638702, 1, 'binary.dkXKTqEjhmKoFQauhwjf', 'nchar.甘肃省慧县淄川何街t座 472618', 1630000000091) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631365000001, -639050810, -5288142338710158760, -32726, -35, 1750485995849.620117, -5947212091.364470, 1, 'binary.hQfgaAPxYdJOaIkPUQJT', 'nchar.甘肃省宁德县孝南北京街f座 436022', 1630000000092) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631365000001, -592064320, -9093756286157608735, -19004, -37, -60515553533903.898438, 4852.484564, 1, 'binary.DyLlxTKVpmVQoztjwPWn', 'nchar.辽宁省武汉县徐汇王路u座 155320', 1630000000092) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631365000000, -168837427, 5524670347645121945, -687, 105, -33530.533779, -857595946215.329956, 0, 'binary.dWHryceFSxVdkHDrNfYa', 'nchar.山东省博市六枝特银川路k座 264255', 1630000000091) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631380000000, -144505842, 9031683748543148709, 30839, 37, 75951623525931.296875, -356608030036.447021, 0, 'binary.YAmFEuHOeLIMgXCOGnRf', 'nchar.黑龙江省秀珍市白云广州街Z座 558462', 1630000000092) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631380000000, -202930007, 2539365322373297240, 30035, -11, 3987179954447.959961, 166663.706087, 0, 'binary.aQPbQkWFDKuugEWfofTC', 'nchar.陕西省建国市江北阜新街O座 931583', 1630000000092) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631379999999, 340191939, 190224560698109215, 7127, 125, 41587961603.659103, -37646578.644303, 1, 'binary.ZClsyheJcXtiVXWSTmJC', 'nchar.内蒙古自治区南京市吉区海门街X座 981848', 1630000000092) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631380000000, 1141439964, 5703107595817904511, 17318, 70, 20244282326280.398438, -374.976792, 1, 'binary.ECmfqstJJJGVfXRSlipY', 'nchar.山东省秀珍市长寿嘉禾街H座 668408', 1630000000092) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631380000001, -822942850, -5193915838519507313, -6726, -109, 12.862186, -308.656139, 1, 'binary.fiNIskGvJlLuWiySSzcR', 'nchar.辽宁省太原市合川沈路K座 765732', 1630000000093) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631380000001, -1084726805, -1799418590653312591, -316, -61, -43.289435, -5628.101135, 1, 'binary.nYWtrJedHHgNuftngNzv', 'nchar.福建省小红市沈北新王街j座 802142', 1630000000093) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631380000000, 2145419646, 1580239203992480528, -14574, 100, -94259.299402, 2214154.396490, 0, 'binary.GZbUYTSXnACDqnrhbNFC', 'nchar.青海省淑华市沙湾阜新路Q座 663492', 1630000000092) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631395000000, -752146752, 8221071117818639487, -24048, -125, -4922542596.502000, 69.541336, 0, 'binary.DpfvmRBpvyGTcVOJPyJo', 'nchar.江西省刚县房山安街D座 955283', 1630000000093) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631395000000, -878950287, -8422331468601695661, -13558, 43, 339844.201301, 9.764866, 0, 'binary.RefVNTHmgyVTPXRzLkLd', 'nchar.浙江省马鞍山县海陵王街B座 867693', 1630000000093) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631394999999, 1783522942, 6078410931639616068, 9495, 98, 727091818.991834, 8165776010706.599609, 1, 'binary.dtkNAQMwyepAJbdqweVh', 'nchar.河北省天津市沈河贵阳街N座 113675', 1630000000093) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631395000000, 1165805677, 1114429668955803199, 26742, 75, 965648.432436, 67940.285447, 1, 'binary.STtpcklCmoPcTqcnVEYp', 'nchar.湖北省荆门县静安拉萨街x座 767367', 1630000000093) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631395000001, -1314056119, -4268557454181639559, -17681, -70, 9569.520951, -3.709641, 1, 'binary.eAxSwIhCTWRsxHmnyhOO', 'nchar.四川省建华县沙市沈阳路f座 959538', 1630000000094) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631395000001, -1195931348, -3234878011308908109, -8224, -81, 68272155.434104, 2277301.750441, 1, 'binary.cCbIERRNYVmzqgdEkLyn', 'nchar.宁夏回族自治区长春市山亭海门路i座 441560', 1630000000094) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631395000000, 1044986483, 708621525043415947, 23174, 25, -87522059062286.000000, 91518.977374, 0, 'binary.KWZOCXHGUnswxAQvgLbX', 'nchar.甘肃省上海市大东合肥路v座 576201', 1630000000093) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631410000000, -883689952, -6467532462337897809, -20092, 56, 2802216728037.279785, -9.303156, 0, 'binary.qwPhaldJXqLHFGOeyrHw', 'nchar.甘肃省南宁市孝南彭街T座 566484', 1630000000094) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631410000000, 972297407, -5877490557670044529, -27447, 44, 40.846479, -4231.348093, 0, 'binary.DwlvVHWtVzbpJAeCWIMr', 'nchar.山西省莹县魏都张街A座 689281', 1630000000094) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631409999999, 1032579814, 2390187777440316314, 19171, 78, -63005465989151.203125, 5961100651288.120117, 1, 'binary.VAqPpjxEFxcYSxnzUAwL', 'nchar.贵州省辽阳县静安安街c座 964229', 1630000000094) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631410000000, 241342224, 8497667456001609204, 18172, 104, -906790925488.797974, 36707840437.474998, 1, 'binary.FLLdUdBRMRgvzrMSflyN', 'nchar.甘肃省哈尔滨县翔安拉萨路L座 242629', 1630000000094) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631410000001, -1560976462, -1082805904642279032, -24035, -84, 5518722837.437610, 99553268986.260300, 1, 'binary.yXYqlIPBknzcrQaHQVBK', 'nchar.山西省福州县白云乌鲁木齐街I座 977466', 1630000000095) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631410000001, -1279270656, -127272614642938342, -18488, -105, 820203443079.204956, -39324.928647, 1, 'binary.vcWaeUuquQmpiNmaMFTJ', 'nchar.重庆市红市友好张家港街h座 853577', 1630000000095) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631410000000, -810546809, 4707087124402946180, 14228, -33, 401.288641, -573136.630366, 0, 'binary.oglpZSvAEAkKdUTqMhCy', 'nchar.安徽省大冶县锡山高路Q座 272097', 1630000000094) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631425000000, -1291692620, -3976582859582309880, 99, -107, -643212263540.171997, 91650599.279398, 0, 'binary.QtWoywiZBLMnNCtJddrC', 'nchar.海南省凤英市新城单路Y座 332919', 1630000000095) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631425000000, -1636741671, 6149617241982859450, -29331, -23, 53068143981197.398438, 507.769638, 0, 'binary.rwiKvwHMRitScXUVmJhW', 'nchar.陕西省辛集县清浦李路H座 631016', 1630000000095) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631424999999, 2070489093, 3407988531094502611, 31121, 105, -797.417546, -5114.871991, 1, 'binary.VKDzqKpnljjtWvPxhJtw', 'nchar.台湾省淑英县黄浦齐齐哈尔街c座 143348', 1630000000095) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631425000000, 1536720383, 3880153804085171184, 11796, 82, 45989.231323, 92.649541, 1, 'binary.tbEDrcIJyjZTjRieTqRC', 'nchar.上海市北镇市怀柔阜新路R座 405512', 1630000000095) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631425000001, -955300022, -7851370978801274222, -14072, -90, -91217.776216, -9476202.110944, 1, 'binary.wYLmyHTheIfPsDKWcbvP', 'nchar.河南省丹市金平潮州路n座 514612', 1630000000096) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631425000001, -1019361248, -57576815854175575, -24873, -4, -32984292266917.800781, 58.748899, 1, 'binary.HNDdWAeDLFDTfTKRiPvW', 'nchar.云南省桂芝市长寿王街C座 833966', 1630000000096) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631425000000, 1923224809, -2907800501658168815, -9896, 49, -33656345.811017, -671677543.932121, 0, 'binary.PJVocGHwGGXYBPOAxHSo', 'nchar.内蒙古自治区柳县崇文王街n座 759363', 1630000000095) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631440000000, 1147520901, -7715180528849786436, -17616, -76, 6.545288, -50974540.927085, 0, 'binary.vSYpvPIBkKueVfRtelNq', 'nchar.江西省亮市孝南合肥路t座 737452', 1630000000096) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631440000000, -113454687, -5823484358741527503, 28969, 121, -64687699.492563, -79961693.274913, 0, 'binary.eNlgFeimPdtilNzjMToG', 'nchar.辽宁省通辽县东丽廖路E座 551853', 1630000000096) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631439999999, 1457091374, 8334151643776472564, 2662, 82, 323215.440926, -9805209441096.250000, 1, 'binary.rMLCVjMtmxFxYRYbvQQh', 'nchar.安徽省武汉县城东萧路w座 417063', 1630000000096) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631440000000, 199139943, 2468266181580361696, 6282, 45, 938749.350559, -728777906039.301025, 1, 'binary.QCaxrlOInebbkEcnmLYI', 'nchar.天津市拉萨县魏都李街D座 325624', 1630000000096) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631440000001, -1074274106, -6116630471404653549, -13682, -70, 513137.327759, -588918896.561140, 1, 'binary.TyKIxNLJfeZgAKvWAFfB', 'nchar.海南省济南县闵行西宁路m座 451609', 1630000000097) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631440000001, -565301435, -4026730978460667946, -19020, -77, -8.983572, -43.480820, 1, 'binary.ydTJczfbrhMoGjzUmQfP', 'nchar.香港特别行政区柳州市璧山张家港街l座 596812', 1630000000097) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631440000000, 625692002, -7425751090292284243, 10228, 1, 750.678719, -90.988373, 0, 'binary.xzExJqxxmHYoAUDKciSV', 'nchar.湖北省婷县龙潭兰州街n座 199763', 1630000000096) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631455000000, 2072736931, -3329284412762274677, 12268, -69, 5910.358156, 997044108049.300049, 0, 'binary.aBqZKnHzsSpmRSwSQPYY', 'nchar.山西省郑州市孝南王路e座 167062', 1630000000097) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631455000000, 1463682034, 990280305241763342, -3488, 89, 419973.481918, -55750492618.939903, 0, 'binary.OybEvgqNWyaCiEEvxpeR', 'nchar.青海省荆门县孝南东莞路a座 305732', 1630000000097) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631454999999, 1438955591, 8811422557823062850, 15737, 98, 1754297.282564, 567752594.816600, 1, 'binary.OMjmDDXPGGJaZZRMlpqF', 'nchar.上海市台北市黄浦周街v座 378966', 1630000000097) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631455000000, 1828878609, 7873820745339300844, 23138, 106, 9.263627, 946712871592.369995, 1, 'binary.wDtceAzvXHGjCqbAGulx', 'nchar.浙江省邯郸县长寿张路V座 106929', 1630000000097) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631455000001, -1388085018, -6219226483229634812, -21928, -116, -896801017371.463989, 91302.519671, 1, 'binary.YMYcdmnGDpGZSmUvXpYa', 'nchar.重庆市刚县江北北镇路o座 294056', 1630000000098) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631455000001, -1225032046, -2776099211554722026, -11329, -26, 22948.709678, -47848.985287, 1, 'binary.muQMoYipLCOlIkSyKxUk', 'nchar.山东省郑州市合川张家港街X座 960693', 1630000000098) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631455000000, 1161217978, 1842781937217393115, 17682, -46, 286163234.229566, -2.426507, 0, 'binary.CRKBkwUTzvgcBPDSNWiy', 'nchar.广西壮族自治区浩市安次苏街L座 929528', 1630000000097) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631470000000, -821482750, -6759948063516530731, -16375, 89, -84205.305774, 768242.497026, 0, 'binary.vMJVGyqMTgaGrLmmbZIE', 'nchar.天津市琴市江北孙街m座 262672', 1630000000098) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631470000000, 717271992, 7986931673188494197, -9479, 52, 4711.839591, -5371732.797787, 0, 'binary.kPRwzfEKYpYgWRWaeGzP', 'nchar.重庆市乌鲁木齐市闵行南京路R座 883727', 1630000000098) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631469999999, 1077620215, 2558543784745208971, 25857, 52, -47179130892.244499, -20848774363.230000, 1, 'binary.BQGtKbxrxZCgjfTUjLJe', 'nchar.黑龙江省岩市海陵天津街v座 971806', 1630000000098) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631470000000, 1977913093, 3861242852069723630, 20743, 59, 9464902993.309589, -5024.160475, 1, 'binary.lzQOJDAUyRQtQDjNrWZJ', 'nchar.甘肃省齐齐哈尔市华龙沈阳街I座 777477', 1630000000098) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631470000001, -428527206, -547566441621156192, -12808, -31, -74278620895119.906250, 50537841781.787697, 1, 'binary.FkYBhPfxSWPoKPiVwaNT', 'nchar.吉林省南宁市平山张路Z座 293046', 1630000000099) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631470000001, -1181912125, -427873392135772867, -13447, -55, 3457499617.219500, -7038680.198896, 1, 'binary.ozhZqPebRJOHopCsXWpU', 'nchar.上海市伟市闵行北京街i座 107708', 1630000000099) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631470000000, 744599275, 5384505142686943052, 30013, -71, -4.424027, -5.984967, 0, 'binary.RcgJmYOFSSkGHfTHlqvY', 'nchar.陕西省东县大东窦路E座 174935', 1630000000098) ;''') + tdSql.execute(f'''insert into stable_1_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double , q_bool , q_binary , q_nchar, q_ts) values(1631485000000, -1492370578, 4514526083062070789, 31730, -102, -717.383970, 52910.663266, 0, 'binary.jsHQYTHKPARRqiGzZKOz', 'nchar.澳门特别行政区邯郸县丰都宋街W座 598200', 1630000000099) ;''') + tdSql.execute(f'''insert into regular_table_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631485000000, 963480452, 5458394487863298148, -21434, 125, -1656.168120, 5768934065.605500, 0, 'binary.rCnbtltacJIWEVZWlXVF', 'nchar.湖北省合肥县龙潭马路o座 149144', 1630000000099) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631484999999, 224551324, 4933122153940335639, 2537, 23, -4225000.312926, -7035665314327.099609, 1, 'binary.RgTacOhlKMDWwPcrKsZK', 'nchar.山西省杭州市长寿沈阳街K座 225610', 1630000000099) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631485000000, 336564804, 2661017413987846119, 26066, 127, 2271.487346, 26543272352747.398438, 1, 'binary.FKgzwzTQzUHULzcaEmAd', 'nchar.贵州省成都市清河李路w座 620531', 1630000000099) ;''') + tdSql.execute(f'''insert into stable_1_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631485000001, -1922225927, -8001645480178976724, -25777, -111, -789464.882012, -360094093.372387, 1, 'binary.pxrkoGUZiddEAkYHiVjK', 'nchar.湖北省太原市永川吴路b座 333484', 1630000000100) ;''') + tdSql.execute(f'''insert into regular_table_2 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631485000001, -1213998634, -4431806460604559923, -22976, -105, -49517009982577.796875, -959039647940.217041, 1, 'binary.VxnbNGXEiRmRkEseJUFg', 'nchar.西藏自治区张家港县浔阳张路z座 876862', 1630000000100) ;''') + tdSql.execute(f'''insert into stable_2_1 (ts , q_int , q_bigint , q_smallint , q_tinyint , q_float , q_double, q_bool , q_binary , q_nchar, q_ts) values(1631485000000, -1591388398, 1970187840324683506, 20196, -59, 28171713.207903, 6.598821, 0, 'binary.fDSGiJNSRdOTovcESQFl', 'nchar.山西省梅市沙市王街r座 815669', 1630000000099) ;''') + tdSql.execute(f'''flush database table_lastrow_2_2;''') + + def basic_query(self): + # TD-23175 + tdSql.query(f'''select _wstart, LAST_ROW(q_float) from stable_2_1 where q_ts <= now +1h and _C0 <= now +1h and q_bool in (0 , 1) interval(11s) order by ts''') + tdSql.checkRows(100) + + # TD-23178 + tdSql.query(f'''select count(*) from (select LAST(q_tinyint) from stable_2 where q_ts between 1600000000000 and now +1h interval(12s) sliding(3s) order by ts)''') + tdSql.checkData(0, 0, 400) + tdSql.query(f'''select count(*) from (select LAST(q_tinyint) from stable_2 where q_ts between 1600000000000 and now +1h interval(12s) sliding(3s) order by ts)''') + tdSql.checkData(0, 0, 400) + + # TD-23173 + tdSql.query(f'''select _wstart,_wend,LAST_ROW(q_nchar) from stable_1 interval(17d) sliding(5d) order by _wstart;''') + tdSql.checkRows(7) + tdSql.checkData(0, 2, 'nchar.安徽省玲市西夏海口街o座 109427') + tdSql.checkData(1, 2, 'nchar.黑龙江省芳县海陵贺路c座 606589') + tdSql.checkData(2, 2, 'nchar.江苏省冬梅县六枝特张路g座 635526') + tdSql.checkData(3, 2, 'nchar.甘肃省宁德县孝南北京街f座 436022') + tdSql.checkData(4, 2, 'nchar.湖北省太原市永川吴路b座 333484') + tdSql.checkData(5, 2, 'nchar.湖北省太原市永川吴路b座 333484') + tdSql.checkData(6, 2, 'nchar.湖北省太原市永川吴路b座 333484') + + tdSql.query(f'''select _wstart,_wend,LAST_ROW(q_nchar) from stable_1 where q_ts between 1600000000000 and now +1h interval(17d) sliding(5d) order by _wstart;''') + tdSql.checkRows(7) + tdSql.checkData(0, 2, 'nchar.安徽省玲市西夏海口街o座 109427') + tdSql.checkData(1, 2, 'nchar.黑龙江省芳县海陵贺路c座 606589') + tdSql.checkData(2, 2, 'nchar.江苏省冬梅县六枝特张路g座 635526') + tdSql.checkData(3, 2, 'nchar.甘肃省宁德县孝南北京街f座 436022') + tdSql.checkData(4, 2, 'nchar.湖北省太原市永川吴路b座 333484') + tdSql.checkData(5, 2, 'nchar.湖北省太原市永川吴路b座 333484') + tdSql.checkData(6, 2, 'nchar.湖北省太原市永川吴路b座 333484') + + # TD-23222 + tdSql.query(f'''select LAST_ROW(q_tinyint) from stable_2 where q_ts between 1600000000000 and now +1h and _c0 <= now +1h and (q_nchar like 'nchar%' or q_binary = '0' or q_nchar = 'nchar_' ) and (q_bool = 0 or q_bool = 1 or q_bool is null) interval(15a,9a);''') + tdSql.checkRows(100) + + def run(self): + self.prepare_data() + self.basic_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/limit.py b/tests/system-test/2-query/limit.py index 91719aa21b0ce4245a096686aa1f5089e10ef542..c00e3b7d56af46f662ddb855a34e154e7c723b80 100644 --- a/tests/system-test/2-query/limit.py +++ b/tests/system-test/2-query/limit.py @@ -140,7 +140,7 @@ class TDTestCase: val2 = paraDict["ctbNum"] - 1 # select count(*), t1, t2, t3, t4, t5, t6 from $stb where t1 > $val1 and t1 < $val2 group by t1, t2, t3, t4, t5, t6 order by t1 asc limit 1 offset 0 sqlStr = f"select count(*), t1, t2, t3, t4, t5, t6 from %s where t1 > %d and t1 < %d group by t1, t2, t3, t4, t5, t6 order by t1 asc limit 1 offset 0"%(paraDict["stbName"], val1, val2) - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(1) tdSql.checkData(0, 0, paraDict["rowsPerTbl"]) @@ -152,7 +152,7 @@ class TDTestCase: # select count(*), t3, t4 from $stb where t2 like '%' and t1 > 2 and t1 < 5 group by t3, t4 order by t3 desc limit 2 offset 0 sqlStr = f"select count(*), t3, t4 from %s where t2 like '%%' and t1 > 2 and t1 < 5 group by t3, t4 order by t3 desc limit 2 offset 0"%(paraDict["stbName"]) - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(2) tdSql.checkData(0, 0, paraDict["rowsPerTbl"]) @@ -164,7 +164,7 @@ class TDTestCase: # select count(*) from $stb where t2 like '%' and t1 > 2 and t1 < 5 group by t3, t4 order by t3 desc limit 1 offset 1 sqlStr = f"select count(*) from %s where t2 like '%%' and t1 > 2 and t1 < 5 group by t3, t4 order by t3 desc limit 1 offset 1"%(paraDict["stbName"]) - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(1) @@ -179,18 +179,18 @@ class TDTestCase: tb = paraDict["ctbPrefix"] + '0' # select _wstart, max(c1) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1) limit 10 offset 1 sqlStr = f"select _wstart, max(c1) from %s where ts >= %d and ts <= %d interval(5m) fill(value, -1) limit 10 offset 1"%(tb, ts0, tsu) - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(10) - tdSql.checkData(0, 0, "18-09-17 09:05:00.000") + tdSql.checkData(0, 0, "2018-09-17 09:05:00.000") tdSql.checkData(0, 1, -1) tdSql.checkData(1, 1, 1) - tdSql.checkData(9, 0, "18-09-17 09:50:00.000") + tdSql.checkData(9, 0, "2018-09-17 09:50:00.000") tdSql.checkData(9, 1, 5) - + tb5 = paraDict["ctbPrefix"] + '5' sqlStr = f"select max(c1), min(c2) from %s where ts >= %d and ts <= %d interval(5m) fill(value, -1, -2) limit 10 offset 1"%(tb5, ts0, tsu) - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(10) tdSql.checkData(0, 0, -1) @@ -206,22 +206,22 @@ class TDTestCase: limit = paraDict["rowsPerTbl"] offset = limit / 2 sqlStr = f"select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from %s where ts >= %d and ts <= %d interval(5m) fill(value, -1, -2 ,-3, -4 , -5, -6 ,-7 ,'-8', '-9') limit %d offset %d"%(tb, ts0, tsu, limit, offset) - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(limit) tdSql.checkData(0, 1, 0) sqlStr = f"select max(c1) from lm2_tb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(value, -1000) limit 8200" - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(8200) sqlStr = f"select max(c1) from lm2_tb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(value, -1000) limit 100000;" - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) sqlStr = f"select max(c1) from lm2_tb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(value, -1000) limit 10 offset 8190;" - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(10) tdSql.checkData(0, 0, 5) @@ -231,7 +231,7 @@ class TDTestCase: sqlStr = f"select max(c1) from lm2_tb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(value, -1000) limit 10 offset 10001;" - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(10) tdSql.checkData(0, 0, -1000) @@ -240,13 +240,13 @@ class TDTestCase: tdSql.checkData(3, 0, 2) sqlStr = f"select max(c1) from lm2_tb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(value, -1000) limit 10000 offset 10001;" - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(9998) sqlStr = f"select max(c1) from lm2_tb0 where ts >= 1537146000000 and ts <= 1543145400000 interval(5m) fill(value, -1000) limit 100 offset 20001;" - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(0) @@ -254,7 +254,7 @@ class TDTestCase: limit = paraDict["rowsPerTbl"] offset = limit / 2 sqlStr = f"select _wstart,max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from %s where ts >= %d and ts <= %d interval(5m) fill(linear) limit %d offset %d"%(tb,ts0,tsu,limit, offset) - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(limit) tdSql.checkData(0, 1, 0) @@ -272,7 +272,7 @@ class TDTestCase: limit = paraDict["rowsPerTbl"] offset = limit / 2 sqlStr = f"select max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from %s where ts >= %d and ts <= %d interval(5m) fill(prev) limit %d offset %d"%(tb,ts0,tsu,limit, offset) - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(limit) @@ -280,7 +280,7 @@ class TDTestCase: limit = paraDict["rowsPerTbl"] offset = limit / 2 + 10 sqlStr = f"select _wstart,max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from %s where ts >= %d and ts <= %d and c1 = 5 interval(5m) fill(value, -1, -2 ,-3, -4 , -5, -6 ,-7 ,'-8', '-9') limit %d offset %d"%(tb,ts0,tsu,limit, offset) - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(limit) tdSql.checkData(0, 1, 5) @@ -298,7 +298,7 @@ class TDTestCase: limit = paraDict["rowsPerTbl"] offset = limit * 2 - 11 sqlStr = f"select _wstart,max(c1), min(c2), sum(c3), avg(c4), stddev(c5), spread(c6), first(c7), last(c8), first(c9) from %s where ts >= %d and ts <= %d and c1 = 5 interval(5m) fill(value, -1, -2 ,-3, -4 , -5, -6 ,-7 ,'-8', '-9') limit %d offset %d"%(tb,ts0,tsu,limit, offset) - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(10) tdSql.checkData(0, 1, -1) @@ -314,7 +314,7 @@ class TDTestCase: ### [TBASE-350] ## stb + interval + fill + group by + limit offset sqlStr = f"select max(c1), min(c2), sum(c3), avg(c4), first(c7), last(c8), first(c9) from lm2_tb0 where ts >= 1537146000000 and ts <= 1543145400000 partition by t1 interval(5m) fill(value, -1, -2, -3, -4 ,-7 ,'-8', '-9') limit 2 offset 10" - print("====sql:%s"%(sqlStr)) + tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(2) @@ -322,7 +322,7 @@ class TDTestCase: offset = paraDict["rowsPerTbl"] * 2 offset = offset - 2 sqlStr = f"select max(c1), min(c2), sum(c3), avg(c4), first(c7), last(c8), first(c9) from lm2_tb0 where ts >= 1537146000000 and ts <= 1543145400000 partition by t1 interval(5m) fill(value, -1, -2, -3, -4 ,-7 ,'-8', '-9') order by t1 limit %d offset %d"%(limit, offset) - print("====sql:%s"%(sqlStr)) + # tdLog.info("====sql:%s"%(sqlStr)) tdSql.query(sqlStr) tdSql.checkRows(1) tdSql.checkData(0, 0, 9) @@ -339,7 +339,7 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 1 end ...... ") def run(self): - tdSql.prepare() + # tdSql.prepare() self.prepareTestEnv() self.tmqCase1() diff --git a/tests/system-test/2-query/mode.py b/tests/system-test/2-query/mode.py index 807a1ac394aee9477fdf88120f554685a465f219..8321ef167585ac31d7d8086bfa24ccb34926ecb8 100644 --- a/tests/system-test/2-query/mode.py +++ b/tests/system-test/2-query/mode.py @@ -53,6 +53,7 @@ class TDTestCase: ( '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:32.000', 9, -99999999999999999, -999, -99, -9.99, -999999999999999999999.99, 1, "binary9", "nchar9", "1900-01-01 00: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 ) ''' diff --git a/tests/system-test/2-query/nestedQuery.py b/tests/system-test/2-query/nestedQuery.py index 6557aad05f7dc0d3021f1e0bbba8dfb08964ad0f..1b843defcef09ceb8bece595cae1b4b7611c33ae 100755 --- a/tests/system-test/2-query/nestedQuery.py +++ b/tests/system-test/2-query/nestedQuery.py @@ -6144,7 +6144,7 @@ class TDTestCase: startTime = time.time() - self.function_before_26() + #self.function_before_26() self.math_nest(['UNIQUE']) self.math_nest(['MODE']) @@ -6157,9 +6157,9 @@ class TDTestCase: # self.math_nest(['MAVG']) # self.math_nest(['HYPERLOGLOG']) # self.math_nest(['TAIL']) - # self.math_nest(['CSUM']) - # self.math_nest(['statecount','stateduration']) - # self.math_nest(['HISTOGRAM']) + self.math_nest(['CSUM']) + self.math_nest(['statecount','stateduration']) + self.math_nest(['HISTOGRAM']) # self.str_nest(['LTRIM','RTRIM','LOWER','UPPER']) # self.str_nest(['LENGTH','CHAR_LENGTH']) diff --git a/tests/system-test/2-query/nestedQuery_26.py b/tests/system-test/2-query/nestedQuery_26.py new file mode 100755 index 0000000000000000000000000000000000000000..9d5f31d1e067969f30f74d3f3de41236e346712e --- /dev/null +++ b/tests/system-test/2-query/nestedQuery_26.py @@ -0,0 +1,76 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- +from util.cases import tdCases +from .nestedQuery import * + +class TDTestCase(TDTestCase): + + + def run(self): + tdSql.prepare() + + startTime = time.time() + + self.function_before_26() + + # self.math_nest(['UNIQUE']) + # self.math_nest(['MODE']) + # self.math_nest(['SAMPLE']) + + # self.math_nest(['ABS','SQRT']) + # self.math_nest(['SIN','COS','TAN','ASIN','ACOS','ATAN']) + # self.math_nest(['POW','LOG']) + # self.math_nest(['FLOOR','CEIL','ROUND']) + # self.math_nest(['MAVG']) + # self.math_nest(['HYPERLOGLOG']) + # self.math_nest(['TAIL']) + # self.math_nest(['CSUM']) + # self.math_nest(['statecount','stateduration']) + # self.math_nest(['HISTOGRAM']) + + # self.str_nest(['LTRIM','RTRIM','LOWER','UPPER']) + # self.str_nest(['LENGTH','CHAR_LENGTH']) + # self.str_nest(['SUBSTR']) + # self.str_nest(['CONCAT']) + # self.str_nest(['CONCAT_WS']) + # self.time_nest(['CAST']) #放到time里起来弄 + # self.time_nest(['CAST_1']) + # self.time_nest(['CAST_2']) + # self.time_nest(['CAST_3']) + # self.time_nest(['CAST_4']) + + + + # self.time_nest(['NOW','TODAY']) + # self.time_nest(['TIMEZONE']) + # self.time_nest(['TIMETRUNCATE']) + # self.time_nest(['TO_ISO8601']) + # self.time_nest(['TO_UNIXTIMESTAMP']) + # self.time_nest(['ELAPSED']) + #self.time_nest(['TIMEDIFF_1']) + #self.time_nest(['TIMEDIFF_2']) + + + endTime = time.time() + print("total time %ds" % (endTime - startTime)) + + + + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/system-test/2-query/nestedQuery_math.py b/tests/system-test/2-query/nestedQuery_math.py index 2d0bbcb352a4cfc732a2ccd4ec83604733146d32..3e37a2c15e6f2db8d657bc9dcbd001b1ec8c7aea 100755 --- a/tests/system-test/2-query/nestedQuery_math.py +++ b/tests/system-test/2-query/nestedQuery_math.py @@ -34,9 +34,9 @@ class TDTestCase(TDTestCase): self.math_nest(['MAVG']) self.math_nest(['HYPERLOGLOG']) self.math_nest(['TAIL']) - self.math_nest(['CSUM']) - self.math_nest(['statecount','stateduration']) - self.math_nest(['HISTOGRAM']) + # self.math_nest(['CSUM']) + # self.math_nest(['statecount','stateduration']) + # self.math_nest(['HISTOGRAM']) # self.str_nest(['LTRIM','RTRIM','LOWER','UPPER']) # self.str_nest(['LENGTH','CHAR_LENGTH']) diff --git a/tests/system-test/2-query/odbc.py b/tests/system-test/2-query/odbc.py index f26f0abda0db5edb6c54261eb7e85f72daaafea2..9ff4a26ac03cf3514b1b56a7ce27062a734e443a 100644 --- a/tests/system-test/2-query/odbc.py +++ b/tests/system-test/2-query/odbc.py @@ -22,7 +22,7 @@ class TDTestCase: tdSql.execute("insert into db.ctb using db.stb tags(1) (ts, c1) values (now, 1)") tdSql.query("select count(*) from information_schema.ins_columns") - tdSql.checkData(0, 0, 271) + tdSql.checkData(0, 0, 275) tdSql.query("select * from information_schema.ins_columns where table_name = 'ntb'") tdSql.checkRows(14) diff --git a/tests/system-test/2-query/out_of_order.py b/tests/system-test/2-query/out_of_order.py index e07eaed092a0dfac84afbf4d796661e31e273dd5..8685b112068b5fbba72db009f6bd707a74dd6dbc 100644 --- a/tests/system-test/2-query/out_of_order.py +++ b/tests/system-test/2-query/out_of_order.py @@ -168,19 +168,18 @@ class TDTestCase: sql = "select count(*) from (select distinct(tbname) from %s.meters)" %dbname tdSql.query(sql) - num = tdSql.getData(0,0) + # 目前不需要了 + # num = tdSql.getData(0,0) - for i in range(0,num): - sql1 = "select count(*) from %s.d%d" %(dbname,i) - tdSql.query(sql1) - sql1_result = tdSql.getData(0,0) - tdLog.info("sql:%s , result: %s" %(sql1,sql1_result)) + # for i in range(0,num): + # sql1 = "select count(*) from %s.d%d" %(dbname,i) + # tdSql.query(sql1) + # sql1_result = tdSql.getData(0,0) + # tdLog.info("sql:%s , result: %s" %(sql1,sql1_result)) + def check_out_of_order(self,dbname,tables,per_table_num,order,replica): self.run_benchmark(dbname,tables,per_table_num,order,replica) - print("sleep 10 seconds") - #time.sleep(10) - print("sleep 10 seconds finish") self.run_sql(dbname) @@ -188,7 +187,7 @@ class TDTestCase: startTime = time.time() #self.check_out_of_order('db1',10,random.randint(10000,50000),random.randint(1,10),1) - self.check_out_of_order('db1',random.randint(50,200),random.randint(10000,20000),random.randint(1,5),1) + self.check_out_of_order('db1',random.randint(50,100),random.randint(10000,20000),random.randint(1,5),1) # self.check_out_of_order('db2',random.randint(50,200),random.randint(10000,50000),random.randint(5,50),1) diff --git a/tests/system-test/2-query/sample.py b/tests/system-test/2-query/sample.py index a09d6a2b856bca40f1df55673c7d8e555f1df0f6..a43c2e635eb771687a237cabdb61d1311f29a1de 100644 --- a/tests/system-test/2-query/sample.py +++ b/tests/system-test/2-query/sample.py @@ -171,6 +171,7 @@ class TDTestCase: if any(parm in condition.lower().strip() for parm in condition_exception): print(f"case in {line}: ", end='') + print(f"condition : {condition}: ", end='') return tdSql.error(self.sample_query_form( sel=sel, func=func, col=col, m_comm=m_comm, k=k, r_comm=r_comm, alias=alias, fr=fr, table_expr=table_expr, condition=condition @@ -391,16 +392,6 @@ class TDTestCase: self.checksample(**case25) case26 = {"k": 1000} self.checksample(**case26) - case27 = { - "table_expr": f"{DBNAME}.stb1", - "condition": "group by tbname slimit 1 " - } - self.checksample(**case27) # with slimit - case28 = { - "table_expr": f"{DBNAME}.stb1", - "condition": "group by tbname slimit 1 soffset 1" - } - self.checksample(**case28) # with soffset pass diff --git a/tests/system-test/2-query/timeerror.py b/tests/system-test/2-query/timeerror.py new file mode 100644 index 0000000000000000000000000000000000000000..f43dc91de6a7c9faeeb3f86d92214f309f02c3e3 --- /dev/null +++ b/tests/system-test/2-query/timeerror.py @@ -0,0 +1,69 @@ +import taos +import sys +from time import sleep +from util.log import * +from util.sql import * +from util.cases import * + + + +class TDTestCase: + + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + + def run(self): + rows = 10 + + tdSql.execute("create database dbus PRECISION 'us' ") + tdSql.execute("create database dbns PRECISION 'ns' ") + tdSql.execute("create database dbms PRECISION 'ms' ") + dball = ["dbns","dbus","dbms"] + for i in range(len(dball)): + dbname = dball[i] + stb = f"{dbname}.stb1" + if i == 0 : + qts = 1678883666951061471 + qts1 = 1678883666951061471 + + qtime = "2023-03-15 20:34:26.951061471" + elif i == 1 : + qts = 1678883666951061 + qts1 = 1678883666951061 + + qtime = "2023-03-15 20:34:26.951061" + else: + qts = 1678883666951 + qts1 = 1678883666953 + + qtime = "2023-03-15 20:34:26.951" + + tdSql.execute(f"use {dbname}") + tdLog.printNoPrefix("==========step1:create table") + tdSql.execute( + f'''create table if not exists {stb} + (ts timestamp, c1 int, c2 float, c3 bigint, c4 double, c5 smallint, c6 tinyint) + tags(location binary(64), type int, isused bool , family nchar(64))''' + ) + tdSql.execute(f"create table {dbname}.t1 using {stb} tags('beijing', 1, 1, 'nchar1')") + tdSql.execute(f"create table {dbname}.t2 using {stb} tags('shanghai', 2, 0, 'nchar2')") + tdSql.execute(f"create table {dbname}.t3 using {stb} tags('shanghai', 3, 0, 'nchar3')") + + tdLog.printNoPrefix("==========step2:insert data") + tdSql.execute( + f"insert into {dbname}.t3 values ({qts}, null , {-3.4*10**38}, null , {-1.7*10**308}, null , null)" + ) + + tdLog.printNoPrefix("==========step3:query timestamp type") + tdSql.query(f"select ts from {dbname}.t3 limit 1") + tdSql.checkData(0,0,qtime) + tdSql.checkData(0,0,qts) + + 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/tsbsQuery.py b/tests/system-test/2-query/tsbsQuery.py index 4f415550b8e762fd2bb88838f75865e88a77d5c4..0e2975cdba02fc7b5a6ffda879b56f712649b43f 100644 --- a/tests/system-test/2-query/tsbsQuery.py +++ b/tests/system-test/2-query/tsbsQuery.py @@ -211,15 +211,16 @@ class TDTestCase: tdSql.query(f"select model,state_changed,count(state_changed) FROM (SELECT model,diff(broken_down) AS state_changed FROM (SELECT _wstart,model,cast(cast(floor(2*(sum(nzs)/count(nzs))) as bool) as int) AS broken_down FROM (SELECT ts,model, cast(cast(status as bool) as int) AS nzs from {dbname}.diagnostics WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' ) WHERE ts >= '2016-01-01T00:00:00Z' AND ts < '2016-01-05T00:00:01Z' partition BY model interval(10m)) partition BY model) where state_changed =1 partition BY model,state_changed ;") - sql=f"select model,ctc from (SELECT model,count(state_changed) as ctc FROM (SELECT model,diff(broken_down) AS state_changed FROM (SELECT model,cast(cast(floor(2*(sum(nzs)/count(nzs))) as bool) as int) AS broken_down FROM (SELECT ts,model, cast(cast(status as bool) as int) AS nzs from {dbname}.diagnostics WHERE ts >= 1451606400000 AND ts < 1451952001000 ) WHERE ts >= 1451606400000 AND ts < 1451952001000 partition BY model interval(10m)) partition BY model) WHERE state_changed = 1 partition BY model )where model is null;" - - # for i in range(2): - # tdSql.query("%s"%sql) - # quertR1=tdSql.queryResult - # for j in range(50): - # tdSql.query("%s"%sql) - # quertR2=tdSql.queryResult - # assert quertR1 == quertR2 , "%s != %s ,The results of multiple queries are different" %(quertR1,quertR2) + sql=f"SELECT model,count(state_changed) FROM (SELECT _rowts,model,diff(broken_down) AS state_changed FROM (SELECT ts,model,tb,cast(cast(floor(2*(nzs)) as bool) as int) AS broken_down FROM (SELECT _wstart as ts,model,tbname as tb, sum(cast(cast(status as bool) as int))/count(cast(cast(status as bool) as int)) AS nzs FROM {dbname}.diagnostics WHERE ts >= 1451606400000 AND ts < 1451952001000 partition BY tbname,model interval(10m))order by ts) partition BY tb,model ) WHERE state_changed = 1 partition BY model;" + tdSql.query(f"{sql}") + tdSql.checkRows(46) + for i in range(2): + tdSql.query("%s"%sql) + quertR1=tdSql.queryResult + for j in range(50): + tdSql.query("%s"%sql) + quertR2=tdSql.queryResult + assert quertR1 == quertR2 , "%s != %s ,The results of multiple queries are different" %(quertR1,quertR2) #it's already supported: diff --git a/tests/system-test/6-cluster/5dnode1mnode.py b/tests/system-test/6-cluster/5dnode1mnode.py index c17f001f0c3042000fcf4c1c3a82abc0a0fc45ac..61451f03b1927352f9d0a227925f33227458c12f 100644 --- a/tests/system-test/6-cluster/5dnode1mnode.py +++ b/tests/system-test/6-cluster/5dnode1mnode.py @@ -32,7 +32,7 @@ class TDTestCase: 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()) + tdSql.init(conn1.cursor(), True) def getBuildPath(self): diff --git a/tests/system-test/7-tmq/basic5.py b/tests/system-test/7-tmq/basic5.py index 69cf378da3da0b12e56242125c49bfe33afcb3a6..080b431ffe54f43e725e22d84a3f365f8bfc4cea 100644 --- a/tests/system-test/7-tmq/basic5.py +++ b/tests/system-test/7-tmq/basic5.py @@ -57,7 +57,7 @@ class TDTestCase: return cur def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum,rowsPerTbl): - tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) + tsql.execute("create database if not exists %s vgroups %d wal_retention_period 3600"%(dbName, vgroups)) tsql.execute("use %s" %dbName) tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName) pre_create = "create table" @@ -149,6 +149,7 @@ class TDTestCase: topicFromStb = 'topic_stb_column' topicFromCtb = 'topic_ctb_column' + tdSql.execute("alter database %s wal_retention_period 3600" % (parameterDict['dbName'])) tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s" %(topicFromStb, parameterDict['dbName'], parameterDict['stbName'])) tdSql.execute("create topic %s as select ts, c1, c2 from %s.%s_0" %(topicFromCtb, parameterDict['dbName'], parameterDict['stbName'])) diff --git a/tests/system-test/7-tmq/create_wrong_topic.py b/tests/system-test/7-tmq/create_wrong_topic.py index 39d519fec1be19009860408dd02d26630070af44..77d43149cd611225d2ee8f7b017013b0fc784bfb 100644 --- a/tests/system-test/7-tmq/create_wrong_topic.py +++ b/tests/system-test/7-tmq/create_wrong_topic.py @@ -44,6 +44,7 @@ class TDTestCase: def wrong_topic(self): tdSql.prepare() tdSql.execute('use db') + tdSql.execute('alter database db wal_retention_period 3600') stbname = f'db.{tdCom.getLongName(5, "letters")}' tag_dict = { 't0':'int' @@ -75,4 +76,4 @@ class TDTestCase: tdLog.success(f"{__file__} successfully executed") tdCases.addLinux(__file__, TDTestCase()) -tdCases.addWindows(__file__, TDTestCase()) \ No newline at end of file +tdCases.addWindows(__file__, TDTestCase()) diff --git a/tests/system-test/7-tmq/dataFromTsdbNWal-multiCtb.py b/tests/system-test/7-tmq/dataFromTsdbNWal-multiCtb.py index 808a4935e30ccec4d06863e54e5e2ff3e1ba635d..44f58279be2df9cc97ee504babebbbfda1793f44 100644 --- a/tests/system-test/7-tmq/dataFromTsdbNWal-multiCtb.py +++ b/tests/system-test/7-tmq/dataFromTsdbNWal-multiCtb.py @@ -67,6 +67,7 @@ class TDTestCase: tdLog.info("flush db to let data falls into the disk") tdSql.query("flush database %s"%(paraDict['dbName'])) + tdSql.execute("alter database %s wal_retention_period 3600"%(paraDict['dbName'])) return def tmqCase1(self): diff --git a/tests/system-test/7-tmq/dataFromTsdbNWal.py b/tests/system-test/7-tmq/dataFromTsdbNWal.py index 8386c22cd0430128a1b873f3f5150ef51704b245..0f4f1694c17701d9d4361c788980215ae418db5e 100644 --- a/tests/system-test/7-tmq/dataFromTsdbNWal.py +++ b/tests/system-test/7-tmq/dataFromTsdbNWal.py @@ -67,6 +67,7 @@ class TDTestCase: tdLog.info("flush db to let data falls into the disk") tdSql.query("flush database %s"%(paraDict['dbName'])) + tdSql.execute("alter database %s wal_retention_period 3600"%(paraDict['dbName'])) return def tmqCase1(self): diff --git a/tests/system-test/7-tmq/db.py b/tests/system-test/7-tmq/db.py index 04f5aac559b060e17b23618cea1007e41ffb858d..e0d1e2c5b6190ed28f9e8ad9f3e4c8b15d57bb51 100644 --- a/tests/system-test/7-tmq/db.py +++ b/tests/system-test/7-tmq/db.py @@ -60,7 +60,7 @@ class TDTestCase: def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("drop database if exists %s "%(cdbName)) - tdSql.query("create database %s vgroups 1"%(cdbName)) + tdSql.query("create database %s vgroups 1 wal_retention_period 3600"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) diff --git a/tests/system-test/7-tmq/dropDbR3ConflictTransaction.py b/tests/system-test/7-tmq/dropDbR3ConflictTransaction.py index 4371a909c253b3aaf1f7f4d5fad931ee35665519..fa22cad726ee700dd05350d0d03d5463bfbbcdec 100644 --- a/tests/system-test/7-tmq/dropDbR3ConflictTransaction.py +++ b/tests/system-test/7-tmq/dropDbR3ConflictTransaction.py @@ -134,6 +134,7 @@ class TDTestCase: paraDict['ctbNum'] = self.ctbNum paraDict['rowsPerTbl'] = self.rowsPerTbl + tdSql.execute("alter database dbt wal_retention_period 3600") tdLog.info("create topics from stb1") topicFromStb1 = 'topic_stb1' queryString = "select ts, c1, c2 from %s.%s where t4 == 'beijing' or t4 == 'changsha' "%(paraDict['dbName'], paraDict['stbName']) diff --git a/tests/system-test/7-tmq/raw_block_interface_test.py b/tests/system-test/7-tmq/raw_block_interface_test.py new file mode 100644 index 0000000000000000000000000000000000000000..1e89de1cce397e8c64e2a78bb6fb8614d011d47d --- /dev/null +++ b/tests/system-test/7-tmq/raw_block_interface_test.py @@ -0,0 +1,54 @@ + +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, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor()) + + def checkData(self): + tdSql.execute('use db_raw') + tdSql.query("select * from d1") + tdSql.checkRows(1) + tdSql.checkData(0, 1, 120) + + tdSql.query("select * from d2") + tdSql.checkRows(1) + tdSql.checkData(0, 1, None) + + return + + def check(self): + buildPath = tdCom.getBuildPath() + cmdStr = '%s/build/bin/write_raw_block_test'%(buildPath) + tdLog.info(cmdStr) + os.system(cmdStr) + + self.checkData() + + return + + def run(self): + tdSql.prepare() + self.check() + + 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/7-tmq/schema.py b/tests/system-test/7-tmq/schema.py index 04224fbc7e86d177829f898855067986aae81746..95c1839964eeb20ac9aa1672713527d197c179b1 100644 --- a/tests/system-test/7-tmq/schema.py +++ b/tests/system-test/7-tmq/schema.py @@ -60,7 +60,7 @@ class TDTestCase: def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") tdSql.query("drop database if exists %s "%(cdbName)) - tdSql.query("create database %s vgroups 1"%(cdbName)) + tdSql.query("create database %s vgroups 1 wal_retention_period 3600"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) @@ -115,7 +115,7 @@ class TDTestCase: 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)) + tsql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600"%(dbName, vgroups, replica)) tdLog.debug("complete to create database %s"%(dbName)) return diff --git a/tests/system-test/7-tmq/stbFilter.py b/tests/system-test/7-tmq/stbFilter.py index 6b48a6d57076b4baf54d7c08db7cd8a625fab29c..3f862ae0472f6a1312ac5f2ea680adbd4b95f172 100644 --- a/tests/system-test/7-tmq/stbFilter.py +++ b/tests/system-test/7-tmq/stbFilter.py @@ -45,6 +45,7 @@ class TDTestCase: tmqCom.initConsumerTable() tmqCom.create_database(tsql=tdSql, dbName=paraDict["dbName"],dropFlag=paraDict["dropFlag"], vgroups=paraDict['vgroups'],replica=paraDict['replica']) + tdSql.execute("alter database %s wal_retention_period 3600"%(paraDict["dbName"])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/stbTagFilter-1ctb.py b/tests/system-test/7-tmq/stbTagFilter-1ctb.py index c4a7c8cae5551c6374d683f941148f8f054dd53c..7ee5fce5a81ffb50341a61497f5616b03040d998 100644 --- a/tests/system-test/7-tmq/stbTagFilter-1ctb.py +++ b/tests/system-test/7-tmq/stbTagFilter-1ctb.py @@ -106,6 +106,7 @@ class TDTestCase: # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + tdSql.execute("alter database dbt wal_retention_period 3600") tdLog.info("create topics from stb1") topicFromStb1 = 'topic_UpperCase_stb1' # queryString = "select ts, c1, c2 from %s.%s where t4 == 'shanghai' or t4 == 'changsha'"%(paraDict['dbName'], paraDict['stbName']) diff --git a/tests/system-test/7-tmq/stbTagFilter-multiCtb.py b/tests/system-test/7-tmq/stbTagFilter-multiCtb.py index c380d201b2d8827c6e3d12f03a0168ed47af0362..71b7fdef5d6a2fc072b7a21ef4205ea7a651bce2 100644 --- a/tests/system-test/7-tmq/stbTagFilter-multiCtb.py +++ b/tests/system-test/7-tmq/stbTagFilter-multiCtb.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" %(paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/subscribeDb.py b/tests/system-test/7-tmq/subscribeDb.py index 0fa9bcfbd461c0498d301e7b702a2ee3f8dd8aa4..631813e7ab864d486411bbd437079181ba9711bb 100644 --- a/tests/system-test/7-tmq/subscribeDb.py +++ b/tests/system-test/7-tmq/subscribeDb.py @@ -13,11 +13,11 @@ from util.dnodes import * class TDTestCase: hostname = socket.gethostname() - #rpcDebugFlagVal = '143' + # rpcDebugFlagVal = '143' #clientCfgDict = {'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''} #clientCfgDict["rpcDebugFlag"] = rpcDebugFlagVal #updatecfgDict = {'clientCfg': {}, 'serverPort': '', 'firstEp': '', 'secondEp':'', 'rpcDebugFlag':'135', 'fqdn':''} - #updatecfgDict["rpcDebugFlag"] = rpcDebugFlagVal + # updatecfgDict["rpcDebugFlag"] = rpcDebugFlagVal #print ("===================: ", updatecfgDict) def init(self, conn, logSql, replicaVar=1): @@ -52,7 +52,7 @@ class TDTestCase: def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") - tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) + tdSql.query("create database if not exists %s vgroups 1 wal_retention_period 3600"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) @@ -99,7 +99,7 @@ class TDTestCase: os.system(shellCmd) def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum): - tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) + tsql.execute("create database if not exists %s vgroups %d wal_retention_period 3600"%(dbName, vgroups)) tsql.execute("use %s" %dbName) tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName) pre_create = "create table" @@ -180,7 +180,7 @@ class TDTestCase: self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() @@ -278,7 +278,7 @@ class TDTestCase: self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() @@ -345,7 +345,7 @@ class TDTestCase: self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'])) tdSql.execute("create table if not exists %s.%s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%(parameterDict['dbName'], parameterDict['stbName'])) tdLog.info("create topics from db") @@ -415,7 +415,7 @@ class TDTestCase: self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() diff --git a/tests/system-test/7-tmq/subscribeDb0.py b/tests/system-test/7-tmq/subscribeDb0.py index 50ef52cb15a5336395154813619976c7933f2dc7..ed13fcbe06be1c82590752b7257528190b972192 100644 --- a/tests/system-test/7-tmq/subscribeDb0.py +++ b/tests/system-test/7-tmq/subscribeDb0.py @@ -52,7 +52,7 @@ class TDTestCase: def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") - tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) + tdSql.query("create database if not exists %s vgroups 1 wal_retention_period 3600"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) @@ -99,7 +99,7 @@ class TDTestCase: os.system(shellCmd) def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum): - tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) + tsql.execute("create database if not exists %s vgroups %d wal_retention_period 3600"%(dbName, vgroups)) tsql.execute("use %s" %dbName) tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName) pre_create = "create table" @@ -180,7 +180,7 @@ class TDTestCase: self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() @@ -262,7 +262,7 @@ class TDTestCase: self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() diff --git a/tests/system-test/7-tmq/subscribeDb1.py b/tests/system-test/7-tmq/subscribeDb1.py index c5ae44214a0cea58f2c4f3cfee03dd0c3e5918a2..605e862950799b81fe57451a94e62ba086fa0a47 100644 --- a/tests/system-test/7-tmq/subscribeDb1.py +++ b/tests/system-test/7-tmq/subscribeDb1.py @@ -52,7 +52,7 @@ class TDTestCase: def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") - tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) + tdSql.query("create database if not exists %s vgroups 1 wal_retention_period 3600"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) @@ -99,7 +99,7 @@ class TDTestCase: os.system(shellCmd) def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum): - tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) + tsql.execute("create database if not exists %s vgroups %d wal_retention_period 3600"%(dbName, vgroups)) tsql.execute("use %s" %dbName) tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName) pre_create = "create table" @@ -123,8 +123,9 @@ class TDTestCase: pre_insert = "insert into " sql = pre_insert - t = time.time() - startTs = int(round(t * 1000)) + # t = 1678609778776 #time.time() + t = 1600000000000 + startTs = t #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) @@ -179,8 +180,8 @@ class TDTestCase: parameterDict['cfg'] = cfgPath self.initConsumerTable() - tdLog.info("create database if not exists %s vgroups %d replica %d" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) - tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) + tdLog.info("create database if not exists %s vgroups %d replica %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() @@ -196,7 +197,7 @@ class TDTestCase: 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict2['dbName'], parameterDict2['vgroups'], parameterDict2['replica'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600" %(parameterDict2['dbName'], parameterDict2['vgroups'], parameterDict2['replica'])) prepareEnvThread2 = threading.Thread(target=self.prepareEnv, kwargs=parameterDict2) prepareEnvThread2.start() @@ -267,7 +268,7 @@ class TDTestCase: self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'], parameterDict['replica'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() @@ -283,7 +284,7 @@ class TDTestCase: 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - tdSql.execute("create database if not exists %s vgroups %d replica %d" %(parameterDict2['dbName'], parameterDict2['vgroups'], parameterDict2['replica'])) + tdSql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600" %(parameterDict2['dbName'], parameterDict2['vgroups'], parameterDict2['replica'])) prepareEnvThread2 = threading.Thread(target=self.prepareEnv, kwargs=parameterDict2) prepareEnvThread2.start() diff --git a/tests/system-test/7-tmq/subscribeDb2.py b/tests/system-test/7-tmq/subscribeDb2.py index d045842e45f4f526e5916081774177b22847ef11..60cde8d7f0940a8427e7f76ae31f5c682e36ca57 100644 --- a/tests/system-test/7-tmq/subscribeDb2.py +++ b/tests/system-test/7-tmq/subscribeDb2.py @@ -53,7 +53,7 @@ class TDTestCase: def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") - tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) + tdSql.query("create database if not exists %s vgroups 1 wal_retention_period 3600"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) @@ -100,7 +100,7 @@ class TDTestCase: os.system(shellCmd) def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum,rowsPerTbl): - tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) + tsql.execute("create database if not exists %s vgroups %d wal_retention_period 3600"%(dbName, vgroups)) tsql.execute("use %s" %dbName) tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName) pre_create = "create table" @@ -185,7 +185,7 @@ class TDTestCase: self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() @@ -263,7 +263,7 @@ class TDTestCase: self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() diff --git a/tests/system-test/7-tmq/subscribeDb3.py b/tests/system-test/7-tmq/subscribeDb3.py index 747ea3ba86c56a4008014e044fad5de6f8536f32..f82f89f1b9f37ab77ccea3368ccd1d5c51d861e7 100644 --- a/tests/system-test/7-tmq/subscribeDb3.py +++ b/tests/system-test/7-tmq/subscribeDb3.py @@ -52,7 +52,7 @@ class TDTestCase: def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") - tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) + tdSql.query("create database if not exists %s vgroups 1 wal_retention_period 3600"%(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)) @@ -122,7 +122,7 @@ class TDTestCase: os.system(shellCmd) def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum,rowsPerTbl): - tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) + tsql.execute("create database if not exists %s vgroups %d wal_retention_period 3600"%(dbName, vgroups)) tsql.execute("use %s" %dbName) tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName) pre_create = "create table" @@ -203,7 +203,7 @@ class TDTestCase: self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() @@ -280,7 +280,7 @@ class TDTestCase: self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() diff --git a/tests/system-test/7-tmq/subscribeDb4.py b/tests/system-test/7-tmq/subscribeDb4.py index c14d3b27b11fa8e36bd216f23a2371018358aaf0..764362c70882e0851d3cd5eb80ac4f0096a71113 100644 --- a/tests/system-test/7-tmq/subscribeDb4.py +++ b/tests/system-test/7-tmq/subscribeDb4.py @@ -65,6 +65,7 @@ class TDTestCase: tmqCom.initConsumerTable(self.cdbName) tdCom.create_database(tdSql,self.paraDict["dbName"],self.paraDict["dropFlag"]) + tdSql.execute("alter database %s wal_retention_period 3600" % (self.paraDict['dbName'])) self.paraDict["stbName"] = 'stb1' tdCom.create_stable(tdSql,dbname=self.paraDict["dbName"],stbname=self.paraDict["stbName"],column_elm_list=self.paraDict["colSchema"],tag_elm_list=self.paraDict["tagSchema"],count=1, default_stbname_prefix=self.paraDict["stbName"]) diff --git a/tests/system-test/7-tmq/subscribeStb.py b/tests/system-test/7-tmq/subscribeStb.py index 3ff0b25ff6b4585a8abc4061e7e46abced77d15e..c8b66adfa2db404941838e64170be41f27ad24b5 100644 --- a/tests/system-test/7-tmq/subscribeStb.py +++ b/tests/system-test/7-tmq/subscribeStb.py @@ -59,7 +59,7 @@ class TDTestCase: def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") - tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) + tdSql.query("create database if not exists %s vgroups 1 wal_retention_period 3600"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) @@ -114,7 +114,7 @@ class TDTestCase: 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)) + tsql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600"%(dbName, vgroups, replica)) tdLog.debug("complete to create database %s"%(dbName)) return diff --git a/tests/system-test/7-tmq/subscribeStb0.py b/tests/system-test/7-tmq/subscribeStb0.py index 1463cad627a23dd106d6afb78a4ee274345a840f..717cf05bdc6d3dfa4d27c915d57fbe3bf61b8e60 100644 --- a/tests/system-test/7-tmq/subscribeStb0.py +++ b/tests/system-test/7-tmq/subscribeStb0.py @@ -59,7 +59,7 @@ class TDTestCase: def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") - tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) + tdSql.query("create database if not exists %s vgroups 1 wal_retention_period 3600"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) @@ -114,7 +114,7 @@ class TDTestCase: 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)) + tsql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600"%(dbName, vgroups, replica)) tdLog.debug("complete to create database %s"%(dbName)) return diff --git a/tests/system-test/7-tmq/subscribeStb1.py b/tests/system-test/7-tmq/subscribeStb1.py index edbe1bc3c6dbcbef26a9068c3d644db03d1d9d12..6d4b7d2380161be0b4baaded864a782f8dbd86f5 100644 --- a/tests/system-test/7-tmq/subscribeStb1.py +++ b/tests/system-test/7-tmq/subscribeStb1.py @@ -59,7 +59,7 @@ class TDTestCase: def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") - tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) + tdSql.query("create database if not exists %s vgroups 1 wal_retention_period 3600"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) @@ -114,7 +114,7 @@ class TDTestCase: 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)) + tsql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600"%(dbName, vgroups, replica)) tdLog.debug("complete to create database %s"%(dbName)) return @@ -245,8 +245,8 @@ class TDTestCase: for i in range(expectRows): totalConsumeRows += resultList[i] - if totalConsumeRows != expectrowcnt/4: - tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt/4)) + tdLog.info("act consume rows: %d, expect consume rows greater than or equal to: %d"%(totalConsumeRows, expectrowcnt/4)) + if totalConsumeRows < expectrowcnt/4: tdLog.exit("tmq consume rows error!") self.initConsumerInfoTable() @@ -267,8 +267,8 @@ class TDTestCase: for i in range(expectRows): totalConsumeRows += resultList[i] - if totalConsumeRows != expectrowcnt: - tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) + tdLog.info("act consume rows: %d, expect consume rows greater than or equal to: %d"%(totalConsumeRows, expectrowcnt)) + if totalConsumeRows < expectrowcnt: tdLog.exit("tmq consume rows error!") tdSql.query("drop topic %s"%topicFromStb1) diff --git a/tests/system-test/7-tmq/subscribeStb2.py b/tests/system-test/7-tmq/subscribeStb2.py index 6c3e122902cc907dacd8297d95f27c6289cad176..422cb23ffd1c503873cde2ca6b26ae6763a899c8 100644 --- a/tests/system-test/7-tmq/subscribeStb2.py +++ b/tests/system-test/7-tmq/subscribeStb2.py @@ -59,7 +59,7 @@ class TDTestCase: def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") - tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) + tdSql.query("create database if not exists %s vgroups 1 wal_retention_period 3600"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) @@ -114,7 +114,7 @@ class TDTestCase: 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)) + tsql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600"%(dbName, vgroups, replica)) tdLog.debug("complete to create database %s"%(dbName)) return diff --git a/tests/system-test/7-tmq/subscribeStb3.py b/tests/system-test/7-tmq/subscribeStb3.py index 025f403282e46eab4893062069bcea820124203b..7205e846205e87cfa4589f01bc6a76c29fda4986 100644 --- a/tests/system-test/7-tmq/subscribeStb3.py +++ b/tests/system-test/7-tmq/subscribeStb3.py @@ -59,7 +59,7 @@ class TDTestCase: def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") - tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) + tdSql.query("create database if not exists %s vgroups 1 wal_retention_period 3600"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) @@ -114,7 +114,7 @@ class TDTestCase: 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)) + tsql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600"%(dbName, vgroups, replica)) tdLog.debug("complete to create database %s"%(dbName)) return diff --git a/tests/system-test/7-tmq/subscribeStb4.py b/tests/system-test/7-tmq/subscribeStb4.py index 6aa3da66a46b316c55b2586bfc4c82f96fc33a8c..bb8afcf14ee300231e44c2766ac61d3420f237f1 100644 --- a/tests/system-test/7-tmq/subscribeStb4.py +++ b/tests/system-test/7-tmq/subscribeStb4.py @@ -59,7 +59,7 @@ class TDTestCase: def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") - tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) + tdSql.query("create database if not exists %s vgroups 1 wal_retention_period 3600"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) @@ -114,7 +114,7 @@ class TDTestCase: 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)) + tsql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600"%(dbName, vgroups, replica)) tdLog.debug("complete to create database %s"%(dbName)) return diff --git a/tests/system-test/7-tmq/tmq3mnodeSwitch.py b/tests/system-test/7-tmq/tmq3mnodeSwitch.py index cdcdadbcbb396d1e7228bba7779549e86646871c..22ef8cebdc1f367d8d95010087e15b2eaf2f72e8 100644 --- a/tests/system-test/7-tmq/tmq3mnodeSwitch.py +++ b/tests/system-test/7-tmq/tmq3mnodeSwitch.py @@ -200,6 +200,7 @@ class TDTestCase: tdLog.info("async insert data") pThread = tmqCom.asyncInsertData(paraDict) + tdSql.execute("alter database %s wal_retention_period 3600" %(paraDict['dbName'])) tdLog.info("create topics from stb with filter") # queryString = "select ts, log(c1), ceil(pow(c1,3)) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) @@ -211,7 +212,7 @@ class TDTestCase: # 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"] + expectrowcnt = paraDict["rowsPerTbl"] * paraDict["ctbNum"] * 2 # because taosd switch, may be consume duplication data topicList = topicNameList[0] ifcheckdata = 1 ifManualCommit = 1 @@ -251,11 +252,12 @@ class TDTestCase: 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.info("expect consume rows: %d should less/equal than act consume rows: %d"%(expectRowsList[0], resultList[0])) + if expectRowsList[0] > resultList[0]: tdLog.exit("0 tmq consume rows error!") - self.checkFileContent(consumerId, queryString) + if expectRowsList[0] == resultList[0]: + self.checkFileContent(consumerId, queryString) time.sleep(10) for i in range(len(topicNameList)): diff --git a/tests/system-test/7-tmq/tmqAlterSchema.py b/tests/system-test/7-tmq/tmqAlterSchema.py index a70678219f15ba94b7f9ceb1f81b9aa3881660d4..1a8b0693b86cae8d12eaeb11f3af91f587a23a6f 100644 --- a/tests/system-test/7-tmq/tmqAlterSchema.py +++ b/tests/system-test/7-tmq/tmqAlterSchema.py @@ -65,6 +65,7 @@ class TDTestCase: queryStringList = [] tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" %(paraDict['dbName'])) 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") @@ -175,6 +176,7 @@ class TDTestCase: queryStringList = [] tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" %(paraDict['dbName'])) 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 ntb") diff --git a/tests/system-test/7-tmq/tmqAutoCreateTbl.py b/tests/system-test/7-tmq/tmqAutoCreateTbl.py index 41073d83ae13b5a3828bbc758d8d1d2c600f8ca6..5d0af636b206e5c13ca403dd35c70fabeb2601cd 100644 --- a/tests/system-test/7-tmq/tmqAutoCreateTbl.py +++ b/tests/system-test/7-tmq/tmqAutoCreateTbl.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1, wal_retention_size=-1,wal_retention_period=-1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) # tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqCheckData.py b/tests/system-test/7-tmq/tmqCheckData.py index 04d0744ab595279ac834e62669cb100df113d253..a9671241a966ea632f31726349580a8e7152f440 100644 --- a/tests/system-test/7-tmq/tmqCheckData.py +++ b/tests/system-test/7-tmq/tmqCheckData.py @@ -80,6 +80,7 @@ class TDTestCase: tdLog.info("insert data") tmqCom.insert_data(tdSql,paraDict["dbName"],paraDict["ctbPrefix"],paraDict["ctbNum"],paraDict["rowsPerTbl"],paraDict["batchNum"],paraDict["startTs"]) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create topics from stb with filter") queryString = "select ts, log(c1), ceil(pow(c1,3)) from %s.%s where c1 %% 7 == 0" %(paraDict['dbName'], paraDict['stbName']) sqlString = "create topic %s as %s" %(topicNameList[0], queryString) diff --git a/tests/system-test/7-tmq/tmqCheckData1.py b/tests/system-test/7-tmq/tmqCheckData1.py index b9dac62833ba45dc63fca65e1b6f642265b655dd..e06c29c5a2770ec7f2e2a34d391495ee24399f0c 100644 --- a/tests/system-test/7-tmq/tmqCheckData1.py +++ b/tests/system-test/7-tmq/tmqCheckData1.py @@ -73,6 +73,7 @@ class TDTestCase: expectRowsList = [] tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) 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") diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py b/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py index f372a2b7428a77b02b8dcdb5c4c546756ef7e1f7..3ad1d097e11b85f04f1d0cc9b2cd75a9ea1bdb0a 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb-funcNFilter.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb.py b/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb.py index c7f95f6f41cbf72e8d64c3a9bd8218dfd7a1c6d5..fdd683d08daba5625017029a3363b379d2a206b1 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-1ctb.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py index 26dacf514d4f66273d36f6ac3fe49ee17602747a..f05f0abeff3f3f6dabde18ac3d3543d9df032f4e 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb-funcNFilter.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py index d6f100041b15c205e8294cca964353d880b9ecc4..75b49a34fc583217e5ee0bb81324abc8421ed31a 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg-mutilCtb.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py index 87832ac0ef2169ad2895928ceb20121ae17ecba9..26f7a9fb4d1300907807651a5e2fd9dd80579725 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb-mutilVg.py @@ -16,6 +16,8 @@ sys.path.append("./7-tmq") from tmqCommon import * class TDTestCase: + updatecfgDict = {"tsdbDebugFlag":135} + def __init__(self): self.vgroups = 4 self.ctbNum = 10 @@ -54,6 +56,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb.py b/tests/system-test/7-tmq/tmqConsFromTsdb.py index 8ed4a6df973b57f7302d5a2c193debffbf7286a1..cca29c178db281b86d145b8623f72a2dd8df1366 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=self.replicaVar) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py index 6a03f0f75192dda0b8b8394b1733bdec02222bda..00d2491c97b0a178fbfd289cf44e2617107fdfe9 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb.py index c11159c6e551d60b90aab16bb7c90e4b26021ac2..3b1dbae443f0e8d6f71dc3c8127975790c23401a 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-1ctb.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py index 37946d0c22dae353ac62cb8e564c1361115bf8f9..a799fa57195fe84065c7bb0b295dc7c0f14cdd09 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py index 439845aa54a6d29c1cd7633e9949da3eaa40cfee..f0bedbb187b9987e8f367f1afed7b69fb4c41001 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg.py b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg.py index 53ff020b08abf2b758a6de00984b0cb799528d45..a63927dd8bdee0483cc943ececaac1855248ef57 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1-mutilVg.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqConsFromTsdb1.py b/tests/system-test/7-tmq/tmqConsFromTsdb1.py index 4bb6cf463f59519565f43e04e18d7d7902b73108..8fcc991d4e3904da04480c7bbc28cac49cf5c068 100644 --- a/tests/system-test/7-tmq/tmqConsFromTsdb1.py +++ b/tests/system-test/7-tmq/tmqConsFromTsdb1.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=self.replicaVar) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqConsumerGroup.py b/tests/system-test/7-tmq/tmqConsumerGroup.py index 02093a2d889f1f7138e29055145bc63318dd2873..b1aef9d762f7d994c0bfa02ab04b0c64b76edffa 100644 --- a/tests/system-test/7-tmq/tmqConsumerGroup.py +++ b/tests/system-test/7-tmq/tmqConsumerGroup.py @@ -73,6 +73,7 @@ class TDTestCase: expectRowsList = [] tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) 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") diff --git a/tests/system-test/7-tmq/tmqDelete-1ctb.py b/tests/system-test/7-tmq/tmqDelete-1ctb.py index b09efdd1e6a67ac0312f45e4277302d177ca34a4..6dc8de7efce5659b46e386eabcd69130a1c08524 100644 --- a/tests/system-test/7-tmq/tmqDelete-1ctb.py +++ b/tests/system-test/7-tmq/tmqDelete-1ctb.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1,wal_retention_size=-1, wal_retention_period=-1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") @@ -323,7 +324,7 @@ class TDTestCase: if self.snapshot == 0: consumerId = 4 - expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 + 1/4 + 3/4)) + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1/4 + 3/4)) elif self.snapshot == 1: consumerId = 5 expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 - 1/4 + 1/4 + 3/4)) @@ -369,9 +370,14 @@ class TDTestCase: tdLog.info("act consume rows: %d, act query rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsFromQuery, expectrowcnt)) if self.snapshot == 0: - if totalConsumeRows != expectrowcnt: + # If data writing is completed before consumer get snapshot, will consume 7500 from wal; + # If data writing has not started before consumer get snapshot, will consume 10000 from wal; + minRows = int(expectrowcnt * (1 - 1/4)) # 7500 + tdLog.info("consume rows should be between %d and %d, "%(minRows, expectrowcnt)) + if not ((totalConsumeRows >= minRows) and (totalConsumeRows <= expectrowcnt)): tdLog.exit("tmq consume rows error with snapshot = 0!") elif self.snapshot == 1: + tdLog.info("consume rows should be between %d and %d, "%(totalRowsFromQuery, expectrowcnt)) if not ((totalConsumeRows >= totalRowsFromQuery) and (totalConsumeRows <= expectrowcnt)): tdLog.exit("tmq consume rows error with snapshot = 1!") @@ -381,7 +387,113 @@ class TDTestCase: tdLog.printNoPrefix("======== test case 3 end ...... ") + def tmqCase4(self): + tdLog.printNoPrefix("======== test case 4: ") + paraDict = {'dbName': 'dbt', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1},{'type': 'TIMESTAMP', 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbStartIdx': 0, + 'ctbNum': 1, + 'rowsPerTbl': 10000, + 'batchNum': 5000, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 15, + 'showMsg': 1, + 'showRow': 1, + 'snapshot': 0} + paraDict['snapshot'] = self.snapshot + paraDict['vgroups'] = self.vgroups + paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + + tdLog.info("restart taosd to ensure that the data falls into the disk") + tdSql.query("flush database %s"%(paraDict['dbName'])) + + tmqCom.initConsumerTable() + tdLog.info("create topics from stb1") + topicFromStb1 = 'topic_stb1' + queryString = "select ts, c1, c2 from %s.%s"%(paraDict['dbName'], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicFromStb1, queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + + # paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + consumerId = 1 + + if self.snapshot == 0: + consumerId = 4 + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"]) + elif self.snapshot == 1: + consumerId = 5 + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 - 1/4 + 1/4 + 3/4)) + + topicList = topicFromStb1 + ifcheckdata = 1 + ifManualCommit = 1 + keyList = 'group.id:cgrp1,\ + enable.auto.commit:true,\ + auto.commit.interval.ms:1000,\ + auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + # del some data + rowsOfDelete = int(self.rowsPerTbl / 4 ) + paraDict["endTs"] = paraDict["startTs"] + rowsOfDelete - 1 + # pDeleteThread = self.asyncDeleteData(paraDict) + self.threadFunctionForDeletaData(paraDict) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) + + tmqCom.getStartConsumeNotifyFromTmqsim() + + # update to 1/4 rows and insert 3/4 new rows + paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl * 3 / 4) + # paraDict['rowsPerTbl'] = self.rowsPerTbl + # tmqCom.insert_data_with_autoCreateTbl(tsql=tdSql,dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict["ctbPrefix"], + # ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], + # startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + pInsertThread = tmqCom.asyncInsertDataByInterlace(paraDict) + + pInsertThread.join() + + tdLog.info("start to check consume result") + expectRows = 1 + resultList = tmqCom.selectConsumeResult(expectRows) + totalConsumeRows = 0 + for i in range(expectRows): + totalConsumeRows += resultList[i] + + tdSql.query(queryString) + totalRowsFromQuery = tdSql.getRows() + + tdLog.info("act consume rows: %d, act query rows: %d, expect consume rows: %d, "%(totalConsumeRows, totalRowsFromQuery, expectrowcnt)) + + if self.snapshot == 0: + tdLog.info("consume rows should be %d"%(expectrowcnt)) + if (totalConsumeRows != expectrowcnt): + tdLog.exit("tmq consume rows error with snapshot = 0!") + elif self.snapshot == 1: + # If data writing has not started before consumer get snapshot, will consume 10000 from wal, and consumer 7500 from tsdb; + tdLog.info("consume rows should be %d, "%(expectrowcnt)) + if (totalConsumeRows != expectrowcnt): + tdLog.exit("tmq consume rows error with snapshot = 1!") + + # tmqCom.checkFileContent(consumerId, queryString) + + tdSql.query("drop topic %s"%topicFromStb1) + + tdLog.printNoPrefix("======== test case 4 end ...... ") + def run(self): # tdSql.prepare() tdLog.printNoPrefix("=============================================") @@ -409,6 +521,17 @@ class TDTestCase: self.prepareTestEnv() self.tmqCase3() + tdLog.printNoPrefix("=============================================") + tdLog.printNoPrefix("======== snapshot is 0: only consume from wal") + self.snapshot = 0 + self.prepareTestEnv() + self.tmqCase4() + tdLog.printNoPrefix("====================================================================") + tdLog.printNoPrefix("======== snapshot is 1: firstly consume from tsbs, and then from wal") + self.snapshot = 1 + self.prepareTestEnv() + self.tmqCase4() + def stop(self): tdSql.close() tdLog.success(f"{__file__} successfully executed") diff --git a/tests/system-test/7-tmq/tmqDelete-multiCtb.py b/tests/system-test/7-tmq/tmqDelete-multiCtb.py index e59e3d6ecda6e13127eba3f087029ad281cc55b3..7a47cd6025ccffab89656caf017f21aa2005c1c6 100644 --- a/tests/system-test/7-tmq/tmqDelete-multiCtb.py +++ b/tests/system-test/7-tmq/tmqDelete-multiCtb.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=self.replicaVar,wal_retention_size=-1, wal_retention_period=-1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqDnode.py b/tests/system-test/7-tmq/tmqDnode.py index e1d6d91e2d620fe6a1ca7b28a5762047eaaa9bed..b96ca24ac5ad372eb5e3b15fbbebc63adeb9f63e 100644 --- a/tests/system-test/7-tmq/tmqDnode.py +++ b/tests/system-test/7-tmq/tmqDnode.py @@ -110,7 +110,7 @@ class TDTestCase: 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)) + tsql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600"%(dbName, vgroups, replica)) tdLog.debug("complete to create database %s"%(dbName)) return diff --git a/tests/system-test/7-tmq/tmqDnodeRestart.py b/tests/system-test/7-tmq/tmqDnodeRestart.py index a44ff916e5a22c92e68d743333e4c4b921929111..648d629e5cc2e5cbcc8d60cf1599ba93c37d080a 100644 --- a/tests/system-test/7-tmq/tmqDnodeRestart.py +++ b/tests/system-test/7-tmq/tmqDnodeRestart.py @@ -55,6 +55,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1,wal_retention_size=-1, wal_retention_period=-1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") @@ -136,7 +137,7 @@ class TDTestCase: tdLog.info("================= restart dnode ===========================") tdDnodes.stoptaosd(1) tdDnodes.starttaosd(1) - # time.sleep(3) + time.sleep(5) tdLog.info(" restart taosd end and wait to check consume result") expectRows = 1 @@ -145,7 +146,7 @@ class TDTestCase: for i in range(expectRows): totalConsumeRows += resultList[i] - tdSql.query(queryString) + tdSql.query(queryString, None, 50) totalRowsFromQury = tdSql.getRows() tdLog.info("act consume rows: %d, act query rows: %d"%(totalConsumeRows, totalRowsFromQury)) @@ -186,6 +187,7 @@ class TDTestCase: tmqCom.initConsumerTable() # tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + # tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) # tdLog.info("create stb") # tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) # tdLog.info("create ctb") @@ -220,7 +222,7 @@ class TDTestCase: tdLog.info("================= restart dnode ===========================") tdDnodes.stoptaosd(1) tdDnodes.starttaosd(1) - # time.sleep(3) + time.sleep(5) tdLog.info("create some new child table and insert data ") paraDict["batchNum"] = 100 @@ -234,7 +236,7 @@ class TDTestCase: for i in range(expectRows): totalConsumeRows += resultList[i] - tdSql.query(queryString) + tdSql.query(queryString, None, 50) totalRowsFromQuery = tdSql.getRows() tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, totalRowsFromQuery)) diff --git a/tests/system-test/7-tmq/tmqDnodeRestart1.py b/tests/system-test/7-tmq/tmqDnodeRestart1.py index 982cc0a6313f8482031290acd89ea9f556dd5be3..cff55a1239b37414d234185d2326f089c1bb8f41 100644 --- a/tests/system-test/7-tmq/tmqDnodeRestart1.py +++ b/tests/system-test/7-tmq/tmqDnodeRestart1.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1,wal_retention_size=-1, wal_retention_period=-1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqDropNtb-snapshot0.py b/tests/system-test/7-tmq/tmqDropNtb-snapshot0.py index 6c49fae299ac68aac99892acf5de3011df0ab1a0..7a9c1bbb8c808fe62e8fede76640ac78e19f2f30 100644 --- a/tests/system-test/7-tmq/tmqDropNtb-snapshot0.py +++ b/tests/system-test/7-tmq/tmqDropNtb-snapshot0.py @@ -57,6 +57,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdLog.info("start create database....") tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("start create normal tables....") tmqCom.create_ntable(tsql=tdSql, dbname=paraDict["dbName"], tbname_prefix=paraDict["ctbPrefix"], tbname_index_start_num = 1, column_elm_list=paraDict["colSchema"], colPrefix='c', tblNum=paraDict["ctbNum"]) tdLog.info("start insert data into normal tables....") @@ -100,7 +101,7 @@ class TDTestCase: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) - if not ((totalConsumeRows >= expectrowcnt * 3/4) and (totalConsumeRows < expectrowcnt)): + if not ((totalConsumeRows >= expectrowcnt * 3/4) and (totalConsumeRows <= expectrowcnt)): tdLog.exit("tmq consume rows error with snapshot = 0!") tdLog.info("wait subscriptions exit ....") @@ -131,7 +132,7 @@ class TDTestCase: 'batchNum': 100, 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 'endTs': 0, - 'pollDelay': 10, + 'pollDelay': 20, 'showMsg': 1, 'showRow': 1, 'snapshot': 0} @@ -143,6 +144,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdLog.info("start create database....") tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("start create normal tables....") tmqCom.create_ntable(tsql=tdSql, dbname=paraDict["dbName"], tbname_prefix=paraDict["ctbPrefix"], tbname_index_start_num = 1, column_elm_list=paraDict["colSchema"], colPrefix='c', tblNum=paraDict["ctbNum"]) tdLog.info("start insert data into normal tables....") @@ -193,7 +195,7 @@ class TDTestCase: tdLog.info("act consume rows: %d, expect consume rows: %d"%(totalConsumeRows, expectrowcnt)) - if not ((totalConsumeRows >= expectrowcnt / 2 * (1 + 3/4)) and (totalConsumeRows < expectrowcnt)): + if not ((totalConsumeRows >= expectrowcnt / 2 * (1 + 3/4)) and (totalConsumeRows <= expectrowcnt)): tdLog.exit("tmq consume rows error with snapshot = 0!") tdLog.info("wait subscriptions exit ....") diff --git a/tests/system-test/7-tmq/tmqDropNtb-snapshot1.py b/tests/system-test/7-tmq/tmqDropNtb-snapshot1.py index 3fc5a2fdc70b64ec95324c370625f5397287ae7d..0b9cb7e66a2d481f6162f1e5e92d8c1f68dcb300 100644 --- a/tests/system-test/7-tmq/tmqDropNtb-snapshot1.py +++ b/tests/system-test/7-tmq/tmqDropNtb-snapshot1.py @@ -57,6 +57,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdLog.info("start create database....") tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("start create normal tables....") tmqCom.create_ntable(tsql=tdSql, dbname=paraDict["dbName"], tbname_prefix=paraDict["ctbPrefix"], tbname_index_start_num = 1, column_elm_list=paraDict["colSchema"], colPrefix='c', tblNum=paraDict["ctbNum"]) tdLog.info("start insert data into normal tables....") @@ -143,6 +144,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdLog.info("start create database....") tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("start create normal tables....") tmqCom.create_ntable(tsql=tdSql, dbname=paraDict["dbName"], tbname_prefix=paraDict["ctbPrefix"], tbname_index_start_num = 1, column_elm_list=paraDict["colSchema"], colPrefix='c', tblNum=paraDict["ctbNum"]) tdLog.info("start insert data into normal tables....") diff --git a/tests/system-test/7-tmq/tmqDropStb.py b/tests/system-test/7-tmq/tmqDropStb.py index 3789632984c91e49358ea21124824138642162ea..a94747e574cf1dd5b10f875dcf6c6590a3532aca 100644 --- a/tests/system-test/7-tmq/tmqDropStb.py +++ b/tests/system-test/7-tmq/tmqDropStb.py @@ -64,6 +64,7 @@ class TDTestCase: tmqCom.initConsumerTable(self.cdbName) tdCom.create_database(tdSql,self.paraDict["dbName"],self.paraDict["dropFlag"]) + tdSql.execute("alter database %s wal_retention_period 3600" % (self.paraDict['dbName'])) self.paraDict["stbName"] = 'stb1' tdCom.create_stable(tdSql,dbname=self.paraDict["dbName"],stbname=self.paraDict["stbName"],column_elm_list=self.paraDict["colSchema"],tag_elm_list=self.paraDict["tagSchema"],count=1, default_stbname_prefix=self.paraDict["stbName"]) diff --git a/tests/system-test/7-tmq/tmqDropStbCtb.py b/tests/system-test/7-tmq/tmqDropStbCtb.py index c9e34136cc1e59af173205a8e0cb2796acb1a14a..587baf12aab02a3ae3e7d4d9783cafab6ac0ceca 100644 --- a/tests/system-test/7-tmq/tmqDropStbCtb.py +++ b/tests/system-test/7-tmq/tmqDropStbCtb.py @@ -54,6 +54,7 @@ class TDTestCase: # tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqError.py b/tests/system-test/7-tmq/tmqError.py index a39bac8dd194360196ccad80c1352b6028474a0b..b2038f1644e70cd2a6f4f7c2eb979ac58ff9a27e 100644 --- a/tests/system-test/7-tmq/tmqError.py +++ b/tests/system-test/7-tmq/tmqError.py @@ -116,7 +116,7 @@ class TDTestCase: 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)) + tsql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600"%(dbName, vgroups, replica)) tdLog.debug("complete to create database %s"%(dbName)) return diff --git a/tests/system-test/7-tmq/tmqModule.py b/tests/system-test/7-tmq/tmqModule.py index d6b4aff9380bb8f5337ce4b52088e105449a1d07..187152c9ce9a1fd6afba1a718cd82e7e81ae0e4f 100644 --- a/tests/system-test/7-tmq/tmqModule.py +++ b/tests/system-test/7-tmq/tmqModule.py @@ -110,7 +110,7 @@ class TDTestCase: 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)) + tsql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600"%(dbName, vgroups, replica)) tdLog.debug("complete to create database %s"%(dbName)) return diff --git a/tests/system-test/7-tmq/tmqMultiConsumer.py b/tests/system-test/7-tmq/tmqMultiConsumer.py new file mode 100644 index 0000000000000000000000000000000000000000..cc217e0c4c2c3b185a6e7cba656dbcf1e4740ac2 --- /dev/null +++ b/tests/system-test/7-tmq/tmqMultiConsumer.py @@ -0,0 +1,174 @@ + +import taos +import sys +import time +import socket +import os +import threading +import math +# from tests.pytest.util.common import TDCom +# from tests.pytest.util.log import TDLog + +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): + self.vgroups = 32 + self.ctbNum = 100 + self.rowsPerTbl = 1000 + self.snapshot = 1 + self.replicaVar = 3 + + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), False) + + def prepareTestEnv(self): + tdLog.printNoPrefix("======== prepare test env include database, stable, ctables, and insert data: ") + paraDict = {'dbName': 'dbt', + 'dropFlag': 1, + 'event': '', + 'vgroups': 4, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1},{'type': 'TIMESTAMP', 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbStartIdx': 0, + 'ctbNum': 10, + 'rowsPerTbl': 10000, + 'batchNum': 1000, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 10, + 'showMsg': 1, + 'showRow': 1, + 'snapshot': 0} + + paraDict['vgroups'] = self.vgroups + paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + + tmqCom.initConsumerTable() + tmqCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=self.replicaVar) + tdLog.info("create stb") + tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) + tdLog.info("create ctb") + tmqCom.create_ctable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"],ctbPrefix=paraDict['ctbPrefix'], + ctbNum=paraDict["ctbNum"],ctbStartIdx=paraDict['ctbStartIdx']) + tdLog.info("insert data") + tmqCom.insert_data_interlaceByMultiTbl(tsql=tdSql,dbName=paraDict["dbName"],ctbPrefix=paraDict["ctbPrefix"], + ctbNum=paraDict["ctbNum"],rowsPerTbl=paraDict["rowsPerTbl"],batchNum=paraDict["batchNum"], + startTs=paraDict["startTs"],ctbStartIdx=paraDict['ctbStartIdx']) + + # tdLog.info("restart taosd to ensure that the data falls into the disk") + # tdDnodes.stop(1) + # tdDnodes.start(1) + # tdSql.query("flush database %s"%(paraDict['dbName'])) + return + + def tmqCase1(self): + tdLog.printNoPrefix("======== test case 1: ") + paraDict = {'dbName': 'dbt', + 'dropFlag': 1, + 'event': '', + 'vgroups': 1, + 'stbName': 'stb', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1},{'type': 'TIMESTAMP', 'count':1}], + 'tagSchema': [{'type': 'INT', 'count':1},{'type': 'BIGINT', 'count':1},{'type': 'DOUBLE', 'count':1},{'type': 'BINARY', 'len':32, 'count':1},{'type': 'NCHAR', 'len':32, 'count':1}], + 'ctbPrefix': 'ctb', + 'ctbStartIdx': 0, + 'ctbNum': 1, + 'rowsPerTbl': 10000, + 'batchNum': 1000, + 'startTs': 1640966400000, # 2022-01-01 00:00:00.000 + 'pollDelay': 20, + 'showMsg': 1, + 'showRow': 1, + 'snapshot': 1} + + paraDict['vgroups'] = self.vgroups + paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + paraDict['snapshot'] = self.snapshot + + topicNameList = ['topic1', 'topic2'] + tmqCom.initConsumerTable() + + tdLog.info("create topics from stb with filter") + # queryString = "select ts, acos(c1), ceil(pow(c1,3)) from %s.%s where (sin(c2) >= 0) and (c1 %% 4 == 0) and (ts >= %d) and (t4 like 'shanghai')"%(paraDict['dbName'], paraDict['stbName'], paraDict["startTs"]+9379) + queryString = "select ts, acos(c1), ceil(pow(c1,3)) from %s.%s "%(paraDict['dbName'], paraDict['stbName']) + # sqlString = "create topic %s as stable %s" %(topicNameList[0], paraDict['stbName']) + sqlString = "create topic %s as %s" %(topicNameList[0], queryString) + tdLog.info("create topic sql: %s"%sqlString) + tdSql.execute(sqlString) + + 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()) + + # 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"] * 4 + topicList = topicNameList[0] + ',' + topicNameList[0] + ',' + topicNameList[1] + ifcheckdata = 0 + ifManualCommit = 1 + keyList = 'group.id:cgrp1, enable.auto.commit:true, auto.commit.interval.ms:1000, auto.offset.reset:earliest' + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + consumerId = 1 + tmqCom.insertConsumerInfo(consumerId, expectrowcnt,topicList,keyList,ifcheckdata,ifManualCommit) + + tdLog.info("start consume processor") + tmqCom.startTmqSimProcess(pollDelay=paraDict['pollDelay'],dbName=paraDict["dbName"],showMsg=paraDict['showMsg'], showRow=paraDict['showRow'],snapshot=paraDict['snapshot']) + tdLog.info("wait the consume result") + + # continue to insert new rows + paraDict['startTs'] = paraDict['startTs'] + int(self.rowsPerTbl) + pInsertThread = tmqCom.asyncInsertDataByInterlace(paraDict) + pInsertThread.join() + + expectRows = 2 + resultList = tmqCom.selectConsumeResult(expectRows) + actConsumeTotalRows = resultList[0] + resultList[1] + + tdLog.info("act consume rows: %d, expect consume rows: %d"%(actConsumeTotalRows, expectrowcnt)) + + if not ((expectrowcnt <= actConsumeTotalRows) or ((resultList[0] == 0) and (resultList[1] >= expectrowcnt)) or ((resultList[1] == 0) and (resultList[0] >= expectrowcnt))): + tdLog.info("expect consume rows: %d, act consume rows: %d"%(expectrowcnt, actConsumeTotalRows)) + tdLog.exit("%d tmq consume rows error!"%consumerId) + + # tmqCom.checkFileContent(consumerId, queryString) + + time.sleep(10) + for i in range(len(topicNameList)): + tdSql.query("drop topic %s"%topicNameList[i]) + + tdLog.printNoPrefix("======== test case 1 end ...... ") + + + def run(self): + tdSql.prepare() + self.prepareTestEnv() + self.tmqCase1() + + 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/tmqShow.py b/tests/system-test/7-tmq/tmqShow.py index 31ddc1b0f831df5d6e10f4337536488ddeaa892e..e9234f6c7aea99cf339be76ed799b34d3ec44721 100644 --- a/tests/system-test/7-tmq/tmqShow.py +++ b/tests/system-test/7-tmq/tmqShow.py @@ -51,6 +51,7 @@ class TDTestCase: consumerIdList = [0, 1, 2, 3] tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict['vgroups'],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) 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") diff --git a/tests/system-test/7-tmq/tmqSubscribeStb-r3.py b/tests/system-test/7-tmq/tmqSubscribeStb-r3.py index 85222a941bf466631feedd1ead0387ef5f984096..7f322dc2583201bce47f40a9c1883daabadf8e42 100644 --- a/tests/system-test/7-tmq/tmqSubscribeStb-r3.py +++ b/tests/system-test/7-tmq/tmqSubscribeStb-r3.py @@ -94,6 +94,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=self.replica) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot0.py b/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot0.py index 297429b495b4bbc42e6d53a58295ef306b5d6903..a923232706c62fa1343b65e936cbc7aac1b6df5f 100644 --- a/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot0.py +++ b/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot0.py @@ -50,7 +50,7 @@ class TDTestCase: def create_udf_function(self): # create scalar functions - tdSql.execute("create function udf1 as '%s' outputtype int bufSize 8;"%self.libudf1) + tdSql.execute("create function udf1 as '%s' outputtype int;"%self.libudf1) functions = tdSql.getResult("show functions") function_nums = len(functions) @@ -116,6 +116,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") @@ -163,6 +164,7 @@ class TDTestCase: expectRowsList = [] tmqCom.initConsumerTable() # tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + # tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) # 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") @@ -265,6 +267,7 @@ class TDTestCase: expectRowsList = [] tmqCom.initConsumerTable() # tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + # tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) # 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") diff --git a/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot1.py b/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot1.py index 9c139b50de71902d743236c503d6cca12cb8296a..bee174376daca3c0244464c85f80124929e00ce8 100644 --- a/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot1.py +++ b/tests/system-test/7-tmq/tmqUdf-multCtb-snapshot1.py @@ -50,7 +50,7 @@ class TDTestCase: def create_udf_function(self): # create scalar functions - tdSql.execute("create function udf1 as '%s' outputtype int bufSize 8;"%self.libudf1) + tdSql.execute("create function udf1 as '%s' outputtype int;"%self.libudf1) functions = tdSql.getResult("show functions") function_nums = len(functions) @@ -116,6 +116,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") @@ -163,6 +164,7 @@ class TDTestCase: expectRowsList = [] tmqCom.initConsumerTable() # tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + # tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) # 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") @@ -265,6 +267,7 @@ class TDTestCase: expectRowsList = [] tmqCom.initConsumerTable() # tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + # tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) # 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") diff --git a/tests/system-test/7-tmq/tmqUdf.py b/tests/system-test/7-tmq/tmqUdf.py index 8593fd4f1e5969d9eb8083a66200301a6524d8c1..5bb8e3034ceec89c1161b6a5c9bfd9eb5cfddc82 100644 --- a/tests/system-test/7-tmq/tmqUdf.py +++ b/tests/system-test/7-tmq/tmqUdf.py @@ -50,7 +50,7 @@ class TDTestCase: def create_udf_function(self): # create scalar functions - tdSql.execute("create function udf1 as '%s' outputtype int bufSize 8;"%self.libudf1) + tdSql.execute("create function udf1 as '%s' outputtype int;"%self.libudf1) functions = tdSql.getResult("show functions") function_nums = len(functions) @@ -116,6 +116,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") @@ -163,6 +164,7 @@ class TDTestCase: expectRowsList = [] tmqCom.initConsumerTable() # tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + # tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) # 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") @@ -266,6 +268,7 @@ class TDTestCase: expectRowsList = [] tmqCom.initConsumerTable() # tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + # tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) # 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") diff --git a/tests/system-test/7-tmq/tmqUpdate-1ctb.py b/tests/system-test/7-tmq/tmqUpdate-1ctb.py index 2fa6600fb99efa22035091da6d75ac00d6b55afa..8fdf7748a3425b1efe7966949a1098e5867b6ee2 100644 --- a/tests/system-test/7-tmq/tmqUpdate-1ctb.py +++ b/tests/system-test/7-tmq/tmqUpdate-1ctb.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") @@ -207,7 +208,7 @@ class TDTestCase: paraDict['rowsPerTbl'] = self.rowsPerTbl consumerId = 1 if self.snapshot == 0: - expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1/2)) + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1+ 1/2 + 1/2)) elif self.snapshot == 1: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1)) diff --git a/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot0.py b/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot0.py index e2ba47c3fd1a6280bd3dfdc47030f261ce6c2bc5..8b67f6f8252e5e3682284c5c2d5b4295308db26c 100644 --- a/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot0.py +++ b/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot0.py @@ -55,6 +55,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") @@ -213,7 +214,7 @@ class TDTestCase: paraDict['rowsPerTbl'] = self.rowsPerTbl consumerId = 1 if self.snapshot == 0: - expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1/2) * (1/2*3)) + expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] *(2 + 1/2*1/2*2 + 1/2 + 1/4)) elif self.snapshot == 1: expectrowcnt = int(paraDict["rowsPerTbl"] * paraDict["ctbNum"] * (1 + 1/2)) diff --git a/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot1.py b/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot1.py index 6b8c10de271b28726639baad8648e2586c02f9a1..5a35c4f5ee84c950ee7a611e5be93fe13371b031 100644 --- a/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot1.py +++ b/tests/system-test/7-tmq/tmqUpdate-multiCtb-snapshot1.py @@ -55,6 +55,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqUpdate-multiCtb.py b/tests/system-test/7-tmq/tmqUpdate-multiCtb.py index 3975013e747f09d8cc0548b5e32f9f01c63fb9a4..84617efae4d78cf57cf6d522a7b3fbf50321e5f2 100644 --- a/tests/system-test/7-tmq/tmqUpdate-multiCtb.py +++ b/tests/system-test/7-tmq/tmqUpdate-multiCtb.py @@ -55,6 +55,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/7-tmq/tmqUpdateWithConsume.py b/tests/system-test/7-tmq/tmqUpdateWithConsume.py index 4f595788daee975f26cd2e30c1a0fe973e35aa68..6a9bb0ae924d0c0a6366ae6ccb0a6f8a1cec6e0d 100644 --- a/tests/system-test/7-tmq/tmqUpdateWithConsume.py +++ b/tests/system-test/7-tmq/tmqUpdateWithConsume.py @@ -54,6 +54,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=self.replicaVar, wal_retention_size=-1, wal_retention_period=-1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") diff --git a/tests/system-test/99-TDcase/TD-15517.py b/tests/system-test/99-TDcase/TD-15517.py index db06700284d6de78139aef2f2678e2eb75d379fd..aeb28063e47253b085fe664e3109dcb4855539c9 100644 --- a/tests/system-test/99-TDcase/TD-15517.py +++ b/tests/system-test/99-TDcase/TD-15517.py @@ -51,7 +51,7 @@ class TDTestCase: return cur def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum,rowsPerTbl): - tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) + tsql.execute("create database if not exists %s vgroups %d wal_retention_period 3600"%(dbName, vgroups)) tsql.execute("use %s" %dbName) tsql.execute("create table %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName) pre_create = "create table" diff --git a/tests/system-test/99-TDcase/TD-15554.py b/tests/system-test/99-TDcase/TD-15554.py index 51934ccd4408cc002060049f8c32fb6706a41fd3..c8ddeca3c3426c22efe3c4ddbbc6ad5b5992a108 100644 --- a/tests/system-test/99-TDcase/TD-15554.py +++ b/tests/system-test/99-TDcase/TD-15554.py @@ -50,7 +50,7 @@ class TDTestCase: return cur def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum,rowsPerTbl): - tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) + tsql.execute("create database if not exists %s vgroups %d wal_retention_period 3600"%(dbName, vgroups)) tsql.execute("use %s" %dbName) tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName) pre_create = "create table" diff --git a/tests/system-test/99-TDcase/TD-15557.py b/tests/system-test/99-TDcase/TD-15557.py index 884c028a6567d62ce5141eb5ad16240830168f51..f9e676f4f89d9e356d9ede59793f2b8cc431039b 100644 --- a/tests/system-test/99-TDcase/TD-15557.py +++ b/tests/system-test/99-TDcase/TD-15557.py @@ -64,7 +64,7 @@ class TDTestCase: os.system(shellCmd) def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum,rowsPerTbl): - tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) + tsql.execute("create database if not exists %s vgroups %d wal_retention_period 3600"%(dbName, vgroups)) tsql.execute("use %s" %dbName) tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName) pre_create = "create table" @@ -141,7 +141,7 @@ class TDTestCase: 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() @@ -214,7 +214,7 @@ class TDTestCase: 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() @@ -298,7 +298,7 @@ class TDTestCase: 'startTs': 1640966400000} # 2022-01-01 00:00:00.000 parameterDict['cfg'] = cfgPath - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() diff --git a/tests/system-test/99-TDcase/TD-15563.py b/tests/system-test/99-TDcase/TD-15563.py index 5ea652b4fb6fe5b441ea4a946026115431ec24b2..cc4c3f3b39a6ff6259b62a18d39d91265d87ba13 100644 --- a/tests/system-test/99-TDcase/TD-15563.py +++ b/tests/system-test/99-TDcase/TD-15563.py @@ -52,7 +52,7 @@ class TDTestCase: def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") - tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) + tdSql.query("create database if not exists %s vgroups 1 wal_retention_period 3600"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) @@ -95,7 +95,7 @@ class TDTestCase: os.system(shellCmd) def create_tables(self,tsql, dbName,vgroups,stbName,ctbNum,rowsPerTbl): - tsql.execute("create database if not exists %s vgroups %d"%(dbName, vgroups)) + tsql.execute("create database if not exists %s vgroups %d wal_retention_period 3600"%(dbName, vgroups)) tsql.execute("use %s" %dbName) tsql.execute("create table if not exists %s (ts timestamp, c1 bigint, c2 binary(16)) tags(t1 int)"%stbName) pre_create = "create table" @@ -176,7 +176,7 @@ class TDTestCase: self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() @@ -238,7 +238,7 @@ class TDTestCase: self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() @@ -304,7 +304,7 @@ class TDTestCase: self.initConsumerTable() - tdSql.execute("create database if not exists %s vgroups %d" %(parameterDict['dbName'], parameterDict['vgroups'])) + tdSql.execute("create database if not exists %s vgroups %d wal_retention_period 3600" %(parameterDict['dbName'], parameterDict['vgroups'])) prepareEnvThread = threading.Thread(target=self.prepareEnv, kwargs=parameterDict) prepareEnvThread.start() diff --git a/tests/system-test/99-TDcase/TD-16025.py b/tests/system-test/99-TDcase/TD-16025.py index 8c9fa9319f8071db436e4f71a597dc7d5de8758e..3e25b8c8334013b5dbb56b77ead3473994cd8e9e 100644 --- a/tests/system-test/99-TDcase/TD-16025.py +++ b/tests/system-test/99-TDcase/TD-16025.py @@ -59,7 +59,7 @@ class TDTestCase: def initConsumerTable(self,cdbName='cdb'): tdLog.info("create consume database, and consume info table, and consume result table") - tdSql.query("create database if not exists %s vgroups 1"%(cdbName)) + tdSql.query("create database if not exists %s vgroups 1 wal_retention_period 3600"%(cdbName)) tdSql.query("drop table if exists %s.consumeinfo "%(cdbName)) tdSql.query("drop table if exists %s.consumeresult "%(cdbName)) @@ -110,7 +110,7 @@ class TDTestCase: 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)) + tsql.execute("create database if not exists %s vgroups %d replica %d wal_retention_period 3600"%(dbName, vgroups, replica)) tdLog.debug("complete to create database %s"%(dbName)) return diff --git a/tests/system-test/99-TDcase/TD-16821.py b/tests/system-test/99-TDcase/TD-16821.py index f57fae752f8d2d07f730f791ce0b5a63eb7dc832..78ac172f3075733aff7b3608fb29400b32adc01d 100644 --- a/tests/system-test/99-TDcase/TD-16821.py +++ b/tests/system-test/99-TDcase/TD-16821.py @@ -73,6 +73,7 @@ class TDTestCase: expectRowsList = [] tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=4,replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) 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") diff --git a/tests/system-test/99-TDcase/TD-17255.py b/tests/system-test/99-TDcase/TD-17255.py index 0f83468754783ee5adca78113c7a8df5c78bbe99..5f68a5b7389d3ea095a8886e2801dd82fb6af8d9 100644 --- a/tests/system-test/99-TDcase/TD-17255.py +++ b/tests/system-test/99-TDcase/TD-17255.py @@ -53,6 +53,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") @@ -97,6 +98,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") @@ -181,6 +183,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("create ctb") @@ -267,6 +270,7 @@ class TDTestCase: tmqCom.initConsumerTable() tdCom.create_database(tdSql, paraDict["dbName"],paraDict["dropFlag"], vgroups=paraDict["vgroups"],replica=1) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) tdLog.info("create stb") tmqCom.create_stable(tdSql, dbName=paraDict["dbName"],stbName=paraDict["stbName"]) tdLog.info("insert data by auto create ctb") diff --git a/tests/system-test/99-TDcase/TD-17699.py b/tests/system-test/99-TDcase/TD-17699.py index 2862f4a78d5391098f0493afa35e482c5a032817..6956e88aec7d0c8adb84c8af9aff31cb6d80fa1f 100644 --- a/tests/system-test/99-TDcase/TD-17699.py +++ b/tests/system-test/99-TDcase/TD-17699.py @@ -65,6 +65,7 @@ class TDTestCase: tmqCom.initConsumerTable(self.cdbName) tdCom.create_database(tdSql,self.paraDict["dbName"],self.paraDict["dropFlag"]) + tdSql.execute("alter database %s wal_retention_period 3600" % (paraDict['dbName'])) self.paraDict["stbName"] = 'stb1' tdCom.create_stable(tdSql,dbname=self.paraDict["dbName"],stbname=self.paraDict["stbName"],column_elm_list=self.paraDict["colSchema"],tag_elm_list=self.paraDict["tagSchema"],count=1, default_stbname_prefix=self.paraDict["stbName"]) diff --git a/tools/shell/CMakeLists.txt b/tools/shell/CMakeLists.txt index 600e33feab10fcd0b3c0ccee2de3cd61544e16d8..7b1dc3a541416335dca761aba8634679473ecdd2 100644 --- a/tools/shell/CMakeLists.txt +++ b/tools/shell/CMakeLists.txt @@ -26,10 +26,6 @@ ELSE () SET(LINK_WEBSOCKET "") ENDIF () -IF (CUS_NAME OR CUS_PROMPT OR CUS_EMAIL) - ADD_DEFINITIONS(-I${CMAKE_CURRENT_SOURCE_DIR}/../../../enterprise/packaging) -ENDIF (CUS_NAME OR CUS_PROMPT OR CUS_EMAIL) - IF (TD_LINUX AND TD_ALPINE) SET(LINK_ARGP "/usr/lib/libargp.a") ELSE () diff --git a/tools/shell/inc/shellInt.h b/tools/shell/inc/shellInt.h index 08d4b167ea45ceee5e1f45c220d98ac8d6fed8bd..6345647e2f24b1a87cee8a6a0c60275907946dfe 100644 --- a/tools/shell/inc/shellInt.h +++ b/tools/shell/inc/shellInt.h @@ -28,6 +28,10 @@ #ifdef WEBSOCKET #include "taosws.h" + +#define SHELL_WS_TIMEOUT 30 +#define SHELL_WS_DSN_BUFF 256 +#define SHELL_WS_DSN_MASK 10 #endif #define SHELL_MAX_HISTORY_SIZE 1000 @@ -99,7 +103,7 @@ typedef struct { bool exit; #ifdef WEBSOCKET WS_TAOS* ws_conn; - bool stop_query; + bool stop_query; #endif } SShellObj; @@ -139,7 +143,7 @@ void shellExit(); void shellTestNetWork(); #ifdef WEBSOCKET -void shellCheckConnectMode(); +void shellCheckConnectMode(); // shellWebsocket.c int shell_conn_ws_server(bool first); int32_t shell_run_websocket(); diff --git a/tools/shell/src/shellArguments.c b/tools/shell/src/shellArguments.c index 25c3c76b543a6631f49b8d34594496b24b2ca4d3..0f5585991e5efcf4d3c69b74a5b0b3e254a99e60 100644 --- a/tools/shell/src/shellArguments.c +++ b/tools/shell/src/shellArguments.c @@ -18,17 +18,18 @@ #endif #include "shellInt.h" +#include "version.h" #ifndef CUS_NAME - char cusName[] = "TDengine"; +char cusName[] = "TDengine"; #endif #ifndef CUS_PROMPT - char cusPrompt[] = "taos"; +char cusPrompt[] = "taos"; #endif #ifndef CUS_EMAIL - char cusEmail[] = ""; +char cusEmail[] = ""; #endif #if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL) @@ -58,9 +59,9 @@ #define SHELL_VERSION "Print program version." #ifdef WEBSOCKET -#define SHELL_DSN "Use dsn to connect to the TDengine cloud server or to a remote server which provides WebSocket connection." -#define SHELL_REST "Use RESTful mode when connecting." -#define SHELL_TIMEOUT "Set the timeout for websocket query in seconds, default is 10." +#define SHELL_DSN "Use dsn to connect to the cloud server or to a remote server which provides WebSocket connection." +#define SHELL_REST "Use RESTful mode when connecting." +#define SHELL_TIMEOUT "Set the timeout for websocket query in seconds, default is 30." #endif static int32_t shellParseSingleOpt(int32_t key, char *arg); @@ -92,7 +93,11 @@ void shellPrintHelp() { #endif printf("%s%s%s%s\r\n", indent, "-w,", indent, SHELL_WIDTH); printf("%s%s%s%s\r\n", indent, "-V,", indent, SHELL_VERSION); - printf("\r\n\r\nReport bugs to %s.\r\n", cusEmail); +#ifdef CUS_EMAIL + printf("\r\n\r\nReport bugs to %s.\r\n", CUS_EMAIL); +#else + printf("\r\n\r\nReport bugs to %s.\r\n", "support@taosdata.com"); +#endif } #ifdef LINUX @@ -104,7 +109,11 @@ void shellPrintHelp() { #endif const char *argp_program_version = version; -const char *argp_program_bug_address = cusEmail; +#ifdef CUS_EMAIL +const char *argp_program_bug_address = CUS_EMAIL; +#else +const char *argp_program_bug_address = "support@taosdata.com"; +#endif static struct argp_option shellOptions[] = { {"host", 'h', "HOST", 0, SHELL_HOST}, @@ -126,8 +135,8 @@ static struct argp_option shellOptions[] = { {"pktlen", 'l', "PKTLEN", 0, SHELL_PKT_LEN}, #ifdef WEBSOCKET {"dsn", 'E', "DSN", 0, SHELL_DSN}, - {"http", 'R', 0, 0, SHELL_REST}, - {"timeout", 'T', "SECONDS", 0, SHELL_TIMEOUT}, + {"restful", 'R', 0, 0, SHELL_REST}, + {"timeout", 'T', "SECONDS", 0, SHELL_TIMEOUT}, #endif {"pktnum", 'N', "PKTNUM", 0, SHELL_PKT_NUM}, {0}, @@ -145,7 +154,7 @@ static void shellParseArgsUseArgp(int argc, char *argv[]) { #endif #ifndef ARGP_ERR_UNKNOWN - #define ARGP_ERR_UNKNOWN E2BIG +#define ARGP_ERR_UNKNOWN E2BIG #endif static int32_t shellParseSingleOpt(int32_t key, char *arg) { @@ -223,9 +232,9 @@ static int32_t shellParseSingleOpt(int32_t key, char *arg) { pArgs->dsn = arg; pArgs->cloud = true; break; - case 'T': - pArgs->timeout = atoi(arg); - break; + case 'T': + pArgs->timeout = atoi(arg); + break; #endif case 'V': pArgs->is_version = true; @@ -246,7 +255,8 @@ int32_t shellParseArgsWithoutArgp(int argc, char *argv[]) { SShellArgs *pArgs = &shell.args; for (int i = 1; i < argc; i++) { - if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "--usage") == 0 || strcmp(argv[i], "-?") == 0 || strcmp(argv[i], "/?") == 0) { + if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "--usage") == 0 || strcmp(argv[i], "-?") == 0 || + strcmp(argv[i], "/?") == 0) { shellParseSingleOpt('?', NULL); return 0; } @@ -263,11 +273,11 @@ int32_t shellParseArgsWithoutArgp(int argc, char *argv[]) { } if (key[1] == 'h' || key[1] == 'P' || key[1] == 'u' || key[1] == 'a' || key[1] == 'c' || key[1] == 's' || - key[1] == 'f' || key[1] == 'd' || key[1] == 'w' || key[1] == 'n' || key[1] == 'l' || key[1] == 'N' + key[1] == 'f' || key[1] == 'd' || key[1] == 'w' || key[1] == 'n' || key[1] == 'l' || key[1] == 'N' #ifdef WEBSOCKET - || key[1] == 'E' || key[1] == 'T' + || key[1] == 'E' || key[1] == 'T' #endif - ) { + ) { if (i + 1 >= argc) { fprintf(stderr, "option %s requires an argument\r\n", key); return -1; @@ -279,12 +289,12 @@ int32_t shellParseArgsWithoutArgp(int argc, char *argv[]) { } shellParseSingleOpt(key[1], val); i++; - } else if (key[1] == 'p' || key[1] == 'A' || key[1] == 'C' || key[1] == 'r' || key[1] == 'k' || - key[1] == 't' || key[1] == 'V' || key[1] == '?' || key[1] == 1 + } else if (key[1] == 'p' || key[1] == 'A' || key[1] == 'C' || key[1] == 'r' || key[1] == 'k' || key[1] == 't' || + key[1] == 'V' || key[1] == '?' || key[1] == 1 #ifdef WEBSOCKET - ||key[1] == 'R' + || key[1] == 'R' #endif - ) { + ) { shellParseSingleOpt(key[1], NULL); } else { fprintf(stderr, "invalid option %s\r\n", key); @@ -406,18 +416,33 @@ static int32_t shellCheckArgs() { int32_t shellParseArgs(int32_t argc, char *argv[]) { shellInitArgs(argc, argv); - shell.info.clientVersion = + shell.info.clientVersion = "Welcome to the %s Command Line Interface, Client Version:%s\r\n" "Copyright (c) 2022 by %s, all rights reserved.\r\n\r\n"; - strcpy(shell.info.cusName, cusName); - sprintf(shell.info.promptHeader, "%s> ", cusPrompt); +#ifdef CUS_NAME + strcpy(shell.info.cusName, CUS_NAME); +#else + strcpy(shell.info.cusName, "TDengine"); +#endif char promptContinueFormat[32] = {0}; - sprintf(promptContinueFormat, "%%%zus> ", strlen(cusPrompt)); +#ifdef CUS_PROMPT + sprintf(shell.info.promptHeader, "%s> ", CUS_PROMPT); + sprintf(promptContinueFormat, "%%%zus> ", strlen(CUS_PROMPT)); +#else + sprintf(shell.info.promptHeader, "taos> "); + sprintf(promptContinueFormat, "%%%zus> ", strlen("taos")); +#endif sprintf(shell.info.promptContinue, promptContinueFormat, " "); shell.info.promptSize = strlen(shell.info.promptHeader); +#ifdef TD_ENTERPRISE + snprintf(shell.info.programVersion, sizeof(shell.info.programVersion), + "version: %s compatible_version: %s\ngitinfo: %s\ngitinfoOfInternal: %s\nbuildInfo: %s", version, + compatible_version, gitinfo, gitinfoOfInternal, buildinfo); +#else snprintf(shell.info.programVersion, sizeof(shell.info.programVersion), "version: %s compatible_version: %s\ngitinfo: %s\nbuildInfo: %s", version, compatible_version, gitinfo, buildinfo); +#endif #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) shell.info.osname = "Windows"; diff --git a/tools/shell/src/shellAuto.c b/tools/shell/src/shellAuto.c index a8986351b7325802ba6a121db56a1cbc5dfe1295..140720af815cf317bf7665c40750b2d0fb2ebd37 100644 --- a/tools/shell/src/shellAuto.c +++ b/tools/shell/src/shellAuto.c @@ -84,15 +84,15 @@ SWords shellCommands[] = { {"create table using tags(", 0, 0, NULL}, {"create database " " " - " ;", - 0, 0, NULL}, + " ;", 0, 0, NULL}, {"create dnode ", 0, 0, NULL}, {"create index on ()", 0, 0, NULL}, {"create mnode on dnode ;", 0, 0, NULL}, {"create qnode on dnode ;", 0, 0, NULL}, {"create stream into as select", 0, 0, NULL}, // 26 append sub sql {"create topic as select", 0, 0, NULL}, // 27 append sub sql - {"create function ", 0, 0, NULL}, + {"create function as outputtype language ", 0, 0, NULL}, + {"create aggregate function as outputtype bufsize language ", 0, 0, NULL}, {"create user pass sysinfo 0;", 0, 0, NULL}, {"create user pass sysinfo 1;", 0, 0, NULL}, {"describe ", 0, 0, NULL}, @@ -105,7 +105,7 @@ SWords shellCommands[] = { {"drop qnode on dnode ;", 0, 0, NULL}, {"drop user ;", 0, 0, NULL}, // 40 - {"drop function", 0, 0, NULL}, + {"drop function ;", 0, 0, NULL}, {"drop consumer group on ", 0, 0, NULL}, {"drop topic ;", 0, 0, NULL}, {"drop stream ;", 0, 0, NULL}, @@ -272,6 +272,8 @@ char* key_systable[] = { "ins_subscriptions", "ins_streams", "ins_stream_tasks", "ins_vnodes", "ins_user_privileges", "perf_connections", "perf_queries", "perf_consumers", "perf_trans", "perf_apps"}; +char* udf_language[] = {"\'Python\'", "\'C\'"}; + // // ------- global variant define --------- // @@ -291,25 +293,29 @@ bool waitAutoFill = false; #define WT_VAR_USERNAME 4 #define WT_VAR_TOPIC 5 #define WT_VAR_STREAM 6 -#define WT_VAR_ALLTABLE 7 -#define WT_VAR_FUNC 8 -#define WT_VAR_KEYWORD 9 -#define WT_VAR_TBACTION 10 -#define WT_VAR_DBOPTION 11 -#define WT_VAR_ALTER_DBOPTION 12 -#define WT_VAR_DATATYPE 13 -#define WT_VAR_KEYTAGS 14 -#define WT_VAR_ANYWORD 15 -#define WT_VAR_TBOPTION 16 -#define WT_VAR_USERACTION 17 -#define WT_VAR_KEYSELECT 18 -#define WT_VAR_SYSTABLE 19 - -#define WT_VAR_CNT 20 - -#define WT_FROM_DB_MAX 6 // max get content from db +#define WT_VAR_UDFNAME 7 + +#define WT_FROM_DB_MAX 7 // max get content from db #define WT_FROM_DB_CNT (WT_FROM_DB_MAX + 1) +#define WT_VAR_ALLTABLE 8 +#define WT_VAR_FUNC 9 +#define WT_VAR_KEYWORD 10 +#define WT_VAR_TBACTION 11 +#define WT_VAR_DBOPTION 12 +#define WT_VAR_ALTER_DBOPTION 13 +#define WT_VAR_DATATYPE 14 +#define WT_VAR_KEYTAGS 15 +#define WT_VAR_ANYWORD 16 +#define WT_VAR_TBOPTION 17 +#define WT_VAR_USERACTION 18 +#define WT_VAR_KEYSELECT 19 +#define WT_VAR_SYSTABLE 20 +#define WT_VAR_LANGUAGE 21 + +#define WT_VAR_CNT 22 + + #define WT_TEXT 0xFF char dbName[256] = ""; // save use database name; @@ -319,13 +325,13 @@ TdThreadMutex tiresMutex; // save thread handle obtain var name from db server TdThread* threads[WT_FROM_DB_CNT]; // obtain var name with sql from server -char varTypes[WT_VAR_CNT][64] = {"", "", "", "", "", - "", "", "", "", "", - "", "", "", "", "", - "", "", "", ""}; +char varTypes[WT_VAR_CNT][64] = { + "", "", "", "", "", "", "", + "", "", "", "", "", "", "", + "", "", "", "", "", "", "", ""}; char varSqls[WT_FROM_DB_CNT][64] = {"show databases;", "show stables;", "show tables;", "show dnodes;", - "show users;", "show topics;", "show streams;"}; + "show users;", "show topics;", "show streams;", "show functions;"}; // var words current cursor, if user press any one key except tab, cursorVar can be reset to -1 int cursorVar = -1; @@ -390,7 +396,8 @@ void showHelp() { create qnode on dnode ;\n\ create stream into as select ...\n\ create topic as select ...\n\ - create function ...\n\ + create function as outputtype language \'C\' | \'Python\' ;\n\ + create aggregate function as outputtype bufsize language \'C\' | \'Python\';\n\ create user pass ...\n\ ----- D ----- \n\ describe \n\ @@ -401,7 +408,7 @@ void showHelp() { drop mnode on dnode ;\n\ drop qnode on dnode ;\n\ drop user ;\n\ - drop function ;\n\ + drop function ;\n\ drop consumer group ... \n\ drop topic ;\n\ drop stream ;\n\ @@ -643,6 +650,7 @@ bool shellAutoInit() { GenerateVarType(WT_VAR_USERACTION, user_actions, sizeof(user_actions) / sizeof(char*)); GenerateVarType(WT_VAR_KEYSELECT, key_select, sizeof(key_select) / sizeof(char*)); GenerateVarType(WT_VAR_SYSTABLE, key_systable, sizeof(key_systable) / sizeof(char*)); + GenerateVarType(WT_VAR_LANGUAGE, udf_language, sizeof(udf_language) / sizeof(char*)); return true; } diff --git a/tools/shell/src/shellEngine.c b/tools/shell/src/shellEngine.c index 05183a036c2ac6664d0e3a21900f8e47f3310b39..70130397ba7d4b9539080bff1ad81c193e751a54 100644 --- a/tools/shell/src/shellEngine.c +++ b/tools/shell/src/shellEngine.c @@ -102,10 +102,10 @@ int32_t shellRunSingleCommand(char *command) { } #ifdef WEBSOCKET if (shell.args.restful || shell.args.cloud) { - shellRunSingleCommandWebsocketImp(command); + shellRunSingleCommandWebsocketImp(command); } else { #endif - shellRunSingleCommandImp(command); + shellRunSingleCommandImp(command); #ifdef WEBSOCKET } #endif @@ -291,7 +291,9 @@ char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) { } struct tm ptm = {0}; - taosLocalTime(&tt, &ptm); + if (taosLocalTime(&tt, &ptm, buf) == NULL) { + return buf; + } size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", &ptm); if (precision == TSDB_TIME_PRECISION_NANO) { @@ -541,7 +543,7 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t printf("%*" PRIu64, width, *((uint64_t *)val)); break; case TSDB_DATA_TYPE_FLOAT: - printf("%*.5f", width, GET_FLOAT_VAL(val)); + printf("%*ef", width, GET_FLOAT_VAL(val)); break; case TSDB_DATA_TYPE_DOUBLE: n = snprintf(buf, TSDB_MAX_BYTES_PER_ROW, "%*.9f", width, GET_DOUBLE_VAL(val)); @@ -1025,15 +1027,15 @@ void *shellCancelHandler(void *arg) { } #ifdef WEBSOCKET - if (shell.args.restful || shell.args.cloud) { - shell.stop_query = true; - } else { + if (shell.args.restful || shell.args.cloud) { + shell.stop_query = true; + } else { #endif - if (shell.conn) { - taos_kill_query(shell.conn); - } + if (shell.conn) { + taos_kill_query(shell.conn); + } #ifdef WEBSOCKET - } + } #endif #ifdef WINDOWS printf("\n%s", shell.info.promptHeader); @@ -1083,21 +1085,21 @@ int32_t shellExecute() { SShellArgs *pArgs = &shell.args; #ifdef WEBSOCKET if (shell.args.restful || shell.args.cloud) { - if (shell_conn_ws_server(1)) { - return -1; - } + if (shell_conn_ws_server(1)) { + return -1; + } } else { #endif - if (shell.args.auth == NULL) { - shell.conn = taos_connect(pArgs->host, pArgs->user, pArgs->password, pArgs->database, pArgs->port); - } else { - shell.conn = taos_connect_auth(pArgs->host, pArgs->user, pArgs->auth, pArgs->database, pArgs->port); - } - - if (shell.conn == NULL) { - fflush(stdout); - return -1; - } + if (shell.args.auth == NULL) { + shell.conn = taos_connect(pArgs->host, pArgs->user, pArgs->password, pArgs->database, pArgs->port); + } else { + shell.conn = taos_connect_auth(pArgs->host, pArgs->user, pArgs->auth, pArgs->database, pArgs->port); + } + + if (shell.conn == NULL) { + fflush(stdout); + return -1; + } #ifdef WEBSOCKET } #endif @@ -1118,13 +1120,13 @@ int32_t shellExecute() { shellSourceFile(pArgs->file); } #ifdef WEBSOCKET - if (shell.args.restful || shell.args.cloud) { - ws_close(shell.ws_conn); - } else { + if (shell.args.restful || shell.args.cloud) { + ws_close(shell.ws_conn); + } else { #endif - taos_close(shell.conn); + taos_close(shell.conn); #ifdef WEBSOCKET - } + } #endif shellWriteHistory(); @@ -1148,9 +1150,9 @@ int32_t shellExecute() { if (!shell.args.restful && !shell.args.cloud) { #endif #ifndef WINDOWS - printfIntroduction(); + printfIntroduction(); #endif - shellGetGrantInfo(); + shellGetGrantInfo(); #ifdef WEBSOCKET } #endif diff --git a/tools/shell/src/shellMain.c b/tools/shell/src/shellMain.c index 22b8e89959593e9da18124908fedac31bd6b45ed..bc5809ffe8b389ca57146a65f8c67d451f934b9e 100644 --- a/tools/shell/src/shellMain.c +++ b/tools/shell/src/shellMain.c @@ -45,7 +45,7 @@ void shellCrashHandler(int signum, void *sigInfo, void *context) { int main(int argc, char *argv[]) { shell.exit = false; #ifdef WEBSOCKET - shell.args.timeout = 10; + shell.args.timeout = SHELL_WS_TIMEOUT; shell.args.cloud = true; #endif diff --git a/tools/shell/src/shellWebsocket.c b/tools/shell/src/shellWebsocket.c index 81c23035e21a225f98e8214bd5c3adcb25add72c..1d81ce4b2f8c47ef3f8e5344c42ae5afa3b96bcb 100644 --- a/tools/shell/src/shellWebsocket.c +++ b/tools/shell/src/shellWebsocket.c @@ -14,22 +14,51 @@ * along with this program. If not, see . */ #ifdef WEBSOCKET -#include "taosws.h" -#include "shellInt.h" +#include +#include int shell_conn_ws_server(bool first) { - shell.ws_conn = ws_connect_with_dsn(shell.args.dsn); - if (!shell.ws_conn) { - fprintf(stderr, "failed to connect %s, reason: %s\n", - shell.args.dsn, ws_errstr(NULL)); + char cuttedDsn[SHELL_WS_DSN_BUFF] = {0}; + int dsnLen = strlen(shell.args.dsn); + snprintf(cuttedDsn, + ((dsnLen-SHELL_WS_DSN_MASK) > SHELL_WS_DSN_BUFF)? + SHELL_WS_DSN_BUFF:(dsnLen-SHELL_WS_DSN_MASK), + "%s", shell.args.dsn); + fprintf(stdout, "trying to connect %s*** ", cuttedDsn); + fflush(stdout); + for (int i = 0; i < shell.args.timeout; i++) { + shell.ws_conn = ws_connect_with_dsn(shell.args.dsn); + if (NULL == shell.ws_conn) { + int errNo = ws_errno(NULL); + if (0xE001 == errNo) { + fprintf(stdout, "."); + fflush(stdout); + taosMsleep(1000); // sleep 1 second then try again + continue; + } else { + fprintf(stderr, "\nfailed to connect %s***, reason: %s\n", + cuttedDsn, ws_errstr(NULL)); + return -1; + } + } else { + break; + } + } + if (NULL == shell.ws_conn) { + fprintf(stdout, "\n timeout\n"); + fprintf(stderr, "\nfailed to connect %s***, reason: %s\n", + cuttedDsn, ws_errstr(NULL)); return -1; + } else { + fprintf(stdout, "\n"); } if (first && shell.args.restful) { - fprintf(stdout, "successfully connect to %s\n\n", + fprintf(stdout, "successfully connected to %s\n\n", shell.args.dsn); } else if (first && shell.args.cloud) { - fprintf(stdout, "successfully connect to cloud service\n"); + fprintf(stdout, "successfully connected to cloud service\n"); } + fflush(stdout); return 0; } @@ -118,7 +147,8 @@ static int verticalPrintWebsocket(WS_RES* wres, double* pexecute_time) { return numOfRows; } -static int dumpWebsocketToFile(const char* fname, WS_RES* wres, double* pexecute_time) { +static int dumpWebsocketToFile(const char* fname, WS_RES* wres, + double* pexecute_time) { char fullname[PATH_MAX] = {0}; if (taosExpandDir(fname, fullname, PATH_MAX) != 0) { tstrncpy(fullname, fname, PATH_MAX); @@ -150,7 +180,7 @@ static int dumpWebsocketToFile(const char* fname, WS_RES* wres, double* pexecute } taosFprintfFile(pFile, "%s", fields[col].name); } - taosFprintfFile(pFile, "\r\n"); + taosFprintfFile(pFile, "\r\n"); do { uint8_t ty; uint32_t len; @@ -161,7 +191,8 @@ static int dumpWebsocketToFile(const char* fname, WS_RES* wres, double* pexecute taosFprintfFile(pFile, ","); } const void *value = ws_get_value_in_block(wres, i, j, &ty, &len); - shellDumpFieldToFile(pFile, (const char*)value, fields + j, len, precision); + shellDumpFieldToFile(pFile, (const char*)value, + fields + j, len, precision); } taosFprintfFile(pFile, "\r\n"); } @@ -171,7 +202,9 @@ static int dumpWebsocketToFile(const char* fname, WS_RES* wres, double* pexecute return numOfRows; } -static int shellDumpWebsocket(WS_RES *wres, char *fname, int *error_no, bool vertical, double* pexecute_time) { +static int shellDumpWebsocket(WS_RES *wres, char *fname, + int *error_no, bool vertical, + double* pexecute_time) { int numOfRows = 0; if (fname != NULL) { numOfRows = dumpWebsocketToFile(fname, wres, pexecute_time); @@ -227,13 +260,16 @@ void shellRunSingleCommandWebsocketImp(char *command) { // if it's not a ws connection error if (TSDB_CODE_WS_DSN_ERROR != (code&TSDB_CODE_WS_DSN_ERROR)) { et = taosGetTimestampUs(); - fprintf(stderr, "\nDB: error: %s (%.6fs)\n", ws_errstr(res), (et - st)/1E6); + fprintf(stderr, "\nDB: error: %s (%.6fs)\n", + ws_errstr(res), (et - st)/1E6); ws_free_result(res); return; } - if (code == TSDB_CODE_WS_SEND_TIMEOUT || code == TSDB_CODE_WS_RECV_TIMEOUT) { + if (code == TSDB_CODE_WS_SEND_TIMEOUT + || code == TSDB_CODE_WS_RECV_TIMEOUT) { fprintf(stderr, "Hint: use -t to increase the timeout in seconds\n"); - } else if (code == TSDB_CODE_WS_INTERNAL_ERRO || code == TSDB_CODE_WS_CLOSED) { + } else if (code == TSDB_CODE_WS_INTERNAL_ERRO + || code == TSDB_CODE_WS_CLOSED) { shell.ws_conn = NULL; } ws_free_result(res); @@ -252,7 +288,8 @@ void shellRunSingleCommandWebsocketImp(char *command) { execute_time = ws_take_timing(res)/1E6; } - if (shellRegexMatch(command, "^\\s*use\\s+[a-zA-Z0-9_]+\\s*;\\s*$", REG_EXTENDED | REG_ICASE)) { + if (shellRegexMatch(command, "^\\s*use\\s+[a-zA-Z0-9_]+\\s*;\\s*$", + REG_EXTENDED | REG_ICASE)) { fprintf(stdout, "Database changed.\r\n\r\n"); fflush(stdout); ws_free_result(res); @@ -266,10 +303,12 @@ void shellRunSingleCommandWebsocketImp(char *command) { double total_time = (et - st)/1E3; double net_time = total_time - (double)execute_time; printf("Query Ok, %d of %d row(s) in database\n", numOfRows, numOfRows); - printf("Execute: %.2f ms Network: %.2f ms Total: %.2f ms\n", execute_time, net_time, total_time); + printf("Execute: %.2f ms Network: %.2f ms Total: %.2f ms\n", + execute_time, net_time, total_time); } else { int error_no = 0; - numOfRows = shellDumpWebsocket(res, fname, &error_no, printMode, &execute_time); + numOfRows = shellDumpWebsocket(res, fname, &error_no, + printMode, &execute_time); if (numOfRows < 0) { ws_free_result(res); return; @@ -279,11 +318,13 @@ void shellRunSingleCommandWebsocketImp(char *command) { double net_time = total_time - execute_time; if (error_no == 0 && !shell.stop_query) { printf("Query OK, %d row(s) in set\n", numOfRows); - printf("Execute: %.2f ms Network: %.2f ms Total: %.2f ms\n", execute_time, net_time, total_time); + printf("Execute: %.2f ms Network: %.2f ms Total: %.2f ms\n", + execute_time, net_time, total_time); } else { printf("Query interrupted, %d row(s) in set (%.6fs)\n", numOfRows, (et - st)/1E6); - printf("Execute: %.2f ms Network: %.2f ms Total: %.2f ms\n", execute_time, net_time, total_time); + printf("Execute: %.2f ms Network: %.2f ms Total: %.2f ms\n", + execute_time, net_time, total_time); } } printf("\n"); diff --git a/utils/test/c/CMakeLists.txt b/utils/test/c/CMakeLists.txt index 6ca266c55533b644c47ad61eb3bebc273ae7be7f..eda9c70f159b9c440d530a8036ef01eeb409930c 100644 --- a/utils/test/c/CMakeLists.txt +++ b/utils/test/c/CMakeLists.txt @@ -3,6 +3,7 @@ add_dependencies(tmq_demo taos) add_executable(tmq_sim tmqSim.c) add_executable(create_table createTable.c) add_executable(tmq_taosx_ci tmq_taosx_ci.c) +add_executable(write_raw_block_test write_raw_block_test.c) add_executable(sml_test sml_test.c) add_executable(get_db_name_test get_db_name_test.c) target_link_libraries( @@ -34,6 +35,14 @@ target_link_libraries( PUBLIC os ) +target_link_libraries( + write_raw_block_test + PUBLIC taos_static + PUBLIC util + PUBLIC common + PUBLIC os +) + target_link_libraries( sml_test PUBLIC taos_static diff --git a/utils/test/c/sml_test.c b/utils/test/c/sml_test.c index 73c445417888ba690ebdb9a2886f9f961bb27efd..b0cc6f749cb703c601235a3aaf444ce169149057 100644 --- a/utils/test/c/sml_test.c +++ b/utils/test/c/sml_test.c @@ -245,8 +245,7 @@ int smlProcess_json3_Test() { taos_free_result(pRes); const char *sql[] = { - "[{\"metric\":\"sys.cpu.nice3\",\"timestamp\":0,\"value\":\"18\",\"tags\":{\"host\":\"web01\",\"id\":\"t1\",\"dc\":\"lga\"}}]" - }; + "[{\"metric\":\"sys.cpu.nice3\",\"timestamp\":0,\"value\":\"18\",\"tags\":{\"host\":\"web01\",\"id\":\"t1\",\"dc\":\"lga\"}}]"}; char *sql1[1] = {0}; for (int i = 0; i < 1; i++) { sql1[i] = taosMemoryCalloc(1, 1024); @@ -851,7 +850,7 @@ int smlProcess_18784_Test() { taos_free_result(pRes); const char *sql[] = { - "disk,device=sdc inodes_used=176059i,total=1081101176832i 1661943960000000000", + "disk,device=sdc inodes_used=176059i,total=1076048383523889174i 1661943960000000000", "disk,device=sdc inodes_free=66932805i 1661943960000000000", }; pRes = taos_schemaless_insert(taos, (char **)sql, sizeof(sql) / sizeof(sql[0]), TSDB_SML_LINE_PROTOCOL, 0); @@ -876,7 +875,7 @@ int smlProcess_18784_Test() { if (rowIndex == 0) { ASSERT(ts == 1661943960000); ASSERT(used == 176059); - ASSERT(total == 1081101176832); + ASSERT(total == 1076048383523889174); ASSERT(freed == 66932805); // ASSERT_EQ(latitude, 24.5208); // ASSERT_EQ(longitude, 28.09377); @@ -940,6 +939,9 @@ int sml_ts2164_Test() { // "meters,location=la,groupid=ca current=11.8,voltage=221,phase=0.27", "meters,location=la,groupid=ca current=11.8,voltage=221", "meters,location=la,groupid=ca current=11.8,voltage=221,phase=0.27", + "ts3038,location=l2a,groupid=ca current=L\"11.8\"", + "ts3038,location=l2a,groupid=ca voltage=L\"221\"", + "ts3038,location=l2a,groupid=ca phase=L\"221\"", // "meters,location=la,groupid=cb current=11.8,voltage=221,phase=0.27", }; diff --git a/utils/test/c/tmqDemo.c b/utils/test/c/tmqDemo.c index d105b505793eae17068af9e9db02eff5071f5bd4..ce069c2b05878cb6806f2784be896942cb701ae4 100644 --- a/utils/test/c/tmqDemo.c +++ b/utils/test/c/tmqDemo.c @@ -597,7 +597,7 @@ void printParaIntoFile() { time_t tTime = taosGetTimestampSec(); struct tm tm; - taosLocalTime(&tTime, &tm); + taosLocalTime(&tTime, &tm, NULL); taosFprintfFile(pFile, "###################################################################\n"); taosFprintfFile(pFile, "# configDir: %s\n", configDir); diff --git a/utils/test/c/tmqSim.c b/utils/test/c/tmqSim.c index 026067e7f8daca2ec479fcdc729a3f4b0cd4362b..f2de219f4e740b090a87ebbb7e9ceb9cb1c6dcc2 100644 --- a/utils/test/c/tmqSim.c +++ b/utils/test/c/tmqSim.c @@ -166,7 +166,7 @@ static void printHelp() { char* getCurrentTimeString(char* timeString) { time_t tTime = taosGetTimestampSec(); struct tm tm; - taosLocalTime(&tTime, &tm); + taosLocalTime(&tTime, &tm, NULL); sprintf(timeString, "%d-%02d-%02d %02d:%02d:%02d", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); @@ -386,7 +386,7 @@ void addRowsToVgroupId(SThreadInfo* pInfo, int32_t vgroupId, int32_t rows) { pInfo->rowsOfPerVgroups[pInfo->numOfVgroups][1] += rows; pInfo->numOfVgroups++; - taosFprintfFile(g_fp, "consume id %d, add one new vogroup id: %d\n", pInfo->consumerId, vgroupId); + taosFprintfFile(g_fp, "consume id %d, add new vgroupId:%d\n", pInfo->consumerId, vgroupId); if (pInfo->numOfVgroups > MAX_VGROUP_CNT) { taosFprintfFile(g_fp, "====consume id %d, vgroup num %d over than 32. new vgroupId: %d\n", pInfo->consumerId, pInfo->numOfVgroups, vgroupId); @@ -472,7 +472,9 @@ static char* shellFormatTimestamp(char* buf, int64_t val, int32_t precision) { } struct tm ptm; - taosLocalTime(&tt, &ptm); + if (taosLocalTime(&tt, &ptm, buf) == NULL) { + return buf; + } size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", &ptm); if (precision == TSDB_TIME_PRECISION_NANO) { @@ -578,18 +580,25 @@ static int32_t data_msg_process(TAOS_RES* msg, SThreadInfo* pInfo, int32_t msgIn char buf[1024]; int32_t totalRows = 0; - // printf("topic: %s\n", tmq_get_topic_name(msg)); int32_t vgroupId = tmq_get_vgroup_id(msg); const char* dbName = tmq_get_db_name(msg); taosFprintfFile(g_fp, "consumerId: %d, msg index:%d\n", pInfo->consumerId, msgIndex); - taosFprintfFile(g_fp, "dbName: %s, topic: %s, vgroupId: %d\n", dbName != NULL ? dbName : "invalid table", - tmq_get_topic_name(msg), vgroupId); + int32_t index = 0; + for (index = 0; index < pInfo->numOfVgroups; index++) { + if (vgroupId == pInfo->rowsOfPerVgroups[index][0]) { + break; + } + } + + taosFprintfFile(g_fp, "dbName: %s, topic: %s, vgroupId:%d, currentRows:%d\n", dbName != NULL ? dbName : "invalid table", + tmq_get_topic_name(msg), vgroupId, pInfo->rowsOfPerVgroups[index][1]); while (1) { TAOS_ROW row = taos_fetch_row(msg); - - if (row == NULL) break; + if (row == NULL) { + break; + } TAOS_FIELD* fields = taos_fetch_fields(msg); int32_t numOfFields = taos_field_count(msg); @@ -607,7 +616,6 @@ static int32_t data_msg_process(TAOS_RES* msg, SThreadInfo* pInfo, int32_t msgIn #endif dumpToFileForCheck(pInfo->pConsumeRowsFile, row, fields, length, numOfFields, precision); - taos_print_row(buf, row, fields, numOfFields); if (0 != g_stConfInfo.showRowFlag) { @@ -621,7 +629,6 @@ static int32_t data_msg_process(TAOS_RES* msg, SThreadInfo* pInfo, int32_t msgIn } addRowsToVgroupId(pInfo, vgroupId, totalRows); - return totalRows; } @@ -683,16 +690,17 @@ int32_t notifyMainScript(SThreadInfo* pInfo, int32_t cmdId) { } static int32_t g_once_commit_flag = 0; -static void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) { - taosFprintfFile(g_fp, "tmq_commit_cb_print() commit %d\n", code); - if (0 == g_once_commit_flag) { - g_once_commit_flag = 1; - notifyMainScript((SThreadInfo*)param, (int32_t)NOTIFY_CMD_START_COMMIT); +static void tmq_commit_cb_print(tmq_t* tmq, int32_t code, void* param) { + taosFprintfFile(g_fp, "tmq_commit_cb_print() commit %d\n", code); + + if (0 == g_once_commit_flag) { + g_once_commit_flag = 1; + notifyMainScript((SThreadInfo*)param, (int32_t)NOTIFY_CMD_START_COMMIT); } - char tmpString[128]; - taosFprintfFile(g_fp, "%s tmq_commit_cb_print() be called\n", getCurrentTimeString(tmpString)); + char tmpString[128]; + taosFprintfFile(g_fp, "%s tmq_commit_cb_print() be called\n", getCurrentTimeString(tmpString)); } void build_consumer(SThreadInfo* pInfo) { @@ -730,9 +738,7 @@ void build_consumer(SThreadInfo* pInfo) { } pInfo->tmq = tmq_consumer_new(conf, NULL, 0); - tmq_conf_destroy(conf); - return; } @@ -817,7 +823,6 @@ void loop_consume(SThreadInfo* pInfo) { } taos_free_result(tmqMsg); - totalMsgs++; int64_t currentPrintTime = taosGetTimestampMs(); diff --git a/utils/test/c/tmq_taosx_ci.c b/utils/test/c/tmq_taosx_ci.c index 1f25eae366a31b585ca420cc5f289d1cc22c0ecd..c4becdd38196727b0ac3417c028fb4f9d698ae80 100644 --- a/utils/test/c/tmq_taosx_ci.c +++ b/utils/test/c/tmq_taosx_ci.c @@ -441,7 +441,7 @@ int32_t init_env() { taos_free_result(pRes); char sql[128] = {0}; - snprintf(sql, 128, "create database if not exists db_taosx vgroups %d", g_conf.dstVgroups); + snprintf(sql, 128, "create database if not exists db_taosx vgroups %d wal_retention_period 3600", g_conf.dstVgroups); pRes = taos_query(pConn, sql); if (taos_errno(pRes) != 0) { printf("error in create db_taosx, reason:%s\n", taos_errstr(pRes)); @@ -470,7 +470,7 @@ int32_t init_env() { } taos_free_result(pRes); - snprintf(sql, 128, "create database if not exists abc1 vgroups %d", g_conf.srcVgroups); + snprintf(sql, 128, "create database if not exists abc1 vgroups %d wal_retention_period 3600", g_conf.srcVgroups); pRes = taos_query(pConn, sql); if (taos_errno(pRes) != 0) { printf("error in create db, reason:%s\n", taos_errstr(pRes)); @@ -542,7 +542,6 @@ tmq_t* build_consumer() { tmq_conf_set(conf, "td.connect.pass", "taosdata"); tmq_conf_set(conf, "msg.with.table.name", "true"); tmq_conf_set(conf, "enable.auto.commit", "true"); - tmq_conf_set(conf, "enable.heartbeat.background", "true"); if (g_conf.snapShot) { tmq_conf_set(conf, "experimental.snapshot.enable", "true"); diff --git a/utils/test/c/write_raw_block_test.c b/utils/test/c/write_raw_block_test.c new file mode 100644 index 0000000000000000000000000000000000000000..8e5dd6275217b194fa4154fdd1235fdb27e397f1 --- /dev/null +++ b/utils/test/c/write_raw_block_test.c @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include "taos.h" +#include "types.h" + +int buildStable(TAOS* pConn, TAOS_RES* pRes) { + pRes = taos_query(pConn, + "CREATE STABLE `meters` (`ts` TIMESTAMP, `current` INT, `voltage` INT, `phase` FLOAT) TAGS " + "(`groupid` INT, `location` VARCHAR(16))"); + if (taos_errno(pRes) != 0) { + printf("failed to create super table meters, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table d0 using meters tags(1, 'San Francisco')"); + if (taos_errno(pRes) != 0) { + printf("failed to create child table d0, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "insert into d0 (ts, current) values (now, 120)"); + if (taos_errno(pRes) != 0) { + printf("failed to insert into table d0, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table d1 using meters tags(2, 'San Francisco')"); + if (taos_errno(pRes) != 0) { + printf("failed to create child table d1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create table d2 using meters tags(3, 'San Francisco')"); + if (taos_errno(pRes) != 0) { + printf("failed to create child table d1, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + return 0; +} + +int32_t init_env() { + TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); + if (pConn == NULL) { + return -1; + } + + TAOS_RES* pRes = taos_query(pConn, "drop database if exists db_raw"); + if (taos_errno(pRes) != 0) { + printf("error in drop db_taosx, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "create database if not exists db_raw vgroups 2"); + if (taos_errno(pRes) != 0) { + printf("error in create db_taosx, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + pRes = taos_query(pConn, "use db_raw"); + if (taos_errno(pRes) != 0) { + printf("error in create db_taosx, reason:%s\n", taos_errstr(pRes)); + return -1; + } + taos_free_result(pRes); + + buildStable(pConn, pRes); + + pRes = taos_query(pConn, "select * from d0"); + if (taos_errno(pRes) != 0) { + printf("error in drop db_taosx, reason:%s\n", taos_errstr(pRes)); + return -1; + } + void *data = NULL; + int32_t numOfRows = 0; + int error_code = taos_fetch_raw_block(pRes, &numOfRows, &data); + ASSERT(error_code == 0); + ASSERT(numOfRows == 1); + + taos_write_raw_block(pConn, numOfRows, data, "d1"); + taos_free_result(pRes); + + pRes = taos_query(pConn, "select ts,phase from d0"); + if (taos_errno(pRes) != 0) { + printf("error in drop db_taosx, reason:%s\n", taos_errstr(pRes)); + return -1; + } + error_code = taos_fetch_raw_block(pRes, &numOfRows, &data); + ASSERT(error_code == 0); + ASSERT(numOfRows == 1); + + int numFields = taos_num_fields(pRes); + TAOS_FIELD *fields = taos_fetch_fields(pRes); + taos_write_raw_block_with_fields(pConn, numOfRows, data, "d2", fields, numFields); + taos_free_result(pRes); + + taos_close(pConn); + return 0; +} + +int main(int argc, char* argv[]) { + if (init_env() < 0) { + return -1; + } +} diff --git a/utils/tsim/src/simExe.c b/utils/tsim/src/simExe.c index 9dd63d14a28a7f65593703773b1eb1c19d02f5d7..1be28635ef721167d67a33e7837f782c70e17d49 100644 --- a/utils/tsim/src/simExe.c +++ b/utils/tsim/src/simExe.c @@ -772,7 +772,9 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) { tt = (*(int64_t *)row[i]) / 1000000000; } - taosLocalTime(&tt, &tp); + if (taosLocalTime(&tt, &tp, timeStr) == NULL) { + break; + } strftime(timeStr, 64, "%y-%m-%d %H:%M:%S", &tp); if (precision == TSDB_TIME_PRECISION_MILLI) { sprintf(value, "%s.%03d", timeStr, (int32_t)(*((int64_t *)row[i]) % 1000));